tweb/public/297.1bdbe4d3952a46b0e184.ch...

2 lines
1.4 MiB
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

(this.webpackChunktweb=this.webpackChunktweb||[]).push([[297],{5814:(e,t,i)=>{"use strict";i.d(t,{Z:()=>m});var s=i(5400),n=i(3512),a=i(4762),o=i(410),r=i(8487),d=i(3772),l=i(1655),c=i(7625),h=i(2586),u=i(3013),p=i(3035);const f=new class{constructor(){this.observer=new IntersectionObserver((e=>{for(const t of e){const e=t.target;for(const i in this.byGroups){if(this.intersectionLockedGroups[i])continue;const s=this.byGroups[i].find((t=>t.el===e));if(s){if(t.isIntersecting)this.visible.add(s),this.checkAnimation(s,!1);else{this.visible.delete(s),this.checkAnimation(s,!0);const e=s.animation;e instanceof d.Z&&e.clearCache()}break}}}})),this.visible=new Set,this.overrideIdleGroups=new Set,this.byGroups={},this.byPlayer=new Map,this.lockedGroups={},this.onlyOnePlayableGroup="",this.intersectionLockedGroups={},this.videosLocked=!1,u.Z.addEventListener("play",(({doc:e})=>{"round"===e.type&&(this.videosLocked=!0,this.checkAnimations2())})),u.Z.addEventListener("pause",(()=>{this.videosLocked&&(this.videosLocked=!1,this.checkAnimations2())})),h.Z.addEventListener("change",(e=>{this.checkAnimations2(e)}))}setOverrideIdleGroup(e,t){t?this.overrideIdleGroups.add(e):this.overrideIdleGroups.delete(e)}getAnimations(e){const t=[];for(const i in this.byGroups)for(const s of this.byGroups[i])s.el===e&&t.push(s);return t}removeAnimation(e){const{el:t,animation:i}=e;i instanceof HTMLVideoElement||i.remove(),i instanceof HTMLVideoElement&&a.IS_SAFARI&&setTimeout((()=>{i.src="",i.load()}),1e3);const s=this.byGroups[e.group];s&&((0,l.Z)(s,e),s.length||delete this.byGroups[e.group]),this.observer.unobserve(t),this.visible.delete(e),this.byPlayer.delete(i)}removeAnimationByPlayer(e){const t=this.byPlayer.get(e);t&&this.removeAnimation(t)}addAnimation(e){var t,i,a,o;let{animation:r,group:l="",observeElement:c,controlled:h,liteModeKey:u}=e;if("none"===l||this.byPlayer.has(r))return;c||(r instanceof d.Z?c=r.el[0]:r instanceof s.KZ?c=r.canvas:r instanceof s.LD?c=null!==(t=r.placeholder)&&void 0!==t?t:r:r instanceof HTMLElement&&(c=r));const p={el:c,animation:r,group:l,controlled:h,liteModeKey:u};h&&"boolean"!=typeof h&&h.onClean((()=>{this.removeAnimationByPlayer(r)})),r instanceof d.Z&&!n.Z.settings.stickers.loop&&r.loop&&(r.loop=n.Z.settings.stickers.loop),(null!==(i=(a=this.byGroups)[o=l])&&void 0!==i?i:a[o]=[]).push(p),this.observer.observe(p.el),this.byPlayer.set(r,p)}checkAnimations(e,t,i,s){if(void 0!==t&&!this.byGroups[t])return;const n=void 0!==t?[t]:Object.keys(this.byGroups);for(const t of n){if(s&&this.intersectionLockedGroups[t])continue;const n=this.byGroups[t];(0,c.Z)(n,(t=>{this.checkAnimation(t,e,i)}))}}checkAnimations2(e){this.checkAnimations(e,void 0,void 0,!0)}checkAnimation(e,t,i){const{el:s,animation:n,group:a}=e;i||!this.lockedGroups[a]&&!(0,r.Z)(s)?e.controlled&&!i||this.removeAnimation(e):t||this.onlyOnePlayableGroup&&this.onlyOnePlayableGroup!==a||n instanceof HTMLVideoElement&&this.videosLocked?n.paused||n.pause():!(n.paused&&this.visible.has(e)&&n.autoplay)||this.onlyOnePlayableGroup&&this.onlyOnePlayableGroup!==a||h.Z.isIdle&&!this.overrideIdleGroups.has(e.group)||n.play()}getOnlyOnePlayableGroup(){return this.onlyOnePlayableGroup}setOnlyOnePlayableGroup(e=""){this.onlyOnePlayableGroup=e}lockGroup(e){this.lockedGroups[e]=!0}unlockGroup(e){delete this.lockedGroups[e],this.checkAnimations(void 0,e)}refreshGroup(e){const t=this.byGroups[e];(null==t?void 0:t.length)&&(t.forEach((e=>{this.observer.unobserve(e.el)})),(0,p.T2)((()=>{t.forEach((e=>{this.observer.observe(e.el)}))})))}lockIntersectionGroup(e){this.intersectionLockedGroups[e]=!0}unlockIntersectionGroup(e){delete this.intersectionLockedGroups[e],this.refreshGroup(e)}toggleIntersectionGroup(e,t){t?this.lockIntersectionGroup(e):this.unlockIntersectionGroup(e)}setAutoplay(e,t){let i=!1;return this.byPlayer.forEach(((s,a)=>{s.liteModeKey===t&&(i=!0,a.autoplay=!!e&&!!+s.el.dataset.stickerPlay,a.loop=!!e&&!!+s.el.dataset.stickerLoop&&n.Z.settings.stickers.loop)})),i}setLoop(e){let t=!1;return this.byPlayer.forEach(((i,s)=>{+i.el.dataset.stickerLoop&&s.loop!==e&&(s instanceof d.Z||s instanceof HTMLVideoElement)&&(t=!0,s.loop=e,s.autoplay=!!+i.el.dataset.stickerPlay)})),t}};o.GO&&(o.GO.animationIntersector=f);const m=f},3013:(e,t,i)=>{"use strict";i.d(t,{Z:()=>L});var s=i(3512),n=i(3725),a=i(4762),o=i(410),r=i(6669),d=i(5432),l=i(2325),c=i(3719),h=i(8479),u=i(6848),p=i(3699),f=i(7530),m=i(493),g=i(2312),v=i(925),b=i(3241),y=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};const w=(()=>{try{return a.IS_SAFARI&&+navigator.userAgent.match(/ Version\/(\d+)/)[1]<14}catch(e){return!1}})();class S extends b.Z{constructor(){super(...arguments),this.media=new Map,this.scheduled=new Map,this.mediaDetails=new Map,this.waitingMediaForLoad=new Map,this.waitingScheduledMediaForLoad=new Map,this.waitingDocumentsForLoad={},this.playbackRates={voice:1,video:1,audio:1},this.seekBackward=(e,t=this.playingMedia)=>{t&&(t.currentTime=Math.max(0,t.currentTime-(e.seekOffset||10)))},this.seekForward=(e,t=this.playingMedia)=>{t&&(t.currentTime=Math.min(t.duration,t.currentTime+(e.seekOffset||10)))},this.seekTo=(e,t=this.playingMedia)=>{t&&(t.currentTime=e.seekTime)},this.onMediaDocumentLoad=e=>y(this,void 0,void 0,(function*(){const t=this.mediaDetails.get(e),i=yield this.managers.appDocsManager.getDoc(t.docId);"audio"===i.type&&i.supportsStreaming&&w&&this.handleSafariStreamable(e);const s=yield this.managers.thumbsStorage.getCacheContext(i);e.src=s.url,this.playingMedia===e&&(e.playbackRate=this.playbackRate,"audio"===i.type&&(e.loop=this.loop));const n=this.waitingDocumentsForLoad[i.id];n&&(n.delete(e),n.size||delete this.waitingDocumentsForLoad[i.id])})),this.onPlay=e=>{const t=e.target,i=this.mediaDetails.get(t),{peerId:s,mid:n}=i,a=this.pip;a&&a.pause();const o=this.getMessageByMedia(t);if(this.playingMedia!==t){this.stop(),this.setMedia(t,o);const e=e=>e.mid===n&&e.peerId===s,i=this.listLoader,a=i.getCurrent();if(!a||!e(a)){let t;for(const s of[!1,!0]){const n=i.getPrevious(s);let a=n.findIndex(e);if(-1!==a?t=-(n.length-a):(a=i.getNext(s).findIndex(e),-1!==a&&(t=a+1)),void 0!==t)break}t?this.go(t,!1):this.setTargets({peerId:s,mid:n})}}setTimeout((()=>{this.playingMedia===t&&(this.dispatchEvent("play",this.getPlayingDetails()),this.pauseMediaInOtherTabs())}),0)},this.onPause=e=>{this.dispatchEvent("pause")},this.onEnded=e=>{if(e&&!e.isTrusted)return;this.onPause(e);const t=this.listLoader;!this.lockedSwitchers&&(this.round||!t.current||t.next.length)&&t.getNext(!0).length&&this.next()||(this.stop(),this.dispatchEvent("stop"))},this.play=()=>this.toggle(!0),this.pause=()=>this.toggle(!1),this.stop=(e=this.playingMedia,t)=>{if(!e)return!1;if(e.paused||e.pause(),e.currentTime=0,(0,r.Z)(e,"ended"),e===this.playingMedia){const t=this.mediaDetails.get(e);if(null==t?void 0:t.clean){e.src="";const i=t.peerId,s=t.isScheduled?this.scheduled:this.media,n=s.get(i);n&&(n.delete(t.mid),n.size||s.delete(i)),e.remove(),this.mediaDetails.delete(e)}this.playingMedia=void 0,this.playingMediaType=void 0}return t&&this.dispatchEvent("stop"),!0},this.playItem=e=>{const{peerId:t,mid:i}=e,s=this.searchContext.isScheduled;this.getMedia(t,i,s).play(),setTimeout((()=>{this.resolveWaitingForLoadMedia(t,i,s)}),0)},this.go=(e,t)=>{const i=this.listLoader;if(!this.lockedSwitchers&&i)return"audio"===this.playingMediaType?i.goRound(e,t):i.go(e,t)},this.browserPlay=this.bindBrowserCallback((e=>this.toggle(!0,e))),this.browserPause=this.bindBrowserCallback((e=>this.toggle(!1,e))),this.browserStop=this.bindBrowserCallback((e=>this.stop(e))),this.browserSeekBackward=this.bindBrowserCallback(((e,t)=>this.seekBackward(t,e))),this.browserSeekForward=this.bindBrowserCallback(((e,t)=>this.seekForward(t,e))),this.browserSeekTo=this.bindBrowserCallback(((e,t)=>this.seekTo(t,e))),this.browserNext=this.bindBrowserCallback((e=>e||this.next())),this.browserPrevious=this.bindBrowserCallback((e=>e?this.seekToStart(e):this.previous())),this.next=()=>this.go(1),this.previous=()=>{if(!this.seekToStart(this.playingMedia))return this.go(-1)}}construct(e){if(this.managers=e,this.container=document.createElement("div"),this.container.style.cssText="display: none;",document.body.append(this.container),navigator.mediaSession){const e={play:this.browserPlay,pause:this.browserPause,stop:this.browserStop,seekbackward:this.browserSeekBackward,seekforward:this.browserSeekForward,seekto:this.browserSeekTo,previoustrack:this.browserPrevious,nexttrack:this.browserNext};for(const t in e)try{navigator.mediaSession.setActionHandler(t,e[t])}catch(e){console.warn("MediaSession action is not supported:",t)}}s.Z.addEventListener("document_downloaded",(e=>{const t=this.waitingDocumentsForLoad[e];if(t)for(const e of t)this.onMediaDocumentLoad(e)})),s.Z.addEventListener("media_play",(()=>{this.skipMediaPlayEvent?this.skipMediaPlayEvent=!1:!this.pause()&&this.pip&&this.pip.pause()}));const t={};["volume","muted","playbackRate","loop","round"].forEach((e=>{const i="_"+e;t[e]={get:()=>this[i],set:t=>{this[i]!==t&&(this[i]=t,!this.playingMedia||"loop"===e&&"audio"!==this.playingMediaType||"round"===e||(this.playingMedia[e]=t),"playbackRate"===e&&void 0!==this.playingMediaType&&(this.playbackRates[this.playingMediaType]=t),this.dispatchPlaybackParams())}}})),Object.defineProperties(this,t)}dispatchPlaybackParams(){this.dispatchEvent("playbackParams",this.getPlaybackParams())}getPlaybackParams(){const{volume:e,muted:t,playbackRate:i,playbackRates:s,loop:n,round:a}=this;return{volume:e,muted:t,playbackRate:i,playbackRates:s,loop:n,round:a}}setPlaybackParams(e){this.playbackRates=e.playbackRates,this._volume=e.volume,this._muted=e.muted,this._playbackRate=e.playbackRate,this._loop=e.loop,this._round=e.round}addMedia(e,t,i){const{peerId:a,mid:o}=e,r=e.pFlags.is_scheduled?this.scheduled:this.media;let d=r.get(e.peerId);d||r.set(e.peerId,d=new Map);let l=d.get(o);if(l)return l;const c=(0,f.Z)(e,!0);d.set(o,l=document.createElement("round"===c.type||"video"===c.type?"video":"audio")),"round"===c.type&&l.setAttribute("playsinline","true");const h={peerId:a,mid:o,docId:c.id,doc:c,message:e,clean:i,isScheduled:e.pFlags.is_scheduled};this.mediaDetails.set(l,h),l.volume=1,this.container.append(l),l.addEventListener("play",this.onPlay),l.addEventListener("pause",this.onPause),l.addEventListener("ended",this.onEnded),"audio"!==c.type&&(null==e?void 0:e.pFlags.media_unread)&&e.fromId!==s.Z.myId&&l.addEventListener("timeupdate",(()=>{this.managers.appMessagesManager.readMessages(a,[o])}),{once:!0});const u=(0,n.Z)();if(t)u.resolve();else{const t=e.pFlags.is_scheduled?this.waitingScheduledMediaForLoad:this.waitingMediaForLoad;let i=t.get(a);i||t.set(a,i=new Map),i.set(o,u)}return u.then((()=>y(this,void 0,void 0,(function*(){if(c.supportsStreaming||(yield this.managers.thumbsStorage.getCacheContext(c)).url)this.onMediaDocumentLoad(l);else{let e=this.waitingDocumentsForLoad[c.id];e||(e=this.waitingDocumentsForLoad[c.id]=new Set),e.add(l),g.Z.downloadMediaURL({media:c})}})))),l}getMedia(e,t,i){const s=(i?this.scheduled:this.media).get(e);return null==s?void 0:s.get(t)}handleSafariStreamable(e){e.addEventListener("play",(()=>{const t=e.currentTime;e.addEventListener("progress",(()=>{e.currentTime=e.duration-1,e.addEventListener("progress",(()=>{e.currentTime=t,e.paused||e.play()}),{once:!0})}),{once:!0})}))}resolveWaitingForLoadMedia(e,t,i){const s=i?this.waitingScheduledMediaForLoad:this.waitingMediaForLoad,n=s.get(e);if(!n)return;const a=n.get(t);a&&(a.resolve(),n.delete(t),n.size||s.delete(e))}isSafariBuffering(e){return!!e.safariBuffering}setSafariBuffering(e,t){e.safariBuffering=t}setNewMediadata(e,t=this.playingMedia){var i,s;return y(this,void 0,void 0,(function*(){if(document.pictureInPictureElement)return;yield(0,v.Z)(t,void 0,!1);const n=(0,f.Z)(e,!0),o=[],r="voice"===n.type||"round"===n.type;let c="",h="";if(null===(i=n.thumbs)||void 0===i?void 0:i.length){const i=n.thumbs[n.thumbs.length-1];if(!i.bytes){const s=yield this.managers.thumbsStorage.getCacheContext(n,i.type);s.url?o.push({src:s.url,sizes:`${i.w}x${i.h}`,type:"image/jpeg"}):g.Z.downloadMediaURL({media:n,thumb:i}).then((()=>{this.playingMedia===t&&s.url&&this.setNewMediadata(e)}))}}else if(r){const t=e.fromId||e.peerId;yield this.managers.appPeersManager.getPeerPhoto(t),c=yield(0,m.Z)({peerId:t,plainText:!0,onlyFirstName:!1}),h=l.ZP.format("voice"===n.type?"AttachAudio":"AttachRound",!0)}if(!r){const e=n.attributes.find((e=>"documentAttributeAudio"===e._));c=null!==(s=null==e?void 0:e.title)&&void 0!==s?s:n.file_name,h=null==e?void 0:e.performer}o.length||(a.IS_APPLE?d.Z?o.push({src:"assets/img/apple-touch-icon-precomposed.png",sizes:"180x180",type:"image/png"}):o.push({src:"assets/img/apple-touch-icon.png",sizes:"180x180",type:"image/png"}):[72,96,144,192,256,384,512].forEach((e=>{const t=`${e}x${e}`;o.push({src:`assets/img/android-chrome-${t}.png`,sizes:t,type:"image/png"})})));const u=new MediaMetadata({title:c,artist:h,artwork:o});navigator.mediaSession.metadata=u}))}setCurrentMediadata(){const{playingMedia:e}=this;if(!e)return;const t=this.getMessageByMedia(e);this.setNewMediadata(t,e)}getMessageByMedia(e){return this.mediaDetails.get(e).message}getPlayingDetails(){const{playingMedia:e}=this;if(!e)return;const t=this.getMessageByMedia(e);return{doc:(0,f.Z)(t,!0),message:t,media:e,playbackParams:this.getPlaybackParams()}}pauseMediaInOtherTabs(){this.skipMediaPlayEvent=!0,s.Z.dispatchEvent("media_play")}toggle(e,t=this.playingMedia){return!!t&&(void 0===e&&(e=t.paused),t.paused===e&&(e?t.play():t.pause(),!0))}bindBrowserCallback(e){return t=>{e(this.pip,t)}}seekToStart(e){return(null==e?void 0:e.currentTime)>5&&(e.currentTime=0,this.toggle(!0,e),!0)}willBePlayed(e){this.willBePlayedMedia=e}setSearchContext(e){return!(0,u.Z)(this.searchContext,e)&&(this.searchContext=(0,h.Z)(e),!0)}getSearchContext(){return this.searchContext}setTargets(e,t,i){let s=this.listLoader;s?s.reset():s=this.listLoader=new c.Z({loadCount:10,loadWhenLeft:5,processItem:e=>(this.addMedia(e,!1),{peerId:e.peerId,mid:e.mid}),onJump:(e,t)=>{this.playItem(e)},onEmptied:()=>{this.dispatchEvent("stop"),this.stop()}});const n=void 0===this.searchContext.folderId;t?s.setTargets(t,i,n):s.reverse=n,s.setSearchContext(this.searchContext),s.current=e,s.load(!0),s.load(!1)}getPlaybackMediaTypeFromMessage(e){const t=(0,f.Z)(e,!0);let i="audio";return(null==t?void 0:t.type)&&("voice"===t.type||"round"===t.type?i="voice":"video"===t.type&&(i="video")),i}setMedia(e,t){const i=this.getPlaybackMediaTypeFromMessage(t);this._playbackRate=this.playbackRates[i],this.playingMedia=e,this.playingMediaType=i,this.playingMedia.volume=this.volume,this.playingMedia.muted=this.muted,this.playingMedia.playbackRate=this.playbackRate,"audio"===i&&(this.playingMedia.loop=this.loop),"mediaSession"in navigator&&this.setNewMediadata(t)}setSingleMedia(e,t){const i=this.playingMedia,s=this.pause();let n;return e?(n=()=>{const e=this.pip;e&&e.pause(),this.pauseMediaInOtherTabs()},e.paused||n(),e.addEventListener("play",n)):this.pauseMediaInOtherTabs(),this.willBePlayed(void 0),e?this.setMedia(e,t):this.playingMedia=void 0,this.toggleSwitchers(!1),(t=s)=>{this.toggleSwitchers(!0),i&&(this.mediaDetails.get(i)?this.setMedia(i,this.getMessageByMedia(i)):this.next()||this.previous()),this.playingMedia===e&&(this.playingMedia=void 0,this.playingMediaType=void 0),e&&e.removeEventListener("play",n),t&&this.play()}}toggleSwitchers(e){this.lockedSwitchers=!e}setPictureInPicture(e){this.pip=e;const t=new p.Z;t.add(e)("leavepictureinpicture",(()=>{this.pip===e&&(this.pip=void 0,t.removeAll())}),{once:!0}),t.add(e)("play",(t=>{this.playingMedia!==e&&this.pause(),this.pauseMediaInOtherTabs()}))}}const C=new S;o.GO.appMediaPlaybackController=C;const L=C},1784:(e,t,i)=>{"use strict";i.d(t,{Z:()=>E});var s=i(2341),n=i(3910),a=i(2738),o=i(8497),r=i(4668),d=i(130),l=i(4755),c=i(3719),h=i(2312),u=i(7030),p=i(3709),f=i(7530),m=i(5400),g=i(8544),v=i(5128),b=i(4524),y=i(8805),w=i(4332),S=i(1669),C=i(1168),L=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class E extends g.Z{get searchContext(){return this.listLoader.searchContext}constructor(){let e;super(new c.Z({processItem:e=>{const t="inputMessagesFilterDocument"===this.searchContext.inputFilter._,{mid:i,peerId:s}=e,n=(0,f.Z)(e,!0);if(n&&(!t||E.isMediaCompatibleForDocumentViewer(n)))return{element:null,mid:i,peerId:s}}}),["delete","forward"]),this.onPrevClick=e=>L(this,void 0,void 0,(function*(){this.openMedia({message:yield this.getMessageByPeer(e.peerId,e.mid),target:e.element,fromRight:-1})})),this.onNextClick=e=>L(this,void 0,void 0,(function*(){this.openMedia({message:yield this.getMessageByPeer(e.peerId,e.mid),target:e.element,fromRight:1})})),this.onDeleteClick=()=>{const e=this.target;C.Z.createPopup(v.Z,e.peerId,[e.mid],"chat",(()=>{this.target={element:this.content.media},this.close()}))},this.onForwardClick=()=>{const e=this.target;e.mid&&C.Z.createPopup(b.Z,{[e.peerId]:[e.mid]},(()=>this.close()))},this.onAuthorClick=e=>L(this,void 0,void 0,(function*(){const{mid:t,peerId:i}=this.target;if(t&&t!==Number.MAX_SAFE_INTEGER){const s=this.searchContext.threadId,n=yield this.getMessageByPeer(i,t);this.close(e).then((()=>L(this,void 0,void 0,(function*(){if(l.Z.isMobile){const e=w.ZP.getTab(S.Z);e&&e.close()}u.ZP.setInnerPeer({peerId:n.peerId,lastMsgId:t,type:s?"discussion":void 0,threadId:s})}))))}})),this.onDownloadClick=()=>{const{message:e}=this.target,t=(0,f.Z)(e,!0);t&&h.Z.downloadToDisc({media:t,queueId:u.ZP.chat.bubbles.lazyLoadQueue.queueId})},this.listLoader.onEmptied=()=>{this.close()},this.content.caption=document.createElement("div"),this.content.caption.classList.add(g.x+"-caption","spoilers-container");const t=()=>{e&&clearTimeout(e),e=window.setTimeout((()=>{e=void 0,this.content.caption.classList.remove("is-focused")}),800)};this.content.caption.addEventListener("touchstart",(()=>{l.Z.isMobile&&(this.content.caption.classList.add("is-focused"),e&&(clearTimeout(e),e=void 0),document.addEventListener("touchend",t,{once:!0}))})),new y.ZP(this.content.caption).onAdditionalScroll=t,this.wholeDiv.append(this.content.caption),(0,a.fc)(this.buttons.delete,this.onDeleteClick);const i=[this.btnMenuForward={icon:"forward",text:"Forward",onClick:this.onForwardClick},this.btnMenuDownload={icon:"download",text:"MediaViewer.Context.Download",onClick:this.onDownloadClick},this.btnMenuDelete={icon:"delete danger",text:"Delete",onClick:this.onDeleteClick}];this.setBtnMenuToggle(i),this.setListeners()}setListeners(){super.setListeners(),(0,a.fc)(this.buttons.forward,this.onForwardClick),(0,a.fc)(this.author.container,this.onAuthorClick);const e=t=>{const i=(0,r.Z)(t.target,"A");if(i.classList.contains("timestamp"))return;const s=(0,o.Z)(t.target,"spoiler");if(i instanceof HTMLAnchorElement&&(!s||this.content.caption.classList.contains("is-spoiler-visible"))){const s=i.getAttribute("onclick");if(!s||s.includes("showMaskedAlert"))return;return(0,n.Z)(t),this.close().then((()=>{this.content.caption.removeEventListener("click",e,{capture:!0}),i.click()})),!1}};this.content.caption.addEventListener("click",e,{capture:!0})}getMessageByPeer(e,t){return this.searchContext.isScheduled?this.managers.appMessagesManager.getScheduledMessageByPeer(e,t):this.managers.appMessagesManager.getMessageByPeer(e,t)}setCaption(e){const t=e.message;let i;if(t){const s=(0,f.Z)(e,!0);i=(0,m.ZP)(t,{entities:e.totalEntities,maxMediaTimestamp:"video"===(null==s?void 0:s.type)&&s.duration||void 0})}(0,d.Z)(this.content.caption.firstElementChild,i),this.content.caption.classList.toggle("hide",!t)}setSearchContext(e){return this.listLoader.setSearchContext(e),this}openMedia({message:e,target:t,fromRight:i=0,reverse:s=!1,prevTargets:n=[],nextTargets:a=[],mediaTimestamp:o}){const r=Object.create(null,{_openMedia:{get:()=>super._openMedia}});return L(this,void 0,void 0,(function*(){if(this.setMoverPromise)return this.setMoverPromise;const d=e.mid,l=e.fwd_from&&!e.fromId?e.fwd_from.from_name:e.fromId,c=(0,f.Z)(e,!0),h=yield this.managers.appPeersManager.noForwards(e.peerId),u="messageService"===e._,m=u||!(yield this.managers.appMessagesManager.canForward(e)),g=(u?h:m)||!(0,p.Z)(e);[[[this.buttons.forward,this.btnMenuForward],m],[[this.buttons.download,this.btnMenuDownload],g],[[this.buttons.delete,this.btnMenuDelete],!(yield this.managers.appMessagesManager.canDeleteMessage(e))]].forEach((([e,t])=>{e.forEach((e=>{e instanceof HTMLElement?e.classList.toggle("hide",t):e.verify=()=>!t}))})),this.wholeDiv.classList.toggle("no-forwards",g),this.setCaption(e);const v=r._openMedia.call(this,{media:c,timestamp:e.date,fromId:l,fromRight:i,target:t,reverse:s,prevTargets:n,nextTargets:a,message:e,mediaTimestamp:o});return this.target.mid=d,this.target.peerId=e.peerId,this.target.message=e,v}))}static isMediaCompatibleForDocumentViewer(e){return"photo"===e._||s.Z.has(e.mime_type)}}},8544:(e,t,i)=>{"use strict";i.d(t,{x:()=>te,Z:()=>ie});var s=i(3725),n=i(4755),a=i(5432),o=i(4762),r=i(5003),d=i(3013),l=i(3910),c=i(3699),h=i(3003),u=i(5322),p=i(7529),f=i(6733),m=i(5157),g=i(7207),v=i(8427),b=i(5701),y=i(3815),w=i(925),S=i(2738);class C extends p.Z{constructor({video:e,play:t=!1,streamable:i=!1,duration:s,onPlaybackRackMenuToggle:n,onPip:a,onPipClose:o}){if(super(),this.video=e,this.wrapper=document.createElement("div"),this.wrapper.classList.add("ckin__player"),this.onPlaybackRackMenuToggle=n,this.onPip=a,this.onPipClose=o,this.listenerSetter=new c.Z,this.setup({element:this.wrapper,listenerSetter:this.listenerSetter,canHideControls:()=>!(this.video.paused||this.playbackRateButton&&this.playbackRateButton.classList.contains("menu-open")),showOnLeaveToClassName:"media-viewer-caption",ignoreClickClassName:"ckin__controls"}),e.parentNode.insertBefore(this.wrapper,e),this.wrapper.appendChild(e),this.skin="default",this.stylePlayer(s),this.setBtnMenuToggle(),"default"===this.skin){const t=this.wrapper.querySelector(".default__controls.ckin__controls");this.progress=new g.Z({onSeekStart:()=>{this.wrapper.classList.add("is-seeking")},onSeekEnd:()=>{this.wrapper.classList.remove("is-seeking")}}),this.progress.setMedia({media:e,streamable:i,duration:s}),t.prepend(this.progress.container)}t&&e.play().catch((t=>{"NotAllowedError"===t.name&&(e.muted=!0,e.autoplay=!0,e.play())})).finally((()=>{this.wrapper.classList.toggle("is-playing",!this.video.paused)}))}stylePlayer(e){const{wrapper:t,video:i,skin:s,listenerSetter:n}=this;t.classList.add(s);const o=this.buildControls();let r;if(t.insertAdjacentHTML("beforeend",o),"default"===s){this.playbackRateButton=this.wrapper.querySelector(".playback-rate"),this.pipButton=this.wrapper.querySelector(".pip");const e=t.querySelectorAll(".toggle"),s=t.querySelector(".fullscreen"),o=t.querySelector("#time-elapsed");r=t.querySelector("#time-duration"),r.textContent=(0,m.Z)(0|i.duration);const c=new v.Z(n),h=t.querySelector(".left-controls");if(c.btn.classList.remove("btn-icon"),h.insertBefore(c.btn,o.parentElement),Array.from(e).forEach((e=>{(0,S.fc)(e,(()=>{this.togglePlay()}),{listenerSetter:this.listenerSetter})})),this.pipButton){(0,S.fc)(this.pipButton,(()=>{this.video.requestPictureInPicture()}),{listenerSetter:this.listenerSetter});const e=e=>{this.wrapper.style.visibility=e?"hidden":"",this.onPip&&this.onPip(e)},t=20,s=(0,b.Z)(e,t,!1,!0);n.add(i)("enterpictureinpicture",(()=>{s(!0),n.add(i)("leavepictureinpicture",(()=>{const e=n.add(i)("pause",(()=>{clearTimeout(s),this.onPipClose&&this.onPipClose()}),{once:!0}),s=setTimeout((()=>{n.remove(e)}),t)}),{once:!0})})),n.add(i)("leavepictureinpicture",(()=>{s(!1)}))}a.Z||((0,S.fc)(i,(()=>{this.togglePlay()}),{listenerSetter:this.listenerSetter}),n.add(document)("keydown",(e=>{if(y.Z.overlaysActive>1||document.pictureInPictureElement===i)return;const{key:s,code:n}=e;let a=!0;if("KeyF"===n)this.toggleFullScreen();else if("KeyM"===n)d.Z.muted=!d.Z.muted;else if("Space"===n)this.togglePlay();else if(!e.altKey||"Equal"!==n&&"Minus"!==n)!t.classList.contains("ckin__fullscreen")||"ArrowLeft"!==s&&"ArrowRight"!==s?a=!1:"ArrowLeft"===s?d.Z.seekBackward({action:"seekbackward"}):d.Z.seekForward({action:"seekforward"});else{const e="Equal"===n?1:-1,t=d.Z.playbackRate,i=C.PLAYBACK_RATES.indexOf(t)+e;i>=0&&i<C.PLAYBACK_RATES.length&&(d.Z.playbackRate=C.PLAYBACK_RATES[i])}return a?((0,l.Z)(e),!1):void 0}))),n.add(i)("dblclick",(()=>{a.Z||this.toggleFullScreen()})),(0,S.fc)(s,(()=>{this.toggleFullScreen()}),{listenerSetter:this.listenerSetter}),(0,f.Ms)(t,this.onFullScreen.bind(this,s),n),n.add(i)("timeupdate",(()=>{o.textContent=(0,m.Z)(0|i.currentTime)})),n.add(i)("play",(()=>{t.classList.add("played"),a.Z||n.add(i)("play",(()=>{this.hideControls(!0)}))}),{once:!0}),n.add(i)("pause",(()=>{this.showControls(!1)})),n.add(d.Z)("playbackParams",(()=>{this.setPlaybackRateIcon()}))}n.add(i)("play",(()=>{t.classList.add("is-playing")})),n.add(i)("pause",(()=>{t.classList.remove("is-playing")})),i.duration||e?r.textContent=(0,m.Z)(Math.round(i.duration||e)):(0,w.Z)(i).then((()=>{r.textContent=(0,m.Z)(Math.round(i.duration))}))}togglePlay(e=this.video.paused){this.video[e?"play":"pause"]()}buildControls(){const e=this.skin;if("default"===e)return`\n <button class="${e}__button--big toggle tgico" title="Toggle Play"></button>\n <div class="${e}__gradient-bottom ckin__controls"></div>\n <div class="${e}__controls ckin__controls">\n <div class="bottom-controls">\n <div class="left-controls">\n <button class="btn-icon ${e}__button toggle tgico" title="Toggle Video"></button>\n <div class="time">\n <time id="time-elapsed">0:00</time>\n <span> / </span>\n <time id="time-duration">0:00</time>\n </div>\n </div>\n <div class="right-controls">\n <button class="btn-icon ${e}__button btn-menu-toggle playback-rate night" title="Playback Rate"></button>\n ${!o.IS_MOBILE&&document.pictureInPictureEnabled?`<button class="btn-icon ${e}__button pip tgico-pip" title="Picture-in-Picture"></button>`:""}\n <button class="btn-icon ${e}__button fullscreen tgico-fullscreen" title="Full Screen"></button>\n </div>\n </div>\n </div>`}setBtnMenuToggle(){const e=C.PLAYBACK_RATES.map(((e,t)=>({regularText:e+"x",onClick:()=>{d.Z.playbackRate=e}}))),t=(0,h.b)({buttons:e});t.classList.add("top-left"),(0,u.v)({el:this.playbackRateButton,onOpen:this.onPlaybackRackMenuToggle?()=>{this.onPlaybackRackMenuToggle(!0)}:void 0,onClose:this.onPlaybackRackMenuToggle?()=>{this.onPlaybackRackMenuToggle(!1)}:void 0}),this.playbackRateButton.append(t),this.setPlaybackRateIcon()}setPlaybackRateIcon(){const e=this.playbackRateButton;C.PLAYBACK_RATES_ICONS.forEach((t=>{t="tgico-"+t,e.classList.remove(t)}));let t=C.PLAYBACK_RATES.indexOf(d.Z.playbackRate);-1===t&&(t=C.PLAYBACK_RATES.indexOf(1)),e.classList.add("tgico-"+C.PLAYBACK_RATES_ICONS[t])}toggleFullScreen(){const e=this.wrapper;if(o.IS_APPLE_MOBILE){const e=this.video;return e.webkitEnterFullscreen(),void e.enterFullscreen()}(0,f.rB)()?(0,f.C8)():(0,f.Dj)(e)}onFullScreen(e){const t=(0,f.rB)();this.wrapper.classList.toggle("ckin__fullscreen",t),t?(e.classList.remove("tgico-fullscreen"),e.classList.add("tgico-smallscreen"),e.setAttribute("title","Exit Full Screen")):(e.classList.remove("tgico-smallscreen"),e.classList.add("tgico-fullscreen"),e.setAttribute("title","Full Screen"))}setTimestamp(e){this.video.currentTime=e,this.togglePlay(!0)}cleanup(){super.cleanup(),this.listenerSetter.removeAll(),this.progress.removeListeners(),this.onPlaybackRackMenuToggle=this.onPip=void 0}}C.PLAYBACK_RATES=[.5,1,1.5,2],C.PLAYBACK_RATES_ICONS=["playback_05","playback_1x","playback_15","playback_2x"];var L=i(3512),E=i(5814),I=i(9331),P=i(2230),Z=i(3442),M=i(3757),k=i(632),T=i(5824),x=i(8497),A=i(6740),_=i(8204),F=i(9171),D=i(5565),R=i(3035),B=i(65),N=i(241),O=i(3241),U=i(1507),H=i(7660),z=i(8580),j=i(1713),G=i(8115),V=i(4421),K=i(2312),W=i(7362),$=i(2796),q=i(3228);function Y(e,t,i){return e>=t&&e<=i}var Q=i(5975),X=i(5994),J=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};const ee=.5,te="media-viewer";class ie extends O.Z{get target(){return this.listLoader.current}set target(e){this.listLoader.current=e}constructor(e,t){super(!1),this.listLoader=e,this.author={},this.content={},this.buttons={},this.tempId=0,this.preloader=null,this.preloaderStreamable=null,this.isFirstOpen=!0,this.pageEl=document.getElementById("page-chats"),this.zoomElements={},this.transform={x:0,y:0,scale:1},this.lastTransform=this.transform,this.lastZoomCenter=this.transform,this.lastDragOffset=this.transform,this.lastDragDelta=this.transform,this.onSwipeFirst=e=>{this.lastDragOffset=this.lastDragDelta={x:0,y:0},this.lastTransform=Object.assign({},this.transform),"wheel"===(null==e?void 0:e.type)&&this.ctrlKeyDown||(this.moversContainer.classList.add("no-transition"),this.zoomElements.rangeSelector.container.classList.remove("with-transition")),this.isGesturingNow=!0,this.lastGestureTime=Date.now(),this.clampZoomDebounced.clearTimeout(),this.lastTransform.x||this.lastTransform.y||this.isZooming||(this.initialContentRect=this.content.media.getBoundingClientRect())},this.onSwipeReset=e=>{this.moversContainer.classList.remove("no-transition"),this.zoomElements.rangeSelector.container.classList.add("with-transition"),this.clampZoomDebounced.clearTimeout(),"mouseup"===(null==e?void 0:e.type)&&"mousemove"===this.draggingType&&(this.ignoreNextClick=!0);const{draggingType:t}=this;if(this.isZoomingNow=!1,this.isGesturingNow=!1,this.draggingType=void 0,!this.closing)if(this.transform.scale>1){const e=Math.min(this.transform.scale,4),i=e/this.transform.scale;let s=this.transform.x*i+(this.lastZoomCenter.x-i*this.lastZoomCenter.x),n=this.transform.y*i+(this.lastZoomCenter.y-i*this.lastZoomCenter.y);if(t&&"wheel"!==t&&this.lastTransform.scale===this.transform.scale){const e=.1,t=Math.max(1,Date.now()-this.lastGestureTime),i=Math.abs(this.lastDragOffset.x)/t,a=Math.abs(this.lastDragOffset.y)/t;s-=Math.abs(this.lastDragOffset.x)*i*e*-this.lastDragDelta.x,n-=Math.abs(this.lastDragOffset.y)*a*e*-this.lastDragDelta.y}const[a]=this.calculateOffsetBoundaries({x:s,y:n,scale:e});this.lastTransform=a,this.setTransform(a)}else this.transform.scale<1&&this.resetZoom()},this.onZoom=({initialCenterX:e,initialCenterY:t,zoom:i,zoomAdd:s,currentCenterX:n,currentCenterY:a,dragOffsetX:o,dragOffsetY:r,zoomFactor:d})=>{e||(e=N.Z.width/2),t||(t=N.Z.height/2),n||(n=N.Z.width/2),a||(a=N.Z.height/2),this.isZoomingNow=!0;const l=void 0!==s?(0,q.Z)(this.lastTransform.scale+s,ee,12):null!=i?i:(0,q.Z)(this.lastTransform.scale*d,ee,12),c=l/this.lastTransform.scale,h=Math.abs(Math.min(this.lastTransform.x,0)),u=Math.abs(Math.min(this.lastTransform.y,0));this.lastZoomCenter={x:n,y:a};const p=h+e,f=u+t,{scaleOffsetX:m,scaleOffsetY:g}=this.calculateScaleOffset({x:p,y:f,scale:c}),[v]=this.calculateOffsetBoundaries({x:this.lastTransform.x+m+o,y:this.lastTransform.y+g+r,scale:l});this.setTransform(v)},this.calculateOffsetBoundaries=({x:e,y:t,scale:i},s=0)=>{if(!this.initialContentRect)return[{x:e,y:t,scale:i},!0,!0];let n=!0,a=!0;const{minX:o,maxX:r,minY:d,maxY:l}=this.getZoomBoundaries(i,s);return n=Y(e,r,o),e=(0,q.Z)(e,r,o),a=Y(t,l,d),[{x:e,y:t=(0,q.Z)(t,l,d),scale:i},n,a]},this.setZoomValue=(e=this.transform.scale)=>{var t;null!==(t=this.initialContentRect)&&void 0!==t||(this.initialContentRect=this.content.media.getBoundingClientRect()),1===e&&(this.transform.x=0,this.transform.y=0),this.moversContainer.style.transform=`translate3d(${this.transform.x.toFixed(3)}px, ${this.transform.y.toFixed(3)}px, 0px) scale(${e.toFixed(3)})`,this.zoomElements.btnOut.classList.toggle("inactive",e<=ee),this.zoomElements.btnIn.classList.toggle("inactive",e>=4),this.toggleZoom(1!==e)},this.onClick=e=>{if(this.ignoreNextClick)return void(this.ignoreNextClick=void 0);if(this.setMoverAnimationPromise)return;const t=e.target;if("A"===t.tagName)return;if((0,l.Z)(e),a.Z)return this.highlightSwitchersTimeout?clearTimeout(this.highlightSwitchersTimeout):this.wholeDiv.classList.add("highlight-switchers"),void(this.highlightSwitchersTimeout=window.setTimeout((()=>{this.wholeDiv.classList.remove("highlight-switchers"),this.highlightSwitchersTimeout=0}),3e3));if((0,S.Cf)(e))return;const i=this.isZooming&&!1;let s=null;const n=["ckin__player","media-viewer-buttons","media-viewer-author","media-viewer-caption","zoom-container"];i&&n.push("media-viewer-movers"),n.find((e=>{try{if(s=(0,x.Z)(t,e),s)return!0}catch(e){return!1}})),s&&(i||"IMG"!==t.tagName&&"image"!==t.tagName)||this.close()},this.onKeyDown=e=>{if(y.Z.overlaysActive>1)return;const t=e.key;let i=!0;"ArrowRight"===t?!this.isZooming&&this.buttons.next.click():"ArrowLeft"===t?!this.isZooming&&this.buttons.prev.click():"-"===t||"="===t?this.ctrlKeyDown&&this.addZoomStep("="===t):i=!1,(e.ctrlKey||e.metaKey)&&(this.ctrlKeyDown=!0),i&&(0,l.Z)(e)},this.onKeyUp=e=>{y.Z.overlaysActive>1||e.ctrlKey||e.metaKey||(this.ctrlKeyDown=!1,this.isZooming&&this.setZoomValue())},this.managers=L.Z.managers,this.log=(0,r.kg)("AMV"),this.preloader=new Z.Z,this.preloaderStreamable=new Z.Z({cancelable:!1,streamable:!0}),this.preloader.construct(),this.preloaderStreamable.construct(),this.lazyLoadQueue=new V.Z,this.wholeDiv=document.createElement("div"),this.wholeDiv.classList.add(te+"-whole"),this.overlaysDiv=document.createElement("div"),this.overlaysDiv.classList.add("overlays");const i=document.createElement("div");i.classList.add(te);const s=this.topbar=document.createElement("div");s.classList.add(te+"-topbar",te+"-appear");const n=document.createElement("div");n.classList.add(te+"-topbar-left"),this.buttons["mobile-close"]=(0,P.Z)("close",{onlyMobile:!0}),this.author.container=document.createElement("div"),this.author.container.classList.add(te+"-author","no-select");const o=document.createElement("div");this.author.avatarEl=new I.Z,this.author.avatarEl.classList.add(te+"-userpic","avatar-44"),this.author.nameEl=document.createElement("div"),this.author.nameEl.classList.add(te+"-name"),this.author.date=document.createElement("div"),this.author.date.classList.add(te+"-date"),o.append(this.author.nameEl,this.author.date),this.author.container.append(this.author.avatarEl,o);const d=document.createElement("div");d.classList.add(te+"-buttons"),t.concat(["download","zoom","close"]).forEach((e=>{const t=(0,P.Z)(e,{noRipple:!0});this.buttons[e]=t,d.append(t)})),this.buttons.zoom.classList.add("zoom-in"),this.zoomElements.container=document.createElement("div"),this.zoomElements.container.classList.add("zoom-container"),this.zoomElements.btnOut=(0,P.Z)("zoomout",{noRipple:!0}),(0,S.fc)(this.zoomElements.btnOut,(()=>this.addZoomStep(!1))),this.zoomElements.btnIn=(0,P.Z)("zoomin",{noRipple:!0}),(0,S.fc)(this.zoomElements.btnIn,(()=>this.addZoomStep(!0))),this.zoomElements.rangeSelector=new B.Z({step:.01,min:ee,max:4,withTransition:!0},1),this.zoomElements.rangeSelector.setListeners(),this.zoomElements.rangeSelector.setHandlers({onScrub:e=>{var t;const i=e-this.transform.scale;this.addZoom(i),null===(t=this.clampZoomDebounced)||void 0===t||t.clearTimeout()},onMouseDown:()=>{this.onSwipeFirst()},onMouseUp:()=>{this.onSwipeReset()}}),this.zoomElements.container.append(this.zoomElements.btnOut,this.zoomElements.rangeSelector.container,this.zoomElements.btnIn),a.Z||this.wholeDiv.append(this.zoomElements.container),this.content.main=document.createElement("div"),this.content.main.classList.add(te+"-content"),this.content.container=document.createElement("div"),this.content.container.classList.add(te+"-container"),this.content.media=document.createElement("div"),this.content.media.classList.add(te+"-media"),this.content.container.append(this.content.media),this.content.main.append(this.content.container),i.append(this.content.main),this.overlaysDiv.append(i),n.append(this.buttons["mobile-close"],this.author.container),s.append(n,d),this.buttons.prev=document.createElement("div"),this.buttons.prev.className=`${te}-switcher ${te}-switcher-left`,this.buttons.prev.innerHTML=`<span class="tgico-down ${te}-prev-button"></span>`,this.buttons.next=document.createElement("div"),this.buttons.next.className=`${te}-switcher ${te}-switcher-right`,this.buttons.next.innerHTML=`<span class="tgico-down ${te}-next-button"></span>`,this.moversContainer=document.createElement("div"),this.moversContainer.classList.add(te+"-movers"),this.moversContainer.append(this.buttons.prev,this.buttons.next),this.wholeDiv.append(this.overlaysDiv,this.topbar,this.moversContainer),this.listLoader.onLoadedMore=()=>{this.buttons.prev.classList.toggle("hide",!this.listLoader.previous.length),this.buttons.next.classList.toggle("hide",!this.listLoader.next.length)},this.setNewMover()}setListeners(){(0,S.fc)(this.buttons.download,this.onDownloadClick),[this.buttons.close,this.buttons["mobile-close"],this.preloaderStreamable.preloader].forEach((e=>{(0,S.fc)(e,this.close.bind(this))})),[[-1,this.buttons.prev],[1,this.buttons.next]].forEach((([e,t])=>{t.addEventListener("click",(t=>{(0,l.Z)(t),this.setMoverPromise||this.listLoader.go(e)}))})),(0,S.fc)(this.buttons.zoom,(()=>{this.isZooming?this.resetZoom():this.addZoomStep(!0)})),this.wholeDiv.addEventListener("click",this.onClick),this.listLoader.onJump=(e,t)=>{t?this.onNextClick(e):this.onPrevClick(e)};const e=(e,t)=>{const[i,s]=[e-this.lastDragOffset.x,t-this.lastDragOffset.y],[n,a,o]=this.calculateOffsetBoundaries({x:this.transform.x+i,y:this.transform.y+s,scale:this.transform.scale});return this.lastDragDelta={x:i,y:s},this.lastDragOffset={x:e,y:t},this.setTransform(n),{inBoundsX:a,inBoundsY:o}},t=(0,b.Z)((()=>{this.lastGestureTime=Date.now()}),500,!1,!0);this.clampZoomDebounced=(0,b.Z)((()=>{this.onSwipeReset()}),300,!1,!0),this.swipeHandler=new M.Z({element:this.wholeDiv,onReset:this.onSwipeReset,onFirstSwipe:this.onSwipeFirst,onSwipe:(i,s,n,o)=>{if(!(0,f.rB)())if(!this.isZooming||this.isZoomingNow){if(!this.isZoomingNow&&a.Z)return Math.abs(i)/N.Z.width>.2||Math.abs(i)>125?(i>0?this.buttons.prev.click():this.buttons.next.click(),!0):(Math.abs(s)/N.Z.height>.2||Math.abs(s)>125)&&(this.close(),!0)}else{t(),this.draggingType=n.type;const{inBoundsX:a,inBoundsY:r}=e(i,s);null==o||o(!a,!r)}},onZoom:this.onZoom,onDoubleClick:({centerX:e,centerY:t})=>{if(this.isZooming)this.resetZoom();else{const i=3;this.changeZoomByPosition(e,t,i)}},verifyTouchTarget:e=>!((0,f.rB)()||(0,Q.Z)(e.target,this.zoomElements.container)||(0,x.Z)(e.target,"ckin__controls")||(0,x.Z)(e.target,"media-viewer-caption")||(0,x.Z)(e.target,"media-viewer-topbar")&&"wheel"!==e.type),cursor:""})}changeZoomByPosition(e,t,i){const{scaleOffsetX:s,scaleOffsetY:n}=this.calculateScaleOffset({x:e,y:t,scale:i}),a=this.calculateOffsetBoundaries({x:s,y:n,scale:i})[0];this.setTransform(a)}setTransform(e){this.transform=e,this.changeZoom(e.scale)}calculateScaleOffset({x:e,y:t,scale:i}){return{scaleOffsetX:e-i*e,scaleOffsetY:t-i*t}}toggleZoom(e){const t=this.isZooming,i=void 0===e;if((this.zoomElements.rangeSelector.mousedown||this.ctrlKeyDown)&&(e=!0),null!=e||(e=!t),t!==e){if(this.buttons.zoom.classList.toggle("zoom-in",!e),this.zoomElements.container.classList.toggle("is-visible",this.isZooming=e),this.wholeDiv.classList.toggle("is-zooming",e),i||!e){const t=e?this.transform.scale:1;this.setZoomValue(t),this.zoomElements.rangeSelector.setProgress(t)}this.videoPlayer&&this.videoPlayer.lockControls(!e&&void 0)}}addZoomStep(e){this.addZoom(.5*(e?1:-1))}resetZoom(){this.setTransform({x:0,y:0,scale:1})}changeZoom(e=this.transform.scale){this.transform.scale=e,this.zoomElements.rangeSelector.setProgress(e),this.setZoomValue(e)}addZoom(e){this.lastTransform=this.transform,this.onZoom({zoomAdd:e,currentCenterX:0,currentCenterY:0,initialCenterX:0,initialCenterY:0,dragOffsetX:0,dragOffsetY:0}),this.lastTransform=this.transform,this.clampZoomDebounced()}getZoomBounce(){return this.isGesturingNow&&a.Z?50:0}getZoomBoundaries(e=this.transform.scale,t=0){if(!this.initialContentRect)return{minX:0,maxX:0,minY:0,maxY:0};const i=(N.Z.width-N.Z.width*e)/2,s=(N.Z.height-N.Z.height*e)/2;return{minX:Math.max(-this.initialContentRect.left*e,i),maxX:N.Z.width-this.initialContentRect.right*e,minY:Math.max(-this.initialContentRect.top*e+t,s),maxY:N.Z.height-this.initialContentRect.bottom*e}}setBtnMenuToggle(e){const t=(0,u.Z)({buttonOptions:{onlyMobile:!0},direction:"bottom-left",buttons:e});this.topbar.append(t)}close(e){var t,i;if(e&&(0,l.Z)(e),this.setMoverAnimationPromise)return Promise.reject();this.closing=!0,null===(t=this.swipeHandler)||void 0===t||t.removeListeners(),this.navigationItem&&T.Z.removeItem(this.navigationItem),this.lazyLoadQueue.clear();const s=this.setMoverToTarget(null===(i=this.target)||void 0===i?void 0:i.element,!0).then((({onAnimationEnd:e})=>e));return this.listLoader.reset(),this.listLoader.cleanup&&this.listLoader.cleanup(),this.setMoverPromise=null,this.tempId=-1,window.appMediaViewer===this&&(window.appMediaViewer=void 0),this.removeGlobalListeners(),s.finally((()=>{this.wholeDiv.remove(),this.toggleOverlay(!1)})),s}toggleOverlay(e){y.Z.isOverlayActive=e,E.Z.checkAnimations2(e)}toggleGlobalListeners(e){e?this.setGlobalListeners():this.removeGlobalListeners()}removeGlobalListeners(){window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp)}setGlobalListeners(){window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp)}setMediaTimestamp(e){var t;null===(t=this.videoPlayer)||void 0===t||t.setTimestamp(e)}setMoverToTarget(e,t=!1,i=0){return J(this,void 0,void 0,(function*(){this.dispatchEvent("setMoverBefore");const n=this.content.mover;t||n.replaceChildren();const a=this.isZooming&&t?this.transform.scale:1;this.removeCenterFromMover(n);const o=0!==i,r=X.Z.isAvailable("animations")?o?350:200:0;let d,l;e&&(e instanceof I.Z||e.classList.contains("grid-item")?(d=e,l=e.getBoundingClientRect()):e instanceof SVGImageElement||e.parentElement instanceof SVGForeignObjectElement?(d=(0,x.Z)(e,"attachment"),l=d.getBoundingClientRect()):e.classList.contains("profile-avatars-avatar")&&(d=(0,x.Z)(e,"profile-avatars-container"),l=d.getBoundingClientRect(),t&&e.getBoundingClientRect().left!==l.left&&(e=d=l=void 0))),e||(e=this.content.media),l||(d=e.parentElement,l=e.getBoundingClientRect());let c=!1;if(e!==this.content.media&&!e.classList.contains("profile-avatars-avatar")){const i=(0,x.Z)(d,"scrollable"),s=(0,_.Z)(d,i,!0);!t||s&&2!==s.overflow.vertical&&2!==s.overflow.horizontal?!s||1!==s.overflow.vertical&&1!==s.overflow.horizontal||(c=!0):(d=(e=this.content.media).parentElement,l=e.getBoundingClientRect())}const h=this.content.media.getBoundingClientRect();let u,p,f,m="";if(o?(u=1===i?N.Z.width:-h.width,p=h.top):(u=l.left,p=l.top),m+=`translate3d(${u}px,${p}px,0) `,e instanceof HTMLImageElement||e instanceof HTMLVideoElement||"DIV"===e.tagName){if(n.firstElementChild&&n.firstElementChild.classList.contains("media-viewer-aspecter")){f=n.firstElementChild;const e=f.querySelector(".ckin__player");if(e){const t=e.firstElementChild;f.append(t),e.remove()}f.style.cssText||(n.classList.remove("active"),this.setFullAspect(f,h,l),n.offsetLeft,n.classList.add("active"))}else f=document.createElement("div"),f.classList.add("media-viewer-aspecter"),n.prepend(f);f.style.cssText=`width: ${l.width}px; height: ${l.height}px; transform: scale3d(${h.width/l.width}, ${h.height/l.height}, 1);`}n.style.width=h.width+"px",n.style.height=h.height+"px";const g=l.width/h.width,v=l.height/h.height;o||(m+=`scale3d(${g},${v},1) `);let b=window.getComputedStyle(d).getPropertyValue("border-radius");const y=function(e){const t=e.split(" ");if(4!==t.length){t[0]||(t[0]="0px");for(let e=t.length;e<4;++e)t[e]=t[e%2]||t[0]||"0px"}return t}(b);if(b=y.map((e=>parseInt(e)/g+"px")).join(" "),o||(n.style.borderRadius=b),t&&1!==a){const e=l.left-(N.Z.width*g-l.width)/2,t=l.top-(N.Z.height*v-l.height)/2;this.moversContainer.style.transform=`matrix(${g}, 0, 0, ${v}, ${e}, ${t})`}else n.style.transform=m;let w;c&&(n.style.opacity="0");const S=e.classList.contains("is-out"),C=this.setMoverAnimationPromise=(0,s.Z)(),L={onAnimationEnd:C},E=setTimeout((()=>{C.isFulfilled||C.isRejected||C.resolve()}),1e3);if(C.finally((()=>{this.dispatchEvent("setMoverAfter"),this.setMoverAnimationPromise===C&&(this.setMoverAnimationPromise=null),clearTimeout(E)})),t)return e instanceof SVGSVGElement&&(w=n.querySelector("path"),w&&this.sizeTailPath(w,h,g,r,!1,S,b)),e.classList.contains("media-viewer-media")&&n.classList.add("hiding"),this.toggleWholeActive(!1),setTimeout((()=>{n.style.borderRadius=b,n.firstElementChild&&(n.firstElementChild.style.borderRadius=b)}),r/2),setTimeout((()=>{n.replaceChildren(),n.classList.remove("moving","active","hiding"),n.style.cssText="display: none;",C.resolve()}),r),n.classList.remove("opening"),L;{let t,i;const s="video, img, .canvas-thumbnail",a=e.matches(s)?e.parentElement:e,r=Array.from(a.querySelectorAll(s));if(r.length){e=r.pop();const t=document.createElement("canvas"),i=t.getContext("2d");e instanceof HTMLImageElement?(t.width=e.naturalWidth,t.height=e.naturalHeight):e instanceof HTMLVideoElement?(t.width=e.videoWidth,t.height=e.videoHeight):e instanceof HTMLCanvasElement&&(t.width=e.width,t.height=e.height),t.className="canvas-thumbnail thumbnail media-photo",i.drawImage(e,0,0),e=t}if("DIV"===e.tagName||"AVATAR-ELEMENT"===e.tagName){const s=Array.from(e.querySelectorAll("img")).pop();s&&(t=new Image,i=s.src,n.append(t))}else if(e instanceof HTMLImageElement)t=new Image,i=e.src;else if(e instanceof HTMLVideoElement)t=(0,H.Z)(),t.src=e.src;else if(e instanceof SVGSVGElement){const t=e.dataset.clipId,i=t+"-mv",{width:s,height:a}=h,o=document.createElementNS("http://www.w3.org/2000/svg","svg");o.setAttributeNS(null,"width",""+s),o.setAttributeNS(null,"height",""+a),o.setAttributeNS(null,"viewBox",`0 0 ${s} ${a}`),o.setAttributeNS(null,"preserveAspectRatio","xMidYMid meet"),o.insertAdjacentHTML("beforeend",e.firstElementChild.outerHTML.replace(t,i)),o.insertAdjacentHTML("beforeend",e.lastElementChild.outerHTML.replace(t,i));const r=o.firstElementChild,d=r.firstElementChild.firstElementChild;if(d instanceof SVGUseElement){let e,t=d.getAttributeNS(null,"transform");t=t.replace(/translate\((.+?), (.+?)\) scale\((.+?), (.+?)\)/,((e,t,i,n,o)=>`translate(${t=2!=(t=+t)?s-2/g:2/g}, ${a}) scale(${+n/g}, ${+o/v})`)),d.setAttributeNS(null,"transform",t),w=r.firstElementChild.lastElementChild;const i=b.split(" ").map((e=>parseInt(e)));e=S?(0,F.Z)(0,0,s-9/g,a,...i):(0,F.Z)(9/g,0,s-9/g,a,...i),w.setAttributeNS(null,"d",e)}const l=o.lastElementChild;l.setAttributeNS(null,"width",""+h.width),l.setAttributeNS(null,"height",""+h.height),n.prepend(o)}else e instanceof HTMLCanvasElement&&(t=e);f&&(f.style.borderRadius=b,t&&f.append(t)),t=n.querySelector("video, img"),t instanceof HTMLImageElement&&(t.classList.add("thumbnail"),f||(t.style.width=h.width+"px",t.style.height=h.height+"px"),i&&(yield(0,A.cj)(t,i))),n.style.display="",(0,R.T2)((()=>{n.classList.add(o?"moving":"active")}))}return n.classList.add("opening"),yield(0,R.d1)(),n.style.transform=`translate3d(${h.left}px,${h.top}px,0) scale3d(1,1,1)`,c&&(n.style.opacity=""),f&&this.setFullAspect(f,h,l),setTimeout((()=>{n.style.borderRadius="",n.firstElementChild&&(n.firstElementChild.style.borderRadius="")}),0),n.dataset.timeout=""+setTimeout((()=>{n.classList.remove("moving","opening"),f&&(n.querySelector("video"),n.classList.remove("active"),f.style.cssText="",n.offsetLeft),n.classList.add("center","no-transition"),n.classList.add("active"),delete n.dataset.timeout,C.resolve()}),r),w&&this.sizeTailPath(w,h,g,r,!0,S,b),L}))}toggleWholeActive(e){e?this.wholeDiv.classList.add("active"):(this.wholeDiv.classList.add("backwards"),setTimeout((()=>{this.wholeDiv.classList.remove("active")}),0))}setFullAspect(e,t,i){const s=t.width/t.height;let{width:n,height:a}=i;s>0?n=a*s:a=n*s,e.style.cssText=`width: ${n}px; height: ${a}px; transform: scale3d(${t.width/n}, ${t.height/a}, 1);`}sizeTailPath(e,t,i,s,n,a,o){const r=Date.now(),{width:d,height:l}=t;s/=2;const c=o.split(" ").map((e=>parseInt(e))),h=()=>{const t=Date.now()-r;let o=s?t/s:1;o>1&&(o=1),n&&(o=1-o);const u=c.map((e=>e*o));let p;p=a?(0,F.Z)(0,0,d-9/i*o,l,...u):(0,F.Z)(9/i*o,0,d,l,...u),e.setAttributeNS(null,"d",p),t<s&&(0,R.T2)(h)};h()}removeCenterFromMover(e){if(e.classList.contains("center")){const t=this.content.media.getBoundingClientRect();e.style.transform=`translate3d(${t.left}px,${t.top}px,0)`,e.classList.remove("center"),e.offsetLeft,e.classList.remove("no-transition")}}moveTheMover(e,t=!0){const i=N.Z.width;this.removeCenterFromMover(e),e.classList.add("moving"),e.dataset.timeout&&clearTimeout(+e.dataset.timeout);const s=e.getBoundingClientRect(),n=e.style.transform.replace(/translate3d\((.+?),/,((e,n)=>{const a=t?-s.width:i;return e.replace(n,a+"px")}));e.style.transform=n,setTimeout((()=>{e.remove()}),350)}setNewMover(){const e=document.createElement("div");return e.classList.add("media-viewer-mover"),e.style.display="none",this.content.mover?this.content.mover.parentElement.append(e):this.moversContainer.append(e),this.content.mover=e}updateMediaSource(e,t,i){const s=e.tagName.toLowerCase()===i?e:e.querySelector(i);if(s&&!(0,x.Z)(e,"document")){if((0,x.Z)(e,"attachment")){const t=e.parentElement.parentElement.querySelector(".preloader-container");if(t){if("video"===i)return void(t.classList.contains("manual")&&t.click());t.remove()}}s.src!==t&&(0,A.ZP)(s,t),s.classList.contains("thumbnail")&&s.parentElement.classList.contains("media-container-aspecter")&&s.classList.remove("thumbnail")}}setAuthorInfo(e,t){const i=e.isPeerId();let s;if(i)s=(0,W.Z)({peerId:e,dialog:!1,onlyFirstName:!1,plainText:!1});else{const t=s=document.createElement("span");t.append((0,G.Z)(e)),t.classList.add("peer-title")}const n=this.author.avatarEl,a=this.author.avatarEl=n.cloneNode();return Promise.all([this.author.avatarEl.updateWithOptions({peerId:e||U.NM,peerTitle:i?void 0:""+e}),s]).then((([e,i])=>{this.author.avatarEl===a&&((0,D.Z)(this.author.date,(0,k.OD)(t)),(0,D.Z)(this.author.nameEl,i),n.replaceWith(this.author.avatarEl))}))}_openMedia({media:e,timestamp:t,fromId:i,fromRight:s,target:a,reverse:r=!1,prevTargets:c=[],nextTargets:h=[],message:u,mediaTimestamp:p}){return J(this,void 0,void 0,(function*(){if(this.setMoverPromise)return this.setMoverPromise;const f=this.setAuthorInfo(i,t),m="document"===e._,g=m&&e.mime_type&&(["video","gif"].includes(e.type)||0===e.mime_type.indexOf("video/"));this.isFirstOpen&&(this.isFirstOpen=!1,this.listLoader.setTargets(c,h,r),window.appMediaViewer=this),this.listLoader.next.length<10&&setTimeout((()=>{this.listLoader.load(!0)}),0),this.buttons.prev.classList.toggle("hide",!this.listLoader.previous.length),this.buttons.next.classList.toggle("hide",!this.listLoader.next.length);const v=this.content.media,b=!a||a===v;b&&(a=v),this.target={element:a};const y=++this.tempId;v.firstElementChild&&v.replaceChildren(),0!==s?(this.moveTheMover(this.content.mover,1===s),this.setNewMover()):(this.navigationItem={type:"media",onPop:e=>{if(this.setMoverAnimationPromise)return!1;!e&&o.IS_MOBILE_SAFARI&&this.wholeDiv.remove(),this.close()}},T.Z.pushItem(this.navigationItem),this.toggleOverlay(!0),this.setGlobalListeners(),yield f,this.wholeDiv.parentElement||(this.pageEl.insertBefore(this.wholeDiv,document.getElementById("main-columns")),this.wholeDiv.offsetLeft),this.toggleWholeActive(!0));const w=this.content.mover,S=N.Z.width;let L=0;const E=N.Z.height;E<1e6&&!n.Z.isMobile&&(L=120);const I=E-120-L;let P=Promise.resolve();const Z=(0,j.Z)(e,v,S,I,!n.Z.isMobile,void 0,!!(m&&e.w&&e.h)).photoSize;if(b){const t=yield this.managers.thumbsStorage.getCacheContext(e,Z.type);let i;if(t.downloaded)i=new Image,i.src=t.url;else{const s=(0,z.Z)(e,t,!0);s&&(P=s.loadPromise,i=s.image)}i&&(i.classList.add("thumbnail"),v.append(i))}const M=!(!m||!e.supportsStreaming),k=M?this.preloaderStreamable:this.preloader,x=(t=(null==Z?void 0:Z.type))=>this.managers.thumbsStorage.getCacheContext(e,t);let _;if(g){const t=u&&"gif"!==e.type,i=(0,H.Z)({pip:t});this.wholeDiv.classList.contains("no-forwards")&&i.addEventListener("contextmenu",l.Z);const n=()=>this.setMoverToTarget(a,!1,s).then((({onAnimationEnd:s})=>{const n=w.firstElementChild&&w.firstElementChild.classList.contains("media-viewer-aspecter")?w.firstElementChild:w,r=w.querySelector("video");r&&r.remove(),i.setAttribute("playsinline","true"),i.addEventListener("timeupdate",(()=>{this.tempId!==y&&i.pause()})),this.addEventListener("setMoverAfter",(()=>{i.src="",i.load()}),{once:!0}),o.IS_SAFARI&&(i.autoplay=!0),"gif"===e.type?(i.muted=!0,i.autoplay=!0,i.loop=!0):e.duration<60&&(i.loop=!0),void 0!==p&&(i.currentTime=p),n.append(i);const c=new Promise((e=>{i.addEventListener("canplay",e,{once:!0})})),h=()=>{"gif"!==e.type&&(i.dataset.ckin="default",i.dataset.overlay="1",Promise.all([c,s]).then((()=>{this.tempId===y&&((this.videoPlayer=new C({video:i,play:!0,streamable:M,onPlaybackRackMenuToggle:e=>{this.wholeDiv.classList.toggle("hide-caption",!!e)},onPip:e=>{const s=window.appMediaViewer;if(!e&&s&&s!==this)return this.releaseSingleMedia=void 0,void this.close();this.moversContainer.lastElementChild.classList.toggle("hiding",e),this.toggleWholeActive(!e),this.toggleOverlay(!e),this.toggleGlobalListeners(!e),this.navigationItem&&(e?T.Z.removeItem(this.navigationItem):T.Z.pushItem(this.navigationItem)),t&&(e?(this.releaseSingleMedia(!1),this.releaseSingleMedia=void 0,d.Z.setPictureInPicture(i)):this.releaseSingleMedia=d.Z.setSingleMedia(i,u))},onPipClose:()=>{this.close()}})).addEventListener("toggleControls",(e=>{this.wholeDiv.classList.toggle("has-video-controls",e)})),this.addEventListener("setMoverBefore",(()=>{this.wholeDiv.classList.remove("has-video-controls"),this.videoPlayer.cleanup(),this.videoPlayer=void 0}),{once:!0}),this.isZooming&&this.videoPlayer.lockControls(!1))})))};if(M){s.then((()=>{i.readyState<i.HAVE_FUTURE_DATA&&k.attach(w,!0)}));const e=()=>{i.addEventListener("canplay",(()=>{k.detach(),i.parentElement.classList.remove("is-buffering")}),{once:!0})};i.addEventListener("waiting",(()=>{const t=i.networkState===i.NETWORK_LOADING,s=i.readyState<i.HAVE_FUTURE_DATA;t&&s&&(e(),k.attach(w,!0),i.parentElement.classList.add("is-buffering"))})),this.wholeDiv.classList.contains("no-forwards")&&i.addEventListener("contextmenu",(e=>{(0,l.Z)(e)})),e()}this.lazyLoadQueue.unshift({load:()=>J(this,void 0,void 0,(function*(){const r=M?Promise.resolve():K.Z.downloadMediaURL({media:e});return M||s.then((()=>J(this,void 0,void 0,(function*(){(yield x()).url||k.attach(w,!0,r)})))),Promise.all([r,s]).then((()=>J(this,void 0,void 0,(function*(){if(this.tempId!==y)return void this.log.warn("media viewer changed video");const e=(yield x()).url;i.addEventListener("error",(()=>{(0,$.bC)({langPackKey:o.IS_MOBILE?"Video.Unsupported.Mobile":"Video.Unsupported.Desktop"}),4!==i.error.code&&this.log.error("Error "+i.error.code+"; details: "+i.error.message),null==k||k.detach()}),{once:!0}),a instanceof SVGSVGElement?n.firstElementChild.lastElementChild.append(i):(0,A.ZP)(i,e),t&&(this.releaseSingleMedia=d.Z.setSingleMedia(i,u),this.addEventListener("setMoverBefore",(()=>{this.releaseSingleMedia&&(this.releaseSingleMedia(),this.releaseSingleMedia=void 0)}),{once:!0})),this.updateMediaSource(a,e,"video"),h()})))),r}))})}));_=P.then(n)}else{const t=()=>this.setMoverToTarget(a,!1,s).then((({onAnimationEnd:t})=>{this.lazyLoadQueue.unshift({load:()=>J(this,void 0,void 0,(function*(){const i=m?K.Z.downloadMediaURL({media:e}):K.Z.downloadMediaURL({media:e,thumb:Z}),s=!m&&e.sizes.slice().filter((e=>e.w));s&&s.sort(((e,t)=>t.size-e.size));const o=null==s?void 0:s[0],r=!m&&o!==Z&&K.Z.downloadMediaURL({media:e,thumb:o});return t.then((()=>J(this,void 0,void 0,(function*(){(yield x()).url||this.preloader.attachPromise(i)})))),Promise.all([t,i]).then((()=>J(this,void 0,void 0,(function*(){var e;if(this.tempId!==y)return void this.log.warn("media viewer changed photo");const t=(yield x()).url;if(a instanceof SVGSVGElement)this.updateMediaSource(a,t,"img"),this.updateMediaSource(w,t,"img"),n.Z.isMobile&&w.querySelectorAll("img").forEach((e=>{e.classList.remove("thumbnail")}));else{const i=w.firstElementChild&&w.firstElementChild.classList.contains("media-viewer-aspecter")?w.firstElementChild:w,s=["CANVAS","IMG"].includes(null===(e=i.firstElementChild)||void 0===e?void 0:e.tagName)?i.firstElementChild:null;if((null==s?void 0:s.src)!==t){const e=new Image;e.classList.add("thumbnail"),(0,A.ZP)(e,t,(()=>{(0,R.T2)((()=>{this.updateMediaSource(a,t,"img"),s&&(0,R.T2)((()=>{s.remove()})),i.append(e)}))}),!1),r&&r.then((t=>{const i=new Image;i.classList.add("thumbnail"),(0,A.ZP)(i,t,(()=>{(0,R.T2)((()=>{e.replaceWith(i)}))}),!1)}))}}})))).catch((e=>{this.log.error(e),this.preloader.attach(w),this.preloader.setManual()})),i}))})}));_=P.then(t)}return this.setMoverPromise=_.catch((()=>{this.setMoverAnimationPromise=null})).finally((()=>{this.setMoverPromise=null}))}))}}},5824:(e,t,i)=>{"use strict";i.d(t,{Z:()=>h});var s=i(410),n=i(4762),a=i(5003),o=i(8799),r=i(3910),d=i(3444),l=i(1655);const c=new class{constructor(){if(this.onPopState=e=>{const t=window.location.hash,i=e.state;if(this.debug&&this.log("popstate",e,this.isPossibleSwipe,t),t!==this.currentHash)if(this.debug&&this.log.warn(`hash changed, new=${t}, current=${this.currentHash}, overridden=${this.overriddenHash}`),i===this.id&&this.overriddenHash&&this.overriddenHash!==t)this.overrideHash(this.overriddenHash);else{if(!i||this.overriddenHash||!t)return this.currentHash=t,void(this.onHashChange&&this.onHashChange());this.overrideHash()}if(i!==this.id&&(this.pushState(),!this.navigations.length))return;const s=this.navigations.pop();s?(this.manual=!this.isPossibleSwipe,this.handleItem(s)):this.pushState()},this.onKeyDown=e=>{const t=this.navigations[this.navigations.length-1];t&&("Escape"!==e.key||t.onEscape&&!t.onEscape()||((0,r.Z)(e),this.back(t.type)))},this.onTouchStart=e=>{e.touches.length>1||(this.debug&&this.log("touchstart"),(0,d.Z)(e)&&(this.isPossibleSwipe=!0,window.addEventListener("touchend",(()=>{setTimeout((()=>{this.isPossibleSwipe=!1}),100)}),{passive:!0,once:!0})))},this.navigations=[],this.id=Date.now(),this.manual=!1,this.log=(0,a.kg)("NC"),this.debug=!0,this.currentHash=window.location.hash,this.overriddenHash="",this.isPossibleSwipe=!1,window.addEventListener("popstate",this.onPopState),window.addEventListener("keydown",this.onKeyDown,{capture:!0,passive:!1}),n.IS_MOBILE_SAFARI){const e={passive:!0};window.addEventListener("touchstart",this.onTouchStart,e)}history.scrollRestoration="manual",this.pushState()}overrideHash(e=""){e&&"#"!==e[0]?e="#"+e:"#"===e&&(e=""),this.currentHash!==e&&(this.overriddenHash=this.currentHash=e,this.replaceState(),this.pushState())}handleItem(e){const t=e.onPop(!!this.manual&&void 0);this.debug&&this.log("popstate, navigation:",e,this.navigations),!1===t?this.pushItem(e):e.noBlurOnPop||(0,o.Z)(),this.manual=!1}findItemByType(e){for(let t=this.navigations.length-1;t>=0;--t){const i=this.navigations[t];if(i.type===e)return{item:i,index:t}}}back(e){if(e){const t=this.findItemByType(e);if(t)return void this.backByItem(t.item,t.index)}history.back()}backByItem(e,t=this.navigations.indexOf(e)){this.manual=!0,this.navigations.splice(t,1),this.handleItem(e)}onItemAdded(e){this.debug&&this.log("onItemAdded",e,this.navigations),e.noHistory||this.pushState()}pushItem(e){this.navigations.push(e),this.onItemAdded(e)}unshiftItem(e){this.navigations.unshift(e),this.onItemAdded(e)}spliceItems(e,t,...i){this.navigations.splice(e,t,...i),i.forEach((e=>{this.onItemAdded(e)}))}pushState(){this.debug&&this.log("push"),this.manual=!1,history.pushState(this.id,"")}replaceState(){this.debug&&this.log.warn("replace");const e=location.origin+location.pathname+location.search+this.overriddenHash;history.replaceState(this.id,"",e)}removeItem(e){e&&(0,l.Z)(this.navigations,e)}removeByType(e,t=!1){for(let i=this.navigations.length-1;i>=0&&(this.navigations[i].type!==e||(this.navigations.splice(i,1),!t));--i);}};s.GO.appNavigationController=c;const h=c},5884:(e,t,i)=>{"use strict";i.d(t,{Z:()=>l,z:()=>d});var s=i(5005),n=i(8805),a=i(5565),o=i(2325),r=i(3512);class d{constructor(e,t,i=!0,n,a=!0,r=!0,d,l){this.name=e,this.type=t,this.clearable=i,this.autonomous=r,this.onFound=d,this.noIcons=l,this.list=s.default.createChatList(),this.container=document.createElement("div"),n&&(this.container.className=n),e&&(this.nameEl=document.createElement("div"),this.nameEl.classList.add("search-group__name"),"string"==typeof e&&this.nameEl.append((0,o.ag)(e)),this.container.append(this.nameEl)),this.container.classList.add("search-group","search-group-"+t),this.container.append(this.list),this.container.style.display="none",a&&s.default.setListClickListener(this.list,d,void 0,r)}clear(){this.container.style.display="none",this.clearable&&this.list.replaceChildren()}setActive(){this.container.style.display=""}toggle(){this.list.childElementCount?this.setActive():this.clear()}}class l{constructor(e,t,i,s,a){this.container=e,this.searchInput=t,this.searchGroups=i,this.onSearch=s,this.noIcons=a,this.minMsgId=0,this.loadedCount=-1,this.foundCount=-1,this.searchPromise=null,this.searchTimeout=0,this.query="",this.listsContainer=null,this.threadId=0,this.scrollable=new n.ZP(this.container),this.listsContainer=this.scrollable.container;for(const e in this.searchGroups)this.listsContainer.append(this.searchGroups[e].container);this.searchGroups.messages&&this.scrollable.setVirtualContainer(this.searchGroups.messages.list),this.searchInput.onChange=e=>{this.query=e,this.reset(!1),this.searchMore()},this.scrollable.onScrolledBottom=()=>{this.query.trim()&&(this.searchTimeout||(this.searchTimeout=window.setTimeout((()=>{this.searchMore(),this.searchTimeout=0}),0)))}}reset(e=!0){e&&(this.searchInput.value="",this.query="",this.peerId=void 0,this.threadId=0),this.minMsgId=0,this.loadedCount=-1,this.foundCount=-1;for(const e in this.searchGroups)this.searchGroups[e].clear();this.searchPromise=null}beginSearch(e,t=0,i=""){this.peerId=e,this.threadId=t,this.query!==i&&(this.searchInput.inputField.value=i),this.searchInput.input.focus()}searchMore(){if(this.searchPromise)return this.searchPromise;const e=this.query;if(!e.trim())return void(this.onSearch&&this.onSearch(0));if(-1!==this.foundCount&&this.loadedCount>=this.foundCount)return Promise.resolve();const t=this.minMsgId||0;return this.searchPromise=r.Z.managers.appMessagesManager.getSearch({peerId:this.peerId,query:e,inputFilter:{_:"inputMessagesFilterEmpty"},maxId:t,limit:20,threadId:this.threadId}).then((t=>{if(this.searchPromise=null,this.searchInput.value!==e)return;const{count:i,history:n}=t;n.length&&n[0].mid===this.minMsgId&&n.shift();const r=this.searchGroups.messages;n.forEach((t=>{try{const i=this.peerId?t.fromId:t.peerId;s.default.addDialogAndSetLastMessage({peerId:i,container:this.scrollable,avatarSize:"bigger",meAsSaved:!1,message:t,query:e,noIcons:this.noIcons})}catch(e){console.error("[appSearch] render search result",e)}})),r.toggle(),this.minMsgId=n.length&&n[n.length-1].mid,-1===this.loadedCount&&(this.loadedCount=0),this.loadedCount+=n.length,-1===this.foundCount&&(this.foundCount=i,r.nameEl&&(0,a.Z)(r.nameEl,(0,o.ag)(i?"Chat.Search.MessagesFound":"Chat.Search.NoMessagesFound",[i])),this.onSearch&&this.onSearch(this.foundCount))})).catch((e=>{console.error("search error",e),this.searchPromise=null}))}}},6360:(e,t,i)=>{"use strict";i.d(t,{Z:()=>be});var s=i(5005),n=i(5003),a=i(3512),o=i(5884),r=i(6008),d=i(2153),l=i(279),c=i(1405),h=i(8805),u=i(8594),p=i(2325),f=i(8497),m=i(3624),g=i(2894),v=i(4668),b=i(4332),y=i(4755),w=i(7030),S=i(4484),C=i(467),L=i(5432),E=i(1154),I=i(241),P=i(6272),Z=i(3003),M=i(4524),k=i(5128),T=i(7479),x=i(5705),A=i(6054),_=i(3910),F=i(2738),D=i(1784),R=i(8479),B=i(7401),N=i(5953),O=i(3738),U=i(4064),H=i(130),z=i(9687),j=i(2498),G=i(1336),V=i(5798),K=i(2342),W=i(2491),$=i(5400),q=i(5671),Y=i(1604),Q=i(7530),X=i(6566),J=i(177),ee=i(3061),te=i(2566),ie=i(6976),se=i(3416),ne=i(1483),ae=i(3855),oe=i(3699),re=i(296),de=i(9492),le=i(2887),ce=i(319),he=i(6131),ue=i(2353),pe=i(4499),fe=i(1168),me=i(7740),ge=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class ve{constructor(e,t,i){this.attachTo=e,this.searchSuper=t,this.listenerSetter=i,this.onGotoClick=()=>{w.ZP.setInnerPeer({peerId:this.peerId,lastMsgId:this.mid,threadId:this.searchSuper.searchContext.threadId})},this.onForwardClick=()=>{this.searchSuper.selection.isSelecting?(0,F.tH)(this.searchSuper.selection.selectionForwardBtn):fe.Z.createPopup(M.Z,{[this.peerId]:[this.mid]})},this.onSelectClick=()=>{this.searchSuper.selection.toggleByElement(this.target)},this.onClearSelectionClick=()=>{this.searchSuper.selection.cancelSelection()},this.onDeleteClick=()=>{this.searchSuper.selection.isSelecting?(0,F.tH)(this.searchSuper.selection.selectionDeleteBtn):fe.Z.createPopup(k.Z,this.peerId,[this.mid],"chat")},this.managers=t.managers;L.Z||(0,ie.E)({element:e,callback:e=>{let i;this.init&&(this.init(),this.init=null);try{i=(0,f.Z)(e.target,"search-super-item")}catch(e){}if(i){if(e instanceof MouseEvent&&e.preventDefault(),this.element.classList.contains("active"))return!1;e instanceof MouseEvent&&(e.cancelBubble=!0),(()=>{ge(this,void 0,void 0,(function*(){this.target=i,this.peerId=i.dataset.peerId.toPeerId(),this.mid=+i.dataset.mid,this.isSelected=t.selection.isMidSelected(this.peerId,this.mid),this.message=yield this.managers.appMessagesManager.getMessageByPeer(this.peerId,this.mid),this.noForwards=t.selection.isSelecting?this.searchSuper.selection.selectionForwardBtn.classList.contains("hide"):!(yield this.managers.appMessagesManager.canForward(this.message)),this.selectedMessages=t.selection.isSelecting?yield t.selection.getSelectedMessages():void 0,yield Promise.all(this.buttons.map((e=>ge(this,void 0,void 0,(function*(){let t;t=!(this.searchSuper.selection.isSelecting&&!e.withSelection||e.verify&&!(yield e.verify())),e.element.classList.toggle("hide",!t)}))))),i.classList.add("menu-open"),(0,ne.Z)(e,this.element),se.Z.openBtnMenu(this.element,(()=>{i.classList.remove("menu-open")}))}))})()}},listenerSetter:i})}init(){this.buttons=[{icon:"forward",text:"Forward",onClick:this.onForwardClick,verify:()=>!this.noForwards},{icon:"forward",text:"Message.Context.Selection.Forward",onClick:this.onForwardClick,verify:()=>this.searchSuper.selection.isSelecting&&!this.noForwards,withSelection:!0},{icon:"download",text:"MediaViewer.Context.Download",onClick:()=>pe.Z.onDownloadClick(this.message,this.noForwards),verify:()=>!this.searchSuper.selection.isSelecting&&pe.Z.canDownload(this.message,void 0,this.noForwards)},{icon:"download",text:"Message.Context.Selection.Download",onClick:()=>pe.Z.onDownloadClick(this.selectedMessages,this.noForwards),verify:()=>this.searchSuper.selection.isSelecting&&pe.Z.canDownload(this.selectedMessages,void 0,this.noForwards),withSelection:!0},{icon:"message",text:"Message.Context.Goto",onClick:this.onGotoClick,withSelection:!0},{icon:"select",text:"Message.Context.Select",onClick:this.onSelectClick,verify:()=>!this.isSelected,withSelection:!0},{icon:"select",text:"Message.Context.Selection.Clear",onClick:this.onClearSelectionClick,verify:()=>this.isSelected,withSelection:!0},{icon:"delete danger",text:"Delete",onClick:this.onDeleteClick,verify:()=>!this.searchSuper.selection.isSelecting&&this.managers.appMessagesManager.canDeleteMessage(this.message)},{icon:"delete danger",text:"Message.Context.Selection.Delete",onClick:this.onDeleteClick,verify:()=>this.searchSuper.selection.isSelecting&&!this.searchSuper.selection.selectionDeleteBtn.classList.contains("hide"),withSelection:!0}],this.element=(0,Z.b)({buttons:this.buttons,listenerSetter:this.listenerSetter}),this.element.classList.add("search-contextmenu","contextmenu"),document.getElementById("page-chats").append(this.element)}}class be{constructor(e){this.tabs={},this.prevTabId=-1,this.lazyLoadQueue=new d.Z,this.middleware=(0,m.k)(),this.historyStorage={},this.usedFromHistory={},this.loadMutex=Promise.resolve(),this.nextRates={},this.loadPromises={},this.loaded={},this.loadedChats=!1,this.firstLoad=!0,this.log=(0,n.kg)("SEARCH-SUPER"),this.monthContainers={},this.mediaTabsMap=new Map,this.asChatList=!1,this.groupByMonth=!0,this.hideEmptyTabs=!0,this.showSender=!1,this.onTransitionStart=()=>{this.container.classList.add("sliding")},this.onTransitionEnd=()=>{this.container.classList.remove("sliding")},(0,N.Z)(this,e),this.container=document.createElement("div"),this.container.classList.add("search-super"),this.listenerSetter=new oe.Z,this.searchContextMenu=new ve(this.container,this,this.listenerSetter),this.selection=new A.e(this,this.managers,this.listenerSetter);const t=this.navScrollableContainer=document.createElement("div");t.classList.add("search-super-tabs-scrollable","menu-horizontal-scrollable","sticky");const i=this.navScrollable=new h.v7(t);i.container.classList.add("search-super-nav-scrollable");const s=this.nav=document.createElement("nav");s.classList.add("search-super-tabs","menu-horizontal-div"),this.tabsMenu=s,i.container.append(s);for(const e of this.mediaTabs){const t=document.createElement("div");t.classList.add("menu-horizontal-div-item");const i=document.createElement("span"),s=document.createElement("i");i.append((0,p.ag)(e.name)),i.append(s),t.append(i),(0,c.Z)(t),this.tabsMenu.append(t),this.mediaTabsMap.set(e.type,e),e.menuTab=t}let a;this.tabsContainer=document.createElement("div"),this.tabsContainer.classList.add("search-super-tabs-container","tabs-container"),L.Z&&(this.swipeHandler=(0,E.Z)({element:this.tabsContainer,onSwipe:(e,t,i)=>{e*=-1;const s=this.selectTab.prevId(),n=Array.from(this.tabsMenu.children);let o;if(e>0){for(let e=s+1;e<n.length;++e)if(!n[e].classList.contains("hide")){o=e;break}}else for(let e=s-1;e>=0;--e)if(!n[e].classList.contains("hide")){o=e;break}void 0!==o&&(a=function(e){const t=e=>{(0,_.Z)(e)};let i=2;const s=()=>{--i||e.removeEventListener("touchmove",t,{capture:!0})};return e.addEventListener("touchmove",t,{capture:!0,passive:!1}),e.addEventListener("touchend",s,{once:!0}),s}(this.tabsContainer),this.selectTab(o))},verifyTouchTarget:e=>!(0,f.Z)(e.target,"scrollable-x")}));for(const e of this.mediaTabs){const t=document.createElement("div");t.classList.add("search-super-container-"+e.type,"tabs-tab");const i=document.createElement("div");i.classList.add("search-super-content-"+e.type),t.append(i),this.tabsContainer.append(t),this.tabs[e.inputFilter]=i,e.contentTab=i}this.container.append(t,this.tabsContainer),this.searchGroupMedia=new o.z(!1,"messages",!0),this.scrollable.onScrolledBottom=()=>{this.mediaTab.contentTab&&this.canLoadMediaTab(this.mediaTab)&&this.load(!0)},this.selectTab=(0,r.X)(this.tabsMenu,this.tabsContainer,((e,t,i)=>{if(this.prevTabId===e&&!this.skipScroll)return void this.scrollable.scrollIntoViewNew({element:this.container,position:"start",startCallback:this.scrollStartCallback});const s=this.mediaTabs[e];this.onChangeTab&&this.onChangeTab(s);const n=this.mediaTab;if(this.mediaTab=s,-1!==this.prevTabId&&i&&this.onTransitionStart(),this.skipScroll)this.skipScroll=!1;else{const e=this.container.offsetTop;let t=this.scrollable.scrollTop;if(t<e&&(this.scrollable.scrollIntoViewNew({element:this.container,position:"start",startCallback:this.scrollStartCallback}),t=e),n.scroll={scrollTop:t,scrollHeight:this.scrollable.scrollHeight},void 0===s.scroll){const e=this.container.getBoundingClientRect(),i=this.container.parentElement.getBoundingClientRect(),n=e.y-i.y;t>n&&(s.scroll={scrollTop:n,scrollHeight:0})}if(s.scroll){const e=n.scroll.scrollTop-s.scroll.scrollTop;e&&(s.contentTab.style.transform=`translateY(${e}px)`)}}-1===this.prevTabId||s.contentTab.childElementCount||this.load(!0),this.prevTabId=e}),(()=>{this.scrollable.onScroll(),void 0!==this.mediaTab.scroll&&(this.mediaTab.contentTab.style.transform="",this.scrollable.scrollTop=this.mediaTab.scroll.scrollTop),a&&(a(),a=void 0),this.onTransitionEnd()}),void 0,i,this.listenerSetter),(0,F.fc)(this.tabsContainer,(e=>{this.selection.isSelecting&&((0,_.Z)(e),this.selection.toggleByElement((0,f.Z)(e.target,"search-super-item")))}),{capture:!0,passive:!1,listenerSetter:this.listenerSetter});const l=(e,t,i,s)=>ge(this,void 0,void 0,(function*(){const n=(0,f.Z)(s.target,e);if(!n)return;const a=+n.dataset.mid;if(!a)return void this.log.warn("no messageId by click on target:",n);const o=n.querySelector(".media-spoiler-container");if(o)return void(0,he.kN)({event:s,mediaSpoiler:o});const r=n.dataset.peerId.toPeerId(),d=Array.from(this.tabs[i].querySelectorAll("."+t)).map((t=>{const i=(0,f.Z)(t,e);return{element:t,mid:+i.dataset.mid,peerId:i.dataset.peerId.toPeerId()}})),l=d.findIndex((e=>e.mid===a&&e.peerId===r)),c=yield this.managers.appMessagesManager.getMessageByPeer(r,a);(new D.Z).setSearchContext(this.copySearchContext(i)).openMedia({message:c,target:d[l].element,fromRight:0,reverse:!1,prevTargets:d.slice(0,l),nextTargets:d.slice(l+1)})}));(0,F.fc)(this.tabs.inputMessagesFilterPhotoVideo,l.bind(null,"grid-item","grid-item","inputMessagesFilterPhotoVideo"),{listenerSetter:this.listenerSetter}),(0,F.fc)(this.tabs.inputMessagesFilterDocument,l.bind(null,"document-with-thumb","media-container","inputMessagesFilterDocument"),{listenerSetter:this.listenerSetter}),this.mediaTab=this.mediaTabs[0],(0,u.ZP)((()=>{this.lazyLoadQueue.lock()}),(()=>{this.lazyLoadQueue.unlockAndRefresh()}),this.listenerSetter)}filterMessagesByType(e,t){return(0,X.Z)(t,e,e.length)}processEmptyFilter({message:e,searchGroup:t}){const i=[],n=s.default.addDialogNew({peerId:e.peerId,container:t.list,avatarSize:"bigger",loadPromises:i}),a=s.default.setLastMessageN({dialog:{_:"dialog",peerId:e.peerId},lastMessage:e,dialogElement:n,highlightWord:this.searchContext.query});return i.push(a),Promise.all(i).then(ce.Z)}processPhotoVideoFilter({message:e,promises:t,middleware:i}){return ge(this,void 0,void 0,(function*(){const s=(0,Q.Z)(e,!0),n=document.createElement("div");let a;n.classList.add("grid-item");const o=(0,z.Z)(s,200,200);if(a="photo"!==s._?yield(yield(0,le.Z)({doc:s,message:e,container:n,boxWidth:0,boxHeight:0,lazyLoadQueue:this.lazyLoadQueue,middleware:i,onlyPreview:!0,withoutPreloader:!0,noPlayButton:!0,photoSize:o})).thumb:yield(0,de.Z)({photo:s,message:e,container:n,boxWidth:0,boxHeight:0,lazyLoadQueue:this.lazyLoadQueue,middleware:i,withoutPreloader:!0,noBlur:!0,size:o}),e.media.pFlags.spoiler){const e=yield(0,he.ZP)({animationGroup:"chat",media:s,middleware:i,width:140,height:140,multiply:.3});n.append(e)}return[a.images.thumb,a.images.full].filter(Boolean).forEach((e=>{e.classList.add("grid-item-media")})),t.push(a.loadPromises.thumb),{element:n,message:e}}))}processDocumentFilter({message:e,inputFilter:t}){return ge(this,void 0,void 0,(function*(){const i=(0,Q.Z)(e,!0),s=this.showSender||["voice","round"].includes(i.type),n=yield(0,re.Z)({message:e,withTime:!s,fontWeight:400,voiceAsMusic:!0,showSender:s,searchContext:this.copySearchContext(t),lazyLoadQueue:this.lazyLoadQueue,autoDownloadSize:0,getSize:()=>320});return["audio","voice","round"].includes(i.type)&&n.classList.add("audio-48"),{message:e,element:n}}))}processUrlFilter({message:e,promises:t,middleware:i}){var s;return ge(this,void 0,void 0,(function*(){let n=null===(s=e.media)||void 0===s?void 0:s.webpage;if(!n){const t=e.totalEntities?e.totalEntities.find((e=>"messageEntityUrl"===e._||"messageEntityTextUrl"===e._)):null;let i,s,a;if(t)a=e.message.slice(t.offset,t.offset+t.length);else{const t=(0,K.Z)(e.message);if(!t)return;i=t[0]}i="messageEntityTextUrl"===(null==t?void 0:t._)?t.url:i||a,s=i;const o=e.message===i;i.match(/^(ftp|http|https):\/\//)||(s="https://"+i,i=i.includes("@")?i:"https://"+i),s=new URL(s).hostname,n={_:"webPage",url:i,display_url:s,id:"",hash:0},o||(n.description=e.message)}if("webPageEmpty"===n._)return;const a=document.createElement("div");a.classList.add("preview"),n.photo?(0,de.Z)({container:a,message:null,photo:n.photo,boxWidth:0,boxHeight:0,withoutPreloader:!0,lazyLoadQueue:this.lazyLoadQueue,middleware:i,size:(0,z.Z)(n.photo,60,60,!1),loadPromises:t,noBlur:!0}):(a.classList.add("empty"),(0,H.Z)(a,(0,V.Z)(n.title||n.display_url||n.description||n.url,!0)));const o=(0,G.Z)(n),r=(0,j.Z)(n),d=(0,x.Z)((0,$.ZP)(n.url||"")).firstElementChild;if(d instanceof HTMLAnchorElement)try{d.innerText=decodeURIComponent(d.href)}catch(e){}r.firstChild&&r.append("\n"),r.append(d),this.showSender&&r.append("\n",yield(0,q.Z)(e)),o.textContent||o.append((0,W.Z)(n.display_url.split("/",1)[0]));const l=new T.ZP({title:o,titleRight:(0,Y.Z)(e),subtitle:r,havePadding:!0,clickable:!0,noRipple:!0});return l.applyMediaElement(a,"big"),l.container.innerText.trim().length?{message:e,element:l.container}:void 0}))}performSearchResult(e,t,i=!0){return ge(this,void 0,void 0,(function*(){const s=[],n=t.contentTab,a=[],o=this.middleware.get();let r,d=t.inputFilter;yield(0,u.e9)(),"inputMessagesFilterPhotoVideo"===d&&this.searchContext.query.trim()?(d="inputMessagesFilterEmpty",r=this.searchGroupMedia,n.append(r.container)):"inputMessagesFilterEmpty"===d&&(r=this.searchGroups.messages);const l={elemsToAppend:s,inputFilter:d,message:void 0,middleware:o,promises:a,searchGroup:r};let c;switch(d){case"inputMessagesFilterEmpty":c=this.processEmptyFilter;break;case"inputMessagesFilterPhotoVideo":c=this.processPhotoVideoFilter;break;case"inputMessagesFilterVoice":case"inputMessagesFilterRoundVoice":case"inputMessagesFilterMusic":case"inputMessagesFilterDocument":c=this.processDocumentFilter;break;case"inputMessagesFilterUrl":c=this.processUrlFilter}if(c){c=c.bind(this);const t=e.map((e=>ge(this,void 0,void 0,(function*(){try{return l.message=e,yield c(l)}catch(t){this.log.error("error rendering filter",d,l,e,t)}})))),i=(yield Promise.all(t)).filter(Boolean);s.push(...i)}if(r&&r.list.childElementCount&&r.setActive(),this.loadMutex&&a.push(this.loadMutex),!a.length||(yield Promise.all(a),o())){if(s.length){const e=i?"append":"prepend";s.forEach((t=>{var i;const{element:s,message:n}=t,a=this.getMonthContainerByTimestamp(this.groupByMonth?n.date:0,d);s.classList.add("search-super-item"),s.dataset.mid=""+n.mid,s.dataset.peerId=""+n.peerId,a.items[e](s),(null===(i=this.selection)||void 0===i?void 0:i.isSelecting)&&this.selection.toggleElementCheckbox(s,!0)}))}this.afterPerforming("inputMessagesFilterEmpty"===d?1:s.length,n)}}))}afterPerforming(e,t){if(t){const i=t.parentElement;if(Array.from(i.children).slice(1).forEach((e=>{e.remove()})),!e&&!t.childElementCount){const e=document.createElement("div");e.innerText="Nothing interesting here yet...",e.classList.add("position-center","text-center","content-empty","no-select"),i.append(e)}}}loadChats(){const e=new Set,t=this.middleware.get();for(const e in this.searchGroups){const t=this.searchGroups[e];this.tabs.inputMessagesFilterEmpty.append(t.container),t.clear()}const i=this.searchContext.query;if(i){const n=(t,n,o=!1)=>{t.map((t=>{if(e.has(t))return;e.add(t);const{dom:i}=s.default.addDialogNew({peerId:t,container:n.list,avatarSize:"abitbigger",autonomous:n.autonomous});return{dom:i,peerId:t}})).filter(Boolean).forEach((({dom:e,peerId:t})=>ge(this,void 0,void 0,(function*(){const s=yield this.managers.appPeersManager.getPeer(t);if(o&&(s.participants_count||s.participants)){const s=new RegExp(`(${(0,O.Z)(i)}|${(0,O.Z)((0,C.ZP)(i))})`,"gi");e.titleSpan.innerHTML=e.titleSpan.innerHTML.replace(s,"<i>$1</i>"),e.lastMessageSpan.append(yield(0,J.Z)(t.toChatId()))}else if(t===a.Z.myId)e.lastMessageSpan.append((0,p.ag)("Presence.YourChat"));else{let i=yield this.managers.appPeersManager.getPeerUsername(t);if(i)i="@"+i;else{const e=yield this.managers.appUsersManager.getUser(t);e&&e.phone&&(i="+"+(0,P.u)(e.phone).formatted)}e.lastMessageSpan.textContent=i}})))),n.toggle()},o=e=>{if(t())return e};return Promise.all([this.managers.appUsersManager.getContactsPeerIds(i,!0,void 0,10).then(o).then((e=>{e&&n(e,this.searchGroups.contacts,!0)})),this.managers.appUsersManager.searchContacts(i,20).then(o).then((e=>{if(e&&(n(e.my_results,this.searchGroups.contacts,!0),n(e.results,this.searchGroups.globalContacts),this.searchGroups.globalContacts.container.classList.add("is-short"),this.searchGroups.globalContacts.nameEl.lastElementChild!==this.searchGroups.globalContacts.nameEl.firstElementChild&&this.searchGroups.globalContacts.nameEl.lastElementChild.remove(),this.searchGroups.globalContacts.list.childElementCount>3)){const e=document.createElement("div");e.classList.add("search-group__show-more");const t=new p.ZP.IntlElement({key:"Separator.ShowMore"});e.append(t.element),this.searchGroups.globalContacts.nameEl.append(e),(0,F.fc)(e,(()=>{const e=this.searchGroups.globalContacts.container.classList.toggle("is-short");t.key=e?"Separator.ShowMore":"Separator.ShowLess",t.update()}))}})),this.managers.dialogsStorage.getDialogs({query:i,offsetIndex:0,limit:20,filterId:0}).then(o).then((e=>{e&&n(e.dialogs.map((e=>e.peerId)),this.searchGroups.contacts,!0)}))])}if(this.searchContext.peerId||this.searchContext.minDate)return Promise.resolve();{const e=(e=!0)=>ae.Z.getState().then((i=>{t()&&(this.searchGroups.recent.list.replaceChildren(),i.recentSearch.slice(0,20).forEach((e=>ge(this,void 0,void 0,(function*(){const{dom:t}=s.default.addDialogNew({peerId:e,container:this.searchGroups.recent.list,meAsSaved:!0,avatarSize:"abitbigger",autonomous:!0});t.lastMessageSpan.append(yield e.isUser()?(0,ee.Z)(yield this.managers.appUsersManager.getUser(e.toUserId())):(0,J.Z)(e.toChatId()))})))),i.recentSearch.length?e&&this.searchGroups.recent.setActive():this.searchGroups.recent.clear())}));return Promise.all([this.managers.appUsersManager.getTopPeers("correspondents").then((e=>{if(!t())return;const i=e.findIndex((e=>e.id===a.Z.myId));-1!==i&&(e=e.slice()).splice(i,1),e.forEach((e=>{const{dom:t}=s.default.addDialogNew({peerId:e.id,container:this.searchGroups.people.list,onlyFirstName:!0,avatarSize:"bigger",autonomous:!1,noIcons:this.searchGroups.people.noIcons});t.subtitleEl.remove()})),this.searchGroups.people.toggle()})),e()])}}loadMembers(e){return ge(this,void 0,void 0,(function*(){const t="members"===e.type?this.searchContext.peerId.toChatId():void 0,i="groups"===e.type?this.searchContext.peerId.toUserId():void 0,n=this.middleware.get();let a;const o=a=>ge(this,void 0,void 0,(function*(){if(this.loadMutex&&(yield this.loadMutex,!n()))return;let o=this.membersList;o||(o=this.membersList=new g.Z({lazyLoadQueue:this.lazyLoadQueue,rippleEnabled:!1,managers:this.managers}),(0,F.fc)(o.list,(e=>{const t=(0,v.Z)(e.target,s.DIALOG_LIST_ELEMENT_TAG);if(!t)return;const i=t.dataset.peerId.toPeerId();let n=Promise.resolve();y.Z.isMobile&&(n=b.ZP.toggleSidebar(!1)),n.then((()=>{w.ZP.setInnerPeer({peerId:i})}))})),e.contentTab.append(o.list),this.afterPerforming(1,e.contentTab));const r=a.map((e=>{const s=i?e.id.toPeerId(!0):(0,te.Z)(e);if(!(t?s.isAnyChat():s.isUser()))return{peerId:s,rank:(0,me.Z)(e)}})).filter(Boolean),d=yield(0,ue.Z)(r,(({peerId:e})=>ge(this,void 0,void 0,(function*(){const t=yield this.managers.appPeersManager.getPeer(e);return!!n()&&!(!t||t.pFlags.deleted)}))));for(const{peerId:e,rank:t}of d)t&&o.ranks.set(e,t),o.add(e)}));if(i){const t=this.membersList?200:50;a=this.managers.appUsersManager.getCommonChats(i,t,this.nextRates[e.inputFilter]).then((i=>{if(!n())return;const s=i.chats[i.chats.length-1];return this.nextRates[e.inputFilter]=null==s?void 0:s.id,i.chats.length<t&&(this.loaded[e.inputFilter]=!0),o(i.chats)}))}else if(yield this.managers.appChatsManager.isChannel(t)){const i=this.membersList?200:50;a=this.managers.appProfileManager.getChannelParticipants(t,void 0,i,this.nextRates[e.inputFilter]).then((t=>{if(!n())return;const s=e.contentTab.firstElementChild;return this.nextRates[e.inputFilter]=(s?s.childElementCount:0)+t.participants.length,t.participants.length<i&&(this.loaded[e.inputFilter]=!0),o(t.participants)}))}else a=this.managers.appProfileManager.getChatFull(t).then((t=>{if(!n())return;this.loaded[e.inputFilter]=!0;const i=t.participants;return"chatParticipantsForbidden"!==i._?o(i.participants):void 0}));return this.loadPromises[e.inputFilter]=a.finally((()=>{n()&&(this.loadPromises[e.inputFilter]=null)}))}))}loadType(e,t,i,s){var n,a;const o=e.inputFilter;if(this.loadPromises[o])return this.loadPromises[o];if("members"===e.type||"groups"===e.type)return this.loadMembers(e);const r=null!==(n=(a=this.historyStorage)[o])&&void 0!==n?n:a[o]=[];if(!("inputMessagesFilterEmpty"!==o||r.length||(this.loadedChats||(this.loadChats(),this.loadedChats=!0),this.searchContext.query.trim()||this.searchContext.peerId||this.searchContext.minDate)))return this.loaded[o]=!0,Promise.resolve();const d=this.loadPromises[o]=Promise.resolve().then((()=>ge(this,void 0,void 0,(function*(){var n,a;if(r.length&&this.usedFromHistory[o]<r.length&&!t){const t=[];let s=Math.max(0,this.usedFromHistory[o]),n=0;do{const e=r.slice(s,s+i);s+=e.length,n+=e.length;const a=yield Promise.all(e.map((e=>this.managers.appMessagesManager.getMessageByPeer(e.peerId,e.mid))));t.push(...this.filterMessagesByType(a,o))}while(n<i&&s<r.length);return this.usedFromHistory[o]=s,this.performSearchResult(t,e).finally((()=>{setTimeout((()=>{this.scrollable.checkForTriggers()}),0)}))}const l=r.length?r[r.length-1].mid:0,c=yield this.managers.appMessagesManager.getSearch(Object.assign(Object.assign({},this.searchContext),{inputFilter:{_:o},maxId:l,limit:i,nextRate:null!==(n=(a=this.nextRates)[o])&&void 0!==n?n:a[o]=0}));if(r.push(...c.history.map((e=>({mid:e.mid,peerId:e.peerId})))),s()&&((c.history.length<i||void 0!==this.searchContext.folderId&&!c.next_rate||c.history.length===c.count)&&(this.loaded[o]=!0),this.nextRates[o]=c.next_rate,!t))return this.usedFromHistory[o]=r.length,this.loaded[o]||d.then((()=>{setTimeout((()=>{if(s()&&this.mediaTab===e){const e=this.load(!0,!0);e&&e.then((()=>{s()&&setTimeout((()=>{this.scrollable.checkForTriggers()}),0)}))}}),0)})),this.performSearchResult(this.filterMessagesByType(c.history,o),e)})))).catch((e=>{this.log.error("load error:",e)})).finally((()=>{this.loadPromises[o]=null}));return d}canLoadMediaTab(e){const t=e.inputFilter;return!this.loaded[t]||this.historyStorage[t]&&this.usedFromHistory[t]<this.historyStorage[t].length}loadFirstTime(){return ge(this,void 0,void 0,(function*(){const e=this.middleware.get(),{peerId:t,threadId:i}=this.searchContext;if(!this.hideEmptyTabs)return;const s=this.mediaTabs.filter((e=>"inputMessagesFilterEmpty"!==e.inputFilter)),n=s.map((e=>({_:e.inputFilter}))),[a,o,r]=yield Promise.all([this.managers.appMessagesManager.getSearchCounters(t,n,void 0,i),this.canViewMembers(),this.canViewGroups()]);if(!e())return;if(this.loadMutex&&(yield this.loadMutex,!e()))return;let d,l=0;s.forEach((e=>{const t=a.find((t=>t.filter._===e.inputFilter));e.menuTab.classList.toggle("hide",!t.count),e.menuTab.classList.remove("active"),t.count&&(void 0===d&&(d=e),++l)}));const c=this.mediaTabsMap.get("members");[[c,o],[this.mediaTabsMap.get("groups"),r]].forEach((([e,t])=>{e&&(e.menuTab.classList.toggle("hide",!t),t&&++l)})),o&&(d=c),this.container.classList.toggle("hide",!d),this.container.parentElement.classList.toggle("search-empty",!d),d&&(this.skipScroll=!0,this.selectTab(this.mediaTabs.indexOf(d),!1),this.navScrollableContainer.classList.toggle("hide",l<=1))}))}load(e=!1,t=!1){var i;return ge(this,void 0,void 0,(function*(){const s=this.searchContext.peerId;this.log("load",e,s,this.loadPromises);const n=this.middleware.get();if(this.firstLoad){if(yield null!==(i=this.loadFirstTimePromise)&&void 0!==i?i:this.loadFirstTimePromise=this.loadFirstTime(),!n())return;this.loadFirstTimePromise=void 0,this.firstLoad=!1}let a=e?[this.mediaTab]:this.mediaTabs.filter((e=>e!==this.mediaTab));if(a=a.filter((e=>this.canLoadMediaTab(e))),s.isUser()?(0,U.Z)(a,(e=>"members"===e.type)):(0,U.Z)(a,(e=>"groups"===e.type)),!a.length)return;const o=t?50:Math.round(3*(I.Z.height/130|0)*1.25),r=a.map((e=>this.loadType(e,t,o,n)));return Promise.all(r).catch((e=>{this.log.error("Load error all promises:",e)}))}))}getMonthContainerByTimestamp(e,t){var i;const s=new Date(1e3*e);s.setHours(0,0,0),s.setDate(1);const n=s.getTime(),a=null!==(i=this.monthContainers[t])&&void 0!==i?i:this.monthContainers[t]={};if(!(n in a)){const e=document.createElement("div");e.className="search-super-month";const i=document.createElement("div");i.classList.add("search-super-month-name");const o={month:"long"};s.getFullYear()!==(new Date).getFullYear()&&(o.year="numeric");const r=new p.ZP.IntlDateElement({date:s,options:o}).element;i.append(r),e.append(i);const d=document.createElement("div");d.classList.add("search-super-month-items"),e.append(i,d);const l=(0,B.Z)(a,"desc");let c=0;for(;c<l.length&&!(n>l[c]);++c);a[n]={container:e,items:d},(0,S.Z)(e,this.tabs[t],c)}return a[n]}canViewMembers(){const{peerId:e}=this.searchContext;if(!e.isAnyChat()||!this.mediaTabsMap.has("members"))return Promise.resolve(!1);const t=e.toChatId();return Promise.all([this.managers.appChatsManager.isBroadcast(t),this.managers.appChatsManager.hasRights(t,"view_participants"),this.managers.appChatsManager.isForum(t)]).then((([e,t,i])=>!e&&t&&(!this.searchContext.threadId||!i)))}canViewGroups(){return ge(this,void 0,void 0,(function*(){const{peerId:e}=this.searchContext;return!(!e.isUser()||!this.mediaTabsMap.has("groups"))&&!!(yield this.managers.appProfileManager.getProfile(e.toUserId())).common_chats_count}))}cleanup(){var e;this.loadPromises={},this.loaded={},this.loadedChats=!1,this.nextRates={},this.firstLoad=!0,this.prevTabId=-1,this.lazyLoadQueue.clear(),this.mediaTabs.forEach((e=>{this.usedFromHistory[e.inputFilter]=-1})),(null===(e=this.selection)||void 0===e?void 0:e.isSelecting)&&this.selection.cancelSelection(),this.middleware.clean(),this.loadFirstTimePromise=void 0,this.cleanScrollPositions(),this.membersList=void 0}cleanScrollPositions(){this.mediaTabs.forEach((e=>{e.scroll=void 0}))}cleanupHTML(e=!1){this.mediaTabs.forEach((e=>{if(e.contentTab.replaceChildren(),this.hideEmptyTabs&&(this.container.classList.add("hide"),this.container.parentElement.classList.add("search-empty")),"chats"!==e.type&&!this.historyStorage[e.inputFilter]){const t=e.contentTab.parentElement;t.querySelector(".preloader")||(0,l.y)(t,!0);const i=t.querySelector(".content-empty");i&&i.remove()}})),this.monthContainers={},this.searchGroupMedia.clear(),this.scrollable.scrollTop=0}copySearchContext(e){const t=(0,R.Z)(this.searchContext);return t.inputFilter={_:e},t.nextRate=this.nextRates[e],t}setQuery({peerId:e,query:t,threadId:i,historyStorage:s,folderId:n,minDate:a,maxDate:o}){this.searchContext={peerId:e,query:t||"",inputFilter:{_:this.mediaTab.inputFilter},threadId:i,folderId:n,minDate:a,maxDate:o},this.historyStorage=null!=s?s:{},this.cleanup()}destroy(){var e,t;this.cleanup(),this.listenerSetter.removeAll(),this.scrollable.destroy(),null===(e=this.swipeHandler)||void 0===e||e.removeListeners(),null===(t=this.selection)||void 0===t||t.cleanup(),this.scrollStartCallback=void 0,this.onChangeTab=void 0,this.selectTab=void 0,this.searchContextMenu=void 0,this.swipeHandler=void 0,this.selection=void 0}}},5644:(e,t,i)=>{"use strict";i.d(t,{Z:()=>_});var s=i(5005),n=i(3512),a=i(8805),o=i(4789),r=i(9807),d=i(2325),l=i(8763),c=i(8497),h=i(8842),u=i(3910),p=i(5565),f=i(5701),m=i(241),g=i(2738),v=i(6690),b=i(1655),y=i(5953),w=i(4064),S=i(9331),C=i(2353),L=i(2566),E=i(177),I=i(3061),P=i(8493),Z=i(7120),M=i(8050),k=i(36),T=i(5029),x=i(5994),A=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class _{constructor(e){this.container=document.createElement("div"),this.list=s.default.createChatList(),this.chatsContainer=document.createElement("div"),this.selected=new Set,this.freezed=!1,this.folderId=0,this.offsetIndex=0,this.query="",this.loadedWhat={},this.renderedPeerIds=new Set,this.peerType=["dialogs"],this.multiSelect=!0,this.rippleEnabled=!0,this.avatarSize="abitbigger",this.exceptSelf=!1,this.tempIds={},this.selfPresence="Presence.YourChat",this.needSwitchList=!1,this.design="round",this.onInput=()=>{const e=this.input.value;if(this.query!==e){(this.peerType.includes("contacts")||this.peerType.includes("dialogs"))&&(this.cachedContacts=void 0),this.peerType.includes("dialogs")&&(this.folderId=0,this.offsetIndex=0);for(const e in this.tempIds)++this.tempIds[e];this.list=s.default.createChatList(),this.promise=void 0,this.loadedWhat={},this.query=e,this.renderedPeerIds.clear(),this.needSwitchList=!0,this.getMoreResults()}},this.checkForTriggers=()=>{this.scrollable.checkForTriggers()},(0,y.Z)(this,e),this.container.classList.add("selector","selector-"+this.design);const t=(this.renderResultsFunc||this.renderResults).bind(this);if(this.renderResultsFunc=e=>A(this,void 0,void 0,(function*(){return this.needSwitchList&&(this.scrollable.splitUp.replaceWith(this.list),this.scrollable.setVirtualContainer(this.list),this.needSwitchList=!1),e=e.filter((e=>{const t=!this.renderedPeerIds.has(e);return t&&this.renderedPeerIds.add(e),t})),this.filterPeerTypeBy&&(e=yield(0,C.Z)(e,(e=>A(this,void 0,void 0,(function*(){if(e.isPeerId()&&(yield this.managers.appPeersManager.getPeer(e)))for(const t of this.filterPeerTypeBy)if(yield this.managers.appPeersManager[t](e))return!0;return!0}))))),t(e)})),this.input=document.createElement("input"),this.input.classList.add("selector-search-input"),this.placeholder?(0,d.$d)(this.input,this.placeholder,void 0,"placeholder"):(0,d.$d)(this.input,"SendMessageTo",void 0,"placeholder"),this.input.type="text",this.multiSelect){const e=new T.Z({});e.innerContainer.classList.add("selector-search-section");const t=document.createElement("div");t.classList.add("selector-search-container"),this.selectedContainer=document.createElement("div"),this.selectedContainer.classList.add("selector-search"),this.selectedContainer.append(this.input),t.append(this.selectedContainer),this.selectedScrollable=new a.ZP(t),(0,g.fc)(this.selectedContainer,(e=>{if(this.freezed)return;let t=e.target;if(t=(0,c.Z)(t,"selector-user"),!t)return;const i=t.dataset.key,s=this.chatsContainer.querySelector('[data-peer-id="'+i+'"]');s?(0,g.tH)(s):this.remove(i.toPeerId())})),e.content.append(t),this.container.append(e.container)}this.chatsContainer.classList.add("chatlist-container");const i=new T.Z({name:this.sectionNameLangPackKey,noShadow:!0});i.content.append(this.list),this.chatsContainer.append(i.container),this.scrollable=new a.ZP(this.chatsContainer),this.scrollable.setVirtualContainer(this.list),(0,g.fc)(this.chatsContainer,(e=>{const t=(0,l.Z)(e.target,"data-peer-id");if((0,u.Z)(e),!t)return;if(this.freezed)return;let i=t.dataset.peerId;if(i=i.isPeerId()?i.toPeerId():i,!this.multiSelect)return void this.add(i);this.selected.has(i)?this.remove(i):this.add(i);const s=t.querySelector("input");s.checked=!s.checked}));const n=(0,f.Z)(this.onInput,200,!1,!0);this.input.addEventListener("input",n),this.scrollable.onScrolledBottom=()=>{this.getMoreResults()},this.scrollable.container.prepend((0,k.G)()),this.container.append(this.chatsContainer),this.appendTo.append(this.container),setTimeout((()=>{const t=this.getMoreResults();e.onFirstRender&&t.then((()=>{e.onFirstRender()}))}),0)}renderSaved(){return A(this,void 0,void 0,(function*(){this.exceptSelf||this.offsetIndex||0!==this.folderId||!this.peerType.includes("dialogs")||this.query&&!(yield this.managers.appUsersManager.testSelfSearch(this.query))||(yield this.renderResultsFunc([n.Z.myId]))}))}getTempId(e){var t,i;null!==(t=(i=this.tempIds)[e])&&void 0!==t||(i[e]=0);const s=++this.tempIds[e];return{tempId:s,middleware:()=>this.tempIds[e]===s}}getMoreDialogs(){return A(this,void 0,void 0,(function*(){if(this.loadedWhat.dialogs&&this.loadedWhat.archived)return;const e=m.Z.height/56*1.25|0,{middleware:t}=this.getTempId("dialogs"),i=this.managers.dialogsStorage.getDialogs({query:this.query,offsetIndex:this.offsetIndex,limit:e,filterId:this.folderId,skipMigrated:!0});i.catch((()=>{t()&&(this.loadedWhat[this.loadedWhat.dialogs?"archived":"dialogs"]=!0)}));const s=yield i;if(!t())return;let a=s.dialogs;if(a.length){const e=(0,M.Z)(a[a.length-1])||0;if(a=a.slice(),(0,w.Z)(a,(e=>e.peerId===n.Z.myId)),this.chatRightsActions&&(a=yield(0,C.Z)(a,(e=>this.filterByRights(e.peerId))),!t()))return;if(yield this.renderSaved(),!t())return;this.offsetIndex=e}if(this.renderResultsFunc(a.map((e=>e.peerId))),s.isEnd){if(!this.loadedWhat.dialogs){if(yield this.renderSaved(),!t())return;return this.loadedWhat.dialogs=!0,this.offsetIndex=0,this.folderId=1,this.getMoreDialogs()}if(this.loadedWhat.archived=!0,!this.loadedWhat.contacts)return this.getMoreContacts()}}))}filterByRights(e){return A(this,void 0,void 0,(function*(){const t=yield this.managers.appPeersManager.getPeer(e);return e.isUser()?"send_plain"!==this.chatRightsActions[0]||(0,P.Z)(t):!!this.chatRightsActions.every((e=>(0,Z.Z)(t,e)))||void 0}))}getMoreContacts(){return A(this,void 0,void 0,(function*(){if(this.loadedWhat.contacts)return;const e=this.peerType.includes("contacts");if(!this.cachedContacts){const{middleware:t}=this.getTempId("contacts"),i=Promise.all([e?this.managers.appUsersManager.getContactsPeerIds(this.query):[],this.query?this.managers.appUsersManager.searchContacts(this.query):void 0]);i.catch((()=>{t()&&(this.loadedWhat.contacts=!0)}));const[s,a]=yield i;if(!t())return;if(a){let i=e?a.my_results.concat(a.results):a.my_results;if(this.chatRightsActions&&(i=yield(0,C.Z)(i,(e=>this.filterByRights(e))),!t()))return;this.peerType.includes("dialogs")||(i=i.filter((e=>e.isUser()))),this.cachedContacts=(0,v.Z)(s.concat(i))}else this.cachedContacts=s.slice();(0,b.Z)(this.cachedContacts,n.Z.myId)}const t=m.Z.height/56*1.25|0,i=this.cachedContacts.splice(0,t);this.renderResultsFunc(i),this.cachedContacts.length||(this.loadedWhat.contacts=!0)}))}getMoreChannelParticipants(){var e;return A(this,void 0,void 0,(function*(){if(this.loadedWhat.channelParticipants)return;const{middleware:t}=this.getTempId("channelParticipants"),i=this.managers.appProfileManager.getParticipants(this.peerId.toChatId(),{_:"channelParticipantsSearch",q:this.query},50,this.list.childElementCount);i.catch((()=>{t()&&(this.loadedWhat.channelParticipants=!0)}));const s=yield i;if(!t())return;const{participants:a}=s,o=a.map((e=>(0,L.Z)(e)));(0,b.Z)(o,n.Z.myId),this.renderResultsFunc(o);const r=null!==(e=s.count)&&void 0!==e?e:a.length;(this.list.childElementCount>=r||a.length<50)&&(this.loadedWhat.channelParticipants=!0)}))}getMoreResults(){if(this.promise)return this.promise;const e=(()=>this.peerType.includes("dialogs")&&!this.loadedWhat.archived?this.getMoreSomething("dialogs"):!this.peerType.includes("contacts")&&!this.peerType.includes("dialogs")||this.loadedWhat.contacts?this.peerType.includes("channelParticipants")&&!this.loadedWhat.channelParticipants?this.getMoreSomething("channelParticipants"):void 0:this.getMoreSomething("contacts"))();if(!e)return Promise.resolve();const t=this.promise=e.catch((e=>{console.error("get more result error",e)})).finally((()=>{this.promise===t&&(this.promise=void 0),this.checkForTriggers()}));return t}getMoreSomething(e){return{dialogs:this.getMoreDialogs,contacts:this.getMoreContacts,channelParticipants:this.getMoreChannelParticipants}[e].call(this)}renderResults(e){return A(this,void 0,void 0,(function*(){!this.peerType.includes("dialogs")&&this.loadedWhat.contacts&&(e=yield(0,C.Z)(e,(e=>this.managers.appUsersManager.isNonContactUser(e)))),e.forEach((e=>A(this,void 0,void 0,(function*(){const{dom:t}=s.default.addDialogNew({peerId:e,container:this.scrollable,rippleEnabled:this.rippleEnabled,avatarSize:this.avatarSize});if(this.multiSelect){const i=this.selected.has(e),s=new r.Z;i&&(s.input.checked=!0),t.containerEl.prepend(s.label)}let i;i=e.isAnyChat()?yield(0,E.Z)(e.toChatId()):e===n.Z.myId?(0,d.ag)(this.selfPresence):(0,I.Z)(yield this.managers.appUsersManager.getUser(e.toUserId())),t.lastMessageSpan.append(i)}))))}))}add(e,t,i=!0){var s;if(this.selected.add(e),!this.multiSelect)return void this.onChange(this.selected.size);this.query.trim()&&(this.input.value="",this.onInput());const n=document.createElement("div");n.classList.add("selector-user","scale-in");const a=new S.Z;if(a.classList.add("selector-user-avatar","tgico","avatar-32"),a.isDialog=!0,n.dataset.key=""+e,e.isPeerId()){if(void 0===t){const i=new h.Z;i.update({peerId:e.toPeerId(),dialog:!0}),t=i.element}a.updateWithOptions({peerId:e})}return t&&("string"==typeof t?n.innerHTML=t:((0,p.Z)(n,t),n.append(t))),n.insertAdjacentElement("afterbegin",a),this.selectedContainer.insertBefore(n,this.input),null===(s=this.onChange)||void 0===s||s.call(this,this.selected.size),i&&this.selectedScrollable.scrollIntoViewNew({element:this.input,position:"center"}),n}remove(e){if(!this.multiSelect)return;const t=this.selectedContainer.querySelector(`[data-key="${e}"]`);t.classList.remove("scale-in"),t.offsetWidth,t.classList.add("scale-out");const i=()=>{this.selected.delete(e),t.remove(),this.onChange&&this.onChange(this.selected.size)};x.Z.isAvailable("animations")?t.addEventListener("animationend",i,{once:!0}):i()}getSelected(){return[...this.selected]}addInitial(e){e.forEach((e=>{this.add(e,void 0,!1)})),window.requestAnimationFrame((()=>{this.selectedScrollable.scrollIntoViewNew({element:this.input,position:"center",forceDirection:o.f.Static})}))}}},8448:(e,t,i)=>{"use strict";i.d(t,{ZP:()=>D,ns:()=>F});var s=i(3442),n=i(3013),a=i(4755),o=i(4762),r=i(3512),d=i(3910),l=i(2738),c=i(3725),h=i(3699),u=i(319),p=i(8497),f=i(2325),m=i(3251),g=i(632),v=i(9966),b=i(1507),y=i(4081),w=i(5296),S=i(3228),C=i(5157),L=i(7207),E=i(130),I=i(8115),P=i(5671),Z=i(1604),M=i(7530),k=i(2312),T=i(9492),x=i(3035),A=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};function _(e=!0){const t=new s.Z({cancelable:!0,tryAgainOnFail:e});return t.construct(),e||(t.circle.setAttributeNS(null,"r","23"),t.totalLength=143.58203125),t}r.Z.addEventListener("messages_media_read",(({mids:e,peerId:t})=>{e.forEach((e=>{const i=`[data-mid="${e}"][data-peer-id="${t}"]`;Array.from(document.querySelectorAll(`audio-element.is-unread${i}, .media-round.is-unread${i}`)).forEach((e=>{e.classList.remove("is-unread")}))}))}));const F=(e,t)=>{let i,s;const n=!e.classList.contains("search-super-item"),a=(0,p.Z)(e,n?"bubbles-inner":"tabs-tab");if(a){const t=':not([data-is-outgoing="1"])',o=`.audio:not(.is-voice)${t}`;let r;if(r=e.matches(o)?[o]:[`.audio.is-voice${t}`,`.media-round${t}`],n){const e=".bubble:not(.webpage) ";r=r.map((t=>e+t))}const d=r.join(", "),l=Array.from(a.querySelectorAll(d)),c=l.indexOf(e),h=l.map((e=>({peerId:e.dataset.peerId.toPeerId(),mid:+e.dataset.mid})));i=h.slice(0,c),s=h.slice(c+1)}return(s.length&&s[0].mid<t||i.length&&i[i.length-1].mid>t)&&([i,s]=[s.reverse(),i.reverse()]),[i,s]};class D extends HTMLElement{constructor(){super(...arguments),this.withTime=!1,this.voiceAsMusic=!1,this.showSender=!1,this.listenerSetter=new h.Z}render(){var e,t,i;return A(this,void 0,void 0,(function*(){this.classList.add("audio"),this.managers=r.Z.managers,this.dataset.mid=""+this.message.mid,this.dataset.peerId=""+this.message.peerId;const s=(0,M.Z)(this.message),o="voice"===s.type,h=!this.voiceAsMusic&&o,b=this.message.pFlags.is_outgoing,F=null===(e=this.message)||void 0===e?void 0:e.uploadingFileName,D=()=>{const e=this.audio&&this.audio.readyState>=this.audio.HAVE_CURRENT_DATA?this.audio.duration:s.duration;return(0,C.Z)(0|e)};this.innerHTML='\n <div class="audio-toggle audio-ico">\n <div class="audio-play-icon">\n <div class="part one" x="0" y="0" fill="#fff"></div>\n <div class="part two" x="0" y="0" fill="#fff"></div>\n </div>\n </div>';const R=this.firstElementChild,B=document.createElement("div");B.classList.add("audio-download"),"audio"!==s.type&&this.message&&this.message.pFlags.media_unread&&this.classList.add("is-unread"),F&&(this.classList.add("is-outgoing"),this.append(B));const N=yield h?function(e){return A(this,void 0,void 0,(function*(){e.classList.add("is-voice");const t=e.message,i=(0,M.Z)(t);t.pFlags.out&&e.classList.add("is-out");let s=i.attributes.find((e=>"documentAttributeAudio"===e._)).waveform||new Uint8Array([]);s=function(e){e instanceof Uint8Array||(e=new Uint8Array(e));const t=8*e.length/5|0;if(!t)return new Uint8Array([]);let i;try{const s=new DataView(e.buffer);i=new Uint8Array(t);for(let e=0;e<t;e++){const t=5*e/8|0,n=5*e%8,a=s.getUint16(t,!0);i[e]=a>>n&31}}catch(e){i=new Uint8Array([])}return i}(s.slice(0,63));const{svg:n,container:o,availW:r}=function(e,t){const i=a.Z.isMobile?16:23,s=a.Z.isMobile?152:190,n=a.Z.isMobile?190:256,o=(0,S.Z)(t/60*n,s,n),r=Math.max(...e),d=e.length,l=Math.min(o/4|0,d);let c=0;const h=i-4;let u,p,f="";for(let t=0,s=0,n=0;t<d;++t){const a=e[t]||0;if(n+l>=d){n=n+l-d,n<(l+1)/2&&c<a&&(c=a);const e=Math.max((c*h+(r+1)/2)/(r+1),4);f+=`<rect class="audio-waveform-bar" x="${s}" y="${i-e}" width="2" height="${e}" rx="1" ry="1"></rect>`,s+=4,c=n<(l+1)/2?0:a}else c<a&&(c=a),n+=l}return f&&(u=document.createElement("div"),u.classList.add("audio-waveform"),p=document.createElementNS("http://www.w3.org/2000/svg","svg"),p.classList.add("audio-waveform-bars"),p.setAttributeNS(null,"width",""+o),p.setAttributeNS(null,"height",""+i),p.setAttributeNS(null,"viewBox",`0 0 ${o} ${i}`),p.insertAdjacentHTML("beforeend",f),u.append(p)),{svg:p,container:u,availW:o}}(s,i.duration);let c;o&&(c=o.cloneNode(!0),c.classList.add("audio-waveform-fake"),o.classList.add("audio-waveform-background"));const h=document.createElement("div");h.classList.add("audio-waveform-container"),o&&h.append(o,c);const f=document.createElement("div");if(f.classList.add("audio-time"),e.append(h,f),void 0!==e.transcriptionState){e.classList.add("can-transcribe");const t=document.createElement("div");t.classList.add("audio-to-text-button");const i=document.createElement("span");i.classList.add("tgico-transcribe");const s=document.createElement("div");s.classList.add("loader"),s.innerHTML='<svg class="audio-transcribe-outline" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 24"><rect class="audio-transcribe-outline-rect" fill="transparent" stroke-width="3" stroke-linejoin="round" rx="6" ry="6" stroke="var(--message-primary-color)" stroke-dashoffset="1" stroke-dasharray="32,68" width="32" height="24"></rect></svg>',t.append(i),t.onclick=()=>{const n=((0,p.Z)(e,"document-wrapper")||(0,p.Z)(e,"quote-text")).querySelector(".audio-transcribed-text");if(0===e.transcriptionState)if(n)n.classList.remove("hide"),i.classList.remove("tgico-transcribe"),i.classList.add("tgico-up"),e.transcriptionState=2;else{const i=e.message;if(i.pFlags.is_outgoing)return;e.transcriptionState=1,!s.parentElement&&t.append(s),(0,x.d1)().then((()=>{1===e.transcriptionState&&s.classList.add("active")})),e.managers.appMessagesManager.transcribeAudio(i).catch(u.Z)}else 2===e.transcriptionState&&(n.classList.add("hide"),i.classList.remove("tgico-up"),i.classList.add("tgico-transcribe"),e.transcriptionState=0)},e.append(t)}let m,g=n;return g||(m=new L.Z,h.append(m.container)),()=>{let t=e.audio;const s=()=>{c&&(c.style.width=t.currentTime/t.duration*100+"%")};(!t.paused||t.currentTime>0&&t.currentTime!==t.duration)&&s();const n=(0,v.Z)(s);return e.addAudioListener("timeupdate",n),e.addAudioListener("ended",n),e.addAudioListener("play",(()=>{(0,w.cK)((()=>!!t&&(s(),!t.paused)),e)})),g&&e.readyPromise.then((()=>{let i=!1,s=!1;function n(e){let i;if(e instanceof MouseEvent)i=e.offsetX;else{const t=e.target.getBoundingClientRect();i=e.targetTouches[0].pageX-t.left}const s=i/r*t.duration;t.currentTime=s}g.addEventListener("mouseleave",(t=>{i&&(e.togglePlay(void 0,!0),i=!1),s=!1})),g.addEventListener("mousemove",(e=>{s=!0,i&&n(e)})),g.addEventListener("mousedown",(s=>{s.preventDefault(),0===s.button&&(t.paused||e.togglePlay(void 0,!1),n(s),i=!0)})),g.addEventListener("mouseup",(t=>{s&&i&&(e.togglePlay(void 0,!0),i=!1)})),(0,l.fc)(g,(e=>{(0,d.Z)(e),t.paused||n(e)}))}),u.Z),!g&&m.setMedia({media:t,streamable:i.supportsStreaming,duration:i.duration}),()=>{null==g||g.remove(),g=null,t=null}}}))}(this):function(e){var t;return A(this,void 0,void 0,(function*(){const i=e.withTime,s=e.message,n=(0,M.Z)(s),a="voice"===n.type||"round"===n.type,o=document.createElement("div");o.classList.add("audio-description");const r=n.attributes.find((e=>"documentAttributeAudio"===e._));if(!a){const t=[];(null==r?void 0:r.performer)&&t.push((0,I.Z)(r.performer)),i?t.push((0,g.OD)(s.date)):t.length||t.push((0,y.Z)(n.size)),e.showSender&&t.push(yield(0,P.Z)(s)),o.append(...(0,f.A1)(t," • "))}e.insertAdjacentHTML("beforeend",'\n <div class="audio-details">\n <div class="audio-title"></div>\n <div class="audio-subtitle"><div class="audio-time"></div></div>\n </div>');const d=e.querySelector(".audio-title"),l=new m.I;l.dataset.fontWeight=e.dataset.fontWeight,l.dataset.fontSize=e.dataset.fontSize,l.dataset.sizeType=e.dataset.sizeType,l.getSize=e.getSize,a?l.append(yield(0,P.Z)(s)):(0,E.Z)(l,(0,I.Z)(null!==(t=null==r?void 0:r.title)&&void 0!==t?t:n.file_name)),d.append(l),e.showSender&&d.append((0,Z.Z)(s));const c=e.querySelector(".audio-subtitle");return c.append(o),()=>{let t=!1,i=new L.Z;i.setMedia({media:e.audio,streamable:n.supportsStreaming,duration:n.duration}),e.addAudioListener("ended",(()=>{e.classList.remove("audio-show-progress"),c.lastChild.replaceWith(o),t=!1}));const s=()=>{t||(e.classList.add("audio-show-progress"),t=!0,i&&c.lastChild.replaceWith(i.container))};return e.addAudioListener("play",s),(!e.audio.paused||e.audio.currentTime>0)&&s(),()=>{i.removeListeners(),i.container.remove(),i=null}}}))}(this),O=this.querySelector(".audio-time");O.textContent=D();const U=this.onLoad=e=>{this.onLoad=void 0;const t=this.audio=n.Z.addMedia(this.message,e),i=this.readyPromise=(0,c.Z)();this.audio.readyState>=this.audio.HAVE_CURRENT_DATA?i.resolve():this.addAudioListener("canplay",(()=>i.resolve()),{once:!0}),this.onTypeDisconnect=N();const s=()=>(0,C.Z)(0|t.currentTime)+(h?" / "+D():""),a=()=>{O.innerText=s(),R.classList.toggle("playing",!t.paused)};(!t.paused||t.currentTime>0&&t.currentTime!==t.duration)&&a(),(0,l.fc)(R,(e=>this.togglePlay(e)),{listenerSetter:this.listenerSetter}),this.addAudioListener("ended",(()=>{R.classList.remove("playing"),O.innerText=D()})),this.addAudioListener("timeupdate",(()=>{!t.currentTime&&t.paused||n.Z.isSafariBuffering(t)||(O.innerText=s())})),this.addAudioListener("pause",(()=>{R.classList.remove("playing")})),this.addAudioListener("play",a)};if(null===(t=s.thumbs)||void 0===t?void 0:t.length){const e=[],t=yield(0,T.Z)({photo:s,message:null,container:R,boxWidth:48,boxHeight:48,loadPromises:this.loadPromises,withoutPreloader:!0,lazyLoadQueue:this.lazyLoadQueue});R.style.width=R.style.height="",t.images.thumb&&e.push(t.images.thumb),t.images.full&&e.push(t.images.full),this.classList.add("audio-with-thumb"),e.forEach((e=>e.classList.add("audio-thumb")))}if(b)F&&(this.preloader=_(!1),this.preloader.attachPromise(k.Z.getUpload(F)),this.dataset.isOutgoing="1",this.preloader.attach(B,!1));else{let e=this.preloader;const t="audio"!==s.type;U(t);const a=this.load=(t,i)=>{if(this.load=void 0,!this.audio.src){if(n.Z.resolveWaitingForLoadMedia(this.message.peerId,this.message.mid,this.message.pFlags.is_scheduled),this.onDownloadInit(t),!e)if(s.supportsStreaming){let e;this.classList.add("corner-download");const i=()=>{const i=_(!1),s=(0,c.Z)();s.notifyAll({done:75,total:100}),s.catch((()=>{this.audio.pause(),n.Z.willBePlayed(void 0)})),s.cancel=()=>{s.cancel=u.Z;const e=new Error;e.type="CANCELED",s.reject(e)},i.attach(B,!1,s),e=this.addAudioListener("pause",(()=>{s.cancel()}),{once:!0}),this.onDownloadInit(t)},s=this.addAudioListener("play",i);this.readyPromise.then((()=>{this.listenerSetter.remove(s),e&&this.listenerSetter.remove(e)}))}else{e=_(),t||(this.readyPromise=(0,c.Z)());const i=()=>{this.onDownloadInit(t);const i=k.Z.downloadMediaURL({media:s});return t||i.then((()=>{this.readyPromise.resolve()})),e.attach(B,!1,i),{download:i}};e.setDownloadFunction(i),i()}this.classList.contains("corner-download")?R.append(B):this.append(B),this.classList.add("downloading"),this.readyPromise.then((()=>{this.classList.remove("downloading"),B.classList.add("downloaded"),setTimeout((()=>{B.remove()}),200),i||n.Z.willBePlayedMedia!==this.audio||(this.audio.play(),n.Z.willBePlayed(void 0))}))}};(null===(i=this.audio)||void 0===i?void 0:i.src)||(t?a(!1):(0,l.fc)(R,(()=>{a(!0)}),{once:!0,capture:!0,passive:!1,listenerSetter:this.listenerSetter}))}}))}onDownloadInit(e){e&&(n.Z.willBePlayed(this.audio),o.IS_SAFARI&&!this.audio.autoplay&&(this.audio.autoplay=!0))}togglePlay(e,t=this.audio.paused){e&&(0,d.Z)(e),t?(this.setTargetsIfNeeded(),this.audio.play().catch((()=>{}))):this.audio.pause()}setTargetsIfNeeded(){const e=!!this.searchContext;if(n.Z.setSearchContext(this.searchContext||{peerId:b.NM,inputFilter:{_:"inputMessagesFilterEmpty"},useSearch:!1})){const[t,i]=e?F(this,this.message.mid):[];n.Z.setTargets({peerId:this.message.peerId,mid:this.message.mid},t,i)}}playWithTimestamp(e){var t;null===(t=this.load)||void 0===t||t.call(this,!0),this.audio.currentTime=e,this.togglePlay(void 0,!0)}get addAudioListener(){return this.listenerSetter.add(this.audio)}disconnectedCallback(){setTimeout((()=>{this.isConnected||(this.onTypeDisconnect&&(this.onTypeDisconnect(),this.onTypeDisconnect=null),this.readyPromise&&this.readyPromise.reject(),this.listenerSetter&&(this.listenerSetter.removeAll(),this.listenerSetter=null),this.preloader&&(this.preloader=null))}),100)}}customElements.define("audio-element",D)},9331:(e,t,i)=>{"use strict";i.d(t,{Z:()=>C,C:()=>b});var s=i(3512),n=i(2738),a=i(3910),o=i(1784),r=i(6074);class d extends r.Z{constructor(e){super(Object.assign(Object.assign({},e),{loadMore:(e,t,i)=>{if(this.peerId.isAnyChat()||!t)return Promise.resolve({count:0,items:[]});const s=null==e?void 0:e.photoId;return this.managers.appPhotosManager.getUserPhotos(this.peerId,s,i).then((e=>{const t=e.photos.map((e=>({element:null,photoId:e})));return{count:e.count,items:t}}))}})),this.loadedAllUp=!0,this.peerId=e.peerId}}var l=i(2312),c=i(7030),h=i(8544);class u extends h.Z{constructor(e){super(new d({peerId:e,managers:s.Z.managers}),[]),this.onPrevClick=e=>{this.openMedia({photoId:e.photoId,target:e.element,fromRight:-1})},this.onNextClick=e=>{this.openMedia({photoId:e.photoId,target:e.element,fromRight:1})},this.onDownloadClick=()=>{l.Z.downloadToDisc({media:this.target.photo,queueId:c.ZP.chat.bubbles.lazyLoadQueue.queueId})},this.peerId=e,this.setBtnMenuToggle([{icon:"download",text:"MediaViewer.Context.Download",onClick:this.onDownloadClick}]),this.setListeners()}openMedia({photoId:e,target:t,fromRight:i=0,prevTargets:s,nextTargets:n}){const a=Object.create(null,{_openMedia:{get:()=>super._openMedia}});return o=this,r=void 0,l=function*(){if(this.setMoverPromise)return this.setMoverPromise;const o=yield this.managers.appPhotosManager.getPhoto(e),r=a._openMedia.call(this,{media:o,timestamp:o.date,fromId:this.peerId,fromRight:i,target:t,reverse:!1,prevTargets:s,nextTargets:n});return this.target.photoId=o.id,this.target.photo=o,r},new((d=void 0)||(d=Promise))((function(e,t){function i(e){try{n(l.next(e))}catch(e){t(e)}}function s(e){try{n(l.throw(e))}catch(e){t(e)}}function n(t){var n;t.done?e(t.value):(n=t.value,n instanceof d?n:new d((function(e){e(n)}))).then(i,s)}n((l=l.apply(o,r||[])).next())}));var o,r,d,l}}var p=i(5880),f=i(9931),m=i(3624),g=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};const v=({peerId:e,threadId:t})=>{let i='avatar-element[data-peer-id="'+e+'"]';t&&(i+='[data-thread-id="'+t+'"]'),Array.from(document.querySelectorAll(i)).forEach((e=>{e.update()}))};function b(e,t,i,n,a,r){return g(this,void 0,void 0,(function*(){let d=yield s.Z.managers.appProfileManager.getFullPhoto(t);if(!i()||!d)return;const l=()=>Array.from(e.querySelectorAll("img")).find((e=>!e.classList.contains("emoji")))?e:null;if(t.isAnyChat()){const e=!!n,c="inputMessagesFilterChatPhotos";if(!n&&(n=yield s.Z.managers.appMessagesManager.getSearch({peerId:t,inputFilter:{_:c},maxId:0,limit:1}).then((e=>e.history[0])),!i()))return;if(n){n.action.photo.id!==d.id&&(e||(n=s.Z.managers.appMessagesManager.generateFakeAvatarMessage(t,d)));const i=e=>e.map((e=>({element:e.element,mid:e.item.mid,peerId:e.item.peerId})));return void(new o.Z).setSearchContext({peerId:t,inputFilter:{_:c}}).openMedia({message:n,target:l(),prevTargets:a?i(a):void 0,nextTargets:r?i(r):void 0})}}if(d){!(0,p.Z)(n)&&n&&(d=yield s.Z.managers.appPhotosManager.getPhoto(n));const e=e=>e.map((e=>({element:e.element,photoId:e.item})));new u(t).openMedia({photoId:d.id,target:l(),prevTargets:a?e(a):void 0,nextTargets:r?e(r):void 0})}}))}s.Z.addEventListener("avatar_update",v),s.Z.addEventListener("peer_title_edit",(e=>g(void 0,void 0,void 0,(function*(){(yield s.Z.managers.appAvatarsManager.isAvatarCached(e.peerId))||v(e)}))));const y=new Map,w=new Set;function S(e,t){return e+(t?"_"+t:"")}class C extends HTMLElement{constructor(){super(),this.addedToQueue=!1,this.classList.add("avatar-like"),this.middlewareHelper=(0,m.k)()}disconnectedCallback(){var e;const t=S(this.peerId,this.threadId),i=y.get(t);(null==i?void 0:i.has(this))&&(i.delete(this),i.size||y.delete(t)),null===(e=this.lazyLoadQueue)||void 0===e||e.delete({div:this})}attachClickEvent(){let e=!1;(0,n.fc)(this,(t=>g(this,void 0,void 0,(function*(){if((0,a.Z)(t),e)return;const i=this.peerId;e=!0,yield b(this,this.peerId,(()=>this.peerId===i)),e=!1}))))}updateOptions(e){for(const t in e)this[t]=e[t]}updateWithOptions(e){var t;const i=this.peerId,s=this.threadId;this.updateOptions(e);const n=this.peerId,a=this.threadId;if(i===n&&s===a)return;if(this.dataset.peerId=""+n,a?this.dataset.threadId=""+a:s&&delete this.dataset.threadId,i){const e=S(i,s),t=y.get(e);t&&(t.delete(this),t.size||y.delete(e))}const o=null===(t=e.wrapOptions)||void 0===t?void 0:t.middleware;return this.middlewareHelper.destroy(),o?this.middlewareHelper=o.create():this.middlewareHelper.destroy(),this.update()}remove(){this.middlewareHelper.destroy(),super.remove()}r(e=!1){const t=(0,f.Z)({div:this,peerId:this.peerId,isDialog:this.isDialog,title:this.peerTitle,onlyThumb:e,isBig:this.isBig,threadId:this.threadId,wrapOptions:Object.assign({middleware:this.middlewareHelper.get()},this.wrapOptions||{})});return this.loadPromises&&(this.loadPromises.push(t),t.finally((()=>{this.loadPromises=void 0}))),t}update(){if(this.lazyLoadQueue){if(!w.has(this.peerId)){if(this.addedToQueue)return;this.addedToQueue=!0;const e=S(this.peerId,this.threadId);let t=y.get(e);return t||y.set(e,t=new Set),t.add(this),this.lazyLoadQueue.push({div:this,load:()=>(w.add(this.peerId),this.update())}),this.r(!0)}this.addedToQueue&&this.lazyLoadQueue.delete({div:this})}w.add(this.peerId);const e=this.r();this.addedToQueue&&e.finally((()=>{this.addedToQueue=!1}));const t=S(this.peerId,this.threadId),i=y.get(t);if(i){i.delete(this);const e=Array.from(i);y.delete(t);for(let t=0,i=e.length;t<i;++t)e[t].update()}return e}}customElements.define("avatar-element",C)},187:(e,t,i)=>{"use strict";i.d(t,{Z:()=>o});var s=i(2738),n=i(1168),a=i(6765);class o{constructor(e,t){this.container=document.createElement("div"),this.container.classList.add("avatar-edit"),this.canvas=document.createElement("canvas"),this.canvas.classList.add("avatar-edit-canvas"),this.icon=document.createElement("span"),this.icon.classList.add("tgico","tgico-cameraadd"),this.container.append(this.canvas,this.icon),(0,s.fc)(this.container,(()=>{n.Z.createPopup(a.Z,t).open(this.canvas,e)}))}clear(){this.canvas.getContext("2d").clearRect(0,0,this.canvas.width,this.canvas.height)}}},4494:(e,t,i)=>{"use strict";i.d(t,{Z:()=>a});var s=i(2325),n=i(1405);function a(e,t={}){const i=document.createElement(t.asLink?"a":t.asDiv?"div":"button");return i.className=e+(t.icon?" tgico-"+t.icon:""),t.noRipple||(t.rippleSquare&&i.classList.add("rp-square"),(0,n.Z)(i)),t.onlyMobile&&i.classList.add("only-handhelds"),t.disabled&&i.setAttribute("disabled","true"),t.text&&i.append((0,s.ag)(t.text,t.textArgs)),i}},8119:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(4494);const n=(e={})=>{const t=(0,s.Z)("btn-circle btn-corner z-depth-1"+(e.className?" "+e.className:""),e);return t.tabIndex=-1,t}},2230:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(4494);const n=(e,t={})=>(0,s.Z)("btn-icon",Object.assign({icon:e||void 0},t))},3003:(e,t,i)=>{"use strict";i.d(t,{Z:()=>v,b:()=>g});var s=i(7238),n=i(3416),a=i(3910),o=i(2738),r=i(8497),d=i(130),l=i(2325),c=i(9492),h=i(8812),u=i(8222),p=i(4762),f=i(1405);function m(e){if(e.element)return[e.separator,e.element].filter(Boolean);const{icon:t,iconDoc:i,text:s,onClick:m,checkboxField:g,noCheckboxClickListener:v}=e,b=document.createElement("div");b.className="btn-menu-item rp-overflow"+(t?" tgico-"+t:""),p.IS_MOBILE&&(0,f.Z)(b);let y=e.textElement;if(y||(y=e.textElement=s?(0,l.ag)(s,e.textArgs):document.createElement("span"),e.regularText&&(0,d.Z)(y,e.regularText)),i){const t=document.createElement("span");t.classList.add("btn-menu-item-icon"),b.append(t),e.loadPromise=(0,c.Z)({container:t,photo:i,boxWidth:24,boxHeight:24,withoutPreloader:!0,noFadeIn:!0,noBlur:!0,processUrl:e=>fetch(e).then((e=>e.text())).then((e=>{const t=u.Z.getProperty("primary-text-color"),i=(new DOMParser).parseFromString(e,"image/svg+xml").firstElementChild;return i.querySelectorAll("path").forEach((e=>{e.setAttributeNS(null,"fill",t),e.style.stroke=t,e.style.strokeWidth=".25px"})),(0,h.Z)(i.outerHTML)}))}).then((e=>e.loadPromises.thumb))}y.classList.add("btn-menu-item-text"),b.append(y);const w=!!g||!!e.keepOpen;return m&&(0,o.fc)(b,(t=>{var i;(0,a.Z)(t);const s=(0,r.Z)(t.target,"btn-menu");s&&!s.classList.contains("active")||(m(t),!1!==(null===(i=e.checkForClose)||void 0===i?void 0:i.call(e))&&(w||n.Z.close(),g&&!v&&(g.checked="radio"===g.input.type||!g.checked)))}),e.options),g&&b.append(g.label),!0===e.separator&&(e.separator=document.createElement("hr")),e.multiline&&b.classList.add("is-multiline"),[e.separator,e.element=b].filter(Boolean)}function g({listenerSetter:e,buttons:t}){const i=document.createElement("div");i.classList.add("btn-menu"),e&&t.forEach((t=>{t.options?t.options.listenerSetter=e:t.options={listenerSetter:e}}));const n=t.map(m);return i.append(...(0,s.Z)(n)),i}function v(e){return t=this,i=void 0,n=function*(){const t=g(e);return yield Promise.all(e.buttons.map((({loadPromise:e})=>e))),t},new((s=void 0)||(s=Promise))((function(e,a){function o(e){try{d(n.next(e))}catch(e){a(e)}}function r(e){try{d(n.throw(e))}catch(e){a(e)}}function d(t){var i;t.done?e(t.value):(i=t.value,i instanceof s?i:new s((function(e){e(i)}))).then(o,r)}d((n=n.apply(t,i||[])).next())}));var t,i,s,n}},5322:(e,t,i)=>{"use strict";i.d(t,{Z:()=>u,v:()=>h});var s=i(3416),n=i(3910),a=i(2738),o=i(3699),r=i(2230),d=i(3003),l=i(2353),c=i(3035);function h({el:e,onOpen:t,options:i,onClose:o}){((null==i?void 0:i.listenerSetter)?i.listenerSetter.add(e):e.addEventListener.bind(e))(a.pf,(i=>{if(!e.classList.contains("btn-menu-toggle")||(0,a.Cf)(i))return!1;if((0,n.Z)(i),e.classList.contains("menu-open"))s.Z.close();else{const n=null==t?void 0:t(i),a=()=>{const t=e.querySelector(".btn-menu");s.Z.openBtnMenu(t,o)};n instanceof Promise?n.then(a):a()}}))}function u({buttonOptions:e,listenerSetter:t,container:i,direction:s,buttons:n,onOpenBefore:a,onOpen:u,onClose:p,onCloseAfter:f}){e&&(e.asDiv=!0);const m=null!=i?i:(0,r.Z)("more",e);m.classList.add("btn-menu-toggle");const g=new o.Z;let v,b;return h({el:m,onOpen:e=>{return t=this,i=void 0,r=function*(){if(yield null==a?void 0:a(e),b)return clearTimeout(b),void(b=void 0);const t=yield(i=n,(0,l.Z)(i,(e=>{var t,i;return null===(i=null===(t=null==e?void 0:e.verify)||void 0===t?void 0:t.call(e))||void 0===i||i})));var i;if(!t.length)return;const o=v=yield(0,d.Z)({buttons:t,listenerSetter:g});o.classList.add(s),yield null==u?void 0:u(e,o),m.append(o),yield(0,c.d1)()},new((o=void 0)||(o=Promise))((function(e,s){function n(e){try{d(r.next(e))}catch(e){s(e)}}function a(e){try{d(r.throw(e))}catch(e){s(e)}}function d(t){var i;t.done?e(t.value):(i=t.value,i instanceof o?i:new o((function(e){e(i)}))).then(n,a)}d((r=r.apply(t,i||[])).next())}));var t,i,o,r},options:{listenerSetter:t},onClose:()=>{null==p||p(),b=window.setTimeout((()=>{null==f||f(),b=void 0,g.removeAll(),n.forEach((e=>e.element=void 0)),v.remove()}),300)}}),m}},1175:(e,t,i)=>{"use strict";i.d(t,{zp:()=>Ot,O3:()=>jt,ZP:()=>$t,ZK:()=>qt});var s=i(5432),n=i(3512),a=i(1655),o=i(6519),r=i(4484),d=i(9331),l=i(1507),c=i(7625),h=i(54),u=i(4993);class p{constructor(e,t,i){this.container=document.createElement("div"),this.container.classList.add("bubbles-group"),this.chat=e,this.groups=t,this.items=[],this.dateTimestamp=i,this.offset=0}createAvatar(e){if(this.avatarLoadPromise)return this.avatarLoadPromise;if("messageService"===e._)return;this.avatarContainer=document.createElement("div"),this.avatarContainer.classList.add("bubbles-group-avatar-container"),++this.offset;const t=e.fwd_from,i=e.fwdFromId,s=e.from_id&&"peerChannel"===e.from_id._&&e.fromId===i,a=this.chat.peerId;this.avatar=new d.Z,this.avatar.classList.add("bubbles-group-avatar","user-avatar","avatar-40");const o=(t&&(a===n.Z.myId||a===l.hj)||s?i:e.fromId)||l.NM,r=this.avatar.updateWithOptions({lazyLoadQueue:this.chat.bubbles.lazyLoadQueue,peerId:o,peerTitle:!i&&t&&t.from_name?t.from_name:void 0});return this.avatarLoadPromise=r,this.avatarContainer.append(this.avatar),this.container.append(this.avatarContainer),this.avatarLoadPromise}get firstTimestamp(){return this.firstItem.timestamp}get firstMid(){return this.firstItem.mid}get firstItem(){return this.items[this.items.length-1]}get lastTimestamp(){return this.lastItem.timestamp}get lastMid(){return this.lastItem.mid}get lastItem(){return this.items[0]}updateClassNames(){const e=this.items,t=e.length;if(!t)return;const i=e[t-1].bubble;if(1===e.length)return void i.classList.add("is-group-first","is-group-last");i.classList.remove("is-group-last"),i.classList.add("is-group-first");for(let i=1,s=t-1;i<s;++i)e[i].bubble.classList.remove("is-group-last","is-group-first");const s=e[0].bubble;s.classList.remove("is-group-first"),s.classList.add("is-group-last")}insertItem(e){const{items:t}=this;(0,o.Z)(t,e,this.groups.sortGroupItemsKey),e.group=this,1===t.length&&this.groups.insertGroup(this)}removeItem(e){(0,a.Z)(this.items,e),this.items.length||(0,a.Z)(this.groups.groups,this),e.group=void 0}mount(e){if(!this.groups.groups.includes(this)||!this.items.length)return void(this.mounted&&this.onItemUnmount());const{offset:t,items:i}=this,{length:s}=i;(0,c.Z)(i,((e,i)=>{this.mountItem(e,s-1-i,t)})),e&&this.updateClassNames(),this.onItemMount()}mountItem(e,t=this.items.indexOf(e),i=this.offset){e.mounted||((0,r.Z)(e.bubble,this.container,i+t),e.mounted=!0)}unmountItem(e){e.mounted&&(e.bubble.remove(),e.mounted=!1,this.onItemUnmount())}onItemMount(){if(this.mounted)return;const e=this.chat.bubbles.getDateContainerByTimestamp(this.dateTimestamp/1e3),t=this.groups.groups.filter((e=>e.dateTimestamp===this.dateTimestamp)),i=t.length,s=t.indexOf(this),n=t.slice(s+1).reduce(((e,t)=>e+(t.mounted?0:1)),0);(0,r.Z)(this.container,e.container,jt+i-1-s-n),this.mounted=!0}onItemUnmount(){this.mounted&&(this.items.length?this.updateClassNames():(this.container.remove(),this.chat.bubbles.deleteEmptyDateGroups(),this.mounted=!1))}}class f{constructor(e){this.chat=e,this.itemsArr=[],this.itemsMap=new Map,this.groups=[],this.newGroupDiff=121,this.sortItemsKey="scheduled"===e.type?"timestamp":"mid",this.sortGroupsKey="scheduled"===e.type?"lastTimestamp":"lastMid",this.sortGroupItemsKey="groupMid"}removeItem(e){var t;null===(t=e.group)||void 0===t||t.removeItem(e),this.removeItemFromCache(e)}removeAndUnmountBubble(e){const t=this.getItemByBubble(e);if(!t)return e.parentElement&&e.remove(),!1;const i=this.itemsArr,s=i.indexOf(t),n=this.getSiblingsAtIndex(s,i),a=t.group;this.removeItem(t);const o=new Set;a&&(a.unmountItem(t),o.add(a));const[r,d]=n;if(r&&d&&this.canItemsBeGrouped(r,d)&&r.group!==d.group){const e=d.group;this.f(d.group.items),e.onItemUnmount(),o.add(r.group),this.groupUngrouped()}return this.mountUnmountGroups(Array.from(o)),!0}mountUnmountGroups(e){const[t,i]=(0,h.Z)(e,(e=>!!e.items.length));i.forEach((e=>{e.onItemUnmount()})),t.forEach((e=>{e.mount(!0)}))}f(e,t=0,i=e.length){for(;t<i;++t){const s=e[t];s.mounted=!1,s.group.removeItem(s),--i,--t}}getItemByBubble(e){return this.itemsMap.get(e)}getLastGroup(){return this.groups[0]}changeBubbleMid(e,t){const i=this.getItemByBubble(e);i&&(i.mid=t,(0,a.Z)(this.itemsArr,i),this.insertItemToArray(i,this.itemsArr))}changeItemBubble(e,t){this.itemsMap.delete(e.bubble),e.bubble=t,this.itemsMap.set(t,e)}changeBubbleByBubble(e,t){const i=this.getItemByBubble(e);i&&this.changeItemBubble(i,t)}canItemsBeGrouped(e,t){return!(!(t.fromId===e.fromId&&Math.abs(t.timestamp-e.timestamp)<=this.newGroupDiff&&e.dateTimestamp===t.dateTimestamp)||e.single||t.single||e.message.pFlags.out!==t.message.pFlags.out||this.chat.isAllMessagesForum&&(0,u.Z)(e.message,!0)!==(0,u.Z)(t.message,!0)||e.message.pFlags.out&&e.message.fromId!==n.Z.myId)}getSiblingsAtIndex(e,t){return[t[e-1],t[e+1]]}findGroupSiblingByItem(e,t){t=t.slice();const i=this.insertItemToArray(e,t);return this.findGroupSiblingInItems(e,t,i)}findGroupSiblingInItems(e,t,i=t.indexOf(e),s=t.length){const n=t[i-1];let a;if((null==n?void 0:n.group)&&this.canItemsBeGrouped(e,n))a=n;else for(let n=i+1;n<s;++n){const i=t[n];if(!this.canItemsBeGrouped(e,i))break;i.group&&(a=i)}return a}addItemToGroup(e,t){t.insertItem(e),this.addItemToCache(e)}insertItemToArray(e,t){return(0,o.Z)(t,e,this.sortItemsKey)}insertGroup(e){return(0,o.Z)(this.groups,e,this.sortGroupsKey)}addItemToCache(e){this.insertItemToArray(e,this.itemsArr),this.itemsMap.set(e.bubble,e)}removeItemFromCache(e){(0,a.Z)(this.itemsArr,e),this.itemsMap.delete(e.bubble)}getMessageFromId(e){let t=e.fromId;return t===n.Z.myId&&e.peerId===n.Z.myId&&e.fwdFromId===t&&(t=t.toPeerId(!0)),t}createItem(e,t){const i=!("message"===t._||t.action&&Ot.has(t.action._)),{mid:s,date:n}=t,{dateTimestamp:a}=this.chat.bubbles.getDateForDateContainer(n);return{mid:s,groupMid:"scheduled"===this.chat.type?+`${(1e3*n-a)/1e3}.${s}`:s,fromId:this.getMessageFromId(t),bubble:e,timestamp:n,dateTimestamp:a,mounted:!1,single:i,message:t}}splitSiblingsOnGrouping(e){const[t,i]=e,s=null==t?void 0:t.group;if(null==i||i.group,!s)return;const n=s.items,a=n.indexOf(t)+1,o=n.length;if(a===o)return;const r=[s];return this.f(n,a,o),r}prepareForGrouping(e,t){if(this.getItemByBubble(e))return;const i=this.createItem(e,t);this.addItemToCache(i)}groupUngrouped(){var e;const t=this.itemsArr,i=t.length,s=new Set;for(let n=0;n<i;++n){const a=t[n];if(a.group)continue;let o=!0;const r=this.getSiblingsAtIndex(n,t),d=this.findGroupSiblingInItems(a,t,n,i),l=null!==(e=null==d?void 0:d.group)&&void 0!==e?e:(o=!1,new p(this.chat,this,a.dateTimestamp));if(s.add(l),l.insertItem(a),!o){const e=this.splitSiblingsOnGrouping(r);e&&e.forEach((e=>s.add(e)))}}return s}cleanup(){this.itemsArr=[],this.groups=[],this.itemsMap.clear()}}var m=i(2986),g=i(4524),v=i(9298),b=i(3442),y=i(8805),w=i(5117),S=i(5814),C=i(4755),L=i(4762),E=i(2325),I=i(1405),P=i(632),Z=i(130),M=i(2559),k=i(2946),T=i(8115),x=i(8842),A=i(6700),_=i(5565),F=i(2149);const D="replies-element";n.Z.addEventListener("replies_updated",(e=>{Array.from(document.querySelectorAll(D+`[data-post-key="${e.peerId}_${e.mid}"]`)).forEach((t=>{t.message=e,t.render()}))}));class R extends HTMLElement{constructor(){super(),this.updated=!1,this.managers=n.Z.managers}init(){this.render(),this.dataset.postKey=this.message.peerId+"_"+this.message.mid,this.classList.add("replies","replies-"+this.type)}render(){const e=this.message.replies;if("footer"===this.type){let t;this.firstElementChild&&(t=this.firstElementChild),(null==e?void 0:e.recent_repliers)?(t&&!t.classList.contains("replies-footer-avatars")&&(this.replaceChildren(),t=null),this.stackedAvatars||(this.stackedAvatars=new F.Z({lazyLoadQueue:this.lazyLoadQueue,avatarSize:30}),this.stackedAvatars.container.classList.add("replies-footer-avatars")),t=this.stackedAvatars.container,this.stackedAvatars.render(e.recent_repliers.map((e=>(0,k.Z)(e))),this.loadPromises)):(t&&!t.classList.contains("tgico-comments")&&(t.remove(),t=null),t||(t=document.createElement("span"),t.classList.add("tgico-comments"))),t.parentElement||this.prepend(t),this.text||(this.text=new E.ZP.IntlElement);const i=this.text;if(e?e.replies?i.compareAndUpdate({key:"Comments",args:[e.replies]}):i.compareAndUpdate({key:"LeaveAComment"}):i.compareAndUpdate({key:"ViewInChat"}),e){let t=!1;e.replies&&void 0!==e.read_max_id&&void 0!==e.max_id&&(t=e.read_max_id<e.max_id),this.classList.toggle("is-unread",t)}let s=this.children[1];if(!s){s=document.createElement("span"),s.classList.add("replies-footer-text");const e=document.createElement("span");e.classList.add("tgico-next");const t=document.createElement("div");(0,I.Z)(t),this.append(s,e,t)}(0,_.Z)(s,i.element)}else this.classList.add("bubble-beside-button"),this.innerHTML=`<span class="tgico-commentssticker"></span><span class="replies-beside-text">${(null==e?void 0:e.replies)?(0,M.Z)(e.replies,0):""}</span>`;!e||this.updated||this.message.pFlags.is_outgoing||(this.managers.appMessagesManager.subscribeRepliesThread(this.message.peerId,this.message.mid),this.managers.appMessagesManager.updateMessage(this.message.peerId,this.message.mid,"replies_updated"),this.updated=!0),this.loadPromises&&(this.loadPromises=void 0)}}customElements.define(D,R);const B=()=>{const e=document.createElement("i");return e.classList.add("edited"),(0,E.$d)(e,"EditedMessage"),e},N=()=>(0,E.ag)("SponsoredMessage");var O;!function(e){e.setTime=e=>{var t;const{chatType:i,message:s}=e,n=new Date(1e3*s.date),a=[];let o,r;const d=!!s.pFlags.sponsored,l=!("action"in s)&&!d,c=d?void 0:(0,P.mr)(n);if(l){if(s.views){const e=s.post_author||(null===(t=s.fwd_from)||void 0===t?void 0:t.post_author),i=document.createElement("span");i.classList.add("post-views"),i.textContent=(0,M.Z)(s.views,1);const n=document.createElement("i");if(n.classList.add("tgico-channelviews","time-icon"),a.push(i,n),e){const t=document.createElement("span");(0,Z.Z)(t,(0,T.Z)(e)),t.insertAdjacentHTML("beforeend",",&nbsp;"),a.push(t)}}if(s.edit_date&&"scheduled"!==i&&!s.pFlags.edit_hide&&a.unshift(o=B()),"pinned"!==i&&s.pFlags.pinned){const e=document.createElement("i");e.classList.add("tgico-pinnedchat","time-icon"),a.unshift(e)}}else d&&a.push(r=N());c&&a.push(c);let h=d?void 0:(0,P.xE)(n);l&&(h+=(s.edit_date&&!s.pFlags.edit_hide?`\nEdited: ${(0,P.xE)(new Date(1e3*s.edit_date))}`:"")+(s.fwd_from?`\nOriginal: ${(0,P.xE)(new Date(1e3*s.fwd_from.date))}`:""));const u=document.createElement("span");u.classList.add("time","tgico"),u.append(...a);const p=document.createElement("div");p.classList.add("inner","tgico"),h&&(p.title=h);let f=a;return o&&(f[f.indexOf(o)]=B()),r&&(f[f.indexOf(r)]=N()),f=f.map((e=>e instanceof HTMLElement&&!e.classList.contains("i18n")&&!e.classList.contains("reactions")?e.cloneNode(!0):e)),c&&(f[f.length-1]=(0,P.mr)(n)),p.append(...f),u.append(p),u},e.renderReplies=({bubble:e,bubbleContainer:t,message:i,messageDiv:s,loadPromises:n,lazyLoadQueue:a})=>{const o=!e.classList.contains("sticker")&&!e.classList.contains("emoji-big")&&!e.classList.contains("round"),r=new R;return r.message=i,r.type=o?"footer":"beside",r.loadPromises=n,r.lazyLoadQueue=a,r.init(),t.prepend(r),o},e.setReply=({chat:e,bubble:t,bubbleContainer:i,message:s})=>{return a=this,o=void 0,d=function*(){const a=!i;a&&(i=t.querySelector(".bubble-content"));const o=a?i.querySelector(".reply"):null;if(!s.reply_to_mid)return null==o||o.remove(),void t.classList.remove("is-reply");const r=s.reply_to.reply_to_peer_id?(0,k.Z)(s.reply_to.reply_to_peer_id):e.peerId,d=yield n.Z.managers.appMessagesManager.getMessageByPeer(r,s.reply_to_mid);let l,c;if(d){const e=d.fwdFromId;c=s.fwdFromId&&s.fwdFromId===e?s.fwdFromId:d.fromId||e,l=new x.Z({peerId:c,dialog:!1,onlyFirstName:!1,plainText:!1}).element}else n.Z.managers.appMessagesManager.fetchMessageReplyTo(s),e.bubbles.needUpdate.push({replyToPeerId:r,replyMid:s.reply_to_mid,mid:s.mid}),l=(0,E.ag)("Loading");const{container:h,fillPromise:u}=(0,A.Z)(l,void 0,e.animationGroup,d,e.isAnyGroup?c:void 0);return yield u,o?(o.classList.contains("floating-part")&&h.classList.add("floating-part"),o.replaceWith(h)):i.append(h),t.classList.add("is-reply"),h},new((r=void 0)||(r=Promise))((function(e,t){function i(e){try{n(d.next(e))}catch(e){t(e)}}function s(e){try{n(d.throw(e))}catch(e){t(e)}}function n(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r((function(e){e(n)}))).then(i,s)}n((d=d.apply(a,o||[])).next())}));var a,o,r,d}}(O||(O={}));var U=i(2153),H=i(3699),z=i(8448),j=i(4789),G=i(8594),V=i(3035),K=i(3725),W=i(410),$=i(252),q=i(8497),Y=i(4668),Q=i(2796),X=i(3624),J=i(3910),ee=i(2738),te=i(5705),ie=i(2359),se=i(2648),ne=i(5296),ae=i(8938),oe=i(5701),re=i(586),de=i(241),le=i(6272),ce=i(1784),he=i(9099),ue=i(2416),pe=i(8763),fe=i(5975),me=i(8939),ge=i(993),ve=i(4494),be=i(8204),ye=i(1842),we=i(8737),Se=i(8947),Ce=i(5418),Le=i(286),Ee=i(7401),Ie=i(4881);class Pe{constructor(e){this.observing=new Map,this.observingQueue=new Map,this.freezedObservingNew=!1,this.observer=new IntersectionObserver((e=>{const t=this.observing;for(let i=0,s=e.length;i<s;++i){const s=e[i],n=t.get(s.target);if(n)for(const e of n)try{e(s)}catch(e){console.error("intersection process callback error:",e)}else console.error("intersection process no callbacks:",s)}}),e)}disconnect(){this.observing.clear(),this.observingQueue.clear(),this.observer.disconnect()}toggleObservingNew(e){if(this.freezedObservingNew===e)return;this.freezedObservingNew=e;const t=this.observingQueue;if(!e&&t.size){for(const[e,i]of t)for(const t of i)this.observe(e,t);t.clear()}}has(e,t,i=this.observing){const s=i.get(e);return!(!s||!s.has(t))}observe(e,t){if(this.freezedObservingNew&&this.has(e,t))return;const i=this.freezedObservingNew?this.observingQueue:this.observing;let s=i.get(e);s&&s.has(t)||(s||(s=new Set,i.set(e,s),i===this.observing&&this.observer.observe(e)),s.add(t))}unobserve(e,t){const i=this.freezedObservingNew&&!this.has(e,t)?this.observingQueue:this.observing,s=i.get(e);s&&(s.delete(t),s.size||(i.delete(e),this.observer.unobserve(e)))}}var Ze=i(5948),Me=i(2166),ke=i(1168),Te=i(1713),xe=i(2498),Ae=i(1336),_e=i(5400),Fe=i(6239);function De(e){var t;if(!e)return!1;const i=null===(t=e.media)||void 0===t?void 0:t.document;return!(!e.pFlags.media_unread||!e.pFlags.mentioned||i&&["voice","round"].includes(i.type))}var Re=i(7530),Be=i(5990),Ne=i(2790),Oe=i(3781),Ue=i(2586),He=i(3815),ze=i(6976),je=i(3416),Ge=i(8631),Ve=i(3173),Ke=i(319),We=i(2381),$e=i(5180),qe=i(8683),Ye=i(8487),Qe=i(13),Xe=i(9259),Je=i(9405),et=i(3541),tt=i(9687),it=i(2635),st=i(6131),nt=i(9492),at=i(2887);function ot({messages:e,attachmentDiv:t,middleware:i,uploading:s,lazyLoadQueue:a,isOut:o,chat:r,loadPromises:d,autoDownload:l,managers:c=n.Z.managers,animationGroup:h}){const u=[];for(const t of e){const e=(0,Re.Z)(t,!0),i="photo"===e._?(0,tt.Z)(e,480,480):{w:e.w,h:e.h};u.push({size:i,media:e,message:t})}(0,it.Z)({container:t,items:u.map((e=>({w:e.size.w,h:e.size.h}))),maxWidth:C.Z.active.album.width,minWidth:100,spacing:2,forMedia:!0});const{width:p,height:f}=t.style,m=parseInt(p),g=parseInt(f);u.forEach(((e,s)=>{var n;const{size:r,media:u,message:p}=e,f=!!(null===(n=p.media.pFlags)||void 0===n?void 0:n.spoiler),v=t.children[s];v.dataset.mid=""+p.mid,v.dataset.peerId=""+p.peerId;const b=v.firstElementChild;let y;if(y="photo"===u._?(0,nt.Z)({photo:u,message:p,container:b,boxWidth:0,boxHeight:0,isOut:o,lazyLoadQueue:a,middleware:i,size:r,loadPromises:d,autoDownloadSize:l.photo,managers:c}):(0,at.Z)({doc:u,container:b,message:p,boxWidth:0,boxHeight:0,withTail:!1,isOut:o,lazyLoadQueue:a,middleware:i,loadPromises:d,autoDownload:l,managers:c,noAutoplayAttribute:f}),y&&(null==d||d.push(y)),f){const e=(y||Promise.resolve()).then((()=>{return e=this,t=void 0,n=function*(){if(!i())return;const{width:e,height:t}=v.style,s=+e.slice(0,-1)/100*m,n=+t.slice(0,-1)/100*g,a=yield(0,st.ZP)({media:u,animationGroup:h,middleware:i,width:s,height:n});i()&&b.append(a)},new((s=void 0)||(s=Promise))((function(i,a){function o(e){try{d(n.next(e))}catch(e){a(e)}}function r(e){try{d(n.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?i(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(o,r)}d((n=n.apply(e,t||[])).next())}));var e,t,s,n}));null==d||d.push(e)}}))}var rt=i(296);function dt(e){var t;if(!e)return;const i=null===(t=e.media)||void 0===t?void 0:t.document;return["voice","audio","video"].includes(null==i?void 0:i.type)&&i.duration||void 0}var lt=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))},ct=i(7030),ht=i(4332),ut=i(3552),pt=i(5005);class ft extends ut._{init(e){return t=this,i=void 0,n=function*(){this.container.id="poll-results-container",this.container.classList.add("chatlist-container"),this.resultsDiv=document.createElement("div"),this.resultsDiv.classList.add("poll-results"),this.scrollable.append(this.resultsDiv);const t=yield this.managers.appPollsManager.getPoll(e.media.poll.id);this.setTitle(t.poll.pFlags.quiz?"PollResults.Title.Quiz":"PollResults.Title.Poll");const i=document.createElement("h3");(0,Z.Z)(i,(0,T.Z)(t.poll.question));const s=t.results.results.map((e=>e.voters/t.results.total_voters*100));bt(s);const n=document.createDocumentFragment();t.results.results.forEach(((i,a)=>{if(!i.voters)return;const o=document.createElement("hr"),r=t.poll.answers[a],d=document.createElement("div");d.classList.add("poll-results-answer");const l=document.createElement("div");(0,Z.Z)(l,(0,T.Z)(r.text));const c=document.createElement("div");c.innerText=Math.round(s[a])+"%",d.append(l,c);const h=pt.default.createChatList();h.classList.add("poll-results-voters"),pt.default.setListClickListener(h,(()=>{ht.ZP.onCloseBtnClick()}),void 0,!0),h.style.minHeight=48*Math.min(i.voters,4)+"px",n.append(o,d,h);let u,p=4,f=!1,m=Math.max(0,i.voters-4);const g=()=>{f||(f=!0,this.managers.appPollsManager.getVotes(e,r.option,u,p).then((e=>{e.votes.forEach((e=>{const{dom:t}=pt.default.addDialogNew({peerId:e.user_id.toPeerId(!1),container:h,rippleEnabled:!1,meAsSaved:!1,avatarSize:"small"});t.lastMessageSpan.parentElement.remove()})),u&&(m=Math.max(0,m-e.votes.length),m&&v.lastElementChild.replaceWith((0,E.ag)("PollResults.LoadMore",[Math.min(20,m)]))),u=e.next_offset,p=20,m&&e.votes.length||v.remove()})).finally((()=>{f=!1})))},v=(0,ve.Z)("poll-results-more btn btn-primary btn-transparent",{icon:"down"});v.addEventListener("click",g),v.append((0,E.ag)("PollResults.LoadMore",[Math.min(20,m)])),n.append(v),g()})),this.resultsDiv.append(i,n),ht.ZP.toggleSidebar(!0).then((()=>{}))},new((s=void 0)||(s=Promise))((function(e,a){function o(e){try{d(n.next(e))}catch(e){a(e)}}function r(e){try{d(n.throw(e))}catch(e){a(e)}}function d(t){var i;t.done?e(t.value):(i=t.value,i instanceof s?i:new s((function(e){e(i)}))).then(o,r)}d((n=n.apply(t,i||[])).next())}));var t,i,s,n}}var mt=i(5157),gt=i(5994);let vt=0;const bt=e=>{const t=e.reduce(((e,t)=>e+Math.round(t)),0);if(t>100){const i=t-100,s=e.length;for(let t=0;t<i;++t){let t=-1,i=1;for(let n=0;n<s;++n){const s=e[n]%1;s>=.5&&s<i&&(i=s,t=n)}if(-1===t)return;e[t]-=i}}else if(t<100){const i=100-t,s=e.length;for(let t=0;t<i;++t){let t=-1,i=0;for(let n=0;n<s;++n){const s=e[n]%1;s<.5&&s>i&&(i=s,t=n)}if(-1===t)return;e[t]+=1-i}}};n.Z.addEventListener("poll_update",(({poll:e,results:t})=>{Array.from(document.querySelectorAll(`poll-element[poll-id="${e.id}"]`)).forEach((i=>{i.isClosed=!!e.pFlags.closed,i.performResults(t,e.chosenIndexes)}))})),C.Z.addEventListener("resize",(()=>{Et.setMaxLength(),Et.resizePolls()})),C.Z.addEventListener("changeScreen",(()=>{Et.setMaxLength()}));const yt=(e,t,i)=>{e.classList.remove("active"),clearTimeout(i),setTimeout((()=>{t(),e.remove(),wt===e&&St===t&&Ct===i&&(wt=St=null,Ct=0)}),200)};let wt,St,Ct,Lt=!1;class Et extends HTMLElement{constructor(){super(...arguments),this.isClosed=!1,this.isQuiz=!1,this.isRetracted=!1,this.isPublic=!1,this.isMultiple=!1,this.chosenIndexes=[],this.chosingIndexes=[],this.sentVote=!1,this.clickHandler=e=>{const t=(0,q.Z)(e.target,"poll-answer");if(!t)return;(0,J.Z)(e);const i=+t.dataset.index;if(this.isMultiple){t.classList.toggle("is-chosing");const e=this.chosingIndexes.indexOf(i);-1!==e?this.chosingIndexes.splice(e,1):this.chosingIndexes.push(i)}else this.sendVotes([i])}}static setMaxLength(){const e=de.Z.width<=360?de.Z.width-120:C.Z.active.poll.width;this.MAX_LENGTH=e+9+this.MAX_OFFSET+-13.7}static resizePolls(){this.MAX_LENGTH&&Array.from(document.querySelectorAll("poll-element.is-voted")).forEach((e=>{e.svgLines.forEach(((t,i)=>{e.setLineProgress(i,1)}))}))}render(){return e=this,t=void 0,s=function*(){vt||(vt=document.getElementById("poll-line").getTotalLength(),Et.setMaxLength());const{poll:e,results:t}=this.message.media;let i;this.message.pFlags.is_scheduled&&this.classList.add("disable-hover"),e.pFlags&&(this.isPublic=!!e.pFlags.public_voters,this.isQuiz=!!e.pFlags.quiz,this.isClosed=!!e.pFlags.closed,this.isMultiple=!!e.pFlags.multiple_choice,this.isClosed?(i="Chat.Poll.Type.Closed",this.classList.add("is-closed")):i=this.isQuiz?this.isPublic?"Chat.Poll.Type.Quiz":"Chat.Poll.Type.AnonymousQuiz":this.isPublic?"Chat.Poll.Type.Public":"Chat.Poll.Type.Anonymous"),this.classList.toggle("is-multiple",this.isMultiple);const s=this.isMultiple?'<span class="poll-answer-selected tgico-check"></span>':"",a=e.answers.map(((e,t)=>`\n <div class="poll-answer" data-index="${t}">\n <div class="circle-hover">\n <div class="animation-ring"></div>\n <svg class="progress-ring">\n <circle class="progress-ring__circle" cx="13" cy="13" r="9"></circle>\n </svg>\n ${s}\n </div>\n <div class="poll-answer-percents"></div>\n <div class="poll-answer-text"></div>\n <svg version="1.1" class="poll-line" style="display: none;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 485.9 35" xml:space="preserve">\n <use href="#poll-line"></use>\n </svg>\n <span class="poll-answer-selected tgico"></span>\n </div>\n `)).join("");if(this.innerHTML=`\n <div class="poll-title"></div>\n <div class="poll-desc">\n <div class="poll-type"></div>\n <div class="poll-avatars"></div>\n </div>\n ${a}`,(0,Z.Z)(this.firstElementChild,(0,T.Z)(e.question)),Array.from(this.querySelectorAll(".poll-answer-text")).forEach(((t,i)=>{(0,Z.Z)(t,(0,T.Z)(e.answers[i].text))})),this.descDiv=this.firstElementChild.nextElementSibling,this.typeDiv=this.descDiv.firstElementChild,this.avatarsDiv=this.descDiv.lastElementChild,i&&this.typeDiv.append((0,E.ag)(i)),this.isQuiz&&(this.classList.add("is-quiz"),e.close_period&&e.close_date)){const t=document.createElement("div");t.classList.add("poll-time"),this.descDiv.append(t);const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.classList.add("poll-quiz-timer"),this.quizTimer=i;const s=2,a=7,o=2*Math.PI*a,r=document.createElementNS("http://www.w3.org/2000/svg","circle");r.classList.add("poll-quiz-timer-circle"),r.setAttributeNS(null,"cx","16"),r.setAttributeNS(null,"cy","16"),r.setAttributeNS(null,"r",""+a),r.setAttributeNS(null,"stroke-width",""+s),i.append(r),this.descDiv.append(i);const d=1e3*e.close_period,l=1e3*(e.close_date-(yield n.Z.managers.timeManager.getServerTimeOffset()));this.quizInterval=window.setInterval((()=>{const e=Date.now(),i=(l-e)/d,s=(l-e)/1e3+1|0;t.textContent=(0,mt.Z)(s),s<=5&&(t.style.color="#ee545c",r.style.stroke="#ee545c"),r.style.strokeDashoffset=o+i*o,r.style.strokeDasharray=`${o} ${o}`,e>=l&&(clearInterval(this.quizInterval),t.replaceChildren(),r.style.strokeDashoffset=o,this.quizInterval=0,setTimeout((()=>{this.managers.appPollsManager.getResults(this.message)}),3e3))}),1e3)}this.answerDivs=Array.from(this.querySelectorAll(".poll-answer")),this.svgLines=Array.from(this.querySelectorAll(".poll-line")),this.numberDivs=Array.from(this.querySelectorAll(".poll-answer-percents"));const o=document.createElement("div");o.classList.add("poll-footer"),this.viewResults=document.createElement("div"),this.viewResults.className="poll-footer-button poll-view-results hide",this.viewResults.append((0,E.ag)("Chat.Poll.ViewResults")),this.votersCountDiv=document.createElement("div"),this.votersCountDiv.className="poll-votes-count",o.append(this.viewResults,this.votersCountDiv),this.append(o),this.viewResults.addEventListener("click",(e=>{(0,J.Z)(e),ht.ZP.isTabExists(ft)||ht.ZP.createTab(ft).open(this.message)})),(0,I.Z)(this.viewResults),this.isMultiple&&(this.sendVoteBtn=document.createElement("div"),this.sendVoteBtn.classList.add("poll-footer-button","poll-send-vote"),this.sendVoteBtn.append((0,E.ag)("Chat.Poll.SubmitVote")),(0,I.Z)(this.sendVoteBtn),e.chosenIndexes.length||this.votersCountDiv.classList.add("hide"),(0,ee.fc)(this.sendVoteBtn,(e=>{(0,J.Z)(e),this.chosingIndexes.length&&this.sendVotes(this.chosingIndexes).then((()=>{this.chosingIndexes.length=0,this.answerDivs.forEach((e=>{e.classList.remove("is-chosing")}))}))})),o.append(this.sendVoteBtn));const r=!(e.chosenIndexes.length||this.isClosed);r&&!this.isPublic||this.performResults(t,e.chosenIndexes,!1),r&&(this.setVotersCount(t),this.detachClickEvent=(0,ee.fc)(this,this.clickHandler))},new((i=void 0)||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}));var e,t,i,s}initQuizHint(e){if(e.solution&&e.solution_entities){const t=document.createElement("div");if(t.classList.add("tgico-tip","poll-hint"),this.descDiv.append(t),(0,ee.fc)(t,(i=>{(0,J.Z)(i),t.classList.add("active"),((e,t,i)=>{wt&&yt(wt,St,Ct);const n=document.createElement("div");n.classList.add("quiz-hint");const a=document.createElement("div");a.classList.add("container","tgico");const o=document.createElement("div");o.classList.add("text"),a.append(o),n.append(a),(0,Z.Z)(o,(0,_e.ZP)(e,{entities:t})),ct.ZP.chat.bubbles.container.append(n),n.offsetLeft,n.classList.add("active"),wt=n,St=i,Ct=window.setTimeout((()=>{yt(n,i,Ct)}),s.Z?5e3:7e3),Lt||(Lt=!0,ct.ZP.addEventListener("peer_changed",(()=>{wt&&yt(wt,St,Ct)})))})(e.solution,e.solution_entities,(()=>{t.classList.remove("active")}))})),this.sentVote){const i=e.results.find((e=>e.pFlags.correct));i&&!i.pFlags.chosen&&(0,ee.tH)(t)}}}sendVotes(e){if(this.sendVotePromise)return this.sendVotePromise;const t=this.answerDivs.filter(((t,i)=>e.includes(i)));return t.forEach((e=>{e.classList.add("is-voting")})),this.classList.add("disable-hover"),this.sentVote=!0,this.sendVotePromise=this.managers.appPollsManager.sendVote(this.message,e).then((()=>{t.forEach((e=>{e.classList.remove("is-voting")})),this.classList.remove("disable-hover")})).catch((()=>{this.sentVote=!1})).finally((()=>{this.sendVotePromise=null}))}performResults(e,t,i=!0){var s,n,a;if(gt.Z.isAvailable("animations")||(i=!1),this.isQuiz&&((null===(s=e.results)||void 0===s?void 0:s.length)||this.isClosed)){this.answerDivs.forEach(((t,i)=>{t.classList.toggle("is-correct",!!e.results[i].pFlags.correct)})),this.initQuizHint&&(this.initQuizHint(e),this.initQuizHint=null),this.quizInterval&&(clearInterval(this.quizInterval),this.quizInterval=0),(null===(n=this.quizTimer)||void 0===n?void 0:n.parentElement)&&this.quizTimer.remove();const t=this.descDiv.querySelector(".poll-time");t&&t.remove()}if(this.isClosed&&(this.classList.add("is-closed"),(0,_.Z)(this.typeDiv,(0,E.ag)("Chat.Poll.Type.Closed"))),(this.chosenIndexes.length!==t.length||this.isClosed)&&(this.isRetracted=this.chosenIndexes.length&&!t.length,this.chosenIndexes=t.slice(),this.isRetracted?this.detachClickEvent=(0,ee.fc)(this,this.clickHandler):(null===(a=this.detachClickEvent)||void 0===a||a.call(this),this.detachClickEvent=void 0)),this.chosenIndexes.length||this.isRetracted||this.isClosed){const t=e.results.map((t=>e.total_voters?t.voters/e.total_voters*100:0));this.classList.toggle("no-transition",!i),i&&(0,he.Z)({element:this,className:"",forwards:!this.isRetracted,duration:340}),(0,V.T2)((()=>{this.setResults(this.isRetracted?this.percents:t,this.chosenIndexes,i),this.percents=t,this.isRetracted=!1}))}if(this.setVotersCount(e),this.isPublic){this.isMultiple||(this.viewResults.classList.toggle("hide",!e.total_voters||!this.chosenIndexes.length),this.votersCountDiv.classList.toggle("hide",!!this.chosenIndexes.length));const t=(e.recent_voters||[]).map((e=>e.toPeerId())),i=new F.Z({avatarSize:16});i.render(t),(0,_.Z)(this.avatarsDiv,i.container)}if(this.isMultiple){const t=!!this.chosenIndexes.length,i=this.isClosed||t,s=!this.isPublic||!e.total_voters||!t&&!this.isClosed;this.sendVoteBtn.classList.toggle("hide",i),this.viewResults.classList.toggle("hide",s),this.votersCountDiv.classList.toggle("hide",!i||!s)}}setResults(e,t,i){this.svgLines.forEach((e=>e.style.display="")),this.answerDivs.forEach(((e,i)=>{e.classList.toggle("is-chosen",t.includes(i))}));const s=Math.max(...e);if(this.maxPercents=e.map((e=>e/s)),this.isRetracted)this.svgLines.forEach(((e,t)=>{this.setLineProgress(t,-1)}));else{const e=()=>{this.svgLines.forEach(((e,t)=>{this.setLineProgress(t,1)}))};i?(0,V.T2)(e):e()}let n;e=e.slice(),bt(e);const a=t=>{e.forEach(((e,i)=>{const s=n(e,t);this.numberDivs[i].innerText=s+"%"}))};if(this.isRetracted)if(n=(e,t)=>Math.round(e/10*t),i)for(let e=9,t=0;e>=0;--e,++t)setTimeout((()=>{a(e)}),34*t);else a(0);else if(n=(e,t)=>Math.round(e/10*(t+1)),i)for(let e=0;e<10;++e)setTimeout((()=>{a(e)}),34*e);else a(9);if(this.isRetracted){i&&this.classList.add("is-retracting"),this.classList.remove("is-voted");const e=()=>{this.svgLines.forEach((e=>e.style.display="none"))};i?setTimeout((()=>{this.classList.remove("is-retracting"),e()}),340):e()}else this.classList.add("is-voted")}setVotersCount(e){const t=e.total_voters||0;let i;const s=[t];i=this.isClosed?this.isQuiz?t?"Chat.Quiz.TotalVotes":"Chat.Quiz.TotalVotesResultEmpty":t?"Chat.Poll.TotalVotes1":"Chat.Poll.TotalVotesResultEmpty":this.isQuiz?t?"Chat.Quiz.TotalVotes":"Chat.Quiz.TotalVotesEmpty":t?"Chat.Poll.TotalVotes1":"Chat.Poll.TotalVotesEmpty",(0,_.Z)(this.votersCountDiv,(0,E.ag)(i,s))}setLineProgress(e,t){const i=this.svgLines[e];-1===t?(i.style.strokeDasharray="",i.style.strokeDashoffset=""):(i.style.strokeDasharray=t*this.maxPercents[e]*Et.MAX_LENGTH+", 485.9",i.style.strokeDashoffset=""+t*Et.MAX_OFFSET)}}Et.MAX_OFFSET=-46.5,Et.MAX_LENGTH=0,customElements.define("poll-element",Et);const It="֑-߿יִ-﷽ﹰ-ﻼ",Pt=(new RegExp("^[^A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿Ⰰ-﬜﷾-﹯﻽-￿]*["+It+"]"),new RegExp("["+It+"]"));var Zt=i(1564),Mt=i(6628),kt=i(5345),Tt=i(3591),xt=i(9102),At=i(1656),_t=i(1447),Ft=i(3228),Dt=i(7740),Rt=i(6853),Bt=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};const Nt=new Map([["messageActionHistoryClear",!0],["messageActionChatCreate",e=>e.pFlags.out]]),Ot=new Set;ge.Z&&Ot.add("messageActionPhoneCall");const Ut=void 0;let Ht=Ut,zt=0;const jt=3,Gt=new Error("peer changed"),Vt={1:96,2:90,3:84,4:72,5:60,6:48,7:36},Kt=Object.keys(Vt).length;function Wt(e){return Math.max(...e)}class $t{constructor(e,t){let i;this.chat=e,this.managers=t,this.unreadOut=new Set,this.needUpdate=[],this.bubbles={},this.skippedMids=new Set,this.bubblesNewByGroupedId={},this.bubblesNew={},this.dateMessages={},this.scrolledDown=!0,this.isScrollingTimeout=0,this.unreaded=new Map,this.unreadedSeen=new Set,this.preloader=null,this.messagesQueueOnRenderAdditional=null,this.firstUnreadBubble=null,this.middlewareHelper=(0,X.k)(),this.followStack=[],this.isHeavyAnimationInProgress=!1,this.isFirstLoad=!0,this.passEntities={},this.viewsMids=new Set,this.isTopPaddingSet=!1,this.renderingMessages=new Set,this.bubblesToEject=new Set,this.bubblesToReplace=new Map,this.setPeerTempId=0,this.renderNewPromises=new Set,this.extendedMediaMessages=new Set,this.unreadedObserverCallback=e=>{if(e.isIntersecting){const t=e.target,i=this.unreaded.get(t);this.onUnreadedInViewport(t,i)}},this.viewsObserverCallback=e=>{if(e.isIntersecting){const t=+e.target.dataset.mid;if(this.observer.unobserve(e.target,this.viewsObserverCallback),t)this.viewsMids.add(t),this.sendViewCountersDebounced();else{const{sponsoredMessage:e}=this,t=null==e?void 0:e.random_id;t&&(this.managers.appChatsManager.viewSponsoredMessage(this.peerId.toChatId(),t),delete e.random_id)}}},this.stickerEffectObserverCallback=e=>{if(e.isIntersecting){this.observer.unobserve(e.target,this.stickerEffectObserverCallback);const t=e.target.querySelector(".attachment");(0,G.e9)().then((()=>{(0,Ye.Z)(t)&&(0,ee.tH)(t)}))}},this.onBubblesMouseMove=e=>Bt(this,void 0,void 0,(function*(){const t=(0,q.Z)(e.target,"bubble-content");if("scheduled"===this.chat.type||!t||this.chat.selection.isSelecting||(0,q.Z)(e.target,"service")||(0,q.Z)(e.target,"bubble-beside-button"))this.unhoverPrevious();else{const e=(0,q.Z)(t,"bubble");if(!this.chat.selection.canSelectBubble(e))return void this.unhoverPrevious();let{hoverBubble:i,hoverReaction:s}=this;if(e===i)return;if(this.unhoverPrevious(),i=this.hoverBubble=e,s=this.hoverReaction,s)s.dataset.loaded&&this.setHoverVisible(s,!0);else{s=this.hoverReaction=document.createElement("div"),s.classList.add("bubble-hover-reaction");const i=document.createElement("div");i.classList.add("bubble-hover-reaction-sticker"),s.append(i),t.append(s);let n=yield this.chat.getMessage(+e.dataset.mid);if("message"!==(null==n?void 0:n._))return void this.unhoverPrevious();n=yield this.managers.appMessagesManager.getGroupsFirstMessage(n);const a=this.getMiddleware((()=>this.hoverReaction===s));Promise.all([this.managers.appReactionsManager.getAvailableReactionsByMessage(n),(0,Ce.Z)(400)]).then((([e])=>{const t=e[0];t?(0,et.ZP)({div:i,doc:t.select_animation,width:18,height:18,needUpscale:!0,middleware:a,group:this.chat.animationGroup,withThumb:!1,needFadeIn:!1}).then((({render:e})=>e)).then((e=>{(0,ae.Z)(e),e.addEventListener("firstFrame",(()=>{a()&&(s.dataset.loaded="1",this.setHoverVisible(s,!0))}),{once:!0}),(0,ee.fc)(s,(e=>{(0,J.Z)(e),this.managers.appReactionsManager.sendReaction(n,t),this.unhoverPrevious()}),{listenerSetter:this.listenerSetter})}),Ke.Z):s.remove()}))}}})),this.unhoverPrevious=()=>{const{hoverBubble:e,hoverReaction:t}=this;e&&(this.setHoverVisible(t,!1),this.hoverBubble=void 0,this.hoverReaction=void 0)},this.onBubblesClick=e=>Bt(this,void 0,void 0,(function*(){var t;let i=e.target,n=null;try{n=(0,q.Z)(i,"bubble")}catch(e){}if(!n&&!this.chat.selection.isSelecting){const e=(0,q.Z)(i,"user-avatar");if(!e)return;const t=e.dataset.peerId.toPeerId();return void(t!==l.NM?this.chat.appImManager.setInnerPeer({peerId:t}):(0,Q.Am)(E.ZP.format("HidAccount",!0)))}if(n.classList.contains("is-date")&&(0,q.Z)(i,"bubble-content")){if(n.classList.contains("is-fake")&&(n=n.previousElementSibling),n.classList.contains("is-sticky")&&!this.chatInner.classList.contains("is-scrolling"))return;for(const e in this.dateMessages)if(this.dateMessages[e].div===n){ke.Z.createPopup(m.Z,new Date(+e),this.onDatePick).show();break}return}if(!s.Z&&(0,q.Z)(i,"time"))return void this.chat.selection.toggleByElement(n);if(this.chat.selection.isSelecting&&e.isTrusted){if(n.classList.contains("service")&&void 0===n.dataset.mid)return;return(0,J.Z)(e),s.Z&&this.chat.selection.selectedText?void(this.chat.selection.selectedText=void 0):void this.chat.selection.toggleByElement((0,q.Z)(i,"grouped-item")||n)}const a=(0,q.Z)(i,"media-spoiler-container");if(a)return void(0,st.kN)({event:e,mediaSpoiler:a});const o=(0,q.Z)(i,"contact");if(o){const t=o.dataset.peerId.toPeerId();if(t)this.chat.appImManager.setInnerPeer({peerId:t});else{const t=o.querySelector(".contact-number");(0,Me.T)(t.innerText.replace(/\s/g,"")),(0,Q.bC)({langPackKey:"PhoneCopied"}),(0,J.Z)(e)}return}const r=(0,q.Z)(i,"bubble-call");if(r)return void this.chat.appImManager.callUser(this.peerId.toUserId(),r.dataset.type);if((0,q.Z)(i,"is-buy")){(0,J.Z)(e);const t=yield this.chat.getMessage(+n.dataset.mid);if(!t)return;return void ke.Z.createPopup(qe.ZP,t,yield this.managers.appPaymentsManager.getInputInvoiceByPeerId(t.peerId,t.mid))}const d=(0,Y.Z)(i,"REACTION-ELEMENT");if(d){if((0,J.Z)(e),d.classList.contains("is-inactive"))return;const t=d.parentElement,i=t.getReactionCount(d),s=t.getMessage();return void this.managers.appReactionsManager.sendReaction(s,i.reaction)}const c=(0,pe.Z)(i,"data-sticker-emoji");if(c&&1===c.parentElement.querySelectorAll("[data-sticker-emoji]").length&&n.classList.contains("emoji-big"))return void(0,et._2)({event:e,container:c,managers:this.managers,middleware:this.getMiddleware(),peerId:this.peerId});if((0,q.Z)(i,"replies")){const e=+n.dataset.mid;if(this.peerId===l.hj){const t=yield this.chat.getMessage(e),i=(0,k.Z)(t.reply_to.reply_to_peer_id),s=t.reply_to.reply_to_top_id,n=t.fwd_from.saved_from_msg_id;this.chat.appImManager.openThread({peerId:i,lastMsgId:n,threadId:s})}else{const t=yield this.chat.getMessage(e),i=yield this.managers.appMessagesManager.getMessageWithReplies(t),s=i.replies;s&&this.managers.appMessagesManager.getDiscussionMessage(this.peerId,i.mid).then((e=>{this.chat.appImManager.setInnerPeer({peerId:s.channel_id.toPeerId(!0),type:"discussion",threadId:e.mid})}))}return}const h=(0,q.Z)(i,"is-via");if(h){const t=h.querySelector(".peer-title");if(i===t||(0,fe.Z)(i,t)){const i=t.innerText+" ";return this.managers.appDraftsManager.setDraft(this.peerId,this.chat.threadId,i),void(0,J.Z)(e)}}const u=(0,q.Z)(i,"peer-title")||(0,Y.Z)(i,"AVATAR-ELEMENT")||(0,pe.Z)(i,"data-saved-from");if(u&&u!==n){i=u||i;const e=i.dataset.peerId||i.getAttribute("peer")||i.peerId,t=i.dataset.savedFrom;if("string"==typeof e||t)if(t){const[e,s]=t.split("_");if(i.classList.contains("is-receipt-link")){const t=yield this.managers.appMessagesManager.getMessageByPeer(e.toPeerId(),+s);if(t){const e=yield this.managers.appPaymentsManager.getInputInvoiceByPeerId(this.peerId,+n.dataset.mid);ke.Z.createPopup(qe.ZP,t,e,void 0,!0)}}else this.chat.appImManager.setInnerPeer({peerId:e.toPeerId(),lastMsgId:+s})}else{const t=e.toPeerId();t!==l.NM?this.chat.appImManager.setInnerPeer({peerId:t}):(0,Q.Am)(E.ZP.format("HidAccount",!0))}}else if(n.classList.contains("sticker")&&i.parentElement.classList.contains("attachment")){const e=+n.dataset.mid,i=null===(t=(yield this.chat.getMessage(e)).media)||void 0===t?void 0:t.document;(null==i?void 0:i.stickerSetInput)&&ke.Z.createPopup(v.Z,i.stickerSetInput).show()}else if(!(yield this.checkTargetForMediaViewer(i,e))&&(-1===["IMG","DIV","SPAN"].indexOf(i.tagName)&&(i=(0,Y.Z)(i,"DIV")),-1!==["DIV","SPAN"].indexOf(i.tagName))){if(i.classList.contains("goto-original")){const e=n.dataset.savedFrom,[t,i]=e.split("_");return void this.chat.appImManager.setInnerPeer({peerId:t.toPeerId(),lastMsgId:+i})}if(i.classList.contains("forward")){const e=+n.dataset.mid,t=yield this.managers.appMessagesManager.getMessageByPeer(this.peerId,e);return void ke.Z.createPopup(g.Z,{[this.peerId]:yield this.managers.appMessagesManager.getMidsByMessage(t)})}let t=!1;try{t=!!(0,q.Z)(e.target,"reply")}catch(e){}if(t&&n.classList.contains("is-reply")){const e=+n.dataset.mid;this.followStack.push(e);const t=yield this.chat.getMessage(e),i=t.reply_to.reply_to_peer_id?(0,k.Z)(t.reply_to.reply_to_peer_id):this.peerId,s=t.reply_to.reply_to_msg_id;this.chat.appImManager.setInnerPeer({peerId:i,lastMsgId:s,type:this.chat.type,threadId:this.chat.threadId})}}})),this.onScroll=(e,t,i)=>{var s,n,a,o,r;if(this.isHeavyAnimationInProgress){if(null===(s=this.sliceViewportDebounced)||void 0===s||s.clearTimeout(),this.scrolledDown&&!e)return}else null===(n=this.chat.topbar.pinnedMessage)||void 0===n||n.setCorrectIndexThrottled(this.scrollable.lastScrollDirection),null===(a=this.sliceViewportDebounced)||void 0===a||a.call(this),this.setStickyDateManually();if(t&&t.distanceToEnd<300&&this.scrolledDown)return;const d=i?0:null!==(o=null==t?void 0:t.distanceToEnd)&&void 0!==o?o:this.scrollable.getDistanceToEnd();(0!==this.scrollable.lastScrollDirection&&d>0||t||i)&&(this.isScrollingTimeout?clearTimeout(this.isScrollingTimeout):this.chatInner.classList.contains("is-scrolling")||this.chatInner.classList.add("is-scrolling"),this.isScrollingTimeout=window.setTimeout((()=>{this.chatInner.classList.remove("is-scrolling"),this.isScrollingTimeout=0}),1350+(null!==(r=null==t?void 0:t.duration)&&void 0!==r?r:0))),d<300&&(i||this.scrollable.loadedAll.bottom||this.chat.setPeerPromise||!this.peerId)?(this.container.classList.add("scrolled-down"),this.scrolledDown=!0):this.container.classList.contains("scrolled-down")&&(this.container.classList.remove("scrolled-down"),this.scrolledDown=!1)},this.processBatch=(...e)=>Bt(this,void 0,void 0,(function*(){var t,i,s;let[n,a,o]=e;const r=e=>e.filter((e=>e&&this.bubbles[e.bubble.dataset.mid]===e.bubble));n=r(n),o("messages rendered");const d=null===(t=n[0])||void 0===t?void 0:t.reverse,{groups:l,avatarPromises:c}=this.groupBubbles(n.filter((e=>e.updatePosition))),h=n.reduce(((e,t)=>{const i=performance.now(),s=t.promises.slice(),n=s.map((e=>Bt(this,void 0,void 0,(function*(){return yield e,performance.now()-i}))));return Promise.all(n).then((e=>{o.groupCollapsed("media message time",performance.now()-i,t,e),e.forEach(((e,t)=>{o("media message time",e,t,s[t])})),o.groupEnd()})),e.push(...t.promises),e}),[]);h.push(...c),o("media promises to call",h,n,this.isHeavyAnimationInProgress),yield a(Promise.all([...h,this.setUnreadDelimiter()]).catch(Ke.Z)),yield a((0,V.AD)()),o("media promises end"),n=r(n);const{restoreScroll:u,scrollSaver:p}=this.prepareToSaveScroll(d);null===(i=this.messagesQueueOnRenderAdditional)||void 0===i||i.call(this),this.ejectBubbles();for(const[e,t]of this.bubblesToReplace){if(p&&p.replaceSaved(t,e),!n.find((t=>t.bubble===e)))continue;const i=this.bubbleGroups.getItemByBubble(e);i?(i.mounted=!1,l.includes(i.group)||l.push(i.group)):this.log.error("NO ITEM BY BUBBLE",e),this.bubblesToReplace.delete(e)}this.chat.selection.isSelecting&&n.forEach((({bubble:e})=>{this.chat.selection.toggleElementCheckbox(e,!0)})),n.forEach((({message:e,bubble:t,updatePosition:i})=>{e.pFlags.local&&i&&this.chatInner[e.pFlags.sponsored?"append":"prepend"](t)})),this.bubbleGroups.mountUnmountGroups(l),null===(s=this.updatePlaceholderPosition)||void 0===s||s.call(this),null==u||u(),a((0,Ce.Z)(this.chat.setPeerPromise?1e3:0)).then((()=>a((0,G.e9)()))).then((()=>{this.lazyLoadQueue.setAllSeen()})).catch(Ke.Z)})),this.onDatePick=e=>{const t=this.peerId;this.managers.appMessagesManager.requestHistory(t,0,2,-1,e,this.chat.threadId).then((e=>{var i;(null===(i=null==e?void 0:e.messages)||void 0===i?void 0:i.length)?this.peerId===t&&this.chat.setMessageId(e.messages[0].mid):this.log.error("no history!")}))},this.log=this.chat.log,this.listenerSetter=new H.Z,this.constructBubbles(),this.batchProcessor=new kt.s({log:this.log,process:this.processBatch,possibleError:Gt}),this.bubbleGroups=new f(this.chat),this.preloader=new b.Z({cancelable:!1}),this.lazyLoadQueue=new U.Z(void 0,!0),this.lazyLoadQueue.queueId=++zt,this.listenerSetter.add(n.Z)("history_update",(({storageKey:e,sequential:t,message:i})=>Bt(this,void 0,void 0,(function*(){if(this.chat.messagesStorageKey!==e||"scheduled"===this.chat.type)return;const{mid:s}=i,o=this.bubbles[s];if(!o)return;if(this.renderNewPromises.size&&(yield Promise.all(Array.from(this.renderNewPromises))),this.messagesQueuePromise&&(yield this.messagesQueuePromise),this.bubbles[s]!==o)return;const r=this.bubbleGroups.getItemByBubble(o);if(!r)return;if(r.mid===s)return;if(t){const e=r.group,d=this.bubbleGroups.createItem(o,i),l=this.bubbleGroups.itemsArr.slice();(0,a.Z)(l,r);const c=this.bubbleGroups.findGroupSiblingByItem(d,l);if(e===(null==c?void 0:c.group)||e===this.bubbleGroups.getLastGroup()&&1===e.items.length&&d.dateTimestamp===r.dateTimestamp||this.peerId===n.Z.myId&&t&&d.dateTimestamp===r.dateTimestamp)return void this.bubbleGroups.changeBubbleMid(o,s)}this.bubbleGroups.removeAndUnmountBubble(o);const{groups:d}=this.groupBubbles([{bubble:o,message:i}]);this.bubbleGroups.mountUnmountGroups(d),this.scrollingToBubble&&this.scrollToEnd()})))),this.listenerSetter.add(n.Z)("dialog_flush",(({peerId:e})=>{this.peerId===e&&this.deleteMessagesByIds(Object.keys(this.bubbles).map((e=>+e)))})),this.listenerSetter.add(n.Z)("message_sent",(e=>Bt(this,void 0,void 0,(function*(){const{storageKey:t,tempId:i,tempMessage:s,mid:a,message:o}=e;if(this.chat.messagesStorageKey!==t)return;const r=this.bubbles,d=r[i];if(d){const e=r[i];r[a]=e,e.dataset.mid=""+a,delete r[i],(0,V.T2)((()=>{const t=+e.dataset.mid;r[t]===e&&e.classList.contains("is-outgoing")&&(e.classList.remove("is-sending","is-outgoing"),e.classList.add(this.peerId===n.Z.myId&&"scheduled"!==this.chat.type||!this.unreadOut.has(t)?"is-read":"is-sent"))}))}if(this.unreadOut.has(i)&&(this.unreadOut.delete(i),this.unreadOut.add(a)),"scheduled"===this.chat.type&&(Date.now()/1e3|0)>=s.date-10&&this.deleteMessagesByIds([a]),!d)return;let l,c;const h=o.grouped_id;if(h){l=yield this.managers.appMessagesManager.getMessagesByAlbum(h);const e=l.map((({mid:e})=>e));if(!e.length||Wt(e)!==a||r[a]!==d)return;if(r[a]!==d)return;c=Array.from(d.querySelectorAll(".grouped-item")).map((e=>+e.dataset.mid))}else l=[o],c=[i];const u=Array.from(d.querySelectorAll("reactions-element"));u.length&&u.forEach((e=>{e.changeMessage(o)})),l.forEach(((e,t)=>{var i,a,o,r,l;if(!e)return;const u=c[t],p=e.mid,f=d.querySelector(`.document-container[data-mid="${p}"]`)||d;if("message"!==e._)return;if(e.replies){const t=d.querySelector("replies-element");t&&(t.message=e,t.init())}const m=null!==(i=e.media)&&void 0!==i?i:{},g=m.document,v=m.poll,b=m.webpage;if(g){const t=f.querySelector(`.document-container[data-mid="${u}"] .document`);if(t){const i=(0,q.Z)(t,"document-container");!(null===(r=null===(o=null===(a=s.media)||void 0===a?void 0:a.document)||void 0===o?void 0:o.thumbs)||void 0===r?void 0:r.length)&&(null===(l=g.thumbs)||void 0===l?void 0:l.length)&&(0,G.e9)().then((()=>Bt(this,void 0,void 0,(function*(){const i=t.querySelector(".time"),s=yield(0,rt.Z)({message:e,fontSize:n.Z.settings.messagesTextSize});t.replaceWith(s),i&&(s.querySelector(".document")||s).append(i)})))),i&&(i.dataset.mid=""+p)}const i=f.querySelector(`audio-element[data-mid="${u}"], .document[data-doc-id="${u}"], .media-round[data-mid="${u}"]`);i&&(i instanceof z.ZP||i.classList.contains("media-round")?(i.dataset.mid=""+e.mid,delete i.dataset.isOutgoing,i.message=e,i.onLoad(!0)):(i.dataset.docId=""+g.id,i.doc=g))}else if(v){const t=f.querySelector("poll-element");t&&(t.message=e,t.setAttribute("poll-id",""+v.id),t.setAttribute("message-id",""+p))}else b&&!f.querySelector(".web")&&(0,G.e9)().then((()=>{this.safeRenderMessage(e,!0,f),this.scrollToBubbleIfLast(f)}));if(h){const e=f.querySelector(`.grouped-item[data-mid="${u}"]`)||f;e&&(e.dataset.mid=""+p)}}))})))),this.listenerSetter.add(n.Z)("message_edit",(({storageKey:e,message:t})=>Bt(this,void 0,void 0,(function*(){if(e!==this.chat.messagesStorageKey)return;const i=this.bubbles[t.mid];i&&(yield(0,G.e9)(),this.bubbles[t.mid]===i&&this.safeRenderMessage(t,!0,i))})))),this.listenerSetter.add(n.Z)("message_error",(({storageKey:e,tempId:t})=>Bt(this,void 0,void 0,(function*(){if(e!==this.chat.messagesStorageKey)return;const i=this.bubbles[t];i&&(yield(0,G.e9)(),this.bubbles[t]===i&&(i.classList.remove("is-outgoing"),i.classList.add("is-error")))})))),this.listenerSetter.add(n.Z)("message_transcribed",(({peerId:e,mid:t,text:i,pending:s})=>{if(e!==this.peerId)return;const n=this.bubbles[t];if(!n)return;const a=n.querySelector("audio-element");if(!a)return;const o=n.querySelector(".document-wrapper, .quote-text.has-document"),r=a.querySelector(".audio-to-text-button span"),d=a.querySelector(".loader");if(o&&r){let e=o.querySelector(".audio-transcribed-text");if(e){if(!s){const t=e.querySelector(".audio-transcribing-dots");null==t||t.remove()}}else if(e=document.createElement("div"),e.classList.add("audio-transcribed-text"),e.append(document.createTextNode("")),o.classList.contains("document-wrapper")?a.before(e):o.append(e),s){const t=document.createElement("span");t.classList.add("audio-transcribing-dots"),e.append(t)}i||s?i&&(e.firstChild.textContent=i):(e.replaceChildren((0,E.ag)("Chat.Voice.Transribe.Error")),e.classList.add("is-error")),r.classList.remove("tgico-transcribe"),r.classList.add("tgico-up"),!s&&d&&(d.classList.remove("active"),setTimeout((()=>{d.remove()}),300)),a.transcriptionState=2}})),this.listenerSetter.add(n.Z)("album_edit",(({peerId:e,messages:t,deletedMids:i})=>{if(e!==this.peerId)return;const s=t.map((({mid:e})=>e)),n=Wt(s.concat(Array.from(i))),a=this.bubbles[n];if(!a)return;const o=Wt(s),r=t.find((e=>e.mid===o));this.safeRenderMessage(r,!0,a)})),this.listenerSetter.add(n.Z)("messages_reactions",(e=>Bt(this,void 0,void 0,(function*(){if("scheduled"===this.chat.type)return;let t;const i=e.map((({message:e,changedResults:t})=>Bt(this,void 0,void 0,(function*(){if(this.peerId!==e.peerId)return;const i=yield this.getMountedBubble(e.mid,e);return i?{bubble:(0,q.Z)(i.bubble,"bubble"),message:e,changedResults:t}:void 0}))));(yield Promise.all(i)).filter(Boolean).forEach((({bubble:e,message:i,changedResults:s})=>{t||(t=this.createScrollSaver(!1),t.save());const n=i.peerId+"_"+i.mid,a=Se.G.get(n);if(a)for(const e of a)e.update(i,s);else{if(!i.reactions||!i.reactions.results.length)return;this.appendReactionsElementToBubble(e,i,i,s)}})),t&&t.restore()})))),this.listenerSetter.add(n.Z)("messages_downloaded",(({peerId:e,mids:t})=>Bt(this,void 0,void 0,(function*(){const i=this.getMiddleware();yield(0,G.e9)(),i()&&t.forEach((t=>{this.needUpdate;const s=[];(0,c.Z)(this.needUpdate,((i,n)=>{i.replyMid===t&&i.replyToPeerId===e&&(this.needUpdate.splice(n,1)[0],s.push(i))})),s.forEach((({mid:e,replyMid:t,replyToPeerId:s})=>Bt(this,void 0,void 0,(function*(){const n=this.bubbles[e];if(!n)return;const[a,o]=yield Promise.all([yield this.chat.getMessage(e),yield this.managers.appMessagesManager.getMessageByPeer(s,t)]);if(!i())return;let r;O.setReply({chat:this.chat,bubble:n,message:a});const d=n.querySelectorAll(".timestamp");o&&(r=dt(o))&&d.forEach((e=>{+e.dataset.timestamp<r?e.classList.remove("is-disabled"):e.removeAttribute("href")}))}))))}))})))),(0,Xe.Z)({listenTo:this.scrollable.container,listenerSetter:this.listenerSetter,findTarget:e=>{const t=e.target;return t.closest(".attachment.media-sticker-wrapper")||(0,q.Z)(t,"attachment")&&t.closest(".custom-emoji")}}),(0,ee.fc)(this.scrollable.container,this.onBubblesClick,{listenerSetter:this.listenerSetter}),this.listenerSetter.add(this.scrollable.container)("mousedown",(e=>{if(0!==e.button)return;const t=(0,Y.Z)(e.target,"CODE");if(t){(0,J.Z)(e),i=t,(0,Me.T)(i.textContent);const s=e=>{(0,J.Z)(e),(0,Q.bC)({langPackKey:"TextCopied",onClose:()=>{n()}})},n=(0,ee.fc)(window,s,{listenerSetter:this.listenerSetter,once:!0,capture:!0})}else var i})),this.stickyIntersector=new w.Z(this.scrollable.container,((e,t)=>{for(const i in this.dateMessages){const s=this.dateMessages[i];if(s.container===t){const t=s.div;t.classList.toggle("is-sticky",e),e&&(this.previousStickyDate=t);break}}this.previousStickyDate})),L.IS_SAFARI||(this.sliceViewportDebounced=(0,oe.Z)(this.sliceViewport.bind(this),3e3,!1,!0)),(0,G.ZP)((()=>{this.isHeavyAnimationInProgress=!0,this.lazyLoadQueue.lock(),i=this.getMiddleware()}),(()=>{this.isHeavyAnimationInProgress=!1,(null==i?void 0:i())&&this.lazyLoadQueue.unlockAndRefresh(),i=null}),this.listenerSetter)}constructBubbles(){const e=this.container=document.createElement("div");e.classList.add("bubbles","scrolled-down"),(this.chatInner=document.createElement("div")).classList.add("bubbles-inner"),this.setScroll(),e.append(this.scrollable.container)}attachContainerListeners(){const e=this.container;if(this.chat.contextMenu.attachTo(e),this.chat.selection.attachListeners(e,new H.Z),W.ZP&&this.listenerSetter.add(e)("dblclick",(e=>Bt(this,void 0,void 0,(function*(){const t=(0,q.Z)(e.target,"grouped-item")||(0,q.Z)(e.target,"bubble");if(t){const e=+t.dataset.mid;this.log("debug message:",yield this.chat.getMessage(e)),this.highlightBubble(t)}})))),L.IS_MOBILE){if(s.Z){const t="is-gesturing-reply",i=64,s=.75*i;let n,a,o,r=!1;(0,ue.Z)({element:e,verifyTouchTarget:e=>Bt(this,void 0,void 0,(function*(){if("pinned"===this.chat.type||this.chat.selection.isSelecting||!(yield this.chat.canSend()))return!1;if(n=(0,q.Z)(e.target,"bubble"),n){try{const e=n.parentElement.querySelector(".bubbles-group-avatar");e&&(0,be.Z)(e,n)&&(o=e)}catch(e){}[n,o].filter(Boolean).forEach((e=>{(0,he.Z)({element:e,className:t,forwards:!0,duration:250}),e.offsetLeft})),a?(a.classList.remove("is-visible"),a.style.opacity=""):(a=document.createElement("span"),a.classList.add("tgico-reply_filled","bubble-gesture-reply-icon")),n.append(a)}return!!n})),onSwipe:e=>{r=e>=s,r&&!a.classList.contains("is-visible")&&a.classList.add("is-visible"),a.style.opacity=""+Math.min(1,e/s);const t=`translateX(${-Math.max(0,Math.min(i,e))}px)`;n.style.transform=t,o&&(o.style.transform=t),(0,ze.s)()},onReset:()=>{const e=n,i=o;n=o=void 0;const s=()=>{a.parentElement===e&&(a.classList.remove("is-visible"),a.remove())};[e,i].filter(Boolean).forEach(((e,i)=>{(0,he.Z)({element:e,className:t,forwards:!1,duration:250,onTransitionEnd:0===i?s:void 0})})),(0,V.T2)((()=>{if(e.style.transform="",i&&(i.style.transform=""),r){const{mid:t}=e.dataset;this.chat.input.initMessageReply(+t),r=!1}}))},listenerOptions:{capture:!0}})}}else this.listenerSetter.add(e)("dblclick",(e=>Bt(this,void 0,void 0,(function*(){if("pinned"===this.chat.type||this.chat.selection.isSelecting||!(yield this.chat.canSend()))return;const t=e.target,i=t.classList.contains("bubble")?t:t.classList.contains("document-selection")?t.parentElement:null;if(i&&!i.classList.contains("bubble-first")){const e=+i.dataset.mid;if((yield this.chat.getMessage(e)).pFlags.is_outgoing)return;this.chat.input.initMessageReply(e)}}))))}constructPeerHelpers(){this.listenerSetter.add(n.Z)("history_append",(({storageKey:e,message:t})=>Bt(this,void 0,void 0,(function*(){e===this.chat.messagesStorageKey&&"scheduled"!==this.chat.type&&(gt.Z.isAvailable("chat_background")&&(this.updateGradient=!0),this.scrollable.loadedAll.bottom?this.renderNewMessage(t,!0):this.chat.setMessageId())})))),this.listenerSetter.add(n.Z)("history_multiappend",(e=>{this.peerId===e.peerId&&"scheduled"!==this.chat.type&&this.renderNewMessage(e)})),this.listenerSetter.add(n.Z)("history_delete",(({peerId:e,msgs:t})=>{e===this.peerId&&"scheduled"!==this.chat.type&&this.deleteMessagesByIds(Array.from(t))})),this.listenerSetter.add(n.Z)("dialog_unread",(({peerId:e})=>{e===this.peerId&&(this.chat.input.setUnreadCount(),(0,G.e9)().then((()=>{this.updateUnreadByDialog()})))})),this.listenerSetter.add(n.Z)("dialogs_multiupdate",(e=>{e.has(this.peerId)&&"scheduled"!==this.chat.type&&this.chat.input.setUnreadCount()})),this.listenerSetter.add(n.Z)("dialog_notify_settings",(e=>{this.peerId===e.peerId&&"scheduled"!==this.chat.type&&this.chat.input.setUnreadCount()})),this.listenerSetter.add(n.Z)("chat_update",(e=>Bt(this,void 0,void 0,(function*(){const{peerId:t}=this;if(t!==e.toPeerId(!0))return;const i=yield this.managers.appChatsManager.getChat(e),s=this.chatInner.classList.contains("has-rights"),n=this.chat.input.canSendPlain(),[a,o,r]=yield Promise.all([this.chat.canSend("send_messages"),this.chat.canSend("send_plain"),this.chat.canSend("embed_links")]);s===a&&n===o||(yield Promise.all([this.finishPeerChange(),this.chat.input.finishPeerChange({middleware:this.getMiddleware()})])).forEach((e=>e())),(r&&!this.chat.input.willSendWebPage||!r&&this.chat.input.willSendWebPage)&&(this.chat.input.lastUrl="",this.chat.input.onMessageInput()),!!i.pFlags.forum!==this.chat.isForum&&"chat"===this.chat.type&&(this.chat.peerId=0,this.chat.appImManager.setPeer({peerId:t}))})))),this.listenerSetter.add(n.Z)("history_reload",(e=>{if(e!==this.peerId)return;const t=(0,Ee.Z)(this.bubbles,"desc").filter((e=>e>0)),i=this.getMiddleware();this.managers.appMessagesManager.reloadMessages(this.peerId,t).then((e=>{if(!i())return;const s=[];e.forEach(((e,i)=>{const n=t[i];if(e){const t=this.bubbles[e.mid];if(!t)return;this.safeRenderMessage(e,!0,t)}else s.push(n)})),this.deleteMessagesByIds(s),this.setLoaded("top",!1),this.setLoaded("bottom",!1),this.scrollable.checkForTriggers()}))})),this.listenerSetter.add(n.Z)("settings_updated",(({key:e})=>Bt(this,void 0,void 0,(function*(){if("settings.emoji.big"===e){const e=this.getMiddleware(),t=(0,Ee.Z)(this.bubbles,"desc").map((e=>Bt(this,void 0,void 0,(function*(){const t=this.bubbles[e];if(t.classList.contains("can-have-big-emoji"))return{bubble:t,message:yield this.chat.getMessage(e)}})))),i=yield Promise.all(t);if(!e())return;i.filter(Boolean).forEach((({bubble:e,message:t})=>{this.bubbles[t.mid]===e&&this.safeRenderMessage(t,!0,e)}))}})))),this.listenerSetter.add(n.Z)("messages_views",(e=>{"scheduled"!==this.chat.type&&(0,V.T2)((()=>{let t;for(const{peerId:i,views:s,mid:n}of e){if(this.peerId!==i)continue;const e=this.bubbles[n];if(!e)continue;const a=Array.from(e.querySelectorAll(".post-views"));if(!a.length)continue;const o=(0,M.Z)(s,1);let r=!1;a.forEach((e=>{(r||e.textContent!==o)&&(t||(t=this.createScrollSaver(!0),t.save()),r=!0,e.textContent=o)}))}null==t||t.restore()}))})),this.observer=new Pe({root:this.scrollable.container}),this.sendViewCountersDebounced=(0,oe.Z)((()=>{const e=[...this.viewsMids];this.viewsMids.clear(),this.managers.appMessagesManager.incrementMessageViews(this.peerId,e)}),1e3,!1,!0),this.listenerSetter.add(n.Z)("peer_pinned_messages",(({peerId:e,mids:t,pinned:i})=>{"pinned"===this.chat.type&&e===this.peerId&&t&&(i||this.deleteMessagesByIds(t))}));const e=()=>Bt(this,void 0,void 0,(function*(){this.chat.topbar.setTitle((yield this.managers.appMessagesManager.getScheduledMessagesStorage(this.peerId)).size)}));this.listenerSetter.add(n.Z)("scheduled_new",(t=>{"scheduled"===this.chat.type&&t.peerId===this.peerId&&(this.renderNewMessage(t),e())})),this.listenerSetter.add(n.Z)("scheduled_delete",(({peerId:t,mids:i})=>{"scheduled"===this.chat.type&&t===this.peerId&&(this.deleteMessagesByIds(i),e())}))}get peerId(){return this.chat.peerId}get messagesQueuePromise(){return this.batchProcessor.queuePromise}createScrollSaver(e=!0){return new Le.Z(this.scrollable,".bubble:not(.is-date)",e)}createResizeObserver(){if(!("ResizeObserver"in window)||this.resizeObserver)return;const e=this.scrollable.container;let t=0,i=!1,s=!1,n=0,a=0,o=0;const r=()=>{const r=e.offsetHeight,d=this.scrollable.isScrolledDown;r===t||s&&d||(a+=t-r),a&&this.scrollable.setScrollTopSilently(this.scrollable.scrollTop+Math.round(a)),t=r,n=0,o=0,a=0,i=!1,s=!1},d=e=>{o&&window.cancelAnimationFrame(o),o=window.requestAnimationFrame(e?r:()=>{o=window.requestAnimationFrame(r)})};(this.resizeObserver=new ResizeObserver((e=>{if(s)return void d(!1);const o=e[0].contentRect.height;if(!t)return void(t=o);const r=t-o;let l=r+a;const c=l%1;if(l-=c,!i&&(i=!0,r<0&&this.scrollable.isScrolledDown))return a=-r,s=!0,void d(!1);if(n+=l,l){const e=this.scrollable.scrollTop+l;this.scrollable.setScrollTopSilently(e)}d(!1),a=c,t=o}))).observe(e)}destroyResizeObserver(){const e=this.resizeObserver;e&&(e.disconnect(),this.resizeObserver=void 0)}setReactionsHoverListeners(){this.listenerSetter.add(je.Z)("toggle",this.unhoverPrevious),this.listenerSetter.add(He.Z)("change",this.unhoverPrevious),this.listenerSetter.add(this.chat.selection)("toggle",this.unhoverPrevious),this.listenerSetter.add(this.container)("mousemove",this.onBubblesMouseMove)}setHoverVisible(e,t){e.parentElement&&e.parentElement.classList.toggle("hover-reaction-visible",t),(0,he.Z)({element:e,className:"is-visible",forwards:t,duration:200,onTransitionEnd:t?void 0:()=>{e.remove()},useRafs:2})}setStickyDateManually(){}getRenderedLength(){return Object.keys(this.bubbles).length-this.skippedMids.size}onUnreadedInViewport(e,t){this.unreadedSeen.add(t),this.observer.unobserve(e,this.unreadedObserverCallback),this.unreaded.delete(e),this.readUnreaded()}readUnreaded(){if(this.readPromise)return;const e=this.getMiddleware();this.readPromise=Ue.Z.getFocusPromise().then((()=>Bt(this,void 0,void 0,(function*(){if(!e())return;let t=Math.max(...Array.from(this.unreadedSeen));if(this.scrollable.loadedAll.bottom){const e=Math.max(...Object.keys(this.bubbles).map((e=>+e)));t>=e&&(t=Math.max((yield this.chat.getHistoryMaxId())||0,t))}this.unreaded.forEach(((e,i)=>{e<=t&&this.onUnreadedInViewport(i,e)}));const i=[];for(const e of this.unreadedSeen)De(yield this.chat.getMessage(e))&&i.push(e);return this.managers.appMessagesManager.readMessages(this.peerId,i),this.unreadedSeen.clear(),W.ZP&&this.log("will readHistory by maxId:",t),this.managers.appMessagesManager.readHistory(this.peerId,t,this.chat.threadId).catch((e=>{this.log.error("readHistory err:",e),this.managers.appMessagesManager.readHistory(this.peerId,t,this.chat.threadId)})).finally((()=>{e()&&(this.readPromise=void 0,this.unreadedSeen.size&&this.readUnreaded())}))}))))}checkTargetForMediaViewer(e,t,i){return Bt(this,void 0,void 0,(function*(){const s=(0,q.Z)(e,"bubble"),n=(0,q.Z)(e,"document-with-thumb");if("IMG"===e.tagName&&!e.classList.contains("emoji")&&!e.classList.contains("document-thumb")||e.classList.contains("album-item")||"VIDEO"===e.tagName&&!s.classList.contains("round")||n&&!n.querySelector(".preloader-container")||e.classList.contains("canvas-thumbnail")){const a=(0,q.Z)(e,"album-item")||(0,q.Z)(e,"document-container"),o=(a||s).querySelector(".preloader-container");if(o&&t)return(0,ee.tH)(o),void(0,J.Z)(t);(0,J.Z)(t);const r=+(a||s).dataset.mid,d=yield this.chat.getMessage(r);if(!d)return void this.log.warn("no message by messageId:",r);const l="webpage",c=s.classList.contains(l),h=n?e=>ce.Z.isMediaCompatibleForDocumentViewer(e):e=>"photo"===e._||["video","gif"].includes(e.type),u=[],p=c?[r]:(yield Promise.all(Object.keys(this.bubbles).map((e=>+e)).map((e=>Bt(this,void 0,void 0,(function*(){const t=yield this.chat.getMessage(e),i=(0,Re.Z)(t);return i&&h(i)&&e})))))).filter(Boolean).sort(((e,t)=>e-t));p.forEach((e=>{let t;n?t=".document-container":(t=".album-item video, .album-item img, .preview video, .preview img, ",t+=this.bubbles[e].classList.contains("with-media-tail")?".bubble__media-container":".attachment video, .attachment img");const i=Array.from(this.bubbles[e].querySelectorAll(t)),s=new Set;if(n)i.forEach((e=>{u.push({element:e.querySelector(".document-ico"),mid:+e.dataset.mid,peerId:this.peerId})}));else{const t=!!this.bubbles[e].querySelector(".media-container-aspecter");i.forEach((i=>{if(t&&!(0,q.Z)(i,"media-container-aspecter"))return;const n=(0,q.Z)(i,"album-item"),a=n||i.parentElement;s.has(a)||(s.add(a),u.push({element:i,mid:n?+n.dataset.mid:e,peerId:this.peerId}))}))}})),u.sort(((e,t)=>e.mid-t.mid));const f=u.findIndex((e=>e.mid===r));return W.ZP&&this.log("open mediaViewer single with ids:",p,f,u),u[f]?((new ce.Z).setSearchContext({threadId:this.chat.threadId,peerId:this.peerId,inputFilter:{_:n?"inputMessagesFilterDocument":"inputMessagesFilterPhotoVideo"},useSearch:"scheduled"!==this.chat.type&&!c,isScheduled:"scheduled"===this.chat.type}).openMedia({message:d,target:u[f].element,fromRight:0,reverse:!0,prevTargets:u.slice(0,f),nextTargets:u.slice(f+1),mediaTimestamp:i}),!0):void this.log("no target for media viewer!",e)}}))}onGoDownClick(){return Bt(this,void 0,void 0,(function*(){if(!this.followStack.length)return void this.chat.setMessageId();const e=this.getMiddleware(),t=this.followStack.slice(),i=yield Promise.all(t.map((e=>this.chat.getMessage(e))));if(!e())return;t.forEach(((e,t)=>{const s=i[t],n=this.bubbles[e];let a=!0;if(n){const e=n.getBoundingClientRect();a=de.Z.height/2>e.top}else s&&(a=!1);a&&this.followStack.splice(this.followStack.indexOf(e),1)})),this.followStack.sort(((e,t)=>t-e));const s=this.followStack.pop();this.chat.setMessageId(s)}))}getBubbleByPoint(e){const t=this.getViewportSlice(),i=t.visible["top"===e?0:t.visible.length-1];return null==i?void 0:i.element}getGroupedBubble(e){return Bt(this,void 0,void 0,(function*(){const t=yield this.managers.appMessagesManager.getMidsByAlbum(e);for(const e of t)if(this.bubbles[e]&&!this.skippedMids.has(e))return{bubble:this.bubbles[e],mid:e}}))}getBubbleGroupedItems(e){return Array.from(e.querySelectorAll(".grouped-item"))}getMountedBubble(e,t){return Bt(this,void 0,void 0,(function*(){if(void 0===t&&(t=yield this.chat.getMessage(e)),!t)return;const i=t.grouped_id;if(i){const t=yield this.getGroupedBubble(i);if(t)return t.bubble=t.bubble.querySelector(`.document-container[data-mid="${e}"]`)||t.bubble,t}const s=this.bubbles[e];return s&&!this.skippedMids.has(e)?{bubble:s,mid:e}:void 0}))}findNextMountedBubbleByMsgId(e,t){const i=(0,Ee.Z)(this.bubbles,t?"desc":"asc");let s;s=t?t=>t<e:t=>e<t;const n=i.find((e=>{var t;return!!s(e)&&!!(null===(t=this.bubbles[e])||void 0===t?void 0:t.parentElement)}));return this.bubbles[n]}loadMoreHistory(e,t=!1){if(!this.peerId||this.chat.setPeerPromise||this.isHeavyAnimationInProgress||e&&(this.getHistoryTopPromise||this.scrollable.loadedAll.top)||!e&&(this.getHistoryBottomPromise||this.scrollable.loadedAll.bottom))return;const i=Object.keys(this.bubbles).map((e=>+e)).filter((e=>e>0&&!this.skippedMids.has(e))).sort(((e,t)=>e-t));i.length||i.push(0),e?(W.ZP&&this.log("Will load more (up) history by id:",i[0],"maxId:",i[i.length-1],t),this.getHistory1(i[0],!0,void 0,void 0,t)):(W.ZP&&this.log("Will load more (down) history by id:",i[i.length-1],t),this.getHistory1(i[i.length-1],!1,!0,void 0,t))}setScroll(){this.scrollable&&this.destroyScrollable(),this.scrollable=new y.ZP(null,"IM",300),this.setLoaded("top",!1,!1),this.setLoaded("bottom",!1,!1),this.scrollable.container.append(this.chatInner),this.scrollable.onAdditionalScroll=this.onScroll,this.scrollable.onScrolledTop=()=>this.loadMoreHistory(!0),this.scrollable.onScrolledBottom=()=>this.loadMoreHistory(!1),s.Z}updateUnreadByDialog(){return Bt(this,void 0,void 0,(function*(){const e=yield this.chat.getHistoryStorage(),t=this.peerId===n.Z.myId?e.readMaxId:e.readOutboxMaxId;for(const e of this.unreadOut)if(e>0&&e<=t){const t=this.bubbles[e];if(t){if(this.unreadOut.delete(e),t.classList.contains("is-outgoing")||t.classList.contains("is-error"))continue;t.classList.remove("is-sent","is-sending","is-outgoing"),t.classList.add("is-read")}}}))}destroyBubble(e,t=+e.dataset.mid){e.middlewareHelper.destroy(),this.bubbles[t]===e&&delete this.bubbles[t],this.skippedMids.delete(t),this.firstUnreadBubble===e&&(this.firstUnreadBubble=null),this.bubbleGroups.removeAndUnmountBubble(e),this.observer&&(this.observer.unobserve(e,this.unreadedObserverCallback),this.unreaded.delete(e),this.observer.unobserve(e,this.viewsObserverCallback),this.viewsMids.delete(t),this.observer.unobserve(e,this.stickerEffectObserverCallback))}deleteMessagesByIds(e,t=!0,i){let s=!1;e.forEach((e=>{const t=this.bubbles[e];t&&(this.destroyBubble(t,e),s=!0)})),s&&(this.scrollable.ignoreNextScrollEvent(),t&&this.chat.selection.isSelecting&&this.chat.selection.deleteSelectedMids(this.peerId,e),S.Z.checkAnimations(!1,this.chat.animationGroup),this.deleteEmptyDateGroups(),i||this.scrollable.onScroll())}pollExtendedMediaMessages(){const e=Array.from(this.extendedMediaMessages);return this.managers.appMessagesManager.getExtendedMedia(this.peerId,e)}setExtendedMediaMessagesPollInterval(){!this.pollExtendedMediaMessagesPromise&&this.extendedMediaMessages.size&&(this.pollExtendedMediaMessagesPromise=(0,Ce.Z)(3e4).then((()=>this.pollExtendedMediaMessages())).then((()=>this.setExtendedMediaMessagesPollInterval())))}setTopPadding(e=this.getMiddleware()){let t,i=!1;if(!this.isTopPaddingSet&&"scheduled"!==this.chat.type){const{clientHeight:e,scrollHeight:s}=this.scrollable.container;i=e===s,i&&(t=this.chatInner,t.style.paddingTop=e+"px",this.scrollable.setScrollTopSilently(s),this.isTopPaddingSet=!0)}return{isPaddingNeeded:i,unsetPadding:i?()=>{e()&&i&&(t.style.paddingTop="",this.isTopPaddingSet=!1)}:void 0}}renderNewMessage(e,t){const i=this._renderNewMessage(e,t);return this.renderNewPromises.add(i),i.catch(Ke.Z).finally((()=>{this.renderNewPromises.delete(i)})),i}_renderNewMessage(e,t){return Bt(this,void 0,void 0,(function*(){if(!this.scrollable.loadedAll.bottom){const t=this.chat.setPeerPromise;if(t){const i=this.getMiddleware();t.then((()=>Bt(this,void 0,void 0,(function*(){if(!i())return;const t=yield this.chat.getMessage(e.mid);i()&&this.renderNewMessage(t)}))))}return}if(this.chat.threadId&&(0,u.Z)(e,this.chat.isForum)!==this.chat.threadId)return;if(this.bubbles[e.mid])return;t||(t=this.scrolledDown&&(!this.scrollingToBubble||this.scrollingToBubble===this.getLastBubble()||this.scrollingToBubble===this.chatInner));const i=this.getMiddleware(),{isPaddingNeeded:s,unsetPadding:n}=this.setTopPadding(i),a=this.performHistoryResult({history:[e]},!1);return t&&a.then((()=>{if(!i())return;let t;"scheduled"===this.chat.type&&(t=this.bubbles[e.mid]);const a=t?this.scrollToBubbleEnd(t):this.scrollToEnd();s&&a.then(n)})),a}))}getLastBubble(){var e;const t=this.bubbleGroups.getLastGroup();return null===(e=null==t?void 0:t.lastItem)||void 0===e?void 0:e.bubble}scrollToBubble(e,t,i,s){const n=(0,q.Z)(e,"bubble");let a;if(e.parentElement||this.log.error("element is not connected",n),n&&"end"!==t){const e=this.bubbleGroups.getItemByBubble(n);e&&e.group.firstItem===e&&(0,se.Z)(e.group.container)===(this.stickyIntersector?jt:1)&&(a=e.group.container.parentElement)}const o=this.chat.input.messageInput&&this.chat.input.messageInput.classList.contains("is-changing-height")||this.chat.container.classList.contains("is-toggling-helper"),r=this.scrollable.scrollIntoViewNew({element:e,position:t,margin:4,forceDirection:i,forceDuration:s,axis:"y",getNormalSize:o?({rect:e})=>{let t=de.Z.height;return t-=this.container.offsetTop,t-=C.Z.isMobile||de.Z.height<570?58:78,t}:void 0,fallbackToElementStartWhenCentering:a,startCallback:e=>{if(this.onScroll(!0,e),this.updateGradient){const{gradientRenderer:t}=this.chat;null==t||t.toNextPosition(e.getProgress),this.updateGradient=void 0}}});return i===j.f.Static&&(this.scrollable.lastScrollPosition=this.scrollable.scrollTop),r}scrollToEnd(){return this.scrollToBubbleEnd(this.chatInner)}scrollToBubbleEnd(e){return Bt(this,void 0,void 0,(function*(){if(e){this.scrollingToBubble=e;const t=this.getMiddleware();if(yield this.scrollToBubble(e,"end",void 0,void 0),!t())return;this.scrollingToBubble=void 0}}))}scrollToBubbleIfLast(e){return Bt(this,void 0,void 0,(function*(){if(this.getLastBubble()===e)return this.scrollToEnd()}))}highlightBubble(e){const t="highlightTimeout";e.dataset[t]&&(clearTimeout(+e.dataset[t]),e.classList.remove("is-highlighted"),e.offsetWidth),e.classList.add("is-highlighted"),e.dataset[t]=""+setTimeout((()=>{e.classList.remove("is-highlighted"),delete e.dataset[t]}),2e3)}createDateBubble(e,t=new Date(1e3*e)){let i;const s=new Date;s.setHours(0,0,0,0);const n="scheduled"===this.chat.type;if(s.getTime()===t.getTime())i=(0,E.ag)(n?"Chat.Date.ScheduledForToday":"Date.Today");else if(n&&e===re._)i=(0,E.ag)("MessageScheduledUntilOnline");else{const e={day:"numeric",month:"long"};t.getFullYear()!==s.getFullYear()&&(e.year="numeric"),i=new E.ZP.IntlDateElement({date:t,options:e}).element,n&&(i=(0,E.ag)("Chat.Date.ScheduledFor",[i]))}const a=document.createElement("div");a.className="bubble service is-date";const o=document.createElement("div");o.classList.add("bubble-content");const r=document.createElement("div");return r.classList.add("service-msg"),r.append(i),o.append(r),a.append(o),a}getDateForDateContainer(e){const t=new Date(1e3*e);return t.setHours(0,0,0),{date:t,dateTimestamp:t.getTime()}}getDateContainerByTimestamp(e){var t;const{date:i,dateTimestamp:s}=this.getDateForDateContainer(e);let n=this.dateMessages[s];if(n)return n;const a=this.createDateBubble(e,i),o=this.createDateBubble(e,i);o.classList.add("is-fake");const r=document.createElement("section");r.className="bubbles-date-group",r.append(a,o),n=this.dateMessages[s]={div:a,container:r,firstTimestamp:i.getTime()};const d=(0,Ee.Z)(this.dateMessages,"asc"),l=d.length;let c,h=0;for(;h<d.length;++h){const e=d[h];if(c=this.dateMessages[e].container,s<e)break}return h===l&&c&&(c=c.nextElementSibling),c?this.chatInner.insertBefore(r,c):this.chatInner.append(r),null===(t=this.stickyIntersector)||void 0===t||t.observeStickyHeaderChanges(r),this.chatInner.parentElement&&this.container.classList.add("has-groups"),n}destroyScrollable(){this.scrollable.destroy()}destroy(){this.destroyScrollable(),this.listenerSetter.removeAll(),this.lazyLoadQueue.clear(),this.observer&&this.observer.disconnect(),this.stickyIntersector&&this.stickyIntersector.disconnect(),delete this.lazyLoadQueue,this.observer&&delete this.observer,this.stickyIntersector&&delete this.stickyIntersector}cleanup(e=!1){this.log("cleanup"),this.bubbles={},this.setLoaded("top",!1,!1),this.setLoaded("bottom",!1,!1),(0,ne.Kx)(this.scrollable.container),(0,G.gp)(),void 0!==Ht&&(Ht=Ut),this.skippedMids.clear(),this.dateMessages={},this.bubbleGroups.cleanup(),this.unreadOut.clear(),this.needUpdate.length=0,this.lazyLoadQueue.clear(),this.renderNewPromises.clear(),e&&(this.scrollable.container.textContent="",this.chatInner.textContent="",this.cleanupPlaceholders()),this.firstUnreadBubble=null,this.attachedUnreadBubble=!1,this.batchProcessor.clear(),this.getHistoryTopPromise=this.getHistoryBottomPromise=void 0,this.fetchNewPromise=void 0,this.getSponsoredMessagePromise=void 0,this.updateGradient=void 0,this.stickyIntersector&&this.stickyIntersector.disconnect(),this.observer&&(this.observer.disconnect(),this.unreaded.clear(),this.unreadedSeen.clear(),this.readPromise=void 0,this.viewsMids.clear()),this.middlewareHelper.clean(),this.onAnimateLadder=void 0,this.resolveLadderAnimation=void 0,this.attachPlaceholderOnRender=void 0,this.emptyPlaceholderBubble=void 0,this.sponsoredMessage=void 0,this.previousStickyDate=void 0,this.scrollingToBubble=void 0,this.isTopPaddingSet=!1,this.renderingMessages.clear(),this.bubblesToEject.clear(),this.bubblesToReplace.clear(),this.isScrollingTimeout&&(clearTimeout(this.isScrollingTimeout),this.isScrollingTimeout=0),this.container.classList.remove("has-sticky-dates"),this.scrollable.cancelMeasure()}cleanupPlaceholders(e=this.emptyPlaceholderBubble){e&&this.destroyBubble(e)}setPeer(e){var t;return Bt(this,void 0,void 0,(function*(){const{samePeer:i,peerId:s,stack:n}=e;let{lastMsgId:a,startParam:o}=e;const r=++this.setPeerTempId;if(!s)return this.cleanup(!0),this.preloader.detach(),null;const d=performance.now(),c=this.log.bindPrefix("setPeer");c.warn("start");const h=()=>this.setPeerTempId===r,u=(0,Ge.Z)(h,Gt);i||(yield u(this.chat.onChangePeer(e,u)));const p=this.chat.type;("scheduled"===p||this.chat.isRestricted)&&(a=0);const f=yield u(this.chat.getHistoryStorage()),m="pinned"===p?yield u(this.managers.appMessagesManager.getPinnedMessagesMaxId(s,this.chat.threadId)):null!==(t=f.maxId)&&void 0!==t?t:0,g=void 0!==a;let v,b,y,w=0;if(!g)if(i||(b=this.chat.appImManager.getChatSavedPosition(this.chat)),b);else if(m){w=yield u(this.managers.appMessagesManager.getReadMaxIdIfUnread(s,this.chat.threadId));const e=yield u(this.chat.getDialogOrTopic());if(!w||i||e&&1===e.unread_count)a=m;else{const e=f.history.findSliceOffset(w);e&&e.slice.isEnd($.D.Bottom)&&(y=e.slice[e.offset-25]||e.slice[0]||w),v=!g,a=w}}const C=a!==m;if(void 0===o&&(yield u(this.chat.isStartButtonNeeded()))&&(o=l.gZ),i){n&&a&&this.followStack.push(n);const t=yield u(this.getMountedBubble(a));if(t)return g?(this.scrollToBubble(t.bubble,"center"),this.highlightBubble(t.bubble),this.chat.dispatchEvent("setPeer",a,!1)):m&&!C&&(this.scrollToEnd(),this.chat.dispatchEvent("setPeer",a,!0)),void 0!==o&&this.chat.input.setStartParam(o),e.mediaTimestamp&&(0,G.e9)().then((()=>{this.playMediaWithTimestampAndMid({lastMsgId:a,middleware:h,mediaTimestamp:e.mediaTimestamp})})),null}else this.peerId&&(this.lazyLoadQueue.queueId=++zt,this.managers.apiFileManager.setQueueId(this.chat.bubbles.lazyLoadQueue.queueId)),this.followStack.length=0,this.passEntities={messageEntityBotCommand:(yield u(this.managers.appPeersManager.isAnyGroup(s)))||this.chat.isBot};W.ZP&&c("setPeer peerId:",s,f,a,m);const L=null!=y?y:C||"scheduled"===p||this.chat.isRestricted?0:m;let E=0;if(i){const e=this.getBubbleByPoint("bottom");e&&(E=+e.dataset.mid),E<=0&&(E=Math.max(...Object.keys(this.bubbles).map((e=>+e))))}else this.isFirstLoad=!0,this.destroyResizeObserver();const I=this.chatInner,P=this.emptyPlaceholderBubble;this.cleanup();const Z=this.chatInner=document.createElement("div");i?(Z.className=I.className,Z.classList.remove("disable-hover","is-scrolling")):Z.classList.add("bubbles-inner"),this.lazyLoadQueue.lock();const M=i||m&&C||g,k=E>0&&(!a||E<a||a<0),T=!k&&i,x=!T&&k;if(this.willScrollOnLoad=T||x,this.setPeerOptions={lastMsgId:a,topMessage:m,savedPosition:b},!i&&(this.ranks=void 0,this.processRanks=void 0,this.canShowRanks=!1,this.chat.isChannel)){this.canShowRanks=!0;const e=this.processRanks=new Set,t=this.managers.acknowledged.appProfileManager.getParticipants(this.peerId.toChatId(),{_:"channelParticipantsAdmins"},100),i=yield u(t),s=i.result.then((t=>{if(this.processRanks!==e)return;const i=t.participants;this.ranks=new Map,i.forEach((e=>{const t=(0,Dt.Z)(e);this.ranks.set(e.user_id.toPeerId(),t)})),(0,G.e9)().then((()=>{this.processRanks===e&&(e.forEach((e=>e())),this.processRanks=void 0)}))}),(e=>{"CHAT_ADMIN_REQUIRED"!==e.type&&this.log.error("ranks error",e),this.ranks=new Map}));i.cached&&(yield u(s))}let A;A=b?{promise:(0,G.e9)().then((()=>this.performHistoryResult({history:b.mids},!0))),cached:!0,waitPromise:Promise.resolve()}:yield u(this.getHistory1(a,!0,C,L)),this.setPeerCached=A.cached,c.warn("got history");const{promise:F,cached:D}=A,R={isTarget:g,isJump:C,lastMsgId:a,startParam:o,middleware:h};D||i||(yield u(this.chat.finishPeerChange(R)),this.scrollable.container.replaceChildren(),this.preloader.attach(this.container)),S.Z.lockGroup(this.chat.animationGroup);const B=u(F).then((()=>Bt(this,void 0,void 0,(function*(){var t;c.warn("promise fulfilled");const n=M?yield u(a?this.getMountedBubble(a):{bubble:this.getLastBubble()}):void 0;D&&!i&&(c.warn("finishing peer change"),yield u(this.chat.finishPeerChange(R)),c.warn("finished peer change")),this.preloader.detach(),this.resolveLadderAnimation&&(this.resolveLadderAnimation(),this.resolveLadderAnimation=void 0),this.setPeerCached=void 0;const o=this.scrollable;if(o.lastScrollDirection=0,o.lastScrollPosition=0,(0,_.Z)(o.container,Z),P&&this.cleanupPlaceholders(P),this.attachPlaceholderOnRender&&this.attachPlaceholderOnRender(),!g&&this.chat.isPinnedMessagesNeeded()&&(null===(t=this.chat.topbar.pinnedMessage)||void 0===t||t.setCorrectIndex(0)),this.container.classList.toggle("has-groups",!!Object.keys(this.dateMessages).length),c.warn("mounted chat",this.chatInner===Z,this.chatInner.parentElement,performance.now()-d),S.Z.unlockGroup(this.chat.animationGroup),S.Z.checkAnimations(!1,this.chat.animationGroup),this.lazyLoadQueue.unlock(),b)o.setScrollTopSilently(b.top);else if(M){let e;if(T)o.setScrollTopSilently(99999);else if(x){const t=this.setTopPadding();t.isPaddingNeeded&&(e=t.unsetPadding),o.setScrollTopSilently(0)}let t,s=v&&this.firstUnreadBubble||(null==n?void 0:n.bubble);if((null==s?void 0:s.parentElement)||(s=this.findNextMountedBubbleByMsgId(a,!1)||this.findNextMountedBubbleByMsgId(a,!0)),s){const e=this.getLastBubble(),n=v?"start":C||g||e!==s?"center":"end";t="end"===n&&e===s&&i?this.scrollToEnd():this.scrollToBubble(s,n,i?void 0:j.f.Static),!v&&g&&this.highlightBubble(s)}e&&(t||Promise.resolve()).then((()=>{e()}))}else o.setScrollTopSilently(99999);this.onRenderScrollSet(),this.onScroll();const r=Promise.all([B,(0,G.e9)()]);if(r.then((()=>{h()&&(o.checkForTriggers(),void 0!==e.mediaTimestamp)&&(D&&!i&&gt.Z.isAvailable("animations")&&this.chat.appImManager.chats.length>1?(0,Ce.Z)(400):Promise.resolve()).then((()=>this.playMediaWithTimestampAndMid({lastMsgId:a,middleware:h,mediaTimestamp:e.mediaTimestamp})))})),this.chat.dispatchEvent("setPeer",a,!C),Promise.all([this.setFetchReactionsInterval(r),this.setFetchHistoryInterval({afterSetPromise:r,lastMsgId:a,samePeer:i,savedPosition:b,topMessage:m})]).then((()=>{c("scrolledAllDown:",o.loadedAll.bottom),o.loadedAll.bottom&&m&&!this.unreaded.size&&this.onScrolledAllDown()})),"chat"===p&&!this.chat.isForumTopic){const e=yield u(this.managers.appMessagesManager.getDialogOnly(s));(null==e?void 0:e.pFlags.unread_mark)&&this.managers.appMessagesManager.markDialogUnread(s,!0)}})))).catch((e=>{throw c.error("setPeer promise error:",e),h()||this.preloader.detach(),e}));return{cached:D,promise:B}}))}playMediaWithTimestampAndMid({middleware:e,lastMsgId:t,mediaTimestamp:i}){this.getMountedBubble(t).then((t=>{e()&&t&&this.playMediaWithTimestamp(t.bubble,i)}))}playMediaWithTimestamp(e,t){const i=(0,q.Z)(e,"bubble"),s=(0,q.Z)(e,"grouped-item"),n=s?+s.dataset.mid:+i.dataset.textMid;let a=i.querySelector(".attachment");if(a){n&&(a=a.querySelector(`[data-mid="${n}"]`));const e=a.querySelector("img, video, canvas");return void this.checkTargetForMediaViewer(e,void 0,t)}const o=(s||i).querySelector(".audio");if(o)return void o.playWithTimestamp(t);const r=i.dataset.replyToPeerId.toPeerId(),d=+i.dataset.replyToMid;r&&d&&(r===this.peerId?this.chat.setMessageId(d,t):this.chat.appImManager.setInnerPeer({peerId:r,mediaTimestamp:t}))}setFetchReactionsInterval(e){return Bt(this,void 0,void 0,(function*(){const t=this.getMiddleware();if(this.chat.isChannel){const i=()=>Bt(this,void 0,void 0,(function*(){if(!t())return;const e=[];for(const t in this.bubbles){let i=yield this.chat.getMessage(+t);"message"===(null==i?void 0:i._)&&(i=yield this.managers.appMessagesManager.getGroupsFirstMessage(i),e.push(i.mid))}(e.length?this.managers.appReactionsManager.getMessagesReactions(this.peerId,e):Promise.resolve()).then((()=>{setTimeout(i,1e4)}))}));Promise.all([e,(0,G.e9)(),(0,Ce.Z)(500)]).then((()=>{i()}))}}))}setFetchHistoryInterval({lastMsgId:e,topMessage:t,afterSetPromise:i,savedPosition:s,samePeer:n}){return Bt(this,void 0,void 0,(function*(){const e=this.peerId;if(e.isUser())return;const t=this.getMiddleware(),n=yield this.managers.appMessagesManager.isFetchIntervalNeeded(e);if(!s&&!n)return;if(yield i,!t())return;const a=e.toChatId();t.onClean((()=>{this.managers.apiUpdatesManager.unsubscribeFromChannelUpdates(a)})),this.managers.apiUpdatesManager.subscribeToChannelUpdates(a)}))}onScrolledAllDown(){return Bt(this,void 0,void 0,(function*(){if("chat"===this.chat.type||"discussion"===this.chat.type){const e=yield this.chat.getHistoryMaxId();this.managers.appMessagesManager.readHistory(this.peerId,e,this.chat.threadId,!0)}}))}finishPeerChange(){return Bt(this,void 0,void 0,(function*(){const[e,t,i]=yield Promise.all([this.chat.isChannel,this.chat.canSend(),this.chat.isAnyGroup]);return()=>{this.chatInner.classList.toggle("has-rights",t),this.container.classList.toggle("is-chat-input-hidden",!t),this.chatInner.classList.toggle("is-chat",i),this.chatInner.classList.toggle("is-channel",e),this.createResizeObserver()}}))}renderMessagesQueue(e){return this.batchProcessor.addToQueue(e)}ejectBubbles(){for(const e of this.bubblesToEject)e.remove();this.bubblesToEject.clear()}groupBubbles(e){let t;"scheduled"===this.chat.type&&(t=new Set,e.forEach((({bubble:e,message:i})=>{const s=this.bubbleGroups.getItemByBubble(e),n=null==s?void 0:s.group;n&&s.message.date!==i.date&&(this.bubbleGroups.removeItem(s),t.add(n))}))),e.forEach((({bubble:e,message:t})=>{this.bubbleGroups.prepareForGrouping(e,t)}));const i=this.bubbleGroups.groupUngrouped(),s=Array.from(i).map((e=>{if(e.avatar)return;const t=e.firstItem;return t&&this.chat.isAvatarNeeded(t.message)?e.createAvatar(t.message):void 0})).filter(Boolean);if(t)for(const e of t)i.add(e);return{groups:[...i],avatarPromises:s}}getMiddleware(e){return this.middlewareHelper.get(e)}wrapMediaSpoiler({media:e,promise:t,middleware:i,attachmentDiv:s}){return Bt(this,void 0,void 0,(function*(){if(yield t,!i())return;const{width:n,height:a}=s.style,o=yield(0,st.ZP)({media:e,width:parseInt(n),height:parseInt(a),middleware:i,animationGroup:this.chat.animationGroup});i()&&s.append(o)}))}safeRenderMessage(e,t,i,s=!0,n){return Bt(this,void 0,void 0,(function*(){if(!e||this.renderingMessages.has(e.mid)||this.bubbles[e.mid]&&!i)return;const a=this.getMiddleware().create(),o=a.get();let r;try{this.renderingMessages.add(e.mid);const d=document.createElement("div");d.middlewareHelper=a,d.dataset.mid=""+e.mid,d.dataset.peerId=""+e.peerId,d.dataset.timestamp=""+e.date,i&&(i.middlewareHelper.destroy(),this.skippedMids.delete(e.mid),this.bubblesToEject.add(i),this.bubblesToReplace.delete(i),this.bubblesToReplace.set(d,i),this.bubbleGroups.changeBubbleByBubble(i,d)),i=this.bubbles[e.mid]=d;let l=this.renderMessage(e,t,i,o);n&&(l=n(l,i));const c=l.then((e=>e&&o()?Object.assign(Object.assign({},e),{updatePosition:s}):void 0));if(this.renderMessagesQueue(c.catch((()=>{}))),r=yield c,!o())return;r||this.skippedMids.add(+e.mid)}catch(e){this.log.error("renderMessage error:",e)}return o()?(this.renderingMessages.delete(e.mid),r):void 0}))}renderMessage(e,t=!1,i,s){var a,o,r;return Bt(this,void 0,void 0,(function*(){const c="message"===e._,h=c&&e.grouped_id;let p,f;const m=h?yield this.managers.appMessagesManager.getMessagesByAlbum(h):void 0,v="pinned"!==this.chat.type;if(h&&v){p=m.map((e=>e.mid));const t=Wt(p);if(e.mid!==t)return}c&&(f=h?m[0]:e);const b=this.chat.isOurMessage(e),y=document.createElement("div");y.classList.add("message","spoilers-container");const w=document.createElement("div");w.classList.add("bubble-content-wrapper");const S=document.createElement("div");S.classList.add("bubble-content"),i.classList.add("bubble"),w.append(S),i.append(w);let P=!b&&!e.pFlags.out&&(e.pFlags.unread||De(e));if(!P&&this.chat.peerId.isAnyChat()){const t=yield this.managers.appMessagesManager.getReadMaxIdIfUnread(this.chat.peerId,this.chat.threadId);void 0!==t&&t<e.mid&&(P=!0)}P&&this.observer&&(this.observer.observe(i,this.unreadedObserverCallback),this.unreaded.set(i,e.mid));const M=[],A={bubble:i,promises:M,message:e,reverse:t},_={lazyLoadQueue:this.lazyLoadQueue,middleware:s,customEmojiSize:this.chat.appImManager.customEmojiSize,animationGroup:this.chat.animationGroup};if(!("messageService"!==e._||e.action&&Ot.has(e.action._))){const t=e.action;if(t){const i=t._,s=Nt.get(i);if(s&&(!0===s||s(e)))return;if(E.Hz.hasOwnProperty(i)&&!E.Hz[i])return}i.className="bubble service",S.replaceChildren();const a=document.createElement("div");if(a.classList.add("service-msg"),t){let i;if("messageActionChannelMigrateFrom"===t._){const e=new x.Z;i=e.update({peerId:t.chat_id.toPeerId(!0),wrapOptions:_}),a.append((0,E.ag)("ChatMigration.From",[e.element]))}else if("messageActionChatMigrateTo"===t._){const e=new x.Z;i=e.update({peerId:t.channel_id.toPeerId(!0),wrapOptions:_}),a.append((0,E.ag)("ChatMigration.To",[e.element]))}else i=(0,Fe.Z)(Object.assign({message:e},_)).then((e=>a.append(e)));if("messageActionGiftPremium"===t._){const e=S.cloneNode(!1);e.classList.add("bubble-premium-gift-container"),e.style.height="12.875rem",e.style.width="12.5rem";const i=a.cloneNode(!1);i.classList.add("bubble-premium-gift-wrapper");const o=160,r=t.months,d={3:"Gift3",6:"Gift6",12:"Gift12"}[(0,Ft.Z)(r,3,12)],l=function({emoji:e,width:t,height:i,assetName:s,middleware:a,managers:o=n.Z.managers,loop:r=!1,autoplay:d=!0}){return l=this,c=void 0,u=function*(){const n=document.createElement("div");let l;if(n.classList.add("media-sticker-wrapper"),s)l=_t.Z.loadAnimationAsAsset({container:n,loop:r,autoplay:d,width:t,height:i,noCache:!0,middleware:a},s).then((e=>_t.Z.waitForFirstFrame(e)));else if(e){const s=yield o.appStickersManager.getAnimatedEmojiSticker(e);s&&(l=(0,et.ZP)({doc:s,div:n,loop:r,play:d,width:t,height:i,emoji:e,managers:o,middleware:a}).then((e=>e.render)))}return{container:n,promise:l}},new((h=void 0)||(h=Promise))((function(e,t){function i(e){try{n(u.next(e))}catch(e){t(e)}}function s(e){try{n(u.throw(e))}catch(e){t(e)}}function n(t){var n;t.done?e(t.value):(n=t.value,n instanceof h?n:new h((function(e){e(n)}))).then(i,s)}n((u=u.apply(l,c||[])).next())}));var l,c,h,u}({width:o,height:o,assetName:d,middleware:s,loop:!1,autoplay:gt.Z.isAvailable("stickers_chat")}).then((({container:e,promise:t})=>(e.classList.add("bubble-premium-gift-sticker"),e.style.position="relative",e.style.width=e.style.height=o+"px",i.prepend(e),t))),c=r>=12&&!(r%12),h=(0,E.ag)(c?"Years":"Months",[c?r/12:r]),u=(0,E.ag)("ActionGiftPremiumTitle"),p=(0,E.ag)("ActionGiftPremiumSubtitle",[h]);u.classList.add("text-bold"),i.append(u,p),M.push(l),e.append(i),S.after(e)}M.push(i)}return S.append(a),e.pFlags.is_single&&i.classList.add("is-group-last"),A}let F,D,R,B=c&&e.media,N=!0;if(c){if(h&&v){const e=R=(0,We.Z)(m);F=(null==e?void 0:e.message)||"",D=(null==e?void 0:e.totalEntities)||[]}else F=e.message,D=e.totalEntities;const t=null==B?void 0:B.document;t&&("sticker"===(null==t?void 0:t.type)?F=D=void 0:["video","gif"].includes(t.type)||(N=!1))}else"messageActionPhoneCall"===e.action._&&(B={_:"messageMediaCall",action:e.action});let U,H=0;if(D&&!B){const e=D.filter((e=>"messageEntityEmoji"===e._)),t=F.replace(/\s/g,"").length;if(e.reduce(((e,t)=>e+t.length),0)===t){H=Math.min(Kt,e.length),U=C.Z.active.customEmoji;const t=Vt[H];t&&(U=(0,Je.C)(t,t),i.style.setProperty("--emoji-size",t+"px"))}}null!=U||(U=this.chat.appImManager.customEmojiSize);let z=dt(R||e);if(R&&N&&(i.dataset.textMid=""+R.mid),e.reply_to){const t=e.reply_to.reply_to_peer_id?(0,k.Z)(e.reply_to.reply_to_peer_id):this.peerId;if(i.dataset.replyToPeerId=""+t,i.dataset.replyToMid=""+e.reply_to_mid,void 0===z){const i=yield n.Z.managers.appMessagesManager.getMessageByPeer(t,e.reply_to_mid);z=i?dt(i):1/0}}const j={entities:D,passEntities:this.passEntities,loadPromises:M,lazyLoadQueue:this.lazyLoadQueue,customEmojiSize:U,middleware:s,animationGroup:this.chat.animationGroup,maxMediaTimestamp:z},G=F?(0,_e.ZP)(F,j):void 0;let V,K=!0,W=!1;if(H){if(n.Z.settings.emoji.big){const e=1===H&&!D.find((e=>"messageEntityCustomEmoji"===e._))&&(yield this.managers.appStickersManager.getAnimatedEmojiSticker(F));1===H&&!B&&e?B={_:"messageMediaDocument",document:e,pFlags:{}}:(V=document.createElement("div"),V.classList.add("attachment","spoilers-container"),(0,Z.Z)(V,G),S.append(V)),i.classList.add("is-message-empty","emoji-big"),W=!0,K=!1,N=!1}i.classList.add("can-have-big-emoji")}N&&(0,Z.Z)(y,G);const $=(Y=F,Pt.test(Y));var Y;const X=O.setTime({chatType:this.chat.type,message:e,reactionsMessage:f});let ie;if(y.append(X),S.prepend(y),$&&X.classList.add("is-block"),c&&this.chat.isAllMessagesForum){const t=yield(0,xt.Z)({peerId:this.peerId,threadId:(0,u.Z)(e,this.chat.isForum),lastMsgId:e.mid,wrapOptions:{middleware:s},withIcons:!0}),{element:i}=t;ie=document.createElement("div"),ie.classList.add("topic-name-button-container"),ie.append(i)}if(c&&e.views){if(i.classList.add("channel-post"),!(null===(a=e.fwd_from)||void 0===a?void 0:a.saved_from_msg_id)&&"pinned"!==this.chat.type){const e=document.createElement("div");e.classList.add("bubble-beside-button","forward","tgico-forward_filled"),S.prepend(e),i.classList.add("with-beside-button")}!e.pFlags.is_outgoing&&this.observer&&this.observer.observe(i,this.viewsObserverCallback)}const ne=c&&e.reply_markup;let ae="replyInlineMarkup"===(null==ne?void 0:ne._)&&ne.rows;if(ae&&(ae=ae.filter((e=>e.buttons.length))),ae){const t=document.createElement("div");t.classList.add("reply-markup"),ae.forEach((i=>{const s=i.buttons,n=document.createElement("div");n.classList.add("reply-markup-row"),s.forEach((t=>{let i,s=(0,_e.ZP)(t.text,{noLinks:!0,noLinebreaks:!0});switch(t._){case"keyboardButtonUrl":{const e=(0,_e.ZP)(" ",{entities:[{_:"messageEntityTextUrl",length:1,offset:0,url:t.url}]});i=(0,te.Z)(e).firstElementChild,i.classList.add("is-link");break}case"keyboardButtonSwitchInline":i=document.createElement("button"),i.classList.add("is-switch-inline"),(0,ee.fc)(i,(i=>{(0,J.Z)(i);const s=e.viaBotId||e.fromId;let n;n=t.pFlags.same_peer?Promise.resolve(this.peerId):this.managers.appInlineBotsManager.checkSwitchReturn(s).then((e=>e||new Promise(((e,t)=>{const i=ke.Z.createPopup(g.Z,void 0,(t=>{e(t)}));i.addEventListener("close",(()=>{t()}))})))),n.then((e=>{const i=this.peerId===e?this.chat.threadId:void 0;this.chat.appImManager.setInnerPeer({peerId:e}),this.managers.appInlineBotsManager.switchInlineQuery(e,i,s,t.query)}))}));break;case"keyboardButtonBuy":{const e="messageMediaInvoice"===B._?B:void 0;if(null==e?void 0:e.extended_media)break;i=document.createElement("button"),i.classList.add("is-buy"),(null==e?void 0:e.receipt_msg_id)&&(s=(0,E.ag)("Message.ReplyActionButtonShowReceipt"));break}case"keyboardButtonUrlAuth":{i=document.createElement("button"),i.classList.add("is-url-auth");const{peerId:s}=this,{mid:n}=e,{url:a,button_id:o}=t;(0,ee.fc)(i,(()=>{const e=(0,At.Z)([i],!0);this.chat.appImManager.handleUrlAuth({peerId:s,mid:n,url:a,buttonId:o}).then((()=>{e()}))}));break}default:i=document.createElement("button")}if(!i)return;i.classList.add("reply-markup-button","rp","tgico");const a=document.createElement("span");a.classList.add("reply-markup-button-text"),"string"==typeof s?a.insertAdjacentHTML("beforeend",s):a.append(s),(0,I.Z)(i),i.append(a),n.append(i)})),n.childElementCount&&t.append(n)}));const s=!!t.childElementCount;s&&(0,ee.fc)(t,(t=>{let i=t.target;if(i.classList.contains("reply-markup-button")||(i=(0,q.Z)(i,"reply-markup-button")),!i||i.classList.contains("is-link")||i.classList.contains("is-switch-inline")||i.classList.contains("is-buy")||i.classList.contains("is-url-auth"))return;(0,J.Z)(t);const s=(0,se.Z)(i),n=ae[(0,se.Z)(i.parentElement)];if(!n.buttons||!n.buttons[s])return void this.log.warn("no such button",n,s,e);const a=n.buttons[s];this.managers.appInlineBotsManager.callbackButtonClick(this.peerId,e.mid,a).then((e=>{"string"==typeof e.message&&e.message.length&&(0,Q.Am)((0,_e.ZP)(e.message,{noLinks:!0,noLinebreaks:!0}))}))})),s&&(i.classList.add("with-reply-markup"),w.append(t))}const oe=e.pFlags.is_outgoing;if(b){(e.pFlags.unread||oe)&&this.unreadOut.add(e.mid);let t="";t=e.error?"is-error":oe?"is-sending":e.pFlags.unread||e.pFlags.is_scheduled?"is-sent":"is-read",i.classList.add(t)}oe&&!e.error&&i.classList.add("is-outgoing");const re=c&&(yield this.managers.appMessagesManager.getMessageWithCommentReplies(e)),de=!!re&&e.mid>0;de&&i.classList.add("with-replies");const ce=c&&e.fwd_from,he=c&&e.fwdFromId,ue=this.chat.isOutMessage(e);let pe=S;const fe=!(e.viaBotId||e.fromId!==n.Z.myId&&e.pFlags.out),ge=!F;let ve;if(B){V=document.createElement("div"),V.classList.add("attachment"),ge&&i.classList.add("is-message-empty");let t=!1;switch(B._){case"messageMediaPhoto":{const t=B.photo;if(ge&&(K=!1),fe&&i.classList.add("hide-name"),i.classList.add("photo"),v&&h&&1!==p.length){i.classList.add("is-album","is-grouped"),ot({messages:m,attachmentDiv:V,middleware:this.getMiddleware(),isOut:b,lazyLoadQueue:this.lazyLoadQueue,chat:this.chat,loadPromises:M,autoDownload:this.chat.autoDownload});break}const n=!L.IS_ANDROID&&K&&!de&&!1;n&&i.classList.add("with-media-tail");const a=(0,nt.Z)({photo:t,message:e,container:V,withTail:n,isOut:ue,lazyLoadQueue:this.lazyLoadQueue,middleware:this.getMiddleware(),loadPromises:M,autoDownloadSize:this.chat.autoDownload.photo});B.pFlags.spoiler&&M.push(this.wrapMediaSpoiler({media:t,promise:a,middleware:s,attachmentDiv:V}));break}case"messageMediaWebPage":{t=!0;const s=B.webpage;if("webPage"!==s._)break;const a=(0,Tt.Z)(s.url);if("im"===(null==a?void 0:a.onclick)){const e={telegram_channel:"Chat.Message.ViewChannel",telegram_megagroup:"OpenGroup",telegram_bot:"Chat.Message.ViewBot"}[s.type]||"OpenMessage";ve=this.makeViewButton({text:e,asLink:!0}),ve.href=a.url,ve.setAttribute("onclick",`${a.onclick}(this)`)}i.classList.add("webpage");const o=document.createElement("div");o.classList.add("web");const r=document.createElement("div");let d,l;r.classList.add("quote");const c=s.photo;(c||s.document)&&(d=document.createElement("div"),d.classList.add("preview-resizer"),l=document.createElement("div"),l.classList.add("preview"),d.append(l));const h=document.createElement("div");h.classList.add("quote-text");const u=s.document;if(u)if("gif"===u.type||"video"===u.type||"round"===u.type){const t="round"===u.type?C.Z.active.round:C.Z.active.webpage;"round"===u.type?(i.classList.add("round"),l.classList.add("is-round")):i.classList.add("video"),(0,at.Z)({doc:u,container:l,message:e,boxWidth:t.width,boxHeight:t.height,lazyLoadQueue:this.lazyLoadQueue,middleware:this.getMiddleware(),isOut:ue,group:this.chat.animationGroup,loadPromises:M,autoDownload:this.chat.autoDownload,noInfo:e.mid<0})}else{const t=yield(0,rt.Z)({message:e,autoDownloadSize:this.chat.autoDownload.file,lazyLoadQueue:this.lazyLoadQueue,loadPromises:M,sizeType:"documentName",searchContext:{useSearch:!1,peerId:this.peerId,inputFilter:{_:"inputMessagesFilterEmpty"}},fontSize:n.Z.settings.messagesTextSize,canTranscribeVoice:!0});l.append(t),l.classList.add("preview-with-document"),h.classList.add("has-document")}let p;if(d&&h.append(d),s.site_name){const e=(0,_e.ZP)(s.url),t=(0,te.Z)(e).firstElementChild;t.classList.add("webpage-name");const i=document.createElement("strong");(0,Z.Z)(i,(0,T.Z)(s.site_name)),t.textContent="",t.append(i),h.append(t),p=t}const f=(0,Ae.Z)(s);if(f.textContent){const e=document.createElement("div");e.classList.add("title");const t=document.createElement("strong");(0,Z.Z)(t,f),e.append(t),h.append(e),p=e}const m=(0,xe.Z)(s);if(m.textContent){const e=document.createElement("div");e.classList.add("text"),(0,Z.Z)(e,m),h.append(e),p=e}if(r.append(h),c&&!u){i.classList.add("photo");const t=c.sizes[c.sizes.length-1];let s=!1;t.w===t.h&&p?(i.classList.add("is-square-photo"),s=!0,(0,Te.Z)(c,l,48,48,!1)):t.h>t.w&&i.classList.add("is-vertical-photo"),(0,nt.Z)({photo:c,message:e,container:l,boxWidth:s?0:C.Z.active.webpage.width,boxHeight:s?0:C.Z.active.webpage.height,isOut:ue,lazyLoadQueue:this.lazyLoadQueue,middleware:this.getMiddleware(),loadPromises:M,withoutPreloader:s,autoDownloadSize:this.chat.autoDownload.photo})}o.append(r),y.insertBefore(o,X);break}case"messageMediaDocument":{const a=B.document;if(a.sticker){i.classList.add("sticker"),K=!1,W=!0,a.animated&&i.classList.add("sticker-animated");const e=C.Z.active,t=i.classList.contains("emoji-big"),n=t?e.emojiSticker:a.animated?e.animatedSticker:e.staticSticker;(0,Te.Z)(a,V,n.width,n.height),S.style.minWidth=V.style.width,S.style.minHeight=V.style.height,(0,et.ZP)({doc:a,div:V,middleware:s,lazyLoadQueue:this.lazyLoadQueue,group:this.chat.animationGroup,play:!0,liteModeKey:"stickers_chat",loop:!0,emoji:t?F:void 0,withThumb:!0,loadPromises:M,isOut:ue,noPremium:null===(o=null==B?void 0:B.pFlags)||void 0===o?void 0:o.nopremium}),((0,Qe.Z)(a)||t)&&(P||oe)&&this.observer.observe(i,this.stickerEffectObserverCallback)}else if("video"===a.type||"gif"===a.type||"round"===a.type){const t="round"===a.type;if(t&&(W=!0),(t||ge)&&(K=!1),fe&&i.classList.add("hide-name"),i.classList.add(t?"round":"video"),v&&h&&1!==p.length)i.classList.add("is-album","is-grouped"),ot({messages:m,attachmentDiv:V,middleware:s,isOut:b,lazyLoadQueue:this.lazyLoadQueue,chat:this.chat,loadPromises:M,autoDownload:this.chat.autoDownload});else{const n=!L.IS_ANDROID&&!L.IS_APPLE&&!t&&K&&!de&&!1;n&&i.classList.add("with-media-tail");const o=(0,at.Z)({doc:a,container:V,message:e,boxWidth:C.Z.active.regular.width,boxHeight:C.Z.active.regular.height,withTail:n,isOut:ue,lazyLoadQueue:this.lazyLoadQueue,middleware:s,group:this.chat.animationGroup,loadPromises:M,autoDownload:this.chat.autoDownload,searchContext:t?{peerId:this.peerId,inputFilter:{_:"inputMessagesFilterRoundVoice"},threadId:this.chat.threadId,useSearch:!e.pFlags.is_scheduled,isScheduled:e.pFlags.is_scheduled}:void 0,noInfo:e.mid<0,noAutoplayAttribute:!!B.pFlags.spoiler});B.pFlags.spoiler&&M.push(this.wrapMediaSpoiler({media:a,promise:o,middleware:s,attachmentDiv:V}))}}else{const s=yield function({albumMustBeRenderedFull:e,message:t,bubble:i,messageDiv:s,chat:n,loadPromises:a,autoDownloadSize:o,lazyLoadQueue:r,searchContext:d,useSearch:l,sizeType:c,managers:h,fontWeight:u,fontSize:p,richTextFragment:f,richTextOptions:m,canTranscribeVoice:g}){return lt(this,void 0,void 0,(function*(){let l;const v=e?yield n.getMidsByMid(t.mid):[t.mid],b=v.map(((e,t)=>lt(this,void 0,void 0,(function*(){const i=yield n.getMessage(e),s=yield(0,rt.Z)({message:i,loadPromises:a,autoDownloadSize:o,lazyLoadQueue:r,searchContext:d,sizeType:c,managers:h,fontWeight:u,fontSize:p,canTranscribeVoice:g}),b=document.createElement("div");b.classList.add("document-container"),b.dataset.mid=""+e,b.dataset.peerId=""+i.peerId;const y=document.createElement("div");if(y.classList.add("document-wrapper"),i.message){const e=document.createElement("div");e.classList.add("document-message");let t=f;t||(t=(0,_e.ZP)(i.message,Object.assign(Object.assign({},m),{entities:i.totalEntities,maxMediaTimestamp:dt(i)}))),(0,Z.Z)(e,t),y.append(e)}if(v.length>1){const e=document.createElement("div");e.classList.add("document-selection"),b.append(e),b.classList.add("grouped-item"),0===t&&(l=y)}return y.append(s),b.append(y),b})))),y=yield Promise.all(b);return s.append(...y),v.length>1&&i.classList.add("is-multiple-documents","is-grouped"),l}))}({albumMustBeRenderedFull:v,message:e,bubble:i,messageDiv:y,chat:this.chat,loadPromises:M,autoDownloadSize:this.chat.autoDownload.file,lazyLoadQueue:this.lazyLoadQueue,searchContext:"voice"===a.type||"audio"===a.type?{peerId:this.peerId,inputFilter:{_:"voice"===a.type?"inputMessagesFilterRoundVoice":"inputMessagesFilterMusic"},threadId:this.chat.threadId,useSearch:!e.pFlags.is_scheduled,isScheduled:e.pFlags.is_scheduled}:void 0,sizeType:"documentName",fontSize:n.Z.settings.messagesTextSize,richTextFragment:"string"==typeof G?void 0:G,richTextOptions:j,canTranscribeVoice:!0});s&&(pe=s);const o=y.lastElementChild.querySelector(".document-message, .document, .audio");o&&o.append(X),i.classList.remove("is-message-empty");const r=(["photo","pdf"].includes(a.type)?"document":a.type||"document")+"-message";y.classList.add(r),"audio"!==a.type&&"voice"!==a.type||i.classList.add("min-content"),t=!0}break}case"messageMediaCall":{const e=B.action,s=document.createElement("div");s.classList.add("bubble-call",e.pFlags.video?"tgico-videocamera":"tgico-phone");const n=e.pFlags.video?"video":"voice";s.dataset.type=n;const a=document.createElement("div");a.classList.add("bubble-call-title"),(0,E.$d)(a,ue?e.pFlags.video?"CallMessageVideoOutgoing":"CallMessageOutgoing":e.pFlags.video?"CallMessageVideoIncoming":"CallMessageIncoming");const o=document.createElement("div");if(o.classList.add("bubble-call-subtitle"),void 0!==e.duration)o.append((0,me.Z)(e.duration));else{let t;switch(e.reason._){case"phoneCallDiscardReasonBusy":t="Call.StatusBusy";break;case"phoneCallDiscardReasonMissed":t="Chat.Service.Call.Missed";break;default:t="Chat.Service.Call.Cancelled"}o.classList.add("is-reason"),(0,E.$d)(o,t)}o.classList.add("tgico","arrow-"+(void 0!==e.duration?"green":"red")),s.append(a,o),t=!0,i.classList.remove("is-message-empty"),y.classList.add("call-message"),y.append(s);break}case"messageMediaContact":{const e=B,s=document.createElement("div");s.classList.add("contact"),s.dataset.peerId=""+e.user_id,t=!0;const n=document.createElement("div");n.className="contact-details";const a=document.createElement("div");a.className="contact-name";const o=[e.first_name,e.last_name].filter(Boolean).join(" ");a.append(o.trim()?(0,T.Z)(o):(0,E.ag)("AttachContact"));const r=document.createElement("div");r.className="contact-number",r.textContent=e.phone_number?"+"+(0,le.u)(e.phone_number).formatted:"Unknown phone number",s.append(n),n.append(a,r);const l=new d.Z;l.updateWithOptions({lazyLoadQueue:this.lazyLoadQueue,peerId:e.user_id.toPeerId(),peerTitle:e.user_id?void 0:o.trim()?o:E.ZP.format("AttachContact",!0)[0]}),l.classList.add("contact-avatar","avatar-54"),s.prepend(l),i.classList.remove("is-message-empty"),y.classList.add("contact-message"),y.append(s);break}case"messageMediaPoll":{i.classList.remove("is-message-empty");const t=function(e,t=n.Z.managers){const i=new Et;return i.message=e,i.managers=t,i.setAttribute("peer-id",""+e.peerId),i.setAttribute("poll-id",e.media.poll.id),i.setAttribute("message-id",""+e.mid),i.render(),i}(e);y.prepend(t),y.classList.add("poll-message");break}case"messageMediaInvoice":{const t=B.pFlags.test,n=B.extended_media,a="messageExtendedMedia"===(null==n?void 0:n._),o="messageExtendedMediaPreview"===(null==n?void 0:n._);let r=a?n.media.photo||n.media.document:B.photo;const d=(0,$e.Z)(B.total_amount,B.currency);let l,c;if(n){if(o&&(l=document.createElement("span"),l.classList.add("extended-media-buy","tgico-premium_lock"),V.classList.add("is-buy"),(0,E.$d)(l,"Checkout.PayPrice",[d]),void 0!==n.video_duration)){const e=document.createElement("span");e.classList.add("video-time"),e.textContent=(0,mt.Z)(n.video_duration,!1),V.append(e)}}else{l=document.createElement(r?"span":"div");const e=document.createDocumentFragment(),i=(0,E.ag)(B.receipt_msg_id?"PaymentReceipt":t?"PaymentTestInvoice":"PaymentInvoice");i.classList.add("text-uppercase");const s=" "+Zt.Z,n=document.createElement("span");if(n.classList.add("text-bold"),n.textContent=d+s,e.append(n,i),t&&B.receipt_msg_id){const t=document.createElement("span");t.classList.add("text-uppercase","pre-wrap"),t.append(s+"(Test)"),e.append(t)}(0,Z.Z)(l,e)}if(o&&(n.thumb.w=n.w,n.thumb.h=n.h,r={_:"photo",access_hash:"",pFlags:{},date:0,dc_id:0,file_reference:[],id:0,sizes:[n.thumb]}),r){const t=n?C.Z.active.extendedInvoice:C.Z.active.invoice;"document"===r._?((0,at.Z)({doc:r,container:V,withTail:!1,isOut:ue,lazyLoadQueue:this.lazyLoadQueue,middleware:s,loadPromises:M,boxWidth:t.width,boxHeight:t.height,group:this.chat.animationGroup,message:e}),i.classList.add("video")):((0,nt.Z)({photo:r,container:V,withTail:!1,isOut:ue,lazyLoadQueue:this.lazyLoadQueue,middleware:s,loadPromises:M,boxWidth:t.width,boxHeight:t.height,message:a?e:void 0}),i.classList.add("photo")),l&&(n||l.classList.add("video-time"),V.append(l))}else V=void 0;if(o){const{mid:t}=e;this.extendedMediaMessages.add(t),s.onClean((()=>{this.extendedMediaMessages.delete(t)})),this.setExtendedMediaMessagesPollInterval();const{width:i,height:n}=V.style,a=Mt.Z.create({width:parseInt(i),height:parseInt(n),middleware:s,animationGroup:this.chat.animationGroup});V.append(a.canvas)}n||(c=document.createElement("div"),c.classList.add("bubble-primary-color"),(0,Z.Z)(c,(0,T.Z)(B.title)));const h=a?void 0:(0,T.Z)(B.description);y.prepend(...[c,!r&&l,h].filter(Boolean)),h?i.classList.remove("is-message-empty"):K=!1,i.classList.add("is-invoice");break}default:V=void 0,i.classList.remove("is-message-empty"),y.append((0,E.ag)(E.nK),X),this.log.warn("unrecognized media type:",B._,e)}!t&&V&&S.append(V)}W&&i.classList.add("just-media"),ve&&X.before(ve);let be="";const ye=e.fromId!==n.Z.myId&&this.chat.isAnyGroup||e.viaBotId||e.pFlags.sponsored;if(ye||ce||e.reply_to_mid||ie){let t,a;const o="peerChannel"===(null===(r=e.from_id)||void 0===r?void 0:r._)&&e.fromId===he,d=!!e.viaBotId,h=ce&&!ce.from_id;e.viaBotId&&(a=document.createElement("span"),a.innerText="@"+(yield this.managers.appPeersManager.getPeerUsername(e.viaBotId)),a.classList.add("peer-title")),d&&i.classList.add("must-have-name");const u=he||ce;let p,f;if(h?(t=document.createElement("span"),(0,Z.Z)(t,(0,T.Z)(ce.from_name)),t.classList.add("peer-title"),i.classList.add("hidden-profile")):t=new x.Z({peerId:he||e.fromId,withPremiumIcon:!u,wrapOptions:_}).element,c&&e.reply_to_mid&&e.reply_to_mid!==this.chat.threadId&&(!this.chat.isAllMessagesForum||e.reply_to.reply_to_top_id)&&(p=yield O.setReply({chat:this.chat,bubble:i,bubbleContainer:S,message:e})),u)if(this.peerId===n.Z.myId||o||i.classList.add("forwarded"),e.savedFrom&&(be=e.savedFrom,t.dataset.savedFrom=be),f=document.createElement("div"),t.dataset.peerId=""+he,this.peerId!==n.Z.myId&&this.peerId!==l.hj&&!o||W){const e=[t];if(W){const t=document.createElement("br");t.classList.add("hide-ol"),e.unshift(t)}f.append((0,E.ag)("ForwardedFrom",[e]))}else f.style.color=(0,Be.Z)(he,!1),f.classList.add("colored-name"),f.append(t);else if(!e.viaBotId)if(!W&&ye){f=document.createElement("div"),f.append(t);const i=yield this.managers.appPeersManager.getPeer(e.fromId),s=null==i?void 0:i.pFlags;s&&(s.scam||s.fake)&&f.append((0,Ze.Z)(s.scam)),b||(f.style.color=(0,Be.Z)(e.fromId,!1),f.classList.add("colored-name")),f.dataset.peerId=""+e.fromId}else i.classList.add("hide-name");if(e.viaBotId){f?f.append(" "):f=document.createElement("div");const e=document.createElement("span");e.append((0,E.ag)("ViaBot")," ",a),e.classList.add("is-via"),f.append(e)}if(ie&&(W?ie.classList.add("floating-part"):(f||(f=document.createElement("div")),f.append(ie),i.classList.remove("hide-name"))),f?(f.classList.add("name"),W?(pe.append(pe=document.createElement("div")),pe.classList.add("name-with-reply","floating-part")):f.classList.add("floating-part"),pe.append(f),W&&p&&pe.append(p)):W&&p&&p.classList.add("floating-part"),t&&!h&&!he&&this.canShowRanks){const i=()=>{const i=this.ranks.get(e.fromId);i&&t.after(this.createBubbleNameRank(i))};if(this.ranks)i();else{const e=this.processRanks;e.add(i),s.onDestroy((()=>{e.delete(i)}))}}else o&&t.after(this.createBubbleNameRank(0));ie&&W&&(V?V.after(ie):this.log.error("no attachment div?",i,e))}else i.classList.add("hide-name");if("pinned"===this.chat.type&&(be=`${this.chat.peerId}_${e.mid}`),re&&re.mid===this.chat.threadId&&i.classList.add("is-thread-starter","is-group-last"),be&&("pinned"===this.chat.type||ce.saved_from_msg_id)&&this.peerId!==l.hj){const e=document.createElement("div");e.classList.add("bubble-beside-button","goto-original","tgico-arrow_next"),S.append(e),i.dataset.savedFrom=be,i.classList.add("with-beside-button")}return i.classList.add(ue?"is-out":"is-in"),de&&(O.renderReplies({bubble:i,bubbleContainer:S,message:re,messageDiv:y,loadPromises:M,lazyLoadQueue:this.lazyLoadQueue})?K=!0:i.classList.add("with-beside-replies")),c&&this.appendReactionsElementToBubble(i,e,f),K&&(i.classList.add("can-have-tail"),S.append(qt())),A}))}appendReactionsElementToBubble(e,t,i,s){if(this.peerId.isUser(),!(null==i?void 0:i.reactions)||!i.reactions.results.length)return;const n=new Se.Z;if(n.init(i,"block",e.middlewareHelper.get()),n.render(s),e.classList.contains("is-message-empty"))e.querySelector(".bubble-content-wrapper").append(n);else{const s=e.querySelector(".message");if(e.classList.contains("is-multiple-documents")){const e=s.lastElementChild;let a=e.querySelector(".document-message"),o=a&&a.querySelector(".time");o||(o=O.setTime({chatType:this.chat.type,message:t,reactionsMessage:i})),n.append(o),a||(a=document.createElement("div"),a.classList.add("document-message"),e.querySelector(".document-wrapper").prepend(a)),a.append(n)}else{const t=Array.from(e.querySelectorAll(".time")).pop();n.append(t),s.append(n)}}}createBubbleNameRank(e){const t=document.createElement("span");return t.classList.add("bubble-name-rank"),t.append((0,Rt.Z)(e)),t}prepareToSaveScroll(e){if(!this.chatInner.parentElement)return{};const t=this.log.bindPrefix("prepareToSaveScroll");t("save");const i=this.createScrollSaver(e);if(i.save(),this.getRenderedLength()&&!this.chat.setPeerPromise){const e=this.getViewportSlice();this.deleteViewportSlice(e,!0)}return{restoreScroll:()=>{t("restore"),i.restore(e),this.onRenderScrollSet(i.getSaved())},scrollSaver:i}}performHistoryResult(e,t){var i;return Bt(this,void 0,void 0,(function*(){let s=e.history;s=s.slice(),this.needReflowScroll&&((0,ie.Z)(this.scrollable.container),this.needReflowScroll=!1);const n=yield Promise.all(s.map((e=>"number"==typeof e?this.chat.getMessage(e):e))),a=[];if(!this.scrollable.loadedAll.bottom||!this.scrollable.loadedAll.top){let t=e.isEnd;if(!t){const e=yield this.chat.getHistoryStorage(),i=e.history.first,n=e.history.last;t={top:!1,bottom:!1,both:!1},!i.isEnd($.D.Bottom)||i.length&&!s.includes(i[0])||(t.bottom=!0),!n.isEnd($.D.Top)||n.length&&!s.includes(n[n.length-1])||(t.top=!0)}if(!t.bottom&&this.setPeerOptions){const{lastMsgId:e,topMessage:i,savedPosition:s}=this.setPeerOptions;this.setPeerOptions=void 0,(!e&&!s||this.bubbles[i]||e===i)&&(t.bottom=!0)}t.top&&a.push(this.setLoaded("top",!0)),t.bottom&&a.push(this.setLoaded("bottom",!0))}yield Promise.all(a);const o=n.map((e=>e?e.pFlags.local?this.processLocalMessageRender(e):this.safeRenderMessage(e,t):void 0));yield Promise.all(o),yield this.messagesQueuePromise,this.scrollable.loadedAll.top&&this.messagesQueueOnRenderAdditional&&(this.messagesQueueOnRenderAdditional(),null===(i=this.messagesQueueOnRenderAdditional)||void 0===i||i.call(this))}))}onRenderScrollSet(e){const t="has-sticky-dates";if(this.container.classList.contains(t)||this.preloader.detached&&(null!=e||(e={scrollHeight:this.scrollable.scrollHeight,clientHeight:this.scrollable.container.clientHeight}),e.scrollHeight===e.clientHeight))this.willScrollOnLoad=void 0;else{const e=this.getMiddleware(),i=()=>{e()&&this.container.classList.add(t)};this.willScrollOnLoad?i():setTimeout(i,600)}}requestHistory(e,t,i){return"chat"===this.chat.type||"discussion"===this.chat.type?this.managers.acknowledged.appMessagesManager.getHistory(this.peerId,e,t,i,this.chat.threadId):"pinned"===this.chat.type?this.managers.acknowledged.appMessagesManager.getSearch({peerId:this.peerId,inputFilter:{_:"inputMessagesFilterPinned"},maxId:e,limit:t,backLimit:i}).then((e=>({cached:e.cached,result:Promise.resolve(e.result).then((e=>({history:e.history.map((e=>e.mid))})))}))):"scheduled"===this.chat.type?this.managers.acknowledged.appMessagesManager.getScheduledMessages(this.peerId).then((e=>({cached:e.cached,result:Promise.resolve(e.result).then((e=>({history:e.slice().reverse()})))}))):void 0}animateAsLadder(e,t,i,s,n){return Bt(this,void 0,void 0,(function*(){const a=this.log.bindPrefix("ladder");if(this.chat.setPeerPromise&&!this.resolveLadderAnimation)return a.warn("will be delayed"),void(this.resolveLadderAnimation=this.animateAsLadder.bind(this,e,t,i,s,n));if(!Object.keys(this.bubbles).length)return void a.warn("no bubbles");let o,r=(0,Ee.Z)(this.bubbles,"desc");i&&t.length&&(r=r.filter((e=>!t.includes(e)))),o=s?n||Math.max(...r):e||Math.max(...r);const d=r.slice(r.findIndex((e=>o>e))),l=i?[]:[o],c=i?[]:r.slice(0,r.findIndex((e=>o>=e))).reverse();W.ZP&&a("targeting mid:",o,n,e,d.map((e=>(0,Ne.Z)(e))),c.map((e=>(0,Ne.Z)(e))));const h=[];this.chatInner.classList.add("zoom-fading");const u=i?10:40,p=i?0:1,f=(e,t=0)=>{const i=(0,K.Z)();let s=0;return e.forEach(((n,o)=>{const r=this.bubbles[n];if(!r||this.skippedMids.has(n))return void a.warn("no bubble by mid:",n);s=(o+t||.1)*u;const d=r.lastElementChild,l=[d],c=this.bubbleGroups.getItemByBubble(r);if(c&&c.group.avatar&&c.group.lastItem===c&&l.push(c.group.avatar),l.forEach((e=>{e.classList.add("zoom-fade","can-zoom-fade"),e.style.transitionDelay=s+"ms"})),o===e.length-1){const e=t=>{t.target===d&&(i.resolve(),d.removeEventListener("transitionend",e))};d.addEventListener("transitionend",e)}h.push(...l)})),e.length||i.resolve(),{lastMsDelay:s,animationPromise:i}},m=f(d,p),g=f(l),v=f(c,p),b=[m.animationPromise,g.animationPromise,v.animationPromise],y=[m.lastMsDelay,g.lastMsDelay,v.lastMsDelay];let w;return this.onAnimateLadder&&(yield this.onAnimateLadder()),(0,V.T2)((()=>{this.setStickyDateManually(),h.forEach((e=>{e.classList.remove("zoom-fade")}))})),(d.length||l.length||c.length)&&(w=Promise.all(b),(0,G.YW)(w,Math.max(...y)+200).then((()=>{(0,V.T2)((()=>{h.forEach((e=>{e.style.transitionDelay="",e.classList.remove("can-zoom-fade")})),this.chatInner.classList.remove("zoom-fading")}))}))),w}))}renderEmptyPlaceholder(e,t,i,s){return Bt(this,void 0,void 0,(function*(){const i="empty-bubble-placeholder";let n,a;if(t.classList.add(i,i+"-"+e),"group"===e?n=(0,E.ag)("GroupEmptyTitle1"):"saved"===e?n=(0,E.ag)("ChatYourSelfTitle"):"noMessages"===e||"greeting"===e?n=(0,E.ag)("NoMessages"):"noScheduledMessages"===e?n=(0,E.ag)("NoScheduledMessages"):"restricted"===e&&(n=document.createElement("span"),n.innerText=yield this.managers.appPeersManager.getRestrictionReasonText(this.peerId)),n.classList.add("center",i+"-title"),s.push(n),"group"===e)s.push((0,E.ag)("GroupEmptyTitle2")),a=[(0,E.ag)("GroupDescription1"),(0,E.ag)("GroupDescription2"),(0,E.ag)("GroupDescription3"),(0,E.ag)("GroupDescription4")];else if("saved"===e)a=[(0,E.ag)("ChatYourSelfDescription1"),(0,E.ag)("ChatYourSelfDescription2"),(0,E.ag)("ChatYourSelfDescription3"),(0,E.ag)("ChatYourSelfDescription4")];else if("greeting"===e){const e=(0,E.ag)("NoMessagesGreetingsDescription");e.classList.add("center",i+"-subtitle");const t=document.createElement("div");t.classList.add(i+"-sticker");const n=this.getMiddleware();yield this.managers.appStickersManager.getGreetingSticker().then((e=>Bt(this,void 0,void 0,(function*(){if(!n())return;const i=[];return yield(0,et.ZP)({doc:e,div:t,middleware:n,lazyLoadQueue:this.lazyLoadQueue,group:this.chat.animationGroup,play:!0,loop:!0,withThumb:!0,loadPromises:i,liteModeKey:"stickers_chat"}),(0,ee.fc)(t,(e=>{(0,J.Z)(e),Ve.Jo.onMediaClick({target:e.target})})),Promise.all(i)})))),s.push(e,t)}a&&(s.push(...a.map((e=>{const t=document.createElement("span");return t.classList.add(i+"-list-item"),t.append(e),t}))),"group"===e?a.forEach((e=>{const t=document.createElement("span");t.classList.add("tgico-check"),e.prepend(t)})):"saved"===e&&a.forEach((e=>{const t=document.createElement("span");t.classList.add(i+"-list-bullet"),t.innerText="•",e.prepend(t)}))),s.length>1&&t.classList.add("has-description"),s.forEach((e=>e.classList.add(i+"-line")))}))}processLocalMessageRender(e,t,i=this.getMiddleware()){return Bt(this,void 0,void 0,(function*(){const s=!!e.pFlags.sponsored,o=(0,Ge.Z)(i);return this.safeRenderMessage(e,!s,void 0,!1,(i=>Bt(this,void 0,void 0,(function*(){const{bubble:r}=yield o(i);if(!r)return i;r.message=e,r.classList.add("is-group-last","is-group-first");const d=()=>{this.updatePlaceholderPosition===d&&(this.updatePlaceholderPosition=void 0),u[p](r)};s||(r.classList.add("bubble-first"),r.classList.remove("can-have-tail","is-in"));const l=[],c=this.chat.isBot;let h,u=this.container,p="append";if(this.chat.isRestricted)h=this.renderEmptyPlaceholder("restricted",r,e,l);else if(s){let i,s,n,a;r.classList.add("avoid-selection"),r.style.order="999999";const o=this.sponsoredMessage=e.sponsoredMessage,d=(0,k.Z)(o.from_id);o.channel_post?(i="OpenChannelPost",s=(0,Oe.Z)(o.channel_post)):o.start_param||c?(i="Chat.Message.ViewBot",n=o.start_param):i=(yield this.managers.appPeersManager.isAnyGroup(d))?"Chat.Message.ViewGroup":"Chat.Message.ViewChannel",a=o.chat_invite?()=>{ke.Z.createPopup(ye.Z,o.chat_invite_hash,o.chat_invite)}:o.chat_invite_hash?()=>{const e={_:we.z.JOIN_CHAT,invite:o.chat_invite_hash};this.chat.appImManager.processInternalLink(e)}:()=>{this.chat.appImManager.setInnerPeer({peerId:d,lastMsgId:s,startParam:n})};const l=this.makeViewButton({text:i});this.observer.observe(l,this.viewsObserverCallback),a&&(0,ee.fc)(l,a),r.querySelector(".bubble-content").prepend(l),u=this.chatInner,p="append",t=!1}else if(c&&"message"===e._){const e=document.createElement("b");e.append((0,E.ag)("BotInfoTitle")),l.push(e,"\n\n"),u=this.chatInner,p="prepend"}else h=this.chat.isAnyGroup&&(yield o(this.managers.appPeersManager.getPeer(this.peerId))).pFlags.creator?this.renderEmptyPlaceholder("group",r,e,l):"scheduled"===this.chat.type?this.renderEmptyPlaceholder("noScheduledMessages",r,e,l):n.Z.myId===this.peerId?this.renderEmptyPlaceholder("saved",r,e,l):this.peerId.isUser()&&!c&&(yield o(this.chat.canSend()))&&"chat"===this.chat.type?this.renderEmptyPlaceholder("greeting",r,e,l):this.renderEmptyPlaceholder("noMessages",r,e,l);h&&(yield h),l.length&&r.querySelector(".message, .service-msg").prepend(...l);const f=!!this.messagesQueueOnRenderAdditional,m=this.setPeerCached&&!f;if(m){const e=r.firstElementChild;e.classList.add("no-transition"),this.chat.setPeerPromise&&this.chat.setPeerPromise.catch(Ke.Z).finally((()=>{e.classList.remove("no-transition")}))}if(void 0!==t||m||(t=!0),f||t?(this.updatePlaceholderPosition=d,this.onAnimateLadder=()=>{if(this.onAnimateLadder=void 0,!this.messagesQueuePromise)return(0,V.AD)()}):this.chat.setPeerPromise?this.attachPlaceholderOnRender=()=>{this.attachPlaceholderOnRender=void 0,d()}:this.updatePlaceholderPosition=d,!f&&t){yield o((0,G.e9)());const t=(0,Ee.Z)(this.bubbles);(0,a.Z)(t,e.mid),this.animateAsLadder(e.mid,t,!1,0,0)}return r.middlewareHelper.onDestroy((()=>{this.emptyPlaceholderBubble===r&&(this.emptyPlaceholderBubble=void 0)})),this.emptyPlaceholderBubble=r,i}))))}))}makeViewButton(e){return(0,ve.Z)("btn-primary btn-primary-transparent bubble-view-button",e)}generateLocalMessageId(e=0){const t=("scheduled"===this.chat.type?-1:0)+e,i=-Math.abs(t);return{id:i,mid:-Math.abs((0,Oe.Z)(i))}}generateLocalFirstMessage(e,t,i=0){return Bt(this,void 0,void 0,(function*(){const{id:s,mid:n}=this.generateLocalMessageId(i);let a={_:e?"messageService":"message",date:0,id:s,mid:n,peer_id:yield this.managers.appPeersManager.getOutputPeer(this.peerId),pFlags:{local:!0}};return e||(a.message=""),(0,ae.Z)(a),t&&t(a),a=(yield this.managers.appMessagesManager.saveMessages([a],{storage:new Map}))[0],a.mid=n,a}))}getViewportSlice(){return(0,Ie.Z)({overflowElement:this.scrollable.container,selector:".bubbles-date-group .bubble:not(.is-date)",extraSize:2*Math.max(700,de.Z.height)})}deleteViewportSlice(e,t){const{invisibleTop:i,invisibleBottom:s}=e,n=i.concat(s);if(!n.length)return;i.length&&(this.setLoaded("top",!1),this.getHistoryTopPromise=void 0),s.length&&(this.setLoaded("bottom",!1),this.getHistoryBottomPromise=void 0);const a=n.map((({element:e})=>+e.dataset.mid));let o;t||(o=this.createScrollSaver(!!i.length),o.save()),this.deleteMessagesByIds(a,!1,!0),o?o.restore():i.length&&(this.scrollable.lastScrollPosition=this.scrollable.scrollTop)}sliceViewport(e){if(L.IS_SAFARI||this.isHeavyAnimationInProgress&&!e)return;const t=this.getViewportSlice();this.deleteViewportSlice(t)}setLoaded(e,t,i=!0){return Bt(this,void 0,void 0,(function*(){if(this.scrollable.loadedAll[e]!==t)return this.log.bindPrefix("setLoaded")("change",e,t),this.scrollable.loadedAll[e]=t,this.scrollable.onScroll(),i?!this.chat.isRestricted&&("bottom"===e&&this.chat.isBroadcast&&this.toggleSponsoredMessage(t),"top"===e&&t&&this.chat.isBot)?this.renderBotPlaceholder():this.checkIfEmptyPlaceholderNeeded():void 0}))}toggleSponsoredMessage(e){return Bt(this,void 0,void 0,(function*(){const t=this.log.bindPrefix("sponsored");t("checking");const{mid:i}=this.generateLocalMessageId(1);if(e){const e=this.getMiddleware((()=>this.scrollable.loadedAll.bottom&&this.getSponsoredMessagePromise===i)),i=this.getSponsoredMessagePromise=this.managers.appChatsManager.getSponsoredMessage(this.peerId.toChatId()).then((i=>Bt(this,void 0,void 0,(function*(){if(!e()||"messages.sponsoredMessagesEmpty"===i._)return;const s=i.messages[0];if(!s)return void t("no message");const n=this.generateLocalFirstMessage(!1,(e=>{e.message=s.message,e.from_id=s.from_id,e.entities=s.entities,e.pFlags.sponsored=!0,e.sponsoredMessage=s}),1);return Promise.all([n,this.getHistoryTopPromise,this.messagesQueuePromise]).then((([i])=>{if(e())return t("rendering",i),this.performHistoryResult({history:[i]},!1)}))})))).finally((()=>{this.getSponsoredMessagePromise===i&&(this.getSponsoredMessagePromise=void 0)}))}else t("clearing rendered",i),this.getSponsoredMessagePromise=void 0,this.deleteMessagesByIds([i])}))}renderBotPlaceholder(){return Bt(this,void 0,void 0,(function*(){const e=this.log.bindPrefix("bot placeholder"),t=this.getMiddleware(),i=yield this.managers.acknowledged.appProfileManager.getProfile(this.peerId.toUserId());e("getting profile, cached:",i.cached);const s=i.result.then((s=>Bt(this,void 0,void 0,(function*(){var n;if(!t())return;if(!(null===(n=s.bot_info)||void 0===n?void 0:n.description))return e.warn("no description"),this.checkIfEmptyPlaceholderNeeded();const a=yield this.generateLocalFirstMessage(!1,(e=>{const t=s.bot_info;e.message=t.description,t.description_document&&(e.media={_:"messageMediaDocument",document:t.description_document,pFlags:{}}),t.description_photo&&(e.media={_:"messageMediaPhoto",photo:t.description_photo,pFlags:{}})}));return t()?(e("rendering"),{renderPromise:this.processLocalMessageRender(a,!i.cached).then((()=>{e("done")}))}):void 0}))));if(i.cached)return s}))}checkIfEmptyPlaceholderNeeded(){return Bt(this,void 0,void 0,(function*(){if(this.scrollable.loadedAll.top&&this.scrollable.loadedAll.bottom&&void 0===this.emptyPlaceholderBubble&&(this.chat.isRestricted||!(yield this.chat.getHistoryStorage()).count||Object.keys(this.bubbles).length&&!this.getRenderedLength()||"scheduled"===this.chat.type&&!Object.keys(this.bubbles).length)){this.log("inject empty peer placeholder");const e=yield this.generateLocalFirstMessage(!0);return{renderPromise:this.processLocalMessageRender(e)}}}))}getHistory1(e,t,i,s,n){const a=this.getMiddleware(n?void 0:()=>(t?this.getHistoryTopPromise:this.getHistoryBottomPromise)===r),o=this.getHistory(e,t,i,s,n,a),r=o.then((e=>e&&(e.waitPromise||e.promise)));return t?this.getHistoryTopPromise=r:this.getHistoryBottomPromise=r,r.then((()=>{a()&&(t?this.getHistoryTopPromise=void 0:this.getHistoryBottomPromise=void 0,n||"chat"===this.chat.type&&setTimeout((()=>{t?this.loadMoreHistory(!0,!0):this.loadMoreHistory(!1,!0)}),0))})),o}getHistory(e=0,t=!1,i=!1,s=0,n=!1,a){return Bt(this,void 0,void 0,(function*(){const o=this.peerId,r=this.chat.isBroadcast,d=Math.min(30,de.Z.height/40|0);let l=r?20:Object.keys(this.bubbles).length>0?Math.max(35,d):d;if(void 0!==Ht){if(!Ht)return{cached:!1,promise:Promise.resolve(),waitPromise:Promise.resolve()};Object.keys(this.bubbles).length>0&&--Ht}let c,h=0;if(i&&(h=l,t||(l=0)),s&&!i)if("pinned"===this.chat.type)c=[s];else{const t=(yield this.chat.getHistoryStorage()).history.slice;if(t.length<l&&!t.isEnd($.D.Both)){c=t.slice();for(let e=c.length-1;e>=0;--e){const t=yield this.chat.getMessage(c[e]);if(!(null==t?void 0:t.grouped_id))break;c.splice(e,1)}e=c[c.length-1]||e}}let u,p=yield this.requestHistory(e,l,h);this.log("i vin brehnya",p,e,l,h);const f=(null==c?void 0:c.length)&&!p.cached,m=this.isFirstLoad&&h&&!p.cached||f;f&&(u=p.result,p={cached:!0,result:Promise.resolve({history:c})}),this.isFirstLoad=!1;const g=e=>Bt(this,void 0,void 0,(function*(){var t;if(null===(t=e.isEnd)||void 0===t?void 0:t.top){if("discussion"===this.chat.type){const t=yield this.managers.appMessagesManager.getThreadServiceMessageId(this.peerId,this.chat.threadId);t&&e.history.push(t);const i=yield this.chat.getMidsByMid(this.chat.threadId);e.history.push(...i.reverse())}yield this.managers.appProfileManager.getProfileByPeerId(o)}})),v=e=>(0,G.e9)().then((()=>g(e))).then((()=>(!f&&s&&e.history.unshift(s),this.performHistoryResult(e,t)))),b=e=>{const t=Promise.resolve(e).then((e=>{if(a&&!a())throw Gt;if(!n)return v(e);this.scrollable.onScroll()}),(e=>{throw this.log.error("getHistory error:",e),e}));return t};let y,w;if(p.cached){if(n)return this.scrollable.onScroll(),null;w=!0,y=v(yield p.result)}else w=!1,y=b(p.result);const S=f?b(u):y;if(m&&gt.Z.isAvailable("animations")){let i=f?2:1;this.messagesQueueOnRenderAdditional=()=>{this.log("messagesQueueOnRenderAdditional"),--i||(this.messagesQueueOnRenderAdditional=void 0,this.animateAsLadder(s,c,f,h,e).then((()=>{setTimeout((()=>{this.loadMoreHistory(t,!0)}),0)})))}}else this.messagesQueueOnRenderAdditional=void 0;return n?null:{cached:w,promise:y,waitPromise:S}}))}setUnreadDelimiter(){return Bt(this,void 0,void 0,(function*(){if("chat"!==this.chat.type&&"discussion"!==this.chat.type)return;if(this.attachedUnreadBubble)return;const e=yield this.chat.getHistoryMaxId();let t=yield this.managers.appMessagesManager.getReadMaxIdIfUnread(this.peerId,this.chat.threadId);if(t&&(t=Object.keys(this.bubbles).filter((e=>!this.bubbles[e].classList.contains("is-out"))).map((e=>+e)).sort(((e,t)=>e-t)).find((e=>e>t)),t&&this.bubbles[t])){const i=this.bubbles[t];this.firstUnreadBubble&&this.firstUnreadBubble!==i&&(this.firstUnreadBubble.classList.remove("is-first-unread"),this.firstUnreadBubble=null),t!==e&&i.classList.add("is-first-unread"),this.firstUnreadBubble=i,this.attachedUnreadBubble=!0}}))}deleteEmptyDateGroups(){const e=this.stickyIntersector?jt:1;let t=!1;for(const i in this.dateMessages){const s=this.dateMessages[i];s.container.childElementCount===e&&(s.container.remove(),this.stickyIntersector&&this.stickyIntersector.unobserve(s.container,s.div),delete this.dateMessages[i],t=!0)}t&&(Object.keys(this.dateMessages).length||this.container.classList.remove("has-groups"),this.checkIfEmptyPlaceholderNeeded(),this.setStickyDateManually())}}function qt(){const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttributeNS(null,"viewBox","0 0 11 20"),e.setAttributeNS(null,"width","11"),e.setAttributeNS(null,"height","20"),e.classList.add("bubble-tail");const t=document.createElementNS("http://www.w3.org/2000/svg","use");return t.setAttributeNS(null,"href","#message-tail-filled"),e.append(t),e}},4499:(e,t,i)=>{"use strict";i.d(t,{Z:()=>Se});var s=i(5432),n=i(3003),a=i(5128),o=i(4524),r=i(684),d=i(2166),l=i(1962),c=i(2796),h=i(2325),u=i(8497),p=i(3910),f=i(2738),m=i(1452),g=i(1168),v=i(2648),b=i(6787),y=i(4494),w=i(8127),S=i(503),C=i(5772);class L extends w.Z{constructor(e,t,i,s){super("popup-report-messages-confirm",{noTitle:!0,descriptionLangKey:"ReportInfo",buttons:[{langKey:"ReportChat",callback:()=>{a.isValid()&&(s&&s(),this.managers.appMessagesManager.reportMessages(e,t,i,a.value).then((e=>{e&&(0,c.bC)({langPackKey:"ReportSentInfo"})})))}}],body:!0});const n=document.createElement("div");(0,C.Z)({div:n,emoji:L.STICKER_EMOJI,width:100,height:100}).then((({render:e})=>e)).finally((()=>{this.show()})),this.header.replaceWith(n);const a=new S.ZP({label:"ReportHint",maxLength:512,placeholder:"ReportChatDescription"});a.input.addEventListener("input",(()=>{this.buttons[0].element.toggleAttribute("disabled",!a.isValid())})),this.body.append(a.container)}}L.STICKER_EMOJI="👮‍♀️";class E extends w.Z{constructor(e,t,i){super("popup-report-messages",{titleLangKey:"ChatTitle.ReportMessages",buttons:[],body:!0}),t=t.slice();const s=[["ReportChatSpam","inputReportReasonSpam"],["ReportChatViolence","inputReportReasonViolence"],["ReportChatChild","inputReportReasonChildAbuse"],["ReportChatPornography","inputReportReasonPornography"],["ReportChatOther","inputReportReasonOther"],["ReportChatPersonalDetails","inputReportReasonPersonalDetails"],["ReportChatIllegalDrugs","inputReportReasonIllegalDrugs"]];s.forEach((e=>{const t=(0,y.Z)("btn-primary btn-transparent",{text:e[0]});this.body.append(t)}));const n=(0,b.Z)(L.STICKER_EMOJI);(0,f.fc)(this.body,(a=>{const o=(0,u.Z)(a.target,"btn-primary"),r=s[(0,v.Z)(o)][1];n.then((()=>{this.hide(),g.Z.createPopup(L,e,t,r,i)}))}),{listenerSetter:this.listenerSetter}),this.buttonsEl.style.marginTop=".5rem",this.show()}}var I=i(8938);class P extends w.Z{constructor(){super("popup-sponsored",{titleLangKey:"Chat.Message.Sponsored.What",descriptionLangKey:"Chat.Message.Ad.Text",descriptionLangArgs:[(0,h.ag)("Chat.Message.Sponsored.Link")],buttons:[{langKey:"OK",isCancel:!0},{langKey:"Chat.Message.Ad.ReadMore",callback:()=>{window.open(h.ZP.format("Chat.Message.Sponsored.Link",!0))},isCancel:!0}],scrollable:!0}),this.scrollable.append(this.description),this.show()}}var Z=i(3699),M=i(3624),k=i(8842),T=i(2149),x=i(4762),A=i(8947),_=i(6008),F=i(8805),D=i(8936),R=i(5005),B=i(5565),N=i(3541),O=i(2482),U=i(3061),H=i(9405),z=i(9083),j=i(5029),G=i(632),V=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class K extends g.Z{constructor(e){super("popup-reacted-list",{closable:!0,overlayClosable:!0,body:!0}),this.message=e,this.init()}init(){return V(this,void 0,void 0,(function*(){const e=this.middlewareHelper.get(),t=yield this.managers.appMessagesManager.getGroupsFirstMessage(this.message);if(!e())return;const i=yield this.managers.appMessagesManager.canViewMessageReadParticipants(t);if(!e())return;const s=new A.Z,n=Object.assign(Object.assign({},t),{mid:0,id:0,reactions:Object.assign(Object.assign({_:"messageReactions",results:[]},t.reactions),{pFlags:{},recent_reactions:[]})});n.reactions.results=n.reactions.results.map((e=>Object.assign(Object.assign({},e),{chosen_order:void 0,pFlags:{}}))),s.init(n,"block",this.middlewareHelper.get()),s.render(),s.classList.add("no-stripe"),s.classList.remove("has-no-reactions"),s.append(this.btnClose),this.header.append(s);const a=document.createElement("div");a.classList.add("tabs-container"),a.dataset.animation="tabs";const o=new Map;let r=!1;if(n.reactions.results.length){const e=this.createFakeReaction("reactions",n.reactions.results.reduce(((e,t)=>e+t.count),0));s.prepend(e),n.reactions.results.unshift(e.reactionCount),r=!0}let d=!1;if(i)try{const i=yield this.managers.appMessagesManager.getMessageReadParticipants(t.peerId,t.mid);if(!e())return;if(!i.length)throw"";const a=this.createFakeReaction("checks",i.length);s.prepend(a),n.reactions.results.unshift(a.reactionCount),d=!0}catch(e){}n.reactions.results.forEach((i=>{const s=new F.ZP(void 0);s.container.classList.add("tabs-tab");const n=new j.Z({noShadow:!0,noDelimiter:!0}),r=R.default.createChatList({dialogSize:72});R.default.setListClickListener(r,(()=>{this.hide()}),void 0,!1,!0),n.content.append(r),s.container.append(n.container);const d="checks"!==i.reaction,l="checks"===i.reaction;["checks","reactions"].includes(i.reaction)&&(i.reaction=void 0);const c=(0,H.C)(24,24);let h;const u=new D.Z({scrollable:s,getPromise:()=>V(this,void 0,void 0,(function*(){const s=yield this.managers.appMessagesManager.getMessageReactionsListAndReadParticipants(t,void 0,i.reaction,h,d,l);return h=s.nextOffset,yield Promise.all(s.combined.map((({peerId:i,reaction:s,date:n})=>V(this,void 0,void 0,(function*(){const{dom:a}=R.default.addDialogNew({peerId:i,autonomous:!0,container:r,avatarSize:"abitbigger",rippleEnabled:!1,meAsSaved:!1});if(s){const t=document.createElement("div");if(t.classList.add("reacted-list-reaction-icon"),"reactionEmoji"===s._){const i=yield this.managers.appReactionsManager.getReactionCached(s.emoticon);(0,N.ZP)({doc:i.static_icon,div:t,width:24,height:24,middleware:e})}else"reactionCustomEmoji"===s._&&t.append((0,z.Z)({docIds:[s.document_id],customEmojiSize:c,middleware:e}));a.listEl.append(t)}if(n&&t.pFlags.out){const e=document.createElement("span");a.lastMessageSpan.style.cssText="display: flex !important; align-items: center;";const t=document.createElement("span");t.classList.add(s?"tgico-reactions":"tgico-checks","reacted-list-checks");const i=document.createDocumentFragment();e.append((0,G.OD)(n,!1)),i.append(t,e),(0,B.Z)(a.lastMessageSpan,i)}else{const e=yield this.managers.appUsersManager.getUser(i.toUserId());(0,B.Z)(a.lastMessageSpan,(0,U.Z)(e))}}))))),!h}))});o.set(s.container,u),a.append(s.container)})),this.body.append(a);const l=(0,_.X)(s,a,((e,t)=>{if(e===s.childElementCount-1)return!1;const i=s.children[e],n=l.prevId();-1!==n&&s.children[n].setIsChosen(!1),i.setIsChosen(!0),o.get(t).load()}),void 0,void 0,void 0,this.listenerSetter);l(0,!1),this.show()}))}createFakeReaction(e,t){const i=new O.ZP;i.init("block",this.middlewareHelper.get()),i.reactionCount={_:"reactionCount",count:t,reaction:e},i.setCanRenderAvatars(!1),i.renderCounter();const s=document.createElement("div");return s.classList.add("reaction-counter","reaction-sticker-icon","tgico-"+e),i.prepend(s),i}}var W=i(6654),$=i(8204),q=i(5994),Y=i(319),Q=i(3035),X=i(1447),J=i(3512),ee=i(5814);const te="btn-menu-reactions",ie=te+"-reaction",se=!x.IS_SAFARI;class ne{constructor(e,t,i){this.managers=e,this.type=t,this.onScroll=()=>{this.reactionsMap.forEach(((e,t)=>{this.onScrollProcessItem(t,e)}))},this.onMouseMove=e=>{var t;const i=(0,u.Z)(e.target,ie);if(!i)return;const s=this.reactionsMap.get(i);if(!s)return;if(!(null===(t=s.appear)||void 0===t?void 0:t.paused))return;const n=s.select;n&&n.paused&&(n.autoplay=!0,n.restart())};const n=this.widthContainer=document.createElement("div");n.classList.add(te+"-container"),n.classList.add(te+"-container-"+t);const a=this.container=document.createElement("div");a.classList.add(te);const o=this.scrollable="vertical"===t?new F.ZP(void 0):new F.v7(void 0);a.append(o.container),o.onAdditionalScroll=this.onScroll,o.setListeners(),o.container.classList.add("no-scrollbar"),this.reactionsMap=new Map,this.animationGroup=`CHAT-MENU-REACTIONS-${Date.now()}`,ee.Z.setOverrideIdleGroup(this.animationGroup,!0),s.Z||a.addEventListener("mousemove",this.onMouseMove),(0,f.fc)(a,(e=>{const t=(0,u.Z)(e.target,ie);if(!t)return;const i=this.reactionsMap.get(t);i&&this.managers.appReactionsManager.sendReaction(this.message,i.reaction)})),n.append(a),this.middleware=null!=i?i:(0,M.k)()}init(e){this.message=e;const t=this.middleware.get(),i=this.managers.appReactionsManager.getAvailableReactionsByMessage(e);(0,W.Z)(i,(e=>{if(!t()||!e.length)return;e.forEach((e=>{e.pFlags.premium&&!J.Z.premium||this.renderReaction(e)}));const s=()=>{this.container.classList.add("is-visible")};i instanceof Promise?(0,Q.T2)(s):s()}))}cleanup(){this.middleware.clean(),this.scrollable.removeListeners(),this.reactionsMap.clear(),ee.Z.setOverrideIdleGroup(this.animationGroup,!1),ee.Z.checkAnimations(!0,this.animationGroup,!0)}canUseAnimations(){return q.Z.isAvailable("animations")&&q.Z.isAvailable("stickers_chat")&&!x.IS_MOBILE}renderReaction(e){const t=document.createElement("div");t.classList.add(ie);const i=document.createElement("div");i.classList.add(ie+"-scale");const n=document.createElement("div");let a;n.classList.add(ie+"-appear"),this.canUseAnimations()&&(a=document.createElement("div"),a.classList.add(ie+"-select","hide"));const o={selectWrapper:a,appearWrapper:n,reaction:{_:"reactionEmoji",emoticon:e.reaction}};this.reactionsMap.set(t,o);const r=this.middleware.get(),d=26*(s.Z?1:1.25),l={width:d,height:d,skipRatio:1,needFadeIn:!1,withThumb:!1,group:this.animationGroup,middleware:r};if(this.canUseAnimations()){let t=!0;(0,N.ZP)(Object.assign({doc:e.appear_animation,div:n,play:!0,liteModeKey:!1},l)).then((({render:e})=>e)).then((e=>{(0,I.Z)(e),o.appear=e,e.addEventListener("enterFrame",(s=>{e.maxFrame===s&&i.then((e=>{(0,I.Z)(e),n.classList.add("hide"),a.classList.remove("hide"),t&&(o.select=e,t=!1)}),Y.Z)}))}),Y.Z);const i=(0,N.ZP)(Object.assign({doc:e.select_animation,div:a,liteModeKey:!1},l)).then((({render:e})=>e)).then((e=>((0,I.Z)(e),X.Z.waitForFirstFrame(e)))).catch(Y.Z)}else delete l.needFadeIn,delete l.withThumb,(0,N.ZP)(Object.assign({doc:e.static_icon,div:n,liteModeKey:!1},l));i.append(n),a&&i.append(a),t.append(i),this.scrollable.append(t)}onScrollProcessItem(e,t){const i=e.firstElementChild,s=(0,$.Z)(e,this.scrollable.container);let n;if(s)if(s.overflow.left||s.overflow.right){const e=Math.abs(s.rect.left-s.rect.right);n="scale("+Math.min(Math.pow(e,2)/Math.pow(34,2),1)+")"}else n="";else{if(!t.appearWrapper.classList.contains("hide")||!t.appear)return;t.select&&t.select.stop(),t.appear.stop(),t.appear.autoplay=!0,t.appearWrapper.classList.remove("hide"),t.selectWrapper.classList.add("hide"),n=""}se&&(i.style.transform=n)}}var ae=i(2946),oe=i(2790),re=i(1483),de=i(3416),le=i(6976),ce=i(2353),he=i(2312),ue=i(1507),pe=i(6690),fe=i(8115),me=i(3725),ge=i(9298),ve=i(7530),be=i(3709),ye=i(2381),we=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class Se{constructor(e,t){this.chat=e,this.managers=t,this.onContextMenu=e=>{let t,i;try{i=(0,u.Z)(e.target,"bubble-content-wrapper"),t=i?i.parentElement:(0,u.Z)(e.target,"bubble")}catch(e){}if(!t||t.classList.contains("bubble-first"))return;let s=this.element;if((e instanceof MouseEvent||e.hasOwnProperty("preventDefault"))&&e.preventDefault(),s&&s.classList.contains("active"))return!1;(e instanceof MouseEvent||e.hasOwnProperty("cancelBubble"))&&(e.cancelBubble=!0);let n=+t.dataset.mid;n&&(()=>{we(this,void 0,void 0,(function*(){const a=this.isSponsored=n<0;this.isSelectable=this.chat.selection.canSelectBubble(t),this.peerId=this.chat.peerId,this.target=e.target,this.isTextSelected=!(0,m.Z)(),this.isAnchorTarget="A"===this.target.tagName&&("_blank"===this.target.target||this.target.classList.contains("anchor-url")),this.isUsernameTarget="A"===this.target.tagName&&this.target.classList.contains("mention"),this.sponsoredMessage=a?t.message.sponsoredMessage:void 0;const o=yield this.chat.getMidsByMid(n);if(this.chat.selection.isSelecting&&!i){if(a)return;if(o.length>1){const e=this.chat.selection.isMidSelected(this.peerId,n)?n:o.find((e=>this.chat.selection.isMidSelected(this.peerId,e)));e&&(n=e)}}this.isOverBubble=!!i;const r=(0,u.Z)(this.target,"grouped-item");this.isTargetAGroupedItem=!!r,this.mid=r?+r.dataset.mid:n,this.isSelected=this.chat.selection.isMidSelected(this.peerId,this.mid),this.message=t.message||(yield this.chat.getMessage(this.mid)),this.albumMessages=this.message.grouped_id?yield this.managers.appMessagesManager.getMessagesByAlbum(this.message.grouped_id):void 0,this.noForwards=!a&&!(yield this.managers.appMessagesManager.canForward(this.message)),this.viewerPeerId=void 0,this.canOpenReactedList=void 0,this.linkToMessage=yield this.getUrlToMessage(),this.selectedMessagesText=yield this.getSelectedMessagesText(),this.selectedMessages=this.chat.selection.isSelecting?yield this.chat.selection.getSelectedMessages():void 0;const d=yield this.init();if(!d)return;s=d.element;const{cleanup:l,destroy:c,menuPadding:h,reactionsMenu:p,reactionsMenuPosition:f}=d;let g=!1;if(p){const e="is-visible";if(g=p.container.classList.contains(e),g&&p.container.classList.remove(e),"horizontal"===f){const e=s.offsetWidth,t=(e-8)/34%1,i=.65;if(t<i){const n=e+34*(i-t)|0;s.style.minWidth=n+"px"}}}const v=t.classList.contains("is-in")?"left":"right";(0,re.Z)(e.touches?e.touches[0]:e,s,v,h),p&&(p.widthContainer.style.top=s.style.top,p.widthContainer.style.left=s.style.left,p.widthContainer.style.setProperty("--menu-width",s["vertical"===f?"offsetHeight":"offsetWidth"]+"px"),s.parentElement.append(p.widthContainer),g&&p.container.offsetLeft),de.Z.openBtnMenu(s,(()=>{p&&p.container.classList.remove("is-visible"),this.mid=0,this.peerId=void 0,this.target=null,this.viewerPeerId=void 0,this.canOpenReactedList=void 0,l(),setTimeout((()=>{c()}),300)})),g&&p.container.classList.add("is-visible")}))})()},this.onSendScheduledClick=()=>we(this,void 0,void 0,(function*(){this.chat.selection.isSelecting?(0,f.tH)(this.chat.selection.selectionSendNowBtn):g.Z.createPopup(l.Z,this.peerId,yield this.chat.getMidsByMid(this.mid))})),this.onReplyClick=()=>{this.chat.input.initMessageReply(this.mid)},this.onFaveStickerClick=e=>{const t=this.message.media.document.id;this.managers.appStickersManager.faveSticker(t,e)},this.onEditClick=()=>{const e=this.getMessageWithText();this.chat.input.initMessageEditing(this.isTargetAGroupedItem?this.mid:e.mid)},this.onCopyClick=()=>we(this,void 0,void 0,(function*(){(0,m.Z)()?(0,d.T)(this.selectedMessagesText):document.execCommand("copy")})),this.onCopyAnchorLinkClick=()=>{(0,d.T)(this.target.href)},this.onCopyLinkClick=()=>{const{url:e,isPrivate:t}=this.linkToMessage,i=t?"LinkCopiedPrivateInfo":"LinkCopied";(0,c.Am)(h.ZP.format(i,!0)),(0,d.T)(e)},this.onPinClick=()=>{g.Z.createPopup(r.Z,this.peerId,this.mid)},this.onUnpinClick=()=>{g.Z.createPopup(r.Z,this.peerId,this.mid,!0)},this.onRetractVote=()=>{this.managers.appPollsManager.sendVote(this.message,[])},this.onStopPoll=()=>{this.managers.appPollsManager.stopPoll(this.message)},this.onForwardClick=()=>we(this,void 0,void 0,(function*(){if(this.chat.selection.isSelecting)(0,f.tH)(this.chat.selection.selectionForwardBtn);else{const e=this.peerId,t=this.isTargetAGroupedItem?[this.mid]:yield this.chat.getMidsByMid(this.mid);o.Z.create({[e]:t})}})),this.onSelectClick=()=>{this.chat.selection.toggleByElement((0,u.Z)(this.target,"grouped-item")||(0,u.Z)(this.target,"bubble"))},this.onClearSelectionClick=()=>{this.chat.selection.cancelSelection()},this.onDeleteClick=()=>we(this,void 0,void 0,(function*(){this.chat.selection.isSelecting?(0,f.tH)(this.chat.selection.selectionDeleteBtn):g.Z.createPopup(a.Z,this.peerId,this.isTargetAGroupedItem?[this.mid]:yield this.chat.getMidsByMid(this.mid),this.chat.type)})),this.listenerSetter=new Z.Z,this.attachListenerSetter=new Z.Z,this.middleware=(0,M.k)()}attachTo(e){this.attachListenerSetter.removeAll(),s.Z?(0,f.fc)(e,(e=>{this.chat.selection.isSelecting||(this.chat.log("touchend",e),!e.target.closest([".name",".peer-title",".reply",".document","audio-element","avatar-element","a",".bubble-beside-button","replies-element","[data-saved-from]:not(.bubble)","poll-element",".attachment",".reply-markup-button"].join(", "))&&((0,p.Z)(e),this.onContextMenu(e)))}),{listenerSetter:this.attachListenerSetter}):(0,le.E)({element:e,callback:this.onContextMenu,listenerSetter:this.attachListenerSetter})}cleanup(){this.listenerSetter.removeAll(),this.reactionsMenu&&this.reactionsMenu.cleanup(),this.middleware.clean()}destroy(){this.cleanup(),this.attachListenerSetter.removeAll()}filterButtons(e){return we(this,void 0,void 0,(function*(){return(0,ce.Z)(e,(e=>we(this,void 0,void 0,(function*(){let t;return!(this.isSponsored&&!e.isSponsored||!this.isSponsored&&e.isSponsored||(this.chat.selection.isSelecting&&!e.withSelection?t=!1:(this.isOverBubble||s.Z,t=yield e.verify()),!t))}))))}))}setButtons(){var e,t;const i=e=>we(this,void 0,void 0,(function*(){var t;const i=null===(t=this.message.media)||void 0===t?void 0:t.document;if(!(null==i?void 0:i.sticker))return!1;const s=yield this.managers.acknowledged.appStickersManager.getFavedStickersStickers();if(!s.cached)return!1;const n=(yield s.result).some((e=>e.id===i.id));return e?!n:n}));this.buttons=[{icon:"send2",text:"MessageScheduleSend",onClick:this.onSendScheduledClick,verify:()=>"scheduled"===this.chat.type&&!this.message.pFlags.is_outgoing},{icon:"send2",text:"Message.Context.Selection.SendNow",onClick:this.onSendScheduledClick,verify:()=>"scheduled"===this.chat.type&&this.isSelected&&!this.chat.selection.selectionSendNowBtn.hasAttribute("disabled"),notDirect:()=>!0,withSelection:!0},{icon:"schedule",text:"MessageScheduleEditTime",onClick:()=>{this.chat.input.scheduleSending((()=>{(0,I.Z)(this.message),this.managers.appMessagesManager.editMessage(this.message,this.message.message,{scheduleDate:this.chat.input.scheduleDate,entities:this.message.entities}),this.chat.input.onMessageSent(!1,!1)}),new Date(1e3*this.message.date))},verify:()=>"scheduled"===this.chat.type},{icon:"reply",text:"Reply",onClick:this.onReplyClick,verify:()=>we(this,void 0,void 0,(function*(){return(yield this.chat.canSend())&&!this.message.pFlags.is_outgoing&&!!this.chat.input.messageInput&&"scheduled"!==this.chat.type}))},{icon:"favourites",text:"AddToFavorites",onClick:this.onFaveStickerClick.bind(this,!1),verify:()=>i(!0)},{icon:"favourites",text:"DeleteFromFavorites",onClick:this.onFaveStickerClick.bind(this,!0),verify:()=>i(!1)},{icon:"edit",text:"Edit",onClick:this.onEditClick,verify:()=>we(this,void 0,void 0,(function*(){return(yield this.managers.appMessagesManager.canEditMessage(this.message,"text"))&&!!this.chat.input.messageInput}))},{icon:"copy",text:"Copy",onClick:this.onCopyClick,verify:()=>!(this.noForwards||!this.message.message||this.isTextSelected||this.isAnchorTarget&&this.message.message===this.target.innerText)},{icon:"copy",text:"Chat.CopySelectedText",onClick:this.onCopyClick,verify:()=>!this.noForwards&&!!this.message.message&&this.isTextSelected},{icon:"copy",text:"Message.Context.Selection.Copy",onClick:this.onCopyClick,verify:()=>we(this,void 0,void 0,(function*(){if(!this.isSelected||this.noForwards)return!1;for(const[e,t]of this.chat.selection.selectedMids){const i=`${e}_${"scheduled"===this.chat.type?"scheduled":"history"}`;for(const e of t)if((yield this.managers.appMessagesManager.getMessageFromStorage(i,e)).message)return!0}return!1})),notDirect:()=>!0,withSelection:!0},{icon:"copy",text:"CopyLink",onClick:this.onCopyAnchorLinkClick,verify:()=>this.isAnchorTarget,withSelection:!0},{icon:"copy",text:"Text.Context.Copy.Username",onClick:()=>{(0,d.T)(this.target.textContent)},verify:()=>this.isUsernameTarget,withSelection:!0},{icon:"copy",text:"Text.Context.Copy.Hashtag",onClick:()=>{(0,d.T)(this.target.textContent)},verify:()=>this.target.classList.contains("anchor-hashtag"),withSelection:!0},{icon:"link",text:"MessageContext.CopyMessageLink1",onClick:this.onCopyLinkClick,verify:()=>we(this,void 0,void 0,(function*(){return(yield this.managers.appPeersManager.isChannel(this.peerId))&&!this.message.pFlags.is_outgoing}))},{icon:"pin",text:"Message.Context.Pin",onClick:this.onPinClick,verify:()=>we(this,void 0,void 0,(function*(){return!this.message.pFlags.is_outgoing&&"messageService"!==this.message._&&!this.message.pFlags.pinned&&(yield this.managers.appPeersManager.canPinMessage(this.peerId))&&"scheduled"!==this.chat.type}))},{icon:"unpin",text:"Message.Context.Unpin",onClick:this.onUnpinClick,verify:()=>we(this,void 0,void 0,(function*(){return this.message.pFlags.pinned&&(yield this.managers.appPeersManager.canPinMessage(this.peerId))}))},{icon:"download",text:"MediaViewer.Context.Download",onClick:()=>Se.onDownloadClick(this.message,this.noForwards),verify:()=>Se.canDownload(this.message,this.target,this.noForwards)},{icon:"checkretract",text:"Chat.Poll.Unvote",onClick:this.onRetractVote,verify:()=>{var e;const t=null===(e=this.message.media)||void 0===e?void 0:e.poll;return t&&t.chosenIndexes.length&&!t.pFlags.closed&&!t.pFlags.quiz}},{icon:"stop",text:"Chat.Poll.Stop",onClick:this.onStopPoll,verify:()=>we(this,void 0,void 0,(function*(){var e;const t=null===(e=this.message.media)||void 0===e?void 0:e.poll;return(yield this.managers.appMessagesManager.canEditMessage(this.message,"poll"))&&t&&!t.pFlags.closed&&!this.message.pFlags.is_outgoing}))},{icon:"forward",text:"Forward",onClick:this.onForwardClick,verify:()=>!(this.noForwards||"scheduled"===this.chat.type||this.message.pFlags.is_outgoing&&this.message.fromId!==ue.yF||"messageService"===this.message._)},{icon:"forward",text:"Message.Context.Selection.Forward",onClick:this.onForwardClick,verify:()=>this.chat.selection.selectionForwardBtn&&this.isSelected&&!this.chat.selection.selectionForwardBtn.hasAttribute("disabled"),notDirect:()=>!0,withSelection:!0},{icon:"download",text:"Message.Context.Selection.Download",onClick:()=>Se.onDownloadClick(this.selectedMessages,this.noForwards),verify:()=>this.selectedMessages&&Se.canDownload(this.selectedMessages,void 0,this.noForwards),withSelection:!0},{icon:"flag",text:"ReportChat",onClick:()=>{g.Z.createPopup(E,this.peerId,[this.mid])},verify:()=>we(this,void 0,void 0,(function*(){return!this.message.pFlags.out&&"message"===this.message._&&!this.message.pFlags.is_outgoing&&(yield this.managers.appPeersManager.isChannel(this.peerId))})),notDirect:()=>!0,withSelection:!0},{icon:"select",text:"Message.Context.Select",onClick:this.onSelectClick,verify:()=>!this.message.action&&!this.isSelected&&this.isSelectable,notDirect:()=>!0,withSelection:!0},{icon:"select",text:"Message.Context.Selection.Clear",onClick:this.onClearSelectionClick,verify:()=>this.isSelected,notDirect:()=>!0,withSelection:!0},{onClick:()=>{if(this.viewerPeerId,!this.canOpenReactedList)return!1;g.Z.createPopup(K,this.message)},verify:()=>we(this,void 0,void 0,(function*(){var e,t;return!this.peerId.isUser()&&(!!(null===(t=null===(e=this.message.reactions)||void 0===e?void 0:e.recent_reactions)||void 0===t?void 0:t.length)||(yield this.managers.appMessagesManager.canViewMessageReadParticipants(this.message)))})),notDirect:()=>!0,localName:"views"},{icon:"delete danger",text:"Delete",onClick:this.onDeleteClick,verify:()=>we(this,void 0,void 0,(function*(){return this.managers.appMessagesManager.canDeleteMessage(this.message)}))},{icon:"delete danger",text:"Message.Context.Selection.Delete",onClick:this.onDeleteClick,verify:()=>this.isSelected&&!this.chat.selection.selectionDeleteBtn.hasAttribute("disabled"),notDirect:()=>!0,withSelection:!0},{icon:"info",text:"Chat.Message.Sponsored.What",onClick:()=>{g.Z.createPopup(P)},verify:()=>this.isSponsored,isSponsored:!0},{icon:"copy",text:"Copy",onClick:()=>(0,d.T)(this.sponsoredMessage.message),verify:()=>this.isSponsored,isSponsored:!0},{text:"Loading",onClick:()=>{this.emojiInputsPromise.then((e=>{g.Z.createPopup(ge.Z,e,!0).show()}))},verify:()=>!!this.getUniqueCustomEmojisFromMessage().length,notDirect:()=>!0,localName:"emojis"},{regularText:(null===(e=this.sponsoredMessage)||void 0===e?void 0:e.sponsor_info)?(0,fe.Z)(this.sponsoredMessage.sponsor_info):void 0,separator:!0,multiline:!0,onClick:()=>(0,d.T)(this.sponsoredMessage.sponsor_info),verify:()=>!!this.sponsoredMessage.sponsor_info,isSponsored:!0},{regularText:(null===(t=this.sponsoredMessage)||void 0===t?void 0:t.additional_info)?(0,fe.Z)(this.sponsoredMessage.additional_info):void 0,separator:!0,multiline:!0,onClick:()=>(0,d.T)(this.sponsoredMessage.additional_info),verify:()=>!!this.sponsoredMessage.additional_info,isSponsored:!0}]}static canDownload(e,t,i){var n,a;if(Array.isArray(e))return e.some((e=>Se.canDownload(e,t,i)));if(!(0,be.Z)(e)||i)return!1;let o=!1;if(null===(n=e.media)||void 0===n?void 0:n.photo)o=!0;else{if(!(null===(a=e.media)||void 0===a?void 0:a.document))return!1;o=!0}let r=!t||!!s.Z;return o&&t&&(r||(r=!!((0,u.Z)(t,"document")||(0,u.Z)(t,"audio")||(0,u.Z)(t,"media-sticker-wrapper")||(0,u.Z)(t,"media-photo")||(0,u.Z)(t,"media-video")))),o&&r}getMessageWithText(){return this.albumMessages&&(0,ye.Z)(this.albumMessages)||this.message}getUniqueCustomEmojisFromMessage(){const e=[],t=this.getMessageWithText(),i=t.entities;if(i){const t=i.filter((e=>"messageEntityCustomEmoji"===e._));e.push(...t.map((e=>e.document_id)))}const s=t.reactions;if(s){const t=s.results.filter((e=>"reactionCustomEmoji"===e.reaction._));e.push(...t.map((e=>e.reaction.document_id)))}return(0,pe.Z)(e)}init(){return we(this,void 0,void 0,(function*(){this.cleanup(),this.setButtons();const e=yield this.filterButtons(this.buttons);if(!e.length)return;const t=this.element=yield(0,n.Z)({buttons:e,listenerSetter:this.listenerSetter});t.id="bubble-contextmenu",t.classList.add("contextmenu");const i=e.find((e=>"views"===e.localName));if(i){const e=this.message.reactions,t=null==e?void 0:e.recent_reactions,s=!!(null==t?void 0:t.length),n=(yield this.managers.appMessagesManager.canViewMessageReadParticipants(this.message))?(yield this.managers.appPeersManager.getPeer(this.peerId)).participants_count:void 0,a=e?e.results.reduce(((e,t)=>e+t.count),0):void 0;i.element.classList.add("tgico-"+(s?"reactions":"checks"));const o=new h.ZP.IntlElement({key:s?void 0===n?"Chat.Context.ReactedFast":"Chat.Context.Reacted":"NobodyViewed",args:s?void 0===n?[a]:[n,n]:void 0,element:i.textElement});let r;r=s?void 0===n?(0,h.ag)("Chat.Context.ReactedFast",[a]):(0,h.ag)(t.length===n?"Chat.Context.ReactedFast":"Chat.Context.Reacted",[t.length,n]):(0,h.ag)("Loading"),r.classList.add("btn-menu-item-text-fake"),i.element.append(r);const d=22,l=3,c=1.125;o.element.style.visibility="hidden",o.element.style.paddingRight=s?c*Math.min(l,t.length)+"rem":"1rem";const u=this.middleware.get();this.managers.appMessagesManager.getMessageReactionsListAndReadParticipants(this.message).then((e=>{if(!u())return;null==r||r.remove();const a=e.combined,p=void 0===n?e.reactionsCount:s?a.filter((e=>e.reaction)).length:a.length;let f;if(1===a.length)f=new k.Z({peerId:a[0].peerId,onlyFirstName:!0,dialog:!1}).element,(!s||e.readParticipantDates.length<=1)&&(this.viewerPeerId=a[0].peerId);else if(s){const e=p===a.length||void 0===n;f=(0,h.ag)(e?"Chat.Context.ReactedFast":"Chat.Context.Reacted",e?[p]:[p,a.length])}else a.length?f=(0,h.ag)("MessageSeen",[a.length]):o.element.style.visibility="";if(f&&(f.style.paddingRight=c*Math.min(l,p)+"rem",f.classList.add("btn-menu-item-text-fake"),i.element.append(f)),a.length){const e=new T.Z({avatarSize:d});e.render(t?t.map((e=>(0,ae.Z)(e.peer_id))):a.map((e=>e.peerId))),i.element.append(e.container),this.canOpenReactedList=!0}}))}let a,o,r;if(!("message"!==this.message._||this.chat.selection.isSelecting||this.message.pFlags.is_outgoing||this.message.pFlags.is_scheduled||this.message.pFlags.local)){r=x.IS_APPLE||s.Z?"horizontal":"vertical",o=this.reactionsMenu=new ne(this.managers,r,this.middleware),o.init(yield this.managers.appMessagesManager.getGroupsFirstMessage(this.message));const e=44,t=0;a="vertical"===r?{top:t,left:e}:{top:e,right:0,left:t}}const d=e.find((e=>"emojis"===e.localName));if(d){d.element.classList.add("is-multiline"),d.element.parentElement.insertBefore(document.createElement("hr"),d.element);const e=()=>{null!=a||(a={}),a.bottom=24},t=this.getUniqueCustomEmojisFromMessage(),i=this.emojiInputsPromise=(0,me.Z)();yield this.managers.appEmojiManager.getCachedCustomEmojiDocuments(t).then((s=>we(this,void 0,void 0,(function*(){const n=t=>we(this,void 0,void 0,(function*(){const s=new Map;t.forEach((e=>{e&&!s.has(e.stickerSetInput.id)&&s.set(e.stickerSetInput.id,e.stickerSetInput)}));const n=[...s.values()];if(i.resolve(n),1===s.size){const t=yield this.managers.acknowledged.appStickersManager.getStickerSet(n[0]),i=t.result.then((e=>{const t=(0,h.ag)("MessageContainsEmojiPack",[(0,fe.Z)(e.set.title)]);(0,B.Z)(d.textElement,t)}));return t.cached?i:void e()}(0,B.Z)(d.textElement,(0,h.ag)("MessageContainsEmojiPacks",[s.size]))}));if(!s.some((e=>!e)))return n(s);e(),this.managers.appEmojiManager.getCustomEmojiDocuments(t).then(n)}))))}return this.chat.container.append(t),{element:t,cleanup:()=>{this.cleanup(),o&&o.cleanup()},destroy:()=>{t.remove(),o&&o.widthContainer.remove()},menuPadding:a,reactionsMenu:o,reactionsMenuPosition:r}}))}getUrlToMessage(){return we(this,void 0,void 0,(function*(){if(this.peerId.isUser())return;let e;const{peerId:t,mid:i}=this,s=this.chat.threadId;"discussion"===this.chat.type&&(e=yield this.managers.appMessagesManager.getMessageByPeer(t,s));const n=yield this.managers.appPeersManager.getPeerUsername(e?e.fromId:t),a=(0,oe.Z)(i);let o="https://t.me/";return n?(o+=n,o+=e?`/${(0,oe.Z)(e.fwd_from.channel_post)}?comment=${a}`:s?`/${(0,oe.Z)(s)}/${a}`:"/"+a):(o+="c/"+t.toChatId(),o+=e?`/${a}?thread=${(0,oe.Z)(e.mid)}`:s?`/${(0,oe.Z)(s)}/${a}`:"/"+a),{url:o,isPrivate:!n}}))}getSelectedMessagesText(){return we(this,void 0,void 0,(function*(){if(!(0,m.Z)())return"";const e=this.chat.selection.isSelecting?[...this.chat.selection.selectedMids.get(this.peerId)].sort(((e,t)=>e-t)):[this.mid];return(yield Promise.all(e.map((e=>we(this,void 0,void 0,(function*(){const t=yield this.chat.getMessage(e);return(null==t?void 0:t.message)?t.message+"\n":""})))))).join("")}))}static onDownloadClick(e,t){return Array.isArray(e)?e.map((e=>this.onDownloadClick(e))):this.canDownload(e,void 0,t)?he.Z.downloadToDisc({media:(0,ve.Z)(e,!0)}):void 0}}},1571:(e,t,i)=>{"use strict";i.d(t,{Z:()=>a});var s=i(5296),n=i(2064);class a{constructor(){this._width=50,this._height=50,this._tails=90,this._scrollTails=50,this._curve=[0,.25,.5,.75,1,1.5,2,2.5,3,3.5,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,18.3,18.6,18.9,19.2,19.5,19.8,20.1,20.4,20.7,21,21.3,21.6,21.9,22.2,22.5,22.8,23.1,23.4,23.7,24,24.3,24.6,24.9,25.2,25.5,25.8,26.1,26.3,26.4,26.5,26.6,26.7,26.8,26.9,27],this._positions=[{x:.8,y:.1},{x:.6,y:.2},{x:.35,y:.25},{x:.25,y:.6},{x:.2,y:.9},{x:.4,y:.8},{x:.65,y:.75},{x:.75,y:.4}],this._phases=this._positions.length,this.onWheel=e=>{this._animatingToNextPosition||(this._scrollDelta+=e.deltaY,void 0===this._onWheelRAF&&(this._onWheelRAF=requestAnimationFrame(this.drawOnWheel)))},this.drawOnWheel=()=>{const e=this._scrollDelta/this._scrollTails;this._scrollDelta%=this._scrollTails;const t=e>0?Math.floor(e):Math.ceil(e);t&&this.changeTailAndDraw(t),this._onWheelRAF=void 0},this.drawNextPositionAnimated=e=>{var t;let i,s;if(e){const s=e();i=s>=1;const a=-1*(n=s)*(n-2),o=null!==(t=this._nextPositionTail)&&void 0!==t?t:0,r=(this._nextPositionTail=this._nextPositionTails*a)-o;r&&(this._nextPositionLeft-=r,this.changeTailAndDraw(r))}else{const e=this._frames;s=e.shift(),i=!e.length}var n;return s&&this.drawImageData(s),i&&(this._nextPositionLeft=void 0,this._nextPositionTails=void 0,this._nextPositionTail=void 0,this._animatingToNextPosition=void 0),!i};const e=this._tails/this._curve[this._curve.length-1];for(let t=0,i=this._curve.length;t<i;++t)this._curve[t]=this._curve[t]*e;this._incrementalCurve=this._curve.map(((e,t,i)=>{var s;return e-(null!==(s=i[t-1])&&void 0!==s?s:0)}))}hexToRgb(e){const t=(0,n.oo)(e);return{r:t[0],g:t[1],b:t[2]}}getPositions(e){const t=this._positions.slice();t.push(...t.splice(0,e));const i=[];for(let e=0;e<t.length;e+=2)i.push(t[e]);return i}getNextPositions(e,t,i){const s=this.getPositions(e);if(!i[0]&&1===i.length)return[s];const n=this.getPositions(++e%this._phases).map(((e,i)=>({x:(e.x-s[i].x)/t,y:(e.y-s[i].y)/t})));return i.map((e=>n.map(((t,i)=>({x:s[i].x+t.x*e,y:s[i].y+t.y*e})))))}curPosition(e,t){return this.getNextPositions(e,this._tails,[t])[0]}changeTail(e){for(this._tail+=e;this._tail>=this._tails;)this._tail-=this._tails,++this._phase>=this._phases&&(this._phase-=this._phases);for(;this._tail<0;)this._tail+=this._tails,--this._phase<0&&(this._phase+=this._phases)}changeTailAndDraw(e){this.changeTail(e);const t=this.curPosition(this._phase,this._tail);this.drawGradient(t)}getGradientImageData(e){const t=this._hctx.createImageData(this._width,this._height),i=t.data;let s=0;for(let t=0;t<this._height;++t){const n=t/this._height-.5,a=n*n;for(let t=0;t<this._width;++t){const o=t/this._width-.5,r=.35*Math.sqrt(o*o+a),d=r*r*.8*8,l=Math.sin(d),c=Math.cos(d),h=Math.max(0,Math.min(1,.5+o*c-n*l)),u=Math.max(0,Math.min(1,.5+o*l+n*c));let p=0,f=0,m=0,g=0;for(let t=0;t<this._colors.length;t++){const i=h-e[t].x,s=u-e[t].y;let n=Math.max(0,.9-Math.sqrt(i*i+s*s));n*=n*n*n,p+=n,f+=n*this._colors[t].r/255,m+=n*this._colors[t].g/255,g+=n*this._colors[t].b/255}i[s++]=f/p*255,i[s++]=m/p*255,i[s++]=g/p*255,i[s++]=255}}return t}drawImageData(e){this._hctx.putImageData(e,0,0),this._ctx.drawImage(this._hc,0,0,this._width,this._height)}drawGradient(e){this.drawImageData(this.getGradientImageData(e))}init(e){this._frames=[],this._phase=0,this._tail=0,this._scrollDelta=0,void 0!==this._onWheelRAF&&(cancelAnimationFrame(this._onWheelRAF),this._onWheelRAF=void 0);const t=e.getAttribute("data-colors").split(",").reverse();this._colors=t.map((e=>this.hexToRgb(e))),this._hc||(this._hc=document.createElement("canvas"),this._hc.width=this._width,this._hc.height=this._height,this._hctx=this._hc.getContext("2d",{alpha:!1})),this._canvas=e,this._ctx=this._canvas.getContext("2d",{alpha:!1}),this.update()}update(){if(this._colors.length<2){const e=this._colors[0];return this._ctx.fillStyle=`rgb(${e.r}, ${e.g}, ${e.b})`,void this._ctx.fillRect(0,0,this._width,this._height)}const e=this.curPosition(this._phase,this._tail);this.drawGradient(e)}toNextPosition(e){var t,i;if(this._colors.length<2)return;if(e)return this._nextPositionLeft=this._tails+(null!==(t=this._nextPositionLeft)&&void 0!==t?t:0),this._nextPositionTails=this._nextPositionLeft,this._nextPositionTail=void 0,this._animatingToNextPosition=!0,void(0,s.cK)(this.drawNextPositionAnimated.bind(this,e),this);const n=this._tail,a=this._tails;let o;const r=[];for(let e=0,t=this._incrementalCurve.length;e<t;++e){const t=this._incrementalCurve[e];let s=(null!==(i=r[e-1])&&void 0!==i?i:n)+t;+s.toFixed(2)>a&&void 0===o&&(o=e,s%=a),r.push(s)}[r.slice(0,o),void 0!==o?r.slice(o):[]].forEach(((e,t,i)=>{const s=e[e.length-1];if(void 0!==s&&s>a&&(e[e.length-1]=+s.toFixed(2)),this._tail=null!=s?s:0,!e.length)return;const n=this.getNextPositions(this._phase,a,e);t!==i.length-1&&++this._phase>=this._phases&&(this._phase-=this._phases);const o=n.map((e=>this.getGradientImageData(e)));this._frames.push(...o)})),this._animatingToNextPosition=!0,(0,s.cK)(this.drawNextPositionAnimated,this)}scrollAnimate(e){}cleanup(){this.scrollAnimate(!1)}static createCanvas(e){const t=document.createElement("canvas");return t.width=50,t.height=50,void 0!==e&&(t.dataset.colors=e),t}static create(e){const t=this.createCanvas(e),i=new a;return i.init(t),{gradientRenderer:i,canvas:t}}}},8843:(e,t,i)=>{"use strict";i.d(t,{m:()=>Bt,Z:()=>Nt});var s=i(7030),n=i(4329),a=i.n(n),o=i(5432),r=i(9043),d=i(3003),l=i(3173),c=i(1168),h=i(9807),u=i(503),p=i(1218),f=i(8805),m=i(6676),g=i(2325),v=i(4668),b=i(3910),y=i(1293),w=i(2648),S=i(2738),C=i(9336),L=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class E extends c.Z{constructor(e){super("popup-create-poll popup-new-media",{closable:!0,withConfirm:"Create",body:!0,title:"NewPoll"}),this.chat=e,this.tempId=0,this.onSubmitClick=()=>{this.send()},this.onInput=e=>{const t=e.target,i=(0,v.Z)(t,"LABEL"),s=(0,y.Z)(t);s||(t.parentElement.classList.add("is-filled"),i.classList.remove("hidden-widget"),i.firstElementChild.removeAttribute("disabled")),!i.nextElementSibling&&!s&&this.questions.childElementCount<10&&this.appendMoreField(),this.handleChange()},this.onDeleteClick=e=>{const t=e.target,i=(0,v.Z)(t,"LABEL"),s=(0,w.Z)(i);this.correctAnswers&&this.correctAnswers[0][0]===s&&(this.correctAnswers=void 0),i.remove(),this.optionInputFields.splice(s,1),this.optionInputFields.forEach(((e,t)=>{e.options.labelOptions.length=0,e.options.labelOptions.push(t+1),g.ZP.weakMap.get(e.label.firstElementChild).update()})),this.handleChange()},this.construct()}construct(){return L(this,void 0,void 0,(function*(){if(this.questionInputField=new u.ZP({placeholder:"AskAQuestion",label:"AskAQuestion",name:"question",maxLength:255}),this.listenerSetter.add(this.questionInputField.input)("input",(()=>{this.handleChange()})),this.optionInputFields=[],"scheduled"!==this.chat.type){const e=new m.Z({onSilentClick:()=>{this.chat.input.sendSilent=!0,this.send()},onScheduleClick:()=>{this.chat.input.scheduleSending((()=>{this.send()}))},openSide:"bottom-left",onContextElement:this.btnConfirm});e.setPeerId(this.chat.peerId),this.header.append(e.sendMenu)}this.header.append(this.questionInputField.container);const e=document.createElement("hr"),t=document.createElement("div");t.classList.add("caption"),(0,g.$d)(t,"PollOptions"),this.questions=document.createElement("form"),this.questions.classList.add("poll-create-questions");const i=document.createElement("div");i.classList.add("poll-create-settings");const s=document.createElement("div");s.classList.add("caption"),(0,g.$d)(s,"Settings"),(yield this.chat.managers.appPeersManager.isBroadcast(this.chat.peerId))||(this.anonymousCheckboxField=new h.Z({text:"NewPoll.Anonymous",name:"anonymous"}),this.anonymousCheckboxField.input.checked=!0,i.append(this.anonymousCheckboxField.label)),this.multipleCheckboxField=new h.Z({text:"NewPoll.MultipleChoice",name:"multiple"}),this.quizCheckboxField=new h.Z({text:"NewPoll.Quiz",name:"quiz"}),this.listenerSetter.add(this.multipleCheckboxField.input)("change",(()=>{const e=this.multipleCheckboxField.input.checked;this.quizCheckboxField.input.toggleAttribute("disabled",e)})),this.listenerSetter.add(this.quizCheckboxField.input)("change",(()=>{const e=this.quizCheckboxField.input.checked;Array.from(this.questions.children).map((t=>{t.classList.toggle("radio-field",e)})),e||(this.correctAnswers=void 0,this.quizSolutionField.setValueSilently("")),n.forEach((t=>t.classList.toggle("hide",!e))),this.multipleCheckboxField.input.toggleAttribute("disabled",e),this.handleChange()})),i.append(this.multipleCheckboxField.label,this.quizCheckboxField.label);const n=[],a=document.createElement("div");a.classList.add("caption"),(0,g.$d)(a,"AccDescrQuizExplanation");const o=document.createElement("hr"),r=document.createElement("div");r.classList.add("poll-create-questions"),this.quizSolutionField=new u.ZP({placeholder:"NewPoll.Explanation.Placeholder",label:"NewPoll.Explanation.Placeholder",name:"solution",maxLength:200}),this.listenerSetter.add(this.questionInputField.input)("input",(()=>{this.handleChange()}));const d=document.createElement("div");d.classList.add("subtitle"),(0,g.$d)(d,"AddAnExplanationInfo"),r.append(this.quizSolutionField.container,d),n.push(o,a,r),n.forEach((e=>e.classList.add("hide"))),this.body.parentElement.insertBefore(e,this.body),this.body.append(t,this.questions,document.createElement("hr"),s,i,...n),(0,S.fc)(this.btnConfirm,this.onSubmitClick,{listenerSetter:this.listenerSetter}),this.scrollable=new f.ZP(this.body),this.appendMoreField(),this.onEscape=()=>!this.getFilledAnswers().length,this.handleChange()}))}getFilledAnswers(){return Array.from(this.questions.children).map(((e,t)=>{const i=e.querySelector(".input-field-input");return i instanceof HTMLInputElement?i.value:(0,C.Z)(i,!1,!1).value})).filter((e=>!!e.trim()))}validate(){var e;const t=this.questionInputField.value;if(!t)return!1;if(t.length>255)return!1;if(this.quizCheckboxField.input.checked&&!(null===(e=this.correctAnswers)||void 0===e?void 0:e.length))return!1;const i=this.getFilledAnswers();if(i.length<2)return!1;if(i.find((e=>e.length>100)))return!1;const{value:s}=(0,C.Z)(this.quizSolutionField.input,!1,!1);return!(s.length>200)}handleChange(){const e=this.validate();this.btnConfirm.toggleAttribute("disabled",!e)}send(e=!1){return L(this,void 0,void 0,(function*(){const t=this.questionInputField.value,i=this.getFilledAnswers(),{value:s,entities:n}=(0,C.Z)(this.quizSolutionField.input,!0,!1);if("scheduled"===this.chat.type&&!e)return void this.chat.input.scheduleSending((()=>{this.send(!0)}));this.hide();const a={};this.anonymousCheckboxField&&!this.anonymousCheckboxField.input.checked&&(a.public_voters=!0),this.multipleCheckboxField.input.checked&&(a.multiple_choice=!0),this.quizCheckboxField.input.checked&&(a.quiz=!0);const o={_:"poll",pFlags:a,question:t,answers:i.map(((e,t)=>({_:"pollAnswer",text:e,option:new Uint8Array([t])}))),id:void 0},r=yield this.chat.managers.appPollsManager.getInputMediaPoll(o,this.correctAnswers,s,n);this.chat.managers.appMessagesManager.sendOther(this.chat.peerId,r,Object.assign({},this.chat.getMessageSendingParams())),"reply"===this.chat.input.helperType&&this.chat.input.clearHelper(),this.chat.input.onMessageSent(!1,!1)}))}appendMoreField(){const e=this.tempId++,t=this.questions.childElementCount+1,i=new u.ZP({placeholder:"NewPoll.OptionsAddOption",label:"NewPoll.OptionLabel",labelOptions:[t],name:"question-"+e,maxLength:100});this.listenerSetter.add(i.input)("input",this.onInput);const s=new p.Z({text:"",name:"question"});s.main.append(i.container),(0,S.fc)(i.input,b.Z,{listenerSetter:this.listenerSetter}),s.label.classList.add("hidden-widget"),s.input.disabled=!0,this.quizCheckboxField.input.checked||s.label.classList.remove("radio-field"),this.listenerSetter.add(s.input)("change",(()=>{if(s.input.checked){const e=(0,w.Z)(s.label);this.correctAnswers=[new Uint8Array([e])],this.handleChange()}}));const n=document.createElement("span");n.classList.add("btn-icon","tgico-close"),i.container.append(n),(0,S.fc)(n,this.onDeleteClick,{listenerSetter:this.listenerSetter,once:!0}),this.questions.append(s.label),this.scrollable.scrollIntoViewNew({element:this.questions.lastElementChild,position:"center"}),this.optionInputFields.push(i)}}var I=i(4524),P=i(805),Z=i(2796),M=i(3699),k=i(4755),T=i(6787),x=i(3512),A=i(6057),_=i(2153),F=i(9259),D=i(4789),R=i(5975),B=i(8497);const N="keydown",O="active",U=["ArrowUp","ArrowDown"],H=["ArrowLeft","ArrowRight"];function z({list:e,type:t,onSelect:i,once:s,waitForKey:n}){let a=(null==n?void 0:n.length)?new Set(n):void 0;const o=new Set("xy"===t?U.concat(H):"x"===t?H:U);let r;const d=()=>r||e.querySelector("."+O)||e.firstElementChild,l=(e,i)=>{if(r===e)return;let s=!1;r&&(s=!0,r.classList.remove(O)),r=e,r&&(r.classList.add(O),s&&p&&i&&(0,D.Z)({container:p,element:r,position:"center",forceDuration:100,axis:"x"===t?"x":"y"}))},c=(t,i)=>{let s;return s=i?t.nextElementSibling||e.firstElementChild:t.previousElementSibling||e.lastElementChild,s};let h;h="xy"===t?(t,i)=>"ArrowUp"===i||"ArrowDown"===i?((t,i)=>{const s=i?"nextElementSibling":"previousElementSibling",n=i?"firstElementChild":"lastElementChild",a=t.getBoundingClientRect();let o=t[s]||e[n];for(;o!==t;){const t=o.getBoundingClientRect();if(t.x===a.x&&t.y!==a.y)break;o=o[s]||e[n]}return o})(t,"ArrowDown"===i):c(t,"ArrowRight"===i):(e,t)=>c(e,"ArrowRight"===t||"ArrowDown"===t);let u=i=>{const s=i.key;if(o.has(s)){if((0,b.Z)(i),e.childElementCount>1){let e=d();e=h(e,s),l(e,!0)}}else("Enter"===s||"xy"!==t&&"Tab"===s)&&((0,b.Z)(i),g(d()))};const p=(0,B.Z)(e,"scrollable");e.classList.add("navigable-list");const f=t=>{const i=(0,R.Z)(t.target,e);i&&l(i,!1)},m=t=>{(0,b.Z)(t);const i=(0,R.Z)(t.target,e);i&&(l(i,!1),g(d()))},g=e=>{return t=this,n=void 0,o=function*(){const t=yield i(e);(void 0!==t?!t:s)&&C()},new((a=void 0)||(a=Promise))((function(e,i){function s(e){try{d(o.next(e))}catch(e){i(e)}}function r(e){try{d(o.throw(e))}catch(e){i(e)}}function d(t){var i;t.done?e(t.value):(i=t.value,i instanceof a?i:new a((function(e){e(i)}))).then(s,r)}d((o=o.apply(t,n||[])).next())}));var t,n,a,o};let v,y=!1;const w=()=>{y||(y=!0,document.addEventListener(N,u,{capture:!0,passive:!1}),e.addEventListener("mousemove",f,{passive:!0}),v=(0,S.fc)(e,m))},C=()=>{y&&(y=!1,document.removeEventListener(N,u,{capture:!0}),e.removeEventListener("mousemove",f),v(),v=void 0)},L=()=>{a||l(e.firstElementChild,!1)};if(a){const e=u;u=t=>{a.has(t.key)&&((0,b.Z)(t),document.removeEventListener(N,u,{capture:!0}),u=e,document.addEventListener(N,u,{capture:!0,passive:!1}),a=void 0,L())}}else L();return w(),{attach:w,detach:C,resetTarget:L}}var j=i(3241),G=i(4762),V=i(5824),K=i(9099),W=i(5953),$=i(5994);class q extends j.Z{constructor(e){var t;super(!1),this.hidden=!0,this.onVisible=()=>{var e;null===(e=this.detach)||void 0===e||e.call(this);const t=this.list,{attach:i,detach:s,resetTarget:n}=z({list:t,type:this.listType,onSelect:this.onSelect,once:!0,waitForKey:this.waitForKey});this.attach=i,this.detach=s,this.resetTarget=n,G.IS_MOBILE||this.navigationItem||(this.navigationItem={type:"autocomplete-helper",onPop:()=>{this.navigationItem=void 0,this.toggle(!0)},noBlurOnPop:!0},V.Z.pushItem(this.navigationItem)),this.addEventListener("hidden",(()=>{this.resetTarget=void 0,this.attach=void 0,this.detach=void 0,t.replaceChildren(),s(),this.navigationItem&&(V.Z.removeItem(this.navigationItem),this.navigationItem=void 0)}),{once:!0})},(0,W.Z)(this,e),this.container=document.createElement("div"),this.container.classList.add("autocomplete-helper","z-depth-1"),e.appendTo.append(this.container),this.attachNavigation(),null===(t=this.controller)||void 0===t||t.addHelper(this)}toggleListNavigation(e){var t,i;e?null===(t=this.attach)||void 0===t||t.call(this):null===(i=this.detach)||void 0===i||i.call(this)}attachNavigation(){this.addEventListener("visible",this.onVisible)}toggle(e,t=!1,i){var s;if(this.init)return;if(void 0===e&&(e=this.container.classList.contains("is-visible")&&!this.container.classList.contains("backwards")),this.hidden===e)return void(e||this.dispatchEvent("visible"));this.hidden=e,e?(this.navigationItem&&(V.Z.removeItem(this.navigationItem),this.navigationItem=void 0),!t&&this.controller&&this.controller.hideOtherHelpers(),null===(s=this.detach)||void 0===s||s.call(this)):(this.controller&&this.controller.hideOtherHelpers(this),this.dispatchEvent("visible"));const n=this.controller||e?0:2;e&&this.dispatchEvent("hiding"),(0,K.Z)({element:this.container,className:"is-visible",forwards:!e,duration:$.Z.isAvailable("animations")&&!i?300:0,onTransitionEnd:()=>{this.hidden&&this.dispatchEvent("hidden")},useRafs:n})}}class Y extends q{constructor(e,t,i,s){super({appendTo:e,controller:t,listType:"xy",onSelect:e=>{return t=this,i=void 0,n=function*(){return!(yield l.Jo.onMediaClick({target:e},!0))},new((s=void 0)||(s=Promise))((function(e,a){function o(e){try{d(n.next(e))}catch(e){a(e)}}function r(e){try{d(n.throw(e))}catch(e){a(e)}}function d(t){var i;t.done?e(t.value):(i=t.value,i instanceof s?i:new s((function(e){e(i)}))).then(o,r)}d((n=n.apply(t,i||[])).next())}));var t,i,s,n},waitForKey:["ArrowUp","ArrowDown"]}),this.chat=i,this.managers=s,this.container.classList.add("stickers-helper"),this.addEventListener("visible",(()=>{setTimeout((()=>{this.scrollable.container.scrollTop=0}),0),x.Z.dispatchEvent("choosing_sticker",!0)})),this.addEventListener("hidden",(()=>{this.onChangeScreen&&(k.Z.removeEventListener("changeScreen",this.onChangeScreen),this.onChangeScreen=void 0,this.listenerSetter.removeAll(),this.listenerSetter=void 0),x.Z.dispatchEvent("choosing_sticker",!1)}))}checkEmoticon(e){var t;const i=this.controller.getMiddleware();null===(t=this.lazyLoadQueue)||void 0===t||t.clear(),(0,T.Z)(e),this.managers.appStickersManager.getStickersByEmoticon(e,!0,"all"===x.Z.settings.stickers.suggest).then((e=>{if(!i())return;this.init&&(this.init(),this.init=null);const t=this.list.cloneNode();let s;this.lazyLoadQueue.clear(),s=e.length?new Promise((i=>{const s=[];e.forEach((e=>{t.append(this.superStickerRenderer.renderSticker(e,void 0,s))})),Promise.all(s).finally(i)})):Promise.resolve(),s.then((()=>{this.list.replaceWith(t),this.list=t,this.onChangeScreen||(this.onChangeScreen=()=>{const e=this.list.childElementCount*k.Z.active.esgSticker.width+(this.list.childElementCount-1);this.list.style.width=e+"px"},k.Z.addEventListener("changeScreen",this.onChangeScreen),this.listenerSetter=new M.Z,(0,F.Z)({listenTo:this.container,listenerSetter:this.listenerSetter})),this.onChangeScreen(),this.toggle(!e.length),this.scrollable.scrollTop=0}))}))}init(){this.list=document.createElement("div"),this.list.classList.add("stickers-helper-stickers","super-stickers"),this.container.append(this.list),this.scrollable=new f.ZP(this.container),this.lazyLoadQueue=new _.Z,this.superStickerRenderer=new A.vT(this.lazyLoadQueue,this.chat.animationGroup,this.managers)}}var Q=i(2230),X=i(5322),J=i(4494),ee=i(586),te=i(2986);const ie=()=>{const e=new Date;return e.setHours(0,0,0,0),e},se=()=>{const e=new Date;return e.setFullYear(e.getFullYear()+1),e.setDate(e.getDate()-1),e};class ne extends te.Z{constructor(e,t,i){var s;if(super((s=e).getTime()>se().getTime()?new Date:s,t,{noButtons:!0,noTitle:!0,closable:!0,withConfirm:!0,minDate:ie(),maxDate:se(),withTime:!0,showOverflowMonths:!0,confirmShortcutIsSendShortcut:!0,title:!0}),this.element.classList.add("popup-schedule"),this.header.append(this.controlsDiv),this.title.replaceWith(this.monthTitle),this.body.append(this.btnConfirm),i){const e=(0,J.Z)("btn-primary btn-secondary btn-primary-transparent primary",{text:"Schedule.SendWhenOnline"});this.body.append(e),(0,S.fc)(e,(()=>{t(ee._),this.hide()}))}}}var ae=i(684),oe=i(7298),re=i(1175),de=i(8119),le=i(8799),ce=i(6760),he=i(6299),ue=i(2398),pe=i(6039);class fe extends q{constructor(e,t,i,s){super({appendTo:e,controller:t,listType:"x",onSelect:e=>{i.onEmojiSelected((0,pe.xG)(e),!0)}}),this.managers=s,this.container.classList.add("emoji-helper")}init(){this.list=document.createElement("div"),this.list.classList.add("emoji-helper-emojis","super-emojis"),this.container.append(this.list),this.scrollable=new f.v7(this.container),this.addEventListener("visible",(()=>{setTimeout((()=>{this.scrollable.container.scrollLeft=0}),0)}))}render(e,t){if(this.init){if(!e.length)return;this.init(),this.init=null}(e=e.slice(0,80)).length&&(this.list.replaceChildren(),e.forEach((e=>{(0,pe.IA)(e,this.list,!1,!0)}))),this.waitForKey=t?["ArrowUp","ArrowDown"]:void 0,this.toggle(!e.length)}checkQuery(e,t){const i=this.controller.getMiddleware();this.managers.appEmojiManager.getBothEmojiKeywords().then((()=>{return s=this,n=void 0,o=function*(){if(!i())return;const s=e.replace(/^:/,""),n=yield this.managers.appEmojiManager.searchEmojis(s);i()&&this.render(n,":"!==t)},new((a=void 0)||(a=Promise))((function(e,t){function i(e){try{d(o.next(e))}catch(e){t(e)}}function r(e){try{d(o.throw(e))}catch(e){t(e)}}function d(t){var s;t.done?e(t.value):(s=t.value,s instanceof a?s:new a((function(e){e(s)}))).then(i,r)}d((o=o.apply(s,n||[])).next())}));var s,n,a,o}))}}var me=i(130),ge=i(8115),ve=i(9331),be=i(8842);class ye extends q{constructor(e,t,i,s){super({appendTo:e,controller:t,listType:"y",onSelect:s}),this.className=i,this.container.classList.add(ye.BASE_CLASS,i)}init(){this.list=document.createElement("div"),this.list.classList.add(ye.BASE_CLASS+"-list",this.className+"-list"),this.container.append(this.list),this.scrollable=new f.ZP(this.container),this.addEventListener("visible",(()=>{setTimeout((()=>{this.scrollable.container.scrollTop=0}),0)}))}render(e,t){if(this.init){if(!e.length)return;this.init(),this.init=null}e.length&&(this.list.replaceChildren(),e.forEach((e=>{const t=ye.listElement({className:this.className,peerId:e.peerId,name:e.name,description:e.description});this.list.append(t)}))),t||this.toggle(!e.length)}static listElement(e){const t=ye.BASE_CLASS_LIST_ELEMENT;e.className+="-list-element";const i=document.createElement("div");i.classList.add(t,e.className),i.dataset.peerId=""+e.peerId;const s=new ve.Z;s.classList.add("avatar-30",t+"-avatar",e.className+"-avatar"),s.updateWithOptions({isDialog:!1,peerId:e.peerId});const n=document.createElement("div");if(n.classList.add(t+"-name",e.className+"-name"),e.name?(0,me.Z)(n,(0,ge.Z)(e.name)):n.append(new be.Z({peerId:e.peerId,dialog:!1,onlyFirstName:!1,plainText:!1}).element),i.append(s,n),e.description){const s=document.createElement("div");s.classList.add(t+"-description",e.className+"-description"),(0,me.Z)(s,(0,ge.Z)(e.description)),i.append(s)}return i}}ye.BASE_CLASS="autocomplete-peer-helper",ye.BASE_CLASS_LIST_ELEMENT=ye.BASE_CLASS+"-list-element";var we=i(7381);function Se(e,t,i){const s=[].concat(t.bot_info);let n;void 0!==i&&(n=new we.Z({ignoreCase:!0}));const a=new Map;let o;if(s.forEach((t=>{t.commands&&t.commands.forEach((({command:i,description:s},o)=>{const r="/"+i;a.set(i,{peerId:t.user_id?t.user_id.toPeerId(!1):e,command:i,name:r,description:s,index:o}),n&&n.indexObject(i,r)}))})),n){const e=n.search(i);o=Array.from(e).map((e=>a.get(e)))}else o=[...a.values()];return o=o.sort(((e,t)=>a.get(e.command).index-a.get(t.command).index)),o}class Ce extends ye{constructor(e,t,i,s){super(e,t,"commands-helper",(e=>{const t=e.querySelector(`.${ye.BASE_CLASS_LIST_ELEMENT}-name`).innerHTML;return i.getReadyToSend((()=>{i.messageInput.innerHTML=t,i.sendMessage(!0)}))})),this.managers=s}checkQuery(e,t){return i=this,s=void 0,a=function*(){if(!(yield this.managers.appUsersManager.isBot(t)))return!1;const i=this.controller.getMiddleware();return this.managers.appProfileManager.getProfileByPeerId(t).then((s=>{if(!i())return;const n=Se(t,s,e);this.render(n)})),!0},new((n=void 0)||(n=Promise))((function(e,t){function o(e){try{d(a.next(e))}catch(e){t(e)}}function r(e){try{d(a.throw(e))}catch(e){t(e)}}function d(t){var i;t.done?e(t.value):(i=t.value,i instanceof n?i:new n((function(e){e(i)}))).then(o,r)}d((a=a.apply(i,s||[])).next())}));var i,s,n,a}}var Le=i(3624);class Ee{constructor(){this.helpers=new Set,this.middleware=(0,Le.k)()}toggleListNavigation(e){for(const t of this.helpers)t.toggleListNavigation(e)}getMiddleware(){return this.middleware.clean(),this.middleware.get()}addHelper(e){this.helpers.add(e)}hideOtherHelpers(e){this.helpers.forEach((t=>{t!==e&&t.toggle(!0,!0)})),e||this.middleware.clean()}}var Ie=i(5102),Pe=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class Ze extends ye{constructor(e,t,i,s){super(e,t,"mentions-helper",(e=>{const t=e.dataset.peerId.toUserId();Promise.resolve(s.appUsersManager.getUser(t)).then((e=>{let t,s="";const n=(0,Ie.Z)(e);n[0]?s="@"+n[0]:(s=e.first_name||e.last_name,t={_:"messageEntityMentionName",length:s.length,offset:0,user_id:e.id}),s+=" ",i.insertAtCaret(s,t)}))})),this.managers=s}checkQuery(e,t,i){const s=e.trim();if(e.length!==s.length)return!1;const n=this.controller.getMiddleware();return this.managers.appProfileManager.getMentions(t&&t.toChatId(),s,i).then((e=>Pe(this,void 0,void 0,(function*(){if(!n())return;e=e.filter((e=>e!==x.Z.myId));const t=e.map((e=>Pe(this,void 0,void 0,(function*(){const t=yield this.managers.appUsersManager.getUser(e),i=(0,Ie.Z)(t);return{peerId:e,description:i[0]?"@"+i[0]:void 0}}))));this.render((yield Promise.all(t)).filter(Boolean))})))),!0}}var Me=i(5494),ke=i(6339),Te=i(8594),xe=i(5592),Ae=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class _e extends ke.Z{constructor(e){super({element:document.createElement("div")}),this.onBodyTouchStart=e=>{const t=e.touches[0].target;(0,R.Z)(t,this.element)||t===this.btnHover||((0,b.Z)(e),this.toggle(!1))},(0,W.Z)(this,e),this.element.classList.add(_e.BASE_CLASS),this.element.style.display="none",this.scrollable=new f.ZP,this.element.append(this.scrollable.container),this.attachButtonListener(this.btnHover,this.listenerSetter),this.listenerSetter.add(x.Z)("history_reply_markup",(({peerId:e})=>Ae(this,void 0,void 0,(function*(){this.peerId===e&&(this.checkAvailability()&&this.isActive()&&(yield this.render()),(0,Te.e9)().then((()=>{this.checkForceReply()})))}))))}init(){return this.appendTo.append(this.element),this.listenerSetter.add(this)("open",(()=>Ae(this,void 0,void 0,(function*(){yield this.render(),o.Z&&(this.touchListener=this.listenerSetter.add(document.body)("touchstart",this.onBodyTouchStart,{passive:!1,capture:!0}),this.listenerSetter.add(this)("close",(()=>{this.listenerSetter.remove(this.touchListener)}),{once:!0}))})))),(0,S.fc)(this.element,(e=>{const t=(0,B.Z)(e.target,"btn");if(!t)return;const i=t.dataset.type,{peerId:s}=this;"keyboardButtonRequestPhone"===i?(0,xe.Z)({titleLangKey:"ShareYouPhoneNumberTitle",button:{langKey:"OK"},descriptionLangKey:"AreYouSureShareMyContactInfoBot"}).then((()=>{this.managers.appMessagesManager.sendContact(s,x.Z.myId)})):this.managers.appMessagesManager.sendText(s,t.dataset.text),this.toggle(!1)}),{listenerSetter:this.listenerSetter}),super.init()}checkForceReply(){return Ae(this,void 0,void 0,(function*(){const e=yield this.getReplyMarkup();"replyKeyboardForceReply"!==e._||e.pFlags.hidden||e.pFlags.used||(e.pFlags.used=!0,this.chatInput.initMessageReply(e.mid))}))}getReplyMarkup(){var e;return Ae(this,void 0,void 0,(function*(){return null!==(e=(yield this.managers.appMessagesManager.getHistoryStorageTransferable(this.peerId)).replyMarkup)&&void 0!==e?e:{_:"replyKeyboardHide",pFlags:{}}}))}render(e){return Ae(this,void 0,void 0,(function*(){void 0===e&&(e=yield this.getReplyMarkup()),this.scrollable.container.replaceChildren();for(const t of e.rows){const e=document.createElement("div");e.classList.add(_e.BASE_CLASS+"-row");for(const i of t.buttons){const t=document.createElement("button");t.classList.add(_e.BASE_CLASS+"-button","btn"),(0,me.Z)(t,(0,ge.Z)(i.text)),t.dataset.text=i.text,t.dataset.type=i._,e.append(t)}this.scrollable.container.append(e)}}))}checkAvailability(e){var t;return Ae(this,void 0,void 0,(function*(){void 0===e&&(e=yield this.getReplyMarkup());const i="replyKeyboardHide"===e._||!(null===(t=e.rows)||void 0===t?void 0:t.length);return this.btnHover.classList.toggle("hide",i),i&&this.toggle(!1),!i}))}setPeer(e){this.peerId=e,this.checkAvailability(),this.checkForceReply()}}_e.BASE_CLASS="reply-keyboard";var Fe=i(5701),De=i(8938),Re=i(1080),Be=i(8678),Ne=i(2830),Oe=i(5400),Ue=i(515),He=i(2312),ze=i(9492);const je="INLINE-HELPER";class Ge extends q{constructor(e,t,i,s){super({appendTo:e,controller:t,listType:"xy",waitForKey:["ArrowUp","ArrowDown"],onSelect:e=>{if(!e)return!1;const{peerId:t,botId:i,queryId:s}=this.list.dataset;return this.chat.input.getReadyToSend((()=>{const n=(0,Ue.Z)(s,e.dataset.resultId);this.managers.appInlineBotsManager.sendInlineResult(t.toPeerId(),i,n,Object.assign(Object.assign({},this.chat.getMessageSendingParams()),{clearDraft:!0})),this.chat.input.onMessageSent(!0,!0)}))}}),this.chat=i,this.managers=s,this._checkQuery=(e,t,i,s)=>{return n=this,a=void 0,r=function*(){const n=this.controller.getMiddleware(),a=yield this.managers.appUsersManager.resolveUsername(t);if(!n())throw"PEER_CHANGED";if("user"!==a._||!a.pFlags.bot)throw"NOT_A_BOT";if(!s){if(!n())throw"PEER_CHANGED";throw this.init&&(this.init(),this.init=null),this.container.classList.add("cant-send"),this.toggle(!1),"NO_INLINES"}const o=this.managers.appInlineBotsManager.getInlineResults(e,a.id,i).then((t=>{if(!n())throw"PEER_CHANGED";this.init&&(this.init(),this.init=null);const i=this.list.cloneNode();i.dataset.peerId=""+e,i.dataset.botId=""+a.id,i.dataset.queryId=""+t.query_id;const s=new Re.Z(null,je,this.scrollable,!1);this.lazyLoadQueue.clear(),this.superStickerRenderer.clear();const o=[],r=!!t.pFlags.gallery;for(const e of t.results){const t=document.createElement("div");t.classList.add("inline-helper-result"),t.dataset.resultId=e.id;const a=r?void 0:document.createElement("div");if(a&&(a.classList.add("inline-helper-result-preview"),t.append(a)),i.append(t),r)t.classList.add("grid-item");else{a.classList.add("empty"),(0,me.Z)(a,(0,ge.Z)([...e.title.trim()][0]));const s=document.createElement("div");s.classList.add("inline-helper-result-title"),(0,me.Z)(s,(0,ge.Z)(e.title));const n=document.createElement("div");n.classList.add("inline-helper-result-description"),(0,me.Z)(n,(0,Oe.ZP)(e.description,{noCommands:!0,noLinks:!0})),t.append(s,n);const o=document.createElement("div");o.classList.add("inline-helper-separator"),i.append(o)}if("botInlineResult"===e._){if(e.thumb&&0===e.thumb.mime_type.indexOf("image/")){let i;a?(i=document.createElement("div"),a.append(i)):i=t,i.classList.add("media-container"),r&&i.classList.add("no-border-radius"),this.lazyLoadQueue.push({div:t,load:()=>He.Z.download({dcId:4,location:{_:"inputWebFileLocation",access_hash:e.thumb.access_hash,url:e.thumb.url},size:e.thumb.size,mimeType:e.thumb.mime_type}).then((e=>{const t=new Image;t.classList.add("media-photo"),(0,Be.Z)(e).then((e=>{(0,Ne.Z)(i,t,e,!0)}))}))})}}else{const i=e.document||e.photo;if(["sticker","gif"].includes(null==i?void 0:i.type)&&r)(0,De.Z)(i),"gif"===i.type?s.add(i,t):"sticker"===i.type&&(t.classList.add("super-sticker"),this.superStickerRenderer.renderSticker(i,t,o),i.animated&&this.superStickerRenderer.observeAnimated(t));else if(i){const e=r?48:void 0;r&&t.classList.add("no-border-radius"),(0,ze.Z)({photo:i,container:r?t:a,boxWidth:e,boxHeight:e,middleware:n,lazyLoadQueue:this.lazyLoadQueue,loadPromises:o})}}}return Promise.all(o).then((()=>{var o;if(!n())return void s.clear();i.classList.toggle("is-gallery",r),i.classList.toggle("super-stickers",r),this.container.classList.toggle("is-gallery",r);const d=this.list.parentElement;if(d.textContent="",t.switch_pm){const i=(0,J.Z)("btn-primary btn-secondary btn-primary-transparent primary");(0,me.Z)(i,(0,ge.Z)(t.switch_pm.text)),(0,S.fc)(i,(i=>{this.chat.appImManager.setInnerPeer({peerId:e}),this.managers.appInlineBotsManager.switchToPM(e,a.id,t.switch_pm.start_param)})),d.append(i)}d.append(this.list=i),this.container.classList.remove("cant-send"),null===(o=this.gifsMasonry)||void 0===o||o.detach(),this.gifsMasonry=s,s.attach(),this.onChangeScreen||(this.onChangeScreen=()=>{if(this.list.classList.contains("is-gallery")){const e=this.list.childElementCount*k.Z.active.popupSticker.width+(this.list.childElementCount-1);this.list.style.width=e+"px"}else this.list.style.width=""},k.Z.addEventListener("changeScreen",this.onChangeScreen)),this.onChangeScreen(),this.toggle(!t.results.length&&!t.switch_pm),this.scrollable.scrollTop=0}))}));return{user:a,renderPromise:o}},new((o=void 0)||(o=Promise))((function(e,t){function i(e){try{d(r.next(e))}catch(e){t(e)}}function s(e){try{d(r.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o((function(e){e(n)}))).then(i,s)}d((r=r.apply(n,a||[])).next())}));var n,a,o,r},this.container.classList.add("inline-helper"),this.addEventListener("visible",(()=>{setTimeout((()=>{this.scrollable.container.scrollTop=0}),0)})),this.checkQuery=(0,Fe.Z)(this._checkQuery,200,!0,!0),this.addEventListener("hidden",(()=>{this.onChangeScreen&&(k.Z.removeEventListener("changeScreen",this.onChangeScreen),this.onChangeScreen=void 0)}))}init(){this.list=document.createElement("div"),this.list.classList.add("inline-helper-results"),this.container.append(this.list),this.scrollable=new f.ZP(this.container),this.lazyLoadQueue=new _.Z,this.superStickerRenderer=new A.vT(this.lazyLoadQueue,je,this.managers);const e=(0,g.ag)(Bt.send_inline);e.classList.add("inline-helper-cant-send"),this.container.append(e)}}var Ve=i(279),Ke=i(3035),We=i(5128),$e=i(8090),qe=i(8127),Ye=i(3013),Qe=i(1507),Xe=i(5133),Je=i(1656),et=i(6654);class tt extends ye{constructor(e,t,i){super(e,void 0,"bot-commands",(e=>{const i=e.querySelector(`.${ye.BASE_CLASS_LIST_ELEMENT}-name`).innerHTML;return t.getReadyToSend((()=>{t.messageInput.innerHTML=i,t.sendMessage(!0),this.toggle(!0)}))})),this.managers=i}setUserId(e,t){var i;if(this.userId!==e||!(null===(i=this.list)||void 0===i?void 0:i.childElementCount))return this.userId=e,(0,et.Z)(this.managers.appProfileManager.getProfile(e),(i=>{if(!t())return;const s=Se(e.toPeerId(!1),i),n=50*s.length+8+24;this.container.style.setProperty("--height",n+"px"),this.render(s)}));this.toggle(!1)}}var it=i(8479),st=i(5157),nt=(i(1544),i(7197)),at=i(6241),ot=i(6535),rt=i(2821),dt=i(3066),lt=i(496),ct=i(2790),ht=i(3416),ut=i(671);function pt(e){return t=this,i=void 0,n=function*(){return{cached:e.cached,result:e.cached?yield e.result:e.result}},new((s=void 0)||(s=Promise))((function(e,a){function o(e){try{d(n.next(e))}catch(e){a(e)}}function r(e){try{d(n.throw(e))}catch(e){a(e)}}function d(t){var i;t.done?e(t.value):(i=t.value,i instanceof s?i:new s((function(e){e(i)}))).then(o,r)}d((n=n.apply(t,i||[])).next())}));var t,i,s,n}function ft(e){return e.then(pt)}var mt=i(1655),gt=i(2946),vt=i(177),bt=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class yt{constructor(e,t,i){this.managers=e,this.onReady=t,this.onChange=i,this.middleware=(0,Le.k)(),this.listenerSetter=new M.Z,this.construct()}construct(){this.container=document.createElement("div"),this.container.classList.add("new-message-send-as-container"),this.closeBtn=document.createElement("div"),this.closeBtn.classList.add("new-message-send-as-close","new-message-send-as-avatar","tgico-close");const e=[{text:"SendMessageAsTitle",onClick:void 0}];let t;this.buttons=[];const i=e=>{e&&(t=this.avatar);const i=this.avatar!==t,s=!e&&i?2:0;(0,K.Z)({element:this.closeBtn,className:"is-visible",forwards:e,duration:300,useRafs:s}),i||(0,K.Z)({element:t,className:"is-visible",forwards:!e,duration:300,useRafs:s})};(0,X.Z)({buttonOptions:{noRipple:!0},listenerSetter:this.listenerSetter,container:this.container,direction:"top-right",buttons:e,onOpenBefore:()=>{i(!0)},onOpen:(t,i)=>{e[0].element.classList.add("btn-menu-item-header"),this.btnMenu=i,this.btnMenu.classList.add("scrollable","scrollable-y"),this.btnMenu.append(...this.buttons.map((e=>e.element)))},onClose:()=>{i(!1)},onCloseAfter:()=>{this.btnMenu=void 0}}),this.container.append(this.closeBtn)}updateButtons(e){var t;return bt(this,void 0,void 0,(function*(){const i=e.map(((e,t)=>bt(this,void 0,void 0,(function*(){const i=document.createElement("div"),s=document.createElement("div");return s.classList.add("btn-menu-item-subtitle"),e.isUser()?s.append((0,g.ag)("Chat.SendAs.PersonalAccount")):e===this.peerId?s.append((0,g.ag)("VoiceChat.DiscussionGroup")):s.append(yield(0,vt.Z)(e.toChatId())),i.append(new be.Z({peerId:e}).element,s),{onClick:t?()=>bt(this,void 0,void 0,(function*(){const t=this.peerId;this.changeSendAsPeerId(e);const i=this.middleware.get(),s=()=>{if(this.sendAsPeerId!==e||!i())return;const t=this.sendAsPeerIds.slice();(0,mt.Z)(t,e),t.unshift(e),this.updateButtons(t)};$.Z.isAvailable("animations")?setTimeout(s,250):s(),this.managers.appMessagesManager.saveDefaultSendAs(t,e)})):void 0,textElement:i}})))),s=yield Promise.all(i);(0,d.b)({buttons:s}),s.forEach(((t,i)=>{const s=e[i],n=new ve.Z;n.classList.add("avatar-26","btn-menu-item-icon"),n.updateWithOptions({peerId:s}),i||n.classList.add("active"),t.element.prepend(n)})),this.buttons=s,null===(t=this.btnMenu)||void 0===t||t.append(...this.buttons.map((e=>e.element)))}))}updateAvatar(e,t){return bt(this,void 0,void 0,(function*(){const i=this.avatar;if(i&&i.peerId===e)return;i||(t=!0);const s=t?0:2,n=t?0:300,a=this.avatar=new ve.Z;a.classList.add("new-message-send-as-avatar","avatar-30"),yield a.updateWithOptions({isDialog:!1,peerId:e}),(0,K.Z)({element:a,className:"is-visible",forwards:!0,duration:n,useRafs:s}),i&&(0,K.Z)({element:i,className:"is-visible",forwards:!1,duration:n,onTransitionEnd:()=>{i.remove()},useRafs:s}),this.container.append(a)}))}changeSendAsPeerId(e,t){return this.sendAsPeerId=e,this.onChange(e),this.updateAvatar(e,t)}getDefaultSendAs(){return this.managers.acknowledged.appProfileManager.getChannelFull(this.peerId.toChatId()).then((e=>({cached:e.cached,result:e.result.then((e=>e.default_send_as?(0,gt.Z)(e.default_send_as):void 0))})))}updateManual(e){return bt(this,void 0,void 0,(function*(){const t=this.peerId;if(this.updatingPromise||!(yield this.managers.appPeersManager.isChannel(t)))return;const i=this.middleware.get((()=>!this.updatingPromise||this.updatingPromise===d)),{container:s}=this,n=t.toChatId(),a=(yield ft(this.getDefaultSendAs())).result,o=e;a instanceof Promise&&(e=void 0);const r=o&&!e,d=this.updatingPromise=(0,et.Z)(a,(t=>bt(this,void 0,void 0,(function*(){if(!i()||void 0===t)return;if(yield this.changeSendAsPeerId(t,e),!i())return;this.managers.appChatsManager.getSendAs(n).then((e=>{if(!i())return;const s=e.filter((e=>!e.pFlags.premium_required)).map((e=>e.peer)).map((e=>(0,gt.Z)(e)));this.sendAsPeerIds=s.slice(),(0,mt.Z)(s,t),s.unshift(t),this.updateButtons(s)}));const a=()=>{this.onReady(s,e),this.addedListener||(this.listenerSetter.add(x.Z)("peer_full_update",(e=>{this.peerId===e&&this.update()})),this.addedListener=!0)};if(!r)return a;a()}))));return d.finally((()=>{this.updatingPromise===d&&(this.updatingPromise=void 0)})),r?void 0:d}))}update(e){return this.updateManual(e).then((e=>null==e?void 0:e()))}setPeerId(e){this.middleware.clean(),this.updatingPromise=void 0,this.peerId=e}destroy(){this.container.remove(),this.setPeerId(),this.listenerSetter.removeAll()}}var wt=i(2353),St=i(9496),Ct=i(13),Lt=i(9298),Et=i(7362),It=i(6700),Pt=i(7545),Zt=i(669),Mt=i(6034),kt=i(1452),Tt=i(8794),xt=i(1439),At=i(7625),_t=i(2423),Ft=i(1174),Dt=i(554),Rt=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};const Bt={send_voices:"GlobalAttachVoiceRestricted",send_stickers:"GlobalAttachStickersRestricted",send_gifs:"GlobalAttachGifRestricted",send_media:"GlobalAttachMediaRestricted",send_plain:"GlobalSendMessageRestricted",send_polls:"ErrorSendRestrictedPollsAll",send_inline:"GlobalAttachInlineRestricted"};class Nt{constructor(e,t,i){this.chat=e,this.appImManager=t,this.managers=i,this.lastUrl="",this.lastTimeType=0,this.replyElements={},this.willSendWebPage=null,this.recording=!1,this.recordCanceled=!1,this.recordStartTime=0,this.lockRedo=!1,this.canRedoFromHTML="",this.undoHistory=[],this.executedHistory=[],this.canUndoFromHTML="",this.onCancelRecordClick=e=>{e&&(0,b.Z)(e),this.recordCanceled=!0,this.recorder.stop(),r.Z.setKeepAlive(!1)},this.onEmoticonsOpen=()=>{const e=o.Z?"flip-icon":"active";this.btnToggleEmoticons.classList.toggle(e,!0)},this.onEmoticonsClose=()=>{const e=o.Z?"flip-icon":"active";this.btnToggleEmoticons.classList.toggle(e,!1)},this.scheduleSending=(e=this.sendMessage.bind(this,!0),t=new Date)=>Rt(this,void 0,void 0,(function*(){const{peerId:i}=this.chat,s=this.chat.bubbles.getMiddleware(),n=x.Z.myId!==i&&i.isUser()&&(yield this.managers.appUsersManager.isUserOnlineVisible(i));c.Z.createPopup(ne,t,(t=>{s()&&(t<=10+(Date.now()/1e3|0)&&(t=void 0),this.scheduleDate=t,e(),"scheduled"!==this.chat.type&&t&&setTimeout((()=>{s()&&(c.Z.getPopups(Lt.Z).forEach((e=>e.hide())),this.appImManager.openScheduled(i))}),0))}),n).show()})),this.prepareDocumentExecute=()=>(this.executedHistory.push(this.messageInput.innerHTML),()=>this.canUndoFromHTML=this.messageInput.innerHTML),this.undoRedo=(e,t,i)=>{(0,b.Z)(e);let s=this.messageInput.innerHTML;if(s&&s!==i){this.lockRedo=!0;let e=0;do{document.execCommand(t,!1,null);const i=this.messageInput.innerHTML;if(s===i){if(++e>2)break}else e=0;s=i}while(s!==i);this.lockRedo=!1}},this.handleMarkdownShortcut=e=>{const t={KeyB:"bold",KeyI:"italic",KeyU:"underline",KeyS:"strikethrough",KeyM:"monospace",KeyP:"spoiler"};this.appImManager.markupTooltip&&(t.KeyK="link");const i=e.code,s=t[i],n=document.getSelection();if(!(0,kt.Z)(n)&&s&&("KeyK"===i?this.appImManager.markupTooltip.showLinkEditor():this.applyMarkdown(s),(0,b.Z)(e)),"KeyZ"===i){let t=this.messageInput.innerHTML;e.shiftKey?this.undoHistory.length&&(this.executedHistory.push(t),t=this.undoHistory.pop(),this.undoRedo(e,"redo",t),t=this.messageInput.innerHTML,this.canRedoFromHTML=this.undoHistory.length?t:"",this.canUndoFromHTML=t):!this.executedHistory.length||this.canUndoFromHTML&&t!==this.canUndoFromHTML||(this.undoHistory.push(t),t=this.executedHistory.pop(),this.undoRedo(e,"undo",t),this.canUndoFromHTML=this.canRedoFromHTML=this.messageInput.innerHTML)}},this.onMessageInput=e=>{var t,i,s;const{value:n,entities:a,caretPos:o}=(0,C.Z)(this.messageInputField.input),r=(0,rt.Z)(n,a,!0),d=(0,at.Z)(a,(0,ot.Z)(r));this.canRedoFromHTML&&!this.lockRedo&&this.messageInput.innerHTML!==this.canRedoFromHTML&&(this.canRedoFromHTML="",this.undoHistory.length=0);const l=(!(null===(t=this.editMessage)||void 0===t?void 0:t.media)||"messageMediaWebPage"===this.editMessage.media._)&&d.filter((e=>"messageEntityUrl"===e._||"messageEntityTextUrl"===e._));if(l.length)for(const e of l){let t;if("messageEntityTextUrl"===e._)t=e.url;else if(t=n.slice(e.offset,e.offset+e.length),!t.includes("http://")&&!t.includes("https://"))continue;if(this.lastUrl!==t){this.lastUrl=t;const e=this.getWebPagePromise=Promise.all([this.managers.appWebPagesManager.getWebPage(t),this.chat.canSend("embed_links")]).then((([i,s])=>{this.getWebPagePromise===e&&(this.getWebPagePromise=void 0),this.lastUrl===t&&("webPage"===(null==i?void 0:i._)&&s?(this.setTopInfo("webpage",(()=>{}),i.site_name||i.title||"Webpage",i.description||i.url||""),delete this.noWebPage,this.willSendWebPage=i):this.willSendWebPage&&this.onHelperCancel())}))}break}else this.lastUrl&&(this.lastUrl="",delete this.noWebPage,this.willSendWebPage=null,this.helperType?this.helperFunc():this.clearHelper());if(n.trim()){const t=Date.now();t-this.lastTimeType>=6e3&&(null==e?void 0:e.isTrusted)&&(this.lastTimeType=t,this.managers.appMessagesManager.setTyping(this.chat.peerId,{_:"sendMessageTypingAction"},void 0,this.chat.threadId)),null===(s=this.botCommands)||void 0===s||s.toggle(!0)}else this.lastTimeType&&this.managers.appMessagesManager.setTyping(this.chat.peerId,{_:"sendMessageCancelAction"},void 0,this.chat.threadId),null===(i=this.appImManager.markupTooltip)||void 0===i||i.hide(),document.activeElement!==this.messageInput||G.IS_MOBILE||setTimeout((()=>{document.activeElement===this.messageInput&&(this.messageInput.textContent="1",(0,ue.Z)(this.messageInput),this.messageInput.textContent="")}),0);this.botCommands&&this.updateBotCommandsToggle(),this.editMsgId||this.saveDraftDebounced(),this.checkAutocomplete(n,o,d),this.updateSendBtn()},this.onEmojiSelected=(e,t)=>{const i=e.docId?{_:"messageEntityCustomEmoji",document_id:e.docId,length:e.emoji.length,offset:0}:(0,nt.Z)(e.emoji);this.insertAtCaret(e.emoji,i,t)},this.onBtnSendClick=e=>Rt(this,void 0,void 0,(function*(){if((0,b.Z)(e),!this.recorder||this.recording||!this.isInputEmpty()||this.forwarding||this.editMsgId)this.recording?Date.now()-this.recordStartTime<500?this.onCancelRecordClick():this.recorder.stop():this.sendMessage();else{const e=this.chat.peerId.isAnyChat(),t="send_voices";if(e&&!(yield this.chat.canSend(t)))return void(0,Z.bC)({langPackKey:Bt[t]});this.chatInput.classList.add("is-locked"),(0,le.Z)();let i=!1;if(!e){const e=yield this.managers.appProfileManager.getProfile(this.chat.peerId.toUserId());(null==e?void 0:e.pFlags.voice_messages_forbidden)&&((0,Z.bC)({langPackKey:"Chat.SendVoice.PrivacyError",langPackArguments:[yield(0,Et.Z)({peerId:this.chat.peerId})]}),i=!0)}if(i)return void this.chatInput.classList.remove("is-locked");this.recorder.start().then((()=>{this.releaseMediaPlayback=Ye.Z.setSingleMedia(),this.recordCanceled=!1,this.setRecording(!0),r.Z.setKeepAlive(!0);const e=()=>{c.Z.createPopup(qe.Z,"popup-cancel-record",{titleLangKey:"DiscardVoiceMessageTitle",descriptionLangKey:"DiscardVoiceMessageDescription",buttons:[{langKey:"DiscardVoiceMessageAction",callback:()=>{(0,S.tH)(this.btnCancelRecord)}},{langKey:"Continue",isCancel:!0}]}).show()};this.recordingOverlayListener=this.listenerSetter.add(document.body)("mousedown",(t=>{(0,B.Z)(t.target,"chat-input")||(0,B.Z)(t.target,"popup-cancel-record")||((0,b.Z)(t),e())}),{capture:!0,passive:!1}),V.Z.pushItem(this.recordingNavigationItem={type:"voice",onPop:()=>(setTimeout((()=>{e()}),0),!1)}),this.recordStartTime=Date.now();const t=this.recorder.sourceNode,i=t.context.createAnalyser();t.connect(i),i.fftSize=32;const s=new Uint8Array(i.frequencyBinCount),n=255*s.length,a=()=>{if(!this.recording)return;i.getByteFrequencyData(s);let e=0;s.forEach((t=>{e+=t}));const t=Math.min(1,e/n+.36);this.recordRippleEl.style.transform=`scale(${t})`;const o=Date.now()-this.recordStartTime,r=o%1e3,d=(0,st.Z)(o/1e3)+","+("00"+Math.round(r/10)).slice(-2);this.recordTimeEl.innerText=d,(0,Ke.T2)(a)};a()})).catch((e=>{switch(e.name){case"NotAllowedError":(0,Z.Am)("Please allow access to your microphone");break;case"NotReadableError":(0,Z.Am)(e.message);break;default:console.error("Recorder start error:",e,e.name,e.message),(0,Z.Am)(e.message)}this.setRecording(!1),this.chatInput.classList.remove("is-locked")}))}})),this.onHelperCancel=(e,t)=>Rt(this,void 0,void 0,(function*(){var i;if(e&&(0,b.Z)(e),this.willSendWebPage){const e=this.lastUrl;let t=!1;if(this.helperType&&(yield this.helperFunc(),t=!0),this.lastUrl=e,this.noWebPage=!0,this.willSendWebPage=null,t)return}if("edit"===this.helperType&&!t){const e=this.editMessage,t=this.getCurrentInputAsDraft(!0);t&&delete t.pFlags.no_webpage;const s=Object.assign(Object.assign({},e),{_:"draftMessage"});if(null===(i=s.entities)||void 0===i?void 0:i.length){const e=new Set(Object.values(_t.SC));s.entities=s.entities.slice(),(0,At.Z)(s.entities,((t,i,s)=>{e.has(t._)||s.splice(i,1)})),s.entities.length||delete s.entities}if(!(0,Mt.Z)(t,s))return void c.Z.createPopup(qe.Z,"discard-editing",{buttons:[{langKey:"Alert.Confirm.Discard",callback:()=>{this.onHelperCancel(void 0,!0)}}],descriptionLangKey:"Chat.Edit.Cancel.Text"}).show()}this.clearHelper(),this.updateSendBtn()})),this.onHelperClick=e=>{if((0,b.Z)(e),(0,B.Z)(e.target,"reply"))if("forward"===this.helperType){const{forwardElements:e}=this;e&&o.Z&&!e.container.classList.contains("active")&&ht.Z.openBtnMenu(e.container)}else"reply"===this.helperType?this.chat.setMessageId(this.replyToMsgId):"edit"===this.helperType&&this.chat.setMessageId(this.editMsgId)},this.listenerSetter=new M.Z}construct(){this.chatInput=document.createElement("div"),this.chatInput.classList.add("chat-input","hide"),this.inputContainer=document.createElement("div"),this.inputContainer.classList.add("chat-input-container"),this.rowsWrapperWrapper=document.createElement("div"),this.rowsWrapperWrapper.classList.add("rows-wrapper-wrapper"),this.rowsWrapper=document.createElement("div"),this.rowsWrapper.classList.add("rows-wrapper","chat-input-wrapper"),this.rowsWrapperWrapper.append(this.rowsWrapper);const e=(0,re.ZK)();this.rowsWrapper.append(e);const t=this.fakeRowsWrapper=document.createElement("div");t.classList.add("fake-wrapper","fake-rows-wrapper");const i=this.fakeSelectionWrapper=document.createElement("div");i.classList.add("fake-wrapper","fake-selection-wrapper"),this.inputContainer.append(this.rowsWrapperWrapper,t,i),this.chatInput.append(this.inputContainer),this.goDownBtn=(0,de.Z)({icon:"arrow_down",className:"bubbles-corner-button chat-secondary-button bubbles-go-down hide"}),this.inputContainer.append(this.goDownBtn),(0,S.fc)(this.goDownBtn,(e=>{(0,b.Z)(e),this.chat.bubbles.onGoDownClick()}),{listenerSetter:this.listenerSetter});const s=this.controlContainer=document.createElement("div");s.classList.add("chat-input-control","chat-input-wrapper"),this.inputContainer.append(s)}createButtonIcon(...e){const t=(0,Q.Z)(...e);return t.tabIndex=-1,t}constructPeerHelpers(){this.replyElements.container=document.createElement("div"),this.replyElements.container.classList.add("reply-wrapper"),this.replyElements.iconBtn=this.createButtonIcon(""),this.replyElements.cancelBtn=this.createButtonIcon("close reply-cancel",{noRipple:!0}),this.replyElements.container.append(this.replyElements.iconBtn,this.replyElements.cancelBtn);const e=()=>{s=!0},t=()=>{s=!1},i=this.forwardElements={};let s=!1;const n=[i.showSender={text:"Chat.Alert.Forward.Action.Show1",onClick:e,checkForClose:()=>this.canToggleHideAuthor(),checkboxField:new h.Z({checked:!0})},i.hideSender={text:"Chat.Alert.Forward.Action.Hide1",onClick:e,checkForClose:()=>this.canToggleHideAuthor(),checkboxField:new h.Z({checked:!1})},i.showCaption={text:"Chat.Alert.Forward.Action.ShowCaption",onClick:t,checkboxField:new h.Z({checked:!0})},i.hideCaption={text:"Chat.Alert.Forward.Action.HideCaption",onClick:t,checkboxField:new h.Z({checked:!1})},i.changePeer={text:"Chat.Alert.Forward.Action.Another",onClick:()=>{this.changeForwardRecipient()},icon:"replace"}],u=i.container=(0,d.b)({buttons:n,listenerSetter:this.listenerSetter}),p=Array.from(u.children);[{elements:p.slice(0,2),onChange:(e,t)=>{const n=!!+e;s&&(this.forwardWasDroppingAuthor=!n);const a=this.replyElements.container.querySelector(".reply-title");if(a){const e=a.firstElementChild,t=g.ZP.weakMap.get(e),s=i.showSender.checkboxField.checked?"Chat.Accessory.Forward":"Chat.Accessory.Hidden";t.key=s,t.update()}}},{elements:p.slice(2,4),onChange:e=>{const t=!!+e;let s;s=t&&void 0!==this.forwardWasDroppingAuthor?this.forwardWasDroppingAuthor?i.hideSender:i.showSender:t?i.showSender:i.hideSender,s.checkboxField.checked=!0}}].forEach((e=>{const t=(0,Xe.Z)(e.elements.map((e=>({container:e,input:e.querySelector("input")}))),e.onChange),i=document.createElement("hr");t.append(i),u.append(t)})),u.append(i.changePeer.element),o.Z||(this.forwardHover=new ke.Z({element:u})),i.modifyArgs=n.slice(0,-1),this.replyElements.container.append(u),i.modifyArgs.forEach(((e,t)=>{const{input:i}=e.checkboxField;i.type="radio",i.name=t<2?"author":"caption",i.value=""+ +!(t%2)})),this.newMessageWrapper=document.createElement("div"),this.newMessageWrapper.classList.add("new-message-wrapper"),this.replyInTopicOverlay=document.createElement("div"),this.replyInTopicOverlay.classList.add("reply-in-topic-overlay","hide"),this.replyInTopicOverlay.append((0,g.ag)("Chat.Input.ReplyToAnswer")),this.btnToggleEmoticons=this.createButtonIcon("none toggle-emoticons",{noRipple:!0}),this.inputMessageContainer=document.createElement("div"),this.inputMessageContainer.classList.add("input-message-container"),this.goDownUnreadBadge=document.createElement("span"),this.goDownUnreadBadge.classList.add("badge","badge-24","badge-primary"),this.goDownBtn.append(this.goDownUnreadBadge),this.goMentionBtn=(0,de.Z)({icon:"mention",className:"bubbles-corner-button chat-secondary-button bubbles-go-mention"}),this.goMentionUnreadBadge=document.createElement("span"),this.goMentionUnreadBadge.classList.add("badge","badge-24","badge-primary"),this.goMentionBtn.append(this.goMentionUnreadBadge),this.inputContainer.append(this.goMentionBtn),(0,S.fc)(this.goMentionBtn,(e=>{(0,b.Z)(e);const t=this.chat.bubbles.getMiddleware();this.managers.appMessagesManager.goToNextMention(this.chat.peerId,this.chat.threadId).then((e=>{t()&&e&&this.chat.setMessageId(e)}))}),{listenerSetter:this.listenerSetter}),this.btnScheduled=this.createButtonIcon("scheduled btn-scheduled float hide",{noRipple:!0}),(0,S.fc)(this.btnScheduled,(e=>{this.appImManager.openScheduled(this.chat.peerId)}),{listenerSetter:this.listenerSetter}),this.listenerSetter.add(x.Z)("scheduled_new",(({peerId:e})=>{this.chat.peerId===e&&this.btnScheduled.classList.remove("hide")})),this.listenerSetter.add(x.Z)("scheduled_delete",(({peerId:e})=>{this.chat.peerId===e&&this.managers.appMessagesManager.getScheduledMessages(this.chat.peerId).then((e=>{this.btnScheduled.classList.toggle("hide",!e.length)}))})),this.btnToggleReplyMarkup=this.createButtonIcon("botcom toggle-reply-markup float hide",{noRipple:!0}),this.replyKeyboard=new _e({appendTo:this.rowsWrapper,listenerSetter:this.listenerSetter,managers:this.managers,btnHover:this.btnToggleReplyMarkup,chatInput:this}),this.listenerSetter.add(this.replyKeyboard)("open",(()=>this.btnToggleReplyMarkup.classList.add("active"))),this.listenerSetter.add(this.replyKeyboard)("close",(()=>this.btnToggleReplyMarkup.classList.remove("active"))),this.botCommands=new tt(this.rowsWrapper,this,this.managers),this.botCommandsToggle=document.createElement("div"),this.botCommandsToggle.classList.add("new-message-bot-commands");const f=document.createElement("div");f.classList.add("new-message-bot-commands-icon-scale");const v=this.botCommandsIcon=document.createElement("div");v.classList.add("animated-menu-icon","animated-menu-close-icon"),f.append(v),this.botCommandsToggle.append(f),(0,S.fc)(this.botCommandsToggle,(e=>{(0,b.Z)(e),v.classList.contains("state-back")?(this.botCommands.toggle(!0),v.classList.remove("state-back")):(this.botCommands.setUserId(this.chat.peerId.toUserId(),this.chat.bubbles.getMiddleware()),v.classList.add("state-back"))}),{listenerSetter:this.listenerSetter}),this.botCommands.addEventListener("visible",(()=>{v.classList.add("state-back")})),this.botCommands.addEventListener("hiding",(()=>{v.classList.remove("state-back")}));const y=(e,t)=>{this.fileInput.value="";const i=[...e?Ft.Z:[],...t?Dt.Z:[]].join(", ");this.fileInput.setAttribute("accept",i),this.willAttachType="media",this.fileInput.click()};this.attachMenuButtons=[{icon:"image",text:"Chat.Input.Attach.PhotoOrVideo",onClick:()=>y(!0,!0)},{icon:"document",text:"Chat.Input.Attach.Document",onClick:()=>{this.fileInput.value="",this.fileInput.removeAttribute("accept"),this.willAttachType="document",this.fileInput.click()}},{icon:"gift",text:"GiftPremium",onClick:()=>this.chat.appImManager.giftPremium(this.chat.peerId),verify:()=>Promise.all([this.chat.canGiftPremium(),this.managers.apiManager.getAppConfig()]).then((([e,{premium_gift_attach_menu_icon:t}])=>e&&t))},{icon:"poll",text:"Poll",onClick:()=>Rt(this,void 0,void 0,(function*(){const e="send_polls";(yield this.chat.canSend(e))?c.Z.createPopup(E,this.chat).show():(0,Z.bC)({langPackKey:Bt[e]})})),verify:()=>this.chat.peerId.isAnyChat()||this.chat.isBot}],this.managers.appAttachMenuBotsManager.getAttachMenuBots();const w=this.attachMenuButtons.slice();this.attachMenu=(0,X.Z)({buttonOptions:{noRipple:!0},listenerSetter:this.listenerSetter,direction:"top-left",buttons:this.attachMenuButtons,onOpenBefore:()=>Rt(this,void 0,void 0,(function*(){const e=yield this.managers.appAttachMenuBotsManager.getAttachMenuBots(),t=w.slice();console.log(e);const i=e.filter((e=>!e.pFlags.inactive)).map((e=>{const t=(0,Tt.Z)(e);return{regularText:(0,ge.Z)(e.short_name),onClick:()=>{this.managers.appAttachMenuBotsManager.requestWebView(Object.assign({botId:e.bot_id,peerId:this.chat.peerId},this.chat.getMessageSendingParams())).then((t=>{const i=["allow-scripts","allow-same-origin","allow-popups","allow-forms","allow-modals"].join(" ");class s extends c.Z{constructor(t){super("popup-payment popup-payment-verification",{closable:!0,overlayClosable:!0,body:!0,titleRaw:e.short_name}),this.url=t,this.d()}destroy(){return this.telegramWebView.destroy(),super.destroy()}d(){const e=this.telegramWebView=new xt.Z({url:this.url,sandbox:i});e.iframe.classList.add("payment-verification"),this.body.append(e.iframe),this.show(),e.onMount()}}new s(t.url)}))},iconDoc:null==t?void 0:t.icon,verify:()=>Rt(this,void 0,void 0,(function*(){let t=!1;const i={attachMenuPeerTypeSameBotPM:()=>this.chat.peerId.toUserId()===e.bot_id,attachMenuPeerTypeBotPM:()=>this.chat.isBot,attachMenuPeerTypePM:()=>this.chat.peerId.isUser(),attachMenuPeerTypeChat:()=>this.chat.isAnyGroup,attachMenuPeerTypeBroadcast:()=>this.chat.isBroadcast};for(const s of e.peer_types){const e=i[s._];if(t=yield e(),t)break}return t}))}}));t.splice(t.length,0,...i),this.attachMenuButtons.splice(0,this.attachMenuButtons.length,...t)}))}),this.attachMenu.classList.add("attach-file","tgico-attach"),this.attachMenu.classList.remove("tgico-more"),this.recordTimeEl=document.createElement("div"),this.recordTimeEl.classList.add("record-time"),this.fileInput=document.createElement("input"),this.fileInput.type="file",this.fileInput.multiple=!0,this.fileInput.style.display="none",this.newMessageWrapper.append(...[this.botCommandsToggle,this.btnToggleEmoticons,this.inputMessageContainer,this.btnScheduled,this.btnToggleReplyMarkup,this.attachMenu,this.recordTimeEl,this.fileInput].filter(Boolean)),this.rowsWrapper.append(this.replyElements.container),this.autocompleteHelperController=new Ee,this.stickersHelper=new Y(this.rowsWrapper,this.autocompleteHelperController,this.chat,this.managers),this.emojiHelper=new fe(this.rowsWrapper,this.autocompleteHelperController,this,this.managers),this.commandsHelper=new Ce(this.rowsWrapper,this.autocompleteHelperController,this,this.managers),this.mentionsHelper=new Ze(this.rowsWrapper,this.autocompleteHelperController,this,this.managers),this.inlineHelper=new Ge(this.rowsWrapper,this.autocompleteHelperController,this.chat,this.managers),this.rowsWrapper.append(this.newMessageWrapper),this.btnCancelRecord=this.createButtonIcon("binfilled btn-circle btn-record-cancel chat-secondary-button"),this.btnSendContainer=document.createElement("div"),this.btnSendContainer.classList.add("btn-send-container"),this.recordRippleEl=document.createElement("div"),this.recordRippleEl.classList.add("record-ripple"),this.btnSend=this.createButtonIcon("none btn-circle btn-send animated-button-icon"),this.btnSend.insertAdjacentHTML("afterbegin",'\n <span class="tgico tgico-send"></span>\n <span class="tgico tgico-schedule"></span>\n <span class="tgico tgico-check"></span>\n <span class="tgico tgico-microphone_filled"></span>\n '),this.btnSendContainer.append(this.recordRippleEl,this.btnSend),this.sendMenu=new m.Z({onSilentClick:()=>{this.sendSilent=!0,this.sendMessage()},onScheduleClick:()=>{this.scheduleSending(void 0)},listenerSetter:this.listenerSetter,openSide:"top-left",onContextElement:this.btnSend,onOpen:()=>!("scheduled"===this.chat.type||this.isInputEmpty()&&!Object.keys(this.forwarding).length)}),this.btnSendContainer.append(this.sendMenu.sendMenu),this.inputContainer.append(this.btnCancelRecord,this.btnSendContainer),l.ZP.attachButtonListener(this.btnToggleEmoticons,this.listenerSetter),this.listenerSetter.add(l.ZP)("open",this.onEmoticonsOpen),this.listenerSetter.add(l.ZP)("close",this.onEmoticonsClose),this.attachMessageInputField(),this.listenerSetter.add(x.Z)("settings_updated",(()=>{var e;(this.stickersHelper||this.emojiHelper)&&(this.previousQuery="",this.checkAutocomplete()),null===(e=this.messageInputField)||void 0===e||e.onFakeInput()})),this.listenerSetter.add(x.Z)("draft_updated",(({peerId:e,threadId:t,draft:i,force:s})=>{this.chat.threadId===t&&this.chat.peerId===e&&"scheduled"!==this.chat.type&&this.setDraft(i,!0,s)})),this.listenerSetter.add(this.appImManager)("peer_changing",(e=>{this.chat!==e||"chat"!==this.chat.type&&"discussion"!==this.chat.type||this.saveDraft()})),this.listenerSetter.add(this.appImManager)("chat_changing",(({from:e,to:t})=>{this.chat===e?this.autocompleteHelperController.toggleListNavigation(!1):this.chat===t&&this.autocompleteHelperController.toggleListNavigation(!0)})),this.listenerSetter.add(x.Z)("scheduled_delete",(({peerId:e,mids:t})=>{"scheduled"===this.chat.type&&this.chat.peerId===e&&t.includes(this.editMsgId)&&this.onMessageSent()})),this.listenerSetter.add(x.Z)("history_delete",(({peerId:e,msgs:t})=>{this.chat.peerId===e&&"scheduled"!==this.chat.type&&(t.has(this.editMsgId)&&this.onMessageSent(),this.replyToMsgId&&t.has(this.replyToMsgId)&&this.clearHelper("reply"))})),this.listenerSetter.add(x.Z)("dialogs_multiupdate",(e=>{!e.has(this.chat.peerId)||"chat"!==this.chat.type&&"discussion"!==this.chat.type||(this.startParam===Qe.gZ?this.setStartParam():this.center(!0))}));try{this.recorder=new(a())({encoderSampleRate:48e3,monitorGain:0,numberOfChannels:1,recordingGain:1,reuseWorker:!0})}catch(e){console.error("Recorder constructor error:",e)}this.updateSendBtn(),this.listenerSetter.add(this.fileInput)("change",(e=>{const t=e.target.files;t.length&&(c.Z.createPopup(P.Z,this.chat,Array.from(t).slice(),this.willAttachType),this.fileInput.value="")}),!1),(0,S.fc)(this.btnSend,this.onBtnSendClick,{listenerSetter:this.listenerSetter,touchMouseDown:!0}),this.recorder&&((0,S.fc)(this.btnCancelRecord,this.onCancelRecordClick,{listenerSetter:this.listenerSetter}),this.recorder.onstop=()=>{this.setRecording(!1),this.chatInput.classList.remove("is-locked"),this.recordRippleEl.style.transform=""},this.recorder.ondataavailable=e=>{if(this.releaseMediaPlayback&&(this.releaseMediaPlayback(),this.releaseMediaPlayback=void 0),this.recordingOverlayListener&&(this.listenerSetter.remove(this.recordingOverlayListener),this.recordingOverlayListener=void 0),this.recordingNavigationItem&&(V.Z.removeItem(this.recordingNavigationItem),this.recordingNavigationItem=void 0),this.recordCanceled)return;const{peerId:t,threadId:i}=this.chat,s=this.replyToMsgId,n=(Date.now()-this.recordStartTime)/1e3|0,a=new Blob([e],{type:"audio/ogg"});r.Z.decode(e,!0).then((e=>{r.Z.setKeepAlive(!1),this.managers.appMessagesManager.sendFile(t,{file:a,isVoiceMessage:!0,isMedia:!0,duration:n,waveform:e.waveform,objectURL:e.url,replyToMsgId:s,threadId:i,clearDraft:!0}),this.onMessageSent(!1,!0)}))}),(0,S.fc)(this.replyElements.cancelBtn,this.onHelperCancel,{listenerSetter:this.listenerSetter}),(0,S.fc)(this.replyElements.container,this.onHelperClick,{listenerSetter:this.listenerSetter}),this.saveDraftDebounced=(0,Fe.Z)((()=>this.saveDraft()),2500,!1,!0),this.botStartBtn=(0,J.Z)("btn-primary btn-transparent text-bold chat-input-control-button"),this.botStartBtn.append((0,g.ag)("BotStart")),(0,S.fc)(this.botStartBtn,(()=>{const{startParam:e}=this;if(void 0===e)return;const t=this.toggleBotStartBtnDisability=(0,Je.Z)([this.botStartBtn],!0),i=this.chat.peerId,s=this.chat.bubbles.getMiddleware((()=>this.chat.peerId===i&&this.startParam===e&&this.toggleBotStartBtnDisability===t));this.managers.appMessagesManager.startBot(i.toUserId(),void 0,e).then((()=>{s()&&(t(),this.toggleBotStartBtnDisability=void 0,this.setStartParam())}))}),{listenerSetter:this.listenerSetter}),this.controlContainer.append(this.botStartBtn,this.replyInTopicOverlay),this.pinnedControlBtn=(0,J.Z)("btn-primary btn-transparent text-bold chat-input-control-button",{icon:"unpin"}),this.controlContainer.append(this.pinnedControlBtn),this.listenerSetter.add(this.pinnedControlBtn)("click",(()=>{const e=this.chat.peerId;c.Z.createPopup(ae.Z,e,0,!0,(()=>{this.chat.appImManager.setPeer();const e=this.chat.appImManager.chat;e.topbar.pinnedMessage&&e.topbar.pinnedMessage.pinnedMessageContainer.toggle(!0)}))}))}_center(e,t){if(!e&&!this.inputContainer.classList.contains("is-centering"))return;if(e===this.fakeWrapperTo)return;const i=e||this.fakeWrapperTo,s=!!e,n=this.fakeWrapperTo;let a,o="",r="";const d=i.getBoundingClientRect(),l=this.fakeRowsWrapper.getBoundingClientRect(),c=l.width,h=d.width;if(c!==h){const e=h/c,t=(c-h)/2;if(a=d.left-l.left-t,s&&(o=`translateX(${a}px) scaleX(${e})`,e<1)){const t=16;r=t+t*(1-e)+"px"}}this.fakeWrapperTo=e;const u=t?200:0;return(0,K.Z)({element:this.inputContainer,className:"is-centering",forwards:s,duration:u}),(0,K.Z)({element:this.rowsWrapperWrapper,className:"is-centering-to-control",forwards:!!(s&&e&&e.classList.contains("chat-input-control")),duration:u}),this.rowsWrapper.style.transform=o,this.rowsWrapper.style.borderRadius=r,{transform:o,borderRadius:r,needTranslateX:n&&(e&&e.classList.contains("chat-input-control")&&n===this.fakeSelectionWrapper||n.classList.contains("chat-input-control"))?-.5*a:a,widthFrom:c,widthTo:h}}center(e=!1){return Rt(this,void 0,void 0,(function*(){return this._center(yield this.getNeededFakeContainer(),e)}))}setStartParam(e){this.startParam!==e&&(this.startParam=e,this.center(!0))}isReplyInTopicOverlayNeeded(){return this.chat.isForum&&!this.chat.isForumTopic&&!this.replyToMsgId&&"chat"===this.chat.type}getNeededFakeContainer(e=this.startParam){return Rt(this,void 0,void 0,(function*(){return this.chat.selection.isSelecting?this.fakeSelectionWrapper:void 0!==e||"pinned"===this.chat.type||(yield this.chat.isStartButtonNeeded())||this.isReplyInTopicOverlayNeeded()?this.controlContainer:void 0}))}getReadyToSend(e){return"scheduled"===this.chat.type?(this.scheduleSending(e),!0):(e(),!1)}setUnreadCount(){return Rt(this,void 0,void 0,(function*(){if(!this.goDownUnreadBadge)return;const e=yield this.managers.dialogsStorage.getDialogOrTopic(this.chat.peerId,"discussion"===this.chat.type?void 0:this.chat.threadId),t=null==e?void 0:e.unread_count;if(this.goDownUnreadBadge.innerText=""+(t||""),this.goDownUnreadBadge.classList.toggle("badge-gray",yield this.managers.appNotificationsManager.isPeerLocalMuted({peerId:this.chat.peerId,respectType:!0,threadId:this.chat.threadId})),this.goMentionUnreadBadge&&"chat"===this.chat.type){const t=!(!(null==e?void 0:e.unread_mentions_count)||!e.unread_count);this.goMentionUnreadBadge.innerText=t?""+e.unread_mentions_count:"",this.goMentionBtn.classList.toggle("is-visible",t)}}))}getCurrentInputAsDraft(e){const{value:t,entities:i}=(0,C.Z)(this.messageInputField.input,!0,!1);let s;return(t.length||e||this.replyToMsgId)&&(s={_:"draftMessage",date:(0,oe.Z)(!0),message:t,entities:i.length?i:void 0,pFlags:{no_webpage:this.noWebPage},reply_to_msg_id:this.replyToMsgId}),s}saveDraft(){if(!this.chat.peerId||this.editMsgId||"scheduled"===this.chat.type)return;const e=this.getCurrentInputAsDraft();this.managers.appDraftsManager.syncDraft(this.chat.peerId,this.chat.threadId,e)}destroy(){this.listenerSetter.removeAll()}cleanup(e=!0){this.chat.peerId||(this.chatInput.classList.add("hide"),this.goDownBtn.classList.add("hide")),(0,ce.Z)(),this.lastTimeType=0,this.startParam=void 0,this.toggleBotStartBtnDisability&&(this.toggleBotStartBtnDisability(),this.toggleBotStartBtnDisability=void 0),this.messageInput&&(this.clearInput(),e&&this.clearHelper())}setDraft(e,t=!0,i=!1){return Rt(this,void 0,void 0,(function*(){if(!i&&!(0,y.Z)(this.messageInput)||"scheduled"===this.chat.type)return!1;if(!e&&!(e=yield this.managers.appDraftsManager.getDraft(this.chat.peerId,this.chat.threadId)))return i&&(this.chat.container.classList.contains("is-helper-active")&&this.t(),this.messageInputField.inputFake.textContent="",this.messageInputField.onFakeInput(!1),(this.chat.bubbles.messagesQueuePromise||Promise.resolve()).then((()=>{(0,Ke.T2)((()=>{this.onMessageSent()}))}))),!1;const s=function(e,t,i){const s=(0,ot.Z)(e.message),n=e.entities||[],a=(0,at.Z)(n.slice(),s);return(0,dt.Z)(e.message,{entities:a,wrappingForPeerId:t,loadPromises:void 0})}(e,this.chat.peerId),n=this.getCurrentInputAsDraft();return!((0,Mt.Z)(e,n)&&this.replyToMsgId===e.reply_to_msg_id||(t&&this.clearHelper(),this.noWebPage=e.pFlags.no_webpage,e.reply_to_msg_id&&this.initMessageReply(e.reply_to_msg_id),this.setInputValue(s,t,t),0))}))}createSendAs(){if(this.sendAsPeerId=void 0,"chat"===this.chat.type||"discussion"===this.chat.type){let e=!0;this.sendAs=new yt(this.managers,((e,t)=>{let i=0;e.parentElement||(this.newMessageWrapper.prepend(e),i=2),this.updateOffset("as",!0,t,i)}),(t=>{this.sendAsPeerId=t,e?e=!1:this.getPlaceholderKey().then((e=>{this.updateMessageInputPlaceholder(e)}))}))}else this.sendAs=void 0;return this.sendAs}finishPeerChange(e){return Rt(this,void 0,void 0,(function*(){const t=this.chat.peerId,{startParam:i,middleware:s}=e,{forwardElements:n,btnScheduled:a,replyKeyboard:o,sendMenu:r,goDownBtn:d,chatInput:l,botCommandsToggle:c,attachMenu:h}=this,u=this.sendAs,p=this.createSendAs(),f=this.filterAttachMenuButtons(),[m,v,b,y,w,S,C,L,E]=yield Promise.all([this.managers.appPeersManager.isBroadcast(t),this.managers.appPeersManager.canPinMessage(t),this.managers.appPeersManager.isBot(t),this.chat.canSend("send_messages"),this.chat.canSend("send_plain"),this.getNeededFakeContainer(i),ft(this.managers.acknowledged.appProfileManager.getProfileByPeerId(t)),a?ft(this.managers.acknowledged.appMessagesManager.getScheduledMessages(t)):void 0,p?(p.setPeerId(this.chat.peerId),p.updateManual(!0)):void 0]),I=this.messageInput?yield this.getPlaceholderKey(w):void 0;return()=>{var e;if(l.classList.remove("hide"),d.classList.toggle("is-broadcast",m),d.classList.remove("hide"),this.goDownUnreadBadge&&this.setUnreadCount(),"pinned"===this.chat.type&&l.classList.toggle("can-pin",v),n&&(this.forwardWasDroppingAuthor=!1,n.showCaption.checkboxField.setValueSilently(!0),n.showSender.checkboxField.setValueSilently(!0)),a&&L&&(a.classList.add("hide"),(0,et.Z)(L.result,(e=>{s()&&e&&a.classList.toggle("hide",!e.length)}))),this.newMessageWrapper&&this.updateOffset(null,!1,!0),c&&(this.hasBotCommands=void 0,this.botCommands.toggle(!0,void 0,!0),this.updateBotCommandsToggle(!0),c.remove(),b)){const e=C.result;(0,et.Z)(e,(t=>{s()&&this.updateBotCommands(t,!(e instanceof Promise))}))}null==u||u.destroy(),null==E||E(),null==o||o.setPeer(t),null==r||r.setPeerId(t),this.messageInput&&(this.updateMessageInput(y,w,I),this.messageInput.dataset.peerId=""+t,f&&h&&f.then((e=>{s()&&(h.toggleAttribute("disabled",!e.length),h.classList.toggle("btn-disabled",!e.length))}))),null===(e=this.messageInputField)||void 0===e||e.onFakeInput(void 0,!0);let p=!1;if(this.pinnedControlBtn){const e="pinned"===this.chat.type;p||(p=e),this.pinnedControlBtn.classList.toggle("hide",!e),this.pinnedControlBtn.replaceChildren((0,g.ag)(v?"Chat.Input.UnpinAll":"Chat.Pinned.DontShow"))}{const e=this.chat.isForum&&!this.chat.isForumTopic&&"chat"===this.chat.type;p||(p=e),this.replyInTopicOverlay.classList.toggle("hide",!e)}this.botStartBtn.classList.toggle("hide",p),this.startParam=i,this._center(S,!1)}}))}updateOffset(e,t,i,s){e?this.newMessageWrapper.dataset.offset=e:delete this.newMessageWrapper.dataset.offset,(0,K.Z)({element:this.newMessageWrapper,className:"has-offset",forwards:t,duration:i?0:300,useRafs:s})}updateBotCommands(e,t){var i,s;this.hasBotCommands=!!(null===(s=null===(i=e.bot_info)||void 0===i?void 0:i.commands)||void 0===s?void 0:s.length),this.updateBotCommandsToggle(t)}updateBotCommandsToggle(e){const{botCommandsToggle:t,hasBotCommands:i}=this,s=!!i&&this.isInputEmpty();if(!i){if(!t.parentElement)return;t.remove()}const n=s,a=t.parentElement?0:2;t.parentElement||this.newMessageWrapper.prepend(t),this.updateOffset("commands",n,e,a)}getPlaceholderKey(e){return Rt(this,void 0,void 0,(function*(){null!=e||(e=yield this.chat.canSend("send_plain"));const{peerId:t,threadId:i,isForum:s}=this.chat;let n;return n=e?i&&!s?"Comment":(yield this.managers.appPeersManager.isBroadcast(t))?"ChannelBroadcast":void 0!==this.sendAsPeerId&&this.sendAsPeerId!==x.Z.myId||(yield this.managers.appMessagesManager.isAnonymousSending(t))?"SendAnonymously":"Message":"Channel.Persmission.MessageBlock",n}))}updateMessageInputPlaceholder(e){const t=g.ZP.weakMap.get(this.messageInput);if(!t)return;const i=t.key;return t.compareAndUpdate({key:e}),{oldKey:i,newKey:e}}filterAttachMenuButtons(){if(this.attachMenuButtons)return(0,wt.Z)(this.attachMenuButtons,(e=>!e.verify||e.verify()))}updateMessageInput(e,t,i){const{chatInput:s,messageInput:n}=this;s.classList.contains("is-hidden")!==!e&&(s.classList.add("no-transition"),s.classList.toggle("is-hidden",!e),s.offsetLeft,s.classList.remove("no-transition"));const a=e&&!t&&this.restoreInputLock;!a&&this.updateMessageInputPlaceholder(i),a?this.restoreInputLock=()=>{this.updateMessageInputPlaceholder(i),this.messageInput.contentEditable="false"}:e&&t?(this.restoreInputLock=void 0,n.contentEditable="true",this.setDraft(void 0,!1),n.innerHTML||this.messageInputField.onFakeInput(void 0,!0)):(n.contentEditable="false",t||this.messageInputField.onFakeInput(void 0,!0)),this.updateSendBtn()}attachMessageInputField(){const e=this.messageInputField;this.messageInputField=new St.Z({placeholder:"Message",name:"message",withLinebreaks:!0}),this.messageInputField.input.tabIndex=-1,this.messageInputField.input.classList.replace("input-field-input","input-message-input"),this.messageInputField.inputFake.classList.replace("input-field-input","input-message-input"),this.messageInput=this.messageInputField.input,this.attachMessageInputListeners(),$e.T&&(0,$e.Z)(this.messageInput),e?(e.input.replaceWith(this.messageInputField.input),e.inputFake.replaceWith(this.messageInputField.inputFake)):this.inputMessageContainer.append(this.messageInputField.input,this.messageInputField.inputFake)}attachMessageInputListeners(){this.listenerSetter.add(this.messageInput)("keydown",(e=>{const t=e.key;if((0,he.Z)(e))(0,b.Z)(e),this.sendMessage();else if(e.ctrlKey||e.metaKey)this.handleMarkdownShortcut(e);else if(("PageUp"===t||"PageDown"===t)&&!e.shiftKey)if(e.preventDefault(),"PageUp"===t){const e=document.createRange(),t=window.getSelection();e.setStart(this.messageInput.childNodes[0]||this.messageInput,0),e.collapse(!0),t.removeAllRanges(),t.addRange(e)}else(0,ue.Z)(this.messageInput)})),(0,S.fc)(this.messageInput,(e=>{this.canSendPlain()||(0,Z.bC)({langPackKey:Bt.send_plain})}),{listenerSetter:this.listenerSetter}),o.Z&&(0,S.fc)(this.messageInput,(e=>{if(l.ZP.isActive())return l.ZP.toggle(!1),(0,le.Z)(),void(0,b.Z)(e);this.appImManager.selectTab(s.oo.CHAT)}),{listenerSetter:this.listenerSetter}),this.listenerSetter.add(this.messageInput)("input",this.onMessageInput),this.listenerSetter.add(this.messageInput)("keyup",(()=>{this.checkAutocomplete()})),this.listenerSetter.add(this.messageInput)("focusin",(()=>{"chat"!==this.chat.type&&"discussion"!==this.chat.type||!this.chat.bubbles.scrollable.loadedAll.bottom||this.managers.appMessagesManager.readAllHistory(this.chat.peerId,this.chat.threadId)}))}canSendPlain(){return!(!this.messageInput.isContentEditable&&!this.chatInput.classList.contains("is-hidden"))}applyMarkdown(e,t){var i;const s={link:t?()=>document.execCommand("createLink",!1,t):()=>document.execCommand("unlink",!1,null)},n=e=>{s[e]=()=>{const t=(a.includes(e)?a:[e]).filter((e=>c[e]));return(0,mt.Z)(t,e)||t.push(e),t.length?document.execCommand("fontName",!1,"markup-"+t.join("-")):this.resetCurrentFontFormatting()}},a=["bold","italic","underline","strikethrough","spoiler"];if(a.forEach((e=>{n(e)})),n("monospace"),!s[e])return!1;const o=s[e],r=[],d=Zt.Z.getInstance().prepareApplyingMarkdown(),l=this.listenerSetter.add(this.messageInput)("input",b.Z,{capture:!0,passive:!1});r.push(document.execCommand("styleWithCSS",!1,"true"));const c=(0,Pt.Z)(Object.keys(s));return c.monospace&&"link"===e&&r.push(this.resetCurrentFormatting()),r.push("function"==typeof o?o():document.execCommand(o,!1,null)),r.push(document.execCommand("styleWithCSS",!1,"false")),d(),null===(i=this.appImManager.markupTooltip)||void 0===i||i.setActiveMarkupButton(),this.listenerSetter.remove(l),this.messageInputField.simulateInputEvent(),!0}resetCurrentFormatting(){return document.execCommand("removeFormat",!1,null)}resetCurrentFontFormatting(){return document.execCommand("fontName",!1,"Roboto")}insertAtCaret(e,t,i=!0){if(!this.canSendPlain())return void(0,Z.bC)({langPackKey:Bt.send_plain});Zt.Z.getInstance().makeFocused(this.messageInput);const{value:s,caretPos:n,entities:a}=(0,C.Z)(this.messageInput),o=n>=0?n:s.length,r=s.substr(0,o),d=(s.substr(o),i?r.match(Nt.AUTO_COMPLETE_REG_EXP):null),l=d?d.index+(d[0].length-d[2].length):r.length;if(r.slice(0,l),i&&-1!==n){const e=d[2],t=document.getSelection();let i=0;for(;t.toString()!==e;){if(++i>=1e4)throw new Error("lolwhat");t.modify("extend","backward","character")}}(0,u.rf)(this.messageInput,e,t?[t]:void 0,this.chat.peerId)}checkAutocomplete(e,t,i){return Rt(this,void 0,void 0,(function*(){const s=void 0!==e;if(!s){const s=(0,C.Z)(this.messageInputField.input,!0,!0);e=s.value,t=s.caretPos,i=s.entities}if(-1===t&&(t=e.length),void 0===i||!s){const t=(0,rt.Z)(e,i,!0);i=(0,at.Z)(i,(0,ot.Z)(t))}if(e=e.slice(0,t),this.previousQuery===e)return;this.previousQuery=e;const n=e.match(Nt.AUTO_COMPLETE_REG_EXP);let a,o;if(n){const t=i[0];let s=n[2];const o=s[0];if(this.stickersHelper&&"none"!==x.Z.settings.stickers.suggest&&(yield this.chat.canSend("send_stickers"))&&"messageEntityEmoji"===(null==t?void 0:t._)&&t.length===e.length&&!t.offset)a=this.stickersHelper,this.stickersHelper.checkEmoticon(e);else if("@"===o){const e=this.chat.threadId?(0,ct.Z)(this.chat.threadId):void 0;(yield this.mentionsHelper.checkQuery(s,this.chat.peerId.isUser()?Qe.NM:this.chat.peerId,e))&&(a=this.mentionsHelper)}else n[1]||"/"!==o?x.Z.settings.emoji.suggest&&(s=s.replace(/^\s*/,""),e.match(/^\s*:(.+):\s*$/)||e.match(/:[;!@#$%^&*()-=|]/)||!s||(a=this.emojiHelper,this.emojiHelper.checkQuery(s,o))):(yield this.commandsHelper.checkQuery(s,this.chat.peerId))&&(a=this.commandsHelper)}a||(o=yield this.chat.canSend("send_inline")),a=this.checkInlineAutocomplete(e,o,a),this.autocompleteHelperController.hideOtherHelpers(a)}))}checkInlineAutocomplete(e,t,i){let s=!1;const n=e=>{this.btnPreloader&&(e&&!t&&(e=!1),(0,K.Z)({element:this.btnPreloader,className:"show",forwards:e,duration:400}))};if(!i){const a=e.match(/^@([a-zA-Z\\d_]{3,32})\s/);if(a){const o=a[1],r=e.slice(a[0].length);s=a[0].length===e.length,i=this.inlineHelper,this.btnPreloader?n(!0):(this.btnPreloader=this.createButtonIcon("none btn-preloader float show disable-hover",{noRipple:!0}),(0,Ve.y)(this.btnPreloader,!0),this.inputMessageContainer.parentElement.insertBefore(this.btnPreloader,this.inputMessageContainer.nextSibling)),this.inlineHelper.checkQuery(this.chat.peerId,o,r,t).then((({user:e,renderPromise:t})=>{s&&e.bot_inline_placeholder&&(this.messageInput.dataset.inlinePlaceholder=e.bot_inline_placeholder),t.then((()=>{n(!1)}))})).catch((e=>{n(!1)}))}}return s||delete this.messageInput.dataset.inlinePlaceholder,i!==this.inlineHelper&&n(!1),i}setRecording(e){this.recording!==e&&((0,K.Z)({element:this.chatInput,className:"is-recording",forwards:e,duration:200}),this.recording=e,this.updateSendBtn())}changeForwardRecipient(){if(this.helperWaitingForward)return;this.helperWaitingForward=!0;const e=(0,it.Z)(this.forwarding),t=this.helperFunc;this.clearHelper(),this.updateSendBtn();let i=!1;c.Z.createPopup(I.Z,e,(()=>{i=!0})).addEventListener("close",(()=>{this.helperWaitingForward=!1,i||t()}))}clearInput(e=!0,t=!0,i=""){return Rt(this,void 0,void 0,(function*(){if(document.activeElement===this.messageInput&&G.IS_MOBILE_SAFARI){const e=document.createElement("input");document.body.append(e),(0,Me.Z)(e),this.messageInputField.setValueSilently(i),(0,Me.Z)(this.messageInput),e.remove()}else this.messageInputField.setValueSilently(i);o.Z||(this.canRedoFromHTML="",this.undoHistory.length=0,this.executedHistory.length=0,this.canUndoFromHTML="");let s=!1;e&&(s=yield this.setDraft(void 0,!1)),!s&&t&&this.onMessageInput()}))}isInputEmpty(){return(0,y.Z)(this.messageInput)}updateSendBtn(){let e;const t=this.isInputEmpty();e=this.editMsgId?"edit":!this.recorder||this.recording||!t||this.forwarding?"scheduled"===this.chat.type?"schedule":"send":"record",["send","record","edit","schedule"].forEach((t=>{this.btnSend.classList.toggle(t,e===t)})),this.btnScheduled&&this.btnScheduled.classList.toggle("show",t&&"scheduled"!==this.chat.type),this.btnToggleReplyMarkup&&this.btnToggleReplyMarkup.classList.toggle("show",t&&"scheduled"!==this.chat.type)}getValueAndEntities(e){const{entities:t,value:i}=(0,C.Z)(e,!0,!1),s=(0,ot.Z)(i);return{value:i,totalEntities:(0,at.Z)(t,s)}}onMessageSent(e=!0,t){"scheduled"!==this.chat.type&&this.managers.appMessagesManager.readAllHistory(this.chat.peerId,this.chat.threadId,!0),this.scheduleDate=void 0,this.sendSilent=void 0;const{totalEntities:i}=this.getValueAndEntities(this.messageInput);let s=0;i.filter((e=>{if("messageEntityEmoji"===e._||"messageEntityCustomEmoji"===e._){const t=e.offset+e.length;return!(t<=s||(s=t,0))}return!1})).forEach((e=>{const t="messageEntityEmoji"===e._?{emoji:(0,ut.zu)(e.unicode)}:{docId:e.document_id,emoji:""};this.managers.appEmojiManager.pushRecentEmoji(t)})),e&&(this.lastUrl="",delete this.noWebPage,this.willSendWebPage=null,this.clearInput()),(t||e)&&this.clearHelper(),this.updateSendBtn()}sendMessage(e=!1){const{editMsgId:t,chat:i}=this;if("scheduled"===i.type&&!e&&!t)return void this.scheduleSending();const{peerId:s}=i,{noWebPage:n}=this,a=this.chat.getMessageSendingParams(),{value:o,entities:r}=(0,C.Z)(this.messageInputField.input,!0,!1);if(t){const e=this.editMessage;if(!o.trim()&&!e.media)return void c.Z.createPopup(We.Z,s,[t],i.type);this.managers.appMessagesManager.editMessage(e,o,{entities:r,noWebPage:n}),this.onMessageSent()}else o.trim()&&(this.managers.appMessagesManager.sendText(s,o,Object.assign(Object.assign({entities:r},a),{noWebPage:n,webPage:this.getWebPagePromise?void 0:this.willSendWebPage,clearDraft:!0})),"scheduled"===this.chat.type?this.onMessageSent(!0):this.onMessageSent(!1,!1));if(this.forwarding){const e=(0,it.Z)(this.forwarding);for(const t in e)this.managers.appMessagesManager.forwardMessages(s,t.toPeerId(),e[t],Object.assign(Object.assign({},a),{dropAuthor:this.forwardElements&&this.forwardElements.hideSender.checkboxField.checked,dropCaptions:this.isDroppingCaptions()})).catch((e=>Rt(this,void 0,void 0,(function*(){"VOICE_MESSAGES_FORBIDDEN"===e.type&&(0,Z.bC)({langPackKey:"Chat.SendVoice.PrivacyError",langPackArguments:[yield(0,Et.Z)({peerId:s})]})}))));o||this.onMessageSent()}}sendMessageWithDocument(e,t=!1,i=!1,s=!1){return Rt(this,void 0,void 0,(function*(){const n="sticker"===(e=yield this.managers.appDocsManager.getDoc(e)).type?"send_stickers":"gif"===e.type?"send_gifs":"send_media";return this.chat.peerId.isAnyChat()&&!(yield this.chat.canSend(n))?((0,Z.bC)({langPackKey:Bt[n]}),!1):"scheduled"!==this.chat.type||t?!(!e||e.sticker&&(0,Ct.Z)(e)&&!x.Z.premium||(this.managers.appMessagesManager.sendFile(this.chat.peerId,Object.assign(Object.assign({},this.chat.getMessageSendingParams()),{file:e,isMedia:!0,clearDraft:i,silent:s})),this.onMessageSent(i,!0),"sticker"===e.type&&this.managers.appStickersManager.saveRecentSticker(e.id),0)):(this.scheduleSending((()=>this.sendMessageWithDocument(e,!0,i,s))),!1)}))}canToggleHideAuthor(){const{forwardElements:e}=this;if(!e)return!1;const t=e.hideCaption.checkboxField;return!t.checked||(0,v.Z)(t.label,"FORM").classList.contains("hide")}isDroppingCaptions(){return!this.canToggleHideAuthor()}initMessageEditing(e){return Rt(this,void 0,void 0,(function*(){const t=yield this.chat.getMessage(e);let i=(0,dt.Z)(t.message,{entities:t.totalEntities,wrappingForPeerId:this.chat.peerId});const s=()=>Rt(this,void 0,void 0,(function*(){let n;if(!this.messageInput.isContentEditable){const e=yield this.getPlaceholderKey(!0),{contentEditable:t}=this.messageInput;this.messageInput.contentEditable="true";const{oldKey:i}=this.updateMessageInputPlaceholder(e);n=()=>{this.messageInput.contentEditable=t,this.updateMessageInputPlaceholder(i)}}const a=yield(0,lt.Z)({message:t,usingMids:[t.mid]});this.setTopInfo("edit",s,(0,g.ag)("AccDescrEditing"),a,i,t),this.editMsgId=e,this.editMessage=t,i=void 0,this.restoreInputLock=n}));s()}))}initMessagesForward(e){const t=()=>Rt(this,void 0,void 0,(function*(){const i=Object.keys(e).map((e=>e.toPeerId())),s=new Set;let n=0,a=0;const o=i.map((t=>Rt(this,void 0,void 0,(function*(){const i=e[t],o=i.map((e=>Rt(this,void 0,void 0,(function*(){var i;const n=yield this.managers.appMessagesManager.getMessageByPeer(t,e);!(null===(i=n.fwd_from)||void 0===i?void 0:i.from_name)||n.fromId||n.fwdFromId?s.add("P"+n.fromId):s.add("N"+n.fwd_from.from_name),n.media&&n.message&&++a}))));yield Promise.all(o),n+=i.length}))));yield Promise.all(o);const r=s.size>2,d=[...s].map((e=>{const t=e[0];if(e=e.slice(1),"P"===t){const t=e.toPeerId();return t===x.Z.myId?(0,g.ag)("Chat.Accessory.Forward.You"):new be.Z({peerId:t,dialog:!1,onlyFirstName:r}).element}return r?e.split(" ")[0]:e})),{forwardElements:l}=this;(0,v.Z)(l.showCaption.checkboxField.label,"FORM").classList.toggle("hide",!a);const c=l.hideCaption.checkboxField.checked;a&&c?l.hideSender.checkboxField.setValueSilently(!0):void 0!==this.forwardWasDroppingAuthor&&(this.forwardWasDroppingAuthor?l.hideSender:l.showSender).checkboxField.setValueSilently(!0);const h=l.showSender.checkboxField.checked?"Chat.Accessory.Forward":"Chat.Accessory.Hidden",u=(0,g.ag)(h,[n]),p=document.createDocumentFragment();let f,m;if(d.length<3?p.append(...(0,g.v_)(d,!1)):p.append(d[0],(0,g.ag)("AndOther",[d.length-1])),1===i.length){const t=i[0],s=e[t];if(f=yield this.managers.appMessagesManager.getMessageByPeer(t,s[0]),m=!!f.grouped_id,m){const e=yield this.managers.appMessagesManager.getMidsByMessage(f);(e.length!==n||e.find((e=>!s.includes(e))))&&(m=!1)}}const b=document.createDocumentFragment();if(m||1===n){const t=e[i[0]],s=yield(0,lt.Z)({message:f,usingMids:t});b.append(p,": ",s)}else b.append((0,g.ag)("Chat.Accessory.Forward.From"),": ",p);const y=this.setTopInfo("forward",t,u,b);l.modifyArgs.forEach(((e,t)=>{const s=e.textElement,n=g.ZP.weakMap.get(s);n.args=[t<2?i.length:a],n.update()})),this.forwardHover&&this.forwardHover.attachButtonListener(y,this.listenerSetter),this.forwarding=e}));t()}initMessageReply(e){return Rt(this,void 0,void 0,(function*(){if(this.replyToMsgId===e)return;let t=yield this.chat.getMessage(e);const i=()=>{let s;t?s=new be.Z({peerId:t.fromId,dialog:!1}).element:(s=(0,g.ag)("Loading"),this.managers.appMessagesManager.reloadMessages(this.chat.peerId,e).then((s=>{this.replyToMsgId===e&&(t=s,t?i():this.clearHelper("reply"))}))),this.setTopInfo("reply",i,s,t&&t.message,void 0,t),this.setReplyToMsgId(e)};i()}))}setReplyToMsgId(e){this.replyToMsgId=e,this.center(!0)}clearHelper(e){var t;"edit"===this.helperType&&"edit"!==e&&this.clearInput(),e&&(this.lastUrl="",delete this.noWebPage,this.willSendWebPage=null),"reply"!==e&&(this.setReplyToMsgId(void 0),this.forwarding=void 0),this.editMsgId=this.editMessage=void 0,this.helperType=this.helperFunc=void 0,this.restoreInputLock&&(null===(t=this.restoreInputLock)||void 0===t||t.call(this),this.restoreInputLock=void 0),this.chat.container.classList.contains("is-helper-active")&&(V.Z.removeByType("input-helper"),this.chat.container.classList.remove("is-helper-active"),this.t())}t(){const e="is-toggling-helper";(0,K.Z)({element:this.chat.container,className:e,forwards:!0,duration:150,onTransitionEnd:()=>{this.chat.container.classList.remove(e)}})}setInputValue(e,t=!0,i=!0){e||(e=""),t?this.clearInput(!1,!1,e):this.messageInputField.setValueSilently(e),(0,Ke.T2)((()=>{i&&(0,ue.Z)(this.messageInput),this.onMessageInput(),this.messageInput.scrollTop=this.messageInput.scrollHeight}))}setTopInfo(e,t,i="",s="",n,a){if(this.willSendWebPage&&"reply"===e)return;"webpage"!==e&&(this.clearHelper(e),this.helperType=e,this.helperFunc=t);const o=this.replyElements.container,r=o.lastElementChild.previousElementSibling,d=r.classList.contains("reply");this.replyElements.iconBtn.replaceWith(this.replyElements.iconBtn=this.createButtonIcon(("webpage"===e?"link":e)+" active reply-icon",{noRipple:!0}));const{container:l}=(0,It.Z)(i,s,this.chat.animationGroup,a);return d?r.replaceWith(l):o.insertBefore(l,o.lastElementChild),"webpage"===e&&(l.style.cursor="default"),this.chat.container.classList.contains("is-helper-active")||(this.chat.container.classList.add("is-helper-active"),this.t()),G.IS_MOBILE||V.Z.pushItem({type:"input-helper",onPop:()=>{this.onHelperCancel()}}),void 0!==n&&this.setInputValue(n),setTimeout((()=>{this.updateSendBtn()}),0),l}}Nt.AUTO_COMPLETE_REG_EXP=/(\s|^)((?:(?:@|^\/)\S*)|(?::|^[^:@\/])(?!.*[:@\/]).*)$/},2482:(e,t,i)=>{"use strict";i.d(t,{U7:()=>b,ZP:()=>y});var s=i(6654),n=i(2559),a=i(2946),o=i(3512),r=i(9099),d=i(2149),l=i(3541),c=i(9083),h=i(6775),u=i(9405),p=i(3035),f=i(319),m=i(5994);const g="reaction",v=g+"-element",b=4;class y extends HTMLElement{constructor(){super(),this.classList.add(g),this.managers=o.Z.managers}get reactionCount(){return this._reactionCount}set reactionCount(e){this._reactionCount=e}get count(){return this.reactionCount.count}init(e,t){this.type=e,this.classList.add(g+"-"+e),this.middleware=t}setCanRenderAvatars(e){this.canRenderAvatars=e}render(e){const t=!!this.stickerContainer;t||(this.stickerContainer=document.createElement("div"),this.stickerContainer.classList.add(g+"-sticker"),this.append(this.stickerContainer));const i=this.reactionCount;if(!e&&!t){const e=i.reaction;if("reactionEmoji"===e._){const t=this.managers.appReactionsManager.getReaction(e.emoticon);(0,s.Z)(t,(e=>{var t;e.center_icon||this.stickerContainer.classList.add("is-static"),e.pFlags.inactive&&this.classList.add("is-inactive"),this.renderDoc(null!==(t=e.center_icon)&&void 0!==t?t:e.static_icon)}))}else if("reactionCustomEmoji"===e._){this.stickerContainer.classList.add("is-custom");const t=(0,c.Z)({docIds:[e.document_id],customEmojiSize:(0,u.C)(22,22)});this.stickerContainer.append(t)}}}renderDoc(e){const t="inline"===this.type?14:22,i=this.wrapStickerPromise=(0,l.ZP)({div:this.stickerContainer,doc:e,width:t,height:t,static:!0,managers:this.managers,middleware:this.middleware}).then((({render:e})=>e)).finally((()=>{this.wrapStickerPromise===i&&(this.wrapStickerPromise=void 0)}))}renderCounter(){var e;const t=this.reactionCount,i="inline"===this.type?2:b;if(t.count>=i||"block"===this.type&&!this.canRenderAvatars){this.counter||(this.counter=document.createElement("inline"===this.type?"i":"span"),this.counter.classList.add(g+"-counter"));const e=(0,n.Z)(t.count);this.counter.textContent!==e&&(this.counter.textContent=e),this.counter.parentElement||this.append(this.counter)}else(null===(e=this.counter)||void 0===e?void 0:e.parentElement)&&(this.counter.remove(),this.counter=void 0)}renderAvatars(e){"inline"!==this.type&&(this.reactionCount.count>=b||!this.canRenderAvatars?this.stackedAvatars&&(this.stackedAvatars.container.remove(),this.stackedAvatars=void 0):(this.stackedAvatars||(this.stackedAvatars=new d.Z({avatarSize:24}),this.append(this.stackedAvatars.container)),this.stackedAvatars.render(e.map((e=>(0,a.Z)(e.peer_id))))))}setIsChosen(e=void 0!==this.reactionCount.chosen_order){"inline"!==this.type&&(this.classList.contains("is-chosen")&&!this.classList.contains("backwards"))!==e&&(0,r.Z)({element:this,className:"is-chosen",forwards:e,duration:this.isConnected?300:0})}fireAroundAnimation(){if(!m.Z.isAvailable("effects_reactions"))return;const e=this.reactionCount.reaction;"reactionEmoji"===e._&&(0,s.Z)(this.managers.appReactionsManager.getReaction(e.emoticon),(e=>{const t="inline"===this.type?28:40,i=document.createElement("div");i.classList.add(g+"-sticker-activate"),Promise.all([(0,l.ZP)({div:i,doc:e.center_icon,width:t,height:t,withThumb:!1,needUpscale:!0,play:!1,skipRatio:1,group:"none",needFadeIn:!1,managers:this.managers,middleware:this.middleware}).then((({render:e})=>e)),(0,h.Z)({doc:e.around_animation,size:80,target:this.stickerContainer,side:"center",skipRatio:1,play:!1,managers:this.managers,middleware:this.middleware}).stickerPromise.catch(f.Z)]).then((([e,t])=>{const s=()=>{e.remove(),i.remove(),this.stickerContainer.classList.remove("has-animation")};if(!t)return void s();const n=()=>{(0,p.T2)(s)};e.addEventListener("enterFrame",(t=>{t===e.maxFrame&&(this.wrapStickerPromise?this.wrapStickerPromise.then((()=>{setTimeout(n,1e3)})):n())})),e.addEventListener("firstFrame",(()=>{this.stickerContainer.append(i),this.stickerContainer.classList.add("has-animation"),e.play(),t.play()}),{once:!0})}))}))}}customElements.define(v,y)},8947:(e,t,i)=>{"use strict";i.d(t,{G:()=>h,Z:()=>u});var s=i(7625),n=i(4484),a=i(7030),o=i(5285),r=i(3512),d=i(2482);const l="reactions",c=l+"-element",h=new Map;class u extends HTMLElement{constructor(){super(),this.classList.add(l),this.sorted=[],this.middlewareHelpers=new Map,this.managers=r.Z.managers}connectedCallback(){let e=h.get(this.key);e||h.set(this.key,e=new Set),e.add(this),this.onConnectCallback&&this.isConnected&&(this.onConnectCallback(),this.onConnectCallback=void 0)}disconnectedCallback(){const e=h.get(this.key);e.delete(this),e.size||h.delete(this.key)}getReactionCount(e){return this.sorted[this.sorted.indexOf(e)].reactionCount}getMessage(){return this.message}init(e,t,i,s=this.isPlaceholder){void 0!==this.key&&this.disconnectedCallback(),this.middleware!==i&&i.onDestroy((()=>{this.middlewareHelpers.clear()})),this.message=e,this.key=this.message.peerId+"_"+this.message.mid,this.middleware=i,this.isPlaceholder=s,this.type!==t&&(this.type=t,this.classList.add(l+"-"+t)),this.connectedCallback()}changeMessage(e){return this.init(e,this.type,this.middleware)}update(e,t){this.message=e,this.render(t)}render(e){const t=this.message.reactions,i=!(!t||!t.results.length);if(this.classList.toggle("has-no-reactions",!i),!i&&!this.sorted.length)return;this.managers.appReactionsManager.getAvailableReactions();const a=i?t.results:[];a.sort(((e,t)=>{var i,s;return t.count-e.count||(null!==(i=e.chosen_order)&&void 0!==i?i:0)-(null!==(s=t.chosen_order)&&void 0!==s?s:0)})),(0,s.Z)(this.sorted,((e,t,i)=>{const s=e.reactionCount.reaction;a.some((e=>(0,o.Z)(e.reaction,s)))||(this.middlewareHelpers.get(e).destroy(),this.middlewareHelpers.delete(e),i.splice(t,1),e.remove())}));const r=a.reduce(((e,t)=>e+t.count),0),l=t&&(!!t.pFlags.can_see_list||this.message.peerId.isUser())&&r<d.U7;if(this.sorted=a.map(((e,i)=>{let s=this.sorted.find((t=>(0,o.Z)(t.reactionCount.reaction,e.reaction)));if(!s){const e=this.middleware.create();s=new d.ZP,s.init(this.type,e.get()),this.middlewareHelpers.set(s,e)}(0,n.Z)(s,this,i);const a=t.recent_reactions?t.recent_reactions.filter((t=>(0,o.Z)(t.reaction,e.reaction))):[];return s.reactionCount=Object.assign({},e),s.setCanRenderAvatars(l),s.render(this.isPlaceholder),s.renderCounter(),s.renderAvatars(a),s.setIsChosen(),s})),!this.isPlaceholder&&(null==e?void 0:e.length)&&(this.isConnected?this.handleChangedResults(e):this.onConnectCallback=()=>{this.handleChangedResults(e)}),!this.sorted.length&&"block"===this.type){const e=this.parentElement;if(this.remove(),e.classList.contains("document-message")&&!e.childNodes.length)return void e.remove();const t=this.querySelector(".time");t&&e.append(t)}}handleChangedResults(e){this.message.peerId===a.ZP.chat.peerId&&e.forEach((e=>{const t=this.sorted.find((t=>(0,o.Z)(t.reactionCount.reaction,e.reaction)));null==t||t.fireAroundAnimation()}))}}customElements.define(c,u)},3484:(e,t,i)=>{"use strict";i.d(t,{Z:()=>g,o:()=>m});var s=i(5565),n=i(8456),a=i(7030),o=i(9687),r=i(8115),d=i(4561),l=i(496),c=i(9492),h=i(3541),u=i(2887),p=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};const f=32;function m(e){var t;return p(this,void 0,void 0,(function*(){let{title:i,titleEl:d,subtitle:p,subtitleEl:m,mediaEl:g,message:v,loadPromises:b,animationGroup:y}=e;void 0!==i&&("string"==typeof i&&(i=(0,n.Z)(i,140),i=(0,r.Z)(i)),(0,s.Z)(d,i)),b||(b=[]);let w=null==v?void 0:v.media,S=!1,C=!1;const L=g?Array.from(g.children).slice():[];let E;if(w&&g){m.textContent="",m.append(yield(0,l.Z)({message:v,animationGroup:y,withoutMediaType:!0})),w=w.webpage||w;const e=w.photo,i=w.document;if(e||i&&(null===(t=i.thumbs)||void 0===t?void 0:t.length)){E=a.ZP.chat.bubbles.getMiddleware();const t=a.ZP.chat.bubbles.lazyLoadQueue;if("sticker"===(null==i?void 0:i.type))yield(0,h.ZP)({doc:i,div:g,lazyLoadQueue:t,group:y,width:f,height:f,middleware:E,loadPromises:b}),S=!0;else if("gif"===(null==i?void 0:i.type)&&i.video_thumbs)S=!0,yield(0,u.Z)({doc:i,container:g,boxWidth:f,boxHeight:f,lazyLoadQueue:t,noPlayButton:!0,noInfo:!0,middleware:E,loadPromises:b,withoutPreloader:!0,videoSize:i.video_thumbs[0],group:y});else{const s=e||i;C="round"===(null==i?void 0:i.type);try{yield(0,c.Z)({photo:s,container:g,boxWidth:f,boxHeight:f,size:(0,o.Z)(s,f,f),middleware:E,lazyLoadQueue:t,noBlur:!0,withoutPreloader:!0,loadPromises:b}),S=!0}catch(e){}}}}else v?(m.textContent="",m.append(yield(0,l.Z)({message:v}))):("string"==typeof p&&(p=(0,n.Z)(p,140),p=(0,r.Z)(p)),(0,s.Z)(m,p||""));return Promise.all(b).then((()=>{E&&!E()||(L.forEach((e=>e.remove())),g&&g.classList.toggle("is-round",C))})),S}))}class g extends d.Z{constructor(e,t){super(e,((e,i="",s)=>p(this,void 0,void 0,(function*(){this.mediaEl||(this.mediaEl=document.createElement("div"),this.mediaEl.classList.add(this.className+"-media"));const n=yield m({title:e,titleEl:this.title,subtitle:i,subtitleEl:this.subtitle,mediaEl:this.mediaEl,message:s,animationGroup:t});this.container.classList.toggle("is-media",n),n?this.content.prepend(this.mediaEl):this.mediaEl.remove()})))),this.className=e,this.animationGroup=t}}},6054:(e,t,i)=>{"use strict";i.d(t,{e:()=>x,Z:()=>A});var s=i(5432),n=i(4494),a=i(2230),o=i(9807),r=i(5128),d=i(4524),l=i(9099),c=i(1962),h=i(5824),u=i(4762),p=i(2325),f=i(8497),m=i(8799),g=i(3910),v=i(6760),b=i(5565),y=i(8487),w=i(144),S=i(2738),C=i(5975),L=i(3241),E=i(5953),I=i(6976),P=(i(6690),i(7030)),Z=i(1168),M=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};const k=e=>[...e.values()].reduce(((e,t)=>e+t.size),0);class T extends L.Z{constructor(e){super(!1),this.selectedMids=new Map,this.isSelecting=!1,this.onMouseDown=e=>{const t=(0,f.Z)(e.target,this.targetLookupClassName);if(0!==e.button)return;if(this.verifyTarget&&!this.verifyTarget(e,t))return;const i=new Map;let s,n=t;const a=(e,t=!0)=>{const o=+e.dataset.mid;if(!o||!e.dataset.peerId)return;const r=e.dataset.peerId.toPeerId();(0,y.Z)(n)||(n=e);let d=i.get(r);if(d||i.set(r,d=new Set),d.has(o))return;const l=this.isMidSelected(r,o);if(void 0===s&&(s=!l),d.add(o),s&&!l||!s&&l){const s=k(i);if(this.toggleByElement&&t){s<2&&(0,C.Z)(e,n)&&(n=e);const t=this.getElementsBetween(n,e);t.length&&t.forEach((e=>{a(e,!1)}))}if(this.selectedMids.size)this.toggleByElement&&this.toggleByElement(e);else if(2===s&&this.toggleByMid)for(const[e,t]of i)for(const i of t)this.toggleByMid(e,i)}};let o=!1;const r=e=>{o||((0,v.Z)(),o=!0);const t=this.getElementFromTarget(e.target);if(t)return this.verifyMouseMoveTarget&&!this.verifyMouseMoveTarget(e,t,s)?(this.listenerSetter.removeManual(this.listenElement,"mousemove",r),void this.listenerSetter.removeManual(document,"mouseup",d,l)):void a(t)},d=e=>{i.size&&(0,S.fc)(window,g.Z,{capture:!0,once:!0,passive:!1}),this.listenerSetter.removeManual(this.listenElement,"mousemove",r),(0,v.Z)()},l={once:!0};this.listenerSetter.add(this.listenElement)("mousemove",r),this.listenerSetter.add(document)("mouseup",d,l)},this.getElementsBetween=(e,t)=>{if(e===t)return[];const i=e.getBoundingClientRect(),s=t.getBoundingClientRect(),n=(i.top-s.top||i.left-s.left)<0,a=(0,f.Z)(e,this.lookupBetweenParentClassName);if(!a)return[];const o=Array.from(a.querySelectorAll(this.lookupBetweenElementsQuery));let r=o.indexOf(e),d=o.indexOf(t);return n||([d,r]=[r,d]),o.slice(r+1,d)},this.cancelSelection=e=>M(this,void 0,void 0,(function*(){e&&(this.doNotAnimate=!0),this.onCancelSelection&&(yield this.onCancelSelection()),this.selectedMids.clear(),this.toggleSelection(),(0,v.Z)(),e&&(this.doNotAnimate=void 0)})),(0,E.Z)(this,e),this.navigationType="multiselect-"+(0,w.a)()}attachListeners(e,t){if(this.listenElement&&this.listenerSetter.removeAll(),this.listenElement=e,this.listenerSetter=t,e)return s.Z?(t.add(e)("touchend",(()=>{this.isSelecting&&(this.selectedText=window.getSelection?window.getSelection().toString():document.selection?document.selection.createRange().text:"")})),void(0,I.E)({element:e,callback:t=>{if(this.isSelecting||this.verifyTouchLongPress&&!this.verifyTouchLongPress())return;document.body.classList.add("no-select"),e.addEventListener("touchend",(e=>{(0,g.Z)(e),document.body.classList.remove("no-select")}),{once:!0,capture:!0}),(0,v.Z)();const i=this.getElementFromTarget(t.target);i&&this.toggleByElement(i)},listenerSetter:t})):void t.add(e)("mousedown",this.onMouseDown)}isElementShouldBeSelected(e){return this.isMidSelected(e.dataset.peerId.toPeerId(),+e.dataset.mid)}appendCheckbox(e,t){e.prepend(t.label)}toggleElementCheckbox(e,t){const i=!!this.getCheckboxInputFromElement(e);if(t){if(i)return!1;const t=new o.Z({name:e.dataset.mid,round:!0});this.isSelecting&&this.isElementShouldBeSelected(e)&&(t.input.checked=!0,e.classList.add("is-selected")),this.appendCheckbox(e,t)}else i&&(this.getCheckboxInputFromElement(e).parentElement.remove(),(0,l.Z)({element:e,className:"is-selected",forwards:!1,duration:200}));return!0}getCheckboxInputFromElement(e){var t;return"LABEL"===(null===(t=e.firstElementChild)||void 0===t?void 0:t.tagName)&&e.firstElementChild.firstElementChild}updateContainer(e=!1){var t;return M(this,void 0,void 0,(function*(){const i=this.selectedMids.size;if(!i&&!e)return;let s=!i,n=!i;const a=!i;for(const[e,t]of this.selectedMids){const i=this.getStorageKey(e),a=yield this.managers.appMessagesManager.cantForwardDeleteMids(i,Array.from(t));if(s=a.cantForward,n=a.cantDelete,s&&n)break}null===(t=this.onUpdateContainer)||void 0===t||t.call(this,s,n,a)}))}getStorageKey(e){return`${e}_${this.isScheduled?"scheduled":"history"}`}getSelectedMessages(){const e=[];return this.selectedMids.forEach(((t,i)=>{const s=this.getStorageKey(i),n=Array.from(t).map((e=>this.managers.appMessagesManager.getMessageFromStorage(s,e)));e.push(...n)})),Promise.all(e)}toggleSelection(e=!0,t=!1){var i;const n=this.isSelecting,a=this.selectedMids.size;if(this.isSelecting=!!a||t,n===this.isSelecting)return!1;this.dispatchEvent("toggle",this.isSelecting),s.Z||(this.listenElement.classList.toggle("no-select",this.isSelecting),n&&(0,v.Z)()),(0,m.Z)();const o=!!a||t,r=null===(i=this.onToggleSelection)||void 0===i?void 0:i.call(this,o,!this.doNotAnimate);return u.IS_MOBILE_SAFARI||(o?h.Z.pushItem({type:this.navigationType,onPop:()=>{this.cancelSelection()}}):h.Z.removeByType(this.navigationType)),t&&(r||Promise.resolve()).then((()=>this.updateContainer(t))),!0}cleanup(){this.doNotAnimate=!0,this.selectedMids.clear(),this.toggleSelection(!1),this.doNotAnimate=void 0}updateElementSelection(e,t){this.toggleElementCheckbox(e,!0),this.getCheckboxInputFromElement(e).checked=t,this.toggleSelection(),this.updateContainer(),(0,l.Z)({element:e,className:"is-selected",forwards:t,duration:200})}isMidSelected(e,t){const i=this.selectedMids.get(e);return!!(null==i?void 0:i.has(t))}length(){return k(this.selectedMids)}toggleMid(e,t,i){let s=this.selectedMids.get(e);return i||void 0===i&&(null==s?void 0:s.has(t))?s&&(s.delete(t),s.size||this.selectedMids.delete(e)):(s||(s=new Set,this.selectedMids.set(e,s)),s.add(t)),!0}deleteSelectedMids(e,t){const i=this.selectedMids.get(e);i&&(t.forEach((e=>{i.delete(e)})),i.size||this.selectedMids.delete(e),this.updateContainer(),this.toggleSelection())}}class x extends T{constructor(e,t,i){super({managers:t,verifyTarget:(e,t)=>!!t&&this.isSelecting,getElementFromTarget:e=>(0,f.Z)(e,"search-super-item"),targetLookupClassName:"search-super-item",lookupBetweenParentClassName:"tabs-tab",lookupBetweenElementsQuery:".search-super-item"}),this.searchSuper=e,this.toggleByElement=e=>{const t=+e.dataset.mid,i=e.dataset.peerId.toPeerId();this.toggleMid(i,t)&&this.updateElementSelection(e,this.isMidSelected(i,t))},this.toggleByMid=(e,t)=>{const i=this.searchSuper.mediaTab.contentTab.querySelector(`.search-super-item[data-peer-id="${e}"][data-mid="${t}"]`);this.toggleByElement(i)},this.onUpdateContainer=(e,t,i)=>{const s=this.length();(0,b.Z)(this.selectionCountEl,(0,p.ag)("messages",[s])),this.selectionGotoBtn.classList.toggle("hide",1!==s),this.selectionForwardBtn.classList.toggle("hide",e),this.selectionDeleteBtn&&this.selectionDeleteBtn.classList.toggle("hide",t)},this.onToggleSelection=(e,t)=>{if((0,l.Z)({element:this.searchSuper.navScrollableContainer,className:"is-selecting",forwards:e,duration:t?200:0,onTransitionEnd:()=>{this.isSelecting||(this.selectionContainer.remove(),this.selectionContainer=this.selectionForwardBtn=this.selectionDeleteBtn=null,this.selectedText=void 0)}}),(0,l.Z)({element:this.searchSuper.container,className:"is-selecting",forwards:e,duration:200}),this.isSelecting&&!this.selectionContainer){const e="search-super-selection";this.selectionContainer=document.createElement("div"),this.selectionContainer.classList.add(e+"-container");const t=(0,a.Z)(`close ${e}-cancel`,{noRipple:!0});(0,S.fc)(t,(()=>this.cancelSelection()),{listenerSetter:this.listenerSetter,once:!0}),this.selectionCountEl=document.createElement("div"),this.selectionCountEl.classList.add(e+"-count"),this.selectionGotoBtn=(0,a.Z)(`message ${e}-goto`);const i={listenerSetter:this.listenerSetter};(0,S.fc)(this.selectionGotoBtn,(()=>{const e=[...this.selectedMids.keys()][0],t=[...this.selectedMids.get(e)][0];this.cancelSelection(),P.ZP.setInnerPeer({peerId:e,lastMsgId:t})}),i),this.selectionForwardBtn=(0,a.Z)(`forward ${e}-forward`),(0,S.fc)(this.selectionForwardBtn,(()=>{const e={};for(const[t,i]of this.selectedMids)e[t]=Array.from(i).sort(((e,t)=>e-t));Z.Z.createPopup(d.Z,e,(()=>{this.cancelSelection()}))}),i),this.isPrivate&&(this.selectionDeleteBtn=(0,a.Z)(`delete danger ${e}-delete`),(0,S.fc)(this.selectionDeleteBtn,(()=>{const e=[...this.selectedMids.keys()][0];Z.Z.createPopup(r.Z,e,[...this.selectedMids.get(e)],"chat",(()=>{this.cancelSelection()}))}),i)),this.selectionContainer.append(...[t,this.selectionCountEl,this.selectionGotoBtn,this.selectionForwardBtn,this.selectionDeleteBtn].filter(Boolean));const s=this.selectionContainer;s.style.opacity="0",this.searchSuper.navScrollableContainer.append(s),s.offsetLeft,s.style.opacity=""}},this.isPrivate=!e.showSender,this.attachListeners(e.container,i)}toggleSelection(e=!0,t=!1){const i=super.toggleSelection(e,t);return i&&e&&Array.from(this.searchSuper.tabsContainer.querySelectorAll(".search-super-item")).forEach((e=>{this.toggleElementCheckbox(e,this.isSelecting)})),i}}class A extends T{constructor(e,t,i,s){super({managers:s,getElementFromTarget:e=>(0,f.Z)(e,"grouped-item")||(0,f.Z)(e,"bubble"),verifyTarget:(e,t)=>!(!this.selectedMids.size&&!e.target.classList.contains("bubble")&&!e.target.classList.contains("document-selection")&&t),verifyMouseMoveTarget:(e,t,i)=>!(e.target!==t&&!e.target.classList.contains("document-selection")&&void 0===i&&!this.selectedMids.size),verifyTouchLongPress:()=>!this.chat.input.recording,targetLookupClassName:"bubble",lookupBetweenParentClassName:"bubbles-inner",lookupBetweenElementsQuery:".bubble:not(.is-multiple-documents), .grouped-item",isScheduled:"scheduled"===e.type}),this.chat=e,this.bubbles=t,this.input=i,this.toggleByElement=e=>{if(!this.canSelectBubble(e))return;const t=+e.dataset.mid;if(e.classList.contains("is-grouped")){if(!this.isGroupedBubbleSelected(e)){const t=this.selectedMids.get(this.chat.peerId);t&&this.getMidsFromGroupContainer(e).forEach((e=>t.delete(e)))}this.bubbles.getBubbleGroupedItems(e).map(this.toggleByElement)}else if(this.toggleMid(this.chat.peerId,t)){if(e.classList.contains("grouped-item")){const t=(0,f.Z)(e,"bubble"),i=this.isGroupedBubbleSelected(t),s=this.isGroupedMidsSelected(t);(s||i)&&this.updateElementSelection(t,s)}this.updateElementSelection(e,this.isMidSelected(this.chat.peerId,t))}},this.toggleByMid=(e,t)=>M(this,void 0,void 0,(function*(){const e=yield this.bubbles.getMountedBubble(t);e&&this.toggleByElement(e.bubble)})),this.onToggleSelection=(e,t)=>M(this,void 0,void 0,(function*(){const{needTranslateX:i,widthFrom:s,widthTo:o}=yield this.chat.input.center(t);(0,l.Z)({element:this.listenElement,className:"is-selecting",forwards:e,duration:t?200:0,onTransitionEnd:()=>{this.isSelecting||(this.selectionInputWrapper.remove(),this.selectionInputWrapper=this.selectionContainer=this.selectionSendNowBtn=this.selectionForwardBtn=this.selectionDeleteBtn=this.selectionLeft=this.selectionRight=null,this.selectedText=void 0)}});const h=s<o?void 0:2*i;if(this.isSelecting){if(!this.selectionContainer){this.selectionInputWrapper=document.createElement("div"),this.selectionInputWrapper.classList.add("chat-input-wrapper","selection-wrapper"),this.selectionContainer=document.createElement("div"),this.selectionContainer.classList.add("selection-container");const e={listenerSetter:this.listenerSetter},t=(0,a.Z)("close",{noRipple:!0});(0,S.fc)(t,(()=>this.cancelSelection()),{once:!0,listenerSetter:this.listenerSetter}),this.selectionCountEl=document.createElement("div"),this.selectionCountEl.classList.add("selection-container-count"),"scheduled"===this.chat.type?(this.selectionSendNowBtn=(0,n.Z)("btn-primary btn-transparent btn-short text-bold selection-container-send",{icon:"send2"}),this.selectionSendNowBtn.append((0,p.ag)("MessageScheduleSend")),(0,S.fc)(this.selectionSendNowBtn,(()=>{Z.Z.createPopup(c.Z,this.chat.peerId,[...this.selectedMids.get(this.chat.peerId)],(()=>{this.cancelSelection()}))}),e)):(this.selectionForwardBtn=(0,n.Z)("btn-primary btn-transparent text-bold selection-container-forward",{icon:"forward"}),this.selectionForwardBtn.append((0,p.ag)("Forward")),(0,S.fc)(this.selectionForwardBtn,(()=>{const e={};for(const[t,i]of this.selectedMids)e[t]=Array.from(i).sort(((e,t)=>e-t));Z.Z.createPopup(d.Z,e,(()=>{this.cancelSelection()}))}),e)),this.selectionDeleteBtn=(0,n.Z)("btn-primary btn-transparent danger text-bold selection-container-delete",{icon:"delete"}),this.selectionDeleteBtn.append((0,p.ag)("Delete")),(0,S.fc)(this.selectionDeleteBtn,(()=>{Z.Z.createPopup(r.Z,this.chat.peerId,[...this.selectedMids.get(this.chat.peerId)],this.chat.type,(()=>{this.cancelSelection()}))}),e);const i=this.selectionLeft=document.createElement("div");i.classList.add("selection-container-left"),i.append(t,this.selectionCountEl);const s=this.selectionRight=document.createElement("div");s.classList.add("selection-container-right"),s.append(...[this.selectionSendNowBtn,this.selectionForwardBtn,this.selectionDeleteBtn].filter(Boolean)),void 0!==h&&(i.style.transform=`translateX(${-h}px)`,s.style.transform=`translateX(${h}px)`),this.selectionContainer.append(i,s),this.selectionInputWrapper.style.opacity="0",this.selectionInputWrapper.append(this.selectionContainer),this.input.inputContainer.append(this.selectionInputWrapper),this.selectionInputWrapper.offsetLeft,this.selectionInputWrapper.style.opacity=""}this.selectionLeft.style.transform="",this.selectionRight.style.transform=""}else this.selectionLeft&&void 0!==h&&(this.selectionLeft.style.transform=`translateX(-${h}px)`,this.selectionRight.style.transform=`translateX(${h}px)`)})),this.onUpdateContainer=(e,t,i)=>{(0,b.Z)(this.selectionCountEl,(0,p.ag)("messages",[this.length()])),this.selectionSendNowBtn&&this.selectionSendNowBtn.toggleAttribute("disabled",i),this.selectionForwardBtn&&this.selectionForwardBtn.toggleAttribute("disabled",e),this.selectionDeleteBtn&&this.selectionDeleteBtn.toggleAttribute("disabled",t)},this.onCancelSelection=()=>M(this,void 0,void 0,(function*(){}))}appendCheckbox(e,t){t.label.classList.add("bubble-select-checkbox"),e.classList.contains("document-container")?e.querySelector(".document, audio-element").append(t.label):super.appendCheckbox(e,t)}toggleSelection(e=!0,t=!1){const i=super.toggleSelection(e,t);if(i&&e)for(const e in this.bubbles.bubbles){if(this.bubbles.skippedMids.has(+e))continue;const t=this.bubbles.bubbles[e];this.toggleElementCheckbox(t,this.isSelecting)}return i}toggleElementCheckbox(e,t){if(!this.canSelectBubble(e))return;const i=super.toggleElementCheckbox(e,t);return i&&e.classList.contains("is-grouped")&&this.bubbles.getBubbleGroupedItems(e).forEach((e=>this.toggleElementCheckbox(e,t))),i}isElementShouldBeSelected(e){const t=e.classList.contains("is-grouped");return super.isElementShouldBeSelected(e)&&(!t||this.isGroupedMidsSelected(e))}isGroupedBubbleSelected(e){const t=this.getCheckboxInputFromElement(e);return null==t?void 0:t.checked}getMidsFromGroupContainer(e){const t=this.chat.bubbles.getBubbleGroupedItems(e);return t.length||t.push(e),t.map((e=>+e.dataset.mid))}isGroupedMidsSelected(e){const t=this.getMidsFromGroupContainer(e),i=t.filter((e=>this.isMidSelected(this.chat.peerId,e)));return t.length===i.length}getCheckboxInputFromElement(e){return e.classList.contains("document-container")?e.querySelector("label input"):super.getCheckboxInputFromElement(e)}canSelectBubble(e){return!(e.classList.contains("service")||e.classList.contains("is-outgoing")||e.classList.contains("is-error")||e.classList.contains("bubble-first")||e.classList.contains("avoid-selection"))}}},6676:(e,t,i)=>{"use strict";i.d(t,{Z:()=>d});var s=i(3416),n=i(6976),a=i(3910),o=i(3512),r=i(3003);class d{constructor(e){this.sendMenuButtons=[{icon:"mute",text:"Chat.Send.WithoutSound",onClick:e.onSilentClick,verify:()=>"schedule"===this.type},{icon:"schedule",text:"Chat.Send.ScheduledMessage",onClick:e.onScheduleClick,verify:()=>"schedule"===this.type},{icon:"schedule",text:"Chat.Send.SetReminder",onClick:e.onScheduleClick,verify:()=>"reminder"===this.type}],this.sendMenu=(0,r.b)({buttons:this.sendMenuButtons,listenerSetter:e.listenerSetter}),this.sendMenu.classList.add("menu-send",e.openSide),(0,n.E)({element:e.onContextElement,callback:t=>{e.onOpen&&!e.onOpen()||(this.sendMenuButtons.forEach((e=>{e.element.classList.toggle("hide",!e.verify())})),(0,a.Z)(t),s.Z.openBtnMenu(this.sendMenu))},listenerSetter:e.listenerSetter})}setPeerId(e){this.type=e===o.Z.myId?"reminder":"schedule"}}},9807:(e,t,i)=>{"use strict";i.d(t,{Z:()=>l});var s=i(1405),n=i(2325),a=i(9750),o=i(3512),r=i(3855),d=i(6669);class l{constructor(e={}){const t=this.label=document.createElement("label");t.classList.add("checkbox-field"),e.restriction&&!e.toggle&&t.classList.add("checkbox-field-restriction"),e.round&&t.classList.add("checkbox-field-round"),e.disabled&&this.toggleDisability(!0),this.listenerSetter=e.listenerSetter;const i=this.input=document.createElement("input");if(i.classList.add("checkbox-field-input"),i.type=e.asRadio?"radio":"checkbox",e.name&&(i[e.asRadio?"name":"id"]="input-"+e.name),e.checked&&(i.checked=!0),e.stateKey){let t=!1;const s=()=>{if(!t)return;let s;e.stateValues?s=e.stateValues[i.checked?1:0]:(s=i.checked,e.stateValueReverse&&(s=!s)),o.Z.managers.appStateManager.setByKey(e.stateKey,s)};void 0===e.checked&&r.Z.getState().then((i=>{t=!0;const s=(0,a.Z)(i,e.stateKey);let n;e.stateValues?n=1===e.stateValues.indexOf(s):(n=s,e.stateValueReverse&&(n=!n)),this.setValueSilently(n)})),e.listenerSetter?e.listenerSetter.add(i)("change",s):i.addEventListener("change",s)}let d;if(e.text?(d=this.span=document.createElement("span"),d.classList.add("checkbox-caption"),(0,n.$d)(d,e.text,e.textArgs)):t.classList.add("checkbox-without-caption"),t.append(i),e.toggle){t.classList.add("checkbox-field-toggle"),e.restriction&&t.classList.add("checkbox-field-toggle-restriction");const i=document.createElement("div");i.classList.add("checkbox-toggle"),t.append(i)}else{const e=document.createElement("div");e.classList.add("checkbox-box");const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.classList.add("checkbox-box-check"),i.setAttributeNS(null,"viewBox","0 0 24 24");const s=document.createElementNS("http://www.w3.org/2000/svg","use");s.setAttributeNS(null,"href","#check"),s.setAttributeNS(null,"x","-1"),i.append(s);const n=document.createElement("div");n.classList.add("checkbox-box-background");const a=document.createElement("div");a.classList.add("checkbox-box-border"),e.append(a,n,i),t.append(e)}d&&t.append(d),e.withRipple?(t.classList.add("checkbox-ripple","hover-effect"),(0,s.Z)(t,void 0,void 0,!0)):e.withHover&&t.classList.add("hover-effect")}get checked(){return this.input.checked}set checked(e){this.setValueSilently(e),(0,d.Z)(this.input,"change")}setValueSilently(e){this.input.checked=e}isDisabled(){return this.label.classList.contains("checkbox-disabled")}toggleDisability(e){return this.label.classList.toggle("checkbox-disabled",e),this.input.disabled=e,()=>this.toggleDisability(!e)}}},8610:(e,t,i)=>{"use strict";i.d(t,{Z:()=>h});var s=i(3910),n=i(2738),a=i(5975),o=i(5953),r=i(2325),d=i(9807),l=i(7479),c=i(2796);class h{constructor(e){(0,o.Z)(this,e)}createField(e,t){var i;if(e.nestedTo&&!t)return;const o=e.row=new l.ZP({titleLangKey:t?void 0:e.text,checkboxField:e.checkboxField=new d.Z({text:t?e.text:void 0,checked:!e.nested&&e.checked,toggle:!t,listenerSetter:this.listenerSetter,restriction:this.asRestrictions&&!t,name:e.name}),listenerSetter:this.listenerSetter,subtitleLangKey:e.description,clickable:e.nested?e=>{(0,a.Z)(e.target,o.checkboxField.label)||((0,s.Z)(e),o.container.classList.toggle("accordion-toggler-expanded"),u.classList.toggle("is-expanded"))}:void 0});e.restrictionText&&(e.checkboxField.input.disabled=!0,(0,n.fc)(e.checkboxField.label,(t=>{(0,c.Am)(r.ZP.format(e.restrictionText,!0))}),{listenerSetter:this.listenerSetter}));const h=[o.container];let u,p;if(e.nested){const t=u=document.createElement("div");t.classList.add("accordion"),t.style.setProperty("--max-height",48*e.nested.length+"px");const s=e;e.nested.forEach((e=>{var i;null!==(i=e.nestedTo)&&void 0!==i||(e.nestedTo=s),t.append(...this.createField(e,!0).nodes)})),h.push(t);const n=document.createElement("span");n.classList.add("tgico-down","accordion-icon"),p=e.nestedCounter=document.createElement("b"),this.setNestedCounter(e),o.title.append(" ",p," ",n),o.container.classList.add("accordion-toggler"),o.titleRow.classList.add("with-delimiter"),o.checkboxField.setValueSilently(this.getNestedCheckedLength(e)===e.nested.length),null!==(i=e.toggleWith)&&void 0!==i||(e.toggleWith={checked:e.nested,unchecked:e.nested})}if(e.toggleWith||e.nestedTo){const t=e.toggleWith?e=>{const{toggleWith:i,nested:s}=e,n=e.checkboxField.checked,a=n?i.checked:i.unchecked;a&&(this.fields.filter((e=>a.includes(e))).forEach((e=>{e.checkboxField.setValueSilently(n),e.nestedTo&&!s&&this.setNestedCounter(e.nestedTo),e.toggleWith&&t(e)})),e.nested&&this.setNestedCounter(e))}:void 0,i=e.nestedTo?()=>{const t=this.getNestedCheckedLength(e.nestedTo);e.nestedTo.checkboxField.setValueSilently(t===e.nestedTo.nested.length),this.setNestedCounter(e.nestedTo,t)}:void 0;this.listenerSetter.add(e.checkboxField.input)("change",(()=>{null==t||t(e),null==i||i()}))}return{row:o,nodes:h}}getNestedCheckedLength(e){return e.nested.reduce(((e,t)=>e+ +t.checkboxField.checked),0)}setNestedCounter(e,t=this.getNestedCheckedLength(e)){e.nestedCounter.textContent=`${t}/${e.nested.length}`}}},4489:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(503);class n extends s.ZP{constructor(e){super(Object.assign(e,{plainText:!0})),this.options=e;const t=this.input;t.type="tel",t.setAttribute("required",""),t.autocomplete="off";let i=0;this.input.addEventListener("input",(t=>{this.input.classList.remove("error"),this.setLabel();const s=this.value.replace(/\D/g,"").slice(0,e.length);this.setValueSilently(s);const n=this.value.length;if(n===e.length)e.onFill(this.value);else if(n===i)return;i=n}))}}},5592:(e,t,i)=>{"use strict";i.d(t,{Z:()=>a});var s=i(1168),n=i(8127);function a(e){return new Promise(((t,i)=>{var a;const{button:o,checkbox:r}=e;o.callback=i=>{t(r||!i?i?!!i.size:void 0:e.checkboxes.map((e=>i.has(e.text))))};const d=(0,s.x)(e.buttons||[o]),l=d.find((e=>e.isCancel));l.callback=()=>{i()},e.buttons=d,null!==(a=e.checkboxes)&&void 0!==a||(e.checkboxes=r&&[r]),s.Z.createPopup(n.Z,"popup-confirmation",e).show()}))}},5431:(e,t,i)=>{"use strict";i.d(t,{Z:()=>S});var s=i(9976),n=i(3910),a=i(8497),o=i(4668),r=i(5565),d=i(130),l=i(4789),c=i(144),h=i(2325),u=i(8115),p=i(3512),f=i(671),m=i(503),g=i(8805);let v;const b=()=>{v=h.ZP.countriesList.filter((e=>{var t;return!(null===(t=e.pFlags)||void 0===t?void 0:t.hidden)})).sort(((e,t)=>(e.name||e.default_name).localeCompare(t.name||t.default_name)))};let y=()=>{b(),p.Z.addEventListener("language_change",(()=>{b()}))};const w=new Set(["FT"]);class S extends m.ZP{constructor(e={}){super(Object.assign({label:"Country",name:(0,c.a)()},e)),this.options=e,this.hidePicker=()=>{void 0===this.hideTimeout&&(this.selectWrapper.classList.remove("active"),this.hideTimeout=window.setTimeout((()=>{this.selectWrapper.classList.add("hide"),this.hideTimeout=void 0}),200))},this.selectCountryByTarget=e=>{var t,i;const s=e.querySelector("[data-default-name]").dataset.defaultName,n=e.querySelector(".phone-code"),a=null==n?void 0:n.innerText,o=a&&a.replace(/\D/g,"");(0,r.Z)(this.input,(0,h.ag)(s)),this.simulateInputEvent(),this.lastCountrySelected=v.find((e=>e.default_name===s)),this.lastCountryCodeSelected=o&&this.lastCountrySelected.country_codes.find((e=>e.country_code===o)),null===(i=(t=this.options).onCountryChange)||void 0===i||i.call(t,this.lastCountrySelected,this.lastCountryCodeSelected),this.hidePicker()},y&&(y(),y=void 0),this.liMap=new Map,this.container.classList.add("input-select");const t=this.selectWrapper=document.createElement("div");t.classList.add("select-wrapper","z-depth-3","hide");const i=document.createElement("span");i.classList.add("arrow","arrow-down"),this.container.append(i);const p=document.createElement("ul");t.appendChild(p),new g.ZP(t);let m=()=>{m=null,v.forEach((t=>{if(e.noPhoneCodes&&w.has(t.iso2))return;const i=(0,f.Ml)(t.iso2),n=[];for(let a=0,o=Math.min(t.country_codes.length,e.noPhoneCodes?1:1/0);a<o;++a){const o=t.country_codes[a],r=document.createElement("li"),l=(0,u.Z)(i);if(s.Z){const e=document.createElement("span");(0,d.Z)(e,l),r.append(e)}else(0,d.Z)(r,l);const c=(0,h.ag)(t.default_name);if(c.dataset.defaultName=t.default_name,r.append(c),!e.noPhoneCodes){const e=document.createElement("span");e.classList.add("phone-code"),e.innerText="+"+o.country_code,r.appendChild(e)}n.push(r),p.append(r)}this.liMap.set(t.iso2,n)})),p.addEventListener("mousedown",(e=>{if(0!==e.button)return;const t=(0,o.Z)(e.target,"LI");this.selectCountryByTarget(t)})),this.container.appendChild(t)};m(),this.input.addEventListener("focus",(e=>{m?m():v.forEach((e=>{const t=this.liMap.get(e.iso2);t&&t.forEach((e=>e.style.display=""))})),clearTimeout(this.hideTimeout),this.hideTimeout=void 0,t.classList.remove("hide"),t.offsetWidth,t.classList.add("active"),this.select(),(0,l.Z)({container:(0,a.Z)(this.container,"scrollable-y"),element:this.input,position:"start",margin:4}),setTimeout((()=>{b||(document.addEventListener("mousedown",S,{capture:!0}),b=!0)}),0)}));let b=!1;const S=e=>{(0,a.Z)(e.target,"input-select")||e.target!==this.input&&(this.hidePicker(),document.removeEventListener("mousedown",S,{capture:!0}),b=!1)},C=e=>{const t=e.key;if(e.ctrlKey||"Control"===t)return!1;const i=this.value.toLowerCase(),s=[];v.forEach((e=>{const t=this.liMap.get(e.iso2);if(!t)return;const n=[e.name,e.default_name,e.iso2];n.filter(Boolean).forEach((e=>{const t=e.split(" ").filter((e=>/\w/.test(e))).map((e=>e[0])).join("");t.length>1&&n.push(t)}));const a=!!n.filter(Boolean).find((e=>-1!==e.toLowerCase().indexOf(i)));t.forEach((e=>e.style.display=a?"":"none")),a&&s.push(e)})),0===s.length?v.forEach((e=>{const t=this.liMap.get(e.iso2);t&&t.forEach((e=>e.style.display=""))})):1===s.length&&"Enter"===t&&((0,n.Z)(e),this.selectCountryByTarget(this.liMap.get(s[0].iso2)[0]))};this.input.addEventListener("keyup",C),this.input.addEventListener("keydown",(e=>{"Enter"===e.key&&C(e)})),i.addEventListener("mousedown",(e=>{this.input.matches(":focus")?(this.hidePicker(),this.input.blur()):(e.cancelBubble=!0,e.preventDefault(),this.input.focus())}))}getSelected(){return{country:this.lastCountrySelected,code:this.lastCountryCodeSelected}}selectCountryByIso2(e){this.selectCountryByTarget(this.liMap.get(e)[0])}override(e,t,i){var s,n;(0,r.Z)(this.input,e?(0,h.ag)(e.default_name):i),this.lastCountrySelected=e,this.lastCountryCodeSelected=t,null===(n=(s=this.options).onCountryChange)||void 0===n||n.call(s,this.lastCountrySelected,this.lastCountryCodeSelected)}}},4561:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(130);class n{constructor(e,t){this.className=e,this.fill=t,this.container=document.createElement("div"),this.container.className=e,this.border=document.createElement("div"),this.border.classList.add(e+"-border"),this.content=document.createElement("div"),this.content.classList.add(e+"-content"),this.title=document.createElement("div"),this.title.classList.add(e+"-title"),(0,s.m)(this.title),this.subtitle=document.createElement("div"),this.subtitle.classList.add(e+"-subtitle"),(0,s.m)(this.subtitle),this.content.append(this.title,this.subtitle),this.container.append(this.border,this.content)}}},6628:(e,t,i)=>{"use strict";i.d(t,{Z:()=>d});var s=i(4762),n=i(5296),a=i(5994),o=i(3228),r=i(5814);class d{constructor(e,t,i){this.width=e,this.height=t,this.multiply=i,this.loop=!0;const s=this.canvas=document.createElement("canvas"),n=this.dpr=window.devicePixelRatio;s.width=e*n,s.height=t*n,s.classList.add("canvas-thumbnail","canvas-dots"),this.paused=!0,this.autoplay=!0,this.tempId=0,this.context=s.getContext("2d")}prepare(){let e=Math.round(this.width*this.height/(35*(s.IS_MOBILE?2:1)));e*=this.multiply||1,e=Math.min(a.Z.isAvailable("chat_spoilers")?s.IS_MOBILE?1e3:2200:400,e),e=Math.round(e);const t=this.dots=new Array(e);for(let i=0;i<e;++i)t[i]=this.generateDot()}generateDot(e){const t=Math.floor(Math.random()*this.canvas.width),i=Math.floor(Math.random()*this.canvas.height),s=e?0:Math.random(),n=(Math.random()>=.8?1:.5)*this.dpr,a=new Path2D;return a.arc(t,i,n,0,2*Math.PI,!1),{x:t,y:i,opacity:s,radius:n,mOpacity:s,adding:null!=e?e:Math.random()>=.5,counter:0,path:a}}draw(){const{context:e,canvas:t,dots:i}=this;e.clearRect(0,0,t.width,t.height),e.fillStyle="#fff";for(let t=0,s=i.length;t<s;++t){const s=i[t],n=s.adding?.02:-.02;s.mOpacity+=n;const a=(0,o.Z)(s.mOpacity,0,1);e.globalAlpha=a,e.fill(s.path),s.mOpacity<=0?(s.adding=!0,++s.counter>=1&&(i[t]=this.generateDot(s.adding))):s.mOpacity>=1&&(s.adding=!1)}}remove(){this.pause()}pause(){this.paused||(this.paused=!0,++this.tempId)}renderFirstFrame(){this.dots||this.prepare(),this.draw()}play(){if(!this.paused)return;this.paused=!1;const e=++this.tempId;this.dots||this.prepare(),(0,n.jt)((()=>this.tempId===e&&!this.paused&&(this.draw(),!0)))}static create({width:e,height:t,middleware:i,animationGroup:s,multiply:n}){const a=new d(e,t,n);return a.renderFirstFrame(),r.Z.addAnimation({animation:a,group:s,observeElement:a.canvas,controlled:i}),a}}},2621:(e,t,i)=>{"use strict";i.d(t,{Z:()=>d});var s=i(187),n=i(9331),a=i(8119),o=i(5953),r=i(1507);class d{constructor(e){this._disabled=!1,this.avatarSize=120,this.isChanged=()=>{if(this.uploadAvatar)return!0;let e=0,t=0,i=0;return this.inputFields.forEach((s=>{s.isValid()&&(s.isChanged()&&++e,s.required&&++i),s.required&&++t})),t===i&&e>0},this.handleChange=()=>{this.nextBtn.classList.toggle("is-visible",this.isChanged())},(0,o.Z)(this,e),this.peerId||(this.peerId=r.NM),this.nextBtn?this.nextBtn.classList.contains("btn-corner")||(this.handleChange=()=>{this.nextBtn.toggleAttribute("disabled",!this.isChanged()||this.disabled)}):this.nextBtn=(0,a.Z)({icon:"check"}),e.withoutAvatar||(this.avatarElem=new n.Z,this.avatarElem.classList.add("avatar-placeholder","avatar-"+this.avatarSize),this.avatarElem.updateWithOptions({peerId:this.peerId}),e.doNotEditAvatar||(this.avatarEdit=new s.Z((e=>{this.uploadAvatar=e,this.handleChange(),this.avatarElem.remove()}),e.popupOptions),this.avatarEdit.container.append(this.avatarElem))),this.inputFields.forEach((e=>{this.listenerSetter.add(e.input)("input",this.handleChange)})),this.handleChange()}get disabled(){return this._disabled}set disabled(e){this._disabled=e,this.inputFields.forEach((t=>t.input.toggleAttribute("disabled",e))),this.handleChange()}lockWithPromise(e,t=!1){this.disabled=!0,e.then((()=>{t&&(this.disabled=!1)}),(()=>{this.disabled=!1}))}}},3173:(e,t,i)=>{"use strict";i.d(t,{Yd:()=>ee,Jo:()=>ie,ZP:()=>ne});var s=i(5432),n=i(7030),a=i(3512),o=i(5814),r=i(6008),d=i(2153),l=i(4332),c=i(5117),h=i(6039),u=i(1080),p=i(8805),f=i(279),m=i(2738);class g{constructor(e){this.managers=e}init(){this.content=document.getElementById("content-gifs");const e=this.content.firstElementChild;(0,m.fc)(e,ie.onMediaClick);const t=this.scrollable=new p.ZP(this.content,"GIFS"),i=new u.Z(e,ee,t),s=(0,f.y)(this.content,!0);this.managers.appDocsManager.getGifs().then((e=>{e.forEach((e=>{i.add(e)})),s.remove()})),ne.addLazyLoadQueueRepeat(i.lazyLoadQueue,i.processInvisibleDiv),this.init=null}onClose(){}}var v=i(6057),b=i(410),y=i(3552),w=i(3607),S=i(4755),C=i(8497),L=i(1507),E=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};const I="GIFS-SEARCH";class P extends y._{constructor(){super(...arguments),this.nextOffset="",this.loadedAll=!1,this.onGifsClick=e=>E(this,void 0,void 0,(function*(){const t=(0,C.Z)(e.target,"gif");if(!t)return;const i=t.dataset.docId;(yield n.ZP.chat.input.sendMessageWithDocument(i))?S.Z.isMobile&&l.ZP.onCloseBtnClick():console.warn("got no doc by id:",i)}))}init(){this.container.id="search-gifs-container",this.inputSearch=new w.Z("SearchGifsTitle",(e=>{this.reset(),this.search(e)})),this.title.replaceWith(this.inputSearch.container),this.gifsDiv=document.createElement("div"),this.gifsDiv.classList.add("gifs-masonry"),(0,m.fc)(this.gifsDiv,this.onGifsClick,{listenerSetter:this.listenerSetter}),this.scrollable.append(this.gifsDiv),this.masonry=new u.Z(this.gifsDiv,I,this.scrollable),l.ZP.toggleSidebar(!0).then((()=>{this.search("",!0),this.scrollable.onScrolledBottom=()=>{this.search(this.inputSearch.value,!1)}}))}onClose(){this.scrollable.onScrolledBottom=()=>{}}onCloseAfterTimeout(){return this.reset(),this.gifsDiv.replaceChildren(),o.Z.checkAnimations(void 0,I),this.inputSearch.remove(),super.onCloseAfterTimeout()}reset(){this.searchPromise=null,this.nextOffset="",this.loadedAll=!1,this.masonry.clear()}search(e,t=!0){return E(this,void 0,void 0,(function*(){if(!this.searchPromise&&!this.loadedAll){this.gifBotPeerId||(this.gifBotPeerId=(yield this.managers.appUsersManager.resolveUsername("gif")).id.toPeerId(!1));try{this.searchPromise=this.managers.appInlineBotsManager.getInlineResults(L.NM,this.gifBotPeerId,e,this.nextOffset);const{results:i,next_offset:s}=yield this.searchPromise;if(this.inputSearch.value!==e)return;this.searchPromise=null,this.nextOffset=s,t&&this.gifsDiv.replaceChildren(),i.length?i.forEach((e=>{"botInlineMediaResult"===e._&&e.document&&this.masonry.add(e.document)})):this.loadedAll=!0,this.scrollable.onScroll()}catch(e){throw this.searchPromise=null,console.error("gifs loading error:",e),e}}}))}}var Z=i(9298),M=i(2325),k=i(7625),T=i(130),x=i(8115),A=i(9259),_=i(3541),F=i(1168);class D extends y._{init(){this.container.id="stickers-container",this.container.classList.add("chatlist-container"),this.lazyLoadQueue=new d.Z,this.inputSearch=new w.Z("StickersTab.SearchPlaceholder",(e=>{this.search(e)})),this.title.replaceWith(this.inputSearch.container),this.setsDiv=document.createElement("div"),this.setsDiv.classList.add("sticker-sets"),this.scrollable.append(this.setsDiv),(0,A.Z)({listenTo:this.setsDiv,listenerSetter:this.listenerSetter}),(0,m.fc)(this.setsDiv,(e=>{const t=(0,C.Z)(e.target,"sticker-set-sticker");if(t){const e=t.dataset.docId;return void n.ZP.chat.input.sendMessageWithDocument(e)}const i=(0,C.Z)(e.target,"sticker-set");if(!i)return;const s=i.dataset.stickerSet,a=i.dataset.access_hash,o=(0,C.Z)(e.target,"sticker-set-button");o?(e.preventDefault(),e.cancelBubble=!0,o.setAttribute("disabled","true"),this.managers.appStickersManager.getStickerSet({id:s,access_hash:a}).then((e=>{this.managers.appStickersManager.toggleStickerSet(e.set).then((t=>{t&&(o.textContent="",o.append((0,M.ag)(e.set.installed_date?"Stickers.SearchAdded":"Stickers.SearchAdd")),o.classList.toggle("gray",!!e.set.installed_date))})).finally((()=>{o.removeAttribute("disabled")}))}))):this.managers.appStickersManager.getStickerSet({id:s,access_hash:a}).then((e=>{F.Z.createPopup(Z.Z,e.set).show()}))}),{listenerSetter:this.listenerSetter}),l.ZP.toggleSidebar(!0).then((()=>{this.renderFeatured()}))}onCloseAfterTimeout(){return this.setsDiv.replaceChildren(),o.Z.checkAnimations(void 0,"STICKERS-SEARCH"),super.onCloseAfterTimeout()}renderSet(e){const t=document.createElement("div");t.classList.add("sticker-set");const i=document.createElement("div");i.classList.add("sticker-set-header");const s=document.createElement("div");s.classList.add("sticker-set-details"),s.innerHTML='<div class="sticker-set-name"></div>',(0,T.Z)(s.firstElementChild,(0,x.Z)(e.title));const n=document.createElement("div");n.classList.add("sticker-set-count"),n.append((0,M.ag)("Stickers",[e.count])),s.append(n);const a=document.createElement("button");a.classList.add("btn-primary","btn-color-primary","sticker-set-button"),a.append((0,M.ag)(e.installed_date?"Stickers.SearchAdded":"Stickers.SearchAdd")),e.installed_date&&a.classList.add("gray"),i.append(s,a);const o=document.createElement("div");o.classList.add("sticker-set-stickers");const r=Math.min(5,e.count);for(let e=0;e<r;++e){const e=document.createElement("div");e.classList.add("sticker-set-sticker"),o.append(e)}this.managers.appStickersManager.getStickerSet(e).then((e=>{for(let t=0;t<r;++t){const i=o.children[t],s=e.documents[t];"documentEmpty"!==s._&&(0,_.ZP)({doc:s,div:i,lazyLoadQueue:this.lazyLoadQueue,group:"STICKERS-SEARCH",play:!0,loop:!0,width:68,height:68,withLock:!0})}})),t.dataset.stickerSet=""+e.id,t.dataset.access_hash=""+e.access_hash,t.dataset.title=e.title,t.append(i,o),this.setsDiv.append(t)}renderFeatured(){return this.managers.appStickersManager.getFeaturedStickers().then((e=>{this.inputSearch.value||(e=this.filterRendered("",e)).forEach((e=>{this.renderSet(e.set)}))}))}filterRendered(e,t){t=t.slice();const i=Array.from(this.setsDiv.children);return(0,k.Z)(i,(i=>{const s=i.dataset.stickerSet,n=t.findIndex((e=>e.set.id===s));-1!==n?t.splice(n,1):e&&i.dataset.title.toLowerCase().includes(e.toLowerCase())||i.remove()})),o.Z.checkAnimations(void 0,"STICKERS-SEARCH"),t}search(e){return e?this.managers.appStickersManager.searchStickerSets(e,!1).then((t=>{this.inputSearch.value===e&&(t=this.filterRendered(e,t)).forEach((e=>{this.renderSet(e.set)}))})):this.renderFeatured()}}var R,B=i(4668),N=i(8799),O=i(2648),U=i(3910),H=i(6339),z=i(5418),j=i(4762),G=i(3815),V=i(319),K=i(4789),W=i(6802),$=i.n(W),q=i(669),Y=i(3299),Q=i(2796),X=i(8843),J=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};const ee="emoticons-dropdown",te={forceDuration:200,transitionFunction:$()(.42,0,.58,1)};class ie extends H.Z{constructor(){super({element:document.getElementById("emoji-dropdown"),ignoreOutClickClassName:"input-message-input"}),this.tabId=-1,this.onSelectTabClick=e=>{if(this.tabId===e){const{tab:e}=this;return void this.scrollTo(e,e.scrollable.container.firstElementChild)}const t={[this.stickersTab.tabId]:"send_stickers",[this.gifsTab.tabId]:"send_gifs"}[e];if(t&&!this.rights[t])return(0,Q.bC)({langPackKey:X.m[t]}),!1;o.Z.checkAnimations(!0,ee),this.tabId=e,this.searchButton.classList.toggle("hide",this.tabId===this.emojiTab.tabId),this.deleteBtn.classList.toggle("hide",this.tabId!==this.emojiTab.tabId)},this.checkRights=()=>J(this,void 0,void 0,(function*(){const{peerId:e,threadId:t}=n.ZP.chat,i=Object.keys(this.rights),s=yield Promise.all(i.map((i=>this.managers.appMessagesManager.canSendToPeer(e,t,i))));i.forEach(((e,t)=>{this.rights[e]=s[t]}));const a=this.tabsEl.querySelector(".active");!a||(0,O.Z)(a)===this.emojiTab.tabId+1||this.rights.send_stickers&&this.rights.send_gifs||this.selectTab(this.emojiTab.tabId,!1)})),this.rights={send_gifs:void 0,send_stickers:void 0},this.addEventListener("open",(()=>J(this,void 0,void 0,(function*(){var e;s.Z&&(0,N.Z)()&&(yield(0,z.Z)(100)),this.element.parentElement!==n.ZP.chat.input.chatInput&&n.ZP.chat.input.chatInput.append(this.element),this.savedRange=this.getGoodRange(),ie.lazyLoadQueue.lock(),o.Z.lockIntersectionGroup(ee);const t=this.tab;null===(e=t.onOpen)||void 0===e||e.call(t)})))),this.addEventListener("opened",(()=>{var e;o.Z.unlockIntersectionGroup(ee),ie.lazyLoadQueue.unlockAndRefresh();const t=this.tab;null===(e=t.onOpened)||void 0===e||e.call(t)})),this.addEventListener("close",(()=>{var e;ie.lazyLoadQueue.lock(),o.Z.lockIntersectionGroup(ee),o.Z.checkAnimations(!0,ee);const t=this.tab;null===(e=t.onClose)||void 0===e||e.call(t)})),this.addEventListener("closed",(()=>{var e;o.Z.unlockIntersectionGroup(ee),ie.lazyLoadQueue.unlock(),ie.lazyLoadQueue.refresh(),this.savedRange=void 0;const t=this.tab;null===(e=t.onClosed)||void 0===e||e.call(t)}))}get tab(){return this.tabs[this.tabId]}init(){this.managers=a.Z.managers,this.emojiTab=new h.ZP({managers:this.managers}),this.stickersTab=new v.ZP(this.managers),this.gifsTab=new g(this.managers),this.tabs={},[this.emojiTab,this.stickersTab,this.gifsTab].forEach(((e,t)=>{e.tabId=t,this.tabs[t]=e})),this.container=this.element.querySelector(".emoji-container .tabs-container"),this.container.prepend(this.emojiTab.container,this.stickersTab.container),this.tabsEl=this.element.querySelector(".emoji-tabs"),this.selectTab=(0,r.X)(this.tabsEl,this.container,this.onSelectTabClick,(()=>{var e;const{tab:t}=this;null===(e=t.init)||void 0===e||e.call(t),o.Z.checkAnimations(!1,ee)})),this.searchButton=this.element.querySelector(".emoji-tabs-search"),this.searchButton.addEventListener("click",(()=>{this.tabId===this.stickersTab.tabId?l.ZP.isTabExists(D)||l.ZP.createTab(D).open():l.ZP.isTabExists(P)||l.ZP.createTab(P).open()})),this.deleteBtn=this.element.querySelector(".emoji-tabs-delete"),(0,m.fc)(this.deleteBtn,(e=>{(0,U.Z)(e);const t=n.ZP.chat.input.messageInput;let i=q.Z.getInstance().getSavedRange(t);i||(i=document.createRange(),i.setStartAfter(t.lastChild));const s=i.cloneRange();if(i.collapsed){const{node:e,offset:n}=(0,Y.q)(t,i.endContainer,i.endOffset);let a;if(n)a=e;else{if(a=e.previousSibling,!a)return;for(;a.nodeType===a.TEXT_NODE&&!a.nodeValue&&(a=a.previousSibling););if(a.nodeType===a.ELEMENT_NODE&&!a.isContentEditable)return}if(a.nodeType===a.ELEMENT_NODE&&"IMG"===a.tagName)s.selectNode(a);else{const e=[...a.textContent];let t;if(n){let i=0;t=e.find((e=>(i+=e.length,i>=n)))}else t=e.pop()||"";const i=n?n-t.length:a.textContent.length-t.length;s.setStart(a,i)}}s.deleteContents(),n.ZP.chat.input.messageInputField.simulateInputEvent()}));const e=j.IS_APPLE_MOBILE&&!1,t=e?this.stickersTab.tabId:this.emojiTab.tabId;if(e&&this.tabsEl.children[1].classList.add("hide"),(0,m.tH)(this.tabsEl.children[t+1]),this.tabs[t].init&&this.tabs[t].init(),!s.Z){let e,t=!1;const i=t=>{e=t};G.Z.addEventListener("change",(s=>{s?t||(document.body.addEventListener("mousemove",i),t=!0):t&&(document.body.removeEventListener("mousemove",i),e&&this.onMouseOut(e))}))}return n.ZP.addEventListener("peer_changing",(()=>{this.toggle(!1)})),n.ZP.addEventListener("peer_changed",this.checkRights),this.checkRights(),super.init()}getElement(){return this.element}scrollTo(e,t){e.scrollable.scrollIntoViewNew(Object.assign({element:t,axis:"y",position:"start"},te))}static sendDocId(e,t,i){return J(this,void 0,void 0,(function*(){return(yield n.ZP.chat.input.sendMessageWithDocument(e,void 0,t,i))?(se.container&&(se.forceClose=!0,se.toggle(!1)),!0):(console.warn("got no doc by id:",e),!1)}))}addLazyLoadQueueRepeat(e,t){this.addEventListener("close",(()=>{e.lock()})),this.addEventListener("closed",(()=>{const i=e.intersector.getVisible();for(const e of i)t(e);e.intersector.clearVisible()})),this.addEventListener("opened",(()=>{e.unlockAndRefresh()}))}getSavedRange(){return this.getGoodRange()||this.savedRange}getGoodRange(){const e=document.getSelection();if(e.rangeCount&&document.activeElement===n.ZP.chat.input.messageInput)return e.getRangeAt(0)}}R=ie,ie.lazyLoadQueue=new d.Z(1),ie.menuOnClick=(e,t,i,s,n,a)=>{let o=-1;const r=(e,t=!0)=>{if(e===n)return!1;let i=!1;return n&&(n.elements.menuTab.classList.remove("active"),n.menuScroll&&n.menuScroll!==e.menuScroll&&(i=!0,n.menuScroll.container.parentElement.classList.remove("active"),n.menuScroll.scrollIntoViewNew(Object.assign({element:n.menuScroll.container.firstElementChild,forceDirection:t?void 0:K.f.Static,position:"center",axis:"x"},te)))),e.elements.menuTab.classList.add("active"),e.menuScroll&&(e.menuScroll.container.parentElement.classList.add("active"),t&&s.scrollIntoViewNew(Object.assign({element:e.menuScroll.container.parentElement,position:"center",axis:"x"},te))),n&&((e,t)=>{const i=e.menuScroll||s;i&&i.scrollIntoViewNew(Object.assign({element:e.elements.menuTab,position:"center",axis:"x",getElementPosition:t?({elementPosition:e})=>e-106:void 0},te))})(e,i),n=e,!0};let d=!1;const l=new c.Z(i.container,((t,s)=>{if(d)return;if(Math.abs(o-i.container.scrollTop)<=1)return;o=-1;const n=e.getCategoryByContainer(s),a=(0,O.Z)(s);(t||!a&&!n.menuScroll)&&r(n)}));(0,m.fc)(t,(t=>{let s=(0,C.Z)(t.target,"menu-horizontal-div-item");if(!s){if(s=(0,C.Z)(t.target,"menu-horizontal-inner"),!s||s.classList.contains("active"))return;s=s.firstElementChild.firstElementChild}const n=(0,O.Z)(s),a=e.getCategoryByMenuTab(s);r(a);let l=0,c=0;if(n>0||a.menuScroll){const e=a.elements.container;c=1,l=e.offsetTop+c}o=l,d=!0,i.scrollIntoViewNew(Object.assign({element:l?a.elements.container:i.container.firstElementChild,position:"start",axis:"y",getElementPosition:l?({elementPosition:e})=>e+c:void 0},te)).finally((()=>{r(a),d=!1}))}),{listenerSetter:a});const h=i.onAdditionalScroll?i.onAdditionalScroll.bind(i):V.Z;return i.onAdditionalScroll=()=>{e.content.parentElement.classList.toggle("scrolled-top",!i.scrollTop),h()},{stickyIntersector:l,setActive:r,setActiveStatic:t=>{if(null==n?void 0:n.local)return;e.scrollable.scrollTop=t.elements.container.offsetTop+1;const i=e.menuScroll.container,s=t.elements.menuTab;i.scrollLeft=s.offsetLeft-i.clientWidth/2+s.offsetWidth/2,r(t,!1)}}},ie.onMediaClick=(e,t=!1,i)=>J(void 0,void 0,void 0,(function*(){const s=(0,B.Z)(e.target,"DIV");if(!s)return!1;const n=s.dataset.docId;return!!n&&R.sendDocId(n,t,i)}));const se=new ie;b.GO.emoticonsDropdown=se;const ne=se},6039:(e,t,i)=>{"use strict";i.d(t,{IA:()=>R,ZP:()=>V,xG:()=>B});var s=i(3173),n=i(3910),a=i(8497),o=i(3035),r=i(5418),d=i(7030),l=i(3512),c=i(671),h=i(279),u=i(8805),p=i(9976),f=i(5432),m=i(8799),g=i(3447),v=i(7746),b=i(8115),y=i(7197),w=i(5400),S=i(2738),C=i(6057),L=i(9405),E=i(2940),I=i(4755),P=i(1273),Z=i(9259),M=i(4064),k=i(4484),T=i(9298),x=i(2796),A=i(5953),_=i(5994),F=i(1168);const D=new Set;function R(e,t,i=!1,s=!1){var n;const a=document.createElement("span");let r;if(a.classList.add("super-emoji"),s&&!p.Z?r=function(e){return(0,w.ZP)(e,{entities:[(0,y.Z)(e)]})}(e):(e=(0,v.Z)(e),r=(0,b.Z)(e)),a.append(r),a.children.length>1){const e=a.firstElementChild;a.replaceChildren(e)}if("IMG"===(null===(n=a.firstElementChild)||void 0===n?void 0:n.tagName)){const e=a.firstElementChild,t=e.src;if(!D.has(t)){e.setAttribute("loading","lazy");const i=document.createElement("span");i.classList.add("emoji-placeholder"),_.Z.isAvailable("animations")&&(e.style.opacity="0",i.style.opacity="1"),e.addEventListener("load",(()=>{(0,o.T2)((()=>{_.Z.isAvailable("animations")&&(e.style.opacity="",i.style.opacity=""),a.classList.remove("empty"),D.add(t)}))}),{once:!0}),a.append(i)}}return t&&(i?t.prepend(a):t.appendChild(a)),a}function B(e){const t=(0,a.Z)(e,"super-emoji");if(!t)return;const i=t.firstElementChild;return i&&i.classList.contains("custom-emoji")?{emoji:i.dataset.stickerEmoji,docId:i.dataset.docId}:e.nodeType===e.TEXT_NODE?{emoji:e.nodeValue}:("SPAN"===e.tagName&&!e.classList.contains("emoji")&&e.firstElementChild&&(e=e.firstElementChild),{emoji:e.getAttribute("alt")||e.innerText})}const N="Emoji.Recent",O=[N,"recent"],U=["",""],H=[["Emoji.SmilesAndPeople","smile"],["Emoji.AnimalsAndNature","animals"],["Emoji.FoodAndDrink","eats"],["Emoji.TravelAndPlaces","car"],["Emoji.ActivityAndSport","sport"],["Emoji.Objects","lamp"],["Emoji.Flags","flag"],["Skin Tones",""]];let z;function j(){if(z)return z;z=new Map([[U,[]],[O,[]]]);for(const e in g.Z){const t=""+g.Z[e],i=H[+t[0]-1];if(!i)continue;let s=z.get(i);s||(s=[],z.set(i,s)),s[+t.slice(1)||0]=e}z.delete(H.pop()),H.unshift(U,O);const e=H.map((([e])=>e)),t=[...z.entries()].sort(((t,i)=>e.indexOf(t[0][0])-e.indexOf(i[0][0])));return z=new Map(t),z}const G=(0,L.C)(42,42);class V extends C.pw{constructor(e){super(e.managers,"super-emojis",(()=>G),16,4,0),this.onCategoryVisibility=({target:e,visible:t})=>{const i=this.categoriesMap.get(e),s=i.elements.renderer,n=[];if(s){n.push(s);const e=new Map;t?(n.push(...i.items.map((({docId:t,element:i})=>{if(!t)return i;const s=i.firstElementChild;return s.clear(!1),e.set(s.docId,new Set([s])),i}))),s.add(e,void 0,void 0,!1)):(s.clearCanvas(),s.middlewareHelper.clean())}else t&&n.push(...i.items.map((({element:e})=>e)));if(i.elements.items.replaceChildren(...n),s&&!t){const e=new Map;i.items.forEach((({docId:t,element:i})=>{if(!t)return;const s=i.firstElementChild;s.clear(),e.set(s.docId,new Set([s]))})),s.add(e,void 0,!0)}},this.onContentClick=e=>{(0,n.Z)(e);const{target:t}=e,i=(0,a.Z)(t,"emoji-category"),s=this.categoriesMap.get(i);if((0,a.Z)(t,"category-title")){if(s.local)return;return void F.Z.createPopup(T.Z,{id:s.set.id,access_hash:s.set.access_hash},!0).show()}const o=B(t);if(o){if(o.docId&&!l.Z.premium&&(this.isStandalone?""!==s.id:this.peerId!==l.Z.myId)){const e=document.createElement("a");return e.onclick=()=>{d.ZP.openPremiumBot(),(0,x.PE)()},void(0,x.bC)({langPackKey:"CustomEmoji.PremiumAlert",langPackArguments:[e]})}this.onClick?this.onClick(Object.assign(Object.assign({},o),{element:(0,a.Z)(t,"super-emoji").firstElementChild})):d.ZP.chat.input.onEmojiSelected(o,!1),f.Z&&(0,m.Z)()}},(0,A.Z)(this,e),this.container.classList.add("emoji-padding"),this.content.id="content-emoji",this.activeElements=[]}destroy(){var e;super.destroy(),null===(e=this.menuInnerScroll)||void 0===e||e.destroy()}init(){super.init(),this.init=void 0;const e={root:this.isStandalone?this.content:s.ZP.getElement()};this.categoriesIntersector=new E.Z(this.onCategoryVisibility,e),this.menuOnClickResult=s.Jo.menuOnClick(this,this.menu,this.scrollable,this.menuScroll,void 0,this.listenerSetter);const t=(0,h.y)(this.content,!0);let i,n;if(!this.isStandalone){const e=this.menuInnerScroll=new u.v7(void 0);e.container.classList.add("menu-horizontal-inner-scroll"),i=document.createElement("div"),i.classList.add("menu-horizontal-inner"),i.append(e.container)}j(),n=this.noRegularEmoji?new Map([[[U[0],"recent"],[]]]):j(),n.forEach(((e,[t,i])=>{const s=this.createLocalCategory(t,t,i,!i);s.elements.container.classList.remove("hide"),s.elements.items.classList.add(i&&!this.isStandalone?"is-local":"not-local"),e.forEach((e=>{const t=(0,c.zu)(e);this.addEmojiToCategory({category:s,emoji:{emoji:t},batch:!0})}))}));const a=Promise.all([this.isStandalone?void 0:(0,r.Z)(200),!this.noRegularEmoji&&this.managers.appEmojiManager.getRecentEmojis("native"),!this.isStandalone&&this.managers.appEmojiManager.getRecentEmojis("custom"),this.stickerSetId&&this.managers.appStickersManager.getLocalStickerSet(this.stickerSetId),this.managers.appEmojiManager.getCustomEmojis()]).then((([e,n,a,o,r])=>{t.remove(),o&&(a=o.documents.map((e=>e.id)));const c=this.categories[N],h=this.categories[""];if(this.isStandalone||[c&&[c,n],h&&[h,a]].filter(Boolean).forEach((([e,t])=>{e.limit=32,t.splice(32,t.length-32)})),c&&n)for(const e of n)this.addEmojiToCategory({category:c,emoji:{emoji:e},batch:!0});if(h){if(this.createRendererForCategory(h),a)for(const e of a)this.addEmojiToCategory({category:h,emoji:{emoji:"",docId:e},batch:!0});h.elements.container.style.paddingTop=".5rem"}H.forEach((([e])=>{const t=this.categories[e];t&&(this.toggleLocalCategory(t,!0),e!==N&&""!==e&&(t.menuScroll=this.menuInnerScroll,this.menuInnerScroll.container.append(t.elements.menuTab)))})),this.resizeCategories(),c&&i&&c.elements.menuTab.after(i),r.sets.forEach((e=>{this.renderStickerSet(e)})),this.listenerSetter.add(l.Z)("premium_toggle",(()=>{this.toggleCustomCategory()})),this.listenerSetter.add(l.Z)("stickers_top",this.postponedEvent((e=>{const t=this.categories[e];t&&(this.positionCategory(t,!0),this.listenerSetter.add(s.ZP)("openAfterLayout",(()=>{this.menuOnClickResult.setActiveStatic(t)}),{once:!0}))})));const u=e=>{for(const t in this.categories){const i=this.categories[t].elements.renderer;i&&(i.ignoreSettingDimensions=e,e||i.setDimensionsFromRect(void 0,!0))}};!this.isStandalone&&this.listenerSetter.add(s.ZP)("opened",(()=>{u(!1)})),!this.isStandalone&&this.listenerSetter.add(s.ZP)("close",(()=>{u(!0)})),this.listenerSetter.add(l.Z)("stickers_installed",(e=>{!this.categories[e.id]&&e.pFlags.emojis&&this.renderStickerSet(e,!0)})),this.listenerSetter.add(l.Z)("stickers_deleted",(e=>{const t=this.categories[e.id];if(this.deleteCategory(t)){const{renderer:e}=t.elements;e&&e.middlewareHelper.clean()}})),!this.isStandalone&&this.listenerSetter.add(l.Z)("emoji_recent",this.postponedEvent((e=>{const t=this.categories[e.docId?"":N];if(!t)return;const i=e.docId?t=>t.docId===e.docId:t=>t.emoji===e.emoji,s=(0,M.Z)(t.items,i);if(s){if(t.items.unshift(s),this.isCategoryVisible(t)){const{renderer:e}=t.elements;(0,k.Z)(s.element,t.elements.items,e?1:0,-1),null==e||e.forceRender()}}else this.addEmojiToCategory({category:t,emoji:e,batch:!1,prepend:!0});0===this.closeScrollTop&&this.menuOnClickResult.setActive(e.docId?this.categories[N]:t)}))),!this.isStandalone&&this.listenerSetter.add(d.ZP)("peer_changed",(()=>{this.toggleCustomCategory()})),this.toggleCustomCategory(),this.menuOnClickResult.setActive(null!=c?c:h)}));return(0,S.fc)(this.content,this.onContentClick,{listenerSetter:this.listenerSetter}),(0,Z.Z)({listenTo:this.content,listenerSetter:this.listenerSetter}),a}renderStickerSet(e,t){const i=this.createCategory(e,(0,b.Z)(e.title));this.positionCategory(i,t);const{container:n,menuTabPadding:a}=i.elements;i.elements.items.classList.add("not-local"),i.elements.container.classList.add("is-premium-set"),i.elements.title.classList.add("tgico"),this.createRendererForCategory(i),this.managers.appStickersManager.getStickerSet(e).then((({documents:e})=>{e.forEach((e=>{this.addEmojiToCategory({category:i,emoji:{docId:e.id,emoji:e.stickerEmojiRaw},batch:!0})})),this.onCategoryVisibility({target:i.elements.container,visible:this.isCategoryVisible(i)}),i.setCategoryItemsHeight(),n.classList.remove("hide")})),(0,P.Z)({set:e,container:a,group:s.Yd,lazyLoadQueue:s.Jo.lazyLoadQueue,width:32,height:32,autoplay:!1})}get peerId(){return d.ZP.chat.peerId}getCustomCategory(){return this.categories[""]}toggleCustomCategory(){const e=this.categories[""],t=l.Z.premium||this.peerId===l.Z.myId,i=t||this.isStandalone;super.toggleLocalCategory(e,!!e.items.length&&i),this.content.classList.toggle("has-premium",t)}toggleLocalCategory(e,t){""!==e.id?super.toggleLocalCategory(e,t):this.toggleCustomCategory()}createRendererForCategory(e){const t=w.KZ.create({animationGroup:s.Yd,customEmojiSize:I.Z.active.esgCustomEmoji});e.elements.renderer=t,e.elements.items.append(t)}addEmojiToCategory(e){const{category:t,emoji:i,batch:s,prepend:n}=e;let a=e.element;if(a){const e=document.createElement("span");e.classList.add("super-emoji"),e.append(a),a=e}else if(i.docId){const e=w.LD.create(i.docId),t=document.createElement("span");t.classList.add("super-emoji"),t.append(e),a=t}else a=R(i.emoji,void 0,!1);const o=Object.assign(Object.assign({},i||{emoji:void 0}),{element:a});(e.active||this.activeEmoji&&(o.docId?this.activeEmoji.docId===o.docId:this.activeEmoji.emoji===o.emoji))&&(this.activeEmoji,this.activeElements.push(o),a.classList.add("active")),t.items[n?"unshift":"push"](o),s||this.spliceExceed(t)||this.onLocalCategoryUpdate(t)}setActive(e){var t,i;(e===this.activeEmoji||(null==e?void 0:e.docId)?e.docId!==(null===(t=this.activeEmoji)||void 0===t?void 0:t.docId):(null==e?void 0:e.emoji)!==(null===(i=this.activeEmoji)||void 0===i?void 0:i.emoji))&&(this.activeEmoji=e,this.activeElements.forEach((e=>{e.element.classList.remove("active")})),this.activeElements.length=0,this.categoriesMap.forEach((t=>{t.items.forEach((t=>{(e.docId?t.docId===e.docId:t.emoji===e.emoji)&&(t.element.classList.add("active"),this.activeElements.push(t))}))})))}onClose(){this.closeScrollTop=this.scrollable.scrollTop}}},6057:(e,t,i)=>{"use strict";i.d(t,{pw:()=>R,vT:()=>F,ZP:()=>B});var s=i(3173),n=i(8497),a=i(4755),o=i(2325),r=i(8115),d=i(3512),l=i(5814),c=i(1655),h=i(7009),u=i(2940);class p extends h.Z{constructor(e,t,i){super(e),this.onVisibilityChange=t,this.elementsMap=new Map,this.intersector=new u.Z((e=>{var t;const{target:i,visible:s}=e,n=this.elementsMap.get(i);n.visible=s,s?(n.wasSeen=!0,this.queue.includes(n)||this.queue.push(n)):(0,c.Z)(this.queue,n),null===(t=this.onVisibilityChange)||void 0===t||t.call(this,e),this.setProcessQueueTimeout()}),i)}clear(){super.clear(),this.elementsMap.clear()}observe(e){this.elementsMap.set(e.div,e),super.observe(e)}unobserve(e){this.elementsMap.delete(e.div),super.unobserve(e)}}var f=i(279),m=i(9298),g=i(8805),v=i(4064),b=i(2738),y=i(4484),w=i(319),S=i(2230),C=i(5592),L=i(3163),E=i(5975),I=i(7625),P=i(9259),Z=i(3699),M=i(3541),k=i(1273),T=i(8222),x=i(241),A=i(1168),_=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class F{constructor(e,t,i,s){this.regularLazyLoadQueue=e,this.group=t,this.managers=i,this.options=s,this.animated=new Set,this.checkAnimationContainer=(e,t)=>{l.Z.getAnimations(e).forEach((e=>{t?l.Z.checkAnimation(e,!1):l.Z.removeAnimation(e)}))},this.processVisible=e=>_(this,void 0,void 0,(function*(){const t=e.dataset.docId,i=yield this.managers.appDocsManager.getDoc(t),s=a.Z.active.esgSticker.width,n=(0,M.ZP)({doc:i,div:e,width:s,height:s,lazyLoadQueue:null,group:this.group,onlyThumb:!1,play:!0,loop:!0,withLock:!0}).then((({render:e})=>e));return n.then((()=>{this.checkAnimationContainer(e,this.lazyLoadQueue.intersector.isVisible(e))})),n})),this.processInvisible=e=>_(this,void 0,void 0,(function*(){const t=e.dataset.docId,i=yield this.managers.appDocsManager.getDoc(t);this.checkAnimationContainer(e,!1),e.textContent="",this.renderSticker(i,e)})),this.lazyLoadQueue=new p(void 0,(({target:e,visible:t})=>{t||this.processInvisible(e)}),s)}clear(){this.lazyLoadQueue.clear()}renderSticker(e,t,i){return t||((t=document.createElement("div")).classList.add("grid-item","super-sticker"),t.dataset.docId=""+e.id,e.animated&&this.observeAnimated(t)),(0,M.ZP)({doc:e,div:t,lazyLoadQueue:this.regularLazyLoadQueue,group:this.group,onlyThumb:e.animated,loadPromises:i}),t}observeAnimated(e){this.animated.add(e),this.lazyLoadQueue.observe({div:e,load:this.processVisible})}unobserveAnimated(e){this.animated.delete(e),this.lazyLoadQueue.delete({div:e})}}class D{constructor(e){var t,i;const s=document.createElement("div");s.classList.add("emoji-category");const n=document.createElement("div");let a,o,r;n.classList.add("category-items"),e.title&&(a=document.createElement("div"),a.classList.add("category-title"),a.append(e.title)),e.noMenuTab||(o=(0,S.Z)(void 0,{noRipple:!0}),o.classList.add("menu-horizontal-div-item"),r=document.createElement("div"),r.classList.add("menu-horizontal-div-item-padding"),o.append(r)),a&&s.append(a),s.append(n),this.elements={container:s,title:a,items:n,menuTab:o,menuTabPadding:r},this.id=e.id,this.items=[],this.getContainerSize=e.getContainerSize,this.getElementMediaSize=e.getElementMediaSize,this.gapX=null!==(t=e.gapX)&&void 0!==t?t:0,this.gapY=null!==(i=e.gapY)&&void 0!==i?i:0}setCategoryItemsHeight(){const{width:e}=this.getContainerSize(),t=this.getElementMediaSize().width;let i=e/t;this.gapX&&(i-=Math.floor(i-1)*this.gapX/t),i=Math.floor(i);const s=Math.ceil(this.items.length/i);let n=s*t;this.gapY&&(n+=(s-1)*this.gapY),this.elements.items.style.minHeight=n+"px"}}class R{constructor(e,t,i,n,a,o){this.managers=e,this.categoryItemsClassName=t,this.getElementMediaSize=i,this.padding=n,this.gapX=a,this.gapY=o,this.mounted=!1,this.resizeCategories=()=>{for(const[e,t]of this.categoriesMap)t.setCategoryItemsHeight()},this.postponedEvent=e=>(...t)=>{s.ZP.isActive()?this.postponedEvents.push({cb:e,args:t}):e(...t)},this.categories={},this.categoriesMap=new Map,this.categoriesByMenuTabMap=new Map,this.localCategories=[],this.postponedEvents=[],this.listenerSetter=new Z.Z,this.container=document.createElement("div"),this.container.classList.add("tabs-tab","emoticons-container"),this.menuWrapper=document.createElement("div"),this.menuWrapper.classList.add("menu-wrapper","emoticons-menu-wrapper"),this.menu=document.createElement("nav"),this.menu.className="menu-horizontal-div no-stripe justify-start emoticons-menu",this.menuWrapper.append(this.menu),this.menuScroll=new g.v7(this.menuWrapper),this.content=document.createElement("div"),this.content.classList.add("emoticons-content"),this.container.append(this.menuWrapper,this.content),this.scrollable=new g.ZP(this.content,"STICKERS")}getCategoryByContainer(e){return this.categoriesMap.get(e)}getCategoryByMenuTab(e){return this.categoriesByMenuTabMap.get(e)}createCategory(e,t,i,s){const n=new D({id:""+e.id,title:t,overflowElement:this.content,getContainerSize:()=>{let e,t;if(this.getContainerSize){const i=this.getContainerSize();e=i.width,t=i.height}else{const t=T.Z.getPropertyAsSize("esg-width");e=void 0===t?x.Z.width:t}return{width:e-this.padding,height:t}},getElementMediaSize:this.getElementMediaSize,gapX:this.gapX,gapY:this.gapY,noMenuTab:s});this.categoryItemsClassName&&n.elements.items.classList.add(this.categoryItemsClassName);const a=n.elements.container;return a.classList.add("hide"),n.set=e,this.categories[e.id]=n,this.categoriesMap.set(a,n),!s&&this.categoriesByMenuTabMap.set(n.elements.menuTab,n),this.categoriesIntersector.observe(a),!s&&this.menuOnClickResult.stickyIntersector.observeStickyHeaderChanges(a),i||!s&&n.elements.menuTab.classList.add("not-local"),n}positionCategory(e,t){const{menuTab:i,container:s}=e.elements,n=t?this.localCategories.filter((e=>e.mounted)).length:65535;let a=!1;const o=t?this.localCategories.filter((e=>e.menuScroll&&!a?(a=!0,!0):e.mounted&&!e.menuScroll&&e.elements.menuTab)).length:65535;(0,y.Z)(s,this.scrollable.container,n),(0,y.Z)(i,this.menu,o)}isCategoryVisible(e){return this.categoriesIntersector.getVisible().includes(e.elements.container)}toggleLocalCategory(e,t){var i;if(t){const t=this.localCategories.indexOf(e),i=this.localCategories.slice(0,t);let s=0,n=0;i.forEach((e=>{e.mounted?e.elements.menuTab&&!e.menuScroll||++n:(++s,++n)}));const a=t-s,o=t-n;e.elements.menuTab&&(0,y.Z)(e.elements.menuTab,this.menu,o),(0,y.Z)(e.elements.container,this.scrollable.container,a)}else null===(i=e.elements.menuTab)||void 0===i||i.remove(),e.elements.container.remove();e.mounted=t}createLocalCategory(e,t,i,s){const n=this.createCategory({id:e},t&&(0,o.ag)(t),!0,s);return n.local=!0,this.localCategories.push(n),n.elements.title&&n.elements.title.classList.add("disable-hover"),s||(i&&n.elements.menuTab.classList.add("tgico","tgico-"+i),n.elements.menuTabPadding.remove()),this.toggleLocalCategory(n,!1),n}onLocalCategoryUpdate(e){e.setCategoryItemsHeight(),this.toggleLocalCategory(e,!!e.items.length)}deleteCategory(e){return!!e&&(e.elements.container.remove(),e.elements.menuTab.remove(),this.categoriesIntersector.unobserve(e.elements.container),delete this.categories[e.id],this.categoriesMap.delete(e.elements.container),this.categoriesByMenuTabMap.delete(e.elements.menuTab),!0)}spliceExceed(e){if(void 0===e.limit)return!1;const{items:t,limit:i}=e;return t.splice(i,t.length-i).forEach((({element:e})=>{e.remove()})),this.onLocalCategoryUpdate(e),!0}init(){this.listenerSetter.add(s.ZP)("closed",(()=>{this.postponedEvents.forEach((({cb:e,args:t})=>{e(...t)})),this.postponedEvents.length=0}))}destroy(){var e,t,i,s;this.getContainerSize=void 0,this.postponedEvents.length=0,null===(e=this.categoriesIntersector)||void 0===e||e.disconnect(),this.listenerSetter.removeAll(),this.scrollable.destroy(),null===(t=this.menuScroll)||void 0===t||t.destroy(),null===(s=null===(i=this.menuOnClickResult)||void 0===i?void 0:i.stickyIntersector)||void 0===s||s.disconnect()}}class B extends R{constructor(e){super(e,"super-stickers",(()=>a.Z.active.esgSticker),6,4,4),this.onCategoryVisibility=({target:e,visible:t,entry:i})=>{const s=this.categoriesMap.get(e);s.elements.items.replaceChildren(...t?s.items.map((({element:e})=>e)):[])},this.setTyping=(e=!1)=>{(e||s.ZP.isActive()&&s.ZP.tab===this)&&d.Z.dispatchEvent("choosing_sticker",!e)},this.container.classList.add("stickers-padding"),this.content.id="content-stickers"}setFavedLimit(e){this.categories.faved.limit=e}categoryAppendStickers(e,t){const{container:i}=e.elements;t.then((t=>{const s=this.isCategoryVisible(e);t.forEach((t=>{const i=this.superStickerRenderer.renderSticker(t);e.items.push({document:t,element:i}),s&&e.elements.items.append(i)})),e.setCategoryItemsHeight(),i.classList.remove("hide")}))}renderStickerSet(e,t=!1){return _(this,void 0,void 0,(function*(){const i=this.createCategory(e,(0,r.Z)(e.title)),{menuTabPadding:n}=i.elements,a=this.managers.appStickersManager.getStickerSet(e);this.categoryAppendStickers(i,a.then((e=>e.documents))),this.positionCategory(i,t),(0,k.Z)({set:e,container:n,group:s.Yd,lazyLoadQueue:s.Jo.lazyLoadQueue,width:32,height:32,autoplay:!1})}))}init(){super.init(),this.scrollable.onAdditionalScroll=()=>{this.setTyping()};const e={root:s.ZP.getElement()};this.categoriesIntersector=new u.Z(this.onCategoryVisibility,e);const t=e=>{e.elements.items.replaceChildren(),e.items.forEach((({element:e})=>this.superStickerRenderer.unobserveAnimated(e))),e.items.length=0};this.scrollable.container.addEventListener("click",(e=>{const t=e.target;if((0,n.Z)(t,"category-title")){const e=(0,n.Z)(t,"emoji-category"),i=this.categoriesMap.get(e);if(i.local)return;A.Z.createPopup(m.Z,{id:i.set.id,access_hash:i.set.access_hash}).show()}else s.Jo.onMediaClick(e)})),this.menuOnClickResult=s.Jo.menuOnClick(this,this.menu,this.scrollable,this.menuScroll);const i=(0,f.y)(this.content,!0),o=(e,t)=>{e.limit&&(t=t.slice(0,e.limit));const i=new Set(t.map((e=>e.id)));(0,I.Z)(e.items,(t=>{i.has(t.document.id)||this.deleteSticker(e,t.document,!0)})),this.toggleLocalCategory(e,!!t.length),(0,I.Z)(t,((t,i)=>{this.unshiftSticker(e,t,!0,i)})),this.spliceExceed(e),e.elements.container.classList.remove("hide")},r=this.createLocalCategory("faved","FavoriteStickers","savedmessages"),l=this.createLocalCategory("recent","Stickers.Recent","recent");l.limit=20;const c=(0,S.Z)("close",{noRipple:!0});l.elements.title.append(c),(0,b.fc)(c,(()=>{(0,C.Z)({titleLangKey:"ClearRecentStickersAlertTitle",descriptionLangKey:"ClearRecentStickersAlertMessage",button:{langKey:"Clear"}}).then((()=>{this.managers.appStickersManager.clearRecentStickers()}),w.Z)}));const h=this.createLocalCategory("premium","PremiumStickersShort"),p=document.createElement("span");p.classList.add("tgico-star","color-premium"),h.elements.menuTab.append(p);const g=[Promise.all([this.managers.apiManager.getLimit("favedStickers"),this.managers.appStickersManager.getFavedStickersStickers()]).then((([e,t])=>{this.setFavedLimit(e),o(r,t)})),this.managers.appStickersManager.getRecentStickersStickers().then((e=>{o(l,e)})),this.managers.appStickersManager.getAllStickers().then((e=>{for(const t of e.sets)this.renderStickerSet(t)})),this.managers.appStickersManager.getPremiumStickers().then((e=>{const t=e.length;this.toggleLocalCategory(h,d.Z.premium&&!!t),this.categoryAppendStickers(h,Promise.resolve(e)),d.Z.addEventListener("premium_toggle",(e=>{this.toggleLocalCategory(this.categories.premium,e&&!!t)}))}))];Promise.race(g).finally((()=>{i.remove()})),Promise.all(g).finally((()=>{this.mounted=!0,this.setTyping();const e=this.categories.faved,t=this.categories.recent;this.menuOnClickResult.setActive(e.items.length?e:t),d.Z.addEventListener("stickers_installed",(e=>{this.categories[e.id]||this.renderStickerSet(e,!0)}))})),this.superStickerRenderer=new F(s.Jo.lazyLoadQueue,s.Yd,this.managers,e);const v=this.superStickerRenderer.lazyLoadQueue;s.ZP.addLazyLoadQueueRepeat(v,this.superStickerRenderer.processInvisible),d.Z.addEventListener("sticker_updated",(({type:e,document:t,faved:i})=>{const s=this.categories["faved"===e?"faved":"recent"];s&&(i?this.unshiftSticker(s,t):this.deleteSticker(s,t))})),d.Z.addEventListener("stickers_deleted",(({id:e})=>{const i=this.categories[e];this.deleteCategory(i)&&t(i)})),d.Z.addEventListener("stickers_top",this.postponedEvent((e=>{const t=this.categories[e];t&&(this.positionCategory(t,!0),s.ZP.addEventListener("openAfterLayout",(()=>{this.menuOnClickResult.setActiveStatic(t)}),{once:!0}))}))),d.Z.addEventListener("stickers_order",(({type:e,order:t})=>{"stickers"===e&&t.forEach((e=>{const t=this.categories[e];t&&this.positionCategory(t,!1)}))})),d.Z.addEventListener("stickers_updated",(({type:e,stickers:t})=>{const i=this.categories["faved"===e?"faved":"recent"];i&&o(i,t)})),d.Z.addEventListener("app_config",(()=>{this.managers.apiManager.getLimit("favedStickers").then((e=>{this.setFavedLimit(e)}))})),a.Z.addEventListener("resize",this.resizeCategories),(0,P.Z)({listenTo:this.content,listenerSetter:new Z.Z});const y="menu";(0,L.Z)({listenTo:this.content,verifyRecent:e=>!!(0,E.Z)(e,this.categories.recent.elements.items),onOpen:()=>{s.ZP.setIgnoreMouseOut(y,!0)},onClose:()=>{s.ZP.setIgnoreMouseOut(y,!1)}}),this.init=null}deleteSticker(e,t,i){const s=(0,v.Z)(e.items,(e=>e.document.id===t.id));s&&(s.element.remove(),i||this.onLocalCategoryUpdate(e))}unshiftSticker(e,t,i,s){if(void 0!==s){const i=e.items[s];if(i&&i.document.id===t.id)return}let n=(0,v.Z)(e.items,(e=>e.document.id===t.id));n||(n={element:this.superStickerRenderer.renderSticker(t),document:t}),e.items.unshift(n),e.elements.items.prepend(n.element),i||this.spliceExceed(e)}unshiftRecentSticker(e){this.managers.appStickersManager.saveRecentSticker(e.id)}deleteRecentSticker(e){this.managers.appStickersManager.saveRecentSticker(e.id,!0)}onClosed(){this.setTyping(!0)}onOpened(){this.setTyping(),this.resizeCategories()}}},36:(e,t,i)=>{"use strict";i.d(t,{G:()=>s});const s=()=>{const e=document.createElement("div");return e.classList.add("gradient-delimiter"),e}},5948:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(2325);function n(e){const t=document.createElement("span");return t.classList.add("badge-fake"),(0,s.$d)(t,e?"ScamMessage":"FakeMessage"),t}},1080:(e,t,i)=>{"use strict";i.d(t,{Z:()=>f});var s=i(5814),n=i(3725),a=i(3035),o=i(3512),r=i(8847),d=i(7009),l=i(2940);class c extends d.Z{constructor(e,t){super(e),this.onVisibilityChange=t,this.intersector=new l.Z((e=>{const{target:t,visible:i}=e,s=(0,r.Z)(this.queue,(e=>e.div===t));i&&s.length&&s.forEach((e=>{this.queue.unshift(e)})),this.onVisibilityChange&&this.onVisibilityChange(e),this.setProcessQueueTimeout()}))}observe(e){super.observe(e)}}var h=i(2887),u=i(319),p=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class f{constructor(e,t,i,r=!0){this.element=e,this.group=t,this.scrollable=i,this.scrollPromise=Promise.resolve(),this.timeout=0,this.onScroll=()=>{this.timeout?clearTimeout(this.timeout):this.scrollPromise=(0,n.Z)(),this.timeout=window.setTimeout((()=>{this.timeout=0,this.scrollPromise.resolve()}),150)},this.processInvisibleDiv=e=>this.scrollPromise.then((()=>p(this,void 0,void 0,(function*(){if(this.lazyLoadQueue.intersector.isVisible(e))return;const t=e.querySelector("video"),i=e.querySelector("img, canvas");i&&(i.classList.remove("hide"),yield(0,a.d1)()),!this.lazyLoadQueue.intersector.isVisible(e)&&t&&(t.remove(),t.src="",t.load(),s.Z.getAnimations(t).forEach((e=>{s.Z.removeAnimation(e)})))})))),this.managers=o.Z.managers,this.lazyLoadQueue=new c(void 0,(({target:e,visible:t})=>{t?this.processVisibleDiv(e):this.processInvisibleDiv(e)})),r&&this.attach()}attach(){this.scrollable.container.addEventListener("scroll",this.onScroll)}detach(){this.clear(),this.scrollable.container.removeEventListener("scroll",this.onScroll)}clear(){this.lazyLoadQueue.clear()}processVisibleDiv(e){e.querySelector("video")||this.lazyLoadQueue.push({div:e,load:()=>{const t=e.dataset.docId;return Promise.all([this.managers.appDocsManager.getDoc(t),this.scrollPromise]).then((([t])=>p(this,void 0,void 0,(function*(){const i=(yield(0,h.Z)({doc:t,container:e,lazyLoadQueue:null,group:this.group,noInfo:!0,noPreview:!0})).loadPromise;return i.finally((()=>{const t=e.querySelector("video"),i=e.querySelector("img, canvas");i&&i.classList.add("hide"),t&&!t.parentElement&&setTimeout((()=>{t.src="",t.load(),s.Z.getAnimations(t).forEach((e=>{s.Z.removeAnimation(e)}))}),0),this.lazyLoadQueue.intersector.isVisible(e)||this.processInvisibleDiv(e)})),i}))))}})}add(e,t=this.element){const i=document.createElement("div");i.classList.add("gif","grid-item"),i.dataset.docId=""+e.id,t.append(i),this.lazyLoadQueue.observe({div:i,load:u.Z}),(0,h.Z)({doc:e,container:i,lazyLoadQueue:null,noInfo:!0,onlyPreview:!0})}}},6008:(e,t,i)=>{"use strict";i.d(t,{X:()=>c});var s=i(426),n=i(3035),a=i(4789),o=i(5975),r=i(2648),d=i(2738),l=i(5994);function c(e,t,i,c,h=200,u,p){const f=(0,s.Z)({content:t,type:e||"tabs"===t.dataset.animation?"tabs":"navigation",transitionTime:h,onTransitionEnd:c,listenerSetter:p});if(!e)return f;const m=new Proxy(f,{apply:(t,i,s)=>{const n=+s[0],a=void 0===s[1]||s[1],o=e.querySelector(`[data-tab="${n}"]`)||e.children[n];g(o,n,a)}}),g=(s,o,r=!0)=>{return d=this,c=void 0,m=function*(){const d=t.children[o];if(i){const e=i(o,d,r),t=e instanceof Promise?yield e:e;if(void 0!==t&&!t)return}u&&u.scrollIntoViewNew({element:s.parentElement.children[o],position:"center",forceDirection:r?void 0:a.f.Static,forceDuration:h,axis:"x"}),l.Z.isAvailable("animations")||(r=!1);const c=f.prevId();if(s.classList.contains("active")||o===c)return!1;const p=r?n.T2:e=>e(),m=e.querySelector(b.toLowerCase()+".active");m&&p((()=>{m.classList.remove("active")})),v&&-1!==c&&r&&p((()=>{const e=s.querySelector("i"),t=s.parentElement.children[c].querySelector("i");t.classList.remove("animate"),e.classList.remove("animate");const i=t.parentElement.parentElement.offsetLeft-e.parentElement.parentElement.offsetLeft,a=t.clientWidth/e.clientWidth;e.style.transform=`translate3d(${i}px, 0, 0) scale3d(${a}, 1, 1)`,(0,n.T2)((()=>{e.classList.add("animate"),e.style.transform="none"}))})),p((()=>{s.classList.add("active")})),f(o,r)},new((p=void 0)||(p=Promise))((function(e,t){function i(e){try{n(m.next(e))}catch(e){t(e)}}function s(e){try{n(m.throw(e))}catch(e){t(e)}}function n(t){var n;t.done?e(t.value):(n=t.value,n instanceof p?n:new p((function(e){e(n)}))).then(i,s)}n((m=m.apply(d,c||[])).next())}));var d,c,p,m},v=!e.classList.contains("no-stripe"),b=e.firstElementChild.tagName;return(0,d.fc)(e,(t=>{let i,s=t.target;if(s=(0,o.Z)(s,e),!s)return!1;if(s.dataset.tab){if(i=+s.dataset.tab,-1===i)return!1}else i=(0,r.Z)(s);g(s,i)}),{listenerSetter:p}),m}},503:(e,t,i)=>{"use strict";i.d(t,{I1:()=>C,ZP:()=>I,rf:()=>w});var s=i(3910),n=i(6669),a=i(1544),o=i(8763),r=i(4668),d=i(3299),l=i(9336),c=i(1293),h=i(5565),u=i(669),p=i(130),f=i(2325),m=i(1507),g=i(6241),v=i(6535),b=i(3066),y=i(5400);function w(e,t,i,o){return r=this,l=void 0,h=function*(){const r=[],l=(null==i?void 0:i.some((e=>"messageEntityCustomEmoji"===e._)))?L():void 0,c=(0,b.Z)(t,{entities:i,wrappingForPeerId:o,loadPromises:r,customEmojiRenderer:l});c.querySelectorAll('[contenteditable="false"]').forEach((e=>{e.contentEditable="inherit",e.classList.add("pc")})),r.length&&(yield Promise.all(r)),c.querySelectorAll(".input-selectable").forEach((e=>{e.prepend((0,y.SZ)(!0))}));const h=u.Y?u.Z.getInstance():void 0,p=Array.from(c.querySelectorAll(".custom-emoji-placeholder")).map((e=>(e.dataset.ces="1",e.customEmojiElement))),f=(0,a.Z)(c);null==l||l.destroy();const m=(0,d.Z)(e);if(m.node);else{const t=document.createRange();let i=e.lastChild;i||e.append(i=document.createTextNode("")),t.setStartAfter(i),t.collapse(!0),m.selection.removeAllRanges(),m.selection.addRange(t)}e.addEventListener("input",s.Z,{capture:!0,once:!0,passive:!1}),null==h||h.onBeforeInput({inputType:"insertContent"}),window.document.execCommand("insertHTML",!1,f),Array.from(e.querySelectorAll("[data-ces]")).forEach(((e,t)=>{delete e.dataset.ces;const i=p[t];e.customEmojiElement=i,i.placeholder=e})),e.querySelectorAll(".pc").forEach((e=>{e.contentEditable="false"})),null==h||h.removeExtraBOMs(e),(0,n.Z)(e,"input")},new((c=void 0)||(c=Promise))((function(e,t){function i(e){try{n(h.next(e))}catch(e){t(e)}}function s(e){try{n(h.throw(e))}catch(e){t(e)}}function n(t){var n;t.done?e(t.value):(n=t.value,n instanceof c?n:new c((function(e){e(n)}))).then(i,s)}n((h=h.apply(r,l||[])).next())}));var r,l,c,h}let S=()=>{document.addEventListener("paste",(e=>{const t=(0,o.Z)(e.target,'contenteditable="true"');if(!t)return;const i=!!t.dataset.noLinebreaks;let s,n;e.preventDefault();let a=(e.originalEvent||e).clipboardData.getData("text/plain"),r=!0,d=(e.originalEvent||e).clipboardData.getData("text/html")||a;const c=e=>"messageEntityEmoji"===e._||"messageEntityLinebreak"===e._&&!i;if(i){const e=/[\r\n]/g;a=a.replace(e,""),d=d.replace(e,"")}const h=(t.dataset.peerId||m.NM).toPeerId();if(d.trim()){d=d.replace(/<style([\s\S]*)<\/style>/,""),d=d.replace(/<!--([\s\S]*)-->/,""),d=d.replace('<br class="Apple-interchange-newline">',"");const e=d.match(/<body>([\s\S]*)<\/body>/);e&&(d=e[1].trim());const t=(new DOMParser).parseFromString(d,"text/html").body||document.createElement("body");let i=t.firstChild;for(;i;){const e=i.nextSibling;i.nodeType===i.TEXT_NODE&&(i.nodeValue.trim()||i.remove()),i=e}const o=(0,l.Z)(t,!0,!1);h||(o.entities=o.entities.filter((e=>"messageEntityCustomEmoji"!==e._)));{const e=o.value.split("\n");let t=0;for(let i=0;i<e.length;++i){const s=e[i];t+=s.length;const n=t;if("\n"!==a[n]&&i!==e.length-1){const a=e.splice(i+1,1)[0];e[i]=s+a,o.entities.forEach((e=>{e.offset>=n&&(e.offset-=1)})),t+=a.length}t+=1}const i=e.join("\n");o.value=i}if(o.value.replace(/\s/g,"").length===a.replace(/\s/g,"").length||o.entities.find((e=>"messageEntityCustomEmoji"===e._))){s=o.value,n=o.entities,r=!1;let e=(0,v.Z)(s);e=e.filter(c),(0,g.Z)(n,e)}}r&&(s=a,n=(0,v.Z)(s),n=n.filter(c)),w(t,s,n,h)})),S=null};var C;function L(){return y.KZ.create({wrappingDraft:!0,isSelectable:!0})}function E(e){const t=Array.from(e.querySelectorAll(".custom-emoji, .custom-emoji-placeholder"));let i=e.querySelector(".custom-emoji-renderer");if(!i&&t.length)i=L(),e.prepend(i);else if(i&&!t.length)return void i.remove();if(!i)return;const s=new Map;t.forEach((e=>{const t=e instanceof y.LD?e:e.customEmojiElement,{docId:i}=t;let n=s.get(i);n||s.set(i,n=new Set),n.add(t)}));for(const[e,t]of s){let s=i.customEmojis.get(e);if(s)for(const e of s)t.has(e)||e.destroy();else s=new Set;for(const e of t)s.has(e)||e.connectedCallback()}i.add(s,!1),i.forceRender()}!function(e){e[e.Neutral=0]="Neutral",e[e.Valid=1]="Valid",e[e.Error=2]="Error"}(C||(C={}));class I{constructor(e={}){this.options=e,this.container=document.createElement("div"),this.container.classList.add("input-field"),this.required=e.required,this.validate=e.validate,void 0!==e.maxLength&&void 0===e.showLengthOn&&(e.showLengthOn=Math.min(40,Math.round(e.maxLength/3)));const{placeholder:t,maxLength:i,showLengthOn:s,name:n,plainText:a,canBeEdited:o=!0,autocomplete:d}=e,h=e.label||e.labelText,m=[];let g;if(a?(this.container.innerHTML=`\n <input type="text" ${n?`name="${n}"`:""} autocomplete="${null!=d?d:"off"}" ${h?'required=""':""} class="input-field-input">\n `,g=this.container.firstElementChild):(S&&S(),this.container.innerHTML='<div class="input-field-input"></div>',g=this.container.firstElementChild,g.contentEditable=""+!!o,u.Z.getInstance(),g.addEventListener("mousedown",(e=>{var t;const i=document.getSelection();if(!i.isCollapsed)return;const s=(0,r.Z)(e.target,"IMG");if(!s)return;const n=s.getBoundingClientRect(),a=n.left+n.width/2,o=e.clientX>=a,d=document.createRange();d.setStartAfter(o?s:null!==(t=s.previousSibling)&&void 0!==t?t:s),i.removeAllRanges(),i.addRange(d)})),m.push((()=>{(0,c.Z)(g)&&g.replaceChildren(),u.Y&&Array.from(g.querySelectorAll("br:not(.br-not-br)")).forEach((e=>{e.remove()})),(0,y.Cx)(Array.from(g.querySelectorAll(".input-something"))),E(g)}))),(0,p.m)(g),e.inputMode&&(g.inputMode=e.inputMode),t&&(0,f.$d)(g,t,void 0,"placeholder"),h||t){const e=document.createElement("div");e.classList.add("input-field-border"),this.container.append(e)}if(h&&(this.label=document.createElement("label"),this.setLabel(),this.container.append(this.label)),i){const e=this.container.lastElementChild;let t=!1;const n=()=>{const n=g.classList.contains("error"),o=a?g.value.length:[...(0,l.Z)(g,!1,!1).value].length,r=i-o,d=r<0;g.classList.toggle("error",d),d||r<=s?(this.setLabel(),e.append(` (${i-o})`),t||(t=!0)):(n&&!d||t)&&(this.setLabel(),t=!1)};m.push(n)}!e.withLinebreaks&&!a&&(g.dataset.noLinebreaks="1",g.addEventListener("keypress",(e=>{if("Enter"===e.key)return e.preventDefault(),!1}))),m.length&&g.addEventListener("input",(()=>{m.forEach((e=>e()))})),this.input=g}select(){this.value&&(this.options.plainText?this.input.select():function(e){const t=document.createRange();t.selectNodeContents(e);const i=window.getSelection();i.removeAllRanges(),i.addRange(t)}(this.input))}setLabel(){this.label.textContent="",this.options.labelText?(0,p.Z)(this.label,this.options.labelText):this.label.append((0,f.ag)(this.options.label,this.options.labelOptions))}get value(){return this.options.plainText?this.input.value:(0,l.Z)(this.input,!1,!1).value}set value(e){this.setValueSilently(e,!0),this.simulateInputEvent()}simulateInputEvent(){(0,n.Z)(this.input,"input")}setValueSilently(e,t){this.options.plainText?this.input.value=e:((0,h.Z)(this.input,e),E(this.input))}isChanged(){return this.value!==this.originalValue}isValid(){return!this.input.classList.contains("error")&&(!this.validate||this.validate())&&(!this.required||!(0,c.Z)(this.input))}isValidToChange(){return this.isValid()&&this.isChanged()}setDraftValue(e="",t){this.options.plainText||(e=(0,a.Z)((0,b.Z)(e))),t?this.setValueSilently(e,!1):this.value=e}setOriginalValue(e="",t){this.originalValue=e,this.setDraftValue(e,t)}setState(e,t){t?(this.label.textContent="",this.label.append((0,f.ag)(t,this.options.labelOptions))):this.setLabel(),this.input.classList.toggle("error",!!(e&C.Error)),this.input.classList.toggle("valid",!!(e&C.Valid))}setError(e){this.setState(C.Error,e)}}},9496:(e,t,i)=>{"use strict";i.d(t,{Z:()=>l});var s=i(669),n=i(6854),a=i(2325),o=i(503),r=i(9099);const d=new RegExp(`(<span>${n.Z}</span>)|(<br/?>)`,"g");class l extends o.ZP{constructor(e){super(e),this.input.addEventListener("input",(()=>{this.updateInnerHTML(),this.onFakeInput()})),e.placeholder&&(0,a.$d)(this.inputFake,e.placeholder,void 0,"placeholder"),this.input.classList.add("scrollable","scrollable-y","no-scrollbar"),this.inputFake=document.createElement("div"),this.inputFake.contentEditable="true",this.inputFake.tabIndex=-1,this.inputFake.className=this.input.className+" input-field-input-fake"}onFakeInput(e=!0,t){var i;const{scrollHeight:s}=this.inputFake;null!=t||(t=!this.input.isContentEditable);const n=+this.input.style.height.replace("px","");if(n===s)return;const a=t?0:Math.round(50*Math.log(Math.abs(s-n)));this.input.style.transitionDuration=`${a}ms`,e&&(null===(i=this.onChangeHeight)||void 0===i||i.call(this,s),this.input.style.height=s?s+"px":"");const o="is-changing-height";(0,r.Z)({element:this.input,className:o,forwards:!0,duration:a,onTransitionEnd:()=>{this.input.classList.remove(o)}})}updateInnerHTML(e=this.input.innerHTML){e=e.replace(/<custom-emoji-renderer-element.+\/custom-emoji-renderer-element>/,"").replace(/(<custom-emoji-element.+?>).+?\/custom-emoji-element>/g,"$1</custom-emoji-element>"),s.Y&&(e=e.replace(d,"")),this.inputFake.innerHTML=e}setValueSilently(e,t){super.setValueSilently(e,t),this.updateInnerHTML(),t||this.onFakeInput()}}},3607:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(503);class n{constructor(e,t){this.prevValue="",this.timeout=0,this.onInput=()=>{if(!this.onChange)return;const e=this.value;e!==this.prevValue&&(this.prevValue=e,clearTimeout(this.timeout),this.timeout=window.setTimeout((()=>{this.onChange(e)}),200))},this.onClearClick=()=>{this.value="",this.onChange&&this.onChange(""),this.onClear&&this.onClear()},this.inputField=new s.ZP({placeholder:e,plainText:!0}),this.container=this.inputField.container,this.container.classList.remove("input-field"),this.container.classList.add("input-search"),this.onChange=t,this.input=this.inputField.input,this.input.classList.add("input-search-input");const i=document.createElement("i");i.classList.add("tgico","tgico-search"),this.clearBtn=document.createElement("i"),this.clearBtn.classList.add("tgico","btn-icon","tgico-close"),this.input.addEventListener("input",this.onInput),this.clearBtn.addEventListener("click",this.onClearClick),this.container.append(i,this.clearBtn)}get value(){return this.inputField.value}set value(e){this.prevValue=e,clearTimeout(this.timeout),this.inputField.value=e}remove(){clearTimeout(this.timeout),this.input.removeEventListener("input",this.onInput),this.clearBtn.removeEventListener("click",this.onClearClick)}}},2153:(e,t,i)=>{"use strict";i.d(t,{Z:()=>d});var s=i(2940),n=i(8847),a=i(4064),o=i(7009),r=i(8594);class d extends o.Z{constructor(e,t){super(e),this.onVisibilityChange=({target:e,visible:t})=>{(0,n.Z)(this.queue,(t=>t.div===e)).forEach((e=>{t&&(e.wasSeen=!0),e.visible=t;const i=this.queue.findIndex((e=>!e.visible));this.queue.splice(Math.max(0,i),0,e)})),this.setProcessQueueTimeout()},this.intersector=new s.Z(this.onVisibilityChange),!t&&(0,r.ZP)((()=>{this.lock()}),(()=>{this.unlockAndRefresh()}))}getItem(){return(0,a.Z)(this.queue,(e=>e.wasSeen))}processItem(e){const t=Object.create(null,{processItem:{get:()=>super.processItem}});return i=this,s=void 0,a=function*(){yield t.processItem.call(this,e),this.intersector.unobserve(e.div)},new((n=void 0)||(n=Promise))((function(e,t){function o(e){try{d(a.next(e))}catch(e){t(e)}}function r(e){try{d(a.throw(e))}catch(e){t(e)}}function d(t){var i;t.done?e(t.value):(i=t.value,i instanceof n?i:new n((function(e){e(i)}))).then(o,r)}d((a=a.apply(i,s||[])).next())}));var i,s,n,a}addElement(e,t){var i;return!!super.addElement(e,t)&&(this.observe(t),null!==(i=t.wasSeen)&&void 0!==i||(t.wasSeen=!1),!0)}setAllSeen(){this.queue.forEach((e=>{e.wasSeen=!0})),this.setProcessQueueTimeout()}}},7009:(e,t,i)=>{"use strict";i.d(t,{Z:()=>a});var s=i(8847),n=i(4421);class a extends n.Z{constructor(e){super(e),this.queue=[],this.inProcess=new Set}lock(){super.lock(),this.intersector.lock()}unlock(){super.unlock(),this.intersector.unlock()}unlockAndRefresh(){super.unlock(),this.intersector.unlockAndRefresh()}clear(){super.clear(),this.intersector.disconnect()}refresh(){this.intersector.refresh()}loadItem(e){return e.load(e.div)}addElement(e,t){if(this.queue.find((e=>e.div===t.div&&e.load===t.load)))return!1;for(const e of this.inProcess)if(e.div===t.div&&e.load===t.load)return!1;return this.queue[e](t),!0}setProcessQueueTimeout(){var e;null!==(e=this.intersectorTimeout)&&void 0!==e||(this.intersectorTimeout=window.setTimeout((()=>{this.intersectorTimeout=void 0,this.processQueue()}),0))}push(e){super.push(e)}unshift(e){super.unshift(e)}delete(e){(0,s.Z)(this.queue,(t=>t.div===e.div)),this.unobserve(e)}observe(e){this.intersector.observe(e.div)}unobserve(e){this.intersector.unobserve(e.div)}}},7207:(e,t,i)=>{"use strict";i.d(t,{Z:()=>a});var s=i(3013),n=i(65);class a extends n.Z{constructor(e={}){super({step:1e3/60/1e3,min:0,max:1,withTransition:e.withTransition,useTransform:e.useTransform},0),this.options=e,this.onLoadedData=()=>{this.setSeekMax()},this.onEnded=()=>{this.setProgress()},this.onPlay=()=>{const e=()=>{this.setProgress(),this.progressRAF=this.media.paused?void 0:window.requestAnimationFrame(e)};this.progressRAF&&(window.cancelAnimationFrame(this.progressRAF),this.progressRAF=void 0),this.streamable&&this.setLoadProgress(),e()},this.onTimeUpdate=()=>{this.media.paused&&(this.setProgress(),this.streamable&&this.setLoadProgress())},this.onProgress=e=>{this.setLoadProgress()}}setMedia({media:e,streamable:t,duration:i}){this.media&&this.removeListeners(),t&&!this.filledLoad?(this.filledLoad=document.createElement("div"),this.filledLoad.classList.add("progress-line__filled","progress-line__loaded"),this.container.prepend(this.filledLoad)):this.filledLoad&&this.filledLoad.classList.toggle("hide",!t),this.media=e,this.streamable=t,(!e.paused||e.currentTime>0)&&this.onPlay();let s=!1;this.setSeekMax(i),this.setListeners(),this.setHandlers({onMouseDown:()=>{var e,t;s=!this.media.paused,s&&this.media.pause(),null===(t=null===(e=this.options)||void 0===e?void 0:e.onSeekStart)||void 0===t||t.call(e)},onMouseUp:e=>{var t,i;s&&this.media.play(),null===(i=null===(t=this.options)||void 0===t?void 0:t.onSeekEnd)||void 0===i||i.call(t)}})}scrub(e){const t=super.scrub(e);return this.media.currentTime=t,t}setLoadProgress(){if(s.Z.isSafariBuffering(this.media))return;const e=this.media.buffered,t=e.length,i=this.media.currentTime;let n=0,a=0;for(let s=0;s<t;++s){const t=e.start(s);i>=t&&t>=n&&(n=t,a=e.end(s))}const o=this.max?a/this.max:0;this.filledLoad.style.width=100*o+"%"}setSeekMax(e){const t=this.media.duration||0;(void 0===e||t)&&(e=t),(this.max=e)?this.seek.setAttribute("max",""+this.max):this.media.addEventListener("loadeddata",this.onLoadedData)}setProgress(){if(s.Z.isSafariBuffering(this.media))return;const e=this.media.currentTime;super.setProgress(e)}setListeners(){super.setListeners(),this.media.addEventListener("ended",this.onEnded),this.media.addEventListener("play",this.onPlay),this.media.addEventListener("pause",this.onTimeUpdate),this.media.addEventListener("timeupdate",this.onTimeUpdate),this.streamable&&this.media.addEventListener("progress",this.onProgress)}removeListeners(){super.removeListeners(),this.media&&(this.media.removeEventListener("loadeddata",this.onLoadedData),this.media.removeEventListener("ended",this.onEnded),this.media.removeEventListener("play",this.onPlay),this.media.removeEventListener("pause",this.onTimeUpdate),this.media.removeEventListener("timeupdate",this.onTimeUpdate),this.streamable&&this.media.removeEventListener("progress",this.onProgress)),this.progressRAF&&(window.cancelAnimationFrame(this.progressRAF),this.progressRAF=void 0)}}},3251:(e,t,i)=>{"use strict";i.d(t,{I:()=>f});var s=i(3189),n=i(8097),a=i(4755),o=i(3228),r=i(3035);const d=new Map,l=new Set;let c=!1;function h(){c||(c=!0,(0,r.T2)((()=>{c=!1,l.forEach(p),l.clear()})))}function u(e){const t=e.getSize;if(t)return t();const i=e.dataset.sizeType;return i?a.Z.active[i].width:e.getBoundingClientRect().width}function p(e){let t=d.get(e);const i=!t;let{text:a,textLength:r,from:l,multiplier:c,font:h,textWidth:p,elementWidth:f}=t||{};if(i){a=e.textContent,r=a.length,l=50,c=l>0&&l/100;let i=e.dataset.fontSize;i&&+i&&(i+="px"),h=`${e.dataset.fontWeight||s.U9} ${i||s.Bf} ${s.bt}`,p=(0,n.Z)(a,h),f=u(e),t={text:a,textLength:r,from:l,multiplier:c,font:h,textWidth:p,elementWidth:f},d.set(e,t)}const m=u(e),g=i||f!==m;if(!i&&g&&(t.elementWidth=f=m),g)if(p>f){e.setAttribute("title",a);let i=a,s=f;for(;i.length>3;){const t=i.length,a=c&&(0,o.Z)(c*t<<0,1,t-2)||Math.max(t+l-1,1),r=i.substr(0,a).replace(/\s*$/,""),d=i.substr(a+1).replace(/^\s*/,"");if(i=r+d,s=(0,n.Z)(i+"…",h),s<f){e.textContent=r+"…"+d;break}}t.elementWidth=u(e)}else e.removeAttribute("title")}window.addEventListener("resize",(()=>{for(const[e]of d)l.add(e);h()}),{capture:!0,passive:!0});class f extends HTMLElement{connectedCallback(){d.set(this,null),this.dataset.sizeType||this.getSize?p(this):(l.add(this),h())}disconnectedCallback(){d.delete(this),l.delete(this)}}customElements.define("middle-ellipsis-element",f)},4425:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(1447);class n{constructor(e,t){this.passwordInputField=e,this.size=t,this.needFrame=0,this.container=document.createElement("div"),this.container.classList.add("media-sticker-wrapper")}load(){return this.loadPromise?this.loadPromise:this.loadPromise=s.Z.loadAnimationAsAsset({container:this.container,loop:!1,autoplay:!1,width:this.size,height:this.size,noCache:!0},"TwoFactorSetupMonkeyPeek").then((e=>(this.animation=e,this.animation.addEventListener("enterFrame",(e=>{(1===this.animation.direction&&e>=this.needFrame||-1===this.animation.direction&&e<=this.needFrame)&&(this.animation.setSpeed(1),this.animation.pause())})),this.passwordInputField.helpers.onVisibilityClickAdditional=()=>{this.passwordInputField.helpers.passwordVisible?(this.animation.setDirection(1),this.animation.curFrame=0,this.needFrame=16,this.animation.play()):(this.animation.setDirection(-1),this.animation.curFrame=16,this.needFrame=0,this.animation.play())},s.Z.waitForFirstFrame(e))))}remove(){this.animation&&this.animation.remove()}}},3083:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(1447);class n{constructor(e,t){this.inputField=e,this.size=t,this.max=45,this.needFrame=0,this.container=document.createElement("div"),this.container.classList.add("media-sticker-wrapper");const i=e.input;i.addEventListener("blur",(()=>{this.playAnimation(0)})),i.addEventListener("input",(t=>{this.playAnimation(e.value.length)}))}playAnimation(e){if(!this.animation)return;let t;(e=Math.min(e,30))?(t=Math.round(Math.min(this.max,e)*(165/this.max)+11.33),this.idleAnimation&&(this.idleAnimation.stop(!0),this.idleAnimation.canvas[0].style.display="none"),this.animation.canvas[0].style.display=""):t=0;const i=this.needFrame>t?-1:1;this.animation.setDirection(i),0!==this.needFrame&&0===t&&this.animation.setSpeed(7),this.needFrame=t,this.animation.play()}load(){return this.loadPromise?this.loadPromise:this.loadPromise=Promise.all([s.Z.loadAnimationAsAsset({container:this.container,loop:!0,autoplay:!0,width:this.size,height:this.size},"TwoFactorSetupMonkeyIdle").then((e=>(this.idleAnimation=e,this.inputField.value.length||e.play(),s.Z.waitForFirstFrame(e)))),s.Z.loadAnimationAsAsset({container:this.container,loop:!1,autoplay:!1,width:this.size,height:this.size},"TwoFactorSetupMonkeyTracking").then((e=>(this.animation=e,this.inputField.value.length||(this.animation.canvas[0].style.display="none"),this.animation.addEventListener("enterFrame",(e=>{(1===this.animation.direction&&e>=this.needFrame||-1===this.animation.direction&&e<=this.needFrame)&&(this.animation.setSpeed(1),this.animation.pause()),0===e&&0===this.needFrame&&this.idleAnimation&&(this.idleAnimation.canvas[0].style.display="",this.idleAnimation.play(),this.animation.canvas[0].style.display="none")})),s.Z.waitForFirstFrame(e))))])}remove(){this.animation&&this.animation.remove(),this.idleAnimation&&this.idleAnimation.remove()}}},6830:(e,t,i)=>{"use strict";i.d(t,{T:()=>a,Z:()=>o});var s=i(3910),n=i(503);class a{constructor(e,t){this.container=e,this.input=t,this.passwordVisible=!1,this.onVisibilityClick=e=>{(0,s.Z)(e),this.passwordVisible=!this.passwordVisible,this.toggleVisible.classList.toggle("eye-hidden",this.passwordVisible),this.input.type=this.passwordVisible?"text":"password",this.onVisibilityClickAdditional&&this.onVisibilityClickAdditional()},t.type="password",t.setAttribute("required",""),t.name="notsearch_password",t.autocomplete="off";const i=document.createElement("input");i.classList.add("stealthy"),i.tabIndex=-1,i.type="password",t.parentElement.prepend(i),t.parentElement.insertBefore(i.cloneNode(),t.nextSibling);const n=this.toggleVisible=document.createElement("span");n.classList.add("toggle-visible","tgico"),e.classList.add("input-field-password"),e.append(n),n.addEventListener("click",this.onVisibilityClick),n.addEventListener("touchend",this.onVisibilityClick)}}class o extends n.ZP{constructor(e={}){super(Object.assign({plainText:!0},e)),this.helpers=new a(this.container,this.input)}}},8261:(e,t,i)=>{"use strict";i.d(t,{Z:()=>G});var s=i(2365),n=i(3725),a=i(2166),o=i(3532),r=i(2738),d=i(5565),l=i(130),c=i(3699),h=i(5471),u=i(9405),p=i(3624),f=i(8631),m=i(7030),g=i(2790),v=i(5102),b=i(2325),y=i(5400),w=i(3512),S=i(9331),C=i(9807),L=i(36),E=i(5432),I=i(4064),P=i(3910),Z=i(1708),M=i(6074),k=i(3035),T=i(9687),x=i(9931),A=i(3757),_=i(9492),F=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class D{constructor(e,t){this.scrollable=e,this.managers=t,this.processItem=e=>F(this,void 0,void 0,(function*(){const t=document.createElement("div");let i;t.classList.add(D.BASE_CLASS+"-avatar","media-container","hide"),this.avatars.append(t),e&&(i="object"!=typeof e?yield this.managers.appPhotosManager.getPhoto(e):e.action.photo);const s=new Image;s.classList.add("avatar-photo"),s.draggable=!1;const n=()=>F(this,void 0,void 0,(function*(){if(i){const e=yield(0,_.Z)({container:t,photo:i,size:(0,T.Z)(i,420,420,!1),withoutPreloader:!0});[e.images.thumb,e.images.full].filter(Boolean).forEach((e=>{e.classList.add("avatar-photo")}))}else{const e=yield this.managers.appPeersManager.getPeerPhoto(this.peerId);yield(0,x.Y)(t,this.peerId,e,"photo_big",s)}t.classList.remove("hide")}));return this.avatars.childElementCount<=3?yield n():(this.intersectionObserver.observe(t),this.loadCallbacks.set(t,n)),this.addTab(),e})),this.container=document.createElement("div"),this.container.classList.add(D.BASE_CLASS+"-container"),this.avatars=document.createElement("div"),this.avatars.classList.add(D.BASE_CLASS+"-avatars"),this.gradient=document.createElement("div"),this.gradient.classList.add(D.BASE_CLASS+"-gradient"),this.info=document.createElement("div"),this.info.classList.add(D.BASE_CLASS+"-info"),this.tabs=document.createElement("div"),this.tabs.classList.add(D.BASE_CLASS+"-tabs"),this.arrowPrevious=document.createElement("div"),this.arrowPrevious.classList.add(D.BASE_CLASS+"-arrow","tgico-avatarprevious"),this.arrowNext=document.createElement("div"),this.arrowNext.classList.add(D.BASE_CLASS+"-arrow",D.BASE_CLASS+"-arrow-next","tgico-avatarnext"),this.container.append(this.avatars,this.gradient,this.info,this.tabs,this.arrowPrevious,this.arrowNext),this.loadCallbacks=new Map,this.listenerSetter=new c.Z;const i=()=>0===this.scrollable.scrollTop||(this.scrollable.scrollIntoViewNew({element:this.scrollable.container.firstElementChild,position:"start"}),!1),s=1/3;let n=!1,a=!1;(0,r.fc)(this.container,(e=>F(this,void 0,void 0,(function*(){if(a)return void(0,P.Z)(e);if(n)return void(n=!1);if(!i())return;const t=this.container.getBoundingClientRect(),o=e.pageX,r=o-t.left;if(!this.listLoader.previous.length&&!this.listLoader.next.length||r>t.width*s&&r<t.width-t.width*s){const e=this.peerId,t=[];this.listLoader.previous.concat(this.listLoader.current,this.listLoader.next).forEach(((e,i)=>{t.push({element:this.avatars.children[i],item:e})}));const i=t.slice(0,this.listLoader.previous.length),s=t.slice(this.listLoader.previous.length+1),n=this.avatars.children[this.listLoader.previous.length];a=!0,(0,S.C)(n,e,(()=>e===this.peerId),this.listLoader.current,i,s),a=!1}else{const e=o>t.right-t.width/2;let i;this.avatars.classList.add("no-transition"),this.avatars.offsetLeft,i=0!==this.listLoader.index||e?this.listLoader.index===this.listLoader.count-1&&e?-(this.listLoader.count-1):e?1:-1:this.listLoader.count-1,this.listLoader.go(i),(0,k.T2)((()=>{this.avatars.classList.remove("no-transition")}))}}))),{listenerSetter:this.listenerSetter});const o=()=>{n=!0,document.body.addEventListener(E.Z?"touchend":"click",(e=>{n=!1}),{once:!0})};let d=0,l=0,h=0,u=0;this.swipeHandler=new A.Z({element:this.avatars,onSwipe:(e,t)=>{h=e*=-1;let i=l+e*-D.SCALE;return i>0?i=0:i<u&&(i=u),this.avatars.style.transform=D.TRANSLATE_TEMPLATE.replace("{x}",i+"px"),!1},verifyTouchTarget:e=>i()?!this.container.classList.contains("is-single")&&!a:(o(),(0,P.Z)(e),!1),onFirstSwipe:()=>{const e=this.avatars.getBoundingClientRect();d=e.width,u=-d*(this.tabs.childElementCount-1),l=e.left-this.container.getBoundingClientRect().left,this.avatars.style.transform=D.TRANSLATE_TEMPLATE.replace("{x}",l+"px"),this.container.classList.add("is-swiping"),this.avatars.classList.add("no-transition"),this.avatars.offsetLeft},onReset:()=>{const e=Math.ceil(Math.abs(h)/(d/D.SCALE))*(h>=0?1:-1);o(),this.avatars.classList.remove("no-transition"),(0,k.T2)((()=>{this.listLoader.go(e),this.container.classList.remove("is-swiping")}))}}),this.intersectionObserver=new IntersectionObserver((e=>{e.forEach((e=>{e.isIntersecting&&this.loadNearestToTarget(e.target)}))}))}setPeer(e){return F(this,void 0,void 0,(function*(){this.peerId=e;const t=yield this.managers.appPeersManager.getPeerPhoto(e);if(!t)return;const i=this.listLoader=new M.Z({loadCount:50,loadMore:(t,s,n)=>{if(!s)return Promise.resolve({count:void 0,items:[]});if(e.isUser()){const i=t;return this.managers.appPhotosManager.getUserPhotos(e,i,n).then((e=>({count:e.count,items:e.photos})))}{const t=[];return i.current||t.push(this.managers.appProfileManager.getChatFull(e.toChatId())),t.push(this.managers.appMessagesManager.getSearch({peerId:e,maxId:Number.MAX_SAFE_INTEGER,inputFilter:{_:"inputMessagesFilterChatPhotos"},limit:n,backLimit:0})),Promise.all(t).then((e=>F(this,void 0,void 0,(function*(){const t=e.pop();if((0,Z.Z)(t),!i.current){const s=e[0],n=(0,I.Z)(t.history,(e=>e.action.photo.id===s.chat_photo.id));i.current=n||(yield this.managers.appMessagesManager.generateFakeAvatarMessage(this.peerId,s.chat_photo))}return{count:t.count,items:t.history}}))))}},processItem:this.processItem,onJump:(e,t)=>{const i=this.listLoader.index,s=100*D.SCALE*i;this.avatars.style.transform=D.TRANSLATE_TEMPLATE.replace("{x}",`-${s}%`);const n=this.tabs.querySelector(".active");n&&n.classList.remove("active"),this.tabs.children[i].classList.add("active"),this.loadNearestToTarget(this.avatars.children[i])}});"userProfilePhoto"===t._&&(i.current=t.photo_id),yield this.processItem(i.current),i.load(!0)}))}addTab(){const e=document.createElement("div");e.classList.add(D.BASE_CLASS+"-tab"),this.tabs.append(e),1===this.tabs.childElementCount&&e.classList.add("active"),this.container.classList.toggle("is-single",this.tabs.childElementCount<=1)}loadNearestToTarget(e){const t=Array.from(e.parentElement.children),i=t.indexOf(e);t.slice(Math.max(0,i-3),Math.min(t.length,i+3)).forEach((e=>{const t=this.loadCallbacks.get(e);t&&(t(),this.loadCallbacks.delete(e),this.intersectionObserver.unobserve(e))}))}cleanup(){var e;this.listenerSetter.removeAll(),this.swipeHandler.removeListeners(),null===(e=this.intersectionObserver)||void 0===e||e.disconnect()}}D.BASE_CLASS="profile-avatars",D.SCALE=s.Z?2:1,D.TRANSLATE_TEMPLATE=s.Z?`translate3d({x}, 0, -1px) scale(${D.SCALE})`:"translate({x}, 0)";var R=i(7479),B=i(5029),N=i(2796),O=i(8210),U=i(7362),H=i(9102),z=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};const j=(e,t)=>{(0,l.Z)(t.title,e||void 0),t.container.style.display=e?"":"none"};class G{constructor(e,t,i,n=!0){this.managers=e,this.scrollable=t,this.listenerSetter=i,this.isDialog=n,s.Z||this.scrollable.container.classList.add("no-parallax"),i||(this.listenerSetter=new c.Z),this.middlewareHelper=(0,p.k)()}init(){this.init=null,this.element=document.createElement("div"),this.element.classList.add("profile-content"),this.section=new B.Z({noDelimiter:!0}),this.name=document.createElement("div"),this.name.classList.add("profile-name"),this.subtitle=document.createElement("div"),this.subtitle.classList.add("profile-subtitle"),this.bio=new R.ZP({title:" ",subtitle:!0,icon:"info",clickable:e=>{"A"!==e.target.tagName&&((0,a.T)(this.bio.title.textContent),(0,N.Am)(b.ZP.format("BioCopied",!0)))},listenerSetter:this.listenerSetter,contextMenu:{buttons:[{icon:"copy",text:"Text.CopyLabel_About",onClick:()=>{(0,r.tH)(this.bio.container)},verify:()=>!this.peerId.isUser()},{icon:"copy",text:"Text.CopyLabel_Bio",onClick:()=>{(0,r.tH)(this.bio.container)},verify:()=>this.peerId.isUser()}]}}),this.bio.title.classList.add("pre-wrap"),this.username=new R.ZP({title:" ",subtitleLangKey:"Username",icon:"username",clickable:()=>{(0,a.T)("@"+this.username.title.textContent),(0,N.Am)(b.ZP.format("UsernameCopied",!0))},listenerSetter:this.listenerSetter,contextMenu:{buttons:[{icon:"copy",text:"Text.CopyLabel_Username",onClick:()=>{(0,r.tH)(this.username.container)}}]}}),this.phone=new R.ZP({title:" ",subtitle:!0,icon:"phone",clickable:()=>{(0,a.T)(this.phone.title.textContent.replace(/\s/g,"")),(0,N.Am)(b.ZP.format("PhoneCopied",!0))},listenerSetter:this.listenerSetter,contextMenu:{buttons:[{icon:"copy",text:"Text.CopyLabel_PhoneNumber",onClick:()=>{(0,r.tH)(this.phone.container)}},{icon:"info",text:"PeerInfo.Phone.AnonymousInfo",textArgs:[document.createElement("a")],onClick:()=>{window.open("https://fragment.com/numbers","_blank")},separator:!0,multiline:!0,verify:()=>z(this,void 0,void 0,(function*(){const{isAnonymous:e}=(yield this.managers.appUsersManager.getUserPhone(this.peerId.toUserId()))||{};return e}))}]}}),this.link=new R.ZP({title:" ",subtitleLangKey:"SetUrlPlaceholder",icon:"link",clickable:()=>{const e=this.link.title.textContent;(0,a.T)(e);const t=e.includes("/c/");(0,N.Am)(b.ZP.format(t?"LinkCopiedPrivateInfo":"LinkCopied",!0))},listenerSetter:this.listenerSetter,contextMenu:{buttons:[{icon:"copy",text:"Text.CopyLabel_ShareLink",onClick:()=>{(0,r.tH)(this.link.container)}}]}}),this.location=new R.ZP({title:" ",subtitleLangKey:"ChatLocation",icon:"location"}),this.section.content.append(this.phone.container,this.username.container,this.location.container,this.bio.container,this.link.container);const{listenerSetter:e}=this;this.isDialog&&(this.notifications=new R.ZP({checkboxField:new C.Z({toggle:!0}),titleLangKey:"Notifications",icon:"unmute",listenerSetter:this.listenerSetter}),e.add(this.notifications.checkboxField.input)("change",(e=>{e.isTrusted&&this.managers.appMessagesManager.togglePeerMute({peerId:this.peerId,threadId:this.threadId})})),e.add(w.Z)("dialog_notify_settings",(e=>z(this,void 0,void 0,(function*(){if(this.peerId===e.peerId){const e=yield this.managers.appNotificationsManager.isPeerLocalMuted({peerId:this.peerId,respectType:!1,threadId:this.threadId});this.notifications.checkboxField.checked=!e}})))),this.section.content.append(this.notifications.container)),this.element.append(this.section.container),s.Z&&this.element.append((0,L.G)()),e.add(w.Z)("peer_typings",(({peerId:e})=>{this.peerId===e&&this.setPeerStatus()})),e.add(w.Z)("peer_bio_edit",(e=>{e===this.peerId&&this.setMoreDetails(!0)}));const t=({peerId:e,threadId:t})=>z(this,void 0,void 0,(function*(){return this.peerId===e&&(!(yield this.managers.appPeersManager.isForum(this.peerId))||!this.threadId||this.threadId===t)}));e.add(w.Z)("peer_title_edit",(e=>z(this,void 0,void 0,(function*(){(yield t(e))&&(this.fillUsername(),this.setMoreDetails(!0))})))),e.add(w.Z)("user_update",(e=>{this.peerId===e.toPeerId()&&this.setPeerStatus()})),e.add(w.Z)("contacts_update",(e=>z(this,void 0,void 0,(function*(){this.peerId===e.toPeerId()&&((yield this.managers.appUsersManager.getUser(e)).pFlags.self&&this.isDialog||this.fillUserPhone())})))),e.add(w.Z)("avatar_update",(e=>z(this,void 0,void 0,(function*(){(yield t(e))&&this.setAvatar()})))),this.setPeerStatusInterval=window.setInterval((()=>this.setPeerStatus()),6e4)}setPeerStatus(e=!1,t){return z(this,void 0,void 0,(function*(){const i=this.peerId,s=[];s.push((()=>{this.element.classList.toggle("is-me",i===w.Z.myId)}));let n=Promise.resolve();if(i&&(w.Z.myId!==i||!this.isDialog)){const t=yield this.managers.appPeersManager.isForum(this.peerId),a=this.middlewareHelper.get();n=t&&this.threadId?(0,H.Z)({peerId:i,wrapOptions:{middleware:a}}).then((({element:e})=>{this.subtitle.replaceChildren(e)})):m.ZP.setPeerStatus({peerId:i,element:this.subtitle,needClear:e,useWhitespace:!0,middleware:a,ignoreSelf:!this.isDialog}),n.then((e=>e&&s.push(e)))}const a=()=>s.forEach((e=>e()));return n.then((()=>{if(t)return a;a()}))}))}cleanupHTML(){[this.bio,this.phone,this.username,this.location,this.link].forEach((e=>{e.container.style.display="none"})),this.notifications&&(this.notifications.container.style.display="",this.notifications.checkboxField.checked=!0),this.clearSetMoreDetailsTimeout()}canBeDetailed(){return this.peerId!==w.Z.myId||!this.isDialog}createAvatar(){const e=new S.Z;return e.classList.add("profile-avatar","avatar-120"),e.isDialog=this.isDialog,e.attachClickEvent(),e}_setAvatar(){return z(this,void 0,void 0,(function*(){const{peerId:e}=this,t=!(!this.threadId||!(yield this.managers.appPeersManager.isForum(e)));if(this.canBeDetailed()&&!t&&(yield this.managers.appPeersManager.getPeerPhoto(e))){const t=this.avatars;return this.avatars=new D(this.scrollable,this.managers),yield this.avatars.setPeer(e),()=>{var e;this.avatars.info.append(this.name,this.subtitle),null===(e=this.avatar)||void 0===e||e.remove(),this.avatar=void 0,t?t.container.replaceWith(this.avatars.container):this.element.prepend(this.avatars.container),s.Z&&this.scrollable.container.classList.add("parallax")}}const i=this.createAvatar();return yield i.updateWithOptions({peerId:e,threadId:t?this.threadId:void 0,wrapOptions:{customEmojiSize:(0,u.C)(120,120),middleware:this.middlewareHelper.get()}}),()=>{var e;s.Z&&this.scrollable.container.classList.remove("parallax"),this.avatars&&(this.avatars.container.remove(),this.avatars.cleanup(),this.avatars=void 0),null===(e=this.avatar)||void 0===e||e.remove(),this.avatar=i,this.section.content.prepend(this.avatar,this.name,this.subtitle)}}))}setAvatar(e){const t=this._setAvatar();return e?t:t.then((e=>e()))}getUsernamesAlso(e){const t=e.slice(1);if(t.length){const e=t.map((e=>(0,o.Z)({username:e})));return(0,b.ag)("UsernameAlso",[(0,b.v_)(e,!1)])}}fillUsername(){return z(this,void 0,void 0,(function*(){const{peerId:e}=this;if(e.isUser()&&this.canBeDetailed()){const t=yield this.managers.appPeersManager.getPeerActiveUsernames(e),i=this.getUsernamesAlso(t);return()=>{this.username.subtitle.replaceChildren(i||(0,b.ag)("Username")),j(t[0],this.username)}}}))}fillUserPhone(){return z(this,void 0,void 0,(function*(){const{peerId:e}=this;if(e.isUser()&&this.canBeDetailed()){const{phone:t,isAnonymous:i}=(yield this.managers.appUsersManager.getUserPhone(e.toUserId()))||{};return()=>{this.phone.subtitle.replaceChildren((0,b.ag)(i?"AnonymousNumber":"Phone")),j(t?(0,O.Z)(t):void 0,this.phone)}}}))}fillNotifications(){return z(this,void 0,void 0,(function*(){const e=this.notifications;if(e){if(this.canBeDetailed()){const t=yield this.managers.appNotificationsManager.isPeerLocalMuted({peerId:this.peerId,respectType:!1,threadId:this.threadId});return()=>{e.checkboxField.checked=!t}}return()=>{e.container.style.display="none"}}}))}fillName(){return z(this,void 0,void 0,(function*(){const{peerId:e}=this,[t]=yield Promise.all([(0,U.Z)({peerId:e,dialog:this.isDialog,withIcons:!this.threadId,threadId:this.threadId})]);return()=>{(0,d.Z)(this.name,t)}}))}fillRows(e){return z(this,void 0,void 0,(function*(){return Promise.all([this.fillName(),this.fillUsername(),this.fillUserPhone(),this.fillNotifications(),this.setMoreDetails(void 0,e),this.setPeerStatus(!0,!0)]).then((e=>()=>{e.forEach((e=>null==e?void 0:e()))}))}))}fillProfileElements(){return z(this,void 0,void 0,(function*(){if(!this.cleaned)return;this.cleaned=!1,this.cleanupHTML();const e=(0,n.Z)();this.middlewareHelper.get().onClean((()=>{e.reject()}));const t=yield Promise.all([this.setAvatar(!0),this.fillRows(e)]);return()=>{e.resolve(),t.forEach((e=>null==e?void 0:e()))}}))}_setMoreDetails(e,t){return z(this,void 0,void 0,(function*(){const i=this.getMiddlewarePromise();if(this.threadId&&(yield i(this.managers.appPeersManager.isForum(e)))){let t="https://t.me/";const s=(0,g.Z)(this.threadId),n=yield i(this.managers.appPeersManager.getPeerUsername(e));return t+=n?`${n}/${s}`:`c/${e.toChatId()}/${s}`,()=>{j(t,this.link)}}const s=[];if(s.push((()=>{this.bio.subtitle.replaceChildren((0,b.ag)(e.isUser()?"UserBio":"Info")),j(t.about?(0,y.ZP)(t.about):void 0,this.bio)})),!e.isUser()){const n=yield i(this.managers.appChatsManager.getChat(e.toChatId())),a=(0,v.Z)(n);let o;if(a.length)o=this.getUsernamesAlso(a),s.push((()=>j("https://t.me/"+a[0],this.link)));else{const e=t.exported_invite;"chatInviteExported"===(null==e?void 0:e._)&&s.push((()=>j(e.link,this.link)))}s.push((()=>this.link.subtitle.replaceChildren(o||(0,b.ag)("SetUrlPlaceholder"))))}const n=t.location;return"channelLocation"==(null==n?void 0:n._)&&s.push((()=>j(n.address,this.location))),this.setMoreDetailsTimeout=window.setTimeout((()=>this.setMoreDetails(!0)),6e4),()=>{s.forEach((e=>e()))}}))}setMoreDetails(e,t){return z(this,void 0,void 0,(function*(){this.clearSetMoreDetailsTimeout();const{peerId:i}=this,s=this.getMiddlewarePromise();if(!i||!this.canBeDetailed()||(yield s(this.managers.appPeersManager.isPeerRestricted(i))))return;const n=yield s(this.managers.acknowledged.appProfileManager.getProfileByPeerId(i,e)),a=s(n.result).then((e=>z(this,void 0,void 0,(function*(){if(!(yield s(this.managers.appPeersManager.isPeerRestricted(i))))return s(this._setMoreDetails(i,e))}))));if(n.cached&&t)return a;(t||Promise.resolve()).then((()=>a)).then((e=>{null==e||e()}))}))}getMiddlewarePromise(){return(0,f.Z)(this.middlewareHelper.get(),(0,h.Z)("MIDDLEWARE"))}setPeer(e,t){var i;this.peerId===e&&this.threadId===t||(null===(i=this.init)||void 0===i||i.call(this),this.peerId=e,this.threadId=t,this.middlewareHelper.clean(),this.cleaned=!0)}clearSetMoreDetailsTimeout(){void 0!==this.setMoreDetailsTimeout&&(clearTimeout(this.setMoreDetailsTimeout),this.setMoreDetailsTimeout=void 0)}destroy(){var e;this.peerId=this.threadId=void 0,this.clearSetMoreDetailsTimeout(),clearInterval(this.setPeerStatusInterval),null===(e=this.avatars)||void 0===e||e.cleanup(),this.middlewareHelper.destroy()}}},8842:(e,t,i)=>{"use strict";i.d(t,{Z:()=>g});var s=i(3512),n=i(2325),a=i(5565),o=i(1507),r=i(8456),d=i(130),l=i(5953),c=i(8115),h=i(493),u=(i(4755),i(5948));i(3541);function p(e,t,i,n,a){return o=this,r=void 0,l=function*(){const t=[],o=yield s.Z.managers.appPeersManager.getPeer(e);if(o.pFlags.verified&&!i&&t.push(function(){const e=document.createElement("span");e.classList.add("verified-icon","tgico");const t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttributeNS(null,"viewBox","0 0 26 26"),t.setAttributeNS(null,"width","26"),t.setAttributeNS(null,"height","26"),t.classList.add("verified-icon-svg");const i=document.createElementNS("http://www.w3.org/2000/svg","use");i.setAttributeNS(null,"href","#verified-icon-background"),i.classList.add("verified-icon-background");const s=document.createElementNS("http://www.w3.org/2000/svg","use");return s.setAttributeNS(null,"href","#verified-icon-check"),s.classList.add("verified-icon-check"),t.append(s,i),e.append(t),e}()),!o.pFlags.fake&&!o.pFlags.scam||n||t.push((0,u.Z)(o.pFlags.scam)),o.pFlags.premium&&!a){const e=o.emoji_status;e&&e._,t.push(function(){const e=document.createElement("span");return e.classList.add("premium-icon","tgico-star"),e}())}return t},new((d=void 0)||(d=Promise))((function(e,t){function i(e){try{n(l.next(e))}catch(e){t(e)}}function s(e){try{n(l.throw(e))}catch(e){t(e)}}function n(t){var n;t.done?e(t.value):(n=t.value,n instanceof d?n:new d((function(e){e(n)}))).then(i,s)}n((l=l.apply(o,r||[])).next())}));var o,r,d,l}var f=i(9345);const m=new WeakMap;s.Z.addEventListener("peer_title_edit",(({peerId:e,threadId:t})=>{let i=`.peer-title[data-peer-id="${e}"]`;t&&(i+=`[data-thread-id="${t}"]`),Array.from(document.querySelectorAll(i)).forEach((e=>{const t=m.get(e);null==t||t.update()}))}));class g{constructor(e){this.element=document.createElement("span"),this.element.classList.add("peer-title"),(0,d.m)(this.element),this.options={},e&&this.update(e),m.set(this.element,this)}setOptions(e){if(e){(0,l.Z)(this.options,e);for(const t in e){const i=e[t];"object"!=typeof i&&"function"!=typeof i&&(this.element.dataset[t]=i?""+("boolean"==typeof i?+i:i):"0")}}}setHasInner(e){this.hasInner!==e&&(this.hasInner=e,this.element.classList.toggle("with-icons",e))}update(e){var t,i,l,u,m,g,v,b;return m=this,g=void 0,b=function*(){this.setOptions(e);let m,g=this.options.fromName;if(void 0!==g)return void 0!==this.options.limitSymbols&&(g=(0,r.Z)(g,this.options.limitSymbols,this.options.limitSymbols)),void(0,d.Z)(this.element,(0,c.Z)(g));null!==(t=(u=this.options).peerId)&&void 0!==t||(u.peerId=o.NM);const{peerId:v,threadId:b}=this.options;if(v===s.Z.myId&&this.options.dialog)(0,a.Z)(this.element,(0,n.ag)(this.options.onlyFirstName?"Saved":"SavedMessages"));else{if(b){const[e,t]=yield Promise.all([s.Z.managers.dialogsStorage.getForumTopic(v,b),s.Z.managers.appPeersManager.isForum(v)]);if(!e&&t)return s.Z.managers.dialogsStorage.getForumTopicById(v,b).then((e=>{if(!e&&this.options.threadId===b)return this.options.threadId=void 0,void this.update({threadId:void 0});this.update()}),(()=>{this.options.threadId===b&&(this.options.threadId=void 0,this.update({threadId:void 0}))})),(0,d.Z)(this.element,(0,n.ag)("Loading")),void this.setHasInner(!1)}const e=b&&this.options.withIcons?s.Z.managers.dialogsStorage.getForumTopic(v,b).then((e=>{var t;return(0,f.e)(Object.assign(Object.assign({},null!==(t=this.options.wrapOptions)&&void 0!==t?t:{}),{topic:e}))})):void 0,[t,a,o]=yield Promise.all([(0,h.Z)(this.options),this.options.withIcons&&p(v,null===(i=this.options.wrapOptions)||void 0===i||i.middleware)||this.options.withPremiumIcon&&p(v,null===(l=this.options.wrapOptions)||void 0===l||l.middleware,!0,!0),e]);if((null==a?void 0:a.length)||o){const e=document.createElement("span");e.classList.add("peer-title-inner"),m=!0,(0,d.Z)(e,t);const i=document.createDocumentFragment();i.append(...[o,e,...null!=a?a:[]].filter(Boolean)),(0,d.Z)(this.element,i)}else(0,d.Z)(this.element,t)}this.setHasInner(m)},new((v=void 0)||(v=Promise))((function(e,t){function i(e){try{n(b.next(e))}catch(e){t(e)}}function s(e){try{n(b.throw(e))}catch(e){t(e)}}function n(t){var n;t.done?e(t.value):(n=t.value,n instanceof v?n:new v((function(e){e(n)}))).then(i,s)}n((b=b.apply(m,g||[])).next())}))}}},6765:(e,t,i)=>{"use strict";i.d(t,{Z:()=>d});var s=i(1168),n=i(2325),a=i(2738),o=i(8678),r=i(2312);class d extends s.Z{constructor(e={}){super("popup-avatar",{closable:!0,withConfirm:!0}),this.image=new Image,this.cropper={crop:()=>{},removeHandlers:()=>{}},this.h6=document.createElement("h6"),(0,n.$d)(this.h6,"Popup.Avatar.Title"),this.btnClose.classList.remove("btn-icon"),this.header.append(this.h6),this.cropContainer=document.createElement("div"),this.cropContainer.classList.add("crop"),this.cropContainer.append(this.image),e.isForum&&this.cropContainer.classList.add("is-forum"),this.input=document.createElement("input"),this.input.type="file",this.input.style.display="none",this.listenerSetter.add(this.input)("change",(e=>{const t=e.target.files[0];t&&(0,o.Z)(t).then((e=>{this.image=new Image,this.cropContainer.append(this.image),this.image.src=e,this.image.onload=()=>{this.show(),this.cropper=function(e,t){let i,s,n,a={},o=0,r=0,d=0,l=0,c=0;function h(){e.classList.add("crop-blur"),e.draggable=!1,n=new Image,n.src=e.src,n.draggable=!1,n.classList.add("crop-overlay-image"),t||(t=document.createElement("canvas")),i=document.createElement("div"),i.classList.add("crop-component"),s=document.createElement("div"),s.classList.add("crop-overlay");const a=document.createElement("div");a.classList.add("crop-overlay-color"),i.appendChild(s),e.parentNode.appendChild(i),i.appendChild(n),i.appendChild(e),i.appendChild(a),s.appendChild(n),n.style.maxWidth=e.width+"px",c=e.naturalWidth/e.offsetWidth;const o=e.offsetWidth/2-100,r=e.offsetHeight/2-100;u(200,200),p(o,r),f(o,r),s.addEventListener("mousedown",b,!1),s.addEventListener("touchstart",b,!1),s.addEventListener("wheel",v,!1),document.addEventListener("keypress",g,!1)}function u(e,t){d=e*c,l=t*c,s.style.width=e+"px",s.style.height=t+"px"}function p(e,t){r=t*c,o=e*c,n.style.top=-t+"px",n.style.left=-e+"px"}function f(e,t){s.style.top=t+"px",s.style.left=e+"px"}function m(e){e=e*Math.PI*2;let t,i,a,o,r=Math.floor(s.clientWidth+e),d=Math.floor(s.clientHeight+e),l=n.clientWidth,c=n.clientHeight;r<50||r>l||(t=s.offsetLeft-e/2,i=s.offsetTop-e/2,a=t+r,o=i+d,t<0&&(t=0),i<0&&(i=0),a>l||o>c||(u(r,r),p(t,i),f(t,i)))}function g(e){switch(e.preventDefault(),String.fromCharCode(e.charCode)){case"+":m(4);break;case"-":m(-4)}}function v(e){e.preventDefault(),m(e.deltaY>0?1:-1)}function b(e){e.preventDefault(),e.stopPropagation(),function(e){a.container_width=s.offsetWidth,a.container_height=s.offsetHeight,a.container_left=s.offsetLeft,a.container_top=s.offsetTop,a.mouse_x=(e.clientX||e.pageX||e.touches&&e.touches[0].clientX)+window.scrollX,a.mouse_y=(e.clientY||e.pageY||e.touches&&e.touches[0].clientY)+window.scrollY}(e),document.addEventListener("mousemove",w),document.addEventListener("touchmove",w),document.addEventListener("mouseup",y),document.addEventListener("touchend",y)}function y(e){e.preventDefault(),document.removeEventListener("mouseup",y),document.removeEventListener("touchend",y),document.removeEventListener("mousemove",w),document.removeEventListener("touchmove",w)}function w(e){let t,i,o,r,d={x:0,y:0};e.preventDefault(),e.stopPropagation(),d.x=e.pageX||e.touches&&e.touches[0].pageX,d.y=e.pageY||e.touches&&e.touches[0].pageY,t=d.x-(a.mouse_x-a.container_left),i=d.y-(a.mouse_y-a.container_top),o=s.offsetWidth,r=s.offsetHeight,t<0?t=0:t>n.offsetWidth-o&&(t=n.offsetWidth-o),i<0?i=0:i>n.offsetHeight-r&&(i=n.offsetHeight-r),p(t,i),f(t,i)}return e.complete?h():e.onload=h,{crop:function(){t.width=d,t.height=l,t.getContext("2d").drawImage(e,o,r,d,l,0,0,d,l)},removeHandlers:function(){s.removeEventListener("mousedown",b),s.removeEventListener("touchstart",b),s.removeEventListener("wheel",v),document.removeEventListener("mouseup",y),document.removeEventListener("touchend",y),document.removeEventListener("mousemove",w),document.removeEventListener("touchmove",w),document.removeEventListener("keypress",g),i.remove(),s.remove(),n.remove()}}}(this.image,this.canvas),this.input.value=""}}))}),!1),this.btnConfirm.className="btn-primary btn-color-primary btn-circle btn-crop btn-icon tgico-check z-depth-1",(0,a.fc)(this.btnConfirm,(()=>{this.cropper.crop(),this.hide(),this.canvas.toBlob((e=>{this.blob=e,this.darkenCanvas(),this.resolve()}),"image/jpeg",1)}),{listenerSetter:this.listenerSetter}),this.container.append(this.cropContainer,this.btnConfirm,this.input),this.addEventListener("closeAfterTimeout",(()=>{this.cropper.removeHandlers(),this.image&&this.image.remove()}))}resolve(){this.onCrop((()=>r.Z.upload(this.blob)))}open(e,t){this.canvas=e,this.onCrop=t,this.input.click()}darkenCanvas(){const e=this.canvas.getContext("2d");e.fillStyle="rgba(0, 0, 0, 0.3)",e.fillRect(0,0,this.canvas.width,this.canvas.height)}}},2986:(e,t,i)=>{"use strict";i.d(t,{Z:()=>d});var s=i(1168),n=i(2738),a=i(4755),o=i(2325),r=i(503);class d extends s.Z{constructor(e,t,i={}){if(super("popup-date-picker",Object.assign({body:!0,overlayClosable:!0,buttons:i.noButtons?[]:[{langKey:"JumpToDate",callback:()=>{this.onPick&&this.onPick(this.selectedDate.getTime()/1e3|0)}},{langKey:"Cancel",isCancel:!0}],title:!0},i)),this.onPick=t,this.options=i,this.onPrevClick=e=>{this.selectedMonth.setMonth(this.selectedMonth.getMonth()-1),this.setMonth(),this.selectedMonth.getTime()===this.minMonth.getTime()&&this.prevBtn.setAttribute("disabled","true"),this.nextBtn.removeAttribute("disabled")},this.onNextClick=e=>{this.selectedMonth.setMonth(this.selectedMonth.getMonth()+1),this.setMonth(),this.selectedMonth.getTime()===this.maxMonth.getTime()&&this.nextBtn.setAttribute("disabled","true"),this.prevBtn.removeAttribute("disabled")},this.onDateClick=e=>{const t=e.target;if(!t.dataset.timestamp)return;if(this.selectedEl){if(this.selectedEl===t)return;this.selectedEl.classList.remove("active")}this.selectedEl=t,t.classList.add("active");const i=+t.dataset.timestamp;this.selectedDate=new Date(i),this.setTitle(),this.setTimeTitle()},this.minDate=i.minDate||new Date("2013-08-01T00:00:00"),e<this.minDate&&e.setFullYear(this.minDate.getFullYear(),this.minDate.getMonth(),this.minDate.getDate()),this.controlsDiv=document.createElement("div"),this.controlsDiv.classList.add("date-picker-controls"),this.prevBtn=document.createElement("button"),this.prevBtn.classList.add("btn-icon","tgico-down","date-picker-prev"),(0,n.fc)(this.prevBtn,this.onPrevClick,{listenerSetter:this.listenerSetter}),this.nextBtn=document.createElement("button"),this.nextBtn.classList.add("btn-icon","tgico-down","date-picker-next"),(0,n.fc)(this.nextBtn,this.onNextClick,{listenerSetter:this.listenerSetter}),this.monthTitle=document.createElement("div"),this.monthTitle.classList.add("date-picker-month-title"),this.controlsDiv.append(this.prevBtn,this.monthTitle,this.nextBtn),this.monthsContainer=document.createElement("div"),this.monthsContainer.classList.add("date-picker-months"),(0,n.fc)(this.monthsContainer,this.onDateClick,{listenerSetter:this.listenerSetter}),this.body.append(this.controlsDiv,this.monthsContainer),i.withTime){this.timeDiv=document.createElement("div"),this.timeDiv.classList.add("date-picker-time");const t=document.createElement("div");t.classList.add("date-picker-time-delimiter"),t.append(":");const i=(e,t,i,s)=>{const n=""+e;this.listenerSetter.add(t.input)("input",(a=>{let o=t.value.replace(/\D/g,"");o.length>2?o=o.slice(0,2):(1===o.length&&+o[0]>+n[0]||2===o.length&&+o>e)&&(2===o.length&&s&&s(+o[1]),o="0"+o[0]),t.setValueSilently(o),i(o.length)}))};this.hoursInputField=new r.ZP({plainText:!0}),this.minutesInputField=new r.ZP({plainText:!0}),i(23,this.hoursInputField,(e=>{2===e&&this.minutesInputField.input.focus(),this.setTimeTitle()}),(e=>{this.minutesInputField.value=(e+this.minutesInputField.value).slice(0,2)})),i(59,this.minutesInputField,(e=>{e||this.hoursInputField.input.focus(),this.setTimeTitle()})),this.selectedDate=e,e.setMinutes(e.getMinutes()+10),this.hoursInputField.setValueSilently(("0"+e.getHours()).slice(-2)),this.minutesInputField.setValueSilently(("0"+e.getMinutes()).slice(-2)),e.setHours(0,0,0,0),this.timeDiv.append(this.hoursInputField.container,t,this.minutesInputField.container),(0,n.fc)(this.btnConfirm,(()=>{this.onPick&&(this.selectedDate.setHours(+this.hoursInputField.value||0,+this.minutesInputField.value||0,0,0),this.onPick(this.selectedDate.getTime()/1e3|0)),this.hide()}),{listenerSetter:this.listenerSetter}),this.body.append(this.timeDiv),this.prevBtn.classList.add("primary"),this.nextBtn.classList.add("primary")}const s=document.createElement("div");s.classList.add("popup-centerer"),s.append(this.container),this.element.append(s),e.setHours(0,0,0,0),this.selectedDate=e,this.maxDate=i.maxDate||new Date,this.maxDate.setHours(0,0,0,0),this.selectedMonth=new Date(this.selectedDate),this.selectedMonth.setDate(1),this.maxMonth=new Date(this.maxDate),this.maxMonth.setDate(1),this.minMonth=new Date(this.minDate),this.minMonth.setHours(0,0,0,0),this.minMonth.setDate(1),this.selectedMonth.getTime()===this.minMonth.getTime()&&this.prevBtn.setAttribute("disabled","true"),this.selectedMonth.getTime()===this.maxMonth.getTime()&&this.nextBtn.setAttribute("disabled","true"),i.noTitle&&(this.setTitle=()=>{}),this.setTimeTitle(),this.setTitle(),this.setMonth()}setTimeTitle(){if(this.btnConfirm&&this.selectedDate){let e;const t=[],i=new Date;i.setHours(0,0,0,0);const s={minute:"2-digit",hour:"2-digit"},n=new Date(this.selectedDate.getTime());if(n.setHours(+this.hoursInputField.value,+this.minutesInputField.value),this.selectedDate.getTime()===i.getTime())e="Schedule.SendToday";else{e="Schedule.SendDate";const s={month:"short",day:"numeric"};n.getFullYear()!==i.getFullYear()&&(s.year="numeric"),t.push(new o.ZP.IntlDateElement({date:n,options:s}).element)}t.push(new o.ZP.IntlDateElement({date:n,options:s}).element),this.btnConfirm.firstChild.replaceWith((0,o.ag)(e,t))}}setTitle(){this.title.textContent="",this.title.append(new o.ZP.IntlDateElement({date:this.selectedDate,options:{day:"numeric",month:"long",weekday:"short"}}).element)}renderElement(e,t=""){const i=document.createElement("button");return i.classList.add("btn-icon","date-picker-month-date"),e&&i.setAttribute("disabled","true"),t&&i.append(t),i}setMonth(){const e=new Date(this.selectedMonth),t={year:"numeric",month:this.timeDiv&&a.Z.isMobile?"short":"long"};this.monthTitle.textContent="",this.monthTitle.append(new o.ZP.IntlDateElement({date:e,options:t}).element),this.month&&this.month.remove(),this.month=document.createElement("div"),this.month.classList.add("date-picker-month");const i=new Date,s=i.getDay();1!==s&&i.setHours(-24*(s-1));for(let e=0;e<7;++e){const e=this.renderElement(!0,new o.ZP.IntlDateElement({date:i,options:{weekday:"narrow"}}).element);e.classList.remove("date-picker-month-date"),e.classList.add("date-picker-month-day"),this.month.append(e),i.setDate(i.getDate()+1)}let n=e.getDay()-1;-1===n&&(n=6);const r=new Date(e.getTime());r.setDate(r.getDate()-n-1);for(let e=0;e<n;++e)this.options.showOverflowMonths?(r.setDate(r.getDate()+1),this.month.append(this.renderElement(!0,""+r.getDate()))):this.month.append(this.renderElement(!0));do{const t=e.getDate(),i=this.renderElement(e>this.maxDate||e<this.minDate,""+t);i.dataset.timestamp=""+e.getTime(),e.getTime()===this.selectedDate.getTime()&&(this.selectedEl=i,i.classList.add("active")),this.month.append(i),e.setDate(t+1)}while(1!==e.getDate());const d=this.month.childElementCount%7;if(this.options.showOverflowMonths&&d)for(let t=d;t<7;++t)this.month.append(this.renderElement(!0,""+e.getDate())),e.setDate(e.getDate()+1);const l=Math.ceil(this.month.childElementCount/7);this.container.dataset.lines=""+l,this.monthsContainer.append(this.month)}}},6194:(e,t,i)=>{"use strict";i.d(t,{Z:()=>o});var s=i(1168),n=i(7362),a=i(8127);class o{constructor(e,t,i,s){this.peerId=e,this.peerType=t,this.onSelect=i,this.threadId=s,this.construct()}construct(){return e=this,t=void 0,o=function*(){let{peerId:e,peerType:t,onSelect:i,threadId:o}=this;const r=yield(0,n.Z)({peerId:e,threadId:o}),d=s.Z.MANAGERS;void 0===t&&(t=yield d.appPeersManager.getDialogType(e));const l=(t,s=g&&!!t.size)=>{let n=d.appChatsManager.leave(e.toChatId());s&&(n=n.then((()=>d.appMessagesManager.flushHistory(e)))),null==i||i(n)},c=t=>{let s;if(o)s=d.appMessagesManager.flushHistory(e,!1,!0,o);else if(e.isUser())s=d.appMessagesManager.flushHistory(e,!1,g?!!t.size:void 0);else{if(!t.size)return l(t);s=d.appChatsManager.delete(e.toChatId())}null==i||i(s)};let h,u,p,f,m,g;switch(t){case"channel":(yield d.appChatsManager.hasRights(e.toChatId(),"delete_chat"))?(h="ChannelDeleteMenu",p="AreYouSureDeleteAndExitChannel",m=[{langKey:"ChannelDeleteMenu",isDanger:!0,callback:c}],g=[{text:"DeleteChannelForAll"}]):(h="LeaveChannelMenu",p="ChannelLeaveAlertWithName",f=[r],m=[{langKey:"LeaveChannel",isDanger:!0,callback:l}]);break;case"chat":h="DeleteChatUser",p="AreYouSureDeleteThisChatWithUser",f=[r],m=[{langKey:"DeleteChatUser",isDanger:!0,callback:c}],g=[{text:"DeleteMessagesOptionAlso",textArgs:[yield(0,n.Z)({peerId:e})]}];break;case"saved":h="DeleteChatUser",p="AreYouSureDeleteThisChatSavedMessages",m=[{langKey:"DeleteChatUser",isDanger:!0,callback:c}];break;case"megagroup":case"group":o?(h="DeleteTopics",u=[1],p="DeleteSelectedTopic",f=[r],m=[{langKey:"Delete",isDanger:!0,callback:c}]):(yield d.appChatsManager.hasRights(e.toChatId(),"delete_chat"))?(h="DeleteMegaMenu",p="AreYouSureDeleteAndExit",m=[{langKey:"DeleteMegaMenu",isDanger:!0,callback:c}],g=[{text:"DeleteChat.DeleteGroupForAll"}]):(h="LeaveMegaMenu",p="AreYouSureDeleteAndExitName",f=[r],m=[{langKey:"DeleteChatUser",isDanger:!0,callback:e=>l(e,!0)}])}s.Z.createPopup(a.Z,"popup-delete-chat",{peerId:e,threadId:o,titleLangKey:h,titleLangArgs:u,descriptionLangKey:p,descriptionLangArgs:f,buttons:m,checkboxes:g}).show()},new((i=void 0)||(i=Promise))((function(s,n){function a(e){try{d(o.next(e))}catch(e){n(e)}}function r(e){try{d(o.throw(e))}catch(e){n(e)}}function d(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,r)}d((o=o.apply(e,t||[])).next())}));var e,t,i,o}}},5128:(e,t,i)=>{"use strict";i.d(t,{Z:()=>h});var s=i(3512),n=i(1168),a=i(8127),o=i(2325),r=i(7120),d=i(2353),l=i(7362),c=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class h{constructor(e,t,i,s,n){this.peerId=e,this.mids=t,this.type=i,this.onConfirm=s,this.threadId=n,this.construct()}construct(){return c(this,void 0,void 0,(function*(){let{peerId:e,mids:t,type:i,onConfirm:h,threadId:u}=this;const p=yield(0,l.Z)({peerId:e,threadId:u}),f=n.Z.MANAGERS;t=t.slice();const m=(s,n)=>{h&&h(),"scheduled"===i?f.appMessagesManager.deleteScheduledMessages(e,t):f.appMessagesManager.deleteMessages(e,t,!!s.size||n)},g=[{langKey:"Delete",isDanger:!0,callback:m}],v=[];let b,y,w,S;if(1===t.length?b="DeleteSingleMessagesTitle":(b="DeleteMessagesTitle",y=[(0,o.ag)("messages",[t.length])]),w=(yield f.appPeersManager.isMegagroup(e))?1===t.length?"AreYouSureDeleteSingleMessageMega":"AreYouSureDeleteFewMessagesMega":1===t.length?"AreYouSureDeleteSingleMessage":"AreYouSureDeleteFewMessages",e===s.Z.myId||"scheduled"===i);else if(e.isUser())v.push({text:"DeleteMessagesOptionAlso",textArgs:[p]});else{const i=yield f.appChatsManager.getChat(e.toChatId()),n=(0,r.Z)(i,"delete_messages");if("chat"===i._){const i=n?t.slice():yield(0,d.Z)(t,(t=>c(this,void 0,void 0,(function*(){return(yield f.appMessagesManager.getMessageByPeer(e,t)).fromId===s.Z.myId}))));i.length&&(i.length===t.length?v.push({text:"DeleteForAll"}):(v.push({text:"DeleteMessagesOption"}),w="DeleteMessagesTextGroup",S=[(0,o.ag)("messages",[i.length])]))}else g[0].callback=e=>m(e,!0)}(0,n.x)(g),n.Z.createPopup(a.Z,"popup-delete-chat",{peerId:e,threadId:u,titleLangKey:b,titleLangArgs:y,descriptionLangKey:w,descriptionLangArgs:S,buttons:g,checkboxes:v}).show()}))}}},4524:(e,t,i)=>{"use strict";i.d(t,{Z:()=>h});var s=i(7238),n=i(7030),a=i(3512),o=i(2796),r=i(2995),d=i(7530),l=i(1168),c=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class h extends r.Z{constructor(e,t,i=["send_plain"]){super({peerTypes:["dialogs","contacts"],onSelect:!e&&t?t:i=>c(this,void 0,void 0,(function*(){if(t){const e=t(i);e instanceof Promise&&(yield e)}if(i!==a.Z.myId)n.ZP.setInnerPeer({peerId:i}),n.ZP.chat.input.initMessagesForward(e);else{let t=0;for(const s in e){const n=e[s];t+=n.length,this.managers.appMessagesManager.forwardMessages(i,s.toPeerId(),n)}(0,o.bC)({langPackKey:t>0?"FwdMessagesToSavedMessages":"FwdMessageToSavedMessages"})}})),placeholder:"ShareModal.Search.ForwardPlaceholder",chatRightsActions:i,selfPresence:"ChatYourSelf"})}static create(...e){return c(this,void 0,void 0,(function*(){const[t]=e,i=Object.keys(t).map((e=>t[e].map((t=>a.Z.managers.appMessagesManager.getMessageByPeer(e.toPeerId(),t))))),n=yield Promise.all((0,s.Z)(i)),o=new Set;n.forEach((e=>{if(!e)return;const t=(0,d.Z)(e);let i;if(t)if("webPage"===t._)i="embed_links";else if("photo"===t._)i="send_photos";else if("game"===t._)i="send_games";else switch(t.type){case"audio":i="send_audios";break;case"gif":i="send_gifs";break;case"round":i="send_roundvideos";break;case"sticker":i="send_stickers";break;case"voice":i="send_voices";break;case"video":i="send_videos";break;default:i="send_docs"}else i=e.viaBotId?"send_inline":"send_plain";i&&o.add(i)})),l.Z.createPopup(h,e[0],e[1],Array.from(o))}))}}},1168:(e,t,i)=>{"use strict";i.d(t,{Z:()=>L,x:()=>E});var s=i(1405),n=i(5814),a=i(5824),o=i(2325),r=i(8497),d=i(8799),l=i(3699),c=i(2738),h=i(6299),u=i(3910),p=i(3241),f=i(6733),m=i(1655),g=i(3815),v=i(8805),b=i(3624),y=i(8115);const w=document.body;let S=w;const C=()=>{S=(0,f.W7)()||w,L.reAppend()};(0,f.Ms)(w,C);class L extends p.Z{constructor(e,t={}){if(super(!1),this.element=document.createElement("div"),this.container=document.createElement("div"),this.header=document.createElement("div"),this.title=document.createElement("div"),this.onEscape=()=>!0,this.hide=()=>{a.Z.backByItem(this.navigationItem)},this.element.classList.add("popup"),this.element.className="popup"+(e?" "+e:""),this.container.classList.add("popup-container","z-depth-1"),this.header.classList.add("popup-header"),(t.title||t.titleRaw)&&(this.title.classList.add("popup-title"),"string"==typeof t.title?(0,o.$d)(this.title,t.title):t.titleRaw&&this.title.append((0,y.Z)(t.titleRaw)),this.header.append(this.title)),this.middlewareHelper=(0,b.k)(),this.listenerSetter=new l.Z,this.managers=L.MANAGERS,this.confirmShortcutIsSendShortcut=t.confirmShortcutIsSendShortcut,t.closable&&(this.btnClose=document.createElement("span"),this.btnClose.classList.add("btn-icon","popup-close","tgico-close"),this.header.prepend(this.btnClose),(0,c.fc)(this.btnClose,this.hide,{listenerSetter:this.listenerSetter,once:!0})),this.withoutOverlay=t.withoutOverlay,this.withoutOverlay&&this.element.classList.add("no-overlay"),t.overlayClosable&&(0,c.fc)(this.element,(e=>{(0,r.Z)(e.target,"popup-container")||this.hide()}),{listenerSetter:this.listenerSetter}),t.withConfirm&&(this.btnConfirm=document.createElement("button"),this.btnConfirm.classList.add("btn-primary","btn-color-primary"),!0!==t.withConfirm&&this.btnConfirm.append((0,o.ag)(t.withConfirm)),this.header.append(this.btnConfirm),(0,s.Z)(this.btnConfirm)),this.container.append(this.header),t.body&&(this.body=document.createElement("div"),this.body.classList.add("popup-body"),this.container.append(this.body)),t.scrollable){const e=this.scrollable=new v.ZP(this.body);this.attachScrollableListeners(),this.body||this.container.insertBefore(e.container,this.header.nextSibling)}let i=this.btnConfirm;const n=this.buttons=t.buttons;if(null==n?void 0:n.length){const e=this.buttonsEl=document.createElement("div");e.classList.add("popup-buttons");const t=n.map((e=>{const t=document.createElement("button");return t.className="btn"+(e.isDanger?" danger":" primary"),e.noRipple||(0,s.Z)(t),e.text?t.textContent=e.text:t.append((0,o.ag)(e.langKey,e.langArgs)),(0,c.fc)(t,(()=>{var t;null===(t=e.callback)||void 0===t||t.call(e),this.destroy()}),{listenerSetter:this.listenerSetter,once:!0}),e.element=t}));if(!i&&2===n.length){const e=n.find((e=>!e.isCancel));e&&(i=e.element)}e.append(...t),this.container.append(e)}this.btnConfirmOnEnter=i,this.element.append(this.container),L.POPUPS.push(this)}attachScrollableListeners(e){return this.scrollable.attachBorderListeners(e)}onContentUpdate(){this.scrollable&&this.scrollable.onAdditionalScroll()}show(){this.navigationItem={type:"popup",onPop:()=>this.destroy(),onEscape:this.onEscape},a.Z.pushItem(this.navigationItem),(0,d.Z)(),S.append(this.element),this.element.offsetWidth,this.element.classList.add("active"),this.onContentUpdate(),this.withoutOverlay||(g.Z.isOverlayActive=!0,n.Z.checkAnimations2(!0)),setTimeout((()=>{this.element.classList.contains("active")&&this.listenerSetter.add(document.body)("keydown",(e=>{L.POPUPS[L.POPUPS.length-1]===this&&(this.confirmShortcutIsSendShortcut?(0,h.Z)(e):"Enter"===e.key)&&((0,c.tH)(this.btnConfirmOnEnter),(0,u.Z)(e))}))}),0)}destroy(){this.dispatchEvent("close"),this.element.classList.add("hiding"),this.element.classList.remove("active"),this.listenerSetter.removeAll(),this.middlewareHelper.destroy(),this.withoutOverlay||(g.Z.isOverlayActive=!1),a.Z.removeItem(this.navigationItem),this.navigationItem=void 0,(0,m.Z)(L.POPUPS,this),C(),setTimeout((()=>{var e;this.element.remove(),this.dispatchEvent("closeAfterTimeout"),this.cleanup(),null===(e=this.scrollable)||void 0===e||e.destroy(),this.withoutOverlay||n.Z.checkAnimations2(!1)}),150)}static reAppend(){this.POPUPS.forEach((e=>{const{element:t,container:i}=e,s=t.parentElement;s&&s!==S&&S!==i&&S.append(t)}))}static getPopups(e){return this.POPUPS.filter((t=>t instanceof e))}static createPopup(e,...t){return new e(...t)}}L.POPUPS=[];const E=e=>(e.find((e=>e.isCancel))||e.push({langKey:"Cancel",isCancel:!0}),e)},1842:(e,t,i)=>{"use strict";i.d(t,{Z:()=>f});var s=i(1168),n=i(130),a=i(2575),o=i(7030),r=i(2325),d=i(1507),l=i(8115),c=i(9331),h=i(9931),u=i(2796),p=i(9492);class f extends s.Z{constructor(e,t){super("popup-join-chat-invite",{closable:!0,overlayClosable:!0,body:!0,buttons:(0,s.x)([{langKey:t.pFlags.request_needed?"RequestJoin.Button":t.pFlags.broadcast?"JoinByPeekChannelTitle":"JoinByPeekGroupTitle",callback:()=>{this.managers.appChatsManager.importChatInvite(e).then((e=>{const t=e.toPeerId(!0);o.ZP.setInnerPeer({peerId:t})}),(e=>{"INVITE_REQUEST_SENT"===e.type&&(0,u.bC)({langPackKey:"RequestToJoinSent"})}))}}])}),this.hash=e,this.chatInvite=t,this.construct()}construct(){return e=this,t=void 0,s=function*(){this.header.remove();const{chatInvite:e,managers:t,hash:i}=this,s=new c.Z;s.classList.add("avatar-100"),s.isDialog=!1,"photo"===e.photo._?(e.photo=yield t.appPhotosManager.savePhoto(e.photo),(0,p.Z)({container:s,message:null,photo:e.photo,boxHeight:100,boxWidth:100,withoutPreloader:!0}),s.style.width=s.style.height=""):(0,h.Z)({div:s,peerId:d.NM,isDialog:!1,title:e.title});const o=document.createElement("div");o.classList.add("chat-title"),(0,n.Z)(o,(0,l.Z)(e.title));const u=e.pFlags.broadcast,f=(0,r.ag)(u?"Subscribers":"Members",[(0,a.Z)(e.participants_count)]);if(f.classList.add("chat-participants-count"),this.body.append(s,o,f),e.pFlags.request_needed){const e=document.createElement("div");(0,r.$d)(e,u?"RequestToJoinChannelDescription":"RequestToJoinGroupDescription"),e.classList.add("chat-participants-count","request-caption"),this.body.append(e)}this.show()},new((i=void 0)||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}));var e,t,i,s}}},3186:(e,t,i)=>{"use strict";i.d(t,{Z:()=>h});var s=i(5994),n=i(3035),a=i(7030),o=i(2325),r=i(3512),d=i(8127);const l={pin:{title:"LimitReached",description:"LimitReachedPinDialogs",descriptionPremium:"LimitReachedPinDialogsPremium",descriptionLocked:"LimitReachedPinDialogsLocked",icon:"limit_pin"},folders:{title:"LimitReached",description:"LimitReachedFolders",descriptionPremium:"LimitReachedFoldersPremium",descriptionLocked:"LimitReachedFoldersLocked",icon:"limit_folders"}};class c extends d.Z{constructor(e,t){super("popup-limit",{buttons:void 0===e.isPremium?[{langKey:"LimitReached.Ok",isCancel:!0}]:e.isPremium?[{langKey:"OK",isCancel:!0}]:[{langKey:"IncreaseLimit",callback:()=>{a.ZP.openPremiumBot()},noRipple:!0},{langKey:"Cancel",isCancel:!0}],descriptionLangKey:void 0===e.isPremium?t.descriptionLocked:e.isPremium?t.descriptionPremium:t.description,descriptionLangArgs:e.isPremium?[e.limitPremium]:[e.limit,e.limitPremium],titleLangKey:t.title});const i=void 0===e.isPremium;if(i)this.element.classList.add("is-locked");else if(e.isPremium)this.element.classList.add("is-premium");else{const e=this.buttons.find((e=>!e.isCancel));e.element.classList.add("popup-limit-button");const t=document.createElement("i");t.classList.add("popup-limit-button-icon","tgico-premium_double"),e.element.append(t)}const r=document.createElement("div");r.classList.add("popup-limit-line");const d=document.createElement("div");d.classList.add("popup-limit-hint");const l=document.createElement("span");if(l.classList.add("popup-limit-hint-icon","tgico-"+t.icon),d.append(l,""+(e.isPremium?e.limitPremium:e.limit)),r.append(d),!i){const t=document.createElement("div");t.classList.add("limit-line");const i=document.createElement("div");i.classList.add("limit-line-free");const s=document.createElement("div");s.classList.add("limit-line-premium"),t.append(i,s),(0,o.$d)(i,"LimitFree"),s.append((0,o.ag)("LimitPremium"),""+e.limitPremium),r.append(t)}this.container.insertBefore(r,this.description);const c=()=>{d.classList.add("active")};s.Z.isAvailable("animations")?(0,n.d1)().then(c):c()}}function h(e){return function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))}(this,void 0,void 0,(function*(){const t=l[e],[i,s,n]=yield Promise.all([r.Z.managers.apiManager.getAppConfig(),...[!1,!0].map((t=>r.Z.managers.apiManager.getLimit(e,t)))]),a=i.premium_purchase_blocked;new c({isPremium:a?void 0:r.Z.premium,limit:s,limitPremium:n},t).show()}))}},3897:(e,t,i)=>{"use strict";i.d(t,{Z:()=>d});var s=i(7298),n=i(1507),a=i(7479),o=i(8127);const r=[{value:3600,langPackKey:"ChatList.Mute.1Hour"},{value:14400,langPackKey:"ChatList.Mute.4Hours"},{value:28800,langPackKey:"ChatList.Mute.8Hours"},{value:86400,langPackKey:"ChatList.Mute.1Day"},{value:259200,langPackKey:"ChatList.Mute.3Days"},{value:-1,langPackKey:"ChatList.Mute.Forever",checked:!0}];class d extends o.Z{constructor(e,t){let i;super("popup-mute",{peerId:e,titleLangKey:"Notifications",buttons:[{langKey:"ChatList.Context.Mute",callback:()=>{this.managers.appMessagesManager.mutePeer({peerId:e,muteUntil:-1===i?n.rU:(0,s.Z)(!0)+i,threadId:t})}}],body:!0});const o=(0,a.ZC)(r,(e=>{i=+e}));this.body.append(o),this.show()}}},805:(e,t,i)=>{"use strict";i.d(t,{Z:()=>H,Y:()=>U});var s=i(1168),n=i(2796),a=i(6676),o=i(9405),r=i(7814);function d(e){let t,i;return e instanceof HTMLVideoElement?(t=e.videoWidth,i=e.videoHeight):(t=e.naturalWidth,i=e.naturalHeight),(0,r.Z)({media:e,mediaSize:(0,o.C)(t,i),boxSize:(0,o.C)(320,240),quality:.9})}var l=i(2325),c=i(9897),h=i(2398),u=i(2738),p=i(2341);function f(e){const t=e.src;return fetch(t).then((e=>e.arrayBuffer())).then((e=>{const t=new Uint8Array(e);let i=0;for(let e=0,s=t.length;e<s;++e)if(33==t[e]&&249==t[e+1]&&4==t[e+2]&&0==t[e+7]){const s=t[e+5]<<8|255&t[e+4];i+=s<2?10:s}return i/1e3}))}var m=i(5565),g=i(7660),v=i(2635),b=i(925),y=i(3855),w=i(1507),S=i(296),C=i(4531),L=i(8497),E=i(6131),I=i(3035),P=i(8027),Z=i(4059),M=i(6740),k=i(5322),T=i(54),x=i(9496),A=i(1174),_=i(554),F=i(3512),D=i(8928);const R=new Set(["audio/mpeg","audio/aac","audio/wav"]);var B=i(5994),N=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};let O;function U(){return O}class H extends s.Z{constructor(e,t,i,s){super("popup-send-photo popup-new-media",{closable:!0,withConfirm:"Modal.Send",confirmShortcutIsSendShortcut:!0,body:!0,title:!0,scrollable:!0}),this.chat=e,this.files=t,this.ignoreInputValue=s,this.onScroll=()=>{const{input:e}=this.messageInputField;this.scrollable.onAdditionalScroll(),e.scrollTop>0&&e.scrollHeight>130&&this.scrollable.container.classList.remove("scrolled-bottom")},this.onKeyDown=e=>{const t=e.target,{input:i}=this.messageInputField;if(t!==i){if("INPUT"===t.tagName||t.isContentEditable)return;i.focus(),(0,h.Z)(i)}},this.attachFile=e=>{const t=this.willAttach,i=this.shouldCompress(e.type),s=document.createElement("div");s.classList.add("popup-item");const n={file:e};(0,P.Z)(n,["scaledBlob","middlewareHelper","itemDiv","mediaSpoiler"]),n.middlewareHelper=this.middlewareHelper.get().create(),n.itemDiv=s;const a=i?this.attachMedia(n):this.attachDocument(n);return t.sendFileDetails.push(n),a.catch((e=>{s.style.backgroundColor="#000",console.error("error rendering file",e)}))},this.animationGroup="",this.construct(i)}static canSend(e,t){return N(this,void 0,void 0,(function*(){const i=["send_photos","send_videos","send_docs","send_audios","send_gifs"],s=i.map((i=>!(e.isAnyChat()&&!t)||F.Z.managers.appChatsManager.hasRights(e.toChatId(),i))),n={},a=yield Promise.all(s);return i.forEach(((e,t)=>{n[e]=a[t]})),n}))}construct(e){return N(this,void 0,void 0,(function*(){this.willAttach={type:e,sendFileDetails:[],group:!0};const t=yield this.managers.apiManager.getLimit("caption");this.captionLengthMax=t;const i=yield H.canSend(this.chat.peerId,!0),s=i.send_photos,n=i.send_videos,o=i.send_docs;(0,u.fc)(this.btnConfirm,(()=>this.send()),{listenerSetter:this.listenerSetter});const r=yield(0,k.Z)({listenerSetter:this.listenerSetter,direction:"bottom-left",buttons:[{icon:"image",text:"Popup.Attach.AsMedia",onClick:()=>this.changeType("media"),verify:()=>{if(!this.hasAnyMedia()||"document"!==this.willAttach.type)return!1;if(!s&&!n)return!1;if(!s||!n){const e=s?A.Z:_.Z,{media:t,files:i}=this.partition(e);if(i.length)return!1}return!0}},{icon:"document",text:"SendAsFile",onClick:()=>this.changeType("document"),verify:()=>1===this.files.length&&"document"!==this.willAttach.type&&o},{icon:"document",text:"SendAsFiles",onClick:()=>this.changeType("document"),verify:()=>this.files.length>1&&"document"!==this.willAttach.type&&o},{icon:"groupmedia",text:"Popup.Attach.GroupMedia",onClick:()=>this.changeGroup(!0),verify:()=>!this.willAttach.group&&this.canGroupSomething()},{icon:"groupmediaoff",text:"Popup.Attach.UngroupMedia",onClick:()=>this.changeGroup(!1),verify:()=>this.willAttach.group&&this.canGroupSomething()},{icon:"mediaspoiler",text:"EnablePhotoSpoiler",onClick:()=>this.changeSpoilers(!0),verify:()=>this.canToggleSpoilers(!0,!0)},{icon:"mediaspoiler",text:"Popup.Attach.EnableSpoilers",onClick:()=>this.changeSpoilers(!0),verify:()=>this.canToggleSpoilers(!0,!1)},{icon:"mediaspoileroff",text:"DisablePhotoSpoiler",onClick:()=>this.changeSpoilers(!1),verify:()=>this.canToggleSpoilers(!1,!0)},{icon:"mediaspoileroff",text:"Popup.Attach.RemoveSpoilers",onClick:()=>this.changeSpoilers(!1),verify:()=>this.canToggleSpoilers(!1,!1)}]});this.header.append(r),this.btnConfirm.remove(),this.mediaContainer=document.createElement("div"),this.mediaContainer.classList.add("popup-photo"),this.scrollable.container.append(this.mediaContainer);const d=this.inputContainer=document.createElement("div");d.classList.add("popup-input-container");const l=document.createElement("div");let c,h,p;if(l.classList.add("popup-input-inputs","input-message-container"),this.messageInputField=new x.Z({placeholder:"PreviewSender.CaptionPlaceholder",name:"message",withLinebreaks:!0,maxLength:this.captionLengthMax}),this.listenerSetter.add(this.scrollable.container)("scroll",this.onScroll),this.listenerSetter.add(this.messageInputField.input)("scroll",this.onScroll),this.messageInputField.input.classList.replace("input-field-input","input-message-input"),this.messageInputField.inputFake.classList.replace("input-field-input","input-message-input"),l.append(this.messageInputField.input,this.messageInputField.inputFake),d.append(l,this.btnConfirm),this.ignoreInputValue||(this.messageInputField.value=this.wasInputValue=this.chat.input.messageInputField.input.innerHTML,this.chat.input.messageInputField.value=""),this.container.append(d),this.attachFiles(),this.addEventListener("close",(()=>{this.files.length=0,this.willAttach.sendFileDetails.length=0,O===this&&(O=void 0)})),(0,C.Z)({buttons:[{icon:"mediaspoiler",text:"EnablePhotoSpoiler",onClick:()=>{this.applyMediaSpoiler(p)},verify:()=>h&&!p.mediaSpoiler},{icon:"mediaspoileroff",text:"DisablePhotoSpoiler",onClick:()=>{this.removeMediaSpoiler(p)},verify:()=>!(!h||!p.mediaSpoiler)}],listenTo:this.mediaContainer,listenerSetter:this.listenerSetter,findElement:e=>(c=(0,L.Z)(e.target,"popup-item"),h=c.classList.contains("popup-item-media"),p=this.willAttach.sendFileDetails.find((e=>e.itemDiv===c)),c)}),"scheduled"!==this.chat.type){const e=new a.Z({onSilentClick:()=>{this.chat.input.sendSilent=!0,this.send()},onScheduleClick:()=>{this.chat.input.scheduleSending((()=>{this.send()}))},openSide:"top-left",onContextElement:this.btnConfirm,listenerSetter:this.listenerSetter});e.setPeerId(this.chat.peerId),this.container.append(e.sendMenu)}O=this}))}applyMediaSpoiler(e,t){return N(this,void 0,void 0,(function*(){const i=e.middlewareHelper.get(),{width:s,height:n}=e.itemDiv.style;let a,d;if(e.itemDiv.classList.contains("album-item")){const{width:t,height:i}=e.itemDiv.parentElement.style,o=parseInt(t),r=parseInt(i);a=+s.slice(0,-1)/100*o,d=+n.slice(0,-1)/100*r}else a=parseInt(s),d=parseInt(n);const{url:l}=yield(0,r.Z)({media:e.itemDiv.firstElementChild,boxSize:(0,o.C)(40,40),mediaSize:(0,o.C)(a,d),toDataURL:!0,quality:.2}),c=(0,Z.o)(l),h={_:"photoStrippedSize",bytes:c,type:"i"};e.strippedBytes=c;const u={_:"photo",sizes:[h],id:0,access_hash:0,date:0,dc_id:0,file_reference:[],pFlags:{}},p=yield(0,E.ZP)({middleware:i,width:a,height:d,animationGroup:this.animationGroup,media:u});i()&&(t||p.classList.add("is-revealing"),e.mediaSpoiler=p,e.itemDiv.append(p),yield(0,I.d1)(),i()&&(0,E.MR)({mediaSpoiler:p,reveal:!1}))}))}removeMediaSpoiler(e){(0,E.MR)({mediaSpoiler:e.mediaSpoiler,reveal:!0,destroyAfter:!0}),e.mediaSpoiler=void 0}appendDrops(e){this.body.append(e)}get type(){return this.willAttach.type}set type(e){this.willAttach.type=e}partition(e=p.Z){const[t,i]=(0,T.Z)(this.willAttach.sendFileDetails,(t=>e.has(t.file.type)));return{media:t,files:i}}mediaCount(){return this.partition().media.length}hasAnyMedia(){return this.mediaCount()>0}canGroupSomething(){const{media:e,files:t}=this.partition();return e.length>1||t.length>1}canToggleSpoilers(e,t){let i="media"===this.willAttach.type&&this.hasAnyMedia();if(t&&i&&(i=1===this.files.length),i){const s=this.willAttach.sendFileDetails.filter((e=>p.Z.has(e.file.type))),n=s.filter((e=>e.mediaSpoiler));i=!!t||s.length>1,i&&(i=e?s.length!==n.length:s.length===n.length)}return i}changeType(e){this.willAttach.type=e,this.attachFiles()}changeGroup(e){this.willAttach.group=e,this.attachFiles()}changeSpoilers(e){this.partition().media.forEach((t=>{e&&!t.mediaSpoiler?this.applyMediaSpoiler(t):!e&&t.mediaSpoiler&&this.removeMediaSpoiler(t)}))}addFiles(e){const t=e.filter((e=>!this.files.find((t=>t.lastModified===e.lastModified&&t.name===e.name&&t.size===e.size))));t.length&&(this.files.push(...t),this.attachFiles())}send(e=!1){return N(this,void 0,void 0,(function*(){let t=this.messageInputField.value;if(t.length>this.captionLengthMax)return void(0,n.Am)(l.ZP.format("Error.PreviewSender.CaptionTooLong",!0));const{peerId:i,input:s}=this.chat,a=yield H.canSend(i),o=this.willAttach;o.isMedia="media"===o.type||void 0;const{sendFileDetails:r,isMedia:d}=o;let c=!1;if(this.iterate((e=>{if(c)return;const t=e.map((e=>{const t=[[R,"GlobalAttachAudioRestricted","send_audios"],[()=>!p.Z.has(e.file.type),"GlobalAttachDocumentsRestricted","send_docs"]];d&&t.unshift([A.Z,"GlobalAttachPhotoRestricted","send_photos"],[()=>_.Z.has(e.file.type)&&e.noSound,"GlobalAttachGifRestricted","send_gifs"],[_.Z,"GlobalAttachVideoRestricted","send_videos"]);const i=t.find((([t])=>"function"==typeof t?t():t.has(e.file.type)));return i?a[i[2]]?void 0:i[1]:d||a.send_docs?void 0:"GlobalAttachDocumentsRestricted"})).find((e=>"string"==typeof e));t&&((0,n.bC)({langPackKey:t}),B.Z.isAvailable("animations")&&(0,D.Z)(this.body)),c||(c=!!t)})),c)return;if("scheduled"===this.chat.type&&!e)return void this.chat.input.scheduleSending((()=>{this.send(!0)}));const{length:h}=r,u=this.chat.getMessageSendingParams();this.iterate((e=>{t&&e.length!==h&&(this.managers.appMessagesManager.sendText(i,t,Object.assign(Object.assign({},u),{clearDraft:!0})),t=void 0);const s=e.map((e=>Object.assign(Object.assign({},e),{file:e.scaledBlob||e.file,spoiler:!!e.mediaSpoiler}))),n=Object.assign(Object.assign({},o),{sendFileDetails:s});this.managers.appMessagesManager.sendAlbum(i,Object.assign(Object.assign(Object.assign({},u),{caption:t,isMedia:d,clearDraft:!0}),n)),t=void 0})),s.replyToMsgId=this.chat.threadId,s.onMessageSent(),this.wasInputValue=void 0,this.hide()}))}modifyMimeTypeForTelegram(e){return"image/webp"===e?"image/jpeg":e}scaleImageForTelegram(e,t,i){return N(this,void 0,void 0,(function*(){const s=2560;let n,a=e.src;if("image/gif"!==t&&(Math.max(e.naturalWidth,e.naturalHeight)>s||i&&"image/webp"===t)){const{blob:i}=yield(0,r.Z)({media:e,boxSize:(0,o.C)(s,s),mediaSize:(0,o.C)(e.naturalWidth,e.naturalHeight),mimeType:this.modifyMimeTypeForTelegram(t)});n=i,URL.revokeObjectURL(a),a=yield y.Z.invoke("createObjectURL",i),yield(0,M.cj)(e,a)}return n&&{url:a,blob:n}}))}attachMedia(e){return N(this,void 0,void 0,(function*(){const{itemDiv:t}=e;t.classList.add("popup-item-media");const i=e.file;if(i.type.startsWith("video/")){const s=(0,g.Z)();let n;s.src=e.objectURL=yield y.Z.invoke("createObjectURL",i),s.autoplay=!0,s.controls=!1,s.muted=!0,s.addEventListener("timeupdate",(()=>{s.pause()}),{once:!0}),t.append(s);try{yield(0,b.Z)(s)}catch(e){n=e}if(e.width=s.videoWidth,e.height=s.videoHeight,e.duration=Math.floor(s.duration),n)throw n;const a=s.webkitAudioDecodedByteCount;void 0!==a&&(e.noSound=!a);const o=yield function(e){return new Promise(((t,i)=>{e.onseeked=()=>{e.onseeked=()=>{d(e).then(t),e.onseeked=void 0},e.currentTime=0},e.onerror=i,e.currentTime=Math.min(e.duration,1)}))}(s);e.thumb=Object.assign({url:yield y.Z.invoke("createObjectURL",o.blob)},o)}else{const s=new Image;t.append(s);const n=e.objectURL=yield y.Z.invoke("createObjectURL",i);yield(0,M.cj)(s,n);const a=e.file.type,o=yield this.scaleImageForTelegram(s,a,!0);if(o&&(e.objectURL=o.url,e.scaledBlob=o.blob),e.width=s.naturalWidth,e.height=s.naturalHeight,"image/gif"===i.type)return e.noSound=!0,Promise.all([f(s).then((t=>{e.duration=Math.ceil(t)})),d(s).then((t=>N(this,void 0,void 0,(function*(){e.thumb=Object.assign({url:yield y.Z.invoke("createObjectURL",t.blob)},t)}))))]).then((()=>{}))}}))}attachDocument(e){return N(this,void 0,void 0,(function*(){const{itemDiv:t}=e;t.classList.add("popup-item-document");const i=e.file,s=i.type.startsWith("image/"),n=R.has(i.type);(s||n||i.size<2e7)&&(e.objectURL||(e.objectURL=yield y.Z.invoke("createObjectURL",i)));const a=[];let o;if(s&&e.objectURL){o=new Image,yield(0,M.cj)(o,e.objectURL);const t=yield this.scaleImageForTelegram(o,e.file.type);t&&(e.objectURL=t.url)}if(n&&e.objectURL)try{const t=new Audio;t.src=e.objectURL,t.muted=!0,t.autoplay=!0,yield(0,b.Z)(t),e.duration=t.duration,a.push({_:"documentAttributeAudio",duration:e.duration,pFlags:{}})}catch(e){console.error("audio loading error",e)}const r={_:"document",file:i,file_name:i.name||"",size:i.size,type:n?"audio":s?"photo":void 0,access_hash:0,attributes:a,date:0,dc_id:0,file_reference:[],id:0,pFlags:{},duration:e.duration};let d;e.objectURL&&(d={url:e.objectURL,downloaded:i.size,type:w.Pt});const l=yield(0,S.Z)({message:{_:"message",pFlags:{is_outgoing:!0},mid:0,peerId:0,media:{_:"messageMediaDocument",document:r}},cacheContext:d});s&&(e.width=o.naturalWidth,e.height=o.naturalHeight),t.append(l)}))}shouldCompress(e){return"media"===this.willAttach.type&&p.Z.has(e)}onRender(){this.element.classList.contains("active")||(this.listenerSetter.add(document.body)("keydown",this.onKeyDown),!this.ignoreInputValue&&this.addEventListener("close",(()=>{this.wasInputValue&&(this.chat.input.messageInputField.value=this.wasInputValue)})),this.show())}setTitle(){const{willAttach:e,title:t,files:i}=this;let s;const n=[];if("document"===e.type)s="PreviewSender.SendFile",n.push(i.length);else{let e=0,t=0,a=0;i.forEach((i=>{i.type.startsWith("image/")?++e:i.type.startsWith("video/")?++t:++a})),[e,t,a].filter((e=>e>0)).length>1?(s="PreviewSender.SendFile",n.push(i.length)):e?(s="PreviewSender.SendPhoto",n.push(e)):t&&(s="PreviewSender.SendVideo",n.push(t))}(0,m.Z)(t,(0,l.ag)(s,n))}appendMediaToContainer(e){if(this.shouldCompress(e.file.type)){const t=(0,c.Z)(e.width,e.height,384,320);e.itemDiv.style.width=t.width+"px",e.itemDiv.style.height=t.height+"px"}this.mediaContainer.append(e.itemDiv)}iterate(e){const{sendFileDetails:t}=this.willAttach;if(!this.willAttach.group)return void t.forEach((t=>e([t])));const i=t.length;for(let s=0;s<i;){const n=t[s].file.type;let a=0;for(;a<10&&s<i;++s,++a){const e=t[s].file.type;if(this.shouldCompress(n)!==this.shouldCompress(e))break}e(t.slice(s-a,s))}}attachFiles(){const{files:e,willAttach:t,mediaContainer:i}=this,s=t.sendFileDetails.splice(0,t.sendFileDetails.length);s.forEach((e=>{e.middlewareHelper.destroy()}));const n=e.map((e=>this.attachFile(e)));Promise.all(n).then((()=>{i.replaceChildren(),e.length&&(this.setTitle(),this.iterate((e=>{const t=this.shouldCompress(e[0].file.type);if(t&&e.length>1){const t=document.createElement("div");t.classList.add("popup-item-album","popup-item"),t.append(...e.map((e=>e.itemDiv))),(0,v.Z)({container:t,items:e.map((e=>({w:e.width,h:e.height}))),maxWidth:384,minWidth:100,spacing:4}),i.append(t)}else e.forEach((e=>{this.appendMediaToContainer(e)}));t&&e.forEach((e=>{const t=s.find((t=>t.file===e.file));t&&t.mediaSpoiler&&this.applyMediaSpoiler(e,!0)}))})))})).then((()=>{this.onRender(),this.onScroll()}))}}window.PopupNewMedia=H},8683:(e,t,i)=>{"use strict";i.d(t,{BE:()=>Re,ZP:()=>Be,LI:()=>De});var s=i(1168),n=i(7445),a=i(3189),o=i(1470),r=i(8097);const d=function(e){const t={},i={};return s=>{var n,a;const o="_"+s;return null!==(n=(a="string"==typeof s?t:i)[o])&&void 0!==n?n:a[o]=e(s)}};function l(e){return e.replace(/\D/g,"")}const c={visa:/^4/,mastercard:/^(51|52|53|54|55|222|23|24|25|26|27)/,amex:/^(34|37)/,discover:/^(60|64|65)/,diners:/^(30|38|39)/,diners14:/^(36)/,jcb:/^(35)/,unionpay:/^(62[0-6,8-9]|627[0-6,8-9]|6277[0-7,9]|62778[1-9]|81)/,elo:/^(5067|509|636368|627780)/,mir:/^(220[0-4])/},h={visa:{minLength:16,maxLength:16,cvcMaxLength:3,cvcMinLength:null},mastercard:{minLength:16,maxLength:16,cvcMaxLength:3,cvcMinLength:null},amex:{minLength:15,maxLength:15,cvcMaxLength:4,cvcMinLength:3},unionpay:{minLength:13,maxLength:19,cvcMaxLength:3,cvcMinLength:null},diners:{minLength:16,maxLength:16,cvcMaxLength:3,cvcMinLength:null},diners14:{minLength:14,maxLength:14,cvcMaxLength:3,cvcMinLength:null},discover:{minLength:16,maxLength:16,cvcMaxLength:3,cvcMinLength:null},jcb:{minLength:16,maxLength:16,cvcMaxLength:3,cvcMinLength:null},elo:{minLength:16,maxLength:16,cvcMaxLength:3,cvcMinLength:null},mir:{minLength:16,maxLength:16,cvcMaxLength:3,cvcMinLength:null},unknown:{minLength:16,maxLength:16,cvcMaxLength:4,cvcMinLength:3}},u=d(((e="")=>{const t=Object.keys(c),i=l(e);let s,n=0;return t.forEach((e=>{const t=c[e],a=i.match(t);if(a){const t=a[0];t&&t.length>n&&(s=e,n=t.length)}})),s||"unknown"}));function p(e=""){return"diners14"===(t=u(e))?"diners":t;var t}var f=i(2738),m=i(5975),g=i(8497),v=i(2398),b=i(6740),y=i(5565),w=i(130),S=i(1656),C=i(6272),L=i(5180),E=i(286),I=i(7298),P=i(2325),Z=i(8115),M=i(5400),k=i(3512),T=i(9331),x=i(4494),A=i(9807),_=i(8842),F=i(279),D=i(7479),R=i(2796),B=i(7362),N=i(9492),O=i(4762);function U(e,t,i){const s=new Array(e);return s.fill(t),i?s.map(i):s}const H="".charCodeAt(0)-"0".charCodeAt(0),z=/[-]/g;function j(e){return String.fromCharCode(e.charCodeAt(0)-H)}function G(e){return e.replace(z,j)}function V(e,t){return{type:"optional",result:e,consumed:t}}function K(e,t,i){return{type:"required",result:e,consumed:t,partial:i}}function W(e,t){return i=>{const s=new RegExp("^".concat(e.source.replace(/^\^/,""))),n=i.match(s),a=t?V:K;if(n){const e=n[0];return a(e,n.index+e.length)}return a("",i.length)}}const $=W(/1[0-2]|0?[1-9]|0/),q={digit:function(e){return W(/[0-9]/)(G(e))},capitalCharacter:function(e){const t=W(/\w/)(e);return t.result?K(t.result.toUpperCase(),t.consumed):t},month:e=>{const t=$(G(e)),i=l(t.result);return["0","1"].includes(t.result)&&1===e.length||"0"===t.result&&e.length>=2?K(t.result,e.length,!0):K(1===i.length?"0"+i:i,t.consumed)},formattingCharacter:e=>t=>{const i=e===t[0]?1:0;return function(e,t){return{type:"formatting",result:e,consumed:t}}(e,i)},optionalPattern:e=>t=>{const i=W(e,!0)(t);return i.result?i:V("",0)}},Y=q.digit,Q=q.capitalCharacter,X=q.formattingCharacter(" "),J=q.optionalPattern(/\d\d/),ee=[Y,Y,Y,Y,X,Y,Y,Y,Y,Y,Y,X,Y,Y,Y,Y,Y],te=[Y,Y,Y,Y,X,Y,Y,Y,Y,Y,Y,X,Y,Y,Y,Y],ie=new Set(["DZ","AR","AM","AU","AT","AZ","PT","BD","BY","BE","BA","BR","BN","BG","CA","IC","CN","CO","HR","CY","CZ","DK","EC","GB","EE","FO","FI","FR","GE","DE","GR","GL","GU","GG","NL","HU","IN","ID","IL","IT","JP","JE","KZ","KR","FM","KG","LV","LI","LT","LU","MK","MG","PT","MY","MH","MQ","YT","MX","MN","ME","NL","NZ","GB","NO","PK","PH","PL","FM","PT","PR","RE","RU","SA","SF","RS","SG","SK","SI","ZA","ES","LK","SX","VI","VI","SE","CH","TW","TJ","TH","TU","TN","TR","TM","VI","UA","GB","US","UY","UZ","VA","VN","GB","FM"]),se=d((e=>{const t=[];for(let i=0,s=0;i<e;)4===s?(t.push(X),s=0):(t.push(Y),++i,++s);return t})),ne={cardNumber:function(e){const t=u(e);if("amex"===t)return ee;if("diners14"===t)return te;const{minLength:i,maxLength:s}=h[t],n=l(e).length,a=Math.min(Math.max(i,n),s);return se(a)},cardExpiry:()=>[q.month,q.formattingCharacter("/"),Y,Y,J],cardCvc:e=>ne.cardCvcFromBrand(u(e)),cardCvcFromBrand:d((e=>{const t=h[e],{cvcMinLength:i,cvcMaxLength:s}=t,n=U(i||s,Y);if(i&&i<s){const e=s-i,t=q.optionalPattern(/\d/);e&&n.push(...U(e,t))}return n})),postalCodeFromCountry:d((e=>{switch(e){case"US":return U(5,Y);case"CA":return O.IS_ANDROID?null:[Q,Q,Q,X,Q,Q,Q];default:const t=U(10,q.optionalPattern(/\d/));return ie.has(e)&&(t[0]=Y),t}}))},ae=ne;function oe(e){return(0,o.Z)(e.map((e=>e.length)),0)}var re=i(1564);const de=new RegExp(re.Z,"g");function le(e){return e?{type:"invalid",code:e}:null}function ce(e,t={}){const{sanitized:i,minLength:s}=function(e){const t=l(e),i=u(e);return{sanitized:t,brand:i,minLength:h[i].minLength}}(e);return function(e,t,i){return e.length>=t?function(e){const t="0".charCodeAt(0),i=e.length%2;let s=0;for(let n=e.length-1;n>=0;--n){const a=i===n%2;let o=e.charCodeAt(n)-t;a&&(o*=2),o>9&&(o-=9),s+=o}return!(s%10)}(e)||"mir"===u(e)?null:le("invalid"):i?null:le("incomplete")}(i,s,t.ignoreIncomplete)}function he(e,t={}){const i=e.replace(de,"").split(/ ?\/ ?/),[s,n=""]=i,[a,o]=[s,n].map((e=>+e)),r=2===n.length?o%100:o;return n.length<2||3===n.length?t.ignoreIncomplete?null:le("incomplete"):le(function(e,t,i){const s=new Date(Date.now()),n=e<100?s.getFullYear()%100:s.getFullYear(),a=s.getMonth()+1;return isNaN(e)||isNaN(t)?(null==i?void 0:i.ignoreIncomplete)?null:"incomplete":e-n<0?"invalid_expiry_year_past":e-n>50?"invalid_expiry_year":!(e-n)&&t<a?"invalid_expiry_month_past":null}(r,a,t))}var ue=i(319),pe=i(5592),fe=i(5431),me=i(503),ge=i(7030),ve=i(1439);function be(e){const t=new ve.Z(Object.assign(Object.assign({},e),{sandbox:"allow-forms allow-scripts allow-same-origin allow-modals"})),{iframe:i}=t;return i.allow="payment",i.classList.add("payment-verification"),t}class ye extends s.Z{constructor(e,t){super("popup-payment popup-payment-verification",{closable:!0,overlayClosable:!0,body:!0,title:"Checkout.WebConfirmation.Title"}),this.url=e,this.openPathAfter=t,this.d()}d(){const e=this.telegramWebView=be({url:this.url});e.addEventListener("web_app_open_tg_link",(e=>{this.dispatchEvent("finish"),this.hide(),this.openPathAfter&&ge.ZP.openUrl("https://t.me"+e.path_full)})),this.body.append(e.iframe),this.show(),e.onMount()}destroy(){return this.telegramWebView.destroy(),super.destroy()}}var we=i(6830),Se=i(5029);class Ce extends me.ZP{constructor(e){super(e),this.options=e,this.onKeyDown=e=>{var t,i;this.lastKeyDown=e.key,null===(i=(t=this.options).onKeyDown)||void 0===i||i.call(t,e)},this.onInput=()=>{var e,t;const i=this.value,s="Backspace"===this.lastKeyDown&&(this.lastTransformed&&this.lastTransformed.value.length||0)-i.length==1,n=this.lastTransformed=function(e){const{value:t,getPattern:i,deleting:s,input:n}=e,a=!s&&!!t.length,o=function(e,t,i={},s){const n=e(t);if(!n)return{value:t,selection:null,autocorrectComplete:!!t};const a=n.length,o=[],r=[];let d=0,l=0,c=0===i.selectionStart?0:null,h=0===i.selectionEnd?0:null;const u=e=>{e>0&&(null===c&&l+1>=i.selectionStart&&(c=oe(o)+(s?r.length:0)),null===h&&l+1>=i.selectionEnd&&(h=oe(o)+(s?r.length:0)),l+=e)};for(;d<a;){const e=(0,n[d])(t.slice(l)),{type:i,result:a,consumed:c}=e;if("required"===i)if(a){if(o.push(...r,a),r.length=0,++d,e.partial){u(t.length-l);break}u(c)}else{if(!c)break;u(1)}else if("optional"===i)a&&(o.push(...r,a),r.length=0,u(c)),++d;else if("formatting"===i){if(!s&&l>=t.length)break;r.push(a),++d,u(c)}}return s&&o.push(...r),{value:o.join(""),selection:{selectionStart:null===c||t.length&&i.selectionStart===t.length?oe(o):c,selectionEnd:null===h||t.length&&i.selectionEnd===t.length?oe(o):h},autocorrectComplete:d===a}}(i,t,{selectionStart:n?n.selectionStart:0,selectionEnd:n?n.selectionEnd:0},a),{value:r,selection:d}=o;return{value:r,meta:{autocorrectComplete:o.autocorrectComplete,empty:!r},selection:d}}({value:i,getPattern:this.options.formatMethod,deleting:s,input:this.input}),a=n.value;a!==i&&(this.setValueSilently(a),n.selection&&(this.input.selectionStart=n.selection.selectionStart,this.input.selectionEnd=n.selection.selectionEnd)),this.validateNew(a,{ignoreIncomplete:!0}),null===(t=(e=this.options).onChange)||void 0===t||t.call(e,n)},this.onBlur=()=>{var e;const t=null===(e=this.lastTransformed)||void 0===e?void 0:e.value;t&&this.validateNew(t)},this.validate=()=>this.validateNew(),this.input.addEventListener("keydown",this.onKeyDown),this.input.addEventListener("input",this.onInput),this.input.addEventListener("blur",this.onBlur)}update(){this.onInput()}validateNew(e,t,i){var s,n,a,o,r;let d;if(void 0===e&&(e=null!==(n=null===(s=this.lastTransformed)||void 0===s?void 0:s.value)&&void 0!==n?n:""),void 0===t&&(t={}),d=this.options.validateMethod?null===(o=(a=this.options).validateMethod)||void 0===o?void 0:o.call(a,e,t):function(e,t,i={}){return e.meta.autocorrectComplete||i.ignoreIncomplete?null:le("incomplete")}(this.lastTransformed,0,t),null==d?void 0:d.code){const e=null===(r=this.options.errorKeys)||void 0===r?void 0:r[d.code];return!i&&this.setState(me.I1.Error,e),!1}return!i&&this.setState(me.I1.Neutral),!0}}function Le(e,t){const i=()=>{const i=e.every((e=>"validateNew"in e?e.validateNew(void 0,void 0,!0):e.isValid()));t(i)};return e.forEach((e=>{if(e instanceof Ce){const t=e.options.onChange;e.options.onChange=(...e)=>{null==t||t(...e),i()},"update"in e&&e.update()}else e.input.addEventListener("input",i)})),{validate:i}}function Ee(e,t){let i,s;return(e||t)&&(e&&(i=new fe.Z({noPhoneCodes:!0,onCountryChange:()=>{null==s||s.update()},required:!0,autocomplete:"country"})),t&&(s=new Ce({label:"PaymentShippingZipPlaceholder",plainText:!0,inputMode:"numeric",autocomplete:"postal-code",formatMethod:()=>{const{country:e}=i.getSelected(),t=null==e?void 0:e.iso2;return ae.postalCodeFromCountry(t&&t.toUpperCase())}}))),{countryInputField:i,postcodeInputField:s}}const Ie=new Set(["stripe","smartglocal"]);class Pe extends s.Z{constructor(e,t){if(super("popup-payment popup-payment-card",{closable:!0,overlayClosable:!0,body:!0,scrollable:Ie.has(e.native_provider),title:"PaymentCardInfo"}),this.paymentForm=e,this.savedCard=t,Ie.has(e.native_provider))this.d();else{const t=this.telegramWebView=be({url:e.url});t.addEventListener("payment_form_submit",(t=>{const i={title:t.title,save:!1};this.dispatchEvent("finish",{token:t.credentials,card:i}),this.hide(),e.pFlags.can_save_credentials&&(0,pe.Z)({titleLangKey:"PaymentCardSavePaymentInformation",descriptionLangKey:"PaymentCardSavePaymentInformationInfoLine1",button:{langKey:"Save"}}).then((()=>{i.save=!0}),ue.Z)})),this.body.append(t.iframe),this.show(),t.onMount()}}destroy(){var e;return null===(e=this.telegramWebView)||void 0===e||e.destroy(),super.destroy()}d(){const e=this.savedCard,t=new Se.Z({name:"PaymentInfo.Card.Title",noDelimiter:!0,noShadow:!0}),i=JSON.parse(this.paymentForm.native_params.data);let s,n,a=0;const o=new Ce({label:"PaymentCardNumber",plainText:!0,inputMode:"numeric",autocomplete:"cc-number",formatMethod:ae.cardNumber,validateMethod:ce,errorKeys:{invalid:"PaymentCard.Error.Invalid",incomplete:"PaymentCard.Error.Incomplete"},onChange:e=>{(e=>{if(s===e)return;const t=++a;s=e;const i=De(e);if(!i)return void(n&&(n.remove(),n=void 0));const r=new Image;r.classList.add("input-field-icon"),(0,b.cj)(r,i,!1).then((()=>{a===t&&(n?n.replaceWith(r):o.container.append(r),n=r)}))})(p(e.value)),l.update()}});let r;i.need_cardholder_name&&(r=new me.ZP({label:"Checkout.NewCard.CardholderNamePlaceholder",maxLength:255,required:!0,autocomplete:"cc-name"}));const d=new Ce({label:"SecureId.Identity.Placeholder.ExpiryDate",plainText:!0,inputMode:"numeric",autocomplete:"cc-exp",formatMethod:ae.cardExpiry,validateMethod:he});d.input.addEventListener("input",(()=>{let e=d.value;if(e.length<5)return;const t=e.split("/");4===t[1].length&&(e=[t[0],t[1].slice(2)].join("/"),d.setValueSilently(e))}),{capture:!0});const l=new Ce({labelText:"CVC",plainText:!0,inputMode:"numeric",autocomplete:"cc-csc",name:"cvc",formatMethod:()=>ae.cardCvc(o.value)}),c=(new we.T(l.container,l.input),[o,d,l,r].filter(Boolean));c.forEach((e=>{const t=t=>{if(!e.value&&"Backspace"===t.key){const t=c[c.indexOf(e)-1];t&&(0,v.Z)(t.input,!0)}};if(e instanceof Ce){e.options.onKeyDown=t;const i=e.options.onChange;e.options.onChange=t=>{if(null==i||i(t),document.activeElement===e.input&&t.meta.autocorrectComplete)for(let t=c.indexOf(e),i=c.length;t<i;++t){const e=c[t];if(e instanceof Ce?!e.validateNew(void 0,void 0,!0):!e.value){(0,v.Z)(e.input,!0);break}}}}else e.input.addEventListener("keydown",t)}));const h=document.createElement("div");h.classList.add("input-fields-row"),h.append(d.container,l.container);const u=document.createElement("form");let f;u.append(...[o.container,h,null==r?void 0:r.container].filter(Boolean)),t.content.append(u);const{countryInputField:m,postcodeInputField:g}=Ee(i.need_country,i.need_zip);(i.need_country||i.need_zip)&&(f=new Se.Z({name:"PaymentInfo.Billing.Title",noDelimiter:!0,noShadow:!0}),f.content.append(...[m,g].filter(Boolean).map((e=>e.container))));const y=!!this.paymentForm.pFlags.can_save_credentials,w=new A.Z({text:"PaymentCardSavePaymentInformation",checked:!!y}),S=new D.ZP({checkboxField:w,subtitleLangKey:y?"PaymentCardSavePaymentInformationInfoLine1":"Checkout.2FA.Text"});y||S.container.classList.add("is-disabled"),(f||t).content.append(S.container),this.scrollable.append(...[t,f].filter(Boolean).map((e=>e.container)));const C=Re({key:"PaymentInfo.Done",onClick:()=>{return e=this,t=void 0,n=function*(){const e={cardNumber:o.value,expiryFull:d.value,expiryMonth:d.value.split("/")[0],expiryYear:d.value.split("/")[1],cvc:l.value,cardholderName:null==r?void 0:r.value,country:null==m?void 0:m.value,zip:null==g?void 0:g.value,save:null==w?void 0:w.checked},t=this.paymentForm.native_provider;let s;if("stripe"===t){const t=new URL("https://api.stripe.com/v1/tokens");t.search=new URLSearchParams({"card[number]":e.cardNumber,"card[exp_month]":e.expiryMonth,"card[exp_year]":e.expiryYear,"card[cvc]":e.cvc,"card[address_zip]":e.zip,"card[address_country]":e.country,"card[name]":e.cardholderName}).toString();const n=yield fetch(t.toString(),{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/x-www-form-urlencoded",Authorization:`Bearer ${i.publishable_key}`}});s=yield n.json()}else if("smartglocal"===t){const t={card:{number:e.cardNumber.replace(/[^\d]+/g,""),expiration_month:e.expiryMonth,expiration_year:e.expiryYear,security_code:e.cvc.replace(/[^\d]+/g,"")}},n="https://tgb.smart-glocal.com/cds/v1/tokenize/card",a=yield fetch(n,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","X-PUBLIC-TOKEN":i.public_token},body:JSON.stringify(t)});s={type:"card",token:(yield a.json()).data.token}}this.dispatchEvent("finish",{token:s,card:e}),this.hide()},new((s=void 0)||(s=Promise))((function(i,a){function o(e){try{d(n.next(e))}catch(e){a(e)}}function r(e){try{d(n.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?i(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(o,r)}d((n=n.apply(e,t||[])).next())}));var e,t,s,n}});Le([o,r,d,l,m,g].filter(Boolean),(e=>{C.disabled=!e})),e&&(o.value=e.cardNumber,d.value=e.expiryFull,l.value=e.cvc,r&&(r.value=e.cardholderName),m&&(m.value=e.country),g&&(g.value=e.zip)),this.body.append(this.btnConfirmOnEnter=C),this.show(),o.validateNew(void 0,void 0,!0)||(0,v.Z)(o.input)}}class Ze extends s.Z{constructor(e,t){super("popup-payment popup-payment-card-confirmation",{closable:!0,overlayClosable:!0,body:!0,scrollable:!0,title:"Checkout.PasswordEntry.Title"});const i=new Se.Z({noDelimiter:!0,noShadow:!0,caption:"Checkout.PasswordEntry.Text",captionArgs:[e]}),s=new we.Z({labelText:t.hint});i.content.append(s.container),this.scrollable.append(i.container);const n=()=>{a.disabled=!s.value,s.setState(me.I1.Neutral)};s.input.addEventListener("input",n);const a=Re({key:"Checkout.PasswordEntry.Pay",onClick:()=>{return e=this,i=void 0,a=function*(){try{const e=yield this.managers.passwordManager.getInputCheckPassword(s.value,t),i=yield this.managers.apiManager.invokeApi("account.getTmpPassword",{password:e,period:60});this.dispatchEvent("finish",i),this.hide()}catch(e){throw"PASSWORD_HASH_INVALID"===e.type&&(e.handled=!0,s.setError("PASSWORD_HASH_INVALID")),e}},new((n=void 0)||(n=Promise))((function(t,s){function o(e){try{d(a.next(e))}catch(e){s(e)}}function r(e){try{d(a.throw(e))}catch(e){s(e)}}function d(e){var i;e.done?t(e.value):(i=e.value,i instanceof n?i:new n((function(e){e(i)}))).then(o,r)}d((a=a.apply(e,i||[])).next())}));var e,i,n,a}});this.body.append(this.btnConfirmOnEnter=a),n(),this.show(),(0,v.Z)(s.input)}}var Me=i(1171),ke=i(709);class Te extends s.Z{constructor(e,t,i){super("popup-payment popup-payment-shipping",{closable:!0,overlayClosable:!0,body:!0,scrollable:!0,title:"PaymentShippingInfo"}),this.paymentForm=e,this.inputInvoice=t,this.focus=i,this.d()}d(){const e=this.paymentForm.invoice,t=this.paymentForm.saved_info;let i,s,n,a,o,r,d,l,c,h,u;if(e.pFlags.shipping_address_requested){i=new Se.Z({name:"PaymentShippingAddress",noDelimiter:!0,noShadow:!0}),s=new me.ZP({label:"PaymentShippingAddress1Placeholder",maxLength:64,required:!0}),n=new me.ZP({label:"PaymentShippingAddress2Placeholder",maxLength:64}),a=new me.ZP({label:"PaymentShippingCityPlaceholder",maxLength:64,required:!0}),o=new me.ZP({label:"PaymentShippingStatePlaceholder",maxLength:64});const e=Ee(!0,!0);r=e.countryInputField,d=e.postcodeInputField,i.content.append(...[s,n,a,o,r,d].filter(Boolean).map((e=>e.container)))}if([e.pFlags.name_requested,e.pFlags.email_requested,e.pFlags.phone_requested].includes(!0)){l=new Se.Z({name:"PaymentShippingReceiver",noDelimiter:!0,noShadow:!0});const t=()=>{const e=h.value,t=(0,Me.Z)(e);return!(!t||t[0].length!==e.length)},i=()=>!!u.value.match(/\d/);e.pFlags.name_requested&&(c=new me.ZP({label:"PaymentShippingName",maxLength:256,required:!0})),e.pFlags.email_requested&&(h=new me.ZP({label:"PaymentShippingEmailPlaceholder",maxLength:64,required:!0,validate:t})),e.pFlags.phone_requested&&(u=new ke.Z({required:!0,validate:i})),l.content.append(...[c,h,u].filter(Boolean).map((e=>e.container)))}const p=new A.Z({text:"PaymentShippingSave",checked:!0}),f=new D.ZP({checkboxField:p,subtitleLangKey:"PaymentShippingSaveInfo"});(l||i).content.append(f.container),this.scrollable.append(...[i,l].filter(Boolean).map((e=>e.container)));const m=Re({key:"PaymentInfo.Done",onClick:()=>{return e=this,t=void 0,l=function*(){const e=r&&r.getSelected().country,t={_:"paymentRequestedInfo",shipping_address:e&&{_:"postAddress",street_line1:s.value,street_line2:n.value,city:a.value,state:o.value,country_iso2:null==e?void 0:e.iso2,post_code:d.value},name:null==c?void 0:c.value,email:null==h?void 0:h.value,phone:null==u?void 0:u.value};try{const e=yield this.managers.appPaymentsManager.validateRequestedInfo(this.inputInvoice,t,null==p?void 0:p.checked);this.dispatchEvent("finish",{shippingAddress:t,requestedInfo:e}),this.hide()}catch(e){const t={ADDRESS_STREET_LINE1_INVALID:s,ADDRESS_STREET_LINE2_INVALID:n,ADDRESS_COUNTRY_INVALID:r,ADDRESS_CITY_INVALID:a,ADDRESS_STATE_INVALID:o,ADDRESS_POSTCODE_INVALID:d,REQ_INFO_NAME_INVALID:c,REQ_INFO_EMAIL_INVALID:h,REQ_INFO_PHONE_INVALID:u}[e.type];throw t&&(t.setError(),e.handled=!0),e}},new((i=void 0)||(i=Promise))((function(s,n){function a(e){try{r(l.next(e))}catch(e){n(e)}}function o(e){try{r(l.throw(e))}catch(e){n(e)}}function r(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,o)}r((l=l.apply(e,t||[])).next())}));var e,t,i,l}});if(this.body.append(this.btnConfirmOnEnter=m),t){const e=t.shipping_address;e&&(s.value=e.street_line1,n.value=e.street_line2,a.value=e.city,o.value=e.state,r.selectCountryByIso2(e.country_iso2),d.value=e.post_code),t.name&&c&&(c.value=t.name),t.email&&h&&(h.value=t.email),t.phone&&u&&(u.value=t.phone)}const{validate:g}=Le([s,n,a,o,r,d,c,h,u].filter(Boolean),(e=>{m.disabled=!e}));let b;g(),this.show(),b=this.focus?{name:c,email:h,phone:u}[this.focus]:s,b&&(0,v.Z)(b.input)}}var xe=i(1218);class Ae extends s.Z{constructor(e,t,i){super("popup-payment popup-payment-shipping-methods",{closable:!0,overlayClosable:!0,body:!0,scrollable:!0,title:"PaymentShippingMethod"}),this.paymentForm=e,this.requestedInfo=t,this.shippingOption=i,this.d()}d(){const e=new Se.Z({name:"PaymentCheckoutShippingMethod",noDelimiter:!0,noShadow:!0}),t=this.requestedInfo.shipping_options.map((e=>new D.ZP({radioField:new xe.Z({text:e.title,name:"shipping-method",value:e.id}),subtitle:(0,L.Z)((0,o.Z)(e.prices.map((({amount:e})=>+e)),0),this.paymentForm.invoice.currency)})));let i;const s=(0,D.De)(t,(e=>{i=e}));this.shippingOption?t.find((e=>e.radioField.input.value===this.shippingOption.id)).radioField.checked=!0:t[0].radioField.checked=!0,e.content.append(s),this.scrollable.append(e.container);const n=Re({key:"PaymentInfo.Done",onClick:()=>{this.dispatchEvent("finish",this.requestedInfo.shipping_options.find((e=>e.id===i))),this.hide()}});this.body.append(this.btnConfirmOnEnter=n),this.show()}}var _e=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};const Fe=["amex","card","diners","discover","jcb","mastercard","visa","unionpay","mir","logo"];function De(e){if(Fe.includes(e))return`assets/img/${e}.svg`}function Re(e){var t,i;const s=null!==(t=e.textEl)&&void 0!==t?t:new P.ZP.IntlElement({key:null!==(i=e.key)&&void 0!==i?i:"PaymentInfo.Done"}),n=s.key,a=(0,x.Z)("btn-primary btn-color-primary payment-item-pay");return a.append(s.element),(0,f.fc)(a,(()=>_e(this,void 0,void 0,(function*(){const t=e.onClick();if(!(t instanceof Promise))return;const i=(0,F.y)(a),o=(0,S.Z)([a],!0);s.compareAndUpdate({key:"PleaseWait"});try{yield t}catch(e){e.handled||console.error("payment button error",e),o(),s.compareAndUpdate({key:n}),i.remove()}})))),a}class Be extends s.Z{constructor(e,t,i,s){super("popup-payment",{closable:!0,overlayClosable:!0,body:!0,scrollable:!0,title:!0}),this.message=e,this.inputInvoice=t,this.paymentForm=i,this.isReceipt=s,this.tipButtonsMap=new Map,this.d().catch((e=>{console.error("payment popup error",e),this.hide()}))}d(){var e,t,i;return _e(this,void 0,void 0,(function*(){this.element.classList.add("is-loading"),this.show();let d=!1;const l=()=>{d||(d=!0,it&&it.hide(),this.hide())};let{paymentForm:c,message:h}=this;h&&this.listenerSetter.add(k.Z)("payment_sent",(({peerId:e,mid:t})=>{h.peerId===e&&h.mid===t&&l()}));const u=null==h?void 0:h.media,S=null!==(e=this.isReceipt)&&void 0!==e?e:u?!!u.receipt_msg_id||"messageExtendedMedia"===(null===(t=u.extended_media)||void 0===t?void 0:t._):"payments.paymentReceipt"===c._,O=u?u.pFlags.test:c.invoice.pFlags.test,U=u?u.photo:c.photo,H=u?u.title:c.title,z=u?u.description:c.description;(0,P.$d)(this.title,S?"PaymentReceipt":"PaymentCheckout"),O&&this.title.append(" (Test)");const j="payment-item",G=document.createElement("div");G.classList.add(j);const V=j+"-details",K=document.createElement("div");let W;K.classList.add(V),U&&(W=document.createElement("div"),W.classList.add(V+"-photo","media-container-contain"),(0,N.Z)({photo:U,container:W,boxWidth:100,boxHeight:100,size:{_:"photoSizeEmpty",type:""}}),K.append(W));const $=V+"-lines",q=document.createElement("div");q.classList.add($);const Y=document.createElement("div");Y.classList.add($+"-title");const Q=document.createElement("div");Q.classList.add($+"-description");const X=document.createElement("div");X.classList.add($+"-bot-name"),q.append(Y,Q,X),(0,w.Z)(Y,(0,Z.Z)(H)),(0,w.Z)(Q,(0,Z.Z)(z));const J=new _.Z;X.append(J.element),K.append(q),G.append(K),this.scrollable.append(G);const ee=document.createElement("div");ee.classList.add(j+"-preloader-container"),(0,F.y)(ee,!0),this.scrollable.container.append(ee);const te=this.inputInvoice;c||(c=S?yield this.managers.appPaymentsManager.getPaymentReceipt(h.peerId,u.receipt_msg_id||te.msg_id):yield this.managers.appPaymentsManager.getPaymentForm(te),this.paymentForm=c);let ie=c.saved_info||c.info;const se=null===(i=c.saved_credentials)||void 0===i?void 0:i[0];let[ne,ae,oe]=yield Promise.all([!S&&ie&&this.managers.appPaymentsManager.validateRequestedInfo(te,ie),se&&this.managers.passwordManager.getState(),(0,B.Z)({peerId:c.provider_id.toPeerId()})]);yield J.update({peerId:c.bot_id.toPeerId()}),ee.remove(),this.element.classList.remove("is-loading");const re=(e,t)=>(0,L.Z)(e,le,t),{invoice:de}=c,le=de.currency,ce=de.pFlags.recurring&&!S;yield J.update({peerId:c.bot_id.toPeerId()});const he=ce?yield(0,B.Z)({peerId:c.bot_id.toPeerId()}):void 0;ee.remove(),this.element.classList.remove("is-loading");const ue=()=>{const e=document.createElement("div");e.classList.add(pe+"-price");const t=document.createElement("span"),i=document.createElement("span");return e.append(t,i),{label:e,left:t,right:i}},pe=j+"-prices",fe=document.createElement("div");fe.classList.add(pe);const me=e=>e.map((e=>{const{amount:t,label:i}=e,s=ue();s.left.textContent=i;const n=re(t);return s.right.textContent=n,s.label})),ge=me(de.prices);let ve=()=>0,be=0;const we=()=>{const e=re(Le+ve()+be);Ce.right.textContent=e,Se.compareAndUpdate({key:"PaymentCheckoutPay",args:[e]})},Se=new P.ZP.IntlElement,Ce=ue();Ce.label.classList.add("is-total"),(0,P.$d)(Ce.left,"PaymentTransactionTotal");const Le=(0,o.Z)(de.prices.map((({amount:e})=>+e)),0),Ee=void 0!==de.max_tip_amount&&!S||!!c.tip_amount;if(Ee){const e=j+"-tips",t=n.Z[le];ve=()=>+i().replace(/\D/g,"");const i=()=>l.value,s=()=>{const e=(0,r.Z)(i(),`500 ${a.Bf} ${a.bt}`);l.style.width=e+"px"},o=e=>{e=Math.min(+e,+de.max_tip_amount);const t=re(e,!0);l.value=t,document.activeElement===l&&(0,v.Z)(l),C&&C();const i=this.tipButtonsMap.get(e);i&&i.classList.add("active"),s(),we()},d=ue();(0,P.$d)(d.left,S?"PaymentTip":"PaymentTipOptional");const l=document.createElement("input");l.type="tel",l.classList.add("input-clear",e+"-input"),d.right.append(l),S?d.label.classList.add("disable-hover"):d.label.style.cursor="text",d.label.addEventListener("mousedown",(e=>{(0,m.Z)(e.target,l)||(0,v.Z)(l)}));const h=l instanceof HTMLInputElement?1:2,u=()=>{y?--y:(y=h,(0,v.Z)(l))},p=()=>{setTimeout((()=>{y=h,(0,v.Z)(l),document.addEventListener("selectionchange",u)}),0)},b=()=>{l.addEventListener("focus",p,{once:!0}),document.removeEventListener("selectionchange",u)};let y;l.addEventListener("focusout",b),b(),l.addEventListener("input",(()=>{o(ve())}));const w=[t.symbol,t.space_between?" ":""];let C;if(t.symbol_left||w.reverse(),d.right[t.symbol_left?"prepend":"append"](w.join("")),ge.push(d.label),S)o(c.tip_amount);else{const t=document.createElement("div");t.classList.add(e);const i=e+"-tip",s=de.suggested_tip_amounts.map((e=>{const t=(0,x.Z)(i,{noRipple:!0});return t.textContent=re(e),this.tipButtonsMap.set(+e,t),t}));C=()=>{const e=t.querySelector(".active");e&&e.classList.remove("active")},(0,f.fc)(t,(e=>{const t=(0,g.Z)(e.target,i);if(!t)return;let s=0;if(t.classList.contains("active"))t.classList.remove("active");else{C(),t.classList.add("active");for(const[e,i]of this.tipButtonsMap)if(i===t){s=e;break}}o(s)})),o(0),t.append(...s),ge.push(t)}}else we();ge.push(Ce.label),fe.append(...ge),G.append(fe);const Ie=(e,t)=>_e(this,void 0,void 0,(function*(){const i=document.createElement("img");i.classList.add("media-photo"),yield(0,b.cj)(i,De(t));let s=e.media;s?(0,y.Z)(s,i):(s=e.createMedia("small"),s.classList.add("media-container-cover"),s.append(i)),e.container.classList.remove("row-with-icon")})),Me=e=>{e.titleLangKey&&(e.subtitleLangKey=e.titleLangKey),e.noWrap=!0;const t=new D.ZP(e);return t.container.classList.add(j+"-row"),e.titleLangKey&&t.subtitle.classList.add("hide"),t},ke=(e,t)=>{if(e.title.textContent=t,!t){const t=P.ZP.weakMap.get(e.subtitle.firstElementChild);e.title.append((0,P.ag)(t.key))}e.subtitle.classList.toggle("hide",!t)},xe=e=>{let t,i,s;"title"in e?(t=e.title.split(" ").shift(),i=e.title,s=e.icon):(t=p(e.cardNumber),i=t+" *"+e.cardNumber.split(" ").pop()),Oe.title.classList.remove("tgico","tgico-card_outline"),Ie(Oe,s||t.toLowerCase()),ke(Oe,i)},Fe=()=>{s.Z.createPopup(Pe,c,Be).addEventListener("finish",(({token:e,card:t})=>{Ne=e,Be=t,xe(t)}))};let Be,Ne;const Oe=Me({titleLangKey:"PaymentCheckoutMethod",clickable:S?void 0:Fe,icon:"card_outline"});Oe.container.classList.add(j+"-method-row"),se?xe(se):c.credentials_title&&xe({title:c.credentials_title});const Ue=Me({title:oe,subtitleLangKey:"PaymentCheckoutProvider"}),He=new T.Z;let ze,je,Ge,Ve,Ke,We,$e,qe;He.classList.add("avatar-32"),Ue.createMedia("small").append(He),He.updateWithOptions({peerId:c.provider_id.toPeerId()});const Ye=de.pFlags.shipping_address_requested?e=>{if(!e)return Ke.subtitle.classList.add("hide"),void(0,y.Z)(Ke.title,(0,P.ag)("PaymentShippingAddress"));const t=e.shipping_address;ke(ze,[t.city,t.street_line1,t.street_line2].filter(Boolean).join(", ")),Ke.container.classList.toggle("hide",!ne&&!S)}:void 0,Qe=e=>{Ye&&Ye(e),je&&ke(je,e.name),Ge&&ke(Ge,e.email),Ve&&ke(Ve,e.phone&&"+"+(0,C.u)(e.phone).formatted)};if(S||($e=e=>{s.Z.createPopup(Te,c,te,e).addEventListener("finish",(({shippingAddress:e,requestedInfo:t})=>{ne=t,ie=c.saved_info=e,Qe(e)}))}),de.pFlags.shipping_address_requested){const e=e=>{const i=new E.Z(this.scrollable,void 0,!0);if(i.save(),t&&t.forEach((e=>e.remove())),!e)return be=0,we(),i.restore(),void this.onContentUpdate();We=e,ke(Ke,e.title),be=(0,o.Z)(e.prices.map((({amount:e})=>+e)),0),t=me(e.prices);let s=Ce.label;Ee&&(s=s.previousElementSibling,S||(s=s.previousElementSibling)),t.forEach((e=>s.parentElement.insertBefore(e,s))),we(),i.restore(),this.onContentUpdate()};let t;ze=Me({icon:"location",titleLangKey:"PaymentShippingAddress",clickable:!S&&$e.bind(null,void 0)}),Ke=Me({icon:"shipping",titleLangKey:"PaymentCheckoutShippingMethod",clickable:!S&&(qe=()=>{s.Z.createPopup(Ae,c,ne,We).addEventListener("finish",(t=>{e(t)}))})}),Ke.container.classList.add("hide");const i=c.shipping;i&&e(i)}de.pFlags.name_requested&&(je=Me({icon:"newprivate",titleLangKey:"PaymentCheckoutName",clickable:!S&&$e.bind(null,"name")})),de.pFlags.email_requested&&(Ge=Me({icon:"mention",titleLangKey:"PaymentShippingEmailPlaceholder",clickable:!S&&$e.bind(null,"email")})),de.pFlags.phone_requested&&(Ve=Me({icon:"phone",titleLangKey:"PaymentCheckoutPhoneNumber",clickable:!S&&$e.bind(null,"phone")})),ie&&Qe(ie);const Xe=[Oe,Ue,ze,Ke,je,Ge,Ve].filter(Boolean),Je=ce&&new A.Z({text:"Payments.Recurrent.Accept",textArgs:[(0,M.ZP)(de.recurring_terms_url),he]}),et=ce&&Me({checkboxField:Je}),tt=ce?[document.createElement("hr"),et.container]:[];let it,st;this.scrollable.append(...[document.createElement("hr"),...Xe.map((e=>e.container)),...tt].filter(Boolean));const nt=()=>{at.disabled=!(!Je||Je.checked)};let at;at=Re(S?{onClick:()=>this.hide(),key:"Done"}:{onClick:()=>{const e=de.pFlags.name_requested&&!(null==ie?void 0:ie.name)?"name":de.pFlags.email_requested&&!(null==ie?void 0:ie.email)?"email":de.pFlags.phone_requested&&!(null==ie?void 0:ie.phone)?"phone":void 0;if(de.pFlags.shipping_address_requested){if(!ne)return void $e();if(!We)return void qe()}else if(e)return void $e(e);return Be||st?Promise.resolve().then((()=>_e(this,void 0,void 0,(function*(){const e=st?{_:"inputPaymentCredentialsSaved",id:se.id,tmp_password:st.tmp_password}:{_:"inputPaymentCredentials",data:{_:"dataJSON",data:JSON.stringify(Ne.token?Ne:{type:Ne.type,id:Ne.id})},pFlags:{save:Be.save||void 0}};try{const t=yield this.managers.appPaymentsManager.sendPaymentForm(te,c.form_id,null==ne?void 0:ne.id,null==We?void 0:We.id,e,ve());"payments.paymentResult"===t._?l():(it=s.Z.createPopup(ye,t.url,!u.extended_media),it.addEventListener("finish",(()=>{it=void 0,l()})),yield new Promise(((e,t)=>{it.addEventListener("close",(()=>{if(it=void 0,d)e();else{const e=new Error("payment not finished");e.handled=!0,t(e)}}))})))}catch(e){throw"BOT_PRECHECKOUT_TIMEOUT"===e.type?((0,R.bC)({langPackKey:"Error.AnError"}),e.handled=!0):"TMP_PASSWORD_INVALID"===e.type&&(ae=st=void 0,(0,f.tH)(at),e.handled=!0),e}})))):se?void Promise.resolve(null!=ae?ae:this.managers.passwordManager.getState()).then((e=>{s.Z.createPopup(Ze,se.title,e).addEventListener("finish",(e=>{ae=void 0,st=e,(0,f.tH)(at);const t=e.valid_until-(0,I.Z)(!0)-5;setTimeout((()=>{st===e&&(st=void 0)}),1e3*t)}))})):void Fe()},textEl:Se}),nt(),Je&&Je.input.addEventListener("change",nt),this.body.append(this.btnConfirmOnEnter=at),this.onContentUpdate()}))}}},8127:(e,t,i)=>{"use strict";i.d(t,{Z:()=>d});var s=i(9331),n=i(1168),a=i(2325),o=i(9807),r=i(130);class d extends n.Z{constructor(e,t={}){if(super("popup-peer"+(e?" "+e:""),Object.assign(Object.assign({overlayClosable:!0},t),{title:!0,buttons:t.buttons&&(0,n.x)(t.buttons)})),this.className=e,t.peerId){const e=new s.Z;e.classList.add("avatar-32"),e.updateWithOptions({isDialog:!0,peerId:t.peerId,threadId:t.threadId,wrapOptions:{middleware:this.middlewareHelper.get()}}),this.header.prepend(e)}t.noTitle||(t.titleLangKey||!t.title?this.title.append((0,a.ag)(t.titleLangKey||"AppName",t.titleLangArgs)):t.title instanceof HTMLElement?this.title.append(t.title):this.title.innerText=t.title||"");const i=document.createDocumentFragment();if(t.descriptionLangKey||t.description){const e=this.description=document.createElement("p");e.classList.add("popup-description"),t.descriptionLangKey?e.append((0,a.ag)(t.descriptionLangKey,t.descriptionLangArgs)):t.description&&(0,r.Z)(e,t.description),i.append(e)}t.checkboxes&&(this.container.classList.add("have-checkbox"),t.checkboxes.forEach((e=>{e.withRipple=!0;const t=new o.Z(e);e.checkboxField=t,i.append(t.label)})),t.buttons.forEach((e=>{if(e.callback){const i=e.callback;e.callback=()=>{const e=new Set;t.checkboxes.forEach((t=>{t.checkboxField.checked&&e.add(t.text)})),i(e)}}}))),this.container.insertBefore(i,this.header.nextElementSibling)}}},2995:(e,t,i)=>{"use strict";i.d(t,{Z:()=>o});var s=i(5432),n=i(5644),a=i(1168);class o extends a.Z{constructor(e){super("popup-forward",{closable:!0,overlayClosable:!0,body:!0,title:!0}),this.selector=new n.Z({appendTo:this.body,onChange:()=>{return t=this,i=void 0,n=function*(){const t=this.selector.getSelected(),i=t[t.length-1].toPeerId();if(e.onSelect){const t=e.onSelect(i);if(t instanceof Promise)try{yield t}catch(e){return}}this.selector=null,this.hide()},new((s=void 0)||(s=Promise))((function(e,a){function o(e){try{d(n.next(e))}catch(e){a(e)}}function r(e){try{d(n.throw(e))}catch(e){a(e)}}function d(t){var i;t.done?e(t.value):(i=t.value,i instanceof s?i:new s((function(e){e(i)}))).then(o,r)}d((n=n.apply(t,i||[])).next())}));var t,i,s,n},peerType:e.peerTypes,onFirstRender:()=>{this.show(),this.selector.checkForTriggers(),s.Z||this.selector.input.focus()},chatRightsActions:e.chatRightsActions,multiSelect:!1,rippleEnabled:!1,avatarSize:"abitbigger",peerId:e.peerId,placeholder:e.placeholder,selfPresence:e.selfPresence,managers:this.managers}),this.scrollable=this.selector.scrollable,this.attachScrollableListeners(),this.title.append(this.selector.input)}}},1962:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(8127);class n extends s.Z{constructor(e,t,i){super("popup-delete-chat",{title:`Send Message${t.length>1?"s":""} Now`,description:t.length>1?"Send "+t.length+" messages now?":"Send message now?",buttons:[{langKey:"Send",callback:()=>{i&&i(),this.managers.appMessagesManager.sendScheduledMessages(e,t)}}]}),this.show()}}},9298:(e,t,i)=>{"use strict";i.d(t,{Z:()=>k});var s=i(1168),n=i(3541),a=i(2153),o=i(279),r=i(5814),d=i(7030),l=i(4755),c=i(2325),h=i(4494),u=i(8497),p=i(1656),f=i(2738),m=i(2796),g=i(130),v=i(8115),b=i(3163),y=i(9259),w=i(7479),S=i(5565),C=i(3512),L=i(9083),E=i(3173),I=i(5322),P=i(2166),Z=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};const M="STICKERS-POPUP";class k extends s.Z{constructor(e,t){super("popup-stickers",{closable:!0,overlayClosable:!0,body:!0,scrollable:!0,title:!0}),this.stickerSetInput=e,this.isEmojis=t,this.onStickersClick=e=>Z(this,void 0,void 0,(function*(){const t=(0,u.Z)(e.target,"sticker-set-sticker");if(!t)return;const i=t.dataset.docId;(yield d.ZP.chat.input.sendMessageWithDocument(i))&&this.hide()})),this.title.append((0,c.ag)("Loading")),this.updateAdded={},E.ZP.setIgnoreMouseOut("popup",!0),this.addEventListener("close",(()=>{E.ZP.setIgnoreMouseOut("popup",!1),r.Z.setOnlyOnePlayableGroup()})),this.appendTo=this.scrollable.container,this.appendTo.classList.add("is-loading"),(0,o.y)(this.appendTo,!0),this.stickersFooter=document.createElement("div"),this.stickersFooter.classList.add("sticker-set-footer");const i=(0,h.Z)("btn-primary btn-primary-transparent disable-hover",{noRipple:!0,text:"Loading"});this.stickersFooter.append(i),this.body.append(this.stickersFooter),(0,y.Z)({listenTo:this.appendTo,listenerSetter:this.listenerSetter});const s=e=>{const t=this.sets.findIndex((t=>t.id===e.id));if(-1===t)return;this.sets[t]=e;const i=this.updateAdded[e.id];null==i||i(!!e.installed_date),this.updateButton()};this.listenerSetter.add(C.Z)("stickers_installed",s),this.listenerSetter.add(C.Z)("stickers_deleted",s),this.loadStickerSet()}createStickerSetElements(e){const t=document.createElement("div");let i,s;t.classList.add("sticker-set"),e&&(i=new w.ZP({title:(0,v.Z)(e.title),subtitle:(0,c.ag)(e.pFlags.emojis?"EmojiCount":"Stickers",[e.count]),buttonRight:!0}),s=e=>{(0,S.Z)(i.buttonRight,(0,c.ag)(e?"Stickers.SearchAdded":"Stickers.SearchAdd")),i.buttonRight.classList.toggle("active",e)},s(!!e.installed_date),t.append(i.container));const n=document.createElement("div");return n.classList.add("sticker-set-stickers"),t.append(n),{container:t,headerRow:i,updateAdded:s,itemsContainer:n}}loadStickerSet(){var e;return Z(this,void 0,void 0,(function*(){const t=this.middlewareHelper.get(),i=(Array.isArray(this.stickerSetInput)?this.stickerSetInput:[this.stickerSetInput]).map((e=>this.managers.appStickersManager.getStickerSet(e)));let s=yield Promise.all(i);if(!t())return;let o=s[0];if(1===s.length&&!o)return(0,m.bC)({langPackKey:this.isEmojis?"AddEmojiNotFound":"StickerSet.DontExist"}),void this.hide();s=s.filter(Boolean),o=s[0],this.sets=s.map((e=>e.set));const d=null!==(e=this.isEmojis)&&void 0!==e?e:this.isEmojis=!!o.set.pFlags.emojis;if(!d){(0,f.fc)(this.appendTo,this.onStickersClick,{listenerSetter:this.listenerSetter});const{destroy:e}=(0,b.Z)({listenTo:this.appendTo,isStickerPack:!0,onSend:()=>this.hide()});this.addEventListener("close",e)}r.Z.setOnlyOnePlayableGroup(M);const u=new a.Z,y=[],w=s.map((e=>Z(this,void 0,void 0,(function*(){const{container:i,itemsContainer:a,headerRow:o,updateAdded:r}=this.createStickerSetElements(s.length>1?e.set:void 0);let c;o&&(0,f.fc)(o.buttonRight,(()=>{this.managers.appStickersManager.toggleStickerSet(e.set)}),{listenerSetter:this.listenerSetter}),this.updateAdded[e.set.id]=r;const h=e.documents.filter((e=>"document"===(null==e?void 0:e._)));if(d){const e=(0,L.Z)({docIds:h.map((e=>e.id)),loadPromises:y,animationGroup:M,customEmojiSize:l.Z.active.esgCustomEmoji,middleware:t});Array.from(e.children).slice(1).forEach((e=>{const t=document.createElement("span");t.classList.add("super-emoji"),e.replaceWith(t),t.append(e)})),c=[e],a.classList.replace("sticker-set-stickers","super-emojis"),a.classList.add("is-emojis","not-local")}else c=yield Promise.all(h.map((e=>Z(this,void 0,void 0,(function*(){const i=document.createElement("div");i.classList.add("sticker-set-sticker");const s=l.Z.active.popupSticker.width;return yield(0,n.ZP)({doc:e,div:i,lazyLoadQueue:u,group:M,play:!0,loop:!0,width:s,height:s,withLock:!0,loadPromises:y,middleware:t}),i})))));return a.append(...c.filter(Boolean)),i})))),S=yield Promise.all(w);yield Promise.all(y);const C=this.button=(0,h.Z)("",{noRipple:!0});this.updateButton(),(0,f.fc)(C,(()=>{const e=(0,p.Z)([C],!0);this.managers.appStickersManager.toggleStickerSets(s.map((e=>e.set))).then((()=>{this.hide()})).catch((()=>{e()}))}),{listenerSetter:this.listenerSetter}),1===s.length?(0,g.Z)(this.title,(0,v.Z)(o.set.title)):(0,g.Z)(this.title,(0,c.ag)("Emoji"));const E=(0,I.Z)({listenerSetter:this.listenerSetter,buttons:[{icon:"copy",text:"CopyLink",onClick:()=>{const e=`https://t.me/${this.isEmojis?"addemoji":"addstickers"}/`,t=s.map((t=>e+t.set.short_name)).join("\n");(0,P.T)(t)}}],direction:"bottom-left"});this.title.after(E),this.stickersFooter.textContent="",this.stickersFooter.append(C),this.appendTo.classList.remove("is-loading"),this.appendTo.textContent="",this.appendTo.append(...S),this.scrollable.onAdditionalScroll()}))}updateButton(){const{sets:e,isEmojis:t}=this;let i,s;if(1===e.length){const n=e[0];s=(0,c.ag)(t?"EmojiCount":"Stickers",[n.count]),i=!n.installed_date}else{const t=e.filter((e=>e.installed_date));let n;e.length===t.length?(i=!1,n=e.length):(i=!0,n=e.length-t.length),s=(0,c.ag)("EmojiPackCount",[n])}this.button.className=i?"btn-primary btn-color-primary":"btn-primary btn-primary-transparent danger",(0,S.Z)(this.button,(0,c.ag)(i?"AddStickersCount":"RemoveStickersCount",[s]))}}},684:(e,t,i)=>{"use strict";i.d(t,{Z:()=>r});var s=i(1168),n=i(8127),a=i(3512),o=i(7362);class r{constructor(e,t,i,s){this.peerId=e,this.mid=t,this.unpin=i,this.onConfirm=s,this.construct()}construct(){return e=this,t=void 0,r=function*(){const{peerId:e,mid:t,unpin:i,onConfirm:r}=this;let d,l,c;const h=[],u=[],p=s.Z.MANAGERS,f=yield p.appPeersManager.canPinMessage(e),m=(s,n,a)=>{setTimeout((()=>{let s;s=i&&!t?f?p.appMessagesManager.unpinAllMessages(e):p.appMessagesManager.hidePinnedMessages(e):p.appMessagesManager.updatePinnedMessage(e,t,i,a,n),r&&s.then(r)}),300)};if(i){let i="UnpinMessage";t?(d="UnpinMessageAlertTitle",l="Chat.Confirm.Unpin"):f?(d="Popup.Unpin.AllTitle",l="Chat.UnpinAllMessagesConfirmation",c=[""+((yield p.appMessagesManager.getPinnedMessagesCount(e))||1)]):(d="Popup.Unpin.HideTitle",l="Popup.Unpin.HideDescription",i="Popup.Unpin.Hide"),h.push({langKey:i,isDanger:!0,callback:m})}else{d="PinMessageAlertTitle";const t="PinMessage";e.isAnyChat()?(h.push({langKey:t,callback:e=>m(0,!1,!e.size)}),(yield p.appChatsManager.isBroadcast(e.toChatId()))?l="PinMessageAlertChannel":(l="PinMessageAlert",u.push({text:"PinNotify",checked:!0}))):(l="PinMessageAlertChat",e===a.Z.myId?h.push({langKey:t,callback:m}):(h.push({langKey:t,callback:e=>m(0,!e.size)}),u.push({text:"PinAlsoFor",textArgs:[yield(0,o.Z)({peerId:e})],checked:!0})))}(0,s.x)(h),s.Z.createPopup(n.Z,"popup-delete-chat",{peerId:e,titleLangKey:d,descriptionLangKey:l,descriptionLangArgs:c,buttons:h,checkboxes:u}).show()},new((i=void 0)||(i=Promise))((function(s,n){function a(e){try{d(r.next(e))}catch(e){n(e)}}function o(e){try{d(r.throw(e))}catch(e){n(e)}}function d(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,o)}d((r=r.apply(e,t||[])).next())}));var e,t,i,r}}},3442:(e,t,i)=>{"use strict";i.d(t,{Z:()=>l});var s=i(9099),n=i(3035),a=i(3910),o=i(2738),r=i(8487),d=i(5953);class l{constructor(e){this.tempId=0,this.detached=!0,this.promise=null,this.isUpload=!1,this.cancelable=!0,this.streamable=!1,this.tryAgainOnFail=!0,this.attachMethod="append",this.onClick=e=>{var t,i,s;e&&(0,a.Z)(e),this.preloader.classList.contains("manual")?null===(t=this.loadFunc)||void 0===t||t.call(this,e):null===(s=null===(i=this.promise)||void 0===i?void 0:i.cancel)||void 0===s||s.call(i)},e&&(0,d.Z)(this,e),this.isUpload&&(this.tryAgainOnFail=!1)}constructContainer(e={}){this.preloader||(this.preloader=document.createElement("div"),this.preloader.classList.add("preloader-container"),e.color&&this.preloader.classList.add("preloader-"+e.color),e.bold&&this.preloader.classList.add("preloader-bold"),this.streamable&&this.preloader.classList.add("preloader-streamable"))}constructDownloadIcon(){this.constructContainer()}construct(){this.construct=null,this.constructContainer(),this.preloader.innerHTML=`\n <div class="you-spin-me-round">\n <svg xmlns="http://www.w3.org/2000/svg" class="preloader-circular" viewBox="${this.streamable?"25 25 50 50":"27 27 54 54"}">\n <circle class="preloader-path-new" cx="${this.streamable?"50":"54"}" cy="${this.streamable?"50":"54"}" r="${this.streamable?19:24}" fill="none" stroke-miterlimit="10"/>\n </svg>\n </div>`,this.streamable?this.totalLength=118.61124420166016:this.totalLength=149.82473754882812,this.cancelable?(this.preloader.innerHTML+='\n <svg xmlns="http://www.w3.org/2000/svg" class="preloader-close" viewBox="0 0 24 24">\n <g fill="none" fill-rule="evenodd">\n <polygon points="0 0 24 0 24 24 0 24"/>\n <path fill="#000" fill-rule="nonzero" d="M5.20970461,5.38710056 L5.29289322,5.29289322 C5.65337718,4.93240926 6.22060824,4.90467972 6.61289944,5.20970461 L6.70710678,5.29289322 L12,10.585 L17.2928932,5.29289322 C17.6834175,4.90236893 18.3165825,4.90236893 18.7071068,5.29289322 C19.0976311,5.68341751 19.0976311,6.31658249 18.7071068,6.70710678 L13.415,12 L18.7071068,17.2928932 C19.0675907,17.6533772 19.0953203,18.2206082 18.7902954,18.6128994 L18.7071068,18.7071068 C18.3466228,19.0675907 17.7793918,19.0953203 17.3871006,18.7902954 L17.2928932,18.7071068 L12,13.415 L6.70710678,18.7071068 C6.31658249,19.0976311 5.68341751,19.0976311 5.29289322,18.7071068 C4.90236893,18.3165825 4.90236893,17.6834175 5.29289322,17.2928932 L10.585,12 L5.29289322,6.70710678 C4.93240926,6.34662282 4.90467972,5.77939176 5.20970461,5.38710056 L5.29289322,5.29289322 L5.20970461,5.38710056 Z"/>\n </g>\n </svg>\n <svg xmlns="http://www.w3.org/2000/svg" class="preloader-download" viewBox="0 0 24 24">\n <g fill="none" fill-rule="evenodd">\n <polygon points="0 0 24 0 24 24 0 24"/>\n <path fill="#000" fill-rule="nonzero" d="M5,19 L19,19 C19.5522847,19 20,19.4477153 20,20 C20,20.5128358 19.6139598,20.9355072 19.1166211,20.9932723 L19,21 L5,21 C4.44771525,21 4,20.5522847 4,20 C4,19.4871642 4.38604019,19.0644928 4.88337887,19.0067277 L5,19 L19,19 L5,19 Z M11.8833789,3.00672773 L12,3 C12.5128358,3 12.9355072,3.38604019 12.9932723,3.88337887 L13,4 L13,13.585 L16.2928932,10.2928932 C16.6533772,9.93240926 17.2206082,9.90467972 17.6128994,10.2097046 L17.7071068,10.2928932 C18.0675907,10.6533772 18.0953203,11.2206082 17.7902954,11.6128994 L17.7071068,11.7071068 L12.7071068,16.7071068 C12.3466228,17.0675907 11.7793918,17.0953203 11.3871006,16.7902954 L11.2928932,16.7071068 L6.29289322,11.7071068 C5.90236893,11.3165825 5.90236893,10.6834175 6.29289322,10.2928932 C6.65337718,9.93240926 7.22060824,9.90467972 7.61289944,10.2097046 L7.70710678,10.2928932 L11,13.585 L11,4 C11,3.48716416 11.3860402,3.06449284 11.8833789,3.00672773 L12,3 L11.8833789,3.00672773 Z"/>\n </g>\n </svg>',this.downloadSvg=this.preloader.lastElementChild,this.cancelSvg=this.downloadSvg.previousElementSibling):this.preloader.classList.add("preloader-swing"),this.circle=this.preloader.firstElementChild.firstElementChild.firstElementChild,this.cancelable&&(0,o.fc)(this.preloader,this.onClick)}setDownloadFunction(e){this.loadFunc=e}setManual(){this.preloader.classList.add("manual"),this.setProgress(0)}attachPromise(e){if(this.isUpload&&this.promise)return;this.promise=e;const t=--this.tempId,i=Date.now(),s=s=>{if(e.notify=e.notifyAll=null,t!==this.tempId)return;const a=Date.now()-i;if(!s&&this.cancelable){this.setProgress(100);const e=150;a<e?this.detach():setTimeout((()=>{t===this.tempId&&this.detach()}),e)}else this.tryAgainOnFail?(this.attach(this.preloader.parentElement),(0,n.T2)((()=>{this.setManual()}))):this.detach();this.promise=e=null};e.then((()=>s(null))).catch((e=>s(e))),e.addNotifyListener&&e.addNotifyListener((e=>{if(t!==this.tempId)return;const i=e.done/e.total*100;this.setProgress(i)}))}attach(e,t=!1,i){var n;null===(n=this.construct)||void 0===n||n.call(this),this.preloader.parentElement&&this.preloader.classList.remove("manual"),this.detached=!1,i&&this.attachPromise(i);let a=0;(this.detached||this.preloader.parentElement!==e)&&(a=(0,r.Z)(this.preloader)?1:2,this.preloader.parentElement!==e&&e[this.attachMethod](this.preloader)),(0,s.Z)({element:this.preloader,className:"is-visible",forwards:!0,duration:200,useRafs:a}),this.cancelable&&t&&this.setProgress(0)}detach(){var e;this.detached||(this.detached=!0,(null===(e=this.preloader)||void 0===e?void 0:e.parentElement)&&(0,s.Z)({element:this.preloader,className:"is-visible",forwards:!1,duration:200,onTransitionEnd:()=>{this.preloader.remove()},useRafs:1}))}setProgress(e){if(this.totalLength||(0,r.Z)(this.circle))if(0!==e)try{this.totalLength||(this.totalLength=this.circle.getTotalLength()),this.circle.style.strokeDasharray=Math.max(5,e/100*this.totalLength)+", "+this.totalLength}catch(e){}else this.circle.style.strokeDasharray=""}}},2635:(e,t,i)=>{"use strict";i.d(t,{Z:()=>r});var s=i(1470),n=i(3228);class a{constructor(e,t,i,n,o=t){this.sizes=e,this.maxWidth=t,this.minWidth=i,this.spacing=n,this.maxHeight=o,this.count=e.length,this.ratios=a.countRatios(e),this.proportions=a.countProportions(this.ratios),this.averageRatio=(0,s.Z)(this.ratios,1)/this.count,this.maxSizeRatio=t/this.maxHeight}layout(){return this.count?this.count>=5||this.ratios.find((e=>e>2))?new o(this.ratios,this.averageRatio,this.maxWidth,this.minWidth,this.spacing).layout():2===this.count?this.layoutTwo():3===this.count?this.layoutThree():this.layoutFour():[]}layoutTwo(){return"ww"===this.proportions&&this.averageRatio>1.4*this.maxSizeRatio&&this.ratios[1]-this.ratios[0]<.2?this.layoutTwoTopBottom():"ww"===this.proportions||"qq"===this.proportions?this.layoutTwoLeftRightEqual():this.layoutTwoLeftRight()}layoutThree(){return"n"===this.proportions[0]?this.layoutThreeLeftAndOther():this.layoutThreeTopAndOther()}layoutFour(){return"w"===this.proportions[0]?this.layoutFourTopAndOther():this.layoutFourLeftAndOther()}layoutTwoTopBottom(){const e=this.maxWidth,t=Math.round(Math.min(e/this.ratios[0],Math.min(e/this.ratios[1],(this.maxHeight-this.spacing)/2)));return[{geometry:{x:0,y:0,width:e,height:t},sides:11},{geometry:{x:0,y:t+this.spacing,width:e,height:t},sides:14}]}layoutTwoLeftRightEqual(){const e=(this.maxWidth-this.spacing)/2,t=Math.round(Math.min(e/this.ratios[0],Math.min(e/this.ratios[1],1*this.maxHeight)));return[{geometry:{x:0,y:0,width:e,height:t},sides:13},{geometry:{x:e+this.spacing,y:0,width:e,height:t},sides:7}]}layoutTwoLeftRight(){const e=Math.round(1.5*this.minWidth),t=Math.min(Math.round(Math.max(.4*(this.maxWidth-this.spacing),(this.maxWidth-this.spacing)/this.ratios[0]/(1/this.ratios[0]+1/this.ratios[1]))),this.maxWidth-this.spacing-e),i=this.maxWidth-t-this.spacing,s=Math.min(this.maxHeight,Math.round(Math.min(i/this.ratios[0],t/this.ratios[1])));return[{geometry:{x:0,y:0,width:i,height:s},sides:13},{geometry:{x:i+this.spacing,y:0,width:t,height:s},sides:7}]}layoutThreeLeftAndOther(){const e=this.maxHeight,t=Math.round(Math.min((this.maxHeight-this.spacing)/2,this.ratios[1]*(this.maxWidth-this.spacing)/(this.ratios[2]+this.ratios[1]))),i=e-t-this.spacing,s=Math.max(this.minWidth,Math.round(Math.min((this.maxWidth-this.spacing)/2,Math.min(t*this.ratios[2],i*this.ratios[1])))),n=Math.min(Math.round(e*this.ratios[0]),this.maxWidth-this.spacing-s);return[{geometry:{x:0,y:0,width:n,height:e},sides:13},{geometry:{x:n+this.spacing,y:0,width:s,height:i},sides:3},{geometry:{x:n+this.spacing,y:i+this.spacing,width:s,height:t},sides:6}]}layoutThreeTopAndOther(){const e=this.maxWidth,t=Math.round(Math.min(e/this.ratios[0],.66*(this.maxHeight-this.spacing))),i=(this.maxWidth-this.spacing)/2,s=Math.min(this.maxHeight-t-this.spacing,Math.round(Math.min(i/this.ratios[1],i/this.ratios[2]))),n=e-i-this.spacing;return[{geometry:{x:0,y:0,width:e,height:t},sides:11},{geometry:{x:0,y:t+this.spacing,width:i,height:s},sides:12},{geometry:{x:i+this.spacing,y:t+this.spacing,width:n,height:s},sides:6}]}layoutFourTopAndOther(){const e=this.maxWidth,t=Math.round(Math.min(e/this.ratios[0],.66*(this.maxHeight-this.spacing))),i=Math.round((this.maxWidth-2*this.spacing)/(this.ratios[1]+this.ratios[2]+this.ratios[3])),s=Math.max(this.minWidth,Math.round(Math.min(.4*(this.maxWidth-2*this.spacing),i*this.ratios[1]))),n=Math.round(Math.max(Math.max(1*this.minWidth,.33*(this.maxWidth-2*this.spacing)),i*this.ratios[3])),a=e-s-n-2*this.spacing,o=Math.min(this.maxHeight-t-this.spacing,i);return[{geometry:{x:0,y:0,width:e,height:t},sides:11},{geometry:{x:0,y:t+this.spacing,width:s,height:o},sides:12},{geometry:{x:s+this.spacing,y:t+this.spacing,width:a,height:o},sides:4},{geometry:{x:s+this.spacing+a+this.spacing,y:t+this.spacing,width:n,height:o},sides:6}]}layoutFourLeftAndOther(){const e=this.maxHeight,t=Math.round(Math.min(e*this.ratios[0],.6*(this.maxWidth-this.spacing))),i=Math.round((this.maxHeight-2*this.spacing)/(1/this.ratios[1]+1/this.ratios[2]+1/this.ratios[3])),s=Math.round(i/this.ratios[1]),n=Math.round(i/this.ratios[2]),a=e-s-n-2*this.spacing,o=Math.max(this.minWidth,Math.min(this.maxWidth-t-this.spacing,i));return[{geometry:{x:0,y:0,width:t,height:e},sides:13},{geometry:{x:t+this.spacing,y:0,width:o,height:s},sides:3},{geometry:{x:t+this.spacing,y:s+this.spacing,width:o,height:n},sides:2},{geometry:{x:t+this.spacing,y:s+n+2*this.spacing,width:o,height:a},sides:6}]}static countRatios(e){return e.map((e=>e.w/e.h))}static countProportions(e){return e.map((e=>e>1.2?"w":e<.8?"n":"q")).join("")}}class o{constructor(e,t,i,s,n,a=4*i/3){this.averageRatio=t,this.maxWidth=i,this.minWidth=s,this.spacing=n,this.maxHeight=a,this.ratios=o.cropRatios(e,t),this.count=e.length}static cropRatios(e,t){return e.map((e=>t>1.1?(0,n.Z)(e,1,2.75):(0,n.Z)(e,.6667,1)))}layout(){const e=new Array(this.count),t=[],i=(e,t)=>{const i=this.ratios.slice(e,e+t),n=(0,s.Z)(i,0);return(this.maxWidth-(t-1)*this.spacing)/n},n=e=>{const s=[];let n=0;for(const t of e)s.push(i(n,t)),n+=t;t.push({lineCounts:e,heights:s})};for(let e=1;e!==this.count;++e){const t=this.count-e;e>3||t>3||n([e,t])}for(let e=1;e!==this.count-1;++e)for(let t=1;t!==this.count-e;++t){const i=this.count-e-t;e>3||t>(this.averageRatio<.85?4:3)||i>3||n([e,t,i])}for(let e=1;e!==this.count-1;++e)for(let t=1;t!==this.count-e;++t)for(let i=1;i!==this.count-e-t;++i){const s=this.count-e-t-i;e>3||t>3||i>3||s>3||n([e,t,i,s])}let a=null,o=0;for(const e of t){const{heights:t,lineCounts:i}=e,n=i.length,r=(0,s.Z)(t,0)+this.spacing*(n-1),d=Math.min(...t),l=(Math.max(...t),d<this.minWidth?1.5:1),c=(()=>{for(let e=1;e!==n;++e)if(i[e-1]>i[e])return 1.5;return 1})(),h=Math.abs(r-this.maxHeight)*l*c;(!a||h<o)&&(a=e,o=h)}const r=a.lineCounts,d=a.heights,l=r.length;let c=0,h=0;for(let t=0;t!==l;++t){const i=r[t],s=d[t],n=Math.round(s);let a=0;for(let o=0;o!==i;++o){const r=0|(0===t?1:0)|(t===l-1?4:0)|(0===o?8:0)|(o===i-1?2:0),d=this.ratios[c],u=o===i-1?this.maxWidth-a:Math.round(d*s);e[c]={geometry:{x:a,y:h,width:u,height:n},sides:r},a+=u+this.spacing,++c}h+=n+this.spacing}return e}}function r(e){const t=new a(e.items,e.maxWidth,e.minWidth,e.spacing,e.maxHeight).layout(),i=t.find((e=>2&e.sides)),s=i.geometry.width+i.geometry.x,n=t.find((e=>4&e.sides)),o=n.geometry.height+n.geometry.y,r=e.container;r.style.width=s+"px",r.style.height=o+"px";const d=r.children;t.forEach((({geometry:t,sides:i},n)=>{let a;if(a=d[n],a||(a=document.createElement("div"),r.append(a)),a.classList.add("album-item","grouped-item"),a.style.width=t.width/s*100+"%",a.style.height=t.height/o*100+"%",a.style.top=t.y/o*100+"%",a.style.left=t.x/s*100+"%",8&i&&1&i&&(a.style.borderTopLeftRadius="inherit"),8&i&&4&i&&(a.style.borderBottomLeftRadius="inherit"),2&i&&1&i&&(a.style.borderTopRightRadius="inherit"),2&i&&4&i&&(a.style.borderBottomRightRadius="inherit"),e.forMedia){const e=document.createElement("div");e.classList.add("album-item-media"),a.append(e)}}))}},9931:(e,t,i)=>{"use strict";i.d(t,{Z:()=>y,Y:()=>v});var s=i(4059),n=i(6740),a=i(5565),o=i(130),r=i(9674),d=i(5990),l=i(7256),c=i(1507),h=i(5798),u=i(3512),p=i(9345),f=i(319),m=i(5994),g=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};function v(e,t,i,o,d=new Image,l=!1){return g(this,void 0,void 0,(function*(){const l=yield u.Z.managers.acknowledged.appAvatarsManager.loadAvatar(t,i,o),c=l.result,h=l.cached;let p,g,b;if(d.classList.add("avatar-photo"),h)g=()=>{(0,a.Z)(e,d),e.dataset.color=""};else{const l=m.Z.isAvailable("animations");l&&d.classList.add("fade-in");let c=!1;if("photo_big"===o){const s=yield v(e,t,i,"photo_small");p=s.loadThumbPromise||s.loadPromise,b=s.thumbImage}else if(i.stripped_thumb){b=new Image,e.classList.add("avatar-relative"),b.classList.add("avatar-photo","avatar-photo-thumbnail");const t=(0,s.Z)(i.stripped_thumb);p=(0,n.cj)(b,t).then((()=>{c||(0,a.Z)(e,b)}))}g=()=>{c=!0,b?e.append(d):(0,a.Z)(e,d),setTimeout((()=>{e.childElementCount&&r.Z.mutateElement(d,(()=>{e.dataset.color="",l&&d.classList.remove("fade-in"),null==b||b.remove()}))}),l?200:0)}}const y=c.then((e=>(0,n.cj)(d,e))).then(g);return p&&(yield p.catch(f.Z)),{cached:h,loadPromise:y,loadThumbPromise:h?y:p||Promise.resolve(),thumbImage:b}}))}function b(e,t,i,s,n,a){(0,o.Z)(e,t),e.dataset.color=i,e.classList.remove("tgico-saved","tgico-deletedaccount","tgico-reply_filled","is-forum","is-topic"),s&&e.classList.add(s),n&&e.classList.add("is-forum"),a&&e.classList.add("is-topic")}function y({div:e,peerId:t,isDialog:i=!1,title:s="",onlyThumb:n=!1,isBig:a,threadId:o,wrapOptions:r={}}){var f,m;return g(this,void 0,void 0,(function*(){const g=u.Z.myId;if(t===g&&i)return void b(e,"","","tgico-saved");const y=u.Z.managers;if(o){const i=yield y.dialogsStorage.getForumTopic(t,o);return b(e,"","",void 0,void 0,!0),r.customEmojiSize&&e.style.setProperty("--size",r.customEmojiSize.width+"px"),(0,p.e)(Object.assign(Object.assign({},r),{topic:i,lazyLoadQueue:!1})).then((t=>{e.replaceChildren(t)}))}const w=yield y.appPeersManager.getPeer(t);if(t!==c.NM&&t.isUser()&&(null===(f=null==w?void 0:w.pFlags)||void 0===f?void 0:f.deleted))return void b(e,"",(0,d.Z)(t),"tgico-deletedaccount");const S=!!(null===(m=null==w?void 0:w.pFlags)||void 0===m?void 0:m.forum),C=a?"photo_big":"photo_small",L=(0,l.Z)(w),E=!!L,I=!!e.firstElementChild&&!e.firstElementChild.classList.contains("emoji");if(!E||!I||!(yield y.appAvatarsManager.isAvatarCached(t,C))){let n="";if(!t||t===g&&i||(n=(0,d.Z)(t)),t===c.hj)return void b(e,"",n,"tgico-reply_filled");const a=s?(0,h.Z)(s):function(e){var t;let i="";return e&&(i=null!==(t=e.title)&&void 0!==t?t:[e.first_name,e.last_name].filter(Boolean).join(" ")),(0,h.Z)(i)}(w);b(e,a,n,"",S)}return E?v(e,t,L,C,void 0,n):void 0}))}},279:(e,t,i)=>{"use strict";function s(e,t=!1){const i='\n <svg xmlns="http://www.w3.org/2000/svg" class="preloader-circular" viewBox="25 25 50 50">\n <circle class="preloader-path" cx="50" cy="50" r="20" fill="none" stroke-miterlimit="10"/>\n </svg>';if(t){const t=document.createElement("div");return t.classList.add("preloader"),t.innerHTML=i,e&&e.appendChild(t),t}return e.insertAdjacentHTML("beforeend",i),e.lastElementChild}function n(e,t="check"){return e.classList.remove("tgico-"+t),e.disabled=!0,s(e),()=>{e.replaceChildren(),e.classList.add("tgico-"+t),e.removeAttribute("disabled")}}i.d(t,{p:()=>n,y:()=>s}),i(410).GO.putPreloader=s},1218:(e,t,i)=>{"use strict";i.d(t,{Z:()=>d});var s=i(6669),n=i(9750),a=i(2325),o=i(3855),r=i(3512);class d{constructor(e){const t=this.label=document.createElement("label");t.classList.add("radio-field"),e.alignRight&&t.classList.add("radio-field-right");const i=this.input=document.createElement("input");i.type="radio",i.name="input-radio-"+e.name,e.value&&(i.value=e.value,e.stateKey&&(o.Z.getState().then((t=>{i.checked=(0,n.Z)(t,e.stateKey)===e.value})),i.addEventListener("change",(()=>{r.Z.managers.appStateManager.setByKey(e.stateKey,e.value)}))));const s=this.main=document.createElement("div");s.classList.add("radio-field-main"),e.text?s.innerHTML=e.text:e.langKey&&(0,a.$d)(s,e.langKey),t.append(i,s)}get checked(){return this.input.checked}set checked(e){this.setValueSilently(e),(0,s.Z)(this.input,"change")}setValueSilently(e){this.input.checked=e}}},5133:(e,t,i)=>{"use strict";function s(e,t){const i=document.createElement("form");return e.forEach((e=>{const{container:s,input:n}=e;i.append(s),n.addEventListener("change",(e=>{n.checked&&t(n.value,e)}))})),i}i.d(t,{Z:()=>s})},65:(e,t,i)=>{"use strict";i.d(t,{Z:()=>o});var s=i(5077),n=i(3228),a=i(5953);class o{constructor(e,t=0){this.mousedown=!1,this.events={},this.withTransition=!1,this.useTransform=!1,this.vertical=!1,this.onMouseMove=e=>{this.scrub(e)},this.onMouseDown=e=>{var t;this.rect=this.container.getBoundingClientRect(),this.mousedown=!0,this.scrub(e),this.container.classList.add("is-focused"),(null===(t=this.events)||void 0===t?void 0:t.onMouseDown)&&this.events.onMouseDown(e)},this.onMouseUp=e=>{var t;this.mousedown=!1,this.container.classList.remove("is-focused"),(null===(t=this.events)||void 0===t?void 0:t.onMouseUp)&&this.events.onMouseUp(e)},this.onInput=()=>{var e;const t=+this.seek.value;this.setFilled(t),(null===(e=this.events)||void 0===e?void 0:e.onScrub)&&this.events.onScrub(t)},(0,a.Z)(this,e),this.container=document.createElement("div"),this.container.classList.add("progress-line"),this.useTransform?this.container.classList.add("use-transform"):this.withTransition&&this.container.classList.add("with-transition"),this.filled=document.createElement("div"),this.filled.classList.add("progress-line__filled");const i=this.seek=document.createElement("input");i.classList.add("progress-line__seek"),i.type="range",i.step=""+this.step,i.min=""+this.min,i.max=""+this.max,i.value=""+t,t&&this.setProgress(t);const s=""+this.step,n=s.indexOf(".");this.decimals=-1===n?0:s.length-n-1,this.container.append(this.filled,i)}get value(){return+this.seek.value}setHandlers(e){this.events=e}setListeners(){this.seek.addEventListener("input",this.onInput),this._removeListeners=(0,s.Z)(this.container,this.onMouseDown,this.onMouseMove,this.onMouseUp)}setProgress(e){this.seek.value=""+e,this.setFilled(+this.seek.value)}addProgress(e){this.seek.value=""+(+this.seek.value+e),this.setFilled(+this.seek.value)}setFilled(e){let t=(e-this.min)/(this.max-this.min);t=(0,n.Z)(t,0,1),this.useTransform?this.filled.style.transform=`scaleX(${t})`:this.filled.style.width=100*t+"%"}scrub(e){var t;const i=this.vertical?this.rect.height:this.rect.width,s=(0,n.Z)(this.vertical?-(e.y-this.rect.bottom):e.x-this.rect.left,0,i);let a=this.min+s/i*(this.max-this.min);return a-this.min<(this.max-this.min)/2&&(a-=this.step/10),a=+a.toFixed(this.decimals),a=(0,n.Z)(a,this.min,this.max),this.setProgress(a),(null===(t=this.events)||void 0===t?void 0:t.onScrub)&&this.events.onScrub(a),a}removeListeners(){this._removeListeners&&(this._removeListeners(),this._removeListeners=null),this.seek.removeEventListener("input",this.onInput),this.events={}}}},1405:(e,t,i)=>{"use strict";i.d(t,{Z:()=>c});var s=i(8497),n=i(9674),a=i(5432),o=i(5975),r=i(3035),d=i(5994);let l=0;function c(e,t=(()=>Promise.resolve()),i=null,c=!1,h=e){if(e.querySelector(".c-ripple"))return;e.classList.add("rp");const u=document.createElement("div");let p;u.classList.add("c-ripple"),e.classList.contains("rp-square")&&u.classList.add("is-square"),e[c?"prepend":"append"](u);const f=(e,s)=>{const o=Date.now(),d=document.createElement("div"),c=l++,h=1e3*+window.getComputedStyle(u).getPropertyValue("--ripple-duration").replace("s",""),f=p=()=>{const e=Date.now()-o,t=()=>{n.Z.mutate((()=>{d.remove()})),null==i||i(c)};if(e<h){const i=Math.max(h-e,h/2);setTimeout((()=>d.classList.add("hiding")),Math.max(i-h/2,0)),setTimeout(t,i)}else d.classList.add("hiding"),setTimeout(t,h/2);a.Z||(window.removeEventListener("contextmenu",p),window.removeEventListener("mousemove",p)),p=null,g=!1};null==t||t(c),(0,r.T2)((()=>{if(f!==p)return;const t=u.getBoundingClientRect();d.classList.add("c-ripple__circle");const i=e-t.left,n=s-t.top,a=Math.sqrt(Math.pow(Math.abs(n-t.height/2)+t.height/2,2)+Math.pow(Math.abs(i-t.width/2)+t.width/2,2)),o=i-a/2,r=n-a/2;d.style.width=d.style.height=a+"px",d.style.left=o+"px",d.style.top=r+"px",u.append(d)}))},m=t=>t.target!==e&&(["BUTTON","A"].includes(t.target.tagName)||(0,s.Z)(t.target,"c-ripple")!==u)&&(h===e||!(0,o.Z)(t.target,h))&&!(0,s.Z)(t.target,"checkbox-field");let g=!1;if(a.Z){const e=()=>{null==p||p()};h.addEventListener("touchstart",(t=>{if(!d.Z.isAvailable("animations"))return;if(t.touches.length>1||g||m(t))return;g=!0;const{clientX:i,clientY:s}=t.touches[0];f(i,s),h.addEventListener("touchend",e,{once:!0}),window.addEventListener("touchmove",(t=>{t.cancelBubble=!0,t.stopPropagation(),e(),h.removeEventListener("touchend",e)}),{once:!0})}),{passive:!0})}else h.addEventListener("mousedown",(e=>{if(![0,2].includes(e.button))return;if(!d.Z.isAvailable("animations"))return;if("0"===h.dataset.ripple||m(e))return;if(g)return void(g=!1);const{clientX:t,clientY:i}=e;f(t,i),window.addEventListener("mouseup",p,{once:!0,passive:!0}),window.addEventListener("contextmenu",p,{once:!0,passive:!0})}),{passive:!0})}},7479:(e,t,i)=>{"use strict";i.d(t,{De:()=>g,ZC:()=>v,ZP:()=>f,tG:()=>m});var s=i(9807),n=i(1218),a=i(1405),o=i(5133),r=i(2325),d=i(5565),l=i(130),c=i(2738),h=i(4494),u=i(4531);const p=(e,t)=>{!0===t||("string"==typeof t?(0,l.Z)(e,t):e.append(t))};class f{constructor(e={}){this.freezed=!1,e.checkboxFieldOptions&&(e.checkboxField=new s.Z(Object.assign({listenerSetter:e.listenerSetter},e.checkboxFieldOptions)));const t=e.asLink?"a":e.radioField||e.checkboxField?"label":"div";if(this.container=document.createElement(t),this.container.classList.add("row","no-subtitle"),e.noWrap&&this.container.classList.add("no-wrap"),e.subtitle){const t=this.subtitle;if(p(t,e.subtitle),e.noWrap&&t.classList.add("no-wrap"),e.subtitleRight){this.container.append(this.subtitleRow=this.createRow()),this.subtitleRow.classList.add("row-subtitle-row");const i=this.subtitleRight=document.createElement("div");i.classList.add("row-subtitle","row-subtitle-right"),p(i,e.subtitleRight),this.subtitleRow.append(t,i)}}else e.subtitleLangKey&&this.subtitle.append((0,r.ag)(e.subtitleLangKey,e.subtitleLangArgs));let i=!!e.havePadding;if(e.radioField||e.checkboxField){if(e.radioField&&(this.radioField=e.radioField,this.container.append(this.radioField.label),i=!0),e.checkboxField){this.checkboxField=e.checkboxField;const t=e.checkboxField.label.classList.contains("checkbox-field-toggle");if(t?(this.container.classList.add("row-with-toggle"),e.titleRight=this.checkboxField.label):(i=!0,this.checkboxField.span||this.checkboxField.label.classList.add("checkbox-field-absolute"),this.container.append(this.checkboxField.label)),e.withCheckboxSubtitle&&!t){const t=()=>{(0,d.Z)(this.subtitle,(0,r.ag)(this.checkboxField.input.checked?"Checkbox.Enabled":"Checkbox.Disabled"))};e.listenerSetter?e.listenerSetter.add(this.checkboxField.input)("change",t):this.checkboxField.input.addEventListener("change",t)}}(e.radioField||e.checkboxField).label.classList.add("disable-hover")}if(e.title||e.titleLangKey||e.titleRight||e.titleRightSecondary){let t;const i=e.titleRight||e.titleRightSecondary;if(i?(this.container.append(t=this.titleRow=this.createRow()),this.titleRow.classList.add("row-title-row")):t=this.container,this._title=this.createTitle(),e.noWrap&&this.title.classList.add("no-wrap"),e.title?p(this.title,e.title):e.titleLangKey&&this.title.append((0,r.ag)(e.titleLangKey)),t.append(this.title),i){const s=this.titleRight=document.createElement("div");s.classList.add("row-title","row-title-right"),e.titleRightSecondary&&s.classList.add("row-title-right-secondary"),p(s,i),t.append(s)}}e.icon&&(i=!0,this.container.classList.add("tgico","tgico-"+e.icon),this.container.classList.add("row-with-icon")),i&&this.container.classList.add("row-with-padding"),e.navigationTab&&(e.clickable=()=>e.navigationTab.open()),(e.clickable||e.radioField||e.checkboxField)&&("function"==typeof e.clickable&&(0,c.fc)(this.container,(t=>{this.freezed||e.clickable(t)}),{listenerSetter:e.listenerSetter}),this.container.classList.add("row-clickable","hover-effect"),e.noRipple||(0,a.Z)(this.container,void 0,void 0,!0)),(e.buttonRight||e.buttonRightLangKey)&&(this.buttonRight=e.buttonRight instanceof HTMLElement?e.buttonRight:(0,h.Z)("btn-primary btn-color-primary",{text:e.buttonRightLangKey}),this.container.append(this.buttonRight)),e.contextMenu&&(0,u.Z)(Object.assign(Object.assign({},e.contextMenu),{listenTo:this.container,listenerSetter:e.listenerSetter}))}get title(){return this._title}get subtitle(){var e;return null!==(e=this._subtitle)&&void 0!==e?e:this._subtitle=this.createSubtitle()}get midtitle(){var e;return null!==(e=this._midtitle)&&void 0!==e?e:this._midtitle=this.createMidtitle()}createRow(){const e=document.createElement("div");return e.classList.add("row-row"),e}createTitle(){const e=document.createElement("div");return e.classList.add("row-title"),(0,l.m)(e),e}createSubtitle(){const e=document.createElement("div");return e.classList.add("row-subtitle"),(0,l.m)(e),this.title?this.title.after(e):this.container.prepend(e),this.container.classList.remove("no-subtitle"),e}createMidtitle(){const e=document.createElement("div");return e.classList.add("row-midtitle"),this.subtitle.parentElement.insertBefore(e,this.subtitle),e}createMedia(e){const t=document.createElement("div");return this.applyMediaElement(t,e)}applyMediaElement(e,t){return this.container.classList.add("row-with-padding"),this.media=e,e.classList.add("row-media"),t&&e.classList.add("row-media-"+t),this.container.append(e),e}isDisabled(){return this.container.classList.contains("is-disabled")}toggleDisability(e=!this.container.classList.contains("is-disabled")){return this.container.classList.toggle("is-disabled",e),()=>this.toggleDisability(!e)}disableWithPromise(e){const t=this.toggleDisability(!0);e.finally((()=>{t()}))}makeSortable(){const e=document.createElement("span");this.container.classList.add("row-sortable","tgico"),e.classList.add("row-sortable-icon","tgico-menu"),this.container.append(e)}toggleSorting(e){this.container.classList.toggle("cant-sort",!e)}}const m=e=>new f({checkboxField:e,listenerSetter:e.listenerSetter}),g=(e,t)=>(0,o.Z)(e.map((e=>({container:e.container,input:e.radioField.input}))),t),v=(e,t)=>{const i="name-"+(8388607*Math.random()|0);let s;const a=e.map((({langPackKey:e,value:t,checked:a})=>{const o=new f({radioField:new n.Z({langKey:e,name:i,value:""+t})});return a&&(s=o.radioField),o})),o=g(a,t);return s&&(s.checked=!0),o}},8805:(e,t,i)=>{"use strict";i.d(t,{ZP:()=>l,v7:()=>c});var s=i(5432),n=i(5003),a=i(4789),o=i(8594),r=i(3910);class d{constructor(e,t="",i=document.createElement("div")){this.el=e,this.container=i,this.onScrollMeasure=0,this.lastScrollPosition=0,this.lastScrollDirection=0,this.isHeavyAnimationInProgress=!1,this.needCheckAfterAnimation=!1,this.onScroll=()=>{if(this.isHeavyAnimationInProgress)return this.cancelMeasure(),void(this.needCheckAfterAnimation=!0);(this.onScrolledTop||this.onScrolledBottom||this.splitUp||this.onAdditionalScroll)&&(this.onScrollMeasure||(this.onScrollMeasure=window.setTimeout((()=>{this.onScrollMeasure=0;const e=this.container[this.scrollProperty];this.lastScrollDirection=this.lastScrollPosition===e?0:this.lastScrollPosition<e?1:-1,this.lastScrollPosition=e,this.onAdditionalScroll&&this.onAdditionalScroll(),this.checkForTriggers&&this.checkForTriggers()}),24)))},this.container.classList.add("scrollable"),this.log=(0,n.kg)("SCROLL"+(t?"-"+t:""),n.v9.Error),e&&(Array.from(e.children).forEach((e=>this.container.append(e))),e.append(this.container))}addScrollListener(){this.addedScrollListener||(this.addedScrollListener=!0,this.container.addEventListener("scroll",this.onScroll,{passive:!0,capture:!0}))}removeScrollListener(){this.addedScrollListener&&(this.addedScrollListener=!1,this.container.removeEventListener("scroll",this.onScroll,{capture:!0}))}setListeners(){this.removeHeavyAnimationListener||(window.addEventListener("resize",this.onScroll,{passive:!0}),this.addScrollListener(),this.removeHeavyAnimationListener=(0,o.ZP)((()=>{this.isHeavyAnimationInProgress=!0,this.onScrollMeasure&&(this.cancelMeasure(),this.needCheckAfterAnimation=!0)}),(()=>{this.isHeavyAnimationInProgress=!1,this.needCheckAfterAnimation&&(this.onScroll(),this.needCheckAfterAnimation=!1)})))}removeListeners(){this.removeHeavyAnimationListener&&(window.removeEventListener("resize",this.onScroll),this.removeScrollListener(),this.removeHeavyAnimationListener(),this.removeHeavyAnimationListener=void 0)}destroy(){this.removeListeners(),this.onAdditionalScroll=void 0,this.onScrolledTop=void 0,this.onScrolledBottom=void 0}append(...e){this.container.append(...e)}scrollIntoViewNew(e){return(0,a.Z)(Object.assign(Object.assign({},e),{container:this.container}))}cancelMeasure(){this.onScrollMeasure&&(clearTimeout(this.onScrollMeasure),this.onScrollMeasure=0)}}class l extends d{constructor(e,t="",i=300,s){super(e,t),this.onScrollOffset=i,this.loadedAll={top:!0,bottom:!1},this.checkForTriggers=()=>{if(!this.onScrolledTop&&!this.onScrolledBottom)return;if(this.isHeavyAnimationInProgress)return void this.onScroll();const e=this.container.scrollHeight;if(!e)return;const t=e-this.container.clientHeight,i=this.lastScrollPosition;this.onScrolledTop&&i<=this.onScrollOffset&&this.lastScrollDirection<=0&&this.onScrolledTop(),this.onScrolledBottom&&t-i<=this.onScrollOffset&&this.lastScrollDirection>=0&&this.onScrolledBottom()},this.container.classList.add("scrollable-y"),this.setListeners(),this.scrollProperty="scrollTop"}attachBorderListeners(e=this.container){const t=this.onAdditionalScroll;this.onAdditionalScroll=()=>{null==t||t(),e.classList.toggle("scrolled-top",!this.scrollTop),e.classList.toggle("scrolled-bottom",this.isScrolledDown)},e.classList.add("scrolled-top","scrolled-bottom","scrollable-y-bordered")}setVirtualContainer(e){this.splitUp=e,this.log("setVirtualContainer:",e,this)}prepend(...e){(this.splitUp||this.padding||this.container).prepend(...e)}append(...e){(this.splitUp||this.padding||this.container).append(...e)}getDistanceToEnd(){return this.scrollHeight-Math.round(this.scrollTop+this.container.offsetHeight)}get isScrolledDown(){return this.getDistanceToEnd()<=1}set scrollTop(e){this.container.scrollTop=e}get scrollTop(){return this.container.scrollTop}setScrollTopSilently(e){this.lastScrollPosition=e,this.ignoreNextScrollEvent(),this.scrollTop=e}ignoreNextScrollEvent(){this.removeHeavyAnimationListener&&(this.removeScrollListener(),this.container.addEventListener("scroll",(e=>{(0,r.Z)(e),this.addScrollListener()}),{capture:!0,passive:!1,once:!0}))}get scrollHeight(){return this.container.scrollHeight}}class c extends d{constructor(e,t="",i=300,n=15,a=document.createElement("div")){if(super(e,t,a),this.onScrollOffset=i,this.splitCount=n,this.container=a,this.container.classList.add("scrollable-x"),!s.Z){const e=e=>{!e.deltaX&&this.container.scrollWidth>this.container.clientWidth&&(this.container.scrollLeft+=e.deltaY/4,(0,r.Z)(e))};this.container.addEventListener("wheel",e,{passive:!1})}this.scrollProperty="scrollLeft"}}},5029:(e,t,i)=>{"use strict";i.d(t,{R:()=>r,Z:()=>o});var s=i(2325),n=i(36);const a="sidebar-left-section";class o{constructor(e={}){var t;const i=this.container=document.createElement("div");i.classList.add(a+"-container");const o=this.innerContainer=document.createElement("div");if(o.classList.add(a),e.noShadow&&o.classList.add("no-shadow"),e.fakeGradientDelimiter)o.append((0,n.G)()),o.classList.add("with-fake-delimiter");else if(e.noDelimiter)o.classList.add("no-delimiter");else{const e=document.createElement("hr");o.append(e)}const r=this.content=this.generateContentElement();if(e.name){const t=this.title=document.createElement("div");t.classList.add("sidebar-left-h2",a+"-name"),(0,s.XZ)({element:t,key:e.name,args:e.nameArgs}),r.append(t)}i.append(o);const d=null!==(t=e.caption)&&void 0!==t?t:e.captionOld;if(d){const t=this.caption=this.generateContentElement();t.classList.add(a+"-caption"),e.captionOld||i.append(t),!0!==d&&(0,s.XZ)({element:t,key:d,args:e.captionArgs})}}generateContentElement(){const e=document.createElement("div");return e.classList.add(a+"-content"),this.innerContainer.append(e),e}}const r=(e,t,i)=>{const s=new o({name:t,caption:i});return e.append(s.container),s.content}},7856:(e,t,i)=>{"use strict";i.d(t,{ir:()=>Qt,ZP:()=>ei});var s=i(7030),n=i(3512),a=i(5884),o=i(9331),r=i(8805),d=i(3607),l=i(3552),c=i(426),h=i(5005),u=i(503),p=i(187),f=i(2325),m=i(8119),g=i(3061),v=i(2738),b=i(5029);class y extends l._{constructor(){super(...arguments),this.uploadAvatar=null,this.isGeoChat=!1}init(e,t=!1){this.isGeoChat=t,this.peerIds=e,this.container.classList.add("new-group-container"),this.setTitle("NewGroup"),this.avatarEdit=new p.Z((e=>{this.uploadAvatar=e}));const i=new b.Z({}),n=document.createElement("div");n.classList.add("input-wrapper"),this.groupNameInputField=new u.ZP({label:"CreateGroup.NameHolder",maxLength:128}),this.groupLocationInputField=new u.ZP({label:"ChatLocation",name:"location",canBeEdited:!1}),n.append(this.groupNameInputField.container,this.groupLocationInputField.container),this.listenerSetter.add(this.groupNameInputField.input)("input",(()=>{let e=!!this.groupNameInputField.value.length&&!this.groupNameInputField.input.classList.contains("error");this.isGeoChat&&(e=e&&!!this.userLocationCoords&&!!this.userLocationAddress),this.nextBtn.classList.toggle("is-visible",!!e)})),this.nextBtn=(0,m.Z)({icon:"arrow_next"}),(0,v.fc)(this.nextBtn,(()=>{const e=this.groupNameInputField.value;let t;if(this.isGeoChat){if(!this.userLocationAddress||!this.userLocationCoords)return;t=this.managers.appChatsManager.createChannel({title:e,about:"",geo_point:Object.assign({_:"inputGeoPoint"},this.userLocationCoords),address:this.userLocationAddress,megagroup:!0}).then((e=>(this.uploadAvatar&&this.uploadAvatar().then((t=>{this.managers.appChatsManager.editPhoto(e,t)})),this.peerIds.length&&this.managers.appChatsManager.inviteToChannel(e,this.peerIds),e)))}else this.nextBtn.disabled=!0,t=this.managers.appChatsManager.createChat(e,this.peerIds.map((e=>e.toUserId()))).then((e=>(this.uploadAvatar&&this.uploadAvatar().then((t=>{this.managers.appChatsManager.editPhoto(e,t)})),e)));t&&t.then((e=>{this.close(),s.ZP.setInnerPeer({peerId:e.toPeerId(!0)})}))}),{listenerSetter:this.listenerSetter});const a=new b.Z({name:"Members",nameArgs:[this.peerIds.length]});this.peerIds.length||a.container.classList.add("hide");const o=this.list=h.default.createChatList({new:!0});a.content.append(o),i.content.append(this.avatarEdit.container,n),this.content.append(this.nextBtn),this.scrollable.append(i.container,a.container),t?(this.setTitle("NearbyCreateGroup"),this.groupLocationInputField.container.classList.remove("hide"),this.groupLocationInputField.setValueSilently(f.ZP.format("Loading",!0)),this.startLocating()):this.groupLocationInputField.container.classList.add("hide");const r=Promise.all(this.peerIds.map((e=>this.managers.appUsersManager.getUser(e.toUserId())))),d=this.managers.appUsersManager.getSelf(),l=r.then((e=>e.map((e=>{const{dom:t}=h.default.addDialogNew({peerId:e.id.toPeerId(!1),container:this.list,rippleEnabled:!1,avatarSize:"abitbigger"});t.lastMessageSpan.append((0,g.Z)(e))})))),c=this.peerIds.length>0&&this.peerIds.length<5?Promise.all([r,d]).then((([e,t])=>{const i=e.map((e=>[e.first_name,e.last_name].filter(Boolean).join(" ")));i.unshift(t.first_name);const s=(0,f.A1)(i,(e=>e?", ":" & ")).join("");this.groupNameInputField.setDraftValue(s)})):Promise.resolve();return Promise.all([l,c])}onCloseAfterTimeout(){this.avatarEdit.clear(),this.uploadAvatar=null,this.groupNameInputField.value="",this.groupLocationInputField.container.classList.add("hide"),this.nextBtn.disabled=!1}startLocating(){navigator.geolocation.getCurrentPosition((e=>{this.userLocationCoords={lat:e.coords.latitude,long:e.coords.longitude};let t="https://nominatim.openstreetmap.org/reverse";t+="?lat="+e.coords.latitude,t+="&lon="+e.coords.longitude,t+="&format=json",t+="&addressdetails=1",t+="&accept-language=en",fetch(t).then((e=>e.json())).then((e=>{this.userLocationAddress=e.display_name,this.groupLocationInputField.setValueSilently(e.display_name)}))}),(e=>{e instanceof GeolocationPositionError?this.groupLocationInputField.setValueSilently("Location permission denied. Please retry later."):this.groupLocationInputField.setValueSilently("An error has occurred. Please retry later.")}))}}var w,S=i(6360),C=i(632),L=i(410),E=i(5322),I=i(6024),P=i(7479),Z=i(5565),M=i(144);function k(e){const t=[],i={users:[],chats:[]},s={users:[],chats:[]};return e.forEach((e=>{switch(e._){case"privacyValueAllowAll":t.push(2);break;case"privacyValueDisallowAll":t.push(0);break;case"privacyValueAllowContacts":t.push(1);break;case"privacyValueAllowChatParticipants":i.chats.push(...e.chats);break;case"privacyValueAllowUsers":i.users.push(...e.users);break;case"privacyValueDisallowChatParticipants":s.chats.push(...e.chats);break;case"privacyValueDisallowUsers":s.users.push(...e.users)}})),{type:t[0],disallowPeers:s,allowPeers:i}}!function(e){e[e.Everybody=2]="Everybody",e[e.Contacts=1]="Contacts",e[e.Nobody=0]="Nobody"}(w||(w={}));const T=w;var x=i(1218),A=i(5670);class _{constructor(e){this.options=e,this.onRadioChange=e=>{e=+e,this.type=e;const t=this.options.captions[this.type],i=this.radioSection.caption;t?t instanceof HTMLElement?(0,Z.Z)(i,t):(0,f.$d)(i,t):i.replaceChildren(),i.classList.toggle("hide",!t),this.exceptions&&(this.exceptions.get("allow").row.container.classList.toggle("hide",this.type===T.Everybody),this.exceptions.get("disallow").row.container.classList.toggle("hide",this.type===T.Nobody)),this.options.onRadioChange&&this.options.onRadioChange(e)},e.captions&&e.captions.reverse();const t=e.managers;this.radioSection=new b.Z({name:e.title,caption:!0}),this.radioRows=new Map;let i=[{type:T.Everybody,langKey:"PrivacySettingsController.Everbody"},{type:T.Contacts,langKey:"PrivacySettingsController.MyContacts"},{type:T.Nobody,langKey:"PrivacySettingsController.Nobody"}];e.skipTypes&&(i=i.filter((t=>!e.skipTypes.includes(t.type))));const s=(0,M.a)();i.forEach((({type:e,langKey:t})=>{const i=new P.ZP({radioField:new x.Z({langKey:t,name:s,value:""+e})});this.radioRows.set(e,i)}));const n=(0,P.De)([...this.radioRows.values()],this.onRadioChange);if(this.radioSection.content.append(n),e.appendTo&&e.appendTo.append(this.radioSection.container),!e.noExceptions){const t=(0,b.R)(e.appendTo,"PrivacyExceptions","PrivacySettingsController.PeerInfo");this.exceptions=new Map([["disallow",{titleLangKey:e.exceptionTexts[0],key:"disallow",row:null,icon:"deleteuser",subtitleLangKey:"PrivacySettingsController.AddUsers",clickable:!0}],["allow",{titleLangKey:e.exceptionTexts[1],key:"allow",row:null,icon:"adduser",subtitleLangKey:"PrivacySettingsController.AddUsers",clickable:!0}]]),this.exceptions.forEach((i=>{i.row=new P.ZP(i),i.row.container.addEventListener("click",(()=>{a.then((()=>{const t=this.peerIds[i.key];e.tab.slider.createTab(A.Z).open({type:"privacy",skippable:!0,title:i.titleLangKey,placeholder:"PrivacyModal.Search.Placeholder",takeOut:e=>{t.length=0,t.push(...e),i.row.subtitle.replaceChildren(...this.generateStr(this.splitPeersByType(e)))},selectedPeerIds:t})}))})),t.append(i.row.container)}))}const a=t.appPrivacyManager.getPrivacy(e.inputKey).then((i=>{const s=k(i);this.setRadio(s.type),this.exceptions&&(this.peerIds={},["allow","disallow"].forEach((e=>{const t=[],i="allow"===e?s.allowPeers:s.disallowPeers;t.push(...i.users.map((e=>e.toPeerId()))),t.push(...i.chats.map((e=>e.toPeerId(!0)))),this.peerIds[e]=t;const n=this.exceptions.get(e).row.subtitle;n.replaceChildren(),n.append(...this.generateStr(i))}))),e.tab.eventListener.addEventListener("destroy",(()=>{return i=this,s=void 0,a=function*(){const i=[];switch(this.type){case T.Everybody:i.push({_:"inputPrivacyValueAllowAll"});break;case T.Contacts:i.push({_:"inputPrivacyValueAllowContacts"});break;case T.Nobody:i.push({_:"inputPrivacyValueDisallowAll"})}if(this.exceptions){const e=[["allow","inputPrivacyValueAllowChatParticipants","inputPrivacyValueAllowUsers"],["disallow","inputPrivacyValueDisallowChatParticipants","inputPrivacyValueDisallowUsers"]];for(const[s,n,a]of e){if(this.exceptions.get(s).row.container.classList.contains("hide"))continue;const e=this.peerIds[s];if(e){const s=this.splitPeersByType(e);s.chats.length&&i.push({_:n,chats:s.chats}),s.users.length&&i.push({_:a,users:yield Promise.all(s.users.map((e=>t.appUsersManager.getUserInput(e))))})}}}t.appPrivacyManager.setPrivacy(e.inputKey,i)},new((n=void 0)||(n=Promise))((function(e,t){function o(e){try{d(a.next(e))}catch(e){t(e)}}function r(e){try{d(a.throw(e))}catch(e){t(e)}}function d(t){var i;t.done?e(t.value):(i=t.value,i instanceof n?i:new n((function(e){e(i)}))).then(o,r)}d((a=a.apply(i,s||[])).next())}));var i,s,n,a}),{once:!0})}))}setRadio(e){const t=this.radioRows.get(e);this.onRadioChange(e),t.radioField.input.checked=!0}splitPeersByType(e){const t={users:[],chats:[]};return e.forEach((e=>{t[e.isAnyChat()?"chats":"users"].push(e.isAnyChat()?e.toChatId():e)})),t}generateStr(e){return e.users.length||e.chats.length?(0,f.v_)([e.users.length?(0,f.ag)("Users",[e.users.length]):null,e.chats.length?(0,f.ag)("Chats",[e.chats.length]):null].filter(Boolean),!1):[(0,f.ag)("PrivacySettingsController.AddUsers")]}}var F=i(3532);class D extends I.h{init(){return e=this,t=void 0,s=function*(){this.container.classList.add("privacy-tab","privacy-phone-number"),this.setTitle("PrivacyPhone");const e="+"+(yield this.managers.appUsersManager.getSelf()).phone,t=document.createElement("div");t.append((0,f.ag)("PrivacyPhoneInfo"),document.createElement("br"),document.createElement("br"),(0,f.ag)("PrivacyPhoneInfo4"),document.createElement("br"),(0,F.Z)({mePath:e}));const i=new _({tab:this,title:"PrivacyPhoneTitle",inputKey:"inputPrivacyKeyPhoneNumber",captions:[t,t,""],exceptionTexts:["PrivacySettingsController.NeverShare","PrivacySettingsController.AlwaysShare"],appendTo:this.scrollable,onRadioChange:e=>{n.setRadio(T.Everybody),n.radioSection.container.classList.toggle("hide",e!==T.Nobody)},managers:this.managers}),s="PrivacyPhoneInfo3",n=new _({tab:this,title:"PrivacyPhoneTitle2",inputKey:"inputPrivacyKeyAddedByPhone",captions:[s,s,""],noExceptions:!0,skipTypes:[T.Nobody],managers:this.managers});this.scrollable.container.insertBefore(n.radioSection.container,i.radioSection.container.nextSibling)},new((i=void 0)||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}));var e,t,i,s}}var R=i(4494),B=i(1168),N=i(8127),O=i(5772),U=i(279);class H extends l._{init(){this.container.classList.add("two-step-verification","two-step-verification-set"),this.setTitle("TwoStepVerificationPasswordSet");const e=new b.Z({captionOld:"TwoStepVerificationPasswordSetInfo",noDelimiter:!0}),t=document.createElement("div");(0,O.Z)({emoji:"🥳",div:t,width:160,height:160}),e.content.append(t);const i=e.generateContentElement(),s=document.createElement("div");s.classList.add("input-wrapper");const n=(0,R.Z)("btn-primary btn-color-primary",{text:"TwoStepVerificationPasswordReturnSettings"});(0,v.fc)(n,(e=>{this.close()})),this.slider.sliceTabsUntilTab(kt,this),s.append(n),i.append(s),this.scrollable.container.append(e.container)}}var z=i(4489),j=i(4762);function G(e){return!j.IS_MOBILE_SAFARI||!e}var V=i(1656);class K extends l._{constructor(){super(...arguments),this.isFirst=!1}init(){this.container.classList.add("two-step-verification","two-step-verification-email-confirmation"),this.setTitle("TwoStepAuth.RecoveryTitle");const e=new b.Z({captionOld:!0,noDelimiter:!0});(0,f.$d)(e.caption,"TwoStepAuth.ConfirmEmailCodeDesc",[this.email]);const t=document.createElement("div");(0,O.Z)({div:t,width:160,height:160,emoji:"📬"}),e.content.append(t);const i=e.generateContentElement(),s=document.createElement("div");s.classList.add("input-wrapper");const n=this.codeInputField=new z.Z({name:"recovery-email-code",label:"TwoStepAuth.RecoveryCode",length:this.length,onFill:e=>{d(!0),this.managers.passwordManager.confirmPasswordEmail(""+e).then((e=>{r()})).catch((e=>{switch(e.type){case"CODE_INVALID":n.input.classList.add("error"),(0,Z.Z)(n.label,(0,f.ag)("TwoStepAuth.RecoveryCodeInvalid"));break;case"EMAIL_HASH_EXPIRED":n.input.classList.add("error"),(0,Z.Z)(n.label,(0,f.ag)("TwoStepAuth.RecoveryCodeExpired"));break;default:console.error("confirm error",e)}d(!1)}))}}),a=(0,R.Z)("btn-primary btn-primary-transparent primary",{text:"TwoStepAuth.EmailCodeChangeEmail"}),o=(0,R.Z)("btn-primary btn-secondary btn-primary-transparent primary",{text:"ResendCode"}),r=()=>{this.slider.createTab(H).open()},d=e=>{(0,V.Z)([n.input,a,o],e)};(0,v.fc)(a,(e=>{d(!0),this.managers.passwordManager.cancelPasswordEmail().then((e=>{this.slider.sliceTabsUntilTab(q,this),this.close()}),(()=>{d(!1)}))})),(0,v.fc)(o,(e=>{d(!0);const t=(0,U.y)(o);this.managers.passwordManager.resendPasswordEmail().then((e=>{t.remove(),d(!1)}))})),s.append(n.container,a,o),i.append(s),this.scrollable.container.append(e.container)}onOpenAfterTimeout(){G(this.isFirst)&&this.codeInputField.input.focus()}}var W=i(3910),$=i(1171);class q extends l._{constructor(){super(...arguments),this.isFirst=!1}init(){this.container.classList.add("two-step-verification","two-step-verification-email"),this.setTitle("RecoveryEmailTitle");const e=new b.Z({captionOld:!0,noDelimiter:!0}),t=document.createElement("div");(0,O.Z)({div:t,width:160,height:160,emoji:"💌"}),e.content.append(t);const i=e.generateContentElement(),s=document.createElement("div");s.classList.add("input-wrapper");const n=this.inputField=new u.ZP({name:"recovery-email",label:"RecoveryEmail",plainText:!0});n.input.addEventListener("keypress",(e=>{if("Enter"===e.key)return(0,W.Z)(e),d()})),n.input.addEventListener("input",(e=>{n.input.classList.remove("error")}));const a=(0,R.Z)("btn-primary btn-color-primary",{text:"Continue"}),o=(0,R.Z)("btn-primary btn-secondary btn-primary-transparent primary",{text:"YourEmailSkip"}),r=()=>{this.slider.createTab(H).open()},d=()=>{const e=n.value.trim(),t=(0,$.Z)(e);if(!t||t[0].length!==e.length)return void n.input.classList.add("error");l(!0);const i=(0,U.y)(a);this.managers.passwordManager.updateSettings({hint:this.hint,currentPassword:this.plainPassword,newPassword:this.newPassword,email:e}).then((e=>{r()}),(t=>{if(t.type.includes("EMAIL_UNCONFIRMED")){const i=+t.type.match(/^EMAIL_UNCONFIRMED_(\d+)/)[1],s=this.slider.createTab(K);s.state=this.state,s.email=e,s.length=i,s.open()}else console.log("password set error",t);l(!1),i.remove()}))};(0,v.fc)(a,d);const l=e=>{e?(a.setAttribute("disabled","true"),o.setAttribute("disabled","true")):(a.removeAttribute("disabled"),o.removeAttribute("disabled"))};(0,v.fc)(o,(e=>{B.Z.createPopup(N.Z,"popup-skip-email",{buttons:[{langKey:"Cancel",isCancel:!0},{langKey:"YourEmailSkip",callback:()=>{l(!0),(0,U.y)(o),this.managers.passwordManager.updateSettings({hint:this.hint,currentPassword:this.plainPassword,newPassword:this.newPassword,email:""}).then((()=>{r()}),(e=>{l(!1)}))},isDanger:!0}],titleLangKey:"YourEmailSkipWarning",descriptionLangKey:"YourEmailSkipWarningText"}).show()})),s.append(n.container,a,o),i.append(s),this.scrollable.container.append(e.container)}onOpenAfterTimeout(){G(this.isFirst)&&this.inputField.input.focus()}}var Y=i(130),Q=i(8115),X=i(4425),J=i(6830),ee=i(3083),te=i(2796);class ie extends l._{init(){this.container.classList.add("two-step-verification","two-step-verification-hint"),this.setTitle("TwoStepAuth.SetupHintTitle");const e=new b.Z({noDelimiter:!0}),t=document.createElement("div");(0,O.Z)({div:t,width:160,height:160,emoji:"💡"}),e.content.append(t);const i=document.createElement("div");i.classList.add("input-wrapper");const s=this.inputField=new u.ZP({name:"hint",label:"TwoStepAuth.SetupHintPlaceholder"});s.input.addEventListener("keypress",(e=>{if("Enter"===e.key)return(0,W.Z)(e),s.value?r():d()}));const n=(e,t)=>{e&&(0,W.Z)(e);const i=t?s.value:void 0;if(i&&this.newPassword===i)return void(0,te.Am)(f.ZP.format("PasswordAsHintError",!0));const n=this.slider.createTab(q);n.state=this.state,n.plainPassword=this.plainPassword,n.newPassword=this.newPassword,n.hint=i,n.open()},a=(0,R.Z)("btn-primary btn-color-primary",{text:"Continue"}),o=(0,R.Z)("btn-primary btn-secondary btn-primary-transparent primary",{text:"YourEmailSkip"}),r=e=>n(e,!0),d=e=>n(e,!1);(0,v.fc)(a,r),(0,v.fc)(o,d),i.append(s.container,a,o),e.content.append(i),this.scrollable.container.append(e.container)}onOpenAfterTimeout(){this.inputField.input.focus()}}class se extends l._{init(){this.container.classList.add("two-step-verification","two-step-verification-enter-password","two-step-verification-re-enter-password"),this.setTitle("PleaseReEnterPassword");const e=new b.Z({noDelimiter:!0}),t=document.createElement("div");t.classList.add("input-wrapper");const i=this.passwordInputField=new J.Z({name:"re-enter-password",label:"PleaseReEnterPassword"}),s=new ee.Z(i,157),n=(0,R.Z)("btn-primary btn-color-primary",{text:"Continue"});t.append(i.container,n),e.content.append(s.container,t),this.scrollable.container.append(e.container),i.input.addEventListener("keypress",(e=>{if(i.input.classList.contains("error")&&i.setState(u.I1.Neutral),"Enter"===e.key)return o()}));const a=()=>this.newPassword===i.value||(i.setError(),!1),o=e=>{if(e&&(0,W.Z)(e),!a())return;const t=this.slider.createTab(ie);t.state=this.state,t.plainPassword=this.plainPassword,t.newPassword=this.newPassword,t.open()};return(0,v.fc)(n,o),s.load()}onOpenAfterTimeout(){this.passwordInputField.input.focus()}}class ne extends l._{constructor(){super(...arguments),this.isFirst=!0}init(){const e=!this.state.pFlags.has_password||this.plainPassword;this.container.classList.add("two-step-verification","two-step-verification-enter-password"),this.setTitle(e?"PleaseEnterFirstPassword":"PleaseEnterCurrentPassword");const t=new b.Z({noDelimiter:!0}),i=document.createElement("div");i.classList.add("input-wrapper");const s=this.passwordInputField=new J.Z({name:"enter-password",label:e?"PleaseEnterFirstPassword":this.state.hint?void 0:"LoginPassword",labelText:!e&&this.state.hint?(0,Q.Z)(this.state.hint):void 0}),n=new X.Z(s,157),a=(0,R.Z)("btn-primary btn-color-primary"),o=new f.ZP.IntlElement({key:"Continue"});a.append(o.element),i.append(s.container,a),t.content.append(n.container,i),this.scrollable.container.append(t.container),s.input.addEventListener("keypress",(e=>{if(s.input.classList.contains("error")&&(s.input.classList.remove("error"),o.key="Continue",o.update()),"Enter"===e.key)return d()}));const r=()=>!!s.value.length||(s.input.classList.add("error"),!1);let d;if(e)d=e=>{if(e&&(0,W.Z)(e),!r())return;const t=this.slider.createTab(se);t.state=this.state,t.newPassword=s.value,t.plainPassword=this.plainPassword,t.open()};else{let e;const t=()=>(e||(e=window.setInterval(t,1e4)),this.managers.passwordManager.getState().then((e=>{this.state=e,this.state.hint?(0,Y.Z)(s.label,(0,Q.Z)(this.state.hint)):(0,Z.Z)(s.label,(0,f.ag)("LoginPassword"))})));d=i=>{if(!r())return void(0,W.Z)(i);a.setAttribute("disabled","true"),o.key="PleaseWait",o.update();const d=(0,U.y)(a),l=s.value;this.managers.passwordManager.check(s.value,this.state).then((t=>{if(console.log(t),"auth.authorization"===t._){clearInterval(e),n&&n.remove();const t=this.slider.createTab(ae);t.state=this.state,t.plainPassword=l,t.open(),this.slider.removeTabFromHistory(this)}}),(e=>{a.removeAttribute("disabled"),s.input.classList.add("error"),e.type,o.key="PASSWORD_HASH_INVALID",o.update(),d.remove(),s.select(),t()}))},t()}return(0,v.fc)(a,d),n.load()}onOpenAfterTimeout(){G(this.isFirst)&&this.passwordInputField.input.focus()}}class ae extends l._{init(){this.container.classList.add("two-step-verification","two-step-verification-main"),this.setTitle("TwoStepVerificationTitle");const e=new b.Z({captionOld:!0,noDelimiter:!0}),t=document.createElement("div");(0,O.Z)({div:t,width:168,height:168,emoji:"🔐"}),e.content.append(t);const i=e.generateContentElement();if(this.state.pFlags.has_password){(0,f.$d)(e.caption,"TwoStepAuth.GenericHelp");const t=(0,R.Z)("btn-primary btn-transparent",{icon:"edit",text:"TwoStepAuth.ChangePassword"}),s=(0,R.Z)("btn-primary btn-transparent",{icon:"passwordoff",text:"TwoStepAuth.RemovePassword"}),n=(0,R.Z)("btn-primary btn-transparent",{icon:"email",text:this.state.pFlags.has_recovery?"TwoStepAuth.ChangeEmail":"TwoStepAuth.SetupEmail"});(0,v.fc)(t,(()=>{const e=this.slider.createTab(ne);e.state=this.state,e.plainPassword=this.plainPassword,e.open()})),(0,v.fc)(s,(()=>{B.Z.createPopup(N.Z,"popup-disable-password",{buttons:[{langKey:"Disable",callback:()=>{this.managers.passwordManager.updateSettings({currentPassword:this.plainPassword}).then((()=>{this.slider.sliceTabsUntilTab(kt,this),this.close()}))},isDanger:!0}],titleLangKey:"TurnPasswordOffQuestionTitle",descriptionLangKey:"TurnPasswordOffQuestion"}).show()})),(0,v.fc)(n,(()=>{const e=this.slider.createTab(q);e.state=this.state,e.hint=this.state.hint,e.plainPassword=this.plainPassword,e.newPassword=this.plainPassword,e.isFirst=!0,e.open()})),i.append(t,s,n)}else{(0,f.$d)(e.caption,"TwoStepAuth.SetPasswordHelp");const t=document.createElement("div");t.classList.add("input-wrapper");const s=(0,R.Z)("btn-primary btn-color-primary",{text:"TwoStepVerificationSetPassword"});t.append(s),i.append(t),(0,v.fc)(s,(e=>{const t=this.slider.createTab(ne);t.state=this.state,t.open()}))}this.scrollable.container.append(e.container)}}class oe extends I.h{init(){this.container.classList.add("privacy-tab","privacy-last-seen"),this.setTitle("PrivacyLastSeen");const e="PrivacySettingsController.LastSeenDescription";new _({tab:this,title:"LastSeenTitle",inputKey:"inputPrivacyKeyStatusTimestamp",captions:[e,e,e],exceptionTexts:["PrivacySettingsController.NeverShare","PrivacySettingsController.AlwaysShare"],appendTo:this.scrollable,managers:this.managers})}}class re extends I.h{init(){this.container.classList.add("privacy-tab","privacy-profile-photo"),this.setTitle("PrivacyProfilePhoto");const e="PrivacySettingsController.ProfilePhoto.CustomHelp";new _({tab:this,title:"PrivacyProfilePhotoTitle",inputKey:"inputPrivacyKeyProfilePhoto",captions:[e,e,e],exceptionTexts:["PrivacySettingsController.NeverShare","PrivacySettingsController.AlwaysShare"],appendTo:this.scrollable,skipTypes:[T.Nobody],managers:this.managers})}}class de extends I.h{init(){this.container.classList.add("privacy-tab","privacy-forward-messages"),this.setTitle("PrivacySettings.Forwards");const e="PrivacySettingsController.Forwards.CustomHelp";new _({tab:this,title:"PrivacyForwardsTitle",inputKey:"inputPrivacyKeyForwards",captions:[e,e,e],exceptionTexts:["PrivacySettingsController.NeverAllow","PrivacySettingsController.AlwaysAllow"],appendTo:this.scrollable,managers:this.managers})}}class le extends I.h{init(){this.container.classList.add("privacy-tab","privacy-add-to-groups"),this.setTitle("PrivacySettings.Groups");const e="PrivacySettingsController.GroupDescription";new _({tab:this,title:"WhoCanAddMe",inputKey:"inputPrivacyKeyChatInvite",captions:[e,e,e],exceptionTexts:["PrivacySettingsController.NeverAllow","PrivacySettingsController.AlwaysAllow"],appendTo:this.scrollable,skipTypes:[T.Nobody],managers:this.managers})}}class ce extends I.h{init(){this.container.classList.add("privacy-tab","privacy-calls"),this.setTitle("PrivacySettings.VoiceCalls");const e="PrivacySettingsController.PhoneCallDescription";new _({tab:this,title:"WhoCanCallMe",inputKey:"inputPrivacyKeyPhoneCall",captions:[e,e,e],exceptionTexts:["PrivacySettingsController.NeverAllow","PrivacySettingsController.AlwaysAllow"],appendTo:this.scrollable,managers:this.managers});{const e="PrivacySettingsController.P2p.Desc";new _({tab:this,title:"PrivacyP2PHeader",inputKey:"inputPrivacyKeyPhoneP2P",captions:[e,e,e],exceptionTexts:["PrivacySettingsController.NeverAllow","PrivacySettingsController.AlwaysAllow"],appendTo:this.scrollable,managers:this.managers})}}}var he=i(3003),ue=i(8497),pe=i(4064),fe=i(6976),me=i(1483),ge=i(3416);class ve extends I.h{init(){this.container.classList.add("active-sessions-container"),this.setTitle("SessionsTitle");const e=e=>{const t=new P.ZP({title:[e.app_name,e.app_version].join(" "),subtitle:[e.ip,e.country].join(" - "),clickable:!0,titleRight:e.pFlags.current?void 0:(0,C.zM)(new Date(1e3*Math.max(e.date_active,e.date_created)))});return t.container.dataset.hash=""+e.hash,t.midtitle.textContent=[e.device_model,e.system_version||e.platform].filter(Boolean).join(", "),t},t=this.authorizations.slice();{const n=new b.Z({name:"CurrentSession",caption:"ClearOtherSessionsHelp"}),a=(0,pe.Z)(t,(e=>e.pFlags.current)),o=e(a);if(n.content.append(o.container),t.length){const e=(0,R.Z)("btn-primary btn-transparent danger",{icon:"stop",text:"TerminateAllSessions"});(0,v.fc)(e,(t=>{B.Z.createPopup(N.Z,"revoke-session",{buttons:[{langKey:"Terminate",isDanger:!0,callback:()=>{const t=(0,V.Z)([e],!0);this.managers.apiManager.invokeApi("auth.resetAuthorizations").then((t=>{e.remove(),i.container.remove()}),s).finally((()=>{t()}))}}],titleLangKey:"AreYouSureSessionsTitle",descriptionLangKey:"AreYouSureSessions"}).show()}),{listenerSetter:this.listenerSetter}),n.content.append(e)}this.scrollable.append(n.container)}if(!t.length)return;const i=new b.Z({name:"OtherSessions",caption:"SessionsListInfo"});t.forEach((t=>{i.content.append(e(t).container)})),this.scrollable.append(i.container);const s=e=>{"FRESH_RESET_AUTHORISATION_FORBIDDEN"===e.type&&(0,te.Am)(f.ZP.format("RecentSessions.Error.FreshReset",!0))};let n;const a=()=>{const e=n.dataset.hash;B.Z.createPopup(N.Z,"revoke-session",{buttons:[{langKey:"Terminate",isDanger:!0,callback:()=>{this.managers.apiManager.invokeApi("account.resetAuthorization",{hash:e}).then((e=>{e&&n.remove()}),s)}}],titleLangKey:"AreYouSureSessionTitle",descriptionLangKey:"TerminateSessionText"}).show()},o=this.menuElement=(0,he.b)({buttons:[{icon:"stop",text:"Terminate",onClick:a}]});o.id="active-sessions-contextmenu",o.classList.add("contextmenu"),document.getElementById("page-chats").append(o),(0,fe.E)({element:this.scrollable.container,callback:e=>{n=(0,ue.Z)(e.target,"row"),n&&"0"!==n.dataset.hash&&(e instanceof MouseEvent&&e.preventDefault(),e instanceof MouseEvent&&(e.cancelBubble=!0),(0,me.Z)(e,o),ge.Z.openBtnMenu(o))},listenerSetter:this.listenerSetter}),(0,v.fc)(this.scrollable.container,(e=>{n=(0,ue.Z)(e.target,"row"),n&&"0"!==n.dataset.hash&&a()}),{listenerSetter:this.listenerSetter})}onCloseAfterTimeout(){var e;return null===(e=this.menuElement)||void 0===e||e.remove(),super.onCloseAfterTimeout()}}var be=i(2995),ye=i(4668),we=i(8210),Se=i(5102);class Ce extends l._{init(){this.container.classList.add("blocked-users-container"),this.setTitle("BlockedUsers");const e=new b.Z({caption:"BlockedUsersInfo"});e.caption.parentElement.prepend(e.caption),this.scrollable.append(e.container);const t=(0,m.Z)({icon:"add",className:"is-visible"});this.content.append(t),(0,v.fc)(t,(e=>{B.Z.createPopup(be.Z,{peerTypes:["contacts"],placeholder:"BlockModal.Search.Placeholder",onSelect:e=>{this.managers.appUsersManager.toggleBlock(e,!0)}})}),{listenerSetter:this.listenerSetter});const i=h.default.createChatList();this.scrollable.container.classList.add("chatlist-container"),e.content.append(i);const s=(e,t)=>{return s=this,n=void 0,o=function*(){const{dom:s}=h.default.addDialogNew({peerId:e,container:i,rippleEnabled:!0,avatarSize:"abitbigger",append:t}),n=yield this.managers.appUsersManager.getUser(e.toUserId());if(!n)return;const a=(0,Se.Z)(n)[0];n.pFlags.bot?s.lastMessageSpan.append("@"+a):n.phone?s.lastMessageSpan.textContent=(0,we.Z)(n.phone):s.lastMessageSpan.append(a?"@"+a:(0,g.Z)(n))},new((a=void 0)||(a=Promise))((function(e,t){function i(e){try{d(o.next(e))}catch(e){t(e)}}function r(e){try{d(o.throw(e))}catch(e){t(e)}}function d(t){var s;t.done?e(t.value):(s=t.value,s instanceof a?s:new a((function(e){e(s)}))).then(i,r)}d((o=o.apply(s,n||[])).next())}));var s,n,a,o};for(const e of this.peerIds)s(e,!0);let a;const o=this.menuElement=(0,he.b)({buttons:[{icon:"lockoff",text:"Unblock",onClick:()=>{const e=a.dataset.peerId.toPeerId();this.managers.appUsersManager.toggleBlock(e,!1)},options:{listenerSetter:this.listenerSetter}}]});o.id="blocked-users-contextmenu",o.classList.add("contextmenu"),document.getElementById("page-chats").append(o),(0,fe.E)({element:this.scrollable.container,callback:e=>{a=(0,ye.Z)(e.target,h.DIALOG_LIST_ELEMENT_TAG),a&&(e instanceof MouseEvent&&e.preventDefault(),e instanceof MouseEvent&&(e.cancelBubble=!0),(0,me.Z)(e,o),ge.Z.openBtnMenu(o))},listenerSetter:this.listenerSetter}),this.listenerSetter.add(n.Z)("peer_block",(e=>{const{peerId:t,blocked:n}=e,a=i.querySelector(`[data-peer-id="${t}"]`);n?a||s(t,!1):a&&a.remove()}));let r=!1;this.scrollable.onScrolledBottom=()=>{r||(r=!0,this.managers.appUsersManager.getBlocked(i.childElementCount,50).then((e=>{for(const t of e.peerIds)s(t,!0);(e.peerIds.length<50||i.childElementCount===e.count)&&(this.scrollable.onScrolledBottom=null),this.scrollable.checkForTriggers()})).finally((()=>{r=!1})))}}onOpenAfterTimeout(){this.scrollable.onScroll()}onCloseAfterTimeout(){return this.menuElement&&this.menuElement.remove(),super.onCloseAfterTimeout()}}var Le=i(9807);function Ee(e){return"input"+(e[0].toUpperCase()+e.slice(1))}var Ie=i(5592),Pe=i(319);class Ze extends I.h{init(){this.container.classList.add("privacy-tab","privacy-voices"),this.setTitle("PrivacyVoiceMessages");const e="PrivacyVoiceMessagesInfo";new _({tab:this,title:"PrivacyVoiceMessagesTitle",inputKey:"inputPrivacyKeyVoiceMessages",captions:[e,e,e],exceptionTexts:["PrivacySettingsController.NeverAllow","PrivacySettingsController.AlwaysAllow"],appendTo:this.scrollable,managers:this.managers})}}var Me=i(7362),ke=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class Te extends I.h{init(e){return ke(this,void 0,void 0,(function*(){this.container.classList.add("active-sessions-container"),this.setTitle("WebSessionsTitle");const t=e=>ke(this,void 0,void 0,(function*(){const t=e.bot_id.toPeerId(),i=new P.ZP({title:yield(0,Me.Z)({peerId:t}),subtitle:[e.ip,e.region].join(" - "),clickable:!0,titleRight:(0,C.zM)(new Date(1e3*Math.max(e.date_active,e.date_created)))}),s=i.createMedia("big"),n=new o.Z;return n.classList.add("avatar-48"),yield n.updateWithOptions({peerId:t}),s.append(n),i.container.dataset.hash=""+e.hash,i.container.dataset.peerId=""+t,i.midtitle.textContent=[e.domain,e.browser,e.platform].filter(Boolean).join(", "),i}));{const e=new b.Z({caption:"ClearOtherWebSessionsHelp"}),t=(0,R.Z)("btn-primary btn-transparent danger",{icon:"stop",text:"TerminateAllWebSessions"});(0,v.fc)(t,(()=>ke(this,void 0,void 0,(function*(){yield(0,Ie.Z)({descriptionLangKey:"AreYouSureWebSessions",button:{langKey:"Disconnect",isDanger:!0}}),(0,V.Z)([t],!0),this.managers.appSeamlessLoginManager.resetWebAuthorizations().then((()=>{this.close()}))}))),{listenerSetter:this.listenerSetter}),e.content.append(t),this.scrollable.append(e.container)}{const i=new b.Z({name:"OtherWebSessions",caption:"TerminateWebSessionInfo"}),s=yield Promise.all(e.map(t));i.content.append(...s.map((e=>e.container)));let n=s.length;(0,v.fc)(i.content,(e=>ke(this,void 0,void 0,(function*(){const t=(0,ue.Z)(e.target,"row");if(!t)return;yield(0,Ie.Z)({descriptionLangKey:"TerminateWebSessionText",descriptionLangArgs:[yield(0,Me.Z)({peerId:t.dataset.peerId.toPeerId()})],button:{langKey:"Disconnect",isDanger:!0}});const i=t.dataset.hash;t.classList.add("is-disabled"),this.managers.appSeamlessLoginManager.resetWebAuthorization(i).then((()=>{--n?t.remove():this.close()}))}))),{listenerSetter:this.listenerSetter}),this.scrollable.append(i.container)}}))}}class xe extends I.h{static getInitArgs(e){return{appConfig:e.managers.apiManager.getAppConfig(),globalPrivacy:e.managers.appPrivacyManager.getGlobalPrivacySettings(),contentSettings:e.managers.apiManager.invokeApi("account.getContentSettings"),webAuthorizations:e.managers.appSeamlessLoginManager.getWebAuthorizations()}}init(e){this.container.classList.add("dont-u-dare-block-me"),this.setTitle("PrivacySettings");const t="Loading",i=[];{const s=new b.Z({noDelimiter:!0,caption:"SessionsInfo"});let a;const o=new P.ZP({icon:"deleteuser",titleLangKey:"BlockedUsers",subtitleLangKey:t,clickable:()=>{const e=this.slider.createTab(Ce);e.peerIds=a,e.open()},listenerSetter:this.listenerSetter});let r;o.freezed=!0;const d={icon:"lock",titleLangKey:"TwoStepVerification",subtitleLangKey:t,clickable:e=>{let t;r.pFlags.has_password?t=this.slider.createTab(ne):r.email_unconfirmed_pattern?(t=this.slider.createTab(K),t.email=r.email_unconfirmed_pattern,t.length=6,t.isFirst=!0,this.managers.passwordManager.resendPasswordEmail()):t=this.slider.createTab(ae),t.state=r,t.open()},listenerSetter:this.listenerSetter},l=new P.ZP(d);l.freezed=!0;const c=this.activeSessionsRow=new P.ZP({icon:"activesessions",titleLangKey:"SessionsTitle",subtitleLangKey:t,clickable:()=>{const e=this.slider.createTab(ve);e.authorizations=this.authorizations,e.eventListener.addEventListener("destroy",(()=>{this.updateActiveSessions()}),{once:!0}),e.open()},listenerSetter:this.listenerSetter});c.freezed=!0;const h=this.websitesRow=new P.ZP({icon:"mention",titleLangKey:"OtherWebSessions",subtitleLangKey:t,clickable:()=>{const e=this.slider.createTab(Te);e.eventListener.addEventListener("destroy",(()=>{this.updateActiveWebsites()})),e.open(this.websites)},listenerSetter:this.listenerSetter});h.freezed=!0,s.content.append(o.container,l.container,c.container,h.container),this.scrollable.append(s.container);const u=e=>{e?(0,Z.Z)(o.subtitle,(0,f.ag)("PrivacySettingsController.UserCount",[e])):(0,Z.Z)(o.subtitle,(0,f.ag)("BlockedEmpty",[e]))};this.listenerSetter.add(n.Z)("peer_block",(()=>{p()}));const p=()=>{this.managers.appUsersManager.getBlocked().then((e=>{o.freezed=!1,u(e.count),a=e.peerIds}))};p(),this.managers.passwordManager.getState().then((e=>{r=e,(0,Z.Z)(l.subtitle,(0,f.ag)(e.pFlags.has_password?"PrivacyAndSecurity.Item.On":"PrivacyAndSecurity.Item.Off")),l.freezed=!1})),this.updateActiveSessions(),i.push(this.updateActiveWebsites(e.webAuthorizations))}{const e=new b.Z({name:"PrivacyTitle",caption:"GroupsAndChannelsHelp"});e.content.classList.add("privacy-navigation-container");const i={},s=i.inputPrivacyKeyPhoneNumber=new P.ZP({titleLangKey:"PrivacyPhoneTitle",subtitleLangKey:t,clickable:()=>{this.slider.createTab(D).open()},listenerSetter:this.listenerSetter}),a=i.inputPrivacyKeyStatusTimestamp=new P.ZP({titleLangKey:"LastSeenTitle",subtitleLangKey:t,clickable:()=>{this.slider.createTab(oe).open()},listenerSetter:this.listenerSetter}),o=i.inputPrivacyKeyProfilePhoto=new P.ZP({titleLangKey:"PrivacyProfilePhotoTitle",subtitleLangKey:t,clickable:()=>{this.slider.createTab(re).open()},listenerSetter:this.listenerSetter}),r=i.inputPrivacyKeyPhoneCall=new P.ZP({titleLangKey:"WhoCanCallMe",subtitleLangKey:t,clickable:()=>{this.slider.createTab(ce).open()},listenerSetter:this.listenerSetter}),d=i.inputPrivacyKeyForwards=new P.ZP({titleLangKey:"PrivacyForwardsTitle",subtitleLangKey:t,clickable:()=>{this.slider.createTab(de).open()},listenerSetter:this.listenerSetter}),l=i.inputPrivacyKeyChatInvite=new P.ZP({titleLangKey:"WhoCanAddMe",subtitleLangKey:t,clickable:()=>{this.slider.createTab(le).open()},listenerSetter:this.listenerSetter}),c=i.inputPrivacyKeyVoiceMessages=new P.ZP({titleLangKey:"PrivacyVoiceMessagesTitle",subtitleLangKey:t,clickable:()=>{n.Z.premium?this.slider.createTab(Ze).open():(0,te.bC)({langPackKey:"PrivacyVoiceMessagesPremiumOnly"})},listenerSetter:this.listenerSetter}),h=e=>{const t=i[e];t&&this.managers.appPrivacyManager.getPrivacy(e).then((e=>{const i=k(e),s=i.type===T.Everybody?"PrivacySettingsController.Everbody":i.type===T.Contacts?"PrivacySettingsController.MyContacts":"PrivacySettingsController.Nobody",n=i.disallowPeers.users.length+i.disallowPeers.chats.length,a=i.allowPeers.users.length+i.allowPeers.chats.length,o=(0,f.ag)(s);t.subtitle.replaceChildren(o),(n||a)&&t.subtitle.append(` (${[-n,a?"+"+a:0].filter(Boolean).join(", ")})`)}))};e.content.append(s.container,a.container,o.container,r.container,d.container,l.container,c.container),this.scrollable.append(e.container);for(const e in i)h(e);n.Z.addEventListener("privacy_update",(e=>{h(Ee(e.key._))}))}{const t=new b.Z({name:"NewChatsFromNonContacts",caption:"ArchiveAndMuteInfo"}),s=new Le.Z({text:"ArchiveAndMute"}),a=new P.ZP({checkboxField:s});let o,r;t.content.append(a.container),this.eventListener.addEventListener("destroy",(()=>{if(r=!0,void 0!==o&&o!==s.checked)return this.managers.appPrivacyManager.setGlobalPrivacySettings({_:"globalPrivacySettings",archive_and_mute_new_noncontact_peers:s.checked})}),{once:!0});const d=Promise.all([e.appConfig,e.globalPrivacy]).then((([e,i])=>{if(r)return;const a=i=>{t.container.classList.toggle("hide",!i&&!e.autoarchive_setting_available)};this.listenerSetter.add(n.Z)("premium_toggle",a),a(n.Z.premium),o=!!i.archive_and_mute_new_noncontact_peers,s.setValueSilently(o)}));i.push(d),this.scrollable.append(t.container)}{const t=new b.Z({name:"Privacy.SensitiveContent",caption:"PrivacyAndSecurity.SensitiveDesc"});t.container.classList.add("hide");const s=new Le.Z({text:"PrivacyAndSecurity.SensitiveText"}),n=new P.ZP({checkboxField:s});let a;t.content.append(n.container),this.eventListener.addEventListener("destroy",(()=>{if(void 0===a)return;const e=n.checkboxField.checked;return e!==a?this.managers.apiManager.invokeApi("account.setContentSettings",{sensitive_enabled:e}):void 0}),{once:!0});const o=e.contentSettings.then((e=>{e.pFlags.sensitive_can_change&&(a=!!e.pFlags.sensitive_enabled,s.setValueSilently(a),t.container.classList.remove("hide"))}));i.push(o),this.scrollable.append(t.container)}{const e=new b.Z({name:"PrivacyPayments",caption:"PrivacyPaymentsClearInfo"}),t=()=>{const e={titleLangKey:"PrivacyPaymentsClearAlertTitle",descriptionLangKey:"PrivacyPaymentsClearAlertText",button:{langKey:"Clear"},checkboxes:[{text:"PrivacyClearShipping",checked:!0},{text:"PrivacyClearPayment",checked:!0}]};(0,Ie.Z)(e).then((()=>{const[t,s]=e.checkboxes.map((e=>e.checkboxField.checked)),n=(0,V.Z)([i],!0);this.managers.appPaymentsManager.clearSavedInfo(t,s).then((()=>{(t||s)&&(n(),(0,te.bC)({langPackKey:t&&s?"PrivacyPaymentsPaymentShippingCleared":t?"PrivacyPaymentsShippingInfoCleared":"PrivacyPaymentsPaymentInfoCleared"}))}))}),Pe.Z)},i=(0,R.Z)("btn-primary btn-transparent",{icon:"delete",text:"PrivacyPaymentsClear"});this.listenerSetter.add(i)("click",t),e.content.append(i),this.scrollable.append(e.container)}{const e=new b.Z({name:"FilterChats"}),t=()=>{B.Z.createPopup(N.Z,"popup-delete-drafts",{buttons:[{langKey:"Delete",callback:()=>{const e=(0,V.Z)([i],!0);this.managers.appDraftsManager.clearAllDrafts().then((()=>{e()}))},isDanger:!0}],titleLangKey:"AreYouSureClearDraftsTitle",descriptionLangKey:"AreYouSureClearDrafts"}).show()},i=(0,R.Z)("btn-primary btn-transparent",{icon:"delete",text:"PrivacyDeleteCloudDrafts"});this.listenerSetter.add(i)("click",t),e.content.append(i),this.scrollable.append(e.container)}return Promise.all(i)}updateActiveSessions(){return this.managers.apiManager.invokeApi("account.getAuthorizations").then((e=>{this.activeSessionsRow.freezed=!1,this.authorizations=e.authorizations,(0,f.$d)(this.activeSessionsRow.subtitle,"Privacy.Devices",[this.authorizations.length])}))}updateActiveWebsites(e=this.managers.appSeamlessLoginManager.getWebAuthorizations()){return e.then((e=>{this.websitesRow.freezed=!1,this.websites=e,(0,f.$d)(this.websitesRow.subtitle,"Privacy.Websites",[this.websites.length]),this.websitesRow.container.classList.toggle("hide",!this.websites.length)}))}}var Ae=i(65),_e=i(9439),Fe=i(6761);var De=i(3731),Re=i(236),Be=i(6714),Ne=i(5994),Oe=i(7238),Ue=i(5418),He=i(8610);class ze extends I.Z{init(){this.container.classList.add("power-saving-container"),this.setTitle("LiteMode.Title");const e=document.createElement("form");let t;{const i=t=new b.Z({caption:"LiteMode.Info"});e.append(i.container)}const i=["all","video","gif",["stickers",["stickers_panel","stickers_chat"]],["effects",["effects_reactions","effects_premiumstickers","effects_emoji"]],["chat",["chat_background","chat_spoilers"]],"animations"];let s,a;{const o=new b.Z({}),r=e=>{const t=Array.isArray(e),i=t?e[0]:e,s=t?(0,Oe.Z)(e[1].map(r)):void 0,a=n.Z.settings.liteMode[i];return[{key:i,text:"all"===i?"LiteMode.EnableText":`LiteMode.Key.${i}.Title`,checked:"all"===i?a:!a,nested:s,name:"power-saving-"+i},...s||[]]};s=(0,Oe.Z)(i.map(r)),a=new He.Z({fields:s,listenerSetter:this.listenerSetter}),s.forEach(((e,i)=>{const s=a.createField(e);if(!s)return;const{row:n,nodes:r}=s;(0===i?t:o).content.append(...r)})),(0,v.fc)(o.content,(()=>{n.Z.settings.liteMode.all&&(0,te.bC)({langPackKey:"LiteMode.DisableAlert"})}),{listenerSetter:this.listenerSetter}),e.append(o.container)}const o=e=>{s.forEach((t=>{"all"!==t.key&&(t.nested&&a.setNestedCounter(t,e?0:void 0),t.checkboxField.input.classList.toggle("is-fake-disabled",e),t.row.toggleDisability(e))}))};this.listenerSetter.add(e)("change",(()=>{return e=this,t=void 0,a=function*(){const e={};s.forEach((t=>{const i=t.checkboxField.checked;e[t.key]="all"===t.key?i:!i}));const t=n.Z.settings.liteMode.all;t!==e.all&&(o(!t),e.all&&(yield(0,Ue.Z)(200))),yield this.managers.appStateManager.setByKey("settings.liteMode",n.Z.settings.liteMode=e)},new((i=void 0)||(i=Promise))((function(s,n){function o(e){try{d(a.next(e))}catch(e){n(e)}}function r(e){try{d(a.throw(e))}catch(e){n(e)}}function d(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((a=a.apply(e,t||[])).next())}));var e,t,i,a})),o(n.Z.settings.liteMode.all),this.scrollable.append(e)}}var je=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class Ge{constructor(e,t,i,s,n,a=!0){const o="range-setting-selector";this.container=document.createElement("div"),this.container.classList.add(o);const r=document.createElement("div");r.classList.add(o+"-details");const d=document.createElement("div");d.classList.add(o+"-name"),(0,f.$d)(d,e);const l=this.valueContainer=document.createElement("div");l.classList.add(o+"-value"),a&&(l.innerHTML=""+i),r.append(d,l),this.range=new Ae.Z({step:t,min:s,max:n},i),this.range.setListeners(),this.range.setHandlers({onScrub:e=>{this.onChange&&this.onChange(e),a&&(l.innerText=""+e)}}),this.container.append(r,this.range.container)}}class Ve extends I.h{static getInitArgs(){return{themes:n.Z.managers.appThemesManager.getThemes()}}init(e){this.container.classList.add("general-settings-container"),this.setTitle("General");const t=b.R.bind(null,this.scrollable),i=[];{const e=t("Settings"),i=new Ge("TextSize",1,n.Z.settings.messagesTextSize,12,20);i.onChange=e=>{n.Z.managers.appStateManager.setByKey("settings.messagesTextSize",e)};const s=(0,R.Z)("btn-primary btn-transparent",{icon:"image",text:"ChatBackground"}),a=_e.Z.getInitArgs();(0,v.fc)(s,(()=>{this.slider.createTab(_e.Z).open(a)}));const o=()=>n.Z.settings.liteMode.all?"Checkbox.Enabled":"Checkbox.Disabled",r=new f.ZP.IntlElement,d=()=>{r.compareAndUpdate({key:o()}),l.setValueSilently(Ne.Z.isAvailable("animations")),l.toggleDisability(Ne.Z.isEnabled())},l=new Le.Z({text:"EnableAnimations",name:"animations",stateKey:"settings.liteMode.animations",stateValueReverse:!0,checked:!1,listenerSetter:this.listenerSetter}),c=new P.ZP({checkboxField:l,clickable:()=>{l.isDisabled()&&(0,te.bC)({langPackKey:"LiteMode.DisableAlert"})},listenerSetter:this.listenerSetter}),h=new P.ZP({icon:"animations",titleLangKey:"LiteMode.EnableText",titleRightSecondary:r.element,clickable:()=>{this.slider.createTab(ze).open()},listenerSetter:this.listenerSetter});d(),this.listenerSetter.add(n.Z)("settings_updated",d),e.append(i.container,s,c.container,h.container)}{const s=t("ColorTheme"),a=new r.v7(null),o=a.container;o.classList.add("themes-container");const d=new Map;let l=Be.Z.getTheme(),c=Be.Z.isNight();const h=e=>{Be.Z.applyTheme(e.theme,e.container);const t=e.container.querySelector(".background-item");null==t||t.remove();const i=e.wallPaperContainers[c?"baseThemeNight":"baseThemeClassic"];i&&e.container.prepend(i)};let u;(0,v.fc)(o,(e=>je(this,void 0,void 0,(function*(){const t=(0,ue.Z)(e.target,"theme-container");if(!t)return;const i=o.querySelector(".active");i&&i.classList.remove("active");const s=d.get(t);if(t.classList.add("active"),yield Be.Z.applyNewTheme(s.theme),null==u||u(-1),s.player&&Ne.Z.isAvailable("animations"))if(j.IS_SAFARI)s.player.paused&&s.player.restart();else{s.player.paused&&s.player.stop(!0),s.player.el[0].style.transform="scale(2)";const e=u=t=>{s.player.maxFrame!==t&&-1!==t||(s.player.el[0].style.transform="",s.player.removeEventListener("enterFrame",e),u===e&&(u=void 0))};setTimeout((()=>{u===e&&(s.player.play(),s.player.addEventListener("enterFrame",e))}),250)}}))),{listenerSetter:this.listenerSetter});const p=new Set(["baseThemeClassic","baseThemeNight"]),f=e.themes.then((e=>je(this,void 0,void 0,(function*(){const t=e.filter((e=>e.pFlags.default));t.unshift(Re.t);const i=t.map((e=>je(this,void 0,void 0,(function*(){const t=document.createElement("div"),i={container:t,theme:e,wallPaperContainers:{}},s=e.settings.filter((e=>p.has(e.base_theme._))).map((e=>{const t=e.wallpaper,s=_e.Z.addWallPaper(t);return i.wallPaperContainers[e.base_theme._]=s.container,s}));d.set(t,i),h(i),e.id===l.id&&t.classList.add("active");const n=[];let a;if(e.emoticon){a=document.createElement("div"),a.classList.add("theme-emoticon");const t=49;(0,O.Z)({div:a,width:t,height:t,emoji:e.emoticon,managers:this.managers,loadPromises:n,middleware:this.middlewareHelper.get(),play:!1}).then((({render:e})=>e)).then((e=>{i.player=e}))}const o=document.createElement("div");o.classList.add("theme-bubble");const r=o.cloneNode();return r.classList.add("is-in"),o.classList.add("is-out"),n.push(...s.map((e=>e.loadPromise))),t.classList.add("theme-container"),yield Promise.all(n),a&&t.append(a),t.append(r,o),t})))),s=yield Promise.all(i);a.append(...s)}))));i.push(f);const m=document.createElement("form");m.style.marginTop=".5rem";const g="theme",b="settings.theme",y=new P.ZP({radioField:new x.Z({langKey:"ThemeDay",name:g,value:"day",stateKey:b})}),w=new P.ZP({radioField:new x.Z({langKey:"ThemeNight",name:g,value:"night",stateKey:b})}),S=new P.ZP({radioField:new x.Z({langKey:"AutoNightSystemDefault",name:g,value:"system",stateKey:b})});this.listenerSetter.add(n.Z)("settings_updated",(({key:e,value:t,settings:i})=>{e===b&&n.Z.dispatchEvent("theme_change")})),this.listenerSetter.add(n.Z)("theme_change",(()=>{l=Be.Z.getTheme();const e=Be.Z.isNight();if(c===e)return;c=e;const t=o.querySelector(".active");let i;t&&t.classList.remove("active"),d.forEach((e=>{h(e),e.theme.id===l.id&&(e.container.classList.add("active"),i=e.container)})),i&&a.scrollIntoViewNew({element:i,position:"center",axis:"x"})})),m.append(y.container,w.container,S.container),s.append(o,m)}{const e=t("General.Keyboard"),i=document.createElement("form"),s="send-shortcut",n="settings.sendShortcut",a=new P.ZP({radioField:new x.Z({langKey:"General.SendShortcut.Enter",name:s,value:"enter",stateKey:n}),subtitleLangKey:"General.SendShortcut.NewLine.ShiftEnter"}),o=new P.ZP({radioField:new x.Z({name:s,value:"ctrlEnter",stateKey:n}),subtitleLangKey:"General.SendShortcut.NewLine.Enter"});(0,f.$d)(o.radioField.main,"General.SendShortcut.CtrlEnter",[j.IS_APPLE?"⌘":"Ctrl"]),i.append(a.container,o.container),e.append(i)}if(De.Z){const e=t("DistanceUnitsTitle"),i=document.createElement("form"),s="distance-unit",n="settings.distanceUnit",a=new P.ZP({radioField:new x.Z({langKey:"DistanceUnitsKilometers",name:s,value:"kilometers",stateKey:n})}),o=new P.ZP({radioField:new x.Z({langKey:"DistanceUnitsMiles",name:s,value:"miles",stateKey:n})});i.append(a.container,o.container),e.append(i)}{const e=t("General.TimeFormat"),i=document.createElement("form"),s="time-format",n="settings.timeFormat",a=[["h12","General.TimeFormat.h12"],["h23","General.TimeFormat.h23"]],o=a.map((([e,t])=>new P.ZP({radioField:new x.Z({langKey:t,name:s,value:e,stateKey:n})}))),r=function(e,t=!0){return function(e,t,i=!0){const s=e;let n;return i||(e=Pe.Z),function i(){e(),n=Fe.Z.setTimeout(i,t())}(),e=s,()=>{clearTimeout(n)}}(e,(()=>1e3*(60-(new Date).getSeconds())),t)}((()=>{const e=new Date;a.forEach((([t],i)=>{const s=e.toLocaleTimeString("en-us-u-hc-"+t,{hour:"2-digit",minute:"2-digit"});o[i].subtitle.textContent=s}))}));this.eventListener.addEventListener("destroy",r),i.append(...o.map((e=>e.container))),e.append(i)}return Promise.all(i)}}var Ke=i(2010),We=i(1447),$e=i(534),qe=i(4484),Ye=i(1507),Qe=i(2914),Xe=i(2648),Je=i(1655),et=i(3186),tt=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class it extends l._{constructor(){super(...arguments),this.filtersRendered={}}static getInitArgs(){return{animationData:We.Z.loadAnimationFromURLManually("Folders_1"),filters:n.Z.managers.filtersStorage.getDialogFilters()}}renderFolder(e,t,i,s){return tt(this,void 0,void 0,(function*(){let n,a="";const o=[];if("dialogFilterSuggested"===e._)n=e.filter,a=e.description;else{if(n=e,1===Object.keys(n.pFlags).length){const e=n.pFlags;let t;e.contacts?t="FilterAllContacts":e.non_contacts?t="FilterAllNonContacts":e.groups?t="FilterAllGroups":e.broadcasts?t="FilterAllChannels":e.bots&&(t="FilterAllBots"),t&&o.push((0,f.ag)(t))}if(!o.length){const e=yield this.managers.dialogsStorage.getFolderDialogs(n.id);let t=0,i=0,s=0;yield Promise.all(e.map((e=>tt(this,void 0,void 0,(function*(){(yield this.managers.appPeersManager.isAnyGroup(e.peerId))?s++:(yield this.managers.appPeersManager.isBroadcast(e.peerId))?i++:t++}))))),t&&o.push((0,f.ag)("Chats",[t])),i&&o.push((0,f.ag)("Channels",[i])),s&&o.push((0,f.ag)("Groups",[s]))}}if(i)n.id!==Ye.J$&&(0,Z.Z)(i.title,(0,Q.Z)(n.title)),i.subtitle.textContent="",i.subtitle.append(...(0,f.v_)(o));else if(i=new P.ZP({title:n.id===Ye.J$?(0,f.ag)("FilterAllChats"):(0,Q.Z)(n.title),subtitle:a,clickable:!0,buttonRightLangKey:"dialogFilterSuggested"===e._?"Add":void 0}),o.length&&i.subtitle.append(...(0,f.v_)(o)),"dialogFilter"===e._){const e=n.id;if(!this.filtersRendered[n.id]&&n.id!==Ye.J$){const t=$e.Z.getInitArgs();(0,v.fc)(i.container,(()=>tt(this,void 0,void 0,(function*(){const i=yield this.managers.filtersStorage.getFilter(e),s=this.slider.createTab($e.Z);s.setInitFilter(i),s.open(t)}))),{listenerSetter:this.listenerSetter})}this.filtersRendered[n.id]=i,i.makeSortable()}const r=i.container;if(s){const e=n.localId;void 0!==e?(0,qe.Z)(r,r.parentElement||t,e):t&&t.append(r)}return i}))}init(e=it.getInitArgs()){this.container.classList.add("chat-folders-container"),this.setTitle("ChatList.Filter.List.Title"),this.scrollable.container.classList.add("chat-folders"),this.stickerContainer=document.createElement("div"),this.stickerContainer.classList.add("sticker-container");const t=document.createElement("div");t.classList.add("caption"),(0,f.XZ)({element:t,key:"ChatList.Filter.Header"}),this.createFolderBtn=(0,R.Z)("btn-primary btn-color-primary btn-control tgico",{text:"ChatList.Filter.NewTitle",icon:"add"}),this.foldersSection=new b.Z({name:"Filters"}),this.foldersSection.container.classList.add("hide"),this.list=document.createElement("div"),this.foldersSection.content.append(this.list),this.suggestedSection=new b.Z({name:"FilterRecommended"}),this.suggestedSection.container.classList.add("hide"),this.scrollable.append(this.stickerContainer,t,this.createFolderBtn,this.foldersSection.container,this.suggestedSection.container),(0,v.fc)(this.createFolderBtn,(()=>tt(this,void 0,void 0,(function*(){(yield this.canCreateFolder())?this.slider.createTab($e.Z).open():(0,et.Z)("folders")}))),{listenerSetter:this.listenerSetter});const i=()=>{this.foldersSection.container.classList.toggle("hide",!Object.keys(this.filtersRendered).length)},s=[],a=e.filters.then((e=>tt(this,void 0,void 0,(function*(){for(const t of e)t.id!==Ye.Zi&&(yield this.renderFolder(t,this.list,void 0,!0));this.toggleAllChats(),i()}))));return s.push(a),this.listenerSetter.add(n.Z)("filter_update",(e=>tt(this,void 0,void 0,(function*(){const t=this.filtersRendered[e.id];t?yield this.renderFolder(e,null,t):e.id!==Ye.Zi&&(yield this.renderFolder(e,this.list,void 0,!0)),i(),this.getSuggestedFilters()})))),this.listenerSetter.add(n.Z)("filter_delete",(e=>{const t=this.filtersRendered[e.id];t&&(this.getSuggestedFilters(),t.container.remove(),delete this.filtersRendered[e.id]),i()})),this.listenerSetter.add(n.Z)("filter_order",(e=>{e.filter((e=>!!this.filtersRendered[e])).forEach(((e,t)=>{const i=this.filtersRendered[e].container;(0,qe.Z)(i,i.parentElement,t+1)}))})),this.listenerSetter.add(n.Z)("premium_toggle",(()=>{this.toggleAllChats()})),this.loadAnimationPromise=e.animationData.then((e=>tt(this,void 0,void 0,(function*(){const t=yield e({container:this.stickerContainer,loop:!1,autoplay:!1,width:86,height:86});return this.animation=t,We.Z.waitForFirstFrame(t)})))),s.push(this.loadAnimationPromise),new Qe.Z({list:this.list,middleware:this.middlewareHelper.get(),onSort:(e,t)=>{let i=[];for(const e in this.filtersRendered){const t=this.filtersRendered[e];i[(0,Xe.Z)(t.container)]=+e}i=i.filter((e=>void 0!==e)),n.Z.premium||(0,Je.Z)(i,Ye.J$),this.managers.filtersStorage.updateDialogFiltersOrder(i)},scrollable:this.scrollable}),this.getSuggestedFilters(),Promise.all(s)}onOpenAfterTimeout(){return this.loadAnimationPromise.then((()=>{this.animation.autoplay=!0,this.animation.play()})),super.onOpenAfterTimeout()}toggleAllChats(){this.filtersRendered[Ye.J$].container.classList.toggle("hide",!n.Z.premium)}canCreateFolder(){return tt(this,void 0,void 0,(function*(){const[e,t]=yield Promise.all([this.managers.apiManager.getLimit("folders"),this.managers.filtersStorage.getDialogFilters()]);return t.filter((e=>!Ye.DZ.has(e.id))).length<e}))}getSuggestedFilters(){return this.managers.filtersStorage.getSuggestedDialogsFilters().then((e=>tt(this,void 0,void 0,(function*(){this.suggestedSection.container.classList.toggle("hide",!e.length),Array.from(this.suggestedSection.content.children).slice(1).forEach((e=>e.remove()));for(const t of e){const e=yield this.renderFolder(t);this.suggestedSection.content.append(e.container);const i=e.buttonRight;(0,v.fc)(i,(s=>tt(this,void 0,void 0,(function*(){if((0,W.Z)(s),!(yield this.canCreateFolder()))return void(0,et.Z)("folders");i.setAttribute("disabled","true");const n=t.filter;n.includePeerIds=[],n.excludePeerIds=[],n.pinnedPeerIds=[],this.managers.filtersStorage.createDialogFilter(n,!0).then((()=>{e.container.remove(),this.suggestedSection.container.classList.toggle("hide",1===this.suggestedSection.content.childElementCount)})).finally((()=>{i.removeAttribute("disabled")}))}))),{listenerSetter:this.listenerSetter})}}))))}}var st=i(8479),nt=i(3855),at=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class ot extends I.h{init(){this.container.classList.add("notifications-container"),this.setTitle("Telegram.NotificationSettingsViewController");const e=e=>{const t=new b.Z({name:e.name}),i=new P.ZP({checkboxField:new Le.Z({text:e.typeText,checked:!0}),subtitleLangKey:"Loading",listenerSetter:this.listenerSetter,withCheckboxSubtitle:!0}),s=new P.ZP({checkboxField:new Le.Z({text:"MessagePreview",checked:!0}),subtitleLangKey:"Loading",listenerSetter:this.listenerSetter,withCheckboxSubtitle:!0});t.content.append(i.container,s.container),this.scrollable.append(t.container);const a={_:e.inputKey},o=this.managers.appNotificationsManager.getNotifySettings(a);(o instanceof Promise?o:Promise.resolve(o)).then((t=>{const o=()=>at(this,void 0,void 0,(function*(){const e=yield this.managers.appNotificationsManager.isMuted(t);return i.checkboxField.checked=!e,s.checkboxField.checked=t.show_previews,e}));o(),this.eventListener.addEventListener("destroy",(()=>at(this,void 0,void 0,(function*(){const e=!i.checkboxField.checked,n=s.checkboxField.checked;if(e===(yield this.managers.appNotificationsManager.isMuted(t))&&n===t.show_previews)return;const o=(0,st.Z)(t);o._="inputPeerNotifySettings",o.mute_until=e?Ye.rU:0,o.show_previews=n,delete o.flags,this.managers.appNotificationsManager.updateNotifySettings(a,o)}))),{once:!0}),this.listenerSetter.add(n.Z)("notify_settings",(i=>{const s=Ee(i.peer._);e.inputKey===s&&(t=i.notify_settings,o())}))}))};e({name:"NotificationsPrivateChats",typeText:"NotificationsForPrivateChats",inputKey:"inputNotifyUsers"}),e({name:"NotificationsGroups",typeText:"NotificationsForGroups",inputKey:"inputNotifyChats"}),e({name:"NotificationsChannels",typeText:"NotificationsForChannels",inputKey:"inputNotifyBroadcasts"});{const e=new b.Z({name:"NotificationsOther"}),t=new P.ZP({checkboxField:new Le.Z({text:"ContactJoined",checked:!0}),subtitleLangKey:"Loading",listenerSetter:this.listenerSetter,withCheckboxSubtitle:!0}),i=new P.ZP({checkboxField:new Le.Z({text:"Notifications.Sound",checked:!0,stateKey:"settings.notifications.sound",listenerSetter:this.listenerSetter}),subtitleLangKey:"Loading",listenerSetter:this.listenerSetter,withCheckboxSubtitle:!0});nt.Z.getState().then((e=>{i.checkboxField.checked=e.settings.notifications.sound})),e.content.append(t.container,i.container),this.scrollable.append(e.container),this.managers.appNotificationsManager.getContactSignUpNotification().then((e=>{t.checkboxField.checked=e,this.eventListener.addEventListener("destroy",(()=>{const i=t.checkboxField.checked;e!==i&&this.managers.appNotificationsManager.setContactSignUpNotification(!i)}),{once:!0})}))}}}class rt extends l._{static getInitArgs(){return{languages1:n.Z.managers.apiManager.invokeApiCacheable("langpack.getLanguages",{lang_pack:"web"}),languages2:Promise.resolve([])}}init(e){this.header.classList.add("with-border"),this.container.classList.add("language-container"),this.setTitle("Telegram.LanguageViewController");const t=new b.Z({}),i=new Map,s=Promise.all([e.languages1,e.languages2]).then((([e,s])=>{const n=new Set,a=e.map((e=>e.lang_code)),o=(0,M.a)();e.concat(s).forEach((e=>{if(n.has(e.lang_code))return;n.add(e.lang_code);const t=new P.ZP({radioField:new x.Z({text:e.name,name:o,value:e.lang_code}),subtitle:e.native_name});i.set(e.lang_code,t)}));const r=(0,P.De)([...i.values()],(e=>{f.ZP.getLangPack(e,a.includes(e))}));f.ZP.getCacheLangPack().then((e=>{const t=i.get(e.lang_code);t?t.radioField.setValueSilently(!0):console.error("no row",t,e)})),t.content.append(r)}));return this.scrollable.append(t.container),s}}var dt=i(4081),lt=i(6848),ct=i(5701);function ht(e,t,i){const s=new b.Z({name:t}),n="settings.autoDownload."+e+".",a=new Le.Z({text:"AutodownloadContacts",name:"contacts",stateKey:n+"contacts",listenerSetter:i}),o=new Le.Z({text:"AutodownloadPrivateChats",name:"private",stateKey:n+"private",listenerSetter:i}),r=new Le.Z({text:"AutodownloadGroupChats",name:"groups",stateKey:n+"groups",listenerSetter:i}),d=new Le.Z({text:"AutodownloadChannels",name:"channels",stateKey:n+"channels",listenerSetter:i});return s.content.append((0,P.tG)(a).container,(0,P.tG)(o).container,(0,P.tG)(r).container,(0,P.tG)(d).container),s}class ut extends I.h{init(){this.setTitle("AutoDownloadPhotos");const e=ht("photo","AutoDownloadPhotosTitle",this.listenerSetter);this.scrollable.append(e.container)}}class pt extends I.h{init(){this.setTitle("AutoDownloadFiles");const e=(0,ct.Z)((e=>{this.managers.appStateManager.setByKey("settings.autoDownloadNew.file_size_max",e)}),200,!1,!0),t=ht("file","AutoDownloadFilesTitle",this.listenerSetter),i=524288,s=20447232,a=n.Z.settings.autoDownloadNew.file_size_max,o=Math.sqrt(Math.sqrt((a-i)/s)),r=new f.ZP.IntlElement({key:"AutodownloadSizeLimitUpTo",args:[(0,dt.Z)(a)]}),d=new Ge("AutoDownloadMaxFileSize",.01,o,0,1,!1);d.onChange=t=>{const n=Math.pow(t,4)*s+i|0;r.compareAndUpdate({args:[(0,dt.Z)(n)]}),e(n)},d.valueContainer.append(r.element),t.content.append(d.container),this.scrollable.append(t.container)}}class ft extends I.h{init(){this.setTitle("AutoDownloadVideos");const e=ht("video","AutoDownloadVideosTitle",this.listenerSetter);this.scrollable.append(e.container)}}const mt={contacts:"AutoDownloadContacts",private:"AutoDownloadPm",groups:"AutoDownloadGroups",channels:"AutoDownloadChannels"};class gt extends I.h{init(){this.setTitle("DataSettings");{const e=new b.Z({name:"AutomaticMediaDownload",caption:"AutoDownloadAudioInfo"}),t=new Le.Z({text:"AutoDownloadMedia",name:"auto",checked:!n.Z.settings.autoDownloadNew.pFlags.disabled,listenerSetter:this.listenerSetter}),i=new P.ZP({checkboxField:t,listenerSetter:this.listenerSetter}),s=()=>{(0,V.Z)([c],(0,lt.Z)(n.Z.settings.autoDownload,Re.h.settings.autoDownload)&&(0,lt.Z)(n.Z.settings.autoDownloadNew,Re.h.settings.autoDownloadNew))},a=()=>{this.setAutoDownloadSubtitle(r,n.Z.settings.autoDownload.photo),this.setAutoDownloadSubtitle(d,n.Z.settings.autoDownload.video),this.setAutoDownloadSubtitle(l,n.Z.settings.autoDownload.file,n.Z.settings.autoDownloadNew.file_size_max)},o=e=>{const t=this.slider.createTab(e);t.open(),this.listenerSetter.add(t.eventListener)("destroy",(()=>{a(),s()}),{once:!0})},r=new P.ZP({titleLangKey:"AutoDownloadPhotos",subtitle:"",clickable:()=>{o(ut)},listenerSetter:this.listenerSetter}),d=new P.ZP({titleLangKey:"AutoDownloadVideos",subtitle:"",clickable:()=>{o(ft)},listenerSetter:this.listenerSetter}),l=new P.ZP({titleLangKey:"AutoDownloadFiles",subtitle:"",clickable:()=>{o(pt)},listenerSetter:this.listenerSetter}),c=(0,R.Z)("btn-primary btn-transparent primary",{icon:"delete",text:"ResetAutomaticMediaDownload"});(0,v.fc)(c,(()=>{(0,Ie.Z)({titleLangKey:"ResetAutomaticMediaDownloadAlertTitle",descriptionLangKey:"ResetAutomaticMediaDownloadAlert",button:{langKey:"Reset"}}).then((()=>{const e=n.Z.settings;e.autoDownloadNew=(0,st.Z)(Re.h.settings.autoDownloadNew),e.autoDownload=(0,st.Z)(Re.h.settings.autoDownload),n.Z.settings=e,this.managers.appStateManager.setByKey("settings",e),a(),t.checked=!n.Z.settings.autoDownloadNew.pFlags.disabled}))}));const h=()=>{const e=!t.checked,i=n.Z.settings.autoDownloadNew;e?i.pFlags.disabled=!0:delete i.pFlags.disabled,[r,d,l].forEach((t=>{t.container.classList.toggle("is-disabled",e)})),this.managers.appStateManager.setByKey("settings.autoDownloadNew",i),s()};t.input.addEventListener("change",h),h(),a(),e.content.append(i.container,r.container,d.container,l.container,c),this.scrollable.append(e.container)}}setAutoDownloadSubtitle(e,t,i){let s;const n=[],a=Object.keys(t),o=a.map((e=>t[e]?mt[e]:void 0)).filter(Boolean);if(o.length&&0!==i){const e=o.length===a.length;if(void 0!==i?(s=e?"AutoDownloadUpToOnAllChats":"AutoDownloadOnUpToFor",n.push((0,dt.Z)(i))):s=e?"AutoDownloadOnAllChats":"AutoDownloadOnFor",!e){const e=document.createElement("span");e.append(...(0,f.v_)(o.map((e=>(0,f.ag)(e))),!0,!1)),n.push(e)}}else s="AutoDownloadOff";(0,Z.Z)(e.subtitle,(0,f.ag)(s,n))}}var vt=i(2230),bt=i(8261),yt=i(6765),wt=i(8938),St=i(4531),Ct=i(2153),Lt=i(9298),Et=i(1273),It=i(62);class Pt extends I.Z{init(){return this.setTitle("DoubleTapSetting"),this.container.classList.add("quick-reaction-container"),Promise.all([this.managers.appReactionsManager.getQuickReaction(),this.managers.appReactionsManager.getAvailableReactions()]).then((([e,t])=>{t=t.filter((e=>!e.pFlags.inactive));const i=new b.Z,s=t.map((t=>{const i=new x.Z({name:"quick-reaction",text:t.title,value:t.reaction,alignRight:!0}),s=new P.ZP({radioField:i,havePadding:!0});return i.main.classList.add("quick-reaction-title"),(0,It.Z)({row:s,doc:t.static_icon,size:"small"}),t.reaction===e.reaction&&i.setValueSilently(!0),s})),n=(0,P.De)(s,(e=>{this.managers.appReactionsManager.setDefaultReaction({_:"reactionEmoji",emoticon:e})}));i.content.append(n),this.scrollable.append(i.container)}))}}class Zt extends I.Z{static getInitArgs(){return{allStickers:n.Z.managers.appStickersManager.getAllStickers(),quickReaction:n.Z.managers.appReactionsManager.getQuickReaction()}}init(e){this.container.classList.add("stickers-emoji-container"),this.setTitle("StickersName");const t=[];{const t=new b.Z({caption:"LoopAnimatedStickersInfo"}),i=new P.ZP({icon:"lamp",titleLangKey:"Stickers.SuggestStickers",clickable:!0,listenerSetter:this.listenerSetter,titleRightSecondary:!0}),s={all:"SuggestStickersAll",installed:"SuggestStickersInstalled",none:"SuggestStickersNone"},a=()=>{i.titleRight.replaceChildren((0,f.ag)(s[n.Z.settings.stickers.suggest]))};a();const o=e=>{if(n.Z.settings.stickers.suggest!==e)return n.Z.settings.stickers.suggest=e,a(),this.managers.appStateManager.setByKey("settings.stickers.suggest",e)};(0,St.Z)({buttons:[{icon:"stickers_face",text:"SuggestStickersAll",onClick:o.bind(this,"all")},{icon:"newprivate",text:"SuggestStickersInstalled",onClick:o.bind(this,"installed")},{icon:"stop",text:"SuggestStickersNone",onClick:o.bind(this,"none")}],listenTo:i.container,middleware:this.middlewareHelper.get(),listenForClick:!0});const r=new P.ZP({titleLangKey:"DoubleTapSetting",havePadding:!0,clickable:()=>{this.slider.createTab(Pt).open()},listenerSetter:this.listenerSetter}),d=()=>{e.quickReaction.then((e=>"availableReaction"===e._?e.static_icon:this.managers.appEmojiManager.getCustomEmojiDocument(e.document_id))).then((e=>{(0,It.Z)({row:r,doc:e,size:"small"})}))};d(),this.listenerSetter.add(n.Z)("quick_reaction",(()=>{e=Zt.getInitArgs(),d()}));const l=new P.ZP({icon:"flip",titleLangKey:"InstalledStickers.LoopAnimated",checkboxField:new Le.Z({name:"loop",stateKey:"settings.stickers.loop",listenerSetter:this.listenerSetter,toggle:!0}),listenerSetter:this.listenerSetter});t.content.append(r.container,i.container,l.container),this.scrollable.append(t.container)}{const e=new b.Z({name:"Emoji"}),t=new P.ZP({icon:"lamp",titleLangKey:"GeneralSettings.EmojiPrediction",checkboxField:new Le.Z({name:"suggest-emoji",stateKey:"settings.emoji.suggest",listenerSetter:this.listenerSetter,toggle:!0}),listenerSetter:this.listenerSetter}),i=new P.ZP({icon:"smile",titleLangKey:"GeneralSettings.BigEmoji",checkboxField:new Le.Z({name:"emoji-big",stateKey:"settings.emoji.big",listenerSetter:this.listenerSetter,toggle:!0}),listenerSetter:this.listenerSetter});e.content.append(t.container,i.container),this.scrollable.append(e.container)}{const e=new b.Z({name:"DynamicPackOrder",caption:"DynamicPackOrderInfo"}),t=new P.ZP({titleLangKey:"DynamicPackOrder",checkboxField:new Le.Z({name:"dynamic-pack-order",stateKey:"settings.stickers.dynamicPackOrder",listenerSetter:this.listenerSetter,toggle:!0}),listenerSetter:this.listenerSetter});e.content.append(t.container),this.scrollable.append(e.container)}{const i=new b.Z({name:"Telegram.InstalledStickerPacksController",caption:"StickersBotInfo"}),s={},a=i.generateContentElement(),o=new Ct.Z,r=(e,t="append")=>{const i=new P.ZP({title:(0,Q.Z)(e.title),subtitleLangKey:"Stickers",subtitleLangArgs:[e.count],havePadding:!0,clickable:()=>{B.Z.createPopup(Lt.Z,{id:e.id,access_hash:e.access_hash}).show()},listenerSetter:this.listenerSetter});i.container.dataset.id=""+e.id,i.makeSortable(),s[e.id]=i;const n=document.createElement("div");n.classList.add("row-media"),(0,Et.Z)({set:e,container:n,group:"GENERAL-SETTINGS",lazyLoadQueue:o,width:36,height:36,autoplay:!0,middleware:this.middlewareHelper.get()}),i.container.append(n),a[t](i.container)},d=e.allStickers.then((e=>{(0,wt.Z)(e);const t=e.sets.map((e=>r(e)));return Promise.all(t)}));t.push(d),this.listenerSetter.add(n.Z)("stickers_installed",(e=>{s[e.id]||r(e,"prepend")})),this.listenerSetter.add(n.Z)("stickers_deleted",(e=>{s[e.id]&&(s[e.id].container.remove(),delete s[e.id])})),this.listenerSetter.add(n.Z)("stickers_order",(({type:e,order:t})=>{"stickers"===e&&t.forEach(((e,t)=>{const i=s[e];i&&(0,qe.Z)(i.container,a,t)}))})),this.listenerSetter.add(n.Z)("stickers_top",(e=>{const t=s[e];t&&(0,qe.Z)(t.container,a,0)})),new Qe.Z({list:a,middleware:this.middlewareHelper.get(),onSort:(e,t)=>{const i=Array.from(a.children).map((e=>e.dataset.id));this.managers.appStickersManager.reorderStickerSets(i)}}),this.scrollable.append(i.container)}return Promise.all(t)}}var Mt=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class kt extends l._{constructor(){super(...arguments),this.buttons={}}init(){return Mt(this,void 0,void 0,(function*(){this.container.classList.add("settings-container"),this.setTitle("Settings");const e=(0,E.Z)({listenerSetter:this.listenerSetter,direction:"bottom-left",buttons:[{icon:"logout",text:"EditAccount.Logout",onClick:()=>{B.Z.createPopup(N.Z,"logout",{titleLangKey:"LogOut",descriptionLangKey:"LogOut.Description",buttons:[{langKey:"LogOut",callback:()=>{this.managers.apiManager.logOut()},isDanger:!0}]}).show()}}]});this.buttons.edit=(0,vt.Z)("edit"),this.header.append(this.buttons.edit,e),this.profile=new bt.Z(this.managers,this.scrollable,this.listenerSetter,!1),this.profile.init(),this.profile.setPeer(n.Z.myId);const t=this.profile.fillProfileElements(),i=(0,m.Z)({icon:"cameraadd",className:"profile-change-avatar"});(0,v.fc)(i,(()=>{const e=document.createElement("canvas");B.Z.createPopup(yt.Z).open(e,(e=>{e().then((e=>this.managers.appProfileManager.uploadProfilePhoto(e)))}))}),{listenerSetter:this.listenerSetter}),this.profile.element.lastElementChild.firstElementChild.append(i);const s=()=>Mt(this,void 0,void 0,(function*(){var e;const t=yield this.managers.appUsersManager.getSelf();i.classList.toggle("hide","userProfilePhoto"!==(null===(e=t.photo)||void 0===e?void 0:e._))}));s(),this.listenerSetter.add(n.Z)("avatar_update",(({peerId:e})=>{n.Z.myId===e&&s()}));const a=document.createElement("div");a.classList.add("profile-buttons");const o=(e,t,i,s)=>{if(!s){const e=i.getInitArgs;e&&(s=()=>[e(this)])}return{icon:e,text:t,tabConstructor:i,getInitArgs:s,args:null==s?void 0:s()}},r=[o("unmute","AccountSettings.Notifications",ot),o("data","DataSettings",gt),o("lock","AccountSettings.PrivacyAndSecurity",xe),o("settings","Telegram.GeneralSettingsViewController",Ve),o("folder","AccountSettings.Filters",it),o("stickers_face","StickersName",Zt)].map((e=>{const{icon:t,text:i,tabConstructor:s,getInitArgs:n}=e;return new P.ZP({titleLangKey:i,icon:t,clickable:()=>Mt(this,void 0,void 0,(function*(){const t=e.args?yield e.args:[],i=this.slider.createTab(s);i.open(...t),i instanceof I.h&&n&&i.eventListener.addEventListener("destroyAfter",(t=>{e.args=t.then((()=>n()))}))})),listenerSetter:this.listenerSetter})})),d=rt.getInitArgs();r.push(this.devicesRow=new P.ZP({titleLangKey:"Devices",titleRightSecondary:" ",icon:"activesessions",clickable:()=>Mt(this,void 0,void 0,(function*(){this.authorizations||(yield this.updateActiveSessions());const e=this.slider.createTab(ve);e.authorizations=this.authorizations,e.eventListener.addEventListener("destroy",(()=>{this.authorizations=void 0,this.updateActiveSessions(!0)}),{once:!0}),e.open()})),listenerSetter:this.listenerSetter}),this.languageRow=new P.ZP({titleLangKey:"AccountSettings.Language",titleRightSecondary:(0,f.ag)("LanguageName"),icon:"language",clickable:()=>{this.slider.createTab(rt).open(d)},listenerSetter:this.listenerSetter})),a.append(...r.map((e=>e.container)));const l=new b.Z;l.content.append(a),this.scrollable.append(this.profile.element,l.container);const c=()=>{h=Ke.Z.getInitArgs()};let h;(0,v.fc)(this.buttons.edit,(()=>{this.slider.createTab(Ke.Z).open(h)}),{listenerSetter:this.listenerSetter}),c(),this.listenerSetter.add(n.Z)("user_update",(e=>{n.Z.myId.toUserId()===e&&c()})),We.Z.loadLottieWorkers(),this.updateActiveSessions(),(yield t)()}))}getAuthorizations(e){if(this.getAuthorizationsPromise&&!e)return this.getAuthorizationsPromise;const t=this.getAuthorizationsPromise=this.managers.apiManager.invokeApi("account.getAuthorizations").finally((()=>{this.getAuthorizationsPromise===t&&(this.getAuthorizationsPromise=void 0)}));return t}updateActiveSessions(e){return this.getAuthorizations(e).then((e=>{this.authorizations=e.authorizations,this.devicesRow.titleRight.textContent=""+this.authorizations.length}))}onCloseAfterTimeout(){return this.profile.destroy(),super.onCloseAfterTimeout()}}class Tt extends l._{constructor(){super(...arguments),this.uploadAvatar=null}init(){this.container.classList.add("new-channel-container"),this.setTitle("NewChannel"),this.avatarEdit=new p.Z((e=>{this.uploadAvatar=e}));const e=new b.Z({caption:"Channel.DescriptionHolderDescrpiton"}),t=document.createElement("div");t.classList.add("input-wrapper"),this.channelNameInputField=new u.ZP({label:"EnterChannelName",maxLength:128}),this.channelDescriptionInputField=new u.ZP({label:"DescriptionOptionalPlaceholder",maxLength:255}),t.append(this.channelNameInputField.container,this.channelDescriptionInputField.container);const i=()=>{this.nextBtn.classList.toggle("is-visible",!!this.channelNameInputField.value.length&&!this.channelNameInputField.input.classList.contains("error")&&!this.channelDescriptionInputField.input.classList.contains("error"))};this.channelNameInputField.input.addEventListener("input",i),this.channelDescriptionInputField.input.addEventListener("input",i),this.nextBtn=(0,m.Z)({icon:"arrow_next"}),(0,v.fc)(this.nextBtn,(()=>{const e=this.channelNameInputField.value,t=this.channelDescriptionInputField.value;this.nextBtn.disabled=!0,this.managers.appChatsManager.createChannel({title:e,about:t,broadcast:!0}).then((e=>{this.uploadAvatar&&this.uploadAvatar().then((t=>{this.managers.appChatsManager.editPhoto(e,t)})),s.ZP.setInnerPeer({peerId:e.toPeerId(!0)}),ei.removeTabFromHistory(this),this.slider.createTab(A.Z).open({type:"channel",skippable:!0,title:"GroupAddMembers",placeholder:"SendMessageTo",takeOut:t=>this.managers.appChatsManager.inviteToChannel(e,t)})}))}),{listenerSetter:this.listenerSetter}),this.content.append(this.nextBtn),e.content.append(this.avatarEdit.container,t),this.scrollable.append(e.container)}onCloseAfterTimeout(){return this.avatarEdit.clear(),this.uploadAvatar=null,this.channelNameInputField.value="",this.channelDescriptionInputField.value="",this.nextBtn.disabled=!1,super.onCloseAfterTimeout()}}var xt=i(241),At=i(2621),_t=i(709),Ft=i(6272);class Dt extends B.Z{constructor(){super("popup-create-contact popup-send-photo popup-new-media",{closable:!0,withConfirm:"Add",title:"AddContactTitle"}),this.construct()}construct(){return e=this,t=void 0,s=function*(){(0,v.fc)(this.btnConfirm,(()=>{const e=this.managers.appUsersManager.importContact(i.value,s.value,n.value);e.then((()=>{this.hide()}),(e=>{"NO_USER"===e.type&&((0,te.bC)({langPackKey:"Contacts.PhoneNumber.NotRegistred"}),d.disabled=!1)})),d.lockWithPromise(e)}),{listenerSetter:this.listenerSetter});const e=[],t=document.createElement("div");t.classList.add("name-fields");const i=new u.ZP({label:"FirstName",name:"create-contact-name",maxLength:70,required:!0}),s=new u.ZP({label:"LastName",name:"create-contact-lastname",maxLength:70}),n=new _t.Z({required:!0});e.push(i,s,n);const a=()=>{const e=i.value+" "+s.value;d.avatarElem.peerTitle=e,d.avatarElem.update()};this.listenerSetter.add(i.input)("input",a),this.listenerSetter.add(s.input)("input",a),n.validate=()=>!!n.value.match(/\d/);const o=yield this.managers.appUsersManager.getSelf(),r=(0,Ft.u)(o.phone);r.code&&(n.value="+"+r.code.country_code);const d=new At.Z({inputFields:e,listenerSetter:this.listenerSetter,doNotEditAvatar:!0,nextBtn:this.btnConfirm,avatarSize:100});t.append(i.container,s.container,d.avatarElem),this.container.append(t,n.container),this.show()},new((i=void 0)||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}));var e,t,i,s}}var Rt=i(2894),Bt=i(3624);class Nt extends l._{init(){this.container.id="contacts-container";const e=(0,m.Z)({icon:"add",className:"is-visible"});this.content.append(e),(0,v.fc)(e,(()=>{B.Z.createPopup(Dt)}),{listenerSetter:this.listenerSetter}),this.inputSearch=new d.Z("Search",(e=>{this.openContacts(e)})),this.listenerSetter.add(n.Z)("contacts_update",(e=>{return t=this,i=void 0,n=function*(){const t=yield this.managers.appUsersManager.isContact(e),i=e.toPeerId();t?this.sortedUserList.add(i):this.sortedUserList.delete(i)},new((s=void 0)||(s=Promise))((function(e,a){function o(e){try{d(n.next(e))}catch(e){a(e)}}function r(e){try{d(n.throw(e))}catch(e){a(e)}}function d(t){var i;t.done?e(t.value):(i=t.value,i instanceof s?i:new s((function(e){e(i)}))).then(o,r)}d((n=n.apply(t,i||[])).next())}));var t,i,s,n})),this.title.replaceWith(this.inputSearch.container),this.middleware=(0,Bt.k)(),this.openContacts()}createList(){const e=new Rt.Z({managers:this.managers}),t=e.list;return t.id="contacts",t.classList.add("contacts-container"),h.default.setListClickListener(t,(()=>{this.close()}),void 0,!0),e}onClose(){this.middleware.clean()}onOpenAfterTimeout(){!j.IS_MOBILE&&G(!0)&&this.inputSearch.input.focus()}openContacts(e){this.middleware.clean();const t=this.middleware.get();this.scrollable.onScrolledBottom=null,this.scrollable.container.textContent="",this.managers.appUsersManager.getContactsPeerIds(e,void 0,"online").then((e=>{if(!t())return;const i=this.sortedUserList=this.createList();let s=()=>{const t=xt.Z.height/56*1.25|0;e.splice(0,t).forEach((e=>{i.add(e)})),e.length||(s=void 0,this.scrollable.onScrolledBottom=null)};s(),this.scrollable.onScrolledBottom=()=>{s?s():this.scrollable.onScrolledBottom=null},(0,Z.Z)(this.scrollable.container,i.list)}))}}class Ot extends l._{init(){if(this.wasFilterId=h.default.filterId,this.container.id="chats-archived-container",this.setTitle("ArchivedChats"),this.header.classList.add("can-have-forum"),this.content.classList.add("can-have-forum"),!h.default.xds[Ot.filterId]){const{ul:e,scrollable:t}=h.default.l({title:void 0,id:Ot.filterId,localId:Ye.Zi});t.container.append(e)}const e=h.default.xds[Ot.filterId].scrollable;return this.scrollable.container.replaceWith(e.container),e.attachBorderListeners(this.container),h.default.setFilterIdAndChangeTab(Ot.filterId).then((({cached:e,renderPromise:t})=>{if(e)return t}))}onOpenAfterTimeout(){h.default.xds[this.wasFilterId].clear()}onClose(){this.scrollable.onAdditionalScroll=void 0,h.default.setFilterIdAndChangeTab(this.wasFilterId)}onCloseAfterTimeout(){return h.default.xds[Ot.filterId].clear(),super.onCloseAfterTimeout()}}Ot.filterId=Ye.Zi;class Ut extends l._{constructor(){super(...arguments),this.isLocationWatched=!1}parseDistance(e){return"miles"===n.Z.settings.distanceUnit?e>1609.34?(0,f.ag)("MilesAway",[Math.round(e/1609)]):(0,f.ag)("FootsAway",[Math.round(3.281*e)]):e>=1e3?(0,f.ag)("KMetersAway2",[e/1e3]):(0,f.ag)("MetersAway2",[e])}startWatching(){this.latestLocationSaved&&!this.isLocationWatched&&(this.isLocationWatched=!0,(0,te.Am)("Your position is now being shared. Do not close the page or it will be suspended."),this.managers.appUsersManager.getLocated(this.latestLocationSaved.latitude,this.latestLocationSaved.longitude,this.latestLocationSaved.accuracy,!0,2147483647),navigator.geolocation.watchPosition((e=>{const t=e.coords.longitude!==this.latestLocationSaved.longitude,i=e.coords.latitude!==this.latestLocationSaved.latitude,s=this.calculateDistance(e.coords.latitude,e.coords.longitude,this.latestLocationSaved.latitude,this.latestLocationSaved.longitude)>100;(i||t)&&s&&(this.managers.appUsersManager.getLocated(e.coords.latitude,e.coords.longitude,e.coords.accuracy,!0,2147483647),this.latestLocationSaved={latitude:e.coords.latitude,longitude:e.coords.longitude,accuracy:e.coords.accuracy})})))}stopWatching(){this.isLocationWatched&&(this.isLocationWatched=!1,(0,te.Am)("The sharing of your position has been stopped. You will no longer be visible to other users."),this.managers.appUsersManager.getLocated(0,0,0,!1,0))}calculateDistance(e,t,i,s){const n=.017453292519943295;return 12742*Math.asin(Math.sqrt(.5-Math.cos((i-e)*n)+Math.cos(e*n)*Math.cos(i*n)*(1-Math.cos((s-t)*n)/2)))}}var Ht=i(5824),zt=i(8842),jt=i(4159),Gt=i(7487),Vt=i(1405),Kt=i(2559),Wt=i(4755),$t=i(3035),qt=i(6472),Yt=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};const Qt="is-left-column-shown";class Xt extends l.Z{constructor(){super({sidebarEl:document.getElementById("column-left"),navigationType:"left"}),this.searchGroups={}}construct(e){this.managers=e,this.inputSearch=new d.Z("Search");const t=this.sidebarEl.querySelector(".item-main .sidebar-header");t.append(this.inputSearch.container);const i=()=>{this.createTab(Nt).open()};this.backBtn=this.sidebarEl.querySelector(".sidebar-back-button");const a={icon:"archive",text:"ArchivedChats",onClick:()=>{this.createTab(Ot).open()},verify:()=>Yt(this,void 0,void 0,(function*(){return!!(yield this.managers.dialogsStorage.getFolderDialogs(Ye.Zi,!1)).length||!(yield this.managers.dialogsStorage.isDialogsLoaded(Ye.Zi))}))},o=new Le.Z({toggle:!0,checked:"night"===Be.Z.getTheme().name});o.input.addEventListener("change",(()=>Yt(this,void 0,void 0,(function*(){Be.Z.switchTheme(o.input.checked?"night":"day")})))),n.Z.addEventListener("theme_change",(()=>{o.setValueSilently("night"===Be.Z.getTheme().name)}));const r=[{icon:"savedmessages",text:"SavedMessages",onClick:()=>{setTimeout((()=>{s.ZP.setPeer({peerId:s.ZP.myId})}),0)}},a,{icon:"user",text:"Contacts",onClick:i},De.Z?{icon:"group",text:"PeopleNearby",onClick:()=>{this.createTab(Ut).open()}}:void 0,{icon:"settings",text:"Settings",onClick:()=>{this.createTab(kt).open()}},{icon:"darkmode",text:"DarkMode",onClick:()=>{},checkboxField:o},{icon:"animations",text:"Animations",onClick:()=>{},checkboxField:new Le.Z({toggle:!0,checked:!0,stateKey:"settings.liteMode.animations",stateValueReverse:!0}),verify:()=>!Ne.Z.isEnabled()},{icon:"animations",text:"LiteMode.Title",onClick:()=>{this.createTab(ze).open()},verify:()=>Ne.Z.isEnabled()},{icon:"help",text:"TelegramFeatures",onClick:()=>{const e=f.ZP.format("TelegramFeaturesUrl",!0);s.ZP.openUrl(e)}},{icon:"bug",text:"ReportBug",onClick:()=>{const e=document.createElement("a");e.target="_blank",e.href="https://bugs.telegram.org/?tag_ids=40&sort=time",document.body.append(e),e.click(),setTimeout((()=>{e.remove()}),0)}},{icon:"char z",text:"ChatList.Menu.SwitchTo.Z",onClick:()=>{Promise.all([Gt.Z.set({kz_version:"Z"}),Gt.Z.delete("tgme_sync")]).then((()=>{location.href="https://web.telegram.org/z/"}))},verify:()=>jt.Z.isMainDomain},{icon:"download",text:"PWA.Install",onClick:()=>{const e=(0,qt.B)();null==e||e()},verify:()=>!!(0,qt.B)()}].filter(Boolean);this.toolsBtn=(0,E.Z)({direction:"bottom-right",buttons:r,onOpen:(e,t)=>{var i;const s=document.createElement("a");s.href="https://github.com/morethanwords/tweb/blob/master/CHANGELOG.md",s.target="_blank",s.rel="noopener noreferrer",s.classList.add("btn-menu-footer"),s.addEventListener(v.pf,(e=>{e.stopPropagation(),ge.Z.close()}));const n=document.createElement("span");n.classList.add("btn-menu-footer-text"),n.textContent="Telegram Web"+jt.Z.suffix+" "+jt.Z.versionFull,s.append(n),t.classList.add("has-footer"),t.append(s),null===(i=a.element)||void 0===i||i.append(this.archivedCount)}}),this.toolsBtn.classList.remove("tgico-more"),this.toolsBtn.classList.add("sidebar-tools-button","is-visible"),this.backBtn.parentElement.insertBefore(this.toolsBtn,this.backBtn),this.newBtnMenu=(0,E.Z)({direction:"top-left",buttons:[{icon:"newchannel",text:"NewChannel",onClick:()=>{this.createTab(Tt).open()}},{icon:"newgroup",text:"NewGroup",onClick:()=>{this.createTab(A.Z).open({type:"chat",skippable:!0,takeOut:e=>this.createTab(y).open(e),title:"GroupAddMembers",placeholder:"SendMessageTo"})}},{icon:"newprivate",text:"NewPrivateChat",onClick:i}]}),this.newBtnMenu.className="btn-circle rp btn-corner z-depth-1 btn-menu-toggle animated-button-icon",this.newBtnMenu.tabIndex=-1,this.newBtnMenu.insertAdjacentHTML("afterbegin",'\n <span class="tgico tgico-newchat_filled"></span>\n <span class="tgico tgico-close"></span>\n '),this.newBtnMenu.id="new-menu",t.nextElementSibling.append(this.newBtnMenu),this.updateBtn=document.createElement("div"),this.updateBtn.className="btn-circle rp btn-corner z-depth-1 btn-update is-hidden",this.updateBtn.tabIndex=-1,(0,Vt.Z)(this.updateBtn),this.updateBtn.append((0,f.ag)("Update")),(0,v.fc)(this.updateBtn,(()=>{this.updateBtn.classList.contains("is-hidden")||location.reload()})),t.nextElementSibling.append(this.updateBtn),this.inputSearch.input.addEventListener("focus",(()=>this.initSearch()),{once:!0}),this.archivedCount=document.createElement("span"),this.archivedCount.className="archived-count badge badge-24 badge-gray",n.Z.addEventListener("folder_unread",(e=>{if(e.id===Ye.Zi){const t=e.unreadPeerIds.size;this.archivedCount.textContent=""+(0,Kt.Z)(t,1),this.archivedCount.classList.toggle("hide",!t)}})),this.managers.appUsersManager.getTopPeers("correspondents");const l={type:"global-search-focus",onPop:()=>(setTimeout((()=>{this.inputSearch.input.focus()}),0),!1),noHistory:!0};Ht.Z.pushItem(l),nt.Z.getState().then((()=>{const e=setInterval((()=>{fetch("version",{cache:"no-cache"}).then((e=>200===e.status&&e.ok&&e.text()||Promise.reject())).then((t=>{t!==jt.Z.versionFull&&(this.hasUpdate=!0,clearInterval(e),this.newBtnMenu.classList.contains("is-hidden")||this.updateBtn.classList.remove("is-hidden"))})).catch(Pe.Z)}),18e5)}));const c=()=>{const e=this.rect=this.tabsContainer.getBoundingClientRect();document.documentElement.style.setProperty("--left-column-width",e.width+"px")};(0,$t.T2)(c),Wt.Z.addEventListener("resize",c)}initSearch(){const e=this.sidebarEl.querySelector("#search-container"),t=new r.ZP(e),i=()=>{(0,v.tH)(this.backBtn)};this.searchGroups={contacts:new a.z("SearchAllChatsShort","contacts",void 0,void 0,void 0,void 0,i),globalContacts:new a.z("GlobalSearch","contacts",void 0,void 0,void 0,void 0,i),messages:new a.z("SearchMessages","messages"),people:new a.z(!1,"contacts",!0,"search-group-people",!0,!1,i,!0),recent:new a.z("Recent","contacts",!0,"search-group-recent",!0,!0,i)};const s=this.searchSuper=new S.Z({mediaTabs:[{inputFilter:"inputMessagesFilterEmpty",name:"FilterChats",type:"chats"},{inputFilter:"inputMessagesFilterPhotoVideo",name:"SharedMediaTab2",type:"media"},{inputFilter:"inputMessagesFilterUrl",name:"SharedLinksTab2",type:"links"},{inputFilter:"inputMessagesFilterDocument",name:"SharedFilesTab2",type:"files"},{inputFilter:"inputMessagesFilterMusic",name:"SharedMusicTab2",type:"music"},{inputFilter:"inputMessagesFilterRoundVoice",name:"SharedVoiceTab2",type:"voice"}],scrollable:t,searchGroups:this.searchGroups,asChatList:!0,hideEmptyTabs:!1,showSender:!0,managers:this.managers});e.prepend(s.nav.parentElement.parentElement),t.container.append(s.container),s.setQuery({peerId:"".toPeerId(),folderId:0}),s.selectTab(0),s.load(!0);const n=[];let d="".toPeerId(),l=0,u=0;const p=()=>{this.inputSearch.container.classList.toggle("is-picked-twice",2===n.length),this.inputSearch.container.classList.toggle("is-picked",!!n.length),n.length?this.inputSearch.input.style.setProperty("--paddingLeft",n[n.length-1].getBoundingClientRect().right-this.inputSearch.input.getBoundingClientRect().left+"px"):this.inputSearch.input.style.removeProperty("--paddingLeft")},f=document.createElement("div");f.classList.add("search-helper"),f.addEventListener("click",(e=>{const t=(0,ue.Z)(e.target,"selector-user");if(!t)return;const i=t.dataset.key;if(0===i.indexOf("date_")){const[e,t,s]=i.split("_");l=+t,u=+s}else d=i.toPeerId();t.addEventListener("click",(()=>{g(t)})),this.inputSearch.container.append(t),this.inputSearch.onChange(this.inputSearch.value=""),n.push(t),p()})),s.nav.parentElement.append(f);const m=(e,t)=>{const i=document.createElement("div");i.classList.add("selector-user");const s=new o.Z;return s.classList.add("selector-user-avatar","tgico","avatar-32"),s.isDialog=!0,i.dataset.key=""+e,e.isPeerId()?(void 0===t&&(t=new zt.Z({peerId:e.toPeerId()}).element),s.updateWithOptions({peerId:e})):s.classList.add("tgico-calendarfilter"),t&&("string"==typeof t?i.innerHTML=t:((0,Z.Z)(i,t),i.append(t))),i.insertAdjacentElement("afterbegin",s),i},g=e=>{0===e.dataset.key.indexOf("date_")?l=u=0:d="".toPeerId(),e.remove(),(0,Je.Z)(n,e),setTimeout((()=>{p(),this.inputSearch.onChange(this.inputSearch.value)}),0)};this.inputSearch.onClear=()=>{n.forEach((e=>{g(e)}))},this.inputSearch.onChange=e=>{if(s.cleanupHTML(),s.setQuery({peerId:d,folderId:d?void 0:0,query:e,minDate:l,maxDate:u}),s.load(!0),f.replaceChildren(),s.nav.classList.remove("hide"),!d&&e.trim()){const t=s.middleware.get();Promise.all([this.managers.dialogsStorage.getDialogs({query:e}).then((({dialogs:e})=>e.map((e=>e.peerId)))),this.managers.appUsersManager.getContactsPeerIds(e,!0)]).then((e=>{t()&&(new Set(e[0].concat(e[1])).forEach((e=>{f.append(m(e))})),s.nav.classList.toggle("hide",!!f.innerHTML))}))}if(!l&&e.trim()){const t=[];(0,C.fl)(e,t),t.forEach((e=>{f.append(m("date_"+e.minDate+"_"+e.maxDate,e.title))})),s.nav.classList.toggle("hide",!!f.innerHTML)}},s.tabs.inputMessagesFilterEmpty.addEventListener("mousedown",(e=>{const t=(0,ye.Z)(e.target,h.DIALOG_LIST_ELEMENT_TAG);if(!t)return;const i=(0,ue.Z)(t,"search-group");if(!i||i.classList.contains("search-group-recent")||i.classList.contains("search-group-people"))return;const s=t.getAttribute("data-peer-id").toPeerId();this.managers.appUsersManager.pushRecentSearch(s)}),{capture:!0});const b=document.createElement("div");b.classList.add("search-group-scrollable"),b.append(this.searchGroups.people.list),this.searchGroups.people.container.append(b),new r.v7(b);let y,w=!0;const L=(0,c.Z)({content:e.parentElement,type:"zoom-fade",transitionTime:150,onTransitionEnd:e=>{y&&clearTimeout(y),0!==e||w||(s.selectTab(0,!1),this.inputSearch.onClearClick(),y=window.setTimeout((()=>{y=0,this.newBtnMenu.classList.remove("is-hidden"),this.hasUpdate&&this.updateBtn.classList.remove("is-hidden")}),150)),w=!1}});L(0);const E="is-visible",I=()=>{this.toolsBtn.classList.remove(E),this.backBtn.classList.add(E),this.newBtnMenu.classList.add("is-hidden"),this.updateBtn.classList.add("is-hidden"),this.toolsBtn.parentElement.firstElementChild.classList.toggle("state-back",!0);const e="global-search";j.IS_MOBILE_SAFARI||Ht.Z.findItemByType(e)||Ht.Z.pushItem({onPop:()=>{i()},type:e}),L(1)};this.inputSearch.input.addEventListener("focus",I),I(),(0,v.fc)(this.backBtn,(e=>{this.toolsBtn.classList.add(E),this.backBtn.classList.remove(E),this.toolsBtn.parentElement.firstElementChild.classList.toggle("state-back",!1),Ht.Z.removeByType("global-search"),L(0)}));const P=(0,vt.Z)("close");this.searchGroups.recent.nameEl.append(P),P.addEventListener("click",(()=>{(0,Ie.Z)({descriptionLangKey:"Search.Confirm.ClearHistory",button:{langKey:"ClearButton",isDanger:!0}}).then((()=>this.managers.appUsersManager.clearRecentSearch().then((()=>{this.searchGroups.recent.clear()}))))}))}}const Jt=new Xt;L.GO.appSidebarLeft=Jt;const ei=Jt},5670:(e,t,i)=>{"use strict";i.d(t,{Z:()=>r});var s=i(3552),n=i(5644),a=i(279),o=i(8119);class r extends s._{init(e){this.container.classList.add("add-members-container"),this.nextBtn=(0,o.Z)({icon:"arrow_next"}),this.content.append(this.nextBtn),this.scrollable.container.remove(),this.nextBtn.addEventListener("click",(()=>{const e=this.selector.getSelected().map((e=>e.toPeerId())),t=this.takeOut(e);!this.skippable||t instanceof Promise?t instanceof Promise?this.attachToPromise(t):void 0===t&&this.close():this.close()})),this.setTitle(e.title),this.peerType=e.type,this.takeOut=e.takeOut,this.skippable=e.skippable;const t="privacy"===this.peerType;this.selector=new n.Z({appendTo:this.content,onChange:this.skippable?null:e=>{this.nextBtn.classList.toggle("is-visible",!!e)},peerType:[t?"dialogs":"contacts"],placeholder:e.placeholder,exceptSelf:t,filterPeerTypeBy:t?["isAnyGroup","isUser"]:void 0,managers:this.managers,design:"square"}),e.selectedPeerIds&&this.selector.addInitial(e.selectedPeerIds),this.nextBtn.classList.add("tgico-arrow_next"),this.nextBtn.replaceChildren(),this.nextBtn.disabled=!1,this.nextBtn.classList.toggle("is-visible",this.skippable)}attachToPromise(e){const t=(0,a.p)(this.nextBtn,"arrow_next");e.then((()=>{this.close()}),(()=>{t()}))}}},9439:(e,t,i)=>{"use strict";i.d(t,{Z:()=>B});var s=i(6740);function n(e){const t=e.getContext("2d"),i=new Array(4).fill(0),s=t.getImageData(0,0,e.width,e.height).data,n=s.length/4;for(let e=0;e<s.length;e+=4)i[0]+=s[e],i[1]+=s[e+1],i[2]+=s[e+2],i[3]+=s[e+3];const a=new Uint8ClampedArray(4);return a[0]=i[0]/n,a[1]=i[1]/n,a[2]=i[2]/n,a[3]=i[3]/n,a}var a=i(6705),o=i(3725),r=i(2738),d=i(8497),l=i(2064);function c(e){let{h:t,s:i,l:s}=(0,l.dI)(e[0],e[1],e[2]);return i>0&&(i=Math.min(100,i+5+.1*(100-i))),s=Math.max(0,.65*s),`hsla(${t}, ${i}%, ${s}%, .4)`}var h=i(8479),u=i(9674),p=i(1571),f=i(2312),m=i(7030),g=i(3512),v=i(4494),b=i(9807),y=i(3442),w=i(3552),S=i(6724),C=i(6714),L=i(5077),E=i(3228),I=i(503);class P{constructor(){this.hue=0,this.saturation=100,this.lightness=50,this.alpha=1,this.elements={},this.onGrabStart=()=>{document.documentElement.style.cursor=this.elements.boxDragger.style.cursor="grabbing"},this.onGrabEnd=()=>{document.documentElement.style.cursor=this.elements.boxDragger.style.cursor=""},this.container=document.createElement("div"),this.container.classList.add(P.BASE_CLASS);const e=`\n <svg class="${P.BASE_CLASS+"-box"}" viewBox="0 0 380 198">\n <defs>\n <linearGradient id="color-picker-saturation" x1="0%" y1="0%" x2="100%" y2="0%">\n <stop offset="0%" stop-color="#fff"></stop>\n <stop offset="100%" stop-color="hsl(0,100%,50%)"></stop>\n </linearGradient>\n <linearGradient id="color-picker-brightness" x1="0%" y1="0%" x2="0%" y2="100%">\n <stop offset="0%" stop-color="rgba(0,0,0,0)"></stop>\n <stop offset="100%" stop-color="#000"></stop>\n </linearGradient>\n <pattern id="color-picker-pattern" width="100%" height="100%">\n <rect x="0" y="0" width="100%" height="100%" fill="url(#color-picker-saturation)"></rect>\n <rect x="0" y="0" width="100%" height="100%" fill="url(#color-picker-brightness)"></rect>\n </pattern>\n </defs>\n <rect rx="10" ry="10" x="0" y="0" width="380" height="198" fill="url(#color-picker-pattern)"></rect>\n <svg class="${P.BASE_CLASS+"-dragger"} ${P.BASE_CLASS+"-box-dragger"}" x="0" y="0">\n <circle r="11" fill="inherit" stroke="#fff" stroke-width="2"></circle>\n </svg>\n </svg>\n <div class="${P.BASE_CLASS+"-sliders"}">\n <svg class="${P.BASE_CLASS+"-color-slider"}" viewBox="0 0 380 24">\n <defs>\n <linearGradient id="hue" x1="100%" y1="0%" x2="0%" y2="0%">\n <stop offset="0%" stop-color="#f00"></stop>\n <stop offset="16.666%" stop-color="#f0f"></stop>\n <stop offset="33.333%" stop-color="#00f"></stop>\n <stop offset="50%" stop-color="#0ff"></stop>\n <stop offset="66.666%" stop-color="#0f0"></stop>\n <stop offset="83.333%" stop-color="#ff0"></stop>\n <stop offset="100%" stop-color="#f00"></stop>\n </linearGradient>\n </defs>\n <rect rx="4" ry="4" x="0" y="9" width="380" height="8" fill="url(#hue)"></rect>\n <svg class="${P.BASE_CLASS+"-dragger"} ${P.BASE_CLASS+"-color-slider-dragger"}" x="0" y="13">\n <circle r="11" fill="inherit" stroke="#fff" stroke-width="2"></circle>\n </svg>\n </svg>\n </div>\n `;this.container.innerHTML=e,this.elements.box=this.container.firstElementChild,this.elements.boxDragger=this.elements.box.lastElementChild,this.elements.saturation=this.elements.box.firstElementChild.firstElementChild,this.elements.sliders=this.elements.box.nextElementSibling,this.elements.hue=this.elements.sliders.firstElementChild,this.elements.hueDragger=this.elements.hue.lastElementChild,this.hexInputField=new I.ZP({plainText:!0,label:"Appearance.Color.Hex"}),this.rgbInputField=new I.ZP({plainText:!0,label:"Appearance.Color.RGB"});const t=document.createElement("div");t.className=P.BASE_CLASS+"-inputs",t.append(this.hexInputField.container,this.rgbInputField.container),this.container.append(t),this.hexInputField.input.addEventListener("input",(()=>{let e=this.hexInputField.value.replace(/#/g,"").slice(0,6);const t=e.match(/([a-fA-F\d]+)/),i=t&&t[0].length===e.length&&[6].includes(e.length);this.hexInputField.setState(i?I.I1.Neutral:I.I1.Error),e="#"+e,this.hexInputField.setValueSilently(e),i&&this.setColor(e,!1,!0)}));const i=/^(?:rgb)?\(?([01]?\d\d?|2[0-4]\d|25[0-5])(?:\W+)([01]?\d\d?|2[0-4]\d|25[0-5])\W+(?:([01]?\d\d?|2[0-4]\d|25[0-5])\)?)$/;this.rgbInputField.input.addEventListener("input",(()=>{const e=this.rgbInputField.value.match(i);this.rgbInputField.setState(e?I.I1.Neutral:I.I1.Error),e&&this.setColor((0,l.dI)(+e[1],+e[2],+e[3]),!0,!1)})),this.attachBoxListeners(),this.attachHueListeners()}attachBoxListeners(){(0,L.Z)(this.elements.box,(()=>{this.onGrabStart(),this.boxRect=this.elements.box.getBoundingClientRect()}),(e=>{this.saturationHandler(e.x,e.y)}),(()=>{this.onGrabEnd()}))}attachHueListeners(){(0,L.Z)(this.elements.hue,(()=>{this.onGrabStart(),this.hueRect=this.elements.hue.getBoundingClientRect()}),(e=>{this.hueHandler(e.x)}),(()=>{this.onGrabEnd()}))}setColor(e,t=!0,i=!0){if(void 0===e)e={h:0,s:100,l:50,a:1};else if("string"==typeof e)if("#"===e[0])e=(0,l.cw)(e);else{const t=e.match(/[.?\d]+/g);e=(0,l.dI)(+t[0],+t[1],+t[2],void 0===t[3]?1:+t[3])}this.boxRect=this.elements.box.getBoundingClientRect();const s=this.boxRect.width/100*e.s,n=100-e.l/(100-e.s/2)*100,a=this.boxRect.height/100*n;this.saturationHandler(this.boxRect.left+s,this.boxRect.top+a,!1),this.hueRect=this.elements.hue.getBoundingClientRect();const o=e.h/360,r=this.hueRect.left+this.hueRect.width*o;this.hueHandler(r,!1),this.hue=e.h,this.saturation=e.s,this.lightness=e.l,this.alpha=e.a,this.updatePicker(t,i)}getCurrentColor(){const e=(0,l.Y6)(this.hue,this.saturation,this.lightness,this.alpha),t=(0,l.t1)(e),i=t.slice(0,-2);return{hsl:`hsl(${this.hue}, ${this.saturation}%, ${this.lightness}%)`,rgb:`rgb(${e[0]}, ${e[1]}, ${e[2]})`,hex:i,hsla:`hsla(${this.hue}, ${this.saturation}%, ${this.lightness}%, ${this.alpha})`,rgba:`rgba(${e[0]}, ${e[1]}, ${e[2]}, ${e[3]})`,hexa:t,rgbaArray:e}}updatePicker(e=!0,t=!0){const i=this.getCurrentColor();this.elements.boxDragger.setAttributeNS(null,"fill",i.hex),e&&(this.hexInputField.setValueSilently(i.hex),this.hexInputField.setState(I.I1.Neutral)),t&&(this.rgbInputField.setValueSilently(i.rgbaArray.slice(0,-1).join(", ")),this.rgbInputField.setState(I.I1.Neutral)),this.onChange&&this.onChange(i)}hueHandler(e,t=!0){const i=(0,E.Z)(e-this.hueRect.left,0,this.hueRect.width)/this.hueRect.width;this.hue=Math.round(360*i);const s=`hsla(${this.hue}, 100%, 50%, ${this.alpha})`;this.elements.hueDragger.setAttributeNS(null,"x",100*i+"%"),this.elements.hueDragger.setAttributeNS(null,"fill",s),this.elements.saturation.lastElementChild.setAttributeNS(null,"stop-color",s),t&&this.updatePicker()}saturationHandler(e,t,i=!0){const s=this.boxRect.width,n=this.boxRect.height,a=(0,E.Z)(e-this.boxRect.left,0,s)/s*100,o=(0,E.Z)(t-this.boxRect.top,0,n)/n*100,r=this.elements.boxDragger;r.setAttributeNS(null,"x",a+"%"),r.setAttributeNS(null,"y",o+"%");const d=(0,E.Z)(a,0,100),l=100-d/2,c=100-(0,E.Z)(o,0,100),h=(0,E.Z)(c/100*l,0,100);this.saturation=d,this.lightness=h,i&&this.updatePicker()}}P.BASE_CLASS="color-picker";var Z=i(5029);class M extends w._{constructor(){super(...arguments),this._applyColor=(e,t=!0)=>{if(t)this.colorPicker.setColor(e);else{const t=(0,l.Pi)(e),i=this.theme.settings,s=c(t),n={_:"wallPaperNoFile",id:0,pFlags:{},settings:{_:"wallPaperSettings",background_color:parseInt(e.slice(1),16),pFlags:{}}};i.wallpaper=n,i.highlightningColor=s,this.managers.appStateManager.pushToState("settings",g.Z.settings),m.ZP.applyCurrentTheme(void 0,void 0,!0),this.setActive()}},this.onColorChange=e=>{this.applyColor(e.hex,!1)}}init(){this.container.classList.add("background-container","background-color-container"),this.setTitle("SetColor"),this.theme=C.Z.getTheme();const e=new Z.Z({});this.colorPicker=new P,e.content.append(this.colorPicker.container),this.scrollable.append(e.container);const t=new Z.Z({}),i=this.grid=document.createElement("div");i.classList.add("grid"),["#E6EBEE","#B2CEE1","#008DD0","#C6E7CB","#C4E1A6","#60B16E","#CCD0AF","#A6A997","#7A7072","#FDD7AF","#FDB76E","#DD8851"].forEach((e=>{const t=document.createElement("div");t.classList.add("grid-item"),t.dataset.color=e.toLowerCase();const s=document.createElement("div");s.classList.add("grid-item-media"),s.style.backgroundColor=e,t.append(s),i.append(t)})),(0,r.fc)(i,(e=>{const t=(0,d.Z)(e.target,"grid-item");if(!t||t.classList.contains("active"))return;const i=t.dataset.color;i&&this.applyColor(i)}),{listenerSetter:this.listenerSetter}),t.content.append(i),this.scrollable.append(t.container),this.applyColor=(0,S.Z)(this._applyColor,16,!0)}setActive(){const e=this.grid.querySelector(".active"),t=this.theme.settings.wallpaper.settings.background_color,i=t?this.grid.querySelector(`.grid-item[data-color="${t}"]`):null;e!==i&&(e&&e.classList.remove("active"),i&&i.classList.add("active"))}onOpen(){setTimeout((()=>{var e,t;const i=this.theme.settings,s=null===(t=null===(e=null==i?void 0:i.wallpaper)||void 0===e?void 0:e.settings)||void 0===t?void 0:t.background_color,n=!!s&&"wallPaperNoFile"===i.wallpaper._;n&&(this.colorPicker.onChange=this.onColorChange),this.colorPicker.setColor(s&&"#"+s.toString(16)||"#cccccc"),n||(this.colorPicker.onChange=this.onColorChange)}),0)}onCloseAfterTimeout(){return this.colorPicker.onChange=void 0,this.colorPicker=void 0,super.onCloseAfterTimeout()}}var k,T=i(9687),x=i(236),A=i(7814),_=i(9405),F=i(9492),D=i(7479),R=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class B extends w._{constructor(){super(...arguments),this.clicked=new Set,this.wallPapersByElement=new Map,this.elementsByKey=new Map,this.onUploadClick=()=>{(function(e){const t=document.createElement("input");t.type="file",t.style.display="none",e&&(t.accept=e),document.body.append(t);const i=new Promise(((e,i)=>{t.addEventListener("change",(t=>{const s=t.target.files[0];s?e(s):i("NO_FILE_SELECTED")}),{once:!0})})).finally((()=>{t.remove()}));return t.click(),i})("image/x-png,image/png,image/jpeg").then((e=>R(this,void 0,void 0,(function*(){if(e.name.endsWith(".png")){const t=document.createElement("img"),i=URL.createObjectURL(e);yield(0,s.cj)(t,i,!1);const n="image/jpeg",{blob:a}=yield(0,A.Z)({media:t,size:new _.c(t.naturalWidth,t.naturalHeight),mimeType:n});e=new File([a],e.name.replace(/\.png$/,".jpg"),{type:n})}const t=yield this.managers.appDocsManager.prepareWallPaperUpload(e),i=this.managers.appDocsManager.uploadWallPaper(t.id),n=f.Z.getNewDeferredForUpload(e.name,i),a=(0,o.Z)();a.addNotifyListener=n.addNotifyListener,a.cancel=n.cancel,n.then((e=>{this.clicked.delete(r),this.elementsByKey.delete(r),this.wallPapersByElement.set(l,e);const t=this.getWallPaperKey(e);this.elementsByKey.set(t,l),B.setBackgroundDocument(e).then(a.resolve,a.reject)}),a.reject);const r=this.getWallPaperKey(t);a.catch((()=>{l.remove()}));const d=new y.Z({isUpload:!0,cancelable:!0,tryAgainOnFail:!1}),{container:l}=yield this.addWallPaper(t,!1);this.clicked.add(r),d.attach(l,!1,a)}))))},this.onResetClick=()=>{var e,t,i,s;const n=x.h.settings.themes.find((e=>e.name===this.theme.name));n&&(++B.tempId,this.theme.settings=(0,h.Z)(n.settings),this.managers.appStateManager.pushToState("settings",g.Z.settings),m.ZP.applyCurrentTheme(void 0,void 0,!0),this.blurCheckboxField.setValueSilently(null===(s=null===(i=null===(t=null===(e=this.theme.settings)||void 0===e?void 0:e.wallpaper)||void 0===t?void 0:t.settings)||void 0===i?void 0:i.pFlags)||void 0===s?void 0:s.blur))},this.onGridClick=e=>{const t=(0,d.Z)(e.target,"grid-item");if(!t)return;const i=this.wallPapersByElement.get(t);if("wallPaperNoFile"===i._)return void B.setBackgroundDocument(i);const s=this.getWallPaperKey(i);if(this.clicked.has(s))return;this.clicked.add(s);const n=i.document,a=new y.Z({cancelable:!0,tryAgainOnFail:!1}),o=()=>R(this,void 0,void 0,(function*(){var e,s,o,r;const d=B.setBackgroundDocument(i);(yield this.managers.thumbsStorage.getCacheContext(n)).url&&!(null===(r=null===(o=null===(s=null===(e=this.theme.settings)||void 0===e?void 0:e.wallpaper)||void 0===s?void 0:s.settings)||void 0===o?void 0:o.pFlags)||void 0===r?void 0:r.blur)||a.attach(t,!0,d)}));a.construct(),(0,r.fc)(t,(e=>{a.preloader.parentElement?(a.onClick(e),a.detach()):o()}),{listenerSetter:this.listenerSetter}),o()},this.setActive=()=>{const e=this.grid.querySelector(".active"),t=this.elementsByKey.get(this.getWallPaperKeyFromTheme(this.theme));e!==t&&(e&&e.classList.remove("active"),t&&t.classList.add("active"))}}static getInitArgs(){return{backgrounds:g.Z.managers.appThemesManager.getWallPapers()}}get theme(){return C.Z.getTheme()}init(e=B.getInitArgs()){var t,i,s;this.container.classList.add("background-container","background-image-container"),this.setTitle("ChatBackground");{const e=(0,Z.R)(this.scrollable),n=(0,v.Z)("btn-primary btn-transparent",{icon:"cameraadd",text:"ChatBackground.UploadWallpaper"}),a=(0,v.Z)("btn-primary btn-transparent",{icon:"colorize",text:"SetColor"}),d=(0,v.Z)("btn-primary btn-transparent",{icon:"favourites",text:"Appearance.Reset"});(0,r.fc)(n,this.onUploadClick,{listenerSetter:this.listenerSetter}),(0,r.fc)(a,(()=>{this.slider.createTab(M).open()}),{listenerSetter:this.listenerSetter}),(0,r.fc)(d,this.onResetClick,{listenerSetter:this.listenerSetter});const l=null===(t=this.theme.settings)||void 0===t?void 0:t.wallpaper,c=this.blurCheckboxField=new b.Z({text:"ChatBackground.Blur",name:"blur",checked:null===(s=null===(i=null==l?void 0:l.settings)||void 0===i?void 0:i.pFlags)||void 0===s?void 0:s.blur});this.listenerSetter.add(c.input)("change",(()=>R(this,void 0,void 0,(function*(){this.theme.settings.wallpaper.settings.pFlags.blur=c.input.checked||void 0,yield this.managers.appStateManager.pushToState("settings",g.Z.settings),setTimeout((()=>{const e=o.querySelector(".active");if(!e)return;const t=this.wallPapersByElement.get(e);t.pFlags.pattern||"wallPaperNoFile"===t._||B.setBackgroundDocument(t)}),100)})))),e.append(n,a,d,(0,D.tG)(c).container)}g.Z.addEventListener("background_change",this.setActive);const n=e.backgrounds.then((e=>{const t=e.map((e=>this.addWallPaper(e)));return Promise.all(t)})),a=(0,Z.R)(this.scrollable),o=this.grid=document.createElement("div");return o.classList.add("grid"),(0,r.fc)(o,this.onGridClick,{listenerSetter:this.listenerSetter}),a.append(o),n}getWallPaperKey(e){return""+e.id}getWallPaperKeyFromTheme(e){var t;return""+(this.getWallPaperKey(null===(t=e.settings)||void 0===t?void 0:t.wallpaper)||"")}static addWallPaper(e,t=document.createElement("div")){var i;const s=(0,l.EM)(e),n="wallPaper"===e._;if(n&&e.pFlags.pattern&&!s)return;const a=!!e.pFlags.dark;let o=n?e.document:void 0;n&&!o&&(o={_:"webDocumentNoProxy",attributes:[],size:1e5,url:"assets/img/pattern.svg",w:1440,h:2960,mime_type:"image/svg+xml"}),t.classList.add("background-item"),t.dataset.id=""+e.id;const r=document.createElement("div");r.classList.add("background-item-media");const d=[];let c,h;if(n){h=(0,T.Z)(o,200,200),c=(0,F.Z)({photo:o,message:null,container:r,withoutPreloader:!0,size:h,noFadeIn:e.pFlags.pattern}),e.pFlags.pattern&&r.classList.add("is-pattern");const i=c.then((({loadPromises:e,images:t})=>R(this,void 0,void 0,(function*(){return(yield e.thumb)||e.full,t})))).then((i=>{var s;return e.pFlags.pattern&&(a?(i.full.style.display="none",i.thumb&&(i.thumb.style.display="none")):(null===(s=e.settings)||void 0===s?void 0:s.intensity)&&(i.full.style.opacity=""+Math.abs(e.settings.intensity)/100)),u.Z.mutate((()=>{t.append(r)}))}));d.push(i)}else t.append(r);if(null===(i=e.settings)||void 0===i?void 0:i.background_color){const{canvas:t}=p.Z.create(s);if(t.classList.add("background-colors-canvas"),a&&n){const i=c.then((({loadPromises:i})=>i.full.then((()=>R(this,void 0,void 0,(function*(){const i=yield g.Z.managers.thumbsStorage.getCacheContext(o,h.type);t.style.webkitMaskImage=`url(${i.url})`,t.style.opacity=""+(e.pFlags.dark?100+e.settings.intensity:e.settings.intensity)/100,r.append(t)}))))));d.push(i)}else r.append(t)}return{container:t,media:r,loadPromise:Promise.all(d)}}addWallPaper(e,t=!0){const i=B.addWallPaper(e);if(i){const{container:s,media:n}=i;s.classList.add("grid-item"),n.classList.add("grid-item-media");const a=this.getWallPaperKey(e);this.wallPapersByElement.set(s,e),this.elementsByKey.set(a,s),this.getWallPaperKeyFromTheme(this.theme)===a&&s.classList.add("active"),this.grid[t?"append":"prepend"](s)}return i&&i.loadPromise.then((()=>i))}}k=B,B.tempId=0,B.setBackgroundDocument=(e,t)=>{const i=++k.tempId,r=()=>i===k.tempId,d=e.document,h=(0,o.Z)();let u;d?(u=f.Z.downloadMediaURL({media:d,queueId:m.ZP.chat.bubbles?m.ZP.chat.bubbles.lazyLoadQueue.queueId:0}),h.addNotifyListener=u.addNotifyListener,h.cancel=u.cancel):u=Promise.resolve();const v=(e,t)=>{fetch(t).then((t=>{m.ZP.cacheStorage.save("backgrounds/"+e,t)}))};return u.then((()=>R(void 0,void 0,void 0,(function*(){var i,o,u;if(!r())return void h.resolve();const f=!!t;null!=t||(t=C.Z.getTheme().settings);const b=i=>{var a;let o;const d=(0,l.EM)(e);if(i&&!d)o=function(e){const t=document.createElement("img");return(0,s.cj)(t,e,!1).then((()=>function(e,t,i){const s=document.createElement("canvas"),a=t/i;return 1===a?(s.width=50,s.height=s.width/a):a>1?(s.height=50,s.width=s.height/a):s.width=s.height=50,s.getContext("2d").drawImage(e,0,0,t,i,0,0,s.width,s.height),n(s)}(t,t.naturalWidth,t.naturalHeight)))}(i);else{const{canvas:e}=p.Z.create(d);o=Promise.resolve(n(e))}const u=null!==(a=e.slug)&&void 0!==a?a:"";Promise.all([o,u&&v(u,i)]).then((([s])=>{if(!r())return void h.resolve();const n=c(Array.from(s));t.wallpaper=e,t.highlightningColor=n,f||g.Z.managers.appStateManager.pushToState("settings",g.Z.settings),m.ZP.applyCurrentTheme(u,i,!0).then(h.resolve)}))};if(!d)return void b();const y=yield g.Z.managers.thumbsStorage.getCacheContext(d);(null===(u=null===(o=null===(i=t.wallpaper)||void 0===i?void 0:i.settings)||void 0===o?void 0:o.pFlags)||void 0===u?void 0:u.blur)?setTimeout((()=>{const{canvas:e,promise:t}=(0,a.Z)(y.url,12,4);t.then((()=>{r()?b(e.toDataURL()):h.resolve()}))}),200):r()&&b(y.url)})))),h}},534:(e,t,i)=>{"use strict";i.d(t,{Z:()=>T});var s=i(5005),n=i(1447),a=i(3552),o=i(2796),r=i(503),d=i(2230),l=i(5322),c=i(4494),h=i(5644),u=i(9807),p=i(2325),f=i(8479),m=i(7625),g=i(130),v=i(8115),b=i(1507),y=i(3512),w=i(2738),S=i(5029),C=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class L extends a._{constructor(){super(...arguments),this.renderResults=e=>C(this,void 0,void 0,(function*(){yield this.managers.appUsersManager.getContacts(),e.forEach((e=>{const{dom:t}=s.default.addDialogNew({peerId:e,container:this.selector.scrollable,rippleEnabled:!0,avatarSize:"abitbigger"}),i=this.selector.selected.has(e);t.containerEl.append(this.checkbox(i));const n=[];this.dialogsByFilters.forEach(((t,i)=>{if(t.has(e)){const e=document.createElement("span");(0,g.Z)(e,(0,v.Z)(i.title)),n.push(e)}})),(0,p.v_)(n,!1).forEach((e=>{t.lastMessageSpan.append(e)}))}))})),this.onSelectChange=e=>{"included"===this.type&&(this.confirmBtn.style.display=e?"":"none")}}init(e,t,i){this.originalFilter=e,this.filter=(0,f.Z)(this.originalFilter),this.type=t,this.editFolderTab=i,this.content.remove(),this.container.classList.add("included-chatlist-container"),this.confirmBtn=(0,d.Z)("check btn-confirm blue",{noRipple:!0}),this.confirmBtn.style.display="none",this.header.append(this.confirmBtn),(0,w.fc)(this.confirmBtn,(()=>C(this,void 0,void 0,(function*(){const e=this.selector.getSelected();if("included"===this.type)for(const e in this.filter.pFlags)0!==e.indexOf("exclude_")&&delete this.filter.pFlags[e];else for(const e in this.filter.pFlags)0===e.indexOf("exclude_")&&delete this.filter.pFlags[e];const t=[];for(const i of e)i.isPeerId()?t.push(i.toPeerId()):this.filter.pFlags[i]=!0;let i;i="included"===this.type?e=>t.includes(e):e=>!t.includes(e),(0,m.Z)(this.filter.pinnedPeerIds,((e,t)=>{i(e)||(this.filter.pinnedPeerIds.splice(t,1),this.filter.pinned_peers.splice(t,1))}));const s="included"===this.type?"excludePeerIds":"includePeerIds",n="included"===this.type?"exclude_peers":"include_peers";(0,m.Z)(this.filter[s],((e,i)=>{t.includes(e)&&(this.filter[s].splice(i,1),this.filter[n].splice(i,1))})),this.filter["included"===this.type?"includePeerIds":"excludePeerIds"]=t,this.filter["included"===this.type?"include_peers":"exclude_peers"]=yield Promise.all(t.map((e=>this.managers.appPeersManager.getInputPeerById(e)))),this.editFolderTab.setFilter(this.filter,!1),this.close()}))),{listenerSetter:this.listenerSetter});const s=e=>{this.limit=y.Z.premium?e.dialog_filters_chats_limit_premium:e.dialog_filters_chats_limit_default};return this.listenerSetter.add(y.Z)("app_config",s),this.dialogsByFilters=new Map,Promise.all([this.managers.filtersStorage.getDialogFilters().then((e=>C(this,void 0,void 0,(function*(){yield Promise.all(e.filter((e=>!b.DZ.has(e.id))).map((e=>C(this,void 0,void 0,(function*(){const t=(yield this.managers.dialogsStorage.getFolderDialogs(e.id)).map((e=>e.peerId));this.dialogsByFilters.set(e,new Set(t))})))))})))),this.managers.apiManager.getAppConfig().then((e=>{s(e)}))])}checkbox(e){const t=new u.Z({round:!0});return e&&(t.input.checked=e),t.label}onOpen(){this.confirmBtn.style.display="excluded"===this.type?"":"none",this.setTitle("included"===this.type?"FilterAlwaysShow":"FilterNeverShow");const e=this.filter,t=new S.Z({noDelimiter:!0,name:"FilterChatTypes"});let i;t.container.classList.add("folder-categories"),i="excluded"===this.type?{exclude_muted:{ico:"mute",text:"ChatList.Filter.MutedChats"},exclude_archived:{ico:"archive",text:"ChatList.Filter.Archive"},exclude_read:{ico:"readchats",text:"ChatList.Filter.ReadChats"}}:{contacts:{ico:"newprivate",text:"ChatList.Filter.Contacts"},non_contacts:{ico:"noncontacts",text:"ChatList.Filter.NonContacts"},groups:{ico:"group",text:"ChatList.Filter.Groups"},broadcasts:{ico:"newchannel",text:"ChatList.Filter.Channels"},bots:{ico:"bots",text:"ChatList.Filter.Bots"}};const s=document.createDocumentFragment();for(const e in i){const t=(0,c.Z)("btn-primary btn-transparent folder-category-button",{icon:i[e].ico,text:i[e].text});t.dataset.peerId=e,t.append(this.checkbox()),s.append(t)}t.content.append(s);const n=("included"===this.type?e.includePeerIds:e.excludePeerIds).slice();this.selector=new h.Z({appendTo:this.container,onChange:this.onSelectChange,peerType:["dialogs"],renderResultsFunc:this.renderResults,placeholder:"Search",sectionNameLangPackKey:"FilterChats",managers:this.managers}),this.selector.selected=new Set(n);let a=!1;const r=this.selector.add.bind(this.selector);this.selector.add=(e,t,s)=>{if(this.selector.selected.size>=this.limit&&a&&!i[e]){const t=this.selector.list.querySelector(`[data-peer-id="${e}"] [type="checkbox"]`);t&&setTimeout((()=>{t.checked=!1}),0);const i=p.ZP.format("excluded"===this.type?"ChatList.Filter.Exclude.LimitReached":"ChatList.Filter.Include.LimitReached",!0);return void(0,o.Am)(i)}const n=r(e,i[e]?(0,p.ag)(i[e].text):void 0,s);return i[e]&&n.querySelector("avatar-element").classList.add("tgico-"+i[e].ico),n},this.selector.scrollable.container.append(t.container,this.selector.scrollable.container.lastElementChild),this.selector.addInitial(n),a=!0;for(const s in e.pFlags)i.hasOwnProperty(s)&&e.pFlags[s]&&(0,w.tH)(t.content.querySelector(`[data-peer-id="${s}"]`))}onCloseAfterTimeout(){return this.selector&&(this.selector.container.remove(),this.selector=null),super.onCloseAfterTimeout()}}var E=i(8127),I=i(6848),P=i(3066),Z=i(2353),M=i(1168),k=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class T extends a._{constructor(){super(...arguments),this.flags={}}static getInitArgs(){return{animationData:n.Z.loadAnimationFromURLManually("Folders_2")}}init(e=T.getInitArgs()){this.container.classList.add("edit-folder-container"),this.caption=document.createElement("div"),this.caption.classList.add("caption"),this.caption.append((0,p.ag)("FilterIncludeExcludeInfo")),this.stickerContainer=document.createElement("div"),this.stickerContainer.classList.add("sticker-container"),this.confirmBtn=(0,d.Z)("check btn-confirm hide blue");let t=!1;const i={icon:"delete danger",text:"FilterMenuDelete",onClick:()=>{M.Z.createPopup(E.Z,"filter-delete",{titleLangKey:"ChatList.Filter.Confirm.Remove.Header",descriptionLangKey:"ChatList.Filter.Confirm.Remove.Text",buttons:[{langKey:"Delete",callback:()=>{t||(t=!0,this.managers.filtersStorage.updateDialogFilter(this.filter,!0).then((e=>{this.close()})).finally((()=>{t=!1})))},isDanger:!0}]}).show()}};this.menuBtn=(0,l.Z)({listenerSetter:this.listenerSetter,direction:"bottom-left",buttons:[i]}),this.menuBtn.classList.add("hide"),this.header.append(this.confirmBtn,this.menuBtn);const s=new S.Z({}),a=document.createElement("div");a.classList.add("input-wrapper"),this.nameInputField=new r.ZP({label:"FilterNameHint",maxLength:12}),a.append(this.nameInputField.container),s.content.append(a);const h=(e,t,i,s)=>{const n=new S.Z({name:t,noDelimiter:!0});n.container.classList.add("folder-list",e);const a=n.generateContentElement();return a.classList.add("folder-categories"),i.forEach((e=>{const t=(0,c.Z)("folder-category-button btn btn-primary btn-transparent",{icon:e.icon,text:e.text,noRipple:!e.withRipple||void 0});e.name&&(s[e.name]=t),a.append(t)})),n};this.includePeerIds=h("folder-list-included","FilterInclude",[{icon:"add primary",text:"ChatList.Filter.Include.AddChat",withRipple:!0},{text:"ChatList.Filter.Contacts",icon:"newprivate",name:"contacts"},{text:"ChatList.Filter.NonContacts",icon:"noncontacts",name:"non_contacts"},{text:"ChatList.Filter.Groups",icon:"group",name:"groups"},{text:"ChatList.Filter.Channels",icon:"channel",name:"broadcasts"},{text:"ChatList.Filter.Bots",icon:"bots",name:"bots"}],this.flags),this.excludePeerIds=h("folder-list-excluded","FilterExclude",[{icon:"minus primary",text:"ChatList.Filter.Exclude.AddChat",withRipple:!0},{text:"ChatList.Filter.MutedChats",icon:"mute",name:"exclude_muted"},{text:"ChatList.Filter.Archive",icon:"archive",name:"exclude_archived"},{text:"ChatList.Filter.ReadChats",icon:"readchats",name:"exclude_read"}],this.flags),this.scrollable.append(this.stickerContainer,this.caption,s.container,this.includePeerIds.container,this.excludePeerIds.container);const u=this.includePeerIds.container.querySelector(".folder-categories"),f=this.excludePeerIds.container.querySelector(".folder-categories");(0,w.fc)(u.querySelector(".btn"),(()=>{this.slider.createTab(L).open(this.filter,"included",this)}),{listenerSetter:this.listenerSetter}),(0,w.fc)(f.querySelector(".btn"),(()=>{this.slider.createTab(L).open(this.filter,"excluded",this)}),{listenerSetter:this.listenerSetter}),(0,w.fc)(this.confirmBtn,(()=>{if(this.nameInputField.input.classList.contains("error"))return;if(!this.nameInputField.value.trim())return void this.nameInputField.input.classList.add("error");let e,t=Array.from(u.children).slice(1).reduce(((e,t)=>e+ +!t.style.display),0);t+=this.filter.include_peers.length,t?(this.confirmBtn.setAttribute("disabled","true"),e=this.filter.id?this.managers.filtersStorage.updateDialogFilter(this.filter):this.managers.filtersStorage.createDialogFilter(this.filter),e.then((e=>{this.close()})).catch((e=>{"DIALOG_FILTERS_TOO_MUCH"===e.type?(0,o.Am)("Sorry, you can't create more folders."):console.error("updateDialogFilter error:",e)})).finally((()=>{this.confirmBtn.removeAttribute("disabled")}))):(0,o.Am)("Please choose at least one chat for this folder.")}),{listenerSetter:this.listenerSetter}),this.listenerSetter.add(this.nameInputField.input)("input",(()=>{this.filter.title=this.nameInputField.value,this.editCheckForChange()}));const m="edit"===this.type?[this.managers.filtersStorage.reloadMissingPeerIds(this.filter.id,"pinned_peers"),this.managers.filtersStorage.reloadMissingPeerIds(this.filter.id,"include_peers"),this.managers.filtersStorage.reloadMissingPeerIds(this.filter.id,"exclude_peers")]:[];return Promise.all([this.loadAnimationPromise=e.animationData.then((e=>k(this,void 0,void 0,(function*(){const t=yield e({container:this.stickerContainer,loop:!1,autoplay:!1,width:86,height:86});return this.animation=t,n.Z.waitForFirstFrame(t)})))),...m]).then((()=>{"edit"===this.type?(this.setFilter(this.originalFilter,!0),this.onEditOpen()):(this.setInitFilter(),this.onCreateOpen())}))}onOpenAfterTimeout(){this.loadAnimationPromise.then((()=>{this.animation.autoplay=!0,this.animation.play()}))}onCreateOpen(){this.setTitle("FilterNew"),this.menuBtn.classList.add("hide"),this.confirmBtn.classList.remove("hide");for(const e in this.flags)this.flags[e].style.display="none"}onEditOpen(){this.setTitle("create"===this.type?"FilterNew":"FilterHeaderEdit"),"edit"===this.type&&(this.menuBtn.classList.remove("hide"),this.confirmBtn.classList.add("hide"));const e=this.filter;this.nameInputField.value=(0,P.Z)(e.title);for(const t in this.flags)this.flags[t].style.display=e.pFlags[t]?"":"none";["includePeerIds","excludePeerIds"].forEach((t=>k(this,void 0,void 0,(function*(){const i=this[t],n=s.default.createChatList({ignoreClick:!0});let a=e[t];const o=e=>k(this,void 0,void 0,(function*(){return!!(yield this.managers.appMessagesManager.getDialogOnly(e))||!!e.isUser()&&"user"===(yield this.managers.appUsersManager.getUser(e.toUserId()))._})),r=yield(0,Z.Z)(a,(e=>o(e)));a.length=0,a.push(...r),a=a.slice();const d=e=>k(this,void 0,void 0,(function*(){for(let t=0,i=Math.min(a.length,e);t<i;++t){const e=a.shift();if(!e.isUser()&&!(yield this.managers.appMessagesManager.getDialogOnly(e)))continue;const{dom:t}=s.default.addDialogNew({peerId:e,container:n,rippleEnabled:!1,meAsSaved:!0,avatarSize:"small"});t.lastMessageSpan.parentElement.remove()}a.length?l.lastElementChild.replaceWith((0,p.ag)("FilterShowMoreChats",[a.length])):l&&l.remove()}));let l;if(i.generateContentElement().append(n),a.length){const e=i.generateContentElement();l=(0,c.Z)("folder-category-button btn btn-primary btn-transparent",{icon:"down"}),l.classList.add("load-more","rp-overflow"),(0,w.fc)(l,(()=>d(20)),{listenerSetter:this.listenerSetter}),l.append((0,p.ag)("FilterShowMoreChats",[a.length])),e.append(l)}d(4)}))))}editCheckForChange(){if("edit"===this.type){const e=!(0,I.Z)(this.originalFilter,this.filter);this.confirmBtn.classList.toggle("hide",!e),this.menuBtn.classList.toggle("hide",e)}}setFilter(e,t){this.container&&Array.from(this.container.querySelectorAll("ul, .load-more")).forEach((e=>e.remove())),t?(this.originalFilter=e,this.filter=(0,f.Z)(e)):(this.filter=e,this.onEditOpen(),this.editCheckForChange())}setInitFilter(e){void 0===e?(this.setFilter({_:"dialogFilter",id:0,title:"",pFlags:{},pinned_peers:[],include_peers:[],exclude_peers:[],pinnedPeerIds:[],includePeerIds:[],excludePeerIds:[]},!0),this.type="create"):(this.setFilter(e,!0),this.type="edit")}}},2010:(e,t,i)=>{"use strict";i.d(t,{J:()=>f,Z:()=>m});var s=i(503),n=i(3552),a=i(2621),o=i(6726),r=i(2325),d=i(2738),l=i(3512),c=i(2521),h=i(6082),u=i(5029),p=i(9522);function f(){const e=document.createElement("div"),t=(0,c.Z)(document.createElement("a")),i=(0,r.ag)("Username.Purchase",[t]);return i.classList.add("username-purchase-help"),e.append(i,document.createElement("br"),document.createElement("br")),e.classList.add("hide"),{element:e,setUsername:i=>{i&&(t.href="https://fragment.com/username/"+i),e.classList.toggle("hide",!i)}}}class m extends n._{static getInitArgs(){return{bioMaxLength:l.Z.managers.apiManager.getLimit("bio"),user:l.Z.managers.appUsersManager.getSelf(),userFull:l.Z.managers.appProfileManager.getProfile(l.Z.myId.toUserId())}}init(e){return t=this,i=void 0,c=function*(){this.container.classList.add("edit-profile-container"),this.setTitle("EditAccount.Title");const t=[],[i,n,c]=yield Promise.all([e.bioMaxLength,e.user,e.userFull]);{const e=(0,u.R)(this.scrollable,void 0,"Bio.Description"),n=document.createElement("div");n.classList.add("input-wrapper"),this.firstNameInputField=new s.ZP({label:"EditProfile.FirstNameLabel",name:"first-name",maxLength:70}),this.lastNameInputField=new s.ZP({label:"Login.Register.LastName.Placeholder",name:"last-name",maxLength:64}),this.bioInputField=new s.ZP({label:"EditProfile.BioLabel",name:"bio",maxLength:i}),n.append(this.firstNameInputField.container,this.lastNameInputField.container,this.bioInputField.container);const o=document.createElement("div");o.classList.add("caption"),(0,r.XZ)({element:o,key:"Bio.Description"}),t.push(this.firstNameInputField,this.lastNameInputField,this.bioInputField),this.editPeer=new a.Z({peerId:l.Z.myId,inputFields:t,listenerSetter:this.listenerSetter}),this.content.append(this.editPeer.nextBtn),e.append(this.editPeer.avatarEdit.container,n)}{const e=new u.Z({name:"EditAccount.Username",caption:!0}),i=document.createElement("div");i.classList.add("input-wrapper"),this.usernameInputField=new o.l({label:"EditProfile.Username.Label",name:"username",plainText:!0,listenerSetter:this.listenerSetter,onChange:()=>{this.editPeer.handleChange();const{error:e}=this.usernameInputField,t="USERNAME_PURCHASE_AVAILABLE"===(null==e?void 0:e.type);n(t?this.usernameInputField.value:void 0)},availableText:"EditProfile.Username.Available",takenText:"EditProfile.Username.Taken",invalidText:"EditProfile.Username.Invalid"},this.managers),i.append(this.usernameInputField.container);const s=e.caption,{setUsername:n,element:a}=f();s.append(a,(0,r.ag)("UsernameHelp")),t.push(this.usernameInputField),e.content.append(i),this.scrollable.append(e.container)}{const e=new p.Z({peerId:l.Z.myId,peer:n,listenerSetter:this.listenerSetter,usernameInputField:this.usernameInputField,middleware:this.middlewareHelper.get()});this.scrollable.append(e.container)}(0,d.fc)(this.editPeer.nextBtn,(()=>{this.editPeer.nextBtn.disabled=!0;const e=[],t=this.managers.appProfileManager.updateProfile(this.firstNameInputField.value,this.lastNameInputField.value,this.bioInputField.value);e.push(t.then((()=>{this.close()}),(e=>{console.error("updateProfile error:",e)}))),this.editPeer.uploadAvatar&&e.push(this.editPeer.uploadAvatar().then((e=>this.managers.appProfileManager.uploadProfilePhoto(e)))),this.usernameInputField.isValidToChange()&&e.push(this.managers.appUsersManager.updateUsername(this.usernameInputField.value)),Promise.race(e).finally((()=>{this.editPeer.nextBtn.removeAttribute("disabled")}))}),{listenerSetter:this.listenerSetter}),this.firstNameInputField.setOriginalValue(n.first_name,!0),this.lastNameInputField.setOriginalValue(n.last_name,!0),this.bioInputField.setOriginalValue(c.about,!0),this.usernameInputField.setOriginalValue((0,h.Z)(n),!0),this.editPeer.handleChange()},new((n=void 0)||(n=Promise))((function(e,s){function a(e){try{r(c.next(e))}catch(e){s(e)}}function o(e){try{r(c.throw(e))}catch(e){s(e)}}function r(t){var i;t.done?e(t.value):(i=t.value,i instanceof n?i:new n((function(e){e(i)}))).then(a,o)}r((c=c.apply(t,i||[])).next())}));var t,i,n,c}}},4332:(e,t,i)=>{"use strict";i.d(t,{HQ:()=>d,ZP:()=>h});var s=i(7030),n=i(3552),a=i(4755),o=i(1669),r=i(410);const d="is-right-column-shown";class l extends n.Z{constructor(){super({sidebarEl:document.getElementById("column-right"),canHideFirst:!0,navigationType:"right"}),this.isColumnProportionSet=!1}construct(e){this.managers=e,a.Z.addEventListener("changeScreen",((e,t)=>{t===a._.medium&&e!==a._.mobile&&this.toggleSidebar(!1)})),a.Z.addEventListener("resize",(()=>{this.setColumnProportion()}))}createSharedMediaTab(){const e=this.createTab(o.Z,!1,!0);return e.slider=this,e}replaceSharedMediaTab(e){const t=this.sharedMediaTab;if(t){const i=this.historyTabIds.indexOf(t);this._selectTab.getFrom()===t.container&&this._selectTab.setFrom(null==e?void 0:e.container),e?(-1!==i&&(this.historyTabIds[i]=e),t.container.classList.contains("active")&&e.container.classList.add("active"),t.container.replaceWith(e.container)):(-1!==i&&this.historyTabIds.splice(i,1),t.container.remove())}else this.tabsContainer.prepend(e.container);this.sharedMediaTab=e}onCloseTab(e,t,i){this.historyTabIds.length||this.toggleSidebar(!1,t),super.onCloseTab(e,t,i)}setColumnProportion(){const e=this.sidebarEl.scrollWidth/this.sidebarEl.previousElementSibling.scrollWidth;document.documentElement.style.setProperty("--right-column-proportion",""+e)}toggleSidebar(e,t){const i=document.body.classList.contains(d);let n;if(void 0!==e?e?i||(n=!0):i&&(n=!0):n=!0,!n)return Promise.resolve();i||this.historyTabIds.length||this.sharedMediaTab.open(),this.isColumnProportionSet||(this.setColumnProportion(),this.isColumnProportionSet=!0);const a=s.ZP.selectTab(i?s.oo.CHAT:s.oo.PROFILE,t);return document.body.classList.toggle(d,e),a}}const c=new l;r.GO.appSidebarRight=c;const h=c},4240:(e,t,i)=>{"use strict";i.d(t,{Z:()=>S});var s=i(3552),n=i(503),a=i(2621),o=i(7479),r=i(9807),d=i(4494),l=i(8842),c=i(3512),h=i(8127),u=i(1168),p=i(2325),f=i(2738),m=i(1656),g=i(2946),v=i(8210),b=i(5029),y=i(7362),w=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class S extends s._{init(){return w(this,void 0,void 0,(function*(){const{peerId:e}=this,t=e.toUserId();this.container.classList.add("edit-peer-container","edit-contact-container");const[i,s]=yield Promise.all([this.managers.appUsersManager.isContact(t),this.managers.appPrivacyManager.getPrivacy("inputPrivacyKeyPhoneNumber")]),S=!i;this.setTitle(S?"AddContactTitle":"Edit");{const i=new b.Z({noDelimiter:!0}),s=[],d=document.createElement("div");if(d.classList.add("input-wrapper"),this.nameInputField=new n.ZP({label:"FirstName",name:"contact-name",maxLength:70,required:!0}),this.lastNameInputField=new n.ZP({label:"LastName",name:"contact-lastname",maxLength:70}),t){const e=yield this.managers.appUsersManager.getUser(t);S?(this.nameInputField.setDraftValue(e.first_name),this.lastNameInputField.setDraftValue(e.last_name)):(this.nameInputField.setOriginalValue(e.first_name),this.lastNameInputField.setOriginalValue(e.last_name))}if(d.append(this.nameInputField.container,this.lastNameInputField.container),s.push(this.nameInputField,this.lastNameInputField),this.editPeer=new a.Z({peerId:e,inputFields:s,listenerSetter:this.listenerSetter,doNotEditAvatar:!0}),this.content.append(this.editPeer.nextBtn),e){const s=document.createElement("div");s.classList.add("avatar-edit"),s.append(this.editPeer.avatarElem);const n=new r.Z({text:"Notifications"});n.input.addEventListener("change",(t=>{t.isTrusted&&this.managers.appMessagesManager.togglePeerMute({peerId:e})})),this.listenerSetter.add(c.Z)("notify_settings",(e=>w(this,void 0,void 0,(function*(){if("notifyPeer"!==e.peer._)return;const t=(0,g.Z)(e.peer.peer);if(t==t){const t=!(yield this.managers.appNotificationsManager.isMuted(e.notify_settings));t!==n.checked&&(n.checked=t)}}))));const a=document.createElement("div");a.classList.add("profile-name"),a.append(new l.Z({peerId:e}).element);const h=document.createElement("div");if(h.classList.add("profile-subtitle"),h.append((0,p.ag)("EditContact.OriginalName")),i.content.append(s,a,h,d),S){const s=yield this.managers.appUsersManager.getUser(t),n=new o.ZP({icon:"phone",titleLangKey:s.phone?void 0:"MobileHidden",title:s.phone?(0,v.Z)(s.phone):void 0,subtitleLangKey:s.phone?"Phone":"MobileHiddenExceptionInfo",subtitleLangArgs:s.phone?void 0:[new l.Z({peerId:e}).element]});i.content.append(n.container)}else{const t=new o.ZP({checkboxField:n,withCheckboxSubtitle:!0,listenerSetter:this.listenerSetter}),s=!(yield this.managers.appNotificationsManager.isPeerLocalMuted({peerId:e,respectType:!1}));n.checked=s,i.content.append(t.container)}}else i.content.append(d);this.scrollable.append(i.container)}if(S){if(s.some((e=>"privacyValueDisallowAll"===e._))&&!s.some((e=>"privacyValueAllowUsers"===e._&&e.users.includes(t)))){const e=new b.Z({caption:"NewContact.Exception.ShareMyPhoneNumber.Desc",captionArgs:[yield(0,y.Z)({peerId:this.peerId})]}),t=this.sharePhoneCheckboxField=new r.Z({text:"NewContact.Exception.ShareMyPhoneNumber",checked:!0}),i=(0,o.tG)(t);e.content.append(i.container),this.scrollable.append(e.container)}}else{const i=new b.Z,s=(0,d.Z)("btn-primary btn-transparent danger",{icon:"delete",text:"PeerInfo.DeleteContact"});(0,f.fc)(s,(()=>{u.Z.createPopup(h.Z,"popup-delete-contact",{peerId:e,titleLangKey:"DeleteContact",descriptionLangKey:"AreYouSureDeleteContact",buttons:(0,u.x)([{langKey:"Delete",callback:()=>{const e=(0,m.Z)([s],!0);this.managers.appUsersManager.deleteContacts([t]).then((()=>{this.close()}),(()=>{e()}))},isDanger:!0}])}).show()}),{listenerSetter:this.listenerSetter}),i.content.append(s),this.scrollable.append(i.container)}(0,f.fc)(this.editPeer.nextBtn,(()=>w(this,void 0,void 0,(function*(){var e;this.editPeer.nextBtn.disabled=!0,this.managers.appUsersManager.addContact(t,this.nameInputField.value,this.lastNameInputField.value,(yield this.managers.appUsersManager.getUser(t)).phone,null===(e=this.sharePhoneCheckboxField)||void 0===e?void 0:e.checked).finally((()=>{this.editPeer.nextBtn.removeAttribute("disabled"),this.close()}))}))),{listenerSetter:this.listenerSetter})}))}}},730:(e,t,i)=>{"use strict";i.d(t,{Z:()=>C});var s=i(2738),n=i(1656),a=i(9405),o=i(8479),r=i(6848),d=i(7030),l=i(1507),c=i(3785),h=i(2230),u=i(9807),p=i(6039),f=i(503),m=i(7479),g=i(5029),v=i(7856),b=i(6024),y=i(9345),w=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};const S=(0,a.C)(64,64);class C extends b.Z{init(e,t){return w(this,void 0,void 0,(function*(){this.colorIndex=0;const i=!t,a=t===l.Ox;this.container.classList.add("edit-topic-container"),this.setTitle(i?"NewTopic":"ForumTopic.Title.Edit");const r=e.toChatId();t&&(this.topic=this.originalTopic=(0,o.Z)(yield this.managers.dialogsStorage.getForumTopic(e,t)));{const i=new g.Z({name:a?"CreateGeneralTopicTitle":"CreateTopicTitle"}),o=this.iconDiv=document.createElement("div");o.classList.add("edit-topic-icon-container"),!t&&(0,s.fc)(o,(()=>{this.topic.icon_emoji_id||(this.colorIndex=(this.colorIndex+1)%l.OS.length,this.setIcon())}),{listenerSetter:this.listenerSetter}),t&&o.classList.add("disable-hover");const c=document.createElement("div");c.classList.add("input-wrapper");const u=this.nameInputField=new f.ZP({label:"ForumTopic.Name.Placeholder",withLinebreaks:!1,name:"topic-name",maxLength:70,required:!0});this.topic&&u.setOriginalValue(this.topic.title,!0);const p=this.confirmBtn=(0,h.Z)("check btn-confirm blue hide",{noRipple:!0});this.header.append(p),(0,s.fc)(p,(()=>{const i=(0,n.Z)([p],!0);t?this.managers.appChatsManager.editForumTopic({chatId:r,topicId:t,title:u.value,iconEmojiId:this.topic.icon_emoji_id||0}).then((()=>{this.close()})).catch((e=>{console.error("edit topic error",e),i()})):this.managers.appChatsManager.createForumTopic({chatId:r,iconColor:l.OS[this.colorIndex],iconEmojiId:this.topic.icon_emoji_id,title:u.value}).then((t=>{this.close(),d.ZP.setInnerPeer({peerId:e,threadId:t})})).catch((e=>{console.error("create topic error",e),i()}))}),{listenerSetter:this.listenerSetter}),this.listenerSetter.add(u.input)("input",(()=>{var e;this.validate(),this.setIcon(null===(e=this.topic)||void 0===e?void 0:e.icon_emoji_id)})),c.append(u.container),i.content.append(o,c),this.scrollable.append(i.container)}const c=[];if(a){const e=new g.Z({caption:"EditTopicHideInfo"}),i=new u.Z({checked:!this.topic.pFlags.hidden,text:"EditTopicHide"});this.listenerSetter.add(i.input)("change",(()=>{const e=this.managers.appChatsManager.editForumTopic({chatId:r,topicId:t,hidden:!i.checked});s.disableWithPromise(e)}));const s=new m.ZP({checkboxField:i});e.content.append(s.container),this.scrollable.append(e.container)}else{const e=new g.Z({});e.container.classList.add("edit-topic-emoticons-container");const t=new p.ZP({managers:this.managers,isStandalone:!0,noRegularEmoji:!0,stickerSetId:"inputStickerSetEmojiDefaultTopicIcons",onClick:e=>{t.setActive(e.docId?e:{emoji:void 0,docId:void 0}),this.setIcon(e.docId)}});t.getContainerSize=()=>({width:v.ZP.rect.width,height:400}),this.middlewareHelper.onDestroy((()=>{t.destroy()})),t.container.classList.remove("tabs-tab"),this.emojiElement=document.createElement("span"),this.emojiElement.classList.add("super-emoji-topic-icon");const i=t.init().then((()=>w(this,void 0,void 0,(function*(){var e;const i=t.getCustomCategory(),s=null===(e=this.topic)||void 0===e?void 0:e.icon_emoji_id;t.addEmojiToCategory({category:i,element:this.emojiElement,batch:!1,prepend:!0,active:!s}),s&&t.setActive({docId:s,emoji:""})}))));c.push(i),e.content.replaceWith(t.container),this.scrollable.append(e.container)}return Promise.all(c).then((()=>this.s()))}))}validate(){let e=this.nameInputField.isValidToChange();!e&&this.originalTopic&&(e=this.topic.icon_emoji_id!==this.originalTopic.icon_emoji_id),this.confirmBtn.classList.toggle("hide",!e)}s(){var e,t;return(null===(e=this.topic)||void 0===e?void 0:e.icon_color)&&(this.colorIndex=l.OS.indexOf(this.topic.icon_color)),this.setIcon(null===(t=this.topic)||void 0===t?void 0:t.icon_emoji_id,void 0,!0)}setIcon(e,t=this.iconDiv,i){var s;return w(this,void 0,void 0,(function*(){const n=this.nameInputField.value,a=t===this.iconDiv;if(a){const t={id:null===(s=this.topic)||void 0===s?void 0:s.id,icon_color:l.OS[this.colorIndex],title:(0,c.Z)(n,!0).text||"A",icon_emoji_id:e},a=this.topic;if(this.topic=t,!i&&a&&a.icon_color===t.icon_color&&a.title===t.title||this.setIcon(void 0,this.emojiElement),(0,r.Z)(a,t)&&!i)return;this.validate()}const o=yield(0,y.e)({topic:a?this.topic:Object.assign(Object.assign({},this.topic),{icon_emoji_id:void 0}),customEmojiSize:S,middleware:this.middlewareHelper.get()}),d=document.createElement("div");d.classList.add("edit-topic-icon"),d.append(o);const h=t.lastElementChild;t.append(d);const u=(e,t)=>{const i=e.animate([{opacity:"0",transform:"scale(0.8)"},{opacity:"1",transform:"scale(1)"}],{duration:200,iterations:1,easing:"ease-in-out",fill:"forwards",direction:t?"normal":"reverse"});return new Promise((e=>{i.addEventListener("finish",(()=>{e()}),{once:!0})}))};h&&u(h,!1).then((()=>h.remove())),u(d,!0)}))}}},1669:(e,t,i)=>{"use strict";i.d(t,{Z:()=>pe});var s=i(3512),n=i(6360),a=i(3552),o=i(426),r=i(503),d=i(2621),l=i(7479),c=i(4494),h=i(2166),u=i(144),p=i(279),f=i(1218),m=i(2796),g=i(6726),v=i(6024),b=i(2325),y=i(8127),w=i(8119),S=i(2738),C=i(1656),L=i(9807),E=i(5029),I=i(9522),P=i(6082),Z=i(5102),M=i(2010),k=i(5592),T=i(1168),x=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class A extends v.h{init(){return x(this,void 0,void 0,(function*(){this.container.classList.add("edit-peer-container","group-type-container");const e=yield this.managers.appChatsManager.isBroadcast(this.chatId);this.setTitle(e?"ChannelType":"GroupType");const t=new E.Z({name:e?"ChannelType":"GroupType"}),i=(0,u.a)(),n=new l.ZP({radioField:new f.Z({langKey:e?"ChannelPrivate":"MegaPrivate",name:i,value:"private"}),subtitleLangKey:e?"ChannelPrivateInfo":"MegaPrivateInfo"}),a=new l.ZP({radioField:new f.Z({langKey:e?"ChannelPublic":"MegaPublic",name:i,value:"public"}),subtitleLangKey:e?"ChannelPublicInfo":"MegaPublicInfo"}),o=(0,l.De)([n,a],(e=>{const t=[[v.container],[z]];"public"===e&&t.reverse(),t[0].forEach((e=>e.classList.remove("hide"))),t[1].forEach((e=>e.classList.add("hide"))),B()}));let r=yield this.managers.appChatsManager.getChat(this.chatId);const d={basic:[]};this.listenerSetter.add(s.Z)("chat_update",(e=>x(this,void 0,void 0,(function*(){this.chatId===e&&(r=yield this.managers.appChatsManager.getChat(this.chatId),d.basic.forEach((e=>e())))})))),t.content.append(o);const v=new E.Z({}),A=new l.ZP({title:this.chatFull.exported_invite.link,subtitleLangKey:e?"ChannelPrivateLinkHelp":"MegaPrivateLinkHelp",clickable:()=>{(0,h.T)(this.chatFull.exported_invite.link),(0,m.Am)(b.ZP.format("LinkCopied",!0))},listenerSetter:this.listenerSetter}),_=(0,c.Z)("btn-primary btn-transparent danger",{icon:"delete",text:"RevokeLink"});(0,S.fc)(_,(()=>{T.Z.createPopup(y.Z,"revoke-link",{buttons:[{langKey:"RevokeButton",callback:()=>{const e=(0,C.Z)([_],!0);this.managers.appProfileManager.getChatInviteLink(this.chatId,!0).then((t=>{e(),A.title.textContent=t}))}}],titleLangKey:"RevokeLink",descriptionLangKey:"RevokeAlert"}).show()}),{listenerSetter:this.listenerSetter}),v.content.append(A.container,_);const F=new E.Z({caption:!0,noDelimiter:!0}),D=document.createElement("div");D.classList.add("input-wrapper");const R="t.me/",B=()=>{const e=n.radioField.checked&&j!==R||N.isValidToChange()&&N.input.classList.contains("valid");G.classList.toggle("is-visible",e);const{error:t}=N,i="USERNAME_PURCHASE_AVAILABLE"===(null==t?void 0:t.type);O(i?N.getValue():void 0)},N=new g.l({label:"SetUrlPlaceholder",name:"group-public-link",plainText:!0,listenerSetter:this.listenerSetter,availableText:"Link.Available",invalidText:"Link.Invalid",takenText:"Link.Taken",onChange:B,peerId:this.chatId.toPeerId(!0),head:R},this.managers),{setUsername:O,element:U}=(0,M.J)();F.caption.append(U,(0,b.ag)(e?"Channel.UsernameAboutChannel":"Channel.UsernameAboutGroup"));const H=new I.Z({peerId:this.chatId.toPeerId(!0),peer:r,listenerSetter:this.listenerSetter,usernameInputField:N,middleware:this.middlewareHelper.get()}),z=document.createElement("div");z.append(F.container,H.container);const j=R+((0,P.Z)(r)||"");D.append(N.container),F.content.append(D);const G=(0,w.Z)({icon:"check",className:"is-visible"});this.content.append(G),(0,S.fc)(G,(()=>x(this,void 0,void 0,(function*(){const t=a.radioField.checked?N.getValue():"";if(!t){const t=yield this.managers.appChatsManager.getChat(this.chatId),i=(0,P.Z)(t);i&&(yield(0,k.Z)({descriptionLangKey:e?"ChannelVisibility.Confirm.MakePrivate.Channel":"ChannelVisibility.Confirm.MakePrivate.Group",descriptionLangArgs:[i],button:{langKey:"OK"}}))}(0,p.p)(G),this.managers.appChatsManager.migrateChat(this.chatId).then((e=>t?this.managers.appChatsManager.updateUsername(e,t):this.managers.appChatsManager.makeChannelPrivate(e))).then((()=>{this.close()}))}))),{listenerSetter:this.listenerSetter}),(j!==R||(0,Z.Z)(r).length?a:n).radioField.checked=!0,N.setOriginalValue(j,!0),this.scrollable.append(t.container,v.container,z);{const t=new E.Z({name:"SavingContentTitle",caption:e?"RestrictSavingContentInfoChannel":"RestrictSavingContentInfoGroup"}),i=new L.Z({text:"RestrictSavingContent",withRipple:!0});this.listenerSetter.add(i.input)("change",(()=>{const e=i.toggleDisability(!0);this.managers.appChatsManager.toggleNoForwards(this.chatId,i.checked).then((()=>{e()}))}));const s=()=>{i.setValueSilently(!!r.pFlags.noforwards)};((e,t="basic")=>{d[t].push(e)})(s),s(),t.content.append(i.label),this.scrollable.append(t.container)}}))}}var _=i(4668),F=i(5565),D=i(8936),R=i(5005),B=i(8479),N=i(7120),O=i(2946),U=i(2995),H=i(6848),z=i(3061),j=i(7362),G=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class V extends v.h{init(){return G(this,void 0,void 0,(function*(){let e;this.container.classList.add("edit-peer-container","user-permissions-container"),this.setTitle("UserRestrictions");const t=yield this.managers.appChatsManager.isChannel(this.chatId);{const t=new E.Z({name:"UserRestrictionsCanDo"}),i=document.createElement("div");i.classList.add("chatlist-container"),t.content.insertBefore(i,t.title);const s=R.default.createChatList({new:!0});i.append(s);const{dom:n}=R.default.addDialogNew({peerId:this.userId.toPeerId(!1),container:s,rippleEnabled:!0,avatarSize:"abitbigger"});n.lastMessageSpan.append((0,z.Z)(yield this.managers.appUsersManager.getUser(this.userId)));const a=new $({chatId:this.chatId,listenerSetter:this.listenerSetter,appendTo:t.content,participant:"channelParticipantBanned"===this.participant._?this.participant:void 0},this.managers);e=()=>{const e=a.takeOut();"channelParticipantBanned"===this.participant._&&(0,H.Z)(this.participant.banned_rights.pFlags,e.pFlags)||this.managers.appChatsManager.editBanned(this.chatId,this.participant,e)},this.eventListener.addEventListener("destroy",e,{once:!0}),this.scrollable.append(t.container)}{const i=new E.Z({});if("channelParticipantBanned"===this.participant._){const t=(0,c.Z)("btn-primary btn-transparent danger",{icon:"delete",text:"GroupPermission.Delete"});(0,S.fc)(t,(()=>{const i=(0,C.Z)([t],!0);this.managers.appChatsManager.clearChannelParticipantBannedRights(this.chatId,this.participant).then((()=>{this.eventListener.removeEventListener("destroy",e),this.close()}),(()=>{i()}))}),{listenerSetter:this.listenerSetter}),i.content.append(t)}const s=(0,c.Z)("btn-primary btn-transparent danger",{icon:"deleteuser",text:"UserRestrictionsBlock"});(0,S.fc)(s,(()=>G(this,void 0,void 0,(function*(){const i=(0,C.Z)([s],!0);try{const e=this.userId.toPeerId();yield(0,k.Z)({peerId:this.chatId.toPeerId(!0),descriptionLangKey:"Permissions.RemoveFromGroup",descriptionLangArgs:[yield(0,j.Z)({peerId:e})],titleLangKey:"ChannelBlockUser",button:{langKey:"Remove",isDanger:!0}}),t?yield this.managers.appChatsManager.kickFromChannel(this.chatId,this.participant):yield this.managers.appChatsManager.kickFromChat(this.chatId,this.participant)}catch(e){return void i()}this.eventListener.removeEventListener("destroy",e),this.close()}))),{listenerSetter:this.listenerSetter}),i.content.append(s),this.scrollable.append(i.container)}}))}}var K=i(8610),W=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class $ extends K.Z{constructor(e,t){super({listenerSetter:e.listenerSetter,fields:[],asRestrictions:!0}),this.options=e,this.managers=t,this.construct()}construct(){return W(this,void 0,void 0,(function*(){const e=this.options,t=this.chat=yield this.managers.appChatsManager.getChat(e.chatId),i=this.defaultBannedRights=t.default_banned_rights,s=this.rights=e.participant?function(e,t){if(e.default_banned_rights){t=(0,B.Z)(t);const i=e.default_banned_rights.pFlags;for(const e in i)t.pFlags[e]=i[e]}return t}(t,e.participant.banned_rights):i,n=[{flags:["send_photos"],text:"UserRestrictionsSendPhotos",exceptionText:"UserRestrictionsNoSendPhotos"},{flags:["send_videos"],text:"UserRestrictionsSendVideos",exceptionText:"UserRestrictionsNoSendVideos"},{flags:["send_stickers","send_gifs"],text:"UserRestrictionsSendStickers",exceptionText:"UserRestrictionsNoSendStickers"},{flags:["send_audios"],text:"UserRestrictionsSendMusic",exceptionText:"UserRestrictionsNoSendMusic"},{flags:["send_docs"],text:"UserRestrictionsSendFiles",exceptionText:"UserRestrictionsNoSendDocs"},{flags:["send_voices"],text:"UserRestrictionsSendVoices",exceptionText:"UserRestrictionsNoSendVoice"},{flags:["send_roundvideos"],text:"UserRestrictionsSendRound",exceptionText:"UserRestrictionsNoSendRound"},{flags:["embed_links"],text:"UserRestrictionsEmbedLinks",exceptionText:"UserRestrictionsNoEmbedLinks"},{flags:["send_polls"],text:"UserRestrictionsSendPolls",exceptionText:"UserRestrictionsNoSendPolls"}],a=n,o=[{flags:["send_plain"],text:"UserRestrictionsSend",exceptionText:"UserRestrictionsNoSend"},{flags:["send_media"],text:"UserRestrictionsSendMedia",exceptionText:"UserRestrictionsNoSendMedia",nested:n},{flags:["invite_users"],text:"UserRestrictionsInviteUsers",exceptionText:"UserRestrictionsNoInviteUsers"},{flags:["pin_messages"],text:"UserRestrictionsPinMessages",exceptionText:"UserRestrictionsNoPinMessages"},{flags:["change_info"],text:"UserRestrictionsChangeInfo",exceptionText:"UserRestrictionsNoChangeInfo"}],r={};o.push(...n),o.forEach((e=>{const i=e.flags[0];r[i]=e,e.checked=(0,N.Z)(t,i,s)})),n.forEach((e=>e.nestedTo=r.send_media)),r.send_media.toggleWith={unchecked:a,checked:a},r.embed_links.toggleWith={checked:[r.send_plain]},r.send_plain.toggleWith={unchecked:[r.embed_links]},this.fields=o;for(const s of this.fields){if((this.options.participant&&i.pFlags[s.flags[0]]||(0,Z.Z)(t)[0]&&(s.flags.includes("pin_messages")||s.flags.includes("change_info")))&&(s.restrictionText=this.restrictionText),s.nestedTo)continue;const{nodes:n}=this.createField(s);e.appendTo.append(...n)}}))}takeOut(){const e={_:"chatBannedRights",until_date:2147483647,pFlags:{}},t=new Set(["send_media"]);for(const i of this.fields)!i.checkboxField.checked&&i.flags.forEach((i=>{t.has(i)||(e.pFlags[i]=!0)}));return e}}class q extends v.h{init(){return W(this,void 0,void 0,(function*(){let e;this.container.classList.add("edit-peer-container","group-permissions-container"),this.setTitle("ChannelPermissions");{const t=new E.Z({name:"ChannelPermissionsHeader"});e=new $({chatId:this.chatId,listenerSetter:this.listenerSetter,appendTo:t.content},this.managers),this.eventListener.addEventListener("destroy",(()=>{this.managers.appChatsManager.editChatDefaultBannedRights(this.chatId,e.takeOut())}),{once:!0}),this.scrollable.append(t.container)}{const t=new E.Z({name:"PrivacyExceptions"}),i=new l.ZP({titleLangKey:"ChannelAddException",subtitleLangKey:"Loading",icon:"adduser",clickable:()=>{T.Z.createPopup(U.Z,{peerTypes:["channelParticipants"],onSelect:e=>{setTimeout((()=>{n(e)}),0)},placeholder:"ExceptionModal.Search.Placeholder",peerId:-this.chatId})},listenerSetter:this.listenerSetter}),n=e=>W(this,void 0,void 0,(function*(){let t;try{t=yield this.managers.appProfileManager.getParticipant(this.chatId,e)}catch(e){return void(0,m.Am)("User is no longer participant")}const i=this.slider.createTab(V);i.participant=t,i.chatId=this.chatId,i.userId=e,i.open()}));t.content.append(i.container);const a=t.generateContentElement();a.classList.add("chatlist-container");const o=R.default.createChatList({new:!0});a.append(o),(0,S.fc)(o,(e=>{const t=(0,_.Z)(e.target,R.DIALOG_LIST_ELEMENT_TAG);if(!t)return;const i=t.dataset.peerId.toPeerId();n(i)}),{listenerSetter:this.listenerSetter});const r=(t,i)=>W(this,void 0,void 0,(function*(){const s=i.banned_rights,n=(yield this.managers.appChatsManager.getChat(this.chatId)).default_banned_rights,a=[];e.fields.forEach((e=>{const t=e.flags[0];s.pFlags[t]&&!n.pFlags[t]&&a.push(e.exceptionText)}));const o=t.lastMessageSpan;a.length&&o.replaceChildren(...(0,b.v_)(a.map((e=>(0,b.ag)(e))),!1)),o.classList.toggle("hide",!a.length)})),d=(e,t)=>{const{dom:i}=R.default.addDialogNew({peerId:(0,O.Z)(e.peer),container:o,rippleEnabled:!0,avatarSize:"abitbigger",append:t});i.listEl.dialogDom=i,r(i,e)};this.listenerSetter.add(s.Z)("chat_participant",(e=>{var t,i,s;const n="channelParticipantBanned"===(null===(t=e.new_participant)||void 0===t?void 0:t._)&&!e.new_participant.banned_rights.pFlags.view_messages,a=o.querySelector(`[data-peer-id="${e.user_id}"]`);n?(a?r(a.dialogDom,e.new_participant):d(e.new_participant,!1),"channelParticipantBanned"!==(null===(i=e.prev_participant)||void 0===i?void 0:i._)&&++u):(null==a||a.remove(),"channelParticipantBanned"===(null===(s=e.prev_participant)||void 0===s?void 0:s._)&&--u),c()}));const c=()=>{(0,F.Z)(i.subtitle,(0,b.ag)(u?"Permissions.ExceptionsCount":"Permissions.NoExceptions",[u]))};let h,u=0;const p=()=>(h=new D.Z({scrollable:this.scrollable,getPromise:()=>this.managers.appProfileManager.getChannelParticipants(this.chatId,{_:"channelParticipantsBanned",q:""},50,o.childElementCount).then((e=>{for(const t of e.participants)d(t,!0);return u=e.count,c(),e.participants.length<50||e.count===o.childElementCount}))}),h.load());this.scrollable.append(t.container),(yield this.managers.appChatsManager.isChannel(this.chatId))?yield p():(c(),this.listenerSetter.add(s.Z)("dialog_migrate",(({migrateFrom:e,migrateTo:t})=>{this.chatId===e&&(this.chatId=t,p())})))}}))}onOpenAfterTimeout(){this.scrollable.onScroll()}}var Y=i(6194),Q=i(5701),X=i(62),J=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class ee extends v.h{init(){var e;return J(this,void 0,void 0,(function*(){this.setTitle("Reactions");const t=yield this.managers.appReactionsManager.getActiveAvailableReactions(),i=yield this.managers.appProfileManager.getChatFull(this.chatId),s=yield this.managers.appChatsManager.isBroadcast(this.chatId);let n=null!==(e=i.available_reactions)&&void 0!==e?e:{_:"chatReactionsNone"},a=n,o=new Set("chatReactionsSome"===n._?n.reactions.map((e=>e.emoticon)):[]);const r=e=>e.map((e=>({_:"reactionEmoji",emoticon:e}))),d=()=>s?"EnableReactionsChannelInfo":"chatReactionsAll"===a._?"EnableAllReactionsInfo":"chatReactionsNone"===a._?"DisableReactionsInfo":"EnableSomeReactionsInfo",c=new E.Z({name:s?void 0:"AvailableReactions",caption:d()}),h=new E.Z({name:"OnlyAllowThisReactions"}),u=()=>{var e;const t=null!==(e=a.reactions)&&void 0!==e?e:[];o=new Set(t.map((({emoticon:e})=>e))),f.forEach(((e,t)=>{e.setValueSilently(o.has(t))}))};let p;if(s){p=new L.Z({toggle:!0,checked:"chatReactionsSome"===n._});const e=new l.ZP({checkboxField:p,titleLangKey:"EnableReactions",listenerSetter:this.listenerSetter});c.content.append(e.container),this.listenerSetter.add(p.input)("change",(()=>{let e=!0;p.checked?m.every((e=>!e.checked))?a={_:"chatReactionsSome",reactions:r(t.map((({reaction:e})=>e)))}:"chatReactionsSome"!==a._?a={_:"chatReactionsSome",reactions:r(Array.from(o))}:e=!1:a={_:"chatReactionsNone"},e&&(u(),v())}))}else{const e=[["chatReactionsAll","AllReactions"],["chatReactionsSome","SomeReactions"],["chatReactionsNone","NoReactions"]],t=()=>{h.container.classList.toggle("hide","chatReactionsSome"!==a._)};let i=n._;const s=(0,l.ZC)(e.map((([e,t])=>({langPackKey:t,value:e,checked:n._===e}))),(e=>{i=e,a="chatReactionsAll"===i?{_:i,pFlags:{allow_custom:!0}}:"chatReactionsNone"===i?{_:i}:{_:i,reactions:r(["👍","👎"])},(0,F.Z)(c.caption,(0,b.ag)(d())),u(),v(),t()}));c.content.append(s),t()}const f=new Map,m=t.map((e=>{const t=e.reaction,i=new L.Z({toggle:!0,checked:o.has(t)});f.set(t,i),this.listenerSetter.add(i.input)("change",(()=>{i.checked?(o.add(t),p&&!p.checked&&(p.checked=!0)):(o.delete(t),(null==p?void 0:p.checked)&&!o.size&&(p.checked=!1)),v()}));const s=new l.ZP({checkboxField:i,title:e.title,havePadding:!0,listenerSetter:this.listenerSetter});return(0,X.Z)({row:s,doc:e.static_icon,size:"small"}),h.content.append(s.container),i})),g=()=>J(this,void 0,void 0,(function*(){v.clearTimeout(),"chatReactionsSome"===a._&&(a.reactions=r(Array.from(o))),this.managers.appChatsManager.setChatAvailableReactions(this.chatId,a),n=a})),v=(0,Q.Z)(g,3e3,!1,!0);this.eventListener.addEventListener("destroy",(()=>{v.isDebounced()&&g()}),{once:!0}),this.scrollable.append(c.container,h.container)}))}}var te=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class ie extends a._{_init(){return te(this,void 0,void 0,(function*(){this.listenerSetter.removeAll(),this.scrollable.container.replaceChildren(),this.container.classList.add("edit-peer-container","edit-group-container"),this.setTitle("Edit");let[e,t,i,n,a,o,h,u]=yield Promise.all([this.managers.appProfileManager.getChatFull(this.chatId,!0),this.managers.appChatsManager.getChat(this.chatId),this.managers.appChatsManager.isBroadcast(this.chatId),this.managers.appChatsManager.isChannel(this.chatId),this.managers.appChatsManager.hasRights(this.chatId,"change_type"),this.managers.appChatsManager.hasRights(this.chatId,"change_permissions"),this.managers.appChatsManager.hasRights(this.chatId,"manage_topics"),this.managers.apiManager.getAppConfig()]);const p={full:[],basic:[]},f=(e,t="basic")=>{p[t].push(e)};this.listenerSetter.add(s.Z)("chat_update",(e=>te(this,void 0,void 0,(function*(){this.chatId===e&&(t=yield this.managers.appChatsManager.getChat(this.chatId),p.basic.forEach((e=>e())))})))),this.listenerSetter.add(s.Z)("chat_full_update",(t=>te(this,void 0,void 0,(function*(){this.chatId===t&&(e=(yield this.managers.appProfileManager.getCachedFullChat(t))||e,p.full.forEach((e=>e())))}))));const m=this.chatId.toPeerId(!0);{const s=new E.Z({noDelimiter:!0,caption:!0}),n=[],c=document.createElement("div");if(c.classList.add("input-wrapper"),this.chatNameInputField=new r.ZP({label:i?"EnterChannelName":"CreateGroup.NameHolder",name:"chat-name",maxLength:255,required:!0}),this.descriptionInputField=new r.ZP({label:"DescriptionPlaceholder",name:"chat-description",maxLength:255}),this.chatNameInputField.setOriginalValue(t.title),this.descriptionInputField.setOriginalValue(e.about),c.append(this.chatNameInputField.container,this.descriptionInputField.container),n.push(this.chatNameInputField,this.descriptionInputField),this.editPeer=new d.Z({peerId:m,inputFields:n,listenerSetter:this.listenerSetter,popupOptions:{isForum:t.pFlags.forum}}),this.content.append(this.editPeer.nextBtn),s.content.append(this.editPeer.avatarEdit.container,c),a){const n=new l.ZP({titleLangKey:i?"ChannelType":"GroupType",clickable:()=>{const t=this.slider.createTab(A);t.chatId=this.chatId,t.chatFull=e,t.open()},icon:"lock",listenerSetter:this.listenerSetter}),a=()=>{let e;const s=(0,Z.Z)(t)[0];e=i?s?"TypePublic":"TypePrivate":s?"TypePublicGroup":"TypePrivateGroup",n.subtitle.replaceChildren((0,b.ag)(e))};a(),f(a),s.content.append(n.container)}if(a||o){const t=new l.ZP({titleLangKey:"Reactions",icon:"reactions",clickable:()=>{const e=this.slider.createTab(ee);e.chatId=this.chatId,e.open()},listenerSetter:this.listenerSetter}),i=(yield this.managers.appReactionsManager.getAvailableReactions()).filter((e=>!e.pFlags.inactive)).length,n=()=>{var s;const n=null!==(s=e.available_reactions)&&void 0!==s?s:{_:"chatReactionsNone"};if("chatReactionsSome"===n._){const e=n.reactions.length;e===i?(0,F.Z)(t.subtitle,(0,b.ag)("ReactionsAll")):t.subtitle.textContent=e+"/"+i}else(0,F.Z)(t.subtitle,(0,b.ag)("chatReactionsAll"===n._?"ReactionsAll":"Checkbox.Disabled"))};n(),f(n,"full"),s.content.append(t.container)}if(o&&!i){const e=["send_stickers","send_polls","send_photos","send_videos","send_roundvideos","send_audios","send_voices","send_docs","send_plain","embed_links","invite_users","pin_messages","change_info"],i=new l.ZP({titleLangKey:"ChannelPermissions",clickable:()=>{const e=this.slider.createTab(q);e.chatId=this.chatId,e.open()},icon:"permissions",listenerSetter:this.listenerSetter}),n=()=>{i.subtitle.textContent=e.reduce(((e,i)=>e+ +(0,N.Z)(t,i,t.default_banned_rights)),0)+"/"+e.length};n(),f(n),s.content.append(i.container)}if(h&&(t.participants_count>=u.forum_upgrade_participants_min||t.pFlags.forum)&&!i){const e=new l.ZP({checkboxField:new L.Z({toggle:!0}),titleLangKey:"Topics",clickable:()=>{},icon:"topics",listenerSetter:this.listenerSetter}),i=()=>{const i=!!t.pFlags.forum;this.editPeer.avatarElem.parentElement.classList.toggle("is-forum",i),e.checkboxField.setValueSilently(i)};this.listenerSetter.add(e.checkboxField.input)("change",(t=>{if(!t.isTrusted)return;const i=this.managers.appChatsManager.toggleForum(this.chatId,e.checkboxField.checked);e.disableWithPromise(i)})),i(),f(i),s.caption.replaceChildren((0,b.ag)("ForumToggleDescription")),s.content.append(e.container)}if(s.caption.classList.toggle("hide",!s.caption.childElementCount),this.scrollable.append(s.container),(0,S.fc)(this.editPeer.nextBtn,(()=>{this.editPeer.nextBtn.disabled=!0;const e=[],t=this.chatId;this.chatNameInputField.isValidToChange()&&e.push(this.managers.appChatsManager.editTitle(t,this.chatNameInputField.value)),this.descriptionInputField.isValidToChange()&&e.push(this.managers.appChatsManager.editAbout(t,this.descriptionInputField.value)),this.editPeer.uploadAvatar&&e.push(this.editPeer.uploadAvatar().then((e=>this.managers.appChatsManager.editPhoto(t,e)))),Promise.race(e).finally((()=>{this.editPeer.nextBtn.removeAttribute("disabled"),this.close()}))}),{listenerSetter:this.listenerSetter}),i&&(yield this.managers.appChatsManager.hasRights(this.chatId,"change_info"))){const e=new L.Z({text:"ChannelSignMessages",checked:!!t.pFlags.signatures});this.listenerSetter.add(e.input)("change",(()=>{const t=e.toggleDisability(!0);this.managers.appChatsManager.toggleSignatures(this.chatId,e.checked).then((()=>{t()}))})),f((()=>{e.setValueSilently(!!t.pFlags.signatures)})),s.content.append((0,l.tG)(e).container)}}if(!i){const t=new E.Z({});if(!i&&a){const i=new L.Z({text:"ChatHistory"});this.listenerSetter.add(i.input)("change",(()=>{const e=i.toggleDisability(!0);this.managers.appChatsManager.togglePreHistoryHidden(this.chatId,!i.checked).then((()=>{e()}))}));const s=()=>{i.setValueSilently(n&&!e.pFlags.hidden_prehistory)};s(),f(s),t.content.append((0,l.tG)(i).container)}t.content.childElementCount&&this.scrollable.append(t.container)}if(yield this.managers.appChatsManager.hasRights(this.chatId,"delete_chat")){const e=new E.Z({}),t=(0,c.Z)("btn-primary btn-transparent danger",{icon:"delete",text:i?"PeerInfo.DeleteChannel":"DeleteAndExitButton"});(0,S.fc)(t,(()=>{T.Z.createPopup(Y.Z,m,void 0,(e=>{const i=(0,C.Z)([t],!0);e.then((()=>{this.close()}),(()=>{i()}))}))}),{listenerSetter:this.listenerSetter}),e.content.append(t),this.scrollable.append(e.container)}n||this.listenerSetter.add(s.Z)("dialog_migrate",(({migrateFrom:e,migrateTo:t})=>{m===e&&(this.chatId=t.toChatId(),this._init())}))}))}init(){return this._init()}}var se=i(8842),ne=i(4240),ae=i(2230),oe=i(5670),re=i(8261),de=i(4993),le=i(730),ce=i(5994),he=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};const ue={};class pe extends a._{init(){this.container.classList.add("shared-media-container","profile-container");const e=(0,c.Z)("btn-icon sidebar-close-button",{noRipple:!0});this.closeBtn.replaceWith(e),this.closeBtn=e;const t=document.createElement("div");t.classList.add("animated-close-icon"),e.append(t),this.isFirst&&t.classList.add("state-back");const i=document.createElement("div");i.className="transition slide-fade";const a=document.createElement("div");a.classList.add("transition-item"),this.titleI18n=new b.ZP.IntlElement,this.title.append(this.titleI18n.element),this.editBtn=(0,ae.Z)("edit"),a.append(this.title,this.editBtn);const r=document.createElement("div");r.classList.add("transition-item");const d=this.title.cloneNode();d.append((0,b.ag)("PeerInfo.SharedMedia")),r.append(d),i.append(a,r),this.header.append(i),this.profile=new re.Z(this.managers,this.scrollable,this.listenerSetter),this.profile.init(),this.scrollable.append(this.profile.element),this.scrollable.onAdditionalScroll=()=>{const e=this.searchSuper.nav.getBoundingClientRect();if(!e.width)return;const t=e.top-1;l(t<=56)};const l=e=>{t.classList.toggle("state-back",this.isFirst||e),this.searchSuper.container.classList.toggle("is-full-viewport",e),h(+e),e||this.searchSuper.cleanScrollPositions()},h=(0,o.Z)({content:i,type:"slide-fade",transitionTime:400,isHeavy:!1});h(0),(0,S.fc)(this.closeBtn,(e=>{h.prevId()?(this.scrollable.scrollIntoViewNew({element:this.scrollable.container.firstElementChild,position:"start"}),h(0),this.isFirst||t.classList.remove("state-back")):this.scrollable.isHeavyAnimationInProgress||this.slider.onCloseBtnClick()}),{listenerSetter:this.listenerSetter}),(0,S.fc)(this.editBtn,(()=>he(this,void 0,void 0,(function*(){let e;const{peerId:t,threadId:i}=this;e=i&&(yield this.managers.appPeersManager.isForum(t))?this.slider.createTab(le.Z):t.isAnyChat()?this.slider.createTab(ie):this.slider.createTab(ne.Z),e&&(e instanceof le.Z?e.open(t,this.threadId):(e instanceof ie?e.chatId=t.toChatId():e.peerId=t,e.open()))}))),{listenerSetter:this.listenerSetter}),this.listenerSetter.add(s.Z)("contacts_update",(e=>{this.peerId===e&&this.toggleEditBtn()})),this.listenerSetter.add(s.Z)("chat_update",(e=>{this.peerId===e.toPeerId(!0)&&this.toggleEditBtn()})),this.listenerSetter.add(s.Z)("history_multiappend",(e=>{this.renderNewMessage(e)})),this.listenerSetter.add(s.Z)("history_delete",(({peerId:e,msgs:t})=>{this.deleteDeletedMessages(e,Array.from(t))})),this.listenerSetter.add(s.Z)("message_sent",(({message:e})=>{this.renderNewMessage(e)})),this.searchSuper=new n.Z({mediaTabs:[{inputFilter:"inputMessagesFilterEmpty",name:"PeerMedia.Members",type:"members"},{inputFilter:"inputMessagesFilterPhotoVideo",name:"SharedMediaTab2",type:"media"},{inputFilter:"inputMessagesFilterDocument",name:"SharedFilesTab2",type:"files"},{inputFilter:"inputMessagesFilterUrl",name:"SharedLinksTab2",type:"links"},{inputFilter:"inputMessagesFilterMusic",name:"SharedMusicTab2",type:"music"},{inputFilter:"inputMessagesFilterRoundVoice",name:"SharedVoiceTab2",type:"voice"},{inputFilter:"inputMessagesFilterEmpty",name:"ChatList.Filter.Groups",type:"groups"}],scrollable:this.scrollable,onChangeTab:e=>{const t="members"===e.type&&ce.Z.isAvailable("animations")?250:0;setTimeout((()=>{u.classList.toggle("is-hidden","members"!==e.type)}),t)},managers:this.managers}),this.searchSuper.scrollStartCallback=()=>{l(!0)},this.profile.element.append(this.searchSuper.container);const u=(0,w.Z)({icon:"addmember_filled"});this.content.append(u),(0,S.fc)(u,(()=>he(this,void 0,void 0,(function*(){const e=this.peerId,t=this.peerId.toChatId(),i=yield this.managers.appChatsManager.isChannel(t),s=(t,s)=>{let n,a,o,r,d;if(t.length>1)n="AddMembersAlertTitle",a=[(0,b.ag)("Members",[t.length])],o="AddMembersAlertCountText",r=t.map((e=>{const t=document.createElement("b");return t.append(new se.Z({peerId:e}).element),t})),i||(d=[{text:"AddMembersForwardMessages",checked:!0}]);else{n="AddOneMemberAlertTitle",o="AddMembersAlertNamesText";const e=document.createElement("b");e.append(new se.Z({peerId:t[0]}).element),r=[e],i||(d=[{text:"AddOneMemberForwardMessages",textArgs:[new se.Z({peerId:t[0]}).element],checked:!0}])}r.push(new se.Z({peerId:e}).element),T.Z.createPopup(y.Z,"popup-add-members",{peerId:e,titleLangKey:n,descriptionLangKey:o,descriptionLangArgs:r,buttons:[{langKey:"Add",callback:s}],checkboxes:d}).show()},n=e=>{"USER_PRIVACY_RESTRICTED"===e.type&&(0,m.bC)({langPackKey:"InviteToGroupError"})};if(i){const e=this.slider.createTab(oe.Z);e.open({type:"channel",skippable:!1,takeOut:i=>(s(i,(()=>{const s=this.managers.appChatsManager.inviteToChannel(t,i);s.catch(n),e.attachToPromise(s)})),!1),title:"GroupAddMembers",placeholder:"SendMessageTo"})}else T.Z.createPopup(U.Z,{peerTypes:["contacts"],placeholder:"Search",onSelect:e=>{setTimeout((()=>{s([e],(i=>{this.managers.appChatsManager.addChatUser(t,e,i.size?void 0:0).catch(n)}))}),0)}})}))),{listenerSetter:this.listenerSetter})}_renderNewMessage(e,t){var i;const s=null===(i=ue[e.peerId])||void 0===i?void 0:i[t];if(s)for(const t of this.searchSuper.mediaTabs){const i=t.inputFilter,n=s[i];if(!n)continue;const a=this.searchSuper.filterMessagesByType([e],i).filter((e=>!n.find((t=>t.mid===e.mid&&t.peerId===e.peerId))));a.length&&(n.unshift(...a.map((e=>({mid:e.mid,peerId:e.peerId})))),this.peerId===e.peerId&&-1!==this.searchSuper.usedFromHistory[i]&&(this.searchSuper.usedFromHistory[i]+=a.length,this.searchSuper.performSearchResult(a,t,!1)))}}renderNewMessage(e){return he(this,void 0,void 0,(function*(){if(this.init)return;const{peerId:t}=e,i=yield this.managers.appPeersManager.isForum(t),s=(0,de.Z)(e,i);this._renderNewMessage(e),s&&this._renderNewMessage(e,s)}))}_deleteDeletedMessages(e,t,i){for(const s of i)for(const i of this.searchSuper.mediaTabs){const n=i.inputFilter,a=e[n];if(!a)continue;const o=a.findIndex((e=>e.mid===s));if(-1!==o&&(a.splice(o,1),this.peerId===t)){const e=this.searchSuper.tabs[n].querySelector(`[data-mid="${s}"][data-peer-id="${t}"]`);e&&(this.searchSuper.selection.isSelecting&&this.searchSuper.selection.toggleByElement(e),e.remove()),this.searchSuper.usedFromHistory[n]>=o+1&&--this.searchSuper.usedFromHistory[n]}}}deleteDeletedMessages(e,t){if(this.init)return;const i=ue[e];if(i){for(const s in i)this._deleteDeletedMessages(i[s],e,t);this.scrollable.onScroll()}}cleanupHTML(){return he(this,void 0,void 0,(function*(){const e=this.peerId.isAnyChat(),[t,i]=yield Promise.all([!!e&&this.searchSuper.canViewMembers(),!!e&&this.managers.appChatsManager.hasRights(this.peerId.toChatId(),"invite_users")]);return()=>{this.profile.cleanupHTML(),this.editBtn.classList.add("hide"),this.searchSuper.cleanupHTML(!0),this.container.classList.toggle("can-add-members",t&&i)}}))}setLoadMutex(e){this.searchSuper.loadMutex=e}setPeer(e,t){var i,s,n;return(this.peerId!==e||this.threadId!==t)&&(this.peerId=e,this.threadId=t,this.peerChanged=!0,this.init&&(this.init(),this.init=null),this.searchSuper.setQuery({peerId:e,threadId:t,historyStorage:null!==(s=(n=null!==(i=ue[e])&&void 0!==i?i:ue[e]={})[t])&&void 0!==s?s:n[t]={}}),this.profile.setPeer(e,t),!0)}changeTitleKey(){return he(this,void 0,void 0,(function*(){const e=this.managers.appPeersManager.isForum(this.peerId);return()=>{this.titleI18n.compareAndUpdate({key:this.threadId&&e?"AccDescrTopic":"Profile"})}}))}fillProfileElements(){return he(this,void 0,void 0,(function*(){if(!this.peerChanged)return;this.peerChanged=!1;const e=yield Promise.all([this.cleanupHTML(),this.toggleEditBtn(!0),this.profile.fillProfileElements(),this.changeTitleKey()]);return()=>{e.forEach((e=>{null==e||e()}))}}))}toggleEditBtn(e){return he(this,void 0,void 0,(function*(){let t;if(this.peerId.isUser())t=this.peerId!==s.Z.myId&&(yield this.managers.appUsersManager.isContact(this.peerId.toUserId()));else{const e=this.peerId.toChatId(),i=this.threadId&&(yield this.managers.appChatsManager.isForum(e));t=yield this.managers.appChatsManager.hasRights(e,i?"manage_topics":"change_info")}const i=()=>{this.editBtn.classList.toggle("hide",!t)};return e?i:i()}))}loadSidebarMedia(e,t){this.searchSuper.load(e,t)}onOpenAfterTimeout(){super.onOpenAfterTimeout(),this.scrollable.onScroll()}onCloseAfterTimeout(){super.onCloseAfterTimeout(),this.destroyable&&(this.profile.destroy(),this.searchSuper.destroy())}destroy(){this.destroyable=!0,this.onCloseAfterTimeout()}}},9099:(e,t,i)=>{"use strict";i.d(t,{Z:()=>a});var s=i(5994);const n=e=>{const{element:t,className:i,forwards:a,duration:o,onTransitionEnd:r,onTransitionStart:d,useRafs:l}=e,{timeout:c,raf:h}=t.dataset;if(void 0!==c&&clearTimeout(+c),void 0!==h&&(window.cancelAnimationFrame(+h),l||delete t.dataset.raf),l&&s.Z.isAvailable("animations")&&o)return void(t.dataset.raf=""+window.requestAnimationFrame((()=>{delete t.dataset.raf,n(Object.assign(Object.assign({},e),{useRafs:l-1}))})));a&&i&&t.classList.add(i);const u=()=>{delete t.dataset.timeout,!a&&i&&t.classList.remove("backwards",i),t.classList.remove("animating"),null==r||r()};if(null==d||d(),!s.Z.isAvailable("animations")||!o)return t.classList.remove("animating","backwards"),void u();t.classList.add("animating"),t.classList.toggle("backwards",!a),t.dataset.timeout=""+setTimeout(u,o)},a=n},3552:(e,t,i)=>{"use strict";i.d(t,{Z:()=>l,_:()=>a.Z});var s=i(426),n=i(5824),a=i(6024),o=i(1655),r=i(5953),d=i(3624);class l{constructor(e){var t;this.historyTabIds=[],this.canHideFirst=!1,this.onCloseBtnClick=()=>{n.Z.findItemByType(this.navigationType)?n.Z.back(this.navigationType):this.historyTabIds.length&&this.closeTab(this.historyTabIds[this.historyTabIds.length-1])},this.closeTab=(e,t,i)=>{if(void 0!==e&&this.historyTabIds[this.historyTabIds.length-1]!==e)return this.removeTabFromHistory(e),!1;const s=this.historyTabIds.pop();this.onCloseTab(s,t,i);const n=this.historyTabIds[this.historyTabIds.length-1];return this._selectTab(void 0!==n?n instanceof a.Z?n.container:n:this.canHideFirst?-1:0,t),!0},(0,r.Z)(this,e),null!==(t=this.tabs)&&void 0!==t||(this.tabs=new Map),this.tabsContainer=this.sidebarEl.querySelector(".sidebar-slider"),this._selectTab=(0,s.Z)({content:this.tabsContainer,type:"navigation",transitionTime:250}),this.canHideFirst||this._selectTab(0),this.middlewareHelper=(0,d.k)()}getMiddleware(){return this.middlewareHelper.get()}selectTab(e){var t,i,s,o,r;return i=this,s=void 0,r=function*(){if(this.historyTabIds[this.historyTabIds.length-1]===e)return!1;const i=e instanceof a.Z?e:this.tabs.get(e);return this.onOpenTab&&(yield this.onOpenTab()),i&&(null===(t=i.onOpen)||void 0===t||t.call(i),i.onOpenAfterTimeout&&setTimeout((()=>{i.onOpenAfterTimeout()}),250)),n.Z.pushItem({type:this.navigationType,onPop:e=>(this.closeTab(void 0,e,!0),!0)}),this.historyTabIds.push(e),this._selectTab(e instanceof a.Z?e.container:e),!0},new((o=void 0)||(o=Promise))((function(e,t){function n(e){try{d(r.next(e))}catch(e){t(e)}}function a(e){try{d(r.throw(e))}catch(e){t(e)}}function d(t){var i;t.done?e(t.value):(i=t.value,i instanceof o?i:new o((function(e){e(i)}))).then(n,a)}d((r=r.apply(i,s||[])).next())}))}removeTabFromHistory(e){(0,o.Z)(this.historyTabIds,e),this.onCloseTab(e,void 0)}sliceTabsUntilTab(e,t){for(let i=this.historyTabIds.length-1;i>=0;--i){const s=this.historyTabIds[i];if(s!==t){if(s instanceof e)break;this.removeTabFromHistory(s)}}}getTab(e){return this.historyTabIds.find((t=>t instanceof e))}getHistory(){return this.historyTabIds}isTabExists(e){return!!this.getTab(e)}onCloseTab(e,t,i){var s;i||n.Z.removeByType(this.navigationType,!0);const o=e instanceof a.Z?e:this.tabs.get(e);if(o){try{null===(s=o.onClose)||void 0===s||s.call(o)}catch(e){console.error("tab onClose error",o)}o.onCloseAfterTimeout&&setTimeout((()=>{o.onCloseAfterTimeout()}),280)}}addTab(e){e.container.parentElement||(this.tabsContainer.append(e.container),e.closeBtn&&e.closeBtn.addEventListener("click",this.onCloseBtnClick))}deleteTab(e){this.tabs.delete(e)}createTab(e,t=!0,i){const s=new e(i?void 0:this,t);return s.managers=this.managers,s}}},6024:(e,t,i)=>{"use strict";i.d(t,{Z:()=>c,h:()=>h});var s=i(3241),n=i(3699),a=i(3624),o=i(319),r=i(2325),d=i(2230),l=i(8805);class c{constructor(e,t){this._constructor(e,t)}_constructor(e,t=!0){var i;this.slider=e,this.middlewareHelper=e?e.getMiddleware().create():(0,a.k)(),this.destroyable=t,this.container=document.createElement("div"),this.container.classList.add("tabs-tab","sidebar-slider-item"),this.header=document.createElement("div"),this.header.classList.add("sidebar-header"),this.closeBtn=(0,d.Z)("left sidebar-close-button",{noRipple:!0}),this.title=document.createElement("div"),this.title.classList.add("sidebar-header__title"),this.header.append(this.closeBtn,this.title),this.content=document.createElement("div"),this.content.classList.add("sidebar-content"),this.scrollable=new l.ZP(this.content,void 0,void 0,!0),this.scrollable.attachBorderListeners(this.container),this.container.append(this.header,this.content),null===(i=this.slider)||void 0===i||i.addTab(this),this.listenerSetter=new n.Z}close(){return this.slider.closeTab(this)}open(...e){return t=this,i=void 0,n=function*(){if(this.init)try{const t=this.init(...e);this.init=null,t instanceof Promise&&(yield t)}catch(e){console.error("open tab error",e)}this.slider.selectTab(this)},new((s=void 0)||(s=Promise))((function(e,a){function o(e){try{d(n.next(e))}catch(e){a(e)}}function r(e){try{d(n.throw(e))}catch(e){a(e)}}function d(t){var i;t.done?e(t.value):(i=t.value,i instanceof s?i:new s((function(e){e(i)}))).then(o,r)}d((n=n.apply(t,i||[])).next())}));var t,i,s,n}init(...e){}onOpen(){}onOpenAfterTimeout(){}onClose(){}onCloseAfterTimeout(){var e,t,i;this.destroyable&&(null===(e=this.slider)||void 0===e||e.deleteTab(this),this.container.remove(),this.scrollable.destroy(),null===(t=this.listenerSetter)||void 0===t||t.removeAll(),null===(i=this.middlewareHelper)||void 0===i||i.destroy())}setTitle(e){this.title.replaceChildren((0,r.ag)(e))}}class h extends c{constructor(e){super(e),this.eventListener=new s.Z}onClose(){this.eventListener.dispatchEvent("close")}onCloseAfterTimeout(){const e=this.eventListener.dispatchResultableEvent("destroy");return this.eventListener.dispatchEvent("destroyAfter",Promise.all(e).then(o.Z,o.Z)),this.eventListener.cleanup(),super.onCloseAfterTimeout()}}},2894:(e,t,i)=>{"use strict";i.d(t,{Z:()=>m});var s=i(5005),n=i(8594),a=i(8487),o=i(4484),r=i(5565),d=i(3035),l=i(5345),c=i(5953),h=i(3061),u=i(177),p=i(6853),f=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class m extends l.Z{constructor(e){let t;super({getIndex:e.getIndex||(e=>e.id.isAnyChat()?0:this.managers.appUsersManager.getUserStatusForSort(e.id)),onDelete:e=>{e.dom.listEl.remove(),this.onListLengthChange&&this.onListLengthChange()},onUpdate:e.onUpdate||(e=>f(this,void 0,void 0,(function*(){if(e.id.isAnyChat()){const t=yield(0,u.Z)(e.id.toChatId(),this.managers);(0,r.Z)(e.dom.lastMessageSpan,t)}else{const t=(0,h.Z)(yield this.managers.appUsersManager.getUser(e.id));(0,r.Z)(e.dom.lastMessageSpan,t)}}))),onSort:(e,t)=>{const i=e.dom.listEl.parentElement!==this.list;(0,o.Z)(e.dom.listEl,this.list,t),i&&this.onListLengthChange&&this.onListLengthChange()},onElementCreate:e=>{const t=s.default.addDialogNew({peerId:e.id,container:!1,avatarSize:this.avatarSize,autonomous:this.autonomous,meAsSaved:!1,rippleEnabled:this.rippleEnabled,wrapOptions:{lazyLoadQueue:this.lazyLoadQueue}}),i=this.ranks.get(e.id);return i&&t.titleRight.replaceChildren((0,p.Z)(i)),e.dom=t.dom,e},updateElementWith:d.T2,updateListWith:e=>f(this,void 0,void 0,(function*(){return Array.from(this.elements.values()).some((e=>e.id.isUser()))&&(0,a.Z)(this.list)?(yield(0,n.e9)(),(0,a.Z)(this.list)?void e(!0):e(!1)):e(!1)}))}),this.ranks=new Map,this.avatarSize="abitbigger",this.rippleEnabled=!0,this.autonomous=!0,(0,c.Z)(this,e),this.list=s.default.createChatList(this.createChatListOptions);const i=()=>{t=window.setTimeout((()=>{this.updateList((e=>{e&&i()}))}),m.SORT_INTERVAL)};i()}}m.SORT_INTERVAL=3e4},2149:(e,t,i)=>{"use strict";i.d(t,{Z:()=>r});var s=i(9331);const n="stacked-avatars",a=n+"-avatar",o=a+"-container";class r{constructor(e){this.lazyLoadQueue=e.lazyLoadQueue,this.avatarSize=e.avatarSize,this.container=document.createElement("div"),this.container.classList.add(n),this.container.style.setProperty("--avatar-size",e.avatarSize+"px")}render(e,t){const i=this.container.children;(e=e.slice().reverse()).length>3&&(e=e.slice(-3)),e.forEach(((e,n)=>{let r=i[n];r||(r=document.createElement("div"),r.classList.add(o));let d=r.firstElementChild;d||(d=new s.Z,d.classList.add("avatar-"+this.avatarSize,a),d.updateOptions({isDialog:!1,loadPromises:t})),d.updateWithOptions({lazyLoadQueue:this.lazyLoadQueue,peerId:e}),d.parentNode||r.append(d),r.parentNode||this.container.append(r)})),Array.from(i).slice(e.length).forEach((e=>e.remove()))}}},9259:(e,t,i)=>{"use strict";i.d(t,{Z:()=>I});var s=i(5432),n=i(3910),a=i(2738),o=i(5975),r=i(8497),d=i(8204),l=i(9405),c=i(3624),h=i(3035),u=i(5418),p=i(241),f=i(13),m=i(8115),g=i(5400),v=i(1447),b=i(3772),y=i(3512),w=i(5814),S=i(9099),C=i(3541),L=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};let E=!1;function I({listenTo:e,listenerSetter:t,selector:i,findTarget:I}){if(s.Z)return;const P=(t,s)=>{let n;if(I)n=I(t);else{const e=i||".media-sticker-wrapper";n=t.target.closest(e)}return!n||s&&!(0,o.Z)(n,e)?void 0:n},Z=y.Z.managers;t.add(e)("mousedown",(e=>{if(E||e.buttons>1||0!==e.button)return;let t=P(e);if(!t)return;const i=t.dataset.docId;if(!i)return;const s="sticker-viewer",y="STICKER-VIEWER",I=w.Z.getOnlyOnePlayableGroup(),M=(0,c.k)();let k,T;const x=({mediaContainer:e,doc:t,middleware:i,lockGroups:n,isSwitching:o})=>L(this,void 0,void 0,(function*(){const c=(0,f.Z)(t),S=e.getBoundingClientRect(),L=(0,l.C)(t.w,t.h),E=c?280:360,I=(0,l.C)(E,E),P=S.width===S.height?I:L.aspectFitted(I),M=(0,r.Z)(e,"bubble"),T=!M||M.classList.contains("is-out"),x=document.createElement("div");x.classList.add(s+"-transformer");const A=document.createElement("div");A.classList.add(s+"-sticker"),A.style.width=P.width+"px",A.style.height=P.height+"px";const _=document.createElement("div");if(_.classList.add(s+"-emoji"),_.append((0,m.Z)(t.stickerEmojiRaw)),c){const e=(E*C.Vp-E)/3*(T?1:-1);x.classList.add("has-effect"),x.style.setProperty("--translateX",`${e}px`),_.style.setProperty("--translateX",-e+"px")}const F=(0,r.Z)(e,"scrollable"),D=(0,d.Z)(e,F,!0,S);(D.overflow.vertical||D.overflow.horizontal)&&A.classList.add("is-overflow");const R=e.getBoundingClientRect(),B=R.width/P.width,N=R.height/P.height,O=R.left-(p.Z.width-R.width)/2,U=R.top-(p.Z.height-R.height)/2;x.style.transform=`translate(${O}px, ${U}px) scale(${B}, ${N})`,o&&x.classList.add("is-switching"),x.append(A,_),k.append(x);const H=yield(0,C.ZP)({doc:t,div:A,group:y,width:P.width,height:P.height,play:!1,loop:!0,middleware:i,managers:Z,needFadeIn:!1,isOut:T,withThumb:!1,relativeEffect:!0,loopEffect:!0}).then((({render:e})=>e));if(!i())return;k.parentElement||document.body.append(k);const z=Array.isArray(H)?H[0]:H,j=z instanceof b.Z?new Promise((e=>z.addEventListener("firstFrame",e,{once:!0}))):Promise.resolve();if(yield Promise.all([j,(0,h.d1)()]),yield(0,u.Z)(0),i()){if(n&&(w.Z.setOnlyOnePlayableGroup(y),w.Z.checkAnimations2(!0)),z instanceof b.Z){const t=e instanceof g.LD?e.player:v.Z.getAnimation(e);if(t){if(z.curFrame=t.curFrame,z.play(),yield new Promise((e=>{let t=0;const i=()=>{2==++t&&(e(),z.removeEventListener("enterFrame",i))};z.addEventListener("enterFrame",i)})),!i())return;z.pause()}}else if(z instanceof HTMLVideoElement){const t=e.querySelector("video");t&&(z.currentTime=t.currentTime)}return{ready:()=>{(z instanceof b.Z||z instanceof HTMLVideoElement)&&z.play(),c&&(0,a.tH)(A)},transformer:x}}})),A=window.setTimeout((()=>L(this,void 0,void 0,(function*(){document.removeEventListener("mousemove",F),k=document.createElement("div"),k.classList.add(s),E=!0;const e=M.get(),n=yield Z.appDocsManager.getDoc(i);if(!e())return;let a;try{if(a=yield x({doc:n,mediaContainer:t,middleware:e,lockGroups:!0}),!a)return}catch(e){return}const{ready:o,transformer:r}=a;T=r,(0,S.Z)({element:k,className:"is-visible",forwards:!0,duration:200,onTransitionEnd:()=>{e()&&o()}}),document.addEventListener("mousemove",_)}))),125),_=e=>L(this,void 0,void 0,(function*(){const i=P(e,!0);if(!i||t===i)return;const s=i.dataset.docId;if(!s)return;t=i,M.clean();const n=M.get(),a=yield Z.appDocsManager.getDoc(s);if(!n())return;let o;try{if(o=yield x({doc:a,mediaContainer:t,middleware:n,isSwitching:!0}),!o)return}catch(e){return void console.error("sticker viewer error",e)}const{ready:r,transformer:d}=o,l=T;(0,S.Z)({element:l,className:"is-switching",forwards:!0,duration:200,onTransitionEnd:()=>{l.remove()}}),T=d,(0,S.Z)({element:d,className:"is-switching",forwards:!1,duration:200,onTransitionEnd:()=>{n()&&r()}})})),F=e=>{(0,o.Z)(e.target,t)||D()},D=()=>{clearTimeout(A),M.clean(),k&&((0,S.Z)({element:k,className:"is-visible",forwards:!1,duration:200,onTransitionEnd:()=>{k.remove(),w.Z.setOnlyOnePlayableGroup(I),w.Z.checkAnimations2(!1),E=!1}}),(0,a.fc)(document.body,n.Z,{capture:!0,once:!0})),document.removeEventListener("mousemove",F),document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",D,{capture:!0})};document.addEventListener("mousemove",F),document.addEventListener("mouseup",D,{once:!0,capture:!0})}))}},5117:(e,t,i)=>{"use strict";i.d(t,{Z:()=>s});class s{constructor(e,t){this.container=e,this.handler=t,this.observeHeaders(),this.observeElements()}observeHeaders(){this.headersObserver=new IntersectionObserver((e=>{for(const t of e){const e=t.boundingClientRect,i=t.target.parentElement,s=t.rootBounds;e.bottom<s.top&&this.handler(!0,i),e.bottom>=s.top&&e.bottom<s.bottom&&this.handler(!1,i)}}),{threshold:0,root:this.container})}observeElements(){this.elementsObserver=new IntersectionObserver((e=>{const t=e.filter((e=>e.boundingClientRect.top<e.rootBounds.top)).sort(((e,t)=>e.boundingClientRect.top-t.boundingClientRect.top))[0];if(!t)return;const i=t.isIntersecting?t.target:t.target.nextElementSibling;this.handler(!0,i)}),{root:this.container})}addSentinel(e,t){const i=document.createElement("div");return i.classList.add("sticky_sentinel",t),e.appendChild(i)}observeStickyHeaderChanges(e){const t=this.addSentinel(e,"sticky_sentinel--top");this.headersObserver.observe(t),this.elementsObserver.observe(e)}disconnect(){this.headersObserver.disconnect(),this.elementsObserver.disconnect()}unobserve(e,t){this.elementsObserver.unobserve(e),this.headersObserver.unobserve(t)}}},3757:(e,t,i)=>{"use strict";i.d(t,{Z:()=>E});var s=i(3910),n=i(5432),a=i(5953),o=i(3416),r=i(3699),d=i(6976),l=i(5418),c=i(3725),h=i(3228),u=i(5701),p=i(5003),f=i(3444),m=i(241);const g=e=>"touches"in e?e.touches[0]:e;function v(e,t){return t?Math.hypot(t.pageX-e.pageX,t.pageY-e.pageY):0}function b(e,t){return{x:(e.pageX+t.pageX)/2,y:(e.pageY+t.pageY)/2}}const y=document;let w=!1;o.Z.addEventListener("toggle",(e=>{w=e}));const S={passive:!1},C=!1,L={capture:!0,passive:!1};class E{constructor(e){var t,i,o,d,m;this.reset=e=>{var t,i,s;this.log("reset"),n.Z?this.listenerSetter.removeManual(y,"touchmove",this.handleMove,S):(this.listenerSetter.removeManual(y,"mousemove",this.handleMove,C),this.setCursorTo.style.cursor=""),this.hadMove&&(null===(t=this.onReset)||void 0===t||t.call(this,e)),null===(i=this.releaseWheelDrag)||void 0===i||i.clearTimeout(),null===(s=this.releaseWheelZoom)||void 0===s||s.clearTimeout(),this.resetValues()},this.handleStart=e=>{return t=this,i=void 0,o=function*(){var t,i;if(this.log("start"),this.isMouseDown){const t=e.touches;return void(2===(null==t?void 0:t.length)&&(this.initialDistance=v(t[0],t[1]),this.initialTouchCenter=b(t[0],t[1])))}const a=g(e);if(![0,1].includes(Math.max(0,null!==(t=a.button)&&void 0!==t?t:0)))return;if(1===a.button&&(0,s.Z)(e),(0,f.Z)(e))return;const o=++this.tempId,r=null===(i=this.verifyTouchTarget)||void 0===i?void 0:i.call(this,e);if(void 0!==r){let e;if(r instanceof Promise){if(e=yield r,this.tempId!==o)return}else e=r;if(!e)return this.reset()}if(this.isMouseDown=!0,this.withDelay&&!n.Z){const e=Object.assign(Object.assign({},C),{once:!0}),t=(0,c.Z)(),i=()=>t.resolve(),s=this.listenerSetter.add(y)("mousemove",i,e);if(yield Promise.race([(0,l.Z)(300),t]),t.resolve(),this.listenerSetter.remove(s),this.tempId!==o)return}this.xDown=a.clientX,this.yDown=a.clientY,this.eventUp=a,n.Z?this.listenerSetter.add(y)("touchmove",this.handleMove,S):this.listenerSetter.add(y)("mousemove",this.handleMove,C),this.onStart&&(this.onStart(),this.hadMove=!0,this.handleMove(a))},new((a=void 0)||(a=Promise))((function(e,s){function n(e){try{d(o.next(e))}catch(e){s(e)}}function r(e){try{d(o.throw(e))}catch(e){s(e)}}function d(t){var i;t.done?e(t.value):(i=t.value,i instanceof a?i:new a((function(e){e(i)}))).then(n,r)}d((o=o.apply(t,i||[])).next())}));var t,i,a,o},this.handleMove=e=>{var t,i;if(void 0===this.xDown||void 0===this.yDown||w)return void this.reset();if(this.cancelEvent&&(0,s.Z)(e),(null===(t=this.releaseWheelDrag)||void 0===t?void 0:t.isDebounced())||(null===(i=this.releaseWheelZoom)||void 0===i?void 0:i.isDebounced()))return;this.log("move");const n=this.eventUp=g(e),a=n.clientX,o=n.clientY,r=a-this.xDown+this.xAdded,d=o-this.yDown+this.yAdded;if(!this.hadMove){if(!r&&!d)return;this.setHadMove(e)}const l=e.touches;if(this.onZoom&&this.initialDistance>0&&2===l.length){const e=v(l[0],l[1]),t=b(l[0],l[1]),i=t.x-this.initialTouchCenter.x,s=t.y-this.initialTouchCenter.y,n={zoomFactor:e/this.initialDistance,initialCenterX:this.initialTouchCenter.x,initialCenterY:this.initialTouchCenter.y,dragOffsetX:i,dragOffsetY:s,currentCenterX:t.x,currentCenterY:t.y};this.onZoom(n)}this.dispatchOnSwipe(r,d,e)},this.handleWheel=e=>{var t;if(!this.hadMove&&this.verifyTouchTarget){const t=this.verifyTouchTarget(e);if(void 0!==t&&!t)return void this.reset(e)}if((0,s.Z)(e),this.log("wheel"),this.onDoubleClick&&Object.is(e.deltaX,-0)&&Object.is(e.deltaY,-0)&&e.ctrlKey)return this.onWheelCapture(e),this.onDoubleClick({centerX:e.pageX,centerY:e.pageY}),void this.reset();e.metaKey||e.ctrlKey||e.shiftKey?((null===(t=this.releaseWheelDrag)||void 0===t?void 0:t.isDebounced())&&this.reset(),this.onWheelZoom(e)):this.handleWheelDrag(e)},this.handleWheelDrag=e=>{this.log("wheel drag"),this.onWheelCapture(e),this.isDragCanceled.x&&Math.sign(this.initialDragOffset.x)!==Math.sign(e.deltaX)||(this.initialDragOffset.x-=e.deltaX),this.isDragCanceled.y&&Math.sign(this.initialDragOffset.y)!==Math.sign(e.deltaY)||(this.initialDragOffset.y-=e.deltaY);const{x:t,y:i}=this.initialDragOffset;this.releaseWheelDrag(e),this.dispatchOnSwipe(t,i,e,((e,t)=>{this.isDragCanceled={x:e,y:t}}))},this.onWheelCapture=e=>{this.hadMove||(this.log("wheel capture"),this.handleStart(e),this.setHadMove(e),this.initialTouchCenter={x:e.x,y:e.y})},this.onWheelZoom=e=>{if(!this.onZoom)return;this.log("wheel zoom"),this.onWheelCapture(e);const t=e.x-this.initialTouchCenter.x,i=e.y-this.initialTouchCenter.y,s=(0,h.Z)(e.deltaY,-25,25);this.wheelZoom-=.01*s;const n={zoomAdd:this.wheelZoom-1,initialCenterX:this.initialTouchCenter.x,initialCenterY:this.initialTouchCenter.y,dragOffsetX:t,dragOffsetY:i,currentCenterX:e.x,currentCenterY:e.y};this.onZoom(n),this.releaseWheelZoom(e)},(0,a.Z)(this,e),this.log=(0,p.kg)("SWIPE-HANDLER"),null!==(t=this.cursor)&&void 0!==t||(this.cursor="grabbing"),null!==(i=this.cancelEvent)&&void 0!==i||(this.cancelEvent=!0),null!==(o=this.listenerOptions)&&void 0!==o||(this.listenerOptions=S),null!==(d=this.setCursorTo)&&void 0!==d||(this.setCursorTo=this.element),this.listenerSetter=new r.Z,this.setListeners(),this.resetValues(),this.tempId=0,null===(m=e.middleware)||void 0===m||m.onDestroy((()=>{this.reset(),this.removeListeners()})),this.releaseWheelDrag=(0,u.Z)(this.reset,150,!1),this.releaseWheelZoom=(0,u.Z)(this.reset,150,!1)}setListeners(){n.Z?(this.withDelay?(0,d.E)({element:this.element,callback:e=>{(0,s.Z)(e),this.handleStart(e)},listenerSetter:this.listenerSetter,listenerOptions:this.listenerOptions}):this.listenerSetter.add(this.element)("touchstart",this.handleStart,this.listenerOptions),this.onDoubleClick&&this.listenerSetter.add(this.element)("dblclick",(e=>{this.onDoubleClick({centerX:e.pageX,centerY:e.pageY})})),this.listenerSetter.add(y)("touchend",this.reset)):(this.listenerSetter.add(this.element)("mousedown",this.handleStart,this.listenerOptions),this.listenerSetter.add(y)("mouseup",this.reset),(this.onZoom||this.onDoubleClick)&&this.listenerSetter.add(this.element)("wheel",this.handleWheel,L))}removeListeners(){this.log("remove listeners"),this.reset(),this.listenerSetter.removeAll()}setCursor(e=""){this.cursor=e,!n.Z&&this.hadMove&&this.setCursorTo.style.setProperty("cursor",this.cursor,"important")}add(e,t){this.xAdded=e,this.yAdded=t,this.handleMove({clientX:this.eventUp.clientX,clientY:this.eventUp.clientY,target:this.eventUp.target})}resetValues(){++this.tempId,this.hadMove=!1,this.xAdded=this.yAdded=0,this.xDown=this.yDown=this.eventUp=this.isMouseDown=void 0,this.onZoom&&(this.initialDistance=0,this.initialTouchCenter={x:m.Z.width/2,y:m.Z.height/2},this.initialDragOffset={x:0,y:0},this.isDragCanceled={x:!1,y:!1},this.wheelZoom=1)}setHadMove(e){var t;this.hadMove||(this.log("had move"),this.hadMove=!0,this.setCursorTo.style.setProperty("cursor",this.cursor,"important"),null===(t=this.onFirstSwipe)||void 0===t||t.call(this,e))}dispatchOnSwipe(...e){const t=this.onSwipe(...e);void 0!==t&&t&&this.reset()}}},709:(e,t,i)=>{"use strict";i.d(t,{Z:()=>r});var s=i(2398),n=i(6272),a=i(4762),o=i(503);class r extends o.ZP{constructor(e={}){super(Object.assign({label:"Contacts.PhoneNumber.Placeholder",name:"phone"},e)),this.pasted=!1,this.lastValue="",this.container.classList.add("input-field-phone");const t=this.input;if(t instanceof HTMLInputElement)t.type="tel",t.autocomplete="rr55RandomRR55";else{t.inputMode="decimal";const e=window.devicePixelRatio;if(e>1){let i;a.IS_APPLE?i=-.16*e:a.IS_ANDROID&&(i=0),t.style.setProperty("--letter-spacing",i+"px")}const i=this.setValueSilently.bind(this);this.setValueSilently=e=>{i(e),(0,s.Z)(this.input,!0)}}t.addEventListener("input",(()=>{t.classList.remove("error");const i=this.value;let s;Math.abs(i.length-this.lastValue.length)>1&&!this.pasted&&a.IS_APPLE_MOBILE&&this.setValueSilently(this.lastValue+i),this.pasted=!1,this.setLabel();let o,r,d,l="";"+"===this.value.replace(/\++/,"+")?this.setValueSilently("+"):(s=(0,n.u)(this.value),o=s.formatted,r=s.country,l=s.leftPattern,d=s.code,this.setValueSilently(this.lastValue=o?"+"+o:"")),t.dataset.leftPattern=l,e.onInput&&e.onInput(s)})),t.addEventListener("paste",(()=>{this.pasted=!0})),t.addEventListener("keypress",(e=>{const t=e.key;if(/\D/.test(t)&&!e.metaKey&&!e.ctrlKey&&"Backspace"!==t&&("+"!==t||!e.shiftKey))return e.preventDefault(),!1}))}}},1439:(e,t,i)=>{"use strict";i.d(t,{Z:()=>a});var s=i(3241);const n=new WeakMap;window.addEventListener("message",(e=>{const t=n.get(e.source);t&&t(JSON.parse(e.data))}));class a extends s.Z{constructor({url:e,sandbox:t}){super(!1),this.onTelegramWebViewEvent=({eventType:e,eventData:t})=>{""===t&&(t=void 0),console.log("onTelegramWebViewEvent",e,t),this.dispatchEvent(e,t)};const i=this.iframe=document.createElement("iframe");i.src=e,t&&i.setAttribute("sandbox",t)}onMount(){n.set(this.iframe.contentWindow,this.onTelegramWebViewEvent)}destroy(){this.cleanup(),n.delete(this.iframe.contentWindow)}}},2796:(e,t,i)=>{"use strict";i.d(t,{Am:()=>c,PE:()=>l,bC:()=>h});var s=i(5565),n=i(2296),a=i(2325);const o=document.createElement("div");let r;o.classList.add("toast");const d=new n.Z("toast");function l(){d.close(),o.classList.remove("is-visible"),r&&clearTimeout(+r),r=window.setTimeout((()=>{o.remove(),r=void 0}),200)}function c(e,t){d.close(),(0,s.Z)(o,e),o.parentElement||(document.body.append(o),o.offsetLeft),o.classList.add("is-visible"),r&&clearTimeout(+r),d.open(o),r=window.setTimeout(l,3e3),t&&d.addEventListener("toggle",t,{once:!0})}function h(e){c((0,a.ag)(e.langPackKey,e.langPackArguments),e.onClose)}d.addEventListener("toggle",(e=>{e||l()}))},426:(e,t,i)=>{"use strict";i.d(t,{Z:()=>l});var s=i(3725),n=i(8594),a=i(2648),o=i(3910),r=i(5994);const d={navigation:{callback:(e,t,i)=>{const s=t.getBoundingClientRect().width,n=[e,t];return i&&n.reverse(),n[0].style.filter="brightness(80%)",n[0].style.transform=`translate3d(${.25*-s}px, 0, 0)`,n[1].style.transform=`translate3d(${s}px, 0, 0)`,e.classList.add("active"),e.offsetWidth,e.style.transform="",e.style.filter="",()=>{t.style.transform=t.style.filter=""}},animateFirst:!1},tabs:{callback:(e,t,i)=>{const s=t.getBoundingClientRect().width,n=[e,t];return i&&n.reverse(),n[0].style.transform=`translate3d(${-s}px, 0, 0)`,n[1].style.transform=`translate3d(${s}px, 0, 0)`,e.classList.add("active"),e.offsetWidth,e.style.transform="",()=>{t.style.transform=""}},animateFirst:!1}},l=e=>{let{content:t,type:i,transitionTime:l,onTransitionEnd:c,isHeavy:h=!0,once:u=!1,withAnimationListener:p=!0,listenerSetter:f,animateFirst:m=!1}=e;const{callback:g,animateFirst:v}=d[i]||{};t.dataset.animation=i,void 0!==v&&(m=v);const b=new Map;let y,w=null;if(p){const e=g?"transitionend":"animationend",i=s=>{if((0,o.Z)(s),s.target.parentElement!==t)return;const n=b.get(s.target);null==n||n(),s.target===w&&(!y&&h||(y&&(y.resolve(),y=void 0),null==c||c(S.prevId()),t.classList.remove("animating","backwards","disable-hover"),u&&(f?f.removeManual(t,e,i):t.removeEventListener(e,i),w=y=void 0,b.clear())))};f?f.add(t)(e,i):t.addEventListener(e,i)}function S(e,i=!0,o){o&&(w=o),e instanceof HTMLElement&&(e=(0,a.Z)(e));const d=S.prevId();if(e===d)return!1;const u=t.children[e];if(r.Z.isAvailable("animations")&&(-1!==d||m)||(i=!1),!p){const e=t.dataset.timeout;void 0!==e&&clearTimeout(+e),delete t.dataset.timeout}if(!i){if(w)w.classList.remove("active","to","from");else if(u){const e=b.get(u);null==e||e()}return u&&(u.classList.remove("to","from"),u.classList.add("active")),t.classList.remove("animating","backwards","disable-hover"),w=u,void(null==c||c(e))}p||(t.dataset.timeout=""+window.setTimeout((()=>{u.classList.remove("to"),w&&w.classList.remove("from"),t.classList.remove("animating","backwards","disable-hover"),delete t.dataset.timeout}),l)),w&&(w.classList.remove("to"),w.classList.add("from")),t.classList.add("animating");const f=d<e;let v;if(t.classList.toggle("backwards",!f),u&&(g?v=g(u,w,f):u.classList.add("active"),u.classList.remove("from"),u.classList.add("to")),u){const e=u.dataset.transitionTimeout;e&&clearTimeout(+e),b.set(u,(()=>{u.classList.remove("to"),b.delete(u)}))}if(w){let e;const t=w,i=()=>{clearTimeout(e),t.classList.remove("active","from"),null==v||v(),b.delete(t)};u?(e=window.setTimeout(i,l+100),b.set(t,i)):(e=window.setTimeout(i,l),b.set(t,(()=>{clearTimeout(e),b.delete(t)}))),t.dataset.transitionTimeout=""+e,h&&(y||(y=(0,s.Z)()),(0,n.YW)(y,2*l))}w=u}return S.prevId=()=>w?(0,a.Z)(w):-1,S.getFrom=()=>w,S.setFrom=e=>w=e,S}},6726:(e,t,i)=>{"use strict";i.d(t,{l:()=>o});var s=i(5701),n=i(503);function a(e){return(e.length>=3&&e.length<=32||!e.length)&&/^[a-zA-Z0-9_]*$/.test(e)}class o extends n.ZP{constructor(e,t){super(e),this.managers=t,this.checkUsernameDebounced=(0,s.Z)(this.checkUsername.bind(this),150,!1,!0),e.listenerSetter.add(this.input)("input",(()=>{var e,t,i,s;const o=this.getValue();if(this.error=void 0,o===this.originalValue||!o.length)return this.setState(n.I1.Neutral),void(null===(t=(e=this.options).onChange)||void 0===t||t.call(e));a(o)?this.setState(n.I1.Neutral):this.setError(this.options.invalidText),this.input.classList.contains("error")?null===(s=(i=this.options).onChange)||void 0===s||s.call(i):this.checkUsernameDebounced(o)}))}getValue(){let e=this.value;return this.options.head&&(e=e.slice(this.options.head.length),this.setValueSilently(this.options.head+e)),e}checkUsername(e){if(this.checkUsernamePromise)return;let t;this.error=void 0,t=this.options.peerId?this.managers.appChatsManager.checkUsername(this.options.peerId.toChatId(),e):this.managers.appUsersManager.checkUsername(e);const i=this.checkUsernamePromise=t.then((t=>{this.getValue()===e&&(t?this.setState(n.I1.Valid,this.options.availableText):this.setError(this.options.takenText))}),(t=>{this.getValue()===e&&(this.error=t,"USERNAME_PURCHASE_AVAILABLE"===t.type?this.setError(this.options.takenText):this.setError(this.options.invalidText))})).then((()=>{var t,s;this.checkUsernamePromise===i&&(this.checkUsernamePromise=void 0),null===(s=(t=this.options).onChange)||void 0===s||s.call(t);const n=this.getValue();n!==e&&this.isValidToChange()&&a(n)&&this.checkUsername(n)}))}}},9522:(e,t,i)=>{"use strict";i.d(t,{Z:()=>g});var s=i(2738),n=i(5975),a=i(2398),o=i(4484),r=i(2914),d=i(319),l=i(5345),c=i(2325),h=i(3512),u=i(5592),p=i(7479),f=i(5029),m=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class g extends f.Z{constructor(e){super({name:"UsernamesProfileHeader",caption:e.peerId.isUser()?"UsernamesProfileHelp":"UsernamesChannelHelp"});const{peerId:t,peer:i,usernameInputField:f,listenerSetter:g,middleware:v}=e,b=h.Z.managers,y=t.isUser()?void 0:t.toChatId(),w=this,S="usernames",C=document.createElement("div");let L;C.classList.add(S);const E=new l.Z({getIndex:e=>L.length-L.findIndex((t=>t.username===e.id)),onDelete:e=>{e.row.container.remove()},onSort:(e,t)=>{(0,o.Z)(e.row.container,C,t)},onElementCreate:e=>{const t=L.find((t=>t.username===e.id)),i=new p.ZP({title:"@"+t.username,subtitle:!0,clickable:!0}),s=!!t.pFlags.editable,n=!!t.pFlags.active;return s&&(i.container.dataset.editable="1"),i.container.dataset.username=t.username,i.container.classList.add(S+"-username"),i.subtitle.classList.add(S+"-username-status"),i.createMedia("medium").classList.add(S+"-username-icon","tgico"),i.makeSortable(),I(i,n),e.row=i,e}}),I=(e,t)=>{e.subtitle.replaceChildren((0,c.ag)(e.container.dataset.editable?"UsernameLinkEditable":t?"UsernameLinkActive":"UsernameLinkInactive")),e.container.classList.toggle("active",t),e.toggleSorting(t)},P=(e=[])=>{L=e,E.getAll().forEach((t=>{e.some((e=>e.username===t.id))||E.delete(t.id)})),e.forEach((e=>{if(E.has(e.username)){const t=E.get(e.username);E.update(e.username,t),I(t.row,!!e.pFlags.active)}else E.add(e.username)})),w.container.classList.toggle("hide",!E.getAll().size)};P(i.usernames),g.add(h.Z)("peer_title_edit",(({peerId:e})=>m(this,void 0,void 0,(function*(){if(e!==t)return;const i=yield b.appPeersManager.getPeer(t);P(i.usernames)}))));let Z=!1;(0,s.fc)(C,(e=>m(this,void 0,void 0,(function*(){if(Z)return void(Z=!1);const t=(0,n.Z)(e.target,C);if(!t)return;if(t.dataset.editable)return void(0,a.Z)(f.input,!0,!0);const i=t.dataset.username,s=t.classList.contains("active");let o,r;s?(o="UsernameDeactivateLink",r=y?"UsernameDeactivateLinkChannelMessage":"UsernameDeactivateLinkProfileMessage"):(o="UsernameActivateLink",r=y?"UsernameActivateLinkChannelMessage":"UsernameActivateLinkProfileMessage");try{yield(0,u.Z)({titleLangKey:o,descriptionLangKey:r,button:{langKey:s?"Hide":"Show"}})}catch(e){return}const l=!s;let c;c=y?b.appChatsManager.toggleUsername(y,i,l):b.appUsersManager.toggleUsername(i,l),c.catch((e=>{"USERNAMES_ACTIVE_TOO_MUCH"===e.type?(0,u.Z)({titleLangKey:"UsernameActivateErrorTitle",descriptionLangKey:"UsernameActivateErrorMessage",button:{langKey:"OK",isCancel:!0}}).catch(d.Z):console.error("turn username error",e)}))})))),new r.Z({list:C,middleware:v,onSort:(e,t)=>{const i=L.splice(e,1)[0];L.splice(t,0,i),E.updateList();const s=L.filter((e=>e.pFlags.active)).map((e=>e.username));y?b.appChatsManager.reorderUsernames(y,s):b.appUsersManager.reorderUsernames(s)}}),w.content.append(C)}}},2940:(e,t,i)=>{"use strict";i.d(t,{Z:()=>s});class s{constructor(e,t){this.items=new Map,this.locked=!1,this.observer=new IntersectionObserver((t=>{if(this.locked)return;const i=[];t.forEach(((e,t)=>{const s=e.target;if(this.items.get(s)===e.isIntersecting)return;this.items.set(s,e.isIntersecting);const n={target:s,visible:e.isIntersecting,entry:e,index:t};i.push(n)})),i.forEach((t=>{e(t)}))}),t)}getVisible(){const e=[];return this.items.forEach(((t,i)=>{t&&e.push(i)})),e}clearVisible(){const e=this.getVisible();for(const t of e)this.items.set(t,!1)}isVisible(e){return this.items.get(e)}disconnect(){this.observer.disconnect(),this.items.clear()}refresh(){this.observer.disconnect();const e=[...this.items.keys()];for(const t of e)this.observer.observe(t)}refreshVisible(){const e=this.getVisible();for(const t of e)this.observer.unobserve(t);for(const t of e)this.observer.observe(t)}observe(e){this.items.set(e,!1),this.observer.observe(e)}unobserve(e){this.observer.unobserve(e),this.items.delete(e)}unlock(){this.locked=!1}unlockAndRefresh(){this.unlock(),this.refresh()}lock(){this.locked=!0}}},8427:(e,t,i)=>{"use strict";i.d(t,{Z:()=>r});var s=i(3910),n=i(2738),a=i(3013),o=i(65);class r extends o.Z{constructor(e,t=!1){super({step:.01,min:0,max:1,vertical:t},1),this.listenerSetter=e,this.vertical=t,this.onMuteClick=e=>{e&&(0,s.Z)(e),a.Z.muted=!a.Z.muted},this.setVolume=()=>{const{volume:e,muted:t}=a.Z;let i;i=!e||t?0:e>.5?3:e>0&&e<.25?1:2,r.ICONS.forEach((e=>this.icon.classList.remove("tgico-"+e))),this.icon.classList.add("tgico-"+r.ICONS[i]),this.mousedown||this.setProgress(t?0:e)},this.setListeners(),this.setHandlers({onScrub:e=>{const t=Math.max(Math.min(e,1),0);a.Z.muted=!1,a.Z.volume=t}});const i="player-volume",o=this.btn=document.createElement("div");o.classList.add("btn-icon",i);const d=this.icon=document.createElement("span");d.classList.add(i+"__icon"),o.append(d,this.container),(0,n.fc)(d,this.onMuteClick,{listenerSetter:this.listenerSetter}),this.listenerSetter.add(a.Z)("playbackParams",this.setVolume),this.setVolume()}}r.ICONS=["volume_off","volume_mute","volume_down","volume_up"]},9083:(e,t,i)=>{"use strict";i.d(t,{N:()=>a,Z:()=>n});var s=i(5400);function n({docIds:e,loadPromises:t,middleware:i,lazyLoadQueue:n,customEmojiSize:a,animationGroup:o}){const r=" ".repeat(e.length),d=[];return e.forEach(((e,t)=>{d.push({_:"messageEntityCustomEmoji",offset:t,length:1,document_id:e})})),(0,s.ZP)(r,{entities:d,loadPromises:t,animationGroup:o,customEmojiSize:a,middleware:i,lazyLoadQueue:n})}function a(e){var t;const i=null!==(t=e.loadPromises)&&void 0!==t?t:e.loadPromises=[],s=n(e);return Promise.all(i).then((()=>s))}},296:(e,t,i)=>{"use strict";i.d(t,{Z:()=>P});var s=i(2341),n=i(467),a=i(632),o=i(2738),r=i(8497),d=i(4081),l=i(5994),c=i(319),h=i(2312),u=i(7030),p=i(1243),f=i(9687),m=i(2325),g=i(1507),v=i(2491),b=i(3512),y=i(8448),w=i(3251),S=i(3442),C=i(9492),L=i(5671),E=i(1604),I=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};function P({message:e,withTime:t,fontWeight:i,voiceAsMusic:P,showSender:Z,searchContext:M,loadPromises:k,autoDownloadSize:T,lazyLoadQueue:x,sizeType:A,managers:_=b.Z.managers,cacheContext:F,fontSize:D,getSize:R,canTranscribeVoice:B}){var N;return I(this,void 0,void 0,(function*(){null!=i||(i=500),null!=A||(A=""),null!=D||(D=16);const b=0===T,O=e.media.document||e.media.webpage.document,U=null==e?void 0:e.uploadingFileName;if("audio"===O.type||"voice"===O.type||"round"===O.type){const s=new y.ZP;return s.withTime=t,s.message=e,s.noAutoDownload=b,s.lazyLoadQueue=x,s.loadPromises=k,B&&"voice"===O.type&&(s.transcriptionState=0),s.getSize=R,P&&(s.voiceAsMusic=P),M&&(s.searchContext=M),Z&&(s.showSender=Z),s.dataset.fontWeight=""+i,s.dataset.fontSize=""+D,s.dataset.sizeType=A,yield s.render(),s}const H=O.file_name?O.file_name.split("."):"";let z="";z=H.length>1&&Array.isArray(H)?(0,n.ST)(H.pop().split(" ",1)[0].toLowerCase()):"file";const j=document.createElement("div");j.classList.add("document",`ext-${z}`),j.dataset.docId=""+O.id,j.doc=O;const G=document.createElement("div");let V;G.classList.add("document-ico");const K=!!F,W=()=>K?F:_.thumbsStorage.getCacheContext(O);F=yield W();let $=!1;if((null===(N=O.thumbs)||void 0===N?void 0:N.length)||e.pFlags.is_outgoing&&F.url&&"photo"===O.type){j.classList.add("document-with-thumb"),$=!0;const t=[];if(e.pFlags.is_outgoing&&["photo","video"].includes(O.type)&&F.url)G.innerHTML=`<img src="${F.url}">`,t.push(G.firstElementChild);else{performance.now();const e=yield(0,C.Z)({photo:O,message:null,container:G,boxWidth:54,boxHeight:54,loadPromises:k,withoutPreloader:!0,lazyLoadQueue:x,size:(0,f.Z)(O,54,54,!0),managers:_});G.style.width=G.style.height="",e.images.thumb&&t.push(e.images.thumb),e.images.full&&t.push(e.images.full)}t.forEach((e=>e.classList.add("document-thumb")))}else V=document.createElement("span"),V.classList.add("document-ico-text"),V.innerText=z,G.append(V);const q=O.file_name?(0,v.Z)(O.file_name):"Unknown.file";document.createElement("div").classList.add("document-description");const Y=document.createElement("span"),Q=[(0,d.Z)(O.size)];if(t&&Q.push((0,a.OD)(e.date)),Z&&Q.push(yield(0,L.Z)(e)),!t&&!Z){const e=document.createElement("span"),t=(0,d.Z)(O.size);e.append(" / ",t),e.style.visibility="hidden",Q.push(e)}j.innerHTML=`\n ${F.downloaded&&!U||!e.mid||!$?"":'<div class="document-download"></div>'}\n <div class="document-name"></div>\n <div class="document-size"></div>\n `;const X=j.querySelector(".document-name"),J=new w.I;J.dataset.fontWeight=""+i,J.dataset.fontSize=""+D,J.dataset.sizeType=A,J.getSize=R,J.textContent=q,e.mid||j.classList.add("downloaded"),X.append(J),Z&&X.append((0,E.Z)(e));const ee=j.querySelector(".document-size");if(Y.append(...(0,m.A1)(Q," · ")),ee.append(Y),j.prepend(G),!U&&e.pFlags.is_outgoing&&!e.mid)return j;let te,ie=null;const se=()=>{if(j.classList.remove("downloading"),O.size>g.Iw&&!U)return ie.setManual(),ie.attach(te),ie.preloader.classList.add("manual"),void ie.setDownloadFunction(ae);if(O.size<=g.Iw&&j.classList.add("downloaded"),te){if(te!==G){const e=te;setTimeout((()=>{e.remove()}),200)}te=null}ie&&(ie=null)},ne=e=>{j.classList.add("downloading");const t=document.createElement("span"),i=(0,d.Z)(O.size);t.style.position="absolute",t.style.left="0",e.then(se,c.Z).finally((()=>{Y.style.visibility="",t.remove()}));const s=e=>(0,d.Z)(e);let n=s(0);Y.style.visibility="hidden",t.append(n," / ",i),Y.parentElement.append(t),e.addNotifyListener((e=>{const t=s(e.done);n.replaceWith(t),n=t}))},ae=e=>{var t;const i=!e||e.isTrusted,n=j.doc;let a;const o=u.ZP.chat.bubbles?u.ZP.chat.bubbles.lazyLoadQueue.queueId:void 0;if(i)if("pdf"===n.type){const e=!ie||ie.detached;a=h.Z.downloadMediaURL({media:n,queueId:o}),e&&a.then((()=>{setTimeout((()=>I(this,void 0,void 0,(function*(){const e=(yield W()).url;window.open(e)}))),l.Z.isAvailable("animations")?250:0)}))}else a=s.Z.has(n.mime_type)&&(null===(t=n.thumbs)||void 0===t?void 0:t.length)?h.Z.downloadMediaURL({media:n,queueId:o}):h.Z.downloadToDisc({media:n,queueId:o});else a=h.Z.downloadToDisc({media:n,queueId:o},!0);a.catch((()=>{j.classList.remove("downloading")})),te&&(ie.attach(te,!0,a),ne(a))},{fileName:oe}=(0,p.Z)({media:O,downloadId:"1"});if(yield _.apiFileManager.isDownloading(oe)){te=j.querySelector(".document-download")||G;const e=h.Z.downloadToDisc({media:O},!0);ie=new S.Z,ie.attach(te,!1,e),ie.setDownloadFunction(ae),ne(e)}else if(!F.downloaded||U)if(te=j.querySelector(".document-download")||G,ie=new S.Z({isUpload:!!U}),U){const e=h.Z.getUpload(U);ie.attachPromise(e),ie.attach(te),ne(e)}else ie.construct(),ie.setManual(),ie.attach(te),ie.setDownloadFunction(ae),void 0!==T&&T>=O.size&&(0,o.tH)(ie.preloader);return(0,o.fc)(j,(e=>{(0,r.Z)(e.target,"time")||(ie?ie.onClick(e):ae(e))})),j}))}b.Z.addEventListener("document_downloading",(e=>{Array.from(document.querySelectorAll(`.document[data-doc-id="${e}"]`)).forEach((e=>{e.querySelector(".preloader-container.manual")&&(0,o.tH)(e)}))}))},8210:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(6272);function n(e){return"+"+(0,s.u)(e).formatted}},177:(e,t,i)=>{"use strict";i.d(t,{Z:()=>o});var s=i(2575),n=i(2325),a=i(3512);function o(e,t=a.Z.managers){var i,o,r,d,l,c;return r=this,d=void 0,c=function*(){const a=yield t.appChatsManager.getChat(e);if("chatForbidden"===a._)return(0,n.ag)("YouWereKicked");const r=yield t.appProfileManager.getCachedFullChat(e);let d;d=r?"channelFull"===r._?r.participants_count:null===(i=r.participants.participants)||void 0===i?void 0:i.length:a.participants_count||(null===(o=a.participants)||void 0===o?void 0:o.participants.length),d=d||1;const l=a.pFlags.broadcast?"Peer.Status.Subscribers":"Peer.Status.Member";return(0,n.ag)(l,[(0,s.Z)(d)])},new((l=void 0)||(l=Promise))((function(e,t){function i(e){try{n(c.next(e))}catch(e){t(e)}}function s(e){try{n(c.throw(e))}catch(e){t(e)}}function n(t){var n;t.done?e(t.value):(n=t.value,n instanceof l?n:new l((function(e){e(n)}))).then(i,s)}n((c=c.apply(r,d||[])).next())}))}},493:(e,t,i)=>{"use strict";i.d(t,{Z:()=>d});var s=i(8456),n=i(5102),a=i(2325),o=i(8115),r=i(3512);function d(e){return t=this,i=void 0,l=function*(){const{peerId:t=r.Z.myId,plainText:i,onlyFirstName:d,limitSymbols:l,managers:c=r.Z.managers,threadId:h}=e;let u="";if(t.isUser()){const e=yield c.appUsersManager.getUser(t.toUserId());e&&(e.first_name&&(u+=e.first_name),!e.last_name||d&&u||(u+=" "+e.last_name)),u=u?u.trim():!e||e.pFlags.deleted?a.ZP.format(d?"Deleted":"HiddenName",!0):(0,n.Z)(e)[0]||""}else{if(h){const e=yield c.dialogsStorage.getForumTopic(t,h);u=(null==e?void 0:e.title)||""}if(!u){const e=yield c.appChatsManager.getChat(t.toChatId());u=(null==e?void 0:e.title)||""}d&&(u=u.split(" ")[0])}return void 0!==l&&(u=(0,s.Z)(u,l,l)),i?u:(0,o.Z)(u)},new((d=void 0)||(d=Promise))((function(e,s){function n(e){try{o(l.next(e))}catch(e){s(e)}}function a(e){try{o(l.throw(e))}catch(e){s(e)}}function o(t){var i;t.done?e(t.value):(i=t.value,i instanceof d?i:new d((function(e){e(i)}))).then(n,a)}o((l=l.apply(t,i||[])).next())}));var t,i,d,l}},3061:(e,t,i)=>{"use strict";i.d(t,{Z:()=>o});var s=i(632),n=i(2325),a=i(1507);function o(e){var t;if(!e)return document.createElement("span");let i,o;switch(e.id){case a.hj.toUserId():i="Peer.RepliesNotifications";break;case a.yF.toUserId():i="Peer.ServiceNotifications";break;default:if(e.pFlags.bot){i="Bot";break}if(e.pFlags.support){i="SupportStatus";break}switch(null===(t=e.status)||void 0===t?void 0:t._){case"userStatusRecently":i="Lately";break;case"userStatusLastWeek":i="WithinAWeek";break;case"userStatusLastMonth":i="WithinAMonth";break;case"userStatusOffline":{const t=e.status.was_online,n=new Date,a=(n.getTime()/1e3|0)-t;if(a<60)i="Peer.Status.justNow";else if(a<3600)i="Peer.Status.minAgo",o=[a/60|0];else if(a<86400&&n.getDate()===new Date(1e3*t).getDate())i="LastSeen.HoursAgo",o=[a/3600|0];else{i="Peer.Status.LastSeenAt";const{dateEl:e,timeEl:n}=(0,s.rz)(t);o=[e,n]}break}case"userStatusOnline":i="Online";break;default:i="ALongTimeAgo"}}return(0,n.ag)(i,o)}},6131:(e,t,i)=>{"use strict";i.d(t,{MR:()=>d,ZP:()=>c,kN:()=>l});var s=i(3910),n=i(1046),a=i(319),o=i(6628),r=i(9099);function d(e){const{mediaSpoiler:t,reveal:i,destroyAfter:s}=e;(0,r.Z)({element:t,forwards:i,className:"is-revealing",duration:250,onTransitionEnd:()=>{i&&s&&(t.remove(),t.middlewareHelper.destroy())}})}function l(e){const{mediaSpoiler:t,event:i}=e;if((0,s.Z)(i),t.classList.contains("is-revealing"))return;const n=t.parentElement.querySelector("video");n&&!t.parentElement.querySelector(".video-play")&&(n.autoplay=!0,n.play().catch(a.Z)),d({mediaSpoiler:t,reveal:!0,destroyAfter:!0})}function c(e){return t=this,i=void 0,a=function*(){const{media:t}=e,i=(t.sizes||t.thumbs).find((e=>"photoStrippedSize"===e._));if(!i)return;const{image:s,loadPromise:a}=(0,n.Z)(t,i,!0);return yield a,function(e){const{middleware:t,image:i}=e;if(!t())return;i.classList.add("media-spoiler-thumbnail");const s=document.createElement("div");s.classList.add("media-spoiler-container"),s.middlewareHelper=t.create();const n=o.Z.create(Object.assign(Object.assign({},e),{middleware:s.middlewareHelper.get()}));return s.append(i,n.canvas),s}(Object.assign(Object.assign({},e),{image:s}))},new((s=void 0)||(s=Promise))((function(e,n){function o(e){try{d(a.next(e))}catch(e){n(e)}}function r(e){try{d(a.throw(e))}catch(e){n(e)}}function d(t){var i;t.done?e(t.value):(i=t.value,i instanceof s?i:new s((function(e){e(i)}))).then(o,r)}d((a=a.apply(t,i||[])).next())}));var t,i,s,a}},6239:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(9345);function n(e){return t=this,i=void 0,a=function*(){try{return yield(0,s.Z)(e)}catch(t){return console.error("wrapMessageActionTextNewUnsafe error:",t),e.plain?"":document.createElement("span")}},new((n=void 0)||(n=Promise))((function(e,s){function o(e){try{d(a.next(e))}catch(e){s(e)}}function r(e){try{d(a.throw(e))}catch(e){s(e)}}function d(t){var i;t.done?e(t.value):(i=t.value,i instanceof n?i:new n((function(e){e(i)}))).then(o,r)}d((a=a.apply(t,i||[])).next())}));var t,i,n,a}},9345:(e,t,i)=>{"use strict";i.d(t,{Z:()=>F,e:()=>x});var s=i(1655),n=i(632),a=i(2614),o=i(130),r=i(8939),d=i(5180),l=i(2946),c=i(2325),h=i(1507),u=i(8115),p=i(2491),f=i(5400),m=i(3512),g=i(2064),v=i(5798);let b,y,w;const S=new Map;var C=i(9083),L=i(493),E=i(3591);function I(e){const t=e.action,{onclick:i,url:s}=(0,E.Z)(`tg://voicechat?chat_id=${e.peerId.toChatId()}&id=${t.call.id}&access_hash=${t.call.access_hash}`);if(!i)return document.createElement("span");const n=document.createElement("a");return n.href=s,n.setAttribute("onclick",i+"(this)"),n}var P=i(496),Z=i(7362),M=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};function k(e){return M(this,void 0,void 0,(function*(){const t=yield(0,P.Z)(e);if(e.plain)return t;const i=document.createElement("i");return i.dataset.savedFrom=e.message.peerId+"_"+e.message.mid,i.dir="auto",i.append(t),i}))}function T(e,t){return t?e:(0,a.Z)((0,u.Z)(e))}function x(e){return M(this,void 0,void 0,(function*(){const t=e.topic;let i=null==t?void 0:t.icon_emoji_id;return(null==t?void 0:t.id)===h.Ox&&(i="5390854796011906616"),i?e.plain?m.Z.managers.appEmojiManager.getCustomEmojiDocument(i).then((e=>e.stickerEmojiRaw)):(0,C.N)(Object.assign(Object.assign({},e),{docIds:[i]})).then((e=>(e.lastElementChild.classList.add("topic-icon"),e))):e.plain?"":function(e,t){if(!b){w=document.getElementById("svg-defs");const e="http://www.w3.org/2000/svg";b=document.createElementNS(e,"svg"),b.setAttributeNS(null,"width","26"),b.setAttributeNS(null,"height","26"),b.setAttributeNS(null,"viewBox","0 0 26 26"),b.classList.add("topic-icon-svg");const t=document.createElementNS(e,"use");t.setAttributeNS(null,"href","#topic-icon"),b.append(t),y=document.createElement("span"),y.classList.add("topic-icon","avatar-like");const i=document.createElement("span");i.classList.add("topic-icon-content"),y.append(b,i)}e||(console.error("NO TOPIC ICON COLOR!"),e=h.OS[0]),t||(console.error("NO TOPIC NAME!"),t="");const i=e.toString(16),s=`topic-icon-gradient-${e}`;let n=S.get(e);if(!n){const{h:t,s:a,l:o,a:r}=(0,g.cw)("#"+i);w.insertAdjacentHTML("beforeend",`\n <linearGradient id="${s}" x1="0" x2="0" y1="0" y2="1">\n <stop style="stop-color: #${i};" offset="0%" />\n <stop style="stop-color: hsla(${t}, ${a}%, ${Math.max(0,o-30)}%, ${r});" offset="100%" />\n </linearGradient>\n `),S.set(e,n=`hsla(${t}, ${a}%, ${Math.max(0,o-40)}%, ${r})`)}const a=y.cloneNode(!0);return a.firstElementChild.style.fill=`url(#${s})`,a.firstElementChild.style.stroke=n,a.lastElementChild.append((0,v.Z)(t,!0)),a}(null==t?void 0:t.icon_color,null==t?void 0:t.title)}))}function A(e){const t=e.message.action;return x(Object.assign(Object.assign({},e),{topic:t}))}function _(e){return M(this,void 0,void 0,(function*(){const t=e.message.action,i=document.createElement("span");return i.classList.add("topic-name"),i.append(yield A(e),T(t.title,e.plain)),i}))}function F(e){var t,i;return M(this,void 0,void 0,(function*(){const{plain:h,message:g,noLinks:v}=e,b=h?void 0:document.createElement("span"),y="action"in g&&g.action;if(y.message){const e=y.message;return h?(0,p.Z)(e):((0,o.Z)(b,(0,f.ZP)(e,{noLinebreaks:!0})),b)}{let o,p,w=y._;const S=m.Z.managers,C=(e,t)=>t?(0,L.Z)({peerId:e,plainText:t}):(0,Z.Z)({peerId:e});switch(y._){case"messageActionPhoneCall":w+="."+y.type,p=[(0,r.Z)(y.duration,h)];break;case"messageActionGroupCall":w+="."+y.type,p=[],w.endsWith("You")||g.pFlags.post||p.push(C(g.fromId,h)),void 0!==y.duration?p.push((0,r.Z)(y.duration,h)):v?p.push(""):p.push(I(g));break;case"messageActionInviteToGroupCall":{const e=[g.fromId,y.users[0].toPeerId()];let t="Chat.Service.VoiceChatInvitation";const i=m.Z.myId;e[0]===i?t+="ByYou":e[1]===i&&(t+="ForYou"),(0,s.Z)(e,i),o=t,p=e.map((e=>C(e,h))),p.push(v?"":I(g));break}case"messageActionGroupCallScheduled":{const e=new Date,t=new Date(1e3*y.schedule_date),i=(t.getTime()-e.getTime())/864e5,s=new Date(e);s.setDate(s.getDate()+1);const a=yield S.appPeersManager.isBroadcast(g.peerId);o=a?"ChatList.Service.VoiceChatScheduled.Channel":"ChatList.Service.VoiceChatScheduled",p=[];const r=m.Z.myId;let d;g.fromId===r?o+="You":a||p.push(C(g.fromId,h));const l=[];i<1&&t.getDate()===e.getDate()?d="TodayAtFormattedWithToday":i<2&&t.getDate()===s.getDate()?d="Time.TomorrowAt":(d="formatDateAtTime",l.push(new c.ZP.IntlDateElement({date:t,options:{day:"2-digit",month:"2-digit",year:"2-digit"}}).element)),l.push((0,n.mr)(t));const u=(0,c.ag)(d,l);p.push(u);break}case"messageActionChatCreate":{const e=m.Z.myId;g.fromId===e?w+="You":p=[C(g.fromId,h)];break}case"messageActionPinMessage":{const t=g.peerId,i=yield S.appMessagesManager.getMessageByPeer(t,g.reply_to_mid);p=[C(g.fromId,h)],i?p.push(k(Object.assign(Object.assign({},e),{message:i}))):(o="ActionPinnedNoText",g.reply_to_mid&&S.appMessagesManager.fetchMessageReplyTo(g));break}case"messageActionChatJoinedByRequest":{const e=yield S.appPeersManager.isBroadcast(g.peerId);g.pFlags.out?o=e?"RequestToJoinChannelApproved":"RequestToJoinGroupApproved":(o=e?"ChatService.UserJoinedChannelByRequest":"ChatService.UserJoinedGroupByRequest",p=[C(g.fromId,h)]);break}case"messageActionContactSignUp":case"messageActionChatReturn":case"messageActionChatLeave":case"messageActionChatJoined":case"messageActionChatEditPhoto":case"messageActionChatDeletePhoto":case"messageActionChatEditVideo":case"messageActionChatJoinedByLink":case"messageActionChannelEditVideo":case"messageActionChannelDeletePhoto":p=[C(g.fromId,h)];break;case"messageActionChannelEditTitle":case"messageActionChatEditTitle":p=[],"messageActionChatEditTitle"===y._&&p.push(C(g.fromId,h)),p.push(T(y.title));break;case"messageActionChatDeleteUser":case"messageActionChatAddUsers":case"messageActionChatAddUser":{const e=y.users||[y.user_id];if(p=[C(g.fromId,h)],e.length>1){const t=(0,c.v_)(yield Promise.all(e.map((e=>C(e.toPeerId(),h)))),!1,h);if(h)p.push(...t);else{const e=document.createElement("span");e.append(...t),p.push(e)}}else p.push(C(e[0].toPeerId(),h));break}case"messageActionBotAllowed":{if(null===(t=y.pFlags)||void 0===t?void 0:t.attach_menu){o="ActionAttachMenuBotAllowed";break}if(!y.domain)break;const e=(0,f.ZP)(y.domain,{entities:[{_:"messageEntityUrl",length:y.domain.length,offset:0}],noLinks:v});p=[(0,a.Z)(e)];break}case"messageActionPaymentSent":{const t=y.pFlags.recurring_init,s=y.pFlags.recurring_used;if(o=s?"Chat.Service.PaymentSentRecurringUsedNoTitle":t?"Chat.Service.PaymentSentRecurringInitNoTitle":"Chat.Service.PaymentSent1NoTitle",p=[(0,d.Z)(y.total_amount,y.currency),C(g.peerId,h)],g.reply_to_mid){const n=yield S.appMessagesManager.getMessageByPeer((null===(i=g.reply_to)||void 0===i?void 0:i.reply_to_peer_id)?(0,l.Z)(g.reply_to.reply_to_peer_id):g.peerId,g.reply_to_mid);n?(o=s?"Chat.Service.PaymentSentRecurringUsed":t?"Chat.Service.PaymentSentRecurringInit":"Chat.Service.PaymentSent1",p.push(k(Object.assign(Object.assign({},e),{message:n})).then((e=>(e instanceof HTMLElement&&e.classList.add("is-receipt-link"),e))))):S.appMessagesManager.fetchMessageReplyTo(g)}break}case"messageActionSetMessagesTTL":{p=[];const e=yield S.appPeersManager.isBroadcast(g.peerId);if(y.period){let t;if(e?o="ActionTTLChannelChanged":g.fromId===m.Z.myId?o="ActionTTLYouChanged":(o="ActionTTLChanged",p.push(C(g.fromId,h))),y.period>1814400){let e;const i=[],s=31536e3;y.period>=s?(e="Years",i.push(y.period/s|0)):(e="Months",i.push(y.period/(30*n.s2)|0)),t=h?c.ZP.format(e,!0,i):(0,c.ag)(e,i)}else t=(0,r.Z)(y.period,h);p.push(t)}else e?o="ActionTTLChannelDisabled":g.fromId===m.Z.myId?o="ActionTTLYouDisabled":(o="ActionTTLDisabled",p.push(C(g.fromId,h)));break}case"messageActionTopicEdit":{let t,i,s;const n=!!g.pFlags.out,a=void 0!==y.icon_emoji_id,r=a&&!+y.icon_emoji_id,d=void 0!==y.title,l=void 0!==y.hidden;n||(s=C(g.fromId,h)),d&&(i=T(y.title)),a&&!r&&(t=A(e)),p=s?[s]:[],y.closed?o=n?"Chat.Service.Group.TopicEdited.You.Paused":"Chat.Service.Group.TopicEdited.Paused":!1===y.closed?o=n?"Chat.Service.Group.TopicEdited.You.Resumed":"Chat.Service.Group.TopicEdited.Resumed":r&&d?(o=n?"Chat.Service.TopicEdited.You.Mixed.IconRemoved":"Chat.Service.TopicEdited.Mixed.IconRemoved",p.push(i)):a&&d?(o=n?"Chat.Service.TopicEdited.You.Mixed":"Chat.Service.TopicEdited.Mixed",p.push(_(e))):r?o=n?"Chat.Service.Group.TopicEdited.You.Icon.Removed":"Chat.Service.Group.TopicEdited.Icon.Removed":d?(o=n?"Chat.Service.Group.TopicEdited.You.Title":"Chat.Service.Group.TopicEdited.Title",p.push(i)):a?(o=n?"Chat.Service.Group.TopicEdited.You.Icon":"Chat.Service.Group.TopicEdited.Icon",p.push(t)):l&&(o=n?y.hidden?"Chat.Service.Group.TopicEdited.You.Hided":"Chat.Service.Group.TopicEdited.You.Unhided":y.hidden?"Chat.Service.Group.TopicEdited.Hided":"Chat.Service.Group.TopicEdited.Unhided");break}case"messageActionTopicCreate":p=[_(e)],o="TopicWasCreatedAction";break;case"messageActionSetChatTheme":{const e=!!g.pFlags.out;let t;e||(t=C(g.fromId,h)),p=t?[t]:[],y.emoticon?(p.push((0,u.Z)(y.emoticon)),o=e?"ChatThemeChangedYou":"ChatThemeChangedTo"):o=e?"ChatThemeDisabledYou":"ChatThemeDisabled";break}case"messageActionGiftPremium":{const e=!!g.pFlags.out;let t;e||(t=C(g.fromId,h)),p=t?[t]:[],p.push((0,d.Z)(y.amount,y.currency,!1,!0)),o=e?"ActionGiftOutbound":"ActionGiftInbound";break}default:o=c.Hz[w]||`[${y._}]`}o||(o=c.Hz[w],void 0===o&&(o="["+w+"]"));const E=p&&(yield Promise.all(p));return h?c.ZP.format(o,!0,E):(0,c.$d)(b,o,E)}}))}},496:(e,t,i)=>{"use strict";i.d(t,{Z:()=>v});var s=i(8938),n=i(5705),a=i(677),o=i(3738),r=i(8456),d=i(5381),l=i(2325),c=i(6535),h=i(1346),u=i(8115),p=i(2491),f=i(5400),m=i(3512),g=i(6239);function v(e){var t,i,v,b,y,w;return v=this,b=void 0,w=function*(){let{message:v,text:b,usingMids:y,plain:w,highlightWord:S,withoutMediaType:C}=e;null!=b||(b=v.message);const L=[];let E=!1;const I=(e,t)=>{if(e){if(void 0===t&&E)return;t=w?l.ZP.format(e,!0):(0,l.ag)(e)}if(w)L.push(t);else{const e=document.createElement("span");"string"==typeof t?e.innerHTML=t:e.append(t),L.push(e)}},P=m.Z.managers.appMessagesManager,Z=(0,d.Z)(v);let M=null!==(t=v.totalEntities)&&void 0!==t?t:v.entities;if(v.media&&!Z){(0,s.Z)(v);let e=!0;if(v.grouped_id){if(y){const t=yield P.getMidsByMessage(v);if(y.length===t.length){for(const i of t)if(!y.includes(i)){e=!1;break}}else e=!1}if(e){const e=yield P.getAlbumText(v.grouped_id);b=(null==e?void 0:e.message)||"",M=(null==e?void 0:e.totalEntities)||[],C||(I("AttachAlbum"),E=!0)}}else e=!1;if(!e&&!C||!b){const e=v.media;switch(e._){case"messageMediaPhoto":I("AttachPhoto");break;case"messageMediaDice":I(void 0,w?e.emoticon:(0,u.Z)(e.emoticon));break;case"messageMediaVenue":b=e.title,I("AttachLocation");break;case"messageMediaGeo":I("AttachLocation");break;case"messageMediaGeoLive":I("AttachLiveLocation");break;case"messageMediaPoll":const t="📊 "+(e.poll.question||"poll");I(void 0,w?t:(0,u.Z)(t));break;case"messageMediaContact":I("AttachContact");break;case"messageMediaGame":{const t="🎮 "+e.game.title;I(void 0,w?t:(0,u.Z)(t));break}case"messageMediaDocument":{const t=e.document;if("video"===t.type)I("AttachVideo");else if("voice"===t.type)I("AttachAudio");else if("gif"===t.type)I("AttachGif");else if("round"===t.type)I("AttachRound");else if("sticker"===t.type){const e=L.length;if(t.stickerEmojiRaw){const e=t.stickerEmojiRaw+" ";I(void 0,w?e:(0,u.Z)(e))}I("AttachSticker");const i=L.splice(e,2);if(w)L.push(i[0]+(i[1]?i[1]:""));else{const e=window.document.createElement("span");e.append(...i),L.push(e)}b=""}else if("audio"===t.type){const e=t.attributes.find((e=>"documentAttributeAudio"===e._&&(e.title||e.performer))),i="🎵 "+(e?[e.title,e.performer].filter(Boolean).join(" - "):t.file_name);I(void 0,w?i:(0,u.Z)(i))}else I(void 0,w?t.file_name:(0,u.Z)(t.file_name));break}case"messageMediaInvoice":"messageExtendedMediaPreview"===(null===(i=e.extended_media)||void 0===i?void 0:i._)?I(void 0,w?e.description:(0,u.Z)(e.description)):I(void 0,w?e.title:(0,u.Z)(e.title));break;case"messageMediaUnsupported":I(l.nK)}}const t=L.length;for(let e=1;e<t;e+=2)L.splice(e,0,", ");b&&t&&L.push(", ")}if(v.action){const e=yield(0,g.Z)({message:v,plain:w,noLinks:!0,noTextFormat:!0});e&&I(void 0,e)}if(Z&&(b=(0,a.RP)(v.restriction_reason).text,M=[]),b)if(b=(0,r.Z)(b,100),null!=M||(M=(0,c.Z)(b)),w)L.push((0,p.Z)(b,M));else{if(S){S=S.trim();let e,t=!1;const i=new RegExp((0,o.Z)(S),"gi");for(M=M.slice();null!==(e=i.exec(b));)M.push({_:"messageEntityHighlight",length:S.length,offset:e.index}),t=!0;t&&(0,h.Z)(M)}const e=(0,f.ZP)(b,{noLinebreaks:!0,entities:M,noLinks:!0,noTextFormat:!0});L.push((0,n.Z)(e))}if(w)return L.join("");{const e=document.createDocumentFragment();return e.append(...L),e}},new((y=void 0)||(y=Promise))((function(e,t){function i(e){try{n(w.next(e))}catch(e){t(e)}}function s(e){try{n(w.throw(e))}catch(e){t(e)}}function n(t){var n;t.done?e(t.value):(n=t.value,n instanceof y?n:new y((function(e){e(n)}))).then(i,s)}n((w=w.apply(v,b||[])).next())}))}},6853:(e,t,i)=>{"use strict";i.d(t,{Z:()=>a});var s=i(2325),n=i(8115);function a(e){return"number"==typeof e?(0,s.ag)(e?1===e?"Chat.OwnerBadge":"ChatAdmin":"Chat.ChannelBadge"):(0,n.Z)(e)}},7362:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(8842);function n(e){return t=this,i=void 0,a=function*(){const t=new s.Z;return yield t.update(e),t.element},new((n=void 0)||(n=Promise))((function(e,s){function o(e){try{d(a.next(e))}catch(e){s(e)}}function r(e){try{d(a.throw(e))}catch(e){s(e)}}function d(t){var i;t.done?e(t.value):(i=t.value,i instanceof n?i:new n((function(e){e(i)}))).then(o,r)}d((a=a.apply(t,i||[])).next())}));var t,i,n,a}},9492:(e,t,i)=>{"use strict";i.d(t,{Z:()=>b});var s=i(2830),n=i(4755),a=i(3512),o=i(3442),r=i(6705),d=i(8580),l=i(1713),c=i(9687),h=i(2312),u=i(3114),p=i(7660),f=i(319),m=i(1507),g=i(5994),v=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};function b({photo:e,message:t,container:i,boxWidth:y,boxHeight:w,withTail:S,isOut:C,lazyLoadQueue:L,middleware:E,size:I,withoutPreloader:P,loadPromises:Z,autoDownloadSize:M,noBlur:k,noThumb:T,noFadeIn:x,blurAfter:A,managers:_=a.Z.managers,processUrl:F}){return v(this,void 0,void 0,(function*(){const a={loadPromises:{thumb:Promise.resolve(),full:Promise.resolve()},images:{thumb:null,full:null},preloader:null,aspecter:null},D="document"===e._,R=D&&e.mime_type.startsWith("image/")&&!I,B=(0,u.Z)(e);if(!(e.sizes||e.thumbs||B||R))return y&&w&&!I&&D&&(0,l.Z)(e,i,y,w,void 0,t),a;let N=0===M;I||(void 0===y&&(y=n.Z.active.regular.width),void 0===w&&(w=n.Z.active.regular.height)),i.classList.add("media-container");let O,U,H,z=i,j=!0,G=Promise.resolve();if(y&&w&&!I){const s=(0,l.Z)(e,i,y,w,void 0,t,void 0,R?{_:"photoSize",w:e.w,h:e.h,size:e.size,type:m.Pt}:void 0);if(I=s.photoSize,j=s.isFit,U=yield _.thumbsStorage.getCacheContext(e,I.type),!j&&!B){z=document.createElement("div"),z.classList.add("media-container-aspecter"),z.style.width=s.size.width+"px",z.style.height=s.size.height+"px";const n=(0,d.Z)(e,U,!k,!0);if(n){G=n.loadPromise;const e=n.image;e.classList.add("media-photo"),i.append(e)}else(yield b({container:i,message:t,photo:e,boxWidth:0,boxHeight:0,size:I,lazyLoadQueue:L,isOut:C,loadPromises:Z,middleware:E,withoutPreloader:P,withTail:S,autoDownloadSize:M,noBlur:k,noThumb:!0,blurAfter:!0,managers:_})).images.full.classList.add("media-photo","thumbnail");i.classList.add("media-container-fitted"),i.append(z)}}else I||(I=(0,c.Z)(e,y,w,!0)),U=yield _.thumbsStorage.getCacheContext(e,null==I?void 0:I.type);if(!T&&!B){const t=(0,d.Z)(e,U,!k);t&&(G=Promise.all([G,t.loadPromise]),a.loadPromises.thumb=a.loadPromises.full=G,O=a.images.thumb=t.image,O.classList.add("media-photo"),z.append(O))}if(a.aspecter=z,"photoSizeEmpty"===(null==I?void 0:I._)&&D||(null==I?void 0:I.bytes))return a;"videoSize"===(null==I?void 0:I._)?(H=a.images.full=(0,p.Z)(),H.autoplay=!0,H.loop=!0,H.muted=!0,H.classList.add("media-photo")):(H=a.images.full=new Image,H.classList.add("media-photo"));const V=(O||!U.downloaded)&&g.Z.isAvailable("animations")&&!x;let K;const W=null==t?void 0:t.uploadingFileName;P||(U.downloaded&&!W||(K=new o.Z({attachMethod:"prepend",isUpload:!!W})),W&&(K.attachPromise(h.Z.getUpload(W)),K.attach(i),N=void 0));const $=e=>(0,s.Z)(i,H,e,V,z,O),q=e=>v(this,void 0,void 0,(function*(){if(!E||E()){if(F&&(e=yield F(e)),A){const t=(0,r.Z)(e,12);return t.promise.then((()=>$(t.canvas.toDataURL())))}return $(e)}}));let Y;const Q=I.w>=150&&I.h>=150||N,X=()=>v(this,void 0,void 0,(function*(){N&&!P&&K&&(K.construct(),K.setManual());const t=(()=>{const t=R&&!I;return h.Z.downloadMediaURL({media:e,thumb:I,queueId:null==L?void 0:L.queueId,onlyCache:t?void 0:N})})(),s=yield _.thumbsStorage.getCacheContext(e,null==I?void 0:I.type);K&&!s.downloaded&&!P&&Q&&K.attach(i,!1,t),N=void 0;const n=t.then(q);return n.catch(f.Z),{download:t,render:n}}));return K&&K.setDownloadFunction(X),U.downloaded?G=Y=(yield X()).render:L?L.push({div:i,load:()=>X().then((({download:e})=>e))}):Y=(yield X()).render,Z&&G&&Z.push(G),yield G,a.loadPromises.thumb=G,a.loadPromises.full=Y||Promise.resolve(),a.preloader=K,a}))}},6700:(e,t,i)=>{"use strict";i.d(t,{Z:()=>o});var s=i(2064),n=i(5990),a=i(3484);function o(e,t,i,o,r){const d=new a.Z("reply",i),l=d.fill(e,t,o);if(r){const e=(0,n.Z)(r,!1),[t,i,a]=(0,s.oo)(e);d.container.style.setProperty("--override-color",`${t}, ${i}, ${a}`),d.container.classList.add("is-overriding-color")}return{container:d.container,fillPromise:l}}},5671:(e,t,i)=>{"use strict";i.d(t,{Z:()=>r});var s=i(2291),n=i(2325),a=i(3512),o=i(7362);function r(e){return t=this,i=void 0,d=function*(){const t=document.createElement("span");t.classList.add("sender-title");const i=e.fromId===a.Z.myId&&e.peerId!==a.Z.myId;if(t.append(i?(0,n.ag)("FromYou"):yield(0,o.Z)(Object.assign(Object.assign({},(0,s.Z)(e)),{dialog:e.peerId===a.Z.myId}))),(yield a.Z.managers.appPeersManager.isAnyGroup(e.peerId))||i){const i=yield(0,o.Z)({peerId:e.peerId});t.append(" ➝ ",i)}return t},new((r=void 0)||(r=Promise))((function(e,s){function n(e){try{o(d.next(e))}catch(e){s(e)}}function a(e){try{o(d.throw(e))}catch(e){s(e)}}function o(t){var i;t.done?e(t.value):(i=t.value,i instanceof r?i:new r((function(e){e(i)}))).then(n,a)}o((d=d.apply(t,i||[])).next())}));var t,i,r,d}},1604:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(632);function n(e){const t=document.createElement("span");return t.classList.add("sent-time"),t.append((0,s.zM)(new Date(1e3*e.date))),t}},3541:(e,t,i)=>{"use strict";i.d(t,{Vp:()=>R,ZP:()=>U,_2:()=>H,_i:()=>N});var s=i(5269),n=i(3725),a=i(3910),o=i(2738),r=i(7660),d=i(8497),l=i(6740),c=i(1046),h=i(1185),u=i(5471),p=i(9405),f=i(4755),m=i(925),g=i(3174),v=i(6724),b=i(9674),y=i(2312),w=i(7030),S=i(2790),C=i(9687),L=i(13),E=i(1447),I=i(3512),P=i(7730),Z=i(671),M=i(5814),k=i(9298),T=i(2796),x=i(6775),A=i(645),_=i(5994),F=i(1168),D=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};const R=1.49,B={},N={},O=(e,t,i)=>{const s=()=>{e.removeEventListener("animationend",s),t(),clearTimeout(n)};e.addEventListener("animationend",s);const n=setTimeout(s,i)};function U({doc:e,div:t,middleware:i,loadStickerMiddleware:d,lazyLoadQueue:m,exportLoad:v,group:w,play:S,onlyThumb:U,emoji:H,width:z,height:j,withThumb:G,loop:V,loadPromises:K,needFadeIn:W,needUpscale:$,skipRatio:q,static:Y,managers:Q=I.Z.managers,fullThumb:X,isOut:J,noPremium:ee,withLock:te,relativeEffect:ie,loopEffect:se,isCustomEmoji:ne,syncedVideo:ae,liteModeKey:oe,isEffect:re}){var de;return D(this,void 0,void 0,(function*(){t=Array.isArray(t)?t:[t],null!=oe||(oe="stickers_panel"),ne&&(H=e.stickerEmojiRaw);const I=e.sticker;if(1===I&&(Y=!0),!z&&!j){const t=f.Z.active,i=H?t.emojiSticker:e.animated?t.animatedSticker:t.staticSticker,s=(0,p.C)(e.w,e.h).aspectFitted(i);z=s.width,j=s.height}let le;2===I&&E.Z.loadLottieWorkers(),V=!(H&&!ne)&&V,t.forEach((t=>{t.dataset.docId=""+e.id,H&&(t.dataset.stickerEmoji=H),t.dataset.stickerPlay=""+ +(S||!1),t.dataset.stickerLoop=""+ +(V||!1),t.classList.add("media-sticker-wrapper")})),!S||_.Z.isAvailable(oe)||ne||re||(S=!1,V=!1);const ce=(t=(null==le?void 0:le.type))=>D(this,void 0,void 0,(function*(){return le=yield Q.thumbsStorage.getCacheContext(e,t)})),he=!Y&&(2===I||3===I),ue=(0,L.Z)(e);void 0!==J&&ue&&!J&&t.forEach((e=>e.classList.add("reflect-x")));const pe=ue&&te;if(pe){const i=B[e.id];t.forEach((e=>{e.classList.add("is-premium-sticker","tgico-premium_lock"),i&&e.style.setProperty("--lock-url",`url(${i})`)}))}if(Y&&1!==I){const t=(0,C.Z)(e,z,j,!1);yield ce(t.type)}else yield ce(null==X?void 0:X.type);const fe=H&&!ne?(0,Z.tB)(H):-1,me=le.downloaded&&!W,ge=he,ve=2===I||3===I?yield Q.appDocsManager.getLottieCachedThumb(e.id,fe):void 0,be={render:void 0,load:void 0};let ye=(0,n.Z)(),we=!1;if(((null===(de=e.thumbs)||void 0===de?void 0:de.length)||ve)&&!t[0].firstElementChild&&(!me||ge||U)&&!1!==G){let n=ve||e.thumbs[0];const a=(e,t)=>{e.childElementCount?ye.resolve():b.Z.mutateElement(e,(()=>{e.childElementCount||(t.classList.add("media-sticker","thumbnail"),e.append(t)),ye.resolve()}))};if("url"in n)we=!0,t.forEach((e=>{const t=new Image;(0,l.ZP)(t,n.url,(()=>a(e,t)))}));else if("bytes"in n){if("photoPathSize"===n._){n.bytes.length||(n=e.thumbs.find((e=>{var t;return null===(t=e.bytes)||void 0===t?void 0:t.length}))||n);const i=function(e){let t="M";for(let i=0,s=e.length;i<s;++i){const s=e[i];s>=192?t+="AACAAAAHAAALMAAAQASTAVAAAZaacaaaahaaalmaaaqastava.az0123456789-,"[s-128-64]:(s>=128?t+=",":s>=64&&(t+="-"),t+=""+(63&s))}return t+="z",t}(n.bytes),s="http://www.w3.org/2000/svg",a=document.createElementNS(s,"svg");a.classList.add("rlottie-vector","media-sticker","thumbnail"),a.setAttributeNS(null,"viewBox",`0 0 ${e.w||512} ${e.h||512}`);const o=document.createElementNS(s,"path");o.setAttributeNS(null,"d",i),_.Z.isAvailable("animations")&&!ne&&o.setAttributeNS(null,"fill","url(#g)"),a.append(o),t.forEach(((e,t)=>e.append(t>0?a.cloneNode(!0):a))),we=!0,ye.resolve()}else if(fe<=0){const o=()=>{t.forEach((t=>{const i=new Image,s=(0,h.Z)(e,n,!0);(0,l.ZP)(i,s,(()=>a(t,i)))}))};s.Z||e.pFlags.stickerThumbConverted||le.url?(we=!0,o()):(we=!0,P.Z.convert("main-"+e.id,n.bytes).then((s=>{Q.appDocsManager.saveWebPConvertedStrippedThumb(e.id,s),n.bytes=s,e.pFlags.stickerThumbConverted=!0,i&&!i()||t[0].childElementCount?ye.resolve():o()})).catch((()=>ye.resolve())))}}else if((2===I&&fe<=0||3===I)&&(G||U)){const s=()=>D(this,void 0,void 0,(function*(){if(t[0].childElementCount||i&&!i())return void ye.resolve();const s=(e,t,s)=>{e.childElementCount||i&&!i()?ye.resolve():s?(0,l.ZP)(t,s,(()=>a(e,t))):a(e,t)};yield ce(),t.forEach((t=>{if(le.url)s(t,new Image,le.url);else if("bytes"in n){const i=(0,c.Z)(e,n,!0);i.loadPromise.then((()=>s(t,i.image,"")))}else y.Z.downloadMediaURL({media:e,thumb:n}).then((e=>D(this,void 0,void 0,(function*(){return s(t,new Image,e)}))))}))}));if(m&&U)return m.push({div:t[0],load:s}),ye.resolve(),be;s(),n.url&&(we=!0)}}if(K&&we&&K.push(ye),U)return be;const Se=(0,u.Z)("MIDDLEWARE"),Ce=()=>D(this,void 0,void 0,(function*(){if(i&&!i())throw Se;if(2===I&&!Y){const s=yield y.Z.downloadMedia({media:e,queueId:null==m?void 0:m.queueId,thumb:X});if(i&&!i())throw Se;const n=yield E.Z.loadAnimationWorker({container:t[0],loop:V,autoplay:S,animationData:s,width:z,height:j,name:"doc"+e.id,needUpscale:$,skipRatio:q,toneIndex:fe,sync:ne,middleware:null!=d?d:i,group:w,liteModeKey:oe||void 0}),a=pe?()=>{var i,s;const a=null!==(i=B[s=e.id])&&void 0!==i?i:B[s]=function(e){var t;const i=e.getContext("2d"),s=20*(null!==(t=e.dpr)&&void 0!==t?t:1),n=s,a=s,o=(e.width-n)/2,r=e.height-a-0,d=i.getImageData(o,r,n,a).data;let l=0,c=0,h=0,u=0;for(let e=0;e<d.length;e+=4)l+=d[e],c+=d[e+1],h+=d[e+2],u+=d[e+3];const p=document.createElement("canvas");p.width=s,p.height=s;const f=p.getContext("2d"),m=new Uint8ClampedArray([255*l/u,255*c/u,255*h/u,255]),g=`rgba(${m[0]}, ${m[1]}, ${m[2]}, ${m[3]})`;return f.fillStyle=g,f.fillRect(0,0,p.width,p.height),f.fillStyle="rgba(112, 117, 121, 0.3)",f.fillRect(0,0,p.width,p.height),p.toDataURL("image/jpeg")}(n.canvas[0]);t.forEach((e=>e.style.setProperty("--lock-url",`url(${a})`)))}:void 0,o=(e,t)=>{const i=e.firstElementChild!==t&&e.firstElementChild;!1!==W&&(W=(W||!i||"svg"===i.tagName)&&_.Z.isAvailable("animations"));const s=()=>{i&&i!==t&&"DIV"!==i.tagName&&i.remove()};W?b.Z.mutate((()=>{t&&t.classList.add("fade-in"),i&&i.classList.add("fade-out"),O(t||i,(()=>{b.Z.mutate((()=>{t&&t.classList.remove("fade-in"),s()}))}),400)})):i&&b.Z.mutate(s)};return n.addEventListener("firstFrame",(()=>{const i=n.canvas[0];(!1!==G||ne)&&(0,g.O)(e,i,fe),pe&&a(),ne||t.forEach(((e,t)=>{o(e,n.canvas[t])}))}),{once:!0}),H&&Q.appStickersManager.preloadAnimatedEmojiStickerAnimation(H),n}if(Y||3===I){const s=he&&ae,n=s?A.Z.generateName(""+e.id,0,0,void 0,void 0):void 0,a=N[n];if(a)return a;const o=(s?t.slice(0,1):t).map((()=>{let e;if(Y)e=new Image;else{const t=e=(0,r.Z)();if(t.muted=!0,S&&(t.autoplay=!0),V&&(t.loop=!0),V&&"number"==typeof V){let i=0,s=0;function n(){i>this.currentTime&&++s===V&&(this.autoplay=!1,this.loop=!1,this.pause(),t.removeEventListener("timeupdate",n)),i=this.currentTime}t.addEventListener("timeupdate",n)}}return e.classList.add("media-sticker"),e})),c=t.map(((e,t)=>e.firstElementChild!==o[t]&&e.firstElementChild));!1!==W&&(W=(W||!me||(Y?c[0]:!c[0]||"svg"===c[0].tagName))&&_.Z.isAvailable("animations")),W&&o.forEach((e=>e.classList.add("fade-in")));const h=new Promise(((n,a)=>D(this,void 0,void 0,(function*(){const r=()=>D(this,void 0,void 0,(function*(){if(i&&!i())return void a(Se);const r=o.length,d=[];let h;yield ce(),t.forEach(((t,u)=>{const p=o[u];p&&(h=(0,l.cj)(p,le.url)),h.then((()=>((t,o,l)=>{b.Z.mutateElement(t,(()=>{if(!i||i())if(o){if(o){const t=z*window.devicePixelRatio,i=j*window.devicePixelRatio;if(!(0,g.k)(e,fe,t,i)){const s=document.createElement("canvas");s.width=t,s.height=i,s.getContext("2d").drawImage(o,0,0,s.width,s.height),(0,g.O)(e,s,fe)}}s?n(o):(t.append(o),W?(l&&l.classList.add("fade-out"),O(o,(()=>{o.classList.remove("fade-in"),null==l||l.remove()}),400)):null==l||l.remove(),he&&M.Z.addAnimation({animation:o,observeElement:t,group:w,controlled:i,liteModeKey:oe||void 0}),d.push(o)===r&&n(d))}else s&&he||null==l||l.remove();else a(Se)}))})(t,p,c[u])))}))}));if(yield ce(),le.url)r();else{let t;if(1!==I&&Y){const i=(0,C.Z)(e,z,j,!1);t=y.Z.downloadMediaURL({media:e,thumb:i,queueId:null==m?void 0:m.queueId})}else t=y.Z.downloadMediaURL({media:e,queueId:null==m?void 0:m.queueId});t.then(r,a)}}))));return n&&(N[n]=h,d&&h.finally((()=>{d()||delete N[n]}))),h}}));if(v&&(1===v&&(!me||he)||2===v))return be.load=Ce,be;const Le=!m||me&&!he?Ce():(m.push({div:t[0],load:Ce}),Promise.resolve());return me&&Y&&(ye=Le,K&&K.push(ye)),2===I&&ue&&void 0!==J&&!ee&&function({container:e,doc:t,managers:i,middleware:s,isOut:n,width:r,loadPromise:d,relativeEffect:l,loopEffect:c}){i.appStickersManager.preloadSticker(t.id,!0);let h=!1;(0,o.fc)(e,(i=>D(this,void 0,void 0,(function*(){const o=_.Z.isAvailable("effects_premiumstickers")||l;if((0,a.Z)(i),!i.isTrusted&&!o)return;if(h||!o){const e=document.createElement("a");return e.onclick=()=>{(0,T.PE)(),F.Z.createPopup(k.Z,t.stickerSetInput).show()},void(0,T.bC)({langPackKey:"Sticker.Premium.Click.Info",langPackArguments:[e]})}h=!0,yield d;const{animationDiv:u,stickerPromise:p}=(0,x.Z)({doc:t,middleware:s,side:n?"right":"left",size:r*R,target:e,play:!0,fullThumb:(0,L.Z)(t),relativeEffect:l,loopEffect:c});void 0===n||n||u.classList.add("reflect-x"),p.then((e=>{e.addEventListener("destroy",(()=>{h=!1}))}))}))))}({container:t[0],doc:e,managers:Q,middleware:i,isOut:J,width:z,loadPromise:Le,relativeEffect:ie,loopEffect:se}),be.render=Le,be}))}function H({event:e,container:t,managers:i,peerId:s,middleware:n}){var o,r,l,c,h,u;return D(this,void 0,void 0,(function*(){(0,a.Z)(e);const p=(0,d.Z)(t,"bubble"),f=t.dataset.stickerEmoji,g=t.classList.contains("custom-emoji")?void 0:E.Z.getAnimation(t);if(null==g?void 0:g.paused){const e=yield i.appStickersManager.getAnimatedEmojiSoundDocument(f);if(e){const i=document.createElement("audio");i.style.display="none",t.parentElement.append(i);try{const t=yield y.Z.downloadMediaURL({media:e});i.src=t,i.play(),yield(0,m.Z)(i,void 0,!0),i.addEventListener("ended",(()=>{i.src="",i.remove()}),{once:!0})}catch(e){}}g.autoplay=!0,g.restart()}if(!s.isUser()||!_.Z.isAvailable("effects_emoji"))return;const b=null!==(o=(c=t).activeAnimations)&&void 0!==o?o:c.activeAnimations=new Set;if(b.size>=3)return;const C=yield i.appStickersManager.getAnimatedEmojiSticker(f,!0);if(!C)return;const L=null!==(r=(h=t).emojiData)&&void 0!==r?r:h.emojiData={a:[],v:1},I=null!==(l=(u=t).sendInteractionThrottled)&&void 0!==l?l:u.sendInteractionThrottled=(0,v.Z)((()=>{if(!L.a.length)return;const e=L.a[0].t;L.a.forEach((t=>{t.t=(t.t-e)/1e3}));const s=(0,d.Z)(t,"bubble");i.appMessagesManager.setTyping(w.ZP.chat.peerId,{_:"sendMessageEmojiInteraction",msg_id:(0,S.Z)(+s.dataset.mid),emoticon:f,interaction:{_:"dataJSON",data:JSON.stringify(L)}},!0,w.ZP.chat.threadId),L.a.length=0}),1e3,!1),P={};b.add(P);const Z=p?p.classList.contains("is-out"):void 0,{animationDiv:M}=(0,x.Z)({doc:C,middleware:n,side:Z?"right":"left",size:360,target:t,play:!0,withRandomOffset:!0,onUnmount:()=>{b.delete(P)}});void 0===Z||Z||M.classList.add("reflect-x"),e.isTrusted&&(L.a.push({i:1,t:Date.now()}),I())}))}},6775:(e,t,i)=>{"use strict";i.d(t,{Z:()=>u});var s=i(2131),n=i(8938),a=i(8487),o=i(5471),r=i(3624),d=i(9966),l=i(241),c=i(7030),h=i(3541);function u({size:e,doc:t,middleware:i,target:u,side:p,skipRatio:f,play:m,managers:g,fullThumb:v,withRandomOffset:b,relativeEffect:y,loopEffect:w,onUnmount:S}){var C;const L=document.createElement("div");let E;L.classList.add("emoji-animation"),L.style.width=e+"px",L.style.height=e+"px";const I=()=>{P.clean(),null==E||E.remove(),L.remove(),c.ZP.chat.bubbles.scrollable.container.removeEventListener("scroll",A),null==S||S()},P=null!==(C=null==i?void 0:i.create())&&void 0!==C?C:(0,r.k)();i=P.get();const Z=(0,h.ZP)({div:L,doc:t,middleware:i,withThumb:!1,needFadeIn:!1,loop:!!w,width:e,height:e,play:m,group:"none",skipRatio:f,managers:g,fullThumb:v,isEffect:!0}).then((({render:e})=>e)).then((e=>{if((0,n.Z)(e),!i())throw e.remove(),(0,o.Z)("MIDDLEWARE");return E=e,E.addEventListener("enterFrame",(e=>{(w||e!==E.maxFrame)&&(0,a.Z)(u)||I()})),s.Z&&E.addEventListener("firstFrame",(()=>{navigator.vibrate(100)}),{once:!0}),E})),M=e=>{const t=Math.random()*e*2;return t>e?-t%e:t},k=b?M(16):0,T=b?M(4):0,x=()=>{if(!(0,a.Z)(u))return void I();const t=u.getBoundingClientRect(),i=t.width/200,s="center"===p?0:16*("right"===p?1:-1)*i,n="center"===p?0:0*i,o="right"===p?t.right:t.left,r=t.top,d=("center"===p?(t.width-e)/2:"right"===p?-e:0)+s+k,c=(t.height-e)/2+n+T,h=o+d,f=r+c;f<=-e||f>=l.Z.height?I():y?("center"!==p?L.style[p]=-1*Math.abs(s)+"px":L.style.left=d+"px",L.style.top=c+"px"):(L.style.top=f+"px",L.style.left=h+"px")},A=(0,d.Z)(x);return c.ZP.chat.bubbles.scrollable.container.addEventListener("scroll",A),x(),y?(L.classList.add("is-relative"),u.parentElement.append(L)):c.ZP.emojiAnimationContainer.append(L),{animationDiv:L,stickerPromise:Z}}},5772:(e,t,i)=>{"use strict";i.d(t,{Z:()=>a});var s=i(3512),n=i(3541);function a(e){return t=this,i=void 0,o=function*(){const{emoji:t,div:i,managers:a=s.Z.managers}=e,o=yield a.appStickersManager.getAnimatedEmojiSticker(t);if(!o)throw i.classList.add("media-sticker-wrapper"),new Error("no sticker");return(0,n.ZP)(Object.assign({doc:o,play:!0,loop:!1},e))},new((a=void 0)||(a=Promise))((function(e,s){function n(e){try{d(o.next(e))}catch(e){s(e)}}function r(e){try{d(o.throw(e))}catch(e){s(e)}}function d(t){var i;t.done?e(t.value):(i=t.value,i instanceof a?i:new a((function(e){e(i)}))).then(n,r)}d((o=o.apply(t,i||[])).next())}));var t,i,a,o}},1273:(e,t,i)=>{"use strict";i.d(t,{Z:()=>h});var s=i(7660),n=i(6740),a=i(2312),o=i(1447),r=i(3512),d=i(5814),l=i(3541),c=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};function h({set:e,lazyLoadQueue:t,container:i,group:h,autoplay:u,width:p,height:f,managers:m=r.Z.managers,middleware:g}){var v;return c(this,void 0,void 0,(function*(){if(null===(v=e.thumbs)||void 0===v?void 0:v.length)return i.classList.add("media-sticker-wrapper"),void t.push({div:i,load:()=>c(this,void 0,void 0,(function*(){const t=yield m.appStickersManager.getStickerSetThumbDownloadOptions(e),r=a.Z.download(t);if(e.pFlags.animated&&!e.pFlags.videos)return r.then((t=>{o.Z.loadAnimationWorker({container:i,loop:!0,autoplay:u,animationData:t,width:p,height:f,needUpscale:!0,name:"setThumb"+e.id,group:h,middleware:g})}));{let t;return e.pFlags.videos?(t=(0,s.Z)(),t.autoplay=!0,t.muted=!0,t.loop=!0):t=new Image,t.classList.add("media-sticker"),r.then((s=>{(0,n.ZP)(t,URL.createObjectURL(s),(()=>{i.append(t),e.pFlags.videos&&d.Z.addAnimation({animation:t,group:h})}))}))}}))});let r;r=e.thumb_document_id?m.appEmojiManager.getCustomEmojiDocument(e.thumb_document_id):m.appStickersManager.getStickerSet(e).then((e=>e.documents[0]));const b=yield r;"documentEmpty"!==b._&&(0,l.ZP)({doc:b,div:i,group:h,lazyLoadQueue:t,managers:m,width:p,height:f,middleware:g})}))}},62:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(3541);function n({doc:e,row:t,size:i,managers:n}){const a=t.media,o=t.createMedia("small");a&&o.classList.add("hide");const r=a?[]:void 0,d="small"===i?32:48,l=(0,s.ZP)({div:o,doc:e,width:d,height:d,loadPromises:r,managers:n}).then((({render:e})=>e));return r&&Promise.all(r).then((()=>{o.classList.remove("hide"),a.remove()})),l}},9102:(e,t,i)=>{"use strict";i.d(t,{Z:()=>o});var s=i(2790),n=i(4497),a=i(7362);function o(e){return t=this,i=void 0,r=function*(){const{peerId:t,threadId:i,lastMsgId:o}=e,r=Promise.resolve(),d=(0,n.Z)("t.me/c/"+t.toChatId()+(i?"/"+(0,s.Z)(i):"")+(o?"/"+(0,s.Z)(o):""));return d.classList.add("topic-name","topic-name-button"),d.append(yield(0,a.Z)(e)),{cached:!0,element:d,loadPromise:r}},new((o=void 0)||(o=Promise))((function(e,s){function n(e){try{d(r.next(e))}catch(e){s(e)}}function a(e){try{d(r.throw(e))}catch(e){s(e)}}function d(t){var i;t.done?e(t.value):(i=t.value,i instanceof o?i:new o((function(e){e(i)}))).then(n,a)}d((r=r.apply(t,i||[])).next())}));var t,i,o,r}},2887:(e,t,i)=>{"use strict";i.d(t,{Z:()=>A});var s=i(4762),n=i(5296),a=i(3725),o=i(3910),r=i(2738),d=i(7660),l=i(8487),c=i(6740),h=i(8580),u=i(5994),p=i(5471),f=i(4755),m=i(319),g=i(925),v=i(3035),b=i(6724),y=i(9674),w=i(5157),S=i(2312),C=i(7030),L=i(1507),E=i(3512),I=i(5814),P=i(3013),Z=i(8448),M=i(3442),k=i(9492),T=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};let x=0;function A({doc:e,container:t,message:i,boxWidth:A,boxHeight:_,withTail:F,isOut:D,middleware:R,lazyLoadQueue:B,noInfo:N,group:O,onlyPreview:U,noPreview:H,withoutPreloader:z,loadPromises:j,noPlayButton:G,photoSize:V,videoSize:K,searchContext:W,autoDownload:$,managers:q=E.Z.managers,noAutoplayAttribute:Y}){var Q;return T(this,void 0,void 0,(function*(){const E=null==$?void 0:$.video;let X=0===E;const J=!(A&&_),ee=("video"!==e.type||e.size<=52428800&&!J)&&("gif"===e.type?u.Z.isAvailable("gif"):u.Z.isAvailable("video"));let te,ie;if(!N){te=document.createElement("span"),te.classList.add("video-time"),t.append(te);let i=!1;"gif"!==e.type?(te.innerText=(0,w.Z)(e.duration,!1),G||"round"===e.type||(ee&&!X?te.classList.add("tgico","can-autoplay"):i=!0)):(te.innerText="GIF",ee||G||(i=!0,X=void 0)),i&&(ie=document.createElement("span"),ie.classList.add("video-play","tgico-largeplay","btn-circle","position-center"),t.append(ie))}const se={};if("image/gif"===e.mime_type){const s=yield(0,k.Z)({photo:e,message:i,container:t,boxWidth:A,boxHeight:_,withTail:F,isOut:D,lazyLoadQueue:B,middleware:R,withoutPreloader:z,loadPromises:j,autoDownloadSize:E,size:V,managers:q});return se.thumb=s,se.loadPromise=s.loadPromises.full,se}let ne;const ae=(0,d.Z)();if(ae.classList.add("media-video"),ae.muted=!0,"round"===e.type){const s=document.createElement("div");s.classList.add("media-round","z-depth-1"),s.dataset.mid=""+i.mid,s.dataset.peerId=""+i.peerId,s.message=i;const a=f.Z.active.round,d=a.width/2,c=3.5,h=d-2*c;s.innerHTML=`<svg class="progress-ring" width="${a.width}" height="${a.width}" style="transform: rotate(-90deg);">\n <circle class="progress-ring__circle" stroke="white" stroke-opacity="0.3" stroke-width="${c}" cx="${d}" cy="${d}" r="${h}" fill="transparent"/>\n </svg>`;const u=s.firstElementChild.firstElementChild;x||(x=2*Math.PI*h),u.style.strokeDasharray=x+" "+x,u.style.strokeDashoffset=""+x,te.classList.add("tgico"),i.pFlags.media_unread&&s.classList.add("is-unread");const p=document.createElement("canvas");p.width=p.height=e.w,s.prepend(p,te),s.append(ae),t.append(s);const m=p.getContext("2d"),g=()=>{const e=s.message,t=P.Z.addMedia(e,!X),i=()=>{(C.ZP.chat.setPeerPromise||Promise.resolve()).finally((()=>{(0,l.Z)(t)||(t.removeEventListener("play",h),t.removeEventListener("timeupdate",c),t.removeEventListener("pause",f),t.removeEventListener("ended",g))}))},a=()=>{m.drawImage(t,0,0);const e=x-t.currentTime/t.duration*x;return u.style.strokeDashoffset=""+e,!t.paused},d=()=>{t.duration&&((0,l.Z)(t)?(t.paused&&a(),te.innerText=(0,w.Z)(t.duration-t.currentTime,!1)):i())},c=(0,b.Z)((()=>{(0,v.T2)(d)}),1e3,!1),h=()=>{ae.classList.add("hide"),s.classList.remove("is-paused"),(0,n.cK)(a,p),ne&&ne.preloader&&ne.preloader.classList.contains("manual")&&ne.onClick()},f=()=>{(0,l.Z)(t)?s.classList.add("is-paused"):i()},g=()=>{ae.classList.remove("hide"),s.classList.add("is-paused"),ae.currentTime=0,te.innerText=(0,w.Z)(t.duration,!1),t.currentTime&&(t.currentTime=0)};t.addEventListener("play",h),t.addEventListener("timeupdate",c),t.addEventListener("pause",f),t.addEventListener("ended",g),(0,r.fc)(p,(i=>{if((0,o.Z)(i),ne&&!ne.detached&&ne.onClick(),t.paused){const i=!!W;if(P.Z.setSearchContext(W||{peerId:L.NM,inputFilter:{_:"inputMessagesFilterEmpty"},useSearch:!1})){const[t,n]=i?(0,Z.ns)(s,e.mid):[];P.Z.setTargets({peerId:e.peerId,mid:e.mid},t,n)}t.play()}else t.pause()})),t.paused?t.duration&&t.currentTime!==t.duration&&t.currentTime>0?(a(),d(),ae.classList.add("hide")):f():h()};i.pFlags.is_outgoing?(s.onLoad=g,s.dataset.isOutgoing="1"):g()}else Y||(ae.autoplay=!0);let oe,re;if(i){if(oe=yield(0,k.Z)({photo:e,message:i,container:t,boxWidth:A,boxHeight:_,withTail:F,isOut:D,lazyLoadQueue:B,middleware:R,withoutPreloader:!0,loadPromises:j,autoDownloadSize:null==$?void 0:$.photo,size:V,managers:q}),se.thumb=oe,!ee&&"gif"!==e.type||U)return se.loadPromise=oe.loadPromises.full,se;if(F){const e=(oe.images.thumb||oe.images.full).parentElement;ae.width=+e.getAttributeNS(null,"width"),ae.height=+e.getAttributeNS(null,"height"),e.append(ae)}}else if(!H){const i=(0,h.Z)(e,{},!0);if(i){const e=i.image;e.classList.add("media-poster"),t.append(e),se.thumb={loadPromises:{thumb:i.loadPromise,full:Promise.resolve()},images:{thumb:e,full:null},preloader:null,aspecter:null},null==j||j.push(i.loadPromise),se.loadPromise=i.loadPromise}}if(U)return se;!ae.parentElement&&t&&((null==oe?void 0:oe.aspecter)||t).append(ae);const de=()=>T(this,void 0,void 0,(function*(){return re=yield q.thumbsStorage.getCacheContext(e,null==K?void 0:K.type)}));yield de();const le=null==i?void 0:i.uploadingFileName;le?(ne=new M.Z({attachMethod:"prepend",isUpload:!0}),ne.attachPromise(S.Z.getUpload(le)),ne.attach(t,!1),X=void 0):re.downloaded||e.supportsStreaming||z?e.supportsStreaming&&(ne=new M.Z({cancelable:!1,attachMethod:"prepend"})):ne=new M.Z({attachMethod:"prepend"});const ce=(0,a.Z)();if(ae.addEventListener("error",(e=>{4!==ae.error.code&&console.error("Error "+ae.error.code+"; details: "+ae.error.message),ne&&!le&&ne.detach(),ce.isFulfilled||ce.resolve()}),{once:!0}),"video"===e.type){const e=()=>{ae.duration&&(te.innerText=(0,w.Z)(ae.duration-ae.currentTime,!1))},t=(0,b.Z)((()=>{(0,v.T2)(e)}),1e3,!1);ae.addEventListener("timeupdate",t),ie&&ae.addEventListener("timeupdate",(()=>{y.Z.mutateElement(ie,(()=>{ie.remove()}))}),{once:!0})}ae.muted=!0,ae.loop=!0,Y||(ae.autoplay=!0);let he=X&&(null===(Q=null==oe?void 0:oe.preloader)||void 0===Q?void 0:Q.loadFunc);const ue=()=>T(this,void 0,void 0,(function*(){ne&&X&&!z&&(ne.construct(),ne.setManual()),yield de();let n=Promise.resolve();if(ne&&!le||z)if(re.downloaded||e.supportsStreaming)e.supportsStreaming&&(X?n=Promise.reject((0,p.Z)("NO_AUTO_DOWNLOAD")):!re.downloaded&&ne&&(ne.attach(t,!1,null),ae.addEventListener(s.IS_SAFARI?"timeupdate":"canplay",(()=>{ne.detach()}),{once:!0})));else{const i=n=S.Z.downloadMediaURL({media:e,queueId:null==B?void 0:B.queueId,onlyCache:X,thumb:K});ne&&ne.attach(t,!1,i)}return!X&&he&&(he(),he=null),X=void 0,n.then((()=>T(this,void 0,void 0,(function*(){!R||R()?("round"===e.type&&P.Z.resolveWaitingForLoadMedia(i.peerId,i.mid,i.pFlags.is_scheduled),yield de(),(0,g.Z)(ae).then((()=>{O&&I.Z.addAnimation({animation:ae,group:O}),ne&&!le&&ne.detach(),ce.resolve()}),(e=>{console.error("video load error",e),te&&te.classList.add("is-error"),ce.reject(e)})),(0,c.ZP)(ae,re.url)):ce.resolve()}))),m.Z),{download:n,render:Promise.all([n,ce])}}));return ne&&!le&&ne.setDownloadFunction(ue),t.preloader=ne,"gif"!==e.type||ee?se.loadPromise=B?(B.push({div:t,load:()=>ue().then((({render:e})=>e))}),Promise.resolve()):(yield ue()).render:(0,r.fc)(t,(e=>{(0,o.Z)(e),ie.remove(),ue()}),{capture:!0,once:!0}),se.thumb&&(yield se.thumb.loadPromises.thumb),se}))}f.Z.addEventListener("changeScreen",((e,t)=>{if(t===f._.mobile||e===f._.mobile){const e=Array.from(document.querySelectorAll(".media-round .progress-ring")),t=f.Z.active.round.width,i=t/2,s=i-7;x=2*Math.PI*s,e.forEach((e=>{e.setAttributeNS(null,"width",""+t),e.setAttributeNS(null,"height",""+t);const n=e.firstElementChild;n.setAttributeNS(null,"cx",""+i),n.setAttributeNS(null,"cy",""+i),n.setAttributeNS(null,"r",""+s),n.style.strokeDasharray=x+" "+x,n.style.strokeDashoffset=""+x}))}}))},2498:(e,t,i)=>{"use strict";i.d(t,{Z:()=>a});var s=i(8456),n=i(5400);function a(e){const t=(0,s.Z)(e.description||"",150,180);return(0,n.ZP)(t)}},1336:(e,t,i)=>{"use strict";i.d(t,{Z:()=>a});var s=i(8456),n=i(5400);function a(e){let t=e.title||e.author||e.site_name||"";return t=(0,s.Z)(t,80,100),(0,n.ZP)(t,{noLinks:!0,noLinebreaks:!0})}},7445:(e,t,i)=>{"use strict";i.d(t,{Z:()=>s});const s={AED:{code:"AED",title:"United Arab Emirates Dirham",symbol:"AED",native:"د.إ.",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!0,exp:2,min_amount:"367",max_amount:"3673030"},AFN:{code:"AFN",title:"Afghan Afghani",symbol:"AFN",native:"؋",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!1,exp:2,min_amount:"8729",max_amount:"87299487"},ALL:{code:"ALL",title:"Albanian Lek",symbol:"ALL",native:"Lek",thousands_sep:".",decimal_sep:",",symbol_left:!1,space_between:!1,exp:2,min_amount:"11842",max_amount:"118421187"},AMD:{code:"AMD",title:"Armenian Dram",symbol:"AMD",native:"դր.",thousands_sep:",",decimal_sep:".",symbol_left:!1,space_between:!0,exp:2,min_amount:"40943",max_amount:"409436718"},ARS:{code:"ARS",title:"Argentine Peso",symbol:"ARS",native:"$",thousands_sep:".",decimal_sep:",",symbol_left:!0,space_between:!0,exp:2,min_amount:"14705",max_amount:"147059002"},AUD:{code:"AUD",title:"Australian Dollar",symbol:"AU$",native:"$",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!1,exp:2,min_amount:"153",max_amount:"1536825"},AZN:{code:"AZN",title:"Azerbaijani Manat",symbol:"AZN",native:"ман.",thousands_sep:" ",decimal_sep:",",symbol_left:!1,space_between:!0,exp:2,min_amount:"169",max_amount:"1699858"},BAM:{code:"BAM",title:"Bosnia & Herzegovina Convertible Mark",symbol:"BAM",native:"KM",thousands_sep:".",decimal_sep:",",symbol_left:!1,space_between:!0,exp:2,min_amount:"199",max_amount:"1990677"},BDT:{code:"BDT",title:"Bangladeshi Taka",symbol:"BDT",native:"৳",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!0,exp:2,min_amount:"10009",max_amount:"100094046"},BGN:{code:"BGN",title:"Bulgarian Lev",symbol:"BGN",native:"лв.",thousands_sep:" ",decimal_sep:",",symbol_left:!1,space_between:!0,exp:2,min_amount:"199",max_amount:"1993315"},BND:{code:"BND",title:"Brunei Dollar",symbol:"BND",native:"$",thousands_sep:".",decimal_sep:",",symbol_left:!0,space_between:!1,exp:2,min_amount:"142",max_amount:"1421883"},BOB:{code:"BOB",title:"Bolivian Boliviano",symbol:"BOB",native:"Bs",thousands_sep:".",decimal_sep:",",symbol_left:!0,space_between:!0,exp:2,min_amount:"683",max_amount:"6832607"},BRL:{code:"BRL",title:"Brazilian Real",symbol:"R$",native:"R$",thousands_sep:".",decimal_sep:",",symbol_left:!0,space_between:!0,exp:2,min_amount:"539",max_amount:"5397799"},BYN:{code:"BYN",title:"Belarusian ruble",symbol:"BYN",native:"BYN",thousands_sep:" ",decimal_sep:",",symbol_left:!1,space_between:!0,exp:2,min_amount:"249",max_amount:"2495801"},CAD:{code:"CAD",title:"Canadian Dollar",symbol:"CA$",native:"$",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!1,exp:2,min_amount:"136",max_amount:"1366860"},CHF:{code:"CHF",title:"Swiss Franc",symbol:"CHF",native:"CHF",thousands_sep:"'",decimal_sep:".",symbol_left:!1,space_between:!0,exp:2,min_amount:"97",max_amount:"976705"},CLP:{code:"CLP",title:"Chilean Peso",symbol:"CLP",native:"$",thousands_sep:".",decimal_sep:",",symbol_left:!0,space_between:!0,exp:0,min_amount:"963",max_amount:"9637495"},CNY:{code:"CNY",title:"Chinese Renminbi Yuan",symbol:"CN¥",native:"CN¥",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!1,exp:2,min_amount:"709",max_amount:"7094102"},COP:{code:"COP",title:"Colombian Peso",symbol:"COP",native:"$",thousands_sep:".",decimal_sep:",",symbol_left:!0,space_between:!0,exp:2,min_amount:"452870",max_amount:"4528700000"},CRC:{code:"CRC",title:"Costa Rican Colón",symbol:"CRC",native:"₡",thousands_sep:".",decimal_sep:",",symbol_left:!0,space_between:!1,exp:2,min_amount:"62506",max_amount:"625061070"},CZK:{code:"CZK",title:"Czech Koruna",symbol:"CZK",native:"Kč",thousands_sep:" ",decimal_sep:",",symbol_left:!1,space_between:!0,exp:2,min_amount:"2497",max_amount:"24975029"},DKK:{code:"DKK",title:"Danish Krone",symbol:"DKK",native:"kr",thousands_sep:"",decimal_sep:",",symbol_left:!1,space_between:!0,exp:2,min_amount:"755",max_amount:"7555990"},DOP:{code:"DOP",title:"Dominican Peso",symbol:"DOP",native:"$",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!1,exp:2,min_amount:"5275",max_amount:"52757308"},DZD:{code:"DZD",title:"Algerian Dinar",symbol:"DZD",native:"د.ج.",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!0,exp:2,min_amount:"14035",max_amount:"140353307"},EGP:{code:"EGP",title:"Egyptian Pound",symbol:"EGP",native:"ج.م.",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!0,exp:2,min_amount:"1953",max_amount:"19537405"},ETB:{code:"ETB",title:"Ethiopian Birr",symbol:"ETB",native:"ብር",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!1,exp:2,min_amount:"5224",max_amount:"52247069"},EUR:{code:"EUR",title:"Euro",symbol:"€",native:"€",thousands_sep:" ",decimal_sep:",",symbol_left:!1,space_between:!0,exp:2,min_amount:"101",max_amount:"1016045"},GBP:{code:"GBP",title:"British Pound",symbol:"£",native:"£",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!1,exp:2,min_amount:"89",max_amount:"894445"},GEL:{code:"GEL",title:"Georgian Lari",symbol:"GEL",native:"GEL",thousands_sep:" ",decimal_sep:",",symbol_left:!1,space_between:!0,exp:2,min_amount:"283",max_amount:"2830234"},GTQ:{code:"GTQ",title:"Guatemalan Quetzal",symbol:"GTQ",native:"Q",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!1,exp:2,min_amount:"778",max_amount:"7781323"},HKD:{code:"HKD",title:"Hong Kong Dollar",symbol:"HK$",native:"$",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!1,exp:2,min_amount:"784",max_amount:"7849750"},HNL:{code:"HNL",title:"Honduran Lempira",symbol:"HNL",native:"L",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!0,exp:2,min_amount:"2441",max_amount:"24413729"},HRK:{code:"HRK",title:"Croatian Kuna",symbol:"HRK",native:"kn",thousands_sep:".",decimal_sep:",",symbol_left:!1,space_between:!0,exp:2,min_amount:"764",max_amount:"7648805"},HUF:{code:"HUF",title:"Hungarian Forint",symbol:"HUF",native:"Ft",thousands_sep:" ",decimal_sep:",",symbol_left:!1,space_between:!0,exp:2,min_amount:"42685",max_amount:"426850229"},IDR:{code:"IDR",title:"Indonesian Rupiah",symbol:"IDR",native:"Rp",thousands_sep:".",decimal_sep:",",symbol_left:!0,space_between:!1,exp:2,min_amount:"1523370",max_amount:"15233700000"},ILS:{code:"ILS",title:"Israeli New Sheqel",symbol:"₪",native:"₪",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!0,exp:2,min_amount:"354",max_amount:"3543350"},INR:{code:"INR",title:"Indian Rupee",symbol:"₹",native:"₹",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!1,exp:2,min_amount:"8155",max_amount:"81555550"},ISK:{code:"ISK",title:"Icelandic Króna",symbol:"ISK",native:"kr",thousands_sep:".",decimal_sep:",",symbol_left:!1,space_between:!0,exp:0,min_amount:"142",max_amount:"1425603"},JMD:{code:"JMD",title:"Jamaican Dollar",symbol:"JMD",native:"$",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!1,exp:2,min_amount:"15013",max_amount:"150131044"},JPY:{code:"JPY",title:"Japanese Yen",symbol:"¥",native:"¥",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!1,exp:0,min_amount:"144",max_amount:"1443065"},KES:{code:"KES",title:"Kenyan Shilling",symbol:"KES",native:"Ksh",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!1,exp:2,min_amount:"12075",max_amount:"120750271"},KGS:{code:"KGS",title:"Kyrgyzstani Som",symbol:"KGS",native:"KGS",thousands_sep:" ",decimal_sep:"-",symbol_left:!1,space_between:!0,exp:2,min_amount:"8018",max_amount:"80182898"},KRW:{code:"KRW",title:"South Korean Won",symbol:"₩",native:"₩",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!1,exp:0,min_amount:"1431",max_amount:"14315201"},KZT:{code:"KZT",title:"Kazakhstani Tenge",symbol:"KZT",native:"₸",thousands_sep:" ",decimal_sep:"-",symbol_left:!0,space_between:!1,exp:2,min_amount:"47186",max_amount:"471867112"},LBP:{code:"LBP",title:"Lebanese Pound",symbol:"LBP",native:"ل.ل.",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!0,exp:2,min_amount:"150999",max_amount:"1509998778"},LKR:{code:"LKR",title:"Sri Lankan Rupee",symbol:"LKR",native:"රු.",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!0,exp:2,min_amount:"35546",max_amount:"355469651"},MAD:{code:"MAD",title:"Moroccan Dirham",symbol:"MAD",native:"د.م.",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!0,exp:2,min_amount:"1093",max_amount:"10938136"},MDL:{code:"MDL",title:"Moldovan Leu",symbol:"MDL",native:"MDL",thousands_sep:",",decimal_sep:".",symbol_left:!1,space_between:!0,exp:2,min_amount:"1926",max_amount:"19264439"},MNT:{code:"MNT",title:"Mongolian Tögrög",symbol:"MNT",native:"MNT",thousands_sep:" ",decimal_sep:",",symbol_left:!0,space_between:!1,exp:2,min_amount:"322444",max_amount:"3224442056"},MUR:{code:"MUR",title:"Mauritian Rupee",symbol:"MUR",native:"MUR",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!1,exp:2,min_amount:"4453",max_amount:"44535174"},MVR:{code:"MVR",title:"Maldivian Rufiyaa",symbol:"MVR",native:"MVR",thousands_sep:",",decimal_sep:".",symbol_left:!1,space_between:!0,exp:2,min_amount:"1546",max_amount:"15460397"},MXN:{code:"MXN",title:"Mexican Peso",symbol:"MX$",native:"$",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!1,exp:2,min_amount:"2012",max_amount:"20122860"},MYR:{code:"MYR",title:"Malaysian Ringgit",symbol:"MYR",native:"RM",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!1,exp:2,min_amount:"463",max_amount:"4632502"},MZN:{code:"MZN",title:"Mozambican Metical",symbol:"MZN",native:"MTn",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!1,exp:2,min_amount:"6382",max_amount:"63829729"},NGN:{code:"NGN",title:"Nigerian Naira",symbol:"NGN",native:"₦",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!1,exp:2,min_amount:"43203",max_amount:"432039828"},NIO:{code:"NIO",title:"Nicaraguan Córdoba",symbol:"NIO",native:"C$",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!0,exp:2,min_amount:"3556",max_amount:"35566412"},NOK:{code:"NOK",title:"Norwegian Krone",symbol:"NOK",native:"kr",thousands_sep:" ",decimal_sep:",",symbol_left:!0,space_between:!0,exp:2,min_amount:"1069",max_amount:"10690975"},NPR:{code:"NPR",title:"Nepalese Rupee",symbol:"NPR",native:"नेरू",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!1,exp:2,min_amount:"12954",max_amount:"129546657"},NZD:{code:"NZD",title:"New Zealand Dollar",symbol:"NZ$",native:"$",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!1,exp:2,min_amount:"174",max_amount:"1746220"},PAB:{code:"PAB",title:"Panamanian Balboa",symbol:"PAB",native:"B/.",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!0,exp:2,min_amount:"98",max_amount:"988722"},PEN:{code:"PEN",title:"Peruvian Nuevo Sol",symbol:"PEN",native:"S/.",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!0,exp:2,min_amount:"390",max_amount:"3902208"},PHP:{code:"PHP",title:"Philippine Peso",symbol:"PHP",native:"₱",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!1,exp:2,min_amount:"5862",max_amount:"58627496"},PKR:{code:"PKR",title:"Pakistani Rupee",symbol:"PKR",native:"₨",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!1,exp:2,min_amount:"22642",max_amount:"226426805"},PLN:{code:"PLN",title:"Polish Złoty",symbol:"PLN",native:"zł",thousands_sep:" ",decimal_sep:",",symbol_left:!1,space_between:!0,exp:2,min_amount:"493",max_amount:"4932350"},PYG:{code:"PYG",title:"Paraguayan Guaraní",symbol:"PYG",native:"₲",thousands_sep:".",decimal_sep:",",symbol_left:!0,space_between:!0,exp:0,min_amount:"6977",max_amount:"69772317"},QAR:{code:"QAR",title:"Qatari Riyal",symbol:"QAR",native:"ر.ق.",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!0,exp:2,min_amount:"364",max_amount:"3640989"},RON:{code:"RON",title:"Romanian Leu",symbol:"RON",native:"RON",thousands_sep:".",decimal_sep:",",symbol_left:!1,space_between:!0,exp:2,min_amount:"502",max_amount:"5028645"},RSD:{code:"RSD",title:"Serbian Dinar",symbol:"RSD",native:"дин.",thousands_sep:".",decimal_sep:",",symbol_left:!1,space_between:!0,exp:2,min_amount:"11918",max_amount:"119184990"},RUB:{code:"RUB",title:"Russian Ruble",symbol:"RUB",native:"₽",thousands_sep:" ",decimal_sep:",",symbol_left:!1,space_between:!0,exp:2,min_amount:"7128",max_amount:"71281218"},SAR:{code:"SAR",title:"Saudi Riyal",symbol:"SAR",native:"ر.س.",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!0,exp:2,min_amount:"375",max_amount:"3756546"},SEK:{code:"SEK",title:"Swedish Krona",symbol:"SEK",native:"kr",thousands_sep:".",decimal_sep:",",symbol_left:!1,space_between:!0,exp:2,min_amount:"1109",max_amount:"11094972"},SGD:{code:"SGD",title:"Singapore Dollar",symbol:"SGD",native:"$",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!1,exp:2,min_amount:"143",max_amount:"1430495"},THB:{code:"THB",title:"Thai Baht",symbol:"฿",native:"฿",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!1,exp:2,min_amount:"3780",max_amount:"37800497"},TJS:{code:"TJS",title:"Tajikistani Somoni",symbol:"TJS",native:"TJS",thousands_sep:" ",decimal_sep:";",symbol_left:!1,space_between:!0,exp:2,min_amount:"975",max_amount:"9753854"},TRY:{code:"TRY",title:"Turkish Lira",symbol:"TRY",native:"TL",thousands_sep:".",decimal_sep:",",symbol_left:!1,space_between:!0,exp:2,min_amount:"1854",max_amount:"18543598"},TTD:{code:"TTD",title:"Trinidad and Tobago Dollar",symbol:"TTD",native:"$",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!1,exp:2,min_amount:"672",max_amount:"6722681"},TWD:{code:"TWD",title:"New Taiwan Dollar",symbol:"NT$",native:"NT$",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!1,exp:2,min_amount:"3173",max_amount:"31738502"},TZS:{code:"TZS",title:"Tanzanian Shilling",symbol:"TZS",native:"TSh",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!1,exp:2,min_amount:"233199",max_amount:"2331999890"},UAH:{code:"UAH",title:"Ukrainian Hryvnia",symbol:"UAH",native:"₴",thousands_sep:" ",decimal_sep:",",symbol_left:!1,space_between:!1,exp:2,min_amount:"3633",max_amount:"36338830"},UGX:{code:"UGX",title:"Ugandan Shilling",symbol:"UGX",native:"USh",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!1,exp:0,min_amount:"3816",max_amount:"38166726"},USD:{code:"USD",title:"United States Dollar",symbol:"$",native:"$",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!1,exp:2,min_amount:"100",max_amount:1e6},UYU:{code:"UYU",title:"Uruguayan Peso",symbol:"UYU",native:"$",thousands_sep:".",decimal_sep:",",symbol_left:!0,space_between:!0,exp:2,min_amount:"4080",max_amount:"40801205"},UZS:{code:"UZS",title:"Uzbekistani Som",symbol:"UZS",native:"UZS",thousands_sep:" ",decimal_sep:",",symbol_left:!1,space_between:!0,exp:2,min_amount:"1089058",max_amount:"10890583014"},VND:{code:"VND",title:"Vietnamese Đồng",symbol:"₫",native:"₫",thousands_sep:".",decimal_sep:",",symbol_left:!1,space_between:!0,exp:0,min_amount:"23862",max_amount:"238625000"},YER:{code:"YER",title:"Yemeni Rial",symbol:"YER",native:"ر.ي.",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!0,exp:2,min_amount:"25030",max_amount:"250300677"},ZAR:{code:"ZAR",title:"South African Rand",symbol:"ZAR",native:"R",thousands_sep:",",decimal_sep:".",symbol_left:!0,space_between:!0,exp:2,min_amount:"1789",max_amount:"17894299"}}},3447:(e,t,i)=>{"use strict";i.d(t,{Z:()=>a,i:()=>s});const s={14:{"1f6dd":4867,"1f6de":4916,"1f6df":4923,"1f7f0":62832,"1f979":183,"1f9cc":1557,"1fa7b":61332,"1fa7c":61330,"1faa9":51093,"1faaa":61364,"1faab":61189,"1faac":51085,"1fab7":2651,"1fab8":2631,"1fab9":2672,"1faba":2673,"1fac3":1520,"1fac4":1521,"1fac5":1505,"1fad7":3793,"1fad8":3707,"1fad9":3804,"1fae0":111,"1fae1":136,"1fae2":132,"1fae3":133,"1fae4":174,"1fae5":142,"1fae6":1385,"1fae7":61353,"1faf0":1341,"1faf1":1332,"1faf2":1333,"1faf3":1334,"1faf4":1335,"1faf5":1351,"1faf6":1360,"1faf1-1f3fb-200d-1faf2-1f3fc":0,"1faf1-1f3fb-200d-1faf2-1f3fd":0,"1faf1-1f3fb-200d-1faf2-1f3fe":0,"1faf1-1f3fb-200d-1faf2-1f3ff":0,"1faf1-1f3fc-200d-1faf2-1f3fb":0,"1faf1-1f3fc-200d-1faf2-1f3fd":0,"1faf1-1f3fc-200d-1faf2-1f3fe":0,"1faf1-1f3fc-200d-1faf2-1f3ff":0,"1faf1-1f3fd-200d-1faf2-1f3fb":0,"1faf1-1f3fd-200d-1faf2-1f3fc":0,"1faf1-1f3fd-200d-1faf2-1f3fe":0,"1faf1-1f3fd-200d-1faf2-1f3ff":0,"1faf1-1f3fe-200d-1faf2-1f3fb":0,"1faf1-1f3fe-200d-1faf2-1f3fc":0,"1faf1-1f3fe-200d-1faf2-1f3fd":0,"1faf1-1f3fe-200d-1faf2-1f3ff":0,"1faf1-1f3ff-200d-1faf2-1f3fb":0,"1faf1-1f3ff-200d-1faf2-1f3fc":0,"1faf1-1f3ff-200d-1faf2-1f3fd":0,"1faf1-1f3ff-200d-1faf2-1f3fe":0,"1fac3-1f3fb":0,"1fac3-1f3fc":0,"1fac3-1f3fd":0,"1fac3-1f3fe":0,"1fac3-1f3ff":0,"1fac4-1f3fb":0,"1fac4-1f3fc":0,"1fac4-1f3fd":0,"1fac4-1f3fe":0,"1fac4-1f3ff":0,"1fac5-1f3fb":0,"1fac5-1f3fc":0,"1fac5-1f3fd":0,"1fac5-1f3fe":0,"1fac5-1f3ff":0,"1faf0-1f3fb":0,"1faf0-1f3fc":0,"1faf0-1f3fd":0,"1faf0-1f3fe":0,"1faf0-1f3ff":0,"1faf1-1f3fb":0,"1faf1-1f3fc":0,"1faf1-1f3fd":0,"1faf1-1f3fe":0,"1faf1-1f3ff":0,"1faf2-1f3fb":0,"1faf2-1f3fc":0,"1faf2-1f3fd":0,"1faf2-1f3fe":0,"1faf2-1f3ff":0,"1faf3-1f3fb":0,"1faf3-1f3fc":0,"1faf3-1f3fd":0,"1faf3-1f3fe":0,"1faf3-1f3ff":0,"1faf4-1f3fb":0,"1faf4-1f3fc":0,"1faf4-1f3fd":0,"1faf4-1f3fe":0,"1faf4-1f3ff":0,"1faf5-1f3fb":0,"1faf5-1f3fc":0,"1faf5-1f3fd":0,"1faf5-1f3fe":0,"1faf5-1f3ff":0,"1faf6-1f3fb":0,"1faf6-1f3fc":0,"1faf6-1f3fd":0,"1faf6-1f3fe":0,"1faf6-1f3ff":0},"":{2049:62835,2122:62863,2139:62888,2194:62764,2195:62763,2196:62762,2197:62756,2198:62758,2199:62760,2328:61194,2600:4990,2601:4998,2602:41013,2603:41018,2604:41020,2611:62851,2614:41014,2615:3781,2618:2667,2620:1106,2622:62753,2623:62754,2626:62783,2638:62780,2639:177,2648:62788,2649:62789,2650:62796,2651:62797,2652:62798,2653:62799,2660:51095,2663:51098,2665:51096,2666:51097,2668:4865,2692:61297,2693:4922,2694:61300,2696:61311,2697:61319,2699:61309,2702:61284,2705:62850,2708:4931,2709:61245,2712:61259,2714:62852,2716:62828,2721:62779,2728:51029,2733:62858,2734:62859,2744:41017,2747:62860,2753:62836,2754:62837,2755:62838,2757:62839,2763:1137,2764:1141,2795:62829,2796:62830,2797:62831,2934:62767,2935:62768,3030:62840,3297:62912,3299:62913,"0023-20e3":62864,"002a-20e3":62865,"0030-20e3":62866,"0031-20e3":62867,"0032-20e3":62868,"0033-20e3":62869,"0034-20e3":62870,"0035-20e3":62871,"0036-20e3":62872,"0037-20e3":62873,"0038-20e3":62874,"0039-20e3":62875,"00a9":62861,"00ae":62862,"1f004":51101,"1f0cf":51100,"1f170":62882,"1f171":62884,"1f17e":62893,"1f17f":62895,"1f18e":62883,"1f191":62885,"1f192":62886,"1f193":62887,"1f194":62889,"1f195":62891,"1f196":62892,"1f197":62894,"1f198":62896,"1f199":62897,"1f19a":62898,"1f1e6-1f1e8":71594,"1f1e6-1f1e9":71595,"1f1e6-1f1ea":71596,"1f1e6-1f1eb":71597,"1f1e6-1f1ec":71598,"1f1e6-1f1ee":71599,"1f1e6-1f1f1":71600,"1f1e6-1f1f2":71601,"1f1e6-1f1f4":71602,"1f1e6-1f1f6":71603,"1f1e6-1f1f7":71604,"1f1e6-1f1f8":71605,"1f1e6-1f1f9":71606,"1f1e6-1f1fa":71607,"1f1e6-1f1fc":71608,"1f1e6-1f1fd":71609,"1f1e6-1f1ff":71610,"1f1e7-1f1e6":71611,"1f1e7-1f1e7":71612,"1f1e7-1f1e9":71613,"1f1e7-1f1ea":71614,"1f1e7-1f1eb":71615,"1f1e7-1f1ec":71616,"1f1e7-1f1ed":71617,"1f1e7-1f1ee":71618,"1f1e7-1f1ef":71619,"1f1e7-1f1f1":71620,"1f1e7-1f1f2":71621,"1f1e7-1f1f3":71622,"1f1e7-1f1f4":71623,"1f1e7-1f1f6":71624,"1f1e7-1f1f7":71625,"1f1e7-1f1f8":71626,"1f1e7-1f1f9":71627,"1f1e7-1f1fb":71628,"1f1e7-1f1fc":71629,"1f1e7-1f1fe":71630,"1f1e7-1f1ff":71631,"1f1e8-1f1e6":71632,"1f1e8-1f1e8":71633,"1f1e8-1f1e9":71634,"1f1e8-1f1eb":71635,"1f1e8-1f1ec":71636,"1f1e8-1f1ed":71637,"1f1e8-1f1ee":71638,"1f1e8-1f1f0":71639,"1f1e8-1f1f1":71640,"1f1e8-1f1f2":71641,"1f1e8-1f1f3":71642,"1f1e8-1f1f4":71643,"1f1e8-1f1f5":71644,"1f1e8-1f1f7":71645,"1f1e8-1f1fa":71646,"1f1e8-1f1fb":71647,"1f1e8-1f1fc":71648,"1f1e8-1f1fd":71649,"1f1e8-1f1fe":71650,"1f1e8-1f1ff":71651,"1f1e9-1f1ea":71652,"1f1e9-1f1ec":71653,"1f1e9-1f1ef":71654,"1f1e9-1f1f0":71655,"1f1e9-1f1f2":71656,"1f1e9-1f1f4":71657,"1f1e9-1f1ff":71658,"1f1ea-1f1e6":71659,"1f1ea-1f1e8":71660,"1f1ea-1f1ea":71661,"1f1ea-1f1ec":71662,"1f1ea-1f1ed":71663,"1f1ea-1f1f7":71664,"1f1ea-1f1f8":71665,"1f1ea-1f1f9":71666,"1f1ea-1f1fa":71667,"1f1eb-1f1ee":71668,"1f1eb-1f1ef":71669,"1f1eb-1f1f0":71670,"1f1eb-1f1f2":71671,"1f1eb-1f1f4":71672,"1f1eb-1f1f7":71673,"1f1ec-1f1e6":71674,"1f1ec-1f1e7":71675,"1f1ec-1f1e9":71676,"1f1ec-1f1ea":71677,"1f1ec-1f1eb":71678,"1f1ec-1f1ec":71679,"1f1ec-1f1ed":71680,"1f1ec-1f1ee":71681,"1f1ec-1f1f1":71682,"1f1ec-1f1f2":71683,"1f1ec-1f1f3":71684,"1f1ec-1f1f5":71685,"1f1ec-1f1f6":71686,"1f1ec-1f1f7":71687,"1f1ec-1f1f8":71688,"1f1ec-1f1f9":71689,"1f1ec-1f1fa":71690,"1f1ec-1f1fc":71691,"1f1ec-1f1fe":71692,"1f1ed-1f1f0":71693,"1f1ed-1f1f2":71694,"1f1ed-1f1f3":71695,"1f1ed-1f1f7":71696,"1f1ed-1f1f9":71697,"1f1ed-1f1fa":71698,"1f1ee-1f1e8":71699,"1f1ee-1f1e9":71700,"1f1ee-1f1ea":71701,"1f1ee-1f1f1":71702,"1f1ee-1f1f2":71703,"1f1ee-1f1f3":71704,"1f1ee-1f1f4":71705,"1f1ee-1f1f6":71706,"1f1ee-1f1f7":71707,"1f1ee-1f1f8":71708,"1f1ee-1f1f9":71709,"1f1ef-1f1ea":71710,"1f1ef-1f1f2":71711,"1f1ef-1f1f4":71712,"1f1ef-1f1f5":71713,"1f1f0-1f1ea":71714,"1f1f0-1f1ec":71715,"1f1f0-1f1ed":71716,"1f1f0-1f1ee":71717,"1f1f0-1f1f2":71718,"1f1f0-1f1f3":71719,"1f1f0-1f1f5":71720,"1f1f0-1f1f7":71721,"1f1f0-1f1fc":71722,"1f1f0-1f1fe":71723,"1f1f0-1f1ff":71724,"1f1f1-1f1e6":71725,"1f1f1-1f1e7":71726,"1f1f1-1f1e8":71727,"1f1f1-1f1ee":71728,"1f1f1-1f1f0":71729,"1f1f1-1f1f7":71730,"1f1f1-1f1f8":71731,"1f1f1-1f1f9":71732,"1f1f1-1f1fa":71733,"1f1f1-1f1fb":71734,"1f1f1-1f1fe":71735,"1f1f2-1f1e6":71736,"1f1f2-1f1e8":71737,"1f1f2-1f1e9":71738,"1f1f2-1f1ea":71739,"1f1f2-1f1eb":71740,"1f1f2-1f1ec":71741,"1f1f2-1f1ed":71742,"1f1f2-1f1f0":71743,"1f1f2-1f1f1":71744,"1f1f2-1f1f2":71745,"1f1f2-1f1f3":71746,"1f1f2-1f1f4":71747,"1f1f2-1f1f5":71748,"1f1f2-1f1f6":71749,"1f1f2-1f1f7":71750,"1f1f2-1f1f8":71751,"1f1f2-1f1f9":71752,"1f1f2-1f1fa":71753,"1f1f2-1f1fb":71754,"1f1f2-1f1fc":71755,"1f1f2-1f1fd":71756,"1f1f2-1f1fe":71757,"1f1f2-1f1ff":71758,"1f1f3-1f1e6":71759,"1f1f3-1f1e8":71760,"1f1f3-1f1ea":71761,"1f1f3-1f1eb":71762,"1f1f3-1f1ec":71763,"1f1f3-1f1ee":71764,"1f1f3-1f1f1":71765,"1f1f3-1f1f4":71766,"1f1f3-1f1f5":71767,"1f1f3-1f1f7":71768,"1f1f3-1f1fa":71769,"1f1f3-1f1ff":71770,"1f1f4-1f1f2":71771,"1f1f5-1f1e6":71772,"1f1f5-1f1ea":71773,"1f1f5-1f1eb":71774,"1f1f5-1f1ec":71775,"1f1f5-1f1ed":71776,"1f1f5-1f1f0":71777,"1f1f5-1f1f1":71778,"1f1f5-1f1f2":71779,"1f1f5-1f1f3":71780,"1f1f5-1f1f7":71781,"1f1f5-1f1f8":71782,"1f1f5-1f1f9":71783,"1f1f5-1f1fc":71784,"1f1f5-1f1fe":71785,"1f1f6-1f1e6":71786,"1f1f7-1f1ea":71787,"1f1f7-1f1f4":71788,"1f1f7-1f1f8":71789,"1f1f7-1f1fa":71790,"1f1f7-1f1fc":71791,"1f1f8-1f1e6":71792,"1f1f8-1f1e7":71793,"1f1f8-1f1e8":71794,"1f1f8-1f1e9":71795,"1f1f8-1f1ea":71796,"1f1f8-1f1ec":71797,"1f1f8-1f1ed":71798,"1f1f8-1f1ee":71799,"1f1f8-1f1ef":71800,"1f1f8-1f1f0":71801,"1f1f8-1f1f1":71802,"1f1f8-1f1f2":71803,"1f1f8-1f1f3":71804,"1f1f8-1f1f4":71805,"1f1f8-1f1f7":71806,"1f1f8-1f1f8":71807,"1f1f8-1f1f9":71808,"1f1f8-1f1fb":71809,"1f1f8-1f1fd":71810,"1f1f8-1f1fe":71811,"1f1f8-1f1ff":71812,"1f1f9-1f1e6":71813,"1f1f9-1f1e8":71814,"1f1f9-1f1e9":71815,"1f1f9-1f1eb":71816,"1f1f9-1f1ec":71817,"1f1f9-1f1ed":71818,"1f1f9-1f1ef":71819,"1f1f9-1f1f0":71820,"1f1f9-1f1f1":71821,"1f1f9-1f1f2":71822,"1f1f9-1f1f3":71823,"1f1f9-1f1f4":71824,"1f1f9-1f1f7":71825,"1f1f9-1f1f9":71826,"1f1f9-1f1fb":71827,"1f1f9-1f1fc":71828,"1f1f9-1f1ff":71829,"1f1fa-1f1e6":71830,"1f1fa-1f1ec":71831,"1f1fa-1f1f2":71832,"1f1fa-1f1f3":71833,"1f1fa-1f1f8":71834,"1f1fa-1f1fe":71835,"1f1fa-1f1ff":71836,"1f1fb-1f1e6":71837,"1f1fb-1f1e8":71838,"1f1fb-1f1ea":71839,"1f1fb-1f1ec":71840,"1f1fb-1f1ee":71841,"1f1fb-1f1f3":71842,"1f1fb-1f1fa":71843,"1f1fc-1f1eb":71844,"1f1fc-1f1f8":71845,"1f1fd-1f1f0":71846,"1f1fe-1f1ea":71847,"1f1fe-1f1f9":71848,"1f1ff-1f1e6":71849,"1f1ff-1f1f2":71850,"1f1ff-1f1fc":71851,"1f201":62899,"1f202":62900,"1f21a":62906,"1f22f":62903,"1f232":62907,"1f233":62911,"1f234":62910,"1f235":62915,"1f236":62902,"1f237":62901,"1f238":62909,"1f239":62905,"1f23a":62914,"1f250":62904,"1f251":62908,"1f300":41010,"1f301":4857,"1f302":41012,"1f303":4858,"1f304":4860,"1f305":4861,"1f306":4862,"1f307":4863,"1f308":41011,"1f309":4864,"1f30a":41023,"1f30b":4815,"1f30c":4997,"1f30d":4806,"1f30e":4807,"1f30f":4808,"1f310":4809,"1f311":4977,"1f312":4978,"1f313":4979,"1f314":4980,"1f315":4981,"1f316":4982,"1f317":4983,"1f318":4984,"1f319":4985,"1f31a":4986,"1f31b":4987,"1f31c":4988,"1f31d":4991,"1f31e":4992,"1f31f":4995,"1f320":4996,"1f321":4989,"1f324":41001,"1f325":41002,"1f326":41003,"1f327":41004,"1f328":41005,"1f329":41006,"1f32a":41007,"1f32b":41008,"1f32c":41009,"1f32d":3725,"1f32e":3727,"1f32f":3728,"1f330":3708,"1f331":2659,"1f332":2661,"1f333":2662,"1f334":2663,"1f335":2664,"1f336":3698,"1f337":2658,"1f338":2649,"1f339":2653,"1f33a":2655,"1f33b":2656,"1f33c":2657,"1f33d":3697,"1f33e":2665,"1f33f":2666,"1f340":2668,"1f341":2669,"1f342":2670,"1f343":2671,"1f344":3705,"1f345":3690,"1f346":3694,"1f347":3674,"1f348":3675,"1f349":3676,"1f34a":3677,"1f34b":3678,"1f34c":3679,"1f34d":3680,"1f34e":3682,"1f34f":3683,"1f350":3684,"1f351":3685,"1f352":3686,"1f353":3687,"1f354":3722,"1f355":3724,"1f356":3718,"1f357":3719,"1f358":3744,"1f359":3745,"1f35a":3746,"1f35b":3747,"1f35c":3748,"1f35d":3749,"1f35e":3709,"1f35f":3723,"1f360":3750,"1f361":3756,"1f362":3751,"1f363":3752,"1f364":3753,"1f365":3754,"1f366":3765,"1f367":3766,"1f368":3767,"1f369":3768,"1f36a":3769,"1f36b":3774,"1f36c":3775,"1f36d":3776,"1f36e":3777,"1f36f":3778,"1f370":3771,"1f371":3743,"1f372":3735,"1f373":3733,"1f374":3801,"1f375":3783,"1f376":3784,"1f377":3786,"1f378":3787,"1f379":3788,"1f37a":3789,"1f37b":3790,"1f37c":3779,"1f37d":3800,"1f37e":3785,"1f37f":3739,"1f380":51040,"1f381":51041,"1f382":3770,"1f383":51024,"1f384":51025,"1f385":1527,"1f386":51026,"1f387":51027,"1f388":51030,"1f389":51031,"1f38a":51032,"1f38b":51033,"1f38c":71588,"1f38d":51034,"1f38e":51035,"1f38f":51036,"1f390":51037,"1f391":51038,"1f392":61134,"1f393":61147,"1f396":51045,"1f397":51042,"1f399":61167,"1f39a":61168,"1f39b":61169,"1f39e":61203,"1f39f":51043,"1f3a0":4866,"1f3a1":4868,"1f3a2":4869,"1f3a3":51072,"1f3a4":61170,"1f3a5":61202,"1f3a6":62819,"1f3a7":61171,"1f3a8":51105,"1f3a9":61146,"1f3aa":4871,"1f3ab":51044,"1f3ac":61205,"1f3ad":51103,"1f3ae":51086,"1f3af":51078,"1f3b0":51088,"1f3b1":51081,"1f3b2":51089,"1f3b3":51060,"1f3b4":51102,"1f3b5":61165,"1f3b6":61166,"1f3b7":61173,"1f3b8":61175,"1f3b9":61176,"1f3ba":61177,"1f3bb":61178,"1f3bc":61164,"1f3bd":51074,"1f3be":51058,"1f3bf":51075,"1f3c0":51054,"1f3c1":71586,"1f3c2":1600,"1f3c3-200d-2640":1584,"1f3c3-200d-2642":1583,"1f3c3":1582,"1f3c4-200d-2640":1606,"1f3c4-200d-2642":1605,"1f3c4":1604,"1f3c5":51047,"1f3c6":51046,"1f3c7":1598,"1f3c8":51056,"1f3c9":51057,"1f3ca-200d-2640":1612,"1f3ca-200d-2642":1611,"1f3ca":1610,"1f3cb-200d-2640":1618,"1f3cb-200d-2642":1617,"1f3cb":1616,"1f3cc-200d-2640":1603,"1f3cc-200d-2642":1602,"1f3cc":1601,"1f3cd":4902,"1f3ce":4901,"1f3cf":51061,"1f3d0":51055,"1f3d1":51062,"1f3d2":51063,"1f3d3":51065,"1f3d4":4813,"1f3d5":4817,"1f3d6":4818,"1f3d7":4824,"1f3d8":4829,"1f3d9":4859,"1f3da":4830,"1f3db":4823,"1f3dc":4819,"1f3dd":4820,"1f3de":4821,"1f3df":4822,"1f3e0":4831,"1f3e1":4832,"1f3e2":4833,"1f3e3":4834,"1f3e4":4835,"1f3e5":4836,"1f3e6":4837,"1f3e7":62729,"1f3e8":4838,"1f3e9":4839,"1f3ea":4840,"1f3eb":4841,"1f3ec":4842,"1f3ed":4843,"1f3ee":61216,"1f3ef":4844,"1f3f0":4845,"1f3f3-200d-1f308":71591,"1f3f3-200d-26a7":71592,"1f3f3":71590,"1f3f4-200d-2620":71593,"1f3f4-e0067-e0062-e0065-e006e-e0067-e007f":71852,"1f3f4-e0067-e0062-e0073-e0063-e0074-e007f":71853,"1f3f4-e0067-e0062-e0077-e006c-e0073-e007f":71854,"1f3f4":71589,"1f3f5":2652,"1f3f7":61234,"1f3f8":51066,"1f3f9":61303,"1f3fa":3805,"1f3fb":9525,"1f3fc":9526,"1f3fd":9527,"1f3fe":9528,"1f3ff":9529,"1f400":2576,"1f401":2575,"1f402":2556,"1f403":2557,"1f404":2558,"1f405":2547,"1f406":2548,"1f407":2579,"1f408-200d-2b1b":2544,"1f408":2543,"1f409":2618,"1f40a":2613,"1f40b":2622,"1f40c":2632,"1f40d":2616,"1f40e":2550,"1f40f":2563,"1f410":2565,"1f411":2564,"1f412":2531,"1f413":2596,"1f414":2595,"1f415-200d-1f9ba":2537,"1f415":2535,"1f416":2560,"1f417":2561,"1f418":2570,"1f419":2629,"1f41a":2630,"1f41b":2634,"1f41c":2635,"1f41d":2636,"1f41e":2638,"1f41f":2625,"1f420":2626,"1f421":2627,"1f422":2614,"1f423":2597,"1f424":2598,"1f425":2599,"1f426":2600,"1f427":2601,"1f428":2586,"1f429":2538,"1f42a":2566,"1f42b":2567,"1f42c":2623,"1f42d":2574,"1f42e":2555,"1f42f":2546,"1f430":2578,"1f431":2542,"1f432":2617,"1f433":2621,"1f434":2549,"1f435":2530,"1f436":2534,"1f437":2559,"1f438":2612,"1f439":2577,"1f43a":2539,"1f43b-200d-2744":2585,"1f43b":2584,"1f43c":2587,"1f43d":2562,"1f43e":2593,"1f43f":2580,"1f440":1381,"1f441-200d-1f5e8":1159,"1f441":1382,"1f442":1373,"1f443":1375,"1f444":1384,"1f445":1383,"1f446":1347,"1f447":1349,"1f448":1345,"1f449":1346,"1f44a":1355,"1f44b":1327,"1f44c":1336,"1f44d":1352,"1f44e":1353,"1f44f":1358,"1f450":1361,"1f451":61144,"1f452":61145,"1f453":61110,"1f454":61115,"1f455":61116,"1f456":61117,"1f457":61122,"1f458":61123,"1f459":61128,"1f45a":61129,"1f45b":61130,"1f45c":61131,"1f45d":61132,"1f45e":61136,"1f45f":61137,"1f460":61140,"1f461":61141,"1f462":61143,"1f463":1687,"1f464":1684,"1f465":1685,"1f466":1388,"1f467":1389,"1f468-200d-1f33e":1457,"1f468-200d-1f373":1460,"1f468-200d-1f37c":1524,"1f468-200d-1f393":1448,"1f468-200d-1f3a4":1478,"1f468-200d-1f3a8":1481,"1f468-200d-1f3eb":1451,"1f468-200d-1f3ed":1466,"1f468-200d-1f466-200d-1f466":1674,"1f468-200d-1f466":1673,"1f468-200d-1f467-200d-1f466":1676,"1f468-200d-1f467-200d-1f467":1677,"1f468-200d-1f467":1675,"1f468-200d-1f468-200d-1f466":1663,"1f468-200d-1f468-200d-1f466-200d-1f466":1666,"1f468-200d-1f468-200d-1f467":1664,"1f468-200d-1f468-200d-1f467-200d-1f466":1665,"1f468-200d-1f468-200d-1f467-200d-1f467":1667,"1f468-200d-1f469-200d-1f466":1658,"1f468-200d-1f469-200d-1f466-200d-1f466":1661,"1f468-200d-1f469-200d-1f467":1659,"1f468-200d-1f469-200d-1f467-200d-1f466":1660,"1f468-200d-1f469-200d-1f467-200d-1f467":1662,"1f468-200d-1f4bb":1475,"1f468-200d-1f4bc":1469,"1f468-200d-1f527":1463,"1f468-200d-1f52c":1472,"1f468-200d-1f680":1487,"1f468-200d-1f692":1490,"1f468-200d-1f9af":1574,"1f468-200d-1f9b0":1396,"1f468-200d-1f9b1":1397,"1f468-200d-1f9b2":1399,"1f468-200d-1f9b3":1398,"1f468-200d-1f9bc":1577,"1f468-200d-1f9bd":1580,"1f468-200d-2695":1445,"1f468-200d-2696":1454,"1f468-200d-2708":1484,"1f468-200d-2764-200d-1f468":1655,"1f468-200d-2764-200d-1f48b-200d-1f468":1651,"1f468":1392,"1f469-200d-1f33e":1458,"1f469-200d-1f373":1461,"1f469-200d-1f37c":1523,"1f469-200d-1f393":1449,"1f469-200d-1f3a4":1479,"1f469-200d-1f3a8":1482,"1f469-200d-1f3eb":1452,"1f469-200d-1f3ed":1467,"1f469-200d-1f466-200d-1f466":1679,"1f469-200d-1f466":1678,"1f469-200d-1f467-200d-1f466":1681,"1f469-200d-1f467-200d-1f467":1682,"1f469-200d-1f467":1680,"1f469-200d-1f469-200d-1f466":1668,"1f469-200d-1f469-200d-1f466-200d-1f466":1671,"1f469-200d-1f469-200d-1f467":1669,"1f469-200d-1f469-200d-1f467-200d-1f466":1670,"1f469-200d-1f469-200d-1f467-200d-1f467":1672,"1f469-200d-1f4bb":1476,"1f469-200d-1f4bc":1470,"1f469-200d-1f527":1464,"1f469-200d-1f52c":1473,"1f469-200d-1f680":1488,"1f469-200d-1f692":1491,"1f469-200d-1f9af":1575,"1f469-200d-1f9b0":1401,"1f469-200d-1f9b1":1403,"1f469-200d-1f9b2":1407,"1f469-200d-1f9b3":1405,"1f469-200d-1f9bc":1578,"1f469-200d-1f9bd":1581,"1f469-200d-2695":1446,"1f469-200d-2696":1455,"1f469-200d-2708":1485,"1f469-200d-2764-200d-1f468":1654,"1f469-200d-2764-200d-1f469":1656,"1f469-200d-2764-200d-1f48b-200d-1f468":1650,"1f469-200d-2764-200d-1f48b-200d-1f469":1652,"1f469":1400,"1f46a":1657,"1f46b":1647,"1f46c":1648,"1f46d":1646,"1f46e-200d-2640":1494,"1f46e-200d-2642":1493,"1f46e":1492,"1f46f-200d-2640":1590,"1f46f-200d-2642":1589,"1f46f":1588,"1f470-200d-2640":1518,"1f470-200d-2642":1517,"1f470":1516,"1f471-200d-2640":1409,"1f471-200d-2642":1410,"1f471":1391,"1f472":1511,"1f473-200d-2640":1510,"1f473-200d-2642":1509,"1f473":1508,"1f474":1412,"1f475":1413,"1f476":1386,"1f477-200d-2640":1504,"1f477-200d-2642":1503,"1f477":1502,"1f478":1507,"1f479":1109,"1f47a":1110,"1f47b":1111,"1f47c":1526,"1f47d":1112,"1f47e":1113,"1f47f":1104,"1f480":1105,"1f481-200d-2640":1428,"1f481-200d-2642":1427,"1f481":1426,"1f482-200d-2640":1500,"1f482-200d-2642":1499,"1f482":1498,"1f483":1585,"1f484":61152,"1f485":1366,"1f486-200d-2640":1560,"1f486-200d-2642":1559,"1f486":1558,"1f487-200d-2640":1563,"1f487-200d-2642":1562,"1f487":1561,"1f488":4870,"1f489":61326,"1f48a":61328,"1f48b":1127,"1f48c":1128,"1f48d":61153,"1f48e":61154,"1f48f":1649,"1f490":2648,"1f491":1653,"1f492":4846,"1f493":1133,"1f494":1138,"1f495":1135,"1f496":1131,"1f497":1132,"1f498":1129,"1f499":1145,"1f49a":1144,"1f49b":1143,"1f49c":1146,"1f49d":1130,"1f49e":1134,"1f49f":1136,"1f4a0":62946,"1f4a1":61214,"1f4a2":1151,"1f4a3":1157,"1f4a4":1163,"1f4a5":1152,"1f4a6":1154,"1f4a7":41022,"1f4a8":1155,"1f4a9":1107,"1f4aa":1368,"1f4ab":1153,"1f4ac":1158,"1f4ad":1162,"1f4ae":2650,"1f4af":1150,"1f4b0":61235,"1f4b1":62841,"1f4b2":62842,"1f4b3":61242,"1f4b4":61237,"1f4b5":61238,"1f4b6":61239,"1f4b7":61240,"1f4b8":61241,"1f4b9":61244,"1f4ba":4936,"1f4bb":61191,"1f4bc":61265,"1f4bd":61197,"1f4be":61198,"1f4bf":61199,"1f4c0":61200,"1f4c1":61266,"1f4c2":61267,"1f4c3":61227,"1f4c4":61229,"1f4c5":61269,"1f4c6":61270,"1f4c7":61273,"1f4c8":61274,"1f4c9":61275,"1f4ca":61276,"1f4cb":61277,"1f4cc":61278,"1f4cd":61279,"1f4ce":61280,"1f4cf":61282,"1f4d0":61283,"1f4d1":61232,"1f4d2":61226,"1f4d3":61225,"1f4d4":61218,"1f4d5":61219,"1f4d6":61220,"1f4d7":61221,"1f4d8":61222,"1f4d9":61223,"1f4da":61224,"1f4db":62847,"1f4dc":61228,"1f4dd":61264,"1f4de":61185,"1f4df":61186,"1f4e0":61187,"1f4e1":61325,"1f4e2":61159,"1f4e3":61160,"1f4e4":61249,"1f4e5":61250,"1f4e6":61251,"1f4e7":61246,"1f4e8":61247,"1f4e9":61248,"1f4ea":61253,"1f4eb":61252,"1f4ec":61254,"1f4ed":61255,"1f4ee":61256,"1f4ef":61161,"1f4f0":61230,"1f4f1":61182,"1f4f2":61183,"1f4f3":62823,"1f4f4":62824,"1f4f5":62751,"1f4f6":62822,"1f4f7":61207,"1f4f8":61208,"1f4f9":61209,"1f4fa":61206,"1f4fb":61172,"1f4fc":61210,"1f4fd":61204,"1f4ff":61151,"1f500":62801,"1f501":62802,"1f502":62803,"1f503":62769,"1f504":62770,"1f505":62820,"1f506":62821,"1f507":61155,"1f508":61156,"1f509":61157,"1f50a":61158,"1f50b":61188,"1f50c":61190,"1f50d":61211,"1f50e":61212,"1f50f":61290,"1f510":61291,"1f511":61292,"1f512":61288,"1f513":61289,"1f514":61162,"1f515":61163,"1f516":61233,"1f517":61313,"1f518":62947,"1f519":62771,"1f51a":62772,"1f51b":62773,"1f51c":62774,"1f51d":62775,"1f51e":62752,"1f51f":62876,"1f520":62877,"1f521":62878,"1f522":62879,"1f523":62880,"1f524":62881,"1f525":41021,"1f526":61215,"1f527":61306,"1f528":61294,"1f529":61308,"1f52a":3803,"1f52b":61301,"1f52c":61323,"1f52d":61324,"1f52e":51082,"1f52f":62787,"1f530":62848,"1f531":62846,"1f532":62949,"1f533":62948,"1f534":62916,"1f535":62920,"1f536":62940,"1f537":62941,"1f538":62942,"1f539":62943,"1f53a":62944,"1f53b":62945,"1f53c":62811,"1f53d":62813,"1f549":62778,"1f54a":2602,"1f54b":4854,"1f54c":4850,"1f54d":4852,"1f54e":62786,"1f550":4955,"1f551":4957,"1f552":4959,"1f553":4961,"1f554":4963,"1f555":4965,"1f556":4967,"1f557":4969,"1f558":4971,"1f559":4973,"1f55a":4975,"1f55b":4953,"1f55c":4956,"1f55d":4958,"1f55e":4960,"1f55f":4962,"1f560":4964,"1f561":4966,"1f562":4968,"1f563":4970,"1f564":4972,"1f565":4974,"1f566":4976,"1f567":4954,"1f56f":61213,"1f570":4952,"1f573":1156,"1f574":1587,"1f575-200d-2640":1497,"1f575-200d-2642":1496,"1f575":1495,"1f576":61111,"1f577":2641,"1f578":2642,"1f579":51087,"1f57a":1586,"1f587":61281,"1f58a":61261,"1f58b":61260,"1f58c":61262,"1f58d":61263,"1f590":1329,"1f595":1348,"1f596":1331,"1f5a4":1148,"1f5a5":61192,"1f5a8":61193,"1f5b1":61195,"1f5b2":61196,"1f5bc":51104,"1f5c2":61268,"1f5c3":61285,"1f5c4":61286,"1f5d1":61287,"1f5d2":61271,"1f5d3":61272,"1f5dc":61310,"1f5dd":61293,"1f5de":61231,"1f5e1":61299,"1f5e3":1683,"1f5e8":1160,"1f5ef":1161,"1f5f3":61257,"1f5fa":4810,"1f5fb":4816,"1f5fc":4847,"1f5fd":4848,"1f5fe":4811,"1f5ff":61362,"1f600":11,"1f601":14,"1f602":18,"1f603":12,"1f604":13,"1f605":16,"1f606":15,"1f607":114,"1f608":1103,"1f609":112,"1f60a":113,"1f60b":124,"1f60c":150,"1f60d":116,"1f60e":170,"1f60f":144,"1f610":139,"1f611":140,"1f612":145,"1f613":195,"1f614":151,"1f615":173,"1f616":192,"1f617":119,"1f618":118,"1f619":122,"1f61a":121,"1f61b":125,"1f61c":126,"1f61d":128,"1f61e":194,"1f61f":175,"1f620":1101,"1f621":1100,"1f622":189,"1f623":193,"1f624":199,"1f625":188,"1f626":184,"1f627":185,"1f628":186,"1f629":196,"1f62a":152,"1f62b":197,"1f62c":147,"1f62d":190,"1f62e-200d-1f4a8":148,"1f62e":178,"1f62f":179,"1f630":187,"1f631":191,"1f632":180,"1f633":181,"1f634":154,"1f635-200d-1f4ab":165,"1f635":164,"1f636-200d-1f32b":143,"1f636":141,"1f637":155,"1f638":1116,"1f639":1117,"1f63a":1115,"1f63b":1118,"1f63c":1119,"1f63d":1120,"1f63e":1123,"1f63f":1122,"1f640":1121,"1f641":176,"1f642":19,"1f643":110,"1f644":146,"1f645-200d-2640":1422,"1f645-200d-2642":1421,"1f645":1420,"1f646-200d-2640":1425,"1f646-200d-2642":1424,"1f646":1423,"1f647-200d-2640":1437,"1f647-200d-2642":1436,"1f647":1435,"1f648":1124,"1f649":1125,"1f64a":1126,"1f64b-200d-2640":1431,"1f64b-200d-2642":1430,"1f64b":1429,"1f64c":1359,"1f64d-200d-2640":1416,"1f64d-200d-2642":1415,"1f64d":1414,"1f64e-200d-2640":1419,"1f64e-200d-2642":1418,"1f64e":1417,"1f64f":1364,"1f680":4942,"1f681":4937,"1f682":4872,"1f683":4873,"1f684":4874,"1f685":4875,"1f686":4876,"1f687":4877,"1f688":4878,"1f689":4879,"1f68a":4880,"1f68b":4883,"1f68c":4884,"1f68d":4885,"1f68e":4886,"1f68f":4911,"1f690":4887,"1f691":4888,"1f692":4889,"1f693":4890,"1f694":4891,"1f695":4892,"1f696":4893,"1f697":4894,"1f698":4895,"1f699":4896,"1f69a":4898,"1f69b":4899,"1f69c":4900,"1f69d":4881,"1f69e":4882,"1f69f":4938,"1f6a0":4939,"1f6a1":4940,"1f6a2":4930,"1f6a3-200d-2640":1609,"1f6a3-200d-2642":1608,"1f6a3":1607,"1f6a4":4926,"1f6a5":4918,"1f6a6":4919,"1f6a7":4921,"1f6a8":4917,"1f6a9":71587,"1f6aa":61333,"1f6ab":62745,"1f6ac":61358,"1f6ad":62747,"1f6ae":62730,"1f6af":62748,"1f6b0":62731,"1f6b1":62749,"1f6b2":4907,"1f6b3":62746,"1f6b4-200d-2640":1621,"1f6b4-200d-2642":1620,"1f6b4":1619,"1f6b5-200d-2640":1624,"1f6b5-200d-2642":1623,"1f6b5":1622,"1f6b6-200d-2640":1566,"1f6b6-200d-2642":1565,"1f6b6":1564,"1f6b7":62750,"1f6b8":62743,"1f6b9":62733,"1f6ba":62734,"1f6bb":62735,"1f6bc":62736,"1f6bd":61340,"1f6be":62737,"1f6bf":61342,"1f6c0":1643,"1f6c1":61343,"1f6c2":62738,"1f6c3":62739,"1f6c4":62740,"1f6c5":62741,"1f6cb":61338,"1f6cc":1644,"1f6cd":61133,"1f6ce":4944,"1f6cf":61337,"1f6d0":62776,"1f6d1":4920,"1f6d2":61357,"1f6d5":4851,"1f6d6":4828,"1f6d7":61334,"1f6e0":61298,"1f6e1":61304,"1f6e2":4914,"1f6e3":4912,"1f6e4":4913,"1f6e5":4929,"1f6e9":4932,"1f6eb":4933,"1f6ec":4934,"1f6f0":4941,"1f6f3":4927,"1f6f4":4908,"1f6f5":4903,"1f6f6":4925,"1f6f7":51076,"1f6f8":4943,"1f6f9":4909,"1f6fa":4906,"1f6fb":4897,"1f6fc":4910,"1f7e0":62917,"1f7e1":62918,"1f7e2":62919,"1f7e3":62921,"1f7e4":62922,"1f7e5":62925,"1f7e6":62929,"1f7e7":62926,"1f7e8":62927,"1f7e9":62928,"1f7ea":62930,"1f7eb":62931,"1f90c":1337,"1f90d":1149,"1f90e":1147,"1f90f":1338,"1f910":137,"1f911":129,"1f912":156,"1f913":171,"1f914":135,"1f915":157,"1f916":1114,"1f917":130,"1f918":1343,"1f919":1344,"1f91a":1328,"1f91b":1356,"1f91c":1357,"1f91d":1363,"1f91e":1340,"1f91f":1342,"1f920":167,"1f921":1108,"1f922":158,"1f923":17,"1f924":153,"1f925":149,"1f926-200d-2640":1440,"1f926-200d-2642":1439,"1f926":1438,"1f927":160,"1f928":138,"1f929":117,"1f92a":127,"1f92b":134,"1f92c":1102,"1f92d":131,"1f92e":159,"1f92f":166,"1f930":1519,"1f931":1522,"1f932":1362,"1f933":1367,"1f934":1506,"1f935-200d-2640":1515,"1f935-200d-2642":1514,"1f935":1513,"1f936":1528,"1f937-200d-2640":1443,"1f937-200d-2642":1442,"1f937":1441,"1f938-200d-2640":1627,"1f938-200d-2642":1626,"1f938":1625,"1f939-200d-2640":1639,"1f939-200d-2642":1638,"1f939":1637,"1f93a":1597,"1f93c-200d-2640":1630,"1f93c-200d-2642":1629,"1f93c":1628,"1f93d-200d-2640":1633,"1f93d-200d-2642":1632,"1f93d":1631,"1f93e-200d-2640":1636,"1f93e-200d-2642":1635,"1f93e":1634,"1f93f":51073,"1f940":2654,"1f941":61180,"1f942":3791,"1f943":3792,"1f944":3802,"1f945":51069,"1f947":51048,"1f948":51049,"1f949":51050,"1f94a":51067,"1f94b":51068,"1f94c":51077,"1f94d":51064,"1f94e":51053,"1f94f":51059,"1f950":3710,"1f951":3693,"1f952":3700,"1f953":3721,"1f954":3695,"1f955":3696,"1f956":3711,"1f957":3738,"1f958":3734,"1f959":3730,"1f95a":3732,"1f95b":3780,"1f95c":3706,"1f95d":3689,"1f95e":3715,"1f95f":3757,"1f960":3758,"1f961":3759,"1f962":3799,"1f963":3737,"1f964":3794,"1f965":3692,"1f966":3702,"1f967":3773,"1f968":3713,"1f969":3720,"1f96a":3726,"1f96b":3742,"1f96c":3701,"1f96d":3681,"1f96e":3755,"1f96f":3714,"1f970":115,"1f971":198,"1f972":123,"1f973":168,"1f974":163,"1f975":161,"1f976":162,"1f977":1501,"1f978":169,"1f97a":182,"1f97b":61124,"1f97c":61113,"1f97d":61112,"1f97e":61138,"1f97f":61139,"1f980":3760,"1f981":2545,"1f982":2643,"1f983":2594,"1f984":2551,"1f985":2603,"1f986":2604,"1f987":2583,"1f988":2628,"1f989":2606,"1f98a":2540,"1f98b":2633,"1f98c":2553,"1f98d":2532,"1f98e":2615,"1f98f":2572,"1f990":3762,"1f991":3763,"1f992":2569,"1f993":2552,"1f994":2582,"1f995":2619,"1f996":2620,"1f997":2639,"1f998":2591,"1f999":2568,"1f99a":2610,"1f99b":2573,"1f99c":2611,"1f99d":2541,"1f99e":3761,"1f99f":2644,"1f9a0":2647,"1f9a1":2592,"1f9a2":2605,"1f9a3":2571,"1f9a4":2607,"1f9a5":2588,"1f9a6":2589,"1f9a7":2533,"1f9a8":2590,"1f9a9":2609,"1f9aa":3764,"1f9ab":2581,"1f9ac":2554,"1f9ad":2624,"1f9ae":2536,"1f9af":61312,"1f9b4":1380,"1f9b5":1371,"1f9b6":1372,"1f9b7":1379,"1f9b8-200d-2640":1532,"1f9b8-200d-2642":1531,"1f9b8":1530,"1f9b9-200d-2640":1535,"1f9b9-200d-2642":1534,"1f9b9":1533,"1f9ba":61114,"1f9bb":1374,"1f9bc":4905,"1f9bd":4904,"1f9be":1369,"1f9bf":1370,"1f9c0":3717,"1f9c1":3772,"1f9c2":3741,"1f9c3":3796,"1f9c4":3703,"1f9c5":3704,"1f9c6":3731,"1f9c7":3716,"1f9c8":3740,"1f9c9":3797,"1f9ca":3798,"1f9cb":3795,"1f9cd-200d-2640":1569,"1f9cd-200d-2642":1568,"1f9cd":1567,"1f9ce-200d-2640":1572,"1f9ce-200d-2642":1571,"1f9ce":1570,"1f9cf-200d-2640":1434,"1f9cf-200d-2642":1433,"1f9cf":1432,"1f9d0":172,"1f9d1-200d-1f33e":1456,"1f9d1-200d-1f373":1459,"1f9d1-200d-1f37c":1525,"1f9d1-200d-1f384":1529,"1f9d1-200d-1f393":1447,"1f9d1-200d-1f3a4":1477,"1f9d1-200d-1f3a8":1480,"1f9d1-200d-1f3eb":1450,"1f9d1-200d-1f3ed":1465,"1f9d1-200d-1f4bb":1474,"1f9d1-200d-1f4bc":1468,"1f9d1-200d-1f527":1462,"1f9d1-200d-1f52c":1471,"1f9d1-200d-1f680":1486,"1f9d1-200d-1f692":1489,"1f9d1-200d-1f91d-200d-1f9d1":1645,"1f9d1-200d-1f9af":1573,"1f9d1-200d-1f9b0":1402,"1f9d1-200d-1f9b1":1404,"1f9d1-200d-1f9b2":1408,"1f9d1-200d-1f9b3":1406,"1f9d1-200d-1f9bc":1576,"1f9d1-200d-1f9bd":1579,"1f9d1-200d-2695":1444,"1f9d1-200d-2696":1453,"1f9d1-200d-2708":1483,"1f9d1":1390,"1f9d2":1387,"1f9d3":1411,"1f9d4-200d-2640":1395,"1f9d4-200d-2642":1394,"1f9d4":1393,"1f9d5":1512,"1f9d6-200d-2640":1593,"1f9d6-200d-2642":1592,"1f9d6":1591,"1f9d7-200d-2640":1596,"1f9d7-200d-2642":1595,"1f9d7":1594,"1f9d8-200d-2640":1642,"1f9d8-200d-2642":1641,"1f9d8":1640,"1f9d9-200d-2640":1538,"1f9d9-200d-2642":1537,"1f9d9":1536,"1f9da-200d-2640":1541,"1f9da-200d-2642":1540,"1f9da":1539,"1f9db-200d-2640":1544,"1f9db-200d-2642":1543,"1f9db":1542,"1f9dc-200d-2640":1547,"1f9dc-200d-2642":1546,"1f9dc":1545,"1f9dd-200d-2640":1550,"1f9dd-200d-2642":1549,"1f9dd":1548,"1f9de-200d-2640":1553,"1f9de-200d-2642":1552,"1f9de":1551,"1f9df-200d-2640":1556,"1f9df-200d-2642":1555,"1f9df":1554,"1f9e0":1376,"1f9e1":1142,"1f9e2":61148,"1f9e3":61118,"1f9e4":61119,"1f9e5":61120,"1f9e6":61121,"1f9e7":51039,"1f9e8":51028,"1f9e9":51090,"1f9ea":61320,"1f9eb":61321,"1f9ec":61322,"1f9ed":4812,"1f9ee":61201,"1f9ef":61356,"1f9f0":61316,"1f9f1":4825,"1f9f2":61317,"1f9f3":4945,"1f9f4":61346,"1f9f5":51106,"1f9f6":51108,"1f9f7":61347,"1f9f8":51091,"1f9f9":61348,"1f9fa":61349,"1f9fb":61350,"1f9fc":61352,"1f9fd":61355,"1f9fe":61243,"1f9ff":51084,"1fa70":61142,"1fa71":61125,"1fa72":61126,"1fa73":61127,"1fa74":61135,"1fa78":61327,"1fa79":61329,"1fa7a":61331,"1fa80":51079,"1fa81":51080,"1fa82":4935,"1fa83":61302,"1fa84":51083,"1fa85":51092,"1fa86":51094,"1fa90":4993,"1fa91":61339,"1fa92":61345,"1fa93":61295,"1fa94":61217,"1fa95":61179,"1fa96":61149,"1fa97":61174,"1fa98":61181,"1fa99":61236,"1fa9a":61305,"1fa9b":61307,"1fa9c":61318,"1fa9d":61315,"1fa9e":61335,"1fa9f":61336,"1faa0":61341,"1faa1":51107,"1faa2":51109,"1faa3":61351,"1faa4":61344,"1faa5":61354,"1faa6":61360,"1faa7":61363,"1faa8":4826,"1fab0":2645,"1fab1":2646,"1fab2":2637,"1fab3":2640,"1fab4":2660,"1fab5":4827,"1fab6":2608,"1fac0":1377,"1fac1":1378,"1fac2":1686,"1fad0":3688,"1fad1":3699,"1fad2":3691,"1fad3":3712,"1fad4":3729,"1fad5":3736,"1fad6":3782,"203c":62834,"21a9":62765,"21aa":62766,"231a":4948,"231b":4946,"23cf":62818,"23e9":62805,"23ea":62809,"23eb":62812,"23ec":62814,"23ed":62806,"23ee":62810,"23ef":62807,"23f0":4949,"23f1":4950,"23f2":4951,"23f3":4947,"23f8":62815,"23f9":62816,"23fa":62817,"24c2":62890,"25aa":62938,"25ab":62939,"25b6":62804,"25c0":62808,"25fb":62935,"25fc":62934,"25fd":62937,"25fe":62936,"260e":61184,"261d":1350,"262a":62784,"262e":62785,"262f":62781,"263a":120,"264a":62790,"264b":62791,"264c":62792,"264d":62793,"264e":62794,"264f":62795,"265f":51099,"267b":62844,"267e":62833,"267f":62732,"269b":62777,"269c":62845,"26a0":62742,"26a1":41016,"26a7":62827,"26aa":62924,"26ab":62923,"26b0":61359,"26b1":61361,"26bd":51051,"26be":51052,"26c4":41019,"26c5":4999,"26c8":41e3,"26ce":62800,"26cf":61296,"26d1":61150,"26d3":61314,"26d4":62744,"26e9":4853,"26ea":4849,"26f0":4814,"26f1":41015,"26f2":4855,"26f3":51070,"26f4":4928,"26f5":4924,"26f7":1599,"26f8":51071,"26f9-200d-2640":1615,"26f9-200d-2642":1614,"26f9":1613,"26fa":4856,"26fd":4915,"270a":1354,"270b":1330,"270c":1339,"270d":1365,"270f":61258,"271d":62782,"274c":62853,"274e":62854,"2764-200d-1f525":1139,"2764-200d-1fa79":1140,"27a1":62757,"27b0":62855,"27bf":62856,"2b05":62761,"2b06":62755,"2b07":62759,"2b1b":62932,"2b1c":62933,"2b50":4994,"2b55":62849,"303d":62857,"1f385-1f3fb":0,"1f385-1f3fc":0,"1f385-1f3fd":0,"1f385-1f3fe":0,"1f385-1f3ff":0,"1f3c2-1f3fb":0,"1f3c2-1f3fc":0,"1f3c2-1f3fd":0,"1f3c2-1f3fe":0,"1f3c2-1f3ff":0,"1f3c3-1f3fb-200d-2640":0,"1f3c3-1f3fc-200d-2640":0,"1f3c3-1f3fd-200d-2640":0,"1f3c3-1f3fe-200d-2640":0,"1f3c3-1f3ff-200d-2640":0,"1f3c3-1f3fb-200d-2642":0,"1f3c3-1f3fc-200d-2642":0,"1f3c3-1f3fd-200d-2642":0,"1f3c3-1f3fe-200d-2642":0,"1f3c3-1f3ff-200d-2642":0,"1f3c3-1f3fb":0,"1f3c3-1f3fc":0,"1f3c3-1f3fd":0,"1f3c3-1f3fe":0,"1f3c3-1f3ff":0,"1f3c4-1f3fb-200d-2640":0,"1f3c4-1f3fc-200d-2640":0,"1f3c4-1f3fd-200d-2640":0,"1f3c4-1f3fe-200d-2640":0,"1f3c4-1f3ff-200d-2640":0,"1f3c4-1f3fb-200d-2642":0,"1f3c4-1f3fc-200d-2642":0,"1f3c4-1f3fd-200d-2642":0,"1f3c4-1f3fe-200d-2642":0,"1f3c4-1f3ff-200d-2642":0,"1f3c4-1f3fb":0,"1f3c4-1f3fc":0,"1f3c4-1f3fd":0,"1f3c4-1f3fe":0,"1f3c4-1f3ff":0,"1f3c7-1f3fb":0,"1f3c7-1f3fc":0,"1f3c7-1f3fd":0,"1f3c7-1f3fe":0,"1f3c7-1f3ff":0,"1f3ca-1f3fb-200d-2640":0,"1f3ca-1f3fc-200d-2640":0,"1f3ca-1f3fd-200d-2640":0,"1f3ca-1f3fe-200d-2640":0,"1f3ca-1f3ff-200d-2640":0,"1f3ca-1f3fb-200d-2642":0,"1f3ca-1f3fc-200d-2642":0,"1f3ca-1f3fd-200d-2642":0,"1f3ca-1f3fe-200d-2642":0,"1f3ca-1f3ff-200d-2642":0,"1f3ca-1f3fb":0,"1f3ca-1f3fc":0,"1f3ca-1f3fd":0,"1f3ca-1f3fe":0,"1f3ca-1f3ff":0,"1f3cb-1f3fb-200d-2640":0,"1f3cb-1f3fc-200d-2640":0,"1f3cb-1f3fd-200d-2640":0,"1f3cb-1f3fe-200d-2640":0,"1f3cb-1f3ff-200d-2640":0,"1f3cb-1f3fb-200d-2642":0,"1f3cb-1f3fc-200d-2642":0,"1f3cb-1f3fd-200d-2642":0,"1f3cb-1f3fe-200d-2642":0,"1f3cb-1f3ff-200d-2642":0,"1f3cb-1f3fb":0,"1f3cb-1f3fc":0,"1f3cb-1f3fd":0,"1f3cb-1f3fe":0,"1f3cb-1f3ff":0,"1f3cc-1f3fb-200d-2640":0,"1f3cc-1f3fc-200d-2640":0,"1f3cc-1f3fd-200d-2640":0,"1f3cc-1f3fe-200d-2640":0,"1f3cc-1f3ff-200d-2640":0,"1f3cc-1f3fb-200d-2642":0,"1f3cc-1f3fc-200d-2642":0,"1f3cc-1f3fd-200d-2642":0,"1f3cc-1f3fe-200d-2642":0,"1f3cc-1f3ff-200d-2642":0,"1f3cc-1f3fb":0,"1f3cc-1f3fc":0,"1f3cc-1f3fd":0,"1f3cc-1f3fe":0,"1f3cc-1f3ff":0,"1f442-1f3fb":0,"1f442-1f3fc":0,"1f442-1f3fd":0,"1f442-1f3fe":0,"1f442-1f3ff":0,"1f443-1f3fb":0,"1f443-1f3fc":0,"1f443-1f3fd":0,"1f443-1f3fe":0,"1f443-1f3ff":0,"1f446-1f3fb":0,"1f446-1f3fc":0,"1f446-1f3fd":0,"1f446-1f3fe":0,"1f446-1f3ff":0,"1f447-1f3fb":0,"1f447-1f3fc":0,"1f447-1f3fd":0,"1f447-1f3fe":0,"1f447-1f3ff":0,"1f448-1f3fb":0,"1f448-1f3fc":0,"1f448-1f3fd":0,"1f448-1f3fe":0,"1f448-1f3ff":0,"1f449-1f3fb":0,"1f449-1f3fc":0,"1f449-1f3fd":0,"1f449-1f3fe":0,"1f449-1f3ff":0,"1f44a-1f3fb":0,"1f44a-1f3fc":0,"1f44a-1f3fd":0,"1f44a-1f3fe":0,"1f44a-1f3ff":0,"1f44b-1f3fb":0,"1f44b-1f3fc":0,"1f44b-1f3fd":0,"1f44b-1f3fe":0,"1f44b-1f3ff":0,"1f44c-1f3fb":0,"1f44c-1f3fc":0,"1f44c-1f3fd":0,"1f44c-1f3fe":0,"1f44c-1f3ff":0,"1f44d-1f3fb":0,"1f44d-1f3fc":0,"1f44d-1f3fd":0,"1f44d-1f3fe":0,"1f44d-1f3ff":0,"1f44e-1f3fb":0,"1f44e-1f3fc":0,"1f44e-1f3fd":0,"1f44e-1f3fe":0,"1f44e-1f3ff":0,"1f44f-1f3fb":0,"1f44f-1f3fc":0,"1f44f-1f3fd":0,"1f44f-1f3fe":0,"1f44f-1f3ff":0,"1f450-1f3fb":0,"1f450-1f3fc":0,"1f450-1f3fd":0,"1f450-1f3fe":0,"1f450-1f3ff":0,"1f466-1f3fb":0,"1f466-1f3fc":0,"1f466-1f3fd":0,"1f466-1f3fe":0,"1f466-1f3ff":0,"1f467-1f3fb":0,"1f467-1f3fc":0,"1f467-1f3fd":0,"1f467-1f3fe":0,"1f467-1f3ff":0,"1f468-1f3fb-200d-1f33e":0,"1f468-1f3fc-200d-1f33e":0,"1f468-1f3fd-200d-1f33e":0,"1f468-1f3fe-200d-1f33e":0,"1f468-1f3ff-200d-1f33e":0,"1f468-1f3fb-200d-1f373":0,"1f468-1f3fc-200d-1f373":0,"1f468-1f3fd-200d-1f373":0,"1f468-1f3fe-200d-1f373":0,"1f468-1f3ff-200d-1f373":0,"1f468-1f3fb-200d-1f37c":0,"1f468-1f3fc-200d-1f37c":0,"1f468-1f3fd-200d-1f37c":0,"1f468-1f3fe-200d-1f37c":0,"1f468-1f3ff-200d-1f37c":0,"1f468-1f3fb-200d-1f393":0,"1f468-1f3fc-200d-1f393":0,"1f468-1f3fd-200d-1f393":0,"1f468-1f3fe-200d-1f393":0,"1f468-1f3ff-200d-1f393":0,"1f468-1f3fb-200d-1f3a4":0,"1f468-1f3fc-200d-1f3a4":0,"1f468-1f3fd-200d-1f3a4":0,"1f468-1f3fe-200d-1f3a4":0,"1f468-1f3ff-200d-1f3a4":0,"1f468-1f3fb-200d-1f3a8":0,"1f468-1f3fc-200d-1f3a8":0,"1f468-1f3fd-200d-1f3a8":0,"1f468-1f3fe-200d-1f3a8":0,"1f468-1f3ff-200d-1f3a8":0,"1f468-1f3fb-200d-1f3eb":0,"1f468-1f3fc-200d-1f3eb":0,"1f468-1f3fd-200d-1f3eb":0,"1f468-1f3fe-200d-1f3eb":0,"1f468-1f3ff-200d-1f3eb":0,"1f468-1f3fb-200d-1f3ed":0,"1f468-1f3fc-200d-1f3ed":0,"1f468-1f3fd-200d-1f3ed":0,"1f468-1f3fe-200d-1f3ed":0,"1f468-1f3ff-200d-1f3ed":0,"1f468-1f3fb-200d-1f4bb":0,"1f468-1f3fc-200d-1f4bb":0,"1f468-1f3fd-200d-1f4bb":0,"1f468-1f3fe-200d-1f4bb":0,"1f468-1f3ff-200d-1f4bb":0,"1f468-1f3fb-200d-1f4bc":0,"1f468-1f3fc-200d-1f4bc":0,"1f468-1f3fd-200d-1f4bc":0,"1f468-1f3fe-200d-1f4bc":0,"1f468-1f3ff-200d-1f4bc":0,"1f468-1f3fb-200d-1f527":0,"1f468-1f3fc-200d-1f527":0,"1f468-1f3fd-200d-1f527":0,"1f468-1f3fe-200d-1f527":0,"1f468-1f3ff-200d-1f527":0,"1f468-1f3fb-200d-1f52c":0,"1f468-1f3fc-200d-1f52c":0,"1f468-1f3fd-200d-1f52c":0,"1f468-1f3fe-200d-1f52c":0,"1f468-1f3ff-200d-1f52c":0,"1f468-1f3fb-200d-1f680":0,"1f468-1f3fc-200d-1f680":0,"1f468-1f3fd-200d-1f680":0,"1f468-1f3fe-200d-1f680":0,"1f468-1f3ff-200d-1f680":0,"1f468-1f3fb-200d-1f692":0,"1f468-1f3fc-200d-1f692":0,"1f468-1f3fd-200d-1f692":0,"1f468-1f3fe-200d-1f692":0,"1f468-1f3ff-200d-1f692":0,"1f468-1f3fb-200d-1f9af":0,"1f468-1f3fc-200d-1f9af":0,"1f468-1f3fd-200d-1f9af":0,"1f468-1f3fe-200d-1f9af":0,"1f468-1f3ff-200d-1f9af":0,"1f468-1f3fb-200d-1f9b0":0,"1f468-1f3fc-200d-1f9b0":0,"1f468-1f3fd-200d-1f9b0":0,"1f468-1f3fe-200d-1f9b0":0,"1f468-1f3ff-200d-1f9b0":0,"1f468-1f3fb-200d-1f9b1":0,"1f468-1f3fc-200d-1f9b1":0,"1f468-1f3fd-200d-1f9b1":0,"1f468-1f3fe-200d-1f9b1":0,"1f468-1f3ff-200d-1f9b1":0,"1f468-1f3fb-200d-1f9b2":0,"1f468-1f3fc-200d-1f9b2":0,"1f468-1f3fd-200d-1f9b2":0,"1f468-1f3fe-200d-1f9b2":0,"1f468-1f3ff-200d-1f9b2":0,"1f468-1f3fb-200d-1f9b3":0,"1f468-1f3fc-200d-1f9b3":0,"1f468-1f3fd-200d-1f9b3":0,"1f468-1f3fe-200d-1f9b3":0,"1f468-1f3ff-200d-1f9b3":0,"1f468-1f3fb-200d-1f9bc":0,"1f468-1f3fc-200d-1f9bc":0,"1f468-1f3fd-200d-1f9bc":0,"1f468-1f3fe-200d-1f9bc":0,"1f468-1f3ff-200d-1f9bc":0,"1f468-1f3fb-200d-1f9bd":0,"1f468-1f3fc-200d-1f9bd":0,"1f468-1f3fd-200d-1f9bd":0,"1f468-1f3fe-200d-1f9bd":0,"1f468-1f3ff-200d-1f9bd":0,"1f468-1f3fb-200d-2695":0,"1f468-1f3fc-200d-2695":0,"1f468-1f3fd-200d-2695":0,"1f468-1f3fe-200d-2695":0,"1f468-1f3ff-200d-2695":0,"1f468-1f3fb-200d-2696":0,"1f468-1f3fc-200d-2696":0,"1f468-1f3fd-200d-2696":0,"1f468-1f3fe-200d-2696":0,"1f468-1f3ff-200d-2696":0,"1f468-1f3fb-200d-2708":0,"1f468-1f3fc-200d-2708":0,"1f468-1f3fd-200d-2708":0,"1f468-1f3fe-200d-2708":0,"1f468-1f3ff-200d-2708":0,"1f468-1f3fb-200d-2764-200d-1f468-1f3fb":0,"1f468-1f3fb-200d-2764-200d-1f468-1f3fc":0,"1f468-1f3fb-200d-2764-200d-1f468-1f3fd":0,"1f468-1f3fb-200d-2764-200d-1f468-1f3fe":0,"1f468-1f3fb-200d-2764-200d-1f468-1f3ff":0,"1f468-1f3fc-200d-2764-200d-1f468-1f3fb":0,"1f468-1f3fc-200d-2764-200d-1f468-1f3fc":0,"1f468-1f3fc-200d-2764-200d-1f468-1f3fd":0,"1f468-1f3fc-200d-2764-200d-1f468-1f3fe":0,"1f468-1f3fc-200d-2764-200d-1f468-1f3ff":0,"1f468-1f3fd-200d-2764-200d-1f468-1f3fb":0,"1f468-1f3fd-200d-2764-200d-1f468-1f3fc":0,"1f468-1f3fd-200d-2764-200d-1f468-1f3fd":0,"1f468-1f3fd-200d-2764-200d-1f468-1f3fe":0,"1f468-1f3fd-200d-2764-200d-1f468-1f3ff":0,"1f468-1f3fe-200d-2764-200d-1f468-1f3fb":0,"1f468-1f3fe-200d-2764-200d-1f468-1f3fc":0,"1f468-1f3fe-200d-2764-200d-1f468-1f3fd":0,"1f468-1f3fe-200d-2764-200d-1f468-1f3fe":0,"1f468-1f3fe-200d-2764-200d-1f468-1f3ff":0,"1f468-1f3ff-200d-2764-200d-1f468-1f3fb":0,"1f468-1f3ff-200d-2764-200d-1f468-1f3fc":0,"1f468-1f3ff-200d-2764-200d-1f468-1f3fd":0,"1f468-1f3ff-200d-2764-200d-1f468-1f3fe":0,"1f468-1f3ff-200d-2764-200d-1f468-1f3ff":0,"1f468-1f3fb-200d-2764-200d-1f48b-200d-1f468-1f3fb":0,"1f468-1f3fb-200d-2764-200d-1f48b-200d-1f468-1f3fc":0,"1f468-1f3fb-200d-2764-200d-1f48b-200d-1f468-1f3fd":0,"1f468-1f3fb-200d-2764-200d-1f48b-200d-1f468-1f3fe":0,"1f468-1f3fb-200d-2764-200d-1f48b-200d-1f468-1f3ff":0,"1f468-1f3fc-200d-2764-200d-1f48b-200d-1f468-1f3fb":0,"1f468-1f3fc-200d-2764-200d-1f48b-200d-1f468-1f3fc":0,"1f468-1f3fc-200d-2764-200d-1f48b-200d-1f468-1f3fd":0,"1f468-1f3fc-200d-2764-200d-1f48b-200d-1f468-1f3fe":0,"1f468-1f3fc-200d-2764-200d-1f48b-200d-1f468-1f3ff":0,"1f468-1f3fd-200d-2764-200d-1f48b-200d-1f468-1f3fb":0,"1f468-1f3fd-200d-2764-200d-1f48b-200d-1f468-1f3fc":0,"1f468-1f3fd-200d-2764-200d-1f48b-200d-1f468-1f3fd":0,"1f468-1f3fd-200d-2764-200d-1f48b-200d-1f468-1f3fe":0,"1f468-1f3fd-200d-2764-200d-1f48b-200d-1f468-1f3ff":0,"1f468-1f3fe-200d-2764-200d-1f48b-200d-1f468-1f3fb":0,"1f468-1f3fe-200d-2764-200d-1f48b-200d-1f468-1f3fc":0,"1f468-1f3fe-200d-2764-200d-1f48b-200d-1f468-1f3fd":0,"1f468-1f3fe-200d-2764-200d-1f48b-200d-1f468-1f3fe":0,"1f468-1f3fe-200d-2764-200d-1f48b-200d-1f468-1f3ff":0,"1f468-1f3ff-200d-2764-200d-1f48b-200d-1f468-1f3fb":0,"1f468-1f3ff-200d-2764-200d-1f48b-200d-1f468-1f3fc":0,"1f468-1f3ff-200d-2764-200d-1f48b-200d-1f468-1f3fd":0,"1f468-1f3ff-200d-2764-200d-1f48b-200d-1f468-1f3fe":0,"1f468-1f3ff-200d-2764-200d-1f48b-200d-1f468-1f3ff":0,"1f468-1f3fb":0,"1f468-1f3fc":0,"1f468-1f3fd":0,"1f468-1f3fe":0,"1f468-1f3ff":0,"1f469-1f3fb-200d-1f33e":0,"1f469-1f3fc-200d-1f33e":0,"1f469-1f3fd-200d-1f33e":0,"1f469-1f3fe-200d-1f33e":0,"1f469-1f3ff-200d-1f33e":0,"1f469-1f3fb-200d-1f373":0,"1f469-1f3fc-200d-1f373":0,"1f469-1f3fd-200d-1f373":0,"1f469-1f3fe-200d-1f373":0,"1f469-1f3ff-200d-1f373":0,"1f469-1f3fb-200d-1f37c":0,"1f469-1f3fc-200d-1f37c":0,"1f469-1f3fd-200d-1f37c":0,"1f469-1f3fe-200d-1f37c":0,"1f469-1f3ff-200d-1f37c":0,"1f469-1f3fb-200d-1f393":0,"1f469-1f3fc-200d-1f393":0,"1f469-1f3fd-200d-1f393":0,"1f469-1f3fe-200d-1f393":0,"1f469-1f3ff-200d-1f393":0,"1f469-1f3fb-200d-1f3a4":0,"1f469-1f3fc-200d-1f3a4":0,"1f469-1f3fd-200d-1f3a4":0,"1f469-1f3fe-200d-1f3a4":0,"1f469-1f3ff-200d-1f3a4":0,"1f469-1f3fb-200d-1f3a8":0,"1f469-1f3fc-200d-1f3a8":0,"1f469-1f3fd-200d-1f3a8":0,"1f469-1f3fe-200d-1f3a8":0,"1f469-1f3ff-200d-1f3a8":0,"1f469-1f3fb-200d-1f3eb":0,"1f469-1f3fc-200d-1f3eb":0,"1f469-1f3fd-200d-1f3eb":0,"1f469-1f3fe-200d-1f3eb":0,"1f469-1f3ff-200d-1f3eb":0,"1f469-1f3fb-200d-1f3ed":0,"1f469-1f3fc-200d-1f3ed":0,"1f469-1f3fd-200d-1f3ed":0,"1f469-1f3fe-200d-1f3ed":0,"1f469-1f3ff-200d-1f3ed":0,"1f469-1f3fb-200d-1f4bb":0,"1f469-1f3fc-200d-1f4bb":0,"1f469-1f3fd-200d-1f4bb":0,"1f469-1f3fe-200d-1f4bb":0,"1f469-1f3ff-200d-1f4bb":0,"1f469-1f3fb-200d-1f4bc":0,"1f469-1f3fc-200d-1f4bc":0,"1f469-1f3fd-200d-1f4bc":0,"1f469-1f3fe-200d-1f4bc":0,"1f469-1f3ff-200d-1f4bc":0,"1f469-1f3fb-200d-1f527":0,"1f469-1f3fc-200d-1f527":0,"1f469-1f3fd-200d-1f527":0,"1f469-1f3fe-200d-1f527":0,"1f469-1f3ff-200d-1f527":0,"1f469-1f3fb-200d-1f52c":0,"1f469-1f3fc-200d-1f52c":0,"1f469-1f3fd-200d-1f52c":0,"1f469-1f3fe-200d-1f52c":0,"1f469-1f3ff-200d-1f52c":0,"1f469-1f3fb-200d-1f680":0,"1f469-1f3fc-200d-1f680":0,"1f469-1f3fd-200d-1f680":0,"1f469-1f3fe-200d-1f680":0,"1f469-1f3ff-200d-1f680":0,"1f469-1f3fb-200d-1f692":0,"1f469-1f3fc-200d-1f692":0,"1f469-1f3fd-200d-1f692":0,"1f469-1f3fe-200d-1f692":0,"1f469-1f3ff-200d-1f692":0,"1f469-1f3fb-200d-1f9af":0,"1f469-1f3fc-200d-1f9af":0,"1f469-1f3fd-200d-1f9af":0,"1f469-1f3fe-200d-1f9af":0,"1f469-1f3ff-200d-1f9af":0,"1f469-1f3fb-200d-1f9b0":0,"1f469-1f3fc-200d-1f9b0":0,"1f469-1f3fd-200d-1f9b0":0,"1f469-1f3fe-200d-1f9b0":0,"1f469-1f3ff-200d-1f9b0":0,"1f469-1f3fb-200d-1f9b1":0,"1f469-1f3fc-200d-1f9b1":0,"1f469-1f3fd-200d-1f9b1":0,"1f469-1f3fe-200d-1f9b1":0,"1f469-1f3ff-200d-1f9b1":0,"1f469-1f3fb-200d-1f9b2":0,"1f469-1f3fc-200d-1f9b2":0,"1f469-1f3fd-200d-1f9b2":0,"1f469-1f3fe-200d-1f9b2":0,"1f469-1f3ff-200d-1f9b2":0,"1f469-1f3fb-200d-1f9b3":0,"1f469-1f3fc-200d-1f9b3":0,"1f469-1f3fd-200d-1f9b3":0,"1f469-1f3fe-200d-1f9b3":0,"1f469-1f3ff-200d-1f9b3":0,"1f469-1f3fb-200d-1f9bc":0,"1f469-1f3fc-200d-1f9bc":0,"1f469-1f3fd-200d-1f9bc":0,"1f469-1f3fe-200d-1f9bc":0,"1f469-1f3ff-200d-1f9bc":0,"1f469-1f3fb-200d-1f9bd":0,"1f469-1f3fc-200d-1f9bd":0,"1f469-1f3fd-200d-1f9bd":0,"1f469-1f3fe-200d-1f9bd":0,"1f469-1f3ff-200d-1f9bd":0,"1f469-1f3fb-200d-2695":0,"1f469-1f3fc-200d-2695":0,"1f469-1f3fd-200d-2695":0,"1f469-1f3fe-200d-2695":0,"1f469-1f3ff-200d-2695":0,"1f469-1f3fb-200d-2696":0,"1f469-1f3fc-200d-2696":0,"1f469-1f3fd-200d-2696":0,"1f469-1f3fe-200d-2696":0,"1f469-1f3ff-200d-2696":0,"1f469-1f3fb-200d-2708":0,"1f469-1f3fc-200d-2708":0,"1f469-1f3fd-200d-2708":0,"1f469-1f3fe-200d-2708":0,"1f469-1f3ff-200d-2708":0,"1f469-1f3fb-200d-2764-200d-1f468-1f3fb":0,"1f469-1f3fb-200d-2764-200d-1f468-1f3fc":0,"1f469-1f3fb-200d-2764-200d-1f468-1f3fd":0,"1f469-1f3fb-200d-2764-200d-1f468-1f3fe":0,"1f469-1f3fb-200d-2764-200d-1f468-1f3ff":0,"1f469-1f3fc-200d-2764-200d-1f468-1f3fb":0,"1f469-1f3fc-200d-2764-200d-1f468-1f3fc":0,"1f469-1f3fc-200d-2764-200d-1f468-1f3fd":0,"1f469-1f3fc-200d-2764-200d-1f468-1f3fe":0,"1f469-1f3fc-200d-2764-200d-1f468-1f3ff":0,"1f469-1f3fd-200d-2764-200d-1f468-1f3fb":0,"1f469-1f3fd-200d-2764-200d-1f468-1f3fc":0,"1f469-1f3fd-200d-2764-200d-1f468-1f3fd":0,"1f469-1f3fd-200d-2764-200d-1f468-1f3fe":0,"1f469-1f3fd-200d-2764-200d-1f468-1f3ff":0,"1f469-1f3fe-200d-2764-200d-1f468-1f3fb":0,"1f469-1f3fe-200d-2764-200d-1f468-1f3fc":0,"1f469-1f3fe-200d-2764-200d-1f468-1f3fd":0,"1f469-1f3fe-200d-2764-200d-1f468-1f3fe":0,"1f469-1f3fe-200d-2764-200d-1f468-1f3ff":0,"1f469-1f3ff-200d-2764-200d-1f468-1f3fb":0,"1f469-1f3ff-200d-2764-200d-1f468-1f3fc":0,"1f469-1f3ff-200d-2764-200d-1f468-1f3fd":0,"1f469-1f3ff-200d-2764-200d-1f468-1f3fe":0,"1f469-1f3ff-200d-2764-200d-1f468-1f3ff":0,"1f469-1f3fb-200d-2764-200d-1f469-1f3fb":0,"1f469-1f3fb-200d-2764-200d-1f469-1f3fc":0,"1f469-1f3fb-200d-2764-200d-1f469-1f3fd":0,"1f469-1f3fb-200d-2764-200d-1f469-1f3fe":0,"1f469-1f3fb-200d-2764-200d-1f469-1f3ff":0,"1f469-1f3fc-200d-2764-200d-1f469-1f3fb":0,"1f469-1f3fc-200d-2764-200d-1f469-1f3fc":0,"1f469-1f3fc-200d-2764-200d-1f469-1f3fd":0,"1f469-1f3fc-200d-2764-200d-1f469-1f3fe":0,"1f469-1f3fc-200d-2764-200d-1f469-1f3ff":0,"1f469-1f3fd-200d-2764-200d-1f469-1f3fb":0,"1f469-1f3fd-200d-2764-200d-1f469-1f3fc":0,"1f469-1f3fd-200d-2764-200d-1f469-1f3fd":0,"1f469-1f3fd-200d-2764-200d-1f469-1f3fe":0,"1f469-1f3fd-200d-2764-200d-1f469-1f3ff":0,"1f469-1f3fe-200d-2764-200d-1f469-1f3fb":0,"1f469-1f3fe-200d-2764-200d-1f469-1f3fc":0,"1f469-1f3fe-200d-2764-200d-1f469-1f3fd":0,"1f469-1f3fe-200d-2764-200d-1f469-1f3fe":0,"1f469-1f3fe-200d-2764-200d-1f469-1f3ff":0,"1f469-1f3ff-200d-2764-200d-1f469-1f3fb":0,"1f469-1f3ff-200d-2764-200d-1f469-1f3fc":0,"1f469-1f3ff-200d-2764-200d-1f469-1f3fd":0,"1f469-1f3ff-200d-2764-200d-1f469-1f3fe":0,"1f469-1f3ff-200d-2764-200d-1f469-1f3ff":0,"1f469-1f3fb-200d-2764-200d-1f48b-200d-1f468-1f3fb":0,"1f469-1f3fb-200d-2764-200d-1f48b-200d-1f468-1f3fc":0,"1f469-1f3fb-200d-2764-200d-1f48b-200d-1f468-1f3fd":0,"1f469-1f3fb-200d-2764-200d-1f48b-200d-1f468-1f3fe":0,"1f469-1f3fb-200d-2764-200d-1f48b-200d-1f468-1f3ff":0,"1f469-1f3fc-200d-2764-200d-1f48b-200d-1f468-1f3fb":0,"1f469-1f3fc-200d-2764-200d-1f48b-200d-1f468-1f3fc":0,"1f469-1f3fc-200d-2764-200d-1f48b-200d-1f468-1f3fd":0,"1f469-1f3fc-200d-2764-200d-1f48b-200d-1f468-1f3fe":0,"1f469-1f3fc-200d-2764-200d-1f48b-200d-1f468-1f3ff":0,"1f469-1f3fd-200d-2764-200d-1f48b-200d-1f468-1f3fb":0,"1f469-1f3fd-200d-2764-200d-1f48b-200d-1f468-1f3fc":0,"1f469-1f3fd-200d-2764-200d-1f48b-200d-1f468-1f3fd":0,"1f469-1f3fd-200d-2764-200d-1f48b-200d-1f468-1f3fe":0,"1f469-1f3fd-200d-2764-200d-1f48b-200d-1f468-1f3ff":0,"1f469-1f3fe-200d-2764-200d-1f48b-200d-1f468-1f3fb":0,"1f469-1f3fe-200d-2764-200d-1f48b-200d-1f468-1f3fc":0,"1f469-1f3fe-200d-2764-200d-1f48b-200d-1f468-1f3fd":0,"1f469-1f3fe-200d-2764-200d-1f48b-200d-1f468-1f3fe":0,"1f469-1f3fe-200d-2764-200d-1f48b-200d-1f468-1f3ff":0,"1f469-1f3ff-200d-2764-200d-1f48b-200d-1f468-1f3fb":0,"1f469-1f3ff-200d-2764-200d-1f48b-200d-1f468-1f3fc":0,"1f469-1f3ff-200d-2764-200d-1f48b-200d-1f468-1f3fd":0,"1f469-1f3ff-200d-2764-200d-1f48b-200d-1f468-1f3fe":0,"1f469-1f3ff-200d-2764-200d-1f48b-200d-1f468-1f3ff":0,"1f469-1f3fb-200d-2764-200d-1f48b-200d-1f469-1f3fb":0,"1f469-1f3fb-200d-2764-200d-1f48b-200d-1f469-1f3fc":0,"1f469-1f3fb-200d-2764-200d-1f48b-200d-1f469-1f3fd":0,"1f469-1f3fb-200d-2764-200d-1f48b-200d-1f469-1f3fe":0,"1f469-1f3fb-200d-2764-200d-1f48b-200d-1f469-1f3ff":0,"1f469-1f3fc-200d-2764-200d-1f48b-200d-1f469-1f3fb":0,"1f469-1f3fc-200d-2764-200d-1f48b-200d-1f469-1f3fc":0,"1f469-1f3fc-200d-2764-200d-1f48b-200d-1f469-1f3fd":0,"1f469-1f3fc-200d-2764-200d-1f48b-200d-1f469-1f3fe":0,"1f469-1f3fc-200d-2764-200d-1f48b-200d-1f469-1f3ff":0,"1f469-1f3fd-200d-2764-200d-1f48b-200d-1f469-1f3fb":0,"1f469-1f3fd-200d-2764-200d-1f48b-200d-1f469-1f3fc":0,"1f469-1f3fd-200d-2764-200d-1f48b-200d-1f469-1f3fd":0,"1f469-1f3fd-200d-2764-200d-1f48b-200d-1f469-1f3fe":0,"1f469-1f3fd-200d-2764-200d-1f48b-200d-1f469-1f3ff":0,"1f469-1f3fe-200d-2764-200d-1f48b-200d-1f469-1f3fb":0,"1f469-1f3fe-200d-2764-200d-1f48b-200d-1f469-1f3fc":0,"1f469-1f3fe-200d-2764-200d-1f48b-200d-1f469-1f3fd":0,"1f469-1f3fe-200d-2764-200d-1f48b-200d-1f469-1f3fe":0,"1f469-1f3fe-200d-2764-200d-1f48b-200d-1f469-1f3ff":0,"1f469-1f3ff-200d-2764-200d-1f48b-200d-1f469-1f3fb":0,"1f469-1f3ff-200d-2764-200d-1f48b-200d-1f469-1f3fc":0,"1f469-1f3ff-200d-2764-200d-1f48b-200d-1f469-1f3fd":0,"1f469-1f3ff-200d-2764-200d-1f48b-200d-1f469-1f3fe":0,"1f469-1f3ff-200d-2764-200d-1f48b-200d-1f469-1f3ff":0,"1f469-1f3fb":0,"1f469-1f3fc":0,"1f469-1f3fd":0,"1f469-1f3fe":0,"1f469-1f3ff":0,"1f46b-1f3fb":0,"1f46b-1f3fc":0,"1f46b-1f3fd":0,"1f46b-1f3fe":0,"1f46b-1f3ff":0,"1f469-1f3fb-200d-1f91d-200d-1f468-1f3fc":0,"1f469-1f3fb-200d-1f91d-200d-1f468-1f3fd":0,"1f469-1f3fb-200d-1f91d-200d-1f468-1f3fe":0,"1f469-1f3fb-200d-1f91d-200d-1f468-1f3ff":0,"1f469-1f3fc-200d-1f91d-200d-1f468-1f3fb":0,"1f469-1f3fc-200d-1f91d-200d-1f468-1f3fd":0,"1f469-1f3fc-200d-1f91d-200d-1f468-1f3fe":0,"1f469-1f3fc-200d-1f91d-200d-1f468-1f3ff":0,"1f469-1f3fd-200d-1f91d-200d-1f468-1f3fb":0,"1f469-1f3fd-200d-1f91d-200d-1f468-1f3fc":0,"1f469-1f3fd-200d-1f91d-200d-1f468-1f3fe":0,"1f469-1f3fd-200d-1f91d-200d-1f468-1f3ff":0,"1f469-1f3fe-200d-1f91d-200d-1f468-1f3fb":0,"1f469-1f3fe-200d-1f91d-200d-1f468-1f3fc":0,"1f469-1f3fe-200d-1f91d-200d-1f468-1f3fd":0,"1f469-1f3fe-200d-1f91d-200d-1f468-1f3ff":0,"1f469-1f3ff-200d-1f91d-200d-1f468-1f3fb":0,"1f469-1f3ff-200d-1f91d-200d-1f468-1f3fc":0,"1f469-1f3ff-200d-1f91d-200d-1f468-1f3fd":0,"1f469-1f3ff-200d-1f91d-200d-1f468-1f3fe":0,"1f46c-1f3fb":0,"1f46c-1f3fc":0,"1f46c-1f3fd":0,"1f46c-1f3fe":0,"1f46c-1f3ff":0,"1f468-1f3fb-200d-1f91d-200d-1f468-1f3fc":0,"1f468-1f3fb-200d-1f91d-200d-1f468-1f3fd":0,"1f468-1f3fb-200d-1f91d-200d-1f468-1f3fe":0,"1f468-1f3fb-200d-1f91d-200d-1f468-1f3ff":0,"1f468-1f3fc-200d-1f91d-200d-1f468-1f3fb":0,"1f468-1f3fc-200d-1f91d-200d-1f468-1f3fd":0,"1f468-1f3fc-200d-1f91d-200d-1f468-1f3fe":0,"1f468-1f3fc-200d-1f91d-200d-1f468-1f3ff":0,"1f468-1f3fd-200d-1f91d-200d-1f468-1f3fb":0,"1f468-1f3fd-200d-1f91d-200d-1f468-1f3fc":0,"1f468-1f3fd-200d-1f91d-200d-1f468-1f3fe":0,"1f468-1f3fd-200d-1f91d-200d-1f468-1f3ff":0,"1f468-1f3fe-200d-1f91d-200d-1f468-1f3fb":0,"1f468-1f3fe-200d-1f91d-200d-1f468-1f3fc":0,"1f468-1f3fe-200d-1f91d-200d-1f468-1f3fd":0,"1f468-1f3fe-200d-1f91d-200d-1f468-1f3ff":0,"1f468-1f3ff-200d-1f91d-200d-1f468-1f3fb":0,"1f468-1f3ff-200d-1f91d-200d-1f468-1f3fc":0,"1f468-1f3ff-200d-1f91d-200d-1f468-1f3fd":0,"1f468-1f3ff-200d-1f91d-200d-1f468-1f3fe":0,"1f46d-1f3fb":0,"1f46d-1f3fc":0,"1f46d-1f3fd":0,"1f46d-1f3fe":0,"1f46d-1f3ff":0,"1f469-1f3fb-200d-1f91d-200d-1f469-1f3fc":0,"1f469-1f3fb-200d-1f91d-200d-1f469-1f3fd":0,"1f469-1f3fb-200d-1f91d-200d-1f469-1f3fe":0,"1f469-1f3fb-200d-1f91d-200d-1f469-1f3ff":0,"1f469-1f3fc-200d-1f91d-200d-1f469-1f3fb":0,"1f469-1f3fc-200d-1f91d-200d-1f469-1f3fd":0,"1f469-1f3fc-200d-1f91d-200d-1f469-1f3fe":0,"1f469-1f3fc-200d-1f91d-200d-1f469-1f3ff":0,"1f469-1f3fd-200d-1f91d-200d-1f469-1f3fb":0,"1f469-1f3fd-200d-1f91d-200d-1f469-1f3fc":0,"1f469-1f3fd-200d-1f91d-200d-1f469-1f3fe":0,"1f469-1f3fd-200d-1f91d-200d-1f469-1f3ff":0,"1f469-1f3fe-200d-1f91d-200d-1f469-1f3fb":0,"1f469-1f3fe-200d-1f91d-200d-1f469-1f3fc":0,"1f469-1f3fe-200d-1f91d-200d-1f469-1f3fd":0,"1f469-1f3fe-200d-1f91d-200d-1f469-1f3ff":0,"1f469-1f3ff-200d-1f91d-200d-1f469-1f3fb":0,"1f469-1f3ff-200d-1f91d-200d-1f469-1f3fc":0,"1f469-1f3ff-200d-1f91d-200d-1f469-1f3fd":0,"1f469-1f3ff-200d-1f91d-200d-1f469-1f3fe":0,"1f46e-1f3fb-200d-2640":0,"1f46e-1f3fc-200d-2640":0,"1f46e-1f3fd-200d-2640":0,"1f46e-1f3fe-200d-2640":0,"1f46e-1f3ff-200d-2640":0,"1f46e-1f3fb-200d-2642":0,"1f46e-1f3fc-200d-2642":0,"1f46e-1f3fd-200d-2642":0,"1f46e-1f3fe-200d-2642":0,"1f46e-1f3ff-200d-2642":0,"1f46e-1f3fb":0,"1f46e-1f3fc":0,"1f46e-1f3fd":0,"1f46e-1f3fe":0,"1f46e-1f3ff":0,"1f470-1f3fb-200d-2640":0,"1f470-1f3fc-200d-2640":0,"1f470-1f3fd-200d-2640":0,"1f470-1f3fe-200d-2640":0,"1f470-1f3ff-200d-2640":0,"1f470-1f3fb-200d-2642":0,"1f470-1f3fc-200d-2642":0,"1f470-1f3fd-200d-2642":0,"1f470-1f3fe-200d-2642":0,"1f470-1f3ff-200d-2642":0,"1f470-1f3fb":0,"1f470-1f3fc":0,"1f470-1f3fd":0,"1f470-1f3fe":0,"1f470-1f3ff":0,"1f471-1f3fb-200d-2640":0,"1f471-1f3fc-200d-2640":0,"1f471-1f3fd-200d-2640":0,"1f471-1f3fe-200d-2640":0,"1f471-1f3ff-200d-2640":0,"1f471-1f3fb-200d-2642":0,"1f471-1f3fc-200d-2642":0,"1f471-1f3fd-200d-2642":0,"1f471-1f3fe-200d-2642":0,"1f471-1f3ff-200d-2642":0,"1f471-1f3fb":0,"1f471-1f3fc":0,"1f471-1f3fd":0,"1f471-1f3fe":0,"1f471-1f3ff":0,"1f472-1f3fb":0,"1f472-1f3fc":0,"1f472-1f3fd":0,"1f472-1f3fe":0,"1f472-1f3ff":0,"1f473-1f3fb-200d-2640":0,"1f473-1f3fc-200d-2640":0,"1f473-1f3fd-200d-2640":0,"1f473-1f3fe-200d-2640":0,"1f473-1f3ff-200d-2640":0,"1f473-1f3fb-200d-2642":0,"1f473-1f3fc-200d-2642":0,"1f473-1f3fd-200d-2642":0,"1f473-1f3fe-200d-2642":0,"1f473-1f3ff-200d-2642":0,"1f473-1f3fb":0,"1f473-1f3fc":0,"1f473-1f3fd":0,"1f473-1f3fe":0,"1f473-1f3ff":0,"1f474-1f3fb":0,"1f474-1f3fc":0,"1f474-1f3fd":0,"1f474-1f3fe":0,"1f474-1f3ff":0,"1f475-1f3fb":0,"1f475-1f3fc":0,"1f475-1f3fd":0,"1f475-1f3fe":0,"1f475-1f3ff":0,"1f476-1f3fb":0,"1f476-1f3fc":0,"1f476-1f3fd":0,"1f476-1f3fe":0,"1f476-1f3ff":0,"1f477-1f3fb-200d-2640":0,"1f477-1f3fc-200d-2640":0,"1f477-1f3fd-200d-2640":0,"1f477-1f3fe-200d-2640":0,"1f477-1f3ff-200d-2640":0,"1f477-1f3fb-200d-2642":0,"1f477-1f3fc-200d-2642":0,"1f477-1f3fd-200d-2642":0,"1f477-1f3fe-200d-2642":0,"1f477-1f3ff-200d-2642":0,"1f477-1f3fb":0,"1f477-1f3fc":0,"1f477-1f3fd":0,"1f477-1f3fe":0,"1f477-1f3ff":0,"1f478-1f3fb":0,"1f478-1f3fc":0,"1f478-1f3fd":0,"1f478-1f3fe":0,"1f478-1f3ff":0,"1f47c-1f3fb":0,"1f47c-1f3fc":0,"1f47c-1f3fd":0,"1f47c-1f3fe":0,"1f47c-1f3ff":0,"1f481-1f3fb-200d-2640":0,"1f481-1f3fc-200d-2640":0,"1f481-1f3fd-200d-2640":0,"1f481-1f3fe-200d-2640":0,"1f481-1f3ff-200d-2640":0,"1f481-1f3fb-200d-2642":0,"1f481-1f3fc-200d-2642":0,"1f481-1f3fd-200d-2642":0,"1f481-1f3fe-200d-2642":0,"1f481-1f3ff-200d-2642":0,"1f481-1f3fb":0,"1f481-1f3fc":0,"1f481-1f3fd":0,"1f481-1f3fe":0,"1f481-1f3ff":0,"1f482-1f3fb-200d-2640":0,"1f482-1f3fc-200d-2640":0,"1f482-1f3fd-200d-2640":0,"1f482-1f3fe-200d-2640":0,"1f482-1f3ff-200d-2640":0,"1f482-1f3fb-200d-2642":0,"1f482-1f3fc-200d-2642":0,"1f482-1f3fd-200d-2642":0,"1f482-1f3fe-200d-2642":0,"1f482-1f3ff-200d-2642":0,"1f482-1f3fb":0,"1f482-1f3fc":0,"1f482-1f3fd":0,"1f482-1f3fe":0,"1f482-1f3ff":0,"1f483-1f3fb":0,"1f483-1f3fc":0,"1f483-1f3fd":0,"1f483-1f3fe":0,"1f483-1f3ff":0,"1f485-1f3fb":0,"1f485-1f3fc":0,"1f485-1f3fd":0,"1f485-1f3fe":0,"1f485-1f3ff":0,"1f486-1f3fb-200d-2640":0,"1f486-1f3fc-200d-2640":0,"1f486-1f3fd-200d-2640":0,"1f486-1f3fe-200d-2640":0,"1f486-1f3ff-200d-2640":0,"1f486-1f3fb-200d-2642":0,"1f486-1f3fc-200d-2642":0,"1f486-1f3fd-200d-2642":0,"1f486-1f3fe-200d-2642":0,"1f486-1f3ff-200d-2642":0,"1f486-1f3fb":0,"1f486-1f3fc":0,"1f486-1f3fd":0,"1f486-1f3fe":0,"1f486-1f3ff":0,"1f487-1f3fb-200d-2640":0,"1f487-1f3fc-200d-2640":0,"1f487-1f3fd-200d-2640":0,"1f487-1f3fe-200d-2640":0,"1f487-1f3ff-200d-2640":0,"1f487-1f3fb-200d-2642":0,"1f487-1f3fc-200d-2642":0,"1f487-1f3fd-200d-2642":0,"1f487-1f3fe-200d-2642":0,"1f487-1f3ff-200d-2642":0,"1f487-1f3fb":0,"1f487-1f3fc":0,"1f487-1f3fd":0,"1f487-1f3fe":0,"1f487-1f3ff":0,"1f48f-1f3fb":0,"1f48f-1f3fc":0,"1f48f-1f3fd":0,"1f48f-1f3fe":0,"1f48f-1f3ff":0,"1f9d1-1f3fb-200d-2764-200d-1f48b-200d-1f9d1-1f3fc":0,"1f9d1-1f3fb-200d-2764-200d-1f48b-200d-1f9d1-1f3fd":0,"1f9d1-1f3fb-200d-2764-200d-1f48b-200d-1f9d1-1f3fe":0,"1f9d1-1f3fb-200d-2764-200d-1f48b-200d-1f9d1-1f3ff":0,"1f9d1-1f3fc-200d-2764-200d-1f48b-200d-1f9d1-1f3fb":0,"1f9d1-1f3fc-200d-2764-200d-1f48b-200d-1f9d1-1f3fd":0,"1f9d1-1f3fc-200d-2764-200d-1f48b-200d-1f9d1-1f3fe":0,"1f9d1-1f3fc-200d-2764-200d-1f48b-200d-1f9d1-1f3ff":0,"1f9d1-1f3fd-200d-2764-200d-1f48b-200d-1f9d1-1f3fb":0,"1f9d1-1f3fd-200d-2764-200d-1f48b-200d-1f9d1-1f3fc":0,"1f9d1-1f3fd-200d-2764-200d-1f48b-200d-1f9d1-1f3fe":0,"1f9d1-1f3fd-200d-2764-200d-1f48b-200d-1f9d1-1f3ff":0,"1f9d1-1f3fe-200d-2764-200d-1f48b-200d-1f9d1-1f3fb":0,"1f9d1-1f3fe-200d-2764-200d-1f48b-200d-1f9d1-1f3fc":0,"1f9d1-1f3fe-200d-2764-200d-1f48b-200d-1f9d1-1f3fd":0,"1f9d1-1f3fe-200d-2764-200d-1f48b-200d-1f9d1-1f3ff":0,"1f9d1-1f3ff-200d-2764-200d-1f48b-200d-1f9d1-1f3fb":0,"1f9d1-1f3ff-200d-2764-200d-1f48b-200d-1f9d1-1f3fc":0,"1f9d1-1f3ff-200d-2764-200d-1f48b-200d-1f9d1-1f3fd":0,"1f9d1-1f3ff-200d-2764-200d-1f48b-200d-1f9d1-1f3fe":0,"1f491-1f3fb":0,"1f491-1f3fc":0,"1f491-1f3fd":0,"1f491-1f3fe":0,"1f491-1f3ff":0,"1f9d1-1f3fb-200d-2764-200d-1f9d1-1f3fc":0,"1f9d1-1f3fb-200d-2764-200d-1f9d1-1f3fd":0,"1f9d1-1f3fb-200d-2764-200d-1f9d1-1f3fe":0,"1f9d1-1f3fb-200d-2764-200d-1f9d1-1f3ff":0,"1f9d1-1f3fc-200d-2764-200d-1f9d1-1f3fb":0,"1f9d1-1f3fc-200d-2764-200d-1f9d1-1f3fd":0,"1f9d1-1f3fc-200d-2764-200d-1f9d1-1f3fe":0,"1f9d1-1f3fc-200d-2764-200d-1f9d1-1f3ff":0,"1f9d1-1f3fd-200d-2764-200d-1f9d1-1f3fb":0,"1f9d1-1f3fd-200d-2764-200d-1f9d1-1f3fc":0,"1f9d1-1f3fd-200d-2764-200d-1f9d1-1f3fe":0,"1f9d1-1f3fd-200d-2764-200d-1f9d1-1f3ff":0,"1f9d1-1f3fe-200d-2764-200d-1f9d1-1f3fb":0,"1f9d1-1f3fe-200d-2764-200d-1f9d1-1f3fc":0,"1f9d1-1f3fe-200d-2764-200d-1f9d1-1f3fd":0,"1f9d1-1f3fe-200d-2764-200d-1f9d1-1f3ff":0,"1f9d1-1f3ff-200d-2764-200d-1f9d1-1f3fb":0,"1f9d1-1f3ff-200d-2764-200d-1f9d1-1f3fc":0,"1f9d1-1f3ff-200d-2764-200d-1f9d1-1f3fd":0,"1f9d1-1f3ff-200d-2764-200d-1f9d1-1f3fe":0,"1f4aa-1f3fb":0,"1f4aa-1f3fc":0,"1f4aa-1f3fd":0,"1f4aa-1f3fe":0,"1f4aa-1f3ff":0,"1f574-1f3fb":0,"1f574-1f3fc":0,"1f574-1f3fd":0,"1f574-1f3fe":0,"1f574-1f3ff":0,"1f575-1f3fb-200d-2640":0,"1f575-1f3fc-200d-2640":0,"1f575-1f3fd-200d-2640":0,"1f575-1f3fe-200d-2640":0,"1f575-1f3ff-200d-2640":0,"1f575-1f3fb-200d-2642":0,"1f575-1f3fc-200d-2642":0,"1f575-1f3fd-200d-2642":0,"1f575-1f3fe-200d-2642":0,"1f575-1f3ff-200d-2642":0,"1f575-1f3fb":0,"1f575-1f3fc":0,"1f575-1f3fd":0,"1f575-1f3fe":0,"1f575-1f3ff":0,"1f57a-1f3fb":0,"1f57a-1f3fc":0,"1f57a-1f3fd":0,"1f57a-1f3fe":0,"1f57a-1f3ff":0,"1f590-1f3fb":0,"1f590-1f3fc":0,"1f590-1f3fd":0,"1f590-1f3fe":0,"1f590-1f3ff":0,"1f595-1f3fb":0,"1f595-1f3fc":0,"1f595-1f3fd":0,"1f595-1f3fe":0,"1f595-1f3ff":0,"1f596-1f3fb":0,"1f596-1f3fc":0,"1f596-1f3fd":0,"1f596-1f3fe":0,"1f596-1f3ff":0,"1f645-1f3fb-200d-2640":0,"1f645-1f3fc-200d-2640":0,"1f645-1f3fd-200d-2640":0,"1f645-1f3fe-200d-2640":0,"1f645-1f3ff-200d-2640":0,"1f645-1f3fb-200d-2642":0,"1f645-1f3fc-200d-2642":0,"1f645-1f3fd-200d-2642":0,"1f645-1f3fe-200d-2642":0,"1f645-1f3ff-200d-2642":0,"1f645-1f3fb":0,"1f645-1f3fc":0,"1f645-1f3fd":0,"1f645-1f3fe":0,"1f645-1f3ff":0,"1f646-1f3fb-200d-2640":0,"1f646-1f3fc-200d-2640":0,"1f646-1f3fd-200d-2640":0,"1f646-1f3fe-200d-2640":0,"1f646-1f3ff-200d-2640":0,"1f646-1f3fb-200d-2642":0,"1f646-1f3fc-200d-2642":0,"1f646-1f3fd-200d-2642":0,"1f646-1f3fe-200d-2642":0,"1f646-1f3ff-200d-2642":0,"1f646-1f3fb":0,"1f646-1f3fc":0,"1f646-1f3fd":0,"1f646-1f3fe":0,"1f646-1f3ff":0,"1f647-1f3fb-200d-2640":0,"1f647-1f3fc-200d-2640":0,"1f647-1f3fd-200d-2640":0,"1f647-1f3fe-200d-2640":0,"1f647-1f3ff-200d-2640":0,"1f647-1f3fb-200d-2642":0,"1f647-1f3fc-200d-2642":0,"1f647-1f3fd-200d-2642":0,"1f647-1f3fe-200d-2642":0,"1f647-1f3ff-200d-2642":0,"1f647-1f3fb":0,"1f647-1f3fc":0,"1f647-1f3fd":0,"1f647-1f3fe":0,"1f647-1f3ff":0,"1f64b-1f3fb-200d-2640":0,"1f64b-1f3fc-200d-2640":0,"1f64b-1f3fd-200d-2640":0,"1f64b-1f3fe-200d-2640":0,"1f64b-1f3ff-200d-2640":0,"1f64b-1f3fb-200d-2642":0,"1f64b-1f3fc-200d-2642":0,"1f64b-1f3fd-200d-2642":0,"1f64b-1f3fe-200d-2642":0,"1f64b-1f3ff-200d-2642":0,"1f64b-1f3fb":0,"1f64b-1f3fc":0,"1f64b-1f3fd":0,"1f64b-1f3fe":0,"1f64b-1f3ff":0,"1f64c-1f3fb":0,"1f64c-1f3fc":0,"1f64c-1f3fd":0,"1f64c-1f3fe":0,"1f64c-1f3ff":0,"1f64d-1f3fb-200d-2640":0,"1f64d-1f3fc-200d-2640":0,"1f64d-1f3fd-200d-2640":0,"1f64d-1f3fe-200d-2640":0,"1f64d-1f3ff-200d-2640":0,"1f64d-1f3fb-200d-2642":0,"1f64d-1f3fc-200d-2642":0,"1f64d-1f3fd-200d-2642":0,"1f64d-1f3fe-200d-2642":0,"1f64d-1f3ff-200d-2642":0,"1f64d-1f3fb":0,"1f64d-1f3fc":0,"1f64d-1f3fd":0,"1f64d-1f3fe":0,"1f64d-1f3ff":0,"1f64e-1f3fb-200d-2640":0,"1f64e-1f3fc-200d-2640":0,"1f64e-1f3fd-200d-2640":0,"1f64e-1f3fe-200d-2640":0,"1f64e-1f3ff-200d-2640":0,"1f64e-1f3fb-200d-2642":0,"1f64e-1f3fc-200d-2642":0,"1f64e-1f3fd-200d-2642":0,"1f64e-1f3fe-200d-2642":0,"1f64e-1f3ff-200d-2642":0,"1f64e-1f3fb":0,"1f64e-1f3fc":0,"1f64e-1f3fd":0,"1f64e-1f3fe":0,"1f64e-1f3ff":0,"1f64f-1f3fb":0,"1f64f-1f3fc":0,"1f64f-1f3fd":0,"1f64f-1f3fe":0,"1f64f-1f3ff":0,"1f6a3-1f3fb-200d-2640":0,"1f6a3-1f3fc-200d-2640":0,"1f6a3-1f3fd-200d-2640":0,"1f6a3-1f3fe-200d-2640":0,"1f6a3-1f3ff-200d-2640":0,"1f6a3-1f3fb-200d-2642":0,"1f6a3-1f3fc-200d-2642":0,"1f6a3-1f3fd-200d-2642":0,"1f6a3-1f3fe-200d-2642":0,"1f6a3-1f3ff-200d-2642":0,"1f6a3-1f3fb":0,"1f6a3-1f3fc":0,"1f6a3-1f3fd":0,"1f6a3-1f3fe":0,"1f6a3-1f3ff":0,"1f6b4-1f3fb-200d-2640":0,"1f6b4-1f3fc-200d-2640":0,"1f6b4-1f3fd-200d-2640":0,"1f6b4-1f3fe-200d-2640":0,"1f6b4-1f3ff-200d-2640":0,"1f6b4-1f3fb-200d-2642":0,"1f6b4-1f3fc-200d-2642":0,"1f6b4-1f3fd-200d-2642":0,"1f6b4-1f3fe-200d-2642":0,"1f6b4-1f3ff-200d-2642":0,"1f6b4-1f3fb":0,"1f6b4-1f3fc":0,"1f6b4-1f3fd":0,"1f6b4-1f3fe":0,"1f6b4-1f3ff":0,"1f6b5-1f3fb-200d-2640":0,"1f6b5-1f3fc-200d-2640":0,"1f6b5-1f3fd-200d-2640":0,"1f6b5-1f3fe-200d-2640":0,"1f6b5-1f3ff-200d-2640":0,"1f6b5-1f3fb-200d-2642":0,"1f6b5-1f3fc-200d-2642":0,"1f6b5-1f3fd-200d-2642":0,"1f6b5-1f3fe-200d-2642":0,"1f6b5-1f3ff-200d-2642":0,"1f6b5-1f3fb":0,"1f6b5-1f3fc":0,"1f6b5-1f3fd":0,"1f6b5-1f3fe":0,"1f6b5-1f3ff":0,"1f6b6-1f3fb-200d-2640":0,"1f6b6-1f3fc-200d-2640":0,"1f6b6-1f3fd-200d-2640":0,"1f6b6-1f3fe-200d-2640":0,"1f6b6-1f3ff-200d-2640":0,"1f6b6-1f3fb-200d-2642":0,"1f6b6-1f3fc-200d-2642":0,"1f6b6-1f3fd-200d-2642":0,"1f6b6-1f3fe-200d-2642":0,"1f6b6-1f3ff-200d-2642":0,"1f6b6-1f3fb":0,"1f6b6-1f3fc":0,"1f6b6-1f3fd":0,"1f6b6-1f3fe":0,"1f6b6-1f3ff":0,"1f6c0-1f3fb":0,"1f6c0-1f3fc":0,"1f6c0-1f3fd":0,"1f6c0-1f3fe":0,"1f6c0-1f3ff":0,"1f6cc-1f3fb":0,"1f6cc-1f3fc":0,"1f6cc-1f3fd":0,"1f6cc-1f3fe":0,"1f6cc-1f3ff":0,"1f90c-1f3fb":0,"1f90c-1f3fc":0,"1f90c-1f3fd":0,"1f90c-1f3fe":0,"1f90c-1f3ff":0,"1f90f-1f3fb":0,"1f90f-1f3fc":0,"1f90f-1f3fd":0,"1f90f-1f3fe":0,"1f90f-1f3ff":0,"1f918-1f3fb":0,"1f918-1f3fc":0,"1f918-1f3fd":0,"1f918-1f3fe":0,"1f918-1f3ff":0,"1f919-1f3fb":0,"1f919-1f3fc":0,"1f919-1f3fd":0,"1f919-1f3fe":0,"1f919-1f3ff":0,"1f91a-1f3fb":0,"1f91a-1f3fc":0,"1f91a-1f3fd":0,"1f91a-1f3fe":0,"1f91a-1f3ff":0,"1f91b-1f3fb":0,"1f91b-1f3fc":0,"1f91b-1f3fd":0,"1f91b-1f3fe":0,"1f91b-1f3ff":0,"1f91c-1f3fb":0,"1f91c-1f3fc":0,"1f91c-1f3fd":0,"1f91c-1f3fe":0,"1f91c-1f3ff":0,"1f91d-1f3fb":0,"1f91d-1f3fc":0,"1f91d-1f3fd":0,"1f91d-1f3fe":0,"1f91d-1f3ff":0,"1f91e-1f3fb":0,"1f91e-1f3fc":0,"1f91e-1f3fd":0,"1f91e-1f3fe":0,"1f91e-1f3ff":0,"1f91f-1f3fb":0,"1f91f-1f3fc":0,"1f91f-1f3fd":0,"1f91f-1f3fe":0,"1f91f-1f3ff":0,"1f926-1f3fb-200d-2640":0,"1f926-1f3fc-200d-2640":0,"1f926-1f3fd-200d-2640":0,"1f926-1f3fe-200d-2640":0,"1f926-1f3ff-200d-2640":0,"1f926-1f3fb-200d-2642":0,"1f926-1f3fc-200d-2642":0,"1f926-1f3fd-200d-2642":0,"1f926-1f3fe-200d-2642":0,"1f926-1f3ff-200d-2642":0,"1f926-1f3fb":0,"1f926-1f3fc":0,"1f926-1f3fd":0,"1f926-1f3fe":0,"1f926-1f3ff":0,"1f930-1f3fb":0,"1f930-1f3fc":0,"1f930-1f3fd":0,"1f930-1f3fe":0,"1f930-1f3ff":0,"1f931-1f3fb":0,"1f931-1f3fc":0,"1f931-1f3fd":0,"1f931-1f3fe":0,"1f931-1f3ff":0,"1f932-1f3fb":0,"1f932-1f3fc":0,"1f932-1f3fd":0,"1f932-1f3fe":0,"1f932-1f3ff":0,"1f933-1f3fb":0,"1f933-1f3fc":0,"1f933-1f3fd":0,"1f933-1f3fe":0,"1f933-1f3ff":0,"1f934-1f3fb":0,"1f934-1f3fc":0,"1f934-1f3fd":0,"1f934-1f3fe":0,"1f934-1f3ff":0,"1f935-1f3fb-200d-2640":0,"1f935-1f3fc-200d-2640":0,"1f935-1f3fd-200d-2640":0,"1f935-1f3fe-200d-2640":0,"1f935-1f3ff-200d-2640":0,"1f935-1f3fb-200d-2642":0,"1f935-1f3fc-200d-2642":0,"1f935-1f3fd-200d-2642":0,"1f935-1f3fe-200d-2642":0,"1f935-1f3ff-200d-2642":0,"1f935-1f3fb":0,"1f935-1f3fc":0,"1f935-1f3fd":0,"1f935-1f3fe":0,"1f935-1f3ff":0,"1f936-1f3fb":0,"1f936-1f3fc":0,"1f936-1f3fd":0,"1f936-1f3fe":0,"1f936-1f3ff":0,"1f937-1f3fb-200d-2640":0,"1f937-1f3fc-200d-2640":0,"1f937-1f3fd-200d-2640":0,"1f937-1f3fe-200d-2640":0,"1f937-1f3ff-200d-2640":0,"1f937-1f3fb-200d-2642":0,"1f937-1f3fc-200d-2642":0,"1f937-1f3fd-200d-2642":0,"1f937-1f3fe-200d-2642":0,"1f937-1f3ff-200d-2642":0,"1f937-1f3fb":0,"1f937-1f3fc":0,"1f937-1f3fd":0,"1f937-1f3fe":0,"1f937-1f3ff":0,"1f938-1f3fb-200d-2640":0,"1f938-1f3fc-200d-2640":0,"1f938-1f3fd-200d-2640":0,"1f938-1f3fe-200d-2640":0,"1f938-1f3ff-200d-2640":0,"1f938-1f3fb-200d-2642":0,"1f938-1f3fc-200d-2642":0,"1f938-1f3fd-200d-2642":0,"1f938-1f3fe-200d-2642":0,"1f938-1f3ff-200d-2642":0,"1f938-1f3fb":0,"1f938-1f3fc":0,"1f938-1f3fd":0,"1f938-1f3fe":0,"1f938-1f3ff":0,"1f939-1f3fb-200d-2640":0,"1f939-1f3fc-200d-2640":0,"1f939-1f3fd-200d-2640":0,"1f939-1f3fe-200d-2640":0,"1f939-1f3ff-200d-2640":0,"1f939-1f3fb-200d-2642":0,"1f939-1f3fc-200d-2642":0,"1f939-1f3fd-200d-2642":0,"1f939-1f3fe-200d-2642":0,"1f939-1f3ff-200d-2642":0,"1f939-1f3fb":0,"1f939-1f3fc":0,"1f939-1f3fd":0,"1f939-1f3fe":0,"1f939-1f3ff":0,"1f93d-1f3fb-200d-2640":0,"1f93d-1f3fc-200d-2640":0,"1f93d-1f3fd-200d-2640":0,"1f93d-1f3fe-200d-2640":0,"1f93d-1f3ff-200d-2640":0,"1f93d-1f3fb-200d-2642":0,"1f93d-1f3fc-200d-2642":0,"1f93d-1f3fd-200d-2642":0,"1f93d-1f3fe-200d-2642":0,"1f93d-1f3ff-200d-2642":0,"1f93d-1f3fb":0,"1f93d-1f3fc":0,"1f93d-1f3fd":0,"1f93d-1f3fe":0,"1f93d-1f3ff":0,"1f93e-1f3fb-200d-2640":0,"1f93e-1f3fc-200d-2640":0,"1f93e-1f3fd-200d-2640":0,"1f93e-1f3fe-200d-2640":0,"1f93e-1f3ff-200d-2640":0,"1f93e-1f3fb-200d-2642":0,"1f93e-1f3fc-200d-2642":0,"1f93e-1f3fd-200d-2642":0,"1f93e-1f3fe-200d-2642":0,"1f93e-1f3ff-200d-2642":0,"1f93e-1f3fb":0,"1f93e-1f3fc":0,"1f93e-1f3fd":0,"1f93e-1f3fe":0,"1f93e-1f3ff":0,"1f977-1f3fb":0,"1f977-1f3fc":0,"1f977-1f3fd":0,"1f977-1f3fe":0,"1f977-1f3ff":0,"1f9b5-1f3fb":0,"1f9b5-1f3fc":0,"1f9b5-1f3fd":0,"1f9b5-1f3fe":0,"1f9b5-1f3ff":0,"1f9b6-1f3fb":0,"1f9b6-1f3fc":0,"1f9b6-1f3fd":0,"1f9b6-1f3fe":0,"1f9b6-1f3ff":0,"1f9b8-1f3fb-200d-2640":0,"1f9b8-1f3fc-200d-2640":0,"1f9b8-1f3fd-200d-2640":0,"1f9b8-1f3fe-200d-2640":0,"1f9b8-1f3ff-200d-2640":0,"1f9b8-1f3fb-200d-2642":0,"1f9b8-1f3fc-200d-2642":0,"1f9b8-1f3fd-200d-2642":0,"1f9b8-1f3fe-200d-2642":0,"1f9b8-1f3ff-200d-2642":0,"1f9b8-1f3fb":0,"1f9b8-1f3fc":0,"1f9b8-1f3fd":0,"1f9b8-1f3fe":0,"1f9b8-1f3ff":0,"1f9b9-1f3fb-200d-2640":0,"1f9b9-1f3fc-200d-2640":0,"1f9b9-1f3fd-200d-2640":0,"1f9b9-1f3fe-200d-2640":0,"1f9b9-1f3ff-200d-2640":0,"1f9b9-1f3fb-200d-2642":0,"1f9b9-1f3fc-200d-2642":0,"1f9b9-1f3fd-200d-2642":0,"1f9b9-1f3fe-200d-2642":0,"1f9b9-1f3ff-200d-2642":0,"1f9b9-1f3fb":0,"1f9b9-1f3fc":0,"1f9b9-1f3fd":0,"1f9b9-1f3fe":0,"1f9b9-1f3ff":0,"1f9bb-1f3fb":0,"1f9bb-1f3fc":0,"1f9bb-1f3fd":0,"1f9bb-1f3fe":0,"1f9bb-1f3ff":0,"1f9cd-1f3fb-200d-2640":0,"1f9cd-1f3fc-200d-2640":0,"1f9cd-1f3fd-200d-2640":0,"1f9cd-1f3fe-200d-2640":0,"1f9cd-1f3ff-200d-2640":0,"1f9cd-1f3fb-200d-2642":0,"1f9cd-1f3fc-200d-2642":0,"1f9cd-1f3fd-200d-2642":0,"1f9cd-1f3fe-200d-2642":0,"1f9cd-1f3ff-200d-2642":0,"1f9cd-1f3fb":0,"1f9cd-1f3fc":0,"1f9cd-1f3fd":0,"1f9cd-1f3fe":0,"1f9cd-1f3ff":0,"1f9ce-1f3fb-200d-2640":0,"1f9ce-1f3fc-200d-2640":0,"1f9ce-1f3fd-200d-2640":0,"1f9ce-1f3fe-200d-2640":0,"1f9ce-1f3ff-200d-2640":0,"1f9ce-1f3fb-200d-2642":0,"1f9ce-1f3fc-200d-2642":0,"1f9ce-1f3fd-200d-2642":0,"1f9ce-1f3fe-200d-2642":0,"1f9ce-1f3ff-200d-2642":0,"1f9ce-1f3fb":0,"1f9ce-1f3fc":0,"1f9ce-1f3fd":0,"1f9ce-1f3fe":0,"1f9ce-1f3ff":0,"1f9cf-1f3fb-200d-2640":0,"1f9cf-1f3fc-200d-2640":0,"1f9cf-1f3fd-200d-2640":0,"1f9cf-1f3fe-200d-2640":0,"1f9cf-1f3ff-200d-2640":0,"1f9cf-1f3fb-200d-2642":0,"1f9cf-1f3fc-200d-2642":0,"1f9cf-1f3fd-200d-2642":0,"1f9cf-1f3fe-200d-2642":0,"1f9cf-1f3ff-200d-2642":0,"1f9cf-1f3fb":0,"1f9cf-1f3fc":0,"1f9cf-1f3fd":0,"1f9cf-1f3fe":0,"1f9cf-1f3ff":0,"1f9d1-1f3fb-200d-1f33e":0,"1f9d1-1f3fc-200d-1f33e":0,"1f9d1-1f3fd-200d-1f33e":0,"1f9d1-1f3fe-200d-1f33e":0,"1f9d1-1f3ff-200d-1f33e":0,"1f9d1-1f3fb-200d-1f373":0,"1f9d1-1f3fc-200d-1f373":0,"1f9d1-1f3fd-200d-1f373":0,"1f9d1-1f3fe-200d-1f373":0,"1f9d1-1f3ff-200d-1f373":0,"1f9d1-1f3fb-200d-1f37c":0,"1f9d1-1f3fc-200d-1f37c":0,"1f9d1-1f3fd-200d-1f37c":0,"1f9d1-1f3fe-200d-1f37c":0,"1f9d1-1f3ff-200d-1f37c":0,"1f9d1-1f3fb-200d-1f384":0,"1f9d1-1f3fc-200d-1f384":0,"1f9d1-1f3fd-200d-1f384":0,"1f9d1-1f3fe-200d-1f384":0,"1f9d1-1f3ff-200d-1f384":0,"1f9d1-1f3fb-200d-1f393":0,"1f9d1-1f3fc-200d-1f393":0,"1f9d1-1f3fd-200d-1f393":0,"1f9d1-1f3fe-200d-1f393":0,"1f9d1-1f3ff-200d-1f393":0,"1f9d1-1f3fb-200d-1f3a4":0,"1f9d1-1f3fc-200d-1f3a4":0,"1f9d1-1f3fd-200d-1f3a4":0,"1f9d1-1f3fe-200d-1f3a4":0,"1f9d1-1f3ff-200d-1f3a4":0,"1f9d1-1f3fb-200d-1f3a8":0,"1f9d1-1f3fc-200d-1f3a8":0,"1f9d1-1f3fd-200d-1f3a8":0,"1f9d1-1f3fe-200d-1f3a8":0,"1f9d1-1f3ff-200d-1f3a8":0,"1f9d1-1f3fb-200d-1f3eb":0,"1f9d1-1f3fc-200d-1f3eb":0,"1f9d1-1f3fd-200d-1f3eb":0,"1f9d1-1f3fe-200d-1f3eb":0,"1f9d1-1f3ff-200d-1f3eb":0,"1f9d1-1f3fb-200d-1f3ed":0,"1f9d1-1f3fc-200d-1f3ed":0,"1f9d1-1f3fd-200d-1f3ed":0,"1f9d1-1f3fe-200d-1f3ed":0,"1f9d1-1f3ff-200d-1f3ed":0,"1f9d1-1f3fb-200d-1f4bb":0,"1f9d1-1f3fc-200d-1f4bb":0,"1f9d1-1f3fd-200d-1f4bb":0,"1f9d1-1f3fe-200d-1f4bb":0,"1f9d1-1f3ff-200d-1f4bb":0,"1f9d1-1f3fb-200d-1f4bc":0,"1f9d1-1f3fc-200d-1f4bc":0,"1f9d1-1f3fd-200d-1f4bc":0,"1f9d1-1f3fe-200d-1f4bc":0,"1f9d1-1f3ff-200d-1f4bc":0,"1f9d1-1f3fb-200d-1f527":0,"1f9d1-1f3fc-200d-1f527":0,"1f9d1-1f3fd-200d-1f527":0,"1f9d1-1f3fe-200d-1f527":0,"1f9d1-1f3ff-200d-1f527":0,"1f9d1-1f3fb-200d-1f52c":0,"1f9d1-1f3fc-200d-1f52c":0,"1f9d1-1f3fd-200d-1f52c":0,"1f9d1-1f3fe-200d-1f52c":0,"1f9d1-1f3ff-200d-1f52c":0,"1f9d1-1f3fb-200d-1f680":0,"1f9d1-1f3fc-200d-1f680":0,"1f9d1-1f3fd-200d-1f680":0,"1f9d1-1f3fe-200d-1f680":0,"1f9d1-1f3ff-200d-1f680":0,"1f9d1-1f3fb-200d-1f692":0,"1f9d1-1f3fc-200d-1f692":0,"1f9d1-1f3fd-200d-1f692":0,"1f9d1-1f3fe-200d-1f692":0,"1f9d1-1f3ff-200d-1f692":0,"1f9d1-1f3fb-200d-1f91d-200d-1f9d1-1f3fb":0,"1f9d1-1f3fb-200d-1f91d-200d-1f9d1-1f3fc":0,"1f9d1-1f3fb-200d-1f91d-200d-1f9d1-1f3fd":0,"1f9d1-1f3fb-200d-1f91d-200d-1f9d1-1f3fe":0,"1f9d1-1f3fb-200d-1f91d-200d-1f9d1-1f3ff":0,"1f9d1-1f3fc-200d-1f91d-200d-1f9d1-1f3fb":0,"1f9d1-1f3fc-200d-1f91d-200d-1f9d1-1f3fc":0,"1f9d1-1f3fc-200d-1f91d-200d-1f9d1-1f3fd":0,"1f9d1-1f3fc-200d-1f91d-200d-1f9d1-1f3fe":0,"1f9d1-1f3fc-200d-1f91d-200d-1f9d1-1f3ff":0,"1f9d1-1f3fd-200d-1f91d-200d-1f9d1-1f3fb":0,"1f9d1-1f3fd-200d-1f91d-200d-1f9d1-1f3fc":0,"1f9d1-1f3fd-200d-1f91d-200d-1f9d1-1f3fd":0,"1f9d1-1f3fd-200d-1f91d-200d-1f9d1-1f3fe":0,"1f9d1-1f3fd-200d-1f91d-200d-1f9d1-1f3ff":0,"1f9d1-1f3fe-200d-1f91d-200d-1f9d1-1f3fb":0,"1f9d1-1f3fe-200d-1f91d-200d-1f9d1-1f3fc":0,"1f9d1-1f3fe-200d-1f91d-200d-1f9d1-1f3fd":0,"1f9d1-1f3fe-200d-1f91d-200d-1f9d1-1f3fe":0,"1f9d1-1f3fe-200d-1f91d-200d-1f9d1-1f3ff":0,"1f9d1-1f3ff-200d-1f91d-200d-1f9d1-1f3fb":0,"1f9d1-1f3ff-200d-1f91d-200d-1f9d1-1f3fc":0,"1f9d1-1f3ff-200d-1f91d-200d-1f9d1-1f3fd":0,"1f9d1-1f3ff-200d-1f91d-200d-1f9d1-1f3fe":0,"1f9d1-1f3ff-200d-1f91d-200d-1f9d1-1f3ff":0,"1f9d1-1f3fb-200d-1f9af":0,"1f9d1-1f3fc-200d-1f9af":0,"1f9d1-1f3fd-200d-1f9af":0,"1f9d1-1f3fe-200d-1f9af":0,"1f9d1-1f3ff-200d-1f9af":0,"1f9d1-1f3fb-200d-1f9b0":0,"1f9d1-1f3fc-200d-1f9b0":0,"1f9d1-1f3fd-200d-1f9b0":0,"1f9d1-1f3fe-200d-1f9b0":0,"1f9d1-1f3ff-200d-1f9b0":0,"1f9d1-1f3fb-200d-1f9b1":0,"1f9d1-1f3fc-200d-1f9b1":0,"1f9d1-1f3fd-200d-1f9b1":0,"1f9d1-1f3fe-200d-1f9b1":0,"1f9d1-1f3ff-200d-1f9b1":0,"1f9d1-1f3fb-200d-1f9b2":0,"1f9d1-1f3fc-200d-1f9b2":0,"1f9d1-1f3fd-200d-1f9b2":0,"1f9d1-1f3fe-200d-1f9b2":0,"1f9d1-1f3ff-200d-1f9b2":0,"1f9d1-1f3fb-200d-1f9b3":0,"1f9d1-1f3fc-200d-1f9b3":0,"1f9d1-1f3fd-200d-1f9b3":0,"1f9d1-1f3fe-200d-1f9b3":0,"1f9d1-1f3ff-200d-1f9b3":0,"1f9d1-1f3fb-200d-1f9bc":0,"1f9d1-1f3fc-200d-1f9bc":0,"1f9d1-1f3fd-200d-1f9bc":0,"1f9d1-1f3fe-200d-1f9bc":0,"1f9d1-1f3ff-200d-1f9bc":0,"1f9d1-1f3fb-200d-1f9bd":0,"1f9d1-1f3fc-200d-1f9bd":0,"1f9d1-1f3fd-200d-1f9bd":0,"1f9d1-1f3fe-200d-1f9bd":0,"1f9d1-1f3ff-200d-1f9bd":0,"1f9d1-1f3fb-200d-2695":0,"1f9d1-1f3fc-200d-2695":0,"1f9d1-1f3fd-200d-2695":0,"1f9d1-1f3fe-200d-2695":0,"1f9d1-1f3ff-200d-2695":0,"1f9d1-1f3fb-200d-2696":0,"1f9d1-1f3fc-200d-2696":0,"1f9d1-1f3fd-200d-2696":0,"1f9d1-1f3fe-200d-2696":0,"1f9d1-1f3ff-200d-2696":0,"1f9d1-1f3fb-200d-2708":0,"1f9d1-1f3fc-200d-2708":0,"1f9d1-1f3fd-200d-2708":0,"1f9d1-1f3fe-200d-2708":0,"1f9d1-1f3ff-200d-2708":0,"1f9d1-1f3fb":0,"1f9d1-1f3fc":0,"1f9d1-1f3fd":0,"1f9d1-1f3fe":0,"1f9d1-1f3ff":0,"1f9d2-1f3fb":0,"1f9d2-1f3fc":0,"1f9d2-1f3fd":0,"1f9d2-1f3fe":0,"1f9d2-1f3ff":0,"1f9d3-1f3fb":0,"1f9d3-1f3fc":0,"1f9d3-1f3fd":0,"1f9d3-1f3fe":0,"1f9d3-1f3ff":0,"1f9d4-1f3fb-200d-2640":0,"1f9d4-1f3fc-200d-2640":0,"1f9d4-1f3fd-200d-2640":0,"1f9d4-1f3fe-200d-2640":0,"1f9d4-1f3ff-200d-2640":0,"1f9d4-1f3fb-200d-2642":0,"1f9d4-1f3fc-200d-2642":0,"1f9d4-1f3fd-200d-2642":0,"1f9d4-1f3fe-200d-2642":0,"1f9d4-1f3ff-200d-2642":0,"1f9d4-1f3fb":0,"1f9d4-1f3fc":0,"1f9d4-1f3fd":0,"1f9d4-1f3fe":0,"1f9d4-1f3ff":0,"1f9d5-1f3fb":0,"1f9d5-1f3fc":0,"1f9d5-1f3fd":0,"1f9d5-1f3fe":0,"1f9d5-1f3ff":0,"1f9d6-1f3fb-200d-2640":0,"1f9d6-1f3fc-200d-2640":0,"1f9d6-1f3fd-200d-2640":0,"1f9d6-1f3fe-200d-2640":0,"1f9d6-1f3ff-200d-2640":0,"1f9d6-1f3fb-200d-2642":0,"1f9d6-1f3fc-200d-2642":0,"1f9d6-1f3fd-200d-2642":0,"1f9d6-1f3fe-200d-2642":0,"1f9d6-1f3ff-200d-2642":0,"1f9d6-1f3fb":0,"1f9d6-1f3fc":0,"1f9d6-1f3fd":0,"1f9d6-1f3fe":0,"1f9d6-1f3ff":0,"1f9d7-1f3fb-200d-2640":0,"1f9d7-1f3fc-200d-2640":0,"1f9d7-1f3fd-200d-2640":0,"1f9d7-1f3fe-200d-2640":0,"1f9d7-1f3ff-200d-2640":0,"1f9d7-1f3fb-200d-2642":0,"1f9d7-1f3fc-200d-2642":0,"1f9d7-1f3fd-200d-2642":0,"1f9d7-1f3fe-200d-2642":0,"1f9d7-1f3ff-200d-2642":0,"1f9d7-1f3fb":0,"1f9d7-1f3fc":0,"1f9d7-1f3fd":0,"1f9d7-1f3fe":0,"1f9d7-1f3ff":0,"1f9d8-1f3fb-200d-2640":0,"1f9d8-1f3fc-200d-2640":0,"1f9d8-1f3fd-200d-2640":0,"1f9d8-1f3fe-200d-2640":0,"1f9d8-1f3ff-200d-2640":0,"1f9d8-1f3fb-200d-2642":0,"1f9d8-1f3fc-200d-2642":0,"1f9d8-1f3fd-200d-2642":0,"1f9d8-1f3fe-200d-2642":0,"1f9d8-1f3ff-200d-2642":0,"1f9d8-1f3fb":0,"1f9d8-1f3fc":0,"1f9d8-1f3fd":0,"1f9d8-1f3fe":0,"1f9d8-1f3ff":0,"1f9d9-1f3fb-200d-2640":0,"1f9d9-1f3fc-200d-2640":0,"1f9d9-1f3fd-200d-2640":0,"1f9d9-1f3fe-200d-2640":0,"1f9d9-1f3ff-200d-2640":0,"1f9d9-1f3fb-200d-2642":0,"1f9d9-1f3fc-200d-2642":0,"1f9d9-1f3fd-200d-2642":0,"1f9d9-1f3fe-200d-2642":0,"1f9d9-1f3ff-200d-2642":0,"1f9d9-1f3fb":0,"1f9d9-1f3fc":0,"1f9d9-1f3fd":0,"1f9d9-1f3fe":0,"1f9d9-1f3ff":0,"1f9da-1f3fb-200d-2640":0,"1f9da-1f3fc-200d-2640":0,"1f9da-1f3fd-200d-2640":0,"1f9da-1f3fe-200d-2640":0,"1f9da-1f3ff-200d-2640":0,"1f9da-1f3fb-200d-2642":0,"1f9da-1f3fc-200d-2642":0,"1f9da-1f3fd-200d-2642":0,"1f9da-1f3fe-200d-2642":0,"1f9da-1f3ff-200d-2642":0,"1f9da-1f3fb":0,"1f9da-1f3fc":0,"1f9da-1f3fd":0,"1f9da-1f3fe":0,"1f9da-1f3ff":0,"1f9db-1f3fb-200d-2640":0,"1f9db-1f3fc-200d-2640":0,"1f9db-1f3fd-200d-2640":0,"1f9db-1f3fe-200d-2640":0,"1f9db-1f3ff-200d-2640":0,"1f9db-1f3fb-200d-2642":0,"1f9db-1f3fc-200d-2642":0,"1f9db-1f3fd-200d-2642":0,"1f9db-1f3fe-200d-2642":0,"1f9db-1f3ff-200d-2642":0,"1f9db-1f3fb":0,"1f9db-1f3fc":0,"1f9db-1f3fd":0,"1f9db-1f3fe":0,"1f9db-1f3ff":0,"1f9dc-1f3fb-200d-2640":0,"1f9dc-1f3fc-200d-2640":0,"1f9dc-1f3fd-200d-2640":0,"1f9dc-1f3fe-200d-2640":0,"1f9dc-1f3ff-200d-2640":0,"1f9dc-1f3fb-200d-2642":0,"1f9dc-1f3fc-200d-2642":0,"1f9dc-1f3fd-200d-2642":0,"1f9dc-1f3fe-200d-2642":0,"1f9dc-1f3ff-200d-2642":0,"1f9dc-1f3fb":0,"1f9dc-1f3fc":0,"1f9dc-1f3fd":0,"1f9dc-1f3fe":0,"1f9dc-1f3ff":0,"1f9dd-1f3fb-200d-2640":0,"1f9dd-1f3fc-200d-2640":0,"1f9dd-1f3fd-200d-2640":0,"1f9dd-1f3fe-200d-2640":0,"1f9dd-1f3ff-200d-2640":0,"1f9dd-1f3fb-200d-2642":0,"1f9dd-1f3fc-200d-2642":0,"1f9dd-1f3fd-200d-2642":0,"1f9dd-1f3fe-200d-2642":0,"1f9dd-1f3ff-200d-2642":0,"1f9dd-1f3fb":0,"1f9dd-1f3fc":0,"1f9dd-1f3fd":0,"1f9dd-1f3fe":0,"1f9dd-1f3ff":0,"261d-1f3fb":0,"261d-1f3fc":0,"261d-1f3fd":0,"261d-1f3fe":0,"261d-1f3ff":0,"26f9-1f3fb-200d-2640":0,"26f9-1f3fc-200d-2640":0,"26f9-1f3fd-200d-2640":0,"26f9-1f3fe-200d-2640":0,"26f9-1f3ff-200d-2640":0,"26f9-1f3fb-200d-2642":0,"26f9-1f3fc-200d-2642":0,"26f9-1f3fd-200d-2642":0,"26f9-1f3fe-200d-2642":0,"26f9-1f3ff-200d-2642":0,"26f9-1f3fb":0,"26f9-1f3fc":0,"26f9-1f3fd":0,"26f9-1f3fe":0,"26f9-1f3ff":0,"270a-1f3fb":0,"270a-1f3fc":0,"270a-1f3fd":0,"270a-1f3fe":0,"270a-1f3ff":0,"270b-1f3fb":0,"270b-1f3fc":0,"270b-1f3fd":0,"270b-1f3fe":0,"270b-1f3ff":0,"270c-1f3fb":0,"270c-1f3fc":0,"270c-1f3fd":0,"270c-1f3fe":0,"270c-1f3ff":0,"270d-1f3fb":0,"270d-1f3fc":0,"270d-1f3fd":0,"270d-1f3fe":0,"270d-1f3ff":0}},n=s[""];for(const e in s)e&&Object.assign(n,s[e]);const a=n},3189:(e,t,i)=>{"use strict";i.d(t,{Bf:()=>n,U9:()=>a,bt:()=>s});const s='Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif',n="16px",a="400"},356:(e,t,i)=>{"use strict";i.d(t,{Z:()=>s});const s="undefined"!=typeof ImageBitmap},5296:(e,t,i)=>{"use strict";i.d(t,{Kx:()=>r,cK:()=>d,jt:()=>l});var s=i(3035),n=i(3725);const a=new Map;function o(e){return a.get(e)}function r(e){const t=o(e);t&&(t.isCancelled=!0,t.deferred.resolve())}function d(e,t,i){return i||(i=function(e){r(e);const t={isCancelled:!1,deferred:(0,n.Z)()};return a.set(e,t),t.deferred.then((()=>{o(e)===t&&a.delete(e)})),t}(t)),(0,s.T2)((()=>{i.isCancelled||(e()?d(e,t,i):i.deferred.resolve())})),i.deferred}function l(e){(0,s.T2)((()=>{e()&&l(e)}))}},1470:(e,t,i)=>{"use strict";function s(e,t){return e.reduce(((e,t)=>e+t),t)}i.d(t,{Z:()=>s})},2353:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};function n(e,t){return s(this,void 0,void 0,(function*(){const i=e.map(((e,i,n)=>s(this,void 0,void 0,(function*(){if(yield t(e,i,n))return e}))));return(yield Promise.all(i)).filter(Boolean)}))}},8847:(e,t,i)=>{"use strict";function s(e,t){const i=[];let s=-1;for(;-1!==(s=e.findIndex(t));)i.push(e.splice(s,1)[0]);return i}i.d(t,{Z:()=>s})},54:(e,t,i)=>{"use strict";function s(e,t){const i=[],s=[];for(let n=0,a=e.length;n<a;++n){const a=e[n];(t(a,n,e)?i:s).push(a)}return[i,s]}i.d(t,{Z:()=>s})},5916:(e,t,i)=>{"use strict";i.d(t,{Z:()=>s});class s{constructor(e){this.assets=e,this.tempId=0}playSound(e,t=!1){++this.tempId,this.assetName=e;try{const i=this.createAudio();i.autoplay=!0,i.src="assets/audio/"+e,i.loop=t,i.play()}catch(t){console.error("playSound",e,t)}}playSoundIfDifferent(e,t){this.assetName!==e&&this.playSound(e,t)}createAudio(){let{audio:e}=this;return e||(e=this.audio=new Audio,e.play(),e)}stopSound(){this.audio&&this.audio.pause()}cancelDelayedPlay(){++this.tempId}playSoundWithTimeout(e,t,i){const s=++this.tempId;setTimeout((()=>{this.tempId===s&&this.playSound(e,t)}),i)}}},8678:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(3019);function n(e){return(0,s.Z)(e,"readAsDataURL")}},6705:(e,t,i)=>{"use strict";i.d(t,{Z:()=>m});var s=i(3725),n=i(8594),a=i(3035);const o=[];let r=!1;function d(e,t="push"){if(!e.items.length)return Promise.resolve([]);const i=e.promise=(0,s.Z)();return o[t](e),l(),i}function l(){r||function(e){if(!e.items.length)return e.promise.resolve([]),Promise.resolve([]);const t=e.items.slice(),i=[];return new Promise(((s,o)=>{const r=()=>{return d=this,l=void 0,h=function*(){const d=performance.now();do{yield(0,n.e9)();const s=e.process.apply(e.context,t.shift());let a;if(s instanceof Promise)try{a=yield s}catch(e){return void o(e)}else a=s;i.push(a)}while(t.length>0&&performance.now()-d<6);t.length>0?(0,a.T2)(r):s(i)},new((c=void 0)||(c=Promise))((function(e,t){function i(e){try{n(h.next(e))}catch(e){t(e)}}function s(e){try{n(h.throw(e))}catch(e){t(e)}}function n(t){var n;t.done?e(t.value):(n=t.value,n instanceof c?n:new c((function(e){e(n)}))).then(i,s)}n((h=h.apply(d,l||[])).next())}));var d,l,c,h};(0,a.T2)(r)})).then(e.promise.resolve,e.promise.reject)}(o.shift()).finally((()=>{r=!1,o.length&&l()}))}var c=i(6663);let h,u;function p(e,t,i,s=document.createElement("canvas")){s.width=e.width,s.height=e.height;const n=s.getContext("2d",{alpha:!1});return c.Z?(n.filter=`blur(${t}px)`,n.drawImage(e,2*-t,2*-t,s.width+4*t,s.height+4*t)):(n.drawImage(e,0,0),u(n,0,0,s.width,s.height,t,i)),s}h=c.Z?Promise.resolve():i.e(77).then(i.bind(i,7077)).then((e=>{u=e.default}));const f=new Map;function m(e,t=2,i=2){if(!e)throw"no dataUri for blur: "+e;f.size>150&&f.clear();const s=document.createElement("canvas");s.className="canvas-thumbnail";let n=f.get(e);if(n)s.width=n.canvas.width,s.height=n.canvas.height,n.promise.then((()=>{s.getContext("2d").drawImage(n.canvas,0,0,s.width,s.height)}));else{const a=new Promise((n=>{h.then((()=>{const a=new Image;a.onload=()=>{d({items:[[a,t,i,s]],context:null,process:p},"unshift").then((()=>{n()}))},a.src=e}))}));f.set(e,n={canvas:s,promise:a})}return Object.assign(Object.assign({},n),{canvas:s})}},4059:(e,t,i)=>{"use strict";i.d(t,{Z:()=>l,o:()=>d});var s=i(4762),n=i(3306),a=i(9818);const o=(0,n.Z)("ffd8ffe000104a46494600010100000100010000ffdb004300281c1e231e19282321232d2b28303c64413c37373c7b585d4964918099968f808c8aa0b4e6c3a0aadaad8a8cc8ffcbdaeef5ffffff9bc1fffffffaffe6fdfff8ffdb0043012b2d2d3c353c76414176f8a58ca5f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8ffc00011080000000003012200021101031101ffc4001f0000010501010101010100000000000000000102030405060708090a0bffc400b5100002010303020403050504040000017d01020300041105122131410613516107227114328191a1082342b1c11552d1f02433627282090a161718191a25262728292a3435363738393a434445464748494a535455565758595a636465666768696a737475767778797a838485868788898a92939495969798999aa2a3a4a5a6a7a8a9aab2b3b4b5b6b7b8b9bac2c3c4c5c6c7c8c9cad2d3d4d5d6d7d8d9dae1e2e3e4e5e6e7e8e9eaf1f2f3f4f5f6f7f8f9faffc4001f0100030101010101010101010000000000000102030405060708090a0bffc400b51100020102040403040705040400010277000102031104052131061241510761711322328108144291a1b1c109233352f0156272d10a162434e125f11718191a262728292a35363738393a434445464748494a535455565758595a636465666768696a737475767778797a82838485868788898a92939495969798999aa2a3a4a5a6a7a8a9aab2b3b4b5b6b7b8b9bac2c3c4c5c6c7c8c9cad2d3d4d5d6d7d8d9dae2e3e4e5e6e7e8e9eaf2f3f4f5f6f7f8f9faffda000c03010002110311003f00"),r=(0,n.Z)("ffd9");function d(e){const t="base64,",i=e.slice(e.indexOf(t)+t.length),s=[...atob(i)].map((e=>e.charCodeAt(0)));return new Uint8Array(s)}function l(e,t=!1){let i,n;t||1!==e[0]?i=(0,a.Z)(e):(i=new Uint8Array(o.concat(Array.from(e.slice(3)),r)),i[164]=e[1],i[166]=e[2]),n=t?s.IS_SAFARI?"image/png":"image/webp":"image/jpeg";const d=function(e,t="image/jpeg"){return`data:${t};base64,${btoa(String.fromCharCode(...e))}`}(i,n);return d}},9897:(e,t,i)=>{"use strict";i.d(t,{Z:()=>a});var s=i(410),n=i(9405);function a(e,t,i,s,a=!0){if(e<i&&t<s&&a)return(0,n.C)(e,t);let o=i,r=s;return e/t>i/s?r=t*i/e|0:(o=e*s/t|0,o>i&&(r=r*i/o|0,o=i)),a&&o>=e&&r>=t&&(o=e,r=t),(0,n.C)(o,r)}s.GO.calcImageInBox=a},2890:(e,t,i)=>{"use strict";function s(e,t,i,s,n,a){const o=e.canvas.dpr;o&&(t*=o,i*=o,s*=o),e.beginPath(),e.arc(t,i,s,0,2*Math.PI,!1),e.closePath(),n&&e.fill(),a&&e.stroke()}function n(e,t,i,n,a,o){return s(e,t+n,i+n,n,a,o)}i.d(t,{Z:()=>s,o:()=>n})},8097:(e,t,i)=>{"use strict";let s;function n(e,t){if(!s){const e=document.createElement("canvas");s=e.getContext("2d",{alpha:!1})}return s.font!==t&&(s.font=t),s.measureText(e).width}i.d(t,{Z:()=>n})},7814:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(356);function n(e){return new Promise((t=>{return i=this,n=void 0,o=function*(){var i,n,a;const o=document.createElement("canvas"),r=null!==(i=e.size)&&void 0!==i?i:e.mediaSize.aspectFitted(e.boxSize),d=window.devicePixelRatio&&1;o.width=r.width*d,o.height=r.height*d;const l=o.getContext("2d");let c;c=s.Z?yield createImageBitmap(e.media,{resizeWidth:r.width,resizeHeight:r.height}):e.media,l.drawImage(c,0,0,o.width,o.height),s.Z&&(null==c||c.close());const h=null!==(n=e.mimeType)&&void 0!==n?n:"image/jpeg",u=null!==(a=e.quality)&&void 0!==a?a:1;if(e.toDataURL){const e=o.toDataURL(h,u);t({url:e,size:r})}else o.toBlob((e=>{t({blob:e,size:r})}),h,u)},new((a=void 0)||(a=Promise))((function(e,t){function s(e){try{d(o.next(e))}catch(e){t(e)}}function r(e){try{d(o.throw(e))}catch(e){t(e)}}function d(t){var i;t.done?e(t.value):(i=t.value,i instanceof a?i:new a((function(e){e(i)}))).then(s,r)}d((o=o.apply(i,n||[])).next())}));var i,n,a,o}))}},467:(e,t,i)=>{"use strict";i.d(t,{ST:()=>r,ZP:()=>d,gV:()=>l});var s=i(5813);const n=/[`~!@#$%^&*()\-_=+\[\]\\|{}'";:\/?.>,<]+/g,a=/^\s+|\s$/g,o={й:"q",ц:"w",у:"e",к:"r",е:"t",н:"y",г:"u",ш:"i",щ:"o",з:"p",х:"[",ъ:"]",ф:"a",ы:"s",в:"d",а:"f",п:"g",р:"h",о:"j",л:"k",д:"l",ж:";",э:"'",я:"z",ч:"x",с:"c",м:"v",и:"b",т:"n",ь:"m",б:",",ю:".",".":"/"};function r(e){return e.replace(n,"").replace(a,"")}function d(e,t=!0){return l(e,{clearBadChars:!0,latinize:t,ignoreCase:!0})}function l(e,t={}){const i=t.includeTag&&"%"===e.charAt(0),n=e;return t.clearBadChars&&(e=r(e)),t.latinize&&(e=function(e){return e.replace(/[^A-Za-z0-9]/g,(e=>{const t=s.Z[e];return null!=t?t:e}))}(e)),t.ignoreCase&&(e=e.toLowerCase()),i&&(e="%"+e),t.latinize&&(e+=""+function(e){return e.toLowerCase().replace(/[\wа-я]/g,(e=>{const t=o[e];return null!=t?t:e}))}(n)),e}},2166:(e,t,i)=>{"use strict";function s(e){var t=document.createElement("textarea");t.value=e,t.style.top="0",t.style.left="0",t.style.position="fixed",document.body.appendChild(t),t.focus(),t.select();try{document.execCommand("copy")}catch(e){}document.body.removeChild(t)}function n(e){navigator.clipboard?navigator.clipboard.writeText(e).catch((t=>{console.error("clipboard error",t),s(e)})):s(e)}i.d(t,{T:()=>n})},3416:(e,t,i)=>{"use strict";i.d(t,{Z:()=>r});var s=i(5432),n=i(4755),a=i(2296);class o extends a.Z{constructor(){super("menu",!0),this.onMouseMove=e=>{const t=this.element.getBoundingClientRect(),{clientX:i,clientY:s}=e,n=i>=t.right?i-t.right:t.left-i,a=s>=t.bottom?s-t.bottom:t.top-s;(n>=100||a>=100)&&this.close()},n.Z.addEventListener("resize",(()=>{this.element&&this.close()}))}isOpened(){return!!this.element}close(){this.element&&(this.element.classList.remove("active"),this.element.parentElement.classList.remove("menu-open")),super.close(),s.Z||window.removeEventListener("mousemove",this.onMouseMove)}openBtnMenu(e,t){super.open(e),this.element.classList.add("active","was-open"),this.element.parentElement.classList.add("menu-open"),t&&this.addEventListener("toggle",t,{once:!0}),s.Z||window.addEventListener("mousemove",this.onMouseMove)}}const r=new o},632:(e,t,i)=>{"use strict";i.d(t,{OD:()=>h,fl:()=>S,mr:()=>u,rz:()=>c,s2:()=>r,xE:()=>p,zM:()=>l});var s=i(410),n=i(2325);const a=["January","February","March","April","May","June","July","August","September","October","November","December"],o=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],r=86400,d=e=>{const t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())),i=t.getUTCDay()||7;t.setUTCDate(t.getUTCDate()+4-i);const s=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t.getTime()-s.getTime())/r+1)/7)};function l(e){const t=new Date,i=t.getTime()/1e3|0,s=e.getTime()/1e3|0,a={};return i-s<r&&t.getDate()===e.getDate()?a.hour=a.minute="2-digit":t.getFullYear()!==e.getFullYear()?(a.year=a.day="numeric",a.month="2-digit"):i-s<7*r&&d(t)===d(e)?a.weekday="short":(a.month="short",a.day="numeric"),new n.ZP.IntlDateElement({date:e,options:a}).element}function c(e,t={}){const i=new Date,s=new Date(1e3*e),a=i.getTime()/1e3,o=u(s);let d;return a-e<r&&i.getDate()===s.getDate()?d=(0,n.ag)(t.capitalize?"Date.Today":"Peer.Status.Today"):a-e<2*r&&i.getDate()-1===s.getDate()?(d=(0,n.ag)(t.capitalize?"Yesterday":"Peer.Status.Yesterday"),t.capitalize&&(d.style.textTransform="capitalize")):d=i.getFullYear()!==s.getFullYear()?new n.ZP.IntlDateElement({date:s,options:{month:"short",day:"numeric",year:"numeric"}}).element:new n.ZP.IntlDateElement({date:s,options:{month:"short",day:"numeric"}}).element,{dateEl:d,timeEl:o}}function h(e,t=!0){const{dateEl:i,timeEl:s}=c(e,{capitalize:t}),a=document.createDocumentFragment();return a.append(i," ",(0,n.ag)("ScheduleController.at")," ",s),a}function u(e){return new n.ZP.IntlDateElement({date:e,options:{hour:"2-digit",minute:"2-digit"}}).element}s.GO&&(s.GO.formatDateAccordingToTodayNew=l);const p=(e,t={})=>{const i=t.monthAsNumber?".":" ",s=("0"+e.getHours()).slice(-2)+":"+("0"+e.getMinutes()).slice(-2)+(t.noSeconds?"":":"+("0"+e.getSeconds()).slice(-2));return(t.leadingZero?("0"+e.getDate()).slice(-2):e.getDate())+i+(t.monthAsNumber?("0"+(e.getMonth()+1)).slice(-2):a[e.getMonth()])+i+e.getFullYear()+(t.noTime?"":", "+s)},f=2013,m=new RegExp("20[0-9]{1,2}"),g=new RegExp("(\\w{3,}) ([0-9]{0,4})","i"),v=new RegExp("([0-9]{0,4}) (\\w{2,})","i"),b=new RegExp("^([0-9]{1,4})(\\.| |/|\\-)([0-9]{1,4})$","i"),y=new RegExp("^([0-9]{1,2})(\\.| |/|\\-)([0-9]{1,2})(\\.| |/|\\-)([0-9]{1,4})$","i"),w=[31,29,31,30,31,30,31,31,30,31,30,31];function S(e,t){const i=e.trim().toLowerCase();if(i.length<3)return;if(0==="today".indexOf(i)){const e=new Date,i=e.getFullYear(),s=e.getMonth(),n=e.getDate();e.setFullYear(i,s,n),e.setHours(0,0,0);const a=e.getTime();e.setFullYear(i,s,n+1),e.setHours(0,0,0);const o=e.getTime()-1;return void t.push({title:"Today",minDate:a,maxDate:o})}if(0==="yesterday".indexOf(i)){const e=new Date,i=e.getFullYear(),s=e.getMonth(),n=e.getDate();e.setFullYear(i,s,n),e.setHours(0,0,0);const a=e.getTime()-864e5;e.setFullYear(i,s,n+1),e.setHours(0,0,0);const o=e.getTime()-86400001;return void t.push({title:"Yesterday",minDate:a,maxDate:o})}const s=function(e){const t=new Date;if(e.length<=3)return-1;for(let i=0;i<7;i++)if(t.setDate(t.getDate()+1),0===Z(t.getTime()).toLowerCase().indexOf(e))return t.getDay();return-1}(i);if(s>=0){const e=new Date,i=e.getTime(),n=s-e.getDay();e.setDate(e.getDate()+n),e.getTime()>i&&e.setTime(e.getTime()-6048e5);const a=e.getFullYear(),o=e.getMonth(),r=e.getDate();e.setFullYear(a,o,r),e.setHours(0,0,0);const d=e.getTime();e.setFullYear(a,o,r+1),e.setHours(0,0,0);const l=e.getTime()-1;return void t.push({title:Z(d),minDate:d,maxDate:l})}let n;if(null===(n=b.exec(i)))if(null===(n=y.exec(i)))if(null===(n=m.exec(i))){if(null!==(n=g.exec(i))){const e=n[1],i=n[2],s=k(e);if(s>=0){const e=+i;if(e>0&&e<=31)return void L(t,e-1,s);if(e>=f)return void C(t,s,e)}}if(null!==(n=v.exec(i))){const e=n[1],i=k(n[2]);if(i>=0){const s=+e;if(s>0&&s<=31)return void L(t,s-1,i);s>=f&&C(t,i,s)}}}else{let e=+i;const s=(new Date).getFullYear();if(e<f){e=f;for(let i=s;i>=e;i--){const e=new Date;e.setFullYear(i,0,1),e.setHours(0,0,0);const s=e.getTime();e.setFullYear(i+1,0,1),e.setHours(0,0,0);const n=e.getTime()-1;t.push({title:""+i,minDate:s,maxDate:n})}}else if(e<=s){const i=new Date;i.setFullYear(e,0,1),i.setHours(0,0,0);const s=i.getTime();i.setFullYear(e+1,0,1),i.setHours(0,0,0);const n=i.getTime()-1;t.push({title:""+e,minDate:s,maxDate:n})}}else{const e=n[1],i=n[3],s=n[5];if(!n[2]===n[4])return;const a=parseInt(e),o=parseInt(i)-1;let r=parseInt(s);r>=10&&r<=99&&(r+=2e3);const d=(new Date).getFullYear();if(M(a-1,o)&&r>=f&&r<=d){const e=new Date;e.setFullYear(r,o,a),e.setHours(0,0,0);const i=e.getTime();e.setFullYear(r,o,a+1),e.setHours(0,0,0);const s=e.getTime()-1;return void t.push({title:P(i),minDate:i,maxDate:s})}}else{const e=n[1],i=n[3],s=parseInt(e),a=parseInt(i);if(s>0&&s<=31){if(a>=f&&s<=12)return void C(t,s-1,a);a<=12&&L(t,s-1,a-1)}else s>=f&&a<=12&&C(t,a-1,s)}}function C(e,t,i){const s=(new Date).getFullYear(),n=Date.now();if(i>=f&&i<=s){const s=new Date;s.setFullYear(i,t,1),s.setHours(0,0,0);const a=s.getTime();if(a>n)return;s.setMonth(s.getMonth()+1);const o=s.getTime()-1;e.push({title:E(a),minDate:a,maxDate:o})}}function L(e,t,i){if(M(t,i)){const n=(new Date).getFullYear(),a=Date.now();for(let o=n;o>=f;o--){if(1===i&&28===t&&((s=o)%4!=0||s%100==0)&&s%400!=0)continue;const r=new Date;r.setFullYear(o,i,t+1),r.setHours(0,0,0);const d=r.getTime();if(d>a)continue;r.setFullYear(o,i,t+2),r.setHours(0,0,0);const l=r.getTime()-1;o===n?e.push({title:I(d),minDate:d,maxDate:l}):e.push({title:P(d),minDate:d,maxDate:l})}}var s}function E(e){const t=new Date(e);return a[t.getMonth()].slice(0,3)+" "+t.getFullYear()}function I(e){const t=new Date(e);return a[t.getMonth()].slice(0,3)+" "+t.getDate()}function P(e){const t=new Date(e);return("0"+t.getDate()).slice(-2)+"."+("0"+(t.getMonth()+1)).slice(-2)+"."+t.getFullYear()}function Z(e){const t=new Date(e);return o[t.getDay()]}function M(e,t){return t>=0&&t<12&&e>=0&&e<w[t]}function k(e){e=e.toLowerCase();for(let t=0;t<12;t++)if(0===a[t].toLowerCase().indexOf(e))return t;return-1}s.GO.fillTipDates=S},3532:(e,t,i)=>{"use strict";i.d(t,{Z:()=>d});var s=i(2796),n=i(2166),a=i(3910),o=i(2738);const r="https://t.me/";function d(e={}){const t=document.createElement("a");t.classList.add("anchor-copy");let i,d="LinkCopied";if(e.mePath){const s=r+e.mePath;i=t.href=t.innerText=s}if(e.username){const s=r+e.username;t.href=s,i=t.innerText="@"+e.username,d="UsernameCopied"}return(0,o.fc)(t,(e=>{(0,a.Z)(e),(0,n.T)(null!=i?i:t.href),(0,s.bC)({langPackKey:d})})),t}},6976:(e,t,i)=>{"use strict";i.d(t,{E:()=>c,s:()=>l});var s=i(5432),n=i(4762),a=i(3416),o=i(3910);let r=!1,d=0;function l(){d&&clearTimeout(d),d=window.setTimeout((()=>{d=0,r=!1}),400),r=!0}function c({element:e,callback:t,listenerSetter:i,listenerOptions:d}){const l=i?i.add(e):e.addEventListener.bind(e),c=i?i.removeManual.bind(i,e):e.removeEventListener.bind(e);if(n.IS_APPLE&&s.Z||d){let e;const i=Object.assign(Object.assign({},d||{}),{capture:!0}),s=()=>{clearTimeout(e),c("touchmove",s,i),c("touchend",s,i),c("touchcancel",s,i)};l("touchstart",(n=>{n.touches.length>1?s():(l("touchmove",s,i),l("touchend",s,i),l("touchcancel",s,i),e=window.setTimeout((()=>{r?s():(t(n),s(),a.Z.isOpened()&&l("touchend",o.Z,{once:!0}))}),400))}),d)}else l("contextmenu",s.Z?e=>{t(e),a.Z.isOpened()&&l("touchend",o.Z,{once:!0})}:t,d)}},5077:(e,t,i)=>{"use strict";function s(e,t,i,s){const n=e=>{i({x:e.pageX,y:e.pageY,event:e})},a=t=>{document.removeEventListener("mousemove",n),e.addEventListener("mousedown",o,{once:!0}),null==s||s({x:t.pageX,y:t.pageY,event:t})},o=i=>{0===i.button?(t({x:i.pageX,y:i.pageY,event:i}),n(i),document.addEventListener("mousemove",n),document.addEventListener("mouseup",a,{once:!0})):e.addEventListener("mousedown",o,{once:!0})};e.addEventListener("mousedown",o,{once:!0});const r=e=>{e.preventDefault(),i({x:e.touches[0].clientX,y:e.touches[0].clientY,isTouch:!0,event:e})},d=t=>{document.removeEventListener("touchmove",r),e.addEventListener("touchstart",l,{passive:!1,once:!0});const i=t.touches[0]||t.changedTouches[0];null==s||s({x:i.clientX,y:i.clientY,isTouch:!0,event:t})},l=e=>{t({x:e.touches[0].clientX,y:e.touches[0].clientY,isTouch:!0,event:e}),r(e),document.addEventListener("touchmove",r,{passive:!1}),document.addEventListener("touchend",d,{passive:!1,once:!0})};return e.addEventListener("touchstart",l,{passive:!1,once:!0}),()=>{e.removeEventListener("mousedown",o),document.removeEventListener("mousemove",n),document.removeEventListener("mouseup",a),e.removeEventListener("touchstart",l),document.removeEventListener("touchmove",r),document.removeEventListener("touchend",d)}}i.d(t,{Z:()=>s})},6760:(e,t,i)=>{"use strict";function s(){window.getSelection?window.getSelection().empty?window.getSelection().empty():window.getSelection().removeAllRanges&&window.getSelection().removeAllRanges():document.selection&&document.selection.empty()}i.d(t,{Z:()=>s})},2738:(e,t,i)=>{"use strict";i.d(t,{Cf:()=>o,fc:()=>d,pf:()=>r,tH:()=>l});var s=i(5432),n=i(6669);let a;function o(e){if(e.isTrusted&&"click"===e.type&&e.target!==a)return!0}document.addEventListener("mousedown",(e=>{a=e.target}));const r=s.Z?"mousedown":"click";function d(e,t,i={}){const s=i.listenerSetter?i.listenerSetter.add(e):e.addEventListener.bind(e),n=i.listenerSetter?i.listenerSetter.removeManual.bind(i.listenerSetter,e):e.removeEventListener.bind(e);if(i.touchMouseDown=!0,"click"===r){const e=t;t=t=>{o(t)||e(t)}}return s(r,t,i),()=>n(r,t,i)}function l(e){(0,n.Z)(e,r)}},7529:(e,t,i)=>{"use strict";i.d(t,{Z:()=>r});var s=i(5432),n=i(3241),a=i(5953),o=i(8497);class r extends n.Z{constructor(){super(!1),this.hideControls=(e=!1)=>{if(e)return void(this.hideControlsTimeout||(this.hideControlsTimeout=window.setTimeout(this.hideControls,3e3)));clearTimeout(this.hideControlsTimeout),this.hideControlsTimeout=0;const t=this.element.classList.contains("show-controls");if(!1!==this.controlsLocked){if(this.canHideControls&&!this.canHideControls()||!t||this.controlsLocked)return}else if(!t)return;this.dispatchEvent("toggleControls",!1),this.element.classList.remove("show-controls")},this.showControls=(e=!0)=>{this.hideControlsTimeout?(clearTimeout(this.hideControlsTimeout),this.hideControlsTimeout=0):this.element.classList.contains("show-controls")||!1===this.controlsLocked||(this.dispatchEvent("toggleControls",!0),this.element.classList.add("show-controls")),e&&!this.controlsLocked&&(this.hideControlsTimeout=window.setTimeout(this.hideControls,3e3))},this.toggleControls=e=>{const t=this.element.classList.contains("show-controls");if(void 0===e)t?this.hideControls():this.showControls();else{if(e===t)return;!1===e?this.hideControls():this.showControls()}},this.hideControlsTimeout=0}setup(e){(0,a.Z)(this,e);const{listenerSetter:t,element:i}=this;s.Z?t.add(i)("click",(e=>{this.ignoreClickClassName&&(0,o.Z)(e.target,this.ignoreClickClassName)||this.toggleControls()})):(t.add(i)("mousemove",(()=>{this.showControls()})),t.add(i)("mouseenter",(()=>{this.showControls(!1)})),t.add(i)("mouseleave",(e=>{e.relatedTarget&&this.showOnLeaveToClassName&&(0,o.Z)(e.relatedTarget,this.showOnLeaveToClassName)?this.showControls(!1):this.hideControls()})))}lockControls(e){this.controlsLocked=e,this.element.classList.toggle("disable-hover",!1===e),this.toggleControls(e)}}},4531:(e,t,i)=>{"use strict";i.d(t,{Z:()=>p});var s=i(3003),n=i(2353),a=i(6654),o=i(3416),r=i(3699),d=i(3624),l=i(1483),c=i(6976),h=i(2738),u=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};function p({buttons:e,findElement:t,listenTo:i,appendTo:p,filterButtons:f,onOpen:m,onClose:g,onBeforeOpen:v,listenerSetter:b,middleware:y,listenForClick:w}){null!=p||(p=document.body),null!=b||(b=new r.Z);const S=new r.Z,C=y?y.create():(0,d.k)();let L;const E=e=>{const s=t?t(e):i;if(!s)return;let n=L;if((e instanceof MouseEvent||e.hasOwnProperty("preventDefault"))&&e.preventDefault(),n&&n.classList.contains("active"))return!1;(e instanceof MouseEvent||e.hasOwnProperty("cancelBubble"))&&(e.cancelBubble=!0),(()=>{u(this,void 0,void 0,(function*(){yield null==m?void 0:m(s);const t=yield Z();if(!t)return;n=t.element;const{cleanup:i,destroy:a}=t;(0,l.Z)(e,n),o.Z.openBtnMenu(n,(()=>{null==g||g(),i(),setTimeout((()=>{a()}),300)}))}))})()};(0,c.E)({element:i,callback:E,listenerSetter:b});const I=()=>{S.removeAll(),C.clean()},P=()=>{I(),b.removeAll()},Z=()=>u(this,void 0,void 0,(function*(){I(),e.forEach((e=>e.element=void 0));const t=f||(e=>(0,n.Z)(e,(e=>!(null==e?void 0:e.verify)||(0,a.Z)(e.verify(),(e=>null!=e&&e))))),i=yield t(e);if(!i.length)return;const o=L=yield(0,s.Z)({buttons:i,listenerSetter:S});return o.classList.add("contextmenu"),yield null==v?void 0:v(),p.append(o),{element:o,cleanup:I,destroy:()=>{o.remove()}}}));return y&&y.onDestroy((()=>{P()})),w&&(0,h.fc)(i,E,{listenerSetter:b}),{element:L,destroy:P,open:E}}},3163:(e,t,i)=>{"use strict";i.d(t,{Z:()=>h});var s=i(9298),n=i(7030),a=i(3512),o=i(4531),r=i(8497),d=i(3173),l=i(1168),c=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};function h(e){const{listenTo:t,isStickerPack:i,verifyRecent:h,appendTo:u,onOpen:p,onClose:f,onSend:m}=e;let g,v;const b=e=>c(this,void 0,void 0,(function*(){const t=yield a.Z.managers.acknowledged.appStickersManager.getFavedStickersStickers();if(!t.cached)return!1;const i=(yield t.result).some((e=>e.id===v.id));return e?!i:i}));return(0,o.Z)({listenTo:t,appendTo:u,findElement:e=>g=(0,r.Z)(e.target,"media-sticker-wrapper"),onOpen:()=>c(this,void 0,void 0,(function*(){return v=yield a.Z.managers.appDocsManager.getDoc(g.dataset.docId),null==p?void 0:p()})),onClose:f,buttons:[{icon:"stickers",text:"Context.ViewStickerSet",onClick:()=>l.Z.createPopup(s.Z,v.stickerSetInput).show(),verify:()=>!i},{icon:"favourites",text:"AddToFavorites",onClick:()=>a.Z.managers.appStickersManager.faveSticker(v.id,!1),verify:()=>b(!0)},{icon:"favourites",text:"DeleteFromFavorites",onClick:()=>a.Z.managers.appStickersManager.faveSticker(v.id,!0),verify:()=>b(!1)},{icon:"delete",text:"DeleteFromRecent",onClick:()=>a.Z.managers.appStickersManager.saveRecentSticker(v.id,!0),verify:()=>{var e;return null!==(e=null==h?void 0:h(g))&&void 0!==e&&e}},{icon:"mute",text:"Chat.Send.WithoutSound",onClick:()=>(null==m||m(),d.Jo.sendDocId(v.id,!1,!0)),verify:()=>!(!n.ZP.chat.peerId||n.ZP.chat.peerId===a.Z.myId)},{icon:"schedule",text:"Chat.Send.ScheduledMessage",onClick:()=>n.ZP.chat.input.scheduleSending((()=>n.ZP.chat.input.sendMessageWithDocument(v))),verify:()=>!!n.ZP.chat.peerId}]})}},7660:(e,t,i)=>{"use strict";function s(e={}){const t=document.createElement("video");return e.pip||(t.disablePictureInPicture=!0),t.setAttribute("playsinline","true"),t}i.d(t,{Z:()=>s})},8222:(e,t,i)=>{"use strict";i.d(t,{Z:()=>r});var s=i(410),n=i(3512),a=i(4755);const o=new class{constructor(){this.resetCache=()=>{this.computedStyle=void 0;const e=this.cache;this.cache={};for(const t in e)this.getProperty(t)},this.cache={},n.Z.addEventListener("theme_change",this.resetCache),a.Z.addEventListener("resize",this.resetCache)}getProperty(e){let t=this.cache[e];return t||(this.computedStyle||(this.computedStyle=window.getComputedStyle(document.documentElement)),t=this.computedStyle.getPropertyValue("--"+e).trim(),this.cache[e]=t)}getPropertyAsSize(e){const t=this.getProperty(e);let i;return"%"===t[t.length-1]||(i=t.indexOf("rem")?16*+t.replace("rem",""):+t.replace("px","")),i}};s.GO&&(s.GO.customProperties=o);const r=o},6669:(e,t,i)=>{"use strict";function s(e,t){const i=new Event(t,{bubbles:!0,cancelable:!0});e.dispatchEvent(i)}i.d(t,{Z:()=>s})},1544:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(4056);function n(e){return Array.from(e.childNodes).map((e=>e.nodeType===e.TEXT_NODE?(0,s.Z)(e.textContent):e.outerHTML)).join("")}},5975:(e,t,i)=>{"use strict";function s(e,t){if(!e)return null;if(e.parentElement===t)return e;for(;e.parentElement;)if((e=e.parentElement).parentElement===t)return e;return null}i.d(t,{Z:()=>s})},8763:(e,t,i)=>{"use strict";function s(e,t){return e.closest(`[${t}]`)}i.d(t,{Z:()=>s})},4668:(e,t,i)=>{"use strict";function s(e,t){return e.closest(t)}i.d(t,{Z:()=>s})},6733:(e,t,i)=>{"use strict";function s(e){e.requestFullscreen?e.requestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen&&e.msRequestFullscreen()}function n(){document.cancelFullScreen?document.cancelFullScreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitCancelFullScreen?document.webkitCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen()}function a(e,t,i){const s=i?i.add(e):e.addEventListener.bind(e);"webkitfullscreenchange mozfullscreenchange fullscreenchange MSFullscreenChange".split(" ").forEach((e=>{s(e,t,!1)}))}function o(){return document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement}function r(){return!!o()}i.d(t,{C8:()=>n,Dj:()=>s,Ms:()=>a,W7:()=>o,rB:()=>r})},3299:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n,q:()=>a});var s=i(5975);function n(e,t){const i=document.getSelection(),n=i[t?"anchorNode":"focusNode"],o=i[t?"anchorOffset":"focusOffset"];return(0,s.Z)(n,e)||n===e?Object.assign(Object.assign({},a(e,n,o)),{selection:i}):{selection:i}}function a(e,t,i){if(t===e){const s=e.childNodes,n=s.length;n&&i>=n?i=((t=s[n-1]).textContent||t.alt||"").length:(t=s[i],i=0)}return{node:t,offset:i}}},9041:(e,t,i)=>{"use strict";i.d(t,{CS:()=>r,ZP:()=>c,o8:()=>n});var s=i(6854);const n={bold:{match:'[style*="bold"], [style*="font-weight: 700"], [style*="font-weight: 600"], [style*="font-weight:700"], [style*="font-weight:600"], b, strong',entityName:"messageEntityBold"},underline:{match:'[style*="underline"], u, ins',entityName:"messageEntityUnderline"},italic:{match:'[style*="italic"], i, em',entityName:"messageEntityItalic"},monospace:{match:'[style*="monospace"], [face*="monospace"], pre',entityName:"messageEntityCode"},strikethrough:{match:'[style*="line-through"], [style*="strikethrough"], strike, del, s',entityName:"messageEntityStrike"},link:{match:"A:not(.follow)",entityName:"messageEntityTextUrl"},mentionName:{match:"A.follow",entityName:"messageEntityMentionName"},spoiler:{match:'[style*="spoiler"]',entityName:"messageEntitySpoiler"}},a=new Set(["DIV","P","BR","LI","SECTION","H6","H5","H4","H3","H2","H1","TR","OL","UL"]),o=new RegExp(s.Z,"g"),r="";function d(e,t,i,s){const a=e.parentElement;for(const e in n){const o=n[e],r=a.closest(o.match+', [contenteditable="true"]');null===(null==r?void 0:r.getAttribute("contenteditable"))&&("messageEntityTextUrl"===o.entityName?i.push({_:o.entityName,url:r.href,offset:s.offset,length:t.length}):"messageEntityMentionName"===o.entityName?i.push({_:o.entityName,offset:s.offset,length:t.length,user_id:r.dataset.follow.toUserId()}):i.push({_:o.entityName,offset:s.offset,length:t.length}))}}function l(e){const{length:t}=e;return!t||e[t-1]===r&&t===r.length}function c(e,t,i,s,n,h,u={offset:0}){var p;if(e.nodeType===e.TEXT_NODE){let t=e.nodeValue;return t=t.replace(o,""),t?s===e?i.push(t.substr(0,n)+r+t.substr(n)):i.push(t):s===e&&i.push(r),h&&t.length&&e.parentNode&&d(e,t,h,u),void(u.offset+=t.length)}if(e.nodeType!==e.ELEMENT_NODE)return;const f=()=>{t.push(i.join("")),i.length=0,++u.offset},m=s===e,g=a.has(e.tagName);if(g&&(i.length&&"\n"!==i[i.length-1].slice(-1)||"BR"===e.tagName))f();else{const t=e.dataset.stickerEmoji||e.alt,s=e.dataset.stickerEmoji;t&&h&&d(e,t,h,u),s&&h&&h.push({_:"messageEntityCustomEmoji",document_id:e.dataset.docId,offset:u.offset,length:t.length}),t&&(i.push(t),u.offset+=t.length)}m&&!n&&i.push(r);const v=e.matches('[style*="table-cell"], th, td'),b=null==h?void 0:h.length;t.length;let y=!0,w=e.firstChild;for(;w;)c(w,t,i,s,n,h,u),w=w.nextSibling,l(i)||(y=!1);if(y&&(null===(p=e.textContent)||void 0===p?void 0:p.replace(/[\r\n]/g,""))&&(y=!1),m&&n&&i.push(r),v&&e.nextSibling&&!l(i)&&(i.push(" "),++u.offset,void 0!==b))for(let e=b,t=h.length;e<t;++e)++h[e].length;g&&!y&&f(),!y&&"P"===e.tagName&&e.nextSibling&&(t.push(""),++u.offset)}},9336:(e,t,i)=>{"use strict";i.d(t,{Z:()=>r});var s=i(410),n=i(6875),a=i(1346),o=i(9041);function r(e,t=!0,i=!0){const s=[],r=[],{node:d,offset:l}=!(e instanceof DocumentFragment)&&i&&function(e){const t=window.getSelection();let i,s;if(null==t?void 0:t.rangeCount){const n=t.getRangeAt(0),a=n.startOffset;if(n.startContainer&&n.startContainer==n.endContainer&&a==n.endOffset){const t=a-1,o=e.childNodes;if(n.startContainer===e&&o[t]){i=o[t],s=0;for(let e=0;e<n.endOffset;++e){const t=o[e],i=t.nodeValue||t.alt;i&&(s+=i.length)}}else i=n.startContainer,s=a}}return{node:i,offset:s}}(e),c=t?[]:void 0,h={offset:0};if(e instanceof DocumentFragment){let t=e.firstChild;for(;t;)(0,o.ZP)(t,s,r,d,l,c,h),t=t.nextSibling}else(0,o.ZP)(e,s,r,d,l,c,h);r.length&&s.push(r.join(""));let u=s.join("\n");const p=u.indexOf(o.CS);return-1!==p&&(u=u.substr(0,p)+u.substr(p+1)),u=u.replace(/\u00A0/g," "),(null==c?void 0:c.length)&&((0,n.Z)(c),(0,a.Z)(c)),{value:u,entities:c,caretPos:p}}s.GO.getRichValueWithCaret=r},4881:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(8204);function n({overflowElement:e,overflowRect:t,selector:i,extraSize:n,elements:a}){null!=t||(t=e.getBoundingClientRect()),null!=a||(a=Array.from(e.querySelectorAll(i))),n&&(t={top:t.top-n,right:t.right+n,bottom:t.bottom+n,left:t.left-n});const o=[],r=[],d=[];let l=!1;for(const i of a){const n=i.getBoundingClientRect(),a=(0,s.Z)(i,e,!1,n,t);let c;a?(l=!0,c=r):c=l?d:o,c.push({element:i,rect:n,visibleRect:a})}return{invisibleTop:o,visible:r,invisibleBottom:d}}},8204:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(241);function n(e,t,i,n=e.getBoundingClientRect(),a=t.getBoundingClientRect()){let{top:o,right:r,bottom:d,left:l}=a;if(i){const e=t.querySelector(".sticky");e&&(o=e.getBoundingClientRect().bottom)}if(n.top>=d||n.bottom<=o||n.right<=l||n.left>=r)return null;const c={top:!1,right:!1,bottom:!1,left:!1,vertical:0,horizontal:0},h=s.Z.width,u=s.Z.height;return{rect:{top:n.top<o&&0!==o?(c.top=!0,++c.vertical,o):n.top,right:n.right>r&&r!==h?(c.right=!0,++c.horizontal,r):n.right,bottom:n.bottom>d&&d!==u?(c.bottom=!0,++c.vertical,d):n.bottom,left:n.left<l&&0!==l?(c.left=!0,++c.horizontal,l):n.left},overflow:c}}window.getVisibleRect=n},2416:(e,t,i)=>{"use strict";i.d(t,{Z:()=>r});var s=i(3757),n=i(3910),a=i(8497),o=i(3444);function r(e){let t=!1;return new s.Z(Object.assign(Object.assign({},e),{verifyTouchTarget:t=>!(0,a.Z)(t.target,"progress-line")&&!(0,o.Z)(t)&&(!e.verifyTouchTarget||e.verifyTouchTarget(t)),onSwipe:(i,s,a)=>{if(i*=-1,s*=-1,!t&&Math.abs(s)>20)return!0;if(Math.abs(i)>Math.abs(s))(0,n.Z)(a),t=!0;else if(!t&&Math.abs(s)>Math.abs(i))return!0;return e.onSwipe(i,s,a)},onReset:()=>{t=!1,e.onReset&&e.onReset()},cancelEvent:!1}))}},1154:(e,t,i)=>{"use strict";i.d(t,{Z:()=>a});var s=i(6976),n=i(2416);function a(e){return(0,n.Z)(Object.assign(Object.assign({},e),{onSwipe:(t,i,n)=>{if(t*=-1,i*=-1,Math.abs(t)>50)return e.onSwipe(t,i,n),(0,s.s)(),!0}}))}},7545:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(9041);function n(e,t){const i={};e.forEach((e=>i[e]=0));const n=window.getSelection();let a=-1;if(!n.isCollapsed){const t=n.getRangeAt(0),o=t.commonAncestorContainer,r=o.nodeType===o.ELEMENT_NODE?o:o.parentElement,d=document.createTreeWalker(r.closest('[contenteditable="true"]'),NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,{acceptNode:e=>t.intersectsNode(e)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT});let l;for(a=0;l=d.nextNode();){++a;for(const t of e){const e=s.o8[t];(l.nodeType===l.ELEMENT_NODE?l:l.parentElement).closest(e.match)&&++i[t]}}}const o={};for(const s of e)o[s]=i[s]>=(t?a:1);return o}},5705:(e,t,i)=>{"use strict";function s(e){if(e instanceof DocumentFragment)return e;const t=document.createElement("template");return e=e.trim(),t.innerHTML=e,t.content}i.d(t,{Z:()=>s})},2614:(e,t,i)=>{"use strict";function s(e){const t=document.createElement("span");return"string"==typeof e?t.innerHTML=e:t.append(e),t}i.d(t,{Z:()=>s})},8487:(e,t,i)=>{"use strict";function s(e){return null==e?void 0:e.isConnected}i.d(t,{Z:()=>s})},1293:(e,t,i)=>{"use strict";function s(e){return e.isContentEditable||"INPUT"!==e.tagName?!e.textContent.trim()&&!e.querySelector(".emoji, .custom-emoji, .custom-emoji-placeholder"):!e.value.trim()}i.d(t,{Z:()=>s})},1452:(e,t,i)=>{"use strict";function s(e=window.getSelection()){if(!(null==e?void 0:e.rangeCount))return!0;const t=e.getRangeAt(0);return!(!t.collapsed&&t.START_TO_END)}i.d(t,{Z:()=>s})},6299:(e,t,i)=>{"use strict";i.d(t,{Z:()=>a});var s=i(3512),n=i(4762);function a(e){if("Enter"===e.key&&!n.IS_MOBILE&&!e.isComposing){if("enter"===s.Z.settings.sendShortcut){if(e.shiftKey||e.ctrlKey||e.metaKey)return;return!0}{const t=n.IS_APPLE?e.metaKey:e.ctrlKey;if(e.shiftKey||(n.IS_APPLE?e.ctrlKey:e.metaKey))return;if(t)return!0}}return!1}},3444:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(4762);function n(e){return s.IS_MOBILE_SAFARI&&e instanceof TouchEvent&&e.touches[0].clientX<30}},2398:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(5432);function n(e,t=!1,i=!0){if(!s.Z||t&&("INPUT"===document.activeElement.tagName||document.activeElement.isContentEditable))if(i&&e.focus(),e instanceof HTMLInputElement){const t=e.value.length;e.selectionStart=t,e.selectionEnd=t}else{const t=document.createRange();t.selectNodeContents(e),t.collapse(!1);const i=window.getSelection();i.removeAllRanges(),i.addRange(t)}}window.placeCaretAtEnd=n},4484:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(2648);function n(e,t,i,n){return void 0===n&&(n=e.parentElement===t?(0,s.Z)(e):-1),n!==i&&(-1!==n&&n<i&&(i+=1),i?t.childElementCount>i?t.insertBefore(e,t.children[i]):t.append(e):t.prepend(e),!0)}},2359:(e,t,i)=>{"use strict";function s(e){e.style.display="none",e.offsetLeft,e.style.display=""}i.d(t,{Z:()=>s})},6740:(e,t,i)=>{"use strict";i.d(t,{ZP:()=>o,cj:()=>r});var s=i(925);const n={},a=(e,t)=>{e instanceof HTMLImageElement||e instanceof HTMLVideoElement?e.src=t:e instanceof SVGImageElement?e.setAttributeNS(null,"href",t):e.style.backgroundImage="url("+t+")"};function o(e,t,i,o=!0){if(!t)return console.error("renderImageFromUrl: no url?",e,t),void(null==i||i());const r=e instanceof HTMLVideoElement;if(n[t]&&o||r)e&&a(e,t),i&&(r?(0,s.Z)(e).then(i):null==i||i());else{const s=e instanceof HTMLImageElement,o=s?e:new Image;o.src=t;const r=()=>{!s&&e&&a(e,t),n[t]=!0,null==i||i(),o.removeEventListener("error",d)},d=e=>{console.error("Render image from url failed:",e,t,o),o.removeEventListener("load",r),null==i||i()};o.addEventListener("load",r,{once:!0}),o.addEventListener("error",d,{once:!0})}}function r(e,t,i){return new Promise((s=>{o(e,t,s,i)}))}},2830:(e,t,i)=>{"use strict";i.d(t,{Z:()=>a});var s=i(9674),n=i(6740);function a(e,t,i,a,o=e,r){return a&&t.classList.add("fade-in"),(0,n.cj)(t,i).then((()=>s.Z.mutateElement(e,(()=>{o.append(t),a?t.addEventListener("animationend",(()=>{s.Z.mutate((()=>{t.classList.remove("fade-in"),null==r||r.remove()}))}),{once:!0}):null==r||r.remove()}))))}},5565:(e,t,i)=>{"use strict";function s(e,t){if("string"==typeof t)return void(e.textContent=t);const i=e.firstChild;i?e.lastChild===i?i.replaceWith(t):(e.textContent="",e.append(t)):e.append(t)}i.d(t,{Z:()=>s})},669:(e,t,i)=>{"use strict";i.d(t,{Y:()=>m,Z:()=>g});var s=i(4762),n=i(5003),a=i(5400),o=i(3699),r=i(6854),d=i(3228),l=i(5975),c=i(2648);function h(e,t,i,s){let n;if(e===i)n=t-s;else if(e.parentElement===i.parentElement)n=(0,c.Z)(e,!0)-(0,c.Z)(i,!0);else{const t=[];let s=e.parentElement;do{t.push(s)}while(s=s.parentElement);s=i.parentElement;do{if(t.includes(s))break}while(s=s.parentElement);const a=s;e=(0,l.Z)(e,a),i=(0,l.Z)(i,a),n=(0,c.Z)(e,!0)-(0,c.Z)(i,!0)}return(0,d.Z)(n,-1,1)}window.compareNodes=h;var u=i(3299),p=i(2398);const f=new RegExp(`[^${r.Z}]`),m=!1;class g{constructor(){this.saveSelectionOnChange=e=>{const t=document.activeElement;this.saveRangeForElement(t)},this.onFocusOut=e=>{this.lastNode=this.lastOffset=void 0},this.onSelectionChange=e=>{var t;const{input:i}=this;if(!i)return void this.setSelectionClassName(document.getSelection());let s=this.getCaretPosN();for(;;){const{node:e,offset:n,selection:a,move:o}=s;if((null==e?void 0:e.nodeValue)!==r.Z||!this.lastNode)break;const d=h(e,n,this.lastNode,this.lastOffset)<0;void 0!==d&&(a.isCollapsed?this.superMove(i,s,d,!0):a.modify(a.isCollapsed?"move":"extend",d?"backward":"forward","character")),this.log("selectionchange",e,n,this.lastNode,this.lastOffset,e===this.lastNode,(0,c.Z)(this.getFiller(e)),(0,c.Z)(this.getFiller(this.lastNode)),d,a,document.getSelection(),document.getSelection().getRangeAt(0),null==e?void 0:e.parentNode,null===(t=this.lastNode)||void 0===t?void 0:t.parentNode),s=this.getCaretPosN(),this.lastNode=e,this.lastOffset=n;break}this.lastNode=this.lastOffset=void 0,this.setSelectionClassName(s.selection,i)},this.onBeforeInput=e=>{var t;const{input:i,log:s}=this;if(!i)return;const n=this.addInputCallback.bind(this,i),a=this.getCaretPosN();let{node:o,offset:d,selection:l,move:c}=a;if(s("beforeinput",e,o,d,l,a),this.lastNode=this.lastOffset=void 0,e.inputType.startsWith("delete")){if(n((()=>{this.processEmptiedFillers(i),this.removeExtraBOMs(i),this.fixInsertedLineBreaks(i)})),(null==o?void 0:o.nodeValue)===r.Z&&l.isCollapsed&&e.inputType.includes("deleteContent")){const t=e.inputType.includes("Backward"),s=d===r.Z.length&&t||!d&&!t;this.superMove(i,a,t,s)}}else{if(e.inputType.startsWith("insert")){if(null===(t=null==o?void 0:o.classList)||void 0===t?void 0:t.contains("input-something")){o=o.previousSibling.firstChild;const e=l.getRangeAt(0);e.setStart(o,0),e.setEnd(o,0),e.collapse(!0);const t=this.getCaretPosN();o=t.node,l=t.selection,d=t.offset}if(o&&o.textContent===r.Z&&d===r.Z.length){l.modify("move","backward","character");const e=this.getCaretPosN();o=e.node,l=e.selection,d=e.offset}e.inputType;{o&&o.nodeType===o.ELEMENT_NODE&&(o=o.firstChild,s.warn("fixing focus on span"));const t=(null==o?void 0:o.nodeValue)===r.Z;if(s("inserting line break",t,o,`"${null==o?void 0:o.nodeValue}"`,(null==o?void 0:o.parentElement)?Array.from(o.parentElement.childNodes).slice():[]),t){const e=o.parentElement;e.classList.replace("input-filler","input-filler-text"),e.childNodes.length,n((()=>{e.childNodes.length>1?(s("inserting line break, remove"),o=Array.from(e.childNodes).find((e=>e.nodeValue===r.Z)),e.t=o):o.nodeValue!==r.Z&&(s("inserting line break, deleteData"),o.deleteData(o.nodeValue.indexOf(r.Z),r.Z.length)),this.fixInsertedLineBreaks(i)}))}else"insertLineBreak"===e.inputType&&n((()=>{this.fixInsertedLineBreaks(i)}))}return}"historyUndo"===e.inputType?n((()=>{this.processFilledFillers(i),this.processEmptiedFillers(i),this.removeExtraBOMs(i),this.removeEmptyTextNodes(i),this.fixBuggedCaret()})):"historyRedo"===e.inputType&&n((()=>{this.processFilledFillers(i),this.processEmptiedFillers(i),i.querySelectorAll(".input-something:not([contenteditable])").forEach((e=>{e.contentEditable="false"})),this.removeExtraBOMs(i),this.fixBuggedCaret()}))}},this.onKeyDown=e=>{var t;const i=e.key;if("ArrowDown"===i||"ArrowUp"===i)this.lastNode=this.lastOffset=void 0;else{const{node:e,offset:t}=this.getCaretPosN();this.lastNode=e,this.lastOffset=t,this.lastNode===this.input&&(this.lastNode=this.lastOffset=void 0)}this.log("keydown",this.lastNode,null===(t=this.lastNode)||void 0===t?void 0:t.parentNode,this.lastOffset,this.getCaretPosN(),e)},this.log=(0,n.kg)("RICH-INPUT"),this.listenerSetter=new o.Z,this.savedRanges=new WeakMap,this.listenerSetter.add(document)("selectionchange",this.saveSelectionOnChange),m&&(this.listenerSetter.add(document)("focusout",this.onFocusOut),this.listenerSetter.add(document)("selectionchange",this.onSelectionChange),this.listenerSetter.add(document)("beforeinput",this.onBeforeInput),this.listenerSetter.add(document)("keydown",this.onKeyDown,{capture:!0}),s.IS_FIREFOX&&(this.inputCaptureCallbacks=[],this.listenerSetter.add(document)("input",(()=>{this.inputCaptureCallbacks.forEach((e=>e())),this.inputCaptureCallbacks.length=0}),{capture:!0})))}get input(){const e=document.getSelection(),{anchorNode:t}=e;if(t)return(t.closest?t:t.parentElement).closest('[contenteditable="true"]')}saveRangeForElement(e){e&&(e.isContentEditable||"INPUT"===e.tagName)&&document.getSelection().rangeCount&&this.savedRanges.set(e,document.getSelection().getRangeAt(0))}findPreviousSmthIndex(e,t,i){const s=Array.from(null!=i?i:e.querySelectorAll(".input-something")),n=s.findIndex((e=>h(e,0,t,0)>=0));return-1===n?s.length-1:Math.max(0,n-1)}superMove(e,t,i,s){var n,a;const{node:o,offset:d,move:l}=t,c=e.querySelectorAll(".input-something"),h=this.findPreviousSmthIndex(e,o,c),u=document.createRange();u[i?"setEnd":"setStart"](o,d),s&&l(i);const p=this.getCaretPosN();if((null===(n=p.node)||void 0===n?void 0:n.nodeValue)===r.Z&&(!s||o===this.lastNode)){const t=this.findPreviousSmthIndex(e,p.node,c);let n=!s;for(;;){const s=this.getCaretPosN(),d=this.findPreviousSmthIndex(e,s.node,c);u[i?"setStart":"setEnd"](s.node,s.offset);const p=u.toString(),m=!f.test(p);if(this.log("test cursor",p,m,t,d),!m||(null===(a=s.node)||void 0===a?void 0:a.nodeValue)!==r.Z||d!==t||!d&&!s.offset||!(d<c.length-1||s.offset<r.Z.length)){if(n){(!this.getFiller(o).classList.contains("input-filler-text")&&t!==h||s.offset===r.Z.length)&&l(!i);break}break}l(i),n=!0}}}restoreSavedRange(e){const t=this.getSavedRange(e);if(!t)return!1;const i=window.getSelection();return i.removeAllRanges(),i.addRange(t),!0}getSavedRange(e){return this.savedRanges.get(e)}makeFocused(e){document.activeElement===e||this.restoreSavedRange(e)||(0,p.Z)(e,!1,!1)}fixInsertedLineBreaks(e){e.querySelectorAll("br").forEach((e=>{e.classList.add("br-not-br")}))}fixBuggedCaret(){const e=document.getSelection(),t=e.getRangeAt(0);e.removeAllRanges(),e.addRange(t)}addInputCallback(e,t,i=!0){const n=()=>{this.log("input modify callback"),t()};i&&s.IS_FIREFOX?this.inputCaptureCallbacks.push(n):this.listenerSetter.add(e)("input",n,{once:!0,capture:i})}removeExtraBOMs(e){const t=e=>{var t;return null===(t=null==e?void 0:e.classList)||void 0===t?void 0:t.contains("input-something")};e.querySelectorAll(".input-filler").forEach((e=>{var i;const{previousSibling:s,nextSibling:n}=e;let o=!1;!(null===(i=null==n?void 0:n.classList)||void 0===i?void 0:i.contains("input-filler"))&&(0,a.Hc)(n)&&(o=t(s)||t(n)),o||(this.log.warn("removing empty bom node",e),e.remove())}))}getFiller(e){return e&&e.nodeType===e.TEXT_NODE&&e.parentElement!==this.input?e.parentElement:e}getCaretPosN(){const e=(0,u.Z)(this.input);return Object.assign(Object.assign({},e),{move:this.move.bind(this,e.selection)})}removeEmptyTextNodes(e){const{log:t}=this,i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode:t=>t.parentElement!==e||t.nodeValue?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT});let s;for(;s=i.nextNode();)t.warn("removing empty text node",s),s.remove()}removePossibleBOMSiblings(e,t){[e,t].forEach((e=>{var t;(null===(t=null==e?void 0:e.classList)||void 0===t?void 0:t.contains("input-filler"))&&e.remove()}))}removePossibleBOMSiblingsByNode(e){const{previousSibling:t,nextSibling:i}=e;this.removePossibleBOMSiblings(t,i)}processEmptiedFillers(e){e.querySelectorAll(".input-filler-text").forEach((e=>{var t;this.removeExtraBOMs(e);let i=!0;if(e.textContent)f.test(e.textContent)||e.querySelector(".input-something")?i=!1:e.classList.replace("input-filler-text","input-filler");else{e.classList.replace("input-filler-text","input-filler");const i=Array.from(e.childNodes).find((e=>e.nodeType===e.TEXT_NODE));i?i.insertData(0,r.Z):(null===(t=e.t)||void 0===t?void 0:t.nodeValue)?e.append(e.t):e.append(document.createTextNode(r.Z))}i&&this.removePossibleBOMSiblingsByNode(e)}))}processFilledFillers(e){e.querySelectorAll(".input-filler").forEach((e=>{if(e.textContent!==r.Z){e.classList.replace("input-filler","input-filler-text");const t=e.t,i=Array.from(e.childNodes).find((e=>e.nodeType===e.TEXT_NODE&&e.nodeValue.includes(r.Z)));if(i&&!(null==t?void 0:t.nodeValue)){const e=i.nodeValue.indexOf(r.Z);-1!==e&&i.deleteData(e,r.Z.length)}}}))}setSelectionClassName(e,t){if(e.rangeCount){const i=e.getRangeAt(0);t?Array.from(t.querySelectorAll(".input-selectable")).forEach((e=>{e.classList.toggle("selection",!i.collapsed&&i.intersectsNode(e))})):Array.from(document.querySelectorAll(".input-selectable.selection")).forEach((e=>e.classList.remove("selection")))}}move(e,t){const{focusNode:i,focusOffset:s}=e;e.modify("extend",t?"backward":"forward","character"),t?e.collapseToStart():e.collapseToEnd();const{focusNode:n,focusOffset:a}=e;this.log("moving cursor",t,i,i.nodeType===i.ELEMENT_NODE?i:i.parentElement,s,n,n.nodeType===n.ELEMENT_NODE?n:n.parentElement,a)}prepareApplyingMarkdown(){const{input:e}=this,t=e.querySelectorAll(".input-filler"),i=e.querySelectorAll(".input-something");return i.forEach((e=>{e.contentEditable="inherit"})),()=>{t.forEach((e=>{e.contentEditable="inherit"})),i.forEach((e=>{e.contentEditable="false"})),this.removeExtraBOMs(e)}}static getInstance(){var e;return null!==(e=this.INSTANCE)&&void 0!==e?e:this.INSTANCE=new g}}},8928:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(5994);function n(e){if(!s.Z.isAvailable("animations"))return;const t=[{transform:"translateX(0)"},{transform:"translateX(.25rem)"},{transform:"translateX(-.25rem)"},{transform:"translateX(0)"}];e.animate([...t,...t,...t],{duration:300,iterations:1,easing:"ease-in-out"})}},2914:(e,t,i)=>{"use strict";i.d(t,{Z:()=>f});var s=i(3757),n=i(5432),a=i(5994),o=i(3228),r=i(5953),d=i(5418),l=i(3910),c=i(2738),h=i(5975),u=i(4484),p=i(2648);class f{constructor(e){this.onSwipe=(e,t)=>{t=(0,o.Z)(t,this.minY,this.maxY),this.element.style.transform=`translateY(${t}px)`;const i=Math.round(Math.abs(t)/this.elementRect.height),s=this.siblings;this.siblings=[];const n=t<0?"previousElementSibling":"nextElementSibling";let a=this.element[n];for(let e=0;e<i&&this.getSortableTarget(a);++e)this.siblings.push(a),a=a[n];if((s||[]).forEach((e=>{this.siblings.includes(e)||(e.style.transform="")})),this.siblings.forEach((e=>{const i=this.elementRect.height*(t<0?1:-1);e.style.transform=`translateY(${i}px)`})),this.scrollableRect){const e=t,i=e>0,s=(i?this.elementRect.bottom:this.elementRect.top)+e-this.addScrollPos;let n=2;s+(i?0:this.elementRect.height)>=this.scrollableRect.bottom||(s-(i?this.elementRect.height:0)<=this.scrollableRect.top?n*=-1:n=void 0),void 0!==n&&(this.scrollable.container[this.scrollable.scrollProperty]+=n)}},this.verifyTouchTarget=e=>!this.list.classList.contains("is-reordering")&&(this.element=this.getSortableTarget(e.target),!!this.element),this.onScroll=()=>{const e=this.scrollable.container[this.scrollable.scrollProperty],t=this.addScrollPos=e-this.startScrollPos,i="scrollTop"===this.scrollable.scrollProperty;this.swipeHandler.add(i?0:t,i?t:0)},this.onStart=()=>{this.list.classList.add("is-reordering"),this.element.classList.add("is-dragging","no-transition"),this.swipeHandler.setCursor("grabbing"),this.elementRect=this.element.getBoundingClientRect(),this.containerRect=this.list.getBoundingClientRect(),this.minY=this.containerRect.top-this.elementRect.top,this.maxY=this.containerRect.bottom-this.elementRect.bottom,this.addScrollPos=0,this.scrollable&&(this.startScrollPos=this.scrollable.container[this.scrollable.scrollProperty],this.scrollableRect=this.scrollable.container.getBoundingClientRect(),this.scrollable.container.addEventListener("scroll",this.onScroll))},this.onReset=()=>{return e=this,t=void 0,s=function*(){const e=this.siblings.length,t=e&&e*(this.siblings[0].previousElementSibling===this.element?1:-1),i=(0,p.Z)(this.element),s=i+t;this.element.classList.remove("no-transition"),this.element.style.transform=t?`translateY(${t*this.elementRect.height}px)`:"",this.swipeHandler.setCursor(""),this.scrollable&&this.scrollable.container.removeEventListener("scroll",this.onScroll),n.Z||(0,c.fc)(document.body,l.Z,{capture:!0,once:!0}),a.Z.isAvailable("animations")&&(yield(0,d.Z)(250)),this.list.classList.remove("is-reordering"),this.element.classList.remove("is-dragging"),(0,u.Z)(this.element,this.list,s,i),[this.element,...this.siblings].forEach((e=>{e.style.transform=""})),this.element=this.siblings=this.elementRect=this.containerRect=this.minY=this.maxY=this.startScrollPos=this.addScrollPos=void 0,t&&this.onSort(i,s)},new((i=void 0)||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}));var e,t,i,s},(0,r.Z)(this,e),this.swipeHandler=new s.Z({element:this.list,onSwipe:this.onSwipe,verifyTouchTarget:this.verifyTouchTarget,onStart:this.onStart,onReset:this.onReset,setCursorTo:document.body,middleware:this.middleware,withDelay:!0})}getSortableTarget(e){if(!e)return;let t=(0,h.Z)(e,this.list);return t&&t.classList.contains("cant-sort")&&(t=void 0),t}}},1656:(e,t,i)=>{"use strict";function s(e,t){return t?e.forEach((e=>e.setAttribute("disabled","true"))):e.forEach((e=>e.removeAttribute("disabled"))),()=>s(e,!t)}i.d(t,{Z:()=>s})},2648:(e,t,i)=>{"use strict";function s(e,t){if(!e.parentNode)return-1;if(t)return Array.from(e.parentNode.childNodes).indexOf(e);let i=0;for(;null!==(e=e.previousElementSibling);)++i;return i}i.d(t,{Z:()=>s})},6339:(e,t,i)=>{"use strict";i.d(t,{Z:()=>h});var s=i(2738),n=i(5975),a=i(3241),o=i(5432),r=i(5953),d=i(5824),l=i(8497),c=i(5994);class h extends a.Z{constructor(e){super(!1),this.onClickOut=e=>{const t=e.target;(0,n.Z)(t,this.element)||Array.from(this.ignoreButtons).some((e=>(0,n.Z)(t,e)||t===e))||!(this.ignoreMouseOut.size<=1)||this.ignoreOutClickClassName&&(0,l.Z)(t,this.ignoreOutClickClassName)||this.toggle(!1)},this.onMouseOut=e=>{if(!this.isActive())return;if(this.clearTimeout("toggle"),this.ignoreMouseOut.size)return;const t=e.toElement;t&&(0,n.Z)(t,this.element)||this.setTimeout("toggle",(()=>{this.toggle(!1)}),200)},this.toggle=e=>{return t=this,i=void 0,n=function*(){var t;const i=!!this.element.style.display&&void 0===e||e;if(this.init){if(!i)return;this.init(),this.init=null}if(i===this.isActive())return;const s=o.Z||!c.Z.isAvailable("animations")?0:200;if(this.element.style.display&&void 0===e||e){const e=this.dispatchResultableEvent("open");yield Promise.all(e),this.element.style.display="",this.element.offsetLeft,this.element.classList.add("active"),this.dispatchEvent("openAfterLayout"),d.Z.pushItem(this.navigationItem={type:"dropdown",onPop:()=>{this.toggle(!1)}}),this.clearTimeout("toggle"),this.setTimeout("done",(()=>{this.forceClose=!1,this.dispatchEvent("opened")}),s)}else this.dispatchEvent("close"),this.ignoreMouseOut.clear(),this.ignoreButtons.clear(),this.element.classList.remove("active"),d.Z.removeItem(this.navigationItem),null===(t=this.detachClickEvent)||void 0===t||t.call(this),this.detachClickEvent=void 0,this.clearTimeout("toggle"),this.setTimeout("done",(()=>{this.element.style.display="none",this.forceClose=!1,this.dispatchEvent("closed")}),s)},new((s=void 0)||(s=Promise))((function(e,a){function o(e){try{d(n.next(e))}catch(e){a(e)}}function r(e){try{d(n.throw(e))}catch(e){a(e)}}function d(t){var i;t.done?e(t.value):(i=t.value,i instanceof s?i:new s((function(e){e(i)}))).then(o,r)}d((n=n.apply(t,i||[])).next())}));var t,i,s,n},(0,r.Z)(this,e),this.forceClose=!1,this.inited=!1,this.ignoreMouseOut=new Set,this.ignoreButtons=new Set,this.timeouts={}}attachButtonListener(e,t){let i=!0;o.Z?(0,s.fc)(e,(()=>{i?(i=!1,this.toggle(!0)):this.toggle()}),{listenerSetter:t}):(t.add(e)("mouseover",(s=>{i&&(t.add(e)("mouseout",(e=>{this.clearTimeout("toggle"),this.onMouseOut(e)})),i=!1),this.setTimeout("toggle",(()=>{this.toggle(!0)}),200)})),(0,s.fc)(e,(()=>{const t="click",i=!this.ignoreMouseOut.has(t);i&&!this.ignoreMouseOut.size&&(this.ignoreButtons.add(e),setTimeout((()=>{this.detachClickEvent=(0,s.fc)(window,this.onClickOut,{capture:!0})}),0)),this.setIgnoreMouseOut(t,i),this.toggle(i)}),{listenerSetter:t}))}clearTimeout(e){void 0!==this.timeouts[e]&&(clearTimeout(this.timeouts[e]),delete this.timeouts[e])}setTimeout(e,t,i){this.clearTimeout(e),this.timeouts[e]=window.setTimeout((()=>{this.clearTimeout(e),t()}),i)}init(){o.Z||(this.element.onmouseout=this.onMouseOut,this.element.onmouseover=e=>{this.forceClose||this.clearTimeout("toggle")})}isActive(){return this.element.classList.contains("active")}setIgnoreMouseOut(e,t){t?this.ignoreMouseOut.add(e):this.ignoreMouseOut.delete(e)}}},4789:(e,t,i)=>{"use strict";i.d(t,{Z:()=>l,f:()=>s});var s,n=i(8594),a=i(3035),o=i(5296),r=i(8487),d=i(5994);function l(e){var t,i,o;if(null!==(t=e.margin)&&void 0!==t||(e.margin=0),null!==(i=e.maxDistance)&&void 0!==i||(e.maxDistance=1500),null!==(o=e.axis)&&void 0!==o||(e.axis="y"),d.Z.isAvailable("animations")&&0!==e.forceDuration||(e.forceDirection=s.Static),e.forceDirection===s.Static)return e.forceDuration=0,c(e);const r=(0,a.AD)().then((()=>c(e)));return"y"===e.axis?(0,n.YW)(r):r}function c(e){const{element:t,container:i,getNormalSize:s,getElementPosition:n,transitionFunction:a,axis:d,margin:l,position:p,forceDirection:f,maxDistance:m,forceDuration:g}=e;if(!(0,r.Z)(t))return(0,o.Kx)(i),Promise.resolve();const v="y"===d?"top":"left",b="y"===d?"bottom":"right",y="y"===d?"height":"width",w="y"===d?"scrollHeight":"scrollWidth",S="y"===d?"scrollHeight":"offsetWidth",C="y"===d?"scrollTop":"scrollLeft",L=t.getBoundingClientRect(),E=i.getBoundingClientRect?i.getBoundingClientRect():document.body.getBoundingClientRect(),I=L[v]-E[v],P=n?n({elementRect:L,containerRect:E,elementPosition:I}):I,Z=t[S],M=s?s({rect:E}):E[y];let k=i[C];const T=i[w];let x;switch(p){case"start":x=P-l;break;case"end":x=L[b]-E[b]+l;break;case"nearest":case"center":if(Z<M)x=P+Z/2-M/2;else{if(e.fallbackToElementStartWhenCentering&&e.fallbackToElementStartWhenCentering!==t)return e.element=e.fallbackToElementStartWhenCentering,e.position="start",c(e);x=P-l}}if(Math.abs(x-(l||0))<1)return(0,o.Kx)(i),Promise.resolve();if("y"===d&&void 0===f&&(x>m?(k=i.scrollTop+=x-m,x=m):x<-m&&(k=i.scrollTop+=x+m,x=-m)),x<0){const e=-k;x=Math.max(x,e)}else if(x>0){const e=T-(k+M);x=Math.min(x,e)}const A=i[C]+x,_=Math.abs(x),F=null!=g?g:250+_/1500*350,D=Date.now(),R=null!=a?a:_<500?u:h,B=()=>F?Math.min((Date.now()-D)/F,1):1,N=()=>{const e=B(),t=R(e),s=x*(1-t);return i[C]=Math.round(A-s),e<1};if(!F||!x)return(0,o.Kx)(i),N(),Promise.resolve();if(e.startCallback){const t=T-Math.round(A+i["y"===d?"offsetHeight":"offsetWidth"]);e.startCallback({scrollSize:T,scrollPosition:k,distanceToEnd:t,path:x,duration:F,containerRect:E,elementRect:L,getProgress:B})}return(0,o.cK)(N,i)}function h(e){return 1-Math.pow(1-e,5)}function u(e){return 1-Math.pow(1-e,3.5)}!function(e){e[e.Up=0]="Up",e[e.Down=1]="Down",e[e.Static=2]="Static"}(s||(s={}))},8801:(e,t,i)=>{"use strict";i.d(t,{P:()=>n});const s="_";function n(e,t){const i=""["".length-1]||"";let n;switch(e._){case"inputPhotoFileLocation":n=["photo",""[0],e.id,e.thumb_size].filter(Boolean).join(s);break;case"inputDocumentFileLocation":n=["document",""[0],e.id,e.thumb_size].filter(Boolean).join(s);break;case"inputPeerPhotoFileLocation":n=["peerPhoto",e.photo_id,e.pFlags.big?"big":"small"].join(s);break;case"inputStickerSetThumb":n=["stickerSetThumb",e.stickerset.id||e.stickerset.short_name||e.stickerset.emoticon||e.stickerset._,e.thumb_version].join(s);break;case"inputFileLocation":n=[e.volume_id,e.local_id].join(s);break;case"inputWebFileLocation":n=["webFile",e.url].join(s);break;default:console.error("Unrecognized location:",e),n=""}return n+((null==t?void 0:t.downloadId)?"_download":"")+(i?"."+i:i)}},1708:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(7625);function n(e){(0,s.Z)(e.history,((t,i,s)=>{t.action.photo||(s.splice(i,1),void 0!==e.count&&--e.count)}))}},4081:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(2325);function n(e,t="auto"){if(0===e)return(0,s.ag)("FileSize.B",[0]);const i="auto"===t,n=Math.floor(Math.log(e)/Math.log(1024)),a="auto"===t?Math.max(0,n-1):t,o=Math.max(0,a),r=(e/Math.pow(1024,n)).toFixed(o);return(0,s.ag)(["FileSize.B","FileSize.KB","FileSize.MB","FileSize.GB"][n],[i?r:parseFloat(r)])}},8939:(e,t,i)=>{"use strict";i.d(t,{Z:()=>a});var s=i(2325);const n={s:"Seconds",m:"Minutes",h:"Hours",d:"Days",w:"Weeks",mm:"Months",y:"Years"};function a(e,t){const i=function(e,t=2){e||(e=1);const i=[],s=[{m:1,t:"s"},{m:60,t:"m"},{m:60,t:"h"},{m:24,t:"d"},{m:7,t:"w"}];let n=1;s.forEach(((t,a)=>{if(n=Math.round(n*t.m),e<n)return;let o=e/n;a!==s.length-1&&(o%=s[a===s.length-1?a:a+1].m),i.push({duration:0|o,type:t.t})}));const a=i.slice(-t).reverse();for(let e=a.length-1;e>=0;--e)0===a[e].duration&&a.splice(e,1);return a}(e,2);if(t){const e=i.map((e=>s.ZP.format(n[e.type],!0,[e.duration])));return(0,s.v_)(e,!1,t)}const a=i.map((e=>(0,s.ag)(n[e.type],[e.duration]))),o=document.createElement("span");return o.append(...(0,s.v_)(a,!1)),o}},6272:(e,t,i)=>{"use strict";i.d(t,{u:()=>r});var s=i(2325);const n=new Map;let a=0;const o=(e,t,i="")=>{i=t.country_code+i,a=Math.max(a,i.length),n.set(i,{country:e,code:t})};function r(e){e=e||"",n.size||s.ZP.countriesList.forEach((e=>{e.country_codes.forEach((t=>{t.prefixes?t.prefixes.forEach((i=>{o(e,t,i)})):o(e,t)}))}));let t=e.replace(/\D/g,"");const i=t.slice(0,a);let r;for(let e=i.length-1;e>=0&&(r=n.get(i.slice(0,e+1)),!r);--e);if(!r)return{formatted:t,country:void 0,code:void 0,leftPattern:""};const d=r.country,l=r.code.patterns||[],c=t.slice(r.code.country_code.length);let h="",u=0,p="";for(let e=l.length-1;e>=0;--e){h=l[e];const t=h.replace(/ /g,"");let i=0;for(let e=0,s=Math.min(c.length,t.length);e<s;++e)if(c[e]===t[e])i+=1.01;else{if("X"!==t[e]){i=0;break}++i}i>u&&(u=i,p=h)}h=p||h,h=h.replace(/\d/g,"X"),h=r.code.country_code+" "+h,h.split("").forEach(((e,i)=>{" "===e&&" "!==t[i]&&t.length>i&&(t=t.slice(0,i)+" "+t.slice(i))}));let f=h&&h.length>t.length?h.slice(t.length):"";return f&&(f=f.replace(/X/g,"")),{formatted:t,country:d,code:r.code,leftPattern:f}}},645:(e,t,i)=>{"use strict";i.d(t,{M:()=>s,Z:()=>n});class s{constructor(){this.cache=new Map}static createCache(){const e={frames:new Map,framesNew:new Map,framesURLs:new Map,clearCache:()=>{e.framesNew.forEach((e=>{var t,i;null===(i=(t=e).close)||void 0===i||i.call(t)})),e.frames.clear(),e.framesNew.clear(),e.framesURLs.clear()},counter:0};return e}getCache(e){let t=this.cache.get(e);return t||this.cache.set(e,t=s.createCache()),++t.counter,t}releaseCache(e){const t=this.cache.get(e);t&&!--t.counter&&this.cache.delete(e)}getCacheCounter(e){const t=this.cache.get(e);return null==t?void 0:t.counter}generateName(e,t,i,s,n){return[e,t,i,s?"colored":"",n||""].filter(Boolean).join("-")}}const n=new s},9171:(e,t,i)=>{"use strict";function s(e,t,i,s,n,a,o){return[e,",",t," ",i," ",s,",",n," ",a,",",o].join("")}function n(e,t,i,n,a,o,r,d){const l=[];return l.push("M"+(e+i/2)+","+t),l.push("H"+(e+i-o)),o>0&&l.push("A"+s(o,o,0,0,1,e+i,t+o)),l.push("V"+(t+n-r)),r>0&&l.push("A"+s(r,r,0,0,1,e+i-r,t+n)),l.push("H"+(e+d)),d>0&&l.push("A"+s(d,d,0,0,1,e+0,t+n-d)),l.push("V"+(t+a)),a>0&&l.push("A"+s(a,a,0,0,1,e+a,t+0)),l.push("Z"),l.join(" ")}i.d(t,{Z:()=>n}),i(410).GO.generatePathData=n},1046:(e,t,i)=>{"use strict";i.d(t,{Z:()=>o});var s=i(6740),n=i(1185),a=i(6705);function o(e,t,i){const o=(0,n.Z)(e,t,!1);let r,d;if(i){const e=(0,a.Z)(o);r=e.canvas,d=e.promise}else r=new Image,d=(0,s.cj)(r,o);return r.classList.add("thumbnail"),{image:r,loadPromise:d}}},1185:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(4059);function n(e,t,i=!1){return(0,s.Z)(t.bytes,i)}},8580:(e,t,i)=>{"use strict";i.d(t,{Z:()=>a});var s=i(1507),n=i(1046);function a(e,t,i,a=!1){const o=["video","gif"].includes(e.type);if(!t.downloaded||o||a){if("document"===e._&&t.downloaded&&!a&&(!o||t.type!==s.Pt))return null;const r=e.sizes||e.thumbs,d=(null==r?void 0:r.length)?r.find((e=>"photoStrippedSize"===e._)):null;if(d&&"bytes"in d)return(0,n.Z)(e,d,i)}return null}},6074:(e,t,i)=>{"use strict";i.d(t,{Z:()=>a});var s=i(7625),n=i(5953);class a{constructor(e){this.previous=[],this.next=[],this.reverse=!1,this.loadCount=50,this.loadWhenLeft=20,this.loadedAllUp=!1,this.loadedAllDown=!1,(0,n.Z)(this,e)}setTargets(e,t,i){this.previous=e,this.next=t,this.reverse=i}get index(){return void 0!==this.count?this.previous.length:-1}reset(e=!1){this.current=void 0,this.previous=[],this.next=[],this.setLoaded(!0,e),this.setLoaded(!1,e)}go(e,t=!0){let i,s;if(e>0){if(i=this.next.splice(0,e),s=i.pop(),!s)return;void 0!==this.current&&i.unshift(this.current),this.previous.push(...i)}else{if(i=this.previous.splice(Math.max(0,this.previous.length+e),-e),s=i.shift(),!s)return;void 0!==this.current&&i.push(this.current),this.next.unshift(...i)}return this.next.length<this.loadWhenLeft&&this.load(!this.reverse),this.previous.length<this.loadWhenLeft&&this.load(this.reverse),this.current=s,t&&this.onJump&&this.onJump(s,e>0),this.current}unsetCurrent(e){e?this.previous.push(this.current):this.next.unshift(this.current),this.current=void 0}goUnsafe(e,t){const i=e>0?Math.max(0,e-this.next.length):Math.min(0,e+this.previous.length),s=this.go(e,!i&&t);return{item:i?void 0:s,leftLength:i}}setLoaded(e,t){return(e?this.loadedAllDown:this.loadedAllUp)!==t&&(e?this.loadedAllDown=t:this.loadedAllUp=t,t||(e?this.loadPromiseDown=null:this.loadPromiseUp=null),!0)}load(e){if(e?this.loadedAllDown:this.loadedAllUp)return Promise.resolve();let t,i=e?this.loadPromiseDown:this.loadPromiseUp;return i||(t=e?this.reverse?this.previous[0]:this.next[this.next.length-1]:this.reverse?this.next[this.next.length-1]:this.previous[0],null!=t||(t=this.current),i=this.loadMore(t,e,this.loadCount).then((t=>{return n=this,a=void 0,r=function*(){if((e?this.loadPromiseDown:this.loadPromiseUp)!==i)return;t.items.length<this.loadCount&&this.setLoaded(e,!0),void 0===this.count&&(this.count=t.count||t.items.length);const n=[];(e?t.items.forEach.bind(t.items):s.Z.bind(null,t.items))((e=>{const t=this.processItem?this.processItem(e):e;t&&n.push(t)}));const a=yield Promise.all(n);e?this.reverse?this.previous.unshift(...a):this.next.push(...a):this.reverse?this.next.push(...a):this.previous.unshift(...a),this.onLoadedMore&&this.onLoadedMore()},new((o=void 0)||(o=Promise))((function(e,t){function i(e){try{d(r.next(e))}catch(e){t(e)}}function s(e){try{d(r.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o((function(e){e(n)}))).then(i,s)}d((r=r.apply(n,a||[])).next())}));var n,a,o,r}),(()=>{})).then((()=>{e?this.loadPromiseDown=null:this.loadPromiseUp=null})),e?this.loadPromiseDown=i:this.loadPromiseUp=i,i)}}},3699:(e,t,i)=>{"use strict";i.d(t,{Z:()=>s});class s{constructor(){this.listeners=new Set}add(e){return(t,i,s)=>{const n={element:e,event:t,callback:i,options:s};return this.addManual(n),n}}addManual(e){var t;e.element.addEventListener(e.event,e.callback,e.options),(null===(t=e.options)||void 0===t?void 0:t.once)&&(e.onceCallback=()=>{this.remove(e),e.onceFired=!0},e.element.addEventListener(e.event,e.onceCallback,e.options)),this.listeners.add(e)}remove(e){e.onceFired||(e.element.removeEventListener(e.event,e.callback,e.options),e.onceCallback&&e.element.removeEventListener(e.event,e.onceCallback,e.options)),this.listeners.delete(e)}removeManual(e,t,i,s){let n;for(const a of this.listeners)if(a.element===e&&a.event===t&&a.callback===i&&a.options===s){n=a;break}n&&this.remove(n)}removeAll(){this.listeners.forEach((e=>{this.remove(e)}))}}},5994:(e,t,i)=>{"use strict";i.d(t,{Z:()=>o});var s=i(410),n=i(3512);const a=new class{isEnabled(){return n.Z.settings.liteMode.all}isAvailable(e){return!n.Z.settings.liteMode.all&&!n.Z.settings.liteMode[e]}};s.GO&&(s.GO.liteMode=a);const o=a},9405:(e,t,i)=>{"use strict";i.d(t,{C:()=>a,c:()=>n});var s=i(9897);class n{constructor(e=0,t=e){this.width=e,this.height=t}aspect(e,t){return(0,s.Z)(this.width,this.height,e.width,e.height,t)}aspectFitted(e){return this.aspect(e,!0)}aspectCovered(e){return this.aspect(e,!1)}}function a(e,t){return new n(e,t)}},4755:(e,t,i)=>{"use strict";i.d(t,{Z:()=>u,_:()=>s});var s,n=i(410),a=i(3241),o=i(9405);!function(e){e[e.mobile=0]="mobile",e[e.medium=1]="medium",e[e.large=2]="large"}(s||(s={}));const r=(0,o.C)(20,20),d=(0,o.C)(36,36),l=(0,o.C)(18,18);class c extends a.Z{constructor(){super(),this.screenSizes=[{key:s.mobile,value:600},{key:s.medium,value:1275},{key:s.large,value:1680}],this.sizes={handhelds:{regular:(0,o.C)(270,270),webpage:(0,o.C)(270,200),album:(0,o.C)(270,0),esgSticker:(0,o.C)(68,68),animatedSticker:(0,o.C)(180,180),staticSticker:(0,o.C)(180,180),emojiSticker:(0,o.C)(112,112),poll:(0,o.C)(240,0),round:(0,o.C)(200,200),documentName:(0,o.C)(200,0),invoice:(0,o.C)(270,270),extendedInvoice:(0,o.C)(270,270),customEmoji:r,esgCustomEmoji:d,emojiStatus:l,popupSticker:(0,o.C)(68,68)},desktop:{regular:(0,o.C)(420,340),webpage:(0,o.C)(420,340),album:(0,o.C)(420,0),esgSticker:(0,o.C)(72,72),animatedSticker:(0,o.C)(200,200),staticSticker:(0,o.C)(200,200),emojiSticker:(0,o.C)(112,112),poll:(0,o.C)(330,0),round:(0,o.C)(280,280),documentName:(0,o.C)(240,0),invoice:(0,o.C)(320,320),extendedInvoice:(0,o.C)(420,340),customEmoji:r,esgCustomEmoji:d,emojiStatus:l,popupSticker:(0,o.C)(80,80)}},this.isMobile=!1,this.handleResize=()=>{const e=window.innerWidth;let t=this.screenSizes[0].key;for(let i=this.screenSizes.length-1;i>=0;--i)if(this.screenSizes[i].value<e){t=(this.screenSizes[i+1]||this.screenSizes[i]).key;break}const i=this.activeScreen;this.activeScreen=t,this.isMobile=this.activeScreen===s.mobile,this.active=this.isMobile?this.sizes.handhelds:this.sizes.desktop,i!==t&&void 0!==i&&this.dispatchEvent("changeScreen",i,t),void 0!==i&&this.dispatchEvent("resize")},window.addEventListener("resize",(()=>{this.rAF&&window.cancelAnimationFrame(this.rAF),this.rAF=window.requestAnimationFrame((()=>{this.handleResize(),this.rAF=0}))})),this.handleResize()}}const h=new c;n.GO.mediaSizes=h;const u=h},8631:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});const s=(0,i(5471).Z)("MIDDLEWARE");function n(e,t=s){return i=>{if(!(i instanceof Promise)){if(i instanceof Error)throw i;return i}return i.then((i=>{if(!e())throw t;return i}))}}},2559:(e,t,i)=>{"use strict";function s(e,t=2){if(0===e)return"0";const i=t<0?0:t,s=Math.floor(Math.log(e)/Math.log(1e3));return parseFloat((e/Math.pow(1e3,s)).toFixed(i))+["","K","M","B","T"][s]}i.d(t,{Z:()=>s})},2575:(e,t,i)=>{"use strict";function s(e,t=" "){const i=e.toString().split(".");return i[0]=i[0].replace(/\B(?=(\d{3})+(?!\d))/g,t),i.join(".")}i.d(t,{Z:()=>s})},925:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(4762);function n(e,t=e.HAVE_METADATA,i){return new Promise(((n,a)=>{if(e.readyState>=t)return void n();const o=s.IS_APPLE_MOBILE&&!i?"loadeddata":"canplay",r="error",d=()=>{e.removeEventListener(r,l),n()},l=t=>{e.removeEventListener(o,d),a(e.error)};e.addEventListener(o,d,{once:!0}),e.addEventListener(r,l,{once:!0})}))}},2296:(e,t,i)=>{"use strict";i.d(t,{Z:()=>c});var s=i(5824),n=i(5432),a=i(4762),o=i(3910),r=i(2738),d=i(5975),l=i(3241);class c extends l.Z{constructor(e,t){super(!1),this.navigationType=e,this.withOverlay=t,this.onClick=e=>{var t;(0,r.Cf)(e)||this.element&&(0,d.Z)(e.target,this.element)||((null===(t=this.listenerOptions)||void 0===t?void 0:t.capture)&&(0,o.Z)(e),this.close())},this.listenerOptions=t?{}:{capture:!0}}close(){var e;this.element&&(null===(e=this.overlay)||void 0===e||e.remove(),this.element=void 0,this.dispatchEvent("toggle",!1)),n.Z||window.removeEventListener("contextmenu",this.onClick,this.listenerOptions),document.removeEventListener(r.pf,this.onClick,this.listenerOptions),a.IS_MOBILE_SAFARI||s.Z.removeByType(this.navigationType)}open(e){this.close(),a.IS_MOBILE_SAFARI||s.Z.pushItem({type:this.navigationType,onPop:e=>{this.close()}}),this.element=e,!this.overlay&&this.withOverlay&&(this.overlay=document.createElement("div"),this.overlay.classList.add("btn-menu-overlay"),this.overlay.addEventListener(r.pf,(e=>{(0,o.Z)(e),this.onClick(e)}))),this.overlay&&this.element.parentElement.insertBefore(this.overlay,this.element),n.Z||window.addEventListener("contextmenu",this.onClick,Object.assign(Object.assign({},this.listenerOptions),{once:!0})),document.addEventListener(r.pf,this.onClick,this.listenerOptions),this.dispatchEvent("toggle",!0)}}},5180:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(7445);function n(e,t,i,n){const a=(e=+e)<0,o=s.Z[t];if(!o)throw new Error("CURRENCY_WRAP_INVALID");const r=e/Math.pow(10,o.exp);let d=o.exp;"IRR"==t&&Math.floor(r)==r&&(d=0);let l=function(e,t,i,s){e=(e+"").replace(/[^0-9+\-Ee.]/g,"");var n=isFinite(+e)?+e:0,a=isFinite(+t)?Math.abs(t):0,o=void 0===s?",":s,r=void 0===i?".":i,d="";return(d=(a?function(e,t){var i=Math.pow(10,t);return""+Math.round(e*i)/i}(n,a):""+Math.round(n)).split("."))[0].length>3&&(d[0]=d[0].replace(/\B(?=(?:\d{3})+(?!\d))/g,o)),(d[1]||"").length<a&&(d[1]=d[1]||"",d[1]+=new Array(a-d[1].length+1).join("0")),d.join(r)}(r,d,o.decimal_sep,o.thousands_sep);if(i)return l;let c,h=n&&o.native||o.symbol;a&&!o.space_between&&o.symbol_left&&(h="-"+h,l=l.replace("-",""));const u=o.space_between?" ":"";return c=o.symbol_left?h+u+l:l+u+h,c}window.p=n},1483:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(4755);function n(e,t,i,n){e.touches&&(e=e.touches[0]);const{pageX:a,pageY:o}=e,r=Array.from(t.children).find((e=>e.classList.contains("btn-menu-item")&&!e.classList.contains("hide")))||t;let{scrollWidth:d}=r;const{scrollHeight:l}=t,c=document.body.getBoundingClientRect(),h=c.width,u=c.height;d+=2*r.offsetLeft;let p=8,f=8,m=8,g=8;n&&(n.top&&n.top,n.right&&(f+=n.right),n.bottom&&(m+=n.bottom),n.left&&(g+=n.left)),i=s.Z.isMobile?"right":"left";let v="top";const b=u-l-m,y=h-d-f,w=g,S={x:{left:a,right:Math.min(y,a-d)},intermediateX:"right"===i?w:y,y:{top:o,bottom:o-l},intermediateY:b},C={left:S.x.left+d+f<=h,right:S.x.right>=g},L={top:S.y.top+l+m<=u,bottom:S.y.bottom-m>=m};{const e=C[i]?S.x[i]:(i="center",S.intermediateX);t.style.left=e+"px"}{const e=L[v]?S.y[v]:(v="center",S.intermediateY);t.style.top=e+"px"}return t.className=t.className.replace(/(top|center|bottom)-(left|center|right)/g,""),t.classList.add(("center"===v?v:"bottom")+"-"+("center"===i?i:"left"===i?"right":"left")),{width:d,height:l}}},6787:(e,t,i)=>{"use strict";i.d(t,{Z:()=>l});var s=i(2312),n=i(1447),a=i(3512),o=i(671),r=i(4755),d=i(3174);function l(e,t,i){return a.Z.managers.appStickersManager.preloadAnimatedEmojiSticker(e).then((({doc:a})=>{if(a)return s.Z.downloadMedia({media:a}).then((s=>{return l=this,c=void 0,u=function*(){const l=r.Z.active.emojiSticker,c=(0,o.tB)(e),h=yield n.Z.loadAnimationWorker({container:void 0,animationData:s,width:null!=t?t:l.width,height:null!=i?i:l.height,name:"doc"+a.id,autoplay:!1,loop:!1,toneIndex:c,group:"none"});h.addEventListener("firstFrame",(()=>{(0,d.O)(a,h.canvas[0],c),h.remove()}),{once:!0})},new((h=void 0)||(h=Promise))((function(e,t){function i(e){try{n(u.next(e))}catch(e){t(e)}}function s(e){try{n(u.throw(e))}catch(e){t(e)}}function n(t){var n;t.done?e(t.value):(n=t.value,n instanceof h?n:new h((function(e){e(n)}))).then(i,s)}n((u=u.apply(l,c||[])).next())}));var l,c,h,u}))}))}},677:(e,t,i)=>{"use strict";i.d(t,{RP:()=>a,X:()=>o});const s=new Set(["all","web","webk"]),n=new Set;function a(e){return e.find((e=>s.has(e.platform)&&!n.has(e.reason)))}function o(e){return!!a(e)}},3174:(e,t,i)=>{"use strict";i.d(t,{O:()=>o,k:()=>a});var s=i(3512);const n={};function a(e,t,i,s){const a=e.id+"-"+t,o=n[a];return o&&o.width>=i&&o.height>=s}function o(e,t,i){return o=this,r=void 0,l=function*(){const o=e.id+"-"+i,{width:r,height:d}=t;if(a(e,i,r,d))return;const l=n[o]={width:r,height:d},c=yield s.Z.managers.appDocsManager.getLottieCachedThumb(e.id,i);if(n[o]!==l)return;if(c&&c.w>=r&&c.h>=d)return;const h=new Promise((e=>{t.toBlob((t=>e(t)))})),u=yield h;n[o]===l&&s.Z.managers.appDocsManager.saveLottiePreview(e.id,u,r,d,i)},new((d=void 0)||(d=Promise))((function(e,t){function i(e){try{n(l.next(e))}catch(e){t(e)}}function s(e){try{n(l.throw(e))}catch(e){t(e)}}function n(t){var n;t.done?e(t.value):(n=t.value,n instanceof d?n:new d((function(e){e(n)}))).then(i,s)}n((l=l.apply(o,r||[])).next())}));var o,r,d,l}},9966:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(3035);function n(e){return function(e,t){let i,s=!1;return(...n)=>{i=n,s||(s=!0,e((()=>{s=!1,t(...i)})))}}(s.T2,e)}},286:(e,t,i)=>{"use strict";i.d(t,{Z:()=>r});var s=i(410),n=i(4762),a=i(8204),o=i(2359);class r{constructor(e,t,i){this.scrollable=e,this.query=t,this.reverse=i}get container(){return this.scrollable.container}getSaved(){return{scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,clientHeight:this.clientHeight}}findElements(){if(!this.query)return[];const{container:e}=this,t=e.getBoundingClientRect(),i=Array.from(e.querySelectorAll(this.query)),s=[];for(const n of i){const i=n.getBoundingClientRect();if((0,a.Z)(n,e,void 0,i,t))s.push({element:n,rect:i});else if(s.length)break}if(!s.length){const e=i[0];e&&s.push({element:e,rect:e.getBoundingClientRect()})}return s}replaceSaved(e,t){if(!this.elements)return;const i=this.elements.findIndex((({element:t})=>e===t));-1!==i&&(this.elements[i].element=t)}findAndSetElements(){this.elements=this.findElements()}save(){this.findAndSetElements(),this._save()}_save(){const{scrollTop:e,scrollHeight:t,clientHeight:i}=this.container;this.scrollHeight=t,this.scrollTop=e,this.clientHeight=i,this.scrollHeightMinusTop=this.reverse?t-e:e}onRestore(e){n.IS_SAFARI&&e&&(0,o.Z)(this.container)}setScrollTop(e,t){this.scrollable.setScrollTopSilently(this.scrollTop=e),this.onRestore(t)}restore(e){var t;const{scrollTop:i,scrollHeight:s}=this.scrollable;if(this.scrollHeight=s,!this.elements.length)return void this._restore(e);let n;if(n=this.elements[this.elements.length-1],!(null===(t=null==n?void 0:n.element)||void 0===t?void 0:t.parentElement)&&(this.findAndSetElements(),n=this.elements[this.elements.length-1],!n))return void this._restore(e);const{element:a,rect:o}=n,r=a.getBoundingClientRect().bottom-o.bottom;this.setScrollTop(i+r,e)}_restore(e){const{scrollHeightMinusTop:t,scrollable:i}=this,s=this.scrollHeight,n=this.reverse?s-t:t;this.setScrollTop(n,e)}}s.GO&&(s.GO.ScrollSaver=r)},8936:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(5953);class n{constructor(e){this.loading=!1,this.loaded=!1,(0,s.Z)(this,e),e.scrollable.onScrolledBottom=()=>{this.load()}}load(){return this.loaded?Promise.resolve():this.loading?this.promise:(this.loading=!0,void(this.promise=this.getPromise().then((e=>{this.loading=!1,this.promise=void 0,e?(this.loaded=!0,this.scrollable.onScrolledBottom=null):this.scrollable.checkForTriggers()}),(()=>{this.promise=void 0,this.loading=!1}))))}}},3719:(e,t,i)=>{"use strict";i.d(t,{Z:()=>c});var s=i(3781),n=i(2790),a=i(3512),o=i(7625),r=i(1708),d=i(6074),l=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class c extends d.Z{constructor(e={}){var t;super(Object.assign(Object.assign({},e),{loadMore:(e,t,i)=>{const a=t?0:i;let o=null==e?void 0:e.mid;var d;return void 0===o&&(o=this.searchContext.maxId),t||(d=o,1,o=(0,s.Z)((0,n.Z)(d)+1)),this.managers.appMessagesManager.getSearch(Object.assign(Object.assign({},this.searchContext),{peerId:this.searchContext.peerId||(null==e?void 0:e.peerId),maxId:o,limit:a?0:i,backLimit:a})).then((e=>("inputMessagesFilterChatPhotos"===this.searchContext.inputFilter._&&(0,r.Z)(e),e.next_rate&&(this.searchContext.nextRate=e.next_rate),{count:e.count,items:e.history})))},processItem:t=>l(this,void 0,void 0,(function*(){if((yield this.filterMids([t.mid])).length)return e.processItem(t)}))})),this.onHistoryDelete=({peerId:e,msgs:t})=>{const i=i=>i.peerId===e&&t.has(i.mid),s=(e,t,s)=>{i(e)&&s.splice(t,1)};(0,o.Z)(this.previous,s),(0,o.Z)(this.next,s),this.current&&i(this.current)&&(this.current=void 0,this.onEmptied&&this.onEmptied())},this.onHistoryMultiappend=e=>l(this,void 0,void 0,(function*(){if(void 0!==this.searchContext.folderId)return;if(!this.loadedAllUp||this.loadPromiseUp)return;if(e.peerId!==this.searchContext.peerId)return;const t=yield this.filterMids([e.mid]),i=(yield Promise.all(t.map((e=>this.processItem(e))))).filter(Boolean);i.length&&(this.current?this.next.push(...i):this.previous.push(...i))})),this.onMessageSent=({message:e})=>{this.onHistoryMultiappend(e)},null!==(t=this.managers)&&void 0!==t||(this.managers=a.Z.managers),a.Z.addEventListener("history_delete",this.onHistoryDelete),a.Z.addEventListener("history_multiappend",this.onHistoryMultiappend),a.Z.addEventListener("message_sent",this.onMessageSent),e.isInner||(this.otherSideLoader=new c(Object.assign(Object.assign({},e),{isInner:!0})))}filterMids(e){return l(this,void 0,void 0,(function*(){const t=`${this.searchContext.peerId}_${this.searchContext.isScheduled?"scheduled":"history"}`;return yield this.managers.appMessagesManager.filterMessagesByInputFilterFromStorage(this.searchContext.inputFilter._,e,t,e.length)}))}setSearchContext(e){this.searchContext=e,void 0!==this.searchContext.folderId&&(this.loadedAllUp=!0,void 0===this.searchContext.nextRate&&(this.loadedAllDown=!0)),"inputMessagesFilterChatPhotos"===this.searchContext.inputFilter._&&(this.loadedAllUp=!0),!1===this.searchContext.useSearch&&(this.loadedAllDown=this.loadedAllUp=!0),this.otherSideLoader&&this.otherSideLoader.setSearchContext(e)}reset(){super.reset(),this.searchContext=void 0,this.otherSideLoader&&this.otherSideLoader.reset()}getPrevious(e){let t=this.previous;return this.otherSideLoader&&e&&(t=t.concat(this.otherSideLoader.previous)),t}getNext(e){let t=this.next;return this.otherSideLoader&&e&&(t=t.concat(this.otherSideLoader.next)),t}getCurrent(){var e;return this.current||(null===(e=this.otherSideLoader)||void 0===e?void 0:e.current)}goToOtherEnd(e){return e>0?this.go(-this.previous.length):this.go(this.next.length)}goRound(e,t){var i;let s;if(null===(i=this.otherSideLoader)||void 0===i?void 0:i.current){if(s=this.otherSideLoader.goUnsafe(e,t),s.item)return s.item;if(!((e=s.leftLength)>0?this.otherSideLoader.next:this.otherSideLoader.previous).length){if(!(e>0?this.otherSideLoader.loadedAllUp:this.otherSideLoader.loadedAllDown))return;if(e>0&&(1===this.otherSideLoader.searchContext.maxId||this.otherSideLoader.loadedAllDown)||e<0&&(0===this.otherSideLoader.searchContext.maxId||this.otherSideLoader.loadedAllUp))return this.otherSideLoader.goToOtherEnd(e);this.otherSideLoader.unsetCurrent(e>0)}}if(s=this.goUnsafe(e,t),!s.item){if(this.loadedAllUp&&this.loadedAllDown)return this.goToOtherEnd(e);this.otherSideLoader&&(e=s.leftLength,s=this.otherSideLoader.goUnsafe(e,t),s.item&&this.unsetCurrent(e>0))}return null==s?void 0:s.item}setLoaded(e,t){var i;const s=super.setLoaded(e,t);if(s&&this.otherSideLoader&&t&&!1!==(null===(i=this.searchContext)||void 0===i?void 0:i.useSearch)){const e=this.loadedAllUp;this.otherSideLoader.setSearchContext(Object.assign(Object.assign({},this.searchContext),{maxId:e?1:0})),this.otherSideLoader.reverse=this.reverse,this.otherSideLoader.setLoaded(e,!0),this.otherSideLoader.load(!e)}return s}cleanup(){this.reset(),a.Z.removeEventListener("history_delete",this.onHistoryDelete),a.Z.removeEventListener("history_multiappend",this.onHistoryMultiappend),a.Z.removeEventListener("message_sent",this.onMessageSent),this.onEmptied=void 0,this.otherSideLoader&&(this.otherSideLoader.cleanup(),this.otherSideLoader=void 0)}}},9674:(e,t,i)=>{"use strict";i.d(t,{Z:()=>d});var s=i(3035),n=i(3725),a=i(410),o=i(8487);const r=new class{constructor(){this.promises={},this.raf=s.T2.bind(null),this.scheduled=!1}do(e,t){let i=this.promises[e];return i||(this.scheduleFlush(),i=this.promises[e]=(0,n.Z)()),void 0!==t&&i.then((()=>t())),i}measure(e){return this.do("read",e)}mutate(e){return this.do("write",e)}mutateElement(e,t){const i=(0,o.Z)(e),s=i?this.mutate():Promise.resolve();return void 0!==t&&(i?s.then((()=>t())):t()),s}scheduleFlush(){this.scheduled||(this.scheduled=!0,this.raf((()=>{this.promises.read&&this.promises.read.resolve(),this.promises.write&&this.promises.write.resolve(),this.scheduled=!1,this.promises={}})))}};a.GO&&(a.GO.sequentialDom=r);const d=r},1713:(e,t,i)=>{"use strict";i.d(t,{Z:()=>r});var s=i(1507),n=i(9687),a=i(9405),o=i(3114);function r(e,t,i,r,d=!0,l,c,h){const u=(0,o.Z)(e);let p;h||(h=(0,n.Z)(e,i,r,void 0,c));const f="document"===e._;p=f||u?(0,a.C)(e.w||h.w||512,e.h||h.h||512):(0,a.C)(h.w||100,h.h||100);let m=(0,a.C)(i,r);m=p=p.aspect(m,d);let g=!0;return(!f||["video","gif"].includes(e.type)||u)&&(m.width<200&&m.height<200&&(m=p=p.aspectCovered((0,a.C)(200,200))),l&&(l.message||l.reply_to_mid||l.media.webpage||l.replies&&l.replies.pFlags.comments&&l.replies.channel_id.toChatId()!==s.IA)&&m.width<320&&(m=(0,a.C)(320,m.height),g=!1),g&&m.width<120&&l&&(m=(0,a.C)(120,m.height),g=!1)),t.style.width=m.width+"px",t.style.height=m.height+"px",{photoSize:h,size:p,isFit:g}}},5345:(e,t,i)=>{"use strict";i.d(t,{Z:()=>u,s:()=>h});var s=i(5003),n=i(6519),a=i(3624),o=i(8631),r=i(5953),d=i(5418),l=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};let c=0;class h{constructor(e){var t;(0,r.Z)(this,e),this.queue=[],null!==(t=this.middlewareHelper)&&void 0!==t||(this.middlewareHelper=(0,a.k)());const i="BATCH-PROCESSOR-"+ ++c;this.log?this.log=this.log.bindPrefix(i):this.log=(0,s.kg)(i)}get queuePromise(){return this.promise}clear(){this.log("clear"),this.queue.length=0,this.promise=void 0,this.middlewareHelper.clean()}addToQueue(e){return this.queue.push(e),this.setQueue()}setQueue(){if(!this.queue.length)return Promise.resolve();if(this.promise)return this.promise;const e=this.middlewareHelper.get(),t=this.log.bindPrefix("queue"),i=(0,o.Z)(e,this.possibleError),s=()=>l(this,void 0,void 0,(function*(){t("start",this.queue.length);const e=this.queue.splice(0,this.queue.length),n=performance.now(),a=e.map((e=>(e.then((e=>{t("render item time",performance.now()-n,e)})),e))),o=yield i(Promise.all(a));if(yield i(this.process(o,i,t)),t("queue rendered"),this.queue.length)return t("have new items to render"),s();t("end")}));t("setting pause");const n=this.promise=i((0,d.Z)(0)).then((()=>s().catch((e=>{throw e!==this.possibleError&&t.error("process queue error",e),e}))),(e=>{throw t("pause has been cleared"),e})).finally((()=>{this.promise===n&&(this.promise=void 0)}));return n}}class u{constructor(e){this.updateElementWith=e=>e(),this.updateListWith=e=>e(!0),(0,r.Z)(this,e),this.elements=new Map,this.sorted=[],this.middleware=(0,a.k)(),this.batchProcessor=new h({log:this.log,process:(e,t,i)=>l(this,void 0,void 0,(function*(){const i=e.map((e=>this.update(e.id,e)));yield t(Promise.all(i))}))})}clear(){this.batchProcessor.clear(),this.middleware.clean(),this.elements.clear(),this.sorted.length=0}_updateList(){this.elements.forEach((e=>{this.update(e.id)})),this.onSort&&this.sorted.forEach(((e,t)=>{this.onSort(e,t)}))}updateList(e){const t=this.middleware.get();this.updateListWith((i=>{t()&&(void 0===i||i)?(this._updateList(),null==e||e(!0)):null==e||e(!1)}))}has(e){return this.elements.has(e)}get(e){return this.elements.get(e)}getAll(){return this.elements}add(e){return l(this,void 0,void 0,(function*(){if(this.get(e))return;const t={id:e,index:0};this.elements.set(e,t);const i=Promise.resolve(this.onElementCreate(t));return this.batchProcessor.addToQueue(i)}))}delete(e,t){const i=this.elements.get(e);if(!i)return!1;this.elements.delete(e);const s=this.sorted.indexOf(i);if(-1!==s&&this.sorted.splice(s,1),this.onDelete)if(t)this.onDelete(i);else{const e=this.middleware.get();this.updateElementWith((()=>{e()&&this.onDelete(i)}))}return!0}update(e,t=this.get(e)){var i;return l(this,void 0,void 0,(function*(){if(!t)return;if(t.index=yield this.getIndex(t),this.get(e)!==t)return;null===(i=this.onUpdate)||void 0===i||i.call(this,t);const s=(0,n.Z)(this.sorted,t,"index");this.onSort(t,s)}))}}},6854:(e,t,i)=>{"use strict";i.d(t,{Z:()=>s});const s="\ufeff"},4056:(e,t,i)=>{"use strict";function s(e){return e.replace(/&/g,"&amp;").replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,(e=>"&#"+(1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320)+65536)+";")).replace(/([^\#-~| |!])/g,(e=>"&#"+e.charCodeAt(0)+";")).replace(/</g,"&lt;").replace(/>/g,"&gt;")}i.d(t,{Z:()=>s})},3738:(e,t,i)=>{"use strict";function s(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}i.d(t,{Z:()=>s})},8456:(e,t,i)=>{"use strict";function s(e,t,i=t+10){return(e=e.trim()).length>i&&(e=e.slice(0,t)+"..."),e}i.d(t,{Z:()=>s})},1564:(e,t,i)=>{"use strict";i.d(t,{Z:()=>s});const s=""},5157:(e,t,i)=>{"use strict";function s(e,t=!1){const i=parseInt(e+"",10),s=Math.floor(i/3600);let n=Math.floor((i-3600*s)/60),a=i-3600*s-60*n;return s&&(t=!0),n<10&&(n=t?"0"+n:n),a<10&&(a="0"+a),(s?s+":":"")+n+":"+a}i.d(t,{Z:()=>s})},8812:(e,t,i)=>{"use strict";function s(e){const t=new Blob([e],{type:"image/svg+xml;charset=utf-8"});return new Promise((e=>{const i=new FileReader;i.onload=t=>{e(t.target.result)},i.readAsDataURL(t)}))}i.d(t,{Z:()=>s})},241:(e,t,i)=>{"use strict";i.d(t,{Z:()=>o});var s=i(410),n=i(1352);const a=new class{constructor(){if(n.kC)return;const e="visualViewport"in window?window.visualViewport:window,t=()=>{this.width=e.width||e.innerWidth,this.height=e.height||e.innerHeight};e.addEventListener("resize",t),t()}};s.GO&&(s.GO.windowSize=a);const o=a},8594:(e,t,i)=>{"use strict";i.d(t,{YW:()=>p,ZP:()=>v,e9:()=>g,gp:()=>m});var s=i(3725),n=i(410),a=i(5418);const o=new(i(3241).Z),r="start",d="end";let l=!1,c=(0,s.Z)(),h=0;c.resolve();const u=console.log.bind(console.log,"[HEAVY-ANIMATION]:");function p(e,t){l||(c=(0,s.Z)(),o.dispatchEvent(r),l=!0,n.ZP&&u("start")),++h,n.ZP&&u("attach promise, length:",h,t);const i=[void 0!==t?(0,a.Z)(t):void 0,e.finally((()=>{}))].filter(Boolean),d=performance.now(),p=c;return Promise.race(i).then((()=>{c!==p||c.isFulfilled||(--h,n.ZP&&u("promise end, length:",h,performance.now()-d),h<=0&&f())})),c}function f(){c.isFulfilled||(l=!1,h=0,o.dispatchEvent(d),c.resolve(),n.ZP&&u("end"))}function m(){f()}function g(){return c}function v(e,t,i){l&&e();const s=i?i.add(o):o.addEventListener.bind(o),n=i?i.removeManual.bind(i,o):o.removeEventListener.bind(o);return s(r,e),s(d,t),()=>{n(d,t),n(r,e)}}window.dispatchHeavyAnimationEvent=p},5005:(e,t,i)=>{"use strict";i.r(t),i.d(t,{AppDialogsManager:()=>ct,DIALOG_LIST_ELEMENT_TAG:()=>tt,DialogElement:()=>nt,default:()=>ut});var s=i(9331),n=i(3512),a=i(6194),o=i(2325),r=i(4668),d=i(2796),l=i(3897),c=i(1507),h=i(3186),u=i(4531),p=i(1168),f=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class m{constructor(e){this.managers=e,this.onArchiveClick=()=>f(this,void 0,void 0,(function*(){const e=yield this.managers.appMessagesManager.getDialogOnly(this.peerId);e&&this.managers.appMessagesManager.editPeerFolders([e.peerId],+!e.folder_id)})),this.onHideTopicClick=()=>{this.managers.appChatsManager.editForumTopic({chatId:this.peerId.toChatId(),topicId:this.threadId,hidden:!0})},this.onToggleTopicClick=()=>{this.managers.appChatsManager.editForumTopic({chatId:this.peerId.toChatId(),topicId:this.threadId,closed:!this.dialog.pFlags.closed})},this.onPinClick=()=>{const{peerId:e,filterId:t,threadId:i}=this;this.managers.appMessagesManager.toggleDialogPin({peerId:e,filterId:t,topicId:i}).catch((e=>f(this,void 0,void 0,(function*(){"PINNED_DIALOGS_TOO_MUCH"!==e.type&&"PINNED_TOO_MUCH"!==e.type||(i?this.managers.apiManager.getLimit("topicPin").then((e=>{(0,d.bC)({langPackKey:"LimitReachedPinnedTopics",langPackArguments:[e]})})):t>=1?(0,d.bC)({langPackKey:"PinFolderLimitReached"}):(0,h.Z)("pin"))}))))},this.onUnmuteClick=()=>{this.managers.appMessagesManager.togglePeerMute({peerId:this.peerId,mute:!1,threadId:this.threadId})},this.onMuteClick=()=>{p.Z.createPopup(l.Z,this.peerId,this.threadId)},this.onUnreadClick=()=>f(this,void 0,void 0,(function*(){const{peerId:e,dialog:t}=this;t.unread_count?(this.managers.appMessagesManager.readHistory(e,t.top_message,this.threadId),this.threadId||this.managers.appMessagesManager.markDialogUnread(e,!0)):this.threadId||this.managers.appMessagesManager.markDialogUnread(e)})),this.onDeleteClick=()=>{p.Z.createPopup(a.Z,this.peerId,void 0,void 0,this.threadId)}}attach(e){(0,u.Z)({listenTo:e,buttons:this.getButtons(),appendTo:document.getElementById("page-chats"),onOpen:e=>f(this,void 0,void 0,(function*(){this.li=e,e.classList.add("menu-open"),this.peerId=e.dataset.peerId.toPeerId(),this.threadId=+e.dataset.threadId||void 0,this.dialog=yield this.managers.dialogsStorage.getDialogOrTopic(this.peerId,this.threadId),this.filterId=this.threadId?void 0:ut.filterId,this.canManageTopics=this.threadId?yield this.managers.appChatsManager.hasRights(this.peerId.toChatId(),"manage_topics"):void 0})),onBeforeOpen:()=>f(this,void 0,void 0,(function*(){const e=this.threadId?"Delete":yield this.managers.appPeersManager.getDeleteButtonText(this.peerId),t=this.buttons[this.buttons.length-1];(null==t?void 0:t.element)&&t.element.lastChild.replaceWith((0,o.ag)(e))})),onClose:()=>{this.li.classList.remove("menu-open"),this.li=this.peerId=this.dialog=this.filterId=this.threadId=this.canManageTopics=void 0},findElement:e=>(0,r.Z)(e.target,tt)})}getButtons(){var e;return null!==(e=this.buttons)&&void 0!==e?e:this.buttons=[{icon:"unread",text:"MarkAsUnread",onClick:this.onUnreadClick,verify:()=>f(this,void 0,void 0,(function*(){return!this.threadId&&!(yield this.managers.appMessagesManager.isDialogUnread(this.dialog))}))},{icon:"readchats",text:"MarkAsRead",onClick:this.onUnreadClick,verify:()=>this.managers.appMessagesManager.isDialogUnread(this.dialog)},{icon:"pin",text:"ChatList.Context.Pin",onClick:this.onPinClick,verify:()=>f(this,void 0,void 0,(function*(){var e;return!(this.threadId&&!this.canManageTopics)&&!(void 0!==this.filterId&&this.filterId>1?(yield this.managers.appMessagesManager.getFilter(this.filterId)).pinnedPeerIds.includes(this.dialog.peerId):null===(e=this.dialog.pFlags)||void 0===e?void 0:e.pinned)}))},{icon:"unpin",text:"ChatList.Context.Unpin",onClick:this.onPinClick,verify:()=>f(this,void 0,void 0,(function*(){var e;return!(this.threadId&&!this.canManageTopics)&&(void 0!==this.filterId&&this.filterId>1?(yield this.managers.appMessagesManager.getFilter(this.filterId)).pinnedPeerIds.includes(this.dialog.peerId):!!(null===(e=this.dialog.pFlags)||void 0===e?void 0:e.pinned))}))},{icon:"mute",text:"ChatList.Context.Mute",onClick:this.onMuteClick,verify:()=>f(this,void 0,void 0,(function*(){return this.peerId!==n.Z.myId&&!(yield this.managers.appNotificationsManager.isPeerLocalMuted({peerId:this.dialog.peerId,threadId:this.threadId}))}))},{icon:"unmute",text:"ChatList.Context.Unmute",onClick:this.onUnmuteClick,verify:()=>f(this,void 0,void 0,(function*(){return this.peerId!==n.Z.myId&&(yield this.managers.appNotificationsManager.isPeerLocalMuted({peerId:this.dialog.peerId,threadId:this.threadId}))}))},{icon:"archive",text:"Archive",onClick:this.onArchiveClick,verify:()=>0===this.filterId&&this.peerId!==n.Z.myId},{icon:"unarchive",text:"Unarchive",onClick:this.onArchiveClick,verify:()=>1===this.filterId&&this.peerId!==n.Z.myId},{icon:"hide",text:"Hide",onClick:this.onHideTopicClick,verify:()=>this.canManageTopics&&this.dialog.id===c.Ox},{icon:"lock",text:"CloseTopic",onClick:this.onToggleTopicClick,verify:()=>this.canManageTopics&&!this.dialog.pFlags.closed},{icon:"lockoff",text:"RestartTopic",onClick:this.onToggleTopicClick,verify:()=>this.canManageTopics&&!!this.dialog.pFlags.closed},{icon:"delete danger",text:"Delete",onClick:this.onDeleteClick,verify:()=>!this.threadId||!!this.canManageTopics&&this.dialog.id!==c.Ox}]}}var g=i(6008),v=i(1405),b=i(8805),y=i(632),w=i(4762),S=i(5003),C=i(7030),L=i(4494),E=i(9099),I=i(410),P=i(8842),Z=i(1447),M=i(9492),k=i(534),T=i(7856),x=i(2738),A=i(4484),_=i(5565),F=i(4159),D=i(3442),R=i(7487),B=i(9174),N=i(3910),O=i(490);class U{constructor(e,t){this.managers=e,this.hadConnect=!1,this.connecting=!1,this.timedOut=!1,this.updating=!1,this.setConnectionStatus=e=>{Promise.all([R.Z.get("dc"),n.Z.managers.rootScope.getConnectionStatus()]).then((([t,i])=>{t||(t=F.Z.baseDcId),this.setFirstConnectionTimeout&&(clearTimeout(this.setFirstConnectionTimeout),this.setFirstConnectionTimeout=0);const s=i["NET-"+t],n=s&&(e||s.status)===B.Q.Connected;this.connecting&&n&&this.managers.apiUpdatesManager.forceGetDifference(),n&&!this.hadConnect&&(this.hadConnect=!0),this.timedOut=s&&(e||s.status)===B.Q.TimedOut,this.connecting=!n,this.retryAt=s&&s.retryAt,I.ZP&&this.log("connecting",this.connecting),this.setState()}))},this.setStatusText=(e,t)=>{this.currentLangPackKey!==e&&(this.currentLangPackKey=e,(0,_.Z)(this.statusEl,(0,o.ag)(e,t)),this.statusPreloader.attach(this.statusEl))},this.setState=()=>{if(O.Z.deactivatedReason)return;const e=U.CHANGE_STATE_DELAY;if(this.connecting)if(this.timedOut){const e=this.getA("ConnectionStatus.ForceReconnect",(()=>this.managers.networkerFactory.forceReconnect()));this.setStatusText("ConnectionStatus.TimedOut",[e])}else if(this.hadConnect)if(void 0!==this.retryAt){const e=document.createElement("span"),t=this.retryAt,i=()=>{const i=Date.now();e.innerText=""+Math.max(0,Math.round((t-i)/1e3)),i>t&&clearInterval(s)},s=setInterval(i,1e3);i();const n=this.getA("ConnectionStatus.Reconnect",(()=>this.managers.networkerFactory.forceReconnectTimeout()));this.setStatusText("ConnectionStatus.ReconnectIn",[e,n])}else this.setStatusText("ConnectionStatus.Reconnecting");else this.setStatusText("ConnectionStatus.Waiting");else this.updating&&this.setStatusText("Updating");I.ZP&&this.log("setState",this.connecting||this.updating),window.requestAnimationFrame((()=>{this.setStateTimeout&&clearTimeout(this.setStateTimeout),this.setStateTimeout=window.setTimeout((()=>{(0,E.Z)({element:this.statusContainer,className:"is-shown",forwards:this.connecting||this.updating,duration:200}),this.setStateTimeout=0,I.ZP&&this.log("setState: isShown:",this.connecting||this.updating)}),e)}))},this.log=(0,S.kg)("CS",void 0,void 0),this.statusContainer=document.createElement("div"),this.statusContainer.classList.add("connection-status"),this.statusEl=(0,L.Z)("btn-primary bg-warning connection-status-button",{noRipple:!0}),this.statusPreloader=new D.Z({cancelable:!1}),this.statusPreloader.constructContainer({color:"transparent",bold:!0}),this.statusContainer.append(this.statusEl),t.prepend(this.statusContainer),n.Z.addEventListener("connection_status_change",(e=>{this.setConnectionStatus()})),n.Z.addEventListener("state_synchronizing",(e=>{e||(this.updating=!0,I.ZP&&this.log("updating",this.updating),this.setState())})),n.Z.addEventListener("state_synchronized",(e=>{I.ZP&&this.log("state_synchronized",e),e||(this.updating=!1,I.ZP&&this.log("updating",this.updating),this.setState())})),this.setFirstConnectionTimeout=window.setTimeout(this.setConnectionStatus,U.CHANGE_STATE_DELAY+1e3)}getA(e,t){const i=document.createElement("a");return i.classList.add("force-reconnect"),i.append((0,o.ag)(e)),(0,x.fc)(i,(e=>{(0,N.Z)(e),t()})),i}}U.CHANGE_STATE_DELAY=1e3;var H,z=i(6740),j=i(3035),G=i(2894),V=i(5432),K=i(1154),W=i(241),$=i(8487);!function(e){e[e.Error=-1]="Error",e[e.Pending=0]="Pending",e[e.Sent=1]="Sent",e[e.Read=2]="Read"}(H||(H={}));var q=i(5345),Y=i(5701),Q=i(5296),X=i(8222);function J(e,t,i,s){return e>=s?t+i:function(e,t){return-t/2*(Math.cos(Math.PI*e)-1)}(e/s,i)+t}var ee=i(4755);function te(e,t,i,s,n,a,o,r){const d=e.canvas.dpr;if(d&&(t*=d,i*=d,s*=d,n*=d),"number"==typeof a)d&&(a*=d),a={tl:a,tr:a,br:a,bl:a};else{const e={tl:0,tr:0,br:0,bl:0};for(const t in e)a[t]=a[t]?d?a[t]*d:a[t]:e[t]}e.beginPath(),e.moveTo(t+a.tl,i),e.lineTo(t+s-a.tr,i),e.quadraticCurveTo(t+s,i,t+s,i+a.tr),e.lineTo(t+s,i+n-a.br),e.quadraticCurveTo(t+s,i+n,t+s-a.br,i+n),e.lineTo(t+a.bl,i+n),e.quadraticCurveTo(t,i+n,t,i+n-a.bl),e.lineTo(t,i+a.tl),e.quadraticCurveTo(t,i,t+a.tl,i),e.closePath(),o&&e.fill(),r&&e.stroke()}const ie=window.devicePixelRatio,se=20*ie,ne=2.5*ie,ae=2*ie,oe=1*ie;var re=i(6818),de=i(5824),le=i(3013),ce=i(130),he=i(4332),ue=i(9687),pe=i(8115),fe=i(496),me=i(5381),ge=i(7530),ve=i(2291),be=i(5772),ye=i(3385),we=i(2554),Se=i(8050),Ce=i(3725),Le=i(7362),Ee=i(8631),Ie=i(2312),Pe=i(2059),Ze=i(2493),Me=i(319),ke=i(2890),Te=i(3228);class xe{constructor(){this.font="30pt Helvetica",this.currTime=Date.now(),this.diffTime=0,this.spread=0,this.paused=!1,this.pausedTime=0,this.pauseInterval=850,this.lightSource=0,this.inc=.032,this.lightSpread=.55,this.animations=["slide","slide","slide","slide"],this.currentAnimationIndex=0}keepTime(){this.diffTime=Date.now()-this.currTime,this.currTime=Date.now()}cycleAnimation(){++this.currentAnimationIndex,this.currentAnimationIndex>=this.animations.length&&(this.currentAnimationIndex=0)}animate(){const e=this.animations[this.currentAnimationIndex];return"glow"===e?this.animateGlow():"slide"===e?this.animateSlide():void console.log("unknown animation type: "+String(e))}animateGlow(){var e=68;return()=>{var t=this.diffTime/(1e3/60)*10;return this.paused?Date.now()-this.pausedTime>800&&(e=68,this.cycleAnimation(),this.paused=!1):(e=parseInt(""+(e+t)))>=255&&(this.paused=!0,this.pausedTime=Date.now()),"rgb("+e+","+e+","+e+")"}}animateSlide(){var e,t,i,s=this.ctx.createLinearGradient(0,0,this.canvas.width,0),n=this.inc*(this.diffTime/(1e3/60));if(this.paused){if(Date.now()-this.pausedTime>this.pauseInterval)return this.lightSource=-.6,this.cycleAnimation(),this.paused=!1,this.animateSlide()}else this.lightSource+=n,this.lightSource>1+this.lightSpread&&(this.paused=!0,this.pausedTime=Date.now());i=(0,Te.Z)(this.lightSource,0,1),e=(0,Te.Z)(this.lightSource-this.lightSpread,0,1),t=(0,Te.Z)(this.lightSource+this.lightSpread,0,1);const a=X.Z.getProperty("background-color-true"),o=X.Z.getProperty("surface-color");return s.addColorStop(e,a),s.addColorStop(i,o),s.addColorStop(t,a),s}settings(e={}){var t,i,s,n,a,o;this.canvas=null!==(t=e.canvas)&&void 0!==t?t:document.createElement("canvas"),this.ctx=this.canvas.getContext("2d"),this.font=null!==(i=e.font)&&void 0!==i?i:this.font,this.lightSpread=null!==(s=e.lightSpread)&&void 0!==s?s:this.lightSpread,this.inc=null!==(n=e.inc)&&void 0!==n?n:this.inc,this.animations=null!==(a=e.animations)&&void 0!==a?a:this.animations,this.text=null!==(o=e.text)&&void 0!==o?o:this.text,this.fillStyle=e.fillStyle,this.canvas.classList.add("shimmer-canvas")}on(){const{width:e,height:t}=this.canvas;this.keepTime(),this.ctx.clearRect(0,0,e,t),this.font&&(this.ctx.font=this.font),this.ctx.fillStyle=this.animate(),this.ctx.fillRect(0,0,e,t),this.fillStyle&&(this.ctx.fillStyle=this.fillStyle,this.ctx.fillRect(0,0,e,t)),this.text&&this.ctx.fillText(this.text,50,50)}}var Ae=i(5994);class _e{constructor(e={}){var t,i,s;this.onThemeChange=()=>{this.stopAnimation(),this.startAnimation()},this.onResize=()=>{const{canvas:e}=this,{width:t,height:i,dpr:s}=e;this.updateCanvasSize(),e.width===t&&e.height===i&&e.dpr===s||(this.stopAnimation(),this.startAnimation())},this.shimmer=new xe,this.tempId=0,this.canvas=document.createElement("canvas"),this.canvas.classList.add("dialogs-placeholder-canvas"),this.ctx=this.canvas.getContext("2d"),this.generatedValues=[],this.avatarSize=null!==(t=e.avatarSize)&&void 0!==t?t:54,this.marginVertical=null!==(i=e.marginVertical)&&void 0!==i?i:9,this.totalHeight=null!==(s=e.totalHeight)&&void 0!==s?s:this.avatarSize+2*this.marginVertical,this.lineHeight=10,this.lineBorderRadius=6,this.lineMarginVertical=8,this.statusWidth=24}attach({container:e,rect:t,getRectFrom:i,onRemove:s,blockScrollable:n}){const{canvas:a}=this;this.onRemove=s,this.getRectFrom="function"==typeof i?i:(i||e).getBoundingClientRect.bind(i||e),(this.blockScrollable=n)&&(n.container.style.overflowY="hidden"),this.updateCanvasSize(t),this.startAnimation(),e.append(a)}detach(e){this.detachTime||(this.availableLength=e,this.detachTime=Date.now(),Ae.Z.isAvailable("animations")||this.remove())}remove(){var e;this.stopAnimation(),this.canvas.parentElement&&(this.canvas.remove(),this.blockScrollable&&(this.blockScrollable.container.style.overflowY="",this.blockScrollable=void 0)),null===(e=this.onRemove)||void 0===e||e.call(this),this.onRemove=void 0}updateCanvasSize(e=this.getRectFrom()){const{canvas:t}=this,i=t.dpr=window.devicePixelRatio;t.width=e.width*i,t.height=e.height*i,t.style.width=e.width+"px",t.style.height=e.height+"px"}renderDetachAnimationFrame(){const{canvas:e,ctx:t,detachTime:i,length:s,availableLength:n}=this;if(!i)return;if(!Ae.Z.isAvailable("animations"))return void this.remove();const{width:a}=e;t.globalCompositeOperation="destination-out";const o=Date.now()-i;let r=!0;for(let e=0;e<s;++e){const i=o-(n<s&&e>=n?15*(n-1):15*e);if(i<=0){r=!1;continue}const d=J(i,0,1,150);t.beginPath(),t.rect(0,this.dialogHeight*e,a,this.dialogHeight),t.fillStyle=`rgba(0, 0, 0, ${d})`,t.fill(),d<1&&(r=!1)}t.globalCompositeOperation="source-over",r&&this.remove()}renderFrame(){this.shimmer.on(),this.renderDetachAnimationFrame()}startAnimation(){const{canvas:e,shimmer:t}=this,i=++this.tempId,s=this.createPattern();t.settings({canvas:e,fillStyle:s});const a=()=>this.tempId===i;this.renderFrame(),(0,Q.jt)((()=>!!a()&&(Ae.Z.isAvailable("animations")&&this.renderFrame(),a()))),n.Z.addEventListener("theme_change",this.onThemeChange),ee.Z.addEventListener("resize",this.onResize)}stopAnimation(){++this.tempId,n.Z.removeEventListener("theme_change",this.onThemeChange),ee.Z.removeEventListener("resize",this.onResize)}createPattern(){const{canvas:e,ctx:t}=this,i=document.createElement("canvas"),s=i.getContext("2d"),n=e.dpr;i.dpr=n,i.width=e.width,i.height=e.height,s.fillStyle=X.Z.getProperty("surface-color"),s.fillRect(0,0,i.width,i.height),s.fillStyle="#000",s.globalCompositeOperation="destination-out";const a=this.dialogHeight=this.totalHeight*n,o=this.length=Math.ceil(e.height/a);for(let e=0;e<o;++e)this.drawChat(s,e,e*a);return t.createPattern(i,"no-repeat")}drawChat(e,t,i){let s=this.generatedValues[t];s||(s=this.generatedValues[t]={firstLineWidth:40+100*Math.random(),secondLineWidth:120+130*Math.random(),statusWidth:24+16*Math.random()});const{firstLineWidth:n,secondLineWidth:a,statusWidth:o}=s,{canvas:r}=e,{dpr:d}=r;i/=d;const{avatarSize:l,marginVertical:c,lineHeight:h,lineBorderRadius:u,lineMarginVertical:p}=this;let f=17;l&&((0,ke.o)(e,f,i+c,l/2,!0),f+=l+10),te(e,f,i+c+p,n,h,u,!0),te(e,f,i+this.totalHeight-c-h-p,a,h,u,!0),te(e,r.width/d-24-o,i+c+p,o,h,u,!0)}}var Fe=i(5418),De=i(3855),Re=i(2353),Be=i(1655),Ne=i(2648),Oe=i(3624),Ue=i(5471),He=i(7479),ze=i(5029),je=i(6024),Ge=i(5953),Ve=i(3699),Ke=i(5322),We=i(4993),$e=i(2559),qe=i(1669),Ye=i(8594),Qe=i(8928),Xe=i(730),Je=i(2790),et=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};const tt="A";function it(e,t){const i=e[t];null==i||i.reject();const s=e[t]=(0,Ce.Z)();s.catch((()=>{})).finally((()=>{e[t]===s&&delete e[t]}));const n=(0,Ee.Z)((()=>e[t]===s));return{deferred:s,middleware:n}}class st extends q.Z{constructor(e){super({getIndex:e=>{var t;return this.managers.dialogsStorage.getDialogIndex(null!==(t=this.forumPeerId)&&void 0!==t?t:e.id,this.indexKey,this.forumPeerId?e.id:void 0)},onDelete:e=>{var t;e.dom.listEl.remove(),null===(t=this.onListLengthChange)||void 0===t||t.call(this)},onSort:(e,t)=>{var i;const s=e.dom.listEl.parentElement!==this.list;(0,A.Z)(e.dom.listEl,this.list,t),s&&(null===(i=this.onListLengthChange)||void 0===i||i.call(this))},onElementCreate:e=>et(this,void 0,void 0,(function*(){var t;const i=[],s=ht.addListDialog({peerId:null!==(t=this.forumPeerId)&&void 0!==t?t:e.id,loadPromises:i,isBatch:!0,threadId:this.forumPeerId?e.id:void 0,isMainList:"index_0"===this.indexKey});return e.dom=s.dom,e.dialogElement=s,yield Promise.all(i),e})),updateElementWith:j.TR,log:e.log}),(0,Ge.Z)(this,e)}clear(){this.list.replaceChildren(),super.clear()}}class nt extends He.ZP{constructor({peerId:e,rippleEnabled:t=!0,onlyFirstName:i=!1,meAsSaved:n=!0,avatarSize:a="bigger",autonomous:o,loadPromises:r,fromName:d,noIcons:l,threadId:c,wrapOptions:h={},isMainList:u}){var p;super({clickable:!0,noRipple:!t,havePadding:!c,title:!0,titleRightSecondary:!0,subtitle:!0,subtitleRight:!0,noWrap:!0,asLink:!0}),this.subtitleRight.remove();const f=c?void 0:new s.Z;if(f){const t={bigger:54,abitbigger:42,small:32}[a];f.classList.add("dialog-avatar","avatar-"+t),f.updateWithOptions({loadPromises:r,lazyLoadQueue:h.lazyLoadQueue,isDialog:!!n,peerId:e,peerTitle:d}),this.applyMediaElement(f,a)}const m=this.container,g=this.title;g.classList.add("user-title"),this.titleRow.classList.add("dialog-title");const v=new P.Z,b=v.update({peerId:e,fromName:d,dialog:n,onlyFirstName:i,withIcons:!l,threadId:c});null==r||r.push(b),g.append(v.element),g.classList.add("tgico");const y=this.subtitle,w=this.container;w.classList.add("chatlist-chat","chatlist-chat-"+a),o||(w.href="#"+e),"bigger"===a?this.container.classList.add("row-big"):"small"===a&&this.container.classList.add("row-small"),w.dataset.peerId=""+e,c&&(w.dataset.threadId=""+c);const S=document.createElement("span");S.classList.add("message-status","sending-status");const L=document.createElement("span");L.classList.add("message-time");const E=this.titleRight;E.classList.add("dialog-title-details"),E.append(S,L),this.subtitleRow.classList.add("dialog-subtitle");const I=this.dom={avatarEl:f,captionDiv:m,titleSpan:v.element,titleSpanContainer:g,statusSpan:S,lastTimeSpan:L,lastMessageSpan:y,containerEl:w,listEl:w,subtitleEl:this.subtitleRow};if(!o){w.dialogDom=I;const t=C.ZP.chat;t&&C.ZP.isSamePeer(t,{peerId:e,threadId:c,type:"chat"})&&ht.setDialogActive(w,!0),u&&(null===(p=ht.forumTab)||void 0===p?void 0:p.peerId)===e&&!c&&w.classList.add("is-forum-open")}}createUnreadBadge(){if(this.dom.unreadBadge)return;const e=this.dom.unreadBadge=document.createElement("div");e.className="dialog-subtitle-badge badge badge-22",this.dom.subtitleEl.append(e)}createUnreadAvatarBadge(){if(this.dom.unreadAvatarBadge)return;const e=this.dom.unreadAvatarBadge=document.createElement("div");e.className="dialog-subtitle-badge badge badge-22 avatar-badge",this.dom.listEl.append(e)}createMentionsBadge(){if(this.dom.mentionsBadge)return;const e=this.dom.mentionsBadge=document.createElement("div");e.className="dialog-subtitle-badge badge badge-22 mention mention-badge",e.innerText="@",this.dom.lastMessageSpan.after(e)}toggleBadgeByKey(e,t,i,s){(0,E.Z)({element:this.dom[e],className:"is-visible",forwards:t,duration:s?0:250,onTransitionEnd:t?void 0:()=>{this.dom[e].remove(),delete this.dom[e]},useRafs:i&&(0,$.Z)(this.dom[e])?0:2})}}class at extends je.h{toggle(e){return et(this,void 0,void 0,(function*(){this.init2&&(yield this.init2()),(0,E.Z)({element:this.container,className:"is-visible",forwards:e,duration:300,onTransitionEnd:e?void 0:()=>{this.onCloseAfterTimeout()},useRafs:this.firstTime?(this.firstTime=void 0,2):void 0})}))}init(e){(0,Ge.Z)(this,e),this.log=(0,S.kg)("FORUM"),this.firstTime=!0,this.container.classList.add("topics-container");const t=!this.slider;t&&(this.closeBtn.classList.replace("tgico-left","tgico-close"),this.container.classList.add("active","is-floating"),(0,x.fc)(this.closeBtn,(()=>{ht.toggleForumTab(void 0,this)}),{listenerSetter:this.listenerSetter})),this.rows=document.createElement("div"),this.rows.classList.add("sidebar-header__rows"),this.subtitle=document.createElement("div"),this.subtitle.classList.add("sidebar-header__subtitle"),this.title.replaceWith(this.rows),this.rows.append(this.title,this.subtitle);const i=ht.createChatList();ht.setListClickListener(i,null,!0),this.scrollable.append(i),this.xd=new dt(this.peerId,t?80:0),this.xd.scrollable=this.scrollable,this.xd.sortedList=new st({managers:this.managers,log:this.log,list:i,indexKey:"index_0",forumPeerId:this.peerId}),this.xd.bindScrollable();const s=()=>({peerId:this.peerId,type:"chat"}),a=(0,Ke.Z)({listenerSetter:this.listenerSetter,direction:"bottom-left",buttons:[{icon:"info",text:"ForumTopic.Context.Info",onClick:()=>et(this,void 0,void 0,(function*(){const e=T.ZP.createTab(qe.Z,!0);e.isFirst=!0,e.setPeer(this.peerId),(yield e.fillProfileElements())(),e.loadSidebarMedia(!0),e.open()}))},{icon:"message",text:"ForumTopic.Context.ShowAsMessages",onClick:()=>{const e=C.ZP.chat;C.ZP[(null==e?void 0:e.peerId)===this.peerId?"setPeer":"setInnerPeer"](s())},verify:()=>{const e=C.ZP.chat;return!e||!C.ZP.isSamePeer(e,s())}},{icon:"adduser",text:"ForumTopic.Context.AddMember",onClick:()=>{},verify:()=>!1},{icon:"add",text:"ForumTopic.Context.New",onClick:()=>{T.ZP.createTab(Xe.Z).open(this.peerId)},separator:!0,verify:()=>this.managers.appChatsManager.hasRights(this.peerId.toChatId(),"manage_topics")}]});if(this.listenerSetter.add(n.Z)("history_reload",(e=>{this.peerId===e&&this.xd.fullReset()})),this.listenerSetter.add(n.Z)("chat_update",(e=>et(this,void 0,void 0,(function*(){this.peerId===e.toPeerId(!0)&&((yield this.managers.appChatsManager.getChat(e)).pFlags.forum||ht.toggleForumTab(void 0,this))})))),V.Z&&(0,K.Z)({element:this.container,onSwipe:()=>{ht.toggleForumTab(void 0,this)},middleware:this.middlewareHelper.get()}),this.header.append(a),!t)return this.init2()}init2(){return et(this,void 0,void 0,(function*(){this.init2=void 0;const e=this.middlewareHelper.get(),t=this.peerId;this.managers.apiUpdatesManager.subscribeToChannelUpdates(this.peerId.toChatId()),e.onDestroy((()=>{this.managers.apiUpdatesManager.unsubscribeFromChannelUpdates(this.peerId.toChatId())}));const i=(0,Le.Z)({peerId:t,dialog:!0,wrapOptions:{middleware:e}}),s=C.ZP.setPeerStatus({peerId:t,element:this.subtitle,needClear:!0,useWhitespace:!1,middleware:e,noTyping:!0});return Promise.all([i,s,this.xd.onChatsScroll().then((e=>e.cached?e.renderPromise:void 0))]).then((([t,i,s])=>{e()&&(this.title.append(t),null==i||i())}))}))}onCloseAfterTimeout(){super.onCloseAfterTimeout(),this.xd.destroy()}}const ot=new Error("not implemented");class rt{constructor(){this.onChatsRegularScroll=()=>{this.sliceTimeout&&clearTimeout(this.sliceTimeout),this.sliceTimeout=window.setTimeout((()=>{this.sliceTimeout=void 0,this.sortedList.list.childElementCount&&!ht.processContact&&(0,j.TR)((()=>{const e=performance.now(),t=this.scrollable.scrollTop,i=this.sortedList.list.firstElementChild,s=this.scrollable.container.getBoundingClientRect(),n=i.getBoundingClientRect(),a=Array.from(this.scrollable.splitUp.children);let o=this.scrollable.splitUp.offsetTop;o&&t<o&&(o-=t);const d=s.y+o,l=s.y,c=(0,r.Z)(document.elementFromPoint(Math.ceil(n.x),Math.ceil(d+1)),i.tagName),h=(0,r.Z)(document.elementFromPoint(Math.ceil(n.x),Math.floor(l+s.height-1)),i.tagName);if(!c||!h)return;const u=c.getBoundingClientRect().y-d,p=[],f=a.indexOf(c),m=a.indexOf(h),g=w.IS_SAFARI?[]:a.slice(0,Math.max(0,f-10)),v=a.slice(m+10);g.length&&(this.scrollable.loadedAll.top=!1),v.length&&(this.scrollable.loadedAll.bottom=!1),p.push(...g),p.push(...v),p.forEach((e=>{this.deleteDialogByKey(this.getDialogKeyFromElement(e))})),this.setOffsets();const b=c.offsetTop-u;this.scrollable.scrollTop=this.scrollable.lastScrollPosition=b,this.log("slice time",performance.now()-e,this.indexKey,b)}))}),200)},this.log=(0,S.kg)("CL"),this.offsets={top:0,bottom:0},this.managers=n.Z.managers,this.listenerSetter=new Ve.Z}getOffsetIndex(e){return{index:this.scrollable.loadedAll[e]?0:this.offsets[e]}}isDialogMustBeInViewport(e){const t=this.getOffsetIndex("top"),i=this.getOffsetIndex("bottom");if(!t.index&&!i.index)return!0;const s=(0,Se.Z)(e,this.indexKey);return(!t.index||s<=t.index)&&(!i.index||s>=i.index)}setIndexKey(e){this.indexKey=e,this.sortedList.indexKey=e}deleteDialogByKey(e){this.sortedList.delete(e)}deleteDialog(e){return this.deleteDialogByKey(this.getDialogKey(e))}updateDialog(e){const t=this.getDialogKey(e);if(!this.isDialogMustBeInViewport(e))return void this.deleteDialog(e);if(!this.sortedList.has(t)&&this.loadedDialogsAtLeastOnce)return void this.sortedList.add(t);const i=this.getDialogElement(t);i&&(ht.setLastMessageN({dialog:e,dialogElement:i,setUnread:!0}),this.sortedList.update(t))}onChatsScrollTop(){return this.onChatsScroll("top")}onChatsScroll(e="bottom"){return this.loadDialogs(e)}createPlaceholder(){const e=this.placeholder=new _e(this.placeholderOptions),t=this.getRectFromForPlaceholder();return e.attach({container:this.sortedList.list.parentElement,getRectFrom:t,onRemove:()=>{this.placeholder===e&&(this.placeholder=void 0)},blockScrollable:this.scrollable}),e}loadDialogs(e){const t=this.log.bindPrefix("load-"+(i=1e3,s=9999,i=Math.ceil(i),s=Math.floor(s),Math.floor(Math.random()*(s-i+1))+i));var i,s;if(t("try",e),this.loadDialogsPromise||this.loadDialogsRenderPromise)return this.loadDialogsPromise;if(this.scrollable.loadedAll[e])return Promise.resolve({cached:!0,renderPromise:Promise.resolve()});t.warn("start",e);const n=(0,Ue.Z)("MIDDLEWARE"),a=(0,Ce.Z)(),o=new Promise(((i,s)=>et(this,void 0,void 0,(function*(){const r=this.sortedList.list;let d=this.placeholder;try{const i=this.loadDialogsInner(e),s=yield i;if(!r.childElementCount&&!d&&(!this.loadedDialogsAtLeastOnce&&this.needPlaceholderAtFirstTime||!s.cached)){if(this.loadDialogsRenderPromise!==o)throw n;d=this.createPlaceholder(),a.resolve(!1)}const l=yield s.result;if(this.loadDialogsRenderPromise!==o)throw n;a.resolve(s.cached),"bottom"===e?l.isEnd&&(this.scrollable.loadedAll[e]=!0):l.isTopEnd&&(this.scrollable.loadedAll[e]=!0);const c=l.dialogs.length;if(t(`will render ${c} dialogs`),c){const t=("top"===e?l.dialogs.slice().reverse():l.dialogs).map((e=>this.sortedList.add(this.getDialogKey(e))));if(yield Promise.all(t).catch(),this.loadDialogsRenderPromise!==o)throw n}const h=l.dialogs["top"===e?0:c-1];h&&(this.offsets[e]=(0,Se.Z)(h,this.indexKey)),this.loadedDialogsAtLeastOnce=!0,ht.onListLengthChange(),t("getDialogs",l,r.childElementCount),setTimeout((()=>{this.scrollable.onScroll()}),0),d&&d.detach(r.childElementCount)}catch(e){return"MIDDLEWARE"!==(null==e?void 0:e.type)&&t.error(e),s(e),void a.reject(e)}i()})))).finally((()=>{this.loadDialogsRenderPromise===o?(t("end"),this.loadDialogsRenderPromise=void 0):t("has been cleared")}));this.loadDialogsRenderPromise=o;const r=this.loadDialogsPromise=a.then((e=>({cached:e,renderPromise:o}))).finally((()=>{this.loadDialogsPromise===r&&(this.loadDialogsPromise=void 0)}));return r}setOffsets(){return et(this,void 0,void 0,(function*(){const e=this.sortedList.list,[t,i]=yield Promise.all([this.getDialogFromElement(e.firstElementChild),this.getDialogFromElement(e.lastElementChild)]),{indexKey:s}=this;this.offsets.top=(0,Se.Z)(t,s),this.offsets.bottom=(0,Se.Z)(i,s)}))}getDialogKey(e){throw ot}getDialogKeyFromElement(e){throw ot}getRectFromForPlaceholder(){throw ot}getDialogFromElement(e){throw ot}loadDialogsInner(e){throw ot}setTyping(e){return et(this,void 0,void 0,(function*(){const t=this.getDialogKey(e),i=this.getDialogDom(t);if(!i)return;const s=i.lastMessageSpan.querySelector(".peer-typing-container"),n=yield C.ZP.getPeerTyping(e.peerId,s,"forumTopic"===e._?e.id:void 0);!s&&n&&((0,_.Z)(i.lastMessageSpan,n),i.lastMessageSpan.classList.add("user-typing"))}))}unsetTyping(e){const t=this.getDialogKey(e),i=this.getDialogElement(t);i&&(i.dom.lastMessageSpan.classList.remove("user-typing"),ht.setLastMessageN({dialog:e,lastMessage:null,dialogElement:i,setUnread:null}))}getDialogDom(e){const t=this.sortedList.get(e);return null==t?void 0:t.dom}getDialogElement(e){const t=this.sortedList.get(e);return null==t?void 0:t.dialogElement}bindScrollable(){this.scrollable.container.addEventListener("scroll",this.onChatsRegularScroll),this.scrollable.onScrolledTop=this.onChatsScrollTop.bind(this),this.scrollable.onScrolledBottom=this.onChatsScroll.bind(this),this.scrollable.setVirtualContainer(this.sortedList.list)}clear(){var e;this.sortedList.clear(),null===(e=this.placeholder)||void 0===e||e.remove()}reset(){this.scrollable.loadedAll.top=!0,this.scrollable.loadedAll.bottom=!1,this.offsets.top=this.offsets.bottom=0,this.loadDialogsRenderPromise=void 0,this.loadDialogsPromise=void 0}fullReset(){return this.reset(),this.clear(),this.onChatsScroll()}destroy(){this.clear(),this.scrollable.destroy(),this.listenerSetter.removeAll()}}class dt extends rt{constructor(e,t){super(),this.peerId=e,this.paddingX=t,this.placeholderOptions={avatarSize:0,marginVertical:5,totalHeight:64},this.listenerSetter.add(n.Z)("peer_typings",(({peerId:e,threadId:t,typings:i})=>et(this,void 0,void 0,(function*(){if(!t||this.peerId!==e)return;const s=yield this.managers.dialogsStorage.getForumTopic(e,t);s&&(i.length?this.setTyping(s):this.unsetTyping(s))})))),this.listenerSetter.add(n.Z)("dialogs_multiupdate",(e=>{for(const[t,{dialog:i,topics:s}]of e)t===this.peerId&&(null==s?void 0:s.size)&&s.forEach((e=>{this.updateDialog(e)}))})),this.listenerSetter.add(n.Z)("dialog_unread",(({dialog:e})=>{"forumTopic"===(null==e?void 0:e._)&&e.peerId===this.peerId&&ht.setUnreadMessagesN({dialog:e,dialogElement:this.getDialogElement(this.getDialogKey(e))})})),this.listenerSetter.add(n.Z)("dialog_notify_settings",(e=>et(this,void 0,void 0,(function*(){if(e.peerId===this.peerId)if("dialog"!==e._)ht.setUnreadMessagesN({dialog:e,dialogElement:this.getDialogElement(this.getDialogKey(e))});else{const e=[...this.sortedList.getAll().entries()],t=e.map((([e])=>this.managers.dialogsStorage.getForumTopic(this.peerId,e))),i=yield Promise.all(t);e.forEach((([e,t],s)=>{ht.setUnreadMessagesN({dialog:i[s],dialogElement:t.dialogElement})}))}})))),this.listenerSetter.add(n.Z)("dialog_drop",(e=>{"forumTopic"===e._&&e.peerId===this.peerId&&this.deleteDialogByKey(this.getDialogKey(e))})),this.listenerSetter.add(n.Z)("dialog_draft",(({dialog:e,drop:t,peerId:i})=>{"forumTopic"===e._&&e.peerId===this.peerId&&(t?this.deleteDialog(e):this.updateDialog(e))}))}isDialogMustBeInViewport(e){return!e.pFlags.hidden&&super.isDialogMustBeInViewport(e)}getDialogKey(e){return e.id}getDialogKeyFromElement(e){return+e.dataset.threadId}getRectFromForPlaceholder(){return()=>{const e=T.ZP.rect;return{top:56,right:e.right,bottom:0,left:this.paddingX,width:e.width-this.paddingX,height:e.height-56}}}getDialogFromElement(e){return this.managers.dialogsStorage.getForumTopic(+e.dataset.peerId,+e.dataset.threadId)}loadDialogsInner(e){return et(this,void 0,void 0,(function*(){const{indexKey:t}=this;let i=W.Z.height/64*1.25|0,s=0;const n=this.peerId,{index:a}=this.getOffsetIndex(e);if(s=a,a)if("top"===e){const e=yield this.managers.dialogsStorage.getFolderDialogs(n,!0),o=e.findIndex((e=>(0,Se.Z)(e,t)<=a)),r=Math.max(0,o-i);i=o-r,s=(0,Se.Z)(e[r],t)+1}else s=a;return this.managers.acknowledged.dialogsStorage.getDialogs({offsetIndex:s,limit:i,filterId:n,skipMigrated:!0})}))}}class lt extends rt{constructor(e){super(),this.filterId=e,this.needPlaceholderAtFirstTime=!0,this.listenerSetter.add(n.Z)("peer_typings",(({peerId:e,typings:t})=>et(this,void 0,void 0,(function*(){const[i,s]=yield Promise.all([this.managers.appMessagesManager.getDialogOnly(e),this.managers.appPeersManager.isForum(e)]);i&&!s&&(t.length?this.setTyping(i):this.unsetTyping(i))})))),this.listenerSetter.add(n.Z)("user_update",(e=>et(this,void 0,void 0,(function*(){if(!this.isActive)return;const t=e.toPeerId(),i=this.getDialogDom(t);if(!i)return;const s=yield this.managers.appUsersManager.getUserStatus(e),n="userStatusOnline"===(null==s?void 0:s._);this.setOnlineStatus(i.avatarEl,n)})))),this.listenerSetter.add(n.Z)("chat_update",(e=>et(this,void 0,void 0,(function*(){const t=e.toPeerId(!0);this.processDialogForCallStatus(t)})))),this.listenerSetter.add(n.Z)("dialog_flush",(({dialog:e})=>{this.isActive&&e&&(ht.setLastMessageN({dialog:e,setUnread:!0}),this.validateDialogForFilter(e))})),this.listenerSetter.add(n.Z)("dialogs_multiupdate",(e=>{var t;if(this.isActive)for(const[i,{dialog:s,topics:n}]of e)"dialog"===(null==s?void 0:s._)&&(this.updateDialog(s),null===(t=ht.processContact)||void 0===t||t.call(ht,i.toPeerId()),this.validateDialogForFilter(s))})),this.listenerSetter.add(n.Z)("dialog_drop",(e=>{var t;this.isActive&&"dialog"===e._&&(this.deleteDialogByKey(e.peerId),null===(t=ht.processContact)||void 0===t||t.call(ht,e.peerId))})),this.listenerSetter.add(n.Z)("dialog_unread",(({dialog:e})=>{this.isActive&&"dialog"===(null==e?void 0:e._)&&(ht.setUnreadMessagesN({dialog:e,dialogElement:this.getDialogElement(this.getDialogKey(e))}),this.validateDialogForFilter(e))})),this.listenerSetter.add(n.Z)("dialog_notify_settings",(e=>{this.isActive&&"forumTopic"!==e._&&(this.validateDialogForFilter(e),ht.setUnreadMessagesN({dialog:e,dialogElement:this.getDialogElement(this.getDialogKey(e))}))})),this.listenerSetter.add(n.Z)("dialog_draft",(({dialog:e,drop:t,peerId:i})=>{var s;this.isActive&&"forumTopic"!==e._&&(t?this.deleteDialog(e):this.updateDialog(e),null===(s=ht.processContact)||void 0===s||s.call(ht,i))})),this.listenerSetter.add(n.Z)("filter_update",(e=>et(this,void 0,void 0,(function*(){if(this.isActive&&e.id===this.filterId&&!c.DZ.has(e.id)){const e=yield this.managers.dialogsStorage.getCachedDialogs(!0);yield this.validateListForFilter();for(let t=0,i=e.length;t<i;++t){const i=e[t];this.updateDialog(i)}}}))))}get isActive(){return ht.xd===this}getRectFromForPlaceholder(){return this.filterId===c.Zi?ht.chatsContainer:ht.folders.container}loadDialogsInner(e){return et(this,void 0,void 0,(function*(){const{filterId:t,indexKey:i}=this;let s=W.Z.height/72*1.25|0,n=0;const a=ht.doNotRenderChatList,{index:o}=this.getOffsetIndex(e);if(o)if("top"===e){const e=yield this.managers.dialogsStorage.getFolderDialogs(t,!0),a=e.findIndex((e=>(0,Se.Z)(e,i)<=o)),r=Math.max(0,a-s);s=a-r,n=(0,Se.Z)(e[r],i)+1}else n=o;const r=this.managers.acknowledged.dialogsStorage.getDialogs({offsetIndex:n,limit:s,filterId:t,skipMigrated:!0}),d=yield r;return a&&(d.result=Promise.reject((0,Ue.Z)("MIDDLEWARE"))),d}))}setOnlineStatus(e,t){const i="is-online",s=e.classList.contains(i);!s&&t&&e.classList.add(i),(0,E.Z)({element:e,className:"is-visible",forwards:t,duration:250,onTransitionEnd:t?void 0:()=>{e.classList.remove(i)},useRafs:t&&!s?2:0})}generateScrollable(e,t){const i=t.id,s=new b.ZP(null,"CL",500);s.container.dataset.filterId=""+i;const a=(0,ye.Z)(t.localId),o=new st({managers:n.Z.managers,log:this.log,list:e,indexKey:a,onListLengthChange:ht.onListLengthChange});return this.scrollable=s,this.sortedList=o,this.setIndexKey(a),this.bindScrollable(),s}testDialogForFilter(e){return c.DZ.has(this.filterId)?this.filterId===e.folder_id:void 0!==(0,Se.Z)(e,this.indexKey)}isDialogMustBeInViewport(e){return!(void 0!==e.migratedTo||!this.testDialogForFilter(e))&&super.isDialogMustBeInViewport(e)}validateListForFilter(){return et(this,void 0,void 0,(function*(){this.sortedList.getAll().forEach((e=>et(this,void 0,void 0,(function*(){const t=yield n.Z.managers.appMessagesManager.getDialogOnly(e.id);this.testDialogForFilter(t)||this.deleteDialog(t)}))))}))}validateDialogForFilter(e){this.getDialogElement(e.peerId)&&(this.testDialogForFilter(e)||this.deleteDialog(e))}setCallStatus(e,t){let{callIcon:i,listEl:s}=e;if(!i&&t){const{canvas:t,startAnimation:n}=e.callIcon=i=function(e=!1){const t=document.createElement("canvas");t.width=t.height=se;const i=t.getContext("2d"),s=(se-(3*ae+2*ne))/2,n=Date.now();let a=!1;const o=()=>{if(t.isConnected)a||(a=t.isConnected);else if(a)return!1;const o=J((Date.now()-n)%1e3,0,1,1e3);i.clearRect(0,0,se,se),i.fillStyle=e&&!ee.Z.isMobile?X.Z.getProperty("primary-color"):"#fff";for(let e=0;e<3;++e){let t;t=o>=.5?e%2?2-2*o:2*(o-.5):e%2?2*o:1-2*o;let n=4+8*t;n*=ie,te(i,s+e*ae+e*ne,(se-n)/2,ae,n,oe,!0)}return!0};return{canvas:t,startAnimation:()=>{(0,Q.jt)(o),o()},setActive:t=>{e=t,o()}}}(s.classList.contains("active"));t.classList.add("dialog-group-call-icon"),s.append(t),n()}i&&(0,E.Z)({element:e.callIcon.canvas,className:"is-visible",forwards:t,duration:250,onTransitionEnd:t?void 0:()=>{e.callIcon.canvas.remove(),e.callIcon=void 0},useRafs:t?2:0})}processDialogForCallStatus(e,t){return et(this,void 0,void 0,(function*(){if(!re.Z)return;if(t||(t=this.getDialogDom(e)),!t)return;const i=yield n.Z.managers.appChatsManager.getChat(e.toChatId());this.setCallStatus(t,!(!i.pFlags.call_active||!i.pFlags.call_not_empty))}))}onChatsScroll(e="bottom"){var t;return this.scrollable.loadedAll[e]&&(null===(t=ht.loadContacts)||void 0===t||t.call(ht)),this.log("onChatsScroll",e),super.onChatsScroll(e)}toggleAvatarUnreadBadges(e,t){if(!e)return void this.sortedList.getAll().forEach((e=>{const{dom:t,dialogElement:i}=e;t.unreadAvatarBadge&&i.toggleBadgeByKey("unreadAvatarBadge",!1,!1,!1)}));const i=["unread","mention"];this.sortedList.getAll().forEach((e=>{var t;const{dom:s,dialogElement:n}=e,a=null===(t=s.unreadBadge)||void 0===t?void 0:t.textContent;if(!a||s.unreadBadge.classList.contains("backwards"))return;const o=!!s.unreadAvatarBadge;n.createUnreadAvatarBadge(),n.toggleBadgeByKey("unreadAvatarBadge",!0,o),s.unreadAvatarBadge.textContent=a;const r=s.unreadAvatarBadge.classList,d=s.unreadBadge.classList;i.forEach((e=>{r.toggle(e,d.contains(e))}))}))}getDialogKey(e){return e.peerId}getDialogKeyFromElement(e){return+e.dataset.peerId}getDialogFromElement(e){return n.Z.managers.appMessagesManager.getDialogOnly(e.dataset.peerId.toPeerId())}}class ct{constructor(){this.chatsContainer=document.getElementById("chatlist-container"),this.log=(0,S.kg)("DIALOGS",S.v9.Log|S.v9.Error|S.v9.Warn|S.v9.Debug),this.folders={menu:document.getElementById("folders-tabs"),menuScrollContainer:null,container:document.getElementById("folders-container")},this.filtersRendered={},this.lastActiveElements=new Set,this.initedListeners=!1,this.xds={},this.onTabChange=()=>(this.xd=this.xds[this.filterId],this.xd.reset(),this.xd.onChatsScroll()),this._onListLengthChange=()=>{if(!this.xd.loadedDialogsAtLeastOnce)return;if(this.checkIfPlaceholderNeeded(),this.filterId!==c.J$)return;const e=this.chatList,t=e.childElementCount,i=e.parentElement.parentElement,s=e.parentElement.nextElementSibling,n=!!s.childElementCount;if(t>=10)return void(n&&this.removeContactsPlaceholder());if(n)return;i.classList.add("with-contacts");const a=new ze.Z({name:"Contacts",noDelimiter:!0,fakeGradientDelimiter:!0});a.container.classList.add("hide"),this.managers.appUsersManager.getContactsPeerIds(void 0,void 0,"online").then((e=>{let t=!1;const i=()=>{t&&a.container.classList.toggle("hide",!s.list.childElementCount),this.updateContactsLength(!0)},s=new G.Z({avatarSize:"abitbigger",createChatListOptions:{dialogSize:48,new:!0},autonomous:!1,onListLengthChange:i,managers:this.managers});this.loadContacts=()=>{const t=W.Z.height/60|0;(0,Re.Z)(e.splice(0,t),this.verifyPeerIdForContacts).then((e=>{e.forEach((e=>{s.add(e)}))})),e.length||(this.loadContacts=void 0)},this.loadContacts(),this.processContact=e=>et(this,void 0,void 0,(function*(){if(e.isAnyChat())return;const t=yield this.verifyPeerIdForContacts(e),i=s.has(e);!i&&t?s.add(e):i&&!t&&s.delete(e)}));const n=s.list;n.classList.add("chatlist-new"),this.setListClickListener(n),a.content.append(n),t=!0,i()})),s.append(a.container)},this.verifyPeerIdForContacts=e=>et(this,void 0,void 0,(function*(){const[t,i]=yield Promise.all([this.managers.appPeersManager.isContact(e),this.managers.appMessagesManager.getDialogOnly(e)]);return t&&!i}))}start(){const e=this.managers=(0,we.Z)();this.contextMenu=new m(e),this.stateMiddlewareHelper=(0,Oe.k)(),this.folders.menuScrollContainer=this.folders.menu.parentElement,this.onListLengthChange=(0,Y.Z)(this._onListLengthChange,100,!1,!0);const t=document.createElement("div");t.classList.add("connection-status-bottom"),t.append(this.folders.container),this.forumsTabs=new Map,this.forumsSlider=document.createElement("div"),this.forumsSlider.classList.add("topics-slider"),this.chatsContainer.parentElement.parentElement.append(this.forumsSlider),V.Z&&(0,K.Z)({element:this.folders.container,onSwipe:e=>{const t=s.prevId();s(e<0?t+1:t-1)},verifyTouchTarget:()=>!this.forumTab}),this.allChatsIntlElement=new o.ZP.IntlElement({key:"FilterAllChatsShort"}),n.Z.addEventListener("premium_toggle",(e=>et(this,void 0,void 0,(function*(){e||(yield this.managers.filtersStorage.isFilterIdAvailable(this.filterId))||s((0,Ne.Z)(this.filtersRendered[c.J$].menu),!1)})))),n.Z.addEventListener("state_cleared",(()=>{const e=c.DZ.has(this.filterId);De.Z.getState().then((t=>et(this,void 0,void 0,(function*(){this.xd.loadedDialogsAtLeastOnce=!1,this.showFiltersPromise=void 0,e&&(this.xd.clear(),this.onTabChange()),this.onStateLoaded(t)}))))})),this.setFilterId(c.J$,c.J$),this.addFilter({id:c.J$,title:"",localId:c.J$});const i=new b.v7(this.folders.menuScrollContainer);t.prepend(this.folders.menuScrollContainer);const s=this.selectTab=(0,g.X)(this.folders.menu,this.folders.container,((e,t)=>et(this,void 0,void 0,(function*(){const i=e;if(e=+t.dataset.filterId||c.J$,-1!==this.filterId&&!c.DZ.has(e)&&!(yield this.managers.filtersStorage.isFilterIdAvailable(e)))return!1;const n=this.filterId;if(w.IS_MOBILE_SAFARI||(i?this.filtersNavigationItem||(this.filtersNavigationItem={type:"filters",onPop:()=>{s(0),this.filtersNavigationItem=void 0}},de.Z.spliceItems(1,0,this.filtersNavigationItem)):this.filtersNavigationItem&&(de.Z.removeItem(this.filtersNavigationItem),this.filtersNavigationItem=void 0)),n===e)return;this.xds[e].clear();const a=this.setFilterIdAndChangeTab(e).then((({cached:e,renderPromise:t})=>{if(e)return t}));return-1!==n?a:void 0}))),(()=>{for(const e in this.xds)+e!==this.filterId&&this.xds[e].clear()}),void 0,i);De.Z.getState().then((e=>(le.Z.setPlaybackParams(e.playbackParams),le.Z.addEventListener("playbackParams",(e=>{this.managers.appStateManager.pushToState("playbackParams",e)})),this.onStateLoaded(e)))),ee.Z.addEventListener("resize",(()=>{this.changeFiltersAllChatsKey()})),new U(this.managers,this.chatsContainer),this.chatsContainer.append(t),setTimeout((()=>{Z.Z.loadLottieWorkers()}),200),p.Z.MANAGERS=n.Z.managers=e,Ie.Z.construct(e),T.ZP.construct(e),he.ZP.construct(e),Pe.ZP.construct(e),Ze.Z.construct(e),C.ZP.construct(e),this.xd=this.xds[this.filterId]}get chatList(){return this.xd.sortedList.list}setFilterId(e,t){this.filterId=e}setFilterIdAndChangeTab(e){return et(this,void 0,void 0,(function*(){return this.filterId=e,this.onTabChange()}))}initListeners(){n.Z.addEventListener("dialog_flush",(({dialog:e})=>{e&&this.setFiltersUnreadCount()})),n.Z.addEventListener("folder_unread",(e=>et(this,void 0,void 0,(function*(){if(e.id<0){const t=this.xd.getDialogElement(e.id);if(!t)return;this.setUnreadMessagesN({dialog:yield this.managers.dialogsStorage.getDialogOnly(e.id),dialogElement:t})}else this.setFilterUnreadCount(e.id)})))),n.Z.addEventListener("contacts_update",(e=>{var t;null===(t=this.processContact)||void 0===t||t.call(this,e.toPeerId())})),C.ZP.addEventListener("peer_changed",(({peerId:e,threadId:t,isForum:i})=>{const s={peerId:e,threadId:i?t:void 0};for(const e of this.lastActiveElements){const t=+e.dataset.threadId||void 0,i=e.dataset.peerId.toPeerId();C.ZP.isSamePeer({peerId:i,threadId:t},s)||this.setDialogActive(e,!1)}Array.from(document.querySelectorAll(`[data-autonomous="0"] .chatlist-chat[data-peer-id="${e}"]`)).forEach((t=>{const i=+t.dataset.threadId||void 0;C.ZP.isSamePeer({peerId:e,threadId:i},s)&&this.setDialogActive(t,!0)}))})),n.Z.addEventListener("filter_update",(e=>et(this,void 0,void 0,(function*(){if(c.DZ.has(e.id))return;if(!this.filtersRendered[e.id])return void this.addFilter(e);const t=this.filtersRendered[e.id];(0,ce.Z)(t.title,(0,pe.Z)(e.title))})))),n.Z.addEventListener("filter_delete",(e=>{const t=this.filtersRendered[e.id];t&&(t.container.remove(),t.menu.remove(),this.xds[e.id].destroy(),delete this.xds[e.id],delete this.filtersRendered[e.id],this.onFiltersLengthChange(),this.filterId===e.id&&this.selectTab(0,!1))})),n.Z.addEventListener("filter_order",(e=>et(this,void 0,void 0,(function*(){e=e.slice(),(0,Be.Z)(e,c.Zi);const t=this.folders.menu,i=yield Promise.all(e.map((e=>et(this,void 0,void 0,(function*(){const[t,i]=yield Promise.all([this.managers.dialogsStorage.getDialogIndexKeyByFilterId(e),this.managers.filtersStorage.getFilter(e)]);return{indexKey:t,filter:i}})))));e.forEach(((e,s)=>{const{indexKey:n,filter:a}=i[s],o=this.filtersRendered[e];this.xds[e].setIndexKey(n),(0,A.Z)(o.menu,t,a.localId),(0,A.Z)(o.container,this.folders.container,a.localId)}))}))))}setDialogActive(e,t){var i;const s=e.dialogDom;e.classList.toggle("active",t),e.classList.toggle("is-forum-open",(null===(i=this.forumTab)||void 0===i?void 0:i.peerId)===e.dataset.peerId.toPeerId()&&!e.dataset.threadId),t?this.lastActiveElements.add(e):this.lastActiveElements.delete(e),(null==s?void 0:s.callIcon)&&s.callIcon.setActive(t)}onStateLoaded(e){return et(this,void 0,void 0,(function*(){this.stateMiddlewareHelper.clean();const t=this.stateMiddlewareHelper.get(),i=e.filtersArr,s=i.length>c.DZ.size,n=e=>{for(const t of e)this.addFilter(t)};let a;s?n(i):a=this.managers.filtersStorage.getDialogFilters().then(n),this.doNotRenderChatList=!0;const o=this.xd.onChatsScroll(),r=(0,Ee.Z)(t);try{yield r(o)}catch(e){}s||this.selectTab(0,!1),a&&(yield r(a)),this.doNotRenderChatList=void 0,this.filterId=-1,this.selectTab(0,!1),this.initedListeners||(this.initListeners(),this.initedListeners=!0),s&&this.showFiltersPromise&&(yield r(this.showFiltersPromise)),this.managers.appNotificationsManager.getNotifyPeerTypeSettings(),yield(yield r(o)).renderPromise.catch(Me.Z),this.managers.appMessagesManager.fillConversations()}))}setFilterUnreadCount(e){var t;return et(this,void 0,void 0,(function*(){const i=null===(t=this.filtersRendered[e])||void 0===t?void 0:t.unread;if(!i)return;const{unreadUnmutedCount:s,unreadCount:n}=yield this.managers.dialogsStorage.getFolderUnreadCount(e);i.classList.toggle("badge-gray",!s);const a=e===c.J$?s:n;i.innerText=a?""+a:""}))}setFiltersUnreadCount(){for(const e in this.filtersRendered)this.setFilterUnreadCount(+e)}l(e){const t=this.createChatList(),i=this.xds[e.id]=new lt(e.id),s=i.generateScrollable(t,e);return this.setListClickListener(t,null,!0),{ul:t,xd:i,scrollable:s}}addFilter(e){if(e.id===c.Zi)return;const t=this.folders.menu,i=this.filtersRendered[e.id];if(i)return(0,A.Z)(i.menu,t,e.localId),void(0,A.Z)(i.container,this.folders.container,e.localId);const s=document.createElement("div");s.classList.add("menu-horizontal-div-item");const n=document.createElement("span"),a=document.createElement("span");a.classList.add("text-super"),e.id===c.J$?a.append(this.allChatsIntlElement.element):(0,ce.Z)(a,(0,pe.Z)(e.title));const o=document.createElement("div");o.classList.add("badge","badge-20","badge-primary");const r=document.createElement("i");n.append(a,o,r),(0,v.Z)(s),s.append(n),s.dataset.filterId=""+e.id,(0,A.Z)(s,t,e.localId);const{ul:d,scrollable:l}=this.l(e);l.container.classList.add("tabs-tab","chatlist-parts");const h=document.createElement("div");h.classList.add("chatlist-top");const u=document.createElement("div");u.classList.add("chatlist-bottom"),h.append(d),l.container.append(h,u);const p=l.container;(0,A.Z)(l.container,this.folders.container,e.localId),this.filtersRendered[e.id]={menu:s,container:p,unread:o,title:a},this.onFiltersLengthChange()}changeFiltersAllChatsKey(){const e=this.folders.menuScrollContainer.firstElementChild,t=e.scrollWidth>e.clientWidth?"FilterAllChatsShort":"FilterAllChats";this.allChatsIntlElement.compareAndUpdate({key:t})}onFiltersLengthChange(){let e=this.showFiltersPromise;return null!=e?e:e=this.showFiltersPromise=(0,Fe.Z)(0).then((()=>{if(this.showFiltersPromise!==e)return;const t=Object.keys(this.filtersRendered).length>1,i=!this.folders.menuScrollContainer.classList.contains("hide");t!==i&&(this.folders.menuScrollContainer.classList.toggle("hide",!t),t&&!i&&this.setFiltersUnreadCount(),this.chatsContainer.classList.toggle("has-filters",t)),this.changeFiltersAllChatsKey(),this.showFiltersPromise=void 0}))}generateEmptyPlaceholder(e){const t="empty-placeholder",i=document.createElement("div");i.classList.add(t,t+"-"+e.classNameType);const s=document.createElement("div");s.classList.add(t+"-header"),(0,o.$d)(s,e.title);const n=document.createElement("div");return n.classList.add(t+"-subtitle"),e.subtitle&&(0,o.$d)(n,e.subtitle,e.subtitleArgs),i.append(s,n),{container:i,header:s,subtitle:n}}checkIfPlaceholderNeeded(){if(this.filterId===c.Zi)return;const e=this.chatList,t=e.parentElement;let i=Array.from(t.children).find((e=>e.matches(".empty-placeholder")));const s=this.xd.scrollable.loadedAll.bottom&&!e.childElementCount;if(s&&i)return;if(!s)return void(i&&(t.classList.remove("with-placeholder"),i.remove()));let n,a;if(this.filterId){n=this.generateEmptyPlaceholder({title:"FilterNoChatsToDisplay",subtitle:"FilterNoChatsToDisplayInfo",classNameType:a="folder"}),i=n.container;const e=document.createElement("div"),t="📂",s=128;(0,be.Z)({div:e,emoji:t,width:s,height:s}),i.prepend(e);const o=(0,L.Z)("btn-primary btn-color-primary btn-control tgico",{text:"FilterHeaderEdit",icon:"settings"});(0,x.fc)(o,(()=>et(this,void 0,void 0,(function*(){const e=T.ZP.createTab(k.Z);e.setInitFilter(yield this.managers.filtersStorage.getFilter(this.filterId)),e.open()})))),i.append(o)}else{n=this.generateEmptyPlaceholder({title:"ChatList.Main.EmptyPlaceholder.Title",classNameType:a="dialogs"}),i=n.container;const e=document.createElement("img");e.classList.add("empty-placeholder-dialogs-icon"),this.emptyDialogsPlaceholderSubtitle=new o.ZP.IntlElement({element:n.subtitle}),Promise.all([this.updateContactsLength(!1),(0,z.cj)(e,"assets/img/EmptyChats.svg"),(0,j.AD)()]).then((([e])=>{i.classList.add("visible"),t.classList.toggle("has-contacts",!!e)})),i.prepend(e)}t.append(i),t.classList.add("with-placeholder"),t.dataset.placeholderType=a}updateContactsLength(e){var t;return null!==(t=this.updateContactsLengthPromise)&&void 0!==t?t:this.updateContactsLengthPromise=this.managers.appUsersManager.getContacts().then((t=>{const i=this.emptyDialogsPlaceholderSubtitle;if(i){let e,s;t.length?(e="ChatList.Main.EmptyPlaceholder.Subtitle",s=[(0,o.ag)("Contacts.Count",[t.length])]):(e="ChatList.Main.EmptyPlaceholder.SubtitleNoContacts",s=[]),i.compareAndUpdate({key:e,args:s})}return e&&this.chatList.parentElement.classList.toggle("has-contacts",!!t.length),this.updateContactsLengthPromise=void 0,t.length}))}removeContactsPlaceholder(){const e=this.chatList,t=e.parentElement.parentElement,i=e.parentElement.nextElementSibling;t.classList.remove("with-contacts"),i.replaceChildren(),this.loadContacts=void 0,this.processContact=void 0}toggleForumTab(e,t=this.forumTab){return et(this,void 0,void 0,(function*(){if(!t&&!e)return;if(t){const e=this.xd.getDialogElement(t.peerId);e&&e.dom.listEl.classList.remove("is-forum-open")}t===e&&(e=void 0),null==t||t.toggle(!1);const i=null==e?void 0:e.toggle(!0);if(t===this.forumTab&&(this.forumTab=e),e){const t=this.xd.getDialogElement(e.peerId);t&&t.dom.listEl.classList.add("is-forum-open"),C.ZP.selectTab(C.oo.CHATLIST)}i&&(yield i),e&&!this.forumNavigationItem?(this.forumNavigationItem={type:"forum",onPop:()=>{this.forumNavigationItem=void 0,this.toggleForumTab()}},de.Z.pushItem(this.forumNavigationItem)):!e&&this.forumNavigationItem&&(de.Z.removeItem(this.forumNavigationItem),this.forumNavigationItem=void 0);const s=!!e,n=i?2:void 0;this.xd.toggleAvatarUnreadBadges(s,n);const a=(0,Ce.Z)();(0,E.Z)({element:this.forumsSlider.parentElement,className:"is-forum-visible",duration:300,forwards:s,useRafs:n,onTransitionEnd:()=>{a.resolve()}}),(0,Ye.YW)(a,300).then((()=>a.resolve()))}))}toggleForumTabByPeerId(e,t){const{managers:i}=this,s=T.ZP.getHistory(),n=s[s.length-1];let a;if(n)return n instanceof at&&n.peerId===e&&t?void(0,Qe.Z)(n.container):(a=T.ZP.createTab(at),void a.open({peerId:e,managers:i}));a=this.forumsTabs.get(e);const o=this.forumTab&&this.forumTab===a;if(null!=t||(t=!o),t!==o)return t&&!a&&(a=new at(void 0),a.init({peerId:e,managers:i}),this.forumsTabs.set(e,a),this.forumsSlider.append(a.container),a.managers=this.managers,a.eventListener.addEventListener("destroy",(()=>{this.forumsTabs.delete(e)}))),this.toggleForumTab(a);t&&(0,Qe.Z)(a.container)}setListClickListener(e,t,i=!1,s=!1,n=!1){let a;const o=(n?C.ZP.setInnerPeer:C.ZP.setPeer).bind(C.ZP);e.dataset.autonomous=""+ +s,e.addEventListener("mousedown",(i=>{if(0!==i.button)return;this.log("dialogs click list");const n=i.target,d=(0,r.Z)(n,tt);if(!d)return;const l=d.dataset.peerId.toPeerId(),h=+d.dataset.mid||void 0,u=+d.dataset.threadId||void 0;if(null==t||t(),!d.querySelector(".is-forum")||i.shiftKey||h){if(i.ctrlKey||i.metaKey)return window.open(d.href||"#"+l,"_blank"),void(0,N.Z)(i);s&&(a&&!(a===d)&&a.classList.remove("active"),d&&(d.classList.add("active"),a=d,this.lastActiveElements.add(d))),u&&!h||this.xd.sortedList.list!==e||this.xd===this.xds[c.Zi]||this.toggleForumTab(),o({peerId:l,lastMsgId:h,threadId:u})}else this.toggleForumTabByPeerId(l)}),{capture:!0}),e.addEventListener("click",(e=>{0===e.button&&(0,N.Z)(e)}),{capture:!0}),i&&this.contextMenu.attach(e)}createChatList(e={}){const t=document.createElement("ul");return t.classList.add("chatlist"),e.new&&t.classList.add("chatlist-new"),e.dialogSize&&t.classList.add("chatlist-"+e.dialogSize),t}setLastMessageN(e){return this.setLastMessage(e).catch((e=>{"MIDDLEWARE"!==(null==e?void 0:e.type)&&this.log.error("set last message error",e)}))}setLastMessage({dialog:e,lastMessage:t,dialogElement:i,highlightWord:s,isBatch:a=!1,setUnread:r=!1}){var d,l;return et(this,void 0,void 0,(function*(){if(!i&&!(i=this.xd.getDialogElement(e.peerId)))return;const{dom:c}=i,{peerId:h}=e,{deferred:u,middleware:p}=it(c,"setLastMessagePromise");let f;if(!t&&("draftMessage"!==(null===(d=e.draft)||void 0===d?void 0:d._)||h.isAnyChat()&&"forumTopic"!==e._&&(yield this.managers.appPeersManager.isForum(h))||(f=e.draft),(null==(t=e.topMessage)?void 0:t.mid)!==e.top_message)){const i=this.managers.appMessagesManager.getMessageByPeer(h,e.top_message);t=yield p(i)}const m=null!==r&&!r;if(m||this.setUnreadMessagesN({dialog:e,dialogElement:i,isBatch:a,setLastMessagePromise:u}),!t)return c.lastMessageSpan.replaceChildren(),c.lastTimeSpan.replaceChildren(),delete c.listEl.dataset.mid,void u.resolve();const g=t&&(0,me.Z)(t);{let e;const i=[];if(t&&!f&&!g){const s=(0,ge.Z)(t,!0),n=new Set(["video","gif","round"]);if(s&&("photo"===s._||n.has(s.type))){const a=(0,ue.Z)(s,20,20);if("photoSizeEmpty"!==a._&&(e=document.createElement("div"),e.classList.add("dialog-subtitle-media"),"round"===s.type&&e.classList.add("is-round"),i.push((0,M.Z)({photo:s,message:t,container:e,withoutPreloader:!0,size:a}).then((()=>e))),n.has(s.type))){const t=document.createElement("span");t.classList.add("tgico-play"),e.append(t)}}}if(f){const e=document.createElement("span");e.classList.add("danger"),e.append((0,o.ag)("Draft"),": "),i.unshift(e)}else if(h.isAnyChat()&&h!==t.fromId&&!t.action){const e=document.createElement("span");if(e.classList.add("primary-text"),t.fromId===n.Z.myId)e.append((0,o.ag)("FromYou")),i.unshift(e);else{const s=p((0,Le.Z)({peerId:t.fromId,onlyFirstName:!0})).then((t=>(e.prepend(t),e)),Me.Z);i.unshift(s)}e.append(": ")}const a=!!e&&!!(null==t?void 0:t.message);let r;if(r=s&&t.message?yield p((0,fe.Z)({message:t,highlightWord:s,withoutMediaType:a})):f?yield p((0,fe.Z)({message:f})):t?yield p((0,fe.Z)({message:t,withoutMediaType:a})):document.createDocumentFragment(),i.length){const e=yield p(Promise.all(i));r.prepend(...e)}(0,_.Z)(c.lastMessageSpan,r)}if(t||f){const e=f?Math.max(f.date,t.date||0):t.date;(0,_.Z)(c.lastTimeSpan,(0,y.zM)(new Date(1e3*e)))}else c.lastTimeSpan.textContent="";if(m){c.listEl.dataset.mid=""+t.mid;const e=t.reply_to;(null===(l=null==e?void 0:e.pFlags)||void 0===l?void 0:l.forum_topic)&&(c.listEl.dataset.threadId=""+(0,We.Z)(t))}u.resolve()}))}setUnreadMessagesN(e){return this.setUnreadMessages(e).catch((()=>{}))}setUnreadMessages({dialog:e,dialogElement:t,isBatch:i=!1,setLastMessagePromise:s}){var a;return et(this,void 0,void 0,(function*(){const{dom:o}=t;if(!o)return;const r="forumTopic"===e._,{deferred:d,middleware:l}=it(o,"setUnreadMessagePromise"),{peerId:h}=e,u=Promise.all([this.managers.appNotificationsManager.isPeerLocalMuted({peerId:h,respectType:!0,threadId:r?e.id:void 0}),"draftMessage"!==(null===(a=e.draft)||void 0===a?void 0:a._)?this.managers.appMessagesManager.getMessageByPeer(h,e.top_message):void 0,r?!!e.pFlags.pinned:this.managers.dialogsStorage.isDialogPinned(h,this.filterId),this.managers.appMessagesManager.isDialogUnread(e),h.isAnyChat()&&!r?this.managers.acknowledged.dialogsStorage.getForumUnreadCount(h).then((i=>i.cached?i.result:(i.result.then((()=>{this.setUnreadMessagesN({dialog:e,dialogElement:t})})),{count:0,hasUnmuted:!1}))).catch((()=>{})):void 0]);let[p,f,m,g,v]=yield l(u);const b=o.listEl.classList.contains("is-muted"),{count:y,hasUnmuted:w}=v||{};let S;f&&f.pFlags.out&&f.peerId!==n.Z.myId&&(S=f);const C=null!=y?y:e.unread_count;void 0!==y&&(g=!!C),r&&!g&&(g=!(0,Je.Z)(e.read_inbox_max_id));const L=m||g,I=this.xd!==this.xds[c.Zi]&&!r&&!!this.forumTab&&this.xd.getDialogElement(h)===t&&g;if(s)try{yield l(s)}catch(e){return}const P=i?0:250;o.listEl.classList.toggle("no-unmuted-topic",!p&&void 0!==w&&!w),p!==b&&(0,E.Z)({element:o.listEl,className:"is-muted",forwards:p,duration:P}),function(e,t,i){let s;if("string"==typeof t?s=t:(null==t?void 0:t.pFlags.out)&&(s=t.error?"sendingerror":t.pFlags.is_outgoing?"sending":t.pFlags.unread?"check":"checks"),!s)return void(e.textContent="");const n="tgico-"+s,a=e.lastElementChild;if(a&&a.classList.contains(n))return;const o=document.createElement("i");o.classList.add("sending-status-icon",n),e.append(o),a&&a.remove()}(o.statusSpan,r&&e.pFlags.closed?"premium_lock":S);const Z=!!o.unreadBadge;L&&t.createUnreadBadge();const M=!!o.unreadAvatarBadge;I&&t.createUnreadAvatarBadge();const k=e.unread_mentions_count&&(e.unread_mentions_count>1||e.unread_count>1),T=!!o.mentionsBadge;if(k&&t.createMentionsBadge(),[["unreadBadge",L,Z],["unreadAvatarBadge",I,M],["mentionsBadge",k,T]].forEach((([e,s,n])=>{o[e]&&t.toggleBadgeByKey(e,s,n,i)})),!L)return void d.resolve();m?o.unreadBadge.classList.add("tgico-chatspinned","tgico"):o.unreadBadge&&o.unreadBadge.classList.remove("tgico-chatspinned","tgico");let x,A=!0,_=!1;if(e.unread_mentions_count&&1===C?(x="@",_=!0):g?x=""+(C?(0,$e.Z)(C,1):" "):(x="",A=!1),r){const e=g&&" "===x;o.unreadBadge.classList.toggle("not-visited",e)}[[o.unreadBadge,x],[o.unreadAvatarBadge,x||void 0]].filter(Boolean).forEach((([e,t])=>{void 0!==t&&(e.innerText=x),e.classList.toggle("unread",A),e.classList.toggle("mention",_)})),d.resolve()}))}getDialog(e,t){return et(this,void 0,void 0,(function*(){if("object"!=typeof e){let i;if(t){if(i=yield this.managers.dialogsStorage.getForumTopic(e,t),!i)return{peerId:e||c.NM,pFlags:{}}}else if(i=yield this.managers.appMessagesManager.getDialogOnly(e),!i){const t=e||c.NM;return{peerId:t,peer:yield this.managers.appPeersManager.getOutputPeer(t),pFlags:{}}}return i}return e}))}addListDialog(e){var t;e.autonomous=!1;const i=this.addDialogNew(e);if(i){const{peerId:s}=e,a=this.getDialog(s,e.threadId).then((t=>{const a=[],o=s.isUser();return o||"dialog"!==t._||a.push(this.xd.processDialogForCallStatus(s,i.dom)),s!==n.Z.myId&&o&&a.push(this.managers.appUsersManager.getUserStatus(s.toUserId()).then((e=>{"userStatusOnline"===(null==e?void 0:e._)&&this.xd.setOnlineStatus(i.dom.avatarEl,!0)}))),a.push(this.setLastMessageN({dialog:t,dialogElement:i,isBatch:e.isBatch,setUnread:!0})),Promise.all(a)}));null===(t=e.loadPromises)||void 0===t||t.push(a)}return i}addDialogAndSetLastMessage(e){const{peerId:t,message:i,query:s}=e,n=this.addDialogNew(Object.assign(Object.assign(Object.assign({},e),(0,ve.Z)(i)),{peerId:t}));return this.setLastMessageN({dialog:{_:"dialog",peerId:t},lastMessage:i,dialogElement:n,highlightWord:s}),i.peerId!==t&&(n.dom.listEl.dataset.peerId=""+i.peerId),n}addDialogNew(e){const t=new nt(Object.assign({autonomous:!!e.container,avatarSize:"bigger"},e));if(e.container){const i=e.append?"prepend":"append";e.container[i](t.container)}return t}}const ht=new ct;I.GO.appDialogsManager=ht;const ut=ht},2312:(e,t,i)=>{"use strict";i.d(t,{Z:()=>v});var s=i(3725),n=i(2202),a=i(3512),o=i(410),r=i(319),d=i(1243),l=i(7086),c=i(1655),h=i(5471),u=i(8801),p=i(6658),f=i(7667),m=i(3855);const g=new class{constructor(){this.downloads={},this.progress={}}construct(e){this.managers=e,a.Z.addEventListener("download_progress",(e=>{var t;const i=this.downloads[e.fileName];(null===(t=null==i?void 0:i.main)||void 0===t?void 0:t.notifyAll)&&(this.progress[e.fileName]=e,i.main.notifyAll(e))}))}getNewDeferred(e,t){const i=(0,s.Z)();let n=this.downloads[e];if(n){const e=n.main;["cancel","addNotifyListener","notify","notifyAll"].forEach((t=>{e[t]&&(i[t]=e[t].bind(e))}))}else n=this.downloads[e]={main:i},i.cancel=()=>{const t=(0,h.Z)("DOWNLOAD_CANCELED");this.managers.apiFileManager.cancelDownload(e),i.reject(t),i.cancel=r.Z},i.catch((()=>{this.clearDownload(e,t)})).finally((()=>{delete this.progress[e]}));return"disc"===t&&i.catch(r.Z).finally((()=>{this.clearDownload(e,t)})),n[t]=i}getNewDeferredForUpload(e,t){const i=this.getNewDeferred(e);return t.then(i.resolve,i.reject),i.finally((()=>{this.clearDownload(e)})),i}clearDownload(e,t){const i=this.downloads[e];if(!i)return;delete i[t];const s=Object.keys(i).length;(!s||i.main&&1===s)&&delete this.downloads[e]}getUpload(e){let t=this.getDownload(e);return t||(t=this.getNewDeferred(e),this.managers.appMessagesManager.getUploadPromise(e).then(t.resolve,t.reject),t)}d(e,t,i){let s=this.getDownload(e,i);return s||(s=this.getNewDeferred(e,i),t().then(s.resolve,s.reject),s)}download(e){const t=(0,l.Z)(e);return this.d(t,(()=>this.managers.apiFileManager.download(e)),"blob")}downloadMedia(e,t="blob",i){const{downloadOptions:s,fileName:n}=(0,d.Z)(e);return this.d(n,(()=>{let s;return s="url"===t?this.managers.apiFileManager.downloadMediaURL:"void"===t?this.managers.apiFileManager.downloadMediaVoid:this.managers.apiFileManager.downloadMedia,i?i.then((()=>s(e))):s(e)}),t)}downloadMediaURL(e){return this.downloadMedia(e,"url")}downloadMediaVoid(e){return this.downloadMedia(e,"void")}upload(e,t,i){return t||(t=(0,n.Z)(e)),i||(i=this.managers.apiFileManager.upload({file:e,fileName:t})),this.getNewDeferredForUpload(t,i)}getDownload(e,t){const i=this.downloads[e];return i&&i[t]}downloadToDisc(e,t){const i=e.media,s="document"===i._;s||e.thumb||(e.thumb=i.sizes.slice().pop());const n=""+(2147483647*Math.random()|0),a=`download/${n}`;e.downloadId=n;const o=m.Z.pingServiceWorkerWithIframe(),d=this.downloadMedia(e,"disc",o);if(t)return d;const l=document.createElement("iframe");l.hidden=!0,o.then((()=>{l.src=a,document.body.append(l)}));let h,g=!1;const v=()=>{g||(g=!0,h=l,(0,c.Z)(d.listeners,v))};return d.addNotifyListener(v),d.then((t=>{if(!t)return;const n=URL.createObjectURL(t),a=s?(0,p.Z)(i):(0,f.Z)(i,e.thumb),o=e.media.file_name||(0,u.P)(a.location);!function(e,t,i){const s=document.createElement("a");s.href=e,s.download=t,s.target="_blank",s.style.position="absolute",s.style.top="1px",s.style.left="1px",document.body.append(s);try{const e=document.createEvent("MouseEvents");e.initMouseEvent("click",!0,!1,window,0,0,0,0,0,!1,!1,!1,!1,0,null),s.dispatchEvent(e)}catch(t){console.error("Download click error",t);try{s.click()}catch(t){window.open(e,"_blank")}}setTimeout((()=>{s.remove(),i&&i()}),100)}(n,a.fileName||o,(()=>{URL.revokeObjectURL(n)}))})).catch(r.Z).finally((()=>{g||v(),setTimeout((()=>{null==h||h.remove()}),1e3)})),d}};o.GO&&(o.GO.appDownloadManager=g);const v=g},7030:(e,t,i)=>{"use strict";i.d(t,{oo:()=>ys,ZP:()=>Es});var s=i(5814),n=i(7856),a=i(4332),o=i(4755),r=i(5003),d=i(3512),l=i(3241),c=i(1175),h=i(4499),u=i(8843),p=i(6054),f=i(4762),m=i(9331),g=i(4494),v=i(2230),b=i(5322),y=i(3013),w=i(4561),S=i(1405),C=i(3910),L=i(2738),E=i(5953);const I="pinned-container";class P{constructor(e){this.floating=!1,(0,E.Z)(this,e);const{divAndCaption:t,className:i}=this;t.container.classList.add(I,"hide"),t.title.classList.add(I+"-title"),t.subtitle.classList.add(I+"-subtitle"),t.content.classList.add(I+"-content"),this.btnClose=document.createElement("button"),this.btnClose.classList.add(I+"-close",`pinned-${i}-close`,"btn-icon","tgico-close"),this.wrapper=document.createElement("div"),this.wrapper.classList.add(I+"-wrapper"),(0,S.Z)(this.wrapper),this.wrapperUtils=document.createElement("div"),this.wrapperUtils.classList.add(I+"-wrapper-utils"),this.wrapperUtils.append(this.btnClose),this.wrapper.append(...Array.from(t.container.children),this.wrapperUtils),t.container.append(this.wrapper),this.attachOnCloseEvent(this.btnClose)}attachOnCloseEvent(e){(0,L.fc)(e,(e=>{(0,C.Z)(e),((this.onClose?this.onClose():null)||Promise.resolve(!0)).then((e=>{e&&this.toggle(!0)}))}),{listenerSetter:this.listenerSetter})}toggle(e){const t=this.divAndCaption.container.classList.contains("hide");if(void 0===e)e=!t;else if(e===t)return;const i=(this.floating||o.Z.isMobile)&&!e;this.divAndCaption.container.classList.toggle("is-floating",i),this.divAndCaption.container.classList.toggle("hide",e),this.topbar.container.classList.toggle("is-pinned-floating",i),this.topbar.container.classList.toggle(`is-pinned-${this.className}-shown`,!e),this.topbar.setFloating(),this.topbar.setUtilsWidth()}isVisible(){return!this.divAndCaption.container.classList.contains("hide")}isFloating(){return this.divAndCaption.container.classList.contains("is-floating")}fill(e,t,i){this.divAndCaption.container.dataset.peerId=""+i.peerId,this.divAndCaption.container.dataset.mid=""+i.mid,this.divAndCaption.fill(e,t,i),this.topbar.setUtilsWidth()}}var Z=i(5565),M=i(8842),k=i(2325),T=i(632),x=i(7207),A=i(8427),_=i(8115);class F extends P{constructor(e,t,i){super({topbar:e,chat:t,listenerSetter:e.listenerSetter,className:"audio",divAndCaption:new w.Z("pinned-audio",((e,t)=>{(0,Z.Z)(this.divAndCaption.title,e),(0,Z.Z)(this.divAndCaption.subtitle,t)})),onClose:()=>{y.Z.stop(void 0,!0)},floating:!0}),this.topbar=e,this.chat=t,this.managers=i,this.onPlaybackParams=e=>{this.fasterEl.classList.toggle("active",e.playbackRate>1),this.repeatEl.classList.remove("tgico-audio_repeat","tgico-audio_repeat_single"),this.repeatEl.classList.add(e.loop?"tgico-audio_repeat_single":"tgico-audio_repeat"),this.repeatEl.classList.toggle("active",e.loop||e.round)},this.onPause=()=>{this.toggleEl.classList.remove("flip-icon")},this.onStop=()=>{this.toggle(!0)},this.onMediaPlay=({doc:e,message:t,media:i,playbackParams:s})=>{var n,a;let o,r;const d="voice"!==e.type&&"round"!==e.type;if(d){const t=e.attributes.find((e=>"documentAttributeAudio"===e._));o=(0,_.Z)(null!==(a=null==t?void 0:t.title)&&void 0!==a?a:e.file_name),r=(null==t?void 0:t.performer)?(0,_.Z)(t.performer):(0,k.ag)("AudioUnknownArtist")}else o=new M.Z({peerId:t.fromId,fromName:null===(n=t.fwd_from)||void 0===n?void 0:n.from_name}).element,r=(0,T.OD)(t.date);this.fasterEl.classList.toggle("hide",d),this.repeatEl.classList.toggle("hide",!d),this.onPlaybackParams(s),this.volumeSelector.setVolume(),this.progressLine.setMedia({media:i,duration:e.duration}),this.fill(o,r,t),this.toggleEl.classList.toggle("flip-icon",!i.paused),this.toggle(!1)},this.divAndCaption.border.remove();const s=(0,v.Z)("fast_rewind active",{noRipple:!0}),n=(0,v.Z)("fast_forward active",{noRipple:!0}),a=(e,t)=>{(0,L.fc)(e,(e=>{(0,C.Z)(e),t()}),{listenerSetter:this.topbar.listenerSetter})};a(s,(()=>{y.Z.previous()})),a(n,(()=>{y.Z.next()})),this.toggleEl=(0,v.Z)("",{noRipple:!0}),this.toggleEl.classList.add("active","pinned-audio-ico","tgico"),a(this.toggleEl,(()=>{y.Z.toggle()})),this.wrapper.prepend(this.wrapper.firstElementChild,s,this.toggleEl,n),this.volumeSelector=new A.Z(this.listenerSetter,!0);const o=document.createElement("div");o.classList.add("progress-line-container"),o.append(this.volumeSelector.container);const r=document.createElement("div");r.classList.add("pinned-audio-volume-tunnel"),this.volumeSelector.btn.classList.add("pinned-audio-volume","active"),this.volumeSelector.btn.prepend(r),this.volumeSelector.btn.append(o),this.repeatEl=(0,v.Z)("audio_repeat",{noRipple:!0}),a(this.repeatEl,(()=>{const e=y.Z.getPlaybackParams();e.round?e.loop?(y.Z.round=!1,y.Z.loop=!1):y.Z.loop=!y.Z.loop:y.Z.round=!0}));const d=this.fasterEl=(0,v.Z)("playback_2x",{noRipple:!0});a(d,(()=>{y.Z.playbackRate=d.classList.contains("active")?1:1.75})),this.wrapperUtils.prepend(this.volumeSelector.btn,d,this.repeatEl);const l=document.createElement("div");l.classList.add("pinned-audio-progress-wrapper"),this.progressLine=new x.Z({withTransition:!0,useTransform:!0}),this.progressLine.container.classList.add("pinned-audio-progress"),l.append(this.progressLine.container),this.wrapper.insertBefore(l,this.wrapperUtils),this.topbar.listenerSetter.add(y.Z)("play",this.onMediaPlay),this.topbar.listenerSetter.add(y.Z)("pause",this.onPause),this.topbar.listenerSetter.add(y.Z)("stop",this.onStop),this.topbar.listenerSetter.add(y.Z)("playbackParams",this.onPlaybackParams);const c=y.Z.getPlayingDetails();c&&(this.onMediaPlay(c),this.onPlaybackParams(c.playbackParams))}destroy(){this.progressLine&&this.progressLine.removeListeners()}}var D,R=i(684);!function(e){e[e.ONE=32]="ONE",e[e.TWO=15]="TWO",e[e.THREE=10]="THREE",e[e.FOUR=8]="FOUR",e[e.MORE=8]="MORE"}(D||(D={}));const B="pinned-message-border";class N{constructor(){this.drawRect=(e,t,i,s,n)=>`M${e},${t+n}a${n},${n},0,0,1,${i},0v${s-2*n}a${n},${n},0,0,1,${-i},0Z`,this.getClipPath=(e,t,i)=>{let s="";if(2===i)s=this.drawRect(0,0,2,t,1)+this.drawRect(0,t+2,2,t,1);else for(let e=0;e<i;++e)s+=this.drawRect(0,(t+1)*e,2,t,1);return this.clipPath||(this.clipPath=document.createElementNS("http://www.w3.org/2000/svg","clipPath"),this.path=document.createElementNS("http://www.w3.org/2000/svg","path"),this.clipPath.append(this.path)),this.clipPath.id=e,this.path.setAttributeNS(null,"d",s),this.clipPath},this.getBarHeight=(e,t)=>{let i;return e<=1?i=D.ONE:2===e?i=D.TWO:3===e?i=D.THREE:4===e?i=D.FOUR:e>3&&(i=D.MORE),i},this.getMarkHeight=(e,t)=>{let i;return e<=1?i=D.ONE:2===e?i=D.TWO:3===e?i=D.THREE:4===e?i=D.FOUR:e>3&&(i=D.MORE),i},this.getMarkTranslateY=(e,t,i)=>1===i?0:2===i?e?t+1:0:3===i?e?1===e?t+1:2*t+2+1:0:(t+1)*e,this.getTrackTranslateY=(e,t,i,s)=>t<=4||e<=1?0:e>=t-2?s-D.ONE-i:(e-2)*i+1*e,this.getTrackHeight=(e,t)=>e<=3?D.ONE:t*e+1*(e-1)}render(e,t){if(this.border||(this.border=document.createElement("div"),this.border.classList.add(B),this.wrapper=document.createElement("div"),this.border.append(this.wrapper)),1===e)return this.count!==e&&(this.wrapper.className=B+"-wrapper-1",this.border.classList.remove(B+"-mask"),this.wrapper.replaceChildren(),this.wrapper.style.cssText=""),this.border;const i=this.getBarHeight(e,t),s=this.getMarkHeight(e,t),n=this.getTrackHeight(e,i),a=`clipPath_${e}`,o=this.getClipPath(a,i,e),r=this.getMarkTranslateY(t,i,e),d=this.getTrackTranslateY(t,e,i,n);return this.border.classList.toggle(B+"-mask",e>4),t<=1?(this.border.classList.add("mask-bottom"),this.border.classList.remove("mask-top")):t>=e-2?(this.border.classList.add("mask-top"),this.border.classList.remove("mask-bottom")):this.border.classList.add("mask-top","mask-bottom"),this.wrapper.className=B+"-wrapper",this.wrapper.style.cssText=`clip-path: url(#${a}); width: 2px; height: ${n}px; transform: translateY(-${d}px);`,this.svg||(this.svg=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.svg.setAttributeNS(null,"height","0"),this.svg.setAttributeNS(null,"width","0"),this.defs=document.createElementNS("http://www.w3.org/2000/svg","defs"),this.defs.append(o),this.svg.append(this.defs),this.mark=document.createElement("div"),this.mark.classList.add(B+"-mark")),this.svg.parentElement||this.wrapper.append(this.svg,this.mark),this.mark.style.cssText=`height: ${s}px; transform: translateY(${r}px);`,this.count=e,this.index=t,this.border}}var O=i(3484),U=i(3699),H=i(8594),z=i(5432),j=i(5701),G=i(6724),V=i(1168),K=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class W{constructor(){this.rows={},this.container=document.createElement("div"),this.container.className=W.BASE_CLASS}getRow(e,t=!1){if(this.rows[e])return this.rows[e].element;const i=document.createElement("div"),s=!Object.keys(this.rows).length&&!t;return i.className=W.BASE_CLASS+"-row"+(s?"":" is-hiding hide"),this.rows[e]={element:i,new:!0},this.container.append(i),i}clearRow(e){this.rows[e]&&(this.rows[e].element.remove(),delete this.rows[e])}clearRows(e){this.clearTimeout&&clearTimeout(this.clearTimeout),this.clearTimeout=window.setTimeout((()=>{for(const t in this.rows)+t!==e&&this.clearRow(+t)}),W.DURATION)}setNewRow(e,t=!1){const i=this.rows[e];i.new&&(t?(i.element.classList.remove("hide"),i.element.offsetLeft):i.element.classList.remove("is-hiding","hide"),delete i.new),this.clearRows(e)}animate(e,t,i=e>t,s=!1){if(e===t)return this.setNewRow(e);const n=this.rows[e],a=this.rows[t];if(!a&&!s)return this.setNewRow(e);const o=["from-top","from-bottom"];i||o.reverse(),n.element.classList.add(o[0]),n.element.classList.remove(o[1]),a&&(a.element.classList.add(o[1]),a.element.classList.remove(o[0])),n.new&&this.setNewRow(e,!0),n.element.classList.toggle("is-hiding",!1),a&&a.element.classList.toggle("is-hiding",!0),this.clearRows(e)}}W.DURATION=200,W.BASE_CLASS="animated-super";class ${constructor(e=!1){this.reverse=e,this.decimals=[],this.previousNumber=0,this.container=document.createElement("div"),this.container.className=$.BASE_CLASS}getDecimal(e){if(this.decimals[e])return this.decimals[e];const t=document.createElement("div");t.className=$.BASE_CLASS+"-decimal";const i=document.createElement("div");i.className=$.BASE_CLASS+"-decimal-placeholder";const s=new W;return s.container.className=$.BASE_CLASS+"-decimal-wrapper",t.append(i,s.container),this.container.append(t),this.decimals[e]={container:t,placeholder:i,animatedSuper:s}}clear(e){this.clearTimeout&&clearTimeout(this.clearTimeout);const t=(""+e).length;t>=this.decimals.length||(this.clearTimeout=window.setTimeout((()=>{this.decimals.splice(t,this.decimals.length-t).forEach((e=>{e.container.remove()}))}),W.DURATION))}hideLeft(e){const t=(""+e).length;this.decimals.slice(t).forEach((t=>{const i=+t.placeholder.innerText||0;t.animatedSuper.getRow($.EMPTY_INDEX,!0),t.animatedSuper.animate($.EMPTY_INDEX,i,this.reverse?e<this.previousNumber:e>this.previousNumber,!0)})),this.clear(e)}setCount(e){const t=Array.from(""+this.previousNumber).map((e=>+e));Array.from(""+e).map((e=>+e)).forEach(((i,s)=>{var n;const a=this.getDecimal(s),o=a.animatedSuper.getRow(i,!0),r=null!==(n=t[s])&&void 0!==n?n:$.EMPTY_INDEX;o.innerText=a.placeholder.innerText=""+i,a.animatedSuper.animate(i,r,this.reverse?e<this.previousNumber:e>this.previousNumber,!0)})),this.hideLeft(e),this.previousNumber=e}}$.EMPTY_INDEX=-1,$.BASE_CLASS="animated-counter";class q{constructor(e,t,i){this.topbar=e,this.chat=t,this.managers=i,this.pinnedMaxMid=0,this.pinnedMid=0,this.pinnedIndex=-1,this.wasPinnedIndex=0,this.wasPinnedMediaIndex=0,this.locked=!1,this.waitForScrollBottom=!1,this.count=0,this.mids=[],this.offsetIndex=0,this.loading=!1,this.loadedBottom=!1,this.loadedTop=!1,this.scrollDownListenerSetter=null,this.hidden=!1,this.getCurrentIndexPromise=null,this.listenerSetter=new U.Z,this.log=(0,r.kg)("PM"),this.debug=!0,this.isStatic=!1;const s=new O.Z("pinned-message",t.animationGroup);this.pinnedMessageContainer=new P({topbar:e,chat:t,listenerSetter:this.listenerSetter,className:"message",divAndCaption:s,onClose:()=>K(this,void 0,void 0,(function*(){return(yield i.appPeersManager.canPinMessage(this.chat.peerId))?V.Z.createPopup(R.Z,this.chat.peerId,this.pinnedMid,!0):V.Z.createPopup(R.Z,this.chat.peerId,0,!0),!1}))}),this.pinnedMessageBorder=new N,s.border.replaceWith(this.pinnedMessageBorder.render(1,0)),this.animatedSubtitle=new W,s.subtitle.append(this.animatedSubtitle.container),this.animatedMedia=new W,this.animatedMedia.container.classList.add("pinned-message-media-container"),s.content.prepend(this.animatedMedia.container),this.animatedCounter=new $(!0),s.title.append((0,k.ag)("PinnedMessage")," ",this.animatedCounter.container);const n=this.pinnedMessageContainer.btnClose.cloneNode(!0);this.pinnedMessageContainer.attachOnCloseEvent(n),s.container.prepend(n),this.btnOpen=(0,v.Z)("pinlist pinned-container-close pinned-message-pinlist",{noRipple:!0}),this.pinnedMessageContainer.wrapperUtils.prepend(this.btnOpen),(0,L.fc)(this.btnOpen,(e=>{(0,C.Z)(e),this.topbar.openPinned(!0)}),{listenerSetter:this.listenerSetter}),this.listenerSetter.add(d.Z)("peer_pinned_messages",(({peerId:e})=>{e===this.chat.peerId&&(this.hidden&&this.pinnedMessageContainer.toggle(this.hidden=!1),this.loadedTop=this.loadedBottom=!1,this.pinnedIndex=-1,this.pinnedMid=0,this.count=0,this.mids=[],this.offsetIndex=0,this.pinnedMaxMid=0,this.setCorrectIndex(0))})),this.listenerSetter.add(d.Z)("peer_pinned_hidden",(({peerId:e})=>{e===this.chat.peerId&&this.pinnedMessageContainer.toggle(this.hidden=!0)})),this.setPinnedMessage=(0,j.Z)((()=>this._setPinnedMessage()),100,!0,!0),this.setCorrectIndexThrottled=(0,G.Z)(this.setCorrectIndex.bind(this),100,!1),this.isStatic=!this.chat.isPinnedMessagesNeeded()}destroy(){this.pinnedMessageContainer.divAndCaption.container.remove(),this.pinnedMessageContainer.toggle(!0),this.listenerSetter.removeAll(),this.unsetScrollDownListener(!1)}setCorrectIndex(e){if(this.isStatic)return;if(this.locked||this.hidden)return;if((this.loadedBottom||this.loadedTop)&&!this.count)return;const t=this.chat.bubbles.getBubbleByPoint("bottom");if(!t)return;const i=t.dataset.mid;t&&void 0!==i&&this.testMid(+i,e)}testMid(e,t){if(this.isStatic)return;if(this.hidden)return;let i=this.mids.findIndex((t=>t<=e));if(-1===i||this.isNeededMore(i)){if(!(this.loadedTop&&e<this.mids[this.mids.length-1]))return void(this.getCurrentIndexPromise||(this.getCurrentIndexPromise=this.getCurrentIndex(e,void 0!==t)));i=this.mids.length-1+this.offsetIndex}else i+=this.offsetIndex;if(this.pinnedIndex!==i){if(this.waitForScrollBottom&&void 0!==t&&(0===this.pinnedIndex||this.pinnedIndex>i))return;this.pinnedIndex=i,this.pinnedMid=this.mids.find((t=>t<=e))||this.mids[this.mids.length-1],this.setPinnedMessage()}}isNeededMore(e){return this.count>q.LOAD_COUNT&&(!this.loadedBottom&&e<=q.LOAD_OFFSET||!this.loadedTop&&this.count-1-e<=q.LOAD_OFFSET)}getCurrentIndex(e,t=!0){return K(this,void 0,void 0,(function*(){if(!this.loading){this.loading=!0;try{const i=this.debug?this.log.bindPrefix("getCurrentIndex"):void 0;i&&i("start",e,t);let s=!1;const n=[this.managers.appMessagesManager.getSearch({peerId:this.chat.peerId,inputFilter:{_:"inputMessagesFilterPinned"},maxId:e,limit:q.LOAD_COUNT,backLimit:q.LOAD_COUNT,threadId:this.chat.threadId}).then((e=>(s=!0,e)))];if(!this.pinnedMaxMid){const e=this.managers.appMessagesManager.getPinnedMessage(this.chat.peerId,this.chat.threadId).then((e=>{e.maxId&&(this.pinnedMaxMid=e.maxId,!s&&t&&(this.mids=[this.pinnedMaxMid],this.count=e.count,this.pinnedIndex=0,this.pinnedMid=this.mids[0],this.setPinnedMessage()))}));n.push(e)}const a=(yield Promise.all(n))[0];let o=a.history.findIndex((t=>t.mid<=e));-1===o&&(o=a.history.length),this.offsetIndex=a.offset_id_offset?a.offset_id_offset-o:0,this.mids=a.history.map((e=>e.mid)).slice(),this.count=a.count,this.count||this.pinnedMessageContainer.toggle(!0),this.loadedTop=this.offsetIndex+this.mids.length===this.count,this.loadedBottom=!this.offsetIndex,i&&i("result",e,a,o,this.offsetIndex,this.loadedTop,this.loadedBottom)}catch(e){this.log.error("getCurrentIndex error",e)}this.loading=!1,this.locked?this.testMid(e):t&&this.setCorrectIndex(0),this.getCurrentIndexPromise=null}}))}setScrollDownListener(){this.waitForScrollBottom=!0,this.scrollDownListenerSetter||(this.scrollDownListenerSetter=new U.Z,function(e,t,i,s){if(z.Z){let t;const n={passive:!0};s.add(e)("touchstart",(i=>{i.touches.length>1?o():(t=i.touches[0].clientY,s.add(e)("touchmove",a,n),s.add(e)("touchend",o,n))}),n);const a=e=>{const s=e.touches[0].clientY,n=s<t;!n||i(),t=s},o=()=>{s.removeManual(e,"touchmove",a,n),s.removeManual(e,"touchend",o,n)}}else s.add(e)("wheel",(e=>{const t=e.deltaY>0;!t||i()}),{passive:!0})}(this.chat.bubbles.scrollable.container,0,(()=>{this.unsetScrollDownListener()}),this.scrollDownListenerSetter))}unsetScrollDownListener(e=!0){this.waitForScrollBottom=!1,this.scrollDownListenerSetter&&(this.scrollDownListenerSetter.removeAll(),this.scrollDownListenerSetter=null),e&&this.setCorrectIndex(0)}handleFollowingPinnedMessage(){return K(this,void 0,void 0,(function*(){this.locked=!0,this.debug&&this.log("handleFollowingPinnedMessage");try{this.setScrollDownListener();const e=this.chat.setPeerPromise;e instanceof Promise&&(yield e),yield(0,H.e9)(),this.getCurrentIndexPromise&&(yield this.getCurrentIndexPromise),this.debug&&this.log("handleFollowingPinnedMessage: unlock"),this.locked=!1}catch(e){this.log.error("handleFollowingPinnedMessage error:",e),this.locked=!1,this.waitForScrollBottom=!1,this.setCorrectIndex(0)}}))}followPinnedMessage(e){return K(this,void 0,void 0,(function*(){(yield this.chat.getMessage(e))&&(this.chat.setMessageId(e),(this.chat.setPeerPromise||Promise.resolve()).then((()=>{this.handleFollowingPinnedMessage(),this.testMid(this.pinnedIndex>=this.count-1?this.pinnedMaxMid:e-1)})))}))}_setPinnedMessage(){return K(this,void 0,void 0,(function*(){const e=this.count;if(e){const t=this.pinnedIndex,i=yield this.chat.getMessage(this.pinnedMid),s=0===t;this.animatedCounter.container.classList.toggle("is-last",s),s||this.animatedCounter.setCount(e-t),this.pinnedMessageContainer.toggle(!1);const n=t>this.wasPinnedIndex;this.debug&&this.log("setPinnedMessage: fromTop",n,t,this.wasPinnedIndex);const a=this.animatedSubtitle.getRow(t),o=this.animatedMedia.getRow(t);o.classList.add("pinned-message-media");const r=[],d=yield(0,O.o)({title:void 0,titleEl:null,subtitle:i.message,subtitleEl:a,message:i,mediaEl:o,loadPromises:r,animationGroup:this.chat.animationGroup});yield Promise.all(r),this.pinnedMessageContainer.divAndCaption.container.classList.toggle("is-media",d),this.animatedSubtitle.animate(t,this.wasPinnedIndex),d?(this.animatedMedia.animate(t,this.wasPinnedMediaIndex),this.wasPinnedMediaIndex=t):this.animatedMedia.clearRows(),this.pinnedMessageBorder.render(e,e-t-1),this.wasPinnedIndex=t,this.pinnedMessageContainer.divAndCaption.container.dataset.mid=""+i.mid}else this.pinnedMessageContainer.toggle(!0),this.wasPinnedIndex=0;this.pinnedMessageContainer.divAndCaption.container.classList.toggle("is-many",this.count>1)}))}}q.LOAD_COUNT=50,q.LOAD_OFFSET=5;var Y=i(6194),Q=i(5824),X=i(8497),J=i(8799),ee=i(4668),te=i(2796),ie=i(2995),se=i(8127),ne=i(4240),ae=i(6818),oe=i(993),re=i(3897),de=i(7120),le=i(7362),ce=i(2059),he=i(3855),ue=i(9405),pe=i(1507),fe=i(2559),me=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class ge{constructor(e,t,i){this.chat=e,this.appSidebarRight=t,this.managers=i,this.verifyButtons=e=>{const t=!!e||!(!this.btnMore||!this.btnMore.classList.contains("menu-open"));e&&(0,C.Z)(e),(()=>{me(this,void 0,void 0,(function*(){const e=this.buttonsToVerify.concat(t?this.menuButtons:[]);(yield Promise.all(e.map((e=>me(this,void 0,void 0,(function*(){return{result:yield e.verify(),button:e}})))))).forEach((({button:e,result:t})=>{e.element.classList.toggle("hide",!t)}))}))})()},this.verifyVideoChatButton=e=>me(this,void 0,void 0,(function*(){var t;if(!ae.Z||this.peerId.isUser()||"chat"!==this.chat.type||this.chat.threadId)return!1;const i=ce.ZP.groupCall,s=this.peerId.toChatId();if((null==i?void 0:i.chatId)===s)return!1;if(e&&((yield this.managers.appPeersManager.isBroadcast(this.peerId))&&"group"===e||(yield this.managers.appPeersManager.isAnyGroup(this.peerId))&&"broadcast"===e))return!1;const n=yield this.managers.appChatsManager.getChat(s);return(null===(t=n.pFlags)||void 0===t?void 0:t.call_active)||(0,de.Z)(n,"manage_call")})),this.verifyCallButton=e=>me(this,void 0,void 0,(function*(){if(!oe.Z||!this.peerId.isUser())return!1;const t=this.peerId.toUserId(),i=yield this.managers.appProfileManager.getCachedFullUser(t);return!!i&&!!("voice"===e?i.pFlags.phone_calls_available:i.pFlags.video_calls_available)})),this.onJoinGroupCallClick=()=>{this.chat.appImManager.joinGroupCall(this.peerId)},this.onMuteClick=()=>{V.Z.createPopup(re.Z,this.peerId)},this.onResize=()=>{this.setUtilsWidth(!0),this.setFloating()},this.onChangeScreen=(e,t)=>{this.container.classList.toggle("is-pinned-floating",o.Z.isMobile),this.pinnedMessage&&this.pinnedMessage.pinnedMessageContainer.divAndCaption.container.classList.toggle("is-floating",t===o._.mobile),this.onResize()},this.setUtilsWidth=(e=!1)=>{this.setUtilsRAF&&window.cancelAnimationFrame(this.setUtilsRAF),f.IS_SAFARI&&e&&this.chatUtils.classList.add("hide"),this.setUtilsRAF=window.requestAnimationFrame((()=>{f.IS_SAFARI&&e&&this.chatUtils.classList.remove("hide");const t=this.chatUtils.getBoundingClientRect().width;this.chat.log("utils width:",t),this.container.style.setProperty("--utils-width",t+"px"),this.setUtilsRAF=0}))},this.setFloating=()=>{var e;const t=[this.chatAudio,null===(e=this.pinnedMessage)||void 0===e?void 0:e.pinnedMessageContainer].filter(Boolean).reduce(((e,t)=>{const i=t.isFloating();return this.container.classList.toggle(`is-pinned-${t.className}-floating`,i),t.isVisible()?e+ +i:e}),0);this.container.dataset.floating=""+t},this.setPeerStatusManual=(e=!1)=>me(this,void 0,void 0,(function*(){if(!this.subtitle||"chat"!==this.chat.type)return;if(this.chat.threadId){const e=yield(0,le.Z)({peerId:this.peerId,dialog:!0}),t=(0,k.ag)("TopicProfileStatus",[e]);return()=>(0,Z.Z)(this.subtitle,t)}const t=this.peerId;return this.chat.appImManager.setPeerStatus({peerId:t,element:this.subtitle,needClear:e,useWhitespace:!1,middleware:()=>t===this.peerId})})),this.setPeerStatus=e=>this.setPeerStatusManual(e).then((e=>{null==e||e()})),this.listenerSetter=new U.Z,this.menuButtons=[],this.buttonsToVerify=[]}construct(){this.container=document.createElement("div"),this.container.classList.add("sidebar-header","topbar","hide"),this.container.dataset.floating="0",this.btnBack=(0,v.Z)("left sidebar-close-button",{noRipple:!0}),this.btnBackBadge=document.createElement("span"),this.btnBackBadge.classList.add("badge","badge-20","badge-primary","back-unread-badge"),this.btnBack.append(this.btnBackBadge),this.chatInfoContainer=document.createElement("div"),this.chatInfoContainer.classList.add("chat-info-container"),this.chatInfo=document.createElement("div"),this.chatInfo.classList.add("chat-info");const e=this.person=document.createElement("div");e.classList.add("person");const t=document.createElement("div");t.classList.add("content");const i=document.createElement("div");i.classList.add("top"),this.title=document.createElement("div"),this.title.classList.add("user-title"),i.append(this.title);const s=document.createElement("div");s.classList.add("bottom"),this.subtitle&&s.append(this.subtitle),t.append(i,s),this.avatarElement&&e.append(this.avatarElement),e.append(t),this.chatInfo.append(e),this.chatUtils=document.createElement("div"),this.chatUtils.classList.add("chat-utils"),this.chatAudio=new F(this,this.chat,this.managers),this.menuButtons.length&&(this.btnMore=(0,b.Z)({listenerSetter:this.listenerSetter,direction:"bottom-left",buttons:this.menuButtons,onOpen:(e,t)=>me(this,void 0,void 0,(function*(){const e=this.menuButtons[this.menuButtons.length-1];if(null==e?void 0:e.element){const t=yield this.managers.appPeersManager.getDeleteButtonText(this.peerId);e.element.lastChild.replaceWith((0,k.ag)(t))}}))})),this.chatUtils.append(...[this.pinnedMessage?this.pinnedMessage.pinnedMessageContainer.divAndCaption.container:null,this.btnJoin,this.btnPinned,this.btnCall,this.btnGroupCall,this.btnMute,this.btnSearch,this.btnMore].filter(Boolean)),this.pushButtonToVerify(this.btnCall,this.verifyCallButton.bind(this,"voice")),this.pushButtonToVerify(this.btnGroupCall,this.verifyVideoChatButton),this.chatInfoContainer.append(this.btnBack,this.chatInfo,this.chatUtils),this.container.append(this.chatInfoContainer),this.chatAudio&&this.container.append(this.chatAudio.divAndCaption.container),this.listenerSetter.add(window)("resize",this.onResize),this.listenerSetter.add(o.Z)("changeScreen",this.onChangeScreen),(0,L.fc)(this.container,(e=>{const t=(0,X.Z)(e.target,"pinned-container");if((0,J.Z)(),t){if((0,C.Z)(e),(0,X.Z)(e.target,"progress-line")||(0,X.Z)(e.target,"pinned-container-wrapper-utils"))return;const i=+t.dataset.mid;if(t.classList.contains("pinned-message"))this.pinnedMessage.followPinnedMessage(i);else{const e=t.dataset.peerId.toPeerId(),s=y.Z.getSearchContext();this.chat.appImManager.setInnerPeer({peerId:e,lastMsgId:i,type:s.isScheduled?"scheduled":s.threadId?"discussion":void 0,threadId:s.threadId})}}else o.Z.activeScreen===o._.medium&&document.body.classList.contains(n.ir)?r():(0,ee.Z)(e.target,"AVATAR-ELEMENT")?this.appSidebarRight.toggleSidebar(!document.body.classList.contains(a.HQ)):this.appSidebarRight.toggleSidebar(!0)}),{listenerSetter:this.listenerSetter});const r=e=>{if(e&&(0,C.Z)(e),o.Z.activeScreen===o._.medium&&document.body.classList.contains(n.ir))this.chat.appImManager.setPeer({peerId:this.peerId});else{const e=0===this.chat.appImManager.chats.indexOf(this.chat);Q.Z.back(e?"im":"chat")}};(0,L.fc)(this.btnBack,r,{listenerSetter:this.listenerSetter})}pushButtonToVerify(e,t){e&&this.buttonsToVerify.push({element:e,verify:t})}constructUtils(){this.menuButtons=[{icon:"search",text:"Search",onClick:()=>{this.chat.initSearch()},verify:()=>o.Z.isMobile},{icon:"mute",text:"ChatList.Context.Mute",onClick:this.onMuteClick,verify:()=>me(this,void 0,void 0,(function*(){return"chat"===this.chat.type&&d.Z.myId!==this.peerId&&!(yield this.managers.appNotificationsManager.isPeerLocalMuted({peerId:this.peerId,respectType:!1,threadId:this.chat.threadId}))}))},{icon:"unmute",text:"ChatList.Context.Unmute",onClick:()=>{this.managers.appMessagesManager.togglePeerMute({peerId:this.peerId,threadId:this.chat.threadId})},verify:()=>me(this,void 0,void 0,(function*(){return"chat"===this.chat.type&&d.Z.myId!==this.peerId&&(yield this.managers.appNotificationsManager.isPeerLocalMuted({peerId:this.peerId,respectType:!1,threadId:this.chat.threadId}))}))},{icon:"comments",text:"ViewDiscussion",onClick:()=>{const e=this.chat.bubbles.getMiddleware();Promise.resolve(this.managers.appProfileManager.getChannelFull(this.peerId.toChatId())).then((t=>{e()&&t.linked_chat_id&&this.chat.appImManager.setInnerPeer({peerId:t.linked_chat_id.toPeerId(!0)})}))},verify:()=>me(this,void 0,void 0,(function*(){const e=yield this.managers.appProfileManager.getCachedFullChat(this.peerId.toChatId());return"chat"===this.chat.type&&!!(null==e?void 0:e.linked_chat_id)}))},{icon:"phone",text:"Call",onClick:this.onCallClick.bind(this,"voice"),verify:this.verifyCallButton.bind(this,"voice")},{icon:"videocamera",text:"VideoCall",onClick:this.onCallClick.bind(this,"video"),verify:this.verifyCallButton.bind(this,"video")},{icon:"videochat",text:"PeerInfo.Action.LiveStream",onClick:this.onJoinGroupCallClick,verify:this.verifyVideoChatButton.bind(this,"broadcast")},{icon:"videochat",text:"PeerInfo.Action.VoiceChat",onClick:this.onJoinGroupCallClick,verify:this.verifyVideoChatButton.bind(this,"group")},{icon:"select",text:"Chat.Menu.SelectMessages",onClick:()=>{const e=this.chat.selection;e.toggleSelection(!0,!0),he.Z.getState().then((t=>{if(t.chatContextMenuHintWasShown)return;const i=e.toggleByElement.bind(e);e.toggleByElement=t=>me(this,void 0,void 0,(function*(){this.managers.appStateManager.pushToState("chatContextMenuHintWasShown",!0),(0,te.Am)((0,k.ag)("Chat.Menu.Hint")),e.toggleByElement=i,e.toggleByElement(t)}))}))},verify:()=>!this.chat.selection.isSelecting&&!!this.chat.bubbles.getRenderedLength()},{icon:"select",text:"Chat.Menu.ClearSelection",onClick:()=>{this.chat.selection.cancelSelection()},verify:()=>this.chat.selection.isSelecting},{icon:"adduser",text:"AddContact",onClick:()=>{if(!this.appSidebarRight.isTabExists(ne.Z)){const e=this.appSidebarRight.createTab(ne.Z);e.peerId=this.peerId,e.open(),this.appSidebarRight.toggleSidebar(!0)}},verify:()=>me(this,void 0,void 0,(function*(){return this.peerId.isUser()&&!(yield this.managers.appPeersManager.isContact(this.peerId))}))},{icon:"forward",text:"ShareContact",onClick:()=>{const e=this.peerId;V.Z.createPopup(ie.Z,{peerTypes:["dialogs","contacts"],onSelect:t=>new Promise(((i,s)=>{V.Z.createPopup(se.Z,"",{titleLangKey:"SendMessageTitle",descriptionLangKey:"SendContactToGroupText",descriptionLangArgs:[new M.Z({peerId:t,dialog:!0}).element],buttons:[{langKey:"Send",callback:()=>{i(),this.managers.appMessagesManager.sendContact(t,e),this.chat.appImManager.setInnerPeer({peerId:t})}},{langKey:"Cancel",callback:()=>{s()},isCancel:!0}],peerId:t,overlayClosable:!0}).show()})),placeholder:"ShareModal.Search.Placeholder",chatRightsActions:["send_plain"],selfPresence:"ChatYourSelf"})},verify:()=>me(this,void 0,void 0,(function*(){return d.Z.myId!==this.peerId&&this.peerId.isUser()&&(yield this.managers.appPeersManager.isContact(this.peerId))&&!!(yield this.managers.appUsersManager.getUser(this.peerId.toUserId())).phone}))},{icon:"gift",text:"GiftPremium",onClick:()=>this.chat.appImManager.giftPremium(this.peerId),verify:()=>this.chat.canGiftPremium()},{icon:"bots",text:"Settings",onClick:()=>{this.managers.appMessagesManager.sendText(this.peerId,"/settings")},verify:()=>me(this,void 0,void 0,(function*(){var e;try{const t=yield this.managers.appAttachMenuBotsManager.getAttachMenuBot(this.peerId.toUserId());return!!(null===(e=null==t?void 0:t.pFlags)||void 0===e?void 0:e.has_settings)}catch(e){return!1}}))},{icon:"lock",text:"BlockUser",onClick:()=>{V.Z.createPopup(se.Z,"",{peerId:this.peerId,titleLangKey:"BlockUser",descriptionLangKey:"AreYouSureBlockContact2",descriptionLangArgs:[new M.Z({peerId:this.peerId}).element],buttons:[{langKey:"BlockUser",isDanger:!0,callback:()=>{this.managers.appUsersManager.toggleBlock(this.peerId,!0).then((e=>{e&&(0,te.bC)({langPackKey:"UserBlocked"})}))}}]}).show()},verify:()=>me(this,void 0,void 0,(function*(){var e;if(!this.peerId.isUser())return!1;const t=yield this.managers.appProfileManager.getCachedFullUser(this.peerId.toUserId());return this.peerId!==d.Z.myId&&t&&!(null===(e=t.pFlags)||void 0===e?void 0:e.blocked)}))},{icon:"lockoff",text:"Unblock",onClick:()=>{this.managers.appUsersManager.toggleBlock(this.peerId,!1).then((e=>{e&&(0,te.bC)({langPackKey:"UserUnblocked"})}))},verify:()=>me(this,void 0,void 0,(function*(){var e;const t=yield this.managers.appProfileManager.getCachedFullUser(this.peerId.toUserId());return!!(null===(e=null==t?void 0:t.pFlags)||void 0===e?void 0:e.blocked)}))},{icon:"delete danger",text:"Delete",onClick:()=>{V.Z.createPopup(Y.Z,this.peerId)},verify:()=>me(this,void 0,void 0,(function*(){return"chat"===this.chat.type&&!!(yield this.managers.appMessagesManager.getDialogOnly(this.peerId))}))}],this.btnSearch=(0,v.Z)("search"),this.attachClickEvent(this.btnSearch,(e=>{this.chat.initSearch()}),!0)}attachClickEvent(e,t,i){(0,L.fc)(e,(e=>{(0,C.Z)(e),!i&&(0,J.Z)(),t(e)}),{listenerSetter:this.listenerSetter})}onCallClick(e){this.chat.appImManager.callUser(this.peerId.toUserId(),e)}constructAvatar(){const e=new m.Z;return e.isDialog=!0,e.classList.add("avatar-42","person-avatar"),e}get peerId(){return this.chat.peerId}constructPeerHelpers(){return this.avatarElement=this.constructAvatar(),this.subtitle=document.createElement("div"),this.subtitle.classList.add("info"),this.pinnedMessage=new q(this,this.chat,this.managers),this.btnJoin=(0,g.Z)("btn-primary btn-color-primary chat-join hide"),this.btnCall=(0,v.Z)("phone"),this.btnGroupCall=(0,v.Z)("videochat"),this.btnPinned=(0,v.Z)("pinlist"),this.btnMute=(0,v.Z)("mute"),this.attachClickEvent(this.btnCall,this.onCallClick.bind(this,"voice")),this.attachClickEvent(this.btnGroupCall,this.onJoinGroupCallClick),this.attachClickEvent(this.btnPinned,(()=>{this.openPinned(!0)})),this.attachClickEvent(this.btnMute,this.onMuteClick),this.attachClickEvent(this.btnJoin,(()=>me(this,void 0,void 0,(function*(){const e=this.chat.bubbles.getMiddleware();this.btnJoin.setAttribute("disabled","true");const t=this.peerId.toChatId();let i;i=(yield this.managers.appChatsManager.isChannel(t))?this.managers.appChatsManager.joinChannel(t):this.managers.appChatsManager.addChatUser(t,d.Z.myId),i.finally((()=>{e()&&this.btnJoin.removeAttribute("disabled")}))})))),this.listenerSetter.add(d.Z)("folder_unread",(e=>{if(e.id!==pe.J$)return;const t=e.unreadUnmutedPeerIds.size;this.btnBackBadge.textContent=t?""+(0,fe.Z)(t,1):""})),this.listenerSetter.add(d.Z)("chat_update",(e=>me(this,void 0,void 0,(function*(){var t;if(this.peerId===e.toPeerId(!0)){const i=yield this.managers.appChatsManager.getChat(e);this.btnJoin.classList.toggle("hide",!(null===(t=null==i?void 0:i.pFlags)||void 0===t?void 0:t.left)),this.setUtilsWidth(),this.verifyButtons()}})))),this.listenerSetter.add(d.Z)("dialog_notify_settings",(e=>{e.peerId===this.peerId&&this.setMutedState()})),this.listenerSetter.add(d.Z)("peer_typings",(({peerId:e})=>{this.peerId===e&&this.setPeerStatus()})),this.listenerSetter.add(d.Z)("user_update",(e=>{this.peerId===e.toPeerId()&&this.setPeerStatus()})),this.listenerSetter.add(d.Z)("peer_full_update",(e=>{this.peerId===e&&this.verifyButtons()})),this.chat.addEventListener("setPeer",((e,t)=>{const i=this.chat.bubbles.getMiddleware();he.Z.getState().then((s=>{i()&&this.pinnedMessage&&(this.pinnedMessage.hidden=!!s.hiddenPinnedMessages[this.chat.peerId],t?(this.pinnedMessage.unsetScrollDownListener(),this.pinnedMessage.testMid(e,0)):this.pinnedMessage.locked||(this.pinnedMessage.handleFollowingPinnedMessage(),this.pinnedMessage.testMid(e)))}))})),this.listenerSetter.add(d.Z)("peer_pinned_messages",(({peerId:e,mids:t})=>{"pinned"===this.chat.type&&e===this.peerId&&t&&this.setTitle()})),this.setPeerStatusInterval=window.setInterval(this.setPeerStatus,6e4),this}openPinned(e){this.chat.appImManager.setInnerPeer({peerId:this.peerId,lastMsgId:e?+this.pinnedMessage.pinnedMessageContainer.divAndCaption.container.dataset.mid:0,type:"pinned"})}destroy(){var e,t;this.listenerSetter.removeAll(),window.clearInterval(this.setPeerStatusInterval),null===(e=this.pinnedMessage)||void 0===e||e.destroy(),null===(t=this.chatAudio)||void 0===t||t.destroy(),delete this.chatAudio,delete this.pinnedMessage}cleanup(){this.chat.peerId||this.container.classList.add("hide")}finishPeerChange(e){var t;return me(this,void 0,void 0,(function*(){const{peerId:e,threadId:i}=this.chat;let s;"chat"===this.chat.type&&(s=(null===(t=this.avatarElement)||void 0===t?void 0:t.peerId)!==this.peerId||this.avatarElement.threadId!==this.chat.threadId?this.constructAvatar():this.avatarElement);const[n,a,o,r,d,l,c]=yield Promise.all([this.managers.appPeersManager.isBroadcast(e),this.managers.appPeersManager.isAnyChat(e),e.isAnyChat()?this.managers.appChatsManager.getChat(e.toChatId()):void 0,s?s.updateWithOptions({peerId:e,threadId:i,wrapOptions:{customEmojiSize:(0,ue.C)(32,32)}}):void 0,this.setTitleManual(),this.setPeerStatusManual(!0),he.Z.getState()]);return()=>{var t,i;const r=!("pinned"===this.chat.type||"scheduled"===this.chat.type);this.btnMute&&this.btnMute.classList.toggle("hide",!n||!r),this.btnJoin&&(a&&!this.chat.isRestricted&&r?((0,Z.Z)(this.btnJoin,(0,k.ag)(n?"Chat.Subscribe":"ChannelJoin")),this.btnJoin.classList.toggle("hide",!(null===(t=null==o?void 0:o.pFlags)||void 0===t?void 0:t.left))):this.btnJoin.classList.add("hide")),this.btnSearch&&this.btnSearch.classList.toggle("hide",!r),this.btnPinned&&this.btnPinned.classList.toggle("hide",!r),this.avatarElement!==s&&(s&&(this.avatarElement?this.avatarElement.replaceWith(s):this.person.prepend(s)),null===(i=this.avatarElement)||void 0===i||i.remove(),this.avatarElement=s),this.setUtilsWidth(),this.verifyButtons(),this.btnMore&&this.btnMore.classList.toggle("hide",!r);const h=this.chat.isPinnedMessagesNeeded();if(h||"discussion"===this.chat.type){if(this.chat.wasAlreadyUsed||!this.pinnedMessage){const e=new q(this,this.chat,this.managers);this.pinnedMessage?(this.pinnedMessage.pinnedMessageContainer.divAndCaption.container.replaceWith(e.pinnedMessageContainer.divAndCaption.container),this.pinnedMessage.destroy()):this.chatUtils.prepend(this.pinnedMessage.pinnedMessageContainer.divAndCaption.container),this.pinnedMessage=e}h?this.pinnedMessage.hidden=!!c.hiddenPinnedMessages[e]:"discussion"===this.chat.type&&(this.pinnedMessage.pinnedMid=this.chat.threadId,this.pinnedMessage.count=1,this.pinnedMessage.pinnedIndex=0,this.pinnedMessage._setPinnedMessage())}else this.pinnedMessage&&(this.pinnedMessage.destroy(),this.pinnedMessage=void 0);d(),null==l||l(),this.subtitle.classList.toggle("hide",!l),this.setMutedState(),this.container.classList.remove("hide")}}))}setTitleManual(e){return me(this,void 0,void 0,(function*(){const{peerId:t,threadId:i}=this.chat,s=()=>this.chat.bubbles.getMiddleware();let n;if("pinned"===this.chat.type)n=void 0===e?(0,k.ag)("Loading"):(0,k.ag)("PinnedMessagesCount",[e]),void 0===e&&this.managers.appMessagesManager.getSearchCounters(t,[{_:"inputMessagesFilterPinned"}],!1).then((e=>{if(!s())return;const t=e[0].count;if(this.setTitle(t),!t){this.chat.appImManager.setPeer();const e=this.chat.appImManager.chat;e.topbar.pinnedMessage&&e.topbar.pinnedMessage.pinnedMessageContainer.toggle(!0)}}));else if("scheduled"===this.chat.type)n=(0,k.ag)(t===d.Z.myId?"Reminders":"ScheduledMessages");else if("discussion"===this.chat.type){if(void 0===e){const n=yield this.managers.acknowledged.appMessagesManager.getHistory(t,0,1,0,i);if(!s())return;if(n.cached){const t=yield n.result;if(!s())return;e=t.count}else n.result.then((e=>{s()&&this.setTitle(e.count)}))}n=void 0===e?(0,k.ag)("Loading"):(0,k.ag)("Chat.Title.Comments",[e])}else if("chat"===this.chat.type&&([n]=yield Promise.all([(0,le.Z)({peerId:t,dialog:!0,withIcons:!i,threadId:i})]),!s()))return;return()=>{(0,Z.Z)(this.title,n)}}))}setTitle(e){this.setTitleManual(e).then((e=>e()))}setMutedState(){return me(this,void 0,void 0,(function*(){if(!this.btnMute)return;const e=this.peerId,t=yield this.managers.appNotificationsManager.isPeerLocalMuted({peerId:e,respectType:!1,threadId:this.chat.threadId});(yield this.managers.appPeersManager.isBroadcast(e))?(this.btnMute.classList.remove("tgico-mute","tgico-unmute"),this.btnMute.classList.add(t?"tgico-unmute":"tgico-mute"),this.btnMute.style.display=""):this.btnMute.style.display="none"}))}}var ve=i(9099),be=i(5884),ye=i(3607),we=i(2986),Se=i(3552);class Ce extends Se._{constructor(){super(...arguments),this.threadId=0,this.query=""}onOpenAfterTimeout(){this.appSearch.beginSearch(this.peerId,this.threadId,this.query)}init(e,t,i,s){this.container.id="search-private-container",this.container.classList.add("chatlist-container"),this.inputSearch=new ye.Z("Search"),this.title.replaceWith(this.inputSearch.container),this.btnPickDate=(0,v.Z)("calendar sidebar-header-right"),this.header.append(this.btnPickDate);const n=document.createElement("div");n.classList.add("chatlist-container"),this.scrollable.container.replaceWith(n),this.appSearch=new be.Z(n,this.inputSearch,{messages:new be.z("Chat.Search.PrivateSearch","messages")}),this.peerId?this.appSearch.beginSearch(this.peerId,this.threadId,s):(this.query=s,this.peerId=e,this.threadId=t,this.onDatePick=i,this.btnPickDate.classList.toggle("hide",!this.onDatePick),this.onDatePick&&(0,L.fc)(this.btnPickDate,(()=>{V.Z.createPopup(we.Z,new Date,this.onDatePick).show()})),s&&this.appSearch.searchInput.inputField.setValueSilently(s),a.ZP.toggleSidebar(!0))}}var Le=i(6740),Ee=i(2648),Ie=i(5005);class Pe{constructor(e,t,i){this.topbar=e,this.chat=t,this.foundCount=0,this.selectedIndex=0,this.onDateClick=e=>{(0,C.Z)(e),V.Z.createPopup(we.Z,new Date,this.chat.bubbles.onDatePick).show()},this.onResultsClick=e=>{const t=(0,ee.Z)(e.target,Ie.DIALOG_LIST_ELEMENT_TAG);t&&this.selectResult(t)},this.onFooterClick=e=>{this.foundCount&&(this.chat.bubbles.container.classList.toggle("search-results-active"),this.results.classList.toggle("active"))},this.onUpClick=e=>{(0,C.Z)(e),this.selectResult(this.searchGroup.list.children[this.selectedIndex+1])},this.onDownClick=e=>{(0,C.Z)(e),this.selectResult(this.searchGroup.list.children[this.selectedIndex-1])},this.element=document.createElement("div"),this.element.classList.add("sidebar-header","chat-search","chatlist-container"),this.backBtn=document.createElement("button"),this.backBtn.classList.add("btn-icon","tgico-left","sidebar-close-button"),(0,S.Z)(this.backBtn);const s=this.listenerSetter=new U.Z,n=(e,t)=>{(0,L.fc)(e,t,{listenerSetter:s})};n(this.backBtn,(()=>{this.destroy()})),this.inputSearch=new ye.Z("Search"),this.results=document.createElement("div"),this.results.classList.add("chat-search-results","chatlist-container"),this.searchGroup=new be.z(!1,"messages",void 0,"",!1),n(this.searchGroup.list,this.onResultsClick),this.appSearch=new be.Z(this.results,this.inputSearch,{messages:this.searchGroup},(e=>{this.foundCount=e,this.foundCount?this.selectResult(this.searchGroup.list.children[0]):((0,Z.Z)(this.foundCountEl,this.inputSearch.value?(0,k.ag)("NoResult"):""),this.results.classList.remove("active"),this.chat.bubbles.container.classList.remove("search-results-active"),this.upBtn.setAttribute("disabled","true"),this.downBtn.setAttribute("disabled","true"))})),this.appSearch.beginSearch(this.chat.peerId,this.chat.threadId),this.chat.bubbles.container.append(this.results),this.footer=document.createElement("div"),this.footer.classList.add("chat-search-footer"),n(this.footer,this.onFooterClick),(0,S.Z)(this.footer),this.foundCountEl=document.createElement("span"),this.foundCountEl.classList.add("chat-search-count"),this.dateBtn=document.createElement("button"),this.dateBtn.classList.add("btn-icon","tgico-calendar"),this.controls=document.createElement("div"),this.controls.classList.add("chat-search-controls"),this.upBtn=document.createElement("button"),this.upBtn.classList.add("btn-icon","tgico-up"),this.downBtn=document.createElement("button"),this.downBtn.classList.add("btn-icon","tgico-down"),this.upBtn.setAttribute("disabled","true"),this.downBtn.setAttribute("disabled","true"),n(this.dateBtn,this.onDateClick),n(this.upBtn,this.onUpClick),n(this.downBtn,this.onDownClick),this.controls.append(this.upBtn,this.downBtn),this.footer.append(this.foundCountEl,this.dateBtn,this.controls),this.topbar.container.parentElement.insertBefore(this.footer,t.input.chatInput),this.element.append(this.backBtn,this.inputSearch.container),this.topbar.container.classList.add("hide-pinned"),this.topbar.container.parentElement.append(this.element),this.inputSearch.input.focus(),i&&this.setQuery(i),f.IS_MOBILE_SAFARI||(this.navigationItem={type:"mobile-search",onPop:()=>{this.destroy()}},Q.Z.pushItem(this.navigationItem))}destroy(){this.topbar.container.classList.remove("hide-pinned"),this.element.remove(),this.inputSearch.remove(),this.results.remove(),this.footer.remove(),this.listenerSetter.removeAll(),this.chat.bubbles.container.classList.remove("search-results-active"),this.chat.search=void 0,Q.Z.removeItem(this.navigationItem)}setQuery(e){this.inputSearch.inputField.value=e}selectResult(e){if(this.setPeerPromise)return this.setPeerPromise;const t=e.dataset.peerId.toPeerId(),i=+e.dataset.mid||void 0,s=(0,Ee.Z)(e);s===this.foundCount-1?this.upBtn.setAttribute("disabled","true"):this.upBtn.removeAttribute("disabled"),s?this.downBtn.removeAttribute("disabled"):this.downBtn.setAttribute("disabled","true"),this.results.classList.remove("active"),this.chat.bubbles.container.classList.remove("search-results-active");const n=this.chat.setPeer({peerId:t,lastMsgId:i});this.setPeerPromise=(n instanceof Promise?n:Promise.resolve(n)).then((()=>{this.selectedIndex=s,(0,Z.Z)(this.foundCountEl,(0,k.ag)("Of",[s+1,this.foundCount]));const e=this.searchGroup.list.childElementCount;this.selectedIndex>=e-6&&this.appSearch.searchMore()})).finally((()=>{this.setPeerPromise=null}))}}var Ze=i(1571),Me=i(1655),ke=i(6848),Te=i(241),xe=i(356);class Ae{constructor(){this.canvases=new Set}static getInstance(e){let t=this.INSTANCES.find((t=>(0,ke.Z)(t.options,e)));return t||(t=new Ae,t.init(e),this.INSTANCES.push(t)),t}init(e){this.options=e}renderToCanvas(e){return this.renderImageFromUrl(this.options.url).then((()=>this.fillCanvas(e)))}renderImageFromUrl(e){if(this.renderImageFromUrlPromise)return this.renderImageFromUrlPromise;const t=this.image=document.createElement("img");return t.crossOrigin="anonymous",this.renderImageFromUrlPromise=(0,Le.cj)(t,e,!1).then((()=>xe.Z?createImageBitmap(t,{resizeWidth:1440,resizeHeight:2960}).then((e=>(this.imageBitmap=e,t))):t))}cleanup(e){var t;this.canvases.delete(e),this.canvases.size||((0,Me.Z)(Ae.INSTANCES,this),this.objectUrl&&(null===(t=this.imageBitmap)||void 0===t||t.close(),URL.revokeObjectURL(this.objectUrl)))}fillCanvas(e){const t=e.getContext("2d"),{width:i,height:s}=e,n=this.imageBitmap||this.image;let a=n.width,o=n.height;const r=(500+Te.Z.height/2.5)*e.dpr;a*=r/o,o=r,this.options.mask?(t.fillStyle="#000",t.fillRect(0,0,i,s),t.globalCompositeOperation="destination-out"):t.globalCompositeOperation="source-over";const d=e=>{for(let s=0;s<i;s+=a)t.drawImage(n,s,e,a,o)},l=(s-o)/2;if(d(l),l>0){let e=l;do{d(e-=o)}while(e>=0)}const c=s-1;for(let e=l+o;e<c;e+=o)d(e)}setCanvasDimensions(e){const t=Math.min(2,window.devicePixelRatio),i=this.options.width*t;let s=this.options.height*t;e.dpr=t,e.dataset.originalHeight=""+s,o.Z.activeScreen===o._.large&&(s*=1.5),e.width=i,e.height=s}createCanvas(){const e=document.createElement("canvas");return this.canvases.add(e),this.setCanvasDimensions(e),e}resize(e,t){this.init(Object.assign(Object.assign({},this.options),{width:e,height:t}));const i=[];for(const e of this.canvases)this.setCanvasDimensions(e),i.push(this.renderToCanvas(e));return Promise.all(i)}static resizeInstances(e,t){return Promise.all(this.INSTANCES.map((i=>i.resize(e,t))))}}Ae.INSTANCES=[];var _e=i(5418),Fe=i(252),De=i(6714),Re=i(319),Be=i(2064),Ne=i(5994),Oe=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class Ue extends l.Z{constructor(e,t){super(),this.appImManager=e,this.managers=t,this.type="chat",this.animationGroup=`chat-${Math.round(65535*Math.random())}`,this.container=document.createElement("div"),this.container.classList.add("chat","tabs-tab"),this.backgroundEl=document.createElement("div"),this.backgroundEl.classList.add("chat-background"),this.log=(0,r.kg)("CHAT",r.v9.Log|r.v9.Warn|r.v9.Debug|r.v9.Error),this.log.warn("constructor"),this.peerId=pe.NM,this.container.append(this.backgroundEl),this.appImManager.chatsContainer.append(this.container),this.backgroundTempId=0,this.sharedMediaTabs=[]}setBackground(e,t){var i;const s=De.Z.getTheme().settings.wallpaper,n=(0,Be.EM)(s);let a;if(n&&!s.slug&&!s.settings.intensity&&"grabbing"===document.documentElement.style.cursor&&this.gradientRenderer&&!this.patternRenderer)return this.gradientCanvas.dataset.colors=n,this.gradientRenderer.init(this.gradientCanvas),Promise.resolve();const o=++this.backgroundTempId,r=this.gradientRenderer,d=this.patternRenderer,l=(this.gradientCanvas,this.patternCanvas);this.gradientRenderer=this.patternRenderer=this.gradientCanvas=this.patternCanvas=void 0;const c=(null===(i=s.settings)||void 0===i?void 0:i.intensity)&&s.settings.intensity/100,h=!!c&&c<0;let u,p,f,m=null==a?void 0:a.firstElementChild;if(!a)if(a=document.createElement("div"),a.classList.add("chat-background-item"),e)if(c){a.classList.add("is-pattern");const t=this.appImManager.chatsContainer.getBoundingClientRect();u=this.patternRenderer=Ae.getInstance({url:e,width:t.width,height:t.height,mask:h}),m=this.patternCanvas=u.createCanvas(),m.classList.add("chat-background-item-canvas","chat-background-item-pattern-canvas"),h&&a.classList.add("is-dark")}else a.classList.add("is-image");else a.classList.add("is-color");if(n){const{canvas:e,gradientRenderer:t}=Ze.Z.create(n);f=this.gradientRenderer=t,p=this.gradientCanvas=e,p.classList.add("chat-background-item-canvas","chat-background-item-color-canvas"),Ne.Z.isAvailable("animations")&&f.scrollAnimate(!0)}if(u){const e=h?p:m;let t=Math.abs(c)*(h?.5:1);h&&(t=Math.max(.3,t)),e.style.setProperty("--opacity-max",""+t)}const g=new Promise((i=>{const s=()=>{if(this.backgroundTempId!==o)return u&&u.cleanup(m),void(f&&f.cleanup());const e=this.backgroundEl.lastElementChild;if(e===a)return void i();const s=[p,m].filter(Boolean);s.length&&a.append(...s),this.backgroundEl.append(a),(0,ve.Z)({element:a,className:"is-visible",forwards:!0,duration:t?0:200,onTransitionEnd:e?()=>{null==d||d.cleanup(l),null==r||r.cleanup(),e.remove()}:null,useRafs:2}),i()};u?u.renderToCanvas(m).then((()=>{this.backgroundTempId===o&&s()})):e?(0,Le.ZP)(a,e,s):s()}));return this.setBackgroundPromise=Promise.race([(0,_e.Z)(500),g])}setType(e){this.type=e}init(){this.topbar=new ge(this,a.ZP,this.managers),this.bubbles=new c.ZP(this,this.managers),this.input=new u.Z(this,this.appImManager,this.managers),this.contextMenu=new h.Z(this,this.managers),this.selection=new p.Z(this,this.bubbles,this.input,this.managers),this.topbar.constructUtils(),this.topbar.constructPeerHelpers(),this.topbar.construct(),this.input.construct(),this.bubbles.constructPeerHelpers(),this.input.constructPeerHelpers(),z.Z||this.bubbles.setReactionsHoverListeners(),this.bubbles.attachContainerListeners(),this.container.append(this.topbar.container,this.bubbles.container,this.input.chatInput),this.bubbles.listenerSetter.add(d.Z)("dialog_migrate",(({migrateFrom:e,migrateTo:t})=>{this.peerId===e&&this.setPeer({peerId:t})})),this.bubbles.listenerSetter.add(d.Z)("dialog_drop",(e=>{e.peerId!==this.peerId||"dialog"!==e._&&this.threadId!==e.id||this.appImManager.setPeer()})),this.bubbles.listenerSetter.add(d.Z)("chat_update",(e=>Oe(this,void 0,void 0,(function*(){const{peerId:t}=this;if(t.isAnyChat()&&t.toChatId()===e){const e=yield this.managers.appMessagesManager.isAnonymousSending(t);t===this.peerId&&(this.isAnonymousSending=e)}}))));const e=e=>{const t=()=>{var t;null===(t=this.bubbles.observer)||void 0===t||t.toggleObservingNew(e),s.Z.toggleIntersectionGroup(this.animationGroup,e),e&&s.Z.checkAnimations(e,this.animationGroup)};e?t():setTimeout((()=>{t()}),400)};this.bubbles.listenerSetter.add(this.appImManager)("chat_changing",(({to:t})=>{e(t!==this)})),this.bubbles.listenerSetter.add(this.appImManager)("tab_changing",(t=>{e(this.appImManager.chat!==this||t!==ys.CHAT&&o.Z.activeScreen===o._.mobile)}))}beforeDestroy(){this.bubbles.cleanup()}cleanupBackground(){++this.backgroundTempId,this.patternRenderer&&(this.patternRenderer.cleanup(this.patternCanvas),this.patternRenderer=void 0),this.gradientRenderer&&(this.gradientRenderer.cleanup(),this.gradientRenderer=void 0)}destroy(){this.destroySharedMediaTab(),this.topbar.destroy(),this.bubbles.destroy(),this.input.destroy(),this.contextMenu&&this.contextMenu.destroy(),this.selection&&this.selection.attachListeners(void 0,void 0),this.cleanupBackground(),delete this.topbar,delete this.bubbles,delete this.input,delete this.selection,delete this.contextMenu,this.container.remove()}cleanup(e=!0){this.input.cleanup(e),this.topbar.cleanup(),this.selection.cleanup()}get isForumTopic(){return!(!this.isForum||!this.threadId)}onChangePeer(e,t){var i;return Oe(this,void 0,void 0,(function*(){const{peerId:s,threadId:n}=this,o=a.ZP.getTab(Ce);null==o||o.close();const[r,d,l,c,h,u,p,f,m,g]=yield t(Promise.all([this.managers.appPeersManager.noForwards(s),this.managers.appPeersManager.isPeerRestricted(s),this._isAnyGroup(s),this.setAutoDownloadMedia(),this.managers.appPeersManager.isMegagroup(s),this.managers.appPeersManager.isBroadcast(s),this.managers.appPeersManager.isChannel(s),this.managers.appPeersManager.isBot(s),this.managers.appPeersManager.isForum(s),this.managers.appMessagesManager.isAnonymousSending(s)]));m&&n&&(yield t(this.managers.dialogsStorage.getForumTopicOrReload(s,n))),this.noForwards=r,this.isRestricted=d,this.isAnyGroup=l,this.isMegagroup=h,this.isBroadcast=u,this.isChannel=p,this.isBot=f,this.isForum=m,this.isAllMessagesForum=m&&!n,this.isAnonymousSending=g,n&&!this.isForum&&(e.type="discussion");const v=null!==(i=e.type)&&void 0!==i?i:"chat";this.setType(v),this.messagesStorageKey=`${this.peerId}_${"scheduled"===this.type?"scheduled":"history"}`,this.container.classList.toggle("no-forwards",this.noForwards),this.sharedMediaTab=a.ZP.createSharedMediaTab(),this.sharedMediaTabs.push(this.sharedMediaTab),this.sharedMediaTab.setPeer(s,n),this.input.clearHelper(),this.selection.cleanup()}))}setPeer(e){const{peerId:t,threadId:i}=e;t?this.inited||(this.init&&(this.init(),this.init=null),this.inited=!0):this.inited=void 0;const s=this.appImManager.isSamePeer(this,e);if(s){if(this.setPeerPromise)return}else this.appImManager.dispatchEvent("peer_changing",this),this.peerId=t||pe.NM,this.threadId=i;if(!t)return a.ZP.toggleSidebar(!1),this.cleanup(!0),this.bubbles.setPeer({samePeer:!1,peerId:t}),this.peerId=0,this.appImManager.dispatchEvent("peer_changed",this),a.ZP.replaceSharedMediaTab(),this.destroySharedMediaTab(),void(this.sharedMediaTab=void 0);this.peerChanged=s;const n=this.bubbles.setPeer(Object.assign(Object.assign({},e),{samePeer:s})),o=this.setPeerPromise=n.then((e=>e.promise)).catch(Re.Z).finally((()=>{this.setPeerPromise===o&&(this.setPeerPromise=null)}));return n}destroySharedMediaTab(e=this.sharedMediaTab){e&&((0,Me.Z)(this.sharedMediaTabs,e),e.destroy())}setAutoDownloadMedia(){return Oe(this,void 0,void 0,(function*(){this.autoDownload=yield function(e){return t=this,i=void 0,n=function*(){let t,i=0,s=0,n=0;const a=d.Z.settings,o=d.Z.managers.appPeersManager;return!a.autoDownloadNew.pFlags.disabled&&e&&(t=e.isUser()?(yield o.isContact(e))?"contacts":"private":(yield o.isBroadcast(e))?"channels":"groups",a.autoDownload.photo[t]&&(i=a.autoDownloadNew.photo_size_max),a.autoDownload.video[t]&&(s=a.autoDownloadNew.video_size_max),a.autoDownload.file[t]&&(n=a.autoDownloadNew.file_size_max)),{photo:i,video:s,file:n}},new((s=void 0)||(s=Promise))((function(e,a){function o(e){try{d(n.next(e))}catch(e){a(e)}}function r(e){try{d(n.throw(e))}catch(e){a(e)}}function d(t){var i;t.done?e(t.value):(i=t.value,i instanceof s?i:new s((function(e){e(i)}))).then(o,r)}d((n=n.apply(t,i||[])).next())}));var t,i,s,n}(this.peerId)}))}setMessageId(e,t){return this.setPeer({peerId:this.peerId,threadId:this.threadId,lastMsgId:e,mediaTimestamp:t})}finishPeerChange(e){return Oe(this,void 0,void 0,(function*(){if(this.peerChanged)return;const t=this.peerId;this.peerChanged=!0,this.wasAlreadyUsed=!0;const{middleware:i}=e;this.cleanup(!1);const s=this.sharedMediaTab,n=Promise.all([this.topbar.finishPeerChange(e),this.bubbles.finishPeerChange(),this.input.finishPeerChange(e),s.fillProfileElements()]),o=yield n;s.loadSidebarMedia(!0),i()&&(o.forEach((e=>{null==e||e()})),a.ZP.replaceSharedMediaTab(s),this.sharedMediaTabs.filter((e=>e!==s)).forEach((e=>this.destroySharedMediaTab(e))),this.container.dataset.type=this.type,this.log.setPrefix("CHAT-"+t+"-"+this.type),this.appImManager.dispatchEvent("peer_changed",this))}))}getMessage(e){return this.managers.appMessagesManager.getMessageFromStorage(this.messagesStorageKey,e)}getMidsByMid(e){return Oe(this,void 0,void 0,(function*(){return this.managers.appMessagesManager.getMidsByMessage(yield this.getMessage(e))}))}getHistoryStorage(e){return this.managers.appMessagesManager.getHistoryStorageTransferable(this.peerId,e?void 0:this.threadId).then((e=>Object.assign(Object.assign({},e),{history:Fe.Z.fromJSON(e.historySerialized)})))}getDialogOrTopic(){return this.isForum&&this.threadId?this.managers.dialogsStorage.getForumTopic(this.peerId,this.threadId):this.managers.dialogsStorage.getDialogOnly(this.peerId)}getHistoryMaxId(){return this.getHistoryStorage().then((e=>e.maxId))}_isAnyGroup(e){return Oe(this,void 0,void 0,(function*(){return e===d.Z.myId||e===pe.hj||(yield this.managers.appPeersManager.isAnyGroup(e))}))}initSearch(e){if(this.peerId)if(o.Z.isMobile)this.search?this.search.setQuery(e):this.search=new Pe(this.topbar,this,e);else{let t=a.ZP.getTab(Ce);t||(t=a.ZP.createTab(Ce)),t.open(this.peerId,this.threadId,this.bubbles.onDatePick,e)}}canSend(e){return this.managers.appMessagesManager.canSendToPeer(this.peerId,this.threadId,e)}isStartButtonNeeded(){return Promise.all([this.managers.appPeersManager.isBot(this.peerId),this.managers.appMessagesManager.getDialogOnly(this.peerId),this.getHistoryStorage(!0)]).then((([e,t,i])=>e&&!t&&!i.history.length))}getMessageSendingParams(){return{threadId:this.threadId,replyToMsgId:this.input.replyToMsgId,scheduleDate:this.input.scheduleDate,silent:this.input.sendSilent,sendAsPeerId:this.input.sendAsPeerId,updateStickersetOrder:d.Z.settings.stickers.dynamicPackOrder}}isOurMessage(e){return e.fromId===d.Z.myId||!!e.pFlags.out&&this.isMegagroup}isOutMessage(e){const t=e.fwd_from;return!(!this.isOurMessage(e)||t&&this.peerId===d.Z.myId)}isAvatarNeeded(e){return this.isAnyGroup&&!this.isOutMessage(e)}isPinnedMessagesNeeded(){return"chat"===this.type||this.isForum}canGiftPremium(){return this.peerId.isUser()&&this.managers.appProfileManager.canGiftPremium(this.peerId.toUserId())}}var He=i(805),ze=i(1452),je=i(8204),Ge=i(3228),Ve=i(2342),Ke=i(6637),We=i(7545);class $e{constructor(e){this.appImManager=e,this.buttons={},this.addedListener=!1,this.waitingForMouseUp=!1,this.mouseUpCounter=0,this.onMouseUpSingle=e=>{if(this.waitingForMouseUp=!1,z.Z){if(e&&(0,C.Z)(e),0!=this.mouseUpCounter++)return void this.hide();this.resetSelection(this.savedRange)}this.show()}}init(){this.container=document.createElement("div"),this.container.classList.add("markup-tooltip","z-depth-1","hide"),this.wrapper=document.createElement("div"),this.wrapper.classList.add("markup-tooltip-wrapper");const e=document.createElement("div"),t=document.createElement("div");e.classList.add("markup-tooltip-tools"),t.classList.add("markup-tooltip-tools"),["bold","italic","underline","strikethrough","monospace","spoiler","link"].forEach((t=>{const i=(0,v.Z)(t,{noRipple:!0});e.append(this.buttons[t]=i),"link"!==t?i.addEventListener("mousedown",(e=>{(0,C.Z)(e),this.appImManager.chat.input.applyMarkdown(t),this.cancelClosening()})):(0,L.fc)(i,(e=>{(0,C.Z)(e),this.showLinkEditor(),this.cancelClosening()}))})),this.linkBackButton=(0,v.Z)("left",{noRipple:!0}),this.linkInput=document.createElement("input"),(0,k.$d)(this.linkInput,"MarkupTooltip.LinkPlaceholder",void 0,"placeholder"),this.linkInput.classList.add("input-clear"),this.linkInput.addEventListener("keydown",(e=>{const t=!this.linkInput.value.length||!!(0,Ve.Z)(this.linkInput.value);"Enter"===e.key&&(t?this.applyLink(e):(this.linkInput.classList.contains("error")&&(this.linkInput.classList.remove("error"),this.linkInput.offsetLeft),this.linkInput.classList.add("error")))})),this.linkInput.addEventListener("input",(e=>{const t=this.isLinkValid();this.linkInput.classList.toggle("is-valid",t),this.linkInput.classList.remove("error")})),this.linkBackButton.addEventListener("mousedown",(e=>{(0,C.Z)(e),this.container.classList.remove("is-link"),this.resetSelection(),this.setTooltipPosition(),this.cancelClosening()})),this.linkApplyButton=(0,v.Z)("check markup-tooltip-link-apply",{noRipple:!0}),this.linkApplyButton.addEventListener("mousedown",(e=>{this.applyLink(e)}));const i=document.createElement("div");i.classList.add("markup-tooltip-link-apply-container");const s=document.createElement("span"),n=document.createElement("span"),a=document.createElement("span");s.classList.add("markup-tooltip-delimiter"),n.classList.add("markup-tooltip-delimiter"),a.classList.add("markup-tooltip-delimiter"),e.insertBefore(s,this.buttons.link),i.append(a,this.linkApplyButton),t.append(this.linkBackButton,n,this.linkInput,i),this.wrapper.append(e,t),this.container.append(this.wrapper),document.body.append(this.container),window.addEventListener("resize",(()=>{this.hide()}))}showLinkEditor(){this.container&&this.container.classList.contains("is-visible")||this.show();const e=this.buttons.link;this.container.classList.add("is-link");const t=document.getSelection();if(this.savedRange=t.getRangeAt(0),e.classList.contains("active")){const e=this.savedRange.startContainer.parentElement;this.linkInput.value=e.href}else this.linkInput.value="";this.setTooltipPosition(!0),setTimeout((()=>{this.linkInput.focus()}),200),this.linkInput.classList.toggle("is-valid",this.isLinkValid())}applyLink(e){(0,C.Z)(e),this.resetSelection();let t=this.linkInput.value;t&&!(0,Ke.Z)(t)&&(t="https://"+t),this.appImManager.chat.input.applyMarkdown("link",t),setTimeout((()=>{this.hide()}),0)}isLinkValid(){return!this.linkInput.value.length||!!(0,Ve.Z)(this.linkInput.value)}resetSelection(e=this.savedRange){const t=window.getSelection();t.removeAllRanges(),t.addRange(e),this.appImManager.chat.input.messageInput.focus()}hide(){this.init||(this.container.classList.remove("is-visible"),document.removeEventListener("mouseup",this.onMouseUpSingle),this.waitingForMouseUp=!1,Q.Z.removeByType("markup"),this.hideTimeout&&clearTimeout(this.hideTimeout),this.hideTimeout=window.setTimeout((()=>{this.hideTimeout=void 0,this.container.classList.add("hide"),this.container.classList.remove("is-link")}),200))}getActiveMarkupButton(){const e=new Set,t=Object.keys(this.buttons),i=(0,We.Z)(t);return t.forEach((t=>{i[t]&&e.add(this.buttons[t])})),[...e]}setActiveMarkupButton(){const e=this.getActiveMarkupButton();for(const t in this.buttons){const i=this.buttons[t];i.classList.toggle("active",e.includes(i))}}setTooltipPosition(e=!1){const t=document.getSelection().getRangeAt(0),i=document.body.getBoundingClientRect(),s=t.getBoundingClientRect(),n=this.appImManager.chat.input.rowsWrapper.getBoundingClientRect();this.container.style.maxWidth=n.width+"px";const a=(0,je.Z)(void 0,this.appImManager.chat.input.messageInput,!1,s).rect.top+-1*i.top,o=(this.container.classList.contains("is-link")?this.wrapper.lastElementChild:this.wrapper.firstElementChild).getBoundingClientRect(),r=a-o.height-8,d=n.left,l=n.left+n.width-Math.min(n.width,o.width);let c;if(e){const e=this.container.getBoundingClientRect();c=(0,Ge.Z)(e.left,d,l)}else{const e=s.left+(s.width-o.width)/2;c=(0,Ge.Z)(e,d,l)}this.container.style.transform=`translate3d(${c}px, ${r}px, 0)`}show(){if(this.init&&(this.init(),this.init=null),(0,ze.Z)())return void this.hide();if(void 0!==this.hideTimeout&&clearTimeout(this.hideTimeout),this.container.classList.contains("is-visible"))return;this.setActiveMarkupButton(),this.container.classList.remove("is-link");const e=this.container.classList.contains("hide");e&&(this.container.classList.remove("hide"),this.container.classList.add("no-transition")),this.setTooltipPosition(),e&&(this.container.offsetLeft,this.container.classList.remove("no-transition")),this.container.classList.add("is-visible"),f.IS_MOBILE||Q.Z.pushItem({type:"markup",onPop:()=>{this.hide()}})}setMouseUpEvent(){this.waitingForMouseUp||(this.waitingForMouseUp=!0,document.addEventListener("mouseup",this.onMouseUpSingle,{once:!0}))}cancelClosening(){z.Z&&!f.IS_APPLE&&(document.removeEventListener("mouseup",this.onMouseUpSingle),document.addEventListener("mouseup",(e=>{(0,C.Z)(e),this.mouseUpCounter=1,this.waitingForMouseUp=!1,this.setMouseUpEvent()}),{once:!0}))}handleSelection(){this.addedListener||(this.addedListener=!0,document.addEventListener("selectionchange",(e=>{if(document.activeElement===this.linkInput)return;const t=this.appImManager.chat.input.messageInput;if(document.activeElement!==t)return void this.hide();const i=document.getSelection();if((0,ze.Z)(i))this.hide();else if(z.Z)if(f.IS_APPLE)this.show(),this.setTooltipPosition();else{if(2===this.mouseUpCounter)return void(this.mouseUpCounter=0);this.savedRange=i.getRangeAt(0),this.setMouseUpEvent()}else this.container&&this.container.classList.contains("is-visible")?(this.setActiveMarkupButton(),this.setTooltipPosition()):t.matches(":active")?this.setMouseUpEvent():this.show()})),document.addEventListener("beforeinput",(e=>{"historyRedo"!==e.inputType&&"historyUndo"!==e.inputType||e.target.addEventListener("input",(()=>this.setActiveMarkupButton()),{once:!0})})))}}var qe=i(9171);class Ye{constructor(e,t){let i;this.options=t,this.onDragOver=e=>{this.container.classList.add("is-dragover")},this.onDragLeave=e=>{this.container.classList.remove("is-dragover")},this.onDrop=e=>{this.options.onDrop(e)},this.container=document.createElement("div"),this.container.classList.add("drop","z-depth-1"),this.outlineWrapper=document.createElement("div"),this.outlineWrapper.classList.add("drop-outline-wrapper"),this.svg=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.svg.classList.add("drop-outline"),this.path=document.createElementNS("http://www.w3.org/2000/svg","path"),this.path.classList.add("drop-outline-path"),t.icon&&(i=document.createElement("div"),i.classList.add("drop-icon","tgico-"+t.icon));const s=document.createElement("div");let n;s.classList.add("drop-header"),s.append((0,k.ag)(t.header,t.headerArgs)),t.subtitle&&(n=document.createElement("div"),n.classList.add("drop-subtitle"),n.append((0,k.ag)(t.subtitle))),this.svg.append(this.path),this.outlineWrapper.append(this.svg),this.container.append(...[this.outlineWrapper,i,s,n].filter(Boolean)),e.append(this.container),this.container.addEventListener("dragover",this.onDragOver),this.container.addEventListener("dragleave",this.onDragLeave),this.container.addEventListener("drop",this.onDrop)}destroy(){delete this.options,this.container.remove(),this.container.removeEventListener("dragover",this.onDragOver),this.container.removeEventListener("dragleave",this.onDragLeave),this.container.removeEventListener("drop",this.onDrop)}setPath(){const e=this.outlineWrapper.getBoundingClientRect();this.svg.setAttributeNS(null,"preserveAspectRatio","none"),this.svg.setAttributeNS(null,"viewBox",`0 0 ${e.width} ${e.height}`),this.svg.setAttributeNS(null,"width",`${e.width}`),this.svg.setAttributeNS(null,"height",`${e.height}`);const t=10,i=e.width-t,s=e.height-t,n=(0,qe.Z)(5,5,i,s,t,t,t,t);this.path.setAttributeNS(null,"d",n)}}var Qe=i(3035),Xe=i(7922),Je=i(410);function et(e){e.forEach((e=>e.classList.add("no-transition"))),(0,Qe.d1)().then((()=>{e.forEach((e=>e.classList.remove("no-transition")))}))}var tt=i(2398),it=i(490),st=i(9298),nt=i(1842),at=i(8737),ot=i(2341),rt=i(1174),dt=i(2831),lt=i(2207);class ct{constructor(e){this.maxRadius=10,this.minRadius=0,this.N=e,this.radius=new Array(e+1),this.radiusNext=new Array(e+1),this.progress=new Array(e+1),this.speed=new Array(e+1);for(let t=0;t<=e;t++)this.generateBlob(this.radius,t),this.generateBlob(this.radiusNext,t),this.progress[t]=0}generateBlob(e,t){const{maxRadius:i,minRadius:s,speed:n}=this,a=i-s;e[t]=s+Math.random()*a,n[t]=.017+.003*Math.random()}generateNextBlob(){const{radius:e,radiusNext:t,progress:i,N:s}=this;for(let n=0;n<s;n++)this.generateBlob(e,n),this.generateBlob(t,n),i[n]=0}update(e,t){const{N:i,progress:s,speed:n,radius:a,radiusNext:o}=this;for(let r=0;r<=i;r++)s[r]+=.8*n[r]+e*n[r]*8.2*t,s[r]>=1&&(s[r]=0,a[r]=o[r],this.generateBlob(o,r))}draw(e,t,i,s,n,a,o,r){if(n.getContext){const d=n.getContext("2d");d.beginPath(),d.moveTo(i,s),d.lineTo(e,s);const{radius:l,radiusNext:c,N:h}=this;for(let n=0;n<=h;n++)if(0===n){const i=this.progress[n],s=(t-(l[n]*(1-i)+c[n]*i))*r+o*(1-r);d.lineTo(e,s)}else{const a=this.progress[n-1],u=l[n-1]*(1-a)+c[n-1]*a,p=this.progress[n],f=(i-e)/h*(n-1),m=(i-e)/h*n,g=f+(m-f)/2,v=(t-u)*r+o*(1-r),b=(t-(l[n]*(1-p)+c[n]*p))*r+o*(1-r);d.bezierCurveTo(g,v,g,b,m,b),n===h&&d.lineTo(i,s)}a(d),d.fill(),d.closePath()}}}class ht{constructor(e){this.stateId=e,this.createGradient(e)}createGradient(e){this.shader=(t,i,s,n,a)=>{t.fillStyle=ht.getGradientFromType(t,e,i,s,n,a)}}static getGradientFromType(e,t,i,s,n,a){const o=e.createLinearGradient(i,s,n,a);return t===lt.Z.MUTED_BY_ADMIN?(o.addColorStop(0,"#F05459"),o.addColorStop(.4,"#766EE9"),o.addColorStop(1,"#57A4FE")):t===lt.Z.UNMUTED?(o.addColorStop(0,"#52CE5D"),o.addColorStop(1,"#00B1C0")):t===lt.Z.MUTED?(o.addColorStop(0,"#0976E3"),o.addColorStop(1,"#2BCEFF")):t===lt.Z.CONNECTING&&(o.addColorStop(0,"#8599aa"),o.addColorStop(1,"#8599aa")),o}update(e,t,i,s){}}class ut{constructor(){this.handleDevicePixelRatioChanged=e=>{this.setSize(),this.forceUpdate()},this.handleResize=()=>{this.resizeHandler&&(clearTimeout(this.resizeHandler),this.resizeHandler=null),this.resizing=!0,this.resizeCanvas(),this.resizeHandler=window.setTimeout((()=>{this.resizing=!1,this.invokeDraw()}),250)},this.handleFocus=()=>{this.focused=!0,this.invokeDraw()},this.handleBlur=()=>{this.focused=!1},this.invokeDraw=()=>{this.raf||this.draw()},this.draw=(e=!1)=>{if(this.raf=null,!this.mounted)return;const{lbd:t,lbd1:i,lbd2:s,scale:n,left:a,top:o,right:r,bottom:d,currentState:l,previousState:c,focused:h,resizing:u,canvas:p}=this;if(!h&&!u&&this.progressToState>=1)return;let f=Date.now()-this.lastUpdateTime;f>20&&(f=17),this.animateToAmplitude!==this.amplitude&&(this.amplitude+=this.animateAmplitudeDiff*f,this.animateAmplitudeDiff>0?this.amplitude>this.animateToAmplitude&&(this.amplitude=this.animateToAmplitude):this.amplitude<this.animateToAmplitude&&(this.amplitude=this.animateToAmplitude)),this.animateToAmplitude!==this.amplitude2&&(this.amplitude2+=this.animateAmplitudeDiff2*f,this.animateAmplitudeDiff2>0?this.amplitude2>this.animateToAmplitude&&(this.amplitude2=this.animateToAmplitude):this.amplitude2<this.animateToAmplitude&&(this.amplitude2=this.animateToAmplitude)),c&&(this.progressToState+=f/250,this.progressToState>1&&(this.progressToState=1,this.previousState=null));const{amplitude:m,amplitude2:g,progressToState:v}=this,b=6*g*n,y=6*g*n;p.getContext("2d").clearRect(0,0,p.width,p.height),t.minRadius=0,t.maxRadius=(2+2*m)*n,i.minRadius=0,i.maxRadius=(3+9*m)*n,s.minRadius=0,s.maxRadius=(3+9*m)*n,t.update(m,.3),i.update(m,.7),s.update(m,.7);for(let e=0;e<2;e++){if(0===e&&!c)continue;let n=1,h=null;0===e?(n=1-v,h=c):(n=c?v:1,l.update(d-o,r-a,f,m),h=l);const u=e=>{e.globalAlpha=.3*n,h.shader(e,a,o,r,d)},g=t=>{t.globalAlpha=0===e?1:n,h.shader(t,a,o,r,d)};i.draw(a,o-b,r,d,p,u,o,1),s.draw(a,o-y,r,d,p,u,o,1),t.draw(a,o,r,d,p,g,o,1)}e||(this.raf=requestAnimationFrame((()=>this.draw())))},this.setCurrentState=(e,t)=>{const{currentState:i,states:s}=this;(null==i?void 0:i.stateId)!==e&&(this.previousState=t?i:null,this.currentState=s.get(e),this.progressToState=this.previousState?0:1)},this.focused=!0,this.resizing=!1,this.lastUpdateTime=Date.now(),this.amplitude=0,this.amplitude2=0,this.states=new Map([[lt.Z.UNMUTED,new ht(lt.Z.UNMUTED)],[lt.Z.MUTED,new ht(lt.Z.MUTED)],[lt.Z.MUTED_BY_ADMIN,new ht(lt.Z.MUTED_BY_ADMIN)],[lt.Z.CONNECTING,new ht(lt.Z.CONNECTING)]]),this.previousState=null,this.currentState=this.states.get(lt.Z.CONNECTING),this.progressToState=1}componentDidMount(){this.mounted||(this.mounted=!0,window.addEventListener("resize",this.handleResize),this.media=window.matchMedia("screen and (min-resolution: 2dppx)"),this.media.addEventListener("change",this.handleDevicePixelRatioChanged),this.setSize(),this.forceUpdate(),this.lbd=new ct(3),this.lbd1=new ct(7),this.lbd2=new ct(8),this.setAmplitude(this.amplitude),this.draw())}componentWillUnmount(){this.mounted=!1,window.removeEventListener("resize",this.handleResize),this.media.addEventListener("change",this.handleDevicePixelRatioChanged);const{canvas:e}=this;e.getContext("2d").clearRect(0,0,e.width,e.height)}setSize(){this.scale=window.devicePixelRatio,this.top=20*this.scale,this.right=(this.mounted?this.container.offsetWidth:1261)*this.scale,this.bottom=(this.mounted?this.container.offsetHeight:68)*this.scale,this.left=0*this.scale,this.setCanvasSize()}setCanvasSize(){this.canvas.width=this.right,this.canvas.height=this.bottom}resizeCanvas(){this.scale=window.devicePixelRatio,this.right=this.container.offsetWidth*this.scale,this.forceUpdate(),this.invokeDraw()}setAmplitude(e){const{amplitude:t}=this;this.animateToAmplitude=e,this.animateAmplitudeDiff=(e-t)/250,this.animateAmplitudeDiff2=(e-t)/120}forceUpdate(){this.setCanvasSize()}render(e){const t=this.container=document.createElement("div");t.classList.add(e);const i=this.canvas=document.createElement("canvas");return i.classList.add(e+"-canvas"),t.append(i),t}}var pt=i(8222),ft=i(1447);class mt{constructor(e,t){this.item=e,(0,E.Z)(this,t)}play(e){return this.item.playPart(this,e)}}class gt{constructor(e,t){this.icon=e,this.autoplay=!1,(0,E.Z)(this,t),this.parts=this.parts.map((e=>this.createPart(e)))}load(){var e;let t=this.loadPromise;if(t)return t;const{container:i,canvas:s,width:n,height:a}=this.icon;return t=ft.Z.loadAnimationAsAsset({container:i,canvas:s,width:n,height:a,group:"none",loop:!1,autoplay:null!==(e=this.autoplay)&&void 0!==e&&e,initFrame:this.initFrame,skipFirstFrameRendering:void 0===this.initFrame,color:this.color,inverseColor:this.inverseColor},this.name).then((e=>ft.Z.waitForFirstFrame(e))).then((e=>{this.player=e,this.onLoadForColor&&(this.onLoadForColor(),this.onLoadForColor=void 0),this.onLoadForPart&&(this.onLoadForPart(),this.onLoadForPart=void 0)})),this.loadPromise=t,this.icon.loadPromises.set(this.name,t),t}createPart(e){return new mt(this,e)}getPart(e){return e instanceof mt?e:"string"==typeof e?this.parts.find((t=>t.name===e)):this.parts[e]}playPart(e,t){return this.icon.playPart(this,e,t)}}class vt{constructor(e){(0,E.Z)(this,e),this.container||(this.container=document.createElement("div")),this.container.classList.add("rlottie-icon");const{width:t,height:i}=this;this.container.style.width=t+"px",this.container.style.height=i+"px";const s=this.canvas=document.createElement("canvas");s.classList.add("rlottie"),s.width=t,s.height=i,this.items=new Map,this.loadPromises=new Map}get loadPromise(){return Promise.all([...this.loadPromises.values()]).then(Re.Z)}getItem(e){return e||1!==this.items.size?this.items.get(e):this.items.values().next().value}add(e){const t=new gt(this,e);return this.items.set(e.name,t),t}playPart(e,t,i){if(!e.player)return void(e.onLoadForPart=()=>{this.playPart(e,t,i)});const s=e.getPart(t);e.player.playPart({from:Ne.Z.isAvailable("animations")&&!this.skipAnimation?s.startFrame:s.endFrame,to:s.endFrame,callback:i})}static generateEqualParts(e,t){return new Array(e).fill(0).map(((e,i)=>{const s=i*t;return{startFrame:s,endFrame:s+t-1}}))}}class bt extends vt{constructor(e){super({width:e.width,height:e.height}),(0,E.Z)(this,e)}load(e,t){if(this.loaded)return this.loadPromise;this.loaded=!0,this.partState=e,this.colorState=t;const i=this.getPart(e),s=void 0!==t&&this.getColor&&this.getColor(t),n=i.item;n.initFrame=i.endFrame,n.color=s;const a=[...this.items.values()].map((e=>e.load()));return Promise.all(a).then(Re.Z)}setState(e,t,i){this.loaded||this.load(e,t);let s=!1,n=!1;return void 0!==e?s=this.setPartState(e,t,i):void 0!==t&&(n=this.setColorState(t)),s||n}setPartState(e,t,i){const{partState:s}=this;return s===e?void 0!==t&&this.setColorState(t):(void 0!==t&&this.setColorState(t,!1),this.partState=e,this.getPart(e,s).play(i),!0)}setColorState(e,t=!0){const{colorState:i}=this;if(i===e||!this.getColor)return!1;this.colorState=e;const s=this.getItem(),n=this.getColor(e,i),a=()=>{s.player.setColor(n,t)};return s.player?a():s.onLoadForColor=a,!0}destroy(){this.items.forEach((e=>{e.loadPromise.then((()=>{e.player.remove()}))}))}}class yt extends bt{constructor(){super({width:36,height:36,getPart:(e,t)=>{const i=oi;let s;switch(e){case i.HAND:s=t===i.MUTED?"muted-to-hand":"unmuted-to-hand";break;case i.MUTED:s=t===i.HAND?"hand-to-muted":"mute";break;case i.UNMUTED:s="unmute"}return this.getItem().getPart(s)}}),this.container.classList.add("group-call-microphone-icon-container"),this.add({name:"voip_filled",parts:[{startFrame:0,endFrame:35,name:"hand-to-muted"},{startFrame:36,endFrame:68,name:"unmute"},{startFrame:69,endFrame:98,name:"mute"},{startFrame:99,endFrame:135,name:"muted-to-hand"},{startFrame:136,endFrame:172,name:"unmuted-to-hand"},{startFrame:173,endFrame:201,name:"scheduled-crossing"},{startFrame:202,endFrame:236,name:"scheduled-to-muted"},{startFrame:237,endFrame:273,name:"scheduled-to-hand"},{startFrame:274,endFrame:310,name:"scheduled-crossed-to-hand"},{startFrame:311,endFrame:343,name:"scheduled-uncrossing"},{startFrame:344,endFrame:375,name:"scheduled-to-muted"},{startFrame:376,endFrame:403,name:"play-to-muted"}]})}}var wt=i(2353),St=i(3416),Ct=i(6976),Lt=i(6733),Et=i(1483),It=i(8936),Pt=i(2946),Zt=i(3003),Mt=i(5592),kt=i(8805),Tt=i(4484),xt=i(5345);class At extends bt{constructor(e){super({width:32,height:32,getPart:(e,t)=>{const i=ai;let s;switch(e){case i.HAND:s=3;break;case i.MUTED:s=t===i.HAND?0:2;break;case i.UNMUTED:s=1}return this.getItem().getPart(s)},getColor:e?(e,t)=>function(e){const t=ai;let i;switch(e){case t.HAND:i="blue";break;case t.MUTED:case t.MUTED_FOR_ME:case t.MUTED_BY_ADMIN:i=e===t.MUTED?"secondary":"red";break;case t.UNMUTED:i="green"}const s=pt.Z.getProperty("gc-"+i+"-text-color");return(0,Be.oo)(s)}(e):void 0}),this.colored=e,this.container.classList.add("group-call-participant-muted-icon-container");const t=vt.generateEqualParts(4,21);this.add({name:"voice_outlined2",parts:t})}setState(e){return super.setState(function(e){const t=ai;switch(e){case t.MUTED_BY_ADMIN:case t.MUTED_FOR_ME:return t.MUTED;default:return e}}(e),e)}}var _t=i(130);const Ft="group-call-participant-status";class Dt{constructor(e){this.withIcons=e,this.container=document.createElement("div"),this.container.classList.add(Ft+"-container")}setState(e,t){const i=ai,s=this.withIcons.filter((e=>!!t[e])).map((e=>{const t="tgico-"+("presentation"===e?"listscreenshare":"videocamera_filled"),i=document.createElement("i");return i.classList.add(Ft+"-icon",Ft+"-icon-"+e,t),i}));let n,a;if(e===i.MUTED_FOR_ME)n=(0,k.ag)("VoiceChat.Status.MutedForYou"),a="is-muted";else if(e===i.UNMUTED)n=(0,k.ag)("VoiceChat.Status.Speaking"),a="is-speaking";else if(e===i.HAND)n=(0,k.ag)("VoiceChat.Status.WantsSpeak"),a="is-waiting";else{if(t.about&&!s.length)return void(0,_t.Z)(this.container,(0,_.Z)(t.about));n=(0,k.ag)("VoiceChat.Status.Listening"),a="is-listening"}const o=document.createElement("span");o.classList.add(Ft,a),o.append(...s,n),(0,Z.Z)(this.container,o)}}var Rt=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class Bt extends xt.Z{constructor(e){super({getIndex:e=>Rt(this,void 0,void 0,(function*(){return(yield this.instance.getParticipantByPeerId(e.id)).date})),onDelete:e=>{e.dom.listEl.remove(),this.onElementDestroy(e)},onUpdate:e=>Rt(this,void 0,void 0,(function*(){const t=yield this.instance.getParticipantByPeerId(e.id),i=ri(t);e.mutedIcon.setState(i),e.status.setState(i,t)})),onSort:(e,t)=>{(0,Tt.Z)(e.dom.listEl,this.list,t)},onElementCreate:e=>{const{dom:t}=Ie.default.addDialogNew({peerId:e.id,container:!1,avatarSize:this.avatarSize,autonomous:this.autonomous,meAsSaved:!1,rippleEnabled:this.rippleEnabled,wrapOptions:{lazyLoadQueue:this.lazyLoadQueue}});t.listEl.classList.add("group-call-participant");const i=new At(!0),s=new Dt(["presentation","video"]);return(0,Z.Z)(t.lastMessageSpan,s.container),t.listEl.append(i.container),e.mutedIcon=i,e.status=s,e.dom=t,e},updateElementWith:Qe.T2}),this.instance=e,this.avatarSize="abitbigger",this.rippleEnabled=!0,this.autonomous=!0,this.createChatListOptions={dialogSize:72},this.list=Ie.default.createChatList(this.createChatListOptions)}destroy(){this.elements.forEach((e=>{this.onElementDestroy(e)}))}onElementDestroy(e){e.mutedIcon.destroy()}}var Nt=i(7529),Ot=i(5296);function Ut(e){const t=document.createElement("canvas");t.classList.add("call-video-blur"),t.width=16,t.height=16;const i=t.getContext("2d",{alpha:!1});i.filter="blur(2px)";const s=()=>{i.drawImage(e,0,0,e.videoWidth,e.videoHeight,0,0,t.width,t.height)};return(0,Ot.jt)((()=>(s(),t.isConnected))),s(),t}const Ht="group-call-participant-video";class zt{constructor(e,t,i){this.managers=e,this.instance=t,this.source=i,this.container=document.createElement("div"),this.container.classList.add(Ht+"-container"),this.info=document.createElement("div"),this.info.classList.add(Ht+"-info"),this.left=document.createElement("div"),this.left.classList.add(Ht+"-info-left"),this.right=document.createElement("div"),this.right.classList.add(Ht+"-info-right"),this.info.append(this.left,this.right),this.container.append(this.info)}setPinned(e){if(!e)return void(this.header&&(this.header.remove(),this.header=void 0));if(this.header)return;this.header=document.createElement("div"),this.header.classList.add(Ht+"-header");const t=document.createElement("i");t.classList.add("group-call-pin-icon","tgico-pin"),this.header.append(t),this.container.append(this.header)}setParticipant(e,t,i){let s;e.pFlags.self?(s=(0,k.ag)("VoiceChat.Status.You"),s.classList.add("peer-title")):(this.peerTitle=new M.Z({peerId:(0,Pt.Z)(e.peer)}),s=this.peerTitle.element),this.groupCallParticipantMutedIcon=new At(!1),this.groupCallParticipantStatus=new Dt([t]),this.left.append(s,this.groupCallParticipantStatus.container),this.right.append(this.groupCallParticipantMutedIcon.container),i.classList.add(Ht,"call-video"),i.paused&&i.play();const n=Ut(i);n.classList.add(Ht+"-blur"),this.container.prepend(n,i),this.updateParticipant(e)}updateParticipant(e){const t=ri(e);this.groupCallParticipantMutedIcon.setState(t),this.groupCallParticipantStatus.setState(t,e)}destroy(){this.groupCallParticipantMutedIcon.destroy()}}class jt extends Nt.Z{constructor(e){super(),(0,E.Z)(this,e);const t=this.container=document.createElement("div");this.container.classList.add("group-call-participants-video-container"),e.appendTo.append(t),this.participantsElements=new Map,this.containers=new Map;const{listenerSetter:i}=this;i.add(d.Z)("group_call_participant",(({groupCallId:e,participant:t})=>{this.instance.id===e&&this.updateParticipant(t)})),i.add(this.instance)("pinned",(e=>{this.participantsElements.forEach((t=>{t.forEach((t=>{this.setElementDisplay(t,e)}))}))})),(0,L.fc)(this.container,(e=>{const t=(0,X.Z)(e.target,"group-call-participant-video-container");if(!t)return;const i=this.containers.get(t);this.instance.pinnedSource!==i.source?this.instance.pinSource(i.source):this.instance.unpinAll()}),{listenerSetter:i}),this.setInstance(this.instance),this.setup({element:t,listenerSetter:i,showOnLeaveToClassName:"group-call-buttons"})}shouldDisplayElement(e,t){return this.displayPinned?!t||e.source===t:t&&e.source!==t}setElementDisplay(e,t){const i=this.shouldDisplayElement(e,t);e.container.classList.toggle("video-hidden",!i);const s=e.source===t;e.setPinned(s)}updateParticipant(e){const t=(0,Pt.Z)(e.peer),i=["video","presentation"],s=i.some((t=>!!e[t]));let n=this.participantsElements.get(t);(s||n)&&(n||this.participantsElements.set(t,n=new Map),i.forEach((i=>{let s=n.get(i);const a=e[i];if(!!a!=!!s){if(a){const t=this.instance.getVideoElementFromParticipantByType(e,i);if(!t)return;const{video:a,source:o}=t;s=new zt(this.managers,this.instance,o),this.containers.set(s.container,s),this.setElementDisplay(s,this.instance.pinnedSource),n.set(i,s),s.setParticipant(e,i,a),this.container.prepend(s.container)}else n.delete(i),s.container.remove(),n.size||(this.participantsElements.delete(t),this.containers.delete(s.container),s.destroy());this._onLengthChange()}else s&&s.updateParticipant(e)})))}_onLengthChange(){const e=this.container.childElementCount;this.container.dataset.length=""+e,this.container.dataset.layout=e<=2?"1":3===e?"3":"4",this.onLengthChange&&this.onLengthChange(e)}setInstance(e){return t=this,i=void 0,n=function*(){(yield e.participants).forEach((e=>{this.updateParticipant(e)}))},new((s=void 0)||(s=Promise))((function(e,a){function o(e){try{d(n.next(e))}catch(e){a(e)}}function r(e){try{d(n.throw(e))}catch(e){a(e)}}function d(t){var i;t.done?e(t.value):(i=t.value,i instanceof s?i:new s((function(e){e(i)}))).then(o,r)}d((n=n.apply(t,i||[])).next())}));var t,i,s,n}destroy(){this.containers.forEach((e=>{e.destroy()}))}}var Gt=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class Vt{constructor(e){this.onOpenProfileClick=()=>{const e=V.Z.getPopups(ci)[0];e&&e.hide(),Es.setInnerPeer({peerId:this.targetPeerId})},this.toggleParticipantMuted=e=>{this.instance.editParticipant(this.participant,{muted:e})},this.buttons=[{icon:"gc_microphoneoff",text:"VoiceChat.MutePeer",verify:()=>this.canManageCall&&this.participant.pFlags.can_self_unmute,onClick:()=>this.toggleParticipantMuted(!0)},{icon:"gc_microphone",text:"VoiceChat.UnmutePeer",verify:()=>this.canManageCall&&!this.participant.pFlags.can_self_unmute,onClick:()=>this.toggleParticipantMuted(!1)},{icon:"gc_microphoneoff",text:"VoiceChat.MuteForMe",verify:()=>!this.canManageCall&&!this.participant.pFlags.muted_by_you,onClick:()=>this.toggleParticipantMuted(!0)},{icon:"gc_microphone",text:"VoiceChat.UnmuteForMe",verify:()=>!this.canManageCall&&this.participant.pFlags.muted_by_you,onClick:()=>this.toggleParticipantMuted(!1)},{icon:"newprivate",text:"VoiceChat.OpenProfile",verify:()=>!0,onClick:this.onOpenProfileClick},{icon:"deleteuser danger",text:"VoiceChat.RemovePeer",verify:()=>this.managers.appChatsManager.hasRights(this.chatId,"ban_users"),onClick:()=>Gt(this,void 0,void 0,(function*(){(0,Mt.Z)({peerId:this.targetPeerId,title:new M.Z({peerId:this.targetPeerId}).element,descriptionLangKey:(yield this.managers.appChatsManager.isBroadcast(this.chatId))?"VoiceChat.RemovePeer.Confirm.Channel":"VoiceChat.RemovePeer.Confirm",descriptionLangArgs:[new M.Z({peerId:this.targetPeerId}).element],button:{langKey:"VoiceChat.RemovePeer.Confirm.OK",isDanger:!0}}).then((()=>{this.managers.appChatsManager.kickFromChat(this.chatId,this.targetPeerId)}),Re.Z)}))}];const{listenerSetter:t}=e;this.managers=e.managers,this.instance=e.instance,this.chatId=this.instance.chatId,this.element=(0,Zt.b)({buttons:this.buttons,listenerSetter:t}),this.element.classList.add("group-call-participant-menu","night"),(0,Ct.E)({element:e.onContextElement,callback:e=>Gt(this,void 0,void 0,(function*(){const t=(0,X.Z)(e.target,"group-call-participant");if(!t)return;this.element.parentElement!==i&&i.append(this.element),(0,C.Z)(e);const s=this.targetPeerId=t.dataset.peerId.toPeerId();this.participant=yield this.instance.getParticipantByPeerId(s),this.participant.pFlags.self||(this.canManageCall=yield this.managers.appChatsManager.hasRights(this.chatId,"manage_call"),yield(0,wt.Z)(this.buttons,(e=>Gt(this,void 0,void 0,(function*(){const t=yield e.verify(s);return e.element.classList.toggle("hide",!t),t})))),(0,Et.Z)(e.touches?e.touches[0]:e,this.element,"right"),St.Z.openBtnMenu(this.element))})),listenerSetter:t}),t.add(d.Z)("group_call_participant",(({groupCallId:e,participant:t})=>{if(this.instance.id===e){const e=(0,Pt.Z)(t.peer);this.targetPeerId===e&&St.Z.close()}}));let i=document.body;(0,Lt.Ms)(document.body,(()=>{const e=(0,Lt.rB)();i=e?V.Z.getPopups(ci)[0].getContainer():document.body,e||St.Z.close()}),t)}}class Kt{constructor(e){(0,E.Z)(this,e);const t="group-call-participants",i=new kt.ZP(void 0);i.container.classList.add(t+"-scrollable");const s=this.container=document.createElement("div");s.classList.add(t);const n=this.sortedList=new Bt(this.instance),{instance:a,listenerSetter:o}=this;this.contextMenu=new Vt(Object.assign(Object.assign({},e),{onContextElement:n.list,listenerSetter:o,instance:a})),this.groupCallParticipantsVideo=new jt(Object.assign(Object.assign({},e),{appendTo:i.container,displayPinned:!1})),i.append(n.list),s.append(i.container),e.appendTo.append(s),o.add(d.Z)("group_call_participant",(({groupCallId:e,participant:t})=>{this.instance.id===e&&this.updateParticipant(t)})),new It.Z({scrollable:i,getPromise:()=>this.managers.appGroupCallsManager.getGroupCallParticipants(this.instance.id).then((({participants:e,isEnd:t})=>(e.forEach((e=>{this.updateParticipant(e)})),t)))}),this.setInstance(a)}updateParticipant(e){const t=(0,Pt.Z)(e.peer),i=this.sortedList.has(t);e.pFlags.left?i&&this.sortedList.delete(t):i?this.sortedList.update(t):this.sortedList.add(t)}setInstance(e){return Gt(this,void 0,void 0,(function*(){(yield e.participants).forEach((e=>{this.updateParticipant(e)}))}))}destroy(){this.sortedList.destroy(),this.groupCallParticipantsVideo.destroy()}}class Wt{constructor(e){this.appendTo=e,this.descriptionIntl=new k.ZP.IntlElement({key:"VoiceChat.Status.Connecting"}),this.descriptionIntl.element.classList.add("group-call-description")}detach(){this.descriptionIntl.element.remove()}update(e){const{state:t}=e;let i,s;t===lt.Z.CONNECTING?i="VoiceChat.Status.Connecting":(i="VoiceChat.Status.Members",s=[e.groupCall.participants_count]);const{descriptionIntl:n}=this;n.compareAndUpdate({key:i,args:s}),this.descriptionIntl.element.parentElement||this.appendTo.append(this.descriptionIntl.element)}}class $t{constructor(e){this.appendTo=e,this.peerTitle=new M.Z({peerId:0})}update(e){const{peerTitle:t,appendTo:i}=this,s=e.groupCall,n=e.chatId.toPeerId(!0);s.title?(0,_t.Z)(i,(0,_.Z)(s.title)):(t.options.peerId!==n&&(t.options.peerId=n,t.update()),t.element.parentElement!==i&&i.append(t.element))}}var qt=i(2820);function Yt(e,t,i){const s=e+"-button",n=document.createElement("div");n.classList.add(s,"call-button","rp-overflow"),i.icon&&n.classList.add("tgico-"+i.icon),i.noRipple||(0,S.Z)(n),i.isDanger&&n.classList.add(s+"-red"),i.isConfirm&&n.classList.add(s+"-green"),i.callback&&(0,L.fc)(n,i.callback,{listenerSetter:t});let a=n;if(i.text){const e=document.createElement("div");e.classList.add(s+"-container","call-button-container");const t="string"==typeof i.text?(0,k.ag)(i.text):i.text;t.classList.add(s+"-text","call-button-text"),e.append(n,t),a=e}return a}var Qt=i(3757);const Xt="movable-element",Jt=Xt+"-resize-handler";class ei extends l.Z{constructor(e){super(!0),this.onResize=()=>{this.fixDimensions(),this.fixPosition(),this.setPosition()},(0,E.Z)(this,e),this.top=this.left=this.width=this.height=0,this.element.classList.add(Xt),this.addResizeHandlers(),this.setSwipeHandler(),o.Z.addEventListener("resize",this.onResize)}destroyElements(){this.element.classList.remove(Xt),this.handlers&&this.handlers.forEach((e=>{e.remove()}))}destroy(){o.Z.removeEventListener("resize",this.onResize),this.swipeHandler.removeListeners()}addResizeHandlers(){this.handlers=["n","e","s","w","ne","se","sw","nw"].map((e=>{const t=document.createElement("div");return t.dataset.side=e,t.classList.add(Jt,Jt+"-side-"+e),this.element.append(t),t}))}setSwipeHandler(){let e,t,i,s,n;const a=this.swipeHandler=new Qt.Z({element:this.element,onSwipe:(a,o,r)=>{if(n){if(n.includes("e")||n.includes("w")){const e=n.includes("e")&&a>0||n.includes("w")&&a<0,s=Math.abs(a)*(e?1:-1),o=n.includes("e")?Te.Z.width-t:i+t;this.width=Math.min(o,i+s)}if(n.includes("n")||n.includes("s")){const t=n.includes("s")&&o>0||n.includes("n")&&o<0,i=Math.abs(o)*(t?1:-1),a=n.includes("s")?Te.Z.height-e:s+e;this.height=Math.min(a,s+i)}this.fixDimensions(),n.includes("w")&&(this.left=Math.min(t+i-this.minWidth,t+a)),n.includes("n")&&(this.top=Math.min(e+s-this.minHeight,e+o))}else this.top=e+o,this.left=t+a;this.fixPosition(),this.setPosition()},verifyTouchTarget:e=>{const t=e.target;if(this.verifyTouchTarget&&!this.verifyTouchTarget(e))return!1;const i=(0,X.Z)(t,Jt);return i?(n=i.dataset.side,a.setCursor("")):(n=void 0,a.setCursor("grabbing")),!0},onFirstSwipe:()=>{e=this.top,t=this.left,i=this.width,s=this.height}})}setPositionToCenter(){this.top=Te.Z.height/2-this.height/2,this.left=Te.Z.width/2-this.width/2,this.setPosition()}fixDimensions(){this.width=(0,Ge.Z)(this.width,this.minWidth,Te.Z.width),this.height=(0,Ge.Z)(this.height,this.minHeight,Te.Z.height)}fixPosition(){this.top=(0,Ge.Z)(this.top,0,Te.Z.height-this.height),this.left=(0,Ge.Z)(this.left,0,Te.Z.width-this.width)}setPosition(){this.element.style.top=this.top+"px",this.element.style.left=this.left+"px",this.element.style.right="auto",this.element.style.bottom="auto",this.element.style.width=this.width+"px",this.element.style.height=this.height+"px",this.dispatchEvent("resize")}get width(){return this._width}get height(){return this._height}set width(e){this._width=e}set height(e){this._height=e}get state(){const{top:e,left:t,width:i,height:s}=this;return{top:e,left:t,width:i,height:s}}set state(e){const{top:t,left:i,width:s,height:n}=e;this.top=t,this.left=i,this.width=s,this.height=n,this.onResize()}}var ti,ii=function(e,t,i,s,n){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?n.call(e,i):n?n.value=i:t.set(e,i),i};class si{constructor(e){ti.set(this,void 0),(0,E.Z)(this,e),this.toggleMovable(!z.Z),this.listenerSetter.add(o.Z)("changeScreen",((e,t)=>{t!==o._.mobile&&e!==o._.mobile||this.toggleMovable(!z.Z)}))}destroy(){const e=this.movable;e&&e.destroy()}get movable(){return function(e,t,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(e):s?s.value:t.get(e)}(this,ti,"f")}get state(){return this.movable?this.movable.state:this.previousState}set state(e){this.previousState=e}toggleMovable(e){let{movable:t}=this;if(e){if(t)return;t=ii(this,ti,new ei(this.movableOptions),"f"),t.state=this.previousState,void 0===this.previousState.top&&t.setPositionToCenter(),this.onResize&&this.listenerSetter.add(t)("resize",this.onResize)}else{if(!t)return;this.previousState=t.state,t.destroyElements(),t.destroy(),ii(this,ti,void 0,"f")}}}function ni(e,t,i){return t.forEach((t=>{t.classList.toggle(e,i)})),()=>ni(e,t,!i)}ti=new WeakMap;var ai,oi;function ri(e){const t=ai;return e.pFlags.muted_by_you?t.MUTED_FOR_ME:void 0!==e.raise_hand_rating?t.HAND:e.pFlags.muted?e.pFlags.can_self_unmute?t.MUTED:t.MUTED_BY_ADMIN:t.UNMUTED}!function(e){e[e.UNMUTED=0]="UNMUTED",e[e.MUTED=1]="MUTED",e[e.MUTED_FOR_ME=2]="MUTED_FOR_ME",e[e.MUTED_BY_ADMIN=3]="MUTED_BY_ADMIN",e[e.HAND=4]="HAND"}(ai||(ai={})),function(e){e[e.HAND=0]="HAND",e[e.MUTED=1]="MUTED",e[e.UNMUTED=2]="UNMUTED"}(oi||(oi={}));let di={width:420,height:640};const li="group-call";class ci extends V.Z{constructor(){super("popup-group-call",{body:!0,withoutOverlay:!0,closable:!0,title:!0}),this.onFullScreenClick=()=>{(0,Lt.Dj)(this.container)},this.onToggleControls=e=>{this.container.classList.toggle("show-controls",e),this.buttonsContainer.classList.toggle("show-controls",e)},this.toggleDisability=ni.bind(null,"btn-disabled"),this.onVideoClick=()=>{const e=this.toggleDisability([this.btnVideo],!0);this.instance.toggleVideoSharing().finally((()=>{e()}))},this.onScreenClick=()=>{const e=this.toggleDisability([this.btnScreen],!0);this.instance.toggleScreenSharing().finally((()=>{e()}))},this.onMuteClick=()=>{const e=this.instance.participant;e.pFlags.can_self_unmute?this.instance.toggleMuted():void 0===e.raise_hand_rating&&this.instance.changeRaiseHand(!0)},this.onLeaveClick=()=>{return e=this,t=void 0,s=function*(){const e=e=>{this.instance.hangUp(e)};(yield this.managers.appChatsManager.hasRights(this.instance.chatId,"manage_call"))?V.Z.createPopup(se.Z,"popup-end-video-chat",{titleLangKey:"VoiceChat.End.Title",descriptionLangKey:"VoiceChat.End.Text",checkboxes:[{text:"VoiceChat.End.Third"}],buttons:[{langKey:"VoiceChat.End.OK",callback:t=>{e(!!t.size)},isDanger:!0}]}).show():e(!1)},new((i=void 0)||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}));var e,t,i,s},this.onFullScreenChange=()=>{this.toggleBigLayout();const e=(0,Lt.rB)(),{btnFullScreen:t,btnExitFullScreen:i}=this,n=this.container.classList.contains("is-full-screen");this.container.classList.toggle("is-full-screen",e),t&&t.classList.toggle("hide",e),i&&i.classList.toggle("hide",!e),this.btnClose.classList.toggle("hide",e),e!==n&&(s.Z.checkAnimations2(e),De.Z.setThemeColor(e?"#000000":void 0))},this.toggleBigLayout=()=>{var e;const t=(0,Lt.rB)(),i=null===(e=this.movablePanel)||void 0===e?void 0:e.movable,s=(t||!!(i&&i.width>=680))&&!!this.videosCount,n=this.container.classList.contains("is-big-layout");let a;s&&!n&&(a=Array.from(this.buttonsContainer.children),a.forEach((e=>{e.style.opacity="0"})),this.buttonsContainer.offsetLeft),this.container.classList.toggle("is-big-layout",s),this.btnInvite.classList.toggle("hide",s),this.btnShowColumn.classList.toggle("hide",!s),a&&a.forEach((e=>{e.style.opacity=""}))},this.toggleRightColumn=()=>{this.container.classList.toggle("is-right-column-shown")},this.videosCount=0,this.container.classList.add(li,"night");const e=this.instance=ce.ZP.groupCall,{listenerSetter:t}=this;if(!f.IS_APPLE_MOBILE){const e=this.btnFullScreen=(0,v.Z)("fullscreen"),i=this.btnFullScreen2=(0,v.Z)("fullscreen "+li+"-cfs"),s=this.btnExitFullScreen=(0,v.Z)("smallscreen");(0,L.fc)(e,this.onFullScreenClick,{listenerSetter:t}),(0,L.fc)(i,this.onFullScreenClick,{listenerSetter:t}),(0,L.fc)(s,(()=>{(0,Lt.C8)()}),{listenerSetter:t}),(0,Lt.Ms)(this.container,this.onFullScreenChange,t)}this.btnInvite=(0,v.Z)("adduser");const i=this.btnShowColumn=(0,v.Z)("rightpanel "+li+"-only-big");(0,L.fc)(i,this.toggleRightColumn,{listenerSetter:t});const n=document.createElement("div");n.classList.add(li+"-header-info"),this.title.classList.add(li+"-header-title");const a=document.createElement("div");a.classList.add(li+"-header-subtitle"),n.append(this.title,a),this.header.classList.add(li+"-header"),this.header.append(...[this.btnExitFullScreen,n,this.btnFullScreen,i].filter(Boolean));const o=this.header.cloneNode(!1),r=n.cloneNode(!1),l=this.title.cloneNode(!1);r.append(l);const c=(0,v.Z)("rightpanel");o.append(...[c,r,this.btnFullScreen2].filter(Boolean)),(0,L.fc)(c,this.toggleRightColumn,{listenerSetter:t}),this.body.prepend(o);const h=new kt.ZP(void 0);h.container.classList.add("group-call-big-video-container"),this.container.append(h.container),this.groupCallTitle=new $t(this.title),this.groupCallDescription=new Wt(a),this.groupCallBodyHeaderDescription=new Wt(l),this.constructButtons(),this.groupCallParticipantsVideo=new jt({appendTo:h.container,instance:e,listenerSetter:t,displayPinned:!0,onLengthChange:e=>{this.videosCount=e,this.toggleBigLayout()},managers:this.managers}),this.groupCallParticipants=new Kt({appendTo:this.body,instance:e,listenerSetter:t,managers:this.managers}),this.movablePanel=new si({listenerSetter:t,movableOptions:{minWidth:400,minHeight:480,element:this.element,verifyTouchTarget:e=>{const t=e.target;return!((0,X.Z)(t,"chatlist")||(0,X.Z)(t,"group-call-button")||(0,X.Z)(t,"btn-icon")||(0,X.Z)(t,"group-call-participants-video-container")||(0,Lt.rB)())}},onResize:()=>this.toggleBigLayout(),previousState:di}),t.add(e)("state",(()=>{this.updateInstance()})),t.add(d.Z)("group_call_update",(e=>{var t;(null===(t=this.instance)||void 0===t?void 0:t.id)===e.id&&this.updateInstance()})),t.add(e)("pinned",(()=>{this.setHasPinned()})),t.add(this.groupCallParticipantsVideo)("toggleControls",this.onToggleControls),this.addEventListener("close",(()=>{const{movablePanel:e}=this;di=e.state,this.groupCallParticipantsVideo.destroy(),this.groupCallParticipants.destroy(),this.groupCallMicrophoneIcon.destroy(),e.destroy()})),this.toggleRightColumn(),this.onFullScreenChange(),this.updateInstance()}constructButtons(){const e=this.buttonsContainer=document.createElement("div");e.classList.add(li+"-buttons");const t=Yt.bind(null,li,this.listenerSetter),i=this.btnVideo=t({callback:this.onVideoClick,icon:"videocamera_filled"}),s=this.btnScreen=t({callback:this.onScreenClick,icon:"sharescreen_filled"});s.classList.toggle("hide",!qt.Z);const n=t({noRipple:!0,callback:(0,G.Z)(this.onMuteClick,600,!0)});n.classList.add(li+"-microphone-button");const a=this.groupCallMicrophoneIcon=new yt;n.append(a.container);const o=t({icon:"settings_filled"});o.classList.add("btn-disabled"),o.classList.toggle("hide",!qt.Z);const r=t({isDanger:!0,callback:this.onLeaveClick,icon:"close"});e.append(i,s,n,o,r),this.container.append(e)}getContainer(){return this.container}setHasPinned(){this.container.classList.toggle("has-pinned",!!this.instance.pinnedSource)}updateInstance(){if(this.instance.state===lt.Z.CLOSED)return this.container.classList.contains("is-full-screen")&&(0,Lt.C8)(),void this.hide();const{participant:e,groupCall:t}=this.instance;if(!e)return;this.setTitle(),this.setDescription(),this.setHasPinned();const i=function(e,t){const i=oi;return t.pFlags.can_self_unmute?t.pFlags.muted?i.MUTED:i.UNMUTED:i.HAND}(0,e);this.container.dataset.micState=i===oi.HAND?"hand":i===oi.MUTED?"muted":"unmuted",this.groupCallMicrophoneIcon.setState(i)}setTitle(){this.groupCallTitle.update(this.instance)}setDescription(){this.groupCallDescription.update(this.instance),this.groupCallBodyHeaderDescription.update(this.instance)}}var hi=i(9078),ui=i(3335),pi=i(5157);class fi{constructor(e){this.appendTo=e,this.container=document.createElement("div"),this.container.classList.add("call-description")}detach(){void 0!==this.interval&&(clearInterval(this.interval),this.interval=void 0),this.container.remove(),this.state=void 0}update(e){const{connectionState:t}=e;if(this.state===t)return;let i;if(this.state=t,t===ui.Z.CONNECTED){i=document.createElement("span"),i.classList.add("call-description-duration");const t=()=>{i.innerText=(0,pi.Z)(e.duration,!0)};this.interval=window.setInterval(t,1e3),t()}else{let s;switch(t){case ui.Z.PENDING:s=e.isOutgoing?"Call.StatusRinging":"Call.StatusCalling";break;case ui.Z.REQUESTING:s="Call.StatusRequesting";break;case ui.Z.EXCHANGING_KEYS:s="VoipExchangingKeys";break;case ui.Z.CLOSED:s=void 0!==e.connectedAt?"Call.StatusEnded":"Call.StatusFailed";break;default:s="Call.StatusConnecting"}i=(0,k.ag)(s),void 0!==this.interval&&(clearInterval(this.interval),this.interval=void 0)}this.container.classList.toggle("has-duration",t===ui.Z.CONNECTED),(0,Z.Z)(this.container,i),this.container.parentElement||this.appendTo.append(this.container)}}var mi=i(925);class gi extends bt{constructor(e,t){super({width:36,height:36,getPart:e=>this.getItem().getPart(e?"unmute":"mute"),getColor:e?e=>e?[255,255,255]:[158,158,158]:void 0,skipAnimation:t}),this.add({name:"voice_mini",parts:[{startFrame:0,endFrame:35,name:"hand-to-muted"},{startFrame:36,endFrame:68,name:"unmute"},{startFrame:69,endFrame:98,name:"mute"},{startFrame:99,endFrame:135,name:"muted-to-hand"},{startFrame:136,endFrame:171,name:"unmuted-to-hand"}]})}}const vi="call",bi={width:400,height:580};let yi=Object.assign({},bi);class wi extends V.Z{constructor(e){super("popup-call",{withoutOverlay:!0,closable:!0}),this.instance=e,this.onFullScreenClick=()=>{(0,Lt.Dj)(this.container)},this.onFullScreenChange=()=>{const e=(0,Lt.rB)(),{btnFullScreen:t,btnExitFullScreen:i}=this,n=this.container.classList.contains("is-full-screen");this.container.classList.toggle("is-full-screen",e),t&&t.classList.toggle("hide",e),i&&i.classList.toggle("hide",!e),this.btnClose.classList.toggle("hide",e),e!==n&&(s.Z.checkAnimations(e),De.Z.setThemeColor(e?"#000000":void 0),this.resizeVideoContainers())},this.videoContainers={};const{container:t,listenerSetter:i}=this;t.classList.add(vi,"night");const n=document.createElement("div");n.classList.add(vi+"-avatar");const a=this.peerId=this.instance.interlocutorUserId.toPeerId(),o=new m.Z;o.classList.add("avatar-full"),o.updateWithOptions({isBig:!0,peerId:a}),n.append(o);const r=new M.Z({peerId:a}).element;r.classList.add(vi+"-title");const d=document.createElement("div");d.classList.add(vi+"-subtitle"),this.description=new fi(d);const l=this.emojisSubtitle=document.createElement("div");l.classList.add(vi+"-emojis"),t.append(n,r,d),f.IS_MOBILE?this.header.append(l):(this.btnFullScreen=(0,v.Z)("fullscreen"),this.btnExitFullScreen=(0,v.Z)("smallscreen hide"),(0,L.fc)(this.btnFullScreen,this.onFullScreenClick,{listenerSetter:i}),(0,L.fc)(this.btnExitFullScreen,(()=>(0,Lt.C8)()),{listenerSetter:i}),(0,Lt.Ms)(this.container,this.onFullScreenChange,i),this.header.prepend(this.btnExitFullScreen),this.header.append(this.btnFullScreen),t.append(l)),this.partyStates=document.createElement("div"),this.partyStates.classList.add(vi+"-party-states"),this.partyMutedState=document.createElement("div"),this.partyMutedState.classList.add(vi+"-party-state");const c=(0,k.ag)("VoipUserMicrophoneIsOff",[new M.Z({peerId:a,onlyFirstName:!0,limitSymbols:18}).element]);c.classList.add(vi+"-party-state-text");const h=new gi(!1,!0);h.setState(!1,!1),this.partyMutedState.append(h.container,c),this.partyStates.append(this.partyMutedState),this.container.append(this.partyStates),this.makeButton=Yt.bind(null,vi,this.listenerSetter),this.constructFirstButtons(),this.constructSecondButtons(),i.add(e)("state",(()=>{this.updateInstance()})),i.add(e)("mediaState",(()=>{this.updateInstance()})),this.movablePanel=new si({listenerSetter:i,movableOptions:{minWidth:400,minHeight:580,element:this.element,verifyTouchTarget:e=>{const t=e.target;return!((0,X.Z)(t,"call-button")||(0,X.Z)(t,"btn-icon")||(0,Lt.rB)())}},previousState:this.instance.wasTryingToJoin||this.instance.isOutgoing?yi:Object.assign({},bi)});const u=this.movablePanel.movable;u&&this.listenerSetter.add(u)("resize",(()=>{this.resizeVideoContainers()}));const p=this.controlsHover=new Nt.Z;p.setup({element:this.container,listenerSetter:this.listenerSetter,showOnLeaveToClassName:"call-buttons"}),p.showControls(!1),this.addEventListener("close",(()=>{const{movablePanel:e}=this;yi=e.state,this.microphoneIcon.destroy(),e.destroy()})),this.updateInstance()}getCallInstance(){return this.instance}constructFirstButtons(){const e=this.firstButtonsRow=document.createElement("div");e.classList.add(vi+"-buttons","is-first");const t=ni.bind(null,"btn-disabled"),i=this.btnVideo=this.makeButton({text:"Call.Camera",icon:"videocamera_filled",callback:()=>{const e=t([i,s],!0);this.instance.toggleVideoSharing().finally(e)}}),s=this.btnScreen=this.makeButton({text:"Call.Screen",icon:"sharescreen_filled",callback:()=>{const e=t([i,s],!0);this.instance.toggleScreenSharing().finally(e)}});qt.Z||(s.classList.add("hide"),this.container.classList.add("no-screen")),this.muteI18nElement=new k.ZP.IntlElement({key:"Call.Mute"});const n=this.btnMute=this.makeButton({text:this.muteI18nElement.element,callback:()=>{this.instance.toggleMuted()}}),a=this.microphoneIcon=new gi(!0,!0);n.firstElementChild.append(a.container),e.append(i,s,n),this.container.append(e)}constructSecondButtons(){const e=this.secondButtonsRow=document.createElement("div");e.classList.add(vi+"-buttons","is-second"),this.declineI18nElement=new k.ZP.IntlElement({key:"Call.Decline"});const t=this.btnDecline=this.makeButton({text:this.declineI18nElement.element,icon:"endcall_filled",callback:()=>{this.instance.hangUp("phoneCallDiscardReasonHangup")},isDanger:!0}),i=this.btnAccept=this.makeButton({text:"Call.Accept",icon:"phone_filled",callback:()=>{this.instance.acceptCall()},isConfirm:!0});e.append(t,i),this.container.append(e)}createVideoContainer(e){const t=vi+"-video",i=document.createElement("div");i.classList.add(t+"-container"),e.classList.add(t),e.paused&&e.play(),(0,L.fc)(i,(()=>{if(!i.classList.contains("small"))return;const e=Object.values(this.videoContainers).find((e=>!e.classList.contains("small")));e.classList.add("small"),e.style.cssText=i.style.cssText,i.classList.remove("small"),i.style.cssText="",this.resizeVideoContainers()}));const s=Ut(e);return s.classList.add(t+"-blur"),i.append(s,e),i}updateInstance(){const{instance:e}=this,{connectionState:t}=e;if(t===ui.Z.CLOSED)return this.container.classList.contains("is-full-screen")&&(0,Lt.C8)(),this.btnVideo.classList.add("disabled"),void this.hide();const i=!e.isOutgoing&&t===ui.Z.PENDING;this.declineI18nElement.compareAndUpdate({key:t===ui.Z.PENDING?"Call.Decline":"Call.End"}),this.btnAccept.classList.toggle("disable",!i),this.btnAccept.classList.toggle("hide-me",!i),this.container.classList.toggle("two-button-rows",i);const s=e.isMuted,n=()=>{this.btnMute.firstElementChild.classList.toggle("active",s)},a=this.microphoneIcon.getItem().player;this.microphoneIcon.setState(!s,!s,n),a||n(),this.muteI18nElement.compareAndUpdate({key:s?"VoipUnmute":"Call.Mute"});const o=e.isSharingVideo;this.btnVideo.firstElementChild.classList.toggle("active",o);const r=e.isSharingScreen;this.btnScreen.firstElementChild.classList.toggle("active",r);const d=e.getMediaState("output");(0,ve.Z)({element:this.partyMutedState,className:"is-visible",forwards:!!(null==d?void 0:d.muted),duration:300});const l=this.videoContainers,c=Object.assign({},l);["input","output"].forEach((t=>{const i=e.getMediaState(t),s=e.getVideoElement(t),n=!!(s&&s.videoWidth&&s.videoHeight);!s||n||s.dataset.hasPromise||(s.dataset.hasPromise="1",(0,mi.Z)(s).then((()=>{delete s.dataset.hasPromise,this.updateInstance()})));const a=!!s&&n&&!(!i||"active"!==i.videoState&&"active"!==i.screencastState);let o=l[t];a&&s&&!o&&(o=l[t]=this.createVideoContainer(s),this.container.append(o)),!a&&o&&(o.remove(),delete l[t])}));{const e=l.input,t=l.output;Object.keys(c).length!==Object.keys(l).length&&e&&e.classList.toggle("small",!!t),t&&!e&&t.classList.remove("small")}this.resizeVideoContainers(),this.container.classList.toggle("no-video",!Object.keys(l).length),!this.emojisSubtitle.textContent&&t<ui.Z.EXCHANGING_KEYS&&Promise.resolve(e.getEmojisFingerprint()).then((e=>{(0,Z.Z)(this.emojisSubtitle,(0,_.Z)(e.join("")))})),this.setDescription()}resizeVideoContainers(){Object.values(this.videoContainers).forEach((e=>{if(e.classList.contains("small")){const t=e.querySelector("video"),i=this.movablePanel.state,s=240,n=240,a=t.videoHeight>t.videoWidth,o=a?n:s,r=1/3*((0,Lt.rB)()?65535:a?i.height:i.width),d=a?t.videoWidth/t.videoHeight:1,l=a?1:t.videoHeight/t.videoWidth;e.style.width=r*d+"px",e.style.height=r*l+"px",e.style.maxWidth=o*d+"px",e.style.maxHeight=o*l+"px"}else e.style.cssText=""}))}setDescription(){this.description.update(this.instance)}}var Si=i(2069),Ci=i(9585),Li=i(2493);const Ei="topbar-call";class Ii{constructor(e){this.managers=e,this.onState=()=>{this.updateInstance(this.instance)};const t=this.listenerSetter=new U.Z;t.add(Li.Z)("instance",(({instance:e})=>{this.instance||this.updateInstance(e)})),t.add(Li.Z)("accepting",(e=>{this.instance!==e&&this.updateInstance(e)})),t.add(ce.ZP)("instance",(e=>{this.updateInstance(e)})),t.add(d.Z)("group_call_update",(e=>{const t=ce.ZP.groupCall;(null==t?void 0:t.id)===e.id&&this.updateInstance(t)})),t.add(Ci.Z.ANALYSER_LISTENER)("amplitude",(({amplitudes:e,type:t})=>{const{weave:i}=this;if(!e.length||!i)return;let s=0;for(let t=0;t<e.length;++t){const{type:i,value:n}=e[t];s=n>s?n:s}i.setAmplitude(s)}))}clearCurrentInstance(){this.instance&&(this.center.textContent="",this.currentDescription&&(this.currentDescription.detach(),this.currentDescription=void 0),this.instance=void 0,this.instanceListenerSetter.removeAll())}updateInstance(e){this.construct&&(this.construct(),this.construct=void 0);const t=this.instance!==e;t&&(this.clearCurrentInstance(),this.instance=e,this.instanceListenerSetter=new U.Z,this.instanceListenerSetter.add(e)("state",this.onState),e instanceof hi.Z?this.currentDescription=this.groupCallDescription:(this.currentDescription=this.callDescription,this.instanceListenerSetter.add(e)("muted",this.onState)),this.container.classList.toggle("is-call",!(e instanceof hi.Z)));const i=this.instance.isMuted,s=e instanceof hi.Z?e.state:function(e,t){switch(e){case ui.Z.CLOSING:case ui.Z.CLOSED:return lt.Z.CLOSED;case ui.Z.CONNECTED:return t?lt.Z.MUTED:lt.Z.UNMUTED;default:return lt.Z.CONNECTING}}(e.connectionState,i),{weave:n}=this;n.componentDidMount();const a=s===lt.Z.CLOSED;(!document.body.classList.contains("is-calling")||t||a)&&(a&&n.setAmplitude(0),(0,ve.Z)({element:document.body,className:"is-calling",forwards:!a,duration:250,onTransitionEnd:a?()=>{n.componentWillUnmount(),this.clearCurrentInstance()}:void 0})),a||(n.setCurrentState(s,!0),this.setTitle(e),this.setDescription(e),this.groupCallMicrophoneIconMini.setState(!i))}setDescription(e){return this.currentDescription.update(e)}setTitle(e){if(e instanceof hi.Z)return this.groupCallTitle.update(e);(0,Z.Z)(this.center,new M.Z({peerId:e.interlocutorUserId.toPeerId()}).element)}construct(){const{listenerSetter:e}=this,t=this.container=document.createElement("div");t.classList.add("sidebar-header",Ei+"-container");const i=document.createElement("div");i.classList.add(Ei+"-left");const s=this.groupCallMicrophoneIconMini=new gi,n=(0,v.Z)();n.append(s.container),i.append(n);const a=(0,G.Z)((()=>{this.instance.toggleMuted()}),600,!0);(0,L.fc)(n,(e=>{(0,C.Z)(e),a()}),{listenerSetter:e});const o=this.center=document.createElement("div");o.classList.add(Ei+"-center"),this.groupCallTitle=new $t(o),this.groupCallDescription=new Wt(i),this.callDescription=new fi(i);const r=document.createElement("div");r.classList.add(Ei+"-right");const d=(0,v.Z)("endcall_filled");r.append(d),(0,L.fc)(d,(e=>{(0,C.Z)(e);const{instance:t}=this;t&&(t instanceof hi.Z?t.hangUp():t.hangUp("phoneCallDiscardReasonHangup"))}),{listenerSetter:e}),(0,L.fc)(t,(()=>{if(this.instance instanceof hi.Z){if(V.Z.getPopups(ci).length)return;V.Z.createPopup(ci).show()}else if(this.instance instanceof Si.Z){if(V.Z.getPopups(wi).find((e=>e.getCallInstance()===this.instance)))return;V.Z.createPopup(wi,this.instance).show()}}),{listenerSetter:e}),t.append(i,o,r);const l=this.weave=new ut,c=l.render(Ei+"-weave");t.prepend(c),document.getElementById("column-center").prepend(t),l.componentDidMount()}}var Pi=i(2614),Zi=i(8479),Mi=i(7401),ki=i(2575),Ti=i(6009),xi=i(493),Ai=i(496),_i=i(3189),Fi=i(2131),Di=i(3725),Ri=i(2890),Bi=i(2586),Ni=i(7298),Oi=i(6702),Ui=i(7746),Hi=i(3785),zi=i(2491),ji=i(1722),Gi=i(3781),Vi=i(4993),Ki=i(5990),Wi=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};const $i=new class{constructor(){this.notificationsShown={},this.notificationIndex=0,this.notificationsCount=0,this.soundsPlayed={},this.vibrateSupport=Fi.Z,this.faviconElements=Array.from(document.head.querySelectorAll('link[rel="icon"], link[rel="alternate icon"]')),this.titleBackup=document.title,this.titleChanged=!1,this.stopped=!1,this.settings={},this.pushInited=!1,this.updateLocalSettings=()=>{const e=["notify_nodesktop","notify_volume","notify_novibrate","notify_nopreview","notify_nopush"].map((()=>{}));Promise.all(e).then((e=>{if(this.settings.nodesktop=e[0],this.settings.volume=void 0===e[1]?.5:e[1],this.settings.novibrate=e[2],this.settings.nopreview=e[3],this.settings.nopush=e[4],this.pushInited){const e=!this.settings.nopush&&!this.settings.nodesktop&&Oi.default.isAvailable||!1;e!==(!1!==this.registeredDevice)&&(e?Oi.default.subscribe():Oi.default.unsubscribe())}Oi.default.setSettings(this.settings)})),he.Z.getState().then((e=>{this.settings.nosound=!e.settings.notifications.sound}))},this.requestPermission=()=>{Notification.requestPermission(),window.removeEventListener("click",this.requestPermission)}}construct(e){this.managers=e,this.log=(0,r.kg)("NOTIFICATIONS"),navigator.vibrate=navigator.vibrate||navigator.mozVibrate||navigator.webkitVibrate,this.setAppBadge=navigator.setAppBadge&&navigator.setAppBadge.bind(navigator),this.setAppBadge&&this.setAppBadge(0),this.notificationsUiSupport="Notification"in window||"mozNotification"in navigator,this.notifySoundEl=document.createElement("div"),this.notifySoundEl.id="notify-sound",document.body.append(this.notifySoundEl),this.topMessagesDeferred=(0,Di.Z)(),it.Z.addEventListener("deactivated",(()=>{this.stop()})),it.Z.addEventListener("activated",(()=>{this.stopped&&this.start()})),Bi.Z.addEventListener("change",(e=>{this.stopped||(e||this.clear(),this.toggleToggler())})),d.Z.addEventListener("notification_reset",(e=>{this.soundReset(e)})),d.Z.addEventListener("notification_cancel",(e=>{this.cancel(e)})),this.setAppBadge&&d.Z.addEventListener("folder_unread",(e=>{0===e.id&&this.setAppBadge(e.unreadUnmutedPeerIds.size)})),Oi.default.addEventListener("push_init",(e=>{this.pushInited=!0,this.settings.nodesktop||this.settings.nopush?this.unregisterDevice(e):e?this.registerDevice(e):Oi.default.subscribe()})),Oi.default.addEventListener("push_subscribe",(e=>{this.registerDevice(e)})),Oi.default.addEventListener("push_unsubscribe",(e=>{this.unregisterDevice(e)})),d.Z.addEventListener("dialogs_multiupdate",(()=>{this.topMessagesDeferred.resolve()}),{once:!0}),Oi.default.addEventListener("push_notification_click",(e=>{if("push_settings"===e.action)return;if("mute1d"===e.action)return void this.managers.apiManager.invokeApi("account.updateDeviceLocked",{period:86400}).then((()=>{}));const t=e.custom&&e.custom.peerId.toPeerId();console.log("click",e,t),t&&this.topMessagesDeferred.then((()=>Wi(this,void 0,void 0,(function*(){const i=t.isAnyChat()?t.toChatId():void 0;i&&!(yield this.managers.appChatsManager.hasChat(i))||t.isUser()&&!(yield this.managers.appUsersManager.hasUser(t.toUserId()))||Es.setInnerPeer({peerId:t,lastMsgId:(0,Gi.Z)(+e.custom.msg_id)})}))))}))}buildNotification({message:e,fwdCount:t,peerReaction:i,peerTypeNotifySettings:s}){return Wi(this,void 0,void 0,(function*(){const n=e.peerId,a=n.isAnyChat(),o={},[r,d=!1]=yield Promise.all([this.managers.appPeersManager.getPeerString(n),a&&this.managers.appPeersManager.isForum(n)]);let l,c=!1;if(s.show_previews)if("message"===e._&&e.fwd_from&&t>1)l=k.ZP.format("Notifications.Forwarded",!0,[t]);else{l=yield(0,Ai.Z)({message:e,plain:!0});const t=null==i?void 0:i.reaction;if("reactionEmoji"===(null==t?void 0:t._)){const e="Notification.Contact.Reacted",i=[(0,Ui.Z)(t.emoticon),l];l=k.ZP.format(e,!0,i)}else c=!0}else l=k.ZP.format("Notifications.New",!0);i&&(o.noIncrement=!0,o.silent=!0);const h={plainText:!0,managers:this.managers},u=d?(0,Vi.Z)(e,d):void 0,p=i?(0,Pt.Z)(i.peer_id):e.fromId,f=o.title=yield(0,xi.Z)(Object.assign(Object.assign({},h),{peerId:n,threadId:u}));if(d){const t=yield(0,xi.Z)(Object.assign(Object.assign({},h),{peerId:n}));o.title+=` (${t})`,c&&p!==e.peerId&&(l=(yield(0,xi.Z)(Object.assign(Object.assign({},h),{peerId:p})))+": "+l)}else a&&p!==e.peerId&&(o.title=(yield(0,xi.Z)(Object.assign(Object.assign({},h),{peerId:p})))+" @ "+o.title);o.title=(0,zi.Z)(o.title),o.onclick=()=>{Es.setInnerPeer({peerId:n,lastMsgId:e.mid,threadId:u})},o.message=l,o.key="msg"+e.mid,o.tag=r,o.silent=!0;const m=yield this.managers.appPeersManager.getPeerPhoto(n);if(m){const t=yield this.managers.appAvatarsManager.loadAvatar(n,m,"photo_small");if(!(i||(e=yield this.managers.appMessagesManager.getMessageByPeer(e.peerId,e.mid))&&e.pFlags.unread))return;o.image=t}else{let{avatarCanvas:e,avatarContext:t}=this;if(this.avatarCanvas)t.clearRect(0,0,e.width,e.height);else{e=this.avatarCanvas=document.createElement("canvas"),t=this.avatarContext=e.getContext("2d");const i=54,s=1;e.dpr=s,e.width=e.height=i*s,this.avatarGradients={}}const i=(0,Ki.Z)(n,!0);let s=this.avatarGradients[i];if(!s){s=this.avatarGradients[i]=t.createLinearGradient(e.width/2,0,e.width/2,e.height);const n=pt.Z.getProperty(`peer-avatar-${i}-top`),a=pt.Z.getProperty(`peer-avatar-${i}-bottom`);s.addColorStop(0,n),s.addColorStop(1,a)}t.fillStyle=s,(0,Ri.Z)(t,e.width/2,e.height/2,e.width/2),t.fill();const a=20*e.dpr,r=(0,Hi.Z)(f);t.font=`700 ${a}px ${_i.bt}`,t.textBaseline="middle",t.textAlign="center",t.fillStyle="white",t.fillText(r.text,e.width/2,e.height*(window.devicePixelRatio,.5625)),o.image=e.toDataURL()}const g={custom:{msg_id:""+e.mid,peerId:""+n},description:"",loc_key:"",loc_args:[],mute:"",random_id:0,title:""};(yield this.notify(o,g))&&this.registeredDevice&&Oi.default.ignorePushByMid(n,e.mid)}))}toggleToggler(e=Bi.Z.isIdle){if(f.IS_MOBILE)return;const t=e=>{this.titleChanged=!1,document.title=this.titleBackup,this.setFavicon()};window.clearInterval(this.titleInterval),this.titleInterval=0,e?this.titleInterval=window.setInterval((()=>{const e=this.notificationsCount;if(e)if(this.titleChanged)t();else{this.titleChanged=!0,document.title=k.ZP.format("Notifications.Count",!0,[e]);const t=document.createElement("canvas");t.width=32*window.devicePixelRatio,t.height=t.width;const i=t.getContext("2d");i.beginPath(),i.arc(t.width/2,t.height/2,t.width/2,0,2*Math.PI,!1),i.fillStyle="#3390ec",i.fill();let s=24,n=""+e;e<10?s=22:e<100?s=20:(n="99+",s=16),s*=window.devicePixelRatio,i.font=`700 ${s}px ${_i.bt}`,i.textBaseline="middle",i.textAlign="center",i.fillStyle="white",i.fillText(n,t.width/2,.5625*t.height),this.setFavicon(t.toDataURL())}else this.toggleToggler(!1)}),1e3):t()}setFavicon(e){this.prevFavicon!==e&&(this.prevFavicon=e,this.faviconElements.forEach(((t,i,s)=>{var n;const a=t.cloneNode();(n=a.dataset).href||(n.href=a.href),null!=e||(e=a.dataset.href),a.href=e,t.replaceWith(s[i]=a)})))}notify(e,t){var i;return Wi(this,void 0,void 0,(function*(){if(this.log("notify",e,Bi.Z.isIdle,this.notificationsUiSupport,this.stopped),this.stopped)return;e.image||(e.image="assets/img/logo_filled_rounded.png"),e.noIncrement||++this.notificationsCount,this.titleInterval||this.toggleToggler();const s=++this.notificationIndex,n=e.key||"k"+s;this.notificationsShown[n]=!0;const a=(0,Ni.Z)();if(this.settings.volume>0&&!this.settings.nosound&&(this.testSound(this.settings.volume),this.soundsPlayed[e.tag]=a),!this.notificationsUiSupport||"Notification"in window&&"granted"!==Notification.permission)return;if(this.settings.nodesktop)return this.vibrateSupport&&!this.settings.novibrate?void navigator.vibrate([200,100,200]):void 0;if(!("Notification"in window))return;let o;const r={badge:"assets/img/logo_plain.svg",icon:e.image||"",body:e.message||"",tag:e.tag||"",silent:e.silent||!1,data:t};try{if(e.tag)for(const t in this.notificationsShown){const i=this.notificationsShown[t];"boolean"!=typeof i&&i.tag===e.tag&&(i.hidden=!0)}o=new Notification(e.title,r)}catch(t){try{const t=yield navigator.serviceWorker.ready;yield t.showNotification(e.title,r);const i=yield t.getNotifications({tag:r.tag});o=i[i.length-1]}catch(t){this.log.error("creating push error",t,e,r)}if(!o)return this.notificationsUiSupport=!1,void Oi.default.setLocalNotificationsDisabled()}return o.onclick=()=>{var t;this.log("notification onclick"),o.close(),ji.Z.focus(),this.clear(),null===(t=e.onclick)||void 0===t||t.call(e)},o.onclose=()=>{this.log("notification onclose"),o.hidden||(delete this.notificationsShown[n],this.clear())},null===(i=o.show)||void 0===i||i.call(o),this.notificationsShown[n]=o,f.IS_MOBILE||setTimeout((()=>{this.hide(n)}),8e3),!0}))}getLocalSettings(){return this.settings}hide(e){const t=this.notificationsShown[e];t&&this.closeNotification(t)}soundReset(e){delete this.soundsPlayed[e]}testSound(e){const t=(0,Ni.Z)();if(this.nextSoundAt&&t<this.nextSoundAt&&this.prevSoundVolume===e)return;this.nextSoundAt=t+1e3,this.prevSoundVolume=e;const i="assets/audio/notification.mp3",s=document.createElement("audio");s.autoplay=!0,s.setAttribute("mozaudiochannel","notification"),s.volume=e,s.innerHTML=`\n <source src="${i}" type="audio/mpeg" />\n <embed hidden="true" autostart="true" loop="false" volume="${100*e}" src="${i}" />\n `,this.notifySoundEl.append(s),s.addEventListener("ended",(()=>{s.remove()}),{once:!0})}cancel(e){const t=this.notificationsShown[e];this.log("cancel",e,t),t&&(this.notificationsCount>0&&--this.notificationsCount,this.closeNotification(t),delete this.notificationsShown[e])}closeNotification(e){try{"boolean"!=typeof e&&e.close&&(this.log("close notification",e),e.hidden=!0,e.close())}catch(e){}}clear(){this.log.warn("clear");for(const e in this.notificationsShown){const t=this.notificationsShown[e];this.closeNotification(t)}this.notificationsShown={},this.notificationsCount=0,Oi.default.hidePushNotifications()}start(){if(this.log("start"),this.updateLocalSettings(),d.Z.addEventListener("settings_updated",this.updateLocalSettings),Oi.default.start(),!this.notificationsUiSupport)return!1;"Notification"in window&&"granted"!==Notification.permission&&"denied"!==Notification.permission&&window.addEventListener("click",this.requestPermission);try{"onbeforeunload"in window&&window.addEventListener("beforeunload",this.clear)}catch(e){}}stop(){this.log("stop"),this.clear(),window.clearInterval(this.titleInterval),this.titleInterval=0,this.setFavicon(),this.stopped=!0}registerDevice(e){if(this.registeredDevice&&(0,ke.Z)(this.registeredDevice,e))return!1;this.managers.apiManager.invokeApi("account.registerDevice",{token_type:e.tokenType,token:e.tokenValue,other_uids:[],app_sandbox:!1,secret:new Uint8Array}).then((()=>{this.log("registered device"),this.registeredDevice=e}),(e=>{e.handled=!0}))}unregisterDevice(e){if(!this.registeredDevice)return!1;this.managers.apiManager.invokeApi("account.unregisterDevice",{token_type:e.tokenType,token:e.tokenValue,other_uids:[]}).then((()=>{this.registeredDevice=!1}),(e=>{e.handled=!0}))}};Je.GO&&(Je.GO.uiNotificationsManager=$i);const qi=$i;var Yi=i(2423),Qi=i(5400),Xi=i(3591),Ji=i(3061),es=i(177),ts=i(236),is=i(5936),ss=i(3815),ns=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};function as(e,t=!1){return ns(this,void 0,void 0,(function*(){const i=[],s=(e,n)=>ns(this,void 0,void 0,(function*(){if(e.isDirectory){const t=e.createReader();yield new Promise(((e,i)=>{t.readEntries((t=>ns(this,void 0,void 0,(function*(){for(const e of t)yield s(e,n);e()}))))}))}else if(e)if(t)i.push(e.type);else{const t=n.getAsFile(),s=e instanceof File?e:e instanceof DataTransferItem?e.getAsFile():yield new Promise(((i,s)=>e.file(i,(e=>i(t)))));if(!s)return;i.push(s)}}));if(e instanceof DragEvent&&e.dataTransfer.files&&!e.dataTransfer.items)for(let s=0;s<e.dataTransfer.files.length;s++){const n=e.dataTransfer.files[s];i.push(t?n.type:n)}else{const i=(e.dataTransfer||e.clipboardData||e.originalEvent.clipboardData).items,n=[];for(let e=0;e<i.length;++e){const a=i[e];if("file"===a.kind){const e=(t?a:a.webkitGetAsEntry())||a.getAsFile();n.push(s(e,a))}}yield Promise.all(n)}return i}))}var os=i(5180),rs=i(8683),ds=i(1564),ls=i(764);function cs(e){window[(e.protocol?e.protocol+"_":"")+e.name]=t=>{!e.noCancelEvent&&(0,C.Z)(null);let i,s,n=t.href;if(!n)return;const a=new URL(n),o=a.host.match(/(.+?)\.t(?:elegram)?\.me/);o&&!pe.BX.has(o[1])&&(a.pathname=o[1]+("/"===a.pathname?"":a.pathname),n=a.toString()),e.noPathnameParams||(i=new URL(n).pathname.split("/").slice(1)),e.noUriParams||(s=(0,ls.Z)(n));const r=e.callback({pathnameParams:i,uriParams:s},t);return void 0===r&&r}}var hs=i(4524),us=i(9439),ps=i(54),fs=i(3772),ms=i(9807),gs=i(7479);const vs="popup-gift-premium";class bs extends V.Z{constructor(e,t){super(vs,{closable:!0,overlayClosable:!0,body:!0,scrollable:!0}),this.peerId=e,this.giftOptions=t,this.construct()}construct(){return e=this,t=void 0,s=function*(){const{peerId:e,giftOptions:t}=this,i=new m.Z;i.classList.add("avatar-100",vs+"-avatar"),yield i.updateWithOptions({peerId:e});const s=document.createElement("span");(0,k.$d)(s,"GiftTelegramPremiumTitle"),s.classList.add(vs+"-title");const n=(0,k.ag)("GiftTelegramPremiumDescription",[yield(0,le.Z)({peerId:e})]);n.classList.add(vs+"-subtitle");const a=this.giftOptions.slice().sort(((e,t)=>e.months-t.months))[0],o=e=>(0,os.Z)(e,a.currency,!1,!0),r=this.giftOptions.map(((e,t)=>{let i=(0,k.ag)("PricePerMonth",[o(+e.amount/e.months)]);if(e!==a){const t=document.createElement("span"),s=document.createElement("span");s.classList.add(vs+"-discount");const n=+a.amount*e.months/a.months,o=Math.round(100*(1-+e.amount/n));s.textContent="-"+o+"%",t.append(s,i),i=t}const s=!(e.months%12),n=new ms.Z({checked:0===t,round:!0,name:"gift-months",asRadio:!0}),r=new gs.ZP({title:(0,k.ag)(s?"Years":"Months",[s?e.months/12:e.months]),checkboxField:n,clickable:!0,subtitle:i,titleRightSecondary:o(e.amount)});return r.container.classList.add(vs+"-option"),r})),d=document.createElement("form");d.classList.add(vs+"-options"),d.append(...r.map((e=>e.container)));const l=new k.ZP.IntlElement({key:"GiftSubscriptionFor",args:[o(t[0].amount)]}),c=()=>t[r.findIndex((e=>e.checkboxField.checked))];this.listenerSetter.add(d)("change",(()=>{l.compareAndUpdate({args:[o(c().amount)]})}));const h=(0,g.Z)(`btn-primary ${vs}-confirm shimmer`);h.append(l.element),(0,L.fc)(h,(()=>{const e=c();Es.openUrl(e.bot_url),this.hide()}),{listenerSetter:this.listenerSetter}),this.scrollable.append(i,s,n,d,h),this.show()},new((i=void 0)||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}));var e,t,i,s}}var ys,ws=i(8938),Ss=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};!function(e){e[e.CHATLIST=0]="CHATLIST",e[e.CHAT=1]="CHAT",e[e.PROFILE=2]="PROFILE"}(ys||(ys={}));class Cs extends l.Z{constructor(){super(...arguments),this.columnEl=document.getElementById("column-center"),this.offline=!1,this.updateStatusInterval=0,this.setPeerPromise=null,this.chats=[],this.cacheStorage=new is.Z("cachedFiles"),this.onHashChange=e=>{try{this.onHashChangeUnsafe(e)}catch(e){this.log.error("hash change error",e)}},this.onHashChangeUnsafe=e=>{const t=location.hash;e||Q.Z.replaceState();const i=t.split("?"),s=(0,ls.Z)(t,i);if(this.log("hashchange",t,i[0],s),t)if(s.tgaddr)this.openUrl(s.tgaddr);else switch(i[0]){default:s.p=i[0].slice(1);case"#/im":{if(!Object.keys(s).length)break;const e=s.p,t=void 0!==s.post?(0,Gi.Z)(+s.post):void 0;"@"===e[0]?this.openUsername({userName:e,lastMsgId:t}):this.setInnerPeer({peerId:t?e.toPeerId(!0):e.toPeerId(),lastMsgId:t})}}},this.setSettings=()=>{const{messagesTextSize:e}=d.Z.settings;this.customEmojiSize=(0,ue.C)(e+4,e+4),document.documentElement.style.setProperty("--messages-text-size",e+"px"),this.customEmojiSize&&(document.querySelectorAll("middle-ellipsis-element").forEach((t=>{t.disconnectedCallback(),t.dataset.fontSize=""+e,t.title&&(t.textContent=t.title),t.connectedCallback()})),document.querySelectorAll(".chat custom-emoji-renderer-element").forEach((e=>{e.forceRenderAfterSize=!0}))),document.body.classList.toggle("animation-level-0",!Ne.Z.isAvailable("animations")),document.body.classList.toggle("animation-level-1",!1),document.body.classList.toggle("animation-level-2",Ne.Z.isAvailable("animations")),this.chatsSelectTabDebounced=(0,j.Z)((()=>{var e;null===(e=this.chat.topbar.pinnedMessage)||void 0===e||e.setCorrectIndex(0),this.managers.apiFileManager.setQueueId(this.chat.bubbles.lazyLoadQueue.queueId)}),Ne.Z.isAvailable("animations")?250:0,!1,!0);const t=s.Z.setLoop(d.Z.settings.stickers.loop),i=!!["stickers_chat","stickers_panel"].filter((e=>s.Z.setAutoplay(Ne.Z.isAvailable(e),e))).length;(t||i)&&s.Z.checkAnimations2(!1);for(const e of this.chats)e.setAutoDownloadMedia();k.ZP.setTimeFormat(d.Z.settings.timeFormat),this.toggleChatGradientAnimation(this.chat)},this.onDocumentPaste=(e,t)=>Ss(this,void 0,void 0,(function*(){const i=(0,He.Y)();if(e instanceof DragEvent){const t=e.dataTransfer.types;(t.contains?t.contains("Files"):t.indexOf("Files")>=0)&&(0,C.Z)(e)}const s=yield as(e);if(((yield this.canDrag())||i)&&s.length){if(i)return void i.addFiles(s);const e=this.chat.input;e.willAttachType=t||(ot.Z.has(s[0].type)?"media":"document"),V.Z.createPopup(He.Z,this.chat,s,e.willAttachType)}}))}get myId(){return d.Z.myId}get chat(){return this.chats[this.chats.length-1]}construct(e){this.managers=e;const{apiUpdatesManager:t}=e;t.attach(k.ZP.lastRequestedLangCode),y.Z.construct(e),qi.construct(e),qi.start(),this.log=(0,r.kg)("IM",r.v9.Log|r.v9.Warn|r.v9.Debug|r.v9.Error),this.backgroundPromises={},ts.h.settings.themes.forEach((e=>{const t=e.settings;if(!t)return;const{wallpaper:i}=t,s=i.slug;if(!s)return;const n="assets/img/"+s+".svg"+(f.IS_FIREFOX?"?1":"");this.backgroundPromises[s]=Promise.resolve(n)})),this.selectTab(ys.CHATLIST),Bi.Z.addEventListener("change",(e=>{this.offline=e,this.updateStatus(),e?clearInterval(this.updateStatusInterval):this.updateStatusInterval=window.setInterval((()=>this.updateStatus()),5e4)})),this.chatsContainer=document.createElement("div"),this.chatsContainer.classList.add("chats-container","tabs-container"),this.chatsContainer.dataset.animation="navigation",this.emojiAnimationContainer=document.createElement("div"),this.emojiAnimationContainer.classList.add("emoji-animation-container"),this.appendEmojiAnimationContainer(o.Z.activeScreen),this.columnEl.append(this.chatsContainer),this.createNewChat(),this.chatsSelectTab(this.chat.container),Q.Z.onHashChange=this.onHashChange,this.setSettings(),d.Z.addEventListener("settings_updated",this.setSettings);const i=e=>{document.body.classList.toggle("is-premium",e)};d.Z.addEventListener("premium_toggle",i),i(d.Z.premium),this.managers.rootScope.getPremium().then(i),(0,H.ZP)((()=>{s.Z.setOnlyOnePlayableGroup("lock"),s.Z.checkAnimations2(!0)}),(()=>{s.Z.setOnlyOnePlayableGroup(),s.Z.checkAnimations2(!1)})),De.Z.AppBackgroundTab=us.Z,f.IS_FIREFOX&&he.Z.oldVersion&&-1===(0,Ti.Z)(he.Z.oldVersion,"1.4.3")?this.deleteFilesIterative((e=>"image/svg+xml"===e.headers.get("Content-Type"))).then((()=>{this.applyCurrentTheme()})):this.applyCurrentTheme(),o.Z.addEventListener("changeScreen",((e,t)=>{document.body.classList.contains(n.ir)&&document.body.classList.contains(a.HQ)&&a.ZP.toggleSidebar(!1),this.appendEmojiAnimationContainer(t)})),o.Z.addEventListener("resize",(()=>{const e=this.chatsContainer.getBoundingClientRect();Ae.resizeInstances(e.width,e.height).then((()=>{}))})),this.addEventListener("peer_changing",(e=>{this.saveChatPosition(e)})),d.Z.addEventListener("theme_change",(()=>{this.applyCurrentTheme()})),d.Z.addEventListener("choosing_sticker",(e=>{this.setChoosingStickerTyping(!e)})),d.Z.addEventListener("peer_title_edit",(({peerId:e,threadId:t})=>{var i;(null===(i=this.chat)||void 0===i?void 0:i.peerId)!==e||t||void 0===this.tabId||this.overrideHash(e)})),d.Z.addEventListener("peer_typings",(({peerId:e,typings:t})=>{var i;const s=this.chat;if(!s||s.peerId!==e||ss.Z.isOverlayActive||o.Z.activeScreen===o._.mobile&&this.tabId!==ys.CHAT)return;const n=t.find((e=>"sendMessageEmojiInteraction"===e.action._));if("sendMessageEmojiInteraction"===(null===(i=null==n?void 0:n.action)||void 0===i?void 0:i._)){const t=n.action,i=s.bubbles.bubbles[(0,Gi.Z)(n.action.msg_id)];if(i&&i.classList.contains("emoji-big")&&(0,je.Z)(i,s.bubbles.scrollable.container)){const s=i.querySelector(".media-sticker-wrapper:not(.bubble-hover-reaction-sticker):not(.reaction-sticker)");JSON.parse(t.interaction.data).a.forEach((e=>{setTimeout((()=>{(0,L.tH)(s)}),1e3*e.t)})),this.managers.appMessagesManager.setTyping(e,{_:"sendMessageEmojiInteractionSeen",emoticon:t.emoticon})}}}));const l=e=>{const t="version"===e,i=V.Z.createPopup(V.Z,"popup-instance-deactivated",{overlayClosable:!0}),s=document.createElement("div");s.classList.add("instance-deactivated-container"),i.container.replaceWith(s);const n=document.createElement("div");n.classList.add("header"),n.append((0,k.ag)(t?"Deactivated.Version.Title":"Deactivated.Title"));const a=document.createElement("div");a.classList.add("subtitle"),a.append((0,k.ag)(t?"Deactivated.Version.Subtitle":"Deactivated.Subtitle")),s.append(n,a),document.body.classList.add("deactivated");const o=t?()=>{ji.Z.reload()}:()=>{document.body.classList.add("deactivated-backwards"),it.Z.activateInstance(),setTimeout((()=>{document.body.classList.remove("deactivated","deactivated-backwards")}),333)};i.addEventListener("close",o),i.show()};it.Z.addEventListener("deactivated",l),it.Z.deactivatedReason&&l(it.Z.deactivatedReason),this.addEventListener("chat_changing",(({to:e})=>{this.toggleChatGradientAnimation(e)})),d.Z.addEventListener("service_notification",(e=>{(0,Mt.Z)({button:{langKey:"OK",isCancel:!0},description:(0,Qi.ZP)(e.message)})})),d.Z.addEventListener("payment_sent",(({peerId:e,mid:t,receiptMessage:i})=>Ss(this,void 0,void 0,(function*(){const s=yield this.managers.appMessagesManager.getMessageByPeer(e,t);if(!s)return;const n=i.action;(0,te.bC)({langPackKey:"PaymentInfoHint",langPackArguments:[(0,os.Z)(n.total_amount,n.currency),(0,_.Z)(s.media.title)]})})))),window.onSpoilerClick=e=>{const t=(0,X.Z)(e.target,"spoiler"),i=(0,X.Z)(t,"spoilers-container")||t.parentElement,s="is-spoiler-visible",n=i.classList.contains(s);n||((0,C.Z)(e),"click"!==L.pf&&window.addEventListener("click",C.Z,{capture:!0,once:!0}));const a=n?0:2;a&&i.classList.add("will-change");const o=i.dataset.spoilerTimeout;null!==o&&(clearTimeout(+o),delete i.dataset.spoilerTimeout),(0,ve.Z)({element:i,className:s,forwards:!0,duration:200,onTransitionEnd:()=>{i.dataset.spoilerTimeout=""+window.setTimeout((()=>{(0,ve.Z)({element:i,className:s,forwards:!1,duration:200,onTransitionEnd:()=>{i.classList.remove("will-change"),delete i.dataset.spoilerTimeout}})}),5e3)},useRafs:a})},document.addEventListener("mousemove",(e=>{const t=(0,X.Z)(e.target,"media-sticker-wrapper");if(!t||t.classList.contains("custom-emoji")||(0,X.Z)(e.target,"emoji-big"))return;const i=s.Z.getAnimations(t);null==i||i.forEach((e=>{const{liteModeKey:t,animation:i}=e;t&&(null==i?void 0:i.paused)&&!Ne.Z.isAvailable(t)&&(i instanceof fs.Z?i.playOrRestart():i.play())}))})),d.Z.addEventListener("sticker_updated",(({type:e,faved:t})=>{"faved"===e?(0,te.bC)({langPackKey:t?"AddedToFavorites":"RemovedFromFavorites"}):t||(0,te.bC)({langPackKey:"RemovedFromRecent"})})),he.Z.addEventListener("notificationBuild",(e=>Ss(this,void 0,void 0,(function*(){const t=yield this.managers.appPeersManager.isForum(e.message.peerId),i=(0,Vi.Z)(e.message,t);(this.chat.peerId!==e.message.peerId||this.chat.threadId!==i||Bi.Z.isIdle)&&qi.buildNotification(e)})))),this.addEventListener("peer_changed",(({peerId:e})=>Ss(this,void 0,void 0,(function*(){document.body.classList.toggle("has-chat",!!e),this.emojiAnimationContainer.textContent="",this.overrideHash(e),he.Z.updateTabState("chatPeerIds",this.chats.map((e=>e.peerId)).filter(Boolean))})))),Xe.Z.setToCache("chatPositions",{}),(oe.Z||ae.Z)&&(this.topbarCall=new Ii(e)),oe.Z&&(Li.Z.addEventListener("instance",(({instance:e})=>{const t=V.Z.createPopup(wi,e);e.addEventListener("acceptCallOverride",(()=>this.discardCurrentCall(e.interlocutorUserId.toPeerId(),void 0,e).then((()=>(Li.Z.dispatchEvent("accepting",e),!0))).catch((()=>!1)))),t.addEventListener("close",(()=>{const t=Li.Z.currentCall;t&&t!==e&&!e.wasTryingToJoin&&e.hangUp("phoneCallDiscardReasonBusy")}),{once:!0}),t.show()})),Li.Z.addEventListener("incompatible",(e=>Ss(this,void 0,void 0,(function*(){(0,te.bC)({langPackKey:"VoipPeerIncompatible",langPackArguments:[yield(0,le.Z)({peerId:e.toPeerId()})]})}))))),it.Z.activateInstance();const c=()=>{dt.default.setAuthorized(!0)};setInterval(c,T.s2),c(),cs({name:"showMaskedAlert",callback:(e,t)=>{const i=t.href,s=t.cloneNode(!0);s.className="anchor-url",s.innerText=i,s.removeAttribute("onclick"),V.Z.createPopup(se.Z,"popup-masked-url",{titleLangKey:"OpenUrlTitle",descriptionLangKey:"OpenUrlAlert2",descriptionLangArgs:[s],buttons:[{langKey:"Open",callback:()=>{s.click()}}]}).show()}}),cs({name:"execBotCommand",callback:({uriParams:e})=>{const{command:t,bot:i}=e;this.managers.appMessagesManager.sendText(this.chat.peerId,"/"+t+(i?"@"+i:""))}}),cs({name:"searchByHashtag",callback:({uriParams:e})=>{const{hashtag:t}=e;t&&this.chat.initSearch("#"+t+" ")}}),cs({name:"setMediaTimestamp",callback:(e,t)=>{const i=+t.dataset.timestamp;(0,X.Z)(t,"bubble")?this.chat.bubbles.playMediaWithTimestamp(t,i):(0,X.Z)(t,"media-viewer-caption")&&window.appMediaViewer.setMediaTimestamp(i)}}),[["addstickers",at.z.STICKER_SET],["addemoji",at.z.EMOJI_SET]].forEach((([e,t])=>{cs({name:e,callback:({pathnameParams:e})=>{if(!e[1])return;const i={_:t,set:e[1]};this.processInternalLink(i)}}),cs({name:e,protocol:"tg",callback:({uriParams:e})=>{const i=this.makeLink(t,e);this.processInternalLink(i)}})})),cs({name:"invoice",callback:({pathnameParams:e})=>{const t={_:at.z.INVOICE,slug:e.length>1?e[1]:e[0].slice(1)};this.processInternalLink(t)}}),cs({name:"joinchat",callback:({pathnameParams:e})=>{const t={_:at.z.JOIN_CHAT,invite:e[1]||decodeURIComponent(e[0]).slice(1)};this.processInternalLink(t)}}),ae.Z&&cs({name:"voicechat",protocol:"tg",callback:({uriParams:e})=>{const t=this.makeLink(at.z.VOICE_CHAT,e);this.processInternalLink(t)}}),cs({name:"im",callback:({pathnameParams:e,uriParams:t},i)=>Ss(this,void 0,void 0,(function*(){let s;if(Yi.kO.test(e[0]))s={_:at.z.USER_PHONE_NUMBER,phone:e[0].slice(1)};else if("c"===e[0]){(0,ws.Z)(t),e.shift();const n="thread"in t?t.thread:e[2]&&e[1];s={_:at.z.PRIVATE_POST,channel:e[0],post:e[2]||e[1],thread:n,comment:t.comment,stack:this.getStackFromElement(i),t:t.t}}else{(0,ws.Z)(t);const n="thread"in t?t.thread:e[2]&&e[1];s={_:at.z.MESSAGE,domain:e[0],post:e[2]||e[1],thread:n,comment:t.comment,start:"start"in t?t.start:void 0,stack:this.getStackFromElement(i),t:t.t}}("startattach"in t||"attach"in t)&&((0,ws.Z)(t),s=Object.assign({_:at.z.ATTACH_MENU_BOT,nestedLink:s},t)),this.processInternalLink(s)}))}),cs({name:"resolve",protocol:"tg",callback:({uriParams:e},t)=>{let i;if(e.phone?i=this.makeLink(at.z.USER_PHONE_NUMBER,e):"telegrampassport"===e.domain||(i=this.makeLink(at.z.MESSAGE,Object.assign(Object.assign({},e),{stack:this.getStackFromElement(t)}))),void 0!==e.attach||void 0!==e.startattach){const t=i;i=this.makeLink(at.z.ATTACH_MENU_BOT,e),i.nestedLink=t}this.processInternalLink(i)}}),cs({name:"privatepost",protocol:"tg",callback:({uriParams:e})=>{const t=this.makeLink(at.z.PRIVATE_POST,e);this.processInternalLink(t)}}),cs({name:"invoice",protocol:"tg",callback:({uriParams:e})=>{const t=this.makeLink(at.z.INVOICE,e);this.processInternalLink(t)}}),["joinchat","join"].forEach((e=>{cs({name:e,protocol:"tg",callback:({uriParams:e})=>{const t=this.makeLink(at.z.JOIN_CHAT,e);this.processInternalLink(t)}})})),this.onHashChange(!0),this.attachKeydownListener(),this.handleAutologinDomains(),this.checkForShare()}checkForShare(){const e=he.Z.share;e&&(he.Z.share=void 0,V.Z.createPopup(hs.Z,void 0,(t=>Ss(this,void 0,void 0,(function*(){var i;if(yield this.setPeer({peerId:t}),null===(i=e.files)||void 0===i?void 0:i.length){const t=e.files.some((e=>ot.Z.has(e.type)));V.Z.createPopup(He.Z,this.chat,e.files,t?"media":"document")}else this.managers.appMessagesManager.sendText(t,e.text)})))))}handleUrlAuth(e){const{peerId:t,mid:i,buttonId:s,url:n}=e,a=e=>{window.open(e,"_blank")},o=e=>Ss(this,void 0,void 0,(function*(){if("urlAuthResultRequest"===e._){const r=document.createElement("b");r.append(e.domain);const l=yield(0,le.Z)({peerId:d.Z.myId}),c=yield(0,le.Z)({peerId:e.bot.id.toPeerId()}),h={text:"OpenUrlOption1",textArgs:[r.cloneNode(!0),l],checked:!0},u=e.pFlags.request_write_access?{text:"OpenUrlOption2",textArgs:[c],checked:!0}:void 0,p=[h,u],f=(0,Mt.Z)({titleLangKey:"OpenUrlTitle",button:{langKey:"Open"},descriptionLangKey:"OpenUrlAlert2",descriptionLangArgs:[r],checkboxes:p.filter(Boolean)});u&&h.checkboxField.input.addEventListener("change",(()=>{const e=!h.checkboxField.checked;u.checkboxField.toggleDisability(e),e&&(u.checkboxField.checked=!1)}));const[m,g]=yield f;if(!m)return void a(n);const v=yield this.managers.appSeamlessLoginManager.acceptUrlAuth(n,t,i,s,g);return o(v)}"urlAuthResultAccepted"===e._?(e=>{a(e.url)})(e):a(n)}));return this.managers.appSeamlessLoginManager.requestUrlAuth(n,t,i,s).then((e=>{o(e)}))}handleAutologinDomains(){let e,t;d.Z.addEventListener("app_config",(t=>{e=t})),d.Z.addEventListener("config",(e=>{t=e}));const i=i=>{var s,n;const a=new URL(i.href);if(e.url_auth_domains.includes(a.hostname))return this.handleUrlAuth({url:i.href}),void(0,C.Z)();const o=t.autologin_token;if(!o||!e.autologin_domains)return;const r=null!==(s=(n=i.dataset).originalUrl)&&void 0!==s?s:n.originalUrl=i.href;e.autologin_domains.includes(a.hostname)&&(a.searchParams.set("autologin_token",o),i.href=a.toString(),setTimeout((()=>{i.href=r,delete i.dataset.originalUrl}),0))};document.addEventListener("click",(e=>{const t=(0,ee.Z)(e.target,"A");(null==t?void 0:t.href)&&i(t)}))}getStackFromElement(e){const t=(0,X.Z)(e,"bubble");return t?+t.dataset.mid:void 0}deleteFilesIterative(e){return this.cacheStorage.timeoutOperation((t=>{const i=performance.now();return t.keys().then((i=>{const s=i.map((i=>t.match(i).then((t=>e(t)))));return Promise.all(s).then((e=>(e.map(((e,s)=>{if(!e)return;const n=i[s];return t.delete(n)})),Promise.all(e.filter(Boolean)))))})).then((()=>{this.log("deleted files",performance.now()-i)}))}))}toggleChatGradientAnimation(e){this.chats.forEach((t=>{t.gradientRenderer&&t.gradientRenderer.scrollAnimate(Ne.Z.isAvailable("animations")&&t===e)}))}appendEmojiAnimationContainer(e){const t=e===o._.mobile?this.columnEl:document.body;this.emojiAnimationContainer.parentElement!==t&&t.append(this.emojiAnimationContainer)}attachKeydownListener(){const e=new Set(["PageUp","PageDown","Meta","Control"]);document.body.addEventListener("keydown",(t=>{var i;const s=t.key,n=document.getSelection().isCollapsed;if(ss.Z.isOverlayActive||e.has(s))return;const a=t.target,r="INPUT"===a.tagName&&!["checkbox","radio"].includes(a.type)||a.isContentEditable,d=this.chat;if((!(s.startsWith("Arrow")||t.shiftKey&&"Shift"===s)||n)&&("KeyC"!==t.code||!t.ctrlKey&&!t.metaKey||r)){if(!t.altKey||"ArrowUp"!==s&&"ArrowDown"!==s){if("ArrowUp"===s&&"scheduled"!==this.chat.type){if(d.input.editMsgId||!d.input.isInputEmpty())return;this.managers.appMessagesManager.getFirstMessageToEdit(d.peerId,d.threadId).then((e=>{e&&(d.input.initMessageEditing(e.mid),(0,C.Z)(t))}))}else if("ArrowDown"===s)return}else(0,C.Z)(t),this.managers.dialogsStorage.getNextDialog(this.chat.peerId,"ArrowDown"===s,Ie.default.filterId).then((e=>{e&&this.setPeer({peerId:e.peerId})}));if((null===(i=null==d?void 0:d.input)||void 0===i?void 0:i.messageInput)&&a!==d.input.messageInput&&!r&&!z.Z&&(!o.Z.isMobile||this.tabId===ys.CHAT)&&!d.selection.isSelecting&&!d.input.recording&&d.input.messageInput.isContentEditable){d.input.messageInput.focus(),(0,tt.Z)(d.input.messageInput);const e=new KeyboardEvent(t.type,t);d.input.messageInput.dispatchEvent(e)}}}))}makeLink(e,t){return Object.assign({_:e},t)}processInternalLink(e){return Ss(this,void 0,void 0,(function*(){switch(null==e?void 0:e._){case at.z.MESSAGE:{const t=e.post?(0,Gi.Z)(+e.post):void 0,i=e.comment?(0,Gi.Z)(+e.comment):void 0,s=e.thread?(0,Gi.Z)(+e.thread):void 0;this.openUsername({userName:e.domain,lastMsgId:t,commentId:i,startParam:e.start,stack:e.stack,threadId:s,mediaTimestamp:e.t&&+e.t});break}case at.z.PRIVATE_POST:{const t=e.channel.toChatId(),i=(t.toPeerId(!0),yield this.managers.appChatsManager.getChat(t));if(!i)try{yield this.managers.appChatsManager.resolveChannel(t)}catch(e){throw(0,te.bC)({langPackKey:"LinkNotFound"}),e}const s=(0,Gi.Z)(+e.post),n=e.thread?(0,Gi.Z)(+e.thread):void 0;this.op({peer:i,lastMsgId:s,threadId:n,stack:e.stack,mediaTimestamp:e.t&&+e.t});break}case at.z.EMOJI_SET:case at.z.STICKER_SET:V.Z.createPopup(st.Z,{id:e.set},e._===at.z.EMOJI_SET).show();break;case at.z.JOIN_CHAT:this.managers.appChatsManager.checkChatInvite(e.invite).then((t=>{t.chat&&this.managers.appChatsManager.saveApiChat(t.chat,!0),"chatInviteAlready"!==t._&&"chatInvitePeek"!==t._?V.Z.createPopup(nt.Z,e.invite,t):this.setInnerPeer({peerId:t.chat.id.toPeerId(!0)})}),(e=>{"INVITE_HASH_EXPIRED"===e.type&&(0,te.Am)((0,k.ag)("InviteExpired"))}));break;case at.z.VOICE_CHAT:ae.Z&&this.joinGroupCall(e.chat_id.toPeerId(!0),e.id);break;case at.z.USER_PHONE_NUMBER:this.managers.appUsersManager.resolvePhone(e.phone).then((e=>{this.setInnerPeer({peerId:e.id.toPeerId(!1)})})).catch((e=>{"PHONE_NOT_OCCUPIED"===e.type&&(0,te.bC)({langPackKey:"Alert.UserDoesntExists"})}));break;case at.z.INVOICE:this.managers.appPaymentsManager.getInputInvoiceBySlug(e.slug).then((e=>{this.managers.appPaymentsManager.getPaymentForm(e).then((t=>{V.Z.createPopup(rs.ZP,void 0,e,t)}))}));break;case at.z.ATTACH_MENU_BOT:{console.log(e);const t=e.attach||e.domain,i=yield this.managers.appUsersManager.resolveUserByUsername(t).catch((()=>{}));let s;if(void 0!==e.attach&&this.processInternalLink(e.nestedLink),i?i.pFlags.bot_attach_menu||(s="BotCantAddToAttachMenu"):s="Alert.UserDoesntExists",s){(0,te.bC)({langPackKey:s});break}const n=i.id.toPeerId(!1),a=yield this.managers.appAttachMenuBotsManager.getAttachMenuBot(i.id);if(console.log(a),a.pFlags.inactive){const e=yield(0,Mt.Z)({button:{text:"Add"},descriptionLangKey:"BotRequestAttachPermission",descriptionLangArgs:[yield(0,le.Z)({peerId:n})],checkbox:a.pFlags.request_write_access?{text:"OpenUrlOption2",textArgs:[yield(0,le.Z)({peerId:n})],checked:!0}:void 0,peerId:n,titleLangKey:"AddBot"});yield this.managers.appAttachMenuBotsManager.toggleBotInAttachMenu(i.id,!0,e)}break}default:this.log.warn("Not supported internal link:",e)}}))}openUrl(e){const{url:t,onclick:i}=(0,Xi.Z)(e);if(!i)return;const s=document.createElement("a");s.href=t,window[i](s)}op(e){return Ss(this,void 0,void 0,(function*(){let{peer:t,commentId:i,threadId:s,lastMsgId:n}=e;const a="user"===t._,o=t.id.toPeerId(!a),r="channel"===t._&&t.pFlags.forum;if(i||s||n||!r){if(r&&n&&!s){const t=yield this.managers.appMessagesManager.reloadMessages(o,n);t?s=e.threadId=(0,Vi.Z)(t,r):(s=e.threadId=n,n=e.lastMsgId=void 0)}return s?this.openThread(Object.assign(Object.assign({},e),{peerId:o})):i?this.openComment({peerId:o,msgId:n,commentId:i}):this.setInnerPeer(Object.assign(Object.assign({},e),{peerId:o}))}Ie.default.toggleForumTabByPeerId(o,!0)}))}openPremiumBot(){return this.managers.apiManager.getAppConfig().then((e=>this.openUsername({userName:e.premium_bot_username})))}openUsername(e){const{userName:t}=e;return this.managers.appUsersManager.resolveUsername(t).then((t=>this.op(Object.assign({peer:t},e))),(e=>{"USERNAME_NOT_OCCUPIED"===e.type?(0,te.bC)({langPackKey:"NoUsernameFound"}):"USERNAME_INVALID"===e.type&&(0,te.bC)({langPackKey:"Alert.UserDoesntExists"})}))}openThread(e){return Ss(this,void 0,void 0,(function*(){return(yield this.managers.appChatsManager.isForum(e.peerId.toChatId()))?(yield this.managers.dialogsStorage.getForumTopicOrReload(e.peerId,e.threadId),this.setInnerPeer(e)):this.managers.appMessagesManager.reloadMessages(e.peerId,e.threadId).then((t=>(t?this.managers.appMessagesManager.generateThreadServiceStartMessage(t):e.lastMsgId=void 0,this.setInnerPeer(Object.assign(Object.assign({},e),{type:"discussion"})))))}))}openComment(e){return this.managers.appMessagesManager.getDiscussionMessage(e.peerId,e.msgId).then((t=>this.openThread({peerId:t.peerId,lastMsgId:e.commentId,threadId:t.mid})))}callUser(e,t){return Ss(this,void 0,void 0,(function*(){Li.Z.getCallByUserId(e)||((yield this.managers.appProfileManager.getProfile(e)).pFlags.phone_calls_private?(0,le.Z)({peerId:e.toPeerId()}).then((e=>(0,Mt.Z)({descriptionLangKey:"Call.PrivacyErrorMessage",descriptionLangArgs:[e],button:{langKey:"OK",isCancel:!0}}))):(yield this.discardCurrentCall(e.toPeerId()),Li.Z.startCallInternal(e,"video"===t)))}))}discardCurrentCall(e,t,i){return ce.ZP.groupCall&&ce.ZP.groupCall!==t?this.discardGroupCallConfirmation(e):Li.Z.currentCall&&Li.Z.currentCall!==i?this.discardCallConfirmation(e):Promise.resolve()}discardCallConfirmation(e){return Ss(this,void 0,void 0,(function*(){const t=Li.Z.currentCall;t&&(yield Promise.all([(0,le.Z)({peerId:t.interlocutorUserId.toPeerId(!1)}),(0,le.Z)({peerId:e})]).then((([t,i])=>(0,Mt.Z)({titleLangKey:"Call.Confirm.Discard.Call.Header",descriptionLangKey:e.isUser()?"Call.Confirm.Discard.Call.ToCall.Text":"Call.Confirm.Discard.Call.ToVoice.Text",descriptionLangArgs:[t,i],button:{langKey:"OK"}}))),t.isClosing||(yield t.hangUp("phoneCallDiscardReasonDisconnect")))}))}discardGroupCallConfirmation(e){return Ss(this,void 0,void 0,(function*(){const t=ce.ZP.groupCall;t&&(yield Promise.all([(0,le.Z)({peerId:t.chatId.toPeerId(!0)}),(0,le.Z)({peerId:e})]).then((([t,i])=>(0,Mt.Z)({titleLangKey:"Call.Confirm.Discard.Voice.Header",descriptionLangKey:e.isUser()?"Call.Confirm.Discard.Voice.ToCall.Text":"Call.Confirm.Discard.Voice.ToVoice.Text",descriptionLangArgs:[t,i],button:{langKey:"OK"}}))),ce.ZP.groupCall===t&&(yield t.hangUp()))}))}joinGroupCall(e,t){return Ss(this,void 0,void 0,(function*(){const i=e.toChatId(),s=this.managers.appChatsManager.hasRights(i,"manage_call");if(t&&"groupCallDiscarded"===(yield this.managers.appGroupCallsManager.getGroupCallFull(t))._){if(!s)return void(0,te.bC)({langPackKey:"VoiceChat.Chat.Ended"});yield(0,Mt.Z)({descriptionLangKey:"VoiceChat.Chat.StartNew",button:{langKey:"VoiceChat.Chat.StartNew.OK"}})}(()=>{Ss(this,void 0,void 0,(function*(){const e=yield this.managers.appProfileManager.getChatFull(i);let t;if(e.call)t=e.call;else{if(!s)return;t=yield this.managers.appGroupCallsManager.createGroupCall(i)}ce.ZP.joinGroupCall(i,t.id,!0,!1)}))})()}))}setCurrentBackground(e=!1){var t,i;const s=De.Z.getTheme(),n=null===(i=null===(t=s.settings)||void 0===t?void 0:t.wallpaper)||void 0===i?void 0:i.slug;if(n){const t=ts.h.settings.themes.find((e=>e.name===s.name));return this.getBackground(n).then((t=>this.setBackground(t,e)),(()=>(s.settings=(0,Zi.Z)(t.settings),this.setCurrentBackground(!0))))}return this.setBackground("",e)}getBackground(e){return this.backgroundPromises[e]?this.backgroundPromises[e]:this.backgroundPromises[e]=this.cacheStorage.getFile("backgrounds/"+e).then((e=>URL.createObjectURL(e)))}setBackground(e,t=!0){this.lastBackgroundUrl=e;const i=this.chats.map((t=>t.setBackground(e)));return i[i.length-1].then((()=>{t&&d.Z.dispatchEvent("background_change")}))}saveChatPosition(e){if(!["chat","discussion"].includes(e.type)||!e.peerId)return;const t=e.bubbles,i=e.peerId+(e.threadId?"_"+e.threadId:""),s=Xe.Z.getFromCache("chatPositions");if(t.scrollable.getDistanceToEnd()<=16&&t.scrollable.loadedAll.bottom||!t.getRenderedLength())delete s[i],this.log("deleted chat position");else{t.sliceViewport(!0);const e=t.scrollable.scrollTop,n={mids:(0,Mi.Z)(t.bubbles,"desc").filter((e=>e>0&&!t.skippedMids.has(e))),top:e};s[i]=n,this.log("saved chat position:",n)}Xe.Z.set({chatPositions:s},!0)}getChatSavedPosition(e){if(!["chat","discussion"].includes(e.type)||!e.peerId)return;const t=e.peerId+(e.threadId?"_"+e.threadId:""),i=Xe.Z.getFromCache("chatPositions");return i&&i[t]}applyCurrentTheme(e,t,i){return t&&(this.backgroundPromises[e]=Promise.resolve(t)),De.Z.setTheme(),this.setCurrentBackground(void 0===i?!!e:i)}chatsSelectTab(e,t){if(this.prevTab!==e){if(!1===t&&this.prevTab&&et([e,this.prevTab].filter(Boolean)),this.prevTab){this.prevTab.classList.remove("active"),this.chatsSelectTabDebounced(),Ne.Z.isAvailable("animations")&&!1!==t&&(0,H.YW)((0,_e.Z)(400),400);const i=(0,Ee.Z)(this.prevTab);(0,Ee.Z)(e)>i&&Q.Z.pushItem({type:"chat",onPop:e=>{this.setPeer({},e),(0,J.Z)()}})}e.classList.add("active"),this.prevTab=e}}init(){document.addEventListener("paste",this.onDocumentPaste,!0),z.Z||this.attachDragAndDropListeners(),this.markupTooltip=new $e(this),this.markupTooltip.handleSelection()}attachDragAndDropListeners(){const e=[],t=[];let i=!1;const s=(r,d)=>Ss(this,void 0,void 0,(function*(){if(d===i)return;const l=r.dataTransfer.types,c=l.contains?l.contains("Files"):l.indexOf("Files")>=0,h=(0,He.Y)(),u=yield as(r,!0);if(!c||!(yield this.canDrag())&&!h)return void(n=0);const p=yield He.Z.canSend(this.chat.peerId,!0),f=h?o:a,m=h?t:e;if(d&&!m.length){const e=c&&!u.length,[t,i]=(0,ps.Z)(u,(e=>ot.Z.has(e))),[n,a]=(0,ps.Z)(t,(e=>rt.Z.has(e)));if(p.send_docs?i.push(...t):i.length=0,p.send_photos||(n.forEach((e=>(0,Me.Z)(t,e))),n.length=0),p.send_videos||(a.forEach((e=>(0,Me.Z)(t,e))),a.length=0),this.log("drag files",u,t,i,n,a),h){h.appendDrops(f);const t=(p.send_docs?[i]:[n,a]).reduce(((e,t)=>e+t.length),0);(t||e)&&m.push(new Ye(f,{header:"Preview.Dragging.AddItems",headerArgs:[t],onDrop:e=>{s(e,!1),this.log("drop",e),this.onDocumentPaste(e,"document")}}))}else(i.length||e)&&m.push(new Ye(f,{icon:"dragfiles",header:"Chat.DropTitle",subtitle:"Chat.DropAsFilesDesc",onDrop:e=>{s(e,!1),this.log("drop",e),this.onDocumentPaste(e,"document")}})),(t.length||e)&&m.push(new Ye(f,{icon:"dragmedia",header:"Chat.DropTitle",subtitle:"Chat.DropQuickDesc",onDrop:e=>{s(e,!1),this.log("drop",e),this.onDocumentPaste(e,"media")}})),this.chat.container.append(f)}(0,ve.Z)({element:f,className:"is-visible",forwards:d,duration:200,onTransitionEnd:()=>{d||(m.forEach((e=>{e.destroy()})),m.length=0)}}),d?m.forEach((e=>{e.setPath()})):n=0,document.body.classList.toggle("is-dragging",d),i=d}));let n=0;document.body.addEventListener("dragenter",(e=>{n++})),document.body.addEventListener("dragover",(e=>{s(e,!0),(0,C.Z)(e)})),document.body.addEventListener("dragleave",(e=>{n--,0===n&&s(e,!1)}));const a=document.createElement("div");a.classList.add("drops-container");const o=a.cloneNode(!0)}canDrag(){return Ss(this,void 0,void 0,(function*(){const e=this.chat;return!(!(null==e?void 0:e.peerId)||ss.Z.isOverlayActive||!(yield e.canSend("send_media")))}))}overrideHash(e){return Ss(this,void 0,void 0,(function*(){let t;if(e){const i=yield this.managers.appPeersManager.getPeerUsername(e);t=i?"@"+i:""+e}Q.Z.overrideHash(t)}))}selectTab(e,t){var i;!1===t&&et([n.ZP.sidebarEl,this.columnEl,a.ZP.sidebarEl]),document.body.classList.toggle(n.ir,e===ys.CHATLIST);const s=this.tabId;void 0!==s&&(this.overrideHash(e>ys.CHATLIST?null===(i=this.chat)||void 0===i?void 0:i.peerId:void 0),this.dispatchEvent("tab_changing",e)),this.log("selectTab",e,s);let r=Ne.Z.isAvailable("animations")?(0,Qe.d1)():Promise.resolve();if(void 0!==s&&s!==e&&Ne.Z.isAvailable("animations")&&!1!==t){const e=100+(o.Z.isMobile?250:200);r=(0,_e.Z)(e),(0,H.YW)(r,e)}this.tabId=e,(0,J.Z)(),o.Z.isMobile&&s===ys.PROFILE&&e<ys.PROFILE&&document.body.classList.remove(a.HQ),void 0!==s&&e>s&&(e<ys.PROFILE||!Q.Z.findItemByType("im"))&&Q.Z.pushItem({type:"im",onPop:e=>{this.setPeer({},e)}});const d=window.onImTabChange;return d&&d(e),r}updateStatus(){return this.managers.appUsersManager.updateMyOnlineStatus(this.offline)}createNewChat(){const e=new Ue(this,this.managers);return this.chats.length&&e.setBackground(this.lastBackgroundUrl,!0),this.chats.push(e),e}spliceChats(e,t=!0,i,s){if(e>=this.chats.length)return;const n=this.chat;this.chats.length>1&&t&&this.dispatchEvent("peer_changing",this.chat),s||(s=this.chats.splice(e,this.chats.length-e));const o=this.chat;this.dispatchEvent("chat_changing",{from:n,to:o});for(let e=0;e<s.length-1;++e)Q.Z.removeByType("chat",!0);if(s.length>1&&s.slice(0,-1).forEach((e=>{e.container.remove()})),this.chatsSelectTab(o.container,i),t){this.dispatchEvent("peer_changed",o);const e=a.ZP.getTab(Ce);null==e||e.close(),a.ZP.replaceSharedMediaTab(o.sharedMediaTab)}s.forEach((e=>{e.beforeDestroy()})),setTimeout((()=>{s.forEach((e=>{e.destroy()}))}),350)}setPeer(e={},t){var i;return Ss(this,void 0,void 0,(function*(){this.init&&(this.init(),this.init=null),null!==(i=e.peerId)&&void 0!==i||(e.peerId=pe.NM);const{peerId:s,lastMsgId:a,threadId:r}=e,d=this.chat,l=this.chats.indexOf(d),c=this.isSamePeer(d,e);if(s){if(l>0&&d.peerId&&!c){const t=this.chats.splice(1,this.chats.length-1);if(this.chat.peerId===s)return void this.spliceChats(0,!0,!0,t);{const i=this.setPeer(e);return this.spliceChats(0,!1,!1,t),i}}}else{if(l>0)return void this.spliceChats(l,void 0,t);if(o.Z.activeScreen===o._.medium)return void this.selectTab(+!this.tabId,t)}if(c&&o.Z.activeScreen<=o._.medium&&document.body.classList.contains(n.ir))return this.selectTab(ys.CHAT,t),!1;if(s||o.Z.activeScreen!==o._.mobile){const i=yield d.setPeer(e),n=(null==i?void 0:i.cached)?i.promise:Promise.resolve();s&&Promise.all([n,d.setBackgroundPromise]).then((()=>{setTimeout((()=>{setTimeout((()=>{this.chatsSelectTab(this.chat.container)}),0),this.selectTab(ys.CHAT,t)}),0)}))}return s?void 0:(this.selectTab(ys.CHATLIST,t),!1)}))}setInnerPeer(e){var t;return Ss(this,void 0,void 0,(function*(){const{peerId:i}=e;if(i===pe.NM||!i)return;e.type||(e.threadId&&!(yield this.managers.appPeersManager.isForum(e.peerId))&&(e.type="discussion"),null!==(t=e.type)&&void 0!==t||(e.type="chat"));const s=this.chats.findIndex((t=>this.isSamePeer(t,e)||o.Z.activeScreen===o._.mobile&&0===this.tabId));if(-1!==s)return this.spliceChats(s+1),this.setPeer(e);const n=this.chat;let a=n;return n.inited&&(a=this.createNewChat()),this.dispatchEvent("chat_changing",{from:n,to:a}),this.setPeer(e)}))}openScheduled(e){this.setInnerPeer({peerId:e,type:"scheduled"})}getTypingElement(e){const t=document.createElement("span");let i="peer-typing";switch(t.classList.add(i),t.dataset.action=e._,e._){case"sendMessageTypingAction":i+="-text";for(let e=0;e<3;++e){const e=document.createElement("span");e.className=i+"-dot",t.append(e)}break;case"sendMessageUploadAudioAction":case"sendMessageUploadDocumentAction":case"sendMessageUploadRoundAction":case"sendMessageUploadVideoAction":case"sendMessageUploadPhotoAction":i+="-upload";break;case"sendMessageRecordAudioAction":case"sendMessageRecordRoundAction":case"sendMessageRecordVideoAction":i+="-record";break;case"sendMessageEmojiInteractionSeen":case"sendMessageChooseStickerAction":i+="-choosing-sticker";for(let e=0;e<2;++e){const e=document.createElement("div");e.className=i+"-eye",t.append(e)}}return t.classList.add(i),t}getPeerTyping(e,t,i){return Ss(this,void 0,void 0,(function*(){const s=e.isUser();if(s&&(yield this.managers.appUsersManager.isBot(e)))return;const n=yield this.managers.appProfileManager.getPeerTypings(e,i);if(!(null==n?void 0:n.length))return;const a=n[0],o={private:{sendMessageTypingAction:"Peer.Activity.User.TypingText",sendMessageUploadAudioAction:"Peer.Activity.User.SendingFile",sendMessageUploadDocumentAction:"Peer.Activity.User.SendingFile",sendMessageUploadPhotoAction:"Peer.Activity.User.SendingPhoto",sendMessageUploadVideoAction:"Peer.Activity.User.SendingVideo",sendMessageUploadRoundAction:"Peer.Activity.User.SendingVideo",sendMessageRecordVideoAction:"Peer.Activity.User.RecordingVideo",sendMessageRecordAudioAction:"Peer.Activity.User.RecordingAudio",sendMessageRecordRoundAction:"Peer.Activity.User.RecordingVideo",sendMessageGamePlayAction:"Peer.Activity.User.PlayingGame",sendMessageChooseStickerAction:"Peer.Activity.User.ChoosingSticker",sendMessageEmojiInteractionSeen:"Peer.Activity.User.EnjoyingAnimations"},chat:{sendMessageTypingAction:"Peer.Activity.Chat.TypingText",sendMessageUploadAudioAction:"Peer.Activity.Chat.SendingFile",sendMessageUploadDocumentAction:"Peer.Activity.Chat.SendingFile",sendMessageUploadPhotoAction:"Peer.Activity.Chat.SendingPhoto",sendMessageUploadVideoAction:"Peer.Activity.Chat.SendingVideo",sendMessageUploadRoundAction:"Peer.Activity.Chat.SendingVideo",sendMessageRecordVideoAction:"Peer.Activity.Chat.RecordingVideo",sendMessageRecordAudioAction:"Peer.Activity.Chat.RecordingAudio",sendMessageRecordRoundAction:"Peer.Activity.Chat.RecordingVideo",sendMessageGamePlayAction:"Peer.Activity.Chat.PlayingGame",sendMessageChooseStickerAction:"Peer.Activity.Chat.ChoosingSticker",sendMessageEmojiInteractionSeen:"Peer.Activity.Chat.EnjoyingAnimations"},multi:{sendMessageTypingAction:"Peer.Activity.Chat.Multi.TypingText1",sendMessageUploadAudioAction:"Peer.Activity.Chat.Multi.SendingFile1",sendMessageUploadDocumentAction:"Peer.Activity.Chat.Multi.SendingFile1",sendMessageUploadPhotoAction:"Peer.Activity.Chat.Multi.SendingPhoto1",sendMessageUploadVideoAction:"Peer.Activity.Chat.Multi.SendingVideo1",sendMessageUploadRoundAction:"Peer.Activity.Chat.Multi.SendingVideo1",sendMessageRecordVideoAction:"Peer.Activity.Chat.Multi.RecordingVideo1",sendMessageRecordAudioAction:"Peer.Activity.Chat.Multi.RecordingAudio1",sendMessageRecordRoundAction:"Peer.Activity.Chat.Multi.RecordingVideo1",sendMessageGamePlayAction:"Peer.Activity.Chat.Multi.PlayingGame1",sendMessageChooseStickerAction:"Peer.Activity.Chat.Multi.ChoosingSticker1"}},r=s?o.private:n.length>1?o.multi:o.chat;let d=a.action;if(n.length>1){const e={};n.forEach((t=>{const i=t.action._;void 0===e[i]&&(e[i]=0),++e[i]})),Object.keys(e).length>1&&(d={_:"sendMessageTypingAction"})}const l=r[d._];if(!l)return;let c,h;if(e.isAnyChat()){const e=new M.Z;c=e.update({peerId:a.userId.toPeerId(!1),onlyFirstName:!0}),h=[e.element,n.length-1],yield c}t||(t=document.createElement("span")).classList.add("online","peer-typing-container"),t.classList.toggle("peer-typing-flex","sendMessageChooseStickerAction"===d._||"sendMessageEmojiInteractionSeen"===d._);let u=t.firstElementChild;if(u?u.dataset.action!==d._&&u.replaceWith(this.getTypingElement(d)):(u=this.getTypingElement(d),t.prepend(u)),"sendMessageEmojiInteractionSeen"===d._){h?h.pop():h=[];const e=(0,Pi.Z)((0,_.Z)(d.emoticon));h.push(e)}const p=(0,k.ag)(l,h);return p.classList.add("peer-typing-description"),t.childElementCount>1?t.lastElementChild.replaceWith(p):t.append(p),t}))}getChatStatus(e,t){return Ss(this,void 0,void 0,(function*(){const i=t?void 0:yield this.getPeerTyping(e.toPeerId(!0));if(i)return{cached:!0,result:Promise.resolve(i)};const s=yield this.managers.acknowledged.appProfileManager.getChatFull(e),n=Promise.resolve(s.result).then((t=>Ss(this,void 0,void 0,(function*(){var i,s;const n=t.participants_count||(null===(s=null===(i=t.participants)||void 0===i?void 0:i.participants)||void 0===s?void 0:s.length)||1;let a=yield(0,es.Z)(e);if(n<2)return a;const o=yield this.managers.appProfileManager.getOnlines(e);if(o>1){const e=document.createElement("span");e.append(...(0,k.v_)([a,(0,k.ag)("OnlineCount",[(0,ki.Z)(o)])],!1)),a=e}return a}))));return{cached:s.cached,result:n}}))}getUserStatus(e,t){var i;return Ss(this,void 0,void 0,(function*(){const s={cached:!0,result:Promise.resolve(void 0)},n=yield this.managers.appUsersManager.getUser(e);if(!n||n.pFlags.self&&!t)return s;const a=(0,Ji.Z)(n);if(!n.pFlags.bot&&!n.pFlags.support){let t=yield this.getPeerTyping(e.toPeerId());if(t||"userStatusOnline"!==(null===(i=n.status)||void 0===i?void 0:i._)||(t=document.createElement("span"),t.classList.add("online"),t.append(a)),t)return s.result=Promise.resolve(t),s}return s.result=Promise.resolve(a),s}))}getPeerStatus(e,t,i){return Ss(this,void 0,void 0,(function*(){if(!e)return;let s;return s=e.isAnyChat()?this.getChatStatus(e.toChatId(),i):this.getUserStatus(e.toUserId(),t),s}))}setPeerStatus(e){return Ss(this,void 0,void 0,(function*(){const{peerId:t,element:i,needClear:s,useWhitespace:n,middleware:a,ignoreSelf:o,noTyping:r}=e;if(!s){const e=i.querySelector(".peer-typing-container");if(e&&(yield this.getPeerTyping(t,e)))return}const d=yield this.getPeerStatus(t,o,r);if(!a())return;const l=()=>Ss(this,void 0,void 0,(function*(){const e=d&&(yield d.result);if(a())return()=>(0,Z.Z)(i,e||c)})),c=n?ds.Z:"";return!d||d.cached||void 0===s?yield l():s?()=>(i.textContent=c,l().then((e=>null==e?void 0:e()))):void 0}))}setChoosingStickerTyping(e){this.managers.appMessagesManager.setTyping(this.chat.peerId,{_:e?"sendMessageCancelAction":"sendMessageChooseStickerAction"},void 0,this.chat.threadId)}isSamePeer(e,t){return e.peerId===t.peerId&&e.threadId===t.threadId&&(typeof e.type!=typeof t.type||e.type===t.type)}giftPremium(e){this.managers.appProfileManager.getProfile(e.toUserId()).then((t=>{V.Z.createPopup(bs,e,t.premium_gifts)}))}}const Ls=new Cs;Je.GO&&(Je.GO.appImManager=Ls);const Es=Ls},8737:(e,t,i)=>{"use strict";var s;i.d(t,{z:()=>s}),function(e){e[e.MESSAGE=0]="MESSAGE",e[e.PRIVATE_POST=1]="PRIVATE_POST",e[e.STICKER_SET=2]="STICKER_SET",e[e.JOIN_CHAT=3]="JOIN_CHAT",e[e.VOICE_CHAT=4]="VOICE_CHAT",e[e.USER_PHONE_NUMBER=5]="USER_PHONE_NUMBER",e[e.INVOICE=6]="INVOICE",e[e.EMOJI_SET=7]="EMOJI_SET",e[e.ATTACH_MENU_BOT=8]="ATTACH_MENU_BOT"}(s||(s={}))},7740:(e,t,i)=>{"use strict";function s(e){return e.rank||("channelParticipantAdmin"===e._||"chatParticipantAdmin"===e._?2:"chatParticipantCreator"===e._||"channelParticipantCreator"===e._?1:void 0)}i.d(t,{Z:()=>s})},3709:(e,t,i)=>{"use strict";function s(e){var t;return e&&!e.pFlags.is_outgoing&&!e.pFlags.noforwards&&!(null===(t=e.media)||void 0===t?void 0:t.extended_media)}i.d(t,{Z:()=>s})},7530:(e,t,i)=>{"use strict";function s(e,t=!1){var i;if(!e)return;let s;if(e.action)s=e.action.photo;else if(e.media){let n=e.media;n.webpage?n=n.webpage:"messageExtendedMedia"===(null===(i=n.extended_media)||void 0===i?void 0:i._)&&(n=n.extended_media.media),s=n.document||n.photo||(t?void 0:n.game||n)}return s}i.d(t,{Z:()=>s})},2291:(e,t,i)=>{"use strict";function s(e){var t;return e.fromId?{peerId:e.fromId}:{fromName:null===(t=e.fwd_from)||void 0===t?void 0:t.from_name}}i.d(t,{Z:()=>s})},5381:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(677);function n(e){return!(!e.restriction_reason||!(0,s.X)(e.restriction_reason))}},5990:(e,t,i)=>{"use strict";i.d(t,{Z:()=>o});const s=["#fc5c51","#0fb297","#d09306","#3d72ed","#895dd5","#cd4073","#00c1a6","#fa790f"],n=["red","green","yellow","blue","violet","pink","cyan","orange"],a=[0,7,4,1,6,3,5];function o(e,t=!0){if(!e)return"";const i=a[Math.abs(+e)%7];return(t?n:s)[i]}},6082:(e,t,i)=>{"use strict";function s(e){if(e.username)return e.username;const t=e.usernames,i=null==t?void 0:t.find((e=>e.pFlags.editable));return null==i?void 0:i.username}i.d(t,{Z:()=>s})},2946:(e,t,i)=>{"use strict";i.d(t,{Z:()=>a});var s=i(5880),n=i(1507);function a(e){if(void 0!==e&&e.isPeerId&&e.isPeerId())return e;if((0,s.Z)(e)){const t=e.user_id;if(void 0!==t)return t.toPeerId(!1);const i=e.channel_id||e.chat_id;return void 0!==i?i.toPeerId(!0):n.NM}if(!e)return n.NM;const t="u"===e.charAt(0),i=e.substr(1).split("_");return t?i[0].toPeerId():(i[0]||"").toPeerId(!0)}},9687:(e,t,i)=>{"use strict";i.d(t,{Z:()=>a});var s=i(9897),n=i(1507);function a(e,t=0,i=0,a=!1,o=!1){window.devicePixelRatio>1&&(t*=2,i*=2);let r=e.sizes||e.thumbs,d={_:"photoSizeEmpty",type:n.Pt};if(o&&r&&"photo"!==e._&&(r=r.concat({_:"photoSize",w:e.w,h:e.h,size:e.size,type:n.Pt})),null==r?void 0:r.length){for(let e=0,n=r.length;e<n;++e){const n=r[e];if(!("w"in n)&&!("h"in n))continue;d=n;const a=(0,s.Z)(n.w,n.h,t,i);if(a.width>=t||a.height>=i)break}a&&"photoSizeEmpty"===d._&&"photoStrippedSize"===r[0]._&&(d=r[0])}return d}},3075:(e,t,i)=>{"use strict";i.d(t,{Z:()=>o});var s=i(5953),n=i(5003),a=i(6752);class o{constructor(e){var t;(0,s.Z)(this,e),this.log||(this.log=(null===(t=this.connection)||void 0===t?void 0:t.log)||(0,n.kg)("CALL-CONNECTION-BASE")),this.sources={}}createPeerConnection(e){return this.connection||(this.connection=function(e,t){t||(t=(0,n.kg)("RTCPeerConnection")),t("constructor");const i=new RTCPeerConnection(e);return i.addEventListener("track",(e=>{t("ontrack",e)})),i.addEventListener("signalingstatechange",(()=>{t("onsignalingstatechange",i.signalingState)})),i.addEventListener("connectionstatechange",(()=>{t("onconnectionstatechange",i.connectionState)})),i.addEventListener("negotiationneeded",(()=>{t("onnegotiationneeded",i.signalingState)})),i.addEventListener("icecandidate",(e=>{t("onicecandidate",e)})),i.addEventListener("iceconnectionstatechange",(()=>{t("oniceconnectionstatechange",i.iceConnectionState)})),i.addEventListener("datachannel",(()=>{t("ondatachannel")})),i.log=t,{connection:i}}(e,this.log.bindPrefix("connection")).connection)}createDataChannel(e){return this.dataChannel||(this.dataChannel=function(e,t,i){i||(i=(0,n.kg)("RTCDataChannel"));const s=e.createDataChannel("data",t);return s.addEventListener("message",(e=>{i("onmessage",e)})),s.addEventListener("open",(()=>{i("onopen")})),s.addEventListener("close",(()=>{i("onclose")})),s.log=i,s}(this.connection,e,this.log.bindPrefix("data")))}createDescription(){return this.description||(this.description=new a.ZP(this.connection))}appendStreamToConference(){return this.streamManager.appendToConference(this.description)}closeConnection(){const{connection:e}=this;if(e)try{e.log("close"),e.close()}catch(e){this.log.error(e)}}closeConnectionAndStream(e){this.closeConnection(),e&&this.streamManager.stop()}negotiate(){return this.negotiating||(this.negotiating=this.negotiateInternal().finally((()=>{this.negotiating=void 0})))}sendDataChannelData(e){"open"===this.dataChannel.readyState&&this.dataChannel.send(JSON.stringify(e))}}},2069:(e,t,i)=>{"use strict";i.d(t,{Z:()=>N});var s=i(6761),n=i(4762),a=i(5953),o=i(5701),r=i(671),d=i(5003),l=i(3855),c=i(3075),h=i(3773);function u(e){const t=(0,h.Z)(e,e.media[0]),i={"@type":"InitialSetup",fingerprints:[t.fingerprint],ufrag:t.ufrag,pwd:t.pwd,audio:void 0,video:void 0,screencast:void 0},s=e=>""+e;for(const t of e.media){const n=t.mediaType;if("application"===n||!t.isSending)continue;const a=i["video"===n&&i.video?"screencast":n]={},o=(0,h.Z)(e,t);a.ssrc=s(o.source),o.sourceGroups&&(a.ssrcGroups=o.sourceGroups.map((e=>({semantics:e.semantics,ssrcs:e.sources.map(s)}))));const r=a.rtpExtensions=[];t.attributes.get("extmap").forEach((e=>{r.push({id:+e.key,uri:e.value})}));const d=new Map,l=e=>{let t=d.get(e);return t||d.set(e,t={id:e}),t};t.attributes.get("rtpmap").forEach((e=>{const t=+e.key,i=l(t),s=e.value.split("/"),[n,a,o]=s;i.name=n,i.clockrate=+a,i.channels=o?+o:0})),t.attributes.get("rtcp-fb").forEach((e=>{const t=+e.key;l(t).feedbackTypes=e.lines.map((e=>{const t=e.split(" "),[i,s]=t;return{type:i,subtype:s||""}}))})),t.attributes.get("fmtp").forEach((e=>{const t=+e.key,i=l(t).parameters={},s=e.value.split(";");for(const e of s){const[t,s]=e.split("=");i[t]=s}})),a.payloadTypes=Array.from(d.values())}return i}var p=i(9124);class f extends c.Z{constructor(e){super(e)}negotiateInternal(){return e=this,t=void 0,s=function*(){const{connection:e,call:t}=this;if(!e.localDescription&&!e.remoteDescription&&!t.isOutgoing)return;let i;if(t.offerReceived){t.offerReceived=!1;const s=i=yield e.createAnswer();this.log("[sdp] local",s.type,s.sdp),yield e.setLocalDescription(s),this.log("[InitialSetup] send 2")}else{const s=i=yield e.createOffer();this.log("[sdp] local",s.sdp),yield e.setLocalDescription(s),t.offerSent=!0,this.log("[InitialSetup] send 0")}const s=u((0,p.DV)(i.sdp));t.sendCallSignalingData(s)},new((i=void 0)||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}));var e,t,i,s}}var m=i(8500),g=i(2493),v=i(3335),b=i(1677),y=i(49),w=i(6752),S=i(4903);const C="undefined"!=typeof window&&"crypto"in window?window.crypto.subtle:self.crypto.subtle;var L=i(9818),E=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class I{constructor(e,t){this.isOutgoing=e,this.p2pKey=t,this.type="Signaling",this.counter=0,this.seqMap=new Map}concatSHA256(e){return t=(0,S.Z)(...e),C.digest("SHA-256",(0,L.Z)(t)).then((e=>new Uint8Array(e)));var t}encryptPrepared(e){return E(this,void 0,void 0,(function*(){const t={counter:0,bytes:new Uint8Array(16+e.length)},i=(this.isOutgoing?0:8)+("Signaling"===this.type?128:0),s=this.p2pKey,n=yield this.concatSHA256([s.subarray(i+88,i+88+32),e]),a=t.bytes;for(let e=0;e<16;++e)a[e]=n[e+8];const o=yield this.prepareAesKeyIv(s,a,i),r=yield this.aesProcessCtr(e,e.length,o,!0);return t.bytes=new Uint8Array([...t.bytes.subarray(0,16),...r]),t}))}encryptRawPacket(e){const t=++this.counter,i=new ArrayBuffer(4);new DataView(i).setUint32(0,t>>>0,!1);const s=new Uint8Array([...new Uint8Array(i),...e]);return this.encryptPrepared(s)}prepareAesKeyIv(e,t,i){return E(this,void 0,void 0,(function*(){const[s,n]=yield Promise.all([this.concatSHA256([t.subarray(0,16),e.subarray(i,i+36)]),this.concatSHA256([e.subarray(40+i,40+i+36),t.subarray(0,16)])]);return{key:new Uint8Array([...s.subarray(0,8),...n.subarray(8,24),...s.subarray(24,32)]),iv:new Uint8Array([...n.subarray(0,4),...s.subarray(8,16),...n.subarray(24,28)])}}))}aesProcessCtr(e,t,i,s=!0){return E(this,void 0,void 0,(function*(){const t=yield C.importKey("raw",i.key,{name:"AES-CTR"},!1,[s?"encrypt":"decrypt"]),n=yield C[s?"encrypt":"decrypt"]({name:"AES-CTR",counter:i.iv,length:8*i.iv.length},t,e);return new Uint8Array(n)}))}constTimeIsDifferent(e,t,i){let s=!0;for(let n=0;n<i;++n)e[n]!==t[n]&&(s=!1);return!s}decryptRawPacket(e){return E(this,void 0,void 0,(function*(){if(e.length<21||e.length>134217728)return;const{isOutgoing:t,type:i}=this,s=(t?8:0)+("Signaling"===i?128:0),n=this.p2pKey,a=e.subarray(0,16),o=e.subarray(16),r=e.length-16,d=yield this.prepareAesKeyIv(n,a,s),l=yield this.aesProcessCtr(o,r,d,!1),c=yield this.concatSHA256([n.subarray(88+s,88+s+32),l]);if(this.constTimeIsDifferent(c.subarray(8),a,16))return;const h=new DataView(l.buffer).getUint32(0);return this.seqMap.has(h)?void 0:(this.seqMap.set(h,h),l.slice(4))}))}}var P=i(630);class Z{static generateOffer(e){const{fingerprints:t,ufrag:i,pwd:s,audio:n,video:a}=e;n.type="audio",a.type="video";const o=[n,a],r=new P.Z;r.add("v=0","o=- 1 2 IN IP4 127.0.0.1","s=-","t=0 0"),t&&t.forEach((e=>{const{hash:t,fingerprint:i,setup:s}=e;r.add(`a=fingerprint:${t} ${i}`,`a=setup:${s}`)})),i&&s&&r.add(`a=ice-ufrag:${i}`,`a=ice-pwd:${s}`),r.add("a=group:BUNDLE 0 1 2","a=extmap-allow-mixed","a=msid-semantic: WMS *");const d="stream"+o.map((e=>e.ssrc)).join("_");for(let e=0;e<o.length;e++){const t=o[e],{type:i,ssrc:s,ssrcGroups:n,payloadTypes:a,rtpExtensions:l}=t;switch(i){case"audio":r.add(`m=audio 56930 UDP/TLS/RTP/SAVPF ${a.map((e=>e.id)).join(" ")}`,"c=IN IP4 0.0.0.0","a=rtcp:9 IN IP4 0.0.0.0","a=ice-options:trickle",`a=mid:${e}`,"a=sendrecv",A(l)),s&&r.add(`a=msid:${d} audio${s}`),r.add("a=rtcp-mux",_(a),F(i,s,n,d));break;case"video":r.add(`m=video 61986 UDP/TLS/RTP/SAVPF ${a.map((e=>e.id)).join(" ")}`,"c=IN IP4 0.0.0.0","a=rtcp:9 IN IP4 0.0.0.0","a=ice-options:trickle",`a=mid:${e}`,"a=sendrecv",A(l)),s&&r.add(`a=msid:${d} video${s}`),r.add("a=rtcp-mux","a=rtcp-rsize",_(a),F(i,s,n,d))}}return r.add("m=application 9 UDP/DTLS/SCTP webrtc-datachannel\nc=IN IP4 0.0.0.0\na=ice-options:trickle\na=mid:2\na=sctp-port:5000\na=max-message-size:262144"),r.finalize()}static generateAnswer(e){const{fingerprints:t,ufrag:i,pwd:s,audio:n,video:a}=e;n.type="audio",a.type="video";const o=[n,a],r=new P.Z;r.add("v=0","o=- 1 2 IN IP4 127.0.0.1","s=-","t=0 0"),t&&t.forEach((e=>{const{hash:t,fingerprint:i,setup:s}=e;r.add(`a=fingerprint:${t} ${i}`,`a=setup:${s}`)})),i&&s&&r.add(`a=ice-ufrag:${i}`,`a=ice-pwd:${s}`),r.add("a=group:BUNDLE 0 1 2","a=extmap-allow-mixed","a=msid-semantic: WMS *");const d="stream"+o.map((e=>e.ssrc)).join("_");for(let e=0;e<o.length;e++){const t=o[e],{type:i,ssrc:s,ssrcGroups:n,payloadTypes:a,rtpExtensions:l}=t;switch(i){case"audio":r.add(`m=audio 56930 UDP/TLS/RTP/SAVPF ${a.map((e=>e.id)).join(" ")}`,"c=IN IP4 0.0.0.0","a=rtcp:9 IN IP4 0.0.0.0","a=ice-options:trickle",`a=mid:${e}`,"a=sendrecv",A(l)),s&&r.add(`a=msid:${d} audio${s}`),r.add("a=rtcp-mux",_(a),F(i,s,n,d));break;case"video":r.add(`m=video 61986 UDP/TLS/RTP/SAVPF ${a.map((e=>e.id)).join(" ")}`,"c=IN IP4 0.0.0.0","a=rtcp:9 IN IP4 0.0.0.0","a=ice-options:trickle",`a=mid:${e}`,"a=sendrecv",A(l)),s&&r.add(`a=msid:${d} video${s}`),r.add("a=rtcp-mux","a=rtcp-rsize",_(a),F(i,s,n,d))}}return r.add("m=application 9 UDP/DTLS/SCTP webrtc-datachannel\nc=IN IP4 0.0.0.0\na=ice-options:trickle\na=mid:2\na=sctp-port:5000\na=max-message-size:262144"),r.finalize()}}class M{static generateOffer(e){const{fingerprints:t,ufrag:i,pwd:s,audio:n,video:a}=e;n.type="audio",a.type="video";const o=[n,a];let r="v=0\no=- 1 0 IN IP4 0.0.0.0\ns=-\nt=0 0";t&&t.forEach((e=>{const{hash:t,fingerprint:i,setup:s}=e;r+=`\na=fingerprint:${t} ${i}\na=setup:${s}`})),i&&s&&(r+=`\na=ice-ufrag:${i}\na=ice-pwd:${s}`),r+="\na=group:BUNDLE 0 1 2\na=ice-options:trickle\na=msid-semantic:WMS *";const d="stream"+o.map((e=>e.ssrc)).join("_");for(let e=0;e<o.length;e++){const t=o[e],{type:i,ssrc:s,ssrcGroups:n,payloadTypes:a,rtpExtensions:l}=t;switch(i){case"audio":r+=`\nm=audio 9 UDP/TLS/RTP/SAVPF ${a.map((e=>e.id)).join(" ")}\nc=IN IP4 0.0.0.0\na=mid:${e}\na=sendrecv`,r+=A(l),r+="\na=rtcp-mux",r+=_(a),r+=F(i,s,n,d);break;case"video":r+=`\nm=video 9 UDP/TLS/RTP/SAVPF ${a.map((e=>e.id)).join(" ")}\nc=IN IP4 0.0.0.0\na=mid:${e}\na=sendrecv`,r+=A(l),r+="\na=rtcp-mux\na=rtcp-rsize",r+=_(a),r+=F(i,s,n,d)}}return r+="m=application 9 UDP/DTLS/SCTP webrtc-datachannel\nc=IN IP4 0.0.0.0\na=ice-options:trickle\na=mid:2\na=sctp-port:5000\na=max-message-size:262144",r+="\n",r}static generateAnswer(e){const{fingerprints:t,ufrag:i,pwd:s,audio:n,video:a}=e;n.type="audio",a.type="video";const o=[n,a];let r="v=0\no=- 1 0 IN IP4 0.0.0.0\ns=-\nt=0 0";t&&t.forEach((e=>{const{hash:t,fingerprint:i,setup:s}=e;r+=`\na=fingerprint:${t} ${i}\na=setup:${s}`})),i&&s&&(r+=`\na=ice-ufrag:${i}\na=ice-pwd:${s}`),r+="\na=group:BUNDLE 0 1 2\na=ice-options:trickle\na=msid-semantic:WMS *";const d="stream"+o.map((e=>e.ssrc)).join("_");for(let e=0;e<o.length;e++){const t=o[e],{type:i,mid:s,ssrc:n,ssrcGroups:a,payloadTypes:l,dir:c,rtpExtensions:h}=t;switch(i){case"audio":r+=`\nm=audio 9 UDP/TLS/RTP/SAVPF ${l.map((e=>e.id)).join(" ")}\nc=IN IP4 0.0.0.0\na=mid:${e}\na=sendrecv`,r+=A(h),r+="\na=rtcp-mux",r+=_(l),r+=F(i,n,a,d);break;case"video":r+=`\nm=video 9 UDP/TLS/RTP/SAVPF ${l.map((e=>e.id)).join(" ")}\nc=IN IP4 0.0.0.0\na=mid:${e}\na=sendrecv`,r+=A(h),r+="\na=rtcp-mux\na=rtcp-rsize",r+=_(l),r+=F(i,n,a,d)}}return r+="m=application 9 UDP/DTLS/SCTP webrtc-datachannel\nc=IN IP4 0.0.0.0\na=ice-options:trickle\na=mid:2\na=sctp-port:5000\na=max-message-size:262144",r+="\n",r}}class k{static generateOffer(e){const{fingerprints:t,ufrag:i,pwd:s,audio:n,video:a}=e;n.type="audio",a.type="video";const o=[n,a];if(!o.length)return"v=0\no=- 1 2 IN IP4 127.0.0.1\ns=-\nt=0 0\na=msid-semantic: WMS\n";let r="v=0\no=- 1 2 IN IP4 127.0.0.1\ns=-\nt=0 0";t&&t.forEach((e=>{const{hash:t,fingerprint:i,setup:s}=e;r+=`\na=fingerprint:${t} ${i}\na=setup:${s}`})),i&&s&&(r+=`\na=ice-ufrag:${i}\na=ice-pwd:${s}`),r+="\na=group:BUNDLE 0 1 2\na=extmap-allow-mixed\na=msid-semantic: WMS *";const d="stream"+o.map((e=>e.ssrc)).join("_");for(let e=0;e<o.length;e++){const t=o[e],{type:i,ssrc:s,ssrcGroups:n,payloadTypes:a,rtpExtensions:l}=t;switch(i){case"audio":r+=`\nm=audio 9 UDP/TLS/RTP/SAVPF ${a.map((e=>e.id)).join(" ")}\nc=IN IP4 0.0.0.0\na=rtcp:9 IN IP4 0.0.0.0\na=ice-options:trickle\na=mid:${e}\na=sendrecv`,r+=A(l),s&&(r+=`\na=msid:${d} audio${s}`),r+="\na=rtcp-mux",r+=_(a),r+=F(i,s,n,d);break;case"video":r+=`\nm=video 9 UDP/TLS/RTP/SAVPF ${a.map((e=>e.id)).join(" ")}\nc=IN IP4 0.0.0.0\na=rtcp:9 IN IP4 0.0.0.0\na=ice-options:trickle\na=mid:${e}\na=sendrecv`,r+=A(l),s&&(r+=`\na=msid:${d} video${s}`),r+="\na=rtcp-mux\na=rtcp-rsize",r+=_(a),r+=F(i,s,n,d)}}return r+="m=application 9 UDP/DTLS/SCTP webrtc-datachannel\nc=IN IP4 0.0.0.0\na=ice-options:trickle\na=mid:2\na=sctp-port:5000\na=max-message-size:262144",r+="\n",r}static generateAnswer(e){const{fingerprints:t,ufrag:i,pwd:s,audio:n,video:a}=e;n.type="audio",a.type="video";const o=[n,a];if(!o.length)return"v=0\no=- 1 2 IN IP4 127.0.0.1\ns=-\nt=0 0\na=msid-semantic: WMS\n";let r="v=0\no=- 1 2 IN IP4 127.0.0.1\ns=-\nt=0 0";t&&t.forEach((e=>{const{hash:t,fingerprint:i,setup:s}=e;r+=`\na=fingerprint:${t} ${i}\na=setup:${s}`})),i&&s&&(r+=`\na=ice-ufrag:${i}\na=ice-pwd:${s}`),r+="\na=group:BUNDLE 0 1 2\na=extmap-allow-mixed\na=msid-semantic: WMS *";const d="stream"+o.map((e=>e.ssrc)).join("_");for(let e=0;e<o.length;e++){const t=o[e],{type:i,ssrc:s,ssrcGroups:n,payloadTypes:a,rtpExtensions:l}=t;switch(i){case"audio":r+=`\nm=audio 9 UDP/TLS/RTP/SAVPF ${a.map((e=>e.id)).join(" ")}\nc=IN IP4 0.0.0.0\na=rtcp:9 IN IP4 0.0.0.0\na=ice-options:trickle\na=mid:${e}\na=sendrecv`,r+=A(l),s&&(r+=`\na=msid:${d} audio${s}`),r+="\na=rtcp-mux",r+=_(a),r+=F(i,s,n,d);break;case"video":r+=`\nm=video 9 UDP/TLS/RTP/SAVPF ${a.map((e=>e.id)).join(" ")}\nc=IN IP4 0.0.0.0\na=rtcp:9 IN IP4 0.0.0.0\na=ice-options:trickle\na=mid:${e}\na=sendrecv`,r+=A(l),s&&(r+=`\na=msid:${d} video${s}`),r+="\na=rtcp-mux\na=rtcp-rsize",r+=_(a),r+=F(i,s,n,d)}}return r+="m=application 9 UDP/DTLS/SCTP webrtc-datachannel\nc=IN IP4 0.0.0.0\na=ice-options:trickle\na=mid:2\na=sctp-port:5000\na=max-message-size:262144",r+="\n",r}}function T(){return navigator.userAgent.toLowerCase().indexOf("firefox")>-1}function x(){return navigator.userAgent.toLowerCase().indexOf("safari")>-1&&-1===navigator.userAgent.toLowerCase().indexOf("chrome")}function A(e){let t=[];for(let i=0;i<e.length;i++){const s=e[i],{id:n,uri:a}=s;console.log("[extmap] add",n,a),t.push(`a=extmap:${n} ${a}`)}return t.join("\n")}function _(e){let t=[];console.log("[SDP] addPayloadTypes",e);for(let i=0;i<e.length;i++){const s=e[i],{id:n,name:a,clockrate:o,channels:r,feedbackTypes:d,parameters:l}=s;if(t.push(`a=rtpmap:${n} ${a}/${o}${r?"/"+r:""}`),d&&d.forEach((e=>{const{type:i,subtype:s}=e;t.push(`a=rtcp-fb:${n} ${[i,s].join(" ")}`)})),l){const e=[];Object.getOwnPropertyNames(l).forEach((t=>{e.push(`${t}=${l[t]}`)})),t.push(`a=fmtp:${n} ${e.join(";")}`)}}return t.join("\n")}function F(e,t,i,s){let n=[];return i&&i.length>0?i.forEach((t=>{t&&t.ssrcs.length>0&&(n.push(`a=ssrc-group:${t.semantics} ${t.ssrcs.join(" ")}`),t.ssrcs.forEach((t=>{n.push(`a=ssrc:${t} cname:stream${t}`,`a=ssrc:${t} msid:${s} ${e}${t}`,`a=ssrc:${t} mslabel:${e}${t}`,`a=ssrc:${t} label:${e}${t}`)})))})):t&&n.push(`a=ssrc:${t} cname:stream${t}`,`a=ssrc:${t} msid:${s} ${e}${t}`,`a=ssrc:${t} mslabel:${e}${t}`,`a=ssrc:${t} label:${e}${t}`),n.join("\n")}class D{static generateCandidate(e){if(!e)return null;const{sdpString:t,sdpMLineIndex:i,sdpMid:s,foundation:n,component:a,protocol:o,priority:r,address:d,type:l,relAddress:c,generation:h,tcpType:u,networkId:p,networkCost:f,username:m}=e;if(t)return{candidate:t,sdpMLineIndex:i,sdpMid:s};throw"no sdpString"}static generateOffer(e){return T()?M.generateOffer(e):x()?k.generateOffer(e):Z.generateOffer(e)}static generateAnswer(e){return T()?M.generateAnswer(e):x()?k.generateAnswer(e):Z.generateAnswer(e)}}var R=i(9585),B=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class N extends m.Z{constructor(e){super(),this.log=(0,d.kg)("CALL"),this.protocol||(this.protocol={_:"phoneCallProtocol",pFlags:{udp_p2p:!0,udp_reflector:!0},min_layer:92,max_layer:92,library_versions:["4.0.0"]}),(0,a.Z)(this,e),this.createdAt=Date.now(),this.offerReceived=!1,this.offerSent=!1,this.decryptQueue=[],this.candidates=[],this.addEventListener("state",(e=>{this.log("state",v.Z[e]),e===v.Z.CLOSED&&this.cleanup()}));const t=this.streamManager=new R.Z(b.iK);t.direction="sendrecv",t.types.push("screencast"),this.isOutgoing||(t.locked=!0,t.canCreateConferenceEntry=!1);let i={"@type":"MediaState",type:"input",lowBattery:!1,muted:!0,screencastState:"inactive",videoRotation:0,videoState:"inactive"};const s=this;i=new Proxy(i,{set:function(e,t,n){return e[t]=n,s.setMediaState(i),s.sendMediaState(),!0}}),this.mediaStates={input:i},this.sendMediaState=(0,o.Z)(this._sendMediaState.bind(this),0,!1,!0)}get connectionState(){const{_connectionState:e,connectionInstance:t}=this;if(void 0!==e)return e;if(t){const{iceConnectionState:e}=t.connection;return"closed"===e?v.Z.CLOSED:"connected"===e||n.IS_SAFARI&&"completed"===e?v.Z.CONNECTED:v.Z.CONNECTING}return v.Z.CONNECTING}get sortIndex(){const e=this.connectionState;let t=1e13*(v.Z.CLOSED-e+1);return t+=2147483647e3-(e===v.Z.PENDING&&this.isOutgoing?0:this.createdAt),t}getVideoElement(e){if("input"===e)return this.elements.get("main");{const e=this.getMediaState("output");if(!e)return;const t="active"===e.videoState?"video":"active"===e.screencastState?"screencast":void 0;if(!t)return;const i=this.description.findEntry((e=>e.type===t));if(!i)return;return this.elements.get(""+i.recvEntry.source)}}startScreenSharingInternal(){return B(this,void 0,void 0,(function*(){try{this.wasStartingScreen=!0,this.wasStartingVideo=!1,this.streamManager.types=["audio","screencast"],yield this.requestScreen()}catch(e){this.log.error("startScreenSharing error",e)}}))}toggleScreenSharing(){return B(this,void 0,void 0,(function*(){return this.isSharingVideo&&(yield this.stopVideoSharing()),this.isSharingScreen?this.stopVideoSharing():this.startScreenSharingInternal()}))}startVideoSharingInternal(){return B(this,void 0,void 0,(function*(){try{this.wasStartingScreen=!1,this.wasStartingVideo=!0,this.streamManager.types=["audio","video"],yield this.requestInputSource(!1,!0,!1)}catch(e){this.log.error("startVideoSharing error",e)}}))}stopVideoSharing(){return B(this,void 0,void 0,(function*(){const e=this.getMediaState("input");e.videoState=e.screencastState="inactive";const{streamManager:t,description:i}=this,s=t.inputStream.getVideoTracks()[0];s&&((0,y.Z)(s),t.appendToConference(i))}))}toggleVideoSharing(){return B(this,void 0,void 0,(function*(){return this.isSharingScreen&&(yield this.stopVideoSharing()),this.isSharingVideo?this.stopVideoSharing():this.startVideoSharingInternal()}))}getMediaState(e){return this.mediaStates[e]}setMediaState(e){this.mediaStates[e.type]=e,this.dispatchEvent("mediaState",e)}isSharingVideoType(e){try{return super.isSharingVideo&&!!(this.wasStartingScreen&&"screencast"===e||this.wasStartingVideo&&"video"===e)}catch(e){return!1}}get isSharingVideo(){return this.isSharingVideoType("video")}get isSharingScreen(){return this.isSharingVideoType("screencast")}get isMuted(){const e=this.streamManager.inputStream.getAudioTracks()[0];return!(null==e?void 0:e.enabled)}get isClosing(){const{connectionState:e}=this;return e===v.Z.CLOSING||e===v.Z.CLOSED}get description(){var e;return null===(e=this.connectionInstance)||void 0===e?void 0:e.description}setHangUpTimeout(e,t){this.clearHangUpTimeout(),this.hangUpTimeout=s.Z.setTimeout((()=>{this.hangUpTimeout=void 0,this.hangUp(t)}),e)}clearHangUpTimeout(){void 0!==this.hangUpTimeout&&(clearTimeout(this.hangUpTimeout),this.hangUpTimeout=void 0)}setPhoneCall(e){this.call=e;const{id:t}=e;if(this.id!==t){const e=this.id;this.id=t,this.dispatchEvent("id",t,e)}}acceptCall(){var e;return B(this,void 0,void 0,(function*(){const t=null===(e=(yield Promise.all(this.dispatchResultableEvent("acceptCallOverride")))[0])||void 0===e||e;if(this.isClosing||!t)return;this.overrideConnectionState(v.Z.EXCHANGING_KEYS);const i=this.call;this.requestInputSource(!0,!!i.pFlags.video,!1);const s=i.g_a_hash;this.managers.appCallsManager.generateDh().then((e=>B(this,void 0,void 0,(function*(){return this.dh={g_a_hash:s,b:e.a,g_b:e.g_a,g_b_hash:e.g_a_hash,p:e.p},this.managers.apiManager.invokeApi("phone.acceptCall",{peer:yield this.managers.appCallsManager.getCallInput(this.id),protocol:this.protocol,g_b:this.dh.g_b})})))).then((e=>B(this,void 0,void 0,(function*(){yield this.managers.appCallsManager.savePhonePhoneCall(e)})))).catch((e=>{this.log.error("accept call error",e),this.hangUp("phoneCallDiscardReasonHangup")}))}))}joinCall(){this.log("joinCall"),this.getEmojisFingerprint(),this.overrideConnectionState();const{isOutgoing:e,encryptionKey:t,streamManager:i}=this,s=function(e){const t=[];return e.connections.forEach((e=>{switch(e._){case"phoneConnectionWebrtc":{const{ip:i,ipv6:s,port:n,username:a,password:o}=e,r=[];e.pFlags.turn?(i&&r.push(`turn:${i}:${n}`),s&&r.push(`turn:[${s}]:${n}`)):e.pFlags.stun&&(i&&r.push(`stun:${i}:${n}`),s&&r.push(`stun:[${s}]:${n}`)),r.length>0&&t.push({urls:r,username:a,credential:o});break}}})),{iceServers:t,iceTransportPolicy:e.pFlags.p2p_allowed?"all":"relay"}}(this.call);if(this.log("joinCall configuration",s),!s)return;const n=this.connectionInstance=new f({call:this,streamManager:i,log:this.log.bindPrefix("connection")}),a=n.createPeerConnection(s);a.addEventListener("iceconnectionstatechange",(()=>{const e=this.connectionState;void 0===this.connectedAt&&e===v.Z.CONNECTED&&(this.connectedAt=Date.now()),this.dispatchEvent("state",e)})),a.addEventListener("negotiationneeded",(()=>{n.negotiate()})),a.addEventListener("icecandidate",(e=>{const{candidate:t}=e;a.log("onicecandidate",t),(null==t?void 0:t.candidate)&&this.sendIceCandidate(t)})),a.addEventListener("track",(e=>{const{track:t}=e;a.log("ontrack",t),this.onTrack(e)})),n.createDescription(),this.encryptor=new I(e,t),this.decryptor=new I(!e,t),this.log("currentCall",this),e&&n.appendStreamToConference(),this.createDataChannel(),this.processDecryptQueue()}createDataChannelEntry(){const e=this.description.createEntry("application");e.setDirection("sendrecv"),e.sendEntry=e.recvEntry=e}createDataChannel(){if(this.connectionInstance.dataChannel)return;const e=this.connectionInstance.createDataChannel({id:0,negotiated:!0});e.addEventListener("message",(e=>{this.applyDataChannelData(JSON.parse(e.data))})),e.addEventListener("open",(()=>{this.sendMediaState()}))}applyDataChannelData(e){"MediaState"===e["@type"]?(e.type="output",this.log("got output media state",e),this.setMediaState(e)):this.log.error("unknown data channel data:",e)}_sendMediaState(){const{connectionInstance:e}=this;if(!e)return;const t=Object.assign({},this.getMediaState("input"));delete t.type,this.log("sendMediaState",t),e.sendDataChannelData(t)}sendCallSignalingData(e){return B(this,void 0,void 0,(function*(){const t=JSON.stringify(e),i=(new TextEncoder).encode(t),{bytes:s}=yield this.encryptor.encryptRawPacket(i);this.log("sendCallSignalingData",this.id,t),yield this.managers.apiManager.invokeApi("phone.sendSignalingData",{peer:yield this.managers.appCallsManager.getCallInput(this.id),data:s})}))}sendIceCandidate(e){this.log("sendIceCandidate",e);const{candidate:t,sdpMLineIndex:i}=e;if(0!==i)return;const s=function(e){if(!e||!e.startsWith("candidate:"))return;const t=e;e=e.substr("candidate:".length);const[i,s,n,a,o,r,...d]=e.split(" "),l={sdpString:t,foundation:i,component:s,protocol:n,priority:a,address:{ip:o,port:r}};for(let e=0;e<d.length;e+=2)switch(d[e]){case"typ":l.type=d[e+1];break;case"raddr":l.relAddress||(l.relAddress={}),l.relAddress.ip=d[e+1];break;case"rport":l.relAddress||(l.relAddress={}),l.relAddress.port=d[e+1];break;case"generation":l.generation=d[e+1];break;case"tcptype":l.tcpType=d[e+1];break;case"network-id":l.networkId=d[e+1];break;case"network-cost":l.networkCost=d[e+1];break;case"ufrag":l.username=d[e+1]}return l}(t);this.sendCallSignalingData({"@type":"Candidates",candidates:[s]})}confirmCall(){return B(this,void 0,void 0,(function*(){const{protocol:e,id:t,call:i}=this,s=this.dh;this.overrideConnectionState(v.Z.EXCHANGING_KEYS);const{key:n,key_fingerprint:a}=yield this.managers.appCallsManager.computeKey(i.g_b,s.a,s.p),o=yield this.managers.apiManager.invokeApi("phone.confirmCall",{peer:yield this.managers.appCallsManager.getCallInput(t),protocol:e,g_a:s.g_a,key_fingerprint:a});this.encryptionKey=n,yield this.managers.appCallsManager.savePhonePhoneCall(o),this.joinCall()}))}getEmojisFingerprint(){return this.emojisFingerprint?this.emojisFingerprint:this.getEmojisFingerprintPromise?this.getEmojisFingerprintPromise:this.getEmojisFingerprintPromise=l.Z.invokeCrypto("get-emojis-fingerprint",this.encryptionKey,this.dh.g_a).then((e=>(this.getEmojisFingerprintPromise=void 0,this.emojisFingerprint=e.map((e=>(0,r.zu)(e))))))}unlockStreamManager(){this.connectionInstance.streamManager.locked=!1,this.connectionInstance.appendStreamToConference()}doTheMagic(){return B(this,void 0,void 0,(function*(){this.connectionInstance.appendStreamToConference();const e=this.connectionInstance.connection;let t=yield e.createAnswer();this.log("[sdp] local",t.type,t.sdp),yield e.setLocalDescription(t),e.getTransceivers().filter((e=>"recvonly"===e.direction)).forEach((e=>{const t=this.connectionInstance.description.getEntryByMid(e.mid);t.transceiver=t.recvEntry.transceiver=e,e.direction="sendrecv"}));const i=this.description,s=i.entries.map((e=>e.mid)),n={type:"offer",sdp:i.generateSdp({bundle:s,entries:i.entries.filter((e=>s.includes(e.mid))),isAnswer:!0})};yield e.setRemoteDescription(n),t=yield e.createAnswer(),yield e.setLocalDescription(t);const a=u((0,p.DV)(t.sdp));this.log("[InitialSetup] send 1"),this.sendCallSignalingData(a),this.unlockStreamManager()}))}overrideConnectionState(e){this._connectionState=e,this.dispatchEvent("state",this.connectionState)}get duration(){return void 0!==this.connectedAt?(Date.now()-this.connectedAt)/1e3|0:0}onInputStream(e){super.onInputStream(e);const t=e.getVideoTracks()[0];if(t){const e=this.getMediaState("input");this.wasStartingScreen||this.wasStartingVideo||(this.wasStartingVideo=!0),this.isSharingVideo?e.videoState="active":this.isSharingScreen&&(e.screencastState="active"),t.addEventListener("ended",(()=>{this.stopVideoSharing()}),{once:!0})}e.getAudioTracks().length&&this.onMutedChange()}onMutedChange(){const e=this.isMuted;this.dispatchEvent("muted",e),this.getMediaState("input").muted=e}toggleMuted(){return this.requestAudioSource(!0).then((()=>{this.setMuted(),this.onMutedChange()}))}hangUp(e,t){return B(this,void 0,void 0,(function*(){if(!this.isClosing&&(this.discardReason=e,this.log("hangUp",e),this.overrideConnectionState(v.Z.CLOSED),this.connectionInstance&&this.connectionInstance.closeConnectionAndStream(!0),e&&!t)){let t=!1;for(const e in this.mediaStates){const i=this.mediaStates[e];t="active"===i.videoState||"active"===i.screencastState||t}yield this.managers.appCallsManager.discardCall(this.id,this.duration,e,t)}}))}performCodec(e){const t=e.payloadTypes.map((e=>Object.assign(Object.assign({},e),{"rtcp-fbs":e.feedbackTypes})));return{"rtp-hdrexts":e.rtpExtensions,"payload-types":t}}setDataToDescription(e){this.description.setData({transport:{pwd:e.pwd,ufrag:e.ufrag,fingerprints:e.fingerprints,"rtcp-mux":!0},audio:this.performCodec(e.audio),video:e.video?this.performCodec(e.video):void 0,screencast:e.screencast?this.performCodec(e.screencast):void 0})}filterNotVP8(e){this.isOutgoing||[e.video,e.screencast].filter(Boolean).forEach((e=>{const t=e.payloadTypes,i=t.findIndex((e=>"VP8"===e.name)),s=t[i],n=t.findIndex((e=>{var t;return+(null===(t=e.parameters)||void 0===t?void 0:t.apt)===s.id}));e.payloadTypes=[t[i],t[n]]}))}applyCallSignalingData(e){return B(this,void 0,void 0,(function*(){this.log("applyCallSignalingData",this,e);const{connection:t,description:i}=this.connectionInstance;switch(e["@type"]){case"InitialSetup":{this.log("[sdp] InitialSetup",e),this.filterNotVP8(e),this.setDataToDescription(e);const s=e=>e.map((e=>({_:"groupCallParticipantVideoSourceGroup",semantics:e.semantics,sources:e.ssrcs.map((e=>+e))})));[(0,w.z_)("audio",+e.audio.ssrc),e.video?(0,w.z_)("video",s(e.video.ssrcGroups)):void 0,e.screencast?(0,w.z_)("screencast",s(e.screencast.ssrcGroups)):void 0].filter(Boolean).forEach((e=>{let t=i.getEntryBySource(e.source);if(t)return;const s=i.findFreeSendRecvEntry(e.type,!1);t=new w.Lp(s.mid,e.type),t.setDirection("sendrecv"),s.recvEntry=t,i.setEntrySource(t,e.sourceGroups||e.source)})),this.createDataChannelEntry();const n=this.offerSent;this.offerSent=!1;const a=i.entries.map((e=>e.mid)),o={type:n?"answer":"offer",sdp:i.generateSdp({bundle:a,entries:i.entries.filter((e=>a.includes(e.mid))),isAnswer:!n})};this.log("[sdp] remote",o.sdp),yield t.setRemoteDescription(o),yield this.tryToReleaseCandidates(),n||(yield this.doTheMagic());break}case"Candidates":for(const t of e.candidates){const e=D.generateCandidate(t);e.sdpMLineIndex=0;const i=new RTCIceCandidate(e);this.candidates.push(i)}yield this.tryToReleaseCandidates();break;default:this.log.error("unrecognized signaling data",e)}}))}tryToReleaseCandidates(){return B(this,void 0,void 0,(function*(){const{connectionInstance:e}=this;if(!e)return;const{connection:t}=e;if(t.remoteDescription){const e=this.candidates.map((e=>this.addIceCandidate(t,e)));this.candidates.length=0,yield Promise.all(e)}else this.log("[candidates] postpone")}))}addIceCandidate(e,t){return B(this,void 0,void 0,(function*(){this.log("[candidate] start",t);try{yield e.addIceCandidate(t),this.log("[candidate] add",t)}catch(e){this.log.error("[candidate] error",t,e)}}))}processDecryptQueue(){return B(this,void 0,void 0,(function*(){const{encryptor:e}=this;if(!e)return void this.log.warn("got encrypted signaling data before the encryption key");if(!this.decryptQueue.length)return;const t=this.decryptQueue.slice();this.decryptQueue.length=0;for(const i of t){const t=yield e.decryptRawPacket(i);if(!t)continue;const s=(new TextDecoder).decode(t);try{const e=JSON.parse(s);this.log("[update] updateNewCallSignalingData",e),this.applyCallSignalingData(e)}catch(e){this.log.error("wrong signaling data",s),this.hangUp("phoneCallDiscardReasonDisconnect"),g.Z.dispatchEvent("incompatible",this.interlocutorUserId)}}}))}onUpdatePhoneCallSignalingData(e){this.decryptQueue.push(e),this.processDecryptQueue()}}},8500:(e,t,i)=>{"use strict";i.d(t,{Z:()=>p});var s=i(3241),n=i(319),a=i(9125),o=i(9337),r=i(382),d=i(5424);function l(){const e={main:{},screen:{}};return t=>{return i=this,s=void 0,a=function*(){const{isScreen:i,constraints:s}=t,n=e[i?"screen":"main"];let a=n[s.audio?"audio":"video"];a||(a=(i?r.Z:d.Z)(s,t.muted),s.audio&&!n.audio&&(n.audio=a.finally((()=>n.audio=void 0))),s.video&&!n.video&&(n.video=a.finally((()=>n.video=void 0))));try{return yield a}catch(e){throw e}},new((n=void 0)||(n=Promise))((function(e,t){function o(e){try{d(a.next(e))}catch(e){t(e)}}function r(e){try{d(a.throw(e))}catch(e){t(e)}}function d(t){var i;t.done?e(t.value):(i=t.value,i instanceof n?i:new n((function(e){e(i)}))).then(o,r)}d((a=a.apply(i,s||[])).next())}));var i,s,n,a}}window.getStreamCached=l;var c=i(312),h=i(49),u=i(9585);class p extends s.Z{constructor(){super(!1);const e=this.player=document.createElement("div");e.classList.add("call-player"),e.style.display="none",document.body.append(e),this.elements=new Map;const t=this.audio=new Audio;t.autoplay=!0,t.volume=1,this.player.append(t),this.elements.set("audio",t),this.fixSafariAudio(),this.getStream=l()}get isSharingAudio(){return!!this.streamManager.hasInputTrackKind("audio")}get isSharingVideo(){return!!this.streamManager.hasInputTrackKind("video")}fixSafariAudio(){this.audio.play().catch(n.Z)}requestAudioSource(e){return this.requestInputSource(!0,!1,e)}requestInputSource(e,t,i){const{streamManager:s}=this;if(s){const i=!e||this.isSharingAudio,s=!t||this.isSharingVideo;if(i&&s)return Promise.resolve()}const n={audio:e&&(0,a.Z)(),video:t&&(0,c.Z)()};return this.getStream({constraints:n,muted:i}).then((e=>{this.onInputStream(e)}))}requestScreen(){return this.getStream({isScreen:!0,constraints:(0,o.Z)(!0)}).then((e=>{this.onInputStream(e)}))}getElement(e){return this.elements.get(""+e)}cleanup(){this.player.textContent="",this.player.remove(),this.elements.clear(),this.streamManager.stop(),super.cleanup()}onTrack(e){this.tryAddTrack({stream:e.streams[0],track:e.track,type:"output"})}saveInputVideoStream(e,t){const i=e.getVideoTracks()[0];this.tryAddTrack({stream:e,track:i,type:"input",source:t||"main"})}tryAddTrack({stream:e,track:t,type:i,source:s}){s||(s=u.Z.getSource(e,i)),this.log("tryAddTrack",e,t,i,s);const a="output"===i,{player:o,elements:r,streamManager:d}=this,l=t.kind,c="video"===l,h=c?s:l;let p=r.get(h);c&&t.addEventListener("ended",(()=>{this.log("[track] onended"),r.delete(h)}),{once:!0}),a&&d.addTrack(e,t,i);const f=c?e:d.outputStream;if(p)p.paused&&p.play().catch(n.Z),p.srcObject=f;else{if(p=document.createElement(l),p.autoplay=!0,p.srcObject=f,p.volume=1,"undefined"!==p.sinkId){const{outputDeviceId:e}=this;e&&p.setSinkId(e)}c?(p.setAttribute("playsinline","true"),p.muted=!0):o.appendChild(p),r.set(h,p)}return s}setMuted(e){this.streamManager.inputStream.getAudioTracks().forEach((t=>{"audio"===(null==t?void 0:t.kind)&&(t.enabled=void 0===e?!t.enabled:!e)}))}onInputStream(e){if(this.isClosing)e.getTracks().forEach((e=>{(0,h.Z)(e)}));else{e.getVideoTracks().length&&this.saveInputVideoStream(e,"main");const{streamManager:t,description:i}=this;t.addStream(e,"input"),i&&t.appendToConference(i)}}}},3335:(e,t,i)=>{"use strict";var s;i.d(t,{Z:()=>n}),function(e){e[e.CONNECTED=0]="CONNECTED",e[e.CONNECTING=1]="CONNECTING",e[e.EXCHANGING_KEYS=2]="EXCHANGING_KEYS",e[e.PENDING=3]="PENDING",e[e.REQUESTING=4]="REQUESTING",e[e.CLOSING=5]="CLOSING",e[e.CLOSED=6]="CLOSED"}(s||(s={}));const n=s},2493:(e,t,i)=>{"use strict";i.d(t,{Z:()=>C});var s=i(5916);let n;var a=i(410),o=i(993),r=i(1655),d=i(6519),l=i(9895),c=i(3241),h=i(7298),u=i(5003),p=i(3855),f=i(1507),m=i(3512),g=i(2069),v=i(3335),b=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};const y=45e3;class w extends c.Z{construct(e){this.managers=e,this.log=(0,u.kg)("CC"),o.Z&&(this.audioAsset=null!=n?n:n=new s.Z(["call_busy.mp3","call_connect.mp3","call_end.mp3","call_incoming.mp3","call_outgoing.mp3","voip_failed.mp3"]),this.tempId=0,this.instances=new Map,this.sortedInstances=[],m.Z.addEventListener("call_update",(e=>b(this,void 0,void 0,(function*(){var t;let i=this.instances.get(e.id);switch(i&&i.setPhoneCall(e),e._){case"phoneCallDiscarded":i&&i.hangUp(null===(t=e.reason)||void 0===t?void 0:t._,!0);break;case"phoneCallAccepted":i&&i.confirmCall();break;case"phoneCallRequested":i||(i=this.createCallInstance({isOutgoing:!1,interlocutorUserId:e.admin_id}),i.overrideConnectionState(v.Z.PENDING),i.setPhoneCall(e),i.setHangUpTimeout(y,"phoneCallDiscardReasonMissed"));break;case"phoneCall":{if(!i||i.encryptionKey)break;const t=i.dh.g_a=e.g_a_or_b,s=i.dh,n=yield p.Z.invokeCrypto("sha256",t);if(!(0,l.Z)(s.g_a_hash,n)){this.log.error("Incorrect g_a_hash",s.g_a_hash,n);break}const{key:a,key_fingerprint:o}=yield this.managers.appCallsManager.computeKey(t,s.b,s.p);if(e.key_fingerprint!==o){this.log.error("Incorrect key fingerprint",e.key_fingerprint,o,t,s),i.hangUp("phoneCallDiscardReasonDisconnect");break}i.encryptionKey=a,i.joinCall();break}}})))),m.Z.addEventListener("call_signaling",(({callId:e,data:t})=>{const i=this.instances.get(e);(null==i?void 0:i.id)===e&&i.onUpdatePhoneCallSignalingData(t)})))}get currentCall(){return this.sortedInstances[0]}getCallByUserId(e){for(const[t,i]of this.instances)if(i.interlocutorUserId===e)return i}createCallInstance(e){const t=new g.Z(Object.assign({managers:this.managers},e));return t.addEventListener("state",(e=>{const i=this.currentCall;e===v.Z.CLOSED?(this.instances.delete(t.id),(0,r.Z)(this.sortedInstances,t)):(0,d.Z)(this.sortedInstances,t,"sortIndex"),e===v.Z.EXCHANGING_KEYS&&(t.wasTryingToJoin=!0);const s=void 0!==t.connectedAt;e===v.Z.EXCHANGING_KEYS||e===v.Z.CONNECTING&&s?t.setHangUpTimeout(y,"phoneCallDiscardReasonDisconnect"):t.clearHangUpTimeout(),i!==t&&i||(e===v.Z.CLOSED?t.isOutgoing||t.wasTryingToJoin?t.wasTryingToJoin&&!s?this.audioAsset.playSound("voip_failed.mp3"):this.audioAsset.playSound("phoneCallDiscardReasonBusy"===t.discardReason?"call_busy.mp3":"call_end.mp3"):this.audioAsset.stopSound():e===v.Z.PENDING?this.audioAsset.playSound(t.isOutgoing?"call_outgoing.mp3":"call_incoming.mp3",!0):e===v.Z.EXCHANGING_KEYS?this.audioAsset.playSoundIfDifferent("call_connect.mp3"):e===v.Z.CONNECTING?t.duration&&this.audioAsset.playSound("voip_connecting.mp3",!0):this.audioAsset.stopSound())})),t.addEventListener("id",((e,i)=>{void 0!==i&&this.instances.delete(i);const s=!!this.currentCall;this.instances.set(e,t),void 0===i&&this.dispatchEvent("instance",{instance:t,hasCurrent:s})})),t}startCallInternal(e,t){return b(this,void 0,void 0,(function*(){this.log("p2pStartCallInternal",e,t);const i=yield this.managers.appProfileManager.getProfile(e);if(!i)return;const{video_calls_available:s}=i.pFlags,n=this.createCallInstance({isOutgoing:!0,interlocutorUserId:e});n.requestInputSource(!0,!(!t||!s),!1),n.overrideConnectionState(v.Z.REQUESTING),n.setPhoneCall({_:"phoneCallWaiting",access_hash:"",admin_id:f.NM,date:(0,h.Z)(!0),id:--this.tempId,participant_id:e,protocol:n.protocol,pFlags:{video:t||void 0}}),this.managers.appCallsManager.generateDh().then((i=>b(this,void 0,void 0,(function*(){return n.dh=i,this.managers.appCallsManager.requestCall(e,n.protocol,n.dh.g_a_hash,t&&s)})))).then((e=>{n.overrideConnectionState(v.Z.PENDING),n.setPhoneCall(e),n.setHangUpTimeout(y,"phoneCallDiscardReasonHangup")}))}))}}const S=new w;a.GO&&(a.GO.callsController=S);const C=S},1677:(e,t,i)=>{"use strict";i.d(t,{KM:()=>s,iK:()=>n});const s=50,n=100},9078:(e,t,i)=>{"use strict";i.d(t,{Z:()=>T});var s=i(4762),n=i(1655),a=i(5953),o=i(6724),r=i(5003),d=i(1507),l=i(3512),c=i(8500),h=i(7625),u=i(3075),p=i(8479),f=i(6752),m=i(9124),g=i(4373),v=i(3773),b=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class y extends u.Z{constructor(e){super(e),this.negotiateThrottled=(0,o.Z)(this.negotiate.bind(this),0,!1)}createPeerConnection(){return this.connection||super.createPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",iceCandidatePoolSize:0})}createDataChannel(){if(this.dataChannel)return this.dataChannel;const e=super.createDataChannel();return e.addEventListener("open",(()=>{this.maybeUpdateRemoteVideoConstraints()})),e.addEventListener("close",(()=>{this.updateConstraintsInterval&&(clearInterval(this.updateConstraintsInterval),this.updateConstraintsInterval=void 0)})),e}createDescription(){return this.description?this.description:super.createDescription()}appendStreamToConference(){super.appendStreamToConference()}invokeJoinGroupCall(e,t,i){return b(this,void 0,void 0,(function*(){const{groupCall:s,description:n}=this,a=s.id,o=t.map((t=>{const i=function(e,t){const i=(0,v.Z)(e,t),s=t.mediaType,n={source:i.source,sourceGroups:i.sourceGroups,type:s};i.fingerprint.setup="active";const a={fingerprints:[i.fingerprint],pwd:i.pwd,ssrc:i.source,"ssrc-groups":i.sourceGroups||[],ufrag:i.ufrag};return{params:{_:"dataJSON",data:JSON.stringify(a)},source:i.source,media:t,sourceGroups:i.sourceGroups,entry:n}}(e,t);return this.sources[i.entry.type]=i.entry,i})),r=o.find((e=>"audio"===e.media.mediaType)),d=o.find((e=>"video"===e.media.mediaType));let{source:c,params:u}=r||{};const p=d||r,f={audio:r,video:d};if(n.entries.forEach((e=>{if("sendonly"===e.direction){const t=f[e.type];if(!t)return;n.setEntrySource(e,t.sourceGroups||t.source),n.setEntryPeerId(e,l.Z.myId)}})),u!==p.params){const e=JSON.parse(p.params.data);c?e.ssrc=c:delete e.ssrc,u={_:"dataJSON",data:JSON.stringify(e)}}const m=yield this.managers.appGroupCallsManager.joinGroupCall(a,u,i),g=JSON.parse(m.params.data);return g.audio=g.audio||s.connections.main.description.audio,n.setData(g),function(e,t){["audio","video"].filter((e=>t[e])).map((e=>[t[e],e])).forEach((([t,i])=>{const s=e.find((e=>e.mediaType===i));if(!s)return;const n=(e=>{const t={};return e.attributes.get("extmap").forEach((e=>{const i=e.key.split("/",1)[0];t[i]=e.value})),t})(s);(0,h.Z)(t["rtp-hdrexts"],((e,t,s)=>{n[e.id]!==e.uri&&(s.splice(t,1),console.log("[sdp] filtered extmap:",e,t,i))}))}))}(t,g),g}))}negotiateInternal(){return b(this,void 0,void 0,(function*(){const{connection:e,description:t}=this,i="new"===e.iceConnectionState&&!t.getEntryByMid("0").source,s=this.log.bindPrefix("startNegotiation");s("start");const n=yield e.createOffer({iceRestart:!1});i&&this.dataChannel&&t.createEntry("application").setDirection("sendrecv");const{sdp:a,offer:o}=function(e){const{offer:t,data:i}=e,s=(0,m.DV)(t.sdp);let n=!1;if(e.skipAddingMulticast||(n=(0,m.e6)(s)||n),(0,h.Z)(s.media,((e,t,a)=>{if(e.isSending)return;if("application"===e.mediaType)return;const o=e.mediaLine,r=o.mediaLineParts,d=(r.ids,o.toString()),l=i[e.mediaType]["payload-types"].map((e=>""+e.id));if(d!==(0,g.Px)(e.mediaType,void 0,l)){const o=(0,v.Z)(s,e),d=Object.assign({},i);d.transport=(0,p.Z)(d.transport),d.transport.ufrag=o.ufrag,d.transport.pwd=o.pwd,d.transport.fingerprints=[o.fingerprint],d.transport.candidates=[];const l=new f.Lp(o.mid,r.type);l.setPort(r.port),o.source&&l.setSource(o.sourceGroups||o.source),l.setDirection(e.direction);const c=(new g.DY).addSsrcEntry(l,d).finalize(),h=(0,m.DV)(c).media[0];a[t]=h,n=!0}})),n){const e=s.toString();t.sdp=e}return{offer:t,sdp:s}}({offer:n,data:t});s("[sdp] setLocalDescription",o.sdp),yield e.setLocalDescription(o);const r=a.media.filter((e=>"application"!==e.mediaType&&e.isSending));if(i)try{yield this.invokeJoinGroupCall(a,r,this.options)}catch(e){this.log.error("[tdweb] joinGroupCall error",e)}const d=[],l=a.bundle;(0,h.Z)(l,((e,i,s)=>{const n=t.getEntryByMid(e);n.shouldBeSkipped(!0)&&(s.splice(i,1),d.push(n))}));const c=a.media.map((e=>{const i=e.mid;let s=t.getEntryByMid(i);return s||(s=new f.Lp(i,e.mediaType),s.setDirection("inactive")),s})),u={type:"answer",sdp:t.generateSdp({bundle:l,entries:c,isAnswer:!0})};d.forEach((e=>{t.deleteEntry(e)})),s(`[sdp] setRemoteDescription signaling=${e.signalingState} ice=${e.iceConnectionState} gathering=${e.iceGatheringState} connection=${e.connectionState}`,u.sdp),yield e.setRemoteDescription(u),s("end")}))}negotiate(){let e=this.negotiating;return e||(e=super.negotiate(),this.updateConstraints&&e.then((()=>{this.maybeUpdateRemoteVideoConstraints(),this.updateConstraints=!1})),"presentation"===this.options.type&&e.then((()=>{this.connection.getTransceivers().find((e=>{var t,i;"video"===(null===(i=null===(t=e.sender)||void 0===t?void 0:t.track)||void 0===i?void 0:i.kind)&&e.sender.setParameters(Object.assign(Object.assign({},e.sender.getParameters()),{degradationPreference:"maintain-resolution"}))}))})),e)}maybeUpdateRemoteVideoConstraints(){if("open"!==this.dataChannel.readyState)return;this.log("maybeUpdateRemoteVideoConstraints");const e={colibriClass:"ReceiverVideoConstraints",constraints:{},defaultConstraints:{maxHeight:0},onStageEndpoints:[]};for(const t of this.description.entries){if("recvonly"!==t.direction||"video"!==t.type)continue;const{endpoint:i}=t;e.onStageEndpoints.push(i),e.constraints[i]={minHeight:180,maxHeight:720}}this.sendDataChannelData(e),e.onStageEndpoints.length?this.updateConstraintsInterval||(this.updateConstraintsInterval=window.setInterval(this.maybeUpdateRemoteVideoConstraints.bind(this),5e3)):this.updateConstraintsInterval&&(clearInterval(this.updateConstraintsInterval),this.updateConstraintsInterval=void 0)}addInputVideoStream(e){this.groupCall.saveInputVideoStream(e,this.type),this.streamManager.addStream(e,"input"),this.appendStreamToConference()}}var w=i(2207),S=i(9337),C=i(382),L=i(5424),E=i(312),I=i(49),P=i(9585),Z=i(2946),M=i(2059),k=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};class T extends c.Z{constructor(e){super(),(0,a.Z)(this,e),this.log||(this.log=(0,r.kg)("GROUP-CALL")),this.connections||(this.connections={}),this.isSpeakingMap||(this.isSpeakingMap=new Map),this.pinnedSources=[],this.participantsSsrcs=new Map,this.hadAutoPinnedSources=new Set,this.dispatchPinnedThrottled=(0,o.Z)((()=>{this.dispatchEvent("pinned",this.pinnedSource)}),0,!1),this.addEventListener("state",(e=>{e===w.Z.CLOSED&&this.cleanup()}))}get connectionState(){return this.connections.main.connection.iceConnectionState}get state(){const{connectionState:e}=this;if("closed"===e)return w.Z.CLOSED;if("connected"===e||s.IS_SAFARI&&"completed"===e){const{participant:e}=this;return e.pFlags.can_self_unmute?e.pFlags.muted?w.Z.MUTED:w.Z.UNMUTED:w.Z.MUTED_BY_ADMIN}return w.Z.CONNECTING}get participants(){return this.managers.appGroupCallsManager.getCachedParticipants(this.id)}get isSharingScreen(){return!!this.connections.presentation}get pinnedSource(){return this.pinnedSources[this.pinnedSources.length-1]}get isMuted(){return this.state!==w.Z.UNMUTED}get isClosing(){const{state:e}=this;return e===w.Z.CLOSED}get streamManager(){return this.connections.main.streamManager}get description(){return this.connections.main.description}pinSource(e){(0,n.Z)(this.pinnedSources,e),this.pinnedSources.push(e),this.dispatchPinnedThrottled()}unpinSource(e){this.hadAutoPinnedSources.delete(e),(0,n.Z)(this.pinnedSources,e),this.dispatchPinnedThrottled()}unpinAll(){this.pinnedSources.length=0,this.dispatchPinnedThrottled()}getParticipantByPeerId(e){return k(this,void 0,void 0,(function*(){return d.NM===e?this.participant:(yield this.participants).get(e)}))}toggleMuted(){return this.requestAudioSource(!0).then((()=>this.changeUserMuted(d.NM)))}changeUserMuted(e,t){return k(this,void 0,void 0,(function*(){const i=yield this.getParticipantByPeerId(e);return d.NM===e&&i.pFlags.can_self_unmute&&(t=void 0===t?!i.pFlags.muted:t),this.editParticipant(i,{muted:t})}))}getElement(e){return super.getElement(e)}getVideoElementFromParticipantByType(e,t){let i;i=e.pFlags.self?"video"===t?"main":"presentation":e[t].source_groups[0].sources[0];const s=this.getElement(i);if(!s)return;const n=s.cloneNode();return n.srcObject=s.srcObject,{video:n,source:i}}createConnectionInstance(e){return this.connections[e.type]=new y(Object.assign({groupCall:this,log:this.log.bindPrefix(e.type),managers:this.managers},e))}changeRaiseHand(e){return this.editParticipant(this.participant,{raiseHand:e})}startScreenSharingInternal(){return k(this,void 0,void 0,(function*(){try{const e="presentation",t=yield(0,C.Z)((0,S.Z)()),i=new P.Z,s=this.createConnectionInstance({streamManager:i,type:e,options:{type:e}});s.createPeerConnection().addEventListener("negotiationneeded",(()=>{s.negotiate()})),t.getVideoTracks()[0].addEventListener("ended",(()=>{this.connections.presentation&&this.stopScreenSharing()}),{once:!0}),s.createDescription(),s.addInputVideoStream(t)}catch(e){this.log.error("start screen sharing error",e)}}))}startScreenSharing(){var e;return null!==(e=this.startScreenSharingPromise)&&void 0!==e?e:this.startScreenSharingPromise=this.startScreenSharingInternal().finally((()=>{this.startScreenSharingPromise=void 0}))}stopScreenSharing(){const e=this.connections.presentation;return e?(delete this.connections.presentation,this.unpinSource("presentation"),e.closeConnectionAndStream(!0),delete this.participant.presentation,this.managers.appGroupCallsManager.saveApiParticipant(this.id,this.participant),this.managers.appGroupCallsManager.leaveGroupCallPresentation(this.id)):Promise.resolve()}toggleScreenSharing(){return this.isSharingScreen?this.stopScreenSharing():this.startScreenSharing()}startVideoSharingInternal(){return k(this,void 0,void 0,(function*(){const e={video:(0,E.Z)()};try{const t=yield(0,L.Z)(e,!1);this.connections.main.addInputVideoStream(t),yield this.editParticipant(this.participant,{videoPaused:!1,videoStopped:!1})}catch(t){this.log.error("startVideoSharing error",t,e)}}))}startVideoSharing(){var e;return null!==(e=this.startVideoSharingPromise)&&void 0!==e?e:this.startVideoSharingPromise=this.startVideoSharingInternal().finally((()=>{this.startVideoSharingPromise=void 0}))}stopVideoSharing(){return k(this,void 0,void 0,(function*(){const e=this.connections.main,t=e.streamManager.inputStream.getVideoTracks()[0];t&&((0,I.Z)(t),e.streamManager.appendToConference(e.description),yield this.editParticipant(this.participant,{videoStopped:!0}))}))}toggleVideoSharing(){return this.isSharingVideo?this.stopVideoSharing():this.startVideoSharing()}hangUp(e=!1,t=!1,i=!1){return k(this,void 0,void 0,(function*(){for(const e in this.connections)this.connections[e].closeConnectionAndStream(!t);if(this.dispatchEvent("state",this.state),!i&&!t){const t=e||(this.joined?this.connections.main.sources.audio.source:void 0);this.managers.appGroupCallsManager.hangUp(this.id,t)}}))}tryAddTrack(e){const{description:t}=this,i=super.tryAddTrack(e);if("output"===e.type){const e=t.getEntryBySource(+i);this.getParticipantByPeerId(e.peerId).then((e=>{e&&l.Z.dispatchEvent("group_call_participant",{groupCallId:this.id,participant:e})}))}return i}editParticipant(e,t){return k(this,void 0,void 0,(function*(){if(Object.keys(t).length){if(e){const i=e.pFlags.self;if(i&&void 0!==t.muted&&!this.isSharingAudio&&(delete t.muted,!Object.keys(t).length))return;const s=t.muted;void 0!==s&&e.pFlags.self&&(s?e.pFlags.muted=!0:e.pFlags.can_self_unmute&&delete e.pFlags.muted),void 0!==t.raiseHand&&(t.raiseHand?e.raise_hand_rating="1":delete e.raise_hand_rating),i&&(void 0!==t.videoStopped&&(t.videoStopped?delete e.video:e.video=(0,M.KR)(this.connections.main.sources.video)),!e.pFlags.muted&&e.pFlags.can_self_unmute&&this.setMuted(!1),this.dispatchEvent("state",this.state))}return this.managers.appGroupCallsManager.editParticipant(this.id,e,t)}}))}onParticipantUpdate(e,t){const i=this.connections.main,{connection:s,description:n}=i,a=(0,Z.Z)(e.peer),o=!!e.pFlags.left,r=this.participantsSsrcs.get(a)||[];if(e.presentation&&!o){const{source:t}=(0,M._f)(e,"video",e.presentation.source_groups,e.presentation.endpoint);this.hadAutoPinnedSources.has(t)||(this.hadAutoPinnedSources.add(t),this.pinSource(e.pFlags.self?"presentation":t))}if(e.pFlags.self){this.participant=e,i.sources.audio.source!==e.source&&this.hangUp();let s=!1;return e.pFlags.can_self_unmute?e.pFlags.muted&&(s=!0):(this.stopScreenSharing(),this.stopVideoSharing(),s=!0),s&&this.setMuted(!0),void(t!==a&&this.dispatchEvent("state",this.state))}const d=o?[]:(0,M.s$)(e);o?this.participantsSsrcs.delete(a):this.participantsSsrcs.set(a,d);const l=new Set;r.forEach((e=>{const t=e.source;if(!d.find((e=>e.source===t))){this.unpinSource(t);const e=n.getEntryBySource(t);e&&"inactive"!==e.direction&&(e.setDirection("inactive"),l.add(e.type))}})),d.forEach((e=>{let t=n.getEntryBySource(e.source);t?"inactive"===t.direction&&(t.setDirection(t.originalDirection),l.add(t.type)):(t=n.createEntry(e.type),n.setEntrySource(t,e.sourceGroups||e.source),n.setEntryPeerId(t,a),"video"===e.type&&t.setEndpoint(e.endpoint),t.createTransceiver(s,{direction:"recvonly"}),l.add(t.type))})),l.size&&(l.has("video")&&(i.updateConstraints=!0),i.negotiateThrottled())}}},2207:(e,t,i)=>{"use strict";var s;i.d(t,{Z:()=>n}),function(e){e[e.UNMUTED=0]="UNMUTED",e[e.MUTED=1]="MUTED",e[e.MUTED_BY_ADMIN=2]="MUTED_BY_ADMIN",e[e.CONNECTING=3]="CONNECTING",e[e.CLOSED=4]="CLOSED"}(s||(s={}));const n=s},2059:(e,t,i)=>{"use strict";i.d(t,{ZP:()=>L,KR:()=>w,_f:()=>y,s$:()=>b});var s=i(5916);let n;var a=i(410),o=i(3241),r=i(5003),d=i(3512),l=i(9078),c=i(2207),h=i(1677),u=i(9585),p=i(9125),f=i(5424),m=i(312),g=i(6752),v=function(e,t,i,s){return new(i||(i=Promise))((function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function r(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((s=s.apply(e,t||[])).next())}))};function b(e){var t,i;return[y(0,"audio",e.source),(null===(t=e.video)||void 0===t?void 0:t.audio_source)&&y(0,"audio",e.video.audio_source),e.video&&y(0,"video",e.video.source_groups,e.video.endpoint),(null===(i=e.presentation)||void 0===i?void 0:i.audio_source)&&y(0,"audio",e.presentation.audio_source),e.presentation&&y(0,"video",e.presentation.source_groups,e.presentation.endpoint)].filter(Boolean)}function y(e,t,i,s){return(0,g.z_)(t,i,s)}function w(e,t){return e&&{_:"groupCallParticipantVideo",pFlags:{},endpoint:"",source_groups:e.sourceGroups,audio_source:t}}class S extends o.Z{construct(e){this.managers=e,this.audioAsset=null!=n?n:n=new s.Z(["group_call_connect.mp3","group_call_end.mp3","group_call_start.mp3","voip_onallowtalk.mp3"]),this.log=(0,r.kg)("GCC"),d.Z.addEventListener("group_call_update",(e=>{const{currentGroupCall:t}=this;(null==t?void 0:t.id)===e.id&&(t.groupCall=e,"groupCallDiscarded"===e._&&t.hangUp(!1,!1,!0))})),d.Z.addEventListener("group_call_participant",(({groupCallId:e,participant:t})=>{const{currentGroupCall:i}=this;(null==i?void 0:i.id)===e&&i.onParticipantUpdate(t)}))}get groupCall(){return this.currentGroupCall}setCurrentGroupCall(e){this.currentGroupCall=e,e&&this.dispatchEvent("instance",e)}startConnectingSound(){this.stopConnectingSound(),this.audioAsset.playSoundWithTimeout("group_call_connect.mp3",!0,2500)}stopConnectingSound(){this.audioAsset.stopSound(),this.audioAsset.cancelDelayedPlay()}joinGroupCall(e,t,i=!0,s,n){return v(this,void 0,void 0,(function*(){let a;return this.audioAsset.createAudio(),this.log(`joinGroupCall chatId=${e} id=${t} muted=${i} rejoin=${s}`),a=s?this.currentGroupCall.connections.main.streamManager:yield function(e,t){return i=this,s=void 0,a=function*(){const i={audio:(0,p.Z)(),video:t&&(0,m.Z)()},s=new u.Z(h.iK);try{const t=yield(0,f.Z)(i,e);s.addStream(t,"input")}catch(e){console.error("joinGroupCall getStream error",e,i),s.inputStream=new MediaStream}return s},new((n=void 0)||(n=Promise))((function(e,t){function o(e){try{d(a.next(e))}catch(e){t(e)}}function r(e){try{d(a.throw(e))}catch(e){t(e)}}function d(t){var i;t.done?e(t.value):(i=t.value,i instanceof n?i:new n((function(e){e(i)}))).then(o,r)}d((a=a.apply(i,s||[])).next())}));var i,s,n,a}(i,n),this.joinGroupCallInternal(e,t,a,i,s,n).then((()=>{const{currentGroupCall:e}=this;e.participants.then((t=>{this.currentGroupCall===e&&e.state!==c.Z.CLOSED&&t.forEach((t=>{t.pFlags.self||e.onParticipantUpdate(t)}))}))}))}))}joinGroupCallInternal(e,t,i,s,n=!1,a){return v(this,void 0,void 0,(function*(){const o=this.log.bindPrefix("joinGroupCallInternal");o("start",t);const r="main";let{currentGroupCall:h}=this;if(!h||!n){h=new l.Z({chatId:e,id:t,managers:this.managers}),h.fixSafariAudio(),h.addEventListener("state",(e=>{this.currentGroupCall===h&&e===c.Z.CLOSED&&(this.setCurrentGroupCall(null),this.stopConnectingSound(),this.audioAsset.playSound("group_call_end.mp3"),d.Z.dispatchEvent("chat_update",h.chatId))})),h.groupCall=yield this.managers.appGroupCallsManager.getGroupCallFull(t);const u=h.createConnectionInstance({streamManager:i,type:r,options:{type:r,isMuted:s,joinVideo:a,rejoin:n}}),p=u.createPeerConnection();return p.addEventListener("negotiationneeded",(()=>{u.negotiate()})),p.addEventListener("track",(e=>{o("ontrack",e),h.onTrack(e)})),p.addEventListener("iceconnectionstatechange",(()=>{h.dispatchEvent("state",h.state);const{iceConnectionState:e}=p;switch("disconnected"===e||"checking"===e||"new"===e?this.startConnectingSound():this.stopConnectingSound(),e){case"checking":case"completed":case"disconnected":case"new":break;case"closed":case"failed":h.hangUp();break;case"connected":h.joined||(h.joined=!0,this.audioAsset.playSound("group_call_start.mp3"),this.managers.appGroupCallsManager.getGroupCallParticipants(t))}})),u.createDescription(),u.createDataChannel(),u.appendStreamToConference(),this.setCurrentGroupCall(h),o("set currentGroupCall",t,h),this.startConnectingSound(),u.negotiate()}h.handleUpdateGroupCallParticipants=!1,h.updatingSdp=!1,o("update currentGroupCall",t,h)}))}}const C=new S;a.GO&&(a.GO.groupCallController=C);const L=C},9125:(e,t,i)=>{"use strict";function s(){const e={channelCount:2};return["noiseSuppression","echoCancellation","autoGainControl"].forEach((t=>{(function(e){var t;return(!!(null===(t=null===navigator||void 0===navigator?void 0:navigator.mediaDevices)||void 0===t?void 0:t.getSupportedConstraints()))[e]})(t)&&(e[t]=!0)})),e}i.d(t,{Z:()=>s})},9337:(e,t,i)=>{"use strict";function s(e){const t={video:{width:{max:1920},height:{max:1080},frameRate:{max:30}}};return e||(t.audio=!0),t}i.d(t,{Z:()=>s})},382:(e,t,i)=>{"use strict";i.d(t,{Z:()=>s});function s(e){return t=this,i=void 0,n=function*(){const t=yield navigator.mediaDevices.getDisplayMedia(e);return t.getVideoTracks()[0].contentHint="text",t},new((s=void 0)||(s=Promise))((function(e,a){function o(e){try{d(n.next(e))}catch(e){a(e)}}function r(e){try{d(n.throw(e))}catch(e){a(e)}}function d(t){var i;t.done?e(t.value):(i=t.value,i instanceof s?i:new s((function(e){e(i)}))).then(o,r)}d((n=n.apply(t,i||[])).next())}));var t,i,s,n}},5424:(e,t,i)=>{"use strict";i.d(t,{Z:()=>s});function s(e,t){return i=this,s=void 0,a=function*(){const i=yield navigator.mediaDevices.getUserMedia(e);return i.getTracks().forEach((e=>{e.enabled=!t})),i},new((n=void 0)||(n=Promise))((function(e,t){function o(e){try{d(a.next(e))}catch(e){t(e)}}function r(e){try{d(a.throw(e))}catch(e){t(e)}}function d(t){var i;t.done?e(t.value):(i=t.value,i instanceof n?i:new n((function(e){e(i)}))).then(o,r)}d((a=a.apply(i,s||[])).next())}));var i,s,n,a}window.getStream=s},312:(e,t,i)=>{"use strict";function s(){return{width:{min:1280,max:1920},height:{min:720,max:1080},frameRate:{min:24,max:30}}}i.d(t,{Z:()=>s})},3773:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(8957);function n(e,t){const i=t.lookupAttributeKeys({"ice-ufrag":!0,"ice-pwd":!0,fingerprint:!0,setup:!0,ssrc:!0,mid:!0,"ssrc-group":!1});if(!i.fingerprint){const t=e.session.lines.find((e=>{var t;return"fingerprint"===(null===(t=e.parsed)||void 0===t?void 0:t.key)}));i.fingerprint=t.parsed.value}const n=function(e){const t=e.map((e=>{const[t,...i]=e.split(" ");return{_:"groupCallParticipantVideoSourceGroup",semantics:t,sources:i.map((e=>(0,s.Fk)(+e)))}}));return t.length?t:void 0}(i["ssrc-group"]),[a,o]=i.fingerprint.split(" ",2),r=i.ssrc&&(0,s.Fk)(+i.ssrc.split(" ",1)[0]);return{raw:i,ufrag:i["ice-ufrag"],pwd:i["ice-pwd"],fingerprint:{fingerprint:o,setup:i.setup,hash:a},source:r,sourceGroups:n,mid:i.mid}}},49:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(6669);function n(e){e.stop(),(0,s.Z)(e,"ended")}},6752:(e,t,i)=>{"use strict";i.d(t,{Lp:()=>o,ZP:()=>d,z_:()=>r});var s=i(1655),n=i(5953),a=i(4373);class o{constructor(e,t){this.mid=e,this.type=t,this.port=a._D}setDirection(e){return this.originalDirection||(this.originalDirection=e),this.direction=e}setPort(e){return this.port=e}setEndpoint(e){return this.endpoint=e}setPeerId(e){return this.peerId=e}createTransceiver(e,t){return(null==t?void 0:t.direction)&&this.setDirection(t.direction),this.transceiver=e.addTransceiver((0,a.pl)(this.type),t)}setSource(e){let t;if(Array.isArray(e)){if(!e[0])return;t=e,e=t[0].sources[0]}return this.sourceGroups=t,this.source=e}shouldBeSkipped(e){return e&&"inactive"===this.direction}}function r(e,t,i){let s;if(Array.isArray(t)){if(!t[0])return;s=t,t=s[0].sources[0]}return{endpoint:i,type:e,source:t,sourceGroups:s}}class d{constructor(e){this.connection=e,this.sessionId=""+Date.now(),this.maxSeenId=-1,this.entries=[],this.entriesByMid=new Map,this.entriesBySource=new Map,this.entriesByPeerId=new Map}setData(e){return(0,n.Z)(this,e)}createEntry(e){const t=""+ ++this.maxSeenId,i=new o(t,e);return this.entries.push(i),this.entriesByMid.set(t,i),i}deleteEntry(e){(0,s.Z)(this.entries,e),this.entriesByMid.delete(e.mid),this.entriesBySource.delete(e.source);const t=this.entriesByPeerId.get(e.peerId);t&&(t.delete(e),t.size||this.entriesByPeerId.delete(e.peerId))}setEntrySource(e,t){e.setSource(t),this.entriesBySource.set(e.source,e)}setEntryPeerId(e,t){e.setPeerId(t);let i=this.entriesByPeerId.get(t);i||this.entriesByPeerId.set(t,i=new Set),i.add(e)}findEntry(e){return this.entries.find(e)}findFreeSendRecvEntry(e,t){let i=this.entries.find((i=>"sendrecv"===i.direction&&i.type===e&&!(t?i.sendEntry:i.recvEntry)));return i||(i=this.createEntry(e),i.setDirection("sendrecv")),i}getEntryByMid(e){return this.entriesByMid.get(e)}getEntryBySource(e){return this.entriesBySource.get(e)}getEntriesByPeerId(e){return this.entriesByPeerId.get(e)}generateSdp(e){return a.DY.fromConference(Object.assign({conference:this},e))}}},9124:(e,t,i)=>{"use strict";i.d(t,{e6:()=>de,DV:()=>oe});var s,n,a=function(e,t,i,s,n){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?n.call(e,i):n?n.value=i:t.set(e,i),i},o=function(e,t,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(e):s?s.value:t.get(e)};class r{constructor(e,t){s.set(this,void 0),n.set(this,void 0),a(this,s,e,"f"),a(this,n,t,"f")}get session(){return o(this,s,"f")}get media(){return o(this,n,"f")}get bundle(){return this.session.lines.find((e=>{var t;return"group"===(null===(t=e.parsed)||void 0===t?void 0:t.key)})).value.split(" ").slice(1)}toString(){return this.session.lines.concat(...this.media.map((e=>e.lines))).map((e=>e.toString())).join("\r\n")+"\r\n"}}function d(e,t,i){const s=e.split(t),n=[];for(;i>0&&s.length;)n.push(s.shift()),--i;return s.length&&n.push(s.join(t)),n}s=new WeakMap,n=new WeakMap;var l,c,h,u=function(e,t,i,s,n){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?n.call(e,i):n?n.value=i:t.set(e,i),i},p=function(e,t,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(e):s?s.value:t.get(e)};class f{constructor(e,t){l.set(this,void 0),c.set(this,void 0),h.set(this,void 0),u(this,l,new Set,"f"),u(this,c,e,"f"),u(this,h,t,"f")}generate(){const e=p(this,c,"f"),t=p(this,h,"f"),i=p(this,l,"f"),s=t-e+1;let n=Math.floor(e+s*Math.random()),a=0;for(;i.has(n);)if(n<t?++n:n=e,++a>=s)return null;return i.add(n),n}add(e){p(this,l,"f").add(e)}}l=new WeakMap,c=new WeakMap,h=new WeakMap;var m,g,v=function(e,t,i,s,n){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?n.call(e,i):n?n.value=i:t.set(e,i),i},b=function(e,t,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(e):s?s.value:t.get(e)};class y{constructor(e,t){m.set(this,void 0),g.set(this,void 0),v(this,m,e,"f"),v(this,g,t,"f")}get key(){return b(this,m,"f")}get value(){return b(this,g,"f")}}m=new WeakMap,g=new WeakMap;var w,S,C,L,E=function(e,t,i,s,n){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?n.call(e,i):n?n.value=i:t.set(e,i),i},I=function(e,t,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(e):s?s.value:t.get(e)};class P{constructor(e,t,i,s){w.set(this,void 0),S.set(this,void 0),C.set(this,void 0),L.set(this,void 0),E(this,w,e,"f"),E(this,S,t,"f"),E(this,C,i,"f"),E(this,L,s,"f")}get type(){return I(this,w,"f")}get port(){return I(this,S,"f")}get protocol(){return I(this,C,"f")}get ids(){return I(this,L,"f")}toString(){return this.type+" "+this.port+" "+this.protocol+" "+this.ids.join(" ")}}w=new WeakMap,S=new WeakMap,C=new WeakMap,L=new WeakMap;var Z,M,k,T,x=function(e,t,i,s,n){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?n.call(e,i):n?n.value=i:t.set(e,i),i},A=function(e,t,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(e):s?s.value:t.get(e)};class _{constructor(e,t){if(Z.set(this,void 0),M.set(this,void 0),k.set(this,void 0),T.set(this,void 0),x(this,Z,e,"f"),"string"==typeof t){if(x(this,M,t,"f"),"m"===e){const e=t.split(" ");x(this,k,new P(e[0],e[1],e[2],e.slice(3)),"f")}else if("a"===e){const e=d(t,":",1);t=e[0],x(this,T,1===e.length?new y(t,null):new y(t,e[1]),"f")}}else t instanceof P?(x(this,k,t,"f"),x(this,M,t.toString(),"f")):t instanceof y&&(x(this,T,t,"f"),x(this,M,t.value?`${t.key}:${t.value}`:t.key,"f"))}get key(){return A(this,Z,"f")}get value(){return A(this,M,"f")}get parsed(){return A(this,T,"f")}get mediaLineParts(){return A(this,k,"f")}toString(){return`${this.key}=${this.value}`}}Z=new WeakMap,M=new WeakMap,k=new WeakMap,T=new WeakMap;var F,D,R,B,N,O,U=function(e,t,i,s,n){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?n.call(e,i):n?n.value=i:t.set(e,i),i},H=function(e,t,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(e):s?s.value:t.get(e)};class z{constructor(e,t,i=":",s=!1){F.set(this,void 0),D.set(this,void 0),R.set(this,void 0),B.set(this,void 0),N.set(this,void 0),O.set(this,void 0),U(this,F,e,"f"),U(this,D,t,"f"),U(this,R,i,"f"),U(this,N,s,"f"),U(this,B,s?new Map:null,"f"),U(this,O,s?[]:null,"f")}get lines(){return H(this,D,"f")}get value(){return H(this,N,"f")||!this.lines.length?null:this.lines[0]}get exists(){return!H(this,N,"f")}get key(){return H(this,F,"f")}get keys(){return z.fill(this),H(this,O,"f")}forEach(e){z.fill(this),H(this,B,"f").forEach(e)}get(e){return z.fill(this),H(this,B,"f").get(e)||new z(e,[],":",!0)}static fill(e){if(null!==H(e,B,"f"))return;const t=new Map;e.lines.forEach((i=>{const[s,n]=d(i,H(e,R,"f"),1),a=t.get(s)||[];t.set(s,[...a,n||""])}));const i=U(e,B,z.makeAttributes(t),"f");U(e,O,Array.from(i.keys()),"f")}static makeAttributes(e){const t=new Map;return e.forEach(((e,i)=>{t.set(i,new z(i,e))})),t}}F=new WeakMap,D=new WeakMap,R=new WeakMap,B=new WeakMap,N=new WeakMap,O=new WeakMap;var j,G,V=function(e,t,i,s,n){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?n.call(e,i):n?n.value=i:t.set(e,i),i},K=function(e,t,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(e):s?s.value:t.get(e)};class W{constructor(e){j.set(this,void 0),G.set(this,void 0),V(this,j,e,"f"),V(this,G,new Map,"f"),W.fillAttributes(this)}get(e){return K(this,G,"f").get(e)||new z(e,[]," ",!0)}static fillAttributes(e){const t=new Map;K(e,j,"f").forEach((e=>{if("a"===e.key){const{key:i,value:s}=e.parsed;let n=t.get(i);n||(n=[],t.set(i,n)),n.push(s||"")}})),t.forEach(((t,i)=>{K(e,G,"f").set(i,new z(i,t," ",!1))}))}}j=new WeakMap,G=new WeakMap;var $,q,Y,Q,X=function(e,t,i,s,n){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?n.call(e,i):n?n.value=i:t.set(e,i),i},J=function(e,t,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(e):s?s.value:t.get(e)};class ee{constructor(e){$.set(this,void 0),q.set(this,void 0),Y.set(this,void 0),Q.set(this,void 0),X(this,$,e,"f"),X(this,q,e[0],"f"),X(this,Y,X(this,Q,null,"f"),"f")}get lines(){return J(this,$,"f")}get mediaLine(){return J(this,q,"f")}get mediaLineParts(){return J(this,q,"f").mediaLineParts}get mediaType(){return this.mediaLineParts.type}get direction(){if(!J(this,Q,"f")){const e=this.attributes;let t;t=e.get("sendonly").exists?"sendonly":e.get("recvonly").exists?"recvonly":e.get("inactive").exists?"inactive":"sendrecv",X(this,Q,t,"f")}return J(this,Q,"f")}get isSending(){return"sendrecv"===this.direction||"sendonly"===this.direction}get isReceiving(){return"sendrecv"===this.direction||"recvonly"===this.direction}get attributes(){return J(this,Y,"f")||X(this,Y,new W(this.lines),"f"),J(this,Y,"f")}get mid(){return this.attributes.get("mid").value}lookupAttributeKeys(e){const t={};for(const i in e){const s=this.attributes.get(i),n=!e[i];t[i]=s?n?s.lines:s.value:n?[]:void 0}return t}}$=new WeakMap,q=new WeakMap,Y=new WeakMap,Q=new WeakMap;var te,ie,se=function(e,t,i,s,n){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?n.call(e,i):n?n.value=i:t.set(e,i),i},ne=function(e,t,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(e):s?s.value:t.get(e)};class ae{constructor(e){te.set(this,void 0),ie.set(this,void 0),se(this,te,e,"f"),se(this,ie,e.filter((e=>"o"===e.key)).map((e=>e.value.split(" ")[1]))[0],"f")}get lines(){return ne(this,te,"f")}get sessionId(){return ne(this,ie,"f")}}function oe(e){function t(){i?n.push(new ee(s)):i=new ae(s)}let i=null,s=[];const n=[];return e.split(/\r?\n/).forEach((e=>{if(!function(e){return/^[\s\xa0]*$/.test(e)}(e)){const i=re(e);"m"===i.key&&(t(),s=[]),s.push(i)}})),t(),new r(i,n)}function re(e){const t=d(e,"=",1);return new _(t[0],t[1])}function de(e){let t;return e.media.forEach(((i,s)=>{if("video"===i.mediaType&&i.isSending&&!i.attributes.get("ssrc-group").get("SIM").exists){t||(t=new f(2,4294967295));const n=i.attributes.get("ssrc-group").get("FID").value.split(" "),a=i.lines;n.forEach((e=>t.add(+e)));const o=[n[0],t.generate(),t.generate()],r=[n[1],t.generate(),t.generate()];a.push(re("a=ssrc-group:SIM "+o.join(" ")));const d=i.attributes.get("ssrc").get(n[0]).lines;o.forEach(((e,t)=>{const i=r[t];t>0&&(a.push(re("a=ssrc-group:FID "+e+" "+i)),d.forEach((t=>{a.push(re("a=ssrc:"+e+" "+t))})),d.forEach((e=>{a.push(re("a=ssrc:"+i+" "+e))})))})),e.media[s]=new ee(a)}})),!!t}te=new WeakMap,ie=new WeakMap},4373:(e,t,i)=>{"use strict";i.d(t,{DY:()=>c,Px:()=>l,_D:()=>o,pl:()=>r});var s=i(4762),n=i(630),a=i(8957);const o="9";function r(e){return"screencast"===e?"video":e}function d(e){return"application"===e?"DTLS/SCTP":"UDP/TLS/RTP/SAVPF"}function l(e,t=o,i){const s=d(e);return`m=${r(e)} ${t} ${s} ${i.join(" ")}`}class c extends n.Z{addCandidate(e){return this.add(function(e){const t=[];return t.push("a=candidate:"),t.push(`${e.foundation} ${e.component} ${e.protocol.toUpperCase()} ${e.priority} ${e.ip} ${e.port} typ ${e.type}`),void 0!==e["rel-addr"]&&t.push(` raddr ${e["rel-addr"]} rport ${e["rel-port"]}`),t.push(` generation ${e.generation}`),t.join("")}(e))}addHeader(e,t){const i=t.join(" ");return this.add("v=0",`o=- ${e} 2 IN IP4 0.0.0.0`,"s=-","t=0 0","a=extmap-allow-mixed",`a=group:BUNDLE ${i}`,"a=ice-options:trickle","a=msid-semantic:WMS *")}addTransport(e,t){this.add(`a=ice-ufrag:${e.ufrag}`,`a=ice-pwd:${e.pwd}`,"a=ice-options:trickle");for(const t of e.fingerprints)this.add(`a=fingerprint:${t.hash} ${t.fingerprint}`,`a=setup:${t.setup}`);if(!t&&e.candidates)for(const t of e.candidates)this.addCandidate(t);return this}addSsrc(e){let t="stream",{type:i,sourceGroups:s}=e;const n=(0,a.h)(e.source);t+=n,i+=n;const o=e=>{this.add(`a=ssrc:${e} cname:${t}`,`a=ssrc:${e} msid:${t} ${i}`,`a=ssrc:${e} mslabel:${t}`,`a=ssrc:${e} label:${i}`)};return(()=>{this.add(`a=msid:${t} ${i}`)})(),(null==s?void 0:s.length)?s.forEach((e=>{if(e.sources.length){const t=e.sources.map(a.h);this.add(`a=ssrc-group:${e.semantics} ${t.join(" ")}`),t.forEach(o)}})):o(n),this}addSsrcEntry(e,t,i){const s=(...e)=>this.add(...e),{type:n,mid:a,direction:o,port:c}=e,h=t.transport,u="application"===n,p=u?void 0:t[n],f="inactive"===o;if(e.shouldBeSkipped(i))return s(`m=${r(n)} 0 ${d(n)} 0`,"c=IN IP4 0.0.0.0","a=inactive",`a=mid:${a}`);const m=u?[{id:5e3}]:p["payload-types"],g=m.map((e=>e.id));s(l(n,c,g),"c=IN IP4 0.0.0.0",`a=rtcp:${c} IN IP4 0.0.0.0`),h["rtcp-mux"]&&s("a=rtcp-mux"),s(`a=mid:${a}`);let v=o;if("sendrecv"===o||!i||f||u||(v="sendonly"===o?"recvonly":"sendonly"),s(`a=${v}`),this.addTransport(h),u)s(`a=sctpmap:${m[0].id} webrtc-datachannel 256`);else{const e=p["rtp-hdrexts"];(null==e?void 0:e.length)&&e.forEach((e=>{s(`a=extmap:${e.id} ${e.uri}`)})),m.forEach((e=>{s(`a=rtpmap:${e.id} ${e.name}/${e.clockrate}${e.channels&&e.channels>1?`/${e.channels}`:""}`);const t=e.parameters;if(Array.isArray(t))t.length&&console.error("parameters is array???",t);else if(t&&Object.keys(t).length){const i=[];for(const e in t)i.push(`${e}=${t[e]}`);s(`a=fmtp:${e.id} ${i.join(";")}`)}const i=e["rtcp-fbs"];(null==i?void 0:i.length)&&i.forEach((t=>{s(`a=rtcp-fb:${e.id} ${t.type}${t.subtype?" "+t.subtype:""}`)}))}))}return!e.source||"sendonly"!==v&&"sendrecv"!==v||this.addSsrc(e),this}addConference(e){const{conference:t,entries:i,bundle:n,isAnswer:a}=e;this.addHeader(t.sessionId,n),s.IS_FIREFOX&&this.addTransport(t.transport);for(const e of i)this.addSsrcEntry((a?e.recvEntry||e.sendEntry:e.sendEntry||e.recvEntry)||e,t,a);return this}static fromConference(e){return(new c).addConference(e).finalize()}}},9585:(e,t,i)=>{"use strict";i.d(t,{Z:()=>c});var s=i(3241),n=i(5003),a=i(1677),o=i(49),r=i(4373),d=i(8957);class l{constructor(e,t){const i=this.streamSource=e.createMediaStreamSource(t),s=this.analyser=e.createAnalyser();this.gain=e.createGain(),s.minDecibels=-100,s.maxDecibels=-30,s.smoothingTimeConstant=.05,s.fftSize=1024,i.connect(s)}}class c{constructor(e){this.interval=e,this.getAmplitude=e=>{const{streamAnalyser:t,stream:i,track:s,source:n,type:a}=e,o=t.analyser;if(!o)return;const r=new Uint8Array(o.frequencyBinCount);return o.getByteFrequencyData(r),{type:a,source:n,stream:i,track:s,value:(0,d.UN)(r)}},this.analyse=()=>{const e=this.counter%3==0,t=(e?this.items:this.items.filter((e=>"input"===e.type))).filter((e=>"audio"===e.kind)).slice(0,a.KM).map(this.getAmplitude);++this.counter>=1e3&&(this.counter=0),c.ANALYSER_LISTENER.dispatchEvent("amplitude",{amplitudes:t,type:e?"all":"input"})},this.context=new(window.AudioContext||window.webkitAudioContext),this.items=[],this.outputStream=new MediaStream,this.inputStream=new MediaStream,this.counter=0,this.log=(0,n.kg)("SM"),this.direction="sendonly",this.canCreateConferenceEntry=!0,this.types=["audio","video"]}addStream(e,t){e.getTracks().forEach((i=>{this.addTrack(e,i,t)}))}addTrack(e,t,i){this.log("addTrack",i,t,e);const{context:s,items:n,inputStream:a,outputStream:o}=this,r=t.kind,d=c.getSource(e,i);switch(i){case"input":a?a.addTrack(t):this.inputStream=e;break;case"output":for(let e=0;e<n.length;++e){const{track:t,type:i,source:s}=n[e];if(s===d&&"input"===i){n.splice(e,1),o.removeTrack(t);break}}"video"!==r&&o.addTrack(t)}this.finalizeAddingTrack({type:i,source:d,stream:e,track:t,kind:r,streamAnalyser:"audio"===r?new l(s,e):void 0}),"audio"===r&&this.interval&&this.changeTimer()}finalizeAddingTrack(e){const{track:t}=e;t.addEventListener("ended",(()=>{this.removeTrack(t)}),{once:!0}),this.items.push(e)}hasInputTrackKind(e){return this.items.find((t=>"input"===t.type&&t.kind===e))}static getSource(e,t){return"input"===t?e.source||e.id:""+(0,d.Fk)(+e.id.substring(6))}removeTrack(e){this.log("removeTrack",e);const{items:t}=this;let i=!1;for(let s=0,n=t.length;!i&&s<n;++s){const{track:n,type:a}=t[s];switch(a){case"output":n===e&&(t.splice(s,1),this.outputStream.removeTrack(e),i=!0);break;case"input":n===e&&(t.splice(s,1),this.inputStream.removeTrack(e),i=!0)}}"audio"===e.kind&&this.interval&&this.changeTimer()}replaceInputAudio(e,t){this.removeTrack(t),this.addStream(e,"input")}changeTimer(){void 0!==this.timer&&clearInterval(this.timer),this.items.length&&(this.timer=window.setInterval(this.analyse,this.interval))}appendToConference(e){if(this.locked)return;const{inputStream:t,direction:i,canCreateConferenceEntry:s}=this,n={direction:i,streams:[t]},a=this.types.map((e=>[e,n])),o=t.getTracks();for(const[t,n]of a){let a=e.findEntry((e=>e.direction===i&&e.type===t));if(!a){if(!s)continue;a=e.createEntry(t)}let{transceiver:d}=a;d||(d=a.createTransceiver(e.connection,n)),a.direction!==d.direction&&(d.direction=a.direction);const l=(0,r.pl)(t),c=o.findIndex((e=>e.kind===l)),h=-1!==c?o.splice(c,1)[0]:void 0,u=d.sender;u.track!==h&&u.replaceTrack(h).catch((e=>{this.log.error(e)}))}}stop(){try{this.inputStream.getTracks().concat(this.outputStream.getTracks()).forEach((e=>{(0,o.Z)(e)}))}catch(e){this.log.error(e)}}}c.ANALYSER_LISTENER=new s.Z},630:(e,t,i)=>{"use strict";i.d(t,{Z:()=>s});class s{constructor(e="\r\n"){this.joiner=e,this.lines=[],this.newLine=[]}add(...e){return this.lines.push(...e),this}push(e){return this.newLine.push(e),this}addJoined(e=""){return this.add(this.newLine.join(e)),this.newLine=[],this}join(){return this.lines.join(this.joiner)}finalize(){return this.join()+this.joiner}}},8957:(e,t,i)=>{"use strict";function s(e){return e<<0}function n(e){return e>>>0}function a(e,t=3){if(!e)return 0;const{length:i}=e;let s=0;for(let t=0;t<i;++t)s+=e[t]*e[t];const n=Math.sqrt(s/i)/255;return Math.min(1,n*t)}i.d(t,{Fk:()=>s,UN:()=>a,h:()=>n})},586:(e,t,i)=>{"use strict";i.d(t,{_:()=>s});const s=2147483646},3785:(e,t,i)=>{"use strict";i.d(t,{Z:()=>o});var s=i(7197),n=i(1229);const a=new RegExp(`(^${n.Z})`);function o(e,t=!1){const i=(e||"").trim().split(" ");if(!i[0])return{text:"",entities:[]};const n=[],o=i[0].match(a),r=(null==o?void 0:o[0])||i[0][0];o&&n.push((0,s.Z)(r));const d=i.length;if(t||1===d)return{text:r,entities:n};const l=i[d-1].match(a),c=(null==l?void 0:l[0])||i[d-1][0];return l&&n.push(Object.assign(Object.assign({},(0,s.Z)(c)),{offset:r.length})),{text:r+c,entities:n}}},7197:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(671);function n(e){return{_:"messageEntityEmoji",offset:0,length:e.length,unicode:(0,s.w1)(e).join("-").replace(/-?fe0f/g,"")}}},1171:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(2423);function n(e){return e?e.match(s.E):null}},2521:(e,t,i)=>{"use strict";function s(e){return e.target="_blank",e.rel="noopener noreferrer",e}i.d(t,{Z:()=>s})},5798:(e,t,i)=>{"use strict";i.d(t,{Z:()=>a});var s=i(8115),n=i(3785);function a(e,t){const{text:i,entities:a}=(0,n.Z)(e,t);return(0,s.Z)(i,void 0,a)}},3066:(e,t,i)=>{"use strict";i.d(t,{Z:()=>a});var s=i(3512),n=i(5400);function a(e,t={}){if(!e)return(0,n.ZP)("");let i=t.entities;return i&&!s.Z.premium&&t.wrappingForPeerId!==s.Z.myId&&(i=i.filter((e=>"messageEntityCustomEmoji"!==e._))),(0,n.ZP)(e,Object.assign(Object.assign({},t),{entities:i,noLinks:!0,wrappingDraft:!0,passEntities:{messageEntityTextUrl:!0,messageEntityMentionName:!0}}))}},8115:(e,t,i)=>{"use strict";i.d(t,{Z:()=>a});var s=i(6535),n=i(5400);function a(e,t=!1,i){return e?(null!=i||(i=(0,s.Z)(e).filter((e=>"messageEntityEmoji"===e._))),(0,n.ZP)(e,{entities:i,wrappingDraft:t})):(0,n.ZP)("")}},5400:(e,t,i)=>{"use strict";i.d(t,{LD:()=>F,KZ:()=>D,SZ:()=>V,ZP:()=>G,Cx:()=>W,Hc:()=>K});var s=i(2423),n=i(3447),a=i(9976),o=i(8479),r=i(4056),d=i(1379),l=i(6535),c=i(2521),h=i(3591);const u={};a.Z&&(u[""]=!0,[["14","🫱🏻"]].forEach((([e,t])=>{u[e]=function(e){const t=document.createElement("span");t.classList.add("emoji"),document.body.appendChild(t),t.innerText=e;const i=t.offsetWidth;t.innerText="❤️";const s=t.offsetWidth;return document.body.removeChild(t),Math.abs(i-s)<5}(t)})));const p=u;var f=i(2738),m=i(3512),g=i(4755),v=i(3541),b=i(3772),y=i(5814),w=i(2153),S=i(393),C=i(8938),L=i(319),E=i(8497),I=i(4881),P=i(3624),Z=i(5565),M=i(6854),k=i(645),T=i(4497),x=i(4762);const A=new ResizeObserver((e=>{for(const t of e)t.target.parentElement.setDimensionsFromRect(t.contentRect)})),_=new w.Z;class F extends HTMLElement{constructor(){super(),this.paused=!0,this.classList.add("custom-emoji")}get docId(){return this.dataset.docId}static create(e){const t=new F;return t.dataset.docId=""+e,t}get isConnected(){var e,t;return null!==(t=null===(e=this.placeholder)||void 0===e?void 0:e.isConnected)&&void 0!==t?t:super.isConnected}connectedCallback(){this.player&&y.Z.addAnimation({animation:this,group:this.renderer.animationGroup,controlled:!0})}disconnectedCallback(){var e;!this.isConnected&&(null===(e=this.renderer)||void 0===e?void 0:e.isSelectable)&&this.clear()}destroy(){this.clear()}clear(e=!0){var t;if(this.clean)return;this.clean=!0,this.pause();const{syncedPlayer:i}=this;if(i&&i.pausedElements.delete(this),null===(t=this.middlewareHelper)||void 0===t||t.clean(),this.renderer){const t=this.renderer.customEmojis.get(this.docId);(null==t?void 0:t.delete(this))&&!t.size&&(this.renderer.customEmojis.delete(this.docId),this.renderer.playersSynced.delete(t)),e&&(this.renderer.isSelectable?this.replaceChildren(V(!0)):this.replaceChildren())}this.player&&y.Z.removeAnimationByPlayer(this),_&&_.delete({div:this}),this.elements=this.renderer=this.player=this.syncedPlayer=void 0}pause(){this.paused||(this.paused=!0,this.player instanceof HTMLVideoElement&&!this.syncedPlayer&&(this.renderer.lastPausedVideo=this.player,this.player.pause()),this.syncedPlayer&&!this.syncedPlayer.pausedElements.has(this)&&(this.syncedPlayer.pausedElements.add(this),this.syncedPlayer.player&&this.syncedPlayer.pausedElements.size===this.syncedPlayer.middlewares.size&&this.syncedPlayer.player.pause()))}play(){var e,t;this.paused&&(this.paused=!1,this.player instanceof HTMLVideoElement&&(this.player.currentTime=null!==(t=null===(e=this.renderer.lastPausedVideo)||void 0===e?void 0:e.currentTime)&&void 0!==t?t:this.player.currentTime,this.player.play().catch(L.Z)),this.syncedPlayer&&this.syncedPlayer.pausedElements.has(this)&&(this.syncedPlayer.pausedElements.delete(this),this.syncedPlayer.pausedElements.size!==this.syncedPlayer.middlewares.size&&this.player.play()))}remove(){this.clear()}get autoplay(){return!0}get loop(){return!0}}class D extends HTMLElement{constructor(){super(),this.classList.add("custom-emoji-renderer"),this.canvas=document.createElement("canvas"),this.canvas.classList.add("custom-emoji-canvas"),this.context=this.canvas.getContext("2d"),this.append(this.canvas),this.playersSynced=new Map,this.clearedElements=new WeakSet,this.customEmojis=new Map,this.animationGroup="EMOJI",this.isCanvasClean=!1}connectedCallback(){N.has(this)||(A.observe(this.canvas),N.add(this),this.connectedCallback=void 0)}disconnectedCallback(){var e;!this.isConnected&&this.auto&&(null===(e=this.destroy)||void 0===e||e.call(this),this.disconnectedCallback=void 0)}destroy(){var e;A.unobserve(this.canvas),this.customEmojis.forEach((e=>{e.forEach((e=>{e.clear()}))})),N.delete(this),this.playersSynced.clear(),null===(e=this.middlewareHelper)||void 0===e||e.clean(),this.customEmojis.clear(),this.destroy=this.lastPausedVideo=void 0}getOffsets(e=new Map){if(!this.playersSynced.size)return e;const t=(0,E.Z)(this,"scrollable")||this.offsetParent;if(!t)return e;const i=t.getBoundingClientRect(),s=this.getBoundingClientRect();for(const n of this.playersSynced.keys()){const a=Array.from(n),o=this.isSelectable?a.map((e=>e.placeholder)):a,{visible:r}=(0,I.Z)({overflowElement:t,overflowRect:i,elements:o,extraSize:2.5*this.size.height}),d=r.map((({rect:e})=>({top:e.top-s.top,left:e.left-s.left,width:e.width})));d.length&&e.set(n,d)}return e}clearCanvas(){if(this.isCanvasClean)return;const{context:e,canvas:t}=this;e.clearRect(0,0,t.width,t.height),this.isCanvasClean=!0}render(e){const{context:t,canvas:i,isDimensionsSet:s}=this;s||this.setDimensionsFromRect(void 0,!1),this.isCanvasClean=!1;const{width:n,height:a,dpr:o}=i;for(const[i,s]of e){const e=this.playersSynced.get(i),a=U.get(e)||(e instanceof HTMLVideoElement?e:void 0);if(!a)continue;const r=a instanceof ImageData;let d,l;e instanceof HTMLVideoElement?(d=this.size.width*o,l=this.size.height*o):(d=a.width,l=a.height);const c=Math.round(s[0].width*o);c!==d&&(d=c,l=c);const h=n-d;this.clearedElements.has(i)||this.isSelectable||(this.isSelectable?i.forEach((e=>{var t;null!==(t=e.lastChildWas)&&void 0!==t||(e.lastChildWas=e.lastChild),(0,Z.Z)(e,e.firstChild)})):i.forEach((e=>{e.replaceChildren()})),this.clearedElements.add(i)),s.forEach((({top:e,left:i})=>{e=Math.round(e*o),(i=Math.round(i*o))<0||i>h||(r?t.putImageData(a,i,e):t.drawImage(a,i,e,d,l))}))}}checkForAnyFrame(){for(const e of this.playersSynced.values())if(U.has(e)||e instanceof HTMLVideoElement)return!0;return!1}remove(){super.remove()}setDimensionsFromRect(e=this.lastRect,t=!0){const{canvas:i}=this,{dpr:s}=i;if(this.lastRect!==e&&(this.lastRect=e),!e||!s||this.ignoreSettingDimensions)return;const{width:n,height:a}=e,o=Math.floor(Math.round(n*s)),r=Math.floor(Math.round(a*s));i.width===o&&i.height===r||(i.width=o,i.height=r,this.isDimensionsSet=!0,this.isCanvasClean=!0,(this.forceRenderAfterSize||this.isSelectable&&t)&&(this.forceRenderAfterSize=void 0,this.forceRender()))}forceRender(){this.isDimensionsSet&&(H(new Set([this]))||this.clearCanvas())}add(e,t,i,s){const n=this;if(e.forEach(((t,i)=>{let s=this.customEmojis.get(i);s?this.clearedElements.delete(s):this.customEmojis.set(i,s=new Set);for(const e of t)s.has(e)?t.delete(e):(e.clean=!1,e.renderer=n,e.elements=s,e.middlewareHelper=this.middlewareHelper.get().create(),s.add(e),e.lastChildWas&&!e.lastChildWas.parentNode&&e.append(e.lastChildWas));t.size||e.delete(i)})),!e.size)return;const a=!(t||!1===t||!_),o=Array.from(e.keys()),r=m.Z.managers,d=this.middlewareHelper.get(),l=this.size;return r.appEmojiManager.getCachedCustomEmojiDocuments(o).then((c=>{if(d&&!d())return;const h=[],u=(o,c)=>{const h=o.id,u=e.get(h),p=n.customEmojis.get(h),f=2===o.sticker,m="video/webm"===o.mime_type&&!S.Z,g=(f||3===o.sticker&&this.isSelectable)&&!i&&!m,w=[],E=Array.from(u),I=(0,v.ZP)({div:E,doc:o,width:l.width,height:l.height,loop:!0,play:R,managers:r,isCustomEmoji:!0,group:"none",loadPromises:w,middleware:d,exportLoad:a||!1===t?2:1,needFadeIn:!1,loadStickerMiddleware:g&&d?d.create().get((()=>!!Z.middlewares.size)):void 0,static:m,onlyThumb:i,withThumb:null!=s?s:!n.clearedElements.has(p)&&void 0,syncedVideo:this.isSelectable});c&&I.then((()=>c.push(...w)));const P={elements:u};if(1===o.sticker||i||m)return this.isSelectable&&(P.onRender=()=>Promise.all(w).then((()=>{d&&!d()||E.forEach((e=>{const{placeholder:t}=e;t.src=e.firstElementChild.src}))}))),I.then((e=>Object.assign(Object.assign({},e),P)));let Z;P.onRender=e=>Promise.all(w).then((()=>{var t;if(d&&!d()||!o.animated)return;const i=Array.isArray(e)?e:[e],s=Array.isArray(i)?i[0]:i;if((0,C.Z)(s),E.forEach(((e,t)=>{const s=i[t]||i[0];e.player=s,Z&&(e.syncedPlayer=Z,e.paused?e.syncedPlayer.pausedElements.add(e):s.paused&&s.play()),e.isConnected&&y.Z.addAnimation({animation:e,group:e.renderer.animationGroup,controlled:!0})})),(s instanceof b.Z||s instanceof HTMLVideoElement&&this.isSelectable)&&(Z.player=s,n.playersSynced.set(p,s)),s instanceof b.Z?(s.group=n.animationGroup,null!==(t=s.overrideRender)&&void 0!==t||(s.overrideRender=e=>{U.set(s,e)})):HTMLVideoElement,g){const e=(0,b.a)(this.size.width,this.size.height);n.canvas.dpr=e,z()}}));const M=[h,l.width,l.height].join("-");if(g){Z=O.get(M),Z||(Z={player:void 0,middlewares:new Set,pausedElements:new Set,key:M},O.set(M,Z));for(const e of u){const t=e.middlewareHelper.get();Z.middlewares.add(t),t.onClean((()=>{var i,s;if(Z.middlewares.delete(t),!Z.middlewares.size){if(Z.player){const t=U.get(Z.player);if(t&&(null===(s=(i=t).close)||void 0===s||s.call(i),U.delete(Z.player)),U.delete(Z.player),Z.player instanceof b.Z)Z.player.overrideRender=L.Z,Z.player.remove();else if(Z.player instanceof HTMLVideoElement){const t=k.Z.generateName(""+e.docId,0,0,void 0,void 0);delete v._i[t]}Z.player=void 0}O.get(Z.key)===Z&&O.delete(Z.key)&&!O.size&&j()}}))}}return I.then((e=>Object.assign(Object.assign({},e),P)))},p=[],f=c.map(((e,t)=>{if(e)return u(e,h);p.push(o[t])})).filter(Boolean),m=p.length?r.appEmojiManager.getCustomEmojiDocuments(p).then((e=>d&&!d()?[]:e.filter(Boolean).map((e=>u(e))))):Promise.resolve([]),g=e=>Promise.all(e).then((e=>{const t=e.map((({load:e,onRender:t,elements:i})=>{if(!e)return;const s=()=>e().then(t);if(!a)return s();i.forEach((e=>{_.push({div:e,load:()=>(i.forEach((e=>{_.delete({div:e})})),s())})}))}));return Promise.all(t)})),w=()=>{if(d&&!d())return;const e=g(f),t=m.then((e=>g(e)));return Promise.all([e,t])};return t?t.push({div:n.canvas,load:w}):w(),Promise.all(f).then((()=>Promise.all(h))).then((()=>{}))}))}static create(e){const t=new D;t.animationGroup=e.animationGroup,t.size=e.customEmojiSize||g.Z.active.customEmoji,t.isSelectable=e.isSelectable,e.wrappingDraft&&(t.contentEditable="false",t.style.height="inherit");let i=e.middleware;return i?(t.middlewareHelper=i.create(),i=t.middlewareHelper.get(),i.onDestroy((()=>{var e;null===(e=t.destroy)||void 0===e||e.call(t)}))):(t.auto=!0,t.middlewareHelper=(0,P.k)()),t}}const R=!0;let B;const N=new Set,O=new Map,U=new Map,H=(e=N)=>{const t=Array.from(e).filter((e=>e.isConnected&&e.checkForAnyFrame()&&!e.ignoreSettingDimensions));if(!t.length)return!1;const i=t.map((e=>{const t=[...e.playersSynced.values()].reduce(((e,t)=>e+ +!!t.paused),0);if(e.playersSynced.size===t)return;const i=e.getOffsets();return i.size?[e,i]:void 0})).filter(Boolean);for(const[e]of i)e.clearCanvas();for(const[e,t]of i)e.render(t);return!0},z=()=>{B||(B=window.setInterval(H,16.666666666666668),H())},j=()=>{B&&(clearInterval(B),B=void 0)};function G(e,t={}){var i,u,m,g,v,b,y,w;const S=document.createDocumentFragment();if(!e)return S;const C=null!==(i=t.nasty)&&void 0!==i?i:t.nasty={i:0,usedLength:0,text:e},L=(e,i)=>{const s=document.createElement("span");return t.wrappingDraft&&(s.contentEditable="false"),s.classList.add("input-something"),s.append(e),(R||S).append(s),e.classList.add("input-selectable"),!i&&e.append(V(!0)),I.add(s),s};t.isSelectable||(t.isSelectable=t.wrappingDraft);const E=null!==(u=t.customEmojis)&&void 0!==u?u:t.customEmojis=new Map,I=null!==(m=t.customWraps)&&void 0!==m?m:t.customWraps=new Set,P=null!==(g=t.entities)&&void 0!==g?g:t.entities=(0,l.Z)(C.text),Z=null!==(v=t.passEntities)&&void 0!==v?v:t.passEntities={},M=null!==(b=t.contextSite)&&void 0!==b?b:t.contextSite="Telegram",k="Telegram"!==M,A=C.text.length,_=P.length;let R;for(;C.i<_;++C.i){let e=P[C.i];if(e.offset>=A){if("messageEntityCaret"!==e._)continue}else e.offset+e.length>A&&(e=(0,o.Z)(e),e.length=A-e.offset);e.length&&(C.lastEntity=e);let i=P[C.i+1];const l=e.offset,u=l+e.length,m=Math.min(u,null!==(y=null==i?void 0:i.offset)&&void 0!==y?y:65535),g=C.text.slice(l,u);let v=C.text.slice(l,m);C.usedLength<l&&(R||S).append(C.text.slice(C.usedLength,l)),R&&(R=S),C.usedLength=m;let b,w="textContent",I=!1;switch(e._){case"messageEntityBold":t.noTextFormat||(t.wrappingDraft?(b=document.createElement("span"),b.style.fontFamily="markup-bold"):b=document.createElement("strong"));break;case"messageEntityItalic":t.noTextFormat||(t.wrappingDraft?(b=document.createElement("span"),b.style.fontFamily="markup-italic"):b=document.createElement("em"));break;case"messageEntityStrike":t.wrappingDraft?(b=document.createElement("span"),b.style.fontFamily="markup-strikethrough"):b=document.createElement("del");break;case"messageEntityUnderline":t.wrappingDraft?(b=document.createElement("span"),b.style.fontFamily="markup-underline"):t.noTextFormat||(b=document.createElement("u"));break;case"messageEntityPre":case"messageEntityCode":t.wrappingDraft?(b=document.createElement("span"),b.style.fontFamily="markup-monospace"):t.noTextFormat||(b=document.createElement("code"));break;case"messageEntityHighlight":b=document.createElement("i"),b.className="text-highlight";break;case"messageEntityBotCommand":if(!t.noLinks&&Z[e._]){let e,i,s=g.slice(1);-1!==(i=s.indexOf("@"))?(e=s.slice(i+1),s=s.slice(0,i)):e=t.fromBot,b=document.createElement("a"),b.href=(0,r.Z)("tg://bot_command?command="+encodeURIComponent(s)+(e?"&bot="+encodeURIComponent(e):"")),k||b.setAttribute("onclick","execBotCommand(this)")}break;case"messageEntityCustomEmoji":{for(;"messageEntityEmoji"===(null==i?void 0:i._)&&i.offset<u;)++C.i,C.lastEntity=i,C.usedLength+=i.length,i=P[C.i+1];const s=b=F.create(e.document_id),{docId:n}=s;let a=E.get(n);if(a||E.set(n,a=new Set),a.add(s),s.dataset.stickerEmoji=g,t.wrappingDraft){b=document.createElement("img"),b.alt=g;for(const e in s.dataset)b.dataset[e]=s.dataset[e];b.customEmojiElement=s,s.placeholder=b,b.classList.add("custom-emoji-placeholder"),b.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAAtJREFUGFdjYAACAAAFAAGq1chRAAAAAElFTkSuQmCC",w="alt";break}t.isSelectable&&(b=L(b,!!t.customEmojiRenderer)),w="alt";break}case"messageEntityEmoji":{let i=a.Z;if(i)for(const t in n.i)if(t&&n.i[t].hasOwnProperty(e.unicode)&&!p[t]){i=!1;break}i?t.wrappingDraft||(b=document.createElement("span"),b.className="emoji"):(b=document.createElement("img"),b.src=`assets/img/emoji/${e.unicode}.png`,w="alt",b.className="emoji");break}case"messageEntityCaret":b=document.createElement("span"),b.className="composer-sel";break;case"messageEntityLinebreak":t.wrappingDraft&&x.IS_FIREFOX&&(b=document.createElement("br"));break;case"messageEntityUrl":case"messageEntityTextUrl":if(!t.noLinks||Z[e._]){let s,n=e.url||g,a=!1;const o=(0,h.Z)(n,!0);n=o.url,s=o.onclick,"messageEntityTextUrl"===e._&&("messageEntityUrl"===(null==i?void 0:i._)&&i.length===e.length&&i.offset===e.offset&&(C.lastEntity=i,++C.i),n!==g&&(a=!0));const r=!!s;s||!a||r||(s="showMaskedAlert"),t.wrappingDraft&&(s=void 0);const d=r||"undefined"==typeof electronHelpers?n:`javascript:electronHelpers.openExternal('${n}');`;b=document.createElement("a"),b.className="anchor-url",b.href=d,r||"undefined"!=typeof electronHelpers||(0,c.Z)(b),s&&b.setAttribute("onclick",s+"(this)")}break;case"messageEntityEmail":t.noLinks||(b=document.createElement("a"),b.href=(0,r.Z)("mailto:"+g),(0,c.Z)(b));break;case"messageEntityHashtag":{const e=!t.noLinks&&s.Hk[M];if(e){const t=g.slice(1);b=document.createElement("a"),b.className="anchor-hashtag",b.href=e.replace("{1}",encodeURIComponent(t)),k?(0,c.Z)(b):b.setAttribute("onclick","searchByHashtag(this)")}break}case"messageEntityMentionName":t.noLinks&&!Z[e._]||(b=document.createElement("a"),b.href=(B=""+e.user_id,"#"+encodeURIComponent(B)),b.className="follow",b.dataset.follow=""+e.user_id);break;case"messageEntityMention":if(!t.noLinks){const e=g.slice(1);b=(0,T.Z)("t.me/"+e),b.className="mention"}break;case"messageEntitySpoiler":if(t.noTextFormat){const t=(0,d.Z)(C.text,e);let s;for(C.text=t.text,v=t.entityText,m!==u&&(C.usedLength+=u-m);s=P[C.i+1],s&&s.offset<u;)++C.i,C.lastEntity=s,i=P[C.i+1]}else if(t.wrappingDraft)b=document.createElement("span"),b.style.fontFamily="markup-spoiler";else{const e=document.createElement("span");e.className="spoiler",b=document.createElement("span"),b.className="spoiler-text",b.textContent=v,I=!0,e.append(b),S.append(e),e[`on${f.pf}`]=window.onSpoilerClick}break;case"messageEntityTimestamp":if(!t.maxMediaTimestamp||e.time>t.maxMediaTimestamp)break;b=document.createElement("a"),b.classList.add("timestamp"),b.dataset.timestamp=""+e.time,b.href="#",b.setAttribute("onclick","setMediaTimestamp(this)"),t.maxMediaTimestamp===1/0&&b.classList.add("is-disabled")}for(!I&&v&&(b?b[w]=v:(b||S).append(v)),b&&!b.parentNode&&(R||S).append(b);i&&i.offset<u;)++C.i,(b||S).append(G(C.text,Object.assign(Object.assign({},t),{voodoo:!0}))),i=P[C.i+1];if(C.usedLength<=u?(C.usedLength<u&&((b||S).append(C.text.slice(C.usedLength,u)),C.usedLength=u),R=S,C.lastEntity=void 0):R=e.length>v.length&&b?b:S,t.voodoo)return S}var B;if(C.lastEntity&&(C.usedLength=C.lastEntity.offset+C.lastEntity.length),C.usedLength<A&&(R||S).append(C.text.slice(C.usedLength)),(!t.wrappingDraft||t.customEmojiRenderer)&&E.size){let e=t.customEmojiRenderer;e||(e=D.create(t),S.prepend(e));const i=e.add(E,t.lazyLoadQueue,t.wrappingDraft);null===(w=t.loadPromises)||void 0===w||w.push(i)}return I.size&&W(I),S}window.syncedPlayers=O,window.emojiRenderers=N,customElements.define("custom-emoji-element",F),customElements.define("custom-emoji-renderer-element",D);const V=e=>{const t=document.createElement("span");return t.classList.add(e?"input-filler2":"input-filler"),t.textContent=M.Z,t};function K(e){var t;if((null==e?void 0:e.textContent)!==M.Z||"false"===(null===(t=null==e?void 0:e.getAttribute)||void 0===t?void 0:t.call(e,"contenteditable"))){if(!e||e.textContent!==M.Z||e.firstElementChild)return 2;if(e.nodeType===e.ELEMENT_NODE)return 1}return 0}function W(e){const t=(e,t,i)=>{const s=K(t);2===s?e[i](V()):1===s&&t.appendChild(document.createTextNode(M.Z))};for(const i of e){const{previousSibling:e,nextSibling:s}=i;t(i,e,"before"),t(i,s,"after")}}window.wrapRichText=G},4497:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(3591);function n(e){const{url:t,onclick:i}=(0,s.Z)(e),n=document.createElement("a");return n.href=t,i&&n.setAttribute("onclick",`${i}(this)`),n}},1447:(e,t,i)=>{"use strict";i.d(t,{Z:()=>v});var s=i(5814),n=i(410),a=i(5418),o=i(5003),r=i(3772),d=i(7328),l=i(3241);class c extends l.Z{constructor(e){super(),this.worker=e,this.worker.onerror=e=>{try{this.dispatchEvent("workerError",e),this.cleanup(),this.terminate()}catch(e){}},this.worker.onmessage=e=>{this.dispatchEvent(e.data.queryMethodListener,...e.data.queryMethodArguments)}}postMessage(e){this.worker.postMessage(e)}terminate(){this.worker.terminate()}sendQuery(e,t){this.worker.postMessage({queryMethod:e.shift(),queryMethodArguments:e},d.Z?t:void 0)}}var h=i(8975),u=i(3855);const p="undefined"!=typeof WebAssembly;var f=i(5471),m=i(4159);const g=new class{constructor(){this.loadPromise=p?void 0:Promise.reject(),this.loaded=!1,this.workersLimit=m.Z.threads,this.players={},this.playersByCacheName={},this.workers=[],this.curWorkerNum=0,this.log=(0,o.kg)("LOTTIE",o.v9.Error),this.onPlayerLoaded=(e,t,i)=>{const s=this.players[e];s?(this.log.debug("onPlayerLoaded"),s.onLoad(t,i)):this.log.warn("onPlayerLoaded on destroyed player:",e,t)},this.onFrame=(e,t,i)=>{const s=this.players[e];s?(void 0!==s.clamped&&i instanceof Uint8ClampedArray&&(s.clamped=i),s.renderFrame(i,t)):this.log.warn("onFrame on destroyed player:",e,t)},this.onPlayerError=(e,t)=>{const i=this.players[e];i&&s.Z.getAnimations(i.el[0]).forEach((e=>{s.Z.removeAnimation(e)}))}}getAnimation(e){for(const t in this.players)if(this.players[t].el.includes(e))return this.players[t];return null}loadLottieWorkers(){return this.loadPromise?this.loadPromise:this.loadPromise=new Promise(((e,t)=>{let s=this.workersLimit;for(let n=0;n<this.workersLimit;++n){const a=new Worker(new URL(i.p+i.u(508),i.b)),o=this.workers[n]=new c(a);o.addEventListener("ready",(()=>{this.log("worker #"+n+" ready"),o.addEventListener("frame",this.onFrame),o.addEventListener("loaded",this.onPlayerLoaded),o.addEventListener("error",this.onPlayerError),--s,s||(this.log("workers ready"),e(),this.loaded=!0)}),{once:!0}),o.addEventListener("workerError",(e=>{t("rlottie load error: "+e.message),this.loaded=!1}),{once:!0})}}))}makeAssetUrl(e){return"assets/tgs/"+e+".json"}loadAnimationAsAsset(e,t){return this.loadAnimationFromURL(e,this.makeAssetUrl(t))}loadAnimationDataFromURL(e){return p?(this.loadLottieWorkers(),fetch(e).then((e=>e.headers&&"application/octet-stream"!==e.headers.get("content-type")?e.blob():e.arrayBuffer().then((e=>u.Z.invokeCrypto("gzipUncompress",e))).then((e=>(0,h.Z)(e,"")))))):this.loadPromise}loadAnimationFromURLManually(e){const t=this.makeAssetUrl(e);return this.loadAnimationDataFromURL(t).then((e=>i=>this.loadAnimationFromURLNext(e,i,t)))}loadAnimationFromURL(e,t){return this.loadAnimationDataFromURL(t).then((i=>this.loadAnimationFromURLNext(i,e,t)))}loadAnimationFromURLNext(e,t,i){const s=Object.assign(t,{animationData:e,needUpscale:!0});return s.name||(s.name=i),this.loadAnimationWorker(s)}waitForFirstFrame(e){return Promise.race([new Promise((t=>{e.addEventListener("firstFrame",t,{once:!0})})),(0,a.Z)(2500)]).then((()=>e))}loadAnimationWorker(e){return t=this,i=void 0,a=function*(){if(!p)return this.loadPromise;this.loaded||(yield this.loadLottieWorkers());const{middleware:t,group:i=""}=e;if(t&&!t())throw(0,f.Z)("MIDDLEWARE");if(e.sync){const t=r.Z.CACHE.generateName(e.name,e.width,e.height,e.color,e.toneIndex),i=this.playersByCacheName[t];if(null==i?void 0:i.size)return Promise.resolve(i.entries().next().value[0])}const n=Array.isArray(e.container)?e.container:[e.container];if(e.width&&e.height||(e.width=parseInt(n[0].style.width),e.height=parseInt(n[0].style.height)),!e.width||!e.height)throw new Error("No size for sticker!");e.group=i;const a=this.initPlayer(n,e);return s.Z.addAnimation({animation:a,group:i,controlled:t,liteModeKey:e.liteModeKey}),a},new((n=void 0)||(n=Promise))((function(e,s){function o(e){try{d(a.next(e))}catch(e){s(e)}}function r(e){try{d(a.throw(e))}catch(e){s(e)}}function d(t){var i;t.done?e(t.value):(i=t.value,i instanceof n?i:new n((function(e){e(i)}))).then(o,r)}d((a=a.apply(t,i||[])).next())}));var t,i,n,a}onDestroy(e){delete this.players[e]}destroyWorkers(){p&&(this.workers.forEach(((e,t)=>{e.terminate(),this.log("worker #"+t+" terminated")})),this.log("workers destroyed"),this.workers.length=0,this.curWorkerNum=0,this.loaded=!1,this.loadPromise=void 0)}initPlayer(e,t){var i,s;const n=new r.Z({el:e,worker:this.workers[this.curWorkerNum++],options:t}),{reqId:a,cacheName:o}=n;this.players[a]=n;const d=o?null!==(i=(s=this.playersByCacheName)[o])&&void 0!==i?i:s[o]=new Set:void 0;return o&&d.add(n),this.curWorkerNum>=this.workers.length&&(this.curWorkerNum=0),n.addEventListener("destroy",(()=>{this.onDestroy(a),d.delete(n)&&!d.size&&delete this.playersByCacheName[o]})),n.loadFromData(t.animationData),n}};n.GO.lottieLoader=g;const v=g},3772:(e,t,i)=>{"use strict";i.d(t,{Z:()=>u,a:()=>h});var s=i(7328),n=i(8189),a=i(4762),o=i(3241),r=i(4755),d=i(3228),l=i(356),c=i(645);function h(e,t,i){let s=(0,d.Z)(window.devicePixelRatio,1,2);return s>1&&!i&&(e>90&&t>90?!a.IS_APPLE&&r.Z.isMobile&&(s=1):(e>60&&t>60||a.IS_ANDROID)&&(s=Math.max(1.5,s-1.5))),s}class u extends o.Z{constructor({el:e,worker:t,options:i}){super(!0),this.reqId=0,this.width=0,this.height=0,this.paused=!0,this.direction=1,this.speed=1,this.autoplay=!0,this.loop=!0,this.group="",this.cachingDelta=0,this.playedTimes=0,this.reqId=++u.reqId,this.el=e,this.worker=t;for(const e in i)this.hasOwnProperty(e)&&(this[e]=i[e]);let o;this._loop=this.loop,this._autoplay=this.autoplay,this.initFrame=i.initFrame,this.color=i.color,this.inverseColor=i.inverseColor,this.name=i.name,this.skipFirstFrameRendering=i.skipFirstFrameRendering,this.toneIndex=i.toneIndex,this.raw=void 0!==this.color,this.liteModeKey=i.liteModeKey,this.name&&(this.cacheName=u.CACHE.generateName(this.name,this.width,this.height,this.color,this.toneIndex)),void 0!==i.skipRatio?o=i.skipRatio:(a.IS_ANDROID||a.IS_APPLE_MOBILE||a.IS_APPLE&&!a.IS_SAFARI&&!n.Z)&&this.width<100&&this.height<100&&!i.needUpscale&&(o=.5),this.skipDelta=void 0!==o?1/o|0:1;const r=h(this.width,this.height,i.needUpscale);this.width=Math.round(this.width*r),this.height=Math.round(this.height*r),i.noCache||(a.IS_APPLE&&this.width>100&&this.height>100?this.cachingDelta=2:this.width<100&&this.height<100?this.cachingDelta=1/0:this.cachingDelta=4),this.canvas||(this.canvas=this.el.map((()=>{const e=document.createElement("canvas");return e.classList.add("rlottie"),e.width=this.width,e.height=this.height,e.dpr=r,e}))),this.contexts=this.canvas.map((e=>e.getContext("2d"))),l.Z&&!this.raw||(this.imageData=new ImageData(this.width,this.height),s.Z&&(this.clamped=new Uint8ClampedArray(this.width*this.height*4))),this.name?this.cache=u.CACHE.getCache(this.cacheName):this.cache=c.M.createCache()}clearCache(){this.cachingDelta!==1/0&&(this.cacheName&&this.cache.counter>1||this.cache.clearCache())}sendQuery(e,t){this.worker.sendQuery([e.shift(),this.reqId,...e],t)}loadFromData(e){this.sendQuery(["loadFromData",e,this.width,this.height,this.toneIndex,void 0!==this.color])}play(){this.paused&&(this.paused=!1,this.setMainLoop())}pause(e=!0){this.paused||(this.paused=!0,e&&(clearTimeout(this.rafId),this.rafId=void 0))}resetCurrentFrame(){var e;return this.curFrame=null!==(e=this.initFrame)&&void 0!==e?e:1===this.direction?this.minFrame:this.maxFrame}stop(e=!0){this.pause();const t=this.resetCurrentFrame();e&&this.requestFrame(t)}restart(){this.stop(!1),this.play()}playOrRestart(){this.paused&&(this.curFrame===this.maxFrame?this.restart():this.play())}setSpeed(e){this.speed!==e&&(this.speed=e,this.paused||this.setMainLoop())}setDirection(e){this.direction!==e&&(this.direction=e,this.paused||this.setMainLoop())}remove(){this.pause(),this.sendQuery(["destroy"]),this.cacheName&&u.CACHE.releaseCache(this.cacheName),this.dispatchEvent("destroy"),this.cleanup()}applyColor(e){const[t,i,s]=this.color;for(let n=0,a=e.length;n<a;n+=4)0!==e[n+3]&&(e[n]=t,e[n+1]=i,e[n+2]=s)}applyInversing(e){const[t,i,s]=this.inverseColor;for(let n=0,a=e.length;n<a;n+=4)0===e[n+3]?(e[n]=t,e[n+1]=i,e[n+2]=s,e[n+3]=255):e[n+3]=0}renderFrame2(e,t){try{e instanceof Uint8ClampedArray&&(this.color&&this.applyColor(e),this.inverseColor&&this.applyInversing(e),this.imageData.data.set(e)),this.contexts.forEach(((i,s)=>{let n=this.cache.framesNew.get(t);if(e instanceof Uint8ClampedArray?s>0&&(n=this.canvas[0]):n=e,!n){const e=document.createElement("canvas");e.width=i.canvas.width,e.height=i.canvas.height,e.getContext("2d").putImageData(this.imageData,0,0),this.cache.framesNew.set(t,e),n=e}this.overrideRender&&this.renderedFirstFrame?this.overrideRender(n||this.imageData):n?(i.clearRect(0,0,n.width,n.height),i.drawImage(n,0,0)):i.putImageData(this.imageData,0,0),this.renderedFirstFrame||(this.renderedFirstFrame=!0)})),this.dispatchEvent("enterFrame",t)}catch(e){console.error("RLottiePlayer renderFrame error:",e,this.width,this.height),this.autoplay=!1,this.pause()}}renderFrame(e,t){if(this.cachingDelta&&(t%this.cachingDelta||!t)&&(e instanceof Uint8ClampedArray&&!this.cache.frames.has(t)?this.cache.frames.set(t,new Uint8ClampedArray(e)):l.Z&&e instanceof ImageBitmap&&!this.cache.framesNew.has(t)&&this.cache.framesNew.set(t,e)),this.frInterval){const i=Date.now()-this.frThen;if(i<0){const s=this.frInterval>-i?-i%this.frInterval:this.frInterval;return this.rafId&&clearTimeout(this.rafId),void(this.rafId=window.setTimeout((()=>{this.renderFrame2(e,t)}),s))}}this.renderFrame2(e,t)}requestFrame(e){const t=this.cache.frames.get(e),i=this.cache.framesNew.get(e);i?this.renderFrame(i,e):t?this.renderFrame(t,e):(this.clamped&&!this.clamped.length&&(this.clamped=new Uint8ClampedArray(this.width*this.height*4)),this.sendQuery(["renderFrame",e],this.clamped?[this.clamped.buffer]:void 0))}onLap(){return++this.playedTimes===this.loop&&(this.loop=!1),!!this.loop||(this.pause(!1),!1)}mainLoopForwards(){const{skipDelta:e,maxFrame:t}=this,i=this.curFrame+e>t?this.curFrame=this.loop?this.minFrame:this.maxFrame:this.curFrame+=e;return this.requestFrame(i),!(i+e>t)||this.onLap()}mainLoopBackwards(){const{skipDelta:e,minFrame:t}=this,i=this.curFrame-e<t?this.curFrame=this.loop?this.maxFrame:this.minFrame:this.curFrame-=e;return this.requestFrame(i),!(i-e<t)||this.onLap()}setMainLoop(){clearTimeout(this.rafId),this.rafId=void 0,this.frInterval=1e3/this.fps/this.speed*this.skipDelta,this.frThen=Date.now()-this.frInterval;const e=(1===this.direction?this.mainLoopForwards:this.mainLoopBackwards).bind(this);this.currentMethod=e,this.frameListener&&void 0!==this.listenerResults.enterFrame&&this.frameListener(this.curFrame)}playPart(e){this.pause();const{from:t,to:i,callback:s}=e;return this.curFrame=t-1,this.playToFrame({frame:i,direction:i>t?1:-1,callback:s})}playToFrame(e){this.pause();const{frame:t,speed:i,callback:s,direction:n}=e;this.setDirection(void 0===n?this.curFrame>t?-1:1:n),void 0!==i&&this.setSpeed(i);const a=[this.curFrame,t];-1===this.direction&&a.reverse(),this.loop=!1,this.setMinMax(a[0],a[1]),this.playToFrameOnFrameCallback&&this.removeEventListener("enterFrame",this.playToFrameOnFrameCallback),s&&(this.playToFrameOnFrameCallback=e=>{e===t&&(this.removeEventListener("enterFrame",this.playToFrameOnFrameCallback),s())},this.addEventListener("enterFrame",this.playToFrameOnFrameCallback)),this.play()}setColor(e,t){this.color=e,t&&this.paused&&this.renderFrame2(this.imageData.data,this.curFrame)}setInverseColor(e){this.inverseColor=e}setMinMax(e=0,t=this.frameCount-1){this.minFrame=e,this.maxFrame=t}onLoad(e,t){return i=this,s=void 0,a=function*(){this.frameCount=e,this.fps=t,this.setMinMax(),void 0!==this.initFrame&&(this.initFrame=(0,d.Z)(this.initFrame,this.minFrame,this.maxFrame));const i=this.resetCurrentFrame();if(this.fps<60&&1!==this.skipDelta){const e=60/t;this.skipDelta=this.skipDelta/e|0}this.frInterval=1e3/this.fps/this.speed*this.skipDelta,this.frThen=Date.now()-this.frInterval,!this.skipFirstFrameRendering&&this.requestFrame(i),this.dispatchEvent("ready"),this.addEventListener("enterFrame",(()=>{this.dispatchEvent("firstFrame"),this.canvas[0].parentNode||!this.el||this.overrideRender||this.el.forEach(((e,t)=>e.append(this.canvas[t]))),this.frameListener=()=>{if(this.paused||!this.currentMethod)return;const e=Date.now();this.frThen=e+this.frInterval,this.currentMethod()||this.loop||!this.autoplay||(this.autoplay=!1)},this.addEventListener("enterFrame",this.frameListener),"none"===this.group&&this.autoplay&&this.play()}),{once:!0})},new((n=void 0)||(n=Promise))((function(e,t){function o(e){try{d(a.next(e))}catch(e){t(e)}}function r(e){try{d(a.throw(e))}catch(e){t(e)}}function d(t){var i;t.done?e(t.value):(i=t.value,i instanceof n?i:new n((function(e){e(i)}))).then(o,r)}d((a=a.apply(i,s||[])).next())}));var i,s,n,a}}u.CACHE=c.Z,u.reqId=0},4874:(e,t,i)=>{"use strict";i.d(t,{Z:()=>c});var s=i(1447),n=i(6008),a=i(410),o=i(4789),r=i(2648);const d=new class{constructor(){this.pageId=-1,this.pagesDiv=document.getElementById("auth-pages"),this.scrollableDiv=this.pagesDiv.querySelector(".scrollable"),this.selectTab=(0,n.X)(null,this.scrollableDiv.querySelector(".tabs-container"),null,(()=>{var e;(null===(e=this.page)||void 0===e?void 0:e.onShown)&&this.page.onShown()}))}setPage(e){if(e.isAuthPage){this.pagesDiv.style.display="";const t=(0,r.Z)(e.pageEl);if(this.pageId===t)return;this.selectTab(t),-1!==this.pageId&&t>1&&s.Z.loadLottieWorkers(),this.pageId=t,this.scrollableDiv&&(0,o.Z)({container:this.scrollableDiv,element:this.scrollableDiv.firstElementChild,position:"start"})}else this.pagesDiv.style.display="none",e.pageEl.style.display="",this.pageId=-1;this.page=e}};a.GO.pagesManager=d;const l=d;class c{constructor(e,t,i,s,n){this.isAuthPage=t,this.onFirstMount=i,this.onMount=s,this.onShown=n,this.installed=!1,this.pageEl=document.body.querySelector("."+e)}mount(...e){return t=this,i=void 0,n=function*(){if(this.onMount){const t=this.onMount(...e);t instanceof Promise&&(yield t)}if(!this.installed){if(this.onFirstMount)try{const t=this.onFirstMount(...e);t instanceof Promise&&(yield t)}catch(e){console.error("PAGE MOUNT ERROR:",e)}this.installed=!0}l.setPage(this)},new((s=void 0)||(s=Promise))((function(e,a){function o(e){try{d(n.next(e))}catch(e){a(e)}}function r(e){try{d(n.throw(e))}catch(e){a(e)}}function d(t){var i;t.done?e(t.value):(i=t.value,i instanceof s?i:new s((function(e){e(i)}))).then(o,r)}d((n=n.apply(t,i||[])).next())}));var t,i,s,n}}},671:(e,t,i)=>{"use strict";function s(e){return r(o(e)).join("-")}i.d(t,{Ml:()=>c,N0:()=>s,tB:()=>d,w1:()=>r,zu:()=>h});const n=/\uFE0F/g,a=String.fromCharCode(8205),o=e=>e.indexOf(a)<0?e.replace(n,""):e;function r(e){const t=[];let i=0,s=0,n=0;for(;n<e.length;)i=e.charCodeAt(n++),s?(t.push((65536+(s-55296<<10)+(i-56320)).toString(16)),s=0):i>55296&&i<=56319?s=i:t.push(i.toString(16));return t.length&&2===t[0].length&&(t[0]="00"+t[0]),t}function d(e){const t=e.match(/[\uDFFB-\uDFFF]/);return t?5-(57343-t[0].charCodeAt(0)):0}const l=new Map([["FT","🏴‍☠"]]);function c(e){var t;return null!==(t=l.get(e))&&void 0!==t?t:String.fromCharCode(55356,56741+e.charCodeAt(0),55356,56741+e.charCodeAt(1))}function h(e){return e.split("-").reduce(((e,t)=>e+String.fromCodePoint(parseInt(t,16))),"")}},4329:function(e){"undefined"!=typeof self&&self,e.exports=function(e){var t={};function i(s){if(t[s])return t[s].exports;var n=t[s]={i:s,l:!1,exports:{}};return e[s].call(n.exports,n,n.exports,i),n.l=!0,n.exports}return i.m=e,i.c=t,i.d=function(e,t,s){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:s})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var s=Object.create(null);if(i.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)i.d(s,n,function(t){return e[t]}.bind(null,n));return s},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=0)}([function(e,t,i){"use strict";(function(t){var i=t.AudioContext||t.webkitAudioContext,s=function(e){if(!s.isRecordingSupported())throw new Error("Recording is not supported in this browser");e||(e={}),this.state="inactive",this.config=Object.assign({bufferLength:4096,encoderApplication:2049,encoderFrameSize:20,encoderPath:"encoderWorker.min.js",encoderSampleRate:48e3,maxFramesPerPage:40,mediaTrackConstraints:!0,monitorGain:0,numberOfChannels:1,recordingGain:1,resampleQuality:3,streamPages:!1,reuseWorker:!1,wavBitDepth:16},e),this.encodedSamplePosition=0};s.isRecordingSupported=function(){return i&&t.navigator&&t.navigator.mediaDevices&&t.navigator.mediaDevices.getUserMedia&&t.WebAssembly},s.prototype.clearStream=function(){this.stream&&(this.stream.getTracks?this.stream.getTracks().forEach((function(e){e.stop()})):this.stream.stop(),delete this.stream),this.audioContext&&this.closeAudioContext&&(this.audioContext.close(),delete this.audioContext)},s.prototype.encodeBuffers=function(e){if("recording"===this.state){for(var t=[],i=0;i<e.numberOfChannels;i++)t[i]=e.getChannelData(i);this.encoder.postMessage({command:"encode",buffers:t})}},s.prototype.initAudioContext=function(e){return e&&e.context?(this.audioContext=e.context,this.closeAudioContext=!1):(this.audioContext=new i,this.closeAudioContext=!0),this.audioContext},s.prototype.initAudioGraph=function(){this.encodeBuffers=function(){delete this.encodeBuffers},this.scriptProcessorNode=this.audioContext.createScriptProcessor(this.config.bufferLength,this.config.numberOfChannels,this.config.numberOfChannels),this.scriptProcessorNode.connect(this.audioContext.destination),this.scriptProcessorNode.onaudioprocess=e=>{this.encodeBuffers(e.inputBuffer)},this.monitorGainNode=this.audioContext.createGain(),this.setMonitorGain(this.config.monitorGain),this.monitorGainNode.connect(this.audioContext.destination),this.recordingGainNode=this.audioContext.createGain(),this.setRecordingGain(this.config.recordingGain),this.recordingGainNode.connect(this.scriptProcessorNode)},s.prototype.initSourceNode=function(e){return e&&e.context?t.Promise.resolve(e):t.navigator.mediaDevices.getUserMedia({audio:this.config.mediaTrackConstraints}).then((e=>(this.stream=e,this.audioContext.createMediaStreamSource(e))))},s.prototype.loadWorker=function(){this.encoder||(this.encoder=new t.Worker(this.config.encoderPath))},s.prototype.initWorker=function(){var e=(this.config.streamPages?this.streamPage:this.storePage).bind(this);return this.recordedPages=[],this.totalLength=0,this.loadWorker(),new Promise(((t,i)=>{var s=i=>{switch(i.data.message){case"ready":t();break;case"page":this.encodedSamplePosition=i.data.samplePosition,e(i.data.page);break;case"done":this.encoder.removeEventListener("message",s),this.finish()}};this.encoder.addEventListener("message",s),this.encoder.postMessage(Object.assign({command:"init",originalSampleRate:this.audioContext.sampleRate,wavSampleRate:this.audioContext.sampleRate},this.config))}))},s.prototype.pause=function(e){if("recording"===this.state){if(this.state="paused",e&&this.config.streamPages){var t=this.encoder;return new Promise(((e,i)=>{var s=i=>{"flushed"===i.data.message&&(t.removeEventListener("message",s),this.onpause(),e())};t.addEventListener("message",s),t.postMessage({command:"flush"})}))}return this.onpause(),Promise.resolve()}},s.prototype.resume=function(){"paused"===this.state&&(this.state="recording",this.onresume())},s.prototype.setRecordingGain=function(e){this.config.recordingGain=e,this.recordingGainNode&&this.audioContext&&this.recordingGainNode.gain.setTargetAtTime(e,this.audioContext.currentTime,.01)},s.prototype.setMonitorGain=function(e){this.config.monitorGain=e,this.monitorGainNode&&this.audioContext&&this.monitorGainNode.gain.setTargetAtTime(e,this.audioContext.currentTime,.01)},s.prototype.start=function(e){if("inactive"===this.state)return this.initAudioContext(e),this.initAudioGraph(),this.encodedSamplePosition=0,this.initWorker().then((()=>this.initSourceNode(e))).then((e=>{this.sourceNode=e,this.state="recording",this.onstart(),this.encoder.postMessage({command:"getHeaderPages"}),this.sourceNode.connect(this.monitorGainNode),this.sourceNode.connect(this.recordingGainNode)}))},s.prototype.stop=function(){if("inactive"!==this.state){this.state="inactive",this.monitorGainNode.disconnect(),this.scriptProcessorNode.disconnect(),this.recordingGainNode.disconnect(),this.sourceNode.disconnect(),this.clearStream();var e=this.encoder;return new Promise((t=>{var i=s=>{"done"===s.data.message&&(e.removeEventListener("message",i),t())};e.addEventListener("message",i),e.postMessage({command:"done"}),this.config.reuseWorker||e.postMessage({command:"close"})}))}return Promise.resolve()},s.prototype.destroyWorker=function(){"inactive"===this.state&&this.encoder&&(this.encoder.postMessage({command:"close"}),delete this.encoder)},s.prototype.storePage=function(e){this.recordedPages.push(e),this.totalLength+=e.length},s.prototype.streamPage=function(e){this.ondataavailable(e)},s.prototype.finish=function(){if(!this.config.streamPages){var e=new Uint8Array(this.totalLength);this.recordedPages.reduce((function(t,i){return e.set(i,t),t+i.length}),0),this.ondataavailable(e)}this.onstop(),this.config.reuseWorker||delete this.encoder},s.prototype.ondataavailable=function(){},s.prototype.onpause=function(){},s.prototype.onresume=function(){},s.prototype.onstart=function(){},s.prototype.onstop=function(){},e.exports=s}).call(this,i(1))},function(e,t){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(e){"object"==typeof window&&(i=window)}e.exports=i}])},6802:e=>{var t=.1,i="function"==typeof Float32Array;function s(e,t){return 1-3*t+3*e}function n(e,t){return 3*t-6*e}function a(e){return 3*e}function o(e,t,i){return((s(t,i)*e+n(t,i))*e+a(t))*e}function r(e,t,i){return 3*s(t,i)*e*e+2*n(t,i)*e+a(t)}function d(e){return e}e.exports=function(e,s,n,a){if(!(0<=e&&e<=1&&0<=n&&n<=1))throw new Error("bezier x values must be in [0, 1] range");if(e===s&&n===a)return d;for(var l=i?new Float32Array(11):new Array(11),c=0;c<11;++c)l[c]=o(c*t,e,n);return function(i){return 0===i||1===i?i:o(function(i){for(var s=0,a=1;10!==a&&l[a]<=i;++a)s+=t;--a;var d=s+(i-l[a])/(l[a+1]-l[a])*t,c=r(d,e,n);return c>=.001?function(e,t,i,s){for(var n=0;n<4;++n){var a=r(t,i,s);if(0===a)return t;t-=(o(t,i,s)-e)/a}return t}(i,d,e,n):0===c?d:function(e,t,i,s,n){var a,r,d=0;do{(a=o(r=t+(i-t)/2,s,n)-e)>0?i=r:t=r}while(Math.abs(a)>1e-7&&++d<10);return r}(i,s,s+t,e,n)}(i),s,a)}}}}]);
//# sourceMappingURL=297.1bdbe4d3952a46b0e184.chunk.js.map