tweb/public/408.03880fedecb1e421da3b.ch...

2 lines
1.2 MiB
Raw 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([[408],{5814:(e,t,i)=>{"use strict";i.d(t,{Z:()=>m});var s=i(4776),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),f=i(3035);const p=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.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,t="",i,a){var o,r,l,c;if("none"===t||this.byPlayer.has(e))return;i||(e instanceof d.Z?i=e.el[0]:e instanceof s.KZ?i=e.canvas:e instanceof s.LD?i=null!==(o=e.placeholder)&&void 0!==o?o:e:e instanceof HTMLElement&&(i=e));const h={el:i,animation:e,group:t,controlled:a};e instanceof d.Z&&!n.Z.settings.stickers.loop&&e.loop&&(e.loop=n.Z.settings.stickers.loop),(null!==(r=(l=this.byGroups)[c=t])&&void 0!==r?r:l[c]=[]).push(h),this.observer.observe(h.el),this.byPlayer.set(e,h)}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,f.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)}};o.GO&&(o.GO.animationIntersector=p);const m=p},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),f=i(3699),p=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.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)=>{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!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,p.Z)(e);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,p.Z)(e),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)(t,!0,!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,p.Z)(t),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,p.Z)(e);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 f.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:()=>L});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(4846),f=i(3709),p=i(7530),m=i(4776),g=i(5824),v=i(5128),b=i(4524),y=i(8805),w=i(4332),S=i(1669),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 g.Z{constructor(){let e;super(new c.Z({processItem:e=>{const t="inputMessagesFilterDocument"===this.searchContext.inputFilter._,{mid:i,peerId:s}=e,n=(0,p.Z)(e);if(n&&(!t||L.isMediaCompatibleForDocumentViewer(n)))return{element:null,mid:i,peerId:s}}}),["delete","forward"]),this.onPrevClick=e=>C(this,void 0,void 0,(function*(){this.openMedia(yield this.getMessageByPeer(e.peerId,e.mid),e.element,-1)})),this.onNextClick=e=>C(this,void 0,void 0,(function*(){this.openMedia(yield this.getMessageByPeer(e.peerId,e.mid),e.element,1)})),this.onDeleteClick=()=>{const e=this.target;new v.Z(e.peerId,[e.mid],"chat",(()=>{this.target={element:this.content.media},this.close()}))},this.onForwardClick=()=>{const e=this.target;e.mid&&new b.Z({[e.peerId]:[e.mid]},(()=>this.close()))},this.onAuthorClick=e=>C(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((()=>C(this,void 0,void 0,(function*(){if(l.Z.isMobile){const e=w.ZP.getTab(S.Z);e&&e.close()}u.Z.setInnerPeer({peerId:n.peerId,lastMsgId:t,type:s?"discussion":void 0,threadId:s})}))))}})),this.onDownloadClick=()=>C(this,void 0,void 0,(function*(){const{peerId:e,mid:t}=this.target,i=yield this.getMessageByPeer(e,t),s=(0,p.Z)(i);s&&h.Z.downloadToDisc({media:s,queueId:u.Z.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()}get searchContext(){return this.listLoader.searchContext}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"),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="";t&&(i=(0,m.ZP)(t,{entities:e.totalEntities})),(0,d.Z)(this.content.caption.firstElementChild,i),this.content.caption.classList.toggle("hide",!t)}setSearchContext(e){return this.listLoader.setSearchContext(e),this}openMedia(e,t,i=0,s=!1,n=[],a=[]){const o=Object.create(null,{_openMedia:{get:()=>super._openMedia}});return C(this,void 0,void 0,(function*(){if(this.setMoverPromise)return this.setMoverPromise;const r=e.mid,d=e.fwd_from&&!e.fromId?e.fwd_from.from_name:e.fromId,l=(0,p.Z)(e),c=yield this.managers.appPeersManager.noForwards(e.peerId),h="messageService"===e._,u=h||!(yield this.managers.appMessagesManager.canForward(e)),m=(h?c:u)||!(0,f.Z)(e);[this.buttons.forward,this.btnMenuForward.element].forEach((e=>{e.classList.toggle("hide",u)})),this.wholeDiv.classList.toggle("no-forwards",m),[this.buttons.download,this.btnMenuDownload.element].forEach((e=>{e.classList.toggle("hide",m)}));const g=yield this.managers.appMessagesManager.canDeleteMessage(e);[this.buttons.delete,this.btnMenuDelete.element].forEach((e=>{e.classList.toggle("hide",!g)})),this.setCaption(e);const v=o._openMedia.call(this,l,e.date,d,i,t,s,n,a,e);return this.target.mid=r,this.target.peerId=e.peerId,v}))}static isMediaCompatibleForDocumentViewer(e){return"photo"===e._||s.Z.has(e.mime_type)}}},5824:(e,t,i)=>{"use strict";i.d(t,{x:()=>q,Z:()=>Q});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),f=i(7529),p=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 f.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(e,i),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,p.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(){this.video[this.video.paused?"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.Z)(e);t.classList.add("top-left"),(0,u.v)(this.playbackRateButton,this.onPlaybackRackMenuToggle?()=>{this.onPlaybackRackMenuToggle(!0)}:void 0,void 0,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,p.rB)()?(0,p.C8)():(0,p.Dj)(e)}onFullScreen(e){const t=(0,p.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"))}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),M=i(2230),P=i(3442),Z=i(3757),k=i(632),T=i(9818),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),$=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 q="media-viewer";class Q extends O.Z{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.zoomSwipeStartX=0,this.zoomSwipeStartY=0,this.zoomSwipeX=0,this.zoomSwipeY=0,this.setZoomValue=(e=this.zoomElements.rangeSelector.value)=>{1===e&&(this.zoomSwipeX=0,this.zoomSwipeY=0),this.moversContainer.style.transform=`matrix(${e}, 0, 0, ${e}, ${this.zoomSwipeX}, ${this.zoomSwipeY})`,this.zoomElements.btnOut.classList.toggle("inactive",.5===e),this.zoomElements.btnIn.classList.toggle("inactive",4===e),this.toggleZoom(1!==e)},this.onClick=e=>{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));const i=this.isZooming();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.buttons.next.click():"ArrowLeft"===t?this.buttons.prev.click():"-"===t||"="===t?this.ctrlKeyDown&&this.changeZoom("="===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.onWheel=e=>{if(!(y.Z.overlaysActive>1||(0,x.Z)(e.target,"media-viewer-caption")&&!this.ctrlKeyDown)&&((0,l.Z)(e),this.ctrlKeyDown)){const t=e.deltaY<0;this.changeZoom(!!t)}},this.managers=L.Z.managers,this.log=(0,r.kg)("AMV"),this.preloader=new P.Z,this.preloaderStreamable=new P.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(q+"-whole"),this.overlaysDiv=document.createElement("div"),this.overlaysDiv.classList.add("overlays");const i=document.createElement("div");i.classList.add(q);const s=this.topbar=document.createElement("div");s.classList.add(q+"-topbar",q+"-appear");const n=document.createElement("div");n.classList.add(q+"-topbar-left"),this.buttons["mobile-close"]=(0,M.Z)("close",{onlyMobile:!0}),this.author.container=document.createElement("div"),this.author.container.classList.add(q+"-author","no-select");const o=document.createElement("div");this.author.avatarEl=new I.Z,this.author.avatarEl.classList.add(q+"-userpic","avatar-44"),this.author.nameEl=document.createElement("div"),this.author.nameEl.classList.add(q+"-name"),this.author.date=document.createElement("div"),this.author.date.classList.add(q+"-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(q+"-buttons"),t.concat(["download","zoom","close"]).forEach((e=>{const t=(0,M.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,M.Z)("zoomout",{noRipple:!0}),(0,S.fc)(this.zoomElements.btnOut,(()=>this.changeZoom(!1))),this.zoomElements.btnIn=(0,M.Z)("zoomin",{noRipple:!0}),(0,S.fc)(this.zoomElements.btnIn,(()=>this.changeZoom(!0))),this.zoomElements.rangeSelector=new B.Z({step:.5,min:.5,max:4,withTransition:!0},1),this.zoomElements.rangeSelector.setListeners(),this.zoomElements.rangeSelector.setHandlers({onScrub:this.setZoomValue,onMouseUp:()=>this.setZoomValue()}),this.zoomElements.container.append(this.zoomElements.btnOut,this.zoomElements.rangeSelector.container,this.zoomElements.btnIn),this.wholeDiv.append(this.zoomElements.container),this.content.main=document.createElement("div"),this.content.main.classList.add(q+"-content"),this.content.container=document.createElement("div"),this.content.container.classList.add(q+"-container"),this.content.media=document.createElement("div"),this.content.media.classList.add(q+"-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=`${q}-switcher ${q}-switcher-left`,this.buttons.prev.innerHTML=`<span class="tgico-down ${q}-prev-button"></span>`,this.buttons.next=document.createElement("div"),this.buttons.next.className=`${q}-switcher ${q}-switcher-right`,this.buttons.next.innerHTML=`<span class="tgico-down ${q}-next-button"></span>`,this.moversContainer=document.createElement("div"),this.moversContainer.classList.add(q+"-movers"),this.wholeDiv.append(this.overlaysDiv,this.buttons.prev,this.buttons.next,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()}get target(){return this.listLoader.current}set target(e){this.listLoader.current=e}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.toggleZoom(!1):this.changeZoom(!0)})),this.wholeDiv.addEventListener("click",this.onClick),this.listLoader.onJump=(e,t)=>{t?this.onNextClick(e):this.onPrevClick(e)},a.Z&&new Z.Z({element:this.wholeDiv,onSwipe:(e,t)=>{if(!(0,p.rB)())return Math.abs(e)/N.Z.width>.2||e>125?(e<0?this.buttons.prev.click():this.buttons.next.click(),!0):(Math.abs(t)/N.Z.height>.2||t>125)&&(this.close(),!0)},verifyTouchTarget:e=>"INPUT"!==e.target.tagName&&!(0,x.Z)(e.target,"media-viewer-caption")})}toggleZoom(e){const t=this.isZooming();if((this.zoomElements.rangeSelector.mousedown||this.ctrlKeyDown)&&(e=!0),t===e)return;void 0===e&&(e=!t),this.buttons.zoom.classList.toggle("zoom-in",!e),this.zoomElements.container.classList.toggle("is-visible",e);const i=e?this.zoomElements.rangeSelector.value:1;if(this.setZoomValue(i),this.zoomElements.rangeSelector.setProgress(i),this.videoPlayer&&this.videoPlayer.lockControls(!e&&void 0),e){if(this.zoomSwipeHandler)this.zoomSwipeHandler.setListeners();else{let e,t;const i=-1;this.zoomSwipeHandler=new Z.Z({element:this.moversContainer,onFirstSwipe:()=>{e=t=0,this.moversContainer.classList.add("no-transition")},onSwipe:(s,n)=>{[s,n]=[s*i,n*i],this.zoomSwipeX+=s-e,this.zoomSwipeY+=n-t,[e,t]=[s,n],this.setZoomValue()},onReset:()=>{this.moversContainer.classList.remove("no-transition")},cursor:"move"})}this.zoomElements.rangeSelector.setProgress(i)}else e||this.zoomSwipeHandler.removeListeners()}changeZoom(e){this.zoomElements.rangeSelector.addProgress(.5*(e?1:-1)),this.setZoomValue()}isZooming(){return this.zoomElements.container.classList.contains("is-visible")}setBtnMenuToggle(e){const t=(0,u.Z)({onlyMobile:!0},"bottom-left",e);this.topbar.append(t)}close(e){var t;if(e&&(0,l.Z)(e),this.setMoverAnimationPromise)return Promise.reject();this.navigationItem&&T.Z.removeItem(this.navigationItem),this.lazyLoadQueue.clear();const i=this.setMoverToTarget(null===(t=this.target)||void 0===t?void 0:t.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(),this.zoomSwipeHandler=void 0,i.finally((()=>{this.wholeDiv.remove(),this.toggleOverlay(!1)})),i}toggleOverlay(e){y.Z.isOverlayActive=e,E.Z.checkAnimations2(e)}toggleGlobalListeners(e){e?this.setGlobalListeners():this.removeGlobalListeners()}removeGlobalListeners(){this.zoomSwipeHandler&&this.zoomSwipeHandler.removeListeners(),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp),window.removeEventListener("wheel",this.onWheel,{capture:!0})}setGlobalListeners(){this.isZooming()&&this.zoomSwipeHandler.setListeners(),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp),a.Z||window.addEventListener("wheel",this.onWheel,{passive:!1,capture:!0})}setMoverToTarget(e,t=!1,i=0){return $(this,void 0,void 0,(function*(){this.dispatchEvent("setMoverBefore");const n=this.content.mover;t||(n.innerHTML="");const a=this.isZooming()&&t?this.zoomElements.rangeSelector.value:1;this.removeCenterFromMover(n);const o=0!==i,r=L.Z.settings.animationsEnabled?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,f,p,m="";if(o?(u=1===i?N.Z.width:-h.width,f=h.top):(u=l.left,f=l.top),m+=`translate3d(${u}px,${f}px,0) `,e instanceof HTMLImageElement||e instanceof HTMLVideoElement||"DIV"===e.tagName){if(n.firstElementChild&&n.firstElementChild.classList.contains("media-viewer-aspecter")){p=n.firstElementChild;const e=p.querySelector(".ckin__player");if(e){const t=e.firstElementChild;p.append(t),e.remove()}p.style.cssText||(n.classList.remove("active"),this.setFullAspect(p,h,l),n.offsetLeft,n.classList.add("active"))}else p=document.createElement("div"),p.classList.add("media-viewer-aspecter"),n.prepend(p);p.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=N.Z.width/2-l.width/2,t=N.Z.height/2-l.height/2,i=l.left-e,s=l.top-t;this.moversContainer.style.transform=`matrix(${g}, 0, 0, ${v}, ${i}, ${s})`}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)(),E={onAnimationEnd:C},M=setTimeout((()=>{C.isFulfilled||C.isRejected||C.resolve()}),1e3);if(C.finally((()=>{this.dispatchEvent("setMoverAfter"),this.setMoverAnimationPromise===C&&(this.setMoverAnimationPromise=null),clearTimeout(M)})),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.innerHTML="",n.classList.remove("moving","active","hiding"),n.style.cssText="display: none;",C.resolve()}),r),n.classList.remove("opening"),E;{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);p&&(p.style.borderRadius=b,t&&p.append(t)),t=n.querySelector("video, img"),t instanceof HTMLImageElement&&(t.classList.add("thumbnail"),p||(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=""),p&&this.setFullAspect(p,h,l),setTimeout((()=>{n.style.borderRadius="",n.firstElementChild&&(n.firstElementChild.style.borderRadius="")}),0),n.dataset.timeout=""+setTimeout((()=>{n.classList.remove("moving","opening"),p&&(n.querySelector("video"),n.classList.remove("active"),p.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),E}))}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 f;f=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",f),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(e,t,i,s,a,r=!1,c=[],h=[],u){return $(this,void 0,void 0,(function*(){if(this.setMoverPromise)return this.setMoverPromise;const f=this.setAuthorInfo(i,t),p="document"===e._,m=p&&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 g=this.content.media,v=!a||a===g;v&&(a=g),this.target={element:a};const b=++this.tempId;g.firstElementChild&&(g.innerHTML=""),0!==s?(this.moveTheMover(this.content.mover,1===s),this.setNewMover()):(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),o.IS_MOBILE_SAFARI||(this.navigationItem={type:"media",onPop:e=>{if(this.setMoverAnimationPromise)return!1;this.close()}},T.Z.pushItem(this.navigationItem)));const y=this.content.mover,w=N.Z.width;let S=0;const L=N.Z.height;L<1e6&&!n.Z.isMobile&&(S=120);const E=L-120-S;let I=Promise.resolve();const M=(0,j.Z)(e,g,w,E,!n.Z.isMobile,void 0,!!(p&&e.w&&e.h)).photoSize;if(v){const t=yield this.managers.thumbsStorage.getCacheContext(e,M.type);let i;if(t.downloaded)i=new Image,i.src=t.url;else{const s=(0,z.Z)(e,t,!0);s&&(I=s.loadPromise,i=s.image)}i&&(i.classList.add("thumbnail"),g.append(i))}const P=!(!p||!e.supportsStreaming),Z=P?this.preloaderStreamable:this.preloader,k=()=>this.managers.thumbsStorage.getCacheContext(e,null==M?void 0:M.type);let x;if(m){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=y.firstElementChild&&y.firstElementChild.classList.contains("media-viewer-aspecter")?y.firstElementChild:y,r=y.querySelector("video");r&&r.remove(),i.setAttribute("playsinline","true"),i.addEventListener("timeupdate",(()=>{this.tempId!==b&&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),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===b&&((this.videoPlayer=new C({video:i,play:!0,streamable:P,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(P){s.then((()=>{i.readyState<i.HAVE_FUTURE_DATA&&Z.attach(y,!0)}));const e=()=>{i.addEventListener("canplay",(()=>{Z.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(),Z.attach(y,!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:()=>$(this,void 0,void 0,(function*(){const o=P?Promise.resolve():K.Z.downloadMediaURL({media:e});return P||s.then((()=>$(this,void 0,void 0,(function*(){(yield k()).url||Z.attach(y,!0,o)})))),Promise.all([o,s]).then((()=>$(this,void 0,void 0,(function*(){if(this.tempId!==b)return void this.log.warn("media viewer changed video");const e=(yield k()).url;i.addEventListener("error",(()=>{4!==i.error.code&&this.log.error("Error "+i.error.code+"; details: "+i.error.message),Z&&Z.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()})))),o}))})}));x=I.then(n)}else{const t=()=>this.setMoverToTarget(a,!1,s).then((({onAnimationEnd:t})=>{this.lazyLoadQueue.unshift({load:()=>$(this,void 0,void 0,(function*(){const i=p?K.Z.downloadMediaURL({media:e}):K.Z.downloadMediaURL({media:e,thumb:M});return t.then((()=>$(this,void 0,void 0,(function*(){(yield k()).url||this.preloader.attachPromise(i)})))),Promise.all([t,i]).then((()=>$(this,void 0,void 0,(function*(){var e;if(this.tempId!==b)return void this.log.warn("media viewer changed photo");const t=(yield k()).url;if(a instanceof SVGSVGElement){if(this.updateMediaSource(a,t,"img"),this.updateMediaSource(y,t,"img"),n.Z.isMobile){const e=y.querySelectorAll("img");e&&e.length&&e.forEach((e=>{e.classList.remove("thumbnail")}))}}else{const i=y.firstElementChild&&y.firstElementChild.classList.contains("media-viewer-aspecter")?y.firstElementChild:y,s="IMG"===(null===(e=i.firstElementChild)||void 0===e?void 0:e.tagName)?i.firstElementChild:null;if(!s||s.src!==t){const e=new Image;e.classList.add("thumbnail"),(0,A.ZP)(e,t,(()=>{this.updateMediaSource(a,t,"img"),s&&(0,R.T2)((()=>{s.remove()})),i.append(e)}))}}})))).catch((e=>{this.log.error(e),this.preloader.attach(y),this.preloader.setManual()})),i}))})}));x=I.then(t)}return this.setMoverPromise=x.catch((()=>{this.setMoverAnimationPromise=null})).finally((()=>{this.setMoverPromise=null}))}))}}},9818:(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.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(9893),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.innerHTML="")}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:()=>fe});var s=i(9893),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),f=i(2325),p=i(8497),m=i(3624),g=i(2894),v=i(4668),b=i(4332),y=i(4755),w=i(4846),S=i(4484),C=i(467),L=i(5432),E=i(1154),I=i(241),M=i(6272),P=i(3003),Z=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(7030),j=i(2498),G=i(1336),V=i(3785),K=i(2342),W=i(2491),$=i(4776),q=i(5671),Q=i(1604),Y=i(7530),J=i(6566),X=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=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{constructor(e,t,i){this.attachTo=e,this.searchSuper=t,this.listenerSetter=i,this.onGotoClick=()=>{w.Z.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):new Z.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):new k.Z(this.peerId,[this.mid],"chat")},this.managers=t.managers;L.Z||(0,ie.E)(e,(e=>{let i;this.init&&(this.init(),this.init=null);try{i=(0,p.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),(()=>{he(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),yield Promise.all(this.buttons.map((e=>he(this,void 0,void 0,(function*(){let t;t=!(this.isSelected&&!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")}))}))})()}}),i)}init(){this.buttons=[{icon:"forward",text:"Forward",onClick:this.onForwardClick,verify:()=>he(this,void 0,void 0,(function*(){return this.managers.appMessagesManager.canForward(yield this.managers.appMessagesManager.getMessageByPeer(this.peerId,this.mid))}))},{icon:"forward",text:"Message.Context.Selection.Forward",onClick:this.onForwardClick,verify:()=>this.isSelected&&!this.searchSuper.selection.selectionForwardBtn.classList.contains("hide"),withSelection:!0},{icon:"message",text:"Message.Context.Goto",onClick:this.onGotoClick,withSelection:!0},{icon:"select",text:"Message.Context.Select",onClick:this.onSelectClick},{icon:"select",text:"Message.Context.Selection.Clear",onClick:this.onClearSelectionClick,verify:()=>this.isSelected,withSelection:!0},{icon:"delete danger",text:"Delete",onClick:this.onDeleteClick,verify:()=>he(this,void 0,void 0,(function*(){return this.managers.appMessagesManager.canDeleteMessage(yield this.managers.appMessagesManager.getMessageByPeer(this.peerId,this.mid))}))},{icon:"delete danger",text:"Message.Context.Selection.Delete",onClick:this.onDeleteClick,verify:()=>this.isSelected&&!this.searchSuper.selection.selectionDeleteBtn.classList.contains("hide"),withSelection:!0}],this.element=(0,P.Z)(this.buttons),this.element.classList.add("search-contextmenu","contextmenu"),document.getElementById("page-chats").append(this.element)}}class fe{constructor(e){this.tabs={},this.prevTabId=-1,this.lazyLoadQueue=new d.Z,this.middleware=(0,m.k)(),this.historyStorage={},this.usedFromHistory={},this.urlsToRevoke=[],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 ue(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,f.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)=>{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))}}));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,p.Z)(e.target,"search-super-item")))}),{capture:!0,passive:!1,listenerSetter:this.listenerSetter});const l=(e,t,i,s)=>he(this,void 0,void 0,(function*(){const n=(0,p.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.dataset.peerId.toPeerId(),r=Array.from(this.tabs[i].querySelectorAll("."+t)).map((t=>{const i=(0,p.Z)(t,e);return{element:t,mid:+i.dataset.mid,peerId:i.dataset.peerId.toPeerId()}})),d=r.findIndex((e=>e.mid===a&&e.peerId===o)),l=yield this.managers.appMessagesManager.getMessageByPeer(o,a);(new D.Z).setSearchContext(this.copySearchContext(i)).openMedia(l,r[d].element,0,!1,r.slice(0,d),r.slice(d+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,J.Z)(t,e,e.length)}processEmptyFilter({message:e,searchGroup:t}){const i=[],{dom: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,dom:n,highlightWord:this.searchContext.query});return i.push(a),Promise.all(i).then(ce.Z)}processPhotoVideoFilter({message:e,promises:t,middleware:i}){return he(this,void 0,void 0,(function*(){const s=(0,Y.Z)(e),n=document.createElement("div");let a;n.classList.add("grid-item");const o=(0,z.Z)(s,200,200);return 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}),[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 he(this,void 0,void 0,(function*(){const i=(0,Y.Z)(e),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});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 he(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)}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,Q.Z)(e),subtitle:r,havePadding:!0,clickable:!0,noRipple:!0});if(l.applyMediaElement(a,"big"),l.container.innerText.trim().length)return{message:e,element:l.container}}))}performSearchResult(e,t,i=!0){return he(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=>he(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.filter(Boolean))}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:e.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})=>he(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,X.Z)(t.toChatId()))}else if(t===a.Z.myId)e.lastMessageSpan.append((0,f.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,M.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 f.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.appMessagesManager.getConversations(i,0,20,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.innerHTML="",i.recentSearch.slice(0,20).forEach((e=>he(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,X.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.length&&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.setActive()})),e()])}}loadMembers(e){return he(this,void 0,void 0,(function*(){const t=this.searchContext.peerId.toChatId(),i=this.middleware.get();let n;const a=t=>he(this,void 0,void 0,(function*(){if(!this.loadMutex||(yield this.loadMutex,i())){this.membersList||(this.membersList=new g.Z({lazyLoadQueue:this.lazyLoadQueue,rippleEnabled:!1,managers:this.managers}),(0,F.fc)(this.membersList.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.Z.setInnerPeer({peerId:i})}))})),e.contentTab.append(this.membersList.list),this.afterPerforming(1,e.contentTab));for(const e of t){const t=(0,te.Z)(e);t.isAnyChat()||((yield this.managers.appUsersManager.getUser(t)).pFlags.deleted||this.membersList.add(t))}}}));if(yield this.managers.appChatsManager.isChannel(t)){const s=this.membersList?200:50;n=this.managers.appProfileManager.getChannelParticipants(t,void 0,s,this.nextRates[e.inputFilter]).then((t=>{if(!i())return;const n=e.contentTab.firstElementChild;return this.nextRates[e.inputFilter]=(n?n.childElementCount:0)+t.participants.length,t.participants.length<s&&(this.loaded[e.inputFilter]=!0),a(t.participants)}))}else n=this.managers.appProfileManager.getChatFull(t).then((t=>{if(!i())return;this.loaded[e.inputFilter]=!0;const s=t.participants;return"chatParticipantsForbidden"!==s._?a(s.participants):void 0}));return this.loadPromises[e.inputFilter]=n.finally((()=>{i()&&(this.loadPromises[e.inputFilter]=null)}))}))}loadType(e,t,i,s){var n;const a=e.inputFilter;if(this.loadPromises[a])return this.loadPromises[a];if("members"===e.type)return this.loadMembers(e);const o=null!==(n=this.historyStorage[a])&&void 0!==n?n:this.historyStorage[a]=[];if(!("inputMessagesFilterEmpty"!==a||o.length||(this.loadedChats||(this.loadChats(),this.loadedChats=!0),this.searchContext.query.trim()||this.searchContext.peerId||this.searchContext.minDate)))return this.loaded[a]=!0,Promise.resolve();const r=this.loadPromises[a]=Promise.resolve().then((()=>he(this,void 0,void 0,(function*(){var n,d;if(o.length&&this.usedFromHistory[a]<o.length&&!t){const t=[];let s=Math.max(0,this.usedFromHistory[a]),n=0;do{const e=o.slice(s,s+i);s+=e.length,n+=e.length;const r=yield Promise.all(e.map((e=>this.managers.appMessagesManager.getMessageByPeer(e.peerId,e.mid))));t.push(...this.filterMessagesByType(r,a))}while(n<i&&s<o.length);return this.usedFromHistory[a]=s,this.performSearchResult(t,e).finally((()=>{setTimeout((()=>{this.scrollable.checkForTriggers()}),0)}))}const l=o.length?o[o.length-1].mid:0,c=yield this.managers.appMessagesManager.getSearch(Object.assign(Object.assign({},this.searchContext),{inputFilter:{_:a},maxId:l,limit:i,nextRate:null!==(n=(d=this.nextRates)[a])&&void 0!==n?n:d[a]=0}));if(o.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[a]=!0),this.nextRates[a]=c.next_rate,!t))return this.usedFromHistory[a]=o.length,this.loaded[a]||r.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,a),e)})))).catch((e=>{this.log.error("load error:",e)})).finally((()=>{this.loadPromises[a]=null}));return r}canLoadMediaTab(e){const t=e.inputFilter;return!this.loaded[t]||this.historyStorage[t]&&this.usedFromHistory[t]<this.historyStorage[t].length}loadFirstTime(){return he(this,void 0,void 0,(function*(){const e=this.middleware.get(),t=this.searchContext.peerId;if(!this.hideEmptyTabs)return;const i=this.mediaTabs.filter((e=>"inputMessagesFilterEmpty"!==e.inputFilter)),s=i.map((e=>({_:e.inputFilter}))),[n,a]=yield Promise.all([this.managers.appMessagesManager.getSearchCounters(t,s),this.canViewMembers()]);if(!e())return;if(this.loadMutex&&(yield this.loadMutex,!e()))return;let o,r=0;i.forEach((e=>{const t=n.find((t=>t.filter._===e.inputFilter));e.menuTab.classList.toggle("hide",!t.count),e.menuTab.classList.remove("active"),t.count&&(void 0===o&&(o=e),++r)}));const d=this.mediaTabsMap.get("members");d.menuTab.classList.toggle("hide",!a),a&&(o=d),this.container.classList.toggle("hide",!o),this.container.parentElement.classList.toggle("search-empty",!o),o&&(this.skipScroll=!0,this.selectTab(this.mediaTabs.indexOf(o),!1),this.navScrollableContainer.classList.toggle("hide",r<=1))}))}load(e=!1,t=!1){var i;return he(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)),!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 f.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(){return Promise.all([this.searchContext.peerId.isAnyChat(),this.managers.appChatsManager.isBroadcast(this.searchContext.peerId.toChatId()),this.managers.appChatsManager.hasRights(this.searchContext.peerId.toChatId(),"view_participants")]).then((([e,t,i])=>e&&!t&&i))}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.urlsToRevoke.length&&(this.urlsToRevoke.forEach((e=>{URL.revokeObjectURL(e)})),this.urlsToRevoke.length=0),this.mediaTabs.forEach((e=>{if(e.contentTab.innerHTML="",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.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:()=>x});var s=i(9893),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),f=i(5565),p=i(5701),m=i(241),g=i(2464),v=i(2738),b=i(6690),y=i(1655),w=i(5953),S=i(4064),C=i(9331),L=i(2353),E=i(2566),I=i(177),M=i(3061),P=i(8493),Z=i(7120),k=i(8050),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())}))};class x{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=null),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=null,this.loadedWhat={},this.query=e,this.renderedPeerIds.clear(),this.needSwitchList=!0,this.getMoreResults()}},this.checkForTriggers=()=>{this.scrollable.checkForTriggers()},(0,w.Z)(this,e),this.container.classList.add("selector","selector-"+this.design);const t=(this.renderResultsFunc||this.renderResults).bind(this);if(this.renderResultsFunc=e=>T(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,L.Z)(e,(e=>T(this,void 0,void 0,(function*(){if(e.isPeerId()&&!(yield this.managers.appPeersManager.getPeer(e)).deleted)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 g.dw({});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,v.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,v.tH)(s):this.remove(i.toPeerId())})),e.content.append(t),this.container.append(e.container)}this.chatsContainer.classList.add("chatlist-container");const i=new g.dw({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,v.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,p.Z)(this.onInput,200,!1,!0);this.input.addEventListener("input",n),this.scrollable.onScrolledBottom=()=>{this.getMoreResults()},this.scrollable.container.prepend((0,g.G7)()),this.container.append(this.chatsContainer),this.appendTo.append(this.container),setTimeout((()=>{const t=this.getMoreResults();e.onFirstRender&&t.then((()=>{e.onFirstRender()}))}),0)}renderSaved(){return T(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){return void 0===this.tempIds[e]&&(this.tempIds[e]=0),++this.tempIds[e]}getMoreDialogs(){return T(this,void 0,void 0,(function*(){if(this.promise)return this.promise;if(this.loadedWhat.dialogs&&this.loadedWhat.archived)return;const e=m.Z.height/56*1.25|0,t=this.getTempId("dialogs"),i=this.managers.appMessagesManager.getConversations(this.query,this.offsetIndex,e,this.folderId,!0);this.promise=i;const s=yield i;if(this.tempIds.dialogs!==t)return;this.promise=null;let a=s.dialogs;if(a.length){const e=(0,k.Z)(a[a.length-1])||0;a=a.slice(),(0,S.Z)(a,(e=>e.peerId===n.Z.myId)),this.chatRightsAction&&(a=yield(0,L.Z)(a,(e=>this.filterByRights(e.peerId)))),yield this.renderSaved(),this.offsetIndex=e}if(this.renderResultsFunc(a.map((e=>e.peerId))),s.isEnd){if(!this.loadedWhat.dialogs)return yield this.renderSaved(),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 T(this,void 0,void 0,(function*(){const t=yield this.managers.appPeersManager.getPeer(e);return e.isUser()?"send_messages"!==this.chatRightsAction||(0,P.Z)(t):!!(0,Z.Z)(t,this.chatRightsAction)||void 0}))}getMoreContacts(){return T(this,void 0,void 0,(function*(){if(this.promise)return this.promise;if(this.loadedWhat.contacts)return;const e=this.peerType.includes("contacts");if(!this.cachedContacts){const t=this.getTempId("contacts"),i=Promise.all([e?this.managers.appUsersManager.getContactsPeerIds(this.query):[],this.query?this.managers.appUsersManager.searchContacts(this.query):void 0]);this.promise=i;const[s,a]=yield i;if(this.tempIds.contacts!==t)return;if(a){let t=e?a.my_results.concat(a.results):a.my_results;this.chatRightsAction&&(t=yield(0,L.Z)(t,(e=>this.filterByRights(e)))),this.peerType.includes("dialogs")||(t=t.filter((e=>e.isUser()))),this.cachedContacts=(0,b.Z)(s.concat(t))}else this.cachedContacts=s.slice();(0,y.Z)(this.cachedContacts,n.Z.myId),this.promise=null}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(){return T(this,void 0,void 0,(function*(){if(this.promise)return this.promise;if(this.loadedWhat.channelParticipants)return;const e=this.getTempId("channelParticipants"),t=this.managers.appProfileManager.getChannelParticipants(this.peerId.toChatId(),{_:"channelParticipantsSearch",q:this.query},50,this.list.childElementCount),i=yield t;if(this.tempIds.channelParticipants!==e)return;const s=i.participants.map((e=>(0,E.Z)(e)));(0,y.Z)(s,n.Z.myId),this.renderResultsFunc(s),(this.list.childElementCount>=i.count||i.participants.length<50)&&(this.loadedWhat.channelParticipants=!0)}))}getMoreResults(){const e=(()=>{const e=[];return!this.peerType.includes("dialogs")||this.loadedWhat.archived||(e.push(this.getMoreDialogs()),this.loadedWhat.archived)?(!this.peerType.includes("contacts")&&!this.peerType.includes("dialogs")||this.loadedWhat.contacts||e.push(this.getMoreContacts()),this.peerType.includes("channelParticipants")&&!this.loadedWhat.channelParticipants&&e.push(this.getMoreChannelParticipants()),e):e})(),t=Promise.all(e);return e.length&&t.then(this.checkForTriggers),t}renderResults(e){return T(this,void 0,void 0,(function*(){!this.peerType.includes("dialogs")&&this.loadedWhat.contacts&&(e=yield(0,L.Z)(e,(e=>this.managers.appUsersManager.isNonContactUser(e)))),e.forEach((e=>T(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,I.Z)(e.toChatId()):e===n.Z.myId?(0,d.ag)(this.selfPresence):(0,M.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 C.Z;return a.classList.add("selector-user-avatar","tgico","avatar-32"),a.isDialog=!0,n.dataset.key=""+e,e.isPeerId()&&(void 0===t&&(t=new h.Z({peerId:e.toPeerId(),dialog:!0}).element),a.updateWithOptions({peerId:e})),t&&("string"==typeof t?n.innerHTML=t:((0,f.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)};n.Z.settings.animationsEnabled?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:()=>F,ns:()=>_});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),f=i(8497),p=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),M=i(5671),P=i(1604),Z=i(7530),k=i(2312),T=i(9492),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())}))};function A(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 _=(e,t)=>{let i,s;const n=!e.classList.contains("search-super-item"),a=(0,f.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 F 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 x(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,Z.Z)(this.message),h="voice"===s.type,f=!this.voiceAsMusic&&h,F=this.message.pFlags.is_outgoing,D=null===(e=this.message)||void 0===e?void 0:e.uploadingFileName,R=(0,C.Z)(0|s.duration);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 B=this.firstElementChild,N=document.createElement("div");N.classList.add("audio-download"),"audio"!==s.type&&this.message&&this.message.pFlags.media_unread&&this.classList.add("is-unread"),D&&(this.classList.add("is-outgoing"),this.append(N));const O=yield f?function(e){return x(this,void 0,void 0,(function*(){e.classList.add("is-voice");const t=e.message,i=(0,Z.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=document.createElementNS("http://www.w3.org/2000/svg","svg");r.classList.add("audio-waveform-bars"),r.setAttributeNS(null,"width",""+o),r.setAttributeNS(null,"height",""+i),r.setAttributeNS(null,"viewBox",`0 0 ${o} ${i}`);const d=Math.max(...e),l=e.length?e.length:100,c=Math.min(o/4|0,l);let h=0;const u=i-4;let f="";for(let t=0,s=0,n=0;t<l;++t){const a=e[t]||0;if(n+c>=l){n=n+c-l,n<(c+1)/2&&h<a&&(h=a);const e=Math.max((h*u+(d+1)/2)/(d+1),4);f+=`\n <rect x="${s}" y="${i-e}" width="2" height="${e}" rx="1" ry="1"></rect>\n `,s+=4,h=n<(c+1)/2?0:a}else h<a&&(h=a),n+=c}const p=document.createElement("div");return p.classList.add("audio-waveform"),p.append(r),r.insertAdjacentHTML("beforeend",f),{svg:r,container:p,availW:o}}(s,i.duration),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"),h.append(o,c);const f=document.createElement("div");f.classList.add("audio-time"),e.append(h,f);let p=n;return()=>{let t=e.audio;const i=()=>{c.style.width=t.currentTime/t.duration*100+"%"};(!t.paused||t.currentTime>0&&t.currentTime!==t.duration)&&i();const s=(0,v.Z)(i);return e.addAudioListener("timeupdate",s),e.addAudioListener("ended",s),e.addAudioListener("play",(()=>{(0,w.cK)((()=>!!t&&(i(),!t.paused)),e)})),e.readyPromise.then((()=>{let e=!1,i=!1;function s(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}p.addEventListener("mouseleave",(s=>{e&&(t.play(),e=!1),i=!1})),p.addEventListener("mousemove",(t=>{i=!0,e&&s(t)})),p.addEventListener("mousedown",(i=>{i.preventDefault(),0===i.button&&(t.paused||t.pause(),s(i),e=!0)})),p.addEventListener("mouseup",(s=>{i&&e&&(t.play(),e=!1)})),(0,l.fc)(p,(e=>{(0,d.Z)(e),t.paused||s(e)}))}),u.Z),()=>{p.remove(),p=null,t=null}}}))}(this):function(e){var t;return x(this,void 0,void 0,(function*(){const i=e.withTime,s=e.message,n=(0,Z.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,M.Z)(s)),o.append(...(0,p.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,a?l.append(yield(0,M.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,P.Z)(s));const c=e.querySelector(".audio-subtitle");return c.append(o),()=>{let t=!1,i=new L.Z(e.audio,n.supportsStreaming);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),U=this.querySelector(".audio-time");U.innerHTML=R;const H=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=O();const s=()=>(0,C.Z)(0|t.currentTime)+(f?" / "+R:""),a=()=>{U.innerText=s(),B.classList.toggle("playing",!t.paused)};(!t.paused||t.currentTime>0&&t.currentTime!==t.duration)&&a();const o=(e,i=t.paused)=>{if(e&&(0,d.Z)(e),i){const e=!!this.searchContext;if(n.Z.setSearchContext(this.searchContext||{peerId:b.NM,inputFilter:{_:"inputMessagesFilterEmpty"},useSearch:!1})){const[t,i]=e?_(this,this.message.mid):[];n.Z.setTargets({peerId:this.message.peerId,mid:this.message.mid},t,i)}t.play().catch((()=>{}))}else t.pause()};return(0,l.fc)(B,(e=>o(e)),{listenerSetter:this.listenerSetter}),this.addAudioListener("ended",(()=>{B.classList.remove("playing"),U.innerText=R})),this.addAudioListener("timeupdate",(()=>{!t.currentTime&&t.paused||n.Z.isSafariBuffering(t)||(U.innerText=s())})),this.addAudioListener("pause",(()=>{B.classList.remove("playing")})),this.addAudioListener("play",a),o};if(null===(t=s.thumbs)||void 0===t?void 0:t.length){const e=[],t=yield(0,T.Z)({photo:s,message:null,container:B,boxWidth:48,boxHeight:48,loadPromises:this.loadPromises,withoutPreloader:!0,lazyLoadQueue:this.lazyLoadQueue});B.style.width=B.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(F)D&&(this.preloader=A(!1),this.preloader.attachPromise(k.Z.getUpload(D)),this.dataset.isOutgoing="1",this.preloader.attach(N,!1));else{let e=this.preloader;const t="audio"!==s.type;H(t);const a=t=>{if(this.audio.src)return;n.Z.resolveWaitingForLoadMedia(this.message.peerId,this.message.mid,this.message.pFlags.is_scheduled);const i=()=>{t&&(n.Z.willBePlayed(this.audio),o.IS_SAFARI&&!this.audio.autoplay&&(this.audio.autoplay=!0))};if(i(),!e)if(s.supportsStreaming){let e;this.classList.add("corner-download");const t=()=>{const t=A(!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)},t.attach(N,!1,s),e=this.addAudioListener("pause",(()=>{s.cancel()}),{once:!0}),i()},s=this.addAudioListener("play",t);this.readyPromise.then((()=>{this.listenerSetter.remove(s),this.listenerSetter.remove(e)}))}else{e=A(),t||(this.readyPromise=(0,c.Z)());const n=()=>{i();const n=k.Z.downloadMediaURL({media:s});return t||n.then((()=>{this.readyPromise.resolve()})),e.attach(N,!1,n),{download:n}};e.setDownloadFunction(n),n()}this.classList.contains("corner-download")?B.append(N):this.append(N),this.classList.add("downloading"),this.readyPromise.then((()=>{this.classList.remove("downloading"),N.classList.add("downloaded"),setTimeout((()=>{N.remove()}),200),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)(B,(()=>{a(!0)}),{once:!0,capture:!0,passive:!1,listenerSetter:this.listenerSetter}))}}))}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",F)},9331:(e,t,i)=>{"use strict";i.d(t,{Z:()=>S,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(4846),h=i(5824),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())}))};class f extends h.Z{constructor(e){super(new d({peerId:e,managers:s.Z.managers}),[]),this.onPrevClick=e=>{this.openMedia(e.photoId,e.element,-1)},this.onNextClick=e=>{this.openMedia(e.photoId,e.element,1)},this.onDownloadClick=()=>u(this,void 0,void 0,(function*(){l.Z.downloadToDisc({media:yield this.managers.appPhotosManager.getPhoto(this.target.photoId),queueId:c.Z.chat.bubbles.lazyLoadQueue.queueId})})),this.peerId=e,this.setBtnMenuToggle([{icon:"download",text:"MediaViewer.Context.Download",onClick:this.onDownloadClick}]),this.setListeners()}openMedia(e,t,i=0,s,n){const a=Object.create(null,{_openMedia:{get:()=>super._openMedia}});return u(this,void 0,void 0,(function*(){if(this.setMoverPromise)return this.setMoverPromise;const o=yield this.managers.appPhotosManager.getPhoto(e),r=a._openMedia.call(this,o,o.date,this.peerId,i,t,!1,s,n);return this.target.photoId=o.id,r}))}}var p=i(5880),m=i(9931),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=e=>{Array.from(document.querySelectorAll('avatar-element[data-peer-id="'+e+'"]')).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(n,l(),void 0,void 0,a?i(a):void 0,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 f(t).openMedia(d.id,l(),void 0,a?e(a):void 0,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))||v(e)}))));const y=new Map,w=new Set;class S extends HTMLElement{constructor(){super(...arguments),this.addedToQueue=!1}disconnectedCallback(){var e;const t=y.get(this.peerId);t&&t.has(this)&&(t.delete(this),t.size||y.delete(this.peerId)),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){const t=this.peerId;this.updateOptions(e);const i=this.peerId;if(t!==i){if(this.peerId=i,this.dataset.peerId=""+i,t){const e=y.get(t);e&&(e.delete(this),e.size||y.delete(t))}return this.update()}}r(e=!1){const t=(0,m.Z)(this,this.peerId,this.isDialog,this.peerTitle,e,this.isBig);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;let e=y.get(this.peerId);return e||(e=new Set,y.set(this.peerId,e)),e.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=y.get(this.peerId);if(t){t.delete(this);const e=Array.from(t);y.delete(this.peerId);for(let t=0,i=e.length;t<i;++t)e[t].update()}return e}}customElements.define("avatar-element",S)},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){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).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);const a=(e,t={})=>{const i=document.createElement(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)),i}},8119:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(4494);const n=(e={})=>(0,s.Z)("btn-circle btn-corner z-depth-1"+(e.className?" "+e.className:""),e)},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:()=>l});var s=i(3416),n=i(3910),a=i(2738),o=i(8497),r=i(2325);const d=e=>{if(e.element)return e.element;const{icon:t,text:i,onClick:d,checkboxField:l,noCheckboxClickListener:c}=e,h=document.createElement("div");h.className="btn-menu-item rp-overflow"+(t?" tgico-"+t:"");let u=e.textElement;u||(u=e.textElement=i?(0,r.ag)(i,e.textArgs):document.createElement("span"),e.regularText&&(u.innerHTML=e.regularText)),u.classList.add("btn-menu-item-text"),h.append(u);const f=!!l||!!e.keepOpen;return d&&(0,a.fc)(h,(e=>{(0,n.Z)(e);const t=(0,o.Z)(e.target,"btn-menu");t&&!t.classList.contains("active")||!1!==d(e)&&(f||s.Z.close(),l&&!c&&(l.checked="radio"===l.input.type||!l.checked))}),e.options),l&&h.append(l.label),e.element=h},l=(e,t)=>{const i=document.createElement("div");i.classList.add("btn-menu"),t&&e.forEach((e=>{e.options?e.options.listenerSetter=t:e.options={listenerSetter:t}}));const s=e.map(d);return i.append(...s),i}},5322:(e,t,i)=>{"use strict";i.d(t,{Z:()=>l,v:()=>d});var s=i(3416),n=i(3910),a=i(2738),o=i(2230),r=i(3003);const d=(e,t,i,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"))return!1;const a=e.querySelector(".btn-menu");if((0,n.Z)(i),e.classList.contains("menu-open"))s.Z.close();else{const e=t&&t(i),n=()=>{s.Z.openBtnMenu(a,o)};e instanceof Promise?e.then(n):n()}}))},l=(e={},t,i,s,n)=>{var a;e.asDiv=!0;const l=null!==(a=e.container)&&void 0!==a?a:(0,o.Z)("more",e);l.classList.add("btn-menu-toggle");const c=(0,r.Z)(i,e.listenerSetter);return c.classList.add(t),d(l,s,e,n),l.append(c),l}},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 f=0,p=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,f+=n,p+=n*this._colors[t].r/255,m+=n*this._colors[t].g/255,g+=n*this._colors[t].b/255}i[s++]=p/f*255,i[s++]=m/f*255,i[s++]=g/f*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}}}},6054:(e,t,i)=>{"use strict";i.d(t,{e:()=>T,Z:()=>x});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(9818),u=i(4762),f=i(2325),p=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),M=(i(6690),i(4846)),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 Z=e=>[...e.values()].reduce(((e,t)=>e+t.size),0);class k extends L.Z{constructor(e){super(!1),this.selectedMids=new Map,this.isSelecting=!1,this.onMouseDown=e=>{const t=(0,p.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=Z(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,p.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=>P(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)(e,(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)}),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)(e,"is-selected",!1,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 P(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=`${e}_${this.isScheduled?"scheduled":"history"}`,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)}))}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)(e,"is-selected",t,200)}isMidSelected(e,t){const i=this.selectedMids.get(e);return null==i?void 0:i.has(t)}length(){return Z(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 T extends k{constructor(e,t,i){super({managers:t,verifyTarget:(e,t)=>!!t&&this.isSelecting,getElementFromTarget:e=>(0,p.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,f.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)(this.searchSuper.navScrollableContainer,"is-selecting",e,t?200:0,(()=>{this.isSelecting||(this.selectionContainer.remove(),this.selectionContainer=this.selectionForwardBtn=this.selectionDeleteBtn=null,this.selectedText=void 0)})),(0,l.Z)(this.searchSuper.container,"is-selecting",e,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(),M.Z.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));new 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];new 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 x extends k{constructor(e,t,i,s){super({managers:s,getElementFromTarget:e=>(0,p.Z)(e,"grouped-item")||(0,p.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,p.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)=>P(this,void 0,void 0,(function*(){const e=yield this.bubbles.getMountedBubble(t);e&&this.toggleByElement(e.bubble)})),this.onToggleSelection=(e,t)=>P(this,void 0,void 0,(function*(){const{needTranslateX:i,widthFrom:s,widthTo:o}=yield this.chat.input.center(t);(0,l.Z)(this.listenElement,"is-selecting",e,t?200:0,(()=>{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,f.ag)("MessageScheduleSend")),(0,S.fc)(this.selectionSendNowBtn,(()=>{new 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,f.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));new 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,f.ag)("Delete")),(0,S.fc)(this.selectionDeleteBtn,(()=>{new 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="",i.style.transform="",s.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,f.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=()=>P(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"))}}},9807:(e,t,i)=>{"use strict";i.d(t,{Z:()=>d});var s=i(1405),n=i(2325),a=i(9750),o=i(3512),r=i(3855);class d{constructor(e={}){const t=this.label=document.createElement("label");t.classList.add("checkbox-field"),e.restriction&&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="checkbox",e.name&&(i.id="input-"+e.name),e.checked&&(i.checked=!0),e.stateKey){let t=!1;const s=()=>{if(!t)return;let s;s=e.stateValues?e.stateValues[i.checked?1:0]:i.checked,o.Z.managers.appStateManager.setByKey(e.stateKey,s)};r.Z.getState().then((i=>{t=!0;const s=(0,a.Z)(i,e.stateKey);let n;n=e.stateValues?1===e.stateValues.indexOf(s):s,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");const e=document.createElement("div");e.classList.add("checkbox-toggle"),t.append(e)}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);const t=new Event("change",{bubbles:!0,cancelable:!0});this.input.dispatchEvent(t)}setValueSilently(e){this.input.checked=e}toggleDisability(e){return this.label.classList.toggle("checkbox-disabled",e),()=>this.toggleDisability(!e)}}},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({plainText:!0},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=e=>{t(e?!!e.size:void 0)};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]),new n.Z("popup-confirmation",e).show()}))}},5431:(e,t,i)=>{"use strict";i.d(t,{Z:()=>w});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),f=i(3512),p=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(),f.Z.addEventListener("language_change",(()=>{b()}))};class w 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 f=document.createElement("ul");t.appendChild(f),new g.ZP(t);let m=()=>{m=null,v.forEach((t=>{const i=(0,p.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),f.append(r)}this.liMap.set(t.iso2,n)})),f.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=>{this.liMap.get(e.iso2).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",w,{capture:!0}),b=!0)}),0)}));let b=!1;const w=e=>{(0,a.Z)(e.target,"input-select")||e.target!==this.input&&(this.hidePicker(),document.removeEventListener("mousedown",w,{capture:!0}),b=!1)},S=e=>{const t=e.key;if(e.ctrlKey||"Control"===t)return!1;const i=this.value.toLowerCase(),s=[];v.forEach((e=>{const t=[e.name,e.default_name,e.iso2];t.filter(Boolean).forEach((e=>{const i=e.split(" ").filter((e=>/\w/.test(e))).map((e=>e[0])).join("");i.length>1&&t.push(i)}));const n=!!t.filter(Boolean).find((e=>-1!==e.toLowerCase().indexOf(i)));this.liMap.get(e.iso2).forEach((e=>e.style.display=n?"":"none")),n&&s.push(e)})),0===s.length?v.forEach((e=>{this.liMap.get(e.iso2).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",S),this.input.addEventListener("keydown",(e=>{"Enter"===e.key&&S(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)}}},2621:(e,t,i)=>{"use strict";i.d(t,{Z:()=>r});var s=i(187),n=i(8119),a=i(5953),o=i(1507);class r{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,a.Z)(this,e),this.peerId||(this.peerId=o.NM),this.nextBtn?this.nextBtn.classList.contains("btn-corner")||(this.handleChange=()=>{this.nextBtn.toggleAttribute("disabled",!this.isChanged()||this.disabled)}):this.nextBtn=(0,n.Z)({icon:"check"}),e.withoutAvatar||(this.avatarElem=document.createElement("avatar-element"),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()})),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:()=>Y,Jo:()=>X,ZP:()=>te});var s=i(5432),n=i(4846),a=i(3512),o=i(5814),r=i(6008),d=i(2153),l=i(4332),c=i(5117),h=i(6039),u=i(1080),f=i(8805),p=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,X.onMediaClick);const t=this.scrollable=new f.ZP(this.content,"GIFS"),i=new u.Z(e,Y,t),s=(0,p.y)(this.content,!0);this.managers.appDocsManager.getGifs().then((e=>{e.forEach((e=>{i.add(e)})),s.remove()})),te.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 M 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.Z.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.innerHTML="",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.innerHTML=""),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 P=i(6787),Z=i(2325),k=i(7625),T=i(130),x=i(8115),A=i(9259),_=i(3541);class F 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.Z.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,Z.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=>{new P.Z(e.set).show()}))}),{listenerSetter:this.listenerSetter}),l.ZP.toggleSidebar(!0).then((()=>{this.renderFeatured()}))}onCloseAfterTimeout(){return this.setsDiv.innerHTML="",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,Z.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,Z.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 D,R=i(4668),B=i(8799),N=i(2648),O=i(3910),U=i(6339),H=i(5418),z=i(4762),j=i(3815),G=i(319),V=i(4789),K=i(6802),W=i.n(K),$=i(669),q=i(3299),Q=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="emoticons-dropdown",J={forceDuration:200,transitionFunction:W()(.42,0,.58,1)};class X extends U.Z{constructor(){super({element:document.getElementById("emoji-dropdown"),ignoreOutClickClassName:"input-message-input"}),this.tabId=-1,this.onSelectTabClick=e=>{if(this.tabId!==e)o.Z.checkAnimations(!0,Y),this.tabId=e,this.searchButton.classList.toggle("hide",this.tabId===this.emojiTab.tabId),this.deleteBtn.classList.toggle("hide",this.tabId!==this.emojiTab.tabId);else{const{tab:e}=this;this.scrollTo(e,e.scrollable.container.firstElementChild)}},this.checkRights=()=>Q(this,void 0,void 0,(function*(){const{peerId:e,threadId:t}=n.Z.chat,i=this.tabsEl.children,s=Array.from(i),[a,o]=yield Promise.all([this.managers.appMessagesManager.canSendToPeer(e,t,"send_stickers"),this.managers.appMessagesManager.canSendToPeer(e,t,"send_gifs")]);s[this.stickersTab.tabId+1].toggleAttribute("disabled",!a),s[this.gifsTab.tabId+1].toggleAttribute("disabled",!o);const r=this.tabsEl.querySelector(".active");!r||(0,N.Z)(r)===this.emojiTab.tabId+1||a&&o||this.selectTab(this.emojiTab.tabId,!1)})),this.addEventListener("open",(()=>Q(this,void 0,void 0,(function*(){var e;s.Z&&(0,B.Z)()&&(yield(0,H.Z)(100)),this.element.parentElement!==n.Z.chat.input.chatInput&&n.Z.chat.input.chatInput.append(this.element),this.savedRange=this.getGoodRange(),X.lazyLoadQueue.lock(),o.Z.lockIntersectionGroup(Y);const t=this.tab;null===(e=t.onOpen)||void 0===e||e.call(t)})))),this.addEventListener("opened",(()=>{var e;o.Z.unlockIntersectionGroup(Y),X.lazyLoadQueue.unlockAndRefresh();const t=this.tab;null===(e=t.onOpened)||void 0===e||e.call(t)})),this.addEventListener("close",(()=>{var e;X.lazyLoadQueue.lock(),o.Z.lockIntersectionGroup(Y),o.Z.checkAnimations(!0,Y);const t=this.tab;null===(e=t.onClose)||void 0===e||e.call(t)})),this.addEventListener("closed",(()=>{var e;o.Z.unlockIntersectionGroup(Y),X.lazyLoadQueue.unlock(),X.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(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.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,Y)})),this.searchButton=this.element.querySelector(".emoji-tabs-search"),this.searchButton.addEventListener("click",(()=>{this.tabId===this.stickersTab.tabId?l.ZP.isTabExists(F)||l.ZP.createTab(F).open():l.ZP.isTabExists(M)||l.ZP.createTab(M).open()})),this.deleteBtn=this.element.querySelector(".emoji-tabs-delete"),(0,m.fc)(this.deleteBtn,(e=>{(0,O.Z)(e);const t=n.Z.chat.input.messageInput;let i=$.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,q.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.Z.chat.input.messageInputField.simulateInputEvent()}));const e=z.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};j.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.Z.addEventListener("peer_changing",(()=>{this.toggle(!1)})),n.Z.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"},J))}static sendDocId(e,t,i){return Q(this,void 0,void 0,(function*(){return(yield n.Z.chat.input.sendMessageWithDocument(e,void 0,t,i))?(ee.container&&(ee.forceClose=!0,ee.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.Z.chat.input.messageInput)return e.getRangeAt(0)}}D=X,X.lazyLoadQueue=new d.Z(1),X.menuOnClick=(e,t,i,s,n)=>{let a=-1;const o=(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:V.f.Static,position:"center",axis:"x"},J)))),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"},J))),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},J))})(e,i),n=e,!0};let r=!1;const d=new c.Z(i.container,((t,s)=>{if(r)return;if(Math.abs(a-i.container.scrollTop)<=1)return;a=-1;const n=e.getCategoryByContainer(s),d=(0,N.Z)(s);(t||!d&&!n.menuScroll)&&o(n)}));t.addEventListener("click",(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,N.Z)(s),d=e.getCategoryByMenuTab(s);o(d);let l=0,c=0;if(n>0||d.menuScroll){const e=d.elements.container;c=1,l=e.offsetTop+c}a=l,r=!0,i.scrollIntoViewNew(Object.assign({element:l?d.elements.container:i.container.firstElementChild,position:"start",axis:"y",getElementPosition:l?({elementPosition:e})=>e+c:void 0},J)).finally((()=>{o(d),r=!1}))}));const l=i.onAdditionalScroll?i.onAdditionalScroll.bind(i):G.Z;return i.onAdditionalScroll=()=>{e.content.parentElement.classList.toggle("scrolled-top",!i.scrollTop),l()},{stickyIntersector:d,setActive:o,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,o(t,!1)}}},X.onMediaClick=(e,t=!1,i)=>Q(void 0,void 0,void 0,(function*(){const s=(0,R.Z)(e.target,"DIV");if(!s)return!1;const n=s.dataset.docId;return!!n&&D.sendDocId(n,t,i)}));const ee=new X;b.GO.emoticonsDropdown=ee;const te=ee},6039:(e,t,i)=>{"use strict";i.d(t,{IA:()=>F,ZP:()=>H,xG:()=>D});var s=i(3173),n=i(3910),a=i(8497),o=i(3035),r=i(5418),d=i(4846),l=i(3512),c=i(671),h=i(279),u=i(8805),f=i(9976),p=i(5432),m=i(8799),g=i(3447),v=i(7746),b=i(8115),y=i(7197),w=i(4776),S=i(2738),C=i(6057),L=i(9405),E=i(2940),I=i(4755),M=i(1273),P=i(9259),Z=i(3699),k=i(4064),T=i(4484),x=i(6787),A=i(2796);const _=new Set;function F(e,t,i=!1,s=!1){var n;const a=document.createElement("span");let r;if(a.classList.add("super-emoji"),s&&!f.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.innerHTML="",a.append(e)}if("IMG"===(null===(n=a.firstElementChild)||void 0===n?void 0:n.tagName)){const e=a.firstElementChild,t=e.src;if(!_.has(t)){e.setAttribute("loading","lazy");const i=document.createElement("span");i.classList.add("emoji-placeholder"),l.Z.settings.animationsEnabled&&(e.style.opacity="0",i.style.opacity="1"),e.addEventListener("load",(()=>{(0,o.T2)((()=>{l.Z.settings.animationsEnabled&&(e.style.opacity="",i.style.opacity=""),a.classList.remove("empty"),_.add(t)}))}),{once:!0}),a.append(i)}}return t&&(i?t.prepend(a):t.appendChild(a)),a}function D(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 R="Emoji.Recent",B=[R,"recent"],N=["",""],O=[["Emoji.SmilesAndPeople","smile"],["Emoji.AnimalsAndNature","animals"],["Emoji.FoodAndDrink","eats"],["Emoji.TravelAndPlaces","car"],["Emoji.ActivityAndSport","sport"],["Emoji.Objects","lamp"],["Emoji.Flags","flag"],["Skin Tones",""]],U=(0,L.C)(42,42);class H extends C.pw{constructor(e){super(e,"super-emojis",(()=>U),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})=>{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((({element:t})=>{const i=t.firstElementChild;i.clear(),e.set(i.docId,new Set([i]))})),s.add(e,void 0,!0)}},this.onContentClick=e=>{(0,n.Z)(e);const{target:t}=e;if((0,a.Z)(t,"category-title")){const e=(0,a.Z)(t,"emoji-category"),i=this.categoriesMap.get(e);if(i.local)return;return void new x.Z({id:i.set.id,access_hash:i.set.access_hash},!0).show()}const i=D(t);if(i){if(i.docId&&!l.Z.premium&&this.peerId!==l.Z.myId){const e=document.createElement("a");return e.onclick=()=>{d.Z.openUsername({userName:"premiumbot"}),(0,A.PE)()},void(0,A.bC)({langPackKey:"CustomEmoji.PremiumAlert",langPackArguments:[e]})}d.Z.chat.input.onEmojiSelected(i,!1),p.Z&&(0,m.Z)()}}}init(){super.init(),this.content=document.getElementById("content-emoji");const e=this.content.previousElementSibling,t=this.menu=e.firstElementChild,i=this.menuScroll=new u.v7(e),n=this.scrollable=new u.ZP(this.content,"EMOJI"),a={root:s.ZP.getElement()};this.categoriesIntersector=new E.Z(this.onCategoryVisibility,a),this.menuOnClickResult=s.Jo.menuOnClick(this,t,n,i,void 0);const o=(0,h.y)(this.content,!0),f=new u.v7(void 0);f.container.classList.add("menu-horizontal-inner-scroll");const p=document.createElement("div");p.classList.add("menu-horizontal-inner"),p.append(f.container),function(){let e=new Map([[N,[]],[B,[]]]);for(const t in g.Z){const i=""+g.Z[t],s=O[+i[0]-1];if(!s)continue;let n=e.get(s);n||(n=[],e.set(s,n)),n[+i.slice(1)||0]=t}e.delete(O.pop()),O.unshift(N,B);const t=O.map((([e])=>e)),i=[...e.entries()].sort(((e,i)=>t.indexOf(e[0][0])-t.indexOf(i[0][0])));return e=new Map(i),e}().forEach(((e,[t,i])=>{const s=this.createLocalCategory(t,t,i,!i);s.elements.container.classList.remove("hide"),s.elements.items.classList.add(i?"is-local":"not-local"),e.forEach((e=>{const t=(0,c.zu)(e);this.addEmojiToCategory(s,{emoji:t},!0)}))})),Promise.all([(0,r.Z)(200),this.managers.appEmojiManager.getRecentEmojis("native"),this.managers.appEmojiManager.getRecentEmojis("custom"),this.managers.appEmojiManager.getCustomEmojis()]).then((([e,t,i,n])=>{o.remove();const a=this.categories["Emoji.Recent"],r=this.categories[""];[[a,t],[r,i]].forEach((([e,t])=>{e.limit=32,t.splice(32,t.length-32)}));for(const e of t)this.addEmojiToCategory(a,{emoji:e},!0);this.createRendererForCategory(r);for(const e of i)this.addEmojiToCategory(r,{emoji:"",docId:e},!0);r.elements.container.style.paddingTop=".5rem",O.forEach((([e])=>{const t=this.categories[e];this.toggleLocalCategory(t,!0),e!==R&&""!==e&&(t.menuScroll=f,f.container.append(t.elements.menuTab))})),this.resizeCategories(),a.elements.menuTab.after(p),n.sets.forEach((e=>{this.renderStickerSet(e)})),l.Z.addEventListener("premium_toggle",(()=>{this.toggleCustomCategory()})),l.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}))})));const c=e=>{for(const t in this.categories){const i=this.categories[t].elements.renderer;i&&(i.ignoreSettingDimensions=e,e||i.setDimensionsFromRect(void 0,!0))}};s.ZP.addEventListener("opened",(()=>{c(!1)})),s.ZP.addEventListener("close",(()=>{c(!0)})),l.Z.addEventListener("stickers_installed",(e=>{!this.categories[e.id]&&e.pFlags.emojis&&this.renderStickerSet(e,!0)})),l.Z.addEventListener("stickers_deleted",(e=>{const t=this.categories[e.id];if(this.deleteCategory(t)){const{renderer:e}=t.elements;e&&e.middlewareHelper.clean()}})),l.Z.addEventListener("emoji_recent",this.postponedEvent((e=>{const t=this.categories[e.docId?"":R],i=e.docId?t=>t.docId===e.docId:t=>t.emoji===e.emoji,s=(0,k.Z)(t.items,i);if(s){if(t.items.unshift(s),this.isCategoryVisible(t)){const{renderer:e}=t.elements;(0,T.Z)(s.element,t.elements.items,e?1:0,-1),null==e||e.forceRender()}}else this.addEmojiToCategory(t,e,!1,!0);0===this.closeScrollTop&&this.menuOnClickResult.setActive(e.docId?this.categories["Emoji.Recent"]:t)}))),d.Z.addEventListener("peer_changed",(()=>{this.toggleCustomCategory()})),this.toggleCustomCategory(),this.menuOnClickResult.setActive(a)})),(0,S.fc)(this.content,this.onContentClick),(0,P.Z)({listenTo:this.content,listenerSetter:new Z.Z}),this.init=null}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(i,{docId:e.id,emoji:e.stickerEmojiRaw},!0)})),this.onCategoryVisibility({target:i.elements.container,visible:this.isCategoryVisible(i)}),i.setCategoryItemsHeight(),n.classList.remove("hide")})),(0,M.Z)({set:e,container:a,group:s.Yd,lazyLoadQueue:s.Jo.lazyLoadQueue,width:32,height:32,autoplay:!1})}get peerId(){return d.Z.chat.peerId}toggleCustomCategory(){const e=this.categories[""],t=l.Z.premium||this.peerId===l.Z.myId;super.toggleLocalCategory(e,!!e.items.length&&t),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,t,i,s){let n;if(t.docId){const e=w.LD.create(t.docId),i=document.createElement("span");i.classList.add("super-emoji"),i.append(e),n=i}else n=F(t.emoji,void 0,!1);const a=Object.assign(Object.assign({},t),{element:n});e.items[s?"unshift":"push"](a),i||this.spliceExceed(e)||this.onLocalCategoryUpdate(e)}onClose(){this.closeScrollTop=this.scrollable.scrollTop}}},6057:(e,t,i)=>{"use strict";i.d(t,{pw:()=>_,vT:()=>x,ZP:()=>F});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 f 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 p=i(279),m=i(6787),g=i(8805),v=i(4064),b=i(2738),y=i(4484),w=i(319),S=i(2230),C=i(5592),L=i(748),E=i(5975),I=i(7625),M=i(9259),P=i(3699),Z=i(3541),k=i(1273),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())}))};class x{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=>T(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,Z.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=>T(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 f(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,Z.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 A{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-1)*this.gapX>e&&--i,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 _{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=[]}getCategoryByContainer(e){return this.categoriesMap.get(e)}getCategoryByMenuTab(e){return this.categoriesByMenuTabMap.get(e)}createCategory(e,t,i,s){const n=new A({id:""+e.id,title:t,overflowElement:this.content,getContainerSize:()=>{const{width:e,height:t}=this.content.getBoundingClientRect();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(){s.ZP.addEventListener("closed",(()=>{this.postponedEvents.forEach((({cb:e,args:t})=>{e(...t)})),this.postponedEvents.length=0}))}}class F extends _{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)}}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 T(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.content=document.getElementById("content-stickers");const e=this.content.previousElementSibling,t=this.menu=e.firstElementChild,i=this.menuScroll=new g.v7(e);this.scrollable=new g.ZP(this.content,"STICKERS"),this.scrollable.onAdditionalScroll=()=>{this.setTyping()};const o={root:s.ZP.getElement()};this.categoriesIntersector=new u.Z(this.onCategoryVisibility,o);const r=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;new m.Z({id:i.set.id,access_hash:i.set.access_hash}).show()}else s.Jo.onMediaClick(e)})),this.menuOnClickResult=s.Jo.menuOnClick(this,t,this.scrollable,i);const l=(0,p.y)(this.content,!0),c=(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")},h=this.createLocalCategory("faved","FavoriteStickers","savedmessages"),f=this.createLocalCategory("recent","Stickers.Recent","recent");f.limit=20;const v=(0,S.Z)("close",{noRipple:!0});f.elements.title.append(v),(0,b.fc)(v,(()=>{(0,C.Z)({titleLangKey:"ClearRecentStickersAlertTitle",descriptionLangKey:"ClearRecentStickersAlertMessage",button:{langKey:"Clear"}}).then((()=>{this.managers.appStickersManager.clearRecentStickers()}),w.Z)}));const y=this.createLocalCategory("premium","PremiumStickersShort"),Z=document.createElement("span");Z.classList.add("tgico-star","color-premium"),y.elements.menuTab.append(Z);const k=[Promise.all([this.managers.apiManager.getLimit("favedStickers"),this.managers.appStickersManager.getFavedStickersStickers()]).then((([e,t])=>{this.setFavedLimit(e),c(h,t)})),this.managers.appStickersManager.getRecentStickersStickers().then((e=>{c(f,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(y,d.Z.premium&&!!t),this.categoryAppendStickers(y,Promise.resolve(e)),d.Z.addEventListener("premium_toggle",(e=>{this.toggleLocalCategory(this.categories.premium,e&&!!t)}))}))];Promise.race(k).finally((()=>{l.remove()})),Promise.all(k).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 x(s.Jo.lazyLoadQueue,s.Yd,this.managers,o);const T=this.superStickerRenderer.lazyLoadQueue;s.ZP.addLazyLoadQueueRepeat(T,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 t=this.categories[e];this.deleteCategory(t)&&r(t)})),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_updated",(({type:e,stickers:t})=>{const i=this.categories["faved"===e?"faved":"recent"];i&&c(i,t)})),d.Z.addEventListener("app_config",(()=>{this.managers.apiManager.getLimit("favedStickers").then((e=>{this.setFavedLimit(e)}))})),a.Z.addEventListener("resize",this.resizeCategories),(0,M.Z)({listenTo:this.content,listenerSetter:new P.Z});const A="menu";(0,L.Z)({listenTo:this.content,verifyRecent:e=>!!(0,E.Z)(e,this.categories.recent.elements.items),onOpen:()=>{s.ZP.setIgnoreMouseOut(A,!0)},onClose:()=>{s.ZP.setIgnoreMouseOut(A,!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()}}},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:()=>p});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),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 p{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((()=>f(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])=>f(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(3512),a=i(3035),o=i(4789),r=i(5975),d=i(2648),l=i(2738);function c(e,t,i,c,h=200,u,f){const p=(0,s.v)(t,e||"tabs"===t.dataset.animation?"tabs":"navigation",h,c,void 0,f);if(!e)return p;const m=new Proxy(p,{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,r,d=!0)=>{return l=this,c=void 0,m=function*(){const l=t.children[r];if(i){const e=i(r,l,d),t=e instanceof Promise?yield e:e;if(void 0!==t&&!t)return}u&&u.scrollIntoViewNew({element:s.parentElement.children[r],position:"center",forceDirection:d?void 0:o.f.Static,forceDuration:h,axis:"x"}),n.Z.settings.animationsEnabled||(d=!1);const c=p.prevId();if(s.classList.contains("active")||r===c)return!1;const f=d?a.T2:e=>e(),m=e.querySelector(b.toLowerCase()+".active");m&&f((()=>{m.classList.remove("active")})),v&&-1!==c&&d&&f((()=>{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,n=t.clientWidth/e.clientWidth;e.style.transform=`translate3d(${i}px, 0, 0) scale3d(${n}, 1, 1)`,(0,a.T2)((()=>{e.classList.add("animate"),e.style.transform="none"}))})),f((()=>{s.classList.add("active")})),p(r,d)},new((f=void 0)||(f=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 f?n:new f((function(e){e(n)}))).then(i,s)}n((m=m.apply(l,c||[])).next())}));var l,c,f,m},v=!e.classList.contains("no-stripe"),b=e.firstElementChild.tagName;return(0,l.fc)(e,(t=>{let i,s=t.target;if(s=(0,r.Z)(s,e),!s)return!1;if(s.dataset.tab){if(i=+s.dataset.tab,-1===i)return!1}else i=(0,d.Z)(s);g(s,i)}),{listenerSetter:f}),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),f=i(130),p=i(2325),m=i(1507),g=i(6241),v=i(6535),b=i(3066),y=i(4776);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,f=Array.from(c.querySelectorAll(".custom-emoji-placeholder")).map((e=>(e.dataset.ces="1",e.customEmojiElement))),p=(0,a.Z)(c);null==l||l.disconnectedCallback(),console.log(p);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}),null==h||h.onBeforeInput({inputType:"insertContent"}),window.document.execCommand("insertHTML",!1,p),Array.from(e.querySelectorAll("[data-ces]")).forEach(((e,t)=>{delete e.dataset.ces;const i=f[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");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);if(!!h||(o.entities=o.entities.filter((e=>"messageEntityCustomEmoji"!==e._))),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.disconnectedCallback();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,f=[];let m;if(a?(this.container.innerHTML=`\n <input type="text" ${n?`name="${n}"`:""} autocomplete="${null!=d?d:"off"}" ${h?'required=""':""} class="input-field-input">\n `,m=this.container.firstElementChild):(S&&S(),this.container.innerHTML='<div class="input-field-input"></div>',m=this.container.firstElementChild,m.contentEditable=""+!!o,u.Z.getInstance(),m.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)})),f.push((()=>{(0,c.Z)(m)&&m.replaceChildren(),u.Y&&Array.from(m.querySelectorAll("br:not(.br-not-br)")).forEach((e=>{e.remove()})),(0,y.Cx)(Array.from(m.querySelectorAll(".input-something"))),E(m)}))),m.setAttribute("dir","auto"),e.inputMode&&(m.inputMode=e.inputMode),t&&(0,p.$d)(m,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=m.classList.contains("error"),o=a?m.value.length:[...(0,l.Z)(m,!1,!1).value].length,r=i-o,d=r<0;m.classList.toggle("error",d),d||r<=s?(this.setLabel(),e.append(` (${i-o})`),t||(t=!0)):(n&&!d||t)&&(this.setLabel(),t=!1)};f.push(n)}!e.withLinebreaks&&!a&&(m.dataset.noLinebreaks="1",m.addEventListener("keypress",(e=>{if("Enter"===e.key)return e.preventDefault(),!1}))),f.length&&m.addEventListener("input",(()=>{f.forEach((e=>e()))})),this.input=m}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,f.Z)(this.label,this.options.labelText):this.label.append((0,p.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,p.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)}}},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)}}},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,t,i,s){super({step:1e3/60/1e3,min:0,max:1,withTransition:i,useTransform:s},0),this.progressRAF=0,this.onLoadedData=()=>{this.max=this.media.duration,this.seek.setAttribute("max",""+this.max)},this.onEnded=()=>{this.setProgress()},this.onPlay=()=>{const e=()=>{this.setProgress(),this.progressRAF=this.media.paused?0:window.requestAnimationFrame(e)};this.progressRAF&&window.cancelAnimationFrame(this.progressRAF),this.streamable&&this.setLoadProgress(),this.progressRAF=window.requestAnimationFrame(e)},this.onTimeUpdate=()=>{this.media.paused&&(this.setProgress(),this.streamable&&this.setLoadProgress())},this.onProgress=e=>{this.setLoadProgress()},e&&this.setMedia(e,t)}setMedia(e,t=!1){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 i=!1;this.setSeekMax(),this.setListeners(),this.setHandlers({onMouseDown:()=>{i=!this.media.paused,i&&this.media.pause()},onMouseUp:e=>{i&&this.media.play()}})}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.media.duration?a/this.media.duration:0;this.filledLoad.style.width=100*o+"%"}setSeekMax(){this.max=this.media.duration||0,this.max>0?this.onLoadedData():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("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("timeupdate",this.onTimeUpdate),this.streamable&&this.media.removeEventListener("progress",this.onProgress)),this.progressRAF&&(window.cancelAnimationFrame(this.progressRAF),this.progressRAF=0)}}},3251:(e,t,i)=>{"use strict";i.d(t,{I:()=>p});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(f),l.clear()})))}function u(e){const t=e.dataset.sizeType;return t?a.Z.active[t].width:e.getBoundingClientRect().width}function f(e){let t=d.get(e);const i=!t;let{text:a,textLength:r,from:l,multiplier:c,font:h,textWidth:f,elementWidth:p}=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}`,f=(0,n.Z)(a,h),p=u(e),t={text:a,textLength:r,from:l,multiplier:c,font:h,textWidth:f,elementWidth:p},d.set(e,t)}const m=u(e),g=i||p!==m;if(!i&&g&&(t.elementWidth=p=m),g)if(f>p){e.setAttribute("title",a);let i=a,s=p;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<p){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 p extends HTMLElement{connectedCallback(){d.set(this,null),this.dataset.sizeType?f(this):(l.add(this),h())}disconnectedCallback(){d.delete(this),l.delete(this)}}customElements.define("middle-ellipsis-element",p)},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:()=>F});var s=i(2365),n=i(2166),a=i(5565),o=i(130),r=i(3699),d=i(3035),l=i(4846),c=i(2325),h=i(4776),u=i(3512),f=i(9331),p=i(9807),m=i(5432),g=i(4064),v=i(3910),b=i(2738),y=i(1708),w=i(6074),S=i(7030),C=i(9931),L=i(3757),E=i(9492),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())}))};class M{constructor(e,t){this.scrollable=e,this.managers=t,this.processItem=e=>I(this,void 0,void 0,(function*(){const t=document.createElement("div");let i;t.classList.add(M.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=()=>I(this,void 0,void 0,(function*(){if(i){const e=yield(0,E.Z)({container:t,photo:i,size:(0,S.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,C.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(M.BASE_CLASS+"-container"),this.avatars=document.createElement("div"),this.avatars.classList.add(M.BASE_CLASS+"-avatars"),this.gradient=document.createElement("div"),this.gradient.classList.add(M.BASE_CLASS+"-gradient"),this.info=document.createElement("div"),this.info.classList.add(M.BASE_CLASS+"-info"),this.tabs=document.createElement("div"),this.tabs.classList.add(M.BASE_CLASS+"-tabs"),this.arrowPrevious=document.createElement("div"),this.arrowPrevious.classList.add(M.BASE_CLASS+"-arrow","tgico-avatarprevious"),this.arrowNext=document.createElement("div"),this.arrowNext.classList.add(M.BASE_CLASS+"-arrow",M.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 r.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,b.fc)(this.container,(e=>I(this,void 0,void 0,(function*(){if(a)return void(0,v.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,f.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,d.T2)((()=>{this.avatars.classList.remove("no-transition")}))}}))),{listenerSetter:this.listenerSetter});const o=()=>{n=!0,document.body.addEventListener(m.Z?"touchend":"click",(e=>{n=!1}),{once:!0})};let l=0,c=0,h=0,u=0;this.swipeHandler=new L.Z({element:this.avatars,onSwipe:(e,t)=>{h=e;let i=c+e*-M.SCALE;return i>0?i=0:i<u&&(i=u),this.avatars.style.transform=M.TRANSLATE_TEMPLATE.replace("{x}",i+"px"),!1},verifyTouchTarget:e=>i()?!this.container.classList.contains("is-single")&&!a:(o(),(0,v.Z)(e),!1),onFirstSwipe:()=>{const e=this.avatars.getBoundingClientRect();l=e.width,u=-l*(this.tabs.childElementCount-1),c=e.left-this.container.getBoundingClientRect().left,this.avatars.style.transform=M.TRANSLATE_TEMPLATE.replace("{x}",c+"px"),this.container.classList.add("is-swiping"),this.avatars.classList.add("no-transition"),this.avatars.offsetLeft},onReset:()=>{const e=Math.ceil(Math.abs(h)/(l/M.SCALE))*(h>=0?1:-1);o(),this.avatars.classList.remove("no-transition"),(0,d.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 I(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 w.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=>I(this,void 0,void 0,(function*(){const t=e.pop();if((0,y.Z)(t),!i.current){const s=e[0],n=(0,g.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*M.SCALE*i;this.avatars.style.transform=M.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(M.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()}}M.BASE_CLASS="profile-avatars",M.SCALE=s.Z?2:1,M.TRANSLATE_TEMPLATE=s.Z?`translate3d({x}, 0, -1px) scale(${M.SCALE})`:"translate({x}, 0)";var P=i(7479),Z=i(2464),k=i(2796),T=i(8210),x=i(7362),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())}))};const _=(e,t)=>{(0,o.Z)(t.title,e||""),t.container.style.display=e?"":"none"};class F{constructor(e,t,i,n=!0){this.managers=e,this.scrollable=t,this.listenerSetter=i,this.isDialog=n,this.setPeerStatus=(e=!1)=>{const t=this.peerId;if(this.element.classList.toggle("is-me",t===u.Z.myId),t&&(u.Z.myId!==t||!this.isDialog))return l.Z.setPeerStatus(t,this.subtitle,e,!0,(()=>t===this.peerId),!this.isDialog).then((e=>{e&&e()}))},s.Z||this.scrollable.container.classList.add("no-parallax"),i||(this.listenerSetter=new r.Z)}init(){this.init=null,this.element=document.createElement("div"),this.element.classList.add("profile-content"),this.section=new Z.dw({noDelimiter:!0}),this.avatar=new f.Z,this.avatar.classList.add("profile-avatar","avatar-120"),this.avatar.isDialog=this.isDialog,this.avatar.attachClickEvent(),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 P.ZP({title:" ",subtitleLangKey:"UserBio",icon:"info",clickable:e=>A(this,void 0,void 0,(function*(){if("A"===e.target.tagName)return;const t=yield this.managers.appProfileManager.getProfileByPeerId(this.peerId);(0,n.T)(t.about),(0,k.Am)(c.ZP.format("BioCopied",!0))})),listenerSetter:this.listenerSetter}),this.bio.title.classList.add("pre-wrap"),this.username=new P.ZP({title:" ",subtitleLangKey:"Username",icon:"username",clickable:()=>A(this,void 0,void 0,(function*(){const e=yield this.managers.appPeersManager.getPeer(this.peerId);(0,n.T)("@"+e.username),(0,k.Am)(c.ZP.format("UsernameCopied",!0))})),listenerSetter:this.listenerSetter}),this.phone=new P.ZP({title:" ",subtitleLangKey:"Phone",icon:"phone",clickable:()=>A(this,void 0,void 0,(function*(){const e=yield this.managers.appUsersManager.getUser(this.peerId);(0,n.T)("+"+e.phone),(0,k.Am)(c.ZP.format("PhoneCopied",!0))})),listenerSetter:this.listenerSetter}),this.link=new P.ZP({title:" ",subtitleLangKey:"SetUrlPlaceholder",icon:"link",clickable:()=>{(0,n.T)(this.link.title.textContent),(0,k.Am)(c.ZP.format("LinkCopied",!0))},listenerSetter:this.listenerSetter}),this.location=new P.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 P.ZP({checkboxField:new p.Z({toggle:!0}),titleLangKey:"Notifications",icon:"unmute",listenerSetter:this.listenerSetter}),e.add(this.notifications.checkboxField.input)("change",(e=>{e.isTrusted&&this.managers.appMessagesManager.togglePeerMute(this.peerId)})),e.add(u.Z)("dialog_notify_settings",(e=>A(this,void 0,void 0,(function*(){if(this.peerId===e.peerId){const e=yield this.managers.appNotificationsManager.isPeerLocalMuted(this.peerId,!1);this.notifications.checkboxField.checked=!e}})))),this.section.content.append(this.notifications.container)),this.element.append(this.section.container),s.Z&&this.element.append((0,Z.G7)()),e.add(u.Z)("peer_typings",(({peerId:e})=>{this.peerId===e&&this.setPeerStatus()})),e.add(u.Z)("peer_bio_edit",(e=>{e===this.peerId&&this.setMoreDetails(!0)})),e.add(u.Z)("peer_title_edit",(e=>{e===this.peerId&&this.fillUsername()})),e.add(u.Z)("user_update",(e=>{this.peerId===e.toPeerId()&&this.setPeerStatus()})),e.add(u.Z)("contacts_update",(e=>A(this,void 0,void 0,(function*(){this.peerId===e.toPeerId()&&((yield this.managers.appUsersManager.getUser(e)).pFlags.self&&this.isDialog||this.fillUserPhone())})))),e.add(u.Z)("avatar_update",(e=>{this.peerId===e&&this.setAvatar()})),this.setPeerStatusInterval=window.setInterval(this.setPeerStatus,6e4)}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!==u.Z.myId||!this.isDialog}setAvatar(){return A(this,void 0,void 0,(function*(){if(this.canBeDetailed()&&(yield this.managers.appPeersManager.getPeerPhoto(this.peerId))){const e=this.avatars;return this.avatars=new M(this.scrollable,this.managers),yield this.avatars.setPeer(this.peerId),this.avatars.info.append(this.name,this.subtitle),this.avatar.remove(),e?e.container.replaceWith(this.avatars.container):this.element.prepend(this.avatars.container),void(s.Z&&this.scrollable.container.classList.add("parallax"))}s.Z&&this.scrollable.container.classList.remove("parallax"),this.avatars&&(this.avatars.container.remove(),this.avatars.cleanup(),this.avatars=void 0),yield this.avatar.updateWithOptions({peerId:this.peerId}),this.section.content.prepend(this.avatar,this.name,this.subtitle)}))}fillUsername(){return A(this,void 0,void 0,(function*(){const{peerId:e}=this;if(e.isUser()&&this.canBeDetailed()){const t=yield this.managers.appPeersManager.getPeerUsername(e);return _(t,this.username)}}))}fillUserPhone(){return A(this,void 0,void 0,(function*(){const{peerId:e}=this;if(e.isUser()&&this.canBeDetailed()){const t=yield this.managers.appUsersManager.getUser(e);return _(t.phone?(0,T.Z)(t.phone):void 0,this.phone)}}))}fillNotifications(){return A(this,void 0,void 0,(function*(){const e=this.notifications;if(e)if(this.canBeDetailed()){const t=yield this.managers.appNotificationsManager.isPeerLocalMuted(this.peerId,!1);e.checkboxField.checked=!t}else(0,d.T2)((()=>{e.container.style.display="none"}))}))}fillRows(){return A(this,void 0,void 0,(function*(){const e=this.peerId;yield Promise.all([this.fillUsername(),this.fillUserPhone(),this.fillNotifications(),this.setMoreDetails(),(()=>A(this,void 0,void 0,(function*(){const[t]=yield Promise.all([(0,x.Z)({peerId:e,dialog:this.isDialog,withIcons:!0})]);(0,a.Z)(this.name,t)})))(),this.setPeerStatus(!0)])}))}fillProfileElements(){return A(this,void 0,void 0,(function*(){this.cleaned&&(this.cleaned=!1,this.cleanupHTML(),yield Promise.all([this.setAvatar(),this.fillRows()]))}))}_setMoreDetails(e,t){return A(this,void 0,void 0,(function*(){if(_(t.about?(0,h.ZP)(t.about):void 0,this.bio),!e.isUser()){const i=yield this.managers.appChatsManager.getChat(e.toChatId());if(i.username)_("https://t.me/"+i.username,this.link);else{const e=t.exported_invite;"chatInviteExported"===(null==e?void 0:e._)&&_(e.link,this.link)}}const i=t.location;"channelLocation"==(null==i?void 0:i._)&&_(i.address,this.location),this.setMoreDetailsTimeout=window.setTimeout((()=>this.setMoreDetails(!0)),6e4)}))}setMoreDetails(e){return A(this,void 0,void 0,(function*(){this.clearSetMoreDetailsTimeout();const t=this.peerId,i=this.threadId;if(!t||(yield this.managers.appPeersManager.isRestricted(t))||!this.canBeDetailed())return;const s=yield this.managers.acknowledged.appProfileManager.getProfileByPeerId(t,e),n=s.result.then((e=>A(this,void 0,void 0,(function*(){this.peerId!==t||this.threadId!==i||(yield this.managers.appPeersManager.isRestricted(t))||(yield this._setMoreDetails(t,e))}))));s.cached&&(yield n)}))}setPeer(e,t=0){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.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()}}},8842:(e,t,i)=>{"use strict";i.d(t,{Z:()=>p});var s=i(3512),n=i(2325),a=i(5565),o=i(1507),r=i(8456),d=i(130),l=i(8115),c=i(493),h=(i(4755),i(5948));i(3541);function u(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,h.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}const f=new WeakMap;s.Z.addEventListener("peer_title_edit",(e=>{Array.from(document.querySelectorAll(`.peer-title[data-peer-id="${e}"]`)).forEach((e=>{const t=f.get(e);null==t||t.update()}))}));class p{constructor(e){this.plainText=!1,this.onlyFirstName=!1,this.dialog=!1,this.element=document.createElement("span"),this.element.classList.add("peer-title"),this.element.setAttribute("dir","auto"),e&&this.update(e),f.set(this.element,this)}setOptions(e){if(e)for(const t in e){const i=e[t];"object"!=typeof i&&(this.element.dataset[t]=i?""+("boolean"==typeof i?+i:i):"0"),this[t]=i}}update(e){var t,i,h,f,p,m;return h=this,f=void 0,m=function*(){this.setOptions(e);let h,f=this.fromName;if(void 0!==f)return void 0!==this.limitSymbols&&(f=(0,r.Z)(f,this.limitSymbols,this.limitSymbols)),void(0,d.Z)(this.element,(0,l.Z)(f));if(null!==(t=this.peerId)&&void 0!==t||(this.peerId=o.NM),this.peerId===s.Z.myId&&this.dialog)(0,a.Z)(this.element,(0,n.ag)(this.onlyFirstName?"Saved":"SavedMessages"));else{const e=null!==(i=this.managers)&&void 0!==i?i:s.Z.managers,[t,n]=yield Promise.all([(0,c.Z)(this.peerId,this.plainText,this.onlyFirstName,this.limitSymbols,e),this.withIcons&&u(this.peerId,this.middleware)||this.withPremiumIcon&&u(this.peerId,this.middleware,!0,!0)]);if(null==n?void 0:n.length){const e=document.createElement("span");e.classList.add("peer-title-inner"),h=!0,(0,d.Z)(e,t);const i=document.createDocumentFragment();i.append(e,...n),(0,d.Z)(this.element,i)}else(0,d.Z)(this.element,t)}this.hasInner!==h&&(this.hasInner=h,this.element.classList.toggle("with-icons",h))},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(h,f||[])).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(){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),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),f(o,r),p(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 f(e,t){r=t*c,o=e*c,n.style.top=-t+"px",n.style.left=-e+"px"}function p(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),f(t,i),p(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),f(t,i),p(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)}}},6194:(e,t,i)=>{"use strict";i.d(t,{Z:()=>o});var s=i(1168),n=i(8842),a=i(8127);class o{constructor(e,t,i){this.peerId=e,this.peerType=t,this.onSelect=i,this.construct()}construct(){return e=this,t=void 0,o=function*(){let{peerId:e,peerType:t,onSelect:i}=this;const o=new n.Z({peerId:e}).element,r=s.Z.MANAGERS;void 0===t&&(t=yield r.appPeersManager.getDialogType(e));const d=(t,s=p&&!!t.size)=>{let n=r.appChatsManager.leave(e.toChatId());s&&(n=n.then((()=>r.appMessagesManager.flushHistory(e)))),null==i||i(n)},l=t=>{let s;if(e.isUser())s=r.appMessagesManager.flushHistory(e,!1,p?!!t.size:void 0);else{if(!t.size)return d(t);s=r.appChatsManager.delete(e.toChatId())}null==i||i(s)};let c,h,u,f,p;switch(t){case"channel":(yield r.appChatsManager.hasRights(e.toChatId(),"delete_chat"))?(c="ChannelDeleteMenu",h="AreYouSureDeleteAndExitChannel",f=[{langKey:"ChannelDeleteMenu",isDanger:!0,callback:l}],p=[{text:"DeleteChannelForAll"}]):(c="LeaveChannelMenu",h="ChannelLeaveAlertWithName",u=[o],f=[{langKey:"LeaveChannel",isDanger:!0,callback:d}]);break;case"chat":c="DeleteChatUser",h="AreYouSureDeleteThisChatWithUser",u=[o],f=[{langKey:"DeleteChatUser",isDanger:!0,callback:l}],p=[{text:"DeleteMessagesOptionAlso",textArgs:[new n.Z({peerId:e}).element]}];break;case"saved":c="DeleteChatUser",h="AreYouSureDeleteThisChatSavedMessages",f=[{langKey:"DeleteChatUser",isDanger:!0,callback:l}];break;case"megagroup":case"group":(yield r.appChatsManager.hasRights(e.toChatId(),"delete_chat"))?(c="DeleteMegaMenu",h="AreYouSureDeleteAndExit",f=[{langKey:"DeleteMegaMenu",isDanger:!0,callback:l}],p=[{text:"DeleteChat.DeleteGroupForAll"}]):(c="LeaveMegaMenu",h="AreYouSureDeleteAndExitName",u=[o],f=[{langKey:"DeleteChatUser",isDanger:!0,callback:e=>d(e,!0)}])}new a.Z("popup-delete-chat",{peerId:e,titleLangKey:c,descriptionLangKey:h,descriptionLangArgs:u,buttons:f,checkboxes:p}).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(8842),d=i(7120),l=i(2353),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){this.peerId=e,this.mids=t,this.type=i,this.onConfirm=s,this.construct()}construct(){return c(this,void 0,void 0,(function*(){let{peerId:e,mids:t,type:i,onConfirm:h}=this;const u=new r.Z({peerId:e}).element,f=n.Z.MANAGERS;t=t.slice();const p=(s,n)=>{h&&h(),"scheduled"===i?f.appMessagesManager.deleteScheduledMessages(e,t):f.appMessagesManager.deleteMessages(e,t,!!s.size||n)},m=[{langKey:"Delete",isDanger:!0,callback:p}],g=[];let v,b,y,w;if(1===t.length?v="DeleteSingleMessagesTitle":(v="DeleteMessagesTitle",b=[(0,o.ag)("messages",[t.length])]),y=(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())g.push({text:"DeleteMessagesOptionAlso",textArgs:[u]});else{const i=yield f.appChatsManager.getChat(e.toChatId()),n=(0,d.Z)(i,"delete_messages");if("chat"===i._){const i=n?t.slice():yield(0,l.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?g.push({text:"DeleteForAll"}):(g.push({text:"DeleteMessagesOption"}),y="DeleteMessagesTextGroup",w=[(0,o.ag)("messages",[i.length])]))}else m[0].callback=e=>p(e,!0)}(0,n.x)(m),new a.Z("popup-delete-chat",{peerId:e,titleLangKey:v,titleLangArgs:b,descriptionLangKey:y,descriptionLangArgs:w,buttons:m,checkboxes:g}).show()}))}}},4524:(e,t,i)=>{"use strict";i.d(t,{Z:()=>a});var s=i(4846),n=i(2995);class a extends n.Z{constructor(e,t,i=!1){super({peerTypes:["dialogs","contacts"],onSelect:i?t:i=>{return n=this,a=void 0,r=function*(){if(t){const e=t(i);e instanceof Promise&&(yield e)}s.Z.setInnerPeer({peerId:i}),s.Z.chat.input.initMessagesForward(e)},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},placeholder:"ShareModal.Search.ForwardPlaceholder",chatRightsAction:"send_messages",selfPresence:"ChatYourSelf"}),this.scrollable=this.selector.scrollable,this.attachScrollableListeners(this.scrollable)}}},1168:(e,t,i)=>{"use strict";i.d(t,{Z:()=>C,x:()=>L});var s=i(1405),n=i(5814),a=i(9818),o=i(2325),r=i(8497),d=i(8799),l=i(3699),c=i(2738),h=i(6299),u=i(3910),f=i(3241),p=i(6733),m=i(1655),g=i(3815),v=i(8805),b=i(3624);const y=document.body;let w=y;const S=()=>{w=(0,p.W7)()||y,C.reAppend()};(0,p.Ms)(y,S);class C extends f.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&&(this.title.classList.add("popup-title"),"string"==typeof t.title&&(0,o.$d)(this.title,t.title),this.header.append(this.title)),this.middlewareHelper=(0,b.k)(),this.listenerSetter=new l.Z,this.managers=C.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(e),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"),(0,s.Z)(t),e.text?t.innerHTML=e.text:t.append((0,o.ag)(e.langKey,e.langArgs)),(0,c.fc)(t,(()=>{e.callback&&e.callback(),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),C.POPUPS.push(this)}attachScrollableListeners(e){const t=e.onAdditionalScroll;e.onAdditionalScroll=()=>{null==t||t(),e.container.classList.toggle("scrolled-top",!e.scrollTop),e.container.classList.toggle("scrolled-bottom",e.isScrolledDown)},e.container.classList.add("scrolled-top","scrolled-bottom","scrollable-y-bordered")}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)(),w.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=>{C.POPUPS[C.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)(C.POPUPS,this),S(),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!==w&&w!==i&&w.append(t)}))}static getPopups(e){return this.POPUPS.filter((t=>t instanceof e))}static createPopup(e,...t){return new e(...t)}}C.POPUPS=[];const L=e=>(e.find((e=>e.isCancel))||e.push({langKey:"Cancel",isCancel:!0}),e)},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){let t;super("popup-mute",{peerId:e,titleLangKey:"Notifications",buttons:[{langKey:"ChatList.Context.Mute",callback:()=>{this.managers.appMessagesManager.mutePeer(e,-1===t?n.rU:(0,s.Z)(!0)+t)}}],body:!0});const i=(0,a.ZC)(r,(e=>{t=+e}));this.body.append(i),this.show()}}},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}),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()},chatRightsAction:e.chatRightsAction,multiSelect:!1,rippleEnabled:!1,avatarSize:"abitbigger",peerId:e.peerId,placeholder:e.placeholder,selfPresence:e.selfPresence,managers:this.managers}),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()}}},6787:(e,t,i)=>{"use strict";i.d(t,{Z:()=>P});var s=i(1168),n=i(3541),a=i(2153),o=i(279),r=i(5814),d=i(4846),l=i(4755),c=i(2325),h=i(4494),u=i(8497),f=i(1656),p=i(2738),m=i(2796),g=i(130),v=i(8115),b=i(748),y=i(9259),w=i(7479),S=i(5565),C=i(3512),L=i(9083),E=i(3173),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())}))};const M="STICKERS-POPUP";class P 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=>I(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.Z.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 I(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,p.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=>I(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,p.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,size: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=>I(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,p.fc)(C,(()=>{const e=(0,f.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")),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]))}}},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=>{e&&(0,a.Z)(e),this.preloader.classList.contains("manual")?this.loadFunc&&this.loadFunc(e):this.promise&&this.promise.cancel&&this.promise.cancel()},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){this.construct&&this.construct(),this.preloader.parentElement&&this.preloader.classList.remove("manual"),this.detached=!1,i&&this.attachPromise(i);let n=0;(this.detached||this.preloader.parentElement!==e)&&(n=(0,r.Z)(this.preloader)?1:2,this.preloader.parentElement!==e&&e[this.attachMethod](this.preloader)),(0,s.Z)(this.preloader,"is-visible",!0,200,void 0,n),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)(this.preloader,"is-visible",!1,200,(()=>{this.preloader.remove()}),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=""}}},9931:(e,t,i)=>{"use strict";i.d(t,{Z:()=>m,Y:()=>f});var s=i(4059),n=i(6740),a=i(5565),o=i(130),r=i(9674),d=i(5990),l=i(1507),c=i(3785),h=i(3512),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 f(e,t,i,o,d=new Image,l=!1){return u(this,void 0,void 0,(function*(){const l=yield h.Z.managers.acknowledged.appAvatarsManager.loadAvatar(t,i,o),c=l.result,u=l.cached;let p,m,g;if(d.classList.add("avatar-photo"),u)m=()=>{(0,a.Z)(e,d),e.dataset.color=""};else{const l=h.Z.settings.animationsEnabled;l&&d.classList.add("fade-in");let c=!1;if("photo_big"===o){const s=yield f(e,t,i,"photo_small");p=s.loadPromise,g=s.thumbImage}else if(i.stripped_thumb){g=new Image,e.classList.add("avatar-relative"),g.classList.add("avatar-photo","avatar-photo-thumbnail");const t=(0,s.Z)(i.stripped_thumb);p=(0,n.cj)(g,t).then((()=>{c||(0,a.Z)(e,g)}))}m=()=>{c=!0,g?e.append(d):(0,a.Z)(e,d),setTimeout((()=>{e.childElementCount&&r.Z.mutateElement(d,(()=>{e.dataset.color="",l&&d.classList.remove("fade-in"),g&&g.remove()}))}),l?200:0)}}const v=c.then((e=>(0,n.cj)(d,e))).then(m);return yield p||v,{cached:u,loadPromise:p||v,thumbImage:g}}))}function p(e,t,i,s){(0,o.Z)(e,t),e.dataset.color=i,e.classList.remove("tgico-saved","tgico-deletedaccount","tgico-reply_filled"),s&&e.classList.add(s)}function m(e,t,i=!1,s="",n=!1,a){return u(this,void 0,void 0,(function*(){const o=h.Z.myId;if(t===o&&i)return void p(e,"","","tgico-saved");const r=h.Z.managers;if(t!==l.NM&&t.isUser()){const i=yield r.appUsersManager.getUser(t);if(i&&i.pFlags&&i.pFlags.deleted)return void p(e,"",(0,d.Z)(t),"tgico-deletedaccount")}const u=a?"photo_big":"photo_small",m=yield r.appPeersManager.getPeerPhoto(t),g=!!m,v=!!e.firstElementChild&&!e.firstElementChild.classList.contains("emoji");if(!g||!v||!(yield r.appAvatarsManager.isAvatarCached(t,u))){let n="";if(!t||t===o&&i||(n=(0,d.Z)(t)),t===l.hj)return void p(e,"",n,"tgico-reply_filled");const a=yield s?(0,c.Z)(s):function(e,t=h.Z.managers){var i,s,n,a,o;return s=this,n=void 0,o=function*(){const s=yield t.appPeersManager.getPeer(e);return(0,c.Z)(null!==(i=s.title)&&void 0!==i?i:[s.first_name,s.last_name].filter(Boolean).join(" "))},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())}))}(t,r);p(e,a,n,"")}return g?f(e,t,m,u,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.innerHTML="",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:()=>r});var s=i(9750),n=i(2325),a=i(3855),o=i(3512);class r{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&&(a.Z.getState().then((t=>{i.checked=(0,s.Z)(t,e.stateKey)===e.value})),i.addEventListener("change",(()=>{o.Z.managers.appStateManager.setByKey(e.stateKey,e.value)}))));const r=this.main=document.createElement("div");r.classList.add("radio-field-main"),e.text?r.innerHTML=e.text:e.langKey&&(0,n.$d)(r,e.langKey),t.append(i,r)}get checked(){return this.input.checked}set checked(e){this.setValueSilently(e);const t=new Event("change",{bubbles:!0,cancelable:!0});this.input.dispatchEvent(t)}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:()=>l});var s=i(8497),n=i(9674),a=i(5432),o=i(3512),r=i(5975);let d=0;function l(e,t=(()=>Promise.resolve()),i=null,l=!1,c=e){if(e.querySelector(".c-ripple"))return;e.classList.add("rp");const h=document.createElement("div");let u;h.classList.add("c-ripple"),e.classList.contains("rp-square")&&h.classList.add("is-square"),e[l?"prepend":"append"](h);const f=(e,s)=>{const o=Date.now(),r=document.createElement("div"),l=d++,c=1e3*+window.getComputedStyle(h).getPropertyValue("--ripple-duration").replace("s","");u=()=>{const e=Date.now()-o,t=()=>{n.Z.mutate((()=>{r.remove()})),i&&i(l)};if(e<c){const i=Math.max(c-e,c/2);setTimeout((()=>r.classList.add("hiding")),Math.max(i-c/2,0)),setTimeout(t,i)}else r.classList.add("hiding"),setTimeout(t,c/2);a.Z||window.removeEventListener("contextmenu",u),u=null,m=!1},t&&t(l),window.requestAnimationFrame((()=>{const t=h.getBoundingClientRect();r.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,d=n-a/2;r.style.width=r.style.height=a+"px",r.style.left=o+"px",r.style.top=d+"px",h.append(r)}))},p=t=>t.target!==e&&(["BUTTON","A"].includes(t.target.tagName)||(0,s.Z)(t.target,"c-ripple")!==h)&&(c===e||!(0,r.Z)(t.target,c));let m=!1;if(a.Z){const e=()=>{u&&u()};c.addEventListener("touchstart",(t=>{if(!o.Z.settings.animationsEnabled)return;if(t.touches.length>1||m||p(t))return;m=!0;const{clientX:i,clientY:s}=t.touches[0];f(i,s),c.addEventListener("touchend",e,{once:!0}),window.addEventListener("touchmove",(t=>{t.cancelBubble=!0,t.stopPropagation(),e(),c.removeEventListener("touchend",e)}),{once:!0})}),{passive:!0})}else c.addEventListener("mousedown",(e=>{if(![0,2].includes(e.button))return;if(!o.Z.settings.animationsEnabled)return;if("0"===c.dataset.ripple||p(e))return;if(m)return void(m=!1);const{clientX:t,clientY:i}=e;f(t,i),window.addEventListener("mouseup",u,{once:!0,passive:!0}),window.addEventListener("contextmenu",u,{once:!0,passive:!0})}),{passive:!0})}},7479:(e,t,i)=>{"use strict";i.d(t,{De:()=>m,ZC:()=>g,ZP:()=>f,tG:()=>p});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);const u=(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(u(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"),u(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.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){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?u(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"),u(s,i),t.append(s)}}e.icon&&(i=!0,this.title.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))}get subtitle(){var e;return null!==(e=this._subtitle)&&void 0!==e?e:this._subtitle=this.createSubtitle()}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"),e.setAttribute("dir","auto"),e}createSubtitle(){const e=document.createElement("div");return e.classList.add("row-subtitle"),e.setAttribute("dir","auto"),this.title?this.title.after(e):this.container.prepend(e),this.container.classList.remove("no-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}}const p=e=>new f({checkboxField:e,listenerSetter:e.listenerSetter}),m=(e,t)=>(0,o.Z)(e.map((e=>({container:e.container,input:e.radioField.input}))),t),g=(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=m(a,t);return s&&(s.checked=!0),o}},8805:(e,t,i)=>{"use strict";i.d(t,{ZP:()=>c,v7:()=>h});var s=i(5432),n=i(5003),a=i(4789),o=i(8594),r=i(3910);const d=i(4762).IS_ANDROID?200:24;class l{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()}),d)))},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 c extends l{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"}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 h extends l{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"}}},2464:(e,t,i)=>{"use strict";i.d(t,{ir:()=>Yt,dw:()=>ei,ZP:()=>ni,G7:()=>ii,RF:()=>ti});var s=i(4846),n=i(3512),a=i(5884),o=i(9331),r=i(8805),d=i(3607),l=i(3552),c=i(426),h=i(9893),u=i(503),f=i(187),p=i(2325),m=i(8119),g=i(3061),v=i(2738);class b 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 f.Z((e=>{this.uploadAvatar=e}));const i=new ei({}),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.Z.setInnerPeer({peerId:e.toPeerId(!0)})}))}),{listenerSetter:this.listenerSetter});const a=new ei({name:"Members",nameArgs:[this.peerIds.length]}),o=this.list=h.default.createChatList({new:!0});return 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(p.ZP.format("Loading",!0)),this.startLocating()):this.groupLocationInputField.container.classList.add("hide"),Promise.all(this.peerIds.map((e=>{return t=this,i=void 0,n=function*(){const{dom:t}=h.default.addDialogNew({peerId:e,container:this.list,rippleEnabled:!1,avatarSize:"abitbigger"});t.lastMessageSpan.append((0,g.Z)(yield this.managers.appUsersManager.getUser(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})))}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 y,w=i(6360),S=i(632),C=i(410),L=i(5322),E=i(4494),I=i(6024),M=i(7479),P=i(5565),Z=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"}(y||(y={}));const T=y;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,P.Z)(i,t):(0,p.$d)(i,t):i.innerHTML="",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 ei({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,Z.a)();i.forEach((({type:e,langKey:t})=>{const i=new M.ZP({radioField:new x.Z({langKey:t,name:s,value:""+e})});this.radioRows.set(e,i)}));const n=(0,M.De)([...this.radioRows.values()],this.onRadioChange);if(this.radioSection.content.append(n),e.appendTo&&e.appendTo.append(this.radioSection.container),!e.noExceptions){const t=ti(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 M.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.innerHTML="",i.row.subtitle.append(...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.innerHTML="",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,p.v_)([e.users.length?(0,p.ag)("Users",[e.users.length]):null,e.chats.length?(0,p.ag)("Chats",[e.chats.length]):null].filter(Boolean),!1):[(0,p.ag)("PrivacySettingsController.AddUsers")]}}var F=i(2796),D=i(2166),R=i(3910);function B(e={}){const t=document.createElement("a");if(t.classList.add("anchor-copy"),e.mePath){const i="https://t.me/"+e.mePath;t.href=t.innerText=i}return(0,v.fc)(t,(e=>{(0,R.Z)(e),(0,D.T)(t.href),(0,F.bC)({langPackKey:"LinkCopied"})})),t}class N extends I.h{init(){return e=this,t=void 0,s=function*(){this.header.classList.add("with-border"),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,p.ag)("PrivacyPhoneInfo"),document.createElement("br"),document.createElement("br"),(0,p.ag)("PrivacyPhoneInfo4"),document.createElement("br"),B({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 O=i(8127),U=i(5772),H=i(279);class z extends l._{init(){this.container.classList.add("two-step-verification","two-step-verification-set"),this.setTitle("TwoStepVerificationPasswordSet");const e=new ei({captionOld:"TwoStepVerificationPasswordSetInfo",noDelimiter:!0}),t=document.createElement("div");(0,U.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,E.Z)("btn-primary btn-color-primary",{text:"TwoStepVerificationPasswordReturnSettings"});(0,v.fc)(n,(e=>{this.close()})),this.slider.sliceTabsUntilTab(At,this),s.append(n),i.append(s),this.scrollable.container.append(e.container)}}var j=i(4489),G=i(4762);function V(e){return!G.IS_MOBILE_SAFARI||!e}var K=i(1656);class W 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 ei({captionOld:!0,noDelimiter:!0});(0,p.$d)(e.caption,"TwoStepAuth.ConfirmEmailCodeDesc",[this.email]);const t=document.createElement("div");(0,U.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 j.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,P.Z)(n.label,(0,p.ag)("TwoStepAuth.RecoveryCodeInvalid"));break;case"EMAIL_HASH_EXPIRED":n.input.classList.add("error"),(0,P.Z)(n.label,(0,p.ag)("TwoStepAuth.RecoveryCodeExpired"));break;default:console.error("confirm error",e)}d(!1)}))}}),a=(0,E.Z)("btn-primary btn-primary-transparent primary",{text:"TwoStepAuth.EmailCodeChangeEmail"}),o=(0,E.Z)("btn-primary btn-secondary btn-primary-transparent primary",{text:"ResendCode"}),r=()=>{this.slider.createTab(z).open()},d=e=>{(0,K.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,H.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(){V(this.isFirst)&&this.codeInputField.input.focus()}}var $=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 ei({captionOld:!0,noDelimiter:!0}),t=document.createElement("div");(0,U.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,R.Z)(e),d()})),n.input.addEventListener("input",(e=>{n.input.classList.remove("error")}));const a=(0,E.Z)("btn-primary btn-color-primary",{text:"Continue"}),o=(0,E.Z)("btn-primary btn-secondary btn-primary-transparent primary",{text:"YourEmailSkip"}),r=()=>{this.slider.createTab(z).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,H.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(W);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=>{new O.Z("popup-skip-email",{buttons:[{langKey:"Cancel",isCancel:!0},{langKey:"YourEmailSkip",callback:()=>{l(!0),(0,H.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(){V(this.isFirst)&&this.inputField.input.focus()}}var Q=i(130),Y=i(8115),J=i(4425),X=i(6830),ee=i(3083);class te extends l._{init(){this.container.classList.add("two-step-verification","two-step-verification-hint"),this.setTitle("TwoStepAuth.SetupHintTitle");const e=new ei({noDelimiter:!0}),t=document.createElement("div");(0,U.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,R.Z)(e),s.value?r():d()}));const n=(e,t)=>{e&&(0,R.Z)(e);const i=t?s.value:void 0;if(i&&this.newPassword===i)return void(0,F.Am)(p.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,E.Z)("btn-primary btn-color-primary",{text:"Continue"}),o=(0,E.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 ie 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 ei({noDelimiter:!0}),t=document.createElement("div");t.classList.add("input-wrapper");const i=this.passwordInputField=new X.Z({name:"re-enter-password",label:"PleaseReEnterPassword"}),s=new ee.Z(i,157),n=(0,E.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,R.Z)(e),!a())return;const t=this.slider.createTab(te);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 se 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 ei({noDelimiter:!0}),i=document.createElement("div");i.classList.add("input-wrapper");const s=this.passwordInputField=new X.Z({name:"enter-password",label:e?"PleaseEnterFirstPassword":this.state.hint?void 0:"LoginPassword",labelText:!e&&this.state.hint?(0,Y.Z)(this.state.hint):void 0}),n=new J.Z(s,157),a=(0,E.Z)("btn-primary btn-color-primary"),o=new p.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,R.Z)(e),!r())return;const t=this.slider.createTab(ie);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,Q.Z)(s.label,(0,Y.Z)(this.state.hint)):(0,P.Z)(s.label,(0,p.ag)("LoginPassword"))})));d=i=>{if(!r())return void(0,R.Z)(i);a.setAttribute("disabled","true"),o.key="PleaseWait",o.update();const d=(0,H.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(ne);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(){V(this.isFirst)&&this.passwordInputField.input.focus()}}class ne extends l._{init(){this.container.classList.add("two-step-verification","two-step-verification-main"),this.setTitle("TwoStepVerificationTitle");const e=new ei({captionOld:!0,noDelimiter:!0}),t=document.createElement("div");(0,U.Z)({div:t,width:168,height:168,emoji:"🔐"}),e.content.append(t);const i=e.generateContentElement();if(this.state.pFlags.has_password){(0,p.$d)(e.caption,"TwoStepAuth.GenericHelp");const t=(0,E.Z)("btn-primary btn-transparent",{icon:"edit",text:"TwoStepAuth.ChangePassword"}),s=(0,E.Z)("btn-primary btn-transparent",{icon:"passwordoff",text:"TwoStepAuth.RemovePassword"}),n=(0,E.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(se);e.state=this.state,e.plainPassword=this.plainPassword,e.open()})),(0,v.fc)(s,(()=>{new O.Z("popup-disable-password",{buttons:[{langKey:"Disable",callback:()=>{this.managers.passwordManager.updateSettings({currentPassword:this.plainPassword}).then((()=>{this.slider.sliceTabsUntilTab(At,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,p.$d)(e.caption,"TwoStepAuth.SetPasswordHelp");const t=document.createElement("div");t.classList.add("input-wrapper");const s=(0,E.Z)("btn-primary btn-color-primary",{text:"TwoStepVerificationSetPassword"});t.append(s),i.append(t),(0,v.fc)(s,(e=>{const t=this.slider.createTab(se);t.state=this.state,t.open()}))}this.scrollable.container.append(e.container)}}class ae extends I.h{init(){this.header.classList.add("with-border"),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 oe extends I.h{init(){this.header.classList.add("with-border"),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 re extends I.h{init(){this.header.classList.add("with-border"),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 de extends I.h{init(){this.header.classList.add("with-border"),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 le extends I.h{init(){this.header.classList.add("with-border"),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 ce=i(3003),he=i(8497),ue=i(4064),fe=i(6976),pe=i(1483),me=i(3416);class ge extends I.h{init(){this.header.classList.add("with-border"),this.container.classList.add("active-sessions-container"),this.setTitle("SessionsTitle");const e=e=>{const t=new M.ZP({title:[e.app_name,e.app_version].join(" "),subtitle:[e.ip,e.country].join(" - "),clickable:!0,titleRight:e.pFlags.current?void 0:(0,S.zM)(new Date(1e3*Math.max(e.date_active,e.date_created)))});t.container.dataset.hash=""+e.hash;const i=document.createElement("div");return i.classList.add("row-midtitle"),i.innerHTML=[e.device_model,e.system_version||e.platform].filter(Boolean).join(", "),t.subtitle.parentElement.insertBefore(i,t.subtitle),t},t=this.authorizations.slice();{const n=new ei({name:"CurrentSession",caption:"ClearOtherSessionsHelp"}),a=(0,ue.Z)(t,(e=>e.pFlags.current)),o=e(a);if(n.content.append(o.container),t.length){const e=(0,E.Z)("btn-primary btn-transparent danger",{icon:"stop",text:"TerminateAllSessions"});(0,v.fc)(e,(t=>{new O.Z("revoke-session",{buttons:[{langKey:"Terminate",isDanger:!0,callback:()=>{const t=(0,K.Z)([e],!0);this.managers.apiManager.invokeApi("auth.resetAuthorizations").then((t=>{e.remove(),i.container.remove()}),s).finally((()=>{t()}))}}],titleLangKey:"AreYouSureSessionsTitle",descriptionLangKey:"AreYouSureSessions"}).show()})),n.content.append(e)}this.scrollable.append(n.container)}if(!t.length)return;const i=new ei({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,F.Am)(p.ZP.format("RecentSessions.Error.FreshReset",!0))};let n;const a=()=>{const e=n.dataset.hash;new O.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,ce.Z)([{icon:"stop",text:"Terminate",onClick:a}]);o.id="active-sessions-contextmenu",o.classList.add("contextmenu"),document.getElementById("page-chats").append(o),(0,fe.E)(this.scrollable.container,(e=>{n=(0,he.Z)(e.target,"row"),n&&"0"!==n.dataset.hash&&(e instanceof MouseEvent&&e.preventDefault(),e instanceof MouseEvent&&(e.cancelBubble=!0),(0,pe.Z)(e,o),me.Z.openBtnMenu(o))})),(0,v.fc)(this.scrollable.container,(e=>{n=(0,he.Z)(e.target,"row"),n&&"0"!==n.dataset.hash&&a()}))}onCloseAfterTimeout(){return this.menuElement&&this.menuElement.remove(),super.onCloseAfterTimeout()}}var ve=i(2995),be=i(4668),ye=i(8210);class we extends l._{init(){this.header.classList.add("with-border"),this.container.classList.add("blocked-users-container"),this.setTitle("BlockedUsers");const e=new ei({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=>{new ve.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);n.pFlags.bot?s.lastMessageSpan.append("@"+n.username):n.phone?s.lastMessageSpan.innerHTML=(0,ye.Z)(n.phone):s.lastMessageSpan.append(n.username?"@"+n.username:(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,ce.Z)([{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)(this.scrollable.container,(e=>{a=(0,be.Z)(e.target,h.DIALOG_LIST_ELEMENT_TAG),a&&(e instanceof MouseEvent&&e.preventDefault(),e instanceof MouseEvent&&(e.cancelBubble=!0),(0,pe.Z)(e,o),me.Z.openBtnMenu(o))}),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 Se=i(9807);function Ce(e){return"input"+(e[0].toUpperCase()+e.slice(1))}var Le=i(5592),Ee=i(319);class Ie extends I.h{init(){this.header.classList.add("with-border"),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})}}class Me extends I.h{static getInitArgs(e){return{appConfig:e.managers.apiManager.getAppConfig(),globalPrivacy:e.managers.appPrivacyManager.getGlobalPrivacySettings(),contentSettings:e.managers.apiManager.invokeApi("account.getContentSettings")}}init(e){this.header.classList.add("with-border"),this.container.classList.add("dont-u-dare-block-me"),this.setTitle("PrivacySettings");const t="Loading";{const e=new ei({noDelimiter:!0,caption:"SessionsInfo"});let i;const s=new M.ZP({icon:"deleteuser",titleLangKey:"BlockedUsers",subtitleLangKey:t,clickable:()=>{const e=this.slider.createTab(we);e.peerIds=i,e.open()},listenerSetter:this.listenerSetter});let a;s.freezed=!0;const o={icon:"lock",titleLangKey:"TwoStepVerification",subtitleLangKey:t,clickable:e=>{let t;a.pFlags.has_password?t=this.slider.createTab(se):a.email_unconfirmed_pattern?(t=this.slider.createTab(W),t.email=a.email_unconfirmed_pattern,t.length=6,t.isFirst=!0,this.managers.passwordManager.resendPasswordEmail()):t=this.slider.createTab(ne),t.state=a,t.open()},listenerSetter:this.listenerSetter},r=new M.ZP(o);r.freezed=!0;const d=this.activeSessionsRow=new M.ZP({icon:"activesessions",titleLangKey:"SessionsTitle",subtitleLangKey:t,clickable:()=>{const e=this.slider.createTab(ge);e.authorizations=this.authorizations,e.eventListener.addEventListener("destroy",(()=>{this.updateActiveSessions()}),{once:!0}),e.open()},listenerSetter:this.listenerSetter});d.freezed=!0,e.content.append(s.container,r.container,d.container),this.scrollable.append(e.container);const l=e=>{e?(0,P.Z)(s.subtitle,(0,p.ag)("PrivacySettingsController.UserCount",[e])):(0,P.Z)(s.subtitle,(0,p.ag)("BlockedEmpty",[e]))};this.listenerSetter.add(n.Z)("peer_block",(()=>{c()}));const c=()=>{this.managers.appUsersManager.getBlocked().then((e=>{s.freezed=!1,l(e.count),i=e.peerIds}))};c(),this.managers.passwordManager.getState().then((e=>{a=e,(0,P.Z)(r.subtitle,(0,p.ag)(e.pFlags.has_password?"PrivacyAndSecurity.Item.On":"PrivacyAndSecurity.Item.Off")),r.freezed=!1})),this.updateActiveSessions()}{const e=new ei({name:"PrivacyTitle",caption:"GroupsAndChannelsHelp"});e.content.classList.add("privacy-navigation-container");const i={},s=i.inputPrivacyKeyPhoneNumber=new M.ZP({titleLangKey:"PrivacyPhoneTitle",subtitleLangKey:t,clickable:()=>{this.slider.createTab(N).open()},listenerSetter:this.listenerSetter}),a=i.inputPrivacyKeyStatusTimestamp=new M.ZP({titleLangKey:"LastSeenTitle",subtitleLangKey:t,clickable:()=>{this.slider.createTab(ae).open()},listenerSetter:this.listenerSetter}),o=i.inputPrivacyKeyProfilePhoto=new M.ZP({titleLangKey:"PrivacyProfilePhotoTitle",subtitleLangKey:t,clickable:()=>{this.slider.createTab(oe).open()},listenerSetter:this.listenerSetter}),r=i.inputPrivacyKeyPhoneCall=new M.ZP({titleLangKey:"WhoCanCallMe",subtitleLangKey:t,clickable:()=>{this.slider.createTab(le).open()},listenerSetter:this.listenerSetter}),d=i.inputPrivacyKeyForwards=new M.ZP({titleLangKey:"PrivacyForwardsTitle",subtitleLangKey:t,clickable:()=>{this.slider.createTab(re).open()},listenerSetter:this.listenerSetter}),l=i.inputPrivacyKeyChatInvite=new M.ZP({titleLangKey:"WhoCanAddMe",subtitleLangKey:t,clickable:()=>{this.slider.createTab(de).open()},listenerSetter:this.listenerSetter}),c=i.inputPrivacyKeyVoiceMessages=new M.ZP({titleLangKey:"PrivacyVoiceMessagesTitle",subtitleLangKey:t,clickable:()=>{n.Z.premium?this.slider.createTab(Ie).open():(0,F.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;t.subtitle.innerHTML="";const o=(0,p.ag)(s);t.subtitle.append(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(Ce(e.key._))}))}const i=[];{const t=new ei({name:"NewChatsFromNonContacts",caption:"ArchiveAndMuteInfo"}),s=new Se.Z({text:"ArchiveAndMute"}),a=new M.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 ei({name:"Privacy.SensitiveContent",caption:"PrivacyAndSecurity.SensitiveDesc"});t.container.classList.add("hide");const s=new Se.Z({text:"PrivacyAndSecurity.SensitiveText"}),n=new M.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 ei({name:"PrivacyPayments",caption:"PrivacyPaymentsClearInfo"}),t=()=>{const e={titleLangKey:"PrivacyPaymentsClearAlertTitle",descriptionLangKey:"PrivacyPaymentsClearAlertText",button:{langKey:"Clear"},checkboxes:[{text:"PrivacyClearShipping",checked:!0},{text:"PrivacyClearPayment",checked:!0}]};(0,Le.Z)(e).then((()=>{const[t,s]=e.checkboxes.map((e=>e.checkboxField.checked)),n=(0,K.Z)([i],!0);this.managers.appPaymentsManager.clearSavedInfo(t,s).then((()=>{(t||s)&&(n(),(0,F.bC)({langPackKey:t&&s?"PrivacyPaymentsPaymentShippingCleared":t?"PrivacyPaymentsShippingInfoCleared":"PrivacyPaymentsPaymentInfoCleared"}))}))}),Ee.Z)},i=(0,E.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 ei({name:"FilterChats"}),t=()=>{new O.Z("popup-delete-drafts",{buttons:[{langKey:"Delete",callback:()=>{const e=(0,K.Z)([i],!0);this.managers.appDraftsManager.clearAllDrafts().then((()=>{e()}))},isDanger:!0}],titleLangKey:"AreYouSureClearDraftsTitle",descriptionLangKey:"AreYouSureClearDrafts"}).show()},i=(0,E.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(){this.managers.apiManager.invokeApi("account.getAuthorizations").then((e=>{this.activeSessionsRow.freezed=!1,this.authorizations=e.authorizations,(0,p.$d)(this.activeSessionsRow.subtitle,"Privacy.Devices",[this.authorizations.length])}))}}var Pe=i(65),Ze=i(6740);function ke(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 Te=i(6705),xe=i(3725),Ae=i(2064);function _e(e){let{h:t,s:i,l:s}=(0,Ae.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 Fe=i(8479),De=i(9674),Re=i(1571),Be=i(2312),Ne=i(3442),Oe=i(6724),Ue=i(6714),He=i(5077),ze=i(3228);class je{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(je.BASE_CLASS);const e=`\n <svg class="${je.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="${je.BASE_CLASS+"-dragger"} ${je.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="${je.BASE_CLASS+"-sliders"}">\n <svg class="${je.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="${je.BASE_CLASS+"-dragger"} ${je.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 u.ZP({plainText:!0,label:"Appearance.Color.Hex"}),this.rgbInputField=new u.ZP({plainText:!0,label:"Appearance.Color.RGB"});const t=document.createElement("div");t.className=je.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?u.I1.Neutral:u.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?u.I1.Neutral:u.I1.Error),e&&this.setColor((0,Ae.dI)(+e[1],+e[2],+e[3]),!0,!1)})),this.attachBoxListeners(),this.attachHueListeners()}attachBoxListeners(){(0,He.Z)(this.elements.box,(()=>{this.onGrabStart(),this.boxRect=this.elements.box.getBoundingClientRect()}),(e=>{this.saturationHandler(e.x,e.y)}),(()=>{this.onGrabEnd()}))}attachHueListeners(){(0,He.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,Ae.cw)(e);else{const t=e.match(/[.?\d]+/g);e=(0,Ae.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,Ae.Y6)(this.hue,this.saturation,this.lightness,this.alpha),t=(0,Ae.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(u.I1.Neutral)),t&&(this.rgbInputField.setValueSilently(i.rgbaArray.slice(0,-1).join(", ")),this.rgbInputField.setState(u.I1.Neutral)),this.onChange&&this.onChange(i)}hueHandler(e,t=!0){const i=(0,ze.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,ze.Z)(e-this.boxRect.left,0,s)/s*100,o=(0,ze.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,ze.Z)(a,0,100),l=100-d/2,c=100-(0,ze.Z)(o,0,100),h=(0,ze.Z)(c/100*l,0,100);this.saturation=d,this.lightness=h,i&&this.updatePicker()}}je.BASE_CLASS="color-picker";class Ge extends l._{constructor(){super(...arguments),this._applyColor=(e,t=!0)=>{if(t)this.colorPicker.setColor(e);else{const t=(0,Ae.Pi)(e),i=this.theme.background,a=_e(t);i.id="2",i.intensity=0,i.slug="",i.color=e.toLowerCase(),i.highlightningColor=a,this.managers.appStateManager.pushToState("settings",n.Z.settings),s.Z.applyCurrentTheme(void 0,void 0,!0),this.setActive()}},this.onColorChange=e=>{this.applyColor(e.hex,!1)}}init(){this.header.classList.add("with-border"),this.container.classList.add("background-container","background-color-container"),this.setTitle("SetColor"),this.theme=Ue.Z.getTheme();const e=new ei({});this.colorPicker=new je,e.content.append(this.colorPicker.container),this.scrollable.append(e.container);const t=new ei({}),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,v.fc)(i,(e=>{const t=(0,he.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,Oe.Z)(this._applyColor,16,!0)}setActive(){const e=this.grid.querySelector(".active"),t=this.theme.background,i=t.color?this.grid.querySelector(`.grid-item[data-color="${t.color}"]`):null;e!==i&&(e&&e.classList.remove("active"),i&&i.classList.add("active"))}onOpen(){setTimeout((()=>{const e=this.theme.background,t=(e.color||"").split(",")[0],i=!!t&&!e.slug;i&&(this.colorPicker.onChange=this.onColorChange),this.colorPicker.setColor(t||"#cccccc"),i||(this.colorPicker.onChange=this.onColorChange)}),0)}onCloseAfterTimeout(){return this.colorPicker.onChange=void 0,this.colorPicker=void 0,super.onCloseAfterTimeout()}}var Ve=i(7030),Ke=i(236),We=i(7814),$e=i(9405),qe=i(9492),Qe=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 Ye extends l._{constructor(){super(...arguments),this.tempId=0,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",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=>Qe(this,void 0,void 0,(function*(){if(e.name.endsWith(".png")){const t=document.createElement("img"),i=URL.createObjectURL(e);yield(0,Ze.cj)(t,i,!1);const s="image/jpeg",{blob:n}=yield(0,We.Z)({media:t,size:new $e.c(t.naturalWidth,t.naturalHeight),mimeType:s});e=new File([n],e.name.replace(/\.png$/,".jpg"),{type:s})}const t=yield this.managers.appDocsManager.prepareWallPaperUpload(e),i=this.managers.appDocsManager.uploadWallPaper(t.id),s=Be.Z.getNewDeferredForUpload(e.name,i),n=(0,xe.Z)();n.addNotifyListener=s.addNotifyListener,n.cancel=s.cancel,s.then((e=>{this.clicked.delete(a),this.elementsByKey.delete(a),this.wallPapersByElement.set(r,e);const t=this.getWallPaperKey(e);this.elementsByKey.set(t,r),this.setBackgroundDocument(e).then(n.resolve,n.reject)}),n.reject);const a=this.getWallPaperKey(t);n.catch((()=>{r.remove()}));const o=new Ne.Z({isUpload:!0,cancelable:!0,tryAgainOnFail:!1}),r=this.addWallPaper(t,!1);this.clicked.add(a),o.attach(r,!1,n)}))))},this.onResetClick=()=>{const e=Ke.h.settings.themes.find((e=>e.name===this.theme.name));e&&(++this.tempId,this.theme.background=(0,Fe.Z)(e.background),this.managers.appStateManager.pushToState("settings",n.Z.settings),s.Z.applyCurrentTheme(void 0,void 0,!0),this.blurCheckboxField.setValueSilently(this.theme.background.blur))},this.onGridClick=e=>{const t=(0,he.Z)(e.target,"grid-item");if(!t)return;const i=this.wallPapersByElement.get(t);if("wallPaperNoFile"===i._)return void this.setBackgroundDocument(i);const s=this.getWallPaperKey(i);if(this.clicked.has(s))return;this.clicked.add(s);const n=i.document,a=new Ne.Z({cancelable:!0,tryAgainOnFail:!1}),o=()=>Qe(this,void 0,void 0,(function*(){const e=this.setBackgroundDocument(i);(yield this.managers.thumbsStorage.getCacheContext(n)).url&&!this.theme.background.blur||a.attach(t,!0,e)}));a.construct(),(0,v.fc)(t,(e=>{a.preloader.parentElement?(a.onClick(e),a.detach()):o()}),{listenerSetter:this.listenerSetter}),o()},this.saveToCache=(e,t)=>{fetch(t).then((t=>{s.Z.cacheStorage.save("backgrounds/"+e,t)}))},this.setBackgroundDocument=e=>{const t=++this.tempId,i=()=>t===this.tempId,a=e.document,o=(0,xe.Z)();let r;return a?(r=Be.Z.downloadMediaURL({media:a,queueId:s.Z.chat.bubbles?s.Z.chat.bubbles.lazyLoadQueue.queueId:0}),o.addNotifyListener=r.addNotifyListener,o.cancel=r.cancel):r=Promise.resolve(),r.then((()=>Qe(this,void 0,void 0,(function*(){if(!i())return void o.resolve();const t=this.theme.background,r=a=>{let r;const d=this.getColorsFromWallPaper(e);if(a&&!d)r=function(e){const t=document.createElement("img");return(0,Ze.cj)(t,e,!1).then((()=>function(e,t,i){const s=document.createElement("canvas"),n=t/i;return 1===n?(s.width=50,s.height=s.width/n):n>1?(s.height=50,s.width=s.height/n):s.width=s.height=50,s.getContext("2d").drawImage(e,0,0,t,i,0,0,s.width,s.height),ke(s)}(t,t.naturalWidth,t.naturalHeight)))}(a);else{const{canvas:e}=Re.Z.create(d);r=Promise.resolve(ke(e))}r.then((r=>{var l,c,h;if(!i())return void o.resolve();const u=_e(Array.from(r)),f=null!==(l=e.slug)&&void 0!==l?l:"";t.id=e.id,t.intensity=null!==(h=null===(c=e.settings)||void 0===c?void 0:c.intensity)&&void 0!==h?h:0,t.color=d,t.slug=f,t.highlightningColor=u,this.managers.appStateManager.pushToState("settings",n.Z.settings),f&&this.saveToCache(f,a),s.Z.applyCurrentTheme(f,a,!0).then(o.resolve)}))};if(!a)return void r();const d=yield this.managers.thumbsStorage.getCacheContext(a);t.blur?setTimeout((()=>{const{canvas:e,promise:t}=(0,Te.Z)(d.url,12,4);t.then((()=>{i()?r(e.toDataURL()):o.resolve()}))}),200):r(d.url)})))),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"))}}get theme(){return Ue.Z.getTheme()}init(){this.header.classList.add("with-border"),this.container.classList.add("background-container","background-image-container"),this.setTitle("ChatBackground");{const e=ti(this.scrollable),i=(0,E.Z)("btn-primary btn-transparent",{icon:"cameraadd",text:"ChatBackground.UploadWallpaper"}),s=(0,E.Z)("btn-primary btn-transparent",{icon:"colorize",text:"SetColor"}),a=(0,E.Z)("btn-primary btn-transparent",{icon:"favourites",text:"Appearance.Reset"});(0,v.fc)(i,this.onUploadClick,{listenerSetter:this.listenerSetter}),(0,v.fc)(s,(()=>{this.slider.createTab(Ge).open()}),{listenerSetter:this.listenerSetter}),(0,v.fc)(a,this.onResetClick,{listenerSetter:this.listenerSetter});const o=this.blurCheckboxField=new Se.Z({text:"ChatBackground.Blur",name:"blur",checked:this.theme.background.blur});this.listenerSetter.add(o.input)("change",(()=>Qe(this,void 0,void 0,(function*(){this.theme.background.blur=o.input.checked,yield this.managers.appStateManager.pushToState("settings",n.Z.settings),setTimeout((()=>{const e=t.querySelector(".active");if(!e)return;const i=this.wallPapersByElement.get(e);i.pFlags.pattern||"wallPaperNoFile"===i._||this.setBackgroundDocument(i)}),100)})))),e.append(i,s,a,(0,M.tG)(o).container)}n.Z.addEventListener("background_change",this.setActive),this.managers.appDocsManager.getWallPapers().then((e=>{e.forEach((e=>{this.addWallPaper(e)}))}));const e=ti(this.scrollable),t=this.grid=document.createElement("div");t.classList.add("grid"),(0,v.fc)(t,this.onGridClick,{listenerSetter:this.listenerSetter}),e.append(t)}getColorsFromWallPaper(e){return e.settings?[e.settings.background_color,e.settings.second_background_color,e.settings.third_background_color,e.settings.fourth_background_color].filter(Boolean).map((e=>"#"+e.toString(16))).join(","):""}getWallPaperKey(e){return""+e.id}getWallPaperKeyFromTheme(e){return""+e.background.id}addWallPaper(e,t=!0){const i=this.getColorsFromWallPaper(e),s="wallPaper"===e._;if(s&&e.pFlags.pattern&&!i)return;const n=!!e.pFlags.dark,a=s?e.document:void 0,o=document.createElement("div");o.classList.add("grid-item"),o.dataset.id=""+e.id;const r=this.getWallPaperKey(e);this.wallPapersByElement.set(o,e),this.elementsByKey.set(r,o);const d=document.createElement("div");let l,c;if(d.classList.add("grid-item-media"),s?(c=(0,Ve.Z)(a,200,200),l=(0,qe.Z)({photo:a,message:null,container:d,withoutPreloader:!0,size:c,noFadeIn:e.pFlags.pattern}),e.pFlags.pattern&&d.classList.add("is-pattern"),l.then((({loadPromises:e,images:t})=>Qe(this,void 0,void 0,(function*(){return(yield e.thumb)||e.full,t})))).then((t=>{var i;e.pFlags.pattern&&(n?(t.full.style.display="none",t.thumb&&(t.thumb.style.display="none")):(null===(i=e.settings)||void 0===i?void 0:i.intensity)&&(t.full.style.opacity=""+Math.abs(e.settings.intensity)/100)),De.Z.mutate((()=>{o.append(d)}))}))):o.append(d),e.settings&&void 0!==e.settings.background_color){const{canvas:t}=Re.Z.create(i);t.classList.add("background-colors-canvas"),n&&s?l.then((({loadPromises:i})=>{i.full.then((()=>Qe(this,void 0,void 0,(function*(){const i=yield this.managers.thumbsStorage.getCacheContext(a,c.type);t.style.webkitMaskImage=`url(${i.url})`,t.style.opacity=""+(e.pFlags.dark?100+e.settings.intensity:e.settings.intensity)/100,d.append(t)}))))})):d.append(t)}return this.getWallPaperKeyFromTheme(this.theme)===r&&o.classList.add("active"),this.grid[t?"append":"prepend"](o),o}}var Je=i(8938),Xe=i(2153),et=i(6787),tt=i(6761);var it=i(3731),st=i(62);class nt extends I.Z{init(){return this.header.classList.add("with-border"),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 ei,s=t.map((t=>{const i=new x.Z({name:"quick-reaction",text:t.title,value:t.reaction,alignRight:!0}),s=new M.ZP({radioField:i,havePadding:!0});return i.main.classList.add("quick-reaction-title"),(0,st.Z)({row:s,doc:t.static_icon,size:"small"}),t.reaction===e.reaction&&i.setValueSilently(!0),s})),n=(0,M.De)(s,(e=>{this.managers.appReactionsManager.setDefaultReaction({_:"reactionEmoji",emoticon:e})}));i.content.append(n),this.scrollable.append(i.container)}))}}var at=i(1273);class ot{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,p.$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 Pe.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 rt extends I.h{init(){this.header.classList.add("with-border"),this.container.classList.add("general-settings-container"),this.setTitle("General");const e=ti.bind(null,this.scrollable);{const t=e("Settings"),i=new ot("TextSize",1,n.Z.settings.messagesTextSize,12,20);i.onChange=e=>{n.Z.managers.appStateManager.setByKey("settings.messagesTextSize",e)};const s=(0,E.Z)("btn-primary btn-transparent",{icon:"image",text:"ChatBackground"});(0,v.fc)(s,(()=>{this.slider.createTab(Ye).open()}));const a=new Se.Z({text:"EnableAnimations",name:"animations",stateKey:"settings.animationsEnabled",listenerSetter:this.listenerSetter});t.append(i.container,s,(0,M.tG)(a).container)}{const t=e("General.Keyboard"),i=document.createElement("form"),s="send-shortcut",n="settings.sendShortcut",a=new M.ZP({radioField:new x.Z({langKey:"General.SendShortcut.Enter",name:s,value:"enter",stateKey:n}),subtitleLangKey:"General.SendShortcut.NewLine.ShiftEnter"}),o=new M.ZP({radioField:new x.Z({name:s,value:"ctrlEnter",stateKey:n}),subtitleLangKey:"General.SendShortcut.NewLine.Enter"});(0,p.$d)(o.radioField.main,"General.SendShortcut.CtrlEnter",[G.IS_APPLE?"⌘":"Ctrl"]),i.append(a.container,o.container),t.append(i)}if(it.Z){const t=e("DistanceUnitsTitle"),i=document.createElement("form"),s="distance-unit",n="settings.distanceUnit",a=new M.ZP({radioField:new x.Z({langKey:"DistanceUnitsKilometers",name:s,value:"kilometers",stateKey:n})}),o=new M.ZP({radioField:new x.Z({langKey:"DistanceUnitsMiles",name:s,value:"miles",stateKey:n})});i.append(a.container,o.container),t.append(i)}{const t=e("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 M.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=Ee.Z),function i(){e(),n=tt.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))),t.append(i)}{const t=e("Emoji"),i=new Se.Z({text:"GeneralSettings.EmojiPrediction",name:"suggest-emoji",stateKey:"settings.emoji.suggest",listenerSetter:this.listenerSetter}),s=new Se.Z({text:"GeneralSettings.BigEmoji",name:"emoji-big",stateKey:"settings.emoji.big",listenerSetter:this.listenerSetter});t.append((0,M.tG)(i).container,(0,M.tG)(s).container)}{const e=new ei({name:"Telegram.InstalledStickerPacksController",caption:"StickersBotInfo"}),t=new M.ZP({titleLangKey:"DoubleTapSetting",havePadding:!0,clickable:()=>{this.slider.createTab(nt).open()},listenerSetter:this.listenerSetter}),i=()=>{this.managers.appReactionsManager.getQuickReaction().then((e=>"availableReaction"===e._?e.static_icon:this.managers.appEmojiManager.getCustomEmojiDocument(e.document_id))).then((e=>{(0,st.Z)({row:t,doc:e,size:"small"})}))};i(),this.listenerSetter.add(n.Z)("quick_reaction",i);const s=new Se.Z({text:"Stickers.SuggestStickers",name:"suggest",stateKey:"settings.stickers.suggest",listenerSetter:this.listenerSetter}),a=new Se.Z({text:"InstalledStickers.LoopAnimated",name:"loop",stateKey:"settings.stickers.loop",listenerSetter:this.listenerSetter}),o={},r=e.generateContentElement(),d=new Xe.Z,l=(e,t="append")=>{const i=new M.ZP({title:(0,Y.Z)(e.title),subtitleLangKey:"Stickers",subtitleLangArgs:[e.count],havePadding:!0,clickable:()=>{new et.Z({id:e.id,access_hash:e.access_hash}).show()},listenerSetter:this.listenerSetter});o[e.id]=i;const s=document.createElement("div");s.classList.add("row-media"),(0,at.Z)({set:e,container:s,group:"GENERAL-SETTINGS",lazyLoadQueue:d,width:36,height:36,autoplay:!0}),i.container.append(s),r[t](i.container)};this.managers.appStickersManager.getAllStickers().then((e=>{(0,Je.Z)(e);for(const t of e.sets)l(t)})),this.listenerSetter.add(n.Z)("stickers_installed",(e=>{o[e.id]||l(e,"prepend")})),this.listenerSetter.add(n.Z)("stickers_deleted",(e=>{o[e.id]&&(o[e.id].container.remove(),delete o[e.id])})),e.content.append(t.container,(0,M.tG)(s).container,(0,M.tG)(a).container),this.scrollable.append(e.container)}}onOpen(){this.init&&(this.init(),this.init=null)}}var dt=i(2621),lt=i(6726);class ct extends l._{static getInitArgs(){return{bioMaxLength:n.Z.managers.apiManager.getLimit("bio"),user:n.Z.managers.appUsersManager.getSelf(),userFull:n.Z.managers.appProfileManager.getProfile(n.Z.myId.toUserId())}}init(e){return t=this,i=void 0,a=function*(){this.container.classList.add("edit-profile-container"),this.setTitle("EditAccount.Title");const t=[],[i,s,a]=yield Promise.all([e.bioMaxLength,e.user,e.userFull]);{const e=ti(this.scrollable,void 0,"Bio.Description"),s=document.createElement("div");s.classList.add("input-wrapper"),this.firstNameInputField=new u.ZP({label:"EditProfile.FirstNameLabel",name:"first-name",maxLength:70}),this.lastNameInputField=new u.ZP({label:"Login.Register.LastName.Placeholder",name:"last-name",maxLength:64}),this.bioInputField=new u.ZP({label:"EditProfile.BioLabel",name:"bio",maxLength:i}),s.append(this.firstNameInputField.container,this.lastNameInputField.container,this.bioInputField.container);const a=document.createElement("div");a.classList.add("caption"),(0,p.XZ)({element:a,key:"Bio.Description"}),t.push(this.firstNameInputField,this.lastNameInputField,this.bioInputField),this.editPeer=new dt.Z({peerId:n.Z.myId,inputFields:t,listenerSetter:this.listenerSetter}),this.content.append(this.editPeer.nextBtn),e.append(this.editPeer.avatarEdit.container,s)}{const e=new ei({name:"EditAccount.Username",caption:!0}),i=document.createElement("div");i.classList.add("input-wrapper"),this.usernameInputField=new lt.l({label:"EditProfile.Username.Label",name:"username",plainText:!0,listenerSetter:this.listenerSetter,onChange:()=>{this.editPeer.handleChange(),this.setProfileUrl()},availableText:"EditProfile.Username.Available",takenText:"EditProfile.Username.Taken",invalidText:"EditProfile.Username.Invalid"},this.managers),i.append(this.usernameInputField.container);const s=e.caption;s.append((0,p.ag)("UsernameSettings.ChangeDescription")),s.append(document.createElement("br"),document.createElement("br"));const n=this.profileUrlContainer=document.createElement("div");n.classList.add("profile-url-container");const a=this.profileUrlAnchor=B();n.append((0,p.ag)("UsernameHelpLink",[a])),s.append(n),t.push(this.usernameInputField),e.content.append(i),this.scrollable.append(e.container)}(0,v.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(s.first_name,!0),this.lastNameInputField.setOriginalValue(s.last_name,!0),this.bioInputField.setOriginalValue(a.about,!0),this.usernameInputField.setOriginalValue(s.username,!0),this.setProfileUrl(),this.editPeer.handleChange()},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}setProfileUrl(){this.usernameInputField.input.classList.contains("error")||!this.usernameInputField.value.length?this.profileUrlContainer.style.display="none":(this.profileUrlContainer.style.display="",this.profileUrlAnchor.replaceWith(this.profileUrlAnchor=B({mePath:this.usernameInputField.value})))}}var ht=i(7425),ut=i(1507),ft=i(3855),pt=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 mt extends I.h{init(){this.header.classList.add("with-border"),this.container.classList.add("notifications-container","with-border"),this.setTitle("Telegram.NotificationSettingsViewController");const e=e=>{const t=new ei({name:e.name}),i=new M.ZP({checkboxField:new Se.Z({text:e.typeText,checked:!0}),subtitleLangKey:"Loading",listenerSetter:this.listenerSetter,withCheckboxSubtitle:!0}),s=new M.ZP({checkboxField:new Se.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=()=>pt(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",(()=>pt(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,Fe.Z)(t);o._="inputPeerNotifySettings",o.mute_until=e?ut.rU:0,o.show_previews=n,this.managers.appNotificationsManager.updateNotifySettings(a,o)}))),{once:!0}),this.listenerSetter.add(n.Z)("notify_settings",(i=>{const s=Ce(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 ei({name:"NotificationsOther"}),t=new M.ZP({checkboxField:new Se.Z({text:"ContactJoined",checked:!0}),subtitleLangKey:"Loading",listenerSetter:this.listenerSetter,withCheckboxSubtitle:!0}),i=new M.ZP({checkboxField:new Se.Z({text:"Notifications.Sound",checked:!0,stateKey:"settings.notifications.sound",listenerSetter:this.listenerSetter}),subtitleLangKey:"Loading",listenerSetter:this.listenerSetter,withCheckboxSubtitle:!0});ft.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 gt 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 ei({}),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,Z.a)();e.concat(s).forEach((e=>{if(n.has(e.lang_code))return;n.add(e.lang_code);const t=new M.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,M.De)([...i.values()],(e=>{p.ZP.getLangPack(e,a.includes(e))}));p.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 vt=i(1447),bt=i(4081),yt=i(6848),wt=i(5701);function St(e,t,i){const s=new ei({name:t}),n="settings.autoDownload."+e+".",a=new Se.Z({text:"AutodownloadContacts",name:"contacts",stateKey:n+"contacts",listenerSetter:i}),o=new Se.Z({text:"AutodownloadPrivateChats",name:"private",stateKey:n+"private",listenerSetter:i}),r=new Se.Z({text:"AutodownloadGroupChats",name:"groups",stateKey:n+"groups",listenerSetter:i}),d=new Se.Z({text:"AutodownloadChannels",name:"channels",stateKey:n+"channels",listenerSetter:i});return s.content.append((0,M.tG)(a).container,(0,M.tG)(o).container,(0,M.tG)(r).container,(0,M.tG)(d).container),s}class Ct extends I.h{init(){this.header.classList.add("with-border"),this.setTitle("AutoDownloadPhotos");const e=St("photo","AutoDownloadPhotosTitle",this.listenerSetter);this.scrollable.append(e.container)}}class Lt extends I.h{init(){this.header.classList.add("with-border"),this.setTitle("AutoDownloadFiles");const e=(0,wt.Z)((e=>{this.managers.appStateManager.setByKey("settings.autoDownloadNew.file_size_max",e)}),200,!1,!0),t=St("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 p.ZP.IntlElement({key:"AutodownloadSizeLimitUpTo",args:[(0,bt.Z)(a)]}),d=new ot("AutoDownloadMaxFileSize",.01,o,0,1,!1);d.onChange=t=>{const n=Math.pow(t,4)*s+i|0;r.compareAndUpdate({args:[(0,bt.Z)(n)]}),e(n)},d.valueContainer.append(r.element),t.content.append(d.container),this.scrollable.append(t.container)}}class Et extends I.h{init(){this.header.classList.add("with-border"),this.setTitle("AutoDownloadVideos");const e=St("video","AutoDownloadVideosTitle",this.listenerSetter);this.scrollable.append(e.container)}}const It={contacts:"AutoDownloadContacts",private:"AutoDownloadPm",groups:"AutoDownloadGroups",channels:"AutoDownloadChannels"};class Mt extends I.h{init(){return e=this,t=void 0,s=function*(){this.header.classList.add("with-border"),this.setTitle("DataSettings");{const e=new ei({name:"AutomaticMediaDownload",caption:"AutoDownloadAudioInfo"}),t=yield ft.Z.getState(),i=new Se.Z({text:"AutoDownloadMedia",name:"auto",checked:!t.settings.autoDownloadNew.pFlags.disabled,listenerSetter:this.listenerSetter}),s=new M.ZP({checkboxField:i,listenerSetter:this.listenerSetter}),a=()=>{(0,K.Z)([h],(0,yt.Z)(t.settings.autoDownload,Ke.h.settings.autoDownload)&&(0,yt.Z)(t.settings.autoDownloadNew,Ke.h.settings.autoDownloadNew))},o=()=>{this.setAutoDownloadSubtitle(d,t.settings.autoDownload.photo),this.setAutoDownloadSubtitle(l,t.settings.autoDownload.video),this.setAutoDownloadSubtitle(c,t.settings.autoDownload.file,t.settings.autoDownloadNew.file_size_max)},r=e=>{const t=this.slider.createTab(e);t.open(),this.listenerSetter.add(t.eventListener)("destroy",(()=>{o(),a()}),{once:!0})},d=new M.ZP({titleLangKey:"AutoDownloadPhotos",subtitle:"",clickable:()=>{r(Ct)},listenerSetter:this.listenerSetter}),l=new M.ZP({titleLangKey:"AutoDownloadVideos",subtitle:"",clickable:()=>{r(Et)},listenerSetter:this.listenerSetter}),c=new M.ZP({titleLangKey:"AutoDownloadFiles",subtitle:"",clickable:()=>{r(Lt)},listenerSetter:this.listenerSetter}),h=(0,E.Z)("btn-primary btn-transparent primary",{icon:"delete",text:"ResetAutomaticMediaDownload"});(0,v.fc)(h,(()=>{(0,Le.Z)({titleLangKey:"ResetAutomaticMediaDownloadAlertTitle",descriptionLangKey:"ResetAutomaticMediaDownloadAlert",button:{langKey:"Reset"}}).then((()=>{const e=n.Z.settings;e.autoDownloadNew=(0,Fe.Z)(Ke.h.settings.autoDownloadNew),e.autoDownload=(0,Fe.Z)(Ke.h.settings.autoDownload),t.settings=e,this.managers.appStateManager.setByKey("settings",e),o(),i.checked=!t.settings.autoDownloadNew.pFlags.disabled}))}));const u=()=>{const e=!i.checked,t=n.Z.settings;e?t.autoDownloadNew.pFlags.disabled=!0:delete t.autoDownloadNew.pFlags.disabled,[d,l,c].forEach((t=>{t.container.classList.toggle("is-disabled",e)})),this.managers.appStateManager.setByKey("settings",t),a()};i.input.addEventListener("change",u),u(),o(),e.content.append(s.container,d.container,l.container,c.container,h),this.scrollable.append(e.container)}{const e=new ei({name:"AutoplayMedia"});e.content.append(new M.ZP({checkboxField:new Se.Z({text:"AutoplayGIF",name:"gifs",stateKey:"settings.autoPlay.gifs",listenerSetter:this.listenerSetter}),listenerSetter:this.listenerSetter}).container,new M.ZP({checkboxField:new Se.Z({text:"AutoplayVideo",name:"videos",stateKey:"settings.autoPlay.videos",listenerSetter:this.listenerSetter}),listenerSetter:this.listenerSetter}).container),this.scrollable.append(e.container)}},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}setAutoDownloadSubtitle(e,t,i){let s;const n=[],a=Object.keys(t),o=a.map((e=>t[e]?It[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,bt.Z)(i))):s=e?"AutoDownloadOnAllChats":"AutoDownloadOnFor",!e){const e=document.createElement("span");e.append(...(0,p.v_)(o.map((e=>(0,p.ag)(e))),!0,!1)),n.push(e)}}else s="AutoDownloadOff";(0,P.Z)(e.subtitle,(0,p.ag)(s,n))}}var Pt=i(2230),Zt=i(8261),kt=i(6765),Tt=i(1168),xt=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 At extends l._{constructor(){super(...arguments),this.buttons={}}init(){return xt(this,void 0,void 0,(function*(){this.container.classList.add("settings-container"),this.setTitle("Settings");const e=(0,L.Z)({listenerSetter:this.listenerSetter},"bottom-left",[{icon:"logout",text:"EditAccount.Logout",onClick:()=>{new O.Z("logout",{titleLangKey:"LogOut",descriptionLangKey:"LogOut.Description",buttons:[{langKey:"LogOut",callback:()=>{this.managers.apiManager.logOut()},isDanger:!0}]}).show()}}]);this.buttons.edit=(0,Pt.Z)("edit"),this.header.append(this.buttons.edit,e),this.profile=new Zt.Z(this.managers,this.scrollable,this.listenerSetter,!1),this.profile.init(),this.profile.setPeer(n.Z.myId);const t=this.profile.fillProfileElements(),i=(0,E.Z)("btn-circle btn-corner z-depth-1 profile-change-avatar",{icon:"cameraadd"});(0,v.fc)(i,(()=>{const e=document.createElement("canvas");Tt.Z.createPopup(kt.Z).open(e,(e=>{e().then((e=>this.managers.appProfileManager.uploadProfilePhoto(e)))}))}),{listenerSetter:this.listenerSetter}),this.profile.element.lastElementChild.firstElementChild.append(i);const s=()=>xt(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",(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",mt),o("data","DataSettings",Mt),o("lock","AccountSettings.PrivacyAndSecurity",Me),o("settings","Telegram.GeneralSettingsViewController",rt),o("folder","AccountSettings.Filters",ht.Z)].map((e=>{const{icon:t,text:i,tabConstructor:s,getInitArgs:n}=e;return new M.ZP({titleLangKey:i,icon:t,clickable:()=>xt(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=gt.getInitArgs();r.push(this.devicesRow=new M.ZP({titleLangKey:"Devices",titleRightSecondary:" ",icon:"activesessions",clickable:()=>xt(this,void 0,void 0,(function*(){this.authorizations||(yield this.updateActiveSessions());const e=this.slider.createTab(ge);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 M.ZP({titleLangKey:"AccountSettings.Language",titleRightSecondary:(0,p.ag)("LanguageName"),icon:"language",clickable:()=>{this.slider.createTab(gt).open(d)},listenerSetter:this.listenerSetter})),a.append(...r.map((e=>e.container)));const l=new ei;l.content.append(a),this.scrollable.append(this.profile.element,l.container);const c=()=>{h=ct.getInitArgs()};let h;(0,v.fc)(this.buttons.edit,(()=>{this.slider.createTab(ct).open(h)}),{listenerSetter:this.listenerSetter}),c(),this.listenerSetter.add(n.Z)("user_update",(e=>{n.Z.myId.toUserId()===e&&c()})),vt.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 _t extends l._{constructor(){super(...arguments),this.uploadAvatar=null}init(){this.container.classList.add("new-channel-container"),this.setTitle("NewChannel"),this.avatarEdit=new f.Z((e=>{this.uploadAvatar=e}));const e=new ei({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.Z.setInnerPeer({peerId:e.toPeerId(!0)}),ni.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 Ft=i(241),Dt=i(709),Rt=i(6272);class Bt extends Tt.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,F.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 Dt.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,Rt.u)(o.phone);r.code&&(n.value="+"+r.code.country_code);const d=new dt.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 Nt=i(2894),Ot=i(3624);class Ut 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,(()=>{Tt.Z.createPopup(Bt)}),{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,Ot.k)(),this.openContacts()}createList(){const e=new Nt.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(){!G.IS_MOBILE&&V(!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=Ft.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,P.Z)(this.scrollable.container,i.list)}))}}class Ht extends l._{init(){if(this.wasFilterId=h.default.filterId,this.container.id="chats-archived-container",this.setTitle("ArchivedChats"),!h.default.sortedLists[Ht.filterId]){const e=h.default.createChatList();h.default.generateScrollable(e,{title:void 0,id:Ht.filterId,localId:ut.Zi}).container.append(e),h.default.setListClickListener(e,null,!0)}const e=h.default.scrollables[Ht.filterId];return this.scrollable.container.replaceWith(e.container),h.default.setFilterIdAndChangeTab(Ht.filterId).then((({cached:e,renderPromise:t})=>{if(e)return t}))}onOpenAfterTimeout(){h.default.sortedLists[this.wasFilterId].clear()}onClose(){h.default.setFilterIdAndChangeTab(this.wasFilterId)}onCloseAfterTimeout(){return h.default.sortedLists[Ht.filterId].clear(),super.onCloseAfterTimeout()}}Ht.filterId=ut.Zi;class zt extends l._{constructor(){super(...arguments),this.isLocationWatched=!1}parseDistance(e){return"miles"===n.Z.settings.distanceUnit?e>1609.34?(0,p.ag)("MilesAway",[Math.round(e/1609)]):(0,p.ag)("FootsAway",[Math.round(3.281*e)]):e>=1e3?(0,p.ag)("KMetersAway2",[e/1e3]):(0,p.ag)("MetersAway2",[e])}startWatching(){this.latestLocationSaved&&!this.isLocationWatched&&(this.isLocationWatched=!0,(0,F.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,F.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 jt=i(9818),Gt=i(8842),Vt=i(4159),Kt=i(7487),Wt=i(1405),$t=i(1655),qt=i(2559),Qt=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 Yt="is-left-column-shown";class Jt 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(Ut).open()};this.backBtn=this.sidebarEl.querySelector(".sidebar-back-button");const a={icon:"archive",text:"ArchivedChats",onClick:()=>{this.createTab(Ht).open()},verify:()=>Qt(this,void 0,void 0,(function*(){return!!(yield this.managers.dialogsStorage.getFolderDialogs(1,!1)).length||!(yield this.managers.dialogsStorage.isDialogsLoaded(1))}))},o=new Se.Z({toggle:!0,checked:"night"===Ue.Z.getTheme().name});o.input.addEventListener("change",(()=>Qt(this,void 0,void 0,(function*(){yield this.managers.appStateManager.setByKey("settings.theme",o.input.checked?"night":"day"),n.Z.dispatchEvent("theme_change")})))),n.Z.addEventListener("theme_change",(()=>{o.setValueSilently("night"===Ue.Z.getTheme().name)}));const r=[{icon:"savedmessages",text:"SavedMessages",onClick:()=>{setTimeout((()=>{s.Z.setPeer({peerId:s.Z.myId})}),0)}},a,{icon:"user",text:"Contacts",onClick:i},it.Z?{icon:"group",text:"PeopleNearby",onClick:()=>{this.createTab(zt).open()}}:void 0,{icon:"settings",text:"Settings",onClick:()=>{this.createTab(At).open()}},{icon:"darkmode",text:"DarkMode",onClick:()=>{},checkboxField:o},{icon:"animations",text:"Animations",onClick:()=>{},checkboxField:new Se.Z({toggle:!0,checked:!0,stateKey:"settings.animationsEnabled"})},{icon:"help",text:"TelegramFeatures",onClick:()=>{const e=p.ZP.format("TelegramFeaturesUrl",!0);s.Z.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([Kt.Z.set({kz_version:"Z"}),Kt.Z.delete("tgme_sync")]).then((()=>{location.href="https://web.telegram.org/z/"}))},verify:()=>Vt.Z.isMainDomain},{icon:"char w",text:"ChatList.Menu.SwitchTo.Webogram",onClick:()=>{Kt.Z.delete("tgme_sync").then((()=>{location.href="https://web.telegram.org/?legacy=1"}))},verify:()=>Vt.Z.isMainDomain}].filter(Boolean);this.toolsBtn=(0,L.Z)({},"bottom-right",r,(e=>Qt(this,void 0,void 0,(function*(){yield Promise.all(r.map((e=>Qt(this,void 0,void 0,(function*(){e.verify&&e.element.classList.toggle("hide",!(yield e.verify()))})))))})))),this.toolsBtn.classList.remove("tgico-more"),this.toolsBtn.classList.add("sidebar-tools-button","is-visible"),this.backBtn.parentElement.insertBefore(this.toolsBtn,this.backBtn);const l=this.toolsBtn.querySelector(".btn-menu"),c=document.createElement("a");c.href="https://github.com/morethanwords/tweb/blob/master/CHANGELOG.md",c.target="_blank",c.rel="noopener noreferrer",c.classList.add("btn-menu-footer"),c.addEventListener(v.pf,(e=>{e.stopPropagation(),me.Z.close()}));const h=document.createElement("span");h.classList.add("btn-menu-footer-text"),h.innerHTML="Telegram Web"+Vt.Z.suffix+" "+Vt.Z.versionFull,c.append(h),l.classList.add("has-footer"),l.append(c),this.newBtnMenu=(0,L.Z)({},"top-left",[{icon:"newchannel",text:"NewChannel",onClick:()=>{this.createTab(_t).open()}},{icon:"newgroup",text:"NewGroup",onClick:()=>{this.createTab(A.Z).open({type:"chat",skippable:!1,takeOut:e=>this.createTab(b).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.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",(0,Wt.Z)(this.updateBtn),this.updateBtn.append((0,p.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",a.element.append(this.archivedCount),n.Z.addEventListener("folder_unread",(e=>{if(1===e.id){const t=e.unreadPeerIds.size;this.archivedCount.innerText=""+(0,qt.Z)(t,1),this.archivedCount.classList.toggle("hide",!t)}})),this.managers.appUsersManager.getTopPeers("correspondents");const u={type:"global-search-focus",onPop:()=>(setTimeout((()=>{this.inputSearch.input.focus()}),0),!1),noHistory:!0};jt.Z.pushItem(u),ft.Z.getState().then((e=>{const t=setInterval((()=>{fetch("version",{cache:"no-cache"}).then((e=>200===e.status&&e.ok&&e.text()||Promise.reject())).then((e=>{e!==Vt.Z.versionFull&&(this.hasUpdate=!0,clearInterval(t),this.newBtnMenu.classList.contains("is-hidden")||this.updateBtn.classList.remove("is-hidden"))})).catch(Ee.Z)}),18e5)}))}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 w.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 f=()=>{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")},p=document.createElement("div");p.classList.add("search-helper"),p.addEventListener("click",(e=>{const t=(0,he.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),f()})),s.nav.parentElement.append(p);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-30"),s.isDialog=!0,i.dataset.key=""+e,e.isPeerId()?(void 0===t&&(t=new Gt.Z({peerId:e.toPeerId()}).element),s.updateWithOptions({peerId:e})):s.classList.add("tgico-calendarfilter"),t&&("string"==typeof t?i.innerHTML=t:((0,P.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,$t.Z)(n,e),setTimeout((()=>{f(),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),p.innerHTML="",s.nav.classList.remove("hide"),!d&&e.trim()){const t=s.middleware.get();Promise.all([this.managers.appMessagesManager.getConversations(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=>{p.append(m(e))})),s.nav.classList.toggle("hide",!!p.innerHTML))}))}if(!l&&e.trim()){const t=[];(0,S.fl)(e,t),t.forEach((e=>{p.append(m("date_"+e.minDate+"_"+e.maxDate,e.title))})),s.nav.classList.toggle("hide",!!p.innerHTML)}},s.tabs.inputMessagesFilterEmpty.addEventListener("mousedown",(e=>{const t=(0,be.Z)(e.target,h.DIALOG_LIST_ELEMENT_TAG);if(!t)return;const i=(0,he.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,C=!0;const L=(0,c.v)(e.parentElement,"zoom-fade",150,(e=>{y&&clearTimeout(y),0!==e||C||(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)),C=!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";G.IS_MOBILE_SAFARI||jt.Z.findItemByType(e)||jt.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),jt.Z.removeByType("global-search"),L(0)}));const M=(0,Pt.Z)("close");this.searchGroups.recent.nameEl.append(M),M.addEventListener("click",(()=>{(0,Le.Z)({descriptionLangKey:"Search.Confirm.ClearHistory",button:{langKey:"ClearButton",isDanger:!0}}).then((()=>this.managers.appUsersManager.clearRecentSearch().then((()=>{this.searchGroups.recent.clear()}))))}))}}const Xt="sidebar-left-section";class ei{constructor(e={}){var t;const i=this.container=document.createElement("div");i.classList.add(Xt+"-container");const s=this.innerContainer=document.createElement("div");if(s.classList.add(Xt),e.noShadow&&s.classList.add("no-shadow"),e.fakeGradientDelimiter)s.append(ii()),s.classList.add("with-fake-delimiter");else if(e.noDelimiter)s.classList.add("no-delimiter");else{const e=document.createElement("hr");s.append(e)}const n=this.content=this.generateContentElement();if(e.name){const t=this.title=document.createElement("div");t.classList.add("sidebar-left-h2",Xt+"-name"),(0,p.XZ)({element:t,key:e.name,args:e.nameArgs}),n.append(t)}i.append(s);const a=null!==(t=e.caption)&&void 0!==t?t:e.captionOld;if(a){const t=this.caption=this.generateContentElement();t.classList.add(Xt+"-caption"),e.captionOld||i.append(t),!0!==a&&(0,p.XZ)({element:t,key:a,args:e.captionArgs})}}generateContentElement(){const e=document.createElement("div");return e.classList.add(Xt+"-content"),this.innerContainer.append(e),e}}const ti=(e,t,i)=>{const s=new ei({name:t,caption:i});return e.append(s.container),s.content},ii=()=>{const e=document.createElement("div");return e.classList.add("gradient-delimiter"),e},si=new Jt;C.GO.appSidebarLeft=si;const ni=si},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?this.close():t instanceof Promise?this.attachToPromise(t):void 0===t&&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.innerHTML="",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()}))}}},7425:(e,t,i)=>{"use strict";i.d(t,{Z:()=>y});var s=i(3552),n=i(1447),a=i(2796),o=i(4494),r=i(3512),d=i(534),l=i(7479),c=i(2464),h=i(2325),u=i(3910),f=i(2738),p=i(4484),m=i(8115),g=i(1507),v=i(5565),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 s._{constructor(){super(...arguments),this.filtersRendered={}}static getInitArgs(){return n.Z.loadAnimationFromURLManually("Folders_1")}renderFolder(e,t,i,s){return b(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,h.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=>b(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,h.ag)("Chats",[t])),i&&o.push((0,h.ag)("Channels",[i])),s&&o.push((0,h.ag)("Groups",[s]))}}if(i)n.id!==g.J$&&(0,v.Z)(i.title,(0,m.Z)(n.title)),i.subtitle.textContent="",i.subtitle.append(...(0,h.v_)(o));else if(i=new l.ZP({title:n.id===g.J$?(0,h.ag)("FilterAllChats"):(0,m.Z)(n.title),subtitle:a,clickable:n.id!==g.J$,buttonRightLangKey:"dialogFilterSuggested"===e._?"Add":void 0}),o.length&&i.subtitle.append(...(0,h.v_)(o)),"dialogFilter"===e._){const e=n.id;this.filtersRendered[n.id]||n.id===g.J$||(0,f.fc)(i.container,(()=>b(this,void 0,void 0,(function*(){this.slider.createTab(d.Z).open(yield this.managers.filtersStorage.getFilter(e))}))),{listenerSetter:this.listenerSetter}),this.filtersRendered[n.id]=i}const r=i.container;if(s){const e=n.localId;void 0!==e?(0,p.Z)(r,r.parentElement||t,e):t&&t.append(r)}return i}))}init(e=y.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,h.XZ)({element:t,key:"ChatList.Filter.Header"}),this.createFolderBtn=(0,o.Z)("btn-primary btn-color-primary btn-control tgico",{text:"ChatList.Filter.NewTitle",icon:"add"}),this.foldersSection=new c.dw({name:"Filters"}),this.foldersSection.container.style.display="none",this.suggestedSection=new c.dw({name:"FilterRecommended"}),this.suggestedSection.container.style.display="none",this.scrollable.append(this.stickerContainer,t,this.createFolderBtn,this.foldersSection.container,this.suggestedSection.container),(0,f.fc)(this.createFolderBtn,(()=>b(this,void 0,void 0,(function*(){(yield this.canCreateFolder())?this.slider.createTab(d.Z).open():(0,a.Am)("Sorry, you can't create more folders.")}))),{listenerSetter:this.listenerSetter});const i=()=>{this.foldersSection.container.style.display=Object.keys(this.filtersRendered).length?"":"none"};return this.managers.filtersStorage.getDialogFilters().then((e=>b(this,void 0,void 0,(function*(){for(const t of e)t.id!==g.Zi&&(yield this.renderFolder(t,this.foldersSection.content,void 0,!0));this.toggleAllChats(),i()})))),this.listenerSetter.add(r.Z)("filter_update",(e=>b(this,void 0,void 0,(function*(){const t=this.filtersRendered[e.id];t?yield this.renderFolder(e,null,t):e.id!==g.Zi&&(yield this.renderFolder(e,this.foldersSection.content,void 0,!0)),i(),this.getSuggestedFilters()})))),this.listenerSetter.add(r.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(r.Z)("filter_order",(e=>{e.filter((e=>!!this.filtersRendered[e])).forEach(((e,t)=>{const i=this.filtersRendered[e].container;(0,p.Z)(i,i.parentElement,t+1)}))})),this.listenerSetter.add(r.Z)("premium_toggle",(()=>{this.toggleAllChats()})),this.loadAnimationPromise=e.then((e=>b(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)})))),this.getSuggestedFilters(),this.loadAnimationPromise}onOpenAfterTimeout(){return this.loadAnimationPromise.then((()=>{this.animation.autoplay=!0,this.animation.play()})),super.onOpenAfterTimeout()}toggleAllChats(){this.filtersRendered[g.J$].container.classList.toggle("hide",!r.Z.premium)}canCreateFolder(){return b(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=>!g.DZ.has(e.id))).length<e}))}getSuggestedFilters(){return this.managers.filtersStorage.getSuggestedDialogsFilters().then((e=>b(this,void 0,void 0,(function*(){this.suggestedSection.container.style.display=e.length?"":"none",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,f.fc)(i,(s=>b(this,void 0,void 0,(function*(){if((0,u.Z)(s),!(yield this.canCreateFolder()))return void(0,a.Am)("Sorry, you can't create more folders.");i.setAttribute("disabled","true");const n=t.filter;n.includePeerIds=[],n.excludePeerIds=[],n.pinnedPeerIds=[],this.managers.filtersStorage.createDialogFilter(n,!0).then((t=>{t&&e.container.remove()})).finally((()=>{i.removeAttribute("disabled")}))}))),{listenerSetter:this.listenerSetter})}}))))}}},534:(e,t,i)=>{"use strict";i.d(t,{Z:()=>k});var s=i(9893),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),f=i(2325),p=i(2464),m=i(8479),g=i(7625),v=i(130),b=i(8115),y=i(1507),w=i(3512),S=i(2738),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,v.Z)(e,(0,b.Z)(i.title)),n.push(e)}})),(0,f.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,m.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,S.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,g.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,g.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=w.Z.premium?e.dialog_filters_chats_limit_premium:e.dialog_filters_chats_limit_default};return this.listenerSetter.add(w.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=>!y.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 p.dw({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=f.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,f.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,S.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),M=i(3066),P=i(2353),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())}))};class k extends a._{constructor(){super(...arguments),this.flags={}}init(){this.container.classList.add("edit-folder-container"),this.caption=document.createElement("div"),this.caption.classList.add("caption"),this.caption.append((0,f.ag)("FilterIncludeExcludeInfo")),this.stickerContainer=document.createElement("div"),this.stickerContainer.classList.add("sticker-container"),this.confirmBtn=(0,d.Z)("check btn-confirm hide blue");const e={icon:"delete danger",text:"FilterMenuDelete",onClick:()=>{new E.Z("filter-delete",{titleLangKey:"ChatList.Filter.Confirm.Remove.Header",descriptionLangKey:"ChatList.Filter.Confirm.Remove.Text",buttons:[{langKey:"Delete",callback:()=>{e.element.setAttribute("disabled","true"),this.managers.filtersStorage.updateDialogFilter(this.filter,!0).then((e=>{e&&this.close()})).finally((()=>{e.element.removeAttribute("disabled")}))},isDanger:!0}]}).show()}};this.menuBtn=(0,l.Z)({listenerSetter:this.listenerSetter},"bottom-left",[e]),this.menuBtn.classList.add("hide"),this.header.append(this.confirmBtn,this.menuBtn);const t=new p.dw({}),i=document.createElement("div");i.classList.add("input-wrapper"),this.nameInputField=new r.ZP({label:"FilterNameHint",maxLength:12}),i.append(this.nameInputField.container),t.content.append(i);const s=(e,t,i,s)=>{const n=new p.dw({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=s("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=s("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,t.container,this.includePeerIds.container,this.excludePeerIds.container);const a=this.includePeerIds.container.querySelector(".folder-categories"),h=this.excludePeerIds.container.querySelector(".folder-categories");(0,S.fc)(a.querySelector(".btn"),(()=>{this.slider.createTab(L).open(this.filter,"included",this)}),{listenerSetter:this.listenerSetter}),(0,S.fc)(h.querySelector(".btn"),(()=>{this.slider.createTab(L).open(this.filter,"excluded",this)}),{listenerSetter:this.listenerSetter}),(0,S.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(a.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=>{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 u="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=n.Z.loadAnimationAsAsset({container:this.stickerContainer,loop:!1,autoplay:!1,width:86,height:86},"Folders_2").then((e=>(this.animation=e,n.Z.waitForFirstFrame(e)))),...u])}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"),this.nameInputField.value="";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,M.Z)(e.title);for(const t in this.flags)this.flags[t].style.display=e.pFlags[t]?"":"none";["includePeerIds","excludePeerIds"].forEach((t=>Z(this,void 0,void 0,(function*(){const i=this[t],n=s.default.createChatList({ignoreClick:!0});let a=e[t];const o=e=>Z(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,P.Z)(a,(e=>o(e)));a.length=0,a.push(...r),a=a.slice();const d=e=>Z(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,f.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,S.fc)(l,(()=>d(20)),{listenerSetter:this.listenerSetter}),l.append((0,f.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,m.Z)(e)):(this.filter=e,this.onEditOpen(),this.editCheckForChange())}open(e){return 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"),super.open().then((()=>{"edit"===this.type?(this.setFilter(this.originalFilter,!0),this.onEditOpen()):this.onCreateOpen()}))}}},4332:(e,t,i)=>{"use strict";i.d(t,{HQ:()=>d,ZP:()=>h});var s=i(4846),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,!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.Z.selectTab(i?1:2,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:()=>w});var s=i(3552),n=i(503),a=i(2621),o=i(2464),r=i(7479),d=i(9807),l=i(4494),c=i(8842),h=i(3512),u=i(8127),f=i(1168),p=i(2325),m=i(2738),g=i(1656),v=i(2946),b=i(8210),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())}))};class w extends s._{init(){return y(this,void 0,void 0,(function*(){this.container.classList.add("edit-peer-container","edit-contact-container");const e=!(yield this.managers.appUsersManager.isContact(this.peerId.toUserId()));this.setTitle(e?"AddContactTitle":"Edit");{const t=new o.dw({noDelimiter:!0}),i=[],s=document.createElement("div");if(s.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}),this.peerId){const t=yield this.managers.appUsersManager.getUser(this.peerId);e?(this.nameInputField.setDraftValue(t.first_name),this.lastNameInputField.setDraftValue(t.last_name)):(this.nameInputField.setOriginalValue(t.first_name),this.lastNameInputField.setOriginalValue(t.last_name))}if(s.append(this.nameInputField.container,this.lastNameInputField.container),i.push(this.nameInputField,this.lastNameInputField),this.editPeer=new a.Z({peerId:this.peerId,inputFields:i,listenerSetter:this.listenerSetter,doNotEditAvatar:!0}),this.content.append(this.editPeer.nextBtn),this.peerId){const i=document.createElement("div");i.classList.add("avatar-edit"),i.append(this.editPeer.avatarElem);const n=new d.Z({text:"Notifications"});n.input.addEventListener("change",(e=>{e.isTrusted&&this.managers.appMessagesManager.togglePeerMute(this.peerId)})),this.listenerSetter.add(h.Z)("notify_settings",(e=>y(this,void 0,void 0,(function*(){if("notifyPeer"!==e.peer._)return;const t=(0,v.Z)(e.peer.peer);if(this.peerId===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 c.Z({peerId:this.peerId}).element);const o=document.createElement("div");if(o.classList.add("profile-subtitle"),o.append((0,p.ag)("EditContact.OriginalName")),t.content.append(i,a,o,s),e){const e=yield this.managers.appUsersManager.getUser(this.peerId),i=new r.ZP({icon:"phone",titleLangKey:e.phone?void 0:"MobileHidden",title:e.phone?(0,b.Z)(e.phone):void 0,subtitleLangKey:e.phone?"Phone":"MobileHiddenExceptionInfo",subtitleLangArgs:e.phone?void 0:[new c.Z({peerId:this.peerId}).element]});t.content.append(i.container)}else{const e=new r.ZP({checkboxField:n,withCheckboxSubtitle:!0,listenerSetter:this.listenerSetter}),i=!(yield this.managers.appNotificationsManager.isPeerLocalMuted(this.peerId,!1));n.checked=i,t.content.append(e.container)}}else t.content.append(s);this.scrollable.append(t.container),(0,m.fc)(this.editPeer.nextBtn,(()=>y(this,void 0,void 0,(function*(){this.editPeer.nextBtn.disabled=!0,this.managers.appUsersManager.addContact(this.peerId,this.nameInputField.value,this.lastNameInputField.value,(yield this.managers.appUsersManager.getUser(this.peerId)).phone).finally((()=>{this.editPeer.nextBtn.removeAttribute("disabled"),this.close()}))}))),{listenerSetter:this.listenerSetter})}if(!e){const e=new o.dw({}),t=(0,l.Z)("btn-primary btn-transparent danger",{icon:"delete",text:"PeerInfo.DeleteContact"});(0,m.fc)(t,(()=>{new u.Z("popup-delete-contact",{peerId:this.peerId,titleLangKey:"DeleteContact",descriptionLangKey:"AreYouSureDeleteContact",buttons:(0,f.x)([{langKey:"Delete",callback:()=>{const e=(0,g.Z)([t],!0);this.managers.appUsersManager.deleteContacts([this.peerId]).then((()=>{this.close()}),(()=>{e()}))},isDanger:!0}])}).show()}),{listenerSetter:this.listenerSetter}),e.content.append(t),this.scrollable.append(e.container)}}))}}},1669:(e,t,i)=>{"use strict";i.d(t,{Z:()=>ee});var s=i(3512),n=i(6360),a=i(3552),o=i(426),r=i(503),d=i(2621),l=i(2464),c=i(7479),h=i(4494),u=i(2166),f=i(144),p=i(279),m=i(1218),g=i(2796),v=i(6726),b=i(6024),y=i(2325),w=i(8127),S=i(8119),C=i(2738),L=i(1656),E=i(9807);class I extends b.h{init(){return e=this,t=void 0,n=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 l.dw({name:e?"ChannelType":"GroupType"}),i=(0,f.a)(),n=new c.ZP({radioField:new m.Z({langKey:e?"ChannelPrivate":"MegaPrivate",name:i,value:"private"}),subtitleLangKey:e?"ChannelPrivateInfo":"MegaPrivateInfo"}),a=new c.ZP({radioField:new m.Z({langKey:e?"ChannelPublic":"MegaPublic",name:i,value:"public"}),subtitleLangKey:e?"ChannelPublicInfo":"MegaPublicInfo"}),o=(0,c.De)([n,a],(e=>{const t=[d,M];"public"===e&&t.reverse(),t[0].container.classList.remove("hide"),t[1].container.classList.add("hide"),k()})),r=yield this.managers.appChatsManager.getChat(this.chatId);t.content.append(o);const d=new l.dw({}),b=new c.ZP({title:this.chatFull.exported_invite.link,subtitleLangKey:e?"ChannelPrivateLinkHelp":"MegaPrivateLinkHelp",clickable:()=>{(0,u.T)(this.chatFull.exported_invite.link),(0,g.Am)(y.ZP.format("LinkCopied",!0))},listenerSetter:this.listenerSetter}),I=(0,h.Z)("btn-primary btn-transparent danger",{icon:"delete",text:"RevokeLink"});(0,C.fc)(I,(()=>{new w.Z("revoke-link",{buttons:[{langKey:"RevokeButton",callback:()=>{const e=(0,L.Z)([I],!0);this.managers.appProfileManager.getChatInviteLink(this.chatId,!0).then((t=>{e(),b.title.innerHTML=t}))}}],titleLangKey:"RevokeLink",descriptionLangKey:"RevokeAlert"}).show()}),{listenerSetter:this.listenerSetter}),d.content.append(b.container,I);const M=new l.dw({caption:e?"Channel.UsernameAboutChannel":"Channel.UsernameAboutGroup",noDelimiter:!0}),P=document.createElement("div");P.classList.add("input-wrapper");const Z="t.me/",k=()=>{const e=n.radioField.checked&&x!==Z||T.isValidToChange()&&T.input.classList.contains("valid");A.classList.toggle("is-visible",e)},T=new v.l({label:"SetUrlPlaceholder",name:"group-public-link",plainText:!0,listenerSetter:this.listenerSetter,availableText:"Link.Available",invalidText:"Link.Invalid",takenText:"Link.Taken",onChange:k,peerId:this.chatId.toPeerId(!0),head:Z},this.managers),x=Z+(r.username||"");P.append(T.container),M.content.append(P);const A=(0,S.Z)({icon:"check",className:"is-visible"});this.content.append(A),(0,C.fc)(A,(()=>{(0,p.p)(A);const e=a.radioField.checked?T.getValue():"";this.managers.appChatsManager.migrateChat(this.chatId).then((t=>this.managers.appChatsManager.updateUsername(t,e))).then((()=>{this.close()}))}),{listenerSetter:this.listenerSetter}),(x!==Z?a:n).radioField.checked=!0,T.setOriginalValue(x),this.scrollable.append(t.container,d.container,M.container);{const t=new l.dw({name:"SavingContentTitle",caption:e?"RestrictSavingContentInfoChannel":"RestrictSavingContentInfoGroup"}),i=new E.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 n=()=>{i.setValueSilently(!!r.pFlags.noforwards)};this.listenerSetter.add(s.Z)("chat_update",(e=>{this.chatId===e&&n()})),n(),t.content.append(i.label),this.scrollable.append(t.container)}},new((i=void 0)||(i=Promise))((function(s,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?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((n=n.apply(e,t||[])).next())}));var e,t,i,n}}var M=i(4668),P=i(5565),Z=i(8936),k=i(9893),T=i(8479),x=i(7120),A=i(2946),_=i(2995),F=i(6848),D=i(3061);class R extends b.h{init(){return e=this,t=void 0,s=function*(){let e;this.container.classList.add("edit-peer-container","user-permissions-container"),this.setTitle("UserRestrictions");{const t=new l.dw({name:"UserRestrictionsCanDo"}),i=document.createElement("div");i.classList.add("chatlist-container"),t.content.insertBefore(i,t.title);const s=k.default.createChatList({new:!0});i.append(s);const{dom:n}=k.default.addDialogNew({peerId:this.userId.toPeerId(!1),container:s,rippleEnabled:!0,avatarSize:"abitbigger"});n.lastMessageSpan.append((0,D.Z)(yield this.managers.appUsersManager.getUser(this.userId)));const a=new N({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,F.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 t=new l.dw({});if("channelParticipantBanned"===this.participant._){const i=(0,h.Z)("btn-primary btn-transparent danger",{icon:"delete",text:"GroupPermission.Delete"});(0,C.fc)(i,(()=>{const t=(0,L.Z)([i],!0);this.managers.appChatsManager.clearChannelParticipantBannedRights(this.chatId,this.participant).then((()=>{this.eventListener.removeEventListener("destroy",e),this.close()}),(()=>{t()}))}),{listenerSetter:this.listenerSetter}),t.content.append(i)}const i=(0,h.Z)("btn-primary btn-transparent danger",{icon:"deleteuser",text:"UserRestrictionsBlock"});(0,C.fc)(i,(()=>{(0,L.Z)([i],!0),this.managers.appChatsManager.kickFromChannel(this.chatId,this.participant).then((()=>{this.eventListener.removeEventListener("destroy",e),this.close()}))}),{listenerSetter:this.listenerSetter}),t.content.append(i),this.scrollable.append(t.container)}},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 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{constructor(e,t){this.options=e,this.managers=t,this.construct()}construct(){return B(this,void 0,void 0,(function*(){this.v=[{flags:["send_messages"],text:"UserRestrictionsSend",exceptionText:"UserRestrictionsNoSend"},{flags:["send_media"],text:"UserRestrictionsSendMedia",exceptionText:"UserRestrictionsNoSendMedia"},{flags:["send_stickers","send_gifs"],text:"UserRestrictionsSendStickers",exceptionText:"UserRestrictionsNoSendStickers"},{flags:["send_polls"],text:"UserRestrictionsSendPolls",exceptionText:"UserRestrictionsNoSendPolls"},{flags:["embed_links"],text:"UserRestrictionsEmbedLinks",exceptionText:"UserRestrictionsNoEmbedLinks"},{flags:["invite_users"],text:"UserRestrictionsInviteUsers",exceptionText:"UserRestrictionsNoInviteUsers"},{flags:["pin_messages"],text:"UserRestrictionsPinMessages",exceptionText:"UserRestrictionsNoPinMessages"},{flags:["change_info"],text:"UserRestrictionsChangeInfo",exceptionText:"UserRestrictionsNoChangeInfo"}],this.toggleWith={send_messages:["send_media","send_stickers","send_polls","embed_links"]};const e=this.options,t=yield this.managers.appChatsManager.getChat(e.chatId),i=t.default_banned_rights,s=e.participant?function(e,t){if(e.default_banned_rights){t=(0,T.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=e.participant?"UserRestrictionsDisabled":"EditCantEditPermissionsPublic";for(const a of this.v){const o=a.flags[0];a.checkboxField=new E.Z({text:a.text,checked:(0,x.Z)(t,o,s),restriction:!0,withRipple:!0}),(e.participant&&i.pFlags[o]||t.username&&(a.flags.includes("pin_messages")||a.flags.includes("change_info")))&&(a.checkboxField.input.disabled=!0,(0,C.fc)(a.checkboxField.label,(e=>{(0,g.Am)(y.ZP.format(n,!0))}),{listenerSetter:e.listenerSetter})),this.toggleWith[o]&&e.listenerSetter.add(a.checkboxField.input)("change",(()=>{a.checkboxField.checked||this.v.filter((e=>this.toggleWith[o].includes(e.flags[0]))).forEach((e=>{e.checkboxField.checked=!1}))})),e.appendTo.append(a.checkboxField.label)}}))}takeOut(){const e={_:"chatBannedRights",until_date:2147483647,pFlags:{}};for(const t of this.v)!t.checkboxField.checked&&t.flags.forEach((t=>{e.pFlags[t]=!0}));return e}}class O extends b.h{init(){return B(this,void 0,void 0,(function*(){let e;this.container.classList.add("edit-peer-container","group-permissions-container"),this.setTitle("ChannelPermissions");{const t=new l.dw({name:"ChannelPermissionsHeader"});e=new N({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 l.dw({name:"PrivacyExceptions"}),i=new c.ZP({titleLangKey:"ChannelAddException",subtitleLangKey:"Loading",icon:"adduser",clickable:()=>{new _.Z({peerTypes:["channelParticipants"],onSelect:e=>{setTimeout((()=>{n(e)}),0)},placeholder:"ExceptionModal.Search.Placeholder",peerId:-this.chatId})},listenerSetter:this.listenerSetter}),n=e=>B(this,void 0,void 0,(function*(){let t;try{t=yield this.managers.appProfileManager.getChannelParticipant(this.chatId,e)}catch(e){return void(0,g.Am)("User is no longer participant")}const i=this.slider.createTab(R);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=k.default.createChatList({new:!0});a.append(o),(0,C.fc)(o,(e=>{const t=(0,M.Z)(e.target,k.DIALOG_LIST_ELEMENT_TAG);if(!t)return;const i=t.dataset.peerId.toPeerId();n(i)}),{listenerSetter:this.listenerSetter});const r=(t,i)=>B(this,void 0,void 0,(function*(){const s=i.banned_rights,n=(yield this.managers.appChatsManager.getChat(this.chatId)).default_banned_rights,a=[];e.v.forEach((e=>{const t=e.flags[0];s.pFlags[t]&&!n.pFlags[t]&&a.push(e.exceptionText)}));const o=t.querySelector(".user-last-message");a.length&&(o.innerHTML="",o.append(...(0,y.v_)(a.map((e=>(0,y.ag)(e))),!1))),o.classList.toggle("hide",!a.length)})),d=(e,t)=>{const{dom:i}=k.default.addDialogNew({peerId:(0,A.Z)(e.peer),container:o,rippleEnabled:!0,avatarSize:"abitbigger",append:t});r(i.listEl,e)},h=()=>{(0,P.Z)(i.subtitle,(0,y.ag)(f?"Permissions.ExceptionsCount":"Permissions.NoExceptions",[f]))};let u,f=0;const p=()=>(u=new Z.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 f=e.count,h(),e.participants.length<50||e.count===o.childElementCount}))}),u.load());this.scrollable.append(t.container),(yield this.managers.appChatsManager.isChannel(this.chatId))?yield p():(h(),this.listenerSetter.add(s.Z)("dialog_migrate",(({migrateFrom:e,migrateTo:t})=>{this.chatId===e&&(this.chatId=t,p())})))}}))}onOpenAfterTimeout(){this.scrollable.onScroll()}}var U=i(6194),H=i(5701),z=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 G extends b.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",h=new l.dw({name:s?void 0:"AvailableReactions",caption:d()}),u=new l.dw({name:"OnlyAllowThisReactions"}),f=()=>{var e;const t=null!==(e=a.reactions)&&void 0!==e?e:[];o=new Set(t.map((({emoticon:e})=>e))),m.forEach(((e,t)=>{e.setValueSilently(o.has(t))}))};let p;if(s){p=new E.Z({toggle:!0,checked:"chatReactionsSome"===n._});const e=new c.ZP({checkboxField:p,titleLangKey:"EnableReactions",listenerSetter:this.listenerSetter});h.content.append(e.container),this.listenerSetter.add(p.input)("change",(()=>{let e=!0;p.checked?g.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&&(f(),b())}))}else{const e=[["chatReactionsAll","AllReactions"],["chatReactionsSome","SomeReactions"],["chatReactionsNone","NoReactions"]],t=()=>{u.container.classList.toggle("hide","chatReactionsSome"!==a._)};let i=n._;const s=(0,c.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,P.Z)(h.caption,(0,y.ag)(d())),f(),b(),t()}));h.content.append(s),t()}const m=new Map,g=t.map((e=>{const t=e.reaction,i=new E.Z({toggle:!0,checked:o.has(t)});m.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)),b()}));const s=new c.ZP({checkboxField:i,title:e.title,havePadding:!0,listenerSetter:this.listenerSetter});return(0,z.Z)({row:s,doc:e.static_icon,size:"small"}),u.content.append(s.container),i})),v=()=>j(this,void 0,void 0,(function*(){b.clearTimeout(),"chatReactionsSome"===a._&&(a.reactions=r(Array.from(o))),this.managers.appChatsManager.setChatAvailableReactions(this.chatId,a),n=a})),b=(0,H.Z)(v,3e3,!1,!0);this.eventListener.addEventListener("destroy",(()=>{b.isDebounced()&&v()}),{once:!0}),this.scrollable.append(h.container,u.container)}))}}var 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 a._{_init(){var e;return V(this,void 0,void 0,(function*(){this.listenerSetter.removeAll(),this.scrollable.container.innerHTML="",null!==(e=this.tempId)&&void 0!==e||(this.tempId=0);const t=++this.tempId;this.container.classList.add("edit-peer-container","edit-group-container"),this.setTitle("Edit");let i=yield this.managers.appProfileManager.getChatFull(this.chatId,!0);const n=yield this.managers.appChatsManager.getChat(this.chatId),a=yield this.managers.appChatsManager.isBroadcast(this.chatId),o=yield this.managers.appChatsManager.isChannel(this.chatId),u=[],f=e=>{u.push(e)};this.listenerSetter.add(s.Z)("chat_update",(e=>{this.chatId===e&&u.forEach((e=>e()))})),this.listenerSetter.add(s.Z)("chat_full_update",(e=>V(this,void 0,void 0,(function*(){this.chatId===e&&(i=(yield this.managers.appProfileManager.getCachedFullChat(e))||i)}))));const p=this.chatId.toPeerId(!0),m=yield this.managers.appChatsManager.hasRights(this.chatId,"change_type"),g=yield this.managers.appChatsManager.hasRights(this.chatId,"change_permissions");{const e=new l.dw({noDelimiter:!0}),o=[],h=document.createElement("div");if(h.classList.add("input-wrapper"),this.chatNameInputField=new r.ZP({label:a?"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(n.title),this.descriptionInputField.setOriginalValue(i.about),h.append(this.chatNameInputField.container,this.descriptionInputField.container),o.push(this.chatNameInputField,this.descriptionInputField),this.editPeer=new d.Z({peerId:p,inputFields:o,listenerSetter:this.listenerSetter}),this.content.append(this.editPeer.nextBtn),e.content.append(this.editPeer.avatarEdit.container,h),m){const t=new c.ZP({titleLangKey:a?"ChannelType":"GroupType",clickable:()=>{const e=this.slider.createTab(I);e.chatId=this.chatId,e.chatFull=i,e.open(),this.listenerSetter.add(e.eventListener)("destroy",s)},icon:"lock",listenerSetter:this.listenerSetter}),s=()=>{let e;t.subtitle.textContent="",e=a?n.username?"TypePublic":"TypePrivate":n.username?"TypePublicGroup":"TypePrivateGroup",t.subtitle.append((0,y.ag)(e))};s(),e.content.append(t.container)}if(m||g){const s=new c.ZP({titleLangKey:"Reactions",icon:"reactions",clickable:()=>{const e=this.slider.createTab(G);e.chatId=this.chatId,e.open().then((()=>{this.tempId===t&&this.listenerSetter.add(e.eventListener)("destroy",a)}))},listenerSetter:this.listenerSetter}),n=(yield this.managers.appReactionsManager.getAvailableReactions()).filter((e=>!e.pFlags.inactive)).length,a=()=>{var e;const t=null!==(e=i.available_reactions)&&void 0!==e?e:{_:"chatReactionsNone"};if("chatReactionsSome"===t._){const e=t.reactions.length;e===n?(0,P.Z)(s.subtitle,(0,y.ag)("ReactionsAll")):s.subtitle.textContent=e+"/"+n}else(0,P.Z)(s.subtitle,(0,y.ag)("chatReactionsAll"===t._?"ReactionsAll":"Checkbox.Disabled"))};a(),e.content.append(s.container)}if(g&&!a){const t=["send_messages","send_media","send_stickers","send_polls","embed_links","invite_users","pin_messages","change_info"],i=new c.ZP({titleLangKey:"ChannelPermissions",clickable:()=>{const e=this.slider.createTab(O);e.chatId=this.chatId,e.open()},icon:"permissions",listenerSetter:this.listenerSetter}),n=()=>V(this,void 0,void 0,(function*(){const e=yield this.managers.appChatsManager.getChatTyped(this.chatId);i.subtitle.innerHTML=t.reduce(((t,i)=>t+ +(0,x.Z)(e,i,e.default_banned_rights)),0)+"/"+t.length}));n(),e.content.append(i.container),this.listenerSetter.add(s.Z)("chat_update",(e=>{this.chatId===e&&n()}))}if(this.scrollable.append(e.container),(0,C.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}),a&&(yield this.managers.appChatsManager.hasRights(this.chatId,"change_info"))){const t=new E.Z({text:"PeerInfo.SignMessages",checked:!!n.pFlags.signatures});this.listenerSetter.add(t.input)("change",(()=>{const e=t.toggleDisability(!0);this.managers.appChatsManager.toggleSignatures(this.chatId,t.checked).then((()=>{e()}))})),f((()=>{t.setValueSilently(!!n.pFlags.signatures)})),e.content.append((0,c.tG)(t).container)}}if(!a){const e=new l.dw({});if(!a&&m){const t=new E.Z({text:"ChatHistory"});this.listenerSetter.add(t.input)("change",(()=>{const e=t.toggleDisability(!0);this.managers.appChatsManager.togglePreHistoryHidden(this.chatId,!t.checked).then((()=>{e()}))}));const s=()=>{t.setValueSilently(o&&!i.pFlags.hidden_prehistory)};s(),f(s),e.content.append((0,c.tG)(t).container)}e.content.childElementCount&&this.scrollable.append(e.container)}if(yield this.managers.appChatsManager.hasRights(this.chatId,"delete_chat")){const e=new l.dw({}),t=(0,h.Z)("btn-primary btn-transparent danger",{icon:"delete",text:a?"PeerInfo.DeleteChannel":"DeleteAndExitButton"});(0,C.fc)(t,(()=>{new U.Z(p,void 0,(e=>{const i=(0,L.Z)([t],!0);e.then((()=>{this.close()}),(()=>{i()}))}))}),{listenerSetter:this.listenerSetter}),e.content.append(t),this.scrollable.append(e.container)}o||this.listenerSetter.add(s.Z)("dialog_migrate",(({migrateFrom:e,migrateTo:t})=>{p===e&&(this.chatId=t.toChatId(),this._init())}))}))}init(){return this._init()}}var W=i(8842),$=i(4240),q=i(2230),Q=i(5670),Y=i(8261),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 X={};class ee extends a._{constructor(e){super(e,!1),this.threadId=0}init(){this.container.classList.add("shared-media-container","profile-container");const e=(0,h.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);const i=document.createElement("div");i.className="transition slide-fade";const a=document.createElement("div");a.classList.add("transition-item"),this.title.append((0,y.ag)("Profile")),this.editBtn=(0,q.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,y.ag)("PeerInfo.SharedMedia")),r.append(d),i.append(a,r),this.header.append(i),this.profile=new Y.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",e),this.searchSuper.container.classList.toggle("is-full-viewport",e),c(+e),e||this.searchSuper.cleanScrollPositions()},c=(0,o.v)(i,"slide-fade",400,null,!1);c(0),(0,C.fc)(this.closeBtn,(e=>{this.closeBtn.firstElementChild.classList.contains("state-back")?(this.scrollable.scrollIntoViewNew({element:this.scrollable.container.firstElementChild,position:"start"}),c(0),t.classList.remove("state-back")):this.scrollable.isHeavyAnimationInProgress||this.slider.onCloseBtnClick()}),{listenerSetter:this.listenerSetter}),(0,C.fc)(this.editBtn,(e=>{let t;t=this.peerId.isAnyChat()?this.slider.createTab(K):this.slider.createTab($.Z),t&&(t instanceof K?t.chatId=this.peerId.toChatId():t.peerId=this.peerId,t.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.renderNewMessages(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.renderNewMessages(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"}],scrollable:this.scrollable,onChangeTab:e=>{const t="members"===e.type&&s.Z.settings.animationsEnabled?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,S.Z)({icon:"addmember_filled"});this.content.append(u),(0,C.fc)(u,(()=>J(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,y.ag)("Members",[t.length])],o="AddMembersAlertCountText",r=t.map((e=>{const t=document.createElement("b");return t.append(new W.Z({peerId:e}).element),t})),i||(d=[{text:"AddMembersForwardMessages",checked:!0}]);else{n="AddOneMemberAlertTitle",o="AddMembersAlertNamesText";const e=document.createElement("b");e.append(new W.Z({peerId:t[0]}).element),r=[e],i||(d=[{text:"AddOneMemberForwardMessages",textArgs:[new W.Z({peerId:t[0]}).element],checked:!0}])}r.push(new W.Z({peerId:e}).element),new w.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,g.bC)({langPackKey:"InviteToGroupError"})};if(i){const e=this.slider.createTab(Q.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 new _.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})}renderNewMessages(e){return J(this,void 0,void 0,(function*(){if(this.init)return;const{peerId:t}=e;if(X[t])for(const i of this.searchSuper.mediaTabs){const s=i.inputFilter,n=X[t][s];if(!n)continue;const a=this.searchSuper.filterMessagesByType([e],s).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===t&&-1!==this.searchSuper.usedFromHistory[s]&&(this.searchSuper.usedFromHistory[s]+=a.length,this.searchSuper.performSearchResult(a,i,!1)))}}))}deleteDeletedMessages(e,t){if(!this.init&&X[e]){for(const i of t)for(const t of this.searchSuper.mediaTabs){const s=t.inputFilter,n=X[e][s];if(!n)continue;const a=n.findIndex((e=>e.mid===i));if(-1!==a&&(n.splice(a,1),this.peerId===e)){const t=this.searchSuper.tabs[s].querySelector(`[data-mid="${i}"][data-peer-id="${e}"]`);t&&(this.searchSuper.selection.isSelecting&&this.searchSuper.selection.toggleByElement(t),t.remove()),this.searchSuper.usedFromHistory[s]>=a+1&&--this.searchSuper.usedFromHistory[s]}}this.scrollable.onScroll()}}cleanupHTML(){return J(this,void 0,void 0,(function*(){this.profile.cleanupHTML(),this.editBtn.classList.add("hide"),this.searchSuper.cleanupHTML(!0),this.container.classList.toggle("can-add-members",(yield this.searchSuper.canViewMembers())&&(yield this.managers.appChatsManager.hasRights(this.peerId.toChatId(),"invite_users")))}))}setLoadMutex(e){this.searchSuper.loadMutex=e}setPeer(e,t=0){var i;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,historyStorage:null!==(i=X[e])&&void 0!==i?i:X[e]={}}),this.profile.setPeer(e,t),!0)}fillProfileElements(){return J(this,void 0,void 0,(function*(){this.peerChanged&&(this.peerChanged=!1,yield this.cleanupHTML(),yield this.toggleEditBtn(),yield this.profile.fillProfileElements())}))}toggleEditBtn(){return J(this,void 0,void 0,(function*(){let e;e=this.peerId.isUser()?this.peerId!==s.Z.myId&&(yield this.managers.appUsersManager.isContact(this.peerId.toUserId())):yield this.managers.appChatsManager.hasRights(this.peerId.toChatId(),"change_info"),this.editBtn.classList.toggle("hide",!e)}))}loadSidebarMedia(e,t){this.searchSuper.load(e,t)}onOpenAfterTimeout(){this.scrollable.onScroll()}destroy(){this.destroyable=!0,this.onCloseAfterTimeout(),this.profile.destroy(),this.searchSuper.destroy()}}},9099:(e,t,i)=>{"use strict";i.d(t,{Z:()=>a});var s=i(3512);const n=(e,t,i,a,o,r,d)=>{const{timeout:l,raf:c}=e.dataset;if(void 0!==l&&clearTimeout(+l),void 0!==c&&(window.cancelAnimationFrame(+c),r||delete e.dataset.raf),r&&s.Z.settings.animationsEnabled&&a)return void(e.dataset.raf=""+window.requestAnimationFrame((()=>{delete e.dataset.raf,n(e,t,i,a,o,r-1,d)})));i&&t&&e.classList.add(t);const h=()=>{delete e.dataset.timeout,!i&&t&&e.classList.remove("backwards",t),e.classList.remove("animating"),null==o||o()};if(null==d||d(),!s.Z.settings.animationsEnabled||!a)return e.classList.remove("animating","backwards"),void h();e.classList.add("animating"),e.classList.toggle("backwards",!i),e.dataset.timeout=""+setTimeout(h,a)},a=n},3552:(e,t,i)=>{"use strict";i.d(t,{Z:()=>d,_:()=>a.Z});var s=i(426),n=i(9818),a=i(6024),o=i(1655),r=i(5953);class d{constructor(e){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),this.tabs||(this.tabs=new Map),this.tabsContainer=this.sidebarEl.querySelector(".sidebar-slider"),this._selectTab=(0,s.v)(this.tabsContainer,"navigation",250),this.canHideFirst||this._selectTab(0)}selectTab(e){var t;if(this.historyTabIds[this.historyTabIds.length-1]===e)return!1;const i=e instanceof a.Z?e:this.tabs.get(e);return 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}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))}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))}createTab(e,t){const i=new e(t?void 0:this,!0);return i.managers=this.managers,i}}},6024:(e,t,i)=>{"use strict";i.d(t,{Z:()=>l,h:()=>c});var s=i(3241),n=i(3699),a=i(319),o=i(2325),r=i(2230),d=i(8805);class l{constructor(e,t){this._constructor(e,t)}_constructor(e,t=!0){this.slider=e,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,r.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 d.ZP(this.content,void 0,void 0,!0),this.container.append(this.header,this.content),this.slider&&this.slider.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;this.destroyable&&(this.slider.tabs.delete(this),this.container.remove(),this.scrollable.destroy(),null===(e=this.listenerSetter)||void 0===e||e.removeAll())}setTitle(e){this.title.replaceChildren((0,o.ag)(e))}}class c extends l{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(a.Z,a.Z)),this.eventListener.cleanup(),super.onCloseAfterTimeout()}}},2894:(e,t,i)=>{"use strict";i.d(t,{Z:()=>f});var s=i(9893),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=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 extends l.Z{constructor(e){let t;super({getIndex:e.getIndex||(e=>this.managers.appUsersManager.getUserStatusForSort(e.id)),onDelete:e=>{e.dom.listEl.remove(),this.onListLengthChange&&this.onListLengthChange()},onUpdate:e.onUpdate||(e=>u(this,void 0,void 0,(function*(){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{dom:t}=s.default.addDialogNew({peerId:e.id,container:!1,avatarSize:this.avatarSize,autonomous:this.autonomous,meAsSaved:!1,rippleEnabled:this.rippleEnabled,lazyLoadQueue:this.lazyLoadQueue});return e.dom=t,e},updateElementWith:d.T2,updateListWith:e=>u(this,void 0,void 0,(function*(){return(0,a.Z)(this.list)?(yield(0,n.e9)(),(0,a.Z)(this.list)?void e(!0):e(!1)):e(!1)}))}),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()}))}),f.SORT_INTERVAL)};i()}}f.SORT_INTERVAL=3e4},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),f=i(241),p=i(13),m=i(8115),g=i(4776),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 M=(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},P=y.Z.managers;t.add(e)("mousedown",(e=>{if(E||e.buttons>1||0!==e.button)return;let t=M(e);if(!t)return;const i=t.dataset.docId;if(!i)return;const s="sticker-viewer",y="STICKER-VIEWER",I=w.Z.getOnlyOnePlayableGroup(),Z=(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,p.Z)(t),S=e.getBoundingClientRect(),L=(0,l.C)(t.w,t.h),E=c?280:360,I=(0,l.C)(E,E),M=S.width===S.height?I:L.aspectFitted(I),Z=(0,r.Z)(e,"bubble"),T=!Z||Z.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=M.width+"px",A.style.height=M.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/M.width,N=R.height/M.height,O=R.left-(f.Z.width-R.width)/2,U=R.top-(f.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:M.width,height:M.height,play:!1,loop:!0,middleware:i,managers:P,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=Z.get(),n=yield P.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)(k,"is-visible",!0,200,(()=>{e()&&o()})),document.addEventListener("mousemove",_)}))),125),_=e=>L(this,void 0,void 0,(function*(){const i=M(e,!0);if(!i||t===i)return;const s=i.dataset.docId;if(!s)return;t=i,Z.clean();const n=Z.get(),a=yield P.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)(l,"is-switching",!0,200,(()=>{l.remove()})),T=d,(0,S.Z)(d,"is-switching",!1,200,(()=>{n()&&r()}))})),F=e=>{(0,o.Z)(e.target,t)||D()},D=()=>{clearTimeout(A),Z.clean(),k&&((0,S.Z)(k,"is-visible",!1,200,(()=>{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:()=>c});var s=i(3910),n=i(5432),a=i(5953),o=i(3416);const r=e=>e.touches?e.touches[0]:e,d=window;let l=!1;o.Z.addEventListener("toggle",(e=>{l=e}));class c{constructor(e){this.cursor="grabbing",this.cancelEvent=!0,this.listenerOptions=!1,this.hadMove=!1,this.xDown=null,this.yDown=null,this.reset=e=>{n.Z?d.removeEventListener("touchmove",this.handleMove,{capture:!0}):(d.removeEventListener("mousemove",this.handleMove),this.setCursorTo.style.cursor=""),this.onReset&&this.hadMove&&this.onReset(),this.xDown=this.yDown=null,this.hadMove=!1},this.handleStart=e=>{return t=this,i=void 0,a=function*(){const t=r(e);if(this.verifyTouchTarget&&!(yield this.verifyTouchTarget(e)))return this.reset();this.xDown=t.clientX,this.yDown=t.clientY,n.Z?d.addEventListener("touchmove",this.handleMove,{passive:!1,capture:!0}):d.addEventListener("mousemove",this.handleMove,!1)},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},this.handleMove=e=>{if(null===this.xDown||null===this.yDown||l)return void this.reset();this.cancelEvent&&(0,s.Z)(e);const t=r(e),i=t.clientX,a=t.clientY,o=this.xDown-i,d=this.yDown-a;if(!this.hadMove){if(!o&&!d)return;this.hadMove=!0,n.Z||this.setCursorTo.style.setProperty("cursor",this.cursor,"important"),this.onFirstSwipe&&this.onFirstSwipe()}const c=this.onSwipe(o,d,e);void 0!==c&&c&&this.reset()},(0,a.Z)(this,e),this.setCursorTo=this.element,this.setListeners()}setListeners(){n.Z?(this.element.addEventListener("touchstart",this.handleStart,this.listenerOptions),d.addEventListener("touchend",this.reset)):(this.element.addEventListener("mousedown",this.handleStart,this.listenerOptions),d.addEventListener("mouseup",this.reset))}removeListeners(){n.Z?(this.element.removeEventListener("touchstart",this.handleStart,this.listenerOptions),d.removeEventListener("touchend",this.reset)):(this.element.removeEventListener("mousedown",this.handleStart,this.listenerOptions),d.removeEventListener("mouseup",this.reset))}setCursor(e){this.cursor=e,!n.Z&&this.hadMove&&this.setCursorTo.style.setProperty("cursor",this.cursor,"important")}}},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}))}}},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,{v:()=>c});var s=i(3512),n=i(3725),a=i(8594),o=i(2648),r=i(3910);function d(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=""}}function l(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=""}}const c=(e,t,i,s,n=!0,a)=>{let o=null;switch(t){case"tabs":o=l;break;case"navigation":o=d}return e.dataset.animation=t,h(e,o,i,s,n,void 0,void 0,a)},h=(e,t,i,d,l=!0,c=!1,h=!0,u)=>{const f=new Map;let p,m=null;if(h){const i=t?"transitionend":"animationend",s=t=>{if((0,r.Z)(t),t.target.parentElement!==e)return;const n=f.get(t.target);null==n||n(),t.target===m&&(!p&&l||(p&&(p.resolve(),p=void 0),d&&d(g.prevId()),e.classList.remove("animating","backwards","disable-hover"),c&&(u?u.removeManual(e,i,s):e.removeEventListener(i,s),m=p=void 0,f.clear())))};u?u.add(e)(i,s):e.addEventListener(i,s)}function g(r,c=!0,u){u&&(m=u),r instanceof HTMLElement&&(r=(0,o.Z)(r));const v=g.prevId();if(r===v)return!1;const b=e.children[r];if(s.Z.settings.animationsEnabled&&-1!==v||(c=!1),!h){const t=e.dataset.timeout;void 0!==t&&clearTimeout(+t),delete e.dataset.timeout}if(!c){if(m)m.classList.remove("active","to","from");else if(b){const e=f.get(b);null==e||e()}return b&&(b.classList.remove("to","from"),b.classList.add("active")),e.classList.remove("animating","backwards","disable-hover"),m=b,void(d&&d(r))}h||(e.dataset.timeout=""+window.setTimeout((()=>{b.classList.remove("to"),m&&m.classList.remove("from"),e.classList.remove("animating","backwards","disable-hover"),delete e.dataset.timeout}),i)),m&&(m.classList.remove("to"),m.classList.add("from")),e.classList.add("animating");const y=v<r;let w;if(e.classList.toggle("backwards",!y),b&&(t?w=t(b,m,y):b.classList.add("active"),b.classList.remove("from"),b.classList.add("to")),b){const e=b.dataset.transitionTimeout;e&&clearTimeout(+e),f.set(b,(()=>{b.classList.remove("to"),f.delete(b)}))}if(m){let e;const t=m,s=()=>{clearTimeout(e),t.classList.remove("active","from"),w&&(null==w||w()),f.delete(t)};b?(e=window.setTimeout(s,i+100),f.set(t,s)):(e=window.setTimeout(s,i),f.set(t,(()=>{clearTimeout(e),f.delete(t)}))),t.dataset.transitionTimeout=""+e,l&&(p||(p=(0,n.Z)()),(0,a.YW)(p,2*i))}m=b}return g.prevId=()=>m?(0,o.Z)(m):-1,g.getFrom=()=>m,g.setFrom=e=>m=e,g}},6726:(e,t,i)=>{"use strict";i.d(t,{l:()=>o});var s=i(5701),n=i(503);function a(e){return(e.length>=5&&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",(()=>{const e=this.getValue();if(e===this.originalValue||!e.length)return this.setState(n.I1.Neutral),void(this.options.onChange&&this.options.onChange());a(e)?this.setState(n.I1.Neutral):this.setError(this.options.invalidText),this.input.classList.contains("error")?this.options.onChange&&this.options.onChange():this.checkUsernameDebounced(e)}))}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){this.checkUsernamePromise||(this.options.peerId?this.checkUsernamePromise=this.managers.appChatsManager.checkUsername(this.options.peerId.toChatId(),e):this.checkUsernamePromise=this.managers.appUsersManager.checkUsername(e),this.checkUsernamePromise.then((t=>{this.getValue()===e&&(t?this.setState(n.I1.Valid,this.options.availableText):this.setError(this.options.takenText))}),(t=>{this.getValue()===e&&"USERNAME_INVALID"===t.type&&this.setError(this.options.invalidText)})).then((()=>{this.checkUsernamePromise=void 0,this.options.onChange&&this.options.onChange();const t=this.getValue();t!==e&&this.isValidToChange()&&a(t)&&this.checkUsername(t)})))}}},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,{Z:()=>n});var s=i(4776);function n({docIds:e,loadPromises:t,middleware:i,lazyLoadQueue:n,size: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})}},296:(e,t,i)=>{"use strict";i.d(t,{Z:()=>I});var s=i(2341),n=i(467),a=i(632),o=i(2738),r=i(8497),d=i(4081),l=i(319),c=i(2312),h=i(4846),u=i(1243),f=i(7030),p=i(2325),m=i(1507),g=i(2491),v=i(3512),b=i(8448),y=i(3251),w=i(3442),S=i(9492),C=i(5671),L=i(1604),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())}))};function I({message:e,withTime:t,fontWeight:i,voiceAsMusic:I,showSender:M,searchContext:P,loadPromises:Z,autoDownloadSize:k,lazyLoadQueue:T,sizeType:x,managers:A=v.Z.managers,cacheContext:_,fontSize:F}){var D;return E(this,void 0,void 0,(function*(){null!=i||(i=500),null!=x||(x=""),null!=F||(F=0);const R=0===k,B=e.media.document||e.media.webpage.document,N=null==e?void 0:e.uploadingFileName;if("audio"===B.type||"voice"===B.type||"round"===B.type){const s=new b.ZP;return s.withTime=t,s.message=e,s.noAutoDownload=R,s.lazyLoadQueue=T,s.loadPromises=Z,I&&(s.voiceAsMusic=I),P&&(s.searchContext=P),M&&(s.showSender=M),s.dataset.fontWeight=""+i,s.dataset.fontSize=""+F,s.dataset.sizeType=x,yield s.render(),s}const O=B.file_name?B.file_name.split("."):"";let U="";U=O.length>1&&Array.isArray(O)?(0,n.ST)(O.pop().split(" ",1)[0].toLowerCase()):"file";const H=document.createElement("div");H.classList.add("document",`ext-${U}`),H.dataset.docId=""+B.id,H.doc=B;const z=document.createElement("div");let j;z.classList.add("document-ico");const G=!!_,V=()=>G?_:A.thumbsStorage.getCacheContext(B);_=yield V();let K=!1;if((null===(D=B.thumbs)||void 0===D?void 0:D.length)||e.pFlags.is_outgoing&&_.url&&"photo"===B.type){H.classList.add("document-with-thumb"),K=!0;const t=[];if(e.pFlags.is_outgoing&&["photo","video"].includes(B.type)&&_.url)z.innerHTML=`<img src="${_.url}">`,t.push(z.firstElementChild);else{performance.now();const e=yield(0,S.Z)({photo:B,message:null,container:z,boxWidth:54,boxHeight:54,loadPromises:Z,withoutPreloader:!0,lazyLoadQueue:T,size:(0,f.Z)(B,54,54,!0),managers:A});z.style.width=z.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 j=document.createElement("span"),j.classList.add("document-ico-text"),j.innerText=U,z.append(j);const W=B.file_name?(0,g.Z)(B.file_name):"Unknown.file";document.createElement("div").classList.add("document-description");const $=document.createElement("span"),q=[(0,d.Z)(B.size)];if(t&&q.push((0,a.OD)(e.date)),M&&q.push(yield(0,C.Z)(e)),!t&&!M){const e=document.createElement("span"),t=(0,d.Z)(B.size);e.append(" / ",t),e.style.visibility="hidden",q.push(e)}H.innerHTML=`\n ${_.downloaded&&!N||!e.mid||!K?"":'<div class="document-download"></div>'}\n <div class="document-name"></div>\n <div class="document-size"></div>\n `;const Q=H.querySelector(".document-name"),Y=new y.I;Y.dataset.fontWeight=""+i,Y.dataset.fontSize=""+F,Y.dataset.sizeType=x,Y.textContent=W,e.mid||H.classList.add("downloaded"),Q.append(Y),M&&Q.append((0,L.Z)(e));const J=H.querySelector(".document-size");if($.append(...(0,p.A1)(q," · ")),J.append($),H.prepend(z),!N&&e.pFlags.is_outgoing&&!e.mid)return H;let X,ee=null;const te=()=>{if(H.classList.remove("downloading"),B.size>m.Iw&&!N)return ee.setManual(),ee.attach(X),ee.preloader.classList.add("manual"),void ee.setDownloadFunction(se);if(B.size<=m.Iw&&H.classList.add("downloaded"),X){if(X!==z){const e=X;setTimeout((()=>{e.remove()}),200)}X=null}ee&&(ee=null)},ie=e=>{H.classList.add("downloading");const t=document.createElement("span"),i=(0,d.Z)(B.size);t.style.position="absolute",t.style.left="0",e.then(te,l.Z).finally((()=>{$.style.visibility="",t.remove()}));const s=e=>(0,d.Z)(e);let n=s(0);$.style.visibility="hidden",t.append(n," / ",i),$.parentElement.append(t),e.addNotifyListener((e=>{const t=s(e.done);n.replaceWith(t),n=t}))},se=e=>{var t;const i=!e||e.isTrusted,n=H.doc;let a;const o=h.Z.chat.bubbles?h.Z.chat.bubbles.lazyLoadQueue.queueId:void 0;if(i)if("pdf"===n.type){const e=!ee||ee.detached;a=c.Z.downloadMediaURL({media:n,queueId:o}),e&&a.then((()=>{setTimeout((()=>E(this,void 0,void 0,(function*(){const e=(yield V()).url;window.open(e)}))),v.Z.settings.animationsEnabled?250:0)}))}else a=s.Z.has(n.mime_type)&&(null===(t=n.thumbs)||void 0===t?void 0:t.length)?c.Z.downloadMediaURL({media:n,queueId:o}):c.Z.downloadToDisc({media:n,queueId:o});else a=c.Z.downloadToDisc({media:n,queueId:o},!0);a.catch((()=>{H.classList.remove("downloading")})),X&&(ee.attach(X,!0,a),ie(a))},{fileName:ne}=(0,u.Z)({media:B,downloadId:"1"});if(yield A.apiFileManager.isDownloading(ne)){X=H.querySelector(".document-download")||z;const e=c.Z.downloadToDisc({media:B},!0);ee=new w.Z,ee.attach(X,!1,e),ee.setDownloadFunction(se),ie(e)}else if(!_.downloaded||N)if(X=H.querySelector(".document-download")||z,ee=new w.Z({isUpload:!!N}),N){const e=c.Z.getUpload(N);ee.attachPromise(e),ee.attach(X),ie(e)}else ee.construct(),ee.setManual(),ee.attach(X),ee.setDownloadFunction(se),void 0!==k&&k>=B.size&&(0,o.tH)(ee.preloader);return(0,o.fc)(H,(e=>{(0,r.Z)(e.target,"time")||(ee?ee.onClick(e):se(e))})),H}))}v.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:()=>r});var s=i(8456),n=i(2325),a=i(8115),o=i(3512);function r(e,t=!1,i=!1,r,d=o.Z.managers){return l=this,c=void 0,u=function*(){e||(e=o.Z.myId);let l="";if(e.isUser()){const t=yield d.appUsersManager.getUser(e.toUserId());t.first_name&&(l+=t.first_name),!t.last_name||i&&l||(l+=" "+t.last_name),l=l?l.trim():t.pFlags.deleted?n.ZP.format(i?"Deleted":"HiddenName",!0):t.username}else l=(yield d.appChatsManager.getChat(e.toChatId())).title,i&&(l=l.split(" ")[0]);return void 0!==r&&(l=(0,s.Z)(l,r,r)),t?l:(0,a.Z)(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}},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)}},5886:(e,t,i)=>{"use strict";i.d(t,{Z:()=>C});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(8115),u=i(2491),f=i(4776),p=i(3512),m=i(493),g=i(3591);function v(e){const t=e.action,{onclick:i,url:s}=(0,g.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 b=i(496),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())}))};function S(e,t){return w(this,void 0,void 0,(function*(){const i=yield(0,b.Z)(e,void 0,void 0,t);if(t)return i;const s=document.createElement("i");return s.dataset.savedFrom=e.peerId+"_"+e.mid,s.dir="auto",s.append(i),s}))}function C(e,t){return i=this,g=void 0,C=function*(){try{return yield function(e,t){var i;return w(this,void 0,void 0,(function*(){const g=t?void 0:document.createElement("span"),b="action"in e&&e.action;if(b.message){const e=b.message;return t?(0,u.Z)(e):((0,o.Z)(g,(0,f.ZP)(e,{noLinebreaks:!0})),g)}{let o,u,w=b._;const C=p.Z.managers,L=(e,t)=>t?(0,m.Z)(e,t):(0,y.Z)({peerId:e});switch(b._){case"messageActionPhoneCall":w+="."+b.type,u=[(0,r.Z)(b.duration,t)];break;case"messageActionGroupCall":w+="."+b.type,u=[],w.endsWith("You")||e.pFlags.post||u.push(L(e.fromId,t)),void 0!==b.duration?u.push((0,r.Z)(b.duration,t)):u.push(v(e));break;case"messageActionInviteToGroupCall":{const i=[e.fromId,b.users[0].toPeerId()];let n="Chat.Service.VoiceChatInvitation";const a=p.Z.myId;i[0]===a?n+="ByYou":i[1]===a&&(n+="ForYou"),(0,s.Z)(i,a),o=n,u=i.map((e=>L(e,t))),u.push(v(e));break}case"messageActionGroupCallScheduled":{const i=new Date,s=new Date(1e3*b.schedule_date),a=(s.getTime()-i.getTime())/864e5,r=new Date(i);r.setDate(r.getDate()+1);const d=yield C.appPeersManager.isBroadcast(e.peerId);o=d?"ChatList.Service.VoiceChatScheduled.Channel":"ChatList.Service.VoiceChatScheduled",u=[];const l=p.Z.myId;let h;e.fromId===l?o+="You":d||u.push(L(e.fromId,t));const f=[];a<1&&s.getDate()===i.getDate()?h="TodayAtFormattedWithToday":a<2&&s.getDate()===r.getDate()?h="Time.TomorrowAt":(h="formatDateAtTime",f.push(new c.ZP.IntlDateElement({date:s,options:{day:"2-digit",month:"2-digit",year:"2-digit"}}).element)),f.push((0,n.mr)(s));const m=(0,c.ag)(h,f);u.push(m);break}case"messageActionChatCreate":{const i=p.Z.myId;e.fromId===i?w+="You":u=[L(e.fromId,t)];break}case"messageActionPinMessage":{const i=e.peerId,s=yield C.appMessagesManager.getMessageByPeer(i,e.reply_to_mid);u=[L(e.fromId,t)],s?u.push(S(s,t)):(o="ActionPinnedNoText",e.reply_to_mid&&C.appMessagesManager.fetchMessageReplyTo(e));break}case"messageActionChatJoinedByRequest":{const i=yield C.appPeersManager.isBroadcast(e.peerId);e.pFlags.out?o=i?"RequestToJoinChannelApproved":"RequestToJoinGroupApproved":(o=i?"ChatService.UserJoinedChannelByRequest":"ChatService.UserJoinedGroupByRequest",u=[L(e.fromId,t)]);break}case"messageActionContactSignUp":case"messageActionChatReturn":case"messageActionChatLeave":case"messageActionChatJoined":case"messageActionChatEditPhoto":case"messageActionChatDeletePhoto":case"messageActionChatEditVideo":case"messageActionChatJoinedByLink":case"messageActionChannelEditVideo":case"messageActionChannelDeletePhoto":u=[L(e.fromId,t)];break;case"messageActionChannelEditTitle":case"messageActionChatEditTitle":u=[],"messageActionChatEditTitle"===b._&&u.push(L(e.fromId,t)),u.push(t?b.title:(0,a.Z)((0,h.Z)(b.title)));break;case"messageActionChatDeleteUser":case"messageActionChatAddUsers":case"messageActionChatAddUser":{const i=b.users||[b.user_id];if(u=[L(e.fromId,t)],i.length>1){const e=(0,c.v_)(yield Promise.all(i.map((e=>L(e.toPeerId(),t)))),!1,t);if(t)u.push(...e);else{const t=document.createElement("span");t.append(...e),u.push(t)}}else u.push(L(i[0].toPeerId(),t));break}case"messageActionBotAllowed":{const e=(0,f.ZP)(b.domain,{entities:[{_:"messageEntityUrl",length:b.domain.length,offset:0}]});u=[(0,a.Z)(e)];break}case"messageActionPaymentSent":{const s=b.pFlags.recurring_init,n=b.pFlags.recurring_used;if(o=n?"Chat.Service.PaymentSentRecurringUsedNoTitle":s?"Chat.Service.PaymentSentRecurringInitNoTitle":"Chat.Service.PaymentSent1NoTitle",u=[(0,d.Z)(b.total_amount,b.currency),L(e.peerId,t)],e.reply_to_mid){const a=yield C.appMessagesManager.getMessageByPeer((null===(i=e.reply_to)||void 0===i?void 0:i.reply_to_peer_id)?(0,l.Z)(e.reply_to.reply_to_peer_id):e.peerId,e.reply_to_mid);a?(o=n?"Chat.Service.PaymentSentRecurringUsed":s?"Chat.Service.PaymentSentRecurringInit":"Chat.Service.PaymentSent1",u.push(S(a,t).then((e=>(e instanceof HTMLElement&&e.classList.add("is-receipt-link"),e))))):C.appMessagesManager.fetchMessageReplyTo(e)}break}case"messageActionSetMessagesTTL":{u=[];const i=yield C.appPeersManager.isBroadcast(e.peerId);if(b.period){let s;if(i?o="ActionTTLChannelChanged":e.fromId===p.Z.myId?o="ActionTTLYouChanged":(o="ActionTTLChanged",u.push(L(e.fromId,t))),b.period>1814400){let e;const i=[],a=31536e3;b.period>=a?(e="Years",i.push(b.period/a|0)):(e="Months",i.push(b.period/(30*n.s2)|0)),s=t?c.ZP.format(e,!0,i):(0,c.ag)(e,i)}else s=(0,r.Z)(b.period,t);u.push(s)}else i?o="ActionTTLChannelDisabled":e.fromId===p.Z.myId?o="ActionTTLYouDisabled":(o="ActionTTLDisabled",u.push(L(e.fromId,t)));break}default:o=c.Hz[w]||`[${b._}]`}o||(o=c.Hz[w],void 0===o&&(o="["+w+"]"));const E=u&&(yield Promise.all(u));return t?c.ZP.format(o,!0,E):(0,c.$d)(g,o,E)}}))}(e,t)}catch(e){return console.error("wrapMessageActionTextNewUnsafe error:",e),t?"":document.createElement("span")}},new((b=void 0)||(b=Promise))((function(e,t){function s(e){try{a(C.next(e))}catch(e){t(e)}}function n(e){try{a(C.throw(e))}catch(e){t(e)}}function a(t){var i;t.done?e(t.value):(i=t.value,i instanceof b?i:new b((function(e){e(i)}))).then(s,n)}a((C=C.apply(i,g||[])).next())}));var i,g,b,C}},496:(e,t,i)=>{"use strict";i.d(t,{Z:()=>g});var s=i(8938),n=i(5705),a=i(677),o=i(3738),r=i(8456),d=i(5381),l=i(2325),c=i(1346),h=i(8115),u=i(2491),f=i(4776),p=i(3512),m=i(5886);function g(e,t=e.message,i,g,v,b){var y,w,S,C,L,E;return S=this,C=void 0,E=function*(){const S=[];let C=!1;const L=(e,t)=>{if(e){if(void 0===t&&C)return;t=g?l.ZP.format(e,!0):(0,l.ag)(e)}if(g)S.push(t);else{const e=document.createElement("span");"string"==typeof t?e.innerHTML=t:e.append(t),S.push(e)}},E=p.Z.managers.appMessagesManager,I=(0,d.Z)(e);let M=null!==(y=e.totalEntities)&&void 0!==y?y:e.entities;if(e.media&&!I){(0,s.Z)(e);let n=!0;if(e.grouped_id){if(i){const t=yield E.getMidsByMessage(e);if(i.length===t.length){for(const e of t)if(!i.includes(e)){n=!1;break}}else n=!1}if(n){const i=yield E.getAlbumText(e.grouped_id);t=i.message,M=i.totalEntities,b||(L("AttachAlbum"),C=!0)}}else n=!1;if(!n&&!b||!t){const i=e.media;switch(i._){case"messageMediaPhoto":L("AttachPhoto");break;case"messageMediaDice":L(void 0,g?i.emoticon:(0,h.Z)(i.emoticon));break;case"messageMediaVenue":t=i.title,L("AttachLocation");break;case"messageMediaGeo":L("AttachLocation");break;case"messageMediaGeoLive":L("AttachLiveLocation");break;case"messageMediaPoll":const e="📊 "+(i.poll.question||"poll");L(void 0,g?e:(0,h.Z)(e));break;case"messageMediaContact":L("AttachContact");break;case"messageMediaGame":{const e="🎮 "+i.game.title;L(void 0,g?e:(0,h.Z)(e));break}case"messageMediaDocument":{const e=i.document;if("video"===e.type)L("AttachVideo");else if("voice"===e.type)L("AttachAudio");else if("gif"===e.type)L("AttachGif");else if("round"===e.type)L("AttachRound");else if("sticker"===e.type){const i=S.length;if(e.stickerEmojiRaw){const t=e.stickerEmojiRaw+" ";L(void 0,g?t:(0,h.Z)(t))}L("AttachSticker");const s=S.splice(i,2);if(g)S.push(s[0]+s[1]);else{const e=window.document.createElement("span");e.append(...s),S.push(e)}t=""}else if("audio"===e.type){const t=e.attributes.find((e=>"documentAttributeAudio"===e._&&(e.title||e.performer))),i="🎵 "+(t?[t.title,t.performer].filter(Boolean).join(" - "):e.file_name);L(void 0,g?i:(0,h.Z)(i))}else L(void 0,g?e.file_name:(0,h.Z)(e.file_name));break}case"messageMediaInvoice":"messageExtendedMediaPreview"===(null===(w=i.extended_media)||void 0===w?void 0:w._)?L(void 0,g?i.description:(0,h.Z)(i.description)):L(void 0,g?i.title:(0,h.Z)(i.title));break;case"messageMediaUnsupported":L(l.nK)}}const a=S.length;for(let e=1;e<a;e+=2)S.splice(e,0,", ");t&&a&&S.push(", ")}if(e.action){const t=yield(0,m.Z)(e,g);t&&L(void 0,t)}if(I&&(t=(0,a.RP)(e.restriction_reason).text,M=[]),t)if(t=(0,r.Z)(t,100),M||(M=[]),g)S.push((0,u.Z)(t,M));else{if(v){v=v.trim();let e,i=!1;const s=new RegExp((0,o.Z)(v),"gi");for(M=M.slice();null!==(e=s.exec(t));)M.push({_:"messageEntityHighlight",length:v.length,offset:e.index}),i=!0;i&&(0,c.Z)(M)}const e=(0,f.ZP)(t,{noLinebreaks:!0,entities:M,noLinks:!0,noTextFormat:!0});S.push((0,n.Z)(e))}if(g)return S.join("");{const e=document.createDocumentFragment();return e.append(...S),e}},new((L=void 0)||(L=Promise))((function(e,t){function i(e){try{n(E.next(e))}catch(e){t(e)}}function s(e){try{n(E.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((E=E.apply(S,C||[])).next())}))}},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:()=>v});var s=i(2830),n=i(4755),a=i(3512),o=i(3442),r=i(6705),d=i(8580),l=i(1713),c=i(7030),h=i(2312),u=i(3114),f=i(7660),p=i(319),m=i(1507),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({photo:e,message:t,container:i,boxWidth:b,boxHeight:y,withTail:w,isOut:S,lazyLoadQueue:C,middleware:L,size:E,withoutPreloader:I,loadPromises:M,autoDownloadSize:P,noBlur:Z,noThumb:k,noFadeIn:T,blurAfter:x,managers:A=a.Z.managers}){return g(this,void 0,void 0,(function*(){const _={loadPromises:{thumb:Promise.resolve(),full:Promise.resolve()},images:{thumb:null,full:null},preloader:null,aspecter:null},F="document"===e._,D=(0,u.Z)(e);if(!e.sizes&&!e.thumbs&&!D)return b&&y&&!E&&F&&(0,l.Z)(e,i,b,y,void 0,t),_;let R=0===P;E||(void 0===b&&(b=n.Z.active.regular.width),void 0===y&&(y=n.Z.active.regular.height)),i.classList.add("media-container");let B,N,O=i,U=!0,H=Promise.resolve();const z=F&&"image/gif"===e.mime_type&&!E;if(b&&y&&!E){const s=(0,l.Z)(e,i,b,y,void 0,t,void 0,z?{_:"photoSize",w:e.w,h:e.h,size:e.size,type:m.Pt}:void 0);if(E=s.photoSize,U=s.isFit,N=yield A.thumbsStorage.getCacheContext(e,E.type),!U&&!D){O=document.createElement("div"),O.classList.add("media-container-aspecter"),O.style.width=s.size.width+"px",O.style.height=s.size.height+"px";const n=(0,d.Z)(e,N,!Z,!0);if(n){H=n.loadPromise;const e=n.image;e.classList.add("media-photo"),i.append(e)}else(yield v({container:i,message:t,photo:e,boxWidth:0,boxHeight:0,size:E,lazyLoadQueue:C,isOut:S,loadPromises:M,middleware:L,withoutPreloader:I,withTail:w,autoDownloadSize:P,noBlur:Z,noThumb:!0,blurAfter:!0,managers:A})).images.full.classList.add("media-photo","thumbnail");i.classList.add("media-container-fitted"),i.append(O)}}else E||(E=(0,c.Z)(e,b,y,!0)),N=yield A.thumbsStorage.getCacheContext(e,null==E?void 0:E.type);if(!k&&!D){const t=(0,d.Z)(e,N,!Z);t&&(H=Promise.all([H,t.loadPromise]),_.loadPromises.thumb=_.loadPromises.full=H,B=_.images.thumb=t.image,B.classList.add("media-photo"),O.append(B))}if(_.aspecter=O,"photoSizeEmpty"===(null==E?void 0:E._)&&F||(null==E?void 0:E.bytes))return _;let j;"videoSize"===(null==E?void 0:E._)?(j=_.images.full=(0,f.Z)(),j.autoplay=!0,j.loop=!0,j.muted=!0,j.classList.add("media-photo")):(j=_.images.full=new Image,j.classList.add("media-photo"));const G=(B||!N.downloaded)&&a.Z.settings.animationsEnabled&&!T;let V;const K=null==t?void 0:t.uploadingFileName;I||(N.downloaded&&!K||(V=new o.Z({attachMethod:"prepend",isUpload:!!K})),K&&(V.attachPromise(h.Z.getUpload(K)),V.attach(i),R=void 0));const W=e=>(0,s.Z)(i,j,e,G,O,B),$=e=>g(this,void 0,void 0,(function*(){if(!L||L()){if(x){const t=(0,r.Z)(e,12);return t.promise.then((()=>W(t.canvas.toDataURL())))}return W(e)}}));let q;const Q=E.w>=150&&E.h>=150||R,Y=()=>g(this,void 0,void 0,(function*(){R&&!I&&V&&(V.construct(),V.setManual());const t=(()=>{const t=z&&!E;return h.Z.downloadMediaURL({media:e,thumb:E,queueId:null==C?void 0:C.queueId,onlyCache:t?void 0:R})})(),s=yield A.thumbsStorage.getCacheContext(e,null==E?void 0:E.type);V&&!s.downloaded&&!I&&Q&&V.attach(i,!1,t),R=void 0;const n=t.then($);return n.catch(p.Z),{download:t,render:n}}));return V&&V.setDownloadFunction(Y),N.downloaded?H=q=(yield Y()).render:C?C.push({div:i,load:()=>Y().then((({download:e})=>e))}):q=(yield Y()).render,M&&H&&M.push(H),yield H,_.loadPromises.thumb=H,_.loadPromises.full=q||Promise.resolve(),_.preloader=V,_}))}},5671:(e,t,i)=>{"use strict";i.d(t,{Z:()=>r});var s=i(2291),n=i(2325),a=i(3512),o=i(8842);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"):new o.Z(Object.assign(Object.assign({},(0,s.Z)(e)),{dialog:e.peerId===a.Z.myId})).element),(yield a.Z.managers.appPeersManager.isAnyGroup(e.peerId))||i){const i=new o.Z({peerId:e.peerId}).element;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:()=>F,ZP:()=>B,_2:()=>N,_i:()=>R});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),f=i(9405),p=i(4755),m=i(925),g=i(3174),v=i(6724),b=i(9674),y=i(2312),w=i(4846),S=i(2790),C=i(7030),L=i(13),E=i(1447),I=i(3512),M=i(7730),P=i(671),Z=i(5814),k=i(6787),T=i(2796),x=i(6775),A=i(645),_=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=1.49,D={},R={};function B({doc:e,div:t,middleware:i,loadStickerMiddleware:d,lazyLoadQueue:m,exportLoad:v,group:w,play:S,onlyThumb:B,emoji:N,width:O,height:U,withThumb:H,loop:z,loadPromises:j,needFadeIn:G,needUpscale:V,skipRatio:K,static:W,managers:$=I.Z.managers,fullThumb:q,isOut:Q,noPremium:Y,withLock:J,relativeEffect:X,loopEffect:ee,isCustomEmoji:te,syncedVideo:ie}){var se;return _(this,void 0,void 0,(function*(){t=Array.isArray(t)?t:[t],te&&(N=e.stickerEmojiRaw);const ne=e.sticker;if(1===ne&&(W=!0),!O&&!U){const t=p.Z.active,i=N?t.emojiSticker:e.animated?t.animatedSticker:t.staticSticker,s=(0,f.C)(e.w,e.h).aspectFitted(i);O=s.width,U=s.height}let ae;2===ne&&E.Z.loadLottieWorkers(),t.forEach((t=>{t.dataset.docId=""+e.id,N&&(t.dataset.stickerEmoji=N),t.classList.add("media-sticker-wrapper")}));const oe=(t=(null==ae?void 0:ae.type))=>_(this,void 0,void 0,(function*(){return ae=yield $.thumbsStorage.getCacheContext(e,t)})),re=!W&&(2===ne||3===ne),de=(0,L.Z)(e);void 0!==Q&&de&&!Q&&t.forEach((e=>e.classList.add("reflect-x")));const le=de&&J;if(le){const i=D[e.id];t.forEach((e=>{e.classList.add("is-premium-sticker","tgico-premium_lock"),i&&e.style.setProperty("--lock-url",`url(${i})`)}))}if(W&&1!==ne){const t=(0,C.Z)(e,O,U,!1);yield oe(t.type)}else yield oe(null==q?void 0:q.type);const ce=N&&!te?(0,P.tB)(N):-1,he=ae.downloaded&&!G,ue=re,fe=2===ne||3===ne?yield $.appDocsManager.getLottieCachedThumb(e.id,ce):void 0,pe={render:void 0,load:void 0};let me=(0,n.Z)(),ge=!1;if(((null===(se=e.thumbs)||void 0===se?void 0:se.length)||fe)&&!t[0].firstElementChild&&(!he||ue||B)&&!1!==H){let n=fe||e.thumbs[0];const a=(e,t)=>{e.childElementCount?me.resolve():(t.classList.add("media-sticker","thumbnail"),b.Z.mutateElement(e,(()=>{e.append(t),me.resolve()})))};if("url"in n)ge=!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),I.Z.settings.animationsEnabled&&!te&&o.setAttributeNS(null,"fill","url(#g)"),a.append(o),t.forEach(((e,t)=>e.append(t>0?a.cloneNode(!0):a))),ge=!0,me.resolve()}else if(ce<=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||ae.url?(ge=!0,o()):(ge=!0,M.Z.convert("main-"+e.id,n.bytes).then((s=>{$.appDocsManager.saveWebPConvertedStrippedThumb(e.id,s),n.bytes=s,e.pFlags.stickerThumbConverted=!0,i&&!i()||t[0].childElementCount?me.resolve():o()})).catch((()=>me.resolve())))}}else if((2===ne&&ce<=0||3===ne)&&(H||B)){const s=()=>_(this,void 0,void 0,(function*(){if(t[0].childElementCount||i&&!i())return void me.resolve();const s=(e,t,s)=>{e.childElementCount||i&&!i()?me.resolve():s?(0,l.ZP)(t,s,(()=>a(e,t))):a(e,t)};yield oe(),t.forEach((t=>{if(ae.url)s(t,new Image,ae.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=>_(this,void 0,void 0,(function*(){return s(t,new Image,e)}))))}))}));if(m&&B)return m.push({div:t[0],load:s}),me.resolve(),pe;s(),n.url&&(ge=!0)}}if(j&&ge&&j.push(me),B)return pe;const ve=(0,u.Z)("MIDDLEWARE"),be=()=>_(this,void 0,void 0,(function*(){if(i&&!i())throw ve;if(2===ne&&!W)return y.Z.downloadMedia({media:e,queueId:null==m?void 0:m.queueId,thumb:q}).then((s=>_(this,void 0,void 0,(function*(){if(i&&!i())throw ve;const n=yield E.Z.loadAnimationWorker({container:t[0],loop:!(N&&!te)&&z,autoplay:S,animationData:s,width:O,height:U,name:"doc"+e.id,needUpscale:V,skipRatio:K,toneIndex:ce,sync:te},w,null!=d?d:i),a=le?()=>{var i,s;const a=null!==(i=D[s=e.id])&&void 0!==i?i:D[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 f=document.createElement("canvas");f.width=s,f.height=s;const p=f.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 p.fillStyle=g,p.fillRect(0,0,f.width,f.height),p.fillStyle="rgba(112, 117, 121, 0.3)",p.fillRect(0,0,f.width,f.height),f.toDataURL("image/jpeg")}(n.canvas[0]);t.forEach((e=>e.style.setProperty("--lock-url",`url(${a})`)))}:void 0;return n.addEventListener("firstFrame",(()=>{const i=n.canvas[0];(!1!==H||te)&&(0,g.O)(e,i,ce),le&&a(),te||t.forEach(((e,t)=>{((e,t)=>{const i=e.firstElementChild;!1!==G&&(G=(G||!i||"svg"===i.tagName)&&I.Z.settings.animationsEnabled);const s=()=>{i&&i!==t&&"DIV"!==i.tagName&&i.remove()};G?b.Z.mutate((()=>{t&&t.classList.add("fade-in"),i&&i.classList.add("fade-out"),(t||i).addEventListener("animationend",(()=>{b.Z.mutate((()=>{t&&t.classList.remove("fade-in"),s()}))}),{once:!0})})):i&&b.Z.mutate(s)})(e,n.canvas[t])}))}),{once:!0}),N&&$.appStickersManager.preloadAnimatedEmojiStickerAnimation(N),n}))));if(W||3===ne){const s=re&&ie,n=s?A.Z.generateName(""+e.id,0,0,void 0,void 0):void 0,a=R[n];if(a)return a;const o=(s?t.slice(0,1):t).map((()=>{let e;if(W)e=new Image;else{const t=e=(0,r.Z)();if(t.muted=!0,S&&(t.autoplay=!0),z&&(t.loop=!0),z&&"number"==typeof z){let i=0,s=0;function n(){i>this.currentTime&&++s===z&&(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!==G&&(G=(G||!he||(W?c[0]:!c[0]||"svg"===c[0].tagName))&&I.Z.settings.animationsEnabled),G&&o.forEach((e=>e.classList.add("fade-in")));const h=new Promise(((n,a)=>_(this,void 0,void 0,(function*(){const r=()=>_(this,void 0,void 0,(function*(){if(i&&!i())return void a(ve);const r=o.length,d=[];let h;yield oe(),t.forEach(((t,u)=>{const f=o[u];f&&(h=(0,l.cj)(f,ae.url)),h.then((()=>((t,o,l)=>{b.Z.mutateElement(t,(()=>{if(!i||i())if(o){if(o){const t=O*window.devicePixelRatio,i=U*window.devicePixelRatio;if(!(0,g.k)(e,ce,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,ce)}}s?n(o):(t.append(o),G?(l&&l.classList.add("fade-out"),o.addEventListener("animationend",(()=>{o.classList.remove("fade-in"),null==l||l.remove()}),{once:!0})):null==l||l.remove(),re&&Z.Z.addAnimation(o,w),d.push(o)===r&&n(d))}else s&&re||null==l||l.remove();else a(ve)}))})(t,f,c[u])))}))}));if(yield oe(),ae.url)r();else{let t;if(1!==ne&&W){const i=(0,C.Z)(e,O,U,!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&&(R[n]=h,d&&h.finally((()=>{d()||delete R[n]}))),h}}));if(v&&(1===v&&(!he||re)||2===v))return pe.load=be,pe;const ye=!m||he&&!re?be():(m.push({div:t[0],load:be}),Promise.resolve());return he&&W&&(me=ye,j&&j.push(me)),2===ne&&de&&void 0!==Q&&!Y&&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=>_(this,void 0,void 0,(function*(){if((0,a.Z)(i),h){const e=document.createElement("a");return e.onclick=()=>{(0,T.PE)(),new k.Z(t.stickerSetInput).show()},void(0,T.bC)({langPackKey:"Sticker.Premium.Click.Info",langPackArguments:[e]})}h=!0,yield d;const{animationDiv:o,stickerPromise:u}=(0,x.Z)({doc:t,middleware:s,side:n?"right":"left",size:r*F,target:e,play:!0,fullThumb:(0,L.Z)(t),relativeEffect:l,loopEffect:c});void 0===n||n||o.classList.add("reflect-x"),u.then((e=>{e.addEventListener("destroy",(()=>{h=!1}))}))}))))}({container:t[0],doc:e,managers:$,middleware:i,isOut:Q,width:O,loadPromise:ye,relativeEffect:X,loopEffect:ee}),pe.render=ye,pe}))}function N({event:e,container:t,managers:i,peerId:s,middleware:n}){var o,r;return _(this,void 0,void 0,(function*(){(0,a.Z)(e);const l=(0,d.Z)(t,"bubble"),c=t.dataset.stickerEmoji,h=t.classList.contains("custom-emoji")?void 0:E.Z.getAnimation(t);if(null==h?void 0:h.paused){const e=yield i.appStickersManager.getAnimatedEmojiSoundDocument(c);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){}}h.autoplay=!0,h.restart()}if(!s.isUser())return;const u=yield i.appStickersManager.getAnimatedEmojiSticker(c,!0);if(!u)return;const f=null!==(o=(r=t).emojiData)&&void 0!==o?o:r.emojiData={a:[],v:1},p=t.sendInteractionThrottled=(0,v.Z)((()=>{if(!f.a.length)return;const e=f.a[0].t;f.a.forEach((t=>{t.t=(t.t-e)/1e3}));const s=(0,d.Z)(t,"bubble");i.appMessagesManager.setTyping(w.Z.chat.peerId,{_:"sendMessageEmojiInteraction",msg_id:(0,S.Z)(+s.dataset.mid),emoticon:c,interaction:{_:"dataJSON",data:JSON.stringify(f)}},!0),f.a.length=0}),1e3,!1),g=l?l.classList.contains("is-out"):void 0,{animationDiv:b}=(0,x.Z)({doc:u,middleware:n,side:g?"right":"left",size:360,target:t,play:!0,withRandomOffset:!0});void 0===g||g||b.classList.add("reflect-x"),e.isTrusted&&(f.a.push({i:1,t:Date.now()}),p())}))}},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(4846),h=i(3541);function u({size:e,doc:t,middleware:i,target:u,side:f,skipRatio:p,play:m,managers:g,fullThumb:v,withRandomOffset:b,relativeEffect:y,loopEffect:w}){var S;const C=document.createElement("div");let L;C.classList.add("emoji-animation"),C.style.width=e+"px",C.style.height=e+"px";const E=()=>{I.clean(),null==L||L.remove(),C.remove(),c.Z.chat.bubbles.scrollable.container.removeEventListener("scroll",x)},I=null!==(S=null==i?void 0:i.create())&&void 0!==S?S:(0,r.k)();i=I.get();const M=(0,h.ZP)({div:C,doc:t,middleware:i,withThumb:!1,needFadeIn:!1,loop:!!w,width:e,height:e,play:m,group:"none",skipRatio:p,managers:g,fullThumb:v}).then((({render:e})=>e)).then((e=>{if((0,n.Z)(e),!i())throw e.remove(),(0,o.Z)("MIDDLEWARE");return L=e,L.addEventListener("enterFrame",(e=>{(w||e!==L.maxFrame)&&(0,a.Z)(u)||E()})),s.Z&&L.addEventListener("firstFrame",(()=>{navigator.vibrate(100)}),{once:!0}),L})),P=e=>{const t=Math.random()*e*2;return t>e?-t%e:t},Z=b?P(16):0,k=b?P(4):0,T=()=>{if(!(0,a.Z)(u))return void E();const t=u.getBoundingClientRect(),i=t.width/200,s="center"===f?0:16*("right"===f?1:-1)*i,n="center"===f?0:0*i,o="right"===f?t.right:t.left,r=t.top,d=("center"===f?(t.width-e)/2:"right"===f?-e:0)+s+Z,c=(t.height-e)/2+n+k,h=o+d,p=r+c;p<=-e||p>=l.Z.height?E():y?("center"!==f?C.style[f]=-1*Math.abs(s)+"px":C.style.left=d+"px",C.style.top=c+"px"):(C.style.top=p+"px",C.style.left=h+"px")},x=(0,d.Z)(T);return c.Z.chat.bubbles.scrollable.container.addEventListener("scroll",x),T(),y?(C.classList.add("is-relative"),u.parentElement.append(C)):c.Z.emojiAnimationContainer.append(C),{animationDiv:C,stickerPromise:M}}},5772:(e,t,i)=>{"use strict";i.d(t,{Z:()=>a});var s=i(3512),n=i(3541);function a({emoji:e,div:t,width:i,height:a,managers:o=s.Z.managers}){return r=this,d=void 0,c=function*(){const s=yield o.appStickersManager.getAnimatedEmojiSticker(e);if(!s)throw t.classList.add("media-sticker-wrapper"),new Error("no sticker");return(0,n.ZP)({doc:s,div:t,emoji:e,width:i,height:a,loop:!1,play:!0})},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())}));var r,d,l,c}},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:f,height:p,managers:m=r.Z.managers}){var g;return c(this,void 0,void 0,(function*(){if(null===(g=e.thumbs)||void 0===g?void 0:g.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:f,height:p,needUpscale:!0,name:"setThumb"+e.id},h)}));{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(t,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 v=yield r;"documentEmpty"!==v._&&(0,l.ZP)({doc:v,div:i,group:h,lazyLoadQueue:t,managers:m,width:f,height:p})}))}},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}},2887:(e,t,i)=>{"use strict";i.d(t,{Z:()=>x});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(5471),f=i(4755),p=i(319),m=i(925),g=i(3035),v=i(6724),b=i(9674),y=i(5157),w=i(2312),S=i(4846),C=i(1507),L=i(3512),E=i(5814),I=i(3013),M=i(8448),P=i(3442),Z=i(9492),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())}))};let T=0;function x({doc:e,container:t,message:i,boxWidth:x,boxHeight:A,withTail:_,isOut:F,middleware:D,lazyLoadQueue:R,noInfo:B,group:N,onlyPreview:O,noPreview:U,withoutPreloader:H,loadPromises:z,noPlayButton:j,photoSize:G,videoSize:V,searchContext:K,autoDownload:W,managers:$=L.Z.managers}){var q;return k(this,void 0,void 0,(function*(){const Q=null==W?void 0:W.video;let Y=0===Q;const J=!(x&&A),X=("video"!==e.type||e.size<=52428800&&!J)&&("gif"===e.type?L.Z.settings.autoPlay.gifs:L.Z.settings.autoPlay.videos);let ee,te;if(!B){ee=document.createElement("span"),ee.classList.add("video-time"),t.append(ee);let i=!1;"gif"!==e.type?(ee.innerText=(0,y.Z)(e.duration,!1),j||"round"===e.type||(X&&!Y?ee.classList.add("tgico","can-autoplay"):i=!0)):(ee.innerText="GIF",X||j||(i=!0,Y=void 0)),i&&(te=document.createElement("span"),te.classList.add("video-play","tgico-largeplay","btn-circle","position-center"),t.append(te))}const ie={};if("image/gif"===e.mime_type){const s=yield(0,Z.Z)({photo:e,message:i,container:t,boxWidth:x,boxHeight:A,withTail:_,isOut:F,lazyLoadQueue:R,middleware:D,withoutPreloader:H,loadPromises:z,autoDownloadSize:Q,size:G,managers:$});return ie.thumb=s,ie.loadPromise=s.loadPromises.full,ie}let se;const ne=(0,d.Z)();if(ne.classList.add("media-video"),ne.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;T||(T=2*Math.PI*h),u.style.strokeDasharray=T+" "+T,u.style.strokeDashoffset=""+T,ee.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,ee),s.append(ne),t.append(s);const m=p.getContext("2d"),b=()=>{const e=s.message,t=I.Z.addMedia(e,!Y),i=()=>{(S.Z.chat.setPeerPromise||Promise.resolve()).finally((()=>{(0,l.Z)(t)||(t.removeEventListener("play",h),t.removeEventListener("timeupdate",c),t.removeEventListener("pause",f),t.removeEventListener("ended",b))}))},a=()=>{m.drawImage(t,0,0);const e=T-t.currentTime/t.duration*T;return u.style.strokeDashoffset=""+e,!t.paused},d=()=>{t.duration&&((0,l.Z)(t)?(t.paused&&a(),ee.innerText=(0,y.Z)(t.duration-t.currentTime,!1)):i())},c=(0,v.Z)((()=>{(0,g.T2)(d)}),1e3,!1),h=()=>{ne.classList.add("hide"),s.classList.remove("is-paused"),(0,n.cK)(a,p),se&&se.preloader&&se.preloader.classList.contains("manual")&&se.onClick()},f=()=>{(0,l.Z)(t)?s.classList.add("is-paused"):i()},b=()=>{ne.classList.remove("hide"),s.classList.add("is-paused"),ne.currentTime=0,ee.innerText=(0,y.Z)(t.duration,!1),t.currentTime&&(t.currentTime=0)};t.addEventListener("play",h),t.addEventListener("timeupdate",c),t.addEventListener("pause",f),t.addEventListener("ended",b),(0,r.fc)(p,(i=>{if((0,o.Z)(i),se&&!se.detached&&se.onClick(),t.paused){const i=!!K;if(I.Z.setSearchContext(K||{peerId:C.NM,inputFilter:{_:"inputMessagesFilterEmpty"},useSearch:!1})){const[t,n]=i?(0,M.ns)(s,e.mid):[];I.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(),ne.classList.add("hide")):f():h()};i.pFlags.is_outgoing?(s.onLoad=b,s.dataset.isOutgoing="1"):b()}else ne.autoplay=!0;let ae,oe;if(i){if(ae=yield(0,Z.Z)({photo:e,message:i,container:t,boxWidth:x,boxHeight:A,withTail:_,isOut:F,lazyLoadQueue:R,middleware:D,withoutPreloader:!0,loadPromises:z,autoDownloadSize:null==W?void 0:W.photo,size:G,managers:$}),ie.thumb=ae,!X&&"gif"!==e.type||O)return ie.loadPromise=ae.loadPromises.full,ie;if(_){const e=(ae.images.thumb||ae.images.full).parentElement;ne.width=+e.getAttributeNS(null,"width"),ne.height=+e.getAttributeNS(null,"height"),e.append(ne)}}else if(!U){const i=(0,h.Z)(e,{},!0);if(i){const e=i.image;e.classList.add("media-poster"),t.append(e),ie.thumb={loadPromises:{thumb:i.loadPromise,full:Promise.resolve()},images:{thumb:e,full:null},preloader:null,aspecter:null},null==z||z.push(i.loadPromise),ie.loadPromise=i.loadPromise}}if(O)return ie;!ne.parentElement&&t&&((null==ae?void 0:ae.aspecter)||t).append(ne);const re=()=>k(this,void 0,void 0,(function*(){return oe=yield $.thumbsStorage.getCacheContext(e,null==V?void 0:V.type)}));yield re();const de=null==i?void 0:i.uploadingFileName;de?(se=new P.Z({attachMethod:"prepend",isUpload:!0}),se.attachPromise(w.Z.getUpload(de)),se.attach(t,!1),Y=void 0):oe.downloaded||e.supportsStreaming||H?e.supportsStreaming&&(se=new P.Z({cancelable:!1,attachMethod:"prepend"})):se=new P.Z({attachMethod:"prepend"});const le=(0,a.Z)();if(ne.addEventListener("error",(e=>{4!==ne.error.code&&console.error("Error "+ne.error.code+"; details: "+ne.error.message),se&&!de&&se.detach(),le.isFulfilled||le.resolve()}),{once:!0}),"video"===e.type){const e=()=>{ne.duration&&(ee.innerText=(0,y.Z)(ne.duration-ne.currentTime,!1))},t=(0,v.Z)((()=>{(0,g.T2)(e)}),1e3,!1);ne.addEventListener("timeupdate",t),te&&ne.addEventListener("timeupdate",(()=>{b.Z.mutateElement(te,(()=>{te.remove()}))}),{once:!0})}ne.muted=!0,ne.loop=!0,ne.autoplay=!0;let ce=Y&&(null===(q=null==ae?void 0:ae.preloader)||void 0===q?void 0:q.loadFunc);const he=()=>k(this,void 0,void 0,(function*(){se&&Y&&!H&&(se.construct(),se.setManual()),yield re();let n=Promise.resolve();if(se&&!de||H)if(oe.downloaded||e.supportsStreaming)e.supportsStreaming&&(Y?n=Promise.reject((0,u.Z)("NO_AUTO_DOWNLOAD")):!oe.downloaded&&se&&(se.attach(t,!1,null),ne.addEventListener(s.IS_SAFARI?"timeupdate":"canplay",(()=>{se.detach()}),{once:!0})));else{const i=n=w.Z.downloadMediaURL({media:e,queueId:null==R?void 0:R.queueId,onlyCache:Y,thumb:V});se&&se.attach(t,!1,i)}return!Y&&ce&&(ce(),ce=null),Y=void 0,n.then((()=>k(this,void 0,void 0,(function*(){!D||D()?("round"===e.type&&I.Z.resolveWaitingForLoadMedia(i.peerId,i.mid,i.pFlags.is_scheduled),yield re(),(0,m.Z)(ne).then((()=>{N&&E.Z.addAnimation(ne,N),se&&!de&&se.detach(),le.resolve()}),(e=>{console.error("video load error",e),le.reject(e)})),(0,c.ZP)(ne,oe.url)):le.resolve()}))),p.Z),{download:n,render:Promise.all([n,le])}}));return se&&!de&&se.setDownloadFunction(he),"gif"!==e.type||X?ie.loadPromise=R?(R.push({div:t,load:()=>he().then((({render:e})=>e))}),Promise.resolve()):(yield he()).render:(0,r.fc)(t,(e=>{(0,o.Z)(e),te.remove(),he()}),{capture:!0,once:!0}),ie.thumb&&(yield ie.thumb.loadPromises.thumb),ie}))}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;T=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=T+" "+T,n.style.strokeDashoffset=""+T}))}}))},2498:(e,t,i)=>{"use strict";i.d(t,{Z:()=>a});var s=i(8456),n=i(4776);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(4776);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)}))}},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})},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 f(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 p=new Map;function m(e,t=2,i=2){if(!e)throw"no dataUri for blur: "+e;p.size>150&&p.clear();const s=document.createElement("canvas");s.className="canvas-thumbnail";let n=p.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:f},"unshift").then((()=>{n()}))},a.src=e}))}));p.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:()=>r});var s=i(4762),n=i(3306);const a=(0,n.Z)("ffd8ffe000104a46494600010100000100010000ffdb004300281c1e231e19282321232d2b28303c64413c37373c7b585d4964918099968f808c8aa0b4e6c3a0aadaad8a8cc8ffcbdaeef5ffffff9bc1fffffffaffe6fdfff8ffdb0043012b2d2d3c353c76414176f8a58ca5f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8ffc00011080000000003012200021101031101ffc4001f0000010501010101010100000000000000000102030405060708090a0bffc400b5100002010303020403050504040000017d01020300041105122131410613516107227114328191a1082342b1c11552d1f02433627282090a161718191a25262728292a3435363738393a434445464748494a535455565758595a636465666768696a737475767778797a838485868788898a92939495969798999aa2a3a4a5a6a7a8a9aab2b3b4b5b6b7b8b9bac2c3c4c5c6c7c8c9cad2d3d4d5d6d7d8d9dae1e2e3e4e5e6e7e8e9eaf1f2f3f4f5f6f7f8f9faffc4001f0100030101010101010101010000000000000102030405060708090a0bffc400b51100020102040403040705040400010277000102031104052131061241510761711322328108144291a1b1c109233352f0156272d10a162434e125f11718191a262728292a35363738393a434445464748494a535455565758595a636465666768696a737475767778797a82838485868788898a92939495969798999aa2a3a4a5a6a7a8a9aab2b3b4b5b6b7b8b9bac2c3c4c5c6c7c8c9cad2d3d4d5d6d7d8d9dae2e3e4e5e6e7e8e9eaf2f3f4f5f6f7f8f9faffda000c03010002110311003f00"),o=(0,n.Z)("ffd9");function r(e,t=!1){let i,n;return t?i=e instanceof Uint8Array?e:new Uint8Array(e):(i=new Uint8Array(a.concat(Array.from(e.slice(3)),o)),i[164]=e[1],i[166]=e[2]),n=t?s.IS_SAFARI?"image/png":"image/webp":"image/jpeg",function(e,t="image/jpeg"){return`data:${t};base64,${btoa(String.fromCharCode(...e))}`}(i,n)}},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},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";function s(e){return new Promise((t=>{var i,s,n;const a=document.createElement("canvas"),o=null!==(i=e.size)&&void 0!==i?i:e.mediaSize.aspectFitted(e.boxSize);a.width=o.width*window.devicePixelRatio,a.height=o.height*window.devicePixelRatio,a.getContext("2d").drawImage(e.media,0,0,a.width,a.height),a.toBlob((e=>{t({blob:e,size:o})}),null!==(s=e.mimeType)&&void 0!==s?s:"image/jpeg",null!==(n=e.quality)&&void 0!==n?n:1)}))}i.d(t,{Z:()=>s})},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){navigator.clipboard?navigator.clipboard.writeText(e):function(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)}(e)}i.d(t,{T:()=>s})},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"),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:()=>f,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){const{dateEl:t,timeEl:i}=c(e,{capitalize:!0}),s=document.createDocumentFragment();return s.append(t," ",(0,n.ag)("ScheduleController.at")," ",i),s}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 f=(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)},p=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===P(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:P(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>=p)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>=p&&C(t,i,s)}}}else{let e=+i;const s=(new Date).getFullYear();if(e<p){e=p;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(Z(a-1,o)&&r>=p&&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:M(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>=p&&s<=12)return void C(t,s-1,a);a<=12&&L(t,s-1,a-1)}else s>=p&&a<=12&&C(t,a-1,s)}}function C(e,t,i){const s=(new Date).getFullYear(),n=Date.now();if(i>=p&&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(Z(t,i)){const n=(new Date).getFullYear(),a=Date.now();for(let o=n;o>=p;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:M(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 M(e){const t=new Date(e);return("0"+t.getDate()).slice(-2)+"."+("0"+(t.getMonth()+1)).slice(-2)+"."+t.getFullYear()}function P(e){const t=new Date(e);return o[t.getDay()]}function Z(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},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(e,t,i){const d=i?i.add(e):e.addEventListener.bind(e),l=i?i.removeManual.bind(i,e):e.removeEventListener.bind(e);if(n.IS_APPLE&&s.Z){let i;const s={capture:!0},n=()=>{clearTimeout(i),l("touchmove",n,s),l("touchend",n,s),l("touchcancel",n,s)};d("touchstart",(l=>{l.touches.length>1?n():(d("touchmove",n,s),d("touchend",n,s),d("touchcancel",n,s),i=window.setTimeout((()=>{r?n():(t(l.touches[0]),n(),a.Z.isOpened()&&e.addEventListener("touchend",o.Z,{once:!0}))}),400))}))}else d("contextmenu",s.Z?i=>{t(i),a.Z.isOpened()&&e.addEventListener("touchend",o.Z,{once:!0})}:t)}},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}),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}),s&&s({x:t.touches[0].clientX,y:t.touches[0].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,{EN:()=>r,fc:()=>o,pf:()=>a,tH:()=>d});var s=i(5432),n=i(6669);const a=s.Z?"mousedown":"click";function o(e,t,i={}){const s=i.listenerSetter?i.listenerSetter.add(e):e.addEventListener.bind(e);i.touchMouseDown=!0,s(a,t,i)}function r(e,t,i){e.removeEventListener(a,t,i)}function d(e){(0,n.Z)(e,a)}},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)}}},748:(e,t,i)=>{"use strict";i.d(t,{Z:()=>v});var s=i(6787),n=i(4846),a=i(3512),o=i(3003),r=i(2353),d=i(3416),l=i(3699),c=i(3624),h=i(1483),u=i(6976),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())}))},p=i(8497),m=i(3173),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){const{listenTo:t,isStickerPack:i,verifyRecent:v,appendTo:b,onOpen:y,onClose:w,onSend:S}=e;let C,L;const E=e=>g(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===L.id));return e?!i:i}));return function({buttons:e,findElement:t,listenTo:i,appendTo:s,filterButtons:n,onOpen:a,onClose:p}){null!=s||(s=document.body);const m=new l.Z,g=new l.Z,v=(0,c.k)();let b;(0,u.E)(i,(e=>{const i=t(e);if(!i)return;let s=b;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),(()=>{f(this,void 0,void 0,(function*(){yield null==a?void 0:a(i);const t=yield w();if(!t)return;s=t.element;const{cleanup:n,destroy:o}=t;(0,h.Z)(e,s),d.Z.openBtnMenu(s,(()=>{null==p||p(),n(),setTimeout((()=>{o()}),300)}))}))})()}),m);const y=()=>{g.removeAll(),v.clean()},w=()=>f(this,void 0,void 0,(function*(){y(),e.forEach((e=>e.element=void 0));const t=n||(e=>(0,r.Z)(e,(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}))),i=yield t(e);if(!i.length)return;const a=b=(0,o.Z)(i,g);return a.classList.add("contextmenu"),s.append(a),{element:a,cleanup:y,destroy:()=>{a.remove()}}}));return{element:b,destroy:()=>{y(),m.removeAll()}}}({listenTo:t,appendTo:b,findElement:e=>C=(0,p.Z)(e.target,"media-sticker-wrapper"),onOpen:()=>g(this,void 0,void 0,(function*(){return L=yield a.Z.managers.appDocsManager.getDoc(C.dataset.docId),null==y?void 0:y()})),onClose:w,buttons:[{icon:"stickers",text:"Context.ViewStickerSet",onClick:()=>new s.Z(L.stickerSetInput).show(),verify:()=>!i},{icon:"favourites",text:"AddToFavorites",onClick:()=>a.Z.managers.appStickersManager.faveSticker(L.id,!1),verify:()=>E(!0)},{icon:"favourites",text:"DeleteFromFavorites",onClick:()=>a.Z.managers.appStickersManager.faveSticker(L.id,!0),verify:()=>E(!1)},{icon:"delete",text:"DeleteFromRecent",onClick:()=>a.Z.managers.appStickersManager.saveRecentSticker(L.id,!0),verify:()=>{var e;return null!==(e=null==v?void 0:v(C))&&void 0!==e&&e}},{icon:"mute",text:"Chat.Send.WithoutSound",onClick:()=>(null==S||S(),m.Jo.sendDocId(L.id,!1,!0)),verify:()=>!(!n.Z.chat.peerId||n.Z.chat.peerId===a.Z.myId)},{icon:"schedule",text:"Chat.Send.ScheduledMessage",onClick:()=>n.Z.chat.input.scheduleSending((()=>n.Z.chat.input.sendMessageWithDocument(L))),verify:()=>!!n.Z.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:()=>n});var s=i(3512);const n=new class{constructor(){this.cache={},s.Z.addEventListener("theme_change",(()=>{this.computedStyle=void 0;const e=this.cache;this.cache={};for(const t in e)this.getProperty(t)}))}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)}}},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,{Z:()=>d,o:()=>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"]),o=new RegExp(s.Z,"g");function r(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 d(e,t,i,s,n,l,c={offset:0}){if(e.nodeType===e.TEXT_NODE){let t=e.nodeValue;return t=t.replace(o,""),t?s===e?i.push(t.substr(0,n)+""+t.substr(n)):i.push(t):s===e&&i.push(""),l&&t.length&&e.parentNode&&r(e,t,l,c),void(c.offset+=t.length)}if(e.nodeType!==e.ELEMENT_NODE)return;const h=s===e,u=a.has(e.tagName);if(u&&(i.length||"BR"===e.tagName))t.push(i.join("")),i.length=0,++c.offset;else{const t=e.dataset.stickerEmoji||e.alt,s=e.dataset.stickerEmoji;t&&l&&r(e,t,l,c),s&&l&&l.push({_:"messageEntityCustomEmoji",document_id:e.dataset.docId,offset:c.offset,length:t.length}),t&&(i.push(t),c.offset+=t.length)}h&&!n&&i.push("");const f=e.matches('[style*="table-cell"], th, td'),p=null==l?void 0:l.length;let m=e.firstChild;for(;m;)d(m,t,i,s,n,l,c),m=m.nextSibling;if(h&&n&&i.push(""),f&&e.nextSibling&&(i.push(" "),++c.offset,void 0!==p))for(let e=p,t=l.length;e<t;++e)++l[e].length;const g=i.length;u&&g&&(t.push(i.join("")),i.splice(0,g),++c.offset),g&&"P"===e.tagName&&e.nextSibling&&(t.push(""),++c.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.Z)(t,s,r,d,l,c,h),t=t.nextSibling}else(0,o.Z)(e,s,r,d,l,c,h);r.length&&s.push(r.join(""));let u=s.join("\n");const f=u.indexOf("");return-1!==f&&(u=u.substr(0,f)+u.substr(f+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:f}}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(!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(Math.abs(t)>50)return e.onSwipe(t,i,n),(0,s.s)(),!0}}))}},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})},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)}},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.innerHTML=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(4776),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),f=i(2398);const p=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 f=this.getCaretPosN();if((null===(n=f.node)||void 0===n?void 0:n.nodeValue)===r.Z&&(!s||o===this.lastNode)){const t=this.findPreviousSmthIndex(e,f.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 f=u.toString(),m=!p.test(f);if(this.log("test cursor",f,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,f.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)p.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}}},130:(e,t,i)=>{"use strict";function s(e,t){e.setAttribute("dir","auto"),"string"==typeof t?t?e.innerHTML=t:e.textContent="":e.replaceChildren(t)}i.d(t,{Z:()=>s})},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(9818),l=i(8497),c=i(3512);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,a=function*(){const t=!!this.element.style.display&&void 0===e||e;if(this.init){if(!t)return;this.init(),this.init=null}if(t===this.isActive())return;const i=o.Z||!c.Z.settings.animationsEnabled?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")}),i)}else this.dispatchEvent("close"),this.ignoreMouseOut.clear(),this.ignoreButtons.clear(),this.element.classList.remove("active"),d.Z.removeItem(this.navigationItem),(0,s.EN)(window,this.onClickOut,{capture:!0}),this.clearTimeout("toggle"),this.setTimeout("done",(()=>{this.element.style.display="none",this.forceClose=!1,this.dispatchEvent("closed")}),i)},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},(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((()=>{(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(3512),d=i(8487);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"),r.Z.settings.animationsEnabled&&0!==e.forceDuration||(e.forceDirection=s.Static),e.forceDirection===s.Static)return e.forceDuration=0,c(e);const d=(0,a.AD)().then((()=>c(e)));return"y"===e.axis?(0,n.YW)(d):d}function c(e){const{element:t,container:i,getNormalSize:s,getElementPosition:n,transitionFunction:a,axis:r,margin:l,position:f,forceDirection:p,maxDistance:m,forceDuration:g}=e;if(!(0,d.Z)(t))return(0,o.Kx)(i),Promise.resolve();const v="y"===r?"top":"left",b="y"===r?"bottom":"right",y="y"===r?"height":"width",w="y"===r?"scrollHeight":"scrollWidth",S="y"===r?"scrollHeight":"offsetWidth",C="y"===r?"scrollTop":"scrollLeft",L=t.getBoundingClientRect(),E=i.getBoundingClientRect?i.getBoundingClientRect():document.body.getBoundingClientRect(),I=L[v]-E[v],M=n?n({elementRect:L,containerRect:E,elementPosition:I}):I,P=t[S],Z=s?s({rect:E}):E[y];let k=i[C];const T=i[w];let x;switch(f){case"start":x=M-l;break;case"end":x=L[b]-E[b]+l;break;case"nearest":case"center":if(P<Z)x=M+P/2-Z/2;else{if(e.fallbackToElementStartWhenCentering&&e.fallbackToElementStartWhenCentering!==t)return e.element=e.fallbackToElementStartWhenCentering,e.position="start",c(e);x=M-l}}if(Math.abs(x-(l||0))<1)return(0,o.Kx)(i),Promise.resolve();if("y"===r&&void 0===p&&(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+Z);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"===r?"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;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,f="";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]&&"X"!==t[e]){i=0;break}++i}i>u&&(u=i,f=h)}h=f||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 p=h&&h.length>t.length?h.slice(t.length):"";return p&&(p=p.replace(/X/g,"")),{formatted:t,country:d,code:r.code,leftPattern:p}}},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)}))}}},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},3624:(e,t,i)=>{"use strict";i.d(t,{A:()=>a,k:()=>o});var s=i(1655);const n=(0,i(5471).Z)("MIDDLEWARE");class a{constructor(){this.details={cleaned:!1,inner:[],onCleanCallbacks:[]},this.onDestroyCallbacks=[],this.onDestroy=e=>{if(this.destroyed)return e();this.onDestroyCallbacks.push(e)}}clean(){const e=this.details;e.cleaned=!0,e.inner.splice(0,e.inner.length).forEach((e=>e.destroy())),e.onCleanCallbacks.splice(0,e.onCleanCallbacks.length).forEach((e=>e())),this.details={cleaned:!1,inner:[],onCleanCallbacks:[]}}destroy(){this.destroyed=!0,this.clean(),this.onDestroyCallbacks.splice(0,this.onDestroyCallbacks.length).forEach((e=>e())),this.parent&&((0,s.Z)(this.parent.details.inner,this),this.parent=void 0)}get(e){const t=this.details,i=()=>!t.cleaned&&(!e||e());return i.create=()=>{if(!i())throw n;const e=new a;return e.parent=this,t.inner.push(e),e},i.onClean=e=>{if(!i())return e();t.onCleanCallbacks.push(e)},i.onDestroy=this.onDestroy,i}}function o(){return new a}},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}))}}},3228:(e,t,i)=>{"use strict";function s(e,t,i){return e<t?t:e>i?i:e}i.d(t,{Z:()=>s})},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(t)};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(9818),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;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){const n=(e=+e)<0,a=s.Z[t];if(!a)throw new Error("CURRENCY_WRAP_INVALID");const o=e/Math.pow(10,a.exp);let r=a.exp;"IRR"==t&&Math.floor(o)==o&&(r=0);let d=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("."),d[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)}(o,r,a.decimal_sep,a.thousands_sep);if(i)return d;let l,c=a.symbol;n&&!a.space_between&&a.symbol_left&&(c="-"+c,d=d.replace("-",""));const h=a.space_between?" ":"";return l=a.symbol_left?c+h+d:d+h+c,l}window.p=n},1483:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(4755);function n({pageX:e,pageY:t},i,n,a){const o=Array.from(i.children).find((e=>e.classList.contains("btn-menu-item")&&!e.classList.contains("hide")))||i,{scrollWidth:r}=o,{scrollHeight:d}=i,l=document.body.getBoundingClientRect(),c=l.width,h=l.height;let u=8,f=8,p=8,m=8;a&&(a.top&&a.top,a.right&&(f+=a.right),a.bottom&&(p+=a.bottom),a.left&&(m+=a.left)),n=s.Z.isMobile?"right":"left";let g="top";const v=h-d-p,b=c-r-f,y=m,w={x:{left:e,right:Math.min(b,e-r)},intermediateX:"right"===n?y:b,y:{top:t,bottom:t-d},intermediateY:v},S={left:w.x.left+r+f<=c,right:w.x.right>=m},C={top:w.y.top+d+p<=h,bottom:w.y.bottom-p>=p};{const e=S[n]?w.x[n]:(n="center",w.intermediateX);i.style.left=e+"px"}{const e=C[g]?w.y[g]:(g="center",w.intermediateY);i.style.top=e+"px"}return i.className=i.className.replace(/(top|center|bottom)-(left|center|right)/g,""),i.classList.add(("center"===g?g:"bottom")+"-"+("center"===n?n:"left"===n?"right":"left")),{width:r,height:d}}},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)}},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(7030),a=i(9405),o=i(3114);function r(e,t,i,r,d=!0,l,c,h){const u=(0,o.Z)(e);let f;h||(h=(0,n.Z)(e,i,r,void 0,c));const p="document"===e._;f=p||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=f=f.aspect(m,d);let g=!0;return(!p||["video","gif"].includes(e.type)||u)&&(m.width<200&&m.height<200&&(m=f=f.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:f,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");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,(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=>{if(!t()||void 0!==i&&!i)return e(!1);this._updateList(),e(!0)}))}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})},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})},241:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(1352);const n=new class{constructor(){if(s.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()}}},8594:(e,t,i)=>{"use strict";i.d(t,{YW:()=>f,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 f(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(),f=c;return Promise.race(i).then((()=>{c!==f||c.isFulfilled||(--h,n.ZP&&u("promise end, length:",h,performance.now()-d),h<=0&&p())})),c}function p(){c.isFulfilled||(l=!1,h=0,o.dispatchEvent(d),c.resolve(),n.ZP&&u("end"))}function m(){p()}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=f},9893:(e,t,i)=>{"use strict";i.r(t),i.d(t,{AppDialogsManager:()=>qe,DIALOG_LIST_ELEMENT_TAG:()=>Ve,default:()=>Ye});var s=i(9331),n=i(3512),a=i(3003),o=i(6194),r=i(2325),d=i(4668),l=i(8127),c=i(7425),h=i(2464),u=i(2796),f=i(3897),p=i(1483),m=i(3416),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{constructor(e){this.managers=e,this.onArchiveClick=()=>g(this,void 0,void 0,(function*(){const e=yield this.managers.appMessagesManager.getDialogOnly(this.selectedId);e&&this.managers.appMessagesManager.editPeerFolders([e.peerId],+!e.folder_id)})),this.onPinClick=()=>{this.managers.appMessagesManager.toggleDialogPin(this.selectedId,this.filterId).catch((e=>g(this,void 0,void 0,(function*(){if("PINNED_DIALOGS_TOO_MUCH"===e.type)if(this.filterId>=1)(0,u.bC)({langPackKey:"PinFolderLimitReached"});else{const e=yield this.managers.apiManager.getConfig();new l.Z("pinned-dialogs-too-much",{buttons:[{langKey:"OK",isCancel:!0},{langKey:"FiltersSetupPinAlert",callback:()=>{h.ZP.createTab(c.Z).open()}}],descriptionLangKey:"PinToTopLimitReached2",descriptionLangArgs:[(0,r.ag)("Chats",[e.pinned_dialogs_count_max])]}).show()}}))))},this.onUnmuteClick=()=>{this.managers.appMessagesManager.togglePeerMute(this.selectedId,!1)},this.onMuteClick=()=>{new f.Z(this.selectedId)},this.onUnreadClick=()=>g(this,void 0,void 0,(function*(){const e=this.selectedId,t=yield this.managers.appMessagesManager.getDialogOnly(e);t&&(t.unread_count?(this.managers.appMessagesManager.readHistory(e,t.top_message),this.managers.appMessagesManager.markDialogUnread(e,!0)):this.managers.appMessagesManager.markDialogUnread(e))})),this.onDeleteClick=()=>{new o.Z(this.selectedId)},this.onContextMenu=e=>{this.init&&(this.init(),this.init=null);let t=null;try{t=(0,d.Z)(e.target,Ve)}catch(e){}if(t){if(e instanceof MouseEvent&&e.preventDefault(),this.element.classList.contains("active"))return!1;e instanceof MouseEvent&&(e.cancelBubble=!0),(()=>{g(this,void 0,void 0,(function*(){this.filterId=Ye.filterId,this.selectedId=t.dataset.peerId.toPeerId(),this.dialog=yield this.managers.appMessagesManager.getDialogOnly(this.selectedId),yield Promise.all(this.buttons.map((e=>g(this,void 0,void 0,(function*(){const t=yield e.verify();e.element.classList.toggle("hide",!t)}))))),this.buttons[this.buttons.length-1].element.lastChild.replaceWith((0,r.ag)(yield this.managers.appPeersManager.getDeleteButtonText(this.selectedId))),t.classList.add("menu-open"),(0,p.Z)(e,this.element),m.Z.openBtnMenu(this.element,(()=>{t.classList.remove("menu-open"),this.selectedId=this.dialog=this.filterId=void 0}))}))})()}}}init(){this.buttons=[{icon:"unread",text:"MarkAsUnread",onClick:this.onUnreadClick,verify:()=>g(this,void 0,void 0,(function*(){return!(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:()=>g(this,void 0,void 0,(function*(){var e;return!(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:()=>g(this,void 0,void 0,(function*(){var e;return 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:()=>g(this,void 0,void 0,(function*(){return this.selectedId!==n.Z.myId&&!(yield this.managers.appNotificationsManager.isPeerLocalMuted(this.dialog.peerId))}))},{icon:"unmute",text:"ChatList.Context.Unmute",onClick:this.onUnmuteClick,verify:()=>g(this,void 0,void 0,(function*(){return this.selectedId!==n.Z.myId&&(yield this.managers.appNotificationsManager.isPeerLocalMuted(this.dialog.peerId))}))},{icon:"archive",text:"Archive",onClick:this.onArchiveClick,verify:()=>0===this.filterId&&this.selectedId!==n.Z.myId},{icon:"unarchive",text:"Unarchive",onClick:this.onArchiveClick,verify:()=>1===this.filterId&&this.selectedId!==n.Z.myId},{icon:"delete danger",text:"Delete",onClick:this.onDeleteClick,verify:()=>!0}],this.element=(0,a.Z)(this.buttons),this.element.id="dialogs-contextmenu",this.element.classList.add("contextmenu"),document.getElementById("page-chats").append(this.element)}}var b=i(6008),y=i(1405),w=i(8805),S=i(632),C=i(4762),L=i(5003),E=i(4846),I=i(4494),M=i(9099),P=i(410),Z=i(8842),k=i(1447),T=i(9492),x=i(534),A=i(2738),_=i(4484),F=i(5565),D=i(4159),R=i(3442),B=i(7487),N=i(9174),O=i(3910),U=i(490);class H{constructor(e,t){this.managers=e,this.hadConnect=!1,this.connecting=!1,this.timedOut=!1,this.updating=!1,this.setConnectionStatus=e=>{Promise.all([B.Z.get("dc"),n.Z.managers.rootScope.getConnectionStatus()]).then((([t,i])=>{t||(t=D.Z.baseDcId),this.setFirstConnectionTimeout&&(clearTimeout(this.setFirstConnectionTimeout),this.setFirstConnectionTimeout=0);const s=i["NET-"+t],n=s&&(e||s.status)===N.Q.Connected;this.connecting&&n&&this.managers.apiUpdatesManager.forceGetDifference(),n&&!this.hadConnect&&(this.hadConnect=!0),this.timedOut=s&&(e||s.status)===N.Q.TimedOut,this.connecting=!n,this.retryAt=s&&s.retryAt,P.ZP&&this.log("connecting",this.connecting),this.setState()}))},this.setStatusText=(e,t)=>{this.currentLangPackKey!==e&&(this.currentLangPackKey=e,(0,F.Z)(this.statusEl,(0,r.ag)(e,t)),this.statusPreloader.attach(this.statusEl))},this.setState=()=>{if(U.Z.deactivatedReason)return;const e=H.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.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");P.ZP&&this.log("setState",this.connecting||this.updating),window.requestAnimationFrame((()=>{this.setStateTimeout&&clearTimeout(this.setStateTimeout),this.setStateTimeout=window.setTimeout((()=>{(0,M.Z)(this.statusContainer,"is-shown",this.connecting||this.updating,200),this.setStateTimeout=0,P.ZP&&this.log("setState: isShown:",this.connecting||this.updating)}),e)}))},this.log=(0,L.kg)("CS",void 0,void 0),this.statusContainer=document.createElement("div"),this.statusContainer.classList.add("connection-status"),this.statusEl=(0,I.Z)("btn-primary bg-warning connection-status-button",{noRipple:!0}),this.statusPreloader=new R.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,P.ZP&&this.log("updating",this.updating),this.setState())})),n.Z.addEventListener("state_synchronized",(e=>{P.ZP&&this.log("state_synchronized",e),e||(this.updating=!1,P.ZP&&this.log("updating",this.updating),this.setState())})),this.setFirstConnectionTimeout=window.setTimeout(this.setConnectionStatus,H.CHANGE_STATE_DELAY+1e3)}getA(e,t){const i=document.createElement("a");return i.classList.add("force-reconnect"),i.append((0,r.ag)(e)),(0,A.fc)(i,(e=>{(0,O.Z)(e),t()})),i}}H.CHANGE_STATE_DELAY=1e3;var z,j=i(6740),G=i(3035),V=i(2894),K=i(5432),W=i(1154),$=i(241),q=i(8487);!function(e){e[e.Error=-1]="Error",e[e.Pending=0]="Pending",e[e.Sent=1]="Sent",e[e.Read=2]="Read"}(z||(z={}));var Q=i(5345),Y=i(5701),J=i(1507),X=i(5296),ee=i(8222);function te(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 ie=i(4755);function se(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 ne=window.devicePixelRatio,ae=20*ne,oe=2.5*ne,re=2*ne,de=1*ne;var le=i(6818),ce=i(9818),he=i(3013),ue=i(130),fe=i(4332),pe=i(1168),me=i(7030),ge=i(8115),ve=i(496),be=i(5381),ye=i(7530),we=i(2291),Se=i(5772),Ce=i(3385),Le=i(2554),Ee=i(8050),Ie=i(6976),Me=i(3725),Pe=i(7362),Ze=i(8631),ke=i(2312),Te=i(2059),xe=i(2493),Ae=i(319);var _e=i(3228);class Fe{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,_e.Z)(this.lightSource,0,1),e=(0,_e.Z)(this.lightSource-this.lightSpread,0,1),t=(0,_e.Z)(this.lightSource+this.lightSpread,0,1);const a=ee.Z.getProperty("background-color-true"),o=ee.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)}}class De{constructor(){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 Fe,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=54,this.marginVertical=9,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=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(),n.Z.settings.animationsEnabled||this.remove())}remove(){this.stopAnimation(),this.canvas.parentElement&&(this.canvas.remove(),this.onRemove&&(this.onRemove(),this.onRemove=void 0),this.blockScrollable&&(this.blockScrollable.container.style.overflowY="",this.blockScrollable=void 0))}updateCanvasSize(e=this.getRectFrom.getBoundingClientRect()){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:a}=this;if(!i)return;if(!n.Z.settings.animationsEnabled)return void this.remove();const{width:o}=e;t.globalCompositeOperation="destination-out";const r=Date.now()-i;let d=!0;for(let e=0;e<s;++e){const i=r-(a<s&&e>=a?15*(a-1):15*e);if(i<=0){d=!1;continue}const n=te(i,0,1,150);t.beginPath(),t.rect(0,this.dialogHeight*e,o,this.dialogHeight),t.fillStyle=`rgba(0, 0, 0, ${n})`,t.fill(),n<1&&(d=!1)}t.globalCompositeOperation="source-over",d&&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,X.jt)((()=>!!a()&&(n.Z.settings.animationsEnabled&&this.renderFrame(),a()))),n.Z.addEventListener("theme_change",this.onThemeChange),ie.Z.addEventListener("resize",this.onResize)}stopAnimation(){++this.tempId,n.Z.removeEventListener("theme_change",this.onThemeChange),ie.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=ee.Z.getProperty("surface-color"),s.fillRect(0,0,i.width,i.height),s.fillStyle="#000",s.globalCompositeOperation="destination-out";const a=this.dialogHeight=(this.avatarSize+2*this.marginVertical)*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:f}=this;let p=17;(function(e,t,i,s,n,a){(function(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()})(e,t+s,i+s,s,n,a)})(e,p,i+c,l/2,!0),p+=l+10,se(e,p,i+c+f,n,h,u,!0),se(e,p,i+c+l-h-f,a,h,u,!0),se(e,r.width/d-24-o,i+c+f,o,h,u,!0)}}var Re=i(5418),Be=i(3855),Ne=i(2353),Oe=i(1655),Ue=i(2648),He=i(3624),ze=i(5471),je=i(7479),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())}))};const Ve="A";function Ke(e,t){const i=e[t];null==i||i.reject();const s=e[t]=(0,Me.Z)();s.catch((()=>{})).finally((()=>{e[t]===s&&delete e[t]}));const n=(0,Ze.Z)((()=>e[t]===s));return{deferred:s,middleware:n}}class We extends Q.Z{constructor(e,t,i,s,n){super({getIndex:t=>e.dialogsStorage.getDialogIndex(t.id,this.indexKey),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,_.Z)(e.dom.listEl,this.list,t),s&&(null===(i=this.onListLengthChange)||void 0===i||i.call(this))},onElementCreate:e=>Ge(this,void 0,void 0,(function*(){const t=[],{dom:i}=Qe.addListDialog({peerId:e.id,loadPromises:t,isBatch:!0});return e.dom=i,yield Promise.all(t),e})),updateElementWith:G.TR,log:t}),this.managers=e,this.list=i,this.indexKey=s,this.onListLengthChange=n}clear(){this.list.replaceChildren(),super.clear()}}class $e extends je.ZP{constructor({peerId:e,rippleEnabled:t=!0,onlyFirstName:i=!1,meAsSaved:n=!0,avatarSize:a="bigger",autonomous:o,lazyLoadQueue:r,loadPromises:d,fromName:l,noIcons:c}){var h;super({clickable:!0,noRipple:!t,havePadding:!0,title:!0,titleRightSecondary:!0,subtitle:!0,subtitleRight:!0,noWrap:!0,asLink:!0});const u=new s.Z,f={bigger:54,abitbigger:42,small:32}[a];u.classList.add("dialog-avatar","avatar-"+f),u.updateWithOptions({loadPromises:d,lazyLoadQueue:r,isDialog:!!n,peerId:e,peerTitle:l});const p=this.container,m=this.title;m.classList.add("user-title"),this.titleRow.classList.add("dialog-title");const g=new Z.Z,v=g.update({peerId:e,fromName:l,dialog:n,onlyFirstName:i,plainText:!1,withIcons:!c});null==d||d.push(v),m.append(g.element),m.classList.add("tgico");const b=this.subtitle,y=this.container;y.classList.add("chatlist-chat","chatlist-chat-"+a),o||(y.href="#"+e),"bigger"===a?this.container.classList.add("row-big"):"small"===a&&this.container.classList.add("row-small"),this.applyMediaElement(u,a),y.dataset.peerId=""+e;const w=document.createElement("span");w.classList.add("message-status","sending-status");const S=document.createElement("span");S.classList.add("message-time");const C=document.createElement("div");C.className="dialog-subtitle-badge badge badge-22";const L=this.titleRight;L.classList.add("dialog-title-details"),L.append(w,S),this.subtitleRow.classList.add("dialog-subtitle");const I=this.dom={avatarEl:u,captionDiv:p,titleSpan:g.element,titleSpanContainer:m,statusSpan:w,lastTimeSpan:S,unreadBadge:C,lastMessageSpan:b,containerEl:y,listEl:y,subtitleEl:this.subtitleRow};o||(y.dialogDom=I,(null===(h=E.Z.chat)||void 0===h?void 0:h.peerId)===e&&Qe.setDialogActive(y,!0))}}class qe{constructor(){this.chatsContainer=document.getElementById("chatlist-container"),this.scroll=null,this.log=(0,L.kg)("DIALOGS",L.v9.Log|L.v9.Error|L.v9.Warn|L.v9.Debug),this.placeholders={},this.sortedLists={},this.scrollables={},this.folders={menu:document.getElementById("folders-tabs"),menuScrollContainer:null,container:document.getElementById("folders-container")},this.filtersRendered={},this.lastActiveElements=new Set,this.offsets={top:0,bottom:0},this.initedListeners=!1,this.loadedDialogsAtLeastOnce=!1,this.onTabChange=()=>(this.scroll=this.scrollables[this.filterId],this.scroll.loadedAll.top=!0,this.scroll.loadedAll.bottom=!1,this.offsets.top=this.offsets.bottom=0,this.loadDialogsRenderPromise=void 0,this.loadDialogsPromise=void 0,this.sortedList=this.sortedLists[this.filterId],this.onChatsScroll()),this._onListLengthChange=()=>{if(!this.loadedDialogsAtLeastOnce)return;if(this.checkIfPlaceholderNeeded(),this.filterId!==J.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 h.dw({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 V.Z({avatarSize:"abitbigger",createChatListOptions:{dialogSize:48,new:!0},autonomous:!1,onListLengthChange:i,managers:this.managers});this.loadContacts=()=>{const t=$.Z.height/60|0;(0,Ne.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=>Ge(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=>Ge(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})),this.onChatsRegularScroll=()=>{this.sliceTimeout&&clearTimeout(this.sliceTimeout),this.sliceTimeout=window.setTimeout((()=>{this.sliceTimeout=void 0,this.chatList.childElementCount&&!this.processContact&&(0,G.TR)((()=>{const e=performance.now(),t=this.scroll.scrollTop,i=this.chatList.firstElementChild,s=this.scroll.container.getBoundingClientRect(),n=i.getBoundingClientRect(),a=Array.from(this.scroll.splitUp.children);let o=this.scroll.splitUp.offsetTop;o&&t<o&&(o-=t);const r=s.y+o,l=s.y,c=(0,d.Z)(document.elementFromPoint(Math.ceil(n.x),Math.ceil(r+1)),i.tagName),h=(0,d.Z)(document.elementFromPoint(Math.ceil(n.x),Math.floor(l+s.height-1)),i.tagName);if(!c||!h)return;const u=c.getBoundingClientRect().y-r,f=[],p=a.indexOf(c),m=a.indexOf(h),g=C.IS_SAFARI?[]:a.slice(0,Math.max(0,p-10)),v=a.slice(m+10);g.length&&(this.scroll.loadedAll.top=!1),v.length&&(this.scroll.loadedAll.bottom=!1),f.push(...g),f.push(...v),f.forEach((e=>{const t=e.dataset.peerId.toPeerId();this.deleteDialog(t)})),this.setOffsets(),this.scroll.scrollTop=c.offsetTop-u,this.log("slice time",performance.now()-e)}))}),200)},this.onChatsScrollTop=()=>this.onChatsScroll("top"),this.onChatsScroll=(e="bottom")=>(this.scroll.loadedAll[e]&&this.loadContacts&&this.loadContacts(),this.log("onChatsScroll",e),this.loadDialogs(e))}start(){const e=this.managers=(0,Le.Z)();this.contextMenu=new v(e),this.stateMiddlewareHelper=new He.A,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),K.Z&&(0,W.Z)({element:this.folders.container,onSwipe:e=>{const t=s.prevId();s(e>0?t+1:t-1)}}),this.allChatsIntlElement=new r.ZP.IntlElement({key:"FilterAllChatsShort"}),n.Z.addEventListener("premium_toggle",(e=>Ge(this,void 0,void 0,(function*(){e||(yield this.managers.filtersStorage.isFilterIdAvailable(this.filterId))||s((0,Ue.Z)(this.filtersRendered[J.J$].menu),!1)})))),n.Z.addEventListener("state_cleared",(()=>{const e=J.DZ.has(this.filterId);Be.Z.getState().then((t=>Ge(this,void 0,void 0,(function*(){this.loadedDialogsAtLeastOnce=!1,this.showFiltersPromise=void 0,e&&(this.sortedList.clear(),this.onTabChange()),this.onStateLoaded(t)}))))})),this.setFilterId(J.J$,J.J$),this.addFilter({id:J.J$,title:"",localId:J.J$});const i=new w.v7(this.folders.menuScrollContainer);t.prepend(this.folders.menuScrollContainer);const s=this.selectTab=(0,b.X)(this.folders.menu,this.folders.container,((e,t)=>Ge(this,void 0,void 0,(function*(){const i=e;if(e=+t.dataset.filterId||J.J$,-1!==this.filterId&&!J.DZ.has(e)&&!(yield this.managers.filtersStorage.isFilterIdAvailable(e)))return!1;const n=this.filterId;if(C.IS_MOBILE_SAFARI||(i?this.filtersNavigationItem||(this.filtersNavigationItem={type:"filters",onPop:()=>{s(0),this.filtersNavigationItem=void 0}},ce.Z.spliceItems(1,0,this.filtersNavigationItem)):this.filtersNavigationItem&&(ce.Z.removeItem(this.filtersNavigationItem),this.filtersNavigationItem=void 0)),n===e)return;this.sortedLists[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.sortedLists)if(+e!==this.filterId){this.sortedLists[e].clear();const t=this.placeholders[e];t&&t.remove()}}),void 0,i);Be.Z.getState().then((e=>(he.Z.setPlaybackParams(e.playbackParams),he.Z.addEventListener("playbackParams",(e=>{this.managers.appStateManager.pushToState("playbackParams",e)})),this.onStateLoaded(e)))),ie.Z.addEventListener("resize",(()=>{this.changeFiltersAllChatsKey()})),new H(this.managers,this.chatsContainer),this.chatsContainer.append(t),setTimeout((()=>{k.Z.loadLottieWorkers()}),200),pe.Z.MANAGERS=n.Z.managers=e,ke.Z.construct(e),h.ZP.construct(e),fe.ZP.construct(e),Te.ZP.construct(e),xe.Z.construct(e),E.Z.construct(e),this.sortedList=this.sortedLists[this.filterId],this.scroll=this.scrollables[this.filterId]}get chatList(){return this.sortedList.list}setFilterId(e,t){this.filterId=e,this.indexKey=(0,Ce.Z)(J.DZ.has(e)?e:t)}setFilterIdAndChangeTab(e){return Ge(this,void 0,void 0,(function*(){return this.filterId=e,this.indexKey=yield this.managers.dialogsStorage.getDialogIndexKeyByFilterId(e),this.onTabChange()}))}setOnlineStatus(e,t){const i="is-online",s=e.classList.contains(i);!s&&t&&e.classList.add(i),(0,M.Z)(e,"is-visible",t,250,t?void 0:()=>{e.classList.remove(i)},t&&!s?2:0)}initListeners(){n.Z.addEventListener("user_update",(e=>Ge(this,void 0,void 0,(function*(){var t;const i=e.toPeerId(),s=this.getDialogDom(i);if(s&&i!==n.Z.myId&&!(yield this.managers.appUsersManager.isBot(e))){const i="userStatusOnline"===(null===(t=(yield this.managers.appUsersManager.getUser(e)).status)||void 0===t?void 0:t._);this.setOnlineStatus(s.avatarEl,i)}})))),n.Z.addEventListener("chat_update",(e=>Ge(this,void 0,void 0,(function*(){const t=e.toPeerId(!0),i=yield this.managers.appMessagesManager.getDialogOnly(t);i&&this.processDialogForCallStatus(i)})))),n.Z.addEventListener("folder_unread",(e=>{this.setFilterUnreadCount(e.id)})),n.Z.addEventListener("contacts_update",(e=>{var t;null===(t=this.processContact)||void 0===t||t.call(this,e.toPeerId())})),n.Z.addEventListener("dialog_flush",(({dialog:e})=>{e&&(this.setLastMessageN({dialog:e,setUnread:!0}),this.validateDialogForFilter(e),this.setFiltersUnreadCount())})),n.Z.addEventListener("dialogs_multiupdate",(e=>{var t;for(const[i,s]of e)this.updateDialog(s),null===(t=this.processContact)||void 0===t||t.call(this,i.toPeerId()),this.validateDialogForFilter(s)})),n.Z.addEventListener("dialog_drop",(({peerId:e})=>{var t;this.deleteDialog(e),null===(t=this.processContact)||void 0===t||t.call(this,e)})),n.Z.addEventListener("dialog_unread",(({dialog:e})=>{e&&(this.setUnreadMessagesN({dialog:e}),this.validateDialogForFilter(e))})),n.Z.addEventListener("dialog_notify_settings",(e=>{this.validateDialogForFilter(e),this.setUnreadMessagesN({dialog:e})})),n.Z.addEventListener("dialog_draft",(({dialog:e,drop:t,peerId:i})=>{var s;t?this.sortedList.delete(i):this.updateDialog(e),null===(s=this.processContact)||void 0===s||s.call(this,i)})),E.Z.addEventListener("peer_changed",(e=>{for(const t of this.lastActiveElements)t.dataset.peerId.toPeerId()!==e&&this.setDialogActive(t,!1);Array.from(document.querySelectorAll(`[data-autonomous="0"] .chatlist-chat[data-peer-id="${e}"]`)).forEach((e=>{this.setDialogActive(e,!0)}))})),n.Z.addEventListener("filter_update",(e=>Ge(this,void 0,void 0,(function*(){if(J.DZ.has(e.id))return;if(!this.filtersRendered[e.id])return void this.addFilter(e);if(e.id===this.filterId){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)}}const t=this.filtersRendered[e.id];(0,ue.Z)(t.title,(0,ge.Z)(e.title))})))),n.Z.addEventListener("filter_delete",(e=>{const t=this.filtersRendered[e.id];t&&(t.container.remove(),t.menu.remove(),delete this.sortedLists[e.id],delete this.scrollables[e.id],delete this.filtersRendered[e.id],this.onFiltersLengthChange(),this.filterId===e.id&&this.selectTab(0,!1))})),n.Z.addEventListener("filter_order",(e=>Ge(this,void 0,void 0,(function*(){e=e.slice(),(0,Oe.Z)(e,J.Zi);const t=this.folders.menu,i=yield Promise.all(e.map((e=>Ge(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.sortedLists[e].indexKey=n,(0,_.Z)(o.menu,t,a.localId),(0,_.Z)(o.container,this.folders.container,a.localId)})),this.indexKey=yield this.managers.dialogsStorage.getDialogIndexKeyByFilterId(this.filterId)})))),n.Z.addEventListener("peer_typings",(({peerId:e,typings:t})=>Ge(this,void 0,void 0,(function*(){const i=yield this.managers.appMessagesManager.getDialogOnly(e);i&&(t.length?this.setTyping(i):this.unsetTyping(i))}))))}setDialogActive(e,t){const i=e.dialogDom;e.classList.toggle("active",t),t?this.lastActiveElements.add(e):this.lastActiveElements.delete(e),(null==i?void 0:i.callIcon)&&i.callIcon.setActive(t)}onStateLoaded(e){return Ge(this,void 0,void 0,(function*(){this.stateMiddlewareHelper.clean();const t=this.stateMiddlewareHelper.get(),i=e.filtersArr,s=i.length>J.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.onChatsScroll(),r=(0,Ze.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(Ae.Z),this.managers.appMessagesManager.fillConversations()}))}getOffsetIndex(e){return{index:this.scroll.loadedAll[e]?0:this.offsets[e]}}isDialogMustBeInViewport(e){if(void 0!==e.migratedTo||!this.testDialogForFilter(e))return!1;const t=this.getOffsetIndex("top"),i=this.getOffsetIndex("bottom");if(!t.index&&!i.index)return!0;const s=(0,Ee.Z)(e,this.indexKey);return(!t.index||s<=t.index)&&(!i.index||s>=i.index)}deleteDialog(e){this.sortedList.delete(e)}updateDialog(e){if(!this.isDialogMustBeInViewport(e))return void this.deleteDialog(e.peerId);if(!this.sortedList.has(e.peerId)&&this.loadedDialogsAtLeastOnce)return void this.sortedList.add(e.peerId);const t=this.getDialogDom(e.peerId);t&&(this.setLastMessageN({dialog:e,dom:t,setUnread:!0}),this.sortedList.update(e.peerId))}setFilterUnreadCount(e){var t;return Ge(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===J.J$?s:n;i.innerText=a?""+a:""}))}setFiltersUnreadCount(){for(const e in this.filtersRendered)this.setFilterUnreadCount(+e)}validateListForFilter(){return Ge(this,void 0,void 0,(function*(){this.sortedList.getAll().forEach((e=>Ge(this,void 0,void 0,(function*(){const t=yield this.managers.appMessagesManager.getDialogOnly(e.id);this.testDialogForFilter(t)||this.deleteDialog(e.id)}))))}))}validateDialogForFilter(e){this.getDialogDom(e.peerId)&&(this.testDialogForFilter(e)||this.deleteDialog(e.peerId))}testDialogForFilter(e){return!(!e||(J.DZ.has(this.filterId)?this.filterId!==e.folder_id:void 0===(0,Ee.Z)(e,this.indexKey)))}generateScrollable(e,t){const i=t.id,s=new w.ZP(null,"CL",500);s.container.addEventListener("scroll",this.onChatsRegularScroll),s.container.dataset.filterId=""+i,s.onScrolledTop=this.onChatsScrollTop,s.onScrolledBottom=this.onChatsScroll,s.setVirtualContainer(e);const n=new We(this.managers,this.log,e,(0,Ce.Z)(t.localId),this.onListLengthChange);return this.scrollables[i]=s,this.sortedLists[i]=n,s}addFilter(e){if(e.id===J.Zi)return;const t=this.folders.menu,i=this.filtersRendered[e.id];if(i)return(0,_.Z)(i.menu,t,e.localId),void(0,_.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===J.J$?a.append(this.allChatsIntlElement.element):(0,ue.Z)(a,(0,ge.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,y.Z)(s),s.append(n),s.dataset.filterId=""+e.id,(0,_.Z)(s,t,e.localId);const d=this.createChatList(),l=this.generateScrollable(d,e);l.container.classList.add("tabs-tab","chatlist-parts");const c=document.createElement("div");c.classList.add("chatlist-top");const h=document.createElement("div");h.classList.add("chatlist-bottom"),c.append(d),l.container.append(c,h);const u=l.container;(0,_.Z)(l.container,this.folders.container,e.localId),this.setListClickListener(d,null,!0),this.filtersRendered[e.id]={menu:s,container:u,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,Re.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}))}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.scroll.loadedAll[e])return Promise.resolve({cached:!0,renderPromise:Promise.resolve()});t.warn("start",e);const n=(0,ze.Z)("MIDDLEWARE"),a=(0,Me.Z)(),o=new Promise(((i,s)=>Ge(this,void 0,void 0,(function*(){const{chatList:r,filterId:d,indexKey:l}=this;let c=$.Z.height/72*1.25|0,h=0;const u=this.doNotRenderChatList,{index:f}=this.getOffsetIndex(e);if(f)if("top"===e){const e=yield this.managers.dialogsStorage.getFolderDialogs(d,!0),t=e.findIndex((e=>(0,Ee.Z)(e,l)<=f)),i=Math.max(0,t-c);c=t-i,h=(0,Ee.Z)(e[i],l)+1}else h=f;let p=this.placeholders[d];try{const i=this.managers.acknowledged.appMessagesManager.getConversations("",h,c,d,!0);if(!(r.childElementCount||p||this.loadedDialogsAtLeastOnce&&(yield i).cached)){p=this.placeholders[d]=new De;const e=d===J.Zi?this.chatsContainer:this.folders.container;p.attach({container:r.parentElement,getRectFrom:e,onRemove:()=>{delete this.placeholders[d]},blockScrollable:this.scroll}),a.resolve(!1)}const s=yield i,f=yield s.result;if(this.loadDialogsRenderPromise!==o||u)throw n;a.resolve(s.cached),"bottom"===e?f.isEnd&&(this.scroll.loadedAll[e]=!0):f.isTopEnd&&(this.scroll.loadedAll[e]=!0);const m=f.dialogs.length;if(t(`will render ${m} dialogs`),m){const t=("top"===e?f.dialogs.slice().reverse():f.dialogs).map((e=>this.sortedList.add(e.peerId)));if(yield Promise.all(t).catch(),this.loadDialogsRenderPromise!==o)throw n}const g=f.dialogs["top"===e?0:m-1];g&&(this.offsets[e]=(0,Ee.Z)(g,l)),this.loadedDialogsAtLeastOnce=!0,this.onListLengthChange(),t("getDialogs "+c+" dialogs by offset:",h,f,r.childElementCount),setTimeout((()=>{this.scroll.onScroll()}),0),p&&p.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}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,r.$d)(s,e.title);const n=document.createElement("div");return n.classList.add(t+"-subtitle"),e.subtitle&&(0,r.$d)(n,e.subtitle,e.subtitleArgs),i.append(s,n),{container:i,header:s,subtitle:n}}checkIfPlaceholderNeeded(){if(this.filterId===J.Zi)return;const e=this.chatList,t=e.parentElement;let i=Array.from(t.children).find((e=>e.matches(".empty-placeholder")));const s=this.scroll.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,Se.Z)({div:e,emoji:t,width:s,height:s}),i.prepend(e);const o=(0,I.Z)("btn-primary btn-color-primary btn-control tgico",{text:"FilterHeaderEdit",icon:"settings"});(0,A.fc)(o,(()=>Ge(this,void 0,void 0,(function*(){h.ZP.createTab(x.Z).open(yield this.managers.filtersStorage.getFilter(this.filterId))})))),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 r.ZP.IntlElement({element:n.subtitle}),Promise.all([this.updateContactsLength(!1),(0,j.cj)(e,"assets/img/EmptyChats.svg"),(0,G.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,r.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}setOffsets(){return Ge(this,void 0,void 0,(function*(){const e=this.chatList,t=yield this.getDialogFromElement(e.firstElementChild),i=yield this.getDialogFromElement(e.lastElementChild),s=this.indexKey;this.offsets.top=(0,Ee.Z)(t,s),this.offsets.bottom=(0,Ee.Z)(i,s)}))}getDialogFromElement(e){return this.managers.appMessagesManager.getDialogOnly(e.dataset.peerId.toPeerId())}setListClickListener(e,t,i=!1,s=!1,n=!1){let a;const o=(n?E.Z.setInnerPeer:E.Z.setPeer).bind(E.Z);e.dataset.autonomous=""+ +s,e.addEventListener("mousedown",(e=>{if(0!==e.button)return;this.log("dialogs click list");const i=e.target,n=(0,d.Z)(i,Ve);if(!n)return;const r=n.dataset.peerId.toPeerId();if(e.ctrlKey||e.metaKey)return window.open(n.href||"#"+r,"_blank"),void(0,O.Z)(e);if(s){const e=a===n;a&&!e&&a.classList.remove("active"),n&&(n.classList.add("active"),a=n,this.lastActiveElements.add(n))}if(n){t&&t();const e=+n.dataset.mid||void 0;o({peerId:r,lastMsgId:e})}else o()}),{capture:!0}),e.addEventListener("click",(e=>{0===e.button&&(0,O.Z)(e)}),{capture:!0}),P.ZP&&e.addEventListener("dblclick",(e=>{const t=(0,d.Z)(e.target,Ve);if(t){const e=t.dataset.peerId.toPeerId();this.log("debug dialog:",this.managers.appMessagesManager.getDialogByPeerId(e))}})),i&&(0,Ie.E)(e,this.contextMenu.onContextMenu)}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.dialog,e.lastMessage,e.dom,e.highlightWord,e.isBatch,e.setUnread).catch(Ae.Z)}setLastMessage(e,t,i,s,a=!1,o=!1){var d;return Ge(this,void 0,void 0,(function*(){if(!i&&!(i=this.getDialogDom(e.peerId)))return;const{deferred:l,middleware:c}=Ke(i,"setLastMessagePromise");let h;if(!t&&("draftMessage"===(null===(d=e.draft)||void 0===d?void 0:d._)&&(h=e.draft),!(t=e.topMessage)||t.mid!==e.top_message)){const i=this.managers.appMessagesManager.getMessageByPeer(e.peerId,e.top_message);t=yield c(i)}if(o&&this.setUnreadMessagesN({dialog:e,dom:i,isBatch:a,setLastMessagePromise:l}),!t)return i.lastMessageSpan.textContent="",i.lastTimeSpan.textContent="",delete i.listEl.dataset.mid,void l.resolve();const u=e.peerId,f=t&&(0,be.Z)(t);{let e;const a=[];if(t&&!h&&!f){const i=(0,ye.Z)(t),s=new Set(["video","gif","round"]);if(i&&("photo"===i._||s.has(i.type))){const n=(0,me.Z)(i,20,20);if("photoSizeEmpty"!==n._&&(e=document.createElement("div"),e.classList.add("dialog-subtitle-media"),"round"===i.type&&e.classList.add("is-round"),a.push((0,T.Z)({photo:i,message:t,container:e,withoutPreloader:!0,size:n}).then((()=>e))),s.has(i.type))){const t=document.createElement("span");t.classList.add("tgico-play"),e.append(t)}}}if(h){const e=document.createElement("span");e.classList.add("danger"),e.append((0,r.ag)("Draft"),": "),a.unshift(e)}else if(u.isAnyChat()&&u!==t.fromId&&!t.action){const e=document.createElement("span");if(e.classList.add("primary-text"),t.fromId===n.Z.myId)e.append((0,r.ag)("FromYou")),a.unshift(e);else{const i=c((0,Pe.Z)({peerId:t.fromId,onlyFirstName:!0})).then((t=>(e.prepend(t),e)),Ae.Z);a.unshift(i)}e.append(": ")}const o=!!e&&!!(null==t?void 0:t.message);let d;if(d=s&&t.message?yield c((0,ve.Z)(t,void 0,void 0,!1,s,o)):h?yield c((0,ve.Z)(h)):t?yield c((0,ve.Z)(t,void 0,void 0,!1,void 0,o)):document.createDocumentFragment(),a.length){const e=yield c(Promise.all(a));d.prepend(...e)}(0,F.Z)(i.lastMessageSpan,d)}if(t||h){const e=h?Math.max(h.date,t.date||0):t.date;(0,F.Z)(i.lastTimeSpan,(0,S.zM)(new Date(1e3*e)))}else i.lastTimeSpan.textContent="";null===o||o||(i.listEl.dataset.mid=""+t.mid),l.resolve()}))}setUnreadMessagesN(e){return this.setUnreadMessages(e.dialog,e.dom,e.isBatch,e.setLastMessagePromise).catch((()=>{}))}setUnreadMessages(e,t=this.getDialogDom(e.peerId),i=!1,s){var a;return Ge(this,void 0,void 0,(function*(){if(!t)return;const{deferred:o,middleware:r}=Ke(t,"setUnreadMessagePromise"),d=yield r(this.managers.appNotificationsManager.isPeerLocalMuted(e.peerId,!0)),l=t.listEl.classList.contains("is-muted");let c;if("draftMessage"!==(null===(a=e.draft)||void 0===a?void 0:a._)){const t=yield r(this.managers.appMessagesManager.getMessageByPeer(e.peerId,e.top_message));t&&t.pFlags.out&&t.peerId!==n.Z.myId&&(c=t)}const h=yield r(this.managers.filtersStorage.getFilter(this.filterId));let u;u=h?-1!==h.pinnedPeerIds.indexOf(e.peerId):!!e.pFlags.pinned;const f=yield r(this.managers.appMessagesManager.isDialogUnread(e)),p=u||f;if(s)try{yield r(s)}catch(e){}const m=i?0:200;d!==l&&(0,M.Z)(t.listEl,"is-muted",d,m),function(e,t,i){let s;if((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()}(t.statusSpan,c);const g=(0,q.Z)(t.unreadBadge);p&&!g&&t.subtitleEl.append(t.unreadBadge);const v=e.unread_mentions_count&&(e.unread_mentions_count>1||e.unread_count>1),b=t.mentionsBadge&&(0,q.Z)(t.mentionsBadge);if(v&&(t.mentionsBadge||(t.mentionsBadge=document.createElement("div"),t.mentionsBadge.className="dialog-subtitle-badge badge badge-22 mention mention-badge",t.mentionsBadge.innerText="@",t.subtitleEl.insertBefore(t.mentionsBadge,t.lastMessageSpan.nextSibling))),(0,M.Z)(t.unreadBadge,"is-visible",p,m,p?void 0:()=>{t.unreadBadge.remove()},g?0:2),t.mentionsBadge&&(0,M.Z)(t.mentionsBadge,"is-visible",v,m,v?void 0:()=>{t.mentionsBadge.remove(),delete t.mentionsBadge},b?0:2),!p)return void o.resolve();u?t.unreadBadge.classList.add("tgico-chatspinned","tgico"):t.unreadBadge.classList.remove("tgico-chatspinned","tgico");let y=!0,w=!1;e.unread_mentions_count&&1===e.unread_count?(t.unreadBadge.innerText="@",w=!0):f?t.unreadBadge.innerText=""+(e.unread_count||" "):(t.unreadBadge.innerText="",y=!1),t.unreadBadge.classList.toggle("unread",y),t.unreadBadge.classList.toggle("mention",w),o.resolve()}))}getDialogDom(e){const t=this.sortedList.get(e);return null==t?void 0:t.dom}getDialog(e){return Ge(this,void 0,void 0,(function*(){if("object"!=typeof e){const t=yield this.managers.appMessagesManager.getDialogOnly(e);if(!t){const t=e||J.NM;return{peerId:t,peer:yield this.managers.appPeersManager.getOutputPeer(t),pFlags:{}}}return t}return 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=ae;const i=t.getContext("2d"),s=(ae-(3*re+2*oe))/2,n=Date.now();let a=!1;const o=()=>{if(t.isConnected)a||(a=t.isConnected);else if(a)return!1;const o=te((Date.now()-n)%1e3,0,1,1e3);i.clearRect(0,0,ae,ae),i.fillStyle=e&&!ie.Z.isMobile?ee.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*=ne,se(i,s+e*re+e*oe,(ae-n)/2,re,n,de,!0)}return!0};return{canvas:t,startAnimation:()=>{(0,X.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,M.Z)(e.callIcon.canvas,"is-visible",t,200,t?void 0:()=>{e.callIcon.canvas.remove(),e.callIcon=void 0},t?2:0)}addListDialog(e){e.autonomous=!1;const t=this.addDialogNew(e);if(t){const i=this.getDialog(e.peerId).then((i=>{const{peerId:s}=i,a=[];return s.isUser()||a.push(this.processDialogForCallStatus(i,t.dom)),s!==n.Z.myId&&s.isUser()&&a.push(this.managers.appUsersManager.getUser(s).then((e=>{var i;"userStatusOnline"===(null===(i=e.status)||void 0===i?void 0:i._)&&this.setOnlineStatus(t.dom.avatarEl,!0)}))),a.push(this.setLastMessageN({dialog:i,dom:t.dom,isBatch:e.isBatch,setUnread:!0})),Promise.all(a)}));e.loadPromises&&e.loadPromises.push(i)}return t}processDialogForCallStatus(e,t){return Ge(this,void 0,void 0,(function*(){if(!le.Z)return;if(t||(t=this.getDialogDom(e.peerId)),!t)return;const i=yield this.managers.appChatsManager.getChat(e.peerId.toChatId());this.setCallStatus(t,!(!i.pFlags.call_active||!i.pFlags.call_not_empty))}))}addDialogAndSetLastMessage(e){const{peerId:t,message:i,query:s}=e,n=this.addDialogNew(Object.assign(Object.assign(Object.assign({},e),(0,we.Z)(i)),{peerId:t}));return this.setLastMessage({_:"dialog",peerId:t},i,n.dom,s),i.peerId!==t&&(n.dom.listEl.dataset.peerId=""+i.peerId),n}addDialogNew(e){const t=new $e(Object.assign({autonomous:!!e.container,avatarSize:"bigger"},e));if(e.container){const i=e.append?"prepend":"append";e.container[i](t.container)}return t}addDialog(e,t,i=!0,n=!1,a=!0,o=!0,r=54,d=!!t,l,c,h,u){var f;const p=new s.Z;p.classList.add("dialog-avatar","avatar-"+r),p.updateWithOptions({loadPromises:c,lazyLoadQueue:l,isDialog:!!a,peerId:e,peerTitle:h});const m=document.createElement("div");m.classList.add("user-caption");const g=document.createElement("span");g.classList.add("user-title");const v=new Z.Z,b=v.update({peerId:e,fromName:h,dialog:a,onlyFirstName:n,plainText:!1,withIcons:!u});c&&c.push(b),g.append(v.element),g.classList.add("tgico");const w=document.createElement("span");w.classList.add("user-last-message"),w.setAttribute("dir","auto");const S=document.createElement(Ve);S.classList.add("chatlist-chat"),d||(S.href="#"+e),i&&(0,y.Z)(S),S.append(p,m),S.dataset.peerId=""+e;const C=document.createElement("span");C.classList.add("message-status","sending-status");const L=document.createElement("span");L.classList.add("message-time");const I=document.createElement("div");I.className="dialog-subtitle-badge badge badge-22";const M=document.createElement("p");M.classList.add("dialog-title");const P=document.createElement("span");P.classList.add("dialog-title-details"),P.append(C,L),M.append(g,P);const k=document.createElement("p");k.classList.add("dialog-subtitle"),k.append(w),m.append(M,k);const T={avatarEl:p,captionDiv:m,titleSpan:v.element,titleSpanContainer:g,statusSpan:C,lastTimeSpan:L,unreadBadge:I,lastMessageSpan:w,containerEl:S,listEl:S,subtitleEl:k};return t&&t[o?"append":"prepend"](S),d||(S.dialogDom=T,(null===(f=E.Z.chat)||void 0===f?void 0:f.peerId)===e&&this.setDialogActive(S,!0)),{dom:T}}setTyping(e){return Ge(this,void 0,void 0,(function*(){const t=this.getDialogDom(e.peerId);if(!t)return;const i=t.lastMessageSpan.querySelector(".peer-typing-container"),s=yield E.Z.getPeerTyping(e.peerId,i);!i&&s&&((0,F.Z)(t.lastMessageSpan,s),t.lastMessageSpan.classList.add("user-typing"))}))}unsetTyping(e){const t=this.getDialogDom(e.peerId);t&&(t.lastMessageSpan.classList.remove("user-typing"),this.setLastMessageN({dialog:e,lastMessage:null,dom:t,setUnread:null}))}}const Qe=new qe;P.GO.appDialogsManager=Qe;const Ye=Qe},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),f=i(6658),p=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,f.Z)(i):(0,p.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},4846:(e,t,i)=>{"use strict";i.d(t,{Z:()=>Ar});var s=i(5814),n=i(2464),a=i(4332),o=i(4755),r=i(5003),d=i(3512),l=i(3241),c=i(5432),h=i(1655),u=i(6519),f=i(4484),p=i(9331),m=i(1507),g=i(7625);class v{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,n=this.chat.peerId;this.avatar=new p.Z,this.avatar.classList.add("bubbles-group-avatar","user-avatar","avatar-40");const a=(t&&(n===d.Z.myId||n===m.hj)||s?i:e.fromId)||m.NM,o=this.avatar.updateWithOptions({lazyLoadQueue:this.chat.bubbles.lazyLoadQueue,peerId:a,peerTitle:!i&&t&&t.from_name?t.from_name:void 0});return this.avatarLoadPromise=o,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,u.Z)(t,e,this.groups.sortGroupItemsKey),e.group=this,1===t.length&&this.groups.insertGroup(this)}removeItem(e){(0,h.Z)(this.items,e),this.items.length||(0,h.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,g.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,f.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,f.Z)(this.container,e.container,ds+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 b{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]=function(e,t){const i=[],s=[];for(let t=0,a=e.length;t<a;++t){const a=e[t];(n=a,n.items.length?i:s).push(a)}var n;return[i,s]}(e);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,h.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}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,u.Z)(t,e,this.sortItemsKey)}insertGroup(e){return(0,u.Z)(this.groups,e,this.sortGroupsKey)}addItemToCache(e){this.insertItemToArray(e,this.itemsArr),this.itemsMap.set(e.bubble,e)}removeItemFromCache(e){(0,h.Z)(this.itemsArr,e),this.itemsMap.delete(e.bubble)}getMessageFromId(e){let t=e.viaBotId||e.fromId;return t===d.Z.myId&&e.peerId===d.Z.myId&&e.fwdFromId===t&&(t=t.toPeerId(!0)),t}createItem(e,t){const i=!("message"===t._||t.action&&ns.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 v(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 y=i(1168),w=i(2738),S=i(2325),C=i(503);class L extends y.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,w.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,w.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,w.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 C.ZP({plainText:!0}),this.minutesInputField=new C.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,w.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 S.ZP.IntlDateElement({date:n,options:s}).element)}t.push(new S.ZP.IntlDateElement({date:n,options:s}).element),this.btnConfirm.firstChild.replaceWith((0,S.ag)(e,t))}}setTitle(){this.title.textContent="",this.title.append(new S.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&&o.Z.isMobile?"short":"long"};this.monthTitle.textContent="",this.monthTitle.append(new S.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 S.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 a=new Date(e.getTime());a.setDate(a.getDate()-n-1);for(let e=0;e<n;++e)this.options.showOverflowMonths?(a.setDate(a.getDate()+1),this.month.append(this.renderElement(!0,""+a.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 r=this.month.childElementCount%7;if(this.options.showOverflowMonths&&r)for(let t=r;t<7;++t)this.month.append(this.renderElement(!0,""+e.getDate())),e.setDate(e.getDate()+1);const d=Math.ceil(this.month.childElementCount/7);this.container.dataset.lines=""+d,this.monthsContainer.append(this.month)}}var E=i(4524),I=i(6787),M=i(3442),P=i(8805),Z=i(5117),k=i(4762),T=i(1405),x=i(632),A=i(130),_=i(2559),F=i(2946),D=i(8115),R=i(8842),B=i(2064),N=i(5990),O=i(5565),U=i(8456),H=i(7030);class z{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"),this.title.setAttribute("dir","auto"),this.subtitle=document.createElement("div"),this.subtitle.classList.add(e+"-subtitle"),this.subtitle.setAttribute("dir","auto"),this.content.append(this.title,this.subtitle),this.container.append(this.border,this.content)}}var j=i(496),G=i(9492),V=i(3541),K=i(2887),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 $=32;function q(e){var t;return W(this,void 0,void 0,(function*(){let{title:i,titleEl:s,subtitle:n,subtitleEl:a,mediaEl:o,message:r,loadPromises:d,animationGroup:l}=e;void 0!==i&&("string"==typeof i&&(i=(0,U.Z)(i,140),i=(0,D.Z)(i)),(0,O.Z)(s,i)),d||(d=[]);let c=null==r?void 0:r.media,h=!1,u=!1;const f=o?Array.from(o.children).slice():[];let p;if(c&&o){a.textContent="",a.append(yield(0,j.Z)(r,void 0,void 0,void 0,void 0,!0)),c=c.webpage||c;const e=c.photo,i=c.document;if(e||i&&(null===(t=i.thumbs)||void 0===t?void 0:t.length)){p=Ar.chat.bubbles.getMiddleware();const t=Ar.chat.bubbles.lazyLoadQueue;if("sticker"===(null==i?void 0:i.type))yield(0,V.ZP)({doc:i,div:o,lazyLoadQueue:t,group:l,width:$,height:$,middleware:p,loadPromises:d}),h=!0;else if("gif"===(null==i?void 0:i.type)&&i.video_thumbs)h=!0,yield(0,K.Z)({doc:i,container:o,boxWidth:$,boxHeight:$,lazyLoadQueue:t,noPlayButton:!0,noInfo:!0,middleware:p,loadPromises:d,withoutPreloader:!0,videoSize:i.video_thumbs[0],group:l});else{const s=e||i;u="round"===(null==i?void 0:i.type);try{yield(0,G.Z)({photo:s,container:o,boxWidth:$,boxHeight:$,size:(0,H.Z)(s,$,$),middleware:p,lazyLoadQueue:t,noBlur:!0,withoutPreloader:!0,loadPromises:d}),h=!0}catch(e){}}}}else r?(a.textContent="",a.append(yield(0,j.Z)(r))):("string"==typeof n&&(n=(0,U.Z)(n,140),n=(0,D.Z)(n)),(0,O.Z)(a,n||""));return Promise.all(d).then((()=>{p&&!p()||(f.forEach((e=>e.remove())),o&&o.classList.toggle("is-round",u))})),h}))}class Q extends z{constructor(e,t){super(e,((e,i="",s)=>W(this,void 0,void 0,(function*(){this.mediaEl||(this.mediaEl=document.createElement("div"),this.mediaEl.classList.add(this.className+"-media"));const n=yield q({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}}function Y(e,t,i,s,n){const a=new Q("reply",i),o=a.fill(e,t,s);if(n){const e=(0,N.Z)(n,!1),[t,i,s]=(0,B.oo)(e);a.container.style.setProperty("--override-color",`${t}, ${i}, ${s}`),a.container.classList.add("is-overriding-color")}return{container:a.container,fillPromise:o}}const J="stacked-avatars";class X{constructor(e){this.lazyLoadQueue=e.lazyLoadQueue,this.avatarSize=e.avatarSize,this.container=document.createElement("div"),this.container.classList.add(J),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,s)=>{let n=i[s];n||(n=document.createElement("div"),n.classList.add("stacked-avatars-avatar-container"));let a=n.firstElementChild;a||(a=new p.Z,a.classList.add("avatar-"+this.avatarSize,"stacked-avatars-avatar"),a.updateOptions({isDialog:!1,loadPromises:t})),a.updateWithOptions({lazyLoadQueue:this.lazyLoadQueue,peerId:e}),a.parentNode||n.append(a),n.parentNode||this.container.append(n)})),Array.from(i).slice(e.length).forEach((e=>e.remove()))}}d.Z.addEventListener("replies_updated",(e=>{Array.from(document.querySelectorAll(`replies-element[data-post-key="${e.peerId}_${e.mid}"]`)).forEach((t=>{t.message=e,t.render()}))}));class ee extends HTMLElement{constructor(){super(),this.updated=!1,this.managers=d.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.innerHTML="",t=null),this.stackedAvatars||(this.stackedAvatars=new X({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,F.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 S.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,T.Z)(t),this.append(s,e,t)}(0,O.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,_.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("replies-element",ee);const te=()=>{const e=document.createElement("i");return e.classList.add("edited"),(0,S.$d)(e,"EditedMessage"),e},ie=()=>(0,S.ag)("SponsoredMessage");var se;!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,x.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.innerHTML=(0,_.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,A.Z)(t,(0,D.Z)(e)),t.insertAdjacentHTML("beforeend",",&nbsp;"),a.push(t)}}if(s.edit_date&&"scheduled"!==i&&!s.pFlags.edit_hide&&a.unshift(o=te()),"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=ie());c&&a.push(c);let h=d?void 0:(0,x.xE)(n);l&&(h+=(s.edit_date&&!s.pFlags.edit_hide?`\nEdited: ${(0,x.xE)(new Date(1e3*s.edit_date))}`:"")+(s.fwd_from?`\nOriginal: ${(0,x.xE)(new Date(1e3*s.fwd_from.date))}`:""));const u=document.createElement("span");u.classList.add("time","tgico"),u.append(...a);const f=document.createElement("div");f.classList.add("inner","tgico"),h&&(f.title=h);let p=a;return o&&(p[p.indexOf(o)]=te()),r&&(p[p.indexOf(r)]=ie()),p=p.map((e=>e instanceof HTMLElement&&!e.classList.contains("i18n")&&!e.classList.contains("reactions")?e.cloneNode(!0):e)),c&&(p[p.length-1]=(0,x.mr)(n)),f.append(...p),u.append(f),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 ee;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 n=this,a=void 0,r=function*(){const n=!i;n&&(i=t.querySelector(".bubble-content"));const a=n?i.querySelector(".reply"):null;if(!s.reply_to_mid)return null==a||a.remove(),void t.classList.remove("is-reply");const o=s.reply_to.reply_to_peer_id?(0,F.Z)(s.reply_to.reply_to_peer_id):e.peerId,r=yield d.Z.managers.appMessagesManager.getMessageByPeer(o,s.reply_to_mid);let l,c;if(r){const e=r.fwdFromId;c=s.fwdFromId&&s.fwdFromId===e?s.fwdFromId:r.fromId||e,l=new R.Z({peerId:c,dialog:!1,onlyFirstName:!1,plainText:!1}).element}else d.Z.managers.appMessagesManager.fetchMessageReplyTo(s),e.bubbles.needUpdate.push({replyToPeerId:o,replyMid:s.reply_to_mid,mid:s.mid}),l=(0,S.ag)("Loading");const{container:h,fillPromise:u}=Y(l,void 0,e.animationGroup,r,e.isAnyGroup?c:void 0);return yield u,a?(a.classList.contains("floating-part")&&h.classList.add("floating-part"),a.replaceWith(h)):i.append(h),t.classList.add("is-reply"),h},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}}(se||(se={}));var ne=i(2153),ae=i(3699),oe=i(8448),re=i(4789),de=i(8594),le=i(3035),ce=i(3725),he=i(410),ue=i(252),fe=i(8497),pe=i(4668),me=i(2796);function ge(e,t,i){const s=e.getBoundingClientRect(),n="center"===i?Math.ceil(s.left+(s.right-s.left)/2+1):Math.ceil(s.left+1),a="bottom"===t?Math.floor(s.top+s.height-1):Math.ceil(s.top+1);return document.elementFromPoint(n,a)}he.GO.getElementByPoint=ge;var ve=i(3624),be=i(3910),ye=i(5705);function we(e){e.style.display="none",e.offsetLeft,e.style.display=""}var Se=i(2648),Ce=i(5296),Le=i(8938),Ee=i(5701);const Ie=2147483646;var Me,Pe=i(241),Ze=i(6272),ke=i(1784),Te=i(9099),xe=i(2416),Ae=i(8763),_e=i(5975),Fe=i(8939),De=i(993),Re=i(4494),Be=i(8204),Ne=i(2575),Oe=i(9931);class Ue extends y.Z{constructor(e,t){super("popup-join-chat-invite",{closable:!0,overlayClosable:!0,body:!0,buttons:(0,y.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);Ar.setInnerPeer({peerId:t})}),(e=>{"INVITE_REQUEST_SENT"===e.type&&(0,me.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 p.Z;s.classList.add("avatar-100"),s.isDialog=!1,"photo"===e.photo._?(e.photo=yield t.appPhotosManager.savePhoto(e.photo),(0,G.Z)({container:s,message:null,photo:e.photo,boxHeight:100,boxWidth:100,withoutPreloader:!0}),s.style.width=s.style.height=""):(0,Oe.Z)(s,m.NM,!1,e.title);const n=document.createElement("div");n.classList.add("chat-title"),(0,A.Z)(n,(0,D.Z)(e.title));const a=e.pFlags.broadcast,o=(0,S.ag)(a?"Subscribers":"Members",[(0,Ne.Z)(e.participants_count)]);if(o.classList.add("chat-participants-count"),this.body.append(s,n,o),e.pFlags.request_needed){const e=document.createElement("div");(0,S.$d)(e,a?"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}}!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"}(Me||(Me={}));var He=i(5285),ze=i(6654),je=i(9083),Ge=i(6775),Ve=i(9405),Ke=i(319);class We extends HTMLElement{constructor(){super(),this.classList.add("reaction"),this.managers=d.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("reaction-"+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("reaction-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,ze.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,je.Z)({docIds:[e.document_id],size:(0,Ve.C)(22,22)});this.stickerContainer.append(t)}}}renderDoc(e){const t="inline"===this.type?14:22,i=this.wrapStickerPromise=(0,V.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:4;if(t.count>=i||"block"===this.type&&!this.canRenderAvatars){this.counter||(this.counter=document.createElement("inline"===this.type?"i":"span"),this.counter.classList.add("reaction-counter"));const e=(0,_.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>=4||!this.canRenderAvatars?this.stackedAvatars&&(this.stackedAvatars.container.remove(),this.stackedAvatars=void 0):(this.stackedAvatars||(this.stackedAvatars=new X({avatarSize:24}),this.append(this.stackedAvatars.container)),this.stackedAvatars.render(e.map((e=>(0,F.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,Te.Z)(this,"is-chosen",e,this.isConnected?300:0)}fireAroundAnimation(){const e=this.reactionCount.reaction;"reactionEmoji"===e._&&(0,ze.Z)(this.managers.appReactionsManager.getReaction(e.emoticon),(e=>{const t="inline"===this.type?28:40,i=document.createElement("div");i.classList.add("reaction-sticker-activate"),Promise.all([(0,V.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,Ge.Z)({doc:e.around_animation,size:80,target:this.stickerContainer,side:"center",skipRatio:1,play:!1,managers:this.managers,middleware:this.middleware}).stickerPromise.catch(Ke.Z)]).then((([e,t])=>{const s=()=>{e.remove(),i.remove(),this.stickerContainer.classList.remove("has-animation")};if(!t)return void s();const n=()=>{(0,le.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("reaction-element",We);const $e=new Map;class qe extends HTMLElement{constructor(){super(),this.classList.add("reactions"),this.sorted=[],this.middlewareHelpers=new Map,this.managers=d.Z.managers}connectedCallback(){let e=$e.get(this.key);e||$e.set(this.key,e=new Set),e.add(this),this.onConnectCallback&&this.isConnected&&(this.onConnectCallback(),this.onConnectCallback=void 0)}disconnectedCallback(){const e=$e.get(this.key);e.delete(this),e.size||$e.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("reactions-"+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 s=i?t.results:[];s.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,g.Z)(this.sorted,((e,t,i)=>{const n=e.reactionCount.reaction;s.some((e=>(0,He.Z)(e.reaction,n)))||(this.middlewareHelpers.get(e).destroy(),this.middlewareHelpers.delete(e),i.splice(t,1),e.remove())}));const n=s.reduce(((e,t)=>e+t.count),0),a=t&&(!!t.pFlags.can_see_list||this.message.peerId.isUser())&&n<4;if(this.sorted=s.map(((e,i)=>{let s=this.sorted.find((t=>(0,He.Z)(t.reactionCount.reaction,e.reaction)));if(!s){const e=this.middleware.create();s=new We,s.init(this.type,e.get()),this.middlewareHelpers.set(s,e)}(0,f.Z)(s,this,i);const n=t.recent_reactions?t.recent_reactions.filter((t=>(0,He.Z)(t.reaction,e.reaction))):[];return s.reactionCount=Object.assign({},e),s.setCanRenderAvatars(a),s.render(this.isPlaceholder),s.renderCounter(),s.renderAvatars(n),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===Ar.chat.peerId&&e.forEach((e=>{const t=this.sorted.find((t=>(0,He.Z)(t.reactionCount.reaction,e.reaction)));null==t||t.fireAroundAnimation()}))}}customElements.define("reactions-element",qe);var Qe=i(5418);class Ye{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,Be.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){k.IS_SAFARI&&e&&we(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)}}he.GO&&(he.GO.ScrollSaver=Ye);var Je=i(7401),Xe=i(4881);class et{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 tt=i(5948),it=i(2166),st=i(1713),nt=i(2498),at=i(1336),ot=i(4776),rt=i(5886);function dt(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 lt=i(7530),ct=i(2790),ht=i(3781),ut=i(2586),ft=i(3815),pt=i(6976),mt=i(3416),gt=i(8631),vt=i(3173),bt=i(2381),yt=i(5180),wt=i(7445),St=i(3189);function Ct(e,t){return e.reduce(((e,t)=>e+t),t)}var Lt=i(8097);const Et=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 It(e){return e.replace(/\D/g,"")}const Mt={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])/},Pt={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}},Zt=Et(((e="")=>{const t=Object.keys(Mt),i=It(e);let s,n=0;return t.forEach((e=>{const t=Mt[e],a=i.match(t);if(a){const t=a[0];t&&t.length>n&&(s=e,n=t.length)}})),s||"unknown"}));function kt(e=""){return"diners14"===(t=Zt(e))?"diners":t;var t}var Tt=i(2398),xt=i(6740),At=i(1656),_t=i(7298),Ft=i(9807),Dt=i(279),Rt=i(7479),Bt=i(7362);function Nt(e,t,i){const s=new Array(e);return s.fill(t),i?s.map(i):s}const Ot="".charCodeAt(0)-"0".charCodeAt(0),Ut=/[-]/g;function Ht(e){return String.fromCharCode(e.charCodeAt(0)-Ot)}function zt(e){return e.replace(Ut,Ht)}function jt(e,t){return{type:"optional",result:e,consumed:t}}function Gt(e,t,i){return{type:"required",result:e,consumed:t,partial:i}}function Vt(e,t){return i=>{const s=new RegExp("^".concat(e.source.replace(/^\^/,""))),n=i.match(s),a=t?jt:Gt;if(n){const e=n[0];return a(e,n.index+e.length)}return a("",i.length)}}const Kt=Vt(/1[0-2]|0?[1-9]|0/),Wt={digit:function(e){return Vt(/[0-9]/)(zt(e))},capitalCharacter:function(e){const t=Vt(/\w/)(e);return t.result?Gt(t.result.toUpperCase(),t.consumed):t},month:e=>{const t=Kt(zt(e)),i=It(t.result);return["0","1"].includes(t.result)&&1===e.length||"0"===t.result&&e.length>=2?Gt(t.result,e.length,!0):Gt(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=Vt(e,!0)(t);return i.result?i:jt("",0)}},$t=Wt.digit,qt=Wt.capitalCharacter,Qt=Wt.formattingCharacter(" "),Yt=Wt.optionalPattern(/\d\d/),Jt=[$t,$t,$t,$t,Qt,$t,$t,$t,$t,$t,$t,Qt,$t,$t,$t,$t,$t],Xt=[$t,$t,$t,$t,Qt,$t,$t,$t,$t,$t,$t,Qt,$t,$t,$t,$t],ei=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"]),ti=Et((e=>{const t=[];for(let i=0,s=0;i<e;)4===s?(t.push(Qt),s=0):(t.push($t),++i,++s);return t})),ii={cardNumber:function(e){const t=Zt(e);if("amex"===t)return Jt;if("diners14"===t)return Xt;const{minLength:i,maxLength:s}=Pt[t],n=It(e).length,a=Math.min(Math.max(i,n),s);return ti(a)},cardExpiry:()=>[Wt.month,Wt.formattingCharacter("/"),$t,$t,Yt],cardCvc:e=>ii.cardCvcFromBrand(Zt(e)),cardCvcFromBrand:Et((e=>{const t=Pt[e],{cvcMinLength:i,cvcMaxLength:s}=t,n=Nt(i||s,$t);if(i&&i<s){const e=s-i,t=Wt.optionalPattern(/\d/);e&&n.push(...Nt(e,t))}return n})),postalCodeFromCountry:Et((e=>{switch(e){case"US":return Nt(5,$t);case"CA":return k.IS_ANDROID?null:[qt,qt,qt,Qt,qt,qt,qt];default:const t=Nt(10,Wt.optionalPattern(/\d/));return ei.has(e)&&(t[0]=$t),t}}))},si=ii;function ni(e){return Ct(e.map((e=>e.length)),0)}const ai=new RegExp("","g");function oi(e){return e?{type:"invalid",code:e}:null}function ri(e,t={}){const{sanitized:i,minLength:s}=function(e){const t=It(e),i=Zt(e);return{sanitized:t,brand:i,minLength:Pt[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"===Zt(e)?null:oi("invalid"):i?null:oi("incomplete")}(i,s,t.ignoreIncomplete)}function di(e,t={}){const i=e.replace(ai,"").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:oi("incomplete"):oi(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 li=i(5592),ci=i(5431);const hi=new WeakMap;function ui(e,t){const i=document.createElement("iframe");return i.allow="payment",i.setAttribute("sandbox","allow-forms allow-scripts allow-same-origin allow-modals"),i.classList.add("payment-verification"),i.src=e,{iframe:i,onMount:()=>{hi.set(i.contentWindow,t)}}}window.addEventListener("message",(e=>{const t=hi.get(e.source);t&&t(JSON.parse(e.data))}));class fi extends y.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{iframe:e,onMount:t}=ui(this.url,(e=>{"web_app_open_tg_link"===e.eventType&&(this.dispatchEvent("finish"),this.hide(),this.openPathAfter&&Ar.openUrl("https://t.me"+e.eventData.path_full))}));this.body.append(e),this.show(),t()}}var pi=i(6830);class mi extends C.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=ni(o)+(s?r.length:0)),null===h&&l+1>=i.selectionEnd&&(h=ni(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?ni(o):c,selectionEnd:null===h||t.length&&i.selectionEnd===t.length?ni(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:oi("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(C.I1.Error,e),!1}return!i&&this.setState(C.I1.Neutral),!0}}function gi(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 mi){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 vi(e,t){let i,s;return(e||t)&&(e&&(i=new ci.Z({noPhoneCodes:!0,onCountryChange:()=>{null==s||s.update()},required:!0,autocomplete:"country"})),t&&(s=new mi({label:"PaymentShippingZipPlaceholder",plainText:!0,inputMode:"numeric",autocomplete:"postal-code",formatMethod:()=>{const{country:e}=i.getSelected(),t=null==e?void 0:e.iso2;return si.postalCodeFromCountry(t&&t.toUpperCase())}}))),{countryInputField:i,postcodeInputField:s}}const bi=new Set(["stripe","smartglocal"]);class yi extends y.Z{constructor(e,t){if(super("popup-payment popup-payment-card",{closable:!0,overlayClosable:!0,body:!0,scrollable:bi.has(e.native_provider),title:"PaymentCardInfo"}),this.paymentForm=e,this.savedCard=t,bi.has(e.native_provider))this.d();else{const{iframe:t,onMount:i}=ui(e.url,(t=>{if("payment_form_submit"!==t.eventType)return;const i=t.eventData,s={title:i.title,save:!1};this.dispatchEvent("finish",{token:i.credentials,card:s}),this.hide(),e.pFlags.can_save_credentials&&(0,li.Z)({titleLangKey:"PaymentCardSavePaymentInformation",descriptionLangKey:"PaymentCardSavePaymentInformationInfoLine1",button:{langKey:"Save"}}).then((()=>{s.save=!0}),Ke.Z)}));this.body.append(t),this.show(),i()}}d(){const e=this.savedCard,t=new n.dw({name:"PaymentInfo.Card.Title",noDelimiter:!0,noShadow:!0}),i=JSON.parse(this.paymentForm.native_params.data);let s,a,o=0;const r=new mi({label:"PaymentCardNumber",plainText:!0,inputMode:"numeric",autocomplete:"cc-number",formatMethod:si.cardNumber,validateMethod:ri,errorKeys:{invalid:"PaymentCard.Error.Invalid",incomplete:"PaymentCard.Error.Incomplete"},onChange:e=>{(e=>{if(s===e)return;const t=++o;s=e;const i=Zi(e);if(!i)return void(a&&(a.remove(),a=void 0));const n=new Image;n.classList.add("input-field-icon"),(0,xt.cj)(n,i,!1).then((()=>{o===t&&(a?a.replaceWith(n):r.container.append(n),a=n)}))})(kt(e.value)),c.update()}});let d;i.need_cardholder_name&&(d=new C.ZP({label:"Checkout.NewCard.CardholderNamePlaceholder",maxLength:255,required:!0,autocomplete:"cc-name"}));const l=new mi({label:"SecureId.Identity.Placeholder.ExpiryDate",plainText:!0,inputMode:"numeric",autocomplete:"cc-exp",formatMethod:si.cardExpiry,validateMethod:di});l.input.addEventListener("input",(()=>{let e=l.value;if(e.length<5)return;const t=e.split("/");4===t[1].length&&(e=[t[0],t[1].slice(2)].join("/"),l.setValueSilently(e))}),{capture:!0});const c=new mi({labelText:"CVC",plainText:!0,inputMode:"numeric",autocomplete:"cc-csc",name:"cvc",formatMethod:()=>si.cardCvc(r.value)}),h=(new pi.T(c.container,c.input),[r,l,c,d].filter(Boolean));h.forEach((e=>{const t=t=>{if(!e.value&&"Backspace"===t.key){const t=h[h.indexOf(e)-1];t&&(0,Tt.Z)(t.input,!0)}};if(e instanceof mi){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=h.indexOf(e),i=h.length;t<i;++t){const e=h[t];if(e instanceof mi?!e.validateNew(void 0,void 0,!0):!e.value){(0,Tt.Z)(e.input,!0);break}}}}else e.input.addEventListener("keydown",t)}));const u=document.createElement("div");u.classList.add("input-fields-row"),u.append(l.container,c.container);const f=document.createElement("form");let p;f.append(...[r.container,u,null==d?void 0:d.container].filter(Boolean)),t.content.append(f);const{countryInputField:m,postcodeInputField:g}=vi(i.need_country,i.need_zip);(i.need_country||i.need_zip)&&(p=new n.dw({name:"PaymentInfo.Billing.Title",noDelimiter:!0,noShadow:!0}),p.content.append(...[m,g].filter(Boolean).map((e=>e.container))));const v=!!this.paymentForm.pFlags.can_save_credentials,b=new Ft.Z({text:"PaymentCardSavePaymentInformation",checked:!!v}),y=new Rt.ZP({checkboxField:b,subtitleLangKey:v?"PaymentCardSavePaymentInformationInfoLine1":"Checkout.2FA.Text"});v||y.container.classList.add("is-disabled"),(p||t).content.append(y.container),this.scrollable.append(...[t,p].filter(Boolean).map((e=>e.container)));const w=ki({key:"PaymentInfo.Done",onClick:()=>{return e=this,t=void 0,n=function*(){const e={cardNumber:r.value,expiryFull:l.value,expiryMonth:l.value.split("/")[0],expiryYear:l.value.split("/")[1],cvc:c.value,cardholderName:null==d?void 0:d.value,country:null==m?void 0:m.value,zip:null==g?void 0:g.value,save:null==b?void 0:b.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}});gi([r,d,l,c,m,g].filter(Boolean),(e=>{w.disabled=!e})),e&&(r.value=e.cardNumber,l.value=e.expiryFull,c.value=e.cvc,d&&(d.value=e.cardholderName),m&&(m.value=e.country),g&&(g.value=e.zip)),this.body.append(this.btnConfirmOnEnter=w),this.show(),r.validateNew(void 0,void 0,!0)||(0,Tt.Z)(r.input)}}class wi extends y.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 n.dw({noDelimiter:!0,noShadow:!0,caption:"Checkout.PasswordEntry.Text",captionArgs:[e]}),s=new pi.Z({labelText:t.hint});i.content.append(s.container),this.scrollable.append(i.container);const a=()=>{o.disabled=!s.value,s.setState(C.I1.Neutral)};s.input.addEventListener("input",a);const o=ki({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=o),a(),this.show(),(0,Tt.Z)(s.input)}}var Si=i(1171),Ci=i(709);class Li extends y.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,a,o,r,d,l,c,h,u,f;if(e.pFlags.shipping_address_requested){i=new n.dw({name:"PaymentShippingAddress",noDelimiter:!0,noShadow:!0}),s=new C.ZP({label:"PaymentShippingAddress1Placeholder",maxLength:64,required:!0}),a=new C.ZP({label:"PaymentShippingAddress2Placeholder",maxLength:64}),o=new C.ZP({label:"PaymentShippingCityPlaceholder",maxLength:64,required:!0}),r=new C.ZP({label:"PaymentShippingStatePlaceholder",maxLength:64});const e=vi(!0,!0);d=e.countryInputField,l=e.postcodeInputField,i.content.append(...[s,a,o,r,d,l].filter(Boolean).map((e=>e.container)))}if([e.pFlags.name_requested,e.pFlags.email_requested,e.pFlags.phone_requested].includes(!0)){c=new n.dw({name:"PaymentShippingReceiver",noDelimiter:!0,noShadow:!0});const t=()=>{const e=u.value,t=(0,Si.Z)(e);return!(!t||t[0].length!==e.length)},i=()=>!!f.value.match(/\d/);e.pFlags.name_requested&&(h=new C.ZP({label:"PaymentShippingName",maxLength:256,required:!0})),e.pFlags.email_requested&&(u=new C.ZP({label:"PaymentShippingEmailPlaceholder",maxLength:64,required:!0,validate:t})),e.pFlags.phone_requested&&(f=new Ci.Z({required:!0,validate:i})),c.content.append(...[h,u,f].filter(Boolean).map((e=>e.container)))}const p=new Ft.Z({text:"PaymentShippingSave",checked:!0}),m=new Rt.ZP({checkboxField:p,subtitleLangKey:"PaymentShippingSaveInfo"});(c||i).content.append(m.container),this.scrollable.append(...[i,c].filter(Boolean).map((e=>e.container)));const g=ki({key:"PaymentInfo.Done",onClick:()=>{return e=this,t=void 0,n=function*(){const e=d&&d.getSelected().country,t={_:"paymentRequestedInfo",shipping_address:e&&{_:"postAddress",street_line1:s.value,street_line2:a.value,city:o.value,state:r.value,country_iso2:null==e?void 0:e.iso2,post_code:l.value},name:null==h?void 0:h.value,email:null==u?void 0:u.value,phone:null==f?void 0:f.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:a,ADDRESS_COUNTRY_INVALID:d,ADDRESS_CITY_INVALID:o,ADDRESS_STATE_INVALID:r,ADDRESS_POSTCODE_INVALID:l,REQ_INFO_NAME_INVALID:h,REQ_INFO_EMAIL_INVALID:u,REQ_INFO_PHONE_INVALID:f}[e.type];throw t&&(t.setError(),e.handled=!0),e}},new((i=void 0)||(i=Promise))((function(s,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?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,r)}d((n=n.apply(e,t||[])).next())}));var e,t,i,n}});if(this.body.append(this.btnConfirmOnEnter=g),t){const e=t.shipping_address;e&&(s.value=e.street_line1,a.value=e.street_line2,o.value=e.city,r.value=e.state,d.selectCountryByIso2(e.country_iso2),l.value=e.post_code),t.name&&h&&(h.value=t.name),t.email&&u&&(u.value=t.email),t.phone&&f&&(f.value=t.phone)}const{validate:v}=gi([s,a,o,r,d,l,h,u,f].filter(Boolean),(e=>{g.disabled=!e}));let b;v(),this.show(),b=this.focus?{name:h,email:u,phone:f}[this.focus]:s,b&&(0,Tt.Z)(b.input)}}var Ei=i(1218);class Ii extends y.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 n.dw({name:"PaymentCheckoutShippingMethod",noDelimiter:!0,noShadow:!0}),t=this.requestedInfo.shipping_options.map((e=>new Rt.ZP({radioField:new Ei.Z({text:e.title,name:"shipping-method",value:e.id}),subtitle:(0,yt.Z)(Ct(e.prices.map((({amount:e})=>+e)),0),this.paymentForm.invoice.currency)})));let i;const s=(0,Rt.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 a=ki({key:"PaymentInfo.Done",onClick:()=>{this.dispatchEvent("finish",this.requestedInfo.shipping_options.find((e=>e.id===i))),this.hide()}});this.body.append(this.btnConfirmOnEnter=a),this.show()}}var Mi=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 Pi=["amex","card","diners","discover","jcb","mastercard","visa","unionpay","mir","logo"];function Zi(e){if(Pi.includes(e))return`assets/img/${e}.svg`}function ki(e){var t,i;const s=null!==(t=e.textEl)&&void 0!==t?t:new S.ZP.IntlElement({key:null!==(i=e.key)&&void 0!==i?i:"PaymentInfo.Done"}),n=s.key,a=(0,Re.Z)("btn-primary btn-color-primary payment-item-pay");return a.append(s.element),(0,w.fc)(a,(()=>Mi(this,void 0,void 0,(function*(){const t=e.onClick();if(!(t instanceof Promise))return;const i=(0,Dt.y)(a),o=(0,At.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 Ti extends y.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 Mi(this,void 0,void 0,(function*(){this.element.classList.add("is-loading"),this.show();let s=!1;const n=()=>{s||(s=!0,Te&&Te.hide(),this.hide())};let{paymentForm:a,message:o}=this;o&&this.listenerSetter.add(d.Z)("payment_sent",(({peerId:e,mid:t})=>{o.peerId===e&&o.mid===t&&n()}));const r=null==o?void 0:o.media,l=null!==(e=this.isReceipt)&&void 0!==e?e:r?!!r.receipt_msg_id||"messageExtendedMedia"===(null===(t=r.extended_media)||void 0===t?void 0:t._):"payments.paymentReceipt"===a._,c=r?r.pFlags.test:a.invoice.pFlags.test,h=r?r.photo:a.photo,u=r?r.title:a.title,f=r?r.description:a.description;(0,S.$d)(this.title,l?"PaymentReceipt":"PaymentCheckout"),c&&this.title.append(" (Test)");const m="payment-item",g=document.createElement("div");g.classList.add(m);const v=m+"-details",b=document.createElement("div");let y;b.classList.add(v),h&&(y=document.createElement("div"),y.classList.add(v+"-photo","media-container-contain"),(0,G.Z)({photo:h,container:y,boxWidth:100,boxHeight:100,size:{_:"photoSizeEmpty",type:""}}),b.append(y));const C=v+"-lines",L=document.createElement("div");L.classList.add(C);const E=document.createElement("div");E.classList.add(C+"-title");const I=document.createElement("div");I.classList.add(C+"-description");const M=document.createElement("div");M.classList.add(C+"-bot-name"),L.append(E,I,M),(0,A.Z)(E,(0,D.Z)(u)),(0,A.Z)(I,(0,D.Z)(f));const P=new R.Z;M.append(P.element),b.append(L),g.append(b),this.scrollable.append(g);const Z=document.createElement("div");Z.classList.add(m+"-preloader-container"),(0,Dt.y)(Z,!0),this.scrollable.container.append(Z);const k=this.inputInvoice;a||(a=l?yield this.managers.appPaymentsManager.getPaymentReceipt(o.peerId,r.receipt_msg_id||k.msg_id):yield this.managers.appPaymentsManager.getPaymentForm(k),this.paymentForm=a);let T=a.saved_info||a.info;const x=null===(i=a.saved_credentials)||void 0===i?void 0:i[0];let[_,F,B]=yield Promise.all([!l&&T&&this.managers.appPaymentsManager.validateRequestedInfo(k,T),x&&this.managers.passwordManager.getState(),(0,Bt.Z)({peerId:a.provider_id.toPeerId()})]);yield P.update({peerId:a.bot_id.toPeerId()}),Z.remove(),this.element.classList.remove("is-loading");const N=(e,t)=>(0,yt.Z)(e,H,t),{invoice:U}=a,H=U.currency,z=U.pFlags.recurring&&!l;yield P.update({peerId:a.bot_id.toPeerId()});const j=z?yield(0,Bt.Z)({peerId:a.bot_id.toPeerId()}):void 0;Z.remove(),this.element.classList.remove("is-loading");const V=()=>{const e=document.createElement("div");e.classList.add(K+"-price");const t=document.createElement("span"),i=document.createElement("span");return e.append(t,i),{label:e,left:t,right:i}},K=m+"-prices",W=document.createElement("div");W.classList.add(K);const $=e=>e.map((e=>{const{amount:t,label:i}=e,s=V();s.left.textContent=i;const n=N(t);return s.right.textContent=n,s.label})),q=$(U.prices);let Q=()=>0,Y=0;const J=()=>{const e=N(te+Q()+Y);ee.right.textContent=e,X.compareAndUpdate({key:"PaymentCheckoutPay",args:[e]})},X=new S.ZP.IntlElement,ee=V();ee.label.classList.add("is-total"),(0,S.$d)(ee.left,"PaymentTransactionTotal");const te=Ct(U.prices.map((({amount:e})=>+e)),0),ie=void 0!==U.max_tip_amount&&!l||!!a.tip_amount;if(ie){const e=m+"-tips",t=wt.Z[H];Q=()=>+i().replace(/\D/g,"");const i=()=>r.value,s=()=>{const e=(0,Lt.Z)(i(),`500 ${St.Bf} ${St.bt}`);r.style.width=e+"px"},n=e=>{e=Math.min(+e,+U.max_tip_amount);const t=N(e,!0);r.value=t,document.activeElement===r&&(0,Tt.Z)(r),g&&g();const i=this.tipButtonsMap.get(e);i&&i.classList.add("active"),s(),J()},o=V();(0,S.$d)(o.left,l?"PaymentTip":"PaymentTipOptional");const r=document.createElement("input");r.type="tel",r.classList.add("input-clear",e+"-input"),o.right.append(r),l?o.label.classList.add("disable-hover"):o.label.style.cursor="text",o.label.addEventListener("mousedown",(e=>{(0,_e.Z)(e.target,r)||(0,Tt.Z)(r)}));const d=r instanceof HTMLInputElement?1:2,c=()=>{f?--f:(f=d,(0,Tt.Z)(r))},h=()=>{setTimeout((()=>{f=d,(0,Tt.Z)(r),document.addEventListener("selectionchange",c)}),0)},u=()=>{r.addEventListener("focus",h,{once:!0}),document.removeEventListener("selectionchange",c)};let f;r.addEventListener("focusout",u),u(),r.addEventListener("input",(()=>{n(Q())}));const p=[t.symbol,t.space_between?" ":""];let g;if(t.symbol_left||p.reverse(),o.right[t.symbol_left?"prepend":"append"](p.join("")),q.push(o.label),l)n(a.tip_amount);else{const t=document.createElement("div");t.classList.add(e);const i=e+"-tip",s=U.suggested_tip_amounts.map((e=>{const t=(0,Re.Z)(i,{noRipple:!0});return t.textContent=N(e),this.tipButtonsMap.set(+e,t),t}));g=()=>{const e=t.querySelector(".active");e&&e.classList.remove("active")},(0,w.fc)(t,(e=>{const t=(0,fe.Z)(e.target,i);if(!t)return;let s=0;if(t.classList.contains("active"))t.classList.remove("active");else{g(),t.classList.add("active");for(const[e,i]of this.tipButtonsMap)if(i===t){s=e;break}}n(s)})),n(0),t.append(...s),q.push(t)}}else J();q.push(ee.label),W.append(...q),g.append(W);const se=(e,t)=>Mi(this,void 0,void 0,(function*(){const i=document.createElement("img");i.classList.add("media-photo"),yield(0,xt.cj)(i,Zi(t));let s=e.media;s?(0,O.Z)(s,i):(s=e.createMedia("small"),s.classList.add("media-container-cover"),s.append(i))})),ne=e=>{e.titleLangKey&&(e.subtitleLangKey=e.titleLangKey),e.noWrap=!0;const t=new Rt.ZP(e);return t.container.classList.add(m+"-row"),e.titleLangKey&&t.subtitle.classList.add("hide"),t},ae=(e,t)=>{if(e.title.textContent=t,!t){const t=S.ZP.weakMap.get(e.subtitle.firstElementChild);e.title.append((0,S.ag)(t.key))}e.subtitle.classList.toggle("hide",!t)},oe=e=>{let t,i,s;"title"in e?(t=e.title.split(" ").shift(),i=e.title,s=e.icon):(t=kt(e.cardNumber),i=t+" *"+e.cardNumber.split(" ").pop()),ce.title.classList.remove("tgico","tgico-card_outline"),se(ce,s||t.toLowerCase()),ae(ce,i)},re=()=>{new yi(a,de).addEventListener("finish",(({token:e,card:t})=>{le=e,de=t,oe(t)}))};let de,le;const ce=ne({titleLangKey:"PaymentCheckoutMethod",clickable:l?void 0:re,icon:"card_outline"});ce.container.classList.add(m+"-method-row"),x?oe(x):a.credentials_title&&oe({title:a.credentials_title});const he=ne({title:B,subtitleLangKey:"PaymentCheckoutProvider"}),ue=new p.Z;let pe,ge,ve,be,ye,we,Se,Ce;ue.classList.add("avatar-32"),he.createMedia("small").append(ue),ue.updateWithOptions({peerId:a.provider_id.toPeerId()});const Le=U.pFlags.shipping_address_requested?e=>{if(!e)return ye.subtitle.classList.add("hide"),void(0,O.Z)(ye.title,(0,S.ag)("PaymentShippingAddress"));const t=e.shipping_address;ae(pe,[t.city,t.street_line1,t.street_line2].filter(Boolean).join(", ")),ye.container.classList.toggle("hide",!_&&!l)}:void 0,Ee=e=>{Le&&Le(e),ge&&ae(ge,e.name),ve&&ae(ve,e.email),be&&ae(be,e.phone&&"+"+(0,Ze.u)(e.phone).formatted)};if(l||(Se=e=>{new Li(a,k,e).addEventListener("finish",(({shippingAddress:e,requestedInfo:t})=>{_=t,T=a.saved_info=e,Ee(e)}))}),U.pFlags.shipping_address_requested){const e=e=>{const i=new Ye(this.scrollable,void 0,!0);if(i.save(),t&&t.forEach((e=>e.remove())),!e)return Y=0,J(),i.restore(),void this.onContentUpdate();we=e,ae(ye,e.title),Y=Ct(e.prices.map((({amount:e})=>+e)),0),t=$(e.prices);let s=ee.label;ie&&(s=s.previousElementSibling,l||(s=s.previousElementSibling)),t.forEach((e=>s.parentElement.insertBefore(e,s))),J(),i.restore(),this.onContentUpdate()};let t;pe=ne({icon:"location",titleLangKey:"PaymentShippingAddress",clickable:!l&&Se.bind(null,void 0)}),ye=ne({icon:"shipping",titleLangKey:"PaymentCheckoutShippingMethod",clickable:!l&&(Ce=()=>{new Ii(a,_,we).addEventListener("finish",(t=>{e(t)}))})}),ye.container.classList.add("hide");const i=a.shipping;i&&e(i)}U.pFlags.name_requested&&(ge=ne({icon:"newprivate",titleLangKey:"PaymentCheckoutName",clickable:!l&&Se.bind(null,"name")})),U.pFlags.email_requested&&(ve=ne({icon:"mention",titleLangKey:"PaymentShippingEmailPlaceholder",clickable:!l&&Se.bind(null,"email")})),U.pFlags.phone_requested&&(be=ne({icon:"phone",titleLangKey:"PaymentCheckoutPhoneNumber",clickable:!l&&Se.bind(null,"phone")})),T&&Ee(T);const Ie=[ce,he,pe,ye,ge,ve,be].filter(Boolean),Me=z&&new Ft.Z({text:"Payments.Recurrent.Accept",textArgs:[(0,ot.ZP)(U.recurring_terms_url),j]}),Pe=z&&ne({checkboxField:Me}),ke=z?[document.createElement("hr"),Pe.container]:[];let Te,xe;this.scrollable.append(...[document.createElement("hr"),...Ie.map((e=>e.container)),...ke].filter(Boolean));const Ae=()=>{Fe.disabled=!(!Me||Me.checked)};let Fe;Fe=ki(l?{onClick:()=>this.hide(),key:"Done"}:{onClick:()=>{const e=U.pFlags.name_requested&&!(null==T?void 0:T.name)?"name":U.pFlags.email_requested&&!(null==T?void 0:T.email)?"email":U.pFlags.phone_requested&&!(null==T?void 0:T.phone)?"phone":void 0;if(U.pFlags.shipping_address_requested){if(!_)return void Se();if(!we)return void Ce()}else if(e)return void Se(e);return de||xe?Promise.resolve().then((()=>Mi(this,void 0,void 0,(function*(){const e=xe?{_:"inputPaymentCredentialsSaved",id:x.id,tmp_password:xe.tmp_password}:{_:"inputPaymentCredentials",data:{_:"dataJSON",data:JSON.stringify(le.token?le:{type:le.type,id:le.id})},pFlags:{save:de.save||void 0}};try{const t=yield this.managers.appPaymentsManager.sendPaymentForm(k,a.form_id,null==_?void 0:_.id,null==we?void 0:we.id,e,Q());"payments.paymentResult"===t._?n():(Te=new fi(t.url,!r.extended_media),Te.addEventListener("finish",(()=>{Te=void 0,n()})),yield new Promise(((e,t)=>{Te.addEventListener("close",(()=>{if(Te=void 0,s)e();else{const e=new Error("payment not finished");e.handled=!0,t(e)}}))})))}catch(e){throw"BOT_PRECHECKOUT_TIMEOUT"===e.type?((0,me.bC)({langPackKey:"Error.AnError"}),e.handled=!0):"TMP_PASSWORD_INVALID"===e.type&&(F=xe=void 0,(0,w.tH)(Fe),e.handled=!0),e}})))):x?void Promise.resolve(null!=F?F:this.managers.passwordManager.getState()).then((e=>{new wi(x.title,e).addEventListener("finish",(e=>{F=void 0,xe=e,(0,w.tH)(Fe);const t=e.valid_until-(0,_t.Z)(!0)-5;setTimeout((()=>{xe===e&&(xe=void 0)}),1e3*t)}))})):void re()},textEl:X}),Ae(),Me&&Me.input.addEventListener("change",Ae),this.body.append(this.btnConfirmOnEnter=Fe),this.onContentUpdate()}))}}var xi=i(8487),Ai=i(13),_i=i(9259),Fi=i(3228);class Di{constructor(e,t,i,s,n=t){this.sizes=e,this.maxWidth=t,this.minWidth=i,this.spacing=s,this.maxHeight=n,this.count=e.length,this.ratios=Di.countRatios(e),this.proportions=Di.countProportions(this.ratios),this.averageRatio=Ct(this.ratios,1)/this.count,this.maxSizeRatio=t/this.maxHeight}layout(){return this.count?this.count>=5||this.ratios.find((e=>e>2))?new Ri(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 Ri{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=Ri.cropRatios(e,t),this.count=e.length}static cropRatios(e,t){return e.map((e=>t>1.1?(0,Fi.Z)(e,1,2.75):(0,Fi.Z)(e,.6667,1)))}layout(){const e=new Array(this.count),t=[],i=(e,t)=>{const i=Ct(this.ratios.slice(e,e+t),0);return(this.maxWidth-(t-1)*this.spacing)/i},s=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||s([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||s([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 n=this.count-e-t-i;e>3||t>3||i>3||n>3||s([e,t,i,n])}let n=null,a=0;for(const e of t){const{heights:t,lineCounts:i}=e,s=i.length,o=Ct(t,0)+this.spacing*(s-1),r=Math.min(...t),d=(Math.max(...t),r<this.minWidth?1.5:1),l=(()=>{for(let e=1;e!==s;++e)if(i[e-1]>i[e])return 1.5;return 1})(),c=Math.abs(o-this.maxHeight)*d*l;(!n||c<a)&&(n=e,a=c)}const o=n.lineCounts,r=n.heights,d=o.length;let l=0,c=0;for(let t=0;t!==d;++t){const i=o[t],s=r[t],n=Math.round(s);let a=0;for(let o=0;o!==i;++o){const r=0|(0===t?1:0)|(t===d-1?4:0)|(0===o?8:0)|(o===i-1?2:0),h=this.ratios[l],u=o===i-1?this.maxWidth-a:Math.round(h*s);e[l]={geometry:{x:a,y:c,width:u,height:n},sides:r},a+=u+this.spacing,++l}c+=n+this.spacing}return e}}function Bi(e){const t=new Di(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)),a=n.geometry.height+n.geometry.y,o=e.container;o.style.width=s+"px",o.style.height=a+"px";const r=o.children;t.forEach((({geometry:t,sides:i},n)=>{let d;if(d=r[n],d||(d=document.createElement("div"),o.append(d)),d.classList.add("album-item","grouped-item"),d.style.width=t.width/s*100+"%",d.style.height=t.height/a*100+"%",d.style.top=t.y/a*100+"%",d.style.left=t.x/s*100+"%",8&i&&1&i&&(d.style.borderTopLeftRadius="inherit"),8&i&&4&i&&(d.style.borderBottomLeftRadius="inherit"),2&i&&1&i&&(d.style.borderTopRightRadius="inherit"),2&i&&4&i&&(d.style.borderBottomRightRadius="inherit"),e.forMedia){const e=document.createElement("div");e.classList.add("album-item-media"),d.append(e)}}))}function Ni({messages:e,attachmentDiv:t,middleware:i,uploading:s,lazyLoadQueue:n,isOut:a,chat:r,loadPromises:l,autoDownload:c,managers:h=d.Z.managers}){const u=[];for(const t of e){const e=(0,lt.Z)(t),i="photo"===e._?(0,H.Z)(e,480,480):{w:e.w,h:e.h};u.push({size:i,media:e,message:t})}Bi({container:t,items:u.map((e=>({w:e.size.w,h:e.size.h}))),maxWidth:o.Z.active.album.width,minWidth:100,spacing:2,forMedia:!0}),u.forEach(((e,s)=>{const{size:o,media:r,message:d}=e,u=t.children[s];u.dataset.mid=""+d.mid,u.dataset.peerId=""+d.peerId;const f=u.firstElementChild;let p;p="photo"===r._?(0,G.Z)({photo:r,message:d,container:f,boxWidth:0,boxHeight:0,isOut:a,lazyLoadQueue:n,middleware:i,size:o,loadPromises:l,autoDownloadSize:c.photo,managers:h}):(0,K.Z)({doc:d.media.document,container:f,message:d,boxWidth:0,boxHeight:0,withTail:!1,isOut:a,lazyLoadQueue:n,middleware:i,loadPromises:l,autoDownload:c,managers:h}),p&&l&&l.push(p)}))}var Oi=i(296),Ui=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())}))},Hi=i(3552),zi=i(9893);class ji extends Hi._{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,A.Z)(i,(0,D.Z)(t.poll.question));const s=t.results.results.map((e=>e.voters/t.results.total_voters*100));Ki(s);const n=document.createDocumentFragment();t.results.results.forEach(((i,o)=>{if(!i.voters)return;const r=document.createElement("hr"),d=t.poll.answers[o],l=document.createElement("div");l.classList.add("poll-results-answer");const c=document.createElement("div");(0,A.Z)(c,(0,D.Z)(d.text));const h=document.createElement("div");h.innerText=Math.round(s[o])+"%",l.append(c,h);const u=zi.default.createChatList();u.classList.add("poll-results-voters"),zi.default.setListClickListener(u,(()=>{a.ZP.onCloseBtnClick()}),void 0,!0),u.style.minHeight=48*Math.min(i.voters,4)+"px",n.append(r,l,u);let f,p=4,m=!1,g=Math.max(0,i.voters-4);const v=()=>{m||(m=!0,this.managers.appPollsManager.getVotes(e,d.option,f,p).then((e=>{e.votes.forEach((e=>{const{dom:t}=zi.default.addDialogNew({peerId:e.user_id.toPeerId(!1),container:u,rippleEnabled:!1,meAsSaved:!1,avatarSize:"small"});t.lastMessageSpan.parentElement.remove()})),f&&(g=Math.max(0,g-e.votes.length),g&&b.lastElementChild.replaceWith((0,S.ag)("PollResults.LoadMore",[Math.min(20,g)]))),f=e.next_offset,p=20,g&&e.votes.length||b.remove()})).finally((()=>{m=!1})))},b=(0,Re.Z)("poll-results-more btn btn-primary btn-transparent",{icon:"down"});b.addEventListener("click",v),b.append((0,S.ag)("PollResults.LoadMore",[Math.min(20,g)])),n.append(b),v()})),this.resultsDiv.append(i,n),a.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 Gi=i(5157);let Vi=0;const Ki=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}}};d.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)}))})),o.Z.addEventListener("resize",(()=>{Ji.setMaxLength(),Ji.resizePolls()})),o.Z.addEventListener("changeScreen",(()=>{Ji.setMaxLength()}));const Wi=(e,t,i)=>{e.classList.remove("active"),clearTimeout(i),setTimeout((()=>{t(),e.remove(),$i===e&&qi===t&&Qi===i&&($i=qi=null,Qi=0)}),200)};let $i,qi,Qi,Yi=!1;class Ji 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}static setMaxLength(){const e=Pe.Z.width<=360?Pe.Z.width-120:o.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*(){Vi||(Vi=document.getElementById("poll-line").getTotalLength(),Ji.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>':"",n=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 ${n}`,(0,A.Z)(this.firstElementChild,(0,D.Z)(e.question)),Array.from(this.querySelectorAll(".poll-answer-text")).forEach(((t,i)=>{(0,A.Z)(t,(0,D.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,S.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,n=7,a=2*Math.PI*n,o=document.createElementNS("http://www.w3.org/2000/svg","circle");o.classList.add("poll-quiz-timer-circle"),o.setAttributeNS(null,"cx","16"),o.setAttributeNS(null,"cy","16"),o.setAttributeNS(null,"r",""+n),o.setAttributeNS(null,"stroke-width",""+s),i.append(o),this.descDiv.append(i);const r=1e3*e.close_period,l=1e3*(e.close_date-(yield d.Z.managers.timeManager.getServerTimeOffset()));this.quizInterval=window.setInterval((()=>{const e=Date.now(),i=(l-e)/r,s=(l-e)/1e3+1|0;t.innerHTML=(0,Gi.Z)(s),s<=5&&(t.style.color="#ee545c",o.style.stroke="#ee545c"),o.style.strokeDashoffset=a+i*a,o.style.strokeDasharray=`${a} ${a}`,e>=l&&(clearInterval(this.quizInterval),t.innerHTML="",o.style.strokeDashoffset=a,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,S.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,be.Z)(e),a.ZP.isTabExists(ji)||a.ZP.createTab(ji).open(this.message)})),(0,T.Z)(this.viewResults),this.isMultiple&&(this.sendVoteBtn=document.createElement("div"),this.sendVoteBtn.classList.add("poll-footer-button","poll-send-vote"),this.sendVoteBtn.append((0,S.ag)("Chat.Poll.SubmitVote")),(0,T.Z)(this.sendVoteBtn),e.chosenIndexes.length||this.votersCountDiv.classList.add("hide"),(0,w.fc)(this.sendVoteBtn,(e=>{(0,be.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),(0,w.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,w.fc)(t,(i=>{(0,be.Z)(i),t.classList.add("active"),((e,t,i)=>{$i&&Wi($i,qi,Qi);const s=document.createElement("div");s.classList.add("quiz-hint");const n=document.createElement("div");n.classList.add("container","tgico");const a=document.createElement("div");a.classList.add("text"),n.append(a),s.append(n),(0,A.Z)(a,(0,ot.ZP)(e,{entities:t})),Ar.chat.bubbles.container.append(s),s.offsetLeft,s.classList.add("active"),$i=s,qi=i,Qi=window.setTimeout((()=>{Wi(s,i,Qi)}),c.Z?5e3:7e3),Yi||(Yi=!0,Ar.addEventListener("peer_changed",(()=>{$i&&Wi($i,qi,Qi)})))})(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,w.tH)(t)}}}clickHandler(e){const t=(0,fe.Z)(e.target,"poll-answer");if(!t)return;(0,be.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])}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;if(d.Z.settings.animationsEnabled||(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,O.Z)(this.typeDiv,(0,S.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?(0,w.fc)(this,this.clickHandler):(0,w.EN)(this,this.clickHandler)),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,Te.Z)(this,"",!this.isRetracted,340),(0,le.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 X({avatarSize:16});i.render(t),(0,O.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,le.T2)(e):e()}let n;e=e.slice(),Ki(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,O.Z)(this.votersCountDiv,(0,S.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]*Ji.MAX_LENGTH+", 485.9",i.style.strokeDashoffset=""+t*Ji.MAX_OFFSET)}}Ji.MAX_OFFSET=-46.5,Ji.MAX_LENGTH=0,customElements.define("poll-element",Ji);new RegExp("^[^A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿Ⰰ-﬜﷾-﹯﻽-￿]*[֑-߿יִ-﷽ﹰ-ﻼ]");const Xi=new RegExp("[֑-߿יִ-﷽ﹰ-ﻼ]");class es{constructor(e,t){this.width=e,this.height=t;const i=this.canvas=document.createElement("canvas"),s=this.dpr=window.devicePixelRatio;i.width=e*s,i.height=t*s,i.classList.add("canvas-thumbnail","canvas-dots"),this.paused=!0,this.autoplay=!0,this.tempId=0,this.context=i.getContext("2d")}prepare(){let e=Math.round(this.width*this.height/(35*(k.IS_MOBILE?2:1)));e=Math.min(k.IS_MOBILE?1e3:2200,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,Fi.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,Ce.jt)((()=>this.tempId===e&&!this.paused&&(this.draw(),!0)))}}var ts=i(5345),is=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 ss=new Set(["messageActionHistoryClear","messageActionChatCreate"]),ns=new Set;De.Z&&ns.add("messageActionPhoneCall");const as=void 0;let os=as,rs=0;const ds=3,ls=new Error("peer changed"),cs={1:96,2:90,3:84,4:72,5:60,6:48,7:36},hs=Object.keys(cs).length;function us(e){return Math.max(...e)}class fs{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,ve.k)(),this.replyFollowHistory=[],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;e&&e.random_id&&(delete e.random_id,this.managers.appChatsManager.viewSponsoredMessage(this.peerId.toChatId(),e.random_id))}}},this.stickerEffectObserverCallback=e=>{if(e.isIntersecting){this.observer.unobserve(e.target,this.stickerEffectObserverCallback);const t=e.target.querySelector(".attachment");(0,de.e9)().then((()=>{(0,xi.Z)(t)&&(0,w.tH)(t)}))}},this.onBubblesMouseMove=e=>is(this,void 0,void 0,(function*(){const t=(0,fe.Z)(e.target,"bubble-content");if(!t||this.chat.selection.isSelecting||(0,fe.Z)(e.target,"service")||(0,fe.Z)(e.target,"bubble-beside-button"))this.unhoverPrevious();else{const e=(0,fe.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,Qe.Z)(400)]).then((([e])=>{const t=e[0];t?(0,V.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,Le.Z)(e),e.addEventListener("firstFrame",(()=>{a()&&(s.dataset.loaded="1",this.setHoverVisible(s,!0))}),{once:!0}),(0,w.fc)(s,(e=>{(0,be.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=>is(this,void 0,void 0,(function*(){var t;let i=e.target,s=null;try{s=(0,fe.Z)(i,"bubble")}catch(e){}if(!s&&!this.chat.selection.isSelecting){const e=(0,fe.Z)(i,"user-avatar");if(!e)return;const t=e.dataset.peerId.toPeerId();return void(t!==m.NM?this.chat.appImManager.setInnerPeer({peerId:t}):(0,me.Am)(S.ZP.format("HidAccount",!0)))}if(s.classList.contains("is-date")&&(0,fe.Z)(i,"bubble-content")){if(s.classList.contains("is-fake")&&(s=s.previousElementSibling),s.classList.contains("is-sticky")&&!this.chatInner.classList.contains("is-scrolling"))return;for(const e in this.dateMessages)if(this.dateMessages[e].div===s){y.Z.createPopup(L,new Date(+e),this.onDatePick).show();break}return}if(!c.Z&&(0,fe.Z)(i,"time"))return void this.chat.selection.toggleByElement(s);if(this.chat.selection.isSelecting&&e.isTrusted){if(s.classList.contains("service")&&void 0===s.dataset.mid)return;return(0,be.Z)(e),c.Z&&this.chat.selection.selectedText?void(this.chat.selection.selectedText=void 0):void this.chat.selection.toggleByElement((0,fe.Z)(i,"grouped-item")||s)}const n=(0,fe.Z)(i,"contact");if(n)return void this.chat.appImManager.setInnerPeer({peerId:n.dataset.peerId.toPeerId()});const a=(0,fe.Z)(i,"bubble-call");if(a)return void this.chat.appImManager.callUser(this.peerId.toUserId(),a.dataset.type);if((0,fe.Z)(i,"is-buy")){(0,be.Z)(e);const t=yield this.chat.getMessage(+s.dataset.mid);if(!t)return;return void new Ti(t,yield this.managers.appPaymentsManager.getInputInvoiceByPeerId(t.peerId,t.mid))}const o=(0,pe.Z)(i,"REACTION-ELEMENT");if(o){if((0,be.Z)(e),o.classList.contains("is-inactive"))return;const t=o.parentElement,i=t.getReactionCount(o),s=t.getMessage();return void this.managers.appReactionsManager.sendReaction(s,i.reaction)}const r=(0,Ae.Z)(i,"data-sticker-emoji");if(r&&1===r.parentElement.querySelectorAll("[data-sticker-emoji]").length&&s.classList.contains("emoji-big"))return void(0,V._2)({event:e,container:r,managers:this.managers,middleware:this.getMiddleware(),peerId:this.peerId});if((0,fe.Z)(i,"replies")){const e=+s.dataset.mid;if(this.peerId===m.hj){const t=yield this.chat.getMessage(e),i=(0,F.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(i,n,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 d=(0,fe.Z)(i,"is-via");if(d){const t=d.querySelector(".peer-title");if(i===t||(0,_e.Z)(i,t)){const i=t.innerText+" ";return this.managers.appDraftsManager.setDraft(this.peerId,this.chat.threadId,i),void(0,be.Z)(e)}}const l=(0,fe.Z)(i,"peer-title")||(0,pe.Z)(i,"AVATAR-ELEMENT")||(0,Ae.Z)(i,"data-saved-from");if(l&&l!==s){i=l||i;const e=i.dataset.peerId||i.getAttribute("peer")||i.peerId,t=i.dataset.savedFrom;if("string"==typeof e||t)if(t){const[e,n]=t.split("_");if(i.classList.contains("is-receipt-link")){const t=yield this.managers.appMessagesManager.getMessageByPeer(e.toPeerId(),+n);if(t){const e=yield this.managers.appPaymentsManager.getInputInvoiceByPeerId(this.peerId,+s.dataset.mid);new Ti(t,e,void 0,!0)}}else this.chat.appImManager.setInnerPeer({peerId:e.toPeerId(),lastMsgId:+n})}else{const t=e.toPeerId();t!==m.NM?this.chat.appImManager.setInnerPeer({peerId:t}):(0,me.Am)(S.ZP.format("HidAccount",!0))}return}if(s.classList.contains("sticker")&&i.parentElement.classList.contains("attachment")){const e=+s.dataset.mid,i=null===(t=(yield this.chat.getMessage(e)).media)||void 0===t?void 0:t.document;return void((null==i?void 0:i.stickerSetInput)&&new I.Z(i.stickerSetInput).show())}const h=(0,fe.Z)(i,"document-with-thumb");if("IMG"===i.tagName&&!i.classList.contains("emoji")&&!i.classList.contains("document-thumb")||i.classList.contains("album-item")||"VIDEO"===i.tagName&&!s.classList.contains("round")||h&&!h.querySelector(".preloader-container")||i.classList.contains("canvas-thumbnail")){const t=(0,fe.Z)(i,"album-item")||(0,fe.Z)(i,"document-container"),n=(t||s).querySelector(".preloader-container");if(n)return(0,w.tH)(n),void(0,be.Z)(e);(0,be.Z)(e);const a=+(t||s).dataset.mid,o=yield this.chat.getMessage(a);if(!o)return void this.log.warn("no message by messageId:",a);const r="webpage",d=s.classList.contains(r),l=h?e=>ke.Z.isMediaCompatibleForDocumentViewer(e):e=>"photo"===e._||["video","gif"].includes(e.type),c=[],u=d?[a]:(yield Promise.all(Object.keys(this.bubbles).map((e=>+e)).map((e=>is(this,void 0,void 0,(function*(){const t=yield this.chat.getMessage(e),i=(0,lt.Z)(t);return i&&l(i)&&e})))))).filter(Boolean).sort(((e,t)=>e-t));u.forEach((e=>{let t;h?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(h)i.forEach((e=>{c.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,fe.Z)(i,"media-container-aspecter"))return;const n=(0,fe.Z)(i,"album-item"),a=n||i.parentElement;s.has(a)||(s.add(a),c.push({element:i,mid:n?+n.dataset.mid:e,peerId:this.peerId}))}))}})),c.sort(((e,t)=>e.mid-t.mid));const f=c.findIndex((e=>e.mid===a));return he.ZP&&this.log("open mediaViewer single with ids:",u,f,c),c[f]?void(new ke.Z).setSearchContext({threadId:this.chat.threadId,peerId:this.peerId,inputFilter:{_:h?"inputMessagesFilterDocument":"inputMessagesFilterPhotoVideo"},useSearch:"scheduled"!==this.chat.type&&!d,isScheduled:"scheduled"===this.chat.type}).openMedia(o,c[f].element,0,!0,c.slice(0,f),c.slice(f+1)):void this.log("no target for media viewer!",i)}if(-1===["IMG","DIV","SPAN"].indexOf(i.tagName)&&(i=(0,pe.Z)(i,"DIV")),-1!==["DIV","SPAN"].indexOf(i.tagName)){if(i.classList.contains("goto-original")){const e=s.dataset.savedFrom,[t,i]=e.split("_");return void this.chat.appImManager.setInnerPeer({peerId:t.toPeerId(),lastMsgId:+i})}if(i.classList.contains("forward")){const e=+s.dataset.mid,t=yield this.managers.appMessagesManager.getMessageByPeer(this.peerId,e);return void new E.Z({[this.peerId]:yield this.managers.appMessagesManager.getMidsByMessage(t)})}let t=!1;try{t=!!(0,fe.Z)(e.target,"reply")}catch(e){}if(t&&s.classList.contains("is-reply")){const e=+s.dataset.mid;this.replyFollowHistory.push(e);const t=yield this.chat.getMessage(e),i=t.reply_to.reply_to_peer_id?(0,F.Z)(t.reply_to.reply_to_peer_id):this.peerId,n=t.reply_to.reply_to_msg_id;this.chat.appImManager.setInnerPeer({peerId:i,lastMsgId:n,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)=>is(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=>is(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()])),yield a((0,le.AD)()),o("media promises end"),n=r(n);const{restoreScroll:u,scrollSaver:f}=this.prepareToSaveScroll(d);null===(i=this.messagesQueueOnRenderAdditional)||void 0===i||i.call(this),this.ejectBubbles();for(const[e,t]of this.bubblesToReplace){if(f&&f.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()})),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 ae.Z,this.constructBubbles(),this.batchProcessor=new ts.s({log:this.log,process:this.processBatch,possibleError:ls}),this.bubbleGroups=new b(this.chat),this.preloader=new M.Z({cancelable:!1}),this.lazyLoadQueue=new ne.Z(void 0,!0),this.lazyLoadQueue.queueId=++rs,this.listenerSetter.add(d.Z)("history_update",(({storageKey:e,sequential:t,message:i})=>is(this,void 0,void 0,(function*(){if(this.chat.messagesStorageKey!==e||"scheduled"===this.chat.type)return;const{mid:s}=i,n=this.bubbles[s];if(!n)return;if(this.renderNewPromises.size&&(yield Promise.all(Array.from(this.renderNewPromises))),this.messagesQueuePromise&&(yield this.messagesQueuePromise),this.bubbles[s]!==n)return;const a=this.bubbleGroups.getItemByBubble(n);if(!a)return;if(a.mid===s)return;if(t){const e=a.group,o=this.bubbleGroups.createItem(n,i),r=this.bubbleGroups.itemsArr.slice();(0,h.Z)(r,a);const l=this.bubbleGroups.findGroupSiblingByItem(o,r);if(e===(null==l?void 0:l.group)||e===this.bubbleGroups.getLastGroup()&&1===e.items.length&&o.dateTimestamp===a.dateTimestamp||this.peerId===d.Z.myId&&t&&o.dateTimestamp===a.dateTimestamp)return void this.bubbleGroups.changeBubbleMid(n,s)}this.bubbleGroups.removeAndUnmountBubble(n);const{groups:o}=this.groupBubbles([{bubble:n,message:i}]);this.bubbleGroups.mountUnmountGroups(o),this.scrollingToBubble&&this.scrollToEnd()})))),this.listenerSetter.add(d.Z)("dialog_flush",(({peerId:e})=>{this.peerId===e&&this.deleteMessagesByIds(Object.keys(this.bubbles).map((e=>+e)))})),this.listenerSetter.add(d.Z)("message_sent",(e=>is(this,void 0,void 0,(function*(){const{storageKey:t,tempId:i,tempMessage:s,mid:n,message:a}=e;if(this.chat.messagesStorageKey!==t)return;const o=this.bubbles,r=o[i];if(r){const e=o[i];o[n]=e,e.dataset.mid=""+n,delete o[i],(0,le.T2)((()=>{const t=+e.dataset.mid;o[t]===e&&e.classList.contains("is-outgoing")&&(e.classList.remove("is-sending","is-outgoing"),e.classList.add(this.peerId===d.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(n)),"scheduled"===this.chat.type&&(Date.now()/1e3|0)>=s.date-10&&this.deleteMessagesByIds([n]),!r)return;let l,c;const h=a.grouped_id;if(h){l=yield this.managers.appMessagesManager.getMessagesByAlbum(h);const e=l.map((({mid:e})=>e));if(!e.length||us(e)!==n||o[n]!==r)return;if(o[n]!==r)return;c=Array.from(r.querySelectorAll(".grouped-item")).map((e=>+e.dataset.mid))}else l=[a],c=[i];const u=Array.from(r.querySelectorAll("reactions-element"));u.length&&u.forEach((e=>{e.changeMessage(a)})),l.forEach(((e,t)=>{var i,n,a,o,l;if(!e)return;const u=c[t],f=e.mid,p=r.querySelector(`.document-container[data-mid="${f}"]`)||r;if("message"!==e._)return;if(e.replies){const t=r.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=p.querySelector(`.document-container[data-mid="${u}"] .document`);if(t){const i=(0,fe.Z)(t,"document-container");!(null===(o=null===(a=null===(n=s.media)||void 0===n?void 0:n.document)||void 0===a?void 0:a.thumbs)||void 0===o?void 0:o.length)&&(null===(l=g.thumbs)||void 0===l?void 0:l.length)&&(0,de.e9)().then((()=>is(this,void 0,void 0,(function*(){const i=t.querySelector(".time"),s=yield(0,Oi.Z)({message:e,fontSize:d.Z.settings.messagesTextSize});t.replaceWith(s),i&&(s.querySelector(".document")||s).append(i)})))),i&&(i.dataset.mid=""+f)}const i=p.querySelector(`audio-element[data-mid="${u}"], .document[data-doc-id="${u}"], .media-round[data-mid="${u}"]`);i&&(i instanceof oe.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=p.querySelector("poll-element");t&&(t.message=e,t.setAttribute("poll-id",""+v.id),t.setAttribute("message-id",""+f))}else b&&!p.querySelector(".web")&&(0,de.e9)().then((()=>{this.safeRenderMessage(e,!0,p),this.scrollToBubbleIfLast(p)}));if(h){const e=p.querySelector(`.grouped-item[data-mid="${u}"]`)||p;e&&(e.dataset.mid=""+f)}}))})))),this.listenerSetter.add(d.Z)("message_edit",(({storageKey:e,message:t})=>is(this,void 0,void 0,(function*(){if(e!==this.chat.messagesStorageKey)return;const i=this.bubbles[t.mid];i&&(yield(0,de.e9)(),this.bubbles[t.mid]===i&&this.safeRenderMessage(t,!0,i))})))),this.listenerSetter.add(d.Z)("message_error",(({storageKey:e,tempId:t})=>is(this,void 0,void 0,(function*(){if(e!==this.chat.messagesStorageKey)return;const i=this.bubbles[t];i&&(yield(0,de.e9)(),this.bubbles[t]===i&&(i.classList.remove("is-outgoing"),i.classList.add("is-error")))})))),this.listenerSetter.add(d.Z)("album_edit",(({peerId:e,messages:t,deletedMids:i})=>{if(e!==this.peerId)return;const s=t.map((({mid:e})=>e)),n=us(s.concat(Array.from(i))),a=this.bubbles[n];if(!a)return;const o=us(s),r=t.find((e=>e.mid===o));this.safeRenderMessage(r,!0,a)})),"scheduled"!==this.chat.type&&this.listenerSetter.add(d.Z)("messages_reactions",(e=>is(this,void 0,void 0,(function*(){let t;const i=e.map((({message:e,changedResults:t})=>is(this,void 0,void 0,(function*(){if(this.peerId!==e.peerId)return;const i=yield this.getMountedBubble(e.mid,e);return i?{bubble:i.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=$e.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(d.Z)("messages_downloaded",(({peerId:e,mids:t})=>is(this,void 0,void 0,(function*(){const i=this.getMiddleware();yield(0,de.e9)(),i()&&t.forEach((t=>{this.needUpdate;const i=[];(0,g.Z)(this.needUpdate,((s,n)=>{s.replyMid===t&&s.replyToPeerId===e&&(this.needUpdate.splice(n,1)[0],i.push(s))})),i.forEach((({mid:e,replyMid:t,replyToPeerId:i})=>is(this,void 0,void 0,(function*(){const t=this.bubbles[e];if(!t)return;const i=yield this.chat.getMessage(e);se.setReply({chat:this.chat,bubble:t,message:i})}))))}))})))),(0,_i.Z)({listenTo:this.scrollable.container,listenerSetter:this.listenerSetter,findTarget:e=>{const t=e.target;return t.closest(".attachment.media-sticker-wrapper")||(0,fe.Z)(t,"attachment")&&t.closest(".custom-emoji")}}),(0,w.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,pe.Z)(e.target,"CODE");return t?((0,be.Z)(e),i=t,(0,it.T)(i.textContent),void(0,me.bC)({langPackKey:"TextCopied"})):void 0;var i})),this.stickyIntersector=new Z.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})),k.IS_SAFARI||(this.sliceViewportDebounced=(0,Ee.Z)(this.sliceViewport.bind(this),3e3,!1,!0)),(0,de.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 ae.Z),he.ZP&&this.listenerSetter.add(e)("dblclick",(e=>is(this,void 0,void 0,(function*(){const t=(0,fe.Z)(e.target,"grouped-item")||(0,fe.Z)(e.target,"bubble");if(t){const e=+t.dataset.mid;this.log("debug message:",yield this.chat.getMessage(e)),this.highlightBubble(t)}})))),"pinned"!==this.chat.type&&"scheduled"!==this.chat.type)if(k.IS_MOBILE){if(c.Z){const t="is-gesturing-reply",i=64,s=.75*i;let n,a,o=!1;(0,xe.Z)({element:e,verifyTouchTarget:e=>is(this,void 0,void 0,(function*(){return!(this.chat.selection.isSelecting||!(yield this.chat.canSend())||(n=(0,fe.Z)(e.target,"bubble"),n&&((0,Te.Z)(n,t,!0,250),n.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)),!n))})),onSwipe:(e,t)=>{o=e>=s,o&&!a.classList.contains("is-visible")&&a.classList.add("is-visible"),a.style.opacity=""+Math.min(1,e/s);const r=-Math.max(0,Math.min(i,e));n.style.transform=`translateX(${r}px)`,(0,pt.s)()},onReset:()=>{const e=n;(0,Te.Z)(e,t,!1,250,(()=>{a.parentElement===e&&(a.classList.remove("is-visible"),a.remove())})),(0,le.T2)((()=>{if(e.style.transform="",o){const{mid:t}=e.dataset;this.chat.input.initMessageReply(+t),o=!1}}))},listenerOptions:{capture:!0}})}}else this.listenerSetter.add(e)("dblclick",(e=>is(this,void 0,void 0,(function*(){if(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(d.Z)("history_append",(({storageKey:e,message:t})=>is(this,void 0,void 0,(function*(){e===this.chat.messagesStorageKey&&(d.Z.settings.animationsEnabled&&(this.updateGradient=!0),this.scrollable.loadedAll.bottom?this.renderNewMessage(t,!0):this.chat.setMessageId())})))),this.listenerSetter.add(d.Z)("history_multiappend",(e=>{this.peerId===e.peerId&&this.renderNewMessage(e)})),this.listenerSetter.add(d.Z)("history_delete",(({peerId:e,msgs:t})=>{e===this.peerId&&this.deleteMessagesByIds(Array.from(t))})),this.listenerSetter.add(d.Z)("dialog_unread",(({peerId:e})=>{e===this.peerId&&(this.chat.input.setUnreadCount(),(0,de.e9)().then((()=>{this.updateUnreadByDialog()})))})),this.listenerSetter.add(d.Z)("dialogs_multiupdate",(e=>{e.has(this.peerId)&&this.chat.input.setUnreadCount()})),this.listenerSetter.add(d.Z)("dialog_notify_settings",(e=>{this.peerId===e.peerId&&this.chat.input.setUnreadCount()})),this.listenerSetter.add(d.Z)("chat_update",(e=>is(this,void 0,void 0,(function*(){this.peerId===e.toPeerId(!0)&&this.chatInner.classList.contains("has-rights")!==(yield this.chat.canSend())&&(yield Promise.all([this.finishPeerChange(),this.chat.input.finishPeerChange()])).forEach((e=>e()))})))),this.listenerSetter.add(d.Z)("settings_updated",(({key:e})=>is(this,void 0,void 0,(function*(){if("settings.emoji.big"===e){const e=this.getMiddleware(),t=(0,Je.Z)(this.bubbles,"desc").map((e=>is(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(d.Z)("messages_views",(e=>{(0,le.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,_.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)}))}t&&t.restore()}))})),this.observer=new et({root:this.scrollable.container}),this.sendViewCountersDebounced=(0,Ee.Z)((()=>{const e=[...this.viewsMids];this.viewsMids.clear(),this.managers.appMessagesManager.incrementMessageViews(this.peerId,e)}),1e3,!1,!0)}get peerId(){return this.chat.peerId}get messagesQueuePromise(){return this.batchProcessor.queuePromise}createScrollSaver(e=!0){return new Ye(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(mt.Z)("toggle",this.unhoverPrevious),this.listenerSetter.add(ft.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,Te.Z)(e,"is-visible",t,200,t?void 0:()=>{e.remove()},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=ut.Z.getFocusPromise().then((()=>is(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)dt(yield this.chat.getMessage(e))&&i.push(e);return this.managers.appMessagesManager.readMessages(this.peerId,i),this.unreadedSeen.clear(),he.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())}))}))))}constructPinnedHelpers(){this.listenerSetter.add(d.Z)("peer_pinned_messages",(e=>{const{peerId:t,mids:i,pinned:s}=e;t===this.peerId&&i&&(s||this.deleteMessagesByIds(i))}))}constructScheduledHelpers(){const e=()=>is(this,void 0,void 0,(function*(){this.chat.topbar.setTitle((yield this.managers.appMessagesManager.getScheduledMessagesStorage(this.peerId)).size)}));this.listenerSetter.add(d.Z)("scheduled_new",(t=>{t.peerId===this.peerId&&(this.renderNewMessage(t),e())})),this.listenerSetter.add(d.Z)("scheduled_delete",(({peerId:t,mids:i})=>{t===this.peerId&&(this.deleteMessagesByIds(i),e())}))}onGoDownClick(){return is(this,void 0,void 0,(function*(){if(!this.replyFollowHistory.length)return void this.chat.setMessageId();const e=this.getMiddleware(),t=this.replyFollowHistory.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=Pe.Z.height/2>e.top}else s&&(a=!1);a&&this.replyFollowHistory.splice(this.replyFollowHistory.indexOf(e),1)})),this.replyFollowHistory.sort(((e,t)=>t-e));const s=this.replyFollowHistory.pop();this.chat.setMessageId(s)}))}getBubbleByPoint(e){let t=ge(this.scrollable.container,e,"center");return t&&(t=(0,fe.Z)(t,"bubble")),t}getGroupedBubble(e){return is(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 is(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?{bubble:s,mid:e}:void 0}))}findNextMountedBubbleByMsgId(e,t){const i=(0,Je.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?(he.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)):(he.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 P.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),c.Z}updateUnreadByDialog(){return is(this,void 0,void 0,(function*(){const e=yield this.chat.getHistoryStorage(),t=this.peerId===d.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 n=!1;e.forEach((e=>{const t=this.bubbles[e];t&&(this.destroyBubble(t,e),n=!0)})),n&&(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,Qe.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 is(this,void 0,void 0,(function*(){if(!this.scrollable.loadedAll.bottom){const t=this.chat.setPeerPromise;if(t){const i=this.getMiddleware();t.then((()=>is(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){const t=null==e?void 0:e.reply_to;if(!t||(t.reply_to_top_id||t.reply_to_msg_id)!==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,fe.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?ds:1)&&(a=e.group.container.parentElement)}const r=this.chat.input.messageInput&&this.chat.input.messageInput.classList.contains("is-changing-height")||this.chat.container.classList.contains("is-toggling-helper"),d=this.scrollable.scrollIntoViewNew({element:e,position:t,margin:4,forceDirection:i,forceDuration:s,axis:"y",getNormalSize:r?({rect:e})=>{let t=Pe.Z.height;return t-=this.container.offsetTop,t-=o.Z.isMobile||Pe.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===re.f.Static&&(this.scrollable.lastScrollPosition=this.scrollable.scrollTop),d}scrollToEnd(){return this.scrollToBubbleEnd(this.chatInner)}scrollToBubbleEnd(e){return is(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 is(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,S.ag)(n?"Chat.Date.ScheduledForToday":"Date.Today");else if(n&&e===Ie)i=(0,S.ag)("MessageScheduledUntilOnline");else{const e={day:"numeric",month:"long"};t.getFullYear()!==s.getFullYear()&&(e.year="numeric"),i=new S.ZP.IntlDateElement({date:t,options:e}).element,n&&(i=(0,S.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,Je.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,Ce.Kx)(this.scrollable.container),(0,de.gp)(),void 0!==os&&(os=as),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,t,i,n){var a;return is(this,void 0,void 0,(function*(){const o=++this.setPeerTempId;if(!t)return this.cleanup(!0),this.preloader.detach(),null;const r=performance.now(),d=this.log.bindPrefix("setPeer");d.warn("start");const l=()=>this.setPeerTempId===o,c=(0,gt.Z)(l,ls);e||(yield c(this.chat.onChangePeer(c)));const h=this.chat.type;("scheduled"===h||this.chat.isRestricted)&&(i=0);const u=yield c(this.chat.getHistoryStorage()),f="pinned"===h?yield c(this.managers.appMessagesManager.getPinnedMessagesMaxId(t)):null!==(a=u.maxId)&&void 0!==a?a:0,p=void 0!==i;let g,v,b,y=0;if(!p)if(e||(v=this.chat.appImManager.getChatSavedPosition(this.chat)),v);else if(f){y=yield c(this.managers.appMessagesManager.getReadMaxIdIfUnread(t,this.chat.threadId));const s=yield c(this.managers.appMessagesManager.getDialogOnly(t));if(!y||e||s&&1===s.unread_count)i=f;else{const e=u.history.findSliceOffset(y);e&&e.slice.isEnd(ue.D.Bottom)&&(b=e.slice[e.offset-25]||e.slice[0]||y),g=!p,i=y}}const w=i!==f;if(void 0===n&&(yield c(this.chat.isStartButtonNeeded()))&&(n=m.gZ),e){const e=yield c(this.getMountedBubble(i));if(e)return p?(this.scrollToBubble(e.bubble,"center"),this.highlightBubble(e.bubble),this.chat.dispatchEvent("setPeer",i,!1)):f&&!w&&(this.scrollToEnd(),this.chat.dispatchEvent("setPeer",i,!0)),void 0!==n&&this.chat.input.setStartParam(n),null}else this.peerId&&(this.lazyLoadQueue.queueId=++rs,this.managers.apiFileManager.setQueueId(this.chat.bubbles.lazyLoadQueue.queueId)),this.replyFollowHistory.length=0,this.passEntities={messageEntityBotCommand:(yield c(this.managers.appPeersManager.isAnyGroup(t)))||this.chat.isBot};he.ZP&&d("setPeer peerId:",t,u,i,f);const S=null!=b?b:w||"scheduled"===h||this.chat.isRestricted?0:f;let C=0;if(e){const e=this.getBubbleByPoint("bottom");e&&(C=+e.dataset.mid),C<=0&&(C=Math.max(...Object.keys(this.bubbles).map((e=>+e))))}else this.isFirstLoad=!0,this.destroyResizeObserver();const L=this.chatInner,E=this.emptyPlaceholderBubble;this.cleanup();const I=this.chatInner=document.createElement("div");e?(I.className=L.className,I.classList.remove("disable-hover","is-scrolling")):I.classList.add("bubbles-inner"),this.lazyLoadQueue.lock();const M=e||f&&w||p,P=C>0&&(!i||C<i||i<0),Z=!P&&e,k=!Z&&P;let T;this.willScrollOnLoad=Z||k,this.setPeerOptions={lastMsgId:i,topMessage:f},T=v?{promise:(0,de.e9)().then((()=>this.performHistoryResult({history:v.mids},!0))),cached:!0,waitPromise:Promise.resolve()}:yield c(this.getHistory1(i,!0,w,S)),this.setPeerCached=T.cached,d.warn("got history");const{promise:x,cached:A}=T;A||e||(yield c(this.chat.finishPeerChange(p,w,i,n)),this.scrollable.container.textContent="",this.preloader.attach(this.container)),s.Z.lockGroup(this.chat.animationGroup);const _=c(x).then((()=>is(this,void 0,void 0,(function*(){d.warn("promise fulfilled");const a=M?yield c(i?this.getMountedBubble(i):{bubble:this.getLastBubble()}):void 0;A&&!e&&(d.warn("finishing peer change"),yield c(this.chat.finishPeerChange(p,w,i,n)),d.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,O.Z)(o.container,I),E&&this.cleanupPlaceholders(E),this.attachPlaceholderOnRender&&this.attachPlaceholderOnRender(),!p&&"chat"===this.chat.type&&this.chat.topbar.pinnedMessage&&this.chat.topbar.pinnedMessage.setCorrectIndex(0),this.container.classList.toggle("has-groups",!!Object.keys(this.dateMessages).length),d.warn("mounted chat",this.chatInner===I,this.chatInner.parentElement,performance.now()-r),s.Z.unlockGroup(this.chat.animationGroup),s.Z.checkAnimations(!1,this.chat.animationGroup),this.lazyLoadQueue.unlock(),v)o.setScrollTopSilently(v.top);else if(M){let t;if(Z)o.setScrollTopSilently(99999);else if(k){const e=this.setTopPadding();e.isPaddingNeeded&&(t=e.unsetPadding),o.setScrollTopSilently(0)}let s,n=g&&this.firstUnreadBubble||(null==a?void 0:a.bubble);if((null==n?void 0:n.parentElement)||(n=this.findNextMountedBubbleByMsgId(i,!1)||this.findNextMountedBubbleByMsgId(i,!0)),n){const t=this.getLastBubble(),i=g?"start":w||p||t!==n?"center":"end";s="end"===i&&t===n&&e?this.scrollToEnd():this.scrollToBubble(n,i,e?void 0:re.f.Static),!g&&p&&this.highlightBubble(n)}t&&(s||Promise.resolve()).then((()=>{t()}))}else o.setScrollTopSilently(99999);this.onRenderScrollSet(),this.onScroll();const l=Promise.all([_,(0,de.e9)()]);if(l.then((()=>{o.checkForTriggers()})),this.chat.dispatchEvent("setPeer",i,!w),Promise.all([this.setFetchReactionsInterval(l),this.setFetchHistoryInterval({afterSetPromise:l,lastMsgId:i,samePeer:e,savedPosition:v,topMessage:f})]).then((()=>{d("scrolledAllDown:",o.loadedAll.bottom),o.loadedAll.bottom&&f&&!this.unreaded.size&&this.onScrolledAllDown()})),"chat"===h){const e=yield c(this.managers.appMessagesManager.getDialogOnly(t));(null==e?void 0:e.pFlags.unread_mark)&&this.managers.appMessagesManager.markDialogUnread(t,!0)}})))).catch((e=>{throw d.error("getHistory promise error:",e),l()||this.preloader.detach(),e}));return{cached:A,promise:_}}))}setFetchReactionsInterval(e){return is(this,void 0,void 0,(function*(){const t=this.getMiddleware();if(this.chat.isChannel){const i=()=>is(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,de.e9)(),(0,Qe.Z)(500)]).then((()=>{i()}))}}))}setFetchHistoryInterval({lastMsgId:e,topMessage:t,afterSetPromise:i,savedPosition:s,samePeer:n}){return is(this,void 0,void 0,(function*(){const e=this.getMiddleware(),t=this.peerId,a=yield this.managers.appMessagesManager.isFetchIntervalNeeded(t);if(!s&&!a)return;if(yield i,!e())return;if(this.setLoaded("bottom",!1),this.scrollable.checkForTriggers(),!a)return;const o=()=>{this.fetchNewPromise=new Promise((i=>is(this,void 0,void 0,(function*(){e()&&(yield this.managers.appMessagesManager.isFetchIntervalNeeded(t))?this.managers.appMessagesManager.getNewHistory(t,this.chat.threadId).then((t=>{if(!e()||!t)return void i();const{isBottomEnd:s}=t;this.scrollable.loadedAll.bottom&&this.scrollable.loadedAll.bottom!==s&&(this.setLoaded("bottom",s),this.onScroll()),setTimeout(o,3e4),i()})):i()})))).finally((()=>{this.fetchNewPromise=void 0}))};n?setTimeout(o,3e4):o()}))}onScrolledAllDown(){return is(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 is(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)}safeRenderMessage(e,t,i,s=!0,n){return is(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,n){var a,r,l;return is(this,void 0,void 0,(function*(){const c="message"===e._,h=c&&e.grouped_id;let u,f;const g=h?yield this.managers.appMessagesManager.getMessagesByAlbum(h):void 0,v="pinned"!==this.chat.type;if(h&&v){u=g.map((e=>e.mid));const t=us(u);if(e.mid!==t)return}c&&(f=h?g[0]:e);const b=this.chat.isOurMessage(e),y=document.createElement("div");y.classList.add("message","spoilers-container");const C=document.createElement("div");C.classList.add("bubble-content-wrapper");const L=document.createElement("div");L.classList.add("bubble-content"),i.classList.add("bubble"),C.append(L),i.append(C);const I=!b&&!e.pFlags.out&&(e.pFlags.unread||dt(e));I&&this.observer&&(this.observer.observe(i,this.unreadedObserverCallback),this.unreaded.set(i,e.mid));const M=[],P={bubble:i,promises:M,message:e,reverse:t};if(!("messageService"!==e._||e.action&&ns.has(e.action._))){const t=e.action;if(t){const e=t._;if(ss.has(e)||S.Hz.hasOwnProperty(e)&&!S.Hz[e])return}i.className="bubble service",L.innerHTML="";const s=document.createElement("div");if(s.classList.add("service-msg"),t){let i;if("messageActionChannelMigrateFrom"===t._){const e=new R.Z;i=e.update({peerId:t.chat_id.toPeerId(!0),middleware:n}),s.append((0,S.ag)("ChatMigration.From",[e.element]))}else if("messageActionChatMigrateTo"===t._){const e=new R.Z;i=e.update({peerId:t.channel_id.toPeerId(!0),middleware:n}),s.append((0,S.ag)("ChatMigration.To",[e.element]))}else s.append(yield(0,rt.Z)(e))}return L.append(s),e.pFlags.is_single&&i.classList.add("is-group-last"),P}let Z,x,_=c&&e.media,F=!0;if(c){if(h&&v){const e=(0,bt.Z)(g);Z=e.message,x=e.totalEntities}else Z=e.message,x=e.totalEntities;const t=null==_?void 0:_.document;t&&("sticker"===(null==t?void 0:t.type)?Z=x=void 0:["video","gif"].includes(t.type)||(F=!1))}else"messageActionPhoneCall"===e.action._&&(_={_:"messageMediaCall",action:e.action});let B,O=0;if(x&&!_){const e=x.filter((e=>"messageEntityEmoji"===e._)),t=Z.replace(/\s/g,"").length;if(e.reduce(((e,t)=>e+t.length),0)===t){O=Math.min(hs,e.length),B=o.Z.active.customEmoji;const t=cs[O];t&&(B=(0,Ve.C)(t,t),i.style.setProperty("--emoji-size",t+"px"))}}null!=B||(B=this.chat.appImManager.customEmojiSize);const U=(0,ot.ZP)(Z,{entities:x,passEntities:this.passEntities,loadPromises:M,lazyLoadQueue:this.lazyLoadQueue,customEmojiSize:B,middleware:n,animationGroup:this.chat.animationGroup});let H=!0,z=!1;if(O){if(d.Z.settings.emoji.big){const e=1===O&&!x.find((e=>"messageEntityCustomEmoji"===e._))&&(yield this.managers.appStickersManager.getAnimatedEmojiSticker(Z));if(1===O&&!_&&e)_={_:"messageMediaDocument",document:e};else{const e=document.createElement("div");e.classList.add("attachment","spoilers-container"),(0,A.Z)(e,U),L.append(e)}i.classList.add("is-message-empty","emoji-big"),z=!0,H=!1,F=!1}i.classList.add("can-have-big-emoji")}F&&(0,A.Z)(y,U);const j=(W=Z,Xi.test(W));var W;const $=se.setTime({chatType:this.chat.type,message:e,reactionsMessage:f});if(y.append($),L.prepend(y),j&&$.classList.add("is-block"),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"),L.prepend(e),i.classList.add("with-beside-button")}!e.pFlags.is_outgoing&&this.observer&&this.observer.observe(i,this.viewsObserverCallback)}const q=c&&e.reply_markup;let Q="replyInlineMarkup"===(null==q?void 0:q._)&&q.rows;if(Q&&(Q=Q.filter((e=>e.buttons.length))),Q){const t=document.createElement("div");t.classList.add("reply-markup"),Q.forEach((i=>{const s=i.buttons,n=document.createElement("div");n.classList.add("reply-markup-row"),s.forEach((t=>{let i,s=(0,ot.ZP)(t.text,{noLinks:!0,noLinebreaks:!0});switch(t._){case"keyboardButtonUrl":{const e=(0,ot.ZP)(" ",{entities:[{_:"messageEntityTextUrl",length:1,offset:0,url:t.url}]});i=(0,ye.Z)(e).firstElementChild,i.classList.add("is-link");break}case"keyboardButtonSwitchInline":i=document.createElement("button"),i.classList.add("is-switch-inline"),(0,w.fc)(i,(i=>{(0,be.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=new E.Z({[this.peerId]:[]},(t=>{e(t)}),!0);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"===_._?_: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,S.ag)("Message.ReplyActionButtonShowReceipt"));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,T.Z)(i),i.append(a),n.append(i)})),n.childElementCount&&t.append(n)}));const s=!!t.childElementCount;s&&(0,w.fc)(t,(t=>{let i=t.target;if(i.classList.contains("reply-markup-button")||(i=(0,fe.Z)(i,"reply-markup-button")),!i||i.classList.contains("is-link")||i.classList.contains("is-switch-inline")||i.classList.contains("is-buy"))return;(0,be.Z)(t);const s=(0,Se.Z)(i),n=Q[(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,me.Am)((0,ot.ZP)(e.message,{noLinks:!0,noLinebreaks:!0}))}))})),s&&(i.classList.add("with-reply-markup"),C.append(t))}const Y=e.pFlags.is_outgoing;if(b){(e.pFlags.unread||Y)&&this.unreadOut.add(e.mid);let t="";t=e.error?"is-error":Y?"is-sending":e.pFlags.unread||e.pFlags.is_scheduled?"is-sent":"is-read",i.classList.add(t)}Y&&!e.error&&i.classList.add("is-outgoing");const J=c&&(yield this.managers.appMessagesManager.getMessageWithCommentReplies(e)),X=!!J&&e.mid>0;X&&i.classList.add("with-replies");const ee=c&&e.fwd_from,te=c&&e.fwdFromId,ie=this.chat.isOutMessage(e);let ne=L;const ae=!(e.viaBotId||e.fromId!==d.Z.myId&&e.pFlags.out);if(_){let t=document.createElement("div");t.classList.add("attachment"),Z||i.classList.add("is-message-empty");let a=!1;switch(_._){case"messageMediaPhoto":{const s=_.photo;if(Z||(H=!1),ae&&i.classList.add("hide-name"),i.classList.add("photo"),v&&h&&1!==u.length){i.classList.add("is-album","is-grouped"),Ni({messages:g,attachmentDiv:t,middleware:this.getMiddleware(),isOut:b,lazyLoadQueue:this.lazyLoadQueue,chat:this.chat,loadPromises:M,autoDownload:this.chat.autoDownload});break}const n=!k.IS_ANDROID&&H&&!X&&!1;n&&i.classList.add("with-media-tail"),(0,G.Z)({photo:s,message:e,container:t,withTail:n,isOut:ie,lazyLoadQueue:this.lazyLoadQueue,middleware:this.getMiddleware(),loadPromises:M,autoDownloadSize:this.chat.autoDownload.photo});break}case"messageMediaWebPage":{a=!0;const t=_.webpage;if("webPage"!==t._)break;i.classList.add("webpage");const s=document.createElement("div");s.classList.add("web");const n=document.createElement("div");let r,l;n.classList.add("quote");const c=t.photo;(c||t.document)&&(r=document.createElement("div"),r.classList.add("preview-resizer"),l=document.createElement("div"),l.classList.add("preview"),r.append(l));const h=document.createElement("div");h.classList.add("quote-text");const u=t.document;if(u)if("gif"===u.type||"video"===u.type||"round"===u.type){const t="round"===u.type?o.Z.active.round:o.Z.active.webpage;"round"===u.type?(i.classList.add("round"),l.classList.add("is-round")):i.classList.add("video"),(0,K.Z)({doc:u,container:l,message:e,boxWidth:t.width,boxHeight:t.height,lazyLoadQueue:this.lazyLoadQueue,middleware:this.getMiddleware(),isOut:ie,group:this.chat.animationGroup,loadPromises:M,autoDownload:this.chat.autoDownload,noInfo:e.mid<0})}else{const t=yield(0,Oi.Z)({message:e,autoDownloadSize:this.chat.autoDownload.file,lazyLoadQueue:this.lazyLoadQueue,loadPromises:M,sizeType:"documentName",searchContext:{useSearch:!1,peerId:this.peerId,inputFilter:{_:"inputMessagesFilterEmpty"}},fontSize:d.Z.settings.messagesTextSize});l.append(t),l.classList.add("preview-with-document"),h.classList.add("has-document")}let f;if(r&&h.append(r),t.site_name){const e=(0,ot.ZP)(t.url),i=(0,ye.Z)(e).firstElementChild;i.classList.add("webpage-name");const s=document.createElement("strong");(0,A.Z)(s,(0,D.Z)(t.site_name)),i.textContent="",i.append(s),h.append(i),f=i}const p=(0,at.Z)(t);if(p.textContent){const e=document.createElement("div");e.classList.add("title");const t=document.createElement("strong");(0,A.Z)(t,p),e.append(t),h.append(e),f=e}const m=(0,nt.Z)(t);if(m.textContent){const e=document.createElement("div");e.classList.add("text"),(0,A.Z)(e,m),h.append(e),f=e}if(n.append(h),c&&!u){i.classList.add("photo");const t=c.sizes[c.sizes.length-1];let s=!1;t.w===t.h&&f?(i.classList.add("is-square-photo"),s=!0,(0,st.Z)(c,l,48,48,!1)):t.h>t.w&&i.classList.add("is-vertical-photo"),(0,G.Z)({photo:c,message:e,container:l,boxWidth:s?0:o.Z.active.webpage.width,boxHeight:s?0:o.Z.active.webpage.height,isOut:ie,lazyLoadQueue:this.lazyLoadQueue,middleware:this.getMiddleware(),loadPromises:M,withoutPreloader:s,autoDownloadSize:this.chat.autoDownload.photo})}s.append(n),y.insertBefore(s,$);break}case"messageMediaDocument":{const s=_.document;if(s.sticker){i.classList.add("sticker"),H=!1,z=!0,s.animated&&i.classList.add("sticker-animated");const e=o.Z.active,a=i.classList.contains("emoji-big"),d=a?e.emojiSticker:s.animated?e.animatedSticker:e.staticSticker;(0,st.Z)(s,t,d.width,d.height),L.style.minWidth=t.style.width,L.style.minHeight=t.style.height,(0,V.ZP)({doc:s,div:t,middleware:n,lazyLoadQueue:this.lazyLoadQueue,group:this.chat.animationGroup,play:!0,loop:!0,emoji:a?Z:void 0,withThumb:!0,loadPromises:M,isOut:ie,noPremium:null===(r=null==_?void 0:_.pFlags)||void 0===r?void 0:r.nopremium}),((0,Ai.Z)(s)||a)&&(I||Y)&&this.observer.observe(i,this.stickerEffectObserverCallback)}else if("video"===s.type||"gif"===s.type||"round"===s.type){const a="round"===s.type;if(a&&(z=!0),!a&&Z||(H=!1),ae&&i.classList.add("hide-name"),i.classList.add(a?"round":"video"),v&&h&&1!==u.length)i.classList.add("is-album","is-grouped"),Ni({messages:g,attachmentDiv:t,middleware:n,isOut:b,lazyLoadQueue:this.lazyLoadQueue,chat:this.chat,loadPromises:M,autoDownload:this.chat.autoDownload});else{const r=!k.IS_ANDROID&&!k.IS_APPLE&&!a&&H&&!X&&!1;r&&i.classList.add("with-media-tail"),(0,K.Z)({doc:s,container:t,message:e,boxWidth:o.Z.active.regular.width,boxHeight:o.Z.active.regular.height,withTail:r,isOut:ie,lazyLoadQueue:this.lazyLoadQueue,middleware:n,group:this.chat.animationGroup,loadPromises:M,autoDownload:this.chat.autoDownload,searchContext:a?{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})}}else{const t=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:f,richTextFragment:p}){return Ui(this,void 0,void 0,(function*(){let l;const m=e?yield n.getMidsByMid(t.mid):[t.mid],g=m.map(((e,t)=>Ui(this,void 0,void 0,(function*(){const i=yield n.getMessage(e),s=yield(0,Oi.Z)({message:i,loadPromises:a,autoDownloadSize:o,lazyLoadQueue:r,searchContext:d,sizeType:c,managers:h,fontWeight:u,fontSize:f}),g=document.createElement("div");g.classList.add("document-container"),g.dataset.mid=""+e,g.dataset.peerId=""+i.peerId;const v=document.createElement("div");if(v.classList.add("document-wrapper"),i.message){const e=document.createElement("div");e.classList.add("document-message"),(0,A.Z)(e,p),v.append(e)}if(m.length>1){const e=document.createElement("div");e.classList.add("document-selection"),g.append(e),g.classList.add("grouped-item"),0===t&&(l=v)}return v.append(s),g.append(v),g})))),v=yield Promise.all(g);return s.append(...v),m.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"===s.type||"audio"===s.type?{peerId:this.peerId,inputFilter:{_:"voice"===s.type?"inputMessagesFilterRoundVoice":"inputMessagesFilterMusic"},threadId:this.chat.threadId,useSearch:!e.pFlags.is_scheduled,isScheduled:e.pFlags.is_scheduled}:void 0,sizeType:"documentName",fontSize:d.Z.settings.messagesTextSize,richTextFragment:U});t&&(ne=t);const n=y.lastElementChild.querySelector(".document-message, .document, .audio");n&&n.append($),i.classList.remove("is-message-empty"),y.classList.add((["photo","pdf"].includes(s.type)?"document":s.type||"document")+"-message"),a=!0}break}case"messageMediaCall":{const e=_.action,t=document.createElement("div");t.classList.add("bubble-call",e.pFlags.video?"tgico-videocamera":"tgico-phone");const s=e.pFlags.video?"video":"voice";t.dataset.type=s;const n=document.createElement("div");n.classList.add("bubble-call-title"),(0,S.$d)(n,ie?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,Fe.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,S.$d)(o,t)}o.classList.add("tgico","arrow-"+(void 0!==e.duration?"green":"red")),t.append(n,o),a=!0,i.classList.remove("is-message-empty"),y.classList.add("call-message"),y.append(t);break}case"messageMediaContact":{const e=_,t=document.createElement("div");t.classList.add("contact"),t.dataset.peerId=""+e.user_id,a=!0;const s=document.createElement("div");s.className="contact-details";const n=document.createElement("div");n.className="contact-name",n.append((0,D.Z)([e.first_name,e.last_name].filter(Boolean).join(" ")));const o=document.createElement("div");o.className="contact-number",o.textContent=e.phone_number?"+"+(0,Ze.u)(e.phone_number).formatted:"Unknown phone number",t.append(s),s.append(n,o);const r=new p.Z;r.updateWithOptions({lazyLoadQueue:this.lazyLoadQueue,peerId:e.user_id.toPeerId()}),r.classList.add("contact-avatar","avatar-54"),t.prepend(r),i.classList.remove("is-message-empty"),y.classList.add("contact-message"),y.append(t);break}case"messageMediaPoll":{i.classList.remove("is-message-empty");const t=function(e,t=d.Z.managers){const i=new Ji;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 a=_.pFlags.test,r=_.extended_media,d="messageExtendedMedia"===(null==r?void 0:r._),l="messageExtendedMediaPreview"===(null==r?void 0:r._);let c=d?r.media.photo||r.media.document:_.photo;const h=(0,yt.Z)(_.total_amount,_.currency);let u,f;if(r){if(l&&(u=document.createElement("span"),u.classList.add("extended-media-buy","tgico-premium_lock"),t.classList.add("is-buy"),(0,S.$d)(u,"Checkout.PayPrice",[h]),void 0!==r.video_duration)){const e=document.createElement("span");e.classList.add("video-time"),e.textContent=(0,Gi.Z)(r.video_duration,!1),t.append(e)}}else{u=document.createElement(c?"span":"div");const e=document.createDocumentFragment(),t=(0,S.ag)(_.receipt_msg_id?"PaymentReceipt":a?"PaymentTestInvoice":"PaymentInvoice");t.classList.add("text-uppercase");const i=" ",s=document.createElement("span");if(s.classList.add("text-bold"),s.textContent=h+i,e.append(s,t),a&&_.receipt_msg_id){const t=document.createElement("span");t.classList.add("text-uppercase","pre-wrap"),t.append(i+"(Test)"),e.append(t)}(0,A.Z)(u,e)}if(l&&(r.thumb.w=r.w,r.thumb.h=r.h,c={_:"photo",access_hash:"",pFlags:{},date:0,dc_id:0,file_reference:[],id:0,sizes:[r.thumb]}),c){const s=r?o.Z.active.extendedInvoice:o.Z.active.invoice;"document"===c._?((0,K.Z)({doc:c,container:t,withTail:!1,isOut:ie,lazyLoadQueue:this.lazyLoadQueue,middleware:n,loadPromises:M,boxWidth:s.width,boxHeight:s.height,group:this.chat.animationGroup,message:e}),i.classList.add("video")):((0,G.Z)({photo:c,container:t,withTail:!1,isOut:ie,lazyLoadQueue:this.lazyLoadQueue,middleware:n,loadPromises:M,boxWidth:s.width,boxHeight:s.height,message:d?e:void 0}),i.classList.add("photo")),u&&(r||u.classList.add("video-time"),t.append(u))}else t=void 0;if(l){const{mid:i}=e;this.extendedMediaMessages.add(i),n.onClean((()=>{this.extendedMediaMessages.delete(i),s.Z.removeAnimationByPlayer(r)})),this.setExtendedMediaMessagesPollInterval();const{width:a,height:o}=t.style,r=new es(parseInt(a),parseInt(o));r.renderFirstFrame(),t.append(r.canvas),s.Z.addAnimation(r,this.chat.animationGroup,r.canvas,!0)}r||(f=document.createElement("div"),f.classList.add("bubble-primary-color"),(0,A.Z)(f,(0,D.Z)(_.title)));const p=d?void 0:(0,D.Z)(_.description);y.prepend(...[f,!c&&u,p].filter(Boolean)),p?i.classList.remove("is-message-empty"):H=!1,i.classList.add("is-invoice");break}default:t=void 0,i.classList.remove("is-message-empty"),y.append((0,S.ag)(S.nK),$),this.log.warn("unrecognized media type:",_._,e)}!a&&t&&L.append(t)}z&&i.classList.add("just-media");let oe="";const re=e.fromId!==d.Z.myId&&this.chat.isAnyGroup||e.viaBotId||e.pFlags.sponsored;if(re||ee||e.reply_to_mid){let t,s;const a="peerChannel"===(null===(l=e.from_id)||void 0===l?void 0:l._)&&e.fromId===te,o=ee&&!ee.from_id;e.viaBotId&&(s=document.createElement("span"),s.innerText="@"+(yield this.managers.appUsersManager.getUser(e.viaBotId)).username,s.classList.add("peer-title"),i.classList.add("must-have-name"));const r=te||ee;let h,u;if(o?(t=document.createElement("span"),(0,A.Z)(t,(0,D.Z)(ee.from_name)),t.classList.add("peer-title"),i.classList.add("hidden-profile")):t=new R.Z({peerId:te||e.fromId,withPremiumIcon:!r,middleware:n}).element,e.reply_to_mid&&e.reply_to_mid!==this.chat.threadId&&c&&(h=yield se.setReply({chat:this.chat,bubble:i,bubbleContainer:L,message:e})),r)if(this.peerId===d.Z.myId||a||i.classList.add("forwarded"),e.savedFrom&&(oe=e.savedFrom,t.dataset.savedFrom=oe),u=document.createElement("div"),t.dataset.peerId=""+te,this.peerId!==d.Z.myId&&this.peerId!==m.hj&&!a||z){const e=[t];if(z){const t=document.createElement("br");t.classList.add("hide-ol"),e.unshift(t)}u.append((0,S.ag)("ForwardedFrom",[e]))}else u.style.color=(0,N.Z)(te,!1),u.classList.add("colored-name"),u.append(t);else if(!e.viaBotId)if(!z&&re){u=document.createElement("div"),u.append(t);const i=yield this.managers.appPeersManager.getPeer(e.fromId),s=null==i?void 0:i.pFlags;s&&(s.scam||s.fake)&&u.append((0,tt.Z)(s.scam)),b||(u.style.color=(0,N.Z)(e.fromId,!1),u.classList.add("colored-name")),u.dataset.peerId=""+e.fromId}else i.classList.add("hide-name");if(e.viaBotId){u?u.append(" "):u=document.createElement("div");const e=document.createElement("span");e.append((0,S.ag)("ViaBot")," ",s),e.classList.add("is-via"),u.append(e)}u?(u.classList.add("name"),z?(ne.append(ne=document.createElement("div")),ne.classList.add("name-with-reply","floating-part")):u.classList.add("floating-part"),ne.append(u),z&&h&&ne.append(h)):z&&h&&h.classList.add("floating-part")}else i.classList.add("hide-name");if("pinned"===this.chat.type&&(oe=`${this.chat.peerId}_${e.mid}`),J&&J.mid===this.chat.threadId&&i.classList.add("is-thread-starter","is-group-last"),oe&&("pinned"===this.chat.type||ee.saved_from_msg_id)&&this.peerId!==m.hj){const e=document.createElement("div");e.classList.add("bubble-beside-button","goto-original","tgico-arrow_next"),L.append(e),i.dataset.savedFrom=oe,i.classList.add("with-beside-button")}return i.classList.add(ie?"is-out":"is-in"),X&&(se.renderReplies({bubble:i,bubbleContainer:L,message:J,messageDiv:y,loadPromises:M,lazyLoadQueue:this.lazyLoadQueue})?H=!0:i.classList.add("with-beside-replies")),c&&this.appendReactionsElementToBubble(i,e,f),H&&(i.classList.add("can-have-tail"),L.append(ps())),P}))}appendReactionsElementToBubble(e,t,i,s){if(this.peerId.isUser(),!(null==i?void 0:i.reactions)||!i.reactions.results.length)return;const n=new qe;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=se.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)}}}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 is(this,void 0,void 0,(function*(){let s=e.history;s=s.slice(),this.needReflowScroll&&(we(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(ue.D.Bottom)||i.length&&!s.includes(i[0])||(t.bottom=!0),!n.isEnd(ue.D.Top)||n.length&&!s.includes(n[n.length-1])||(t.top=!0)}if(!t.bottom&&this.setPeerOptions){const{lastMsgId:e,topMessage:i}=this.setPeerOptions;this.setPeerOptions=void 0,e&&!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 is(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,Je.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();he.ZP&&a("targeting mid:",o,n,e,d.map((e=>(0,ct.Z)(e))),c.map((e=>(0,ct.Z)(e))));const h=[];this.chatInner.classList.add("zoom-fading");const u=i?10:40,f=i?0:1,p=(e,t=0)=>{const i=(0,ce.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=p(d,f),g=p(l),v=p(c,f),b=[m.animationPromise,g.animationPromise,v.animationPromise],y=[m.lastMsDelay,g.lastMsDelay,v.lastMsDelay];let w;return this.onAnimateLadder&&(yield this.onAnimateLadder()),(0,le.T2)((()=>{this.setStickyDateManually(),h.forEach((e=>{e.classList.remove("zoom-fade")}))})),(d.length||l.length||c.length)&&(w=Promise.all(b),(0,de.YW)(w,Math.max(...y)+200).then((()=>{(0,le.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 is(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,S.ag)("GroupEmptyTitle1"):"saved"===e?n=(0,S.ag)("ChatYourSelfTitle"):"noMessages"===e||"greeting"===e?n=(0,S.ag)("NoMessages"):"noScheduledMessages"===e?n=(0,S.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,S.ag)("GroupEmptyTitle2")),a=[(0,S.ag)("GroupDescription1"),(0,S.ag)("GroupDescription2"),(0,S.ag)("GroupDescription3"),(0,S.ag)("GroupDescription4")];else if("saved"===e)a=[(0,S.ag)("ChatYourSelfDescription1"),(0,S.ag)("ChatYourSelfDescription2"),(0,S.ag)("ChatYourSelfDescription3"),(0,S.ag)("ChatYourSelfDescription4")];else if("greeting"===e){const e=(0,S.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=>is(this,void 0,void 0,(function*(){if(!n())return;const i=[];return yield(0,V.ZP)({doc:e,div:t,middleware:n,lazyLoadQueue:this.lazyLoadQueue,group:this.chat.animationGroup,play:!0,loop:!0,withThumb:!0,loadPromises:i}),(0,w.fc)(t,(e=>{(0,be.Z)(e),vt.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 is(this,void 0,void 0,(function*(){const s=!!e.pFlags.sponsored,n=(0,gt.Z)(i);return this.safeRenderMessage(e,!s,void 0,!1,(i=>is(this,void 0,void 0,(function*(){const{bubble:a}=yield n(i);if(!a)return i;a.message=e,a.classList.add("is-group-last","is-group-first");const o=()=>{this.updatePlaceholderPosition===o&&(this.updatePlaceholderPosition=void 0),u[f](a)};s||(a.classList.add("bubble-first"),a.classList.remove("can-have-tail","is-in"));const r=[],l=this.chat.isBot;let c,u=this.container,f="append";if(this.chat.isRestricted)c=this.renderEmptyPlaceholder("restricted",a,e,r);else if(s){let i,s,n,o;a.classList.add("avoid-selection"),a.style.order="999999";const r=this.sponsoredMessage=e.sponsoredMessage,d=(0,F.Z)(r.from_id);r.channel_post?(i="OpenChannelPost",s=(0,ht.Z)(r.channel_post)):r.start_param||l?(i="Chat.Message.ViewBot",n=r.start_param):i=(yield this.managers.appPeersManager.isAnyGroup(d))?"Chat.Message.ViewGroup":"Chat.Message.ViewChannel",o=r.chat_invite?()=>{new Ue(r.chat_invite_hash,r.chat_invite)}:r.chat_invite_hash?()=>{const e={_:Me.JOIN_CHAT,invite:r.chat_invite_hash};this.chat.appImManager.processInternalLink(e)}:()=>{this.chat.appImManager.setInnerPeer({peerId:d,lastMsgId:s,startParam:n})};const c=(0,Re.Z)("btn-primary btn-primary-transparent bubble-view-button",{text:i});this.observer.observe(c,this.viewsObserverCallback),o&&(0,w.fc)(c,o),a.querySelector(".bubble-content").prepend(c),u=this.chatInner,f="append",t=!1}else if(l&&"message"===e._){const e=document.createElement("b");e.append((0,S.ag)("BotInfoTitle")),r.push(e,"\n\n"),u=this.chatInner,f="prepend"}else c=this.chat.isAnyGroup&&(yield n(this.managers.appPeersManager.getPeer(this.peerId))).pFlags.creator?this.renderEmptyPlaceholder("group",a,e,r):"scheduled"===this.chat.type?this.renderEmptyPlaceholder("noScheduledMessages",a,e,r):d.Z.myId===this.peerId?this.renderEmptyPlaceholder("saved",a,e,r):this.peerId.isUser()&&!l&&(yield n(this.chat.canSend()))&&"chat"===this.chat.type?this.renderEmptyPlaceholder("greeting",a,e,r):this.renderEmptyPlaceholder("noMessages",a,e,r);c&&(yield c),r.length&&a.querySelector(".message, .service-msg").prepend(...r);const p=!!this.messagesQueueOnRenderAdditional,m=this.setPeerCached&&!p;if(m){const e=a.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),p||t?(this.updatePlaceholderPosition=o,this.onAnimateLadder=()=>{if(this.onAnimateLadder=void 0,!this.messagesQueuePromise)return(0,le.AD)()}):this.chat.setPeerPromise?this.attachPlaceholderOnRender=()=>{this.attachPlaceholderOnRender=void 0,o()}:this.updatePlaceholderPosition=o,!p&&t){yield n((0,de.e9)());const t=(0,Je.Z)(this.bubbles);(0,h.Z)(t,e.mid),this.animateAsLadder(e.mid,t,!1,0,0)}return a.middlewareHelper.onDestroy((()=>{this.emptyPlaceholderBubble===a&&(this.emptyPlaceholderBubble=void 0)})),this.emptyPlaceholderBubble=a,i}))))}))}generateLocalMessageId(e=0){const t=("scheduled"===this.chat.type?-1:0)+e,i=-Math.abs(t);return{id:i,mid:-Math.abs((0,ht.Z)(i))}}generateLocalFirstMessage(e,t,i=0){return is(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,Le.Z)(a),t&&t(a),a=(yield this.managers.appMessagesManager.saveMessages([a],{storage:new Map}))[0],a.mid=n,a}))}getViewportSlice(){return(0,Xe.Z)({overflowElement:this.scrollable.container,selector:".bubbles-date-group .bubble:not(.is-date)",extraSize:2*Math.max(700,Pe.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(k.IS_SAFARI||this.isHeavyAnimationInProgress&&!e)return;const t=this.getViewportSlice();this.deleteViewportSlice(t)}setLoaded(e,t,i=!0){return is(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 is(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=>is(this,void 0,void 0,(function*(){if(!e())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 is(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=>is(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}),t.description_photo&&(e.media={_:"messageMediaPhoto",photo:t.description_photo})}));return t()?(e("rendering"),{renderPromise:this.processLocalMessageRender(a,!i.cached).then((()=>{e("done")}))}):void 0}))));if(i.cached)return s}))}checkIfEmptyPlaceholderNeeded(){return is(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 is(this,void 0,void 0,(function*(){const o=this.peerId,r=this.chat.isBroadcast,l=Math.min(30,Pe.Z.height/40|0);let c=r?20:Object.keys(this.bubbles).length>0?Math.max(35,l):l;if(void 0!==os){if(!os)return{cached:!1,promise:Promise.resolve(),waitPromise:Promise.resolve()};Object.keys(this.bubbles).length>0&&--os}let h,u=0;if(i&&(u=c,t||(c=0)),s&&!i)if("pinned"===this.chat.type)h=[s];else{const t=(yield this.chat.getHistoryStorage()).history.slice;if(t.length<c&&!t.isEnd(ue.D.Both)){h=t.slice();for(let e=h.length-1;e>=0;--e){const t=yield this.chat.getMessage(h[e]);if(!(null==t?void 0:t.grouped_id))break;h.splice(e,1)}e=h[h.length-1]||e}}let f,p=yield this.requestHistory(e,c,u);const m=(null==h?void 0:h.length)&&!p.cached,g=this.isFirstLoad&&u&&!p.cached||m;m&&(f=p.result,p={cached:!0,result:Promise.resolve({history:h})}),this.isFirstLoad=!1;const v=e=>is(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)}})),b=e=>(0,de.e9)().then((()=>v(e))).then((()=>(!m&&s&&e.history.unshift(s),this.performHistoryResult(e,t)))),y=e=>{const t=Promise.resolve(e).then((e=>{if(a&&!a())throw ls;if(!n)return b(e);this.scrollable.onScroll()}),(e=>{throw this.log.error("getHistory error:",e),e}));return t};let w,S;if(p.cached){if(n)return this.scrollable.onScroll(),null;S=!0,w=b(yield p.result)}else S=!1,w=y(p.result);const C=m?y(f):w;if(g&&d.Z.settings.animationsEnabled){let i=m?2:1;this.messagesQueueOnRenderAdditional=()=>{this.log("messagesQueueOnRenderAdditional"),--i||(this.messagesQueueOnRenderAdditional=void 0,this.animateAsLadder(s,h,m,u,e).then((()=>{setTimeout((()=>{this.loadMoreHistory(t,!0)}),0)})))}}else this.messagesQueueOnRenderAdditional=void 0;return n?null:{cached:S,promise:w,waitPromise:C}}))}setUnreadDelimiter(){return is(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?ds: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 ps(){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}var ms=i(3003),gs=i(5128),vs=i(8127);class bs{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,s=function*(){const{peerId:e,mid:t,unpin:i,onConfirm:s}=this;let n,a,o;const r=[],l=[],c=y.Z.MANAGERS,h=yield c.appPeersManager.canPinMessage(e),u=(n,a,o)=>{setTimeout((()=>{let n;n=i&&!t?h?c.appMessagesManager.unpinAllMessages(e):c.appMessagesManager.hidePinnedMessages(e):c.appMessagesManager.updatePinnedMessage(e,t,i,o,a),s&&n.then(s)}),300)};if(i){let i="UnpinMessage";t?(n="UnpinMessageAlertTitle",a="Chat.Confirm.Unpin"):h?(n="Popup.Unpin.AllTitle",a="Chat.UnpinAllMessagesConfirmation",o=[""+((yield c.appMessagesManager.getPinnedMessagesCount(e))||1)]):(n="Popup.Unpin.HideTitle",a="Popup.Unpin.HideDescription",i="Popup.Unpin.Hide"),r.push({langKey:i,isDanger:!0,callback:u})}else{n="PinMessageAlertTitle";const t="PinMessage";e.isAnyChat()?(r.push({langKey:t,callback:e=>u(0,!1,!e.size)}),(yield c.appChatsManager.isBroadcast(e.toChatId()))?a="PinMessageAlertChannel":(a="PinMessageAlert",l.push({text:"PinNotify",checked:!0}))):(a="PinMessageAlertChat",e===d.Z.myId?r.push({langKey:t,callback:u}):(r.push({langKey:t,callback:e=>u(0,!e.size)}),l.push({text:"PinAlsoFor",textArgs:[new R.Z({peerId:e}).element],checked:!0})))}(0,y.x)(r),new vs.Z("popup-delete-chat",{peerId:e,titleLangKey:n,descriptionLangKey:a,descriptionLangArgs:o,buttons:r,checkboxes:l}).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=i(1962);function ws(e=window.getSelection()){if(!(null==e?void 0:e.rangeCount))return!0;const t=e.getRangeAt(0);return!(!t.collapsed&&t.START_TO_END)}var Ss=i(2312),Cs=i(1447),Ls=i(671),Es=i(3174);function Is(e,t,i){return d.Z.managers.appStickersManager.preloadAnimatedEmojiSticker(e).then((({doc:s})=>{if(s)return Ss.Z.downloadMedia({media:s}).then((n=>{return a=this,r=void 0,l=function*(){const a=o.Z.active.emojiSticker,r=(0,Ls.tB)(e),d=yield Cs.Z.loadAnimationWorker({container:void 0,animationData:n,width:null!=t?t:a.width,height:null!=i?i:a.height,name:"doc"+s.id,autoplay:!1,loop:!1,toneIndex:r},"none");d.addEventListener("firstFrame",(()=>{(0,Es.O)(s,d.canvas[0],r),d.remove()}),{once:!0})},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(a,r||[])).next())}));var a,r,d,l}))}))}var Ms=i(5772);class Ps extends vs.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,me.bC)({langPackKey:"ReportSentInfo"})})))}}],body:!0});const n=document.createElement("div");(0,Ms.Z)({div:n,emoji:Ps.STICKER_EMOJI,width:100,height:100}).then((({render:e})=>e)).finally((()=>{this.show()})),this.header.append(n);const a=new C.ZP({label:"ReportHint",maxLength:512,placeholder:"ReportChatDescription"});a.input.addEventListener("input",(()=>{this.buttons[0].element.toggleAttribute("disabled",!a.isValid())})),this.body.append(a.container)}}Ps.STICKER_EMOJI="👮‍♀️";class Zs extends vs.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,Re.Z)("btn-primary btn-transparent",{text:e[0]});this.body.append(t)}));const n=Is(Ps.STICKER_EMOJI);(0,w.fc)(this.body,(a=>{const o=(0,fe.Z)(a.target,"btn-primary"),r=s[(0,Se.Z)(o)][1];n.then((()=>{this.hide(),new Ps(e,t,r,i)}))}),{listenerSetter:this.listenerSetter}),this.buttonsEl.style.marginTop=".5rem",this.show()}}class ks extends vs.Z{constructor(){super("popup-sponsored",{titleLangKey:"Chat.Message.Sponsored.What",descriptionLangKey:"Chat.Message.Ad.Text",descriptionLangArgs:[(0,S.ag)("Chat.Message.Sponsored.Link")],buttons:[{langKey:"OK",isCancel:!0},{langKey:"Chat.Message.Ad.ReadMore",callback:()=>{window.open(S.ZP.format("Chat.Message.Sponsored.Link",!0))},isCancel:!0}],scrollable:!0}),this.scrollable.append(this.description),this.show()}}var Ts=i(6008),xs=i(8936),As=i(3061),_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())}))};class Fs extends y.Z{constructor(e){super("popup-reacted-list",{closable:!0,overlayClosable:!0,body:!0}),this.message=e,this.init()}init(){return _s(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 qe,a=Object.assign(Object.assign({},t),{mid:0,id:0,reactions:Object.assign(Object.assign({_:"messageReactions",results:[]},t.reactions),{pFlags:{},recent_reactions:[]})});a.reactions.results=a.reactions.results.map((e=>Object.assign(Object.assign({},e),{chosen_order:void 0,pFlags:{}}))),s.init(a,"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 o=document.createElement("div");o.classList.add("tabs-container"),o.dataset.animation="tabs";const r=new Map;let d=!1;if(a.reactions.results.length){const e=this.createFakeReaction("reactions",a.reactions.results.reduce(((e,t)=>e+t.count),0));s.prepend(e),a.reactions.results.unshift(e.reactionCount),d=!0}let l=!1;if(i)try{const i=yield this.managers.appMessagesManager.getMessageReadParticipants(t.peerId,t.mid);if(!e())return;if(!i.length)throw"";const n=this.createFakeReaction("checks",i.length);s.prepend(n),a.reactions.results.unshift(n.reactionCount),l=!0}catch(e){}a.reactions.results.forEach((i=>{const s=new P.ZP(void 0);s.container.classList.add("tabs-tab");const a=new n.dw({noShadow:!0,noDelimiter:!0}),d=zi.default.createChatList({dialogSize:72});zi.default.setListClickListener(d,(()=>{this.hide()}),void 0,!1,!0),a.content.append(d),s.container.append(a.container);const l="checks"!==i.reaction,c="checks"===i.reaction;["checks","reactions"].includes(i.reaction)&&(i.reaction=void 0);const h=(0,Ve.C)(24,24);let u;const f=new xs.Z({scrollable:s,getPromise:()=>_s(this,void 0,void 0,(function*(){const s=yield this.managers.appMessagesManager.getMessageReactionsListAndReadParticipants(t,void 0,i.reaction,u,l,c);return u=s.nextOffset,yield Promise.all(s.combined.map((({peerId:t,reaction:i})=>_s(this,void 0,void 0,(function*(){const{dom:s}=zi.default.addDialogNew({peerId:t,autonomous:!0,container:d,avatarSize:"abitbigger",rippleEnabled:!1,meAsSaved:!1});if(i){const t=document.createElement("div");if(t.classList.add("reacted-list-reaction-icon"),"reactionEmoji"===i._){const s=yield this.managers.appReactionsManager.getReactionCached(i.emoticon);(0,V.ZP)({doc:s.static_icon,div:t,width:24,height:24,middleware:e})}else"reactionCustomEmoji"===i._&&t.append((0,je.Z)({docIds:[i.document_id],size:h,middleware:e}));s.listEl.append(t)}(0,O.Z)(s.lastMessageSpan,(0,As.Z)(yield this.managers.appUsersManager.getUser(t.toUserId())))}))))),!u}))});r.set(s.container,f),o.append(s.container)})),this.body.append(o);const c=(0,Ts.X)(s,o,((e,t)=>{if(e===s.childElementCount-1)return!1;const i=s.children[e],n=c.prevId();-1!==n&&s.children[n].setIsChosen(!1),i.setIsChosen(!0),r.get(t).load()}),void 0,void 0,void 0,this.listenerSetter);c(0,!1),this.show()}))}createFakeReaction(e,t){const i=new We;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}}const Ds="btn-menu-reactions-reaction",Rs=!k.IS_SAFARI;class Bs{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,fe.Z)(e.target,Ds);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("btn-menu-reactions-container"),n.classList.add("btn-menu-reactions-container-"+t);const a=this.container=document.createElement("div");a.classList.add("btn-menu-reactions");const o=this.scrollable="vertical"===t?new P.ZP(void 0):new P.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()}`,s.Z.setOverrideIdleGroup(this.animationGroup,!0),c.Z||a.addEventListener("mousemove",this.onMouseMove),(0,w.fc)(a,(e=>{const t=(0,fe.Z)(e.target,Ds);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,ve.k)()}init(e){this.message=e;const t=this.middleware.get(),i=this.managers.appReactionsManager.getAvailableReactionsByMessage(e);(0,ze.Z)(i,(e=>{if(!t()||!e.length)return;e.forEach((e=>{e.pFlags.premium&&!d.Z.premium||this.renderReaction(e)}));const s=()=>{this.container.classList.add("is-visible")};i instanceof Promise?(0,le.T2)(s):s()}))}cleanup(){this.middleware.clean(),this.scrollable.removeListeners(),this.reactionsMap.clear(),s.Z.setOverrideIdleGroup(this.animationGroup,!1),s.Z.checkAnimations(!0,this.animationGroup,!0)}canUseAnimations(){return d.Z.settings.animationsEnabled&&!k.IS_MOBILE}renderReaction(e){const t=document.createElement("div");t.classList.add(Ds);const i=document.createElement("div");i.classList.add(Ds+"-scale");const s=document.createElement("div");let n;s.classList.add(Ds+"-appear"),this.canUseAnimations()&&(n=document.createElement("div"),n.classList.add(Ds+"-select","hide"));const a={selectWrapper:n,appearWrapper:s,reaction:{_:"reactionEmoji",emoticon:e.reaction}};this.reactionsMap.set(t,a);const o=this.middleware.get(),r=26*(c.Z?1:1.25),d={width:r,height:r,skipRatio:1,needFadeIn:!1,withThumb:!1,group:this.animationGroup,middleware:o};if(this.canUseAnimations()){let t=!0;(0,V.ZP)(Object.assign({doc:e.appear_animation,div:s,play:!0},d)).then((({render:e})=>e)).then((e=>{(0,Le.Z)(e),a.appear=e,e.addEventListener("enterFrame",(o=>{e.maxFrame===o&&i.then((e=>{(0,Le.Z)(e),s.classList.add("hide"),n.classList.remove("hide"),t&&(a.select=e,t=!1)}),Ke.Z)}))}),Ke.Z);const i=(0,V.ZP)(Object.assign({doc:e.select_animation,div:n},d)).then((({render:e})=>e)).then((e=>((0,Le.Z)(e),Cs.Z.waitForFirstFrame(e)))).catch(Ke.Z)}else delete d.needFadeIn,delete d.withThumb,(0,V.ZP)(Object.assign({doc:e.static_icon,div:s},d));i.append(s),n&&i.append(n),t.append(i),this.scrollable.append(t)}onScrollProcessItem(e,t){const i=e.firstElementChild,s=(0,Be.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=""}Rs&&(i.style.transform=n)}}var Ns=i(1483),Os=i(2353),Us=i(6690),Hs=i(3709),zs=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 js{constructor(e,t){this.chat=e,this.managers=t,this.onContextMenu=e=>{let t,i;try{i=(0,fe.Z)(e.target,"bubble-content-wrapper"),t=i?i.parentElement:(0,fe.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&&(()=>{zs(this,void 0,void 0,(function*(){const a=this.isSponsored=n<0;if(this.isSelectable=this.chat.selection.canSelectBubble(t),this.peerId=this.chat.peerId,this.target=e.target,this.isTextSelected=!ws(),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.chat.selection.isSelecting&&!i){if(a)return;const e=yield this.chat.getMidsByMid(n);if(e.length>1){const t=this.chat.selection.isMidSelected(this.peerId,n)?n:e.find((e=>this.chat.selection.isMidSelected(this.peerId,e)));t&&(n=t)}}this.isOverBubble=!!i;const o=(0,fe.Z)(this.target,"grouped-item");this.isTargetAGroupedItem=!!o,this.mid=o?+o.dataset.mid:n,this.isSelected=this.chat.selection.isMidSelected(this.peerId,this.mid),this.message=t.message||(yield this.chat.getMessage(this.mid)),this.noForwards=!a&&!(yield this.managers.appMessagesManager.canForward(this.message)),this.viewerPeerId=void 0,this.canOpenReactedList=void 0;const r=yield this.init();if(!r)return;s=r.element;const{cleanup:d,destroy:l,menuPadding:c,reactionsMenu:h,reactionsMenuPosition:u}=r;let f=!1;if(h){const e="is-visible";if(f=h.container.classList.contains(e),f&&h.container.classList.remove(e),"horizontal"===u){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 p=t.classList.contains("is-in")?"left":"right";(0,Ns.Z)(e.touches?e.touches[0]:e,s,p,c),h&&(h.widthContainer.style.top=s.style.top,h.widthContainer.style.left=s.style.left,h.widthContainer.style.setProperty("--menu-width",s["vertical"===u?"offsetHeight":"offsetWidth"]+"px"),s.parentElement.append(h.widthContainer),f&&h.container.offsetLeft),mt.Z.openBtnMenu(s,(()=>{h&&h.container.classList.remove("is-visible"),this.mid=0,this.peerId=void 0,this.target=null,this.viewerPeerId=void 0,this.canOpenReactedList=void 0,d(),setTimeout((()=>{l()}),300)})),f&&h.container.classList.add("is-visible")}))})()},this.onSendScheduledClick=()=>zs(this,void 0,void 0,(function*(){this.chat.selection.isSelecting?(0,w.tH)(this.chat.selection.selectionSendNowBtn):new ys.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=()=>{this.chat.input.initMessageEditing(this.mid)},this.onCopyClick=()=>zs(this,void 0,void 0,(function*(){if(ws()){const e=this.chat.selection.isSelecting?[...this.chat.selection.selectedMids.get(this.peerId)].sort(((e,t)=>e-t)):[this.mid],t=(yield Promise.all(e.map((e=>zs(this,void 0,void 0,(function*(){const t=yield this.chat.getMessage(e);return(null==t?void 0:t.message)?t.message+"\n":""})))))).join("");(0,it.T)(t)}else document.execCommand("copy")})),this.onCopyAnchorLinkClick=()=>{(0,it.T)(this.target.href)},this.onCopyLinkClick=()=>zs(this,void 0,void 0,(function*(){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,ct.Z)(i);let o,r="https://t.me/";n?(r+=n+"/"+(e?(0,ct.Z)(e.fwd_from.channel_post):a),e&&(r+="?comment="+a),o="LinkCopied"):(r+="c/"+t.toChatId()+"/"+a,e&&(r+="?thread="+(0,ct.Z)(e.mid)),o="LinkCopiedPrivateInfo"),(0,me.Am)(S.ZP.format(o,!0)),(0,it.T)(r)})),this.onPinClick=()=>{new bs(this.peerId,this.mid)},this.onUnpinClick=()=>{new bs(this.peerId,this.mid,!0)},this.onRetractVote=()=>{this.managers.appPollsManager.sendVote(this.message,[])},this.onStopPoll=()=>{this.managers.appPollsManager.stopPoll(this.message)},this.onForwardClick=()=>zs(this,void 0,void 0,(function*(){if(this.chat.selection.isSelecting)(0,w.tH)(this.chat.selection.selectionForwardBtn);else{const e=this.peerId,t=this.isTargetAGroupedItem?[this.mid]:yield this.chat.getMidsByMid(this.mid);new E.Z({[e]:t})}})),this.onSelectClick=()=>{this.chat.selection.toggleByElement((0,fe.Z)(this.target,"grouped-item")||(0,fe.Z)(this.target,"bubble"))},this.onClearSelectionClick=()=>{this.chat.selection.cancelSelection()},this.onDeleteClick=()=>zs(this,void 0,void 0,(function*(){this.chat.selection.isSelecting?(0,w.tH)(this.chat.selection.selectionDeleteBtn):new gs.Z(this.peerId,this.isTargetAGroupedItem?[this.mid]:yield this.chat.getMidsByMid(this.mid),this.chat.type)})),this.listenerSetter=new ae.Z,this.attachListenerSetter=new ae.Z,this.middleware=(0,ve.k)()}attachTo(e){this.attachListenerSetter.removeAll(),c.Z?(0,w.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,be.Z)(e),this.onContextMenu(e)))}),{listenerSetter:this.attachListenerSetter}):(0,pt.E)(e,this.onContextMenu,this.attachListenerSetter)}cleanup(){this.listenerSetter.removeAll(),this.reactionsMenu&&this.reactionsMenu.cleanup(),this.middleware.clean()}destroy(){this.cleanup(),this.attachListenerSetter.removeAll()}filterButtons(e){return zs(this,void 0,void 0,(function*(){return this.isSponsored?e.filter((e=>e.isSponsored)):(0,Os.Z)(e,(e=>zs(this,void 0,void 0,(function*(){let t;return this.chat.selection.isSelecting&&!e.withSelection?t=!1:(this.isOverBubble||c.Z,t=yield e.verify()),!!t}))))}))}setButtons(){const e=e=>zs(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,Le.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:()=>zs(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:()=>e(!0)},{icon:"favourites",text:"DeleteFromFavorites",onClick:this.onFaveStickerClick.bind(this,!0),verify:()=>e(!1)},{icon:"edit",text:"Edit",onClick:this.onEditClick,verify:()=>zs(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:()=>zs(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,it.T)(this.target.innerHTML)},verify:()=>this.isUsernameTarget,withSelection:!0},{icon:"copy",text:"Text.Context.Copy.Hashtag",onClick:()=>{(0,it.T)(this.target.innerHTML)},verify:()=>this.target.classList.contains("anchor-hashtag"),withSelection:!0},{icon:"link",text:"MessageContext.CopyMessageLink1",onClick:this.onCopyLinkClick,verify:()=>zs(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:()=>zs(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:()=>zs(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:()=>{Ss.Z.downloadToDisc({media:(0,lt.Z)(this.message)})},verify:()=>{var e,t;if(!(0,Hs.Z)(this.message)||this.noForwards)return!1;let i=!1;if(null===(e=this.message.media)||void 0===e?void 0:e.photo)i=!0;else{if(!(null===(t=this.message.media)||void 0===t?void 0:t.document))return!1;i=!0}let s=!!c.Z;return i&&(s||(s=!!((0,fe.Z)(this.target,"document")||(0,fe.Z)(this.target,"audio")||(0,fe.Z)(this.target,"media-sticker-wrapper")||(0,fe.Z)(this.target,"media-photo")||(0,fe.Z)(this.target,"media-video")))),i&&s}},{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:()=>zs(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!==m.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:"flag",text:"ReportChat",onClick:()=>{new Zs(this.peerId,[this.mid])},verify:()=>zs(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.chat.appImManager.setInnerPeer({peerId:this.viewerPeerId});else{if(!this.canOpenReactedList)return!1;new Fs(this.message)}},verify:()=>zs(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:()=>zs(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:()=>{new ks},verify:()=>!1,isSponsored:!0},{text:"Loading",onClick:()=>{this.emojiInputsPromise.then((e=>{new I.Z(e,!0).show()}))},verify:()=>!!this.getUniqueCustomEmojisFromMessage(this.message).length,notDirect:()=>!0,localName:"emojis"}]}getUniqueCustomEmojisFromMessage(e){const t=[],i=e.entities;if(i){const e=i.filter((e=>"messageEntityCustomEmoji"===e._));t.push(...e.map((e=>e.document_id)))}const s=e.reactions;if(s){const e=s.results.filter((e=>"reactionCustomEmoji"===e.reaction._));t.push(...e.map((e=>e.reaction.document_id)))}return(0,Us.Z)(t)}init(){return zs(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=(0,ms.Z)(e,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 S.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,S.ag)("Chat.Context.ReactedFast",[a]):(0,S.ag)(t.length===n?"Chat.Context.ReactedFast":"Chat.Context.Reacted",[t.length,n]):(0,S.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 h=this.middleware.get();this.managers.appMessagesManager.getMessageReactionsListAndReadParticipants(this.message).then((e=>{if(!h())return;r&&r.remove();const a=e.combined,u=void 0===n?e.reactionsCount:s?a.filter((e=>e.reaction)).length:a.length;let f;if(1===a.length)f=new R.Z({peerId:a[0].peerId,onlyFirstName:!0,dialog:!1}).element,(!s||e.readParticipants.length<=1)&&(this.viewerPeerId=a[0].peerId);else if(s){const e=u===a.length||void 0===n;f=(0,S.ag)(e?"Chat.Context.ReactedFast":"Chat.Context.Reacted",e?[u]:[u,a.length])}else a.length?f=(0,S.ag)("MessageSeen",[a.length]):o.element.style.visibility="";if(f&&(f.style.paddingRight=c*Math.min(l,u)+"rem",f.classList.add("btn-menu-item-text-fake"),i.element.append(f)),a.length){const e=new X({avatarSize:d});e.render(t?t.map((e=>(0,F.Z)(e.peer_id))):a.map((e=>e.peerId))),i.element.append(e.container),this.canOpenReactedList=!0}}))}let s,n,a;if(!("message"!==this.message._||this.chat.selection.isSelecting||this.message.pFlags.is_outgoing||this.message.pFlags.is_scheduled||this.message.pFlags.local)){a=k.IS_APPLE||c.Z?"horizontal":"vertical",n=this.reactionsMenu=new Bs(this.managers,a,this.middleware),n.init(yield this.managers.appMessagesManager.getGroupsFirstMessage(this.message));const e=44,t=0,i=0;s="vertical"===a?{top:t,left:e}:{top:e,right:i,left:t}}const o=e.find((e=>"emojis"===e.localName));if(o){o.element.classList.add("is-multiline"),o.element.parentElement.insertBefore(document.createElement("hr"),o.element);const e=()=>{null!=s||(s={}),s.bottom=24},t=this.getUniqueCustomEmojisFromMessage(this.message),i=this.emojiInputsPromise=(0,ce.Z)();yield this.managers.appEmojiManager.getCachedCustomEmojiDocuments(t).then((s=>zs(this,void 0,void 0,(function*(){const n=t=>zs(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,S.ag)("MessageContainsEmojiPack",[(0,D.Z)(e.set.title)]);(0,O.Z)(o.textElement,t)}));return t.cached?i:void e()}(0,O.Z)(o.textElement,(0,S.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(),n&&n.cleanup()},destroy:()=>{t.remove(),n&&n.widthContainer.remove()},menuPadding:s,reactionsMenu:n,reactionsMenuPosition:a}}))}}var Gs=i(4329),Vs=i.n(Gs),Ks=i(9043);class Ws{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,ms.Z)(this.sendMenuButtons,e.listenerSetter),this.sendMenu.classList.add("menu-send",e.openSide),(0,pt.E)(e.onContextElement,(t=>{e.onOpen&&!e.onOpen()||(this.sendMenuButtons.forEach((e=>{e.element.classList.toggle("hide",!e.verify())})),(0,be.Z)(t),mt.Z.openBtnMenu(this.sendMenu))}),e.listenerSetter)}setPeerId(e){this.type=e===d.Z.myId?"reminder":"schedule"}}var $s=i(1293),qs=i(9336),Qs=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 Ys extends y.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,pe.Z)(t,"LABEL"),s=(0,$s.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,pe.Z)(t,"LABEL"),s=(0,Se.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),S.ZP.weakMap.get(e.label.firstElementChild).update()})),this.handleChange()},this.construct()}construct(){return Qs(this,void 0,void 0,(function*(){if(this.questionInputField=new C.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 Ws({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,S.$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,S.$d)(s,"Settings"),(yield this.chat.managers.appPeersManager.isBroadcast(this.chat.peerId))||(this.anonymousCheckboxField=new Ft.Z({text:"NewPoll.Anonymous",name:"anonymous"}),this.anonymousCheckboxField.input.checked=!0,i.append(this.anonymousCheckboxField.label)),this.multipleCheckboxField=new Ft.Z({text:"NewPoll.MultipleChoice",name:"multiple"}),this.quizCheckboxField=new Ft.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,S.$d)(a,"AccDescrQuizExplanation");const o=document.createElement("hr"),r=document.createElement("div");r.classList.add("poll-create-questions"),this.quizSolutionField=new C.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,S.$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,w.fc)(this.btnConfirm,this.onSubmitClick,{listenerSetter:this.listenerSetter}),this.scrollable=new P.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,qs.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,qs.Z)(this.quizSolutionField.input,!1,!1);return!(s.length>200)}handleChange(){const e=this.validate();this.btnConfirm.toggleAttribute("disabled",!e)}send(e=!1){return Qs(this,void 0,void 0,(function*(){const t=this.questionInputField.value,i=this.getFilledAnswers(),{value:s,entities:n}=(0,qs.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 C.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 Ei.Z({text:"",name:"question"});s.main.append(i.container),(0,w.fc)(i.input,be.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,Se.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,w.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 Js=i(7814);function Xs(e){let t,i;return e instanceof HTMLVideoElement?(t=e.videoWidth,i=e.videoHeight):(t=e.naturalWidth,i=e.naturalHeight),(0,Js.Z)({media:e,mediaSize:(0,Ve.C)(t,i),boxSize:(0,Ve.C)(320,240),quality:.9})}var en=i(9897),tn=i(2341);function sn(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 nn=i(7660),an=i(925),on=i(3855),rn=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 dn;function ln(){return dn}class cn extends y.Z{constructor(e,t,i){super("popup-send-photo popup-new-media",{closable:!0,withConfirm:"Modal.Send",confirmShortcutIsSendShortcut:!0,body:!0,title:!0}),this.chat=e,this.files=t,this.onKeyDown=e=>{const t=e.target;if(t!==this.input){if("INPUT"===t.tagName||t.isContentEditable)return;this.input.focus(),(0,Tt.Z)(this.input)}},this.attachFile=e=>{const t=this.willAttach,i=this.shouldCompress(e.type),s={};s.file=e;const n=document.createElement("div");n.classList.add("popup-item"),s.itemDiv=n;const a=i?this.attachMedia(s,n):this.attachDocument(s,n);return t.sendFileDetails.push(s),a},this.construct(i)}construct(e){return rn(this,void 0,void 0,(function*(){this.willAttach={type:e,sendFileDetails:[],group:!1};const t=yield this.managers.apiManager.getConfig();if(this.captionLengthMax=t.caption_length_max,(0,w.fc)(this.btnConfirm,(()=>this.send()),{listenerSetter:this.listenerSetter}),"scheduled"!==this.chat.type){const e=new Ws({onSilentClick:()=>{this.chat.input.sendSilent=!0,this.send()},onScheduleClick:()=>{this.chat.input.scheduleSending((()=>{this.send()}))},openSide:"bottom-left",onContextElement:this.btnConfirm,listenerSetter:this.listenerSetter});e.setPeerId(this.chat.peerId),this.header.append(e.sendMenu)}this.mediaContainer=document.createElement("div"),this.mediaContainer.classList.add("popup-photo");const i=new P.ZP(null);i.container.append(this.mediaContainer),this.inputField=new C.ZP({placeholder:"PreviewSender.CaptionPlaceholder",label:"Caption",name:"photo-caption",maxLength:this.captionLengthMax,withLinebreaks:!0}),this.input=this.inputField.input,this.inputField.value=this.wasInputValue=this.chat.input.messageInputField.input.innerHTML,this.chat.input.messageInputField.value="",this.body.append(i.container),this.container.append(this.inputField.container),this.attachFiles(),this.addEventListener("close",(()=>{this.files=[],dn=void 0})),dn=this}))}appendDrops(e){this.body.append(e)}get type(){return this.willAttach.type}set type(e){this.willAttach.type=e}appendGroupCheckboxField(){var e;const t=this.files.length>1;t&&!this.groupCheckboxField?(this.groupCheckboxField=new Ft.Z({text:"PreviewSender.GroupItems",name:"group-items"}),this.container.append(...[this.groupCheckboxField.label,null===(e=this.mediaCheckboxField)||void 0===e?void 0:e.label,this.inputField.container].filter(Boolean)),this.willAttach.group=!0,this.groupCheckboxField.setValueSilently(this.willAttach.group),this.listenerSetter.add(this.groupCheckboxField.input)("change",(()=>{const e=this.groupCheckboxField.checked;this.willAttach.group=e,this.attachFiles()}))):this.groupCheckboxField&&this.groupCheckboxField.label.classList.toggle("hide",!t)}appendMediaCheckboxField(){var e;const t=!!this.files.find((e=>tn.Z.has(e.type)));t&&!this.mediaCheckboxField?(this.mediaCheckboxField=new Ft.Z({text:"PreviewSender.CompressFile",name:"compress-items"}),this.container.append(...[null===(e=this.groupCheckboxField)||void 0===e?void 0:e.label,this.mediaCheckboxField.label,this.inputField.container].filter(Boolean)),this.mediaCheckboxField.setValueSilently("media"===this.willAttach.type),this.listenerSetter.add(this.mediaCheckboxField.input)("change",(()=>{const e=this.mediaCheckboxField.checked;this.willAttach.type=e?"media":"document",this.attachFiles()}))):this.mediaCheckboxField&&this.mediaCheckboxField.label.classList.toggle("hide",!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){if("scheduled"===this.chat.type&&!e)return void this.chat.input.scheduleSending((()=>{this.send(!0)}));let t=this.inputField.value;if(t.length>this.captionLengthMax)return void(0,me.Am)(S.ZP.format("Error.PreviewSender.CaptionTooLong",!0));this.hide();const i=this.willAttach;i.isMedia="media"===i.type||void 0;const{sendFileDetails:s,isMedia:n}=i,{peerId:a,input:o}=this.chat;s.forEach((e=>{e.itemDiv=void 0}));const{length:r}=s,d=this.chat.getMessageSendingParams();this.iterate((e=>{t&&e.length!==r&&(this.managers.appMessagesManager.sendText(a,t,Object.assign(Object.assign({},d),{clearDraft:!0})),t=void 0);const s=Object.assign(Object.assign({},i),{sendFileDetails:e});this.managers.appMessagesManager.sendAlbum(a,s.sendFileDetails.map((e=>e.file)),Object.assign(Object.assign(Object.assign({},d),{caption:t,isMedia:n,clearDraft:!0}),s)),t=void 0})),o.replyToMsgId=this.chat.threadId,o.onMessageSent()}attachMedia(e,t){return rn(this,void 0,void 0,(function*(){t.classList.add("popup-item-media");const i=e.file;let s;if(i.type.startsWith("video/")){const n=(0,nn.Z)(),a=document.createElement("source");a.src=e.objectURL=yield on.Z.invoke("createObjectURL",i),n.autoplay=!0,n.controls=!1,n.muted=!0,n.addEventListener("timeupdate",(()=>{n.pause()}),{once:!0}),s=(0,an.Z)(n).then((()=>rn(this,void 0,void 0,(function*(){e.width=n.videoWidth,e.height=n.videoHeight,e.duration=Math.floor(n.duration);const i=n.webkitAudioDecodedByteCount;void 0!==i&&(e.noSound=!i),t.append(n);const s=yield function(e){return new Promise(((t,i)=>{e.onseeked=()=>{e.onseeked=()=>{Xs(e).then(t),e.onseeked=void 0},e.currentTime=0},e.onerror=i,e.currentTime=Math.min(e.duration,1)}))}(n);e.thumb=Object.assign({url:yield on.Z.invoke("createObjectURL",s.blob)},s)})))),n.append(a)}else{const n=new Image;s=new Promise((s=>{n.onload=()=>{e.width=n.naturalWidth,e.height=n.naturalHeight,t.append(n),"image/gif"===i.type?(e.noSound=!0,Promise.all([sn(n).then((t=>{e.duration=Math.ceil(t)})),Xs(n).then((t=>rn(this,void 0,void 0,(function*(){e.thumb=Object.assign({url:yield on.Z.invoke("createObjectURL",t.blob)},t)}))))]).then((()=>{s()}))):s()}})),n.src=e.objectURL=yield on.Z.invoke("createObjectURL",i)}return s}))}attachDocument(e,t){return rn(this,void 0,void 0,(function*(){t.classList.add("popup-item-document");const i=e.file,s=i.type.startsWith("image/"),n=i.type.startsWith("audio/");(s||n||i.size<2e7)&&(e.objectURL=yield on.Z.invoke("createObjectURL",i));const a={_:"document",file:i,file_name:i.name||"",size:i.size,type:s?"photo":"doc"};let o;e.objectURL&&(o={url:e.objectURL,downloaded:i.size,type:m.Pt});const r=yield(0,Oi.Z)({message:{_:"message",pFlags:{is_outgoing:!0},mid:0,peerId:0,media:{_:"messageMediaDocument",document:a}},cacheContext:o});return new Promise((i=>{const n=()=>{t.append(r),i()};if(s){const t=new Image;t.src=e.objectURL,t.onload=()=>{e.width=t.naturalWidth,e.height=t.naturalHeight,n()},t.onerror=n}else n()}))}))}shouldCompress(e){return"media"===this.willAttach.type&&tn.Z.has(e)}onRender(){this.element.classList.contains("active")||(this.listenerSetter.add(document.body)("keydown",this.onKeyDown),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,O.Z)(t,(0,S.ag)(s,n))}appendMediaToContainer(e,t){if(this.shouldCompress(t.file.type)){const i=(0,en.Z)(t.width,t.height,380,320);e.style.width=i.width+"px",e.style.height=i.height+"px"}this.mediaContainer.append(e)}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;t.sendFileDetails.length=0,this.appendGroupCheckboxField(),this.appendMediaCheckboxField(),Promise.all(e.map(this.attachFile)).then((()=>{i.innerHTML="",e.length&&(this.setTitle(),this.iterate((e=>{if(this.shouldCompress(e[0].file.type)&&e.length>1){const t=document.createElement("div");t.classList.add("popup-item-album","popup-item"),t.append(...e.map((e=>e.itemDiv))),Bi({container:t,items:e.map((e=>({w:e.width,h:e.height}))),maxWidth:380,minWidth:100,spacing:4}),i.append(t)}else e.forEach((e=>{this.appendMediaToContainer(e.itemDiv,e)}))})))})).then((()=>{this.onRender()}))}}var hn=i(6057);const un="keydown",fn="active",pn=["ArrowUp","ArrowDown"],mn=["ArrowLeft","ArrowRight"];function gn({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?pn.concat(mn):"x"===t?mn:pn);let r;const d=()=>r||e.querySelector(".active")||e.firstElementChild,l=(e,i)=>{if(r===e)return;let s=!1;r&&(s=!0,r.classList.remove(fn)),r=e,r&&(r.classList.add(fn),s&&f&&i&&(0,re.Z)({container:f,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,be.Z)(i),e.childElementCount>1){let e=d();e=h(e,s),l(e,!0)}}else("Enter"===s||"xy"!==t&&"Tab"===s)&&((0,be.Z)(i),g(d()))};const f=(0,fe.Z)(e,"scrollable");e.classList.add("navigable-list");const p=t=>{const i=(0,_e.Z)(t.target,e);i&&l(i,!1)},m=t=>{(0,be.Z)(t);const i=(0,_e.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)&&y()},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=!1;const b=()=>{v||(v=!0,document.addEventListener(un,u,{capture:!0,passive:!1}),e.addEventListener("mousemove",p,{passive:!0}),(0,w.fc)(e,m))},y=()=>{v&&(v=!1,document.removeEventListener(un,u,{capture:!0}),e.removeEventListener("mousemove",p),(0,w.EN)(e,m))},S=()=>{a||l(e.firstElementChild,!1)};if(a){const e=u;u=t=>{a.has(t.key)&&((0,be.Z)(t),document.removeEventListener(un,u,{capture:!0}),u=e,document.addEventListener(un,u,{capture:!0,passive:!1}),a=void 0,S())}}else S();return b(),{attach:b,detach:y,resetTarget:S}}var vn=i(9818),bn=i(5953);class yn extends l.Z{constructor(e){super(!1),this.hidden=!0,this.onVisible=()=>{this.detach&&this.detach();const e=this.list,{attach:t,detach:i,resetTarget:s}=gn({list:e,type:this.listType,onSelect:this.onSelect,once:!0,waitForKey:this.waitForKey});this.attach=t,this.detach=i,this.resetTarget=s,k.IS_MOBILE||this.navigationItem||(this.navigationItem={type:"autocomplete-helper",onPop:()=>{this.navigationItem=void 0,this.toggle(!0)},noBlurOnPop:!0},vn.Z.pushItem(this.navigationItem)),this.addEventListener("hidden",(()=>{this.resetTarget=void 0,this.attach=void 0,this.detach=void 0,e.innerHTML="",i(),this.navigationItem&&(vn.Z.removeItem(this.navigationItem),this.navigationItem=void 0)}),{once:!0})},(0,bn.Z)(this,e),this.container=document.createElement("div"),this.container.classList.add("autocomplete-helper","z-depth-1"),e.appendTo.append(this.container),this.attachNavigation(),this.controller&&this.controller.addHelper(this)}toggleListNavigation(e){e?this.attach&&this.attach():this.detach&&this.detach()}attachNavigation(){this.addEventListener("visible",this.onVisible)}toggle(e,t=!1,i){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&&(vn.Z.removeItem(this.navigationItem),this.navigationItem=void 0),!t&&this.controller&&this.controller.hideOtherHelpers(),this.detach&&this.detach()):(this.controller&&this.controller.hideOtherHelpers(this),this.dispatchEvent("visible"));const s=this.controller||e?0:2;e&&this.dispatchEvent("hiding"),(0,Te.Z)(this.container,"is-visible",!e,d.Z.settings.animationsEnabled&&!i?300:0,(()=>{this.hidden&&this.dispatchEvent("hidden")}),s)}}class wn extends yn{constructor(e,t,i,s){super({appendTo:e,controller:t,listType:"xy",onSelect:e=>{return t=this,i=void 0,n=function*(){return!(yield vt.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),d.Z.dispatchEvent("choosing_sticker",!0)})),this.addEventListener("hidden",(()=>{this.onChangeScreen&&(o.Z.removeEventListener("changeScreen",this.onChangeScreen),this.onChangeScreen=void 0,this.listenerSetter.removeAll(),this.listenerSetter=void 0),d.Z.dispatchEvent("choosing_sticker",!1)}))}checkEmoticon(e){const t=this.controller.getMiddleware();this.lazyLoadQueue&&this.lazyLoadQueue.clear(),Is(e),this.managers.appStickersManager.getStickersByEmoticon(e).then((e=>{if(!t())return;this.init&&(this.init(),this.init=null);const i=this.list.cloneNode();let s;this.lazyLoadQueue.clear(),s=e.length?new Promise((t=>{const s=[];e.forEach((e=>{i.append(this.superStickerRenderer.renderSticker(e,void 0,s))})),Promise.all(s).finally(t)})):Promise.resolve(),s.then((()=>{this.list.replaceWith(i),this.list=i,this.onChangeScreen||(this.onChangeScreen=()=>{const e=this.list.childElementCount*o.Z.active.popupSticker.width+(this.list.childElementCount-1);this.list.style.width=e+"px"},o.Z.addEventListener("changeScreen",this.onChangeScreen),this.listenerSetter=new ae.Z,(0,_i.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 P.ZP(this.container),this.lazyLoadQueue=new ne.Z,this.superStickerRenderer=new hn.vT(this.lazyLoadQueue,this.chat.animationGroup,this.managers)}}var Sn=i(2230),Cn=i(5322);const Ln=()=>{const e=new Date;return e.setHours(0,0,0,0),e},En=()=>{const e=new Date;return e.setFullYear(e.getFullYear()+1),e.setDate(e.getDate()-1),e};class In extends L{constructor(e,t,i){var s;if(super((s=e).getTime()>En().getTime()?new Date:s,t,{noButtons:!0,noTitle:!0,closable:!0,withConfirm:!0,minDate:Ln(),maxDate:En(),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,Re.Z)("btn-primary btn-secondary btn-primary-transparent primary",{text:"Schedule.SendWhenOnline"});this.body.append(e),(0,w.fc)(e,(()=>{t(Ie),this.hide()}))}}}var Mn=i(8119),Pn=i(8799),Zn=i(6760),kn=i(6299),Tn=i(6039);class xn extends yn{constructor(e,t,i,s){super({appendTo:e,controller:t,listType:"x",onSelect:e=>{i.onEmojiSelected((0,Tn.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 P.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.innerHTML="",e.forEach((e=>{(0,Tn.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}))}}class An extends yn{constructor(e,t,i,s){super({appendTo:e,controller:t,listType:"y",onSelect:s}),this.className=i,this.container.classList.add(An.BASE_CLASS,i)}init(){this.list=document.createElement("div"),this.list.classList.add(An.BASE_CLASS+"-list",this.className+"-list"),this.container.append(this.list),this.scrollable=new P.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.innerHTML="",e.forEach((e=>{const t=An.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=An.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 p.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,A.Z)(n,(0,D.Z)(e.name)):n.append(new R.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,A.Z)(s,(0,D.Z)(e.description)),i.append(s)}return i}}An.BASE_CLASS="autocomplete-peer-helper",An.BASE_CLASS_LIST_ELEMENT=An.BASE_CLASS+"-list-element";var _n=i(5082);function Fn(e,t,i){const s=[].concat(t.bot_info);let n;void 0!==i&&(n=new _n.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 Dn extends An{constructor(e,t,i,s){super(e,t,"commands-helper",(e=>{const t=e.querySelector(`.${An.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=Fn(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}}class Rn{constructor(){this.helpers=new Set,this.middleware=(0,ve.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 Bn=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 Nn extends An{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="";e.username?s="@"+e.username:(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=>Bn(this,void 0,void 0,(function*(){if(!n())return;const t=s.slice(1).toLowerCase(),i=e.map((e=>Bn(this,void 0,void 0,(function*(){const i=yield this.managers.appUsersManager.getUser(e);if(!i.username||i.username.toLowerCase()!==t)return{peerId:e,description:i.username?"@"+i.username:void 0}}))));this.render((yield Promise.all(i)).filter(Boolean))})))),!0}}var On=i(5494),Un=i(6339),Hn=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 zn extends Un.Z{constructor(e){super({element:document.createElement("div")}),this.onBodyTouchStart=e=>{const t=e.touches[0].target;(0,_e.Z)(t,this.element)||t===this.btnHover||((0,be.Z)(e),this.toggle(!1))},(0,bn.Z)(this,e),this.element.classList.add(zn.BASE_CLASS),this.element.style.display="none",this.attachButtonListener(this.btnHover,this.listenerSetter),this.listenerSetter.add(d.Z)("history_reply_markup",(({peerId:e})=>Hn(this,void 0,void 0,(function*(){this.peerId===e&&(this.checkAvailability()&&this.isActive()&&(yield this.render()),(0,de.e9)().then((()=>{this.checkForceReply()})))}))))}init(){return this.appendTo.append(this.element),this.listenerSetter.add(this)("open",(()=>Hn(this,void 0,void 0,(function*(){yield this.render(),c.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,w.fc)(this.element,(e=>{const t=(0,fe.Z)(e.target,"btn");if(!t)return;const i=t.dataset.type,{peerId:s}=this;"keyboardButtonRequestPhone"===i?(0,li.Z)({titleLangKey:"ShareYouPhoneNumberTitle",button:{langKey:"OK"},descriptionLangKey:"AreYouSureShareMyContactInfoBot"}).then((()=>{this.managers.appMessagesManager.sendContact(s,d.Z.myId)})):this.managers.appMessagesManager.sendText(s,t.dataset.text),this.toggle(!1)}),{listenerSetter:this.listenerSetter}),super.init()}checkForceReply(){return Hn(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 Hn(this,void 0,void 0,(function*(){return null!==(e=(yield this.managers.appMessagesManager.getHistoryStorageTransferable(this.peerId)).replyMarkup)&&void 0!==e?e:{_:"replyKeyboardHide"}}))}render(e){return Hn(this,void 0,void 0,(function*(){void 0===e&&(e=yield this.getReplyMarkup()),this.element.textContent="";for(const t of e.rows){const e=document.createElement("div");e.classList.add(zn.BASE_CLASS+"-row");for(const i of t.buttons){const t=document.createElement("button");t.classList.add(zn.BASE_CLASS+"-button","btn"),(0,A.Z)(t,(0,D.Z)(i.text)),t.dataset.text=i.text,t.dataset.type=i._,e.append(t)}this.element.append(e)}}))}checkAvailability(e){var t;return Hn(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()}}zn.BASE_CLASS="reply-keyboard";var jn=i(1080),Gn=i(8678),Vn=i(2830),Kn=i(515);const Wn="INLINE-HELPER";class $n extends yn{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,Kn.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)=>{return s=this,n=void 0,r=function*(){const s=this.controller.getMiddleware(),n=yield this.managers.appUsersManager.resolveUsername(t);if(!s())throw"PEER_CHANGED";if("user"!==n._)throw"NOT_A_BOT";const a=this.managers.appInlineBotsManager.getInlineResults(e,n.id,i).then((t=>{if(!s())throw"PEER_CHANGED";this.init&&(this.init(),this.init=null);const i=this.list.cloneNode();i.dataset.peerId=""+e,i.dataset.botId=""+n.id,i.dataset.queryId=""+t.query_id;const a=new jn.Z(null,Wn,this.scrollable,!1);this.lazyLoadQueue.clear(),this.superStickerRenderer.clear();const r=[],d=!!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 n=d?void 0:document.createElement("div");if(n&&(n.classList.add("inline-helper-result-preview"),t.append(n)),i.append(t),d)t.classList.add("grid-item");else{n.classList.add("empty"),(0,A.Z)(n,(0,D.Z)([...e.title.trim()][0]));const s=document.createElement("div");s.classList.add("inline-helper-result-title"),(0,A.Z)(s,(0,D.Z)(e.title));const a=document.createElement("div");a.classList.add("inline-helper-result-description"),(0,A.Z)(a,(0,ot.ZP)(e.description,{noCommands:!0,noLinks:!0})),t.append(s,a);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;n?(i=document.createElement("div"),n.append(i)):i=t,i.classList.add("media-container"),d&&i.classList.add("no-border-radius"),this.lazyLoadQueue.push({div:t,load:()=>Ss.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,Gn.Z)(e).then((e=>{(0,Vn.Z)(i,t,e,!0)}))}))})}}else{const i=e.document||e.photo;if(["sticker","gif"].includes(null==i?void 0:i.type)&&d)(0,Le.Z)(i),"gif"===i.type?a.add(i,t):"sticker"===i.type&&(t.classList.add("super-sticker"),this.superStickerRenderer.renderSticker(i,t,r),i.animated&&this.superStickerRenderer.observeAnimated(t));else if(i){const e=d?48:void 0;d&&t.classList.add("no-border-radius"),(0,G.Z)({photo:i,container:d?t:n,boxWidth:e,boxHeight:e,middleware:s,lazyLoadQueue:this.lazyLoadQueue,loadPromises:r})}}}return Promise.all(r).then((()=>{if(!s())return void a.clear();i.classList.toggle("is-gallery",d),i.classList.toggle("super-stickers",d),this.container.classList.toggle("is-gallery",d);const r=this.list.parentElement;if(r.textContent="",t.switch_pm){const i=(0,Re.Z)("btn-primary btn-secondary btn-primary-transparent primary");(0,A.Z)(i,(0,D.Z)(t.switch_pm.text)),(0,w.fc)(i,(i=>{this.chat.appImManager.setInnerPeer({peerId:e}),this.managers.appInlineBotsManager.switchToPM(e,n.id,t.switch_pm.start_param)})),r.append(i)}r.append(this.list=i),this.gifsMasonry&&this.gifsMasonry.detach(),this.gifsMasonry=a,a.attach(),this.onChangeScreen||(this.onChangeScreen=()=>{if(this.list.classList.contains("is-gallery")){const e=this.list.childElementCount*o.Z.active.popupSticker.width+(this.list.childElementCount-1);this.list.style.width=e+"px"}else this.list.style.width=""},o.Z.addEventListener("changeScreen",this.onChangeScreen)),this.onChangeScreen(),this.toggle(!t.results.length&&!t.switch_pm),this.scrollable.scrollTop=0}))}));return{user:n,renderPromise:a}},new((a=void 0)||(a=Promise))((function(e,t){function i(e){try{d(r.next(e))}catch(e){t(e)}}function o(e){try{d(r.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,o)}d((r=r.apply(s,n||[])).next())}));var s,n,a,r},this.container.classList.add("inline-helper"),this.addEventListener("visible",(()=>{setTimeout((()=>{this.scrollable.container.scrollTop=0}),0)})),this.checkQuery=(0,Ee.Z)(this._checkQuery,200,!0,!0),this.addEventListener("hidden",(()=>{this.onChangeScreen&&(o.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 P.ZP(this.container),this.lazyLoadQueue=new ne.Z,this.superStickerRenderer=new hn.vT(this.lazyLoadQueue,Wn,this.managers)}}var qn=i(8090),Qn=i(3013),Yn=i(5133);class Jn extends An{constructor(e,t,i){super(e,void 0,"bot-commands",(e=>{const i=e.querySelector(`.${An.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,ze.Z)(this.managers.appProfileManager.getProfile(e),(i=>{if(!t())return;const s=Fn(e.toPeerId(!1),i),n=50*s.length+8+24;this.container.style.setProperty("--height",n+"px"),this.render(s)}));this.toggle(!1)}}var Xn=i(8479),ea=(i(1544),i(7197)),ta=i(6241),ia=i(6535),sa=i(2821),na=i(3066);function aa(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 oa(e){return e.then(aa)}var ra=i(177),da=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 la{constructor(e,t,i){this.managers=e,this.onReady=t,this.onChange=i,this.middleware=(0,ve.k)(),this.listenerSetter=new ae.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;const i=e=>{e&&(t=this.avatar);const i=this.avatar!==t,s=!e&&i?2:0;(0,Te.Z)(this.closeBtn,"is-visible",e,300,void 0,s),i||(0,Te.Z)(t,"is-visible",!e,300,void 0,s)};(0,Cn.Z)({noRipple:!0,listenerSetter:this.listenerSetter,container:this.container},"top-right",e,(()=>{i(!0)}),(()=>{i(!1)})),e[0].element.classList.add("btn-menu-item-header"),this.btnMenu=this.container.firstElementChild,this.btnMenu.classList.add("scrollable","scrollable-y"),this.container.append(this.closeBtn)}updateButtons(e){return da(this,void 0,void 0,(function*(){const t=e.map(((e,t)=>da(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,S.ag)("Chat.SendAs.PersonalAccount")):e===this.peerId?s.append((0,S.ag)("VoiceChat.DiscussionGroup")):s.append(yield(0,ra.Z)(e.toChatId())),i.append(new R.Z({peerId:e}).element,s),{onClick:t?()=>da(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,h.Z)(t,e),t.unshift(e),this.updateButtons(t)};d.Z.settings.animationsEnabled?setTimeout(s,250):s(),this.managers.appMessagesManager.saveDefaultSendAs(t,e)})):void 0,textElement:i}})))),i=yield Promise.all(t),s=(0,ms.Z)(i);i.forEach(((t,i)=>{const s=e[i],n=new p.Z;n.classList.add("avatar-26","btn-menu-item-icon"),n.updateWithOptions({peerId:s}),i||n.classList.add("active"),t.element.prepend(n)})),Array.from(this.btnMenu.children).slice(1).forEach((e=>e.remove())),this.btnMenu.append(...Array.from(s.children))}))}updateAvatar(e,t){return da(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 p.Z;a.classList.add("new-message-send-as-avatar","avatar-30"),yield a.updateWithOptions({isDialog:!1,peerId:e}),(0,Te.Z)(a,"is-visible",!0,n,void 0,s),i&&(0,Te.Z)(i,"is-visible",!1,n,(()=>{i.remove()}),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,F.Z)(e.default_send_as):void 0))})))}updateManual(e){return da(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===l)),{container:s}=this,n=t.toChatId(),a=(yield oa(this.getDefaultSendAs())).result,o=e;a instanceof Promise&&(e=void 0);const r=o&&!e,l=this.updatingPromise=(0,ze.Z)(a,(t=>da(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,F.Z)(e)));this.sendAsPeerIds=s.slice(),(0,h.Z)(s,t),s.unshift(t),this.updateButtons(s)}));const a=()=>{this.onReady(s,e),this.addedListener||(this.listenerSetter.add(d.Z)("peer_full_update",(e=>{this.peerId===e&&this.update()})),this.addedListener=!0)};if(!r)return a;a()}))));return l.finally((()=>{this.updatingPromise===l&&(this.updatingPromise=void 0)})),r?void 0:l}))}update(e){return this.updateManual(e).then((e=>e&&e()))}setPeerId(e){this.middleware.clean(),this.updatingPromise=void 0,this.peerId=e}destroy(){this.container.remove(),this.setPeerId(),this.listenerSetter.removeAll()}}var ca=i(669),ha=i(6854);const ua=new RegExp(`(<span>${ha.Z}</span>)|(<br/?>)`,"g");class fa extends C.ZP{constructor(e){super(e),this.input.addEventListener("input",(()=>{this.updateInnerHTML(),this.onFakeInput()})),e.placeholder&&(0,S.$d)(this.inputFake,e.placeholder,void 0,"placeholder"),this.input.classList.add("scrollable","scrollable-y"),this.inputFake=document.createElement("div"),this.inputFake.contentEditable="true",this.inputFake.className=this.input.className+" input-field-input-fake"}onFakeInput(e=!0){const{scrollHeight:t}=this.inputFake,i=+this.input.style.height.replace("px","");if(i===t)return;const s=Math.round(50*Math.log(Math.abs(t-i)));this.input.style.transitionDuration=`${s}ms`,e&&(this.input.style.height=t?t+"px":"");const n="is-changing-height";(0,Te.Z)(this.input,n,!0,s,(()=>{this.input.classList.remove(n)}))}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>"),ca.Y&&(e=e.replace(ua,"")),this.inputFake.innerHTML=e}setValueSilently(e,t){super.setValueSilently(e,t),this.updateInnerHTML(),t||this.onFakeInput()}}var pa=i(9041);function ma(e){const t={};e.forEach((e=>t[e]=!1));const i=window.getSelection();if(!i.isCollapsed){const s=i.getRangeAt(0),n=s.commonAncestorContainer,a=document.createTreeWalker((n.nodeType===n.ELEMENT_NODE?n:n.parentElement).closest('[contenteditable="true"]'),NodeFilter.SHOW_ELEMENT,{acceptNode:e=>s.intersectsNode(e)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT});let o;for(;o=a.nextNode();)for(const i of e){if(t[i])continue;const e=pa.o[i];o.matches(e.match)&&(t[i]=!0)}}return t}var ga=i(6034),va=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 ba="Posting media content isn't allowed in this group.";class ya{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,be.Z)(e),this.recordCanceled=!0,this.recorder.stop(),Ks.Z.setKeepAlive(!1)},this.onEmoticonsOpen=()=>{const e=c.Z?"flip-icon":"active";this.btnToggleEmoticons.classList.toggle(e,!0)},this.onEmoticonsClose=()=>{const e=c.Z?"flip-icon":"active";this.btnToggleEmoticons.classList.toggle(e,!1)},this.scheduleSending=(e=this.sendMessage.bind(this,!0),t=new Date)=>va(this,void 0,void 0,(function*(){const{peerId:i}=this.chat,s=this.chat.bubbles.getMiddleware(),n=d.Z.myId!==i&&i.isUser()&&(yield this.managers.appUsersManager.isUserOnlineVisible(i));new In(t,(t=>{s()&&(t<=10+(Date.now()/1e3|0)&&(t=void 0),this.scheduleDate=t,e(),"scheduled"!==this.chat.type&&t&&setTimeout((()=>{s()&&(y.Z.getPopups(I.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,be.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];if(!ws(document.getSelection())&&s&&("KeyK"===i?this.appImManager.markupTooltip.showLinkEditor():this.applyMarkdown(s),(0,be.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;const{value:i,entities:s,caretPos:n}=(0,qs.Z)(this.messageInputField.input),a=(0,sa.Z)(i,s,!0),o=(0,ta.Z)(s,(0,ia.Z)(a));this.canRedoFromHTML&&!this.lockRedo&&this.messageInput.innerHTML!==this.canRedoFromHTML&&(this.canRedoFromHTML="",this.undoHistory.length=0);const r=(!(null===(t=this.editMessage)||void 0===t?void 0:t.media)||"messageMediaWebPage"===this.editMessage.media._)&&o.filter((e=>"messageEntityUrl"===e._||"messageEntityTextUrl"===e._));if(r.length)for(const e of r){let t;if("messageEntityTextUrl"===e._)t=e.url;else if(t=i.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=this.managers.appWebPagesManager.getWebPage(t).then((i=>{this.getWebPagePromise===e&&(this.getWebPagePromise=void 0),this.lastUrl===t&&("webPage"===i._?(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(i.trim()){const e=Date.now();e-this.lastTimeType>=6e3&&(this.lastTimeType=e,this.managers.appMessagesManager.setTyping(this.chat.peerId,{_:"sendMessageTypingAction"})),this.botCommands&&this.botCommands.toggle(!0)}else this.lastTimeType&&this.managers.appMessagesManager.setTyping(this.chat.peerId,{_:"sendMessageCancelAction"}),this.appImManager.markupTooltip&&this.appImManager.markupTooltip.hide(),document.activeElement===this.messageInput&&setTimeout((()=>{document.activeElement===this.messageInput&&this.resetCurrentFontFormatting()}),0);this.botCommands&&this.updateBotCommandsToggle(),this.editMsgId||this.saveDraftDebounced(),this.checkAutocomplete(i,n,o),this.updateSendBtn()},this.onEmojiSelected=(e,t)=>{const i=e.docId?{_:"messageEntityCustomEmoji",document_id:e.docId,length:e.emoji.length,offset:0}:(0,ea.Z)(e.emoji);this.insertAtCaret(e.emoji,i,t)},this.onBtnSendClick=e=>va(this,void 0,void 0,(function*(){if((0,be.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();if(e&&!(yield this.chat.canSend("send_media")))return void(0,me.Am)(ba);this.chatInput.classList.add("is-locked"),(0,Pn.Z)();let t=!1;if(!e){const e=yield this.managers.appProfileManager.getProfile(this.chat.peerId.toUserId());(null==e?void 0:e.pFlags.voice_messages_forbidden)&&((0,me.bC)({langPackKey:"Chat.SendVoice.PrivacyError",langPackArguments:[yield(0,Bt.Z)({peerId:this.chat.peerId})]}),t=!0)}if(t)return void this.chatInput.classList.remove("is-locked");this.recorder.start().then((()=>{this.releaseMediaPlayback=Qn.Z.setSingleMedia(),this.recordCanceled=!1,this.setRecording(!0),Ks.Z.setKeepAlive(!0);const e=()=>{new vs.Z("popup-cancel-record",{titleLangKey:"DiscardVoiceMessageTitle",descriptionLangKey:"DiscardVoiceMessageDescription",buttons:[{langKey:"DiscardVoiceMessageAction",callback:()=>{(0,w.tH)(this.btnCancelRecord)}},{langKey:"Continue",isCancel:!0}]}).show()};this.recordingOverlayListener=this.listenerSetter.add(document.body)("mousedown",(t=>{(0,fe.Z)(t.target,"chat-input")||(0,fe.Z)(t.target,"popup-cancel-record")||((0,be.Z)(t),e())}),{capture:!0,passive:!1}),vn.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,Gi.Z)(o/1e3)+","+("00"+Math.round(r/10)).slice(-2);this.recordTimeEl.innerText=d,(0,le.T2)(a)};a()})).catch((e=>{switch(e.name){case"NotAllowedError":(0,me.Am)("Please allow access to your microphone");break;case"NotReadableError":(0,me.Am)(e.message);break;default:console.error("Recorder start error:",e,e.name,e.message),(0,me.Am)(e.message)}this.setRecording(!1),this.chatInput.classList.remove("is-locked")}))}})),this.onHelperCancel=(e,t)=>va(this,void 0,void 0,(function*(){if(e&&(0,be.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();if(t&&delete t.pFlags.no_webpage,!(0,ga.Z)(t,Object.assign(Object.assign({},e),{_:"draftMessage"})))return void new vs.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,be.Z)(e),(0,fe.Z)(e.target,"reply"))if("forward"===this.helperType){const{forwardElements:e}=this;e&&c.Z&&!e.container.classList.contains("active")&&mt.Z.openBtnMenu(e.container)}else"reply"===this.helperType?this.chat.setMessageId(this.replyToMsgId):"edit"===this.helperType&&this.chat.setMessageId(this.editMsgId)},this.listenerSetter=new ae.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=ps();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,Mn.Z)({icon:"arrow_down",className:"bubbles-corner-button chat-secondary-button bubbles-go-down hide"}),this.inputContainer.append(this.goDownBtn),(0,w.fc)(this.goDownBtn,(e=>{(0,be.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)}constructPeerHelpers(){this.replyElements.container=document.createElement("div"),this.replyElements.container.classList.add("reply-wrapper"),this.replyElements.iconBtn=(0,Sn.Z)(""),this.replyElements.cancelBtn=(0,Sn.Z)("close reply-cancel",{noRipple:!0}),this.replyElements.container.append(this.replyElements.iconBtn,this.replyElements.cancelBtn);const e=()=>(s=!0,this.canToggleHideAuthor()),t=()=>{s=!1},i=this.forwardElements={};let s=!1;const n=[i.showSender={text:"Chat.Alert.Forward.Action.Show1",onClick:e,checkboxField:new Ft.Z({checked:!0})},i.hideSender={text:"Chat.Alert.Forward.Action.Hide1",onClick:e,checkboxField:new Ft.Z({checked:!1})},i.showCaption={text:"Chat.Alert.Forward.Action.ShowCaption",onClick:t,checkboxField:new Ft.Z({checked:!0})},i.hideCaption={text:"Chat.Alert.Forward.Action.HideCaption",onClick:t,checkboxField:new Ft.Z({checked:!1})},i.changePeer={text:"Chat.Alert.Forward.Action.Another",onClick:()=>{this.changeForwardRecipient()},icon:"replace"}],a=i.container=(0,ms.Z)(n,this.listenerSetter),o=Array.from(a.children);if([{elements:o.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=S.ZP.weakMap.get(e),s=i.showSender.checkboxField.checked?"Chat.Accessory.Forward":"Chat.Accessory.Hidden";t.key=s,t.update()}}},{elements:o.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,Yn.Z)(e.elements.map((e=>({container:e,input:e.querySelector("input")}))),e.onChange),i=document.createElement("hr");t.append(i),a.append(t)})),a.append(i.changePeer.element),c.Z||(this.forwardHover=new Un.Z({element:a})),i.modifyArgs=n.slice(0,-1),this.replyElements.container.append(a),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.btnToggleEmoticons=(0,Sn.Z)("none toggle-emoticons",{noRipple:!0}),this.inputMessageContainer=document.createElement("div"),this.inputMessageContainer.classList.add("input-message-container"),"chat"===this.chat.type){this.goDownUnreadBadge=document.createElement("span"),this.goDownUnreadBadge.classList.add("badge","badge-24","badge-primary"),this.goDownBtn.append(this.goDownUnreadBadge),this.goMentionBtn=(0,Mn.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,w.fc)(this.goMentionBtn,(e=>{(0,be.Z)(e);const t=this.chat.bubbles.getMiddleware();this.managers.appMessagesManager.goToNextMention(this.chat.peerId).then((e=>{t()&&e&&this.chat.setMessageId(e)}))}),{listenerSetter:this.listenerSetter}),this.btnScheduled=(0,Sn.Z)("scheduled btn-scheduled float hide",{noRipple:!0}),(0,w.fc)(this.btnScheduled,(e=>{this.appImManager.openScheduled(this.chat.peerId)}),{listenerSetter:this.listenerSetter}),this.listenerSetter.add(d.Z)("scheduled_new",(({peerId:e})=>{this.chat.peerId===e&&this.btnScheduled.classList.remove("hide")})),this.listenerSetter.add(d.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=(0,Sn.Z)("botcom toggle-reply-markup float hide",{noRipple:!0}),this.replyKeyboard=new zn({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 Jn(this.rowsWrapper,this,this.managers),this.botCommandsToggle=document.createElement("div"),this.botCommandsToggle.classList.add("new-message-bot-commands");const e=document.createElement("div");e.classList.add("new-message-bot-commands-icon-scale");const t=this.botCommandsIcon=document.createElement("div");t.classList.add("animated-menu-icon","animated-menu-close-icon"),e.append(t),this.botCommandsToggle.append(e),(0,w.fc)(this.botCommandsToggle,(e=>{(0,be.Z)(e),t.classList.contains("state-back")?(this.botCommands.toggle(!0),t.classList.remove("state-back")):(this.botCommands.setUserId(this.chat.peerId.toUserId(),this.chat.bubbles.getMiddleware()),t.classList.add("state-back"))}),{listenerSetter:this.listenerSetter}),this.botCommands.addEventListener("visible",(()=>{t.classList.add("state-back")})),this.botCommands.addEventListener("hiding",(()=>{t.classList.remove("state-back")}))}this.attachMenuButtons=[{icon:"image",text:"Chat.Input.Attach.PhotoOrVideo",onClick:()=>{this.fileInput.value="";const e=[...tn.Z].join(", ");this.fileInput.setAttribute("accept",e),this.willAttachType="media",this.fileInput.click()},verify:()=>this.chat.canSend("send_media")},{icon:"document",text:"Chat.Input.Attach.Document",onClick:()=>{this.fileInput.value="",this.fileInput.removeAttribute("accept"),this.willAttachType="document",this.fileInput.click()},verify:()=>this.chat.canSend("send_media")},{icon:"poll",text:"Poll",onClick:()=>{y.Z.createPopup(Ys,this.chat).show()},verify:e=>e.isAnyChat()&&this.chat.canSend("send_polls")}],this.attachMenu=(0,Cn.Z)({noRipple:!0,listenerSetter:this.listenerSetter},"top-left",this.attachMenuButtons),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 Rn,this.stickersHelper=new wn(this.rowsWrapper,this.autocompleteHelperController,this.chat,this.managers),this.emojiHelper=new xn(this.rowsWrapper,this.autocompleteHelperController,this,this.managers),this.commandsHelper=new Dn(this.rowsWrapper,this.autocompleteHelperController,this,this.managers),this.mentionsHelper=new Nn(this.rowsWrapper,this.autocompleteHelperController,this,this.managers),this.inlineHelper=new $n(this.rowsWrapper,this.autocompleteHelperController,this.chat,this.managers),this.rowsWrapper.append(this.newMessageWrapper),this.btnCancelRecord=(0,Sn.Z)("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=(0,Sn.Z)("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),"scheduled"!==this.chat.type&&(this.sendMenu=new Ws({onSilentClick:()=>{this.sendSilent=!0,this.sendMessage()},onScheduleClick:()=>{this.scheduleSending(void 0)},listenerSetter:this.listenerSetter,openSide:"top-left",onContextElement:this.btnSend,onOpen:()=>!this.isInputEmpty()||!!Object.keys(this.forwarding).length}),this.btnSendContainer.append(this.sendMenu.sendMenu)),this.inputContainer.append(this.btnCancelRecord,this.btnSendContainer),vt.ZP.attachButtonListener(this.btnToggleEmoticons,this.listenerSetter),this.listenerSetter.add(vt.ZP)("open",this.onEmoticonsOpen),this.listenerSetter.add(vt.ZP)("close",this.onEmoticonsClose),this.attachMessageInputField(),this.listenerSetter.add(d.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(d.Z)("draft_updated",(({peerId:e,threadId:t,draft:i,force:s})=>{this.chat.threadId===t&&this.chat.peerId===e&&this.setDraft(i,!0,s)})),this.listenerSetter.add(this.appImManager)("peer_changing",(e=>{this.chat===e&&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)})),"scheduled"===this.chat.type?this.listenerSetter.add(d.Z)("scheduled_delete",(({peerId:e,mids:t})=>{this.chat.peerId===e&&t.includes(this.editMsgId)&&this.onMessageSent()})):(this.listenerSetter.add(d.Z)("history_delete",(({peerId:e,msgs:t})=>{this.chat.peerId===e&&(t.has(this.editMsgId)&&this.onMessageSent(),this.replyToMsgId&&t.has(this.replyToMsgId)&&this.clearHelper("reply"))})),this.listenerSetter.add(d.Z)("dialogs_multiupdate",(e=>{e.has(this.chat.peerId)&&(this.startParam===m.gZ?this.setStartParam():this.center(!0))})));try{this.recorder=new(Vs())({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&&(y.Z.createPopup(cn,this.chat,Array.from(t).slice(),this.willAttachType),this.fileInput.value="")}),!1),(0,w.fc)(this.btnSend,this.onBtnSendClick,{listenerSetter:this.listenerSetter,touchMouseDown:!0}),this.recorder&&((0,w.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&&(vn.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"});Ks.Z.decode(e,!0).then((e=>{Ks.Z.setKeepAlive(!1),this.managers.appMessagesManager.sendFile(t,a,{isVoiceMessage:!0,isMedia:!0,duration:n,waveform:e.waveform,objectURL:e.url,replyToMsgId:s,threadId:i,clearDraft:!0}),this.onMessageSent(!1,!0)}))}),(0,w.fc)(this.replyElements.cancelBtn,this.onHelperCancel,{listenerSetter:this.listenerSetter}),(0,w.fc)(this.replyElements.container,this.onHelperClick,{listenerSetter:this.listenerSetter}),this.saveDraftDebounced=(0,Ee.Z)((()=>this.saveDraft()),2500,!1,!0),this.botStartBtn=(0,Re.Z)("btn-primary btn-transparent text-bold chat-input-control-button"),this.botStartBtn.append((0,S.ag)("BotStart")),(0,w.fc)(this.botStartBtn,(()=>{const{startParam:e}=this;if(void 0===e)return;const t=this.toggleBotStartBtnDisability=(0,At.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)}constructPinnedHelpers(){this.pinnedControlBtn=(0,Re.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;new bs(e,0,!0,(()=>{this.chat.appImManager.setPeer();const e=this.chat.appImManager.chat;e.topbar.pinnedMessage&&e.topbar.pinnedMessage.pinnedMessageContainer.toggle(!0)}))})),this.chatInput.classList.add("type-pinned")}_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,Te.Z)(this.inputContainer,"is-centering",s,u),(0,Te.Z)(this.rowsWrapperWrapper,"is-centering-to-control",!!(s&&e&&e.classList.contains("chat-input-control")),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 va(this,void 0,void 0,(function*(){return this._center(yield this.getNeededFakeContainer(),e)}))}setStartParam(e){this.startParam!==e&&(this.startParam=e,this.center(!0))}getNeededFakeContainer(e=this.startParam){return va(this,void 0,void 0,(function*(){return this.chat.selection.isSelecting?this.fakeSelectionWrapper:void 0!==e||!(yield this.chat.canSend())||"pinned"===this.chat.type||(yield this.chat.isStartButtonNeeded())?this.controlContainer:void 0}))}getReadyToSend(e){return"scheduled"===this.chat.type?(this.scheduleSending(e),!0):(e(),!1)}setUnreadCount(){return va(this,void 0,void 0,(function*(){if(!this.goDownUnreadBadge)return;const e=yield this.managers.appMessagesManager.getDialogOnly(this.chat.peerId),t=null==e?void 0:e.unread_count;if(this.goDownUnreadBadge.innerText=""+(t||""),this.goDownUnreadBadge.classList.toggle("badge-gray",yield this.managers.appNotificationsManager.isPeerLocalMuted(this.chat.peerId,!0)),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(){const{value:e,entities:t}=(0,qs.Z)(this.messageInputField.input,!0,!1);let i;return(e.length||this.replyToMsgId)&&(i={_:"draftMessage",date:(0,_t.Z)(!0),message:e,entities:t.length?t:void 0,pFlags:{no_webpage:this.noWebPage},reply_to_msg_id:this.replyToMsgId}),i}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,Zn.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 va(this,void 0,void 0,(function*(){if(!i&&!(0,$s.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,le.T2)((()=>{this.onMessageSent()}))}))),!1;const s=function(e,t,i){const s=(0,ia.Z)(e.message),n=e.entities||[],a=(0,ta.Z)(n.slice(),s);return(0,na.Z)(e.message,{entities:a,wrappingForPeerId:t,loadPromises:void 0})}(e,this.chat.peerId),n=this.getCurrentInputAsDraft();return!((0,ga.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 la(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 va(this,void 0,void 0,(function*(){const t=this.chat.peerId,{forwardElements:i,btnScheduled:s,replyKeyboard:n,sendMenu:a,goDownBtn:o,chatInput:r,botCommandsToggle:d}=this,l=this.sendAs,c=this.createSendAs(),[h,u,f,p,m,g,v,b,y]=yield Promise.all([this.managers.appPeersManager.isBroadcast(t),this.managers.appPeersManager.canPinMessage(t),this.managers.appPeersManager.isBot(t),this.chat.canSend(),this.getNeededFakeContainer(e),oa(this.managers.acknowledged.appProfileManager.getProfileByPeerId(t)),s?oa(this.managers.acknowledged.appMessagesManager.getScheduledMessages(t)):void 0,c?(c.setPeerId(this.chat.peerId),c.updateManual(!0)):void 0,this.filterAttachMenuButtons()]),w=this.messageInput?yield this.getPlaceholderKey():void 0;return()=>{var c;if(r.classList.remove("hide"),o.classList.toggle("is-broadcast",h),o.classList.remove("hide"),null===(c=this.messageInputField)||void 0===c||c.onFakeInput(),this.goDownUnreadBadge&&this.setUnreadCount(),"pinned"===this.chat.type&&r.classList.toggle("can-pin",u),i&&(this.forwardWasDroppingAuthor=!1,i.showCaption.checkboxField.setValueSilently(!0),i.showSender.checkboxField.setValueSilently(!0)),s&&v){s.classList.add("hide");const e=this.chat.bubbles.getMiddleware();(0,ze.Z)(v.result,(t=>{e()&&t&&s.classList.toggle("hide",!t.length)}))}if(this.newMessageWrapper&&this.updateOffset(null,!1,!0),d&&(this.hasBotCommands=void 0,this.botCommands.toggle(!0,void 0,!0),this.updateBotCommandsToggle(!0),d.remove(),f)){const e=this.chat.bubbles.getMiddleware(),t=g.result;(0,ze.Z)(t,(i=>{e()&&this.updateBotCommands(i,!(t instanceof Promise))}))}l&&l.destroy(),b&&b(),n&&n.setPeer(t),a&&a.setPeerId(t),this.messageInput?(this.updateMessageInput(p,w,y),this.messageInput.dataset.peerId=""+t):this.pinnedControlBtn&&this.pinnedControlBtn.append((0,S.ag)(u?"Chat.Input.UnpinAll":"Chat.Pinned.DontShow")),this.startParam=e,this._center(m,!1)}}))}updateOffset(e,t,i,s){e?this.newMessageWrapper.dataset.offset=e:delete this.newMessageWrapper.dataset.offset,(0,Te.Z)(this.newMessageWrapper,"has-offset",t,i?0:300,void 0,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(){return va(this,void 0,void 0,(function*(){const{peerId:e,threadId:t}=this.chat;let i;return i=t?"Comment":(yield this.managers.appPeersManager.isBroadcast(e))?"ChannelBroadcast":void 0!==this.sendAsPeerId&&this.sendAsPeerId!==d.Z.myId||(yield this.managers.appMessagesManager.isAnonymousSending(e))?"SendAnonymously":"Message",i}))}updateMessageInputPlaceholder(e){const t=S.ZP.weakMap.get(this.messageInput);t&&t.compareAndUpdate({key:e})}filterAttachMenuButtons(){if(!this.attachMenuButtons)return;const{peerId:e,threadId:t}=this.chat;return(0,Os.Z)(this.attachMenuButtons,(i=>i.verify(e,t)))}updateMessageInput(e,t,i){const{chatInput:s,attachMenu:n,messageInput:a}=this,{peerId:o,threadId:r}=this.chat;s.classList.contains("is-hidden")!==!e&&(s.classList.add("no-transition"),s.classList.toggle("is-hidden",!e),s.offsetLeft,s.classList.remove("no-transition")),this.updateMessageInputPlaceholder(t),this.attachMenuButtons&&this.attachMenuButtons.forEach((e=>{e.element.classList.toggle("hide",!i.includes(e))})),e?(a.contentEditable="true",this.setDraft(void 0,!1),a.innerHTML||this.messageInputField.onFakeInput()):a.contentEditable="inherit",n&&(n.toggleAttribute("disabled",!i.length),n.classList.toggle("btn-disabled",!i.length)),this.updateSendBtn()}attachMessageInputField(){const e=this.messageInputField;this.messageInputField=new fa({placeholder:"Message",name:"message",withLinebreaks:!0}),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.messageInput.classList.add("no-scrollbar"),this.attachMessageInputListeners(),qn.T&&(0,qn.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,kn.Z)(e))(0,be.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,Tt.Z)(this.messageInput)})),c.Z&&(0,w.fc)(this.messageInput,(e=>{if(vt.ZP.isActive())return vt.ZP.toggle(!1),(0,Pn.Z)(),void(0,be.Z)(e);this.appImManager.selectTab(1)}),{listenerSetter:this.listenerSetter}),this.listenerSetter.add(this.messageInput)("input",this.onMessageInput),this.listenerSetter.add(this.messageInput)("keyup",(()=>{this.checkAutocomplete()})),"chat"!==this.chat.type&&"discussion"!==this.chat.type||this.listenerSetter.add(this.messageInput)("focusin",(()=>{this.chat.bubbles.scrollable.loadedAll.bottom&&this.managers.appMessagesManager.readAllHistory(this.chat.peerId,this.chat.threadId)}))}applyMarkdown(e,t){const i={link:t?()=>document.execCommand("createLink",!1,t):()=>document.execCommand("unlink",!1,null)},s=e=>{i[e]=()=>{const t=(n.includes(e)?n:[e]).filter((e=>l[e]));return(0,h.Z)(t,e)||t.push(e),t.length?document.execCommand("fontName",!1,"markup-"+t.join("-")):this.resetCurrentFontFormatting()}},n=["bold","italic","underline","strikethrough","spoiler"];if(n.forEach((e=>{s(e)})),s("monospace"),!i[e])return!1;const a=i[e],o=[],r=ca.Z.getInstance().prepareApplyingMarkdown(),d=this.listenerSetter.add(this.messageInput)("input",be.Z,{capture:!0,passive:!1});o.push(document.execCommand("styleWithCSS",!1,"true"));const l=ma(Object.keys(i));return l.monospace&&"link"===e&&o.push(this.resetCurrentFormatting()),o.push("function"==typeof a?a():document.execCommand(a,!1,null)),o.push(document.execCommand("styleWithCSS",!1,"false")),r(),this.appImManager.markupTooltip&&this.appImManager.markupTooltip.setActiveMarkupButton(),this.listenerSetter.remove(d),this.messageInputField.simulateInputEvent(),!0}resetCurrentFormatting(){return document.execCommand("removeFormat",!1,null)}resetCurrentFontFormatting(){return document.execCommand("fontName",!1,"Roboto")}insertAtCaret(e,t,i=!0){ca.Z.getInstance().makeFocused(this.messageInput);const{value:s,caretPos:n,entities:a}=(0,qs.Z)(this.messageInput),o=n>=0?n:s.length,r=s.substr(0,o),d=(s.substr(o),i?r.match(ya.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,C.rf)(this.messageInput,e,t?[t]:void 0,this.chat.peerId)}checkAutocomplete(e,t,i){return va(this,void 0,void 0,(function*(){if(void 0===e){const s=(0,qs.Z)(this.messageInputField.input,!0,!0);e=s.value,t=s.caretPos,i=s.entities}if(-1===t&&(t=e.length),void 0===i){const t=(0,sa.Z)(e,i,!0);i=(0,ta.Z)(i,(0,ia.Z)(t))}if(e=e.slice(0,t),this.previousQuery===e)return;this.previousQuery=e;const s=e.match(ya.AUTO_COMPLETE_REG_EXP);let n;if(s){const t=i[0];let a=s[2];const o=a[0];if(this.stickersHelper&&d.Z.settings.stickers.suggest&&(yield this.chat.canSend("send_stickers"))&&"messageEntityEmoji"===(null==t?void 0:t._)&&t.length===e.length&&!t.offset)n=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(a,this.chat.peerId.isUser()?m.NM:this.chat.peerId,e))&&(n=this.mentionsHelper)}else s[1]||"/"!==o?d.Z.settings.emoji.suggest&&(a=a.replace(/^\s*/,""),e.match(/^\s*:(.+):\s*$/)||e.match(/:[;!@#$%^&*()-=|]/)||!a||(n=this.emojiHelper,this.emojiHelper.checkQuery(a,o))):(yield this.commandsHelper.checkQuery(a,this.chat.peerId))&&(n=this.commandsHelper)}n=this.checkInlineAutocomplete(e,n),this.autocompleteHelperController.hideOtherHelpers(n)}))}checkInlineAutocomplete(e,t){let i=!1;if(!t){const s=e.match(/^@([a-zA-Z\\d_]{3,32})\s/);if(s){const n=s[1],a=e.slice(s[0].length);i=s[0].length===e.length,t=this.inlineHelper,this.btnPreloader?(0,Te.Z)(this.btnPreloader,"show",!0,400):(this.btnPreloader=(0,Sn.Z)("none btn-preloader float show disable-hover",{noRipple:!0}),(0,Dt.y)(this.btnPreloader,!0),this.inputMessageContainer.parentElement.insertBefore(this.btnPreloader,this.inputMessageContainer.nextSibling)),this.inlineHelper.checkQuery(this.chat.peerId,n,a).then((({user:e,renderPromise:t})=>{i&&e.bot_inline_placeholder&&(this.messageInput.dataset.inlinePlaceholder=e.bot_inline_placeholder),t.then((()=>{(0,Te.Z)(this.btnPreloader,"show",!1,400)}))})).catch(Ke.Z)}}return i||delete this.messageInput.dataset.inlinePlaceholder,t!==this.inlineHelper&&this.btnPreloader&&(0,Te.Z)(this.btnPreloader,"show",!1,400),t}setRecording(e){this.recording!==e&&((0,Te.Z)(this.chatInput,"is-recording",e,200),this.recording=e,this.updateSendBtn())}changeForwardRecipient(){if(this.helperWaitingForward)return;this.helperWaitingForward=!0;const e=(0,Xn.Z)(this.forwarding),t=this.helperFunc;this.clearHelper(),this.updateSendBtn();let i=!1;new E.Z(e,(()=>{i=!0})).addEventListener("close",(()=>{this.helperWaitingForward=!1,i||t()}))}clearInput(e=!0,t=!0,i=""){return va(this,void 0,void 0,(function*(){if(document.activeElement===this.messageInput&&k.IS_MOBILE_SAFARI){const e=document.createElement("input");document.body.append(e),(0,On.Z)(e),this.messageInputField.setValueSilently(i),(0,On.Z)(this.messageInput),e.remove()}else this.messageInputField.setValueSilently(i);c.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,$s.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),this.btnToggleReplyMarkup&&this.btnToggleReplyMarkup.classList.toggle("show",t)}getValueAndEntities(e){const{entities:t,value:i}=(0,qs.Z)(this.messageInput,!0,!1),s=(0,ia.Z)(i);return{value:i,totalEntities:(0,ta.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,Ls.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,qs.Z)(this.messageInputField.input,!0,!1);if(t){const e=this.editMessage;if(!o.trim()&&!e.media)return void new gs.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,Xn.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=>va(this,void 0,void 0,(function*(){"VOICE_MESSAGES_FORBIDDEN"===e.type&&(0,me.bC)({langPackKey:"Chat.SendVoice.PrivacyError",langPackArguments:[yield(0,Bt.Z)({peerId:s})]})}))));o||this.onMessageSent()}}sendMessageWithDocument(e,t=!1,i=!1,s=!1){return va(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,me.Am)(ba),!1):"scheduled"!==this.chat.type||t?!(!e||e.sticker&&(0,Ai.Z)(e)&&!d.Z.premium||(this.managers.appMessagesManager.sendFile(this.chat.peerId,e,Object.assign(Object.assign({},this.chat.getMessageSendingParams()),{isMedia:!0,clearDraft:i||void 0,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,pe.Z)(t.label,"FORM").classList.contains("hide")}isDroppingCaptions(){return!this.canToggleHideAuthor()}initMessageEditing(e){return va(this,void 0,void 0,(function*(){const t=yield this.chat.getMessage(e);let i=(0,na.Z)(t.message,{entities:t.totalEntities,wrappingForPeerId:this.chat.peerId});const s=()=>va(this,void 0,void 0,(function*(){const n=yield(0,j.Z)(t,void 0,[t.mid]);this.setTopInfo("edit",s,(0,S.ag)("AccDescrEditing"),n,i,t),this.editMsgId=e,this.editMessage=t,i=void 0}));s()}))}initMessagesForward(e){const t=()=>va(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=>va(this,void 0,void 0,(function*(){const i=e[t],o=i.map((e=>va(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,l=[...s].map((e=>{const t=e[0];if(e=e.slice(1),"P"===t){const t=e.toPeerId();return t===d.Z.myId?(0,S.ag)("Chat.Accessory.Forward.You"):new R.Z({peerId:t,dialog:!1,onlyFirstName:r}).element}return r?e.split(" ")[0]:e})),{forwardElements:c}=this;(0,pe.Z)(c.showCaption.checkboxField.label,"FORM").classList.toggle("hide",!a);const h=c.hideCaption.checkboxField.checked;a&&h?c.hideSender.checkboxField.setValueSilently(!0):void 0!==this.forwardWasDroppingAuthor&&(this.forwardWasDroppingAuthor?c.hideSender:c.showSender).checkboxField.setValueSilently(!0);const u=c.showSender.checkboxField.checked?"Chat.Accessory.Forward":"Chat.Accessory.Hidden",f=(0,S.ag)(u,[n]),p=document.createDocumentFragment();let m,g;if(l.length<3?p.append(...(0,S.v_)(l,!1)):p.append(l[0],(0,S.ag)("AndOther",[l.length-1])),1===i.length){const t=i[0],s=e[t];if(m=yield this.managers.appMessagesManager.getMessageByPeer(t,s[0]),g=!!m.grouped_id,g){const e=yield this.managers.appMessagesManager.getMidsByMessage(m);(e.length!==n||e.find((e=>!s.includes(e))))&&(g=!1)}}const v=document.createDocumentFragment();if(g||1===n){const t=e[i[0]],s=yield(0,j.Z)(m,void 0,t);v.append(p,": ",s)}else v.append((0,S.ag)("Chat.Accessory.Forward.From"),": ",p);const b=this.setTopInfo("forward",t,f,v);c.modifyArgs.forEach(((e,t)=>{const s=e.textElement,n=S.ZP.weakMap.get(s);n.args=[t<2?i.length:a],n.update()})),this.forwardHover&&this.forwardHover.attachButtonListener(b,this.listenerSetter),this.forwarding=e}));t()}initMessageReply(e){return va(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 R.Z({peerId:t.fromId,dialog:!1}).element:(s=(0,S.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.replyToMsgId=e};i()}))}clearHelper(e){"edit"===this.helperType&&"edit"!==e&&this.clearInput(),e&&(this.lastUrl="",delete this.noWebPage,this.willSendWebPage=null),"reply"!==e&&(this.replyToMsgId=void 0,this.forwarding=void 0),this.editMsgId=this.editMessage=void 0,this.helperType=this.helperFunc=void 0,this.chat.container.classList.contains("is-helper-active")&&(vn.Z.removeByType("input-helper"),this.chat.container.classList.remove("is-helper-active"),this.t())}t(){const e="is-toggling-helper";(0,Te.Z)(this.chat.container,e,!0,150,(()=>{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,le.T2)((()=>{i&&(0,Tt.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=(0,Sn.Z)(("webpage"===e?"link":e)+" active reply-icon",{noRipple:!0}));const{container:l}=Y(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()),k.IS_MOBILE||vn.Z.pushItem({type:"input-helper",onPop:()=>{this.onHelperCancel()}}),void 0!==n&&this.setInputValue(n),setTimeout((()=>{this.updateSendBtn()}),0),l}}ya.AUTO_COMPLETE_REG_EXP=/(\s|^)((?:(?:@|^\/)\S*)|(?::|^[^:@\/])(?!.*[:@\/]).*)$/;var wa=i(6054);const Sa="pinned-container";class Ca{constructor(e){this.floating=!1,(0,bn.Z)(this,e);const{divAndCaption:t,className:i}=this;t.container.classList.add(Sa,"hide"),t.title.classList.add(Sa+"-title"),t.subtitle.classList.add(Sa+"-subtitle"),t.content.classList.add(Sa+"-content"),this.btnClose=document.createElement("button"),this.btnClose.classList.add(Sa+"-close",`pinned-${i}-close`,"btn-icon","tgico-close"),this.wrapper=document.createElement("div"),this.wrapper.classList.add(Sa+"-wrapper"),(0,T.Z)(this.wrapper),this.wrapperUtils=document.createElement("div"),this.wrapperUtils.classList.add(Sa+"-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,w.fc)(e,(e=>{(0,be.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 La,Ea=i(7207),Ia=i(8427);class Ma extends Ca{constructor(e,t,i){super({topbar:e,chat:t,listenerSetter:e.listenerSetter,className:"audio",divAndCaption:new z("pinned-audio",((e,t)=>{(0,O.Z)(this.divAndCaption.title,e),(0,O.Z)(this.divAndCaption.subtitle,t)})),onClose:()=>{Qn.Z.stop()},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,D.Z)(null!==(a=null==t?void 0:t.title)&&void 0!==a?a:e.file_name),r=(null==t?void 0:t.performer)?(0,D.Z)(t.performer):(0,S.ag)("AudioUnknownArtist")}else o=new R.Z({peerId:t.fromId,fromName:null===(n=t.fwd_from)||void 0===n?void 0:n.from_name}).element,r=(0,x.OD)(t.date);this.fasterEl.classList.toggle("hide",d),this.repeatEl.classList.toggle("hide",!d),this.onPlaybackParams(s),this.volumeSelector.setVolume(),this.progressLine.setMedia(i),this.fill(o,r,t),this.toggleEl.classList.toggle("flip-icon",!i.paused),this.toggle(!1)},this.divAndCaption.border.remove();const s=(0,Sn.Z)("fast_rewind active",{noRipple:!0}),n=(0,Sn.Z)("fast_forward active",{noRipple:!0}),a=(e,t)=>{(0,w.fc)(e,(e=>{(0,be.Z)(e),t()}),{listenerSetter:this.topbar.listenerSetter})};a(s,(()=>{Qn.Z.previous()})),a(n,(()=>{Qn.Z.next()})),this.toggleEl=(0,Sn.Z)("",{noRipple:!0}),this.toggleEl.classList.add("active","pinned-audio-ico","tgico"),a(this.toggleEl,(()=>{Qn.Z.toggle()})),this.wrapper.prepend(this.wrapper.firstElementChild,s,this.toggleEl,n),this.volumeSelector=new Ia.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,Sn.Z)("audio_repeat",{noRipple:!0}),a(this.repeatEl,(()=>{const e=Qn.Z.getPlaybackParams();e.round?e.loop?(Qn.Z.round=!1,Qn.Z.loop=!1):Qn.Z.loop=!Qn.Z.loop:Qn.Z.round=!0}));const d=this.fasterEl=(0,Sn.Z)("playback_2x",{noRipple:!0});a(d,(()=>{Qn.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 Ea.Z(void 0,void 0,!0,!0),this.progressLine.container.classList.add("pinned-audio-progress"),l.append(this.progressLine.container),this.wrapper.insertBefore(l,this.wrapperUtils),this.topbar.listenerSetter.add(Qn.Z)("play",this.onMediaPlay),this.topbar.listenerSetter.add(Qn.Z)("pause",this.onPause),this.topbar.listenerSetter.add(Qn.Z)("stop",this.onStop),this.topbar.listenerSetter.add(Qn.Z)("playbackParams",this.onPlaybackParams);const c=Qn.Z.getPlayingDetails();c&&(this.onMediaPlay(c),this.onPlaybackParams(c.playbackParams))}destroy(){this.progressLine&&this.progressLine.removeListeners()}}!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"}(La||(La={}));const Pa="pinned-message-border";class Za{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=La.ONE:2===e?i=La.TWO:3===e?i=La.THREE:4===e?i=La.FOUR:e>3&&(i=La.MORE),i},this.getMarkHeight=(e,t)=>{let i;return e<=1?i=La.ONE:2===e?i=La.TWO:3===e?i=La.THREE:4===e?i=La.FOUR:e>3&&(i=La.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-La.ONE-i:(e-2)*i+1*e,this.getTrackHeight=(e,t)=>e<=3?La.ONE:t*e+1*(e-1)}render(e,t){if(this.border||(this.border=document.createElement("div"),this.border.classList.add(Pa),this.wrapper=document.createElement("div"),this.border.append(this.wrapper)),1===e)return this.count!==e&&(this.wrapper.className=Pa+"-wrapper-1",this.border.classList.remove(Pa+"-mask"),this.wrapper.innerHTML=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(Pa+"-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=Pa+"-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(Pa+"-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 ka=i(6724),Ta=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 xa{constructor(){this.rows={},this.container=document.createElement("div"),this.container.className=xa.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=xa.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)}),xa.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)}}xa.DURATION=200,xa.BASE_CLASS="animated-super";class Aa{constructor(e=!1){this.reverse=e,this.decimals=[],this.previousNumber=0,this.container=document.createElement("div"),this.container.className=Aa.BASE_CLASS}getDecimal(e){if(this.decimals[e])return this.decimals[e];const t=document.createElement("div");t.className=Aa.BASE_CLASS+"-decimal";const i=document.createElement("div");i.className=Aa.BASE_CLASS+"-decimal-placeholder";const s=new xa;return s.container.className=Aa.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()}))}),xa.DURATION))}hideLeft(e){const t=(""+e).length;this.decimals.slice(t).forEach((t=>{const i=+t.placeholder.innerText||0;t.animatedSuper.getRow(Aa.EMPTY_INDEX,!0),t.animatedSuper.animate(Aa.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:Aa.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}}Aa.EMPTY_INDEX=-1,Aa.BASE_CLASS="animated-counter";class _a{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 ae.Z,this.log=(0,r.kg)("PM"),this.debug=!0,this.isStatic=!1;const s=new Q("pinned-message",t.animationGroup);this.pinnedMessageContainer=new Ca({topbar:e,chat:t,listenerSetter:this.listenerSetter,className:"message",divAndCaption:s,onClose:()=>Ta(this,void 0,void 0,(function*(){return(yield i.appPeersManager.canPinMessage(this.chat.peerId))?new bs(this.chat.peerId,this.pinnedMid,!0):new bs(this.chat.peerId,0,!0),!1}))}),this.pinnedMessageBorder=new Za,s.border.replaceWith(this.pinnedMessageBorder.render(1,0)),this.animatedSubtitle=new xa,s.subtitle.append(this.animatedSubtitle.container),this.animatedMedia=new xa,this.animatedMedia.container.classList.add("pinned-message-media-container"),s.content.prepend(this.animatedMedia.container),this.animatedCounter=new Aa(!0),s.title.append((0,S.ag)("PinnedMessage")," ",this.animatedCounter.container);const n=this.pinnedMessageContainer.btnClose.cloneNode(!0);this.pinnedMessageContainer.attachOnCloseEvent(n),s.container.prepend(n),this.btnOpen=(0,Sn.Z)("pinlist pinned-container-close pinned-message-pinlist",{noRipple:!0}),this.pinnedMessageContainer.wrapperUtils.prepend(this.btnOpen),(0,w.fc)(this.btnOpen,(e=>{(0,be.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,Ee.Z)((()=>this._setPinnedMessage()),100,!0,!0),this.setCorrectIndexThrottled=(0,ka.Z)(this.setCorrectIndex.bind(this),100,!1),this.isStatic="discussion"===this.chat.type}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>_a.LOAD_COUNT&&(!this.loadedBottom&&e<=_a.LOAD_OFFSET||!this.loadedTop&&this.count-1-e<=_a.LOAD_OFFSET)}getCurrentIndex(e,t=!0){return Ta(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:_a.LOAD_COUNT,backLimit:_a.LOAD_COUNT}).then((e=>(s=!0,e)))];if(!this.pinnedMaxMid){const e=this.managers.appMessagesManager.getPinnedMessage(this.chat.peerId).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 ae.Z,function(e,t,i,s){if(c.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 Ta(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,de.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 Ta(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 Ta(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 q({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)}))}}_a.LOAD_COUNT=50,_a.LOAD_OFFSET=5;var Fa=i(6194),Da=i(2995),Ra=i(4240),Ba=i(6818),Na=i(3897),Oa=i(7120),Ua=i(2059),Ha=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 za{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,be.Z)(e),(()=>{Ha(this,void 0,void 0,(function*(){const e=yield this.managers.appPeersManager.getDeleteButtonText(this.peerId);t&&this.menuButtons[this.menuButtons.length-1].element.lastChild.replaceWith((0,S.ag)(e));const i=this.buttonsToVerify.concat(t?this.menuButtons:[]);(yield Promise.all(i.map((e=>Ha(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=>Ha(this,void 0,void 0,(function*(){var t;if(!Ba.Z||this.peerId.isUser())return!1;const i=Ua.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.getChatTyped(s);return(null===(t=n.pFlags)||void 0===t?void 0:t.call_active)||(0,Oa.Z)(n,"manage_call")})),this.verifyCallButton=e=>Ha(this,void 0,void 0,(function*(){if(!De.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=()=>{new Na.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),k.IS_SAFARI&&e&&this.chatUtils.classList.add("hide"),this.setUtilsRAF=window.requestAnimationFrame((()=>{k.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=()=>{const e=[this.chatAudio,this.pinnedMessage&&this.pinnedMessage.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=""+e},this.setPeerStatusManual=(e=!1)=>Ha(this,void 0,void 0,(function*(){if(!this.subtitle)return;const t=this.peerId;return this.chat.appImManager.setPeerStatus(t,this.subtitle,e,!1,(()=>t===this.peerId))})),this.setPeerStatus=e=>this.setPeerStatusManual(e).then((e=>{e&&e()})),this.listenerSetter=new ae.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,Sn.Z)("left sidebar-close-button",{noRipple:!0}),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=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 Ma(this,this.chat,this.managers),this.menuButtons.length&&(this.btnMore=(0,Cn.Z)({listenerSetter:this.listenerSetter},"bottom-left",this.menuButtons,this.verifyButtons)),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,w.fc)(this.container,(e=>{const t=(0,fe.Z)(e.target,"pinned-container");if((0,Pn.Z)(),t){if((0,be.Z)(e),(0,fe.Z)(e.target,"progress-line"))return;const i=+t.dataset.mid;if(t.classList.contains("pinned-message"))this.pinnedMessage.followPinnedMessage(i);else{const e=t.dataset.peerId.toPeerId(),s=Qn.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,pe.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,be.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);vn.Z.back(e?"im":"chat")}};(0,w.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:()=>Ha(this,void 0,void 0,(function*(){return"chat"===this.chat.type&&d.Z.myId!==this.peerId&&!(yield this.managers.appNotificationsManager.isPeerLocalMuted(this.peerId,!1))}))},{icon:"unmute",text:"ChatList.Context.Unmute",onClick:()=>{this.managers.appMessagesManager.togglePeerMute(this.peerId)},verify:()=>Ha(this,void 0,void 0,(function*(){return"chat"===this.chat.type&&d.Z.myId!==this.peerId&&(yield this.managers.appNotificationsManager.isPeerLocalMuted(this.peerId,!1))}))},{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:()=>Ha(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),on.Z.getState().then((t=>{if(t.chatContextMenuHintWasShown)return;const i=e.toggleByElement.bind(e);e.toggleByElement=t=>Ha(this,void 0,void 0,(function*(){this.managers.appStateManager.pushToState("chatContextMenuHintWasShown",!0),(0,me.Am)((0,S.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(Ra.Z)){const e=this.appSidebarRight.createTab(Ra.Z);e.peerId=this.peerId,e.open(),this.appSidebarRight.toggleSidebar(!0)}},verify:()=>Ha(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;new Da.Z({peerTypes:["dialogs","contacts"],onSelect:t=>new Promise(((i,s)=>{new vs.Z("",{titleLangKey:"SendMessageTitle",descriptionLangKey:"SendContactToGroupText",descriptionLangArgs:[new R.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",chatRightsAction:"send_messages",selfPresence:"ChatYourSelf"})},verify:()=>Ha(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:"lock",text:"BlockUser",onClick:()=>{new vs.Z("",{peerId:this.peerId,titleLangKey:"BlockUser",descriptionLangKey:"AreYouSureBlockContact2",descriptionLangArgs:[new R.Z({peerId:this.peerId}).element],buttons:[{langKey:"BlockUser",isDanger:!0,callback:()=>{this.managers.appUsersManager.toggleBlock(this.peerId,!0).then((e=>{e&&(0,me.bC)({langPackKey:"UserBlocked"})}))}}]}).show()},verify:()=>Ha(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,me.bC)({langPackKey:"UserUnblocked"})}))},verify:()=>Ha(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:()=>{new Fa.Z(this.peerId)},verify:()=>Ha(this,void 0,void 0,(function*(){return"chat"===this.chat.type&&!!(yield this.managers.appMessagesManager.getDialogOnly(this.peerId))}))}],this.btnSearch=(0,Sn.Z)("search"),this.attachClickEvent(this.btnSearch,(e=>{this.chat.initSearch()}),!0)}attachClickEvent(e,t,i){(0,w.fc)(e,(e=>{(0,be.Z)(e),!i&&(0,Pn.Z)(),t(e)}),{listenerSetter:this.listenerSetter})}onCallClick(e){this.chat.appImManager.callUser(this.peerId.toUserId(),e)}constructAvatar(){const e=new p.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 _a(this,this.chat,this.managers),this.btnJoin=(0,Re.Z)("btn-primary btn-color-primary chat-join hide"),this.btnCall=(0,Sn.Z)("phone"),this.btnGroupCall=(0,Sn.Z)("videochat"),this.btnPinned=(0,Sn.Z)("pinlist"),this.btnMute=(0,Sn.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,(()=>Ha(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)("chat_update",(e=>Ha(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.pinnedMessage&&this.chat.addEventListener("setPeer",((e,t)=>{const i=this.chat.bubbles.getMiddleware();on.Z.getState().then((s=>{i()&&(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.setPeerStatusInterval=window.setInterval(this.setPeerStatus,6e4),this}constructPinnedHelpers(){this.listenerSetter.add(d.Z)("peer_pinned_messages",(({peerId:e,mids:t})=>{e===this.peerId&&t&&this.setTitle()}))}constructDiscussionHelpers(){this.pinnedMessage=new _a(this,this.chat,this.managers)}openPinned(e){this.chat.appImManager.setInnerPeer({peerId:this.peerId,lastMsgId:e?+this.pinnedMessage.pinnedMessageContainer.divAndCaption.container.dataset.mid:0,type:"pinned"})}destroy(){this.listenerSetter.removeAll(),window.clearInterval(this.setPeerStatusInterval),this.pinnedMessage&&this.pinnedMessage.destroy(),this.chatAudio&&this.chatAudio.destroy(),delete this.chatAudio,delete this.pinnedMessage}cleanup(){this.chat.peerId||this.container.classList.add("hide")}finishPeerChange(e){return Ha(this,void 0,void 0,(function*(){const e=this.peerId;let t;this.avatarElement&&(t=this.constructAvatar());const[i,s,n,a,o,r,d]=yield Promise.all([this.managers.appPeersManager.isBroadcast(e),this.managers.appPeersManager.isAnyChat(e),e.isAnyChat()?this.managers.appChatsManager.getChat(e.toChatId()):void 0,t?t.updateWithOptions({peerId:e}):void 0,this.setTitleManual(),this.setPeerStatusManual(!0),on.Z.getState()]);return()=>{var a;if(this.btnMute&&this.btnMute.classList.toggle("hide",!i),this.btnJoin&&(s&&!this.chat.isRestricted?((0,O.Z)(this.btnJoin,(0,S.ag)(i?"Chat.Subscribe":"ChannelJoin")),this.btnJoin.classList.toggle("hide",!(null===(a=null==n?void 0:n.pFlags)||void 0===a?void 0:a.left))):this.btnJoin.classList.add("hide")),t&&(this.avatarElement.replaceWith(t),this.avatarElement=t),this.setUtilsWidth(),this.verifyButtons(),this.pinnedMessage)if("chat"===this.chat.type){if(this.chat.wasAlreadyUsed){const e=new _a(this,this.chat,this.managers);this.pinnedMessage.pinnedMessageContainer.divAndCaption.container.replaceWith(e.pinnedMessageContainer.divAndCaption.container),this.pinnedMessage.destroy(),this.pinnedMessage=e}this.pinnedMessage.hidden=!!d.hiddenPinnedMessages[e]}else"discussion"===this.chat.type&&(this.pinnedMessage.pinnedMid=this.chat.threadId,this.pinnedMessage.count=1,this.pinnedMessage.pinnedIndex=0,this.pinnedMessage._setPinnedMessage());o(),r&&r(),this.setMutedState(),this.container.classList.remove("hide")}}))}setTitleManual(e){return Ha(this,void 0,void 0,(function*(){const t=this.peerId,i=()=>this.peerId===t;let s;if("pinned"===this.chat.type)s=void 0===e?(0,S.ag)("Loading"):(0,S.ag)("PinnedMessagesCount",[e]),void 0===e&&this.managers.appMessagesManager.getSearchCounters(t,[{_:"inputMessagesFilterPinned"}],!1).then((e=>{if(!i())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)s=(0,S.ag)(t===d.Z.myId?"Reminders":"ScheduledMessages");else if("discussion"===this.chat.type){if(void 0===e){const s=yield this.managers.acknowledged.appMessagesManager.getHistory(t,0,1,0,this.chat.threadId);if(!i())return;if(s.cached){const t=yield s.result;if(!i())return;e=t.count}else s.result.then((e=>{i()&&this.setTitle(e.count)}))}s=void 0===e?(0,S.ag)("Loading"):(0,S.ag)("Chat.Title.Comments",[e])}else if("chat"===this.chat.type&&([s]=yield Promise.all([(0,Bt.Z)({peerId:t,dialog:!0,withIcons:!0})]),!i()))return;return()=>{(0,O.Z)(this.title,s)}}))}setTitle(e){this.setTitleManual(e).then((e=>e()))}setMutedState(){return Ha(this,void 0,void 0,(function*(){if(!this.btnMute)return;const e=this.peerId,t=yield this.managers.appNotificationsManager.isPeerLocalMuted(e,!1);(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 ja=i(5884),Ga=i(3607);class Va extends Hi._{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 Ga.Z("Search"),this.title.replaceWith(this.inputSearch.container),this.btnPickDate=(0,Sn.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 ja.Z(n,this.inputSearch,{messages:new ja.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,w.fc)(this.btnPickDate,(()=>{y.Z.createPopup(L,new Date,this.onDatePick).show()})),s&&this.appSearch.searchInput.inputField.setValueSilently(s),a.ZP.toggleSidebar(!0))}}class Ka{constructor(e,t,i){this.topbar=e,this.chat=t,this.foundCount=0,this.selectedIndex=0,this.onDateClick=e=>{(0,be.Z)(e),y.Z.createPopup(L,new Date,this.chat.bubbles.onDatePick).show()},this.onResultsClick=e=>{const t=(0,pe.Z)(e.target,zi.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,be.Z)(e),this.selectResult(this.searchGroup.list.children[this.selectedIndex+1])},this.onDownClick=e=>{(0,be.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,T.Z)(this.backBtn);const s=this.listenerSetter=new ae.Z,n=(e,t)=>{(0,w.fc)(e,t,{listenerSetter:s})};n(this.backBtn,(()=>{this.destroy()})),this.inputSearch=new Ga.Z("Search"),this.results=document.createElement("div"),this.results.classList.add("chat-search-results","chatlist-container"),this.searchGroup=new ja.z(!1,"messages",void 0,"",!1),n(this.searchGroup.list,this.onResultsClick),this.appSearch=new ja.Z(this.results,this.inputSearch,{messages:this.searchGroup},(e=>{this.foundCount=e,this.foundCount?this.selectResult(this.searchGroup.list.children[0]):((0,O.Z)(this.foundCountEl,this.inputSearch.value?(0,S.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,T.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),k.IS_MOBILE_SAFARI||(this.navigationItem={type:"mobile-search",onPop:()=>{this.destroy()}},vn.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,vn.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,Se.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(t,i);this.setPeerPromise=(n instanceof Promise?n:Promise.resolve(n)).then((()=>{this.selectedIndex=s,(0,O.Z)(this.foundCountEl,(0,S.ag)("Of",[s+1,this.foundCount]));const e=this.searchGroup.list.childElementCount;this.selectedIndex>=e-6&&this.appSearch.searchMore()})).finally((()=>{this.setPeerPromise=null}))}}var Wa=i(1571),$a=i(6848),qa=i(356);class Qa{constructor(){this.canvases=new Set}static getInstance(e){let t=this.INSTANCES.find((t=>(0,$a.Z)(t.options,e)));return t||(t=new Qa,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,xt.cj)(t,e,!1).then((()=>qa.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,h.Z)(Qa.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+Pe.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))))}}Qa.INSTANCES=[];var Ya=i(6714),Ja=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 Xa 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.peerId=m.NM,this.container.append(this.backgroundEl),this.appImManager.chatsContainer.append(this.container),this.backgroundTempId=0,this.sharedMediaTabs=[]}setBackground(e,t){const i=Ya.Z.getTheme();let s;if(i.background.color&&!i.background.slug&&!i.background.intensity&&"grabbing"===document.documentElement.style.cursor&&this.gradientRenderer&&!this.patternRenderer)return this.gradientCanvas.dataset.colors=i.background.color,this.gradientRenderer.init(this.gradientCanvas),Promise.resolve();const n=++this.backgroundTempId,a=this.gradientRenderer,o=this.patternRenderer,r=(this.gradientCanvas,this.patternCanvas);this.gradientRenderer=this.patternRenderer=this.gradientCanvas=this.patternCanvas=void 0;const l=i.background.intensity&&i.background.intensity/100,c=!!l&&l<0;let h,u,f,p=null==s?void 0:s.firstElementChild;if(!s)if(s=document.createElement("div"),s.classList.add("chat-background-item"),e)if(l){s.classList.add("is-pattern");const t=this.appImManager.chatsContainer.getBoundingClientRect();h=this.patternRenderer=Qa.getInstance({url:e,width:t.width,height:t.height,mask:c}),p=this.patternCanvas=h.createCanvas(),p.classList.add("chat-background-item-canvas","chat-background-item-pattern-canvas"),c&&s.classList.add("is-dark")}else i.background.slug&&s.classList.add("is-image");else i.background.color&&s.classList.add("is-color");const m=i.background.color;if(m){const{canvas:e,gradientRenderer:t}=Wa.Z.create(m);f=this.gradientRenderer=t,u=this.gradientCanvas=e,u.classList.add("chat-background-item-canvas","chat-background-item-color-canvas"),d.Z.settings.animationsEnabled&&f.scrollAnimate(!0)}h&&(c?u:p).style.setProperty("--opacity-max",""+Math.abs(l)*(c?.5:1));const g=new Promise((i=>{const d=()=>{if(this.backgroundTempId!==n)return h&&h.cleanup(p),void(f&&f.cleanup());const e=this.backgroundEl.lastElementChild;if(e===s)return void i();const d=[u,p].filter(Boolean);d.length&&s.append(...d),this.backgroundEl.append(s),(0,Te.Z)(s,"is-visible",!0,t?0:200,e?()=>{o&&o.cleanup(r),a&&a.cleanup(),e.remove()}:null,2),i()};h?h.renderToCanvas(p).then((()=>{this.backgroundTempId===n&&d()})):e?(0,xt.ZP)(s,e,d):d()}));return this.setBackgroundPromise=Promise.race([(0,Qe.Z)(500),g])}setType(e){this.type=e}init(){this.topbar=new za(this,a.ZP,this.managers),this.bubbles=new fs(this,this.managers),this.input=new ya(this,this.appImManager,this.managers),this.contextMenu=new js(this,this.managers),this.selection=new wa.Z(this,this.bubbles,this.input,this.managers),"chat"===this.type?(this.topbar.constructUtils(),this.topbar.constructPeerHelpers()):"pinned"===this.type?this.topbar.constructPinnedHelpers():"discussion"===this.type&&(this.topbar.constructUtils(),this.topbar.constructDiscussionHelpers()),this.topbar.construct(),this.input.construct(),"chat"===this.type?(this.bubbles.constructPeerHelpers(),this.input.constructPeerHelpers()):"pinned"===this.type?(this.bubbles.constructPinnedHelpers(),this.input.constructPinnedHelpers()):"scheduled"===this.type?(this.bubbles.constructScheduledHelpers(),this.input.constructPeerHelpers()):"discussion"===this.type&&(this.bubbles.constructPeerHelpers(),this.input.constructPeerHelpers()),"scheduled"===this.type||c.Z||this.bubbles.setReactionsHoverListeners(),this.bubbles.attachContainerListeners(),this.container.classList.add("type-"+this.type),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(t)})),this.bubbles.listenerSetter.add(d.Z)("dialog_drop",(e=>{e.peerId===this.peerId&&this.appImManager.setPeer()})),this.bubbles.listenerSetter.add(this.appImManager)("chat_changing",(({to:e})=>{const t=e!==this,i=()=>{var e;null===(e=this.bubbles.observer)||void 0===e||e.toggleObservingNew(t),s.Z.toggleIntersectionGroup(this.animationGroup,t),t&&s.Z.checkAnimations(t,this.animationGroup)};t?i():setTimeout((()=>{i()}),400)}))}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()}onChangePeer(e){return Ja(this,void 0,void 0,(function*(){const{peerId:t}=this,i=a.ZP.getTab(Va);i&&i.close();const[s,n,o,r,d,l,c,h]=yield e(Promise.all([this.managers.appPeersManager.noForwards(t),this.managers.appPeersManager.isRestricted(t),this._isAnyGroup(t),this.setAutoDownloadMedia(),this.managers.appPeersManager.isMegagroup(t),this.managers.appPeersManager.isBroadcast(t),this.managers.appPeersManager.isChannel(t),this.managers.appPeersManager.isBot(t)]));this.noForwards=s,this.isRestricted=n,this.isAnyGroup=o,this.isMegagroup=d,this.isBroadcast=l,this.isChannel=c,this.isBot=h,this.container.classList.toggle("no-forwards",this.noForwards),this.sharedMediaTab=a.ZP.createSharedMediaTab(),this.sharedMediaTabs.push(this.sharedMediaTab),this.sharedMediaTab.setPeer(t,this.threadId),this.input.clearHelper(),this.selection.cleanup()}))}setPeer(e,t,i){e?this.inited||(this.init&&(this.init(),this.init=null),this.inited=!0):this.inited=void 0;const s=this.peerId===e;if(s){if(this.setPeerPromise)return}else this.appImManager.dispatchEvent("peer_changing",this),this.peerId=e||m.NM,this.messagesStorageKey=`${this.peerId}_${"scheduled"===this.type?"scheduled":"history"}`;if(!e)return a.ZP.toggleSidebar(!1),this.cleanup(!0),this.bubbles.setPeer(!1,e),this.appImManager.dispatchEvent("peer_changed",e),a.ZP.replaceSharedMediaTab(),this.destroySharedMediaTab(),void(this.sharedMediaTab=void 0);this.peerChanged=s;const n=this.bubbles.setPeer(s,e,t,i),o=this.setPeerPromise=n.then((e=>e.promise)).catch(Ke.Z).finally((()=>{this.setPeerPromise===o&&(this.setPeerPromise=null)}));return n}destroySharedMediaTab(e=this.sharedMediaTab){e&&((0,h.Z)(this.sharedMediaTabs,e),e.destroy())}setAutoDownloadMedia(){return Ja(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){return this.setPeer(this.peerId,e)}finishPeerChange(e,t,i,s){return Ja(this,void 0,void 0,(function*(){if(this.peerChanged)return;const t=this.peerId;this.peerChanged=!0,this.wasAlreadyUsed=!0;const i=this.bubbles.getMiddleware();this.cleanup(!1);const n=this.sharedMediaTab;n.loadSidebarMedia(!0);const o=Promise.all([this.topbar.finishPeerChange(e),this.bubbles.finishPeerChange(),this.input.finishPeerChange(s)]),[r]=yield Promise.all([o,n.fillProfileElements()]);i()&&(r.forEach((e=>{e()})),a.ZP.replaceSharedMediaTab(n),this.sharedMediaTabs.filter((e=>e!==n)).forEach((e=>this.destroySharedMediaTab(e))),this.log.setPrefix("CHAT-"+t+"-"+this.type),this.appImManager.dispatchEvent("peer_changed",t))}))}getMessage(e){return this.managers.appMessagesManager.getMessageFromStorage(this.messagesStorageKey,e)}getMidsByMid(e){return Ja(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:ue.Z.fromJSON(e.historySerialized)})))}getHistoryMaxId(){return this.getHistoryStorage().then((e=>e.maxId))}_isAnyGroup(e){return Ja(this,void 0,void 0,(function*(){return e===d.Z.myId||e===m.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 Ka(this.topbar,this,e);else{let t=a.ZP.getTab(Va);t||(t=a.ZP.createTab(Va)),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,sendSilent:this.input.sendSilent,sendAsPeerId:this.input.sendAsPeerId}}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)}}var eo=i(2342),to=i(6637);class io{constructor(e){this.appImManager=e,this.buttons={},this.addedListener=!1,this.waitingForMouseUp=!1,this.mouseUpCounter=0,this.onMouseUpSingle=e=>{if(this.waitingForMouseUp=!1,c.Z){if(e&&(0,be.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,Sn.Z)(t,{noRipple:!0});e.append(this.buttons[t]=i),"link"!==t?i.addEventListener("mousedown",(e=>{(0,be.Z)(e),this.appImManager.chat.input.applyMarkdown(t),this.cancelClosening()})):(0,w.fc)(i,(e=>{(0,be.Z)(e),this.showLinkEditor(),this.cancelClosening()}))})),this.linkBackButton=(0,Sn.Z)("left",{noRipple:!0}),this.linkInput=document.createElement("input"),(0,S.$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,eo.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,be.Z)(e),this.container.classList.remove("is-link"),this.resetSelection(),this.setTooltipPosition(),this.cancelClosening()})),this.linkApplyButton=(0,Sn.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,be.Z)(e),this.resetSelection();let t=this.linkInput.value;t&&!(0,to.Z)(t)&&(t="https://"+t),this.appImManager.chat.input.applyMarkdown("link",t),setTimeout((()=>{this.hide()}),0)}isLinkValid(){return!this.linkInput.value.length||!!(0,eo.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,vn.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=ma(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,Be.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,Fi.Z)(e.left,d,l)}else{const e=s.left+(s.width-o.width)/2;c=(0,Fi.Z)(e,d,l)}this.container.style.transform=`translate3d(${c}px, ${r}px, 0)`}show(){if(this.init&&(this.init(),this.init=null),ws())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"),k.IS_MOBILE||vn.Z.pushItem({type:"markup",onPop:()=>{this.hide()}})}setMouseUpEvent(){this.waitingForMouseUp||(this.waitingForMouseUp=!0,document.addEventListener("mouseup",this.onMouseUpSingle,{once:!0}))}cancelClosening(){c.Z&&!k.IS_APPLE&&(document.removeEventListener("mouseup",this.onMouseUpSingle),document.addEventListener("mouseup",(e=>{(0,be.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(ws(i))this.hide();else if(c.Z)if(k.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.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 so=i(9171);class no{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,S.ag)(t.header,t.headerArgs)),t.subtitle&&(n=document.createElement("div"),n.classList.add("drop-subtitle"),n.append((0,S.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,so.Z)(5,5,i,s,t,t,t,t);this.path.setAttributeNS(null,"d",n)}}var ao=i(7922);function oo(e){e.forEach((e=>e.classList.add("no-transition"))),(0,le.d1)().then((()=>{e.forEach((e=>e.classList.remove("no-transition")))}))}var ro=i(490),lo=i(2831),co=i(2207);class ho{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,f=this.progress[n],p=(i-e)/h*(n-1),m=(i-e)/h*n,g=p+(m-p)/2,v=(t-u)*r+o*(1-r),b=(t-(l[n]*(1-f)+c[n]*f))*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 uo{constructor(e){this.stateId=e,this.createGradient(e)}createGradient(e){this.shader=(t,i,s,n,a)=>{t.fillStyle=uo.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===co.Z.MUTED_BY_ADMIN?(o.addColorStop(0,"#F05459"),o.addColorStop(.4,"#766EE9"),o.addColorStop(1,"#57A4FE")):t===co.Z.UNMUTED?(o.addColorStop(0,"#52CE5D"),o.addColorStop(1,"#00B1C0")):t===co.Z.MUTED?(o.addColorStop(0,"#0976E3"),o.addColorStop(1,"#2BCEFF")):t===co.Z.CONNECTING&&(o.addColorStop(0,"#8599aa"),o.addColorStop(1,"#8599aa")),o}update(e,t,i,s){}}class fo{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:f}=this;if(!h&&!u&&this.progressToState>=1)return;let p=Date.now()-this.lastUpdateTime;p>20&&(p=17),this.animateToAmplitude!==this.amplitude&&(this.amplitude+=this.animateAmplitudeDiff*p,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*p,this.animateAmplitudeDiff2>0?this.amplitude2>this.animateToAmplitude&&(this.amplitude2=this.animateToAmplitude):this.amplitude2<this.animateToAmplitude&&(this.amplitude2=this.animateToAmplitude)),c&&(this.progressToState+=p/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;f.getContext("2d").clearRect(0,0,f.width,f.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,p,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,f,u,o,1),s.draw(a,o-y,r,d,f,u,o,1),t.draw(a,o,r,d,f,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([[co.Z.UNMUTED,new uo(co.Z.UNMUTED)],[co.Z.MUTED,new uo(co.Z.MUTED)],[co.Z.MUTED_BY_ADMIN,new uo(co.Z.MUTED_BY_ADMIN)],[co.Z.CONNECTING,new uo(co.Z.CONNECTING)]]),this.previousState=null,this.currentState=this.states.get(co.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 ho(3),this.lbd1=new ho(7),this.lbd2=new ho(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 po=i(8222);class mo{constructor(e,t){this.item=e,(0,bn.Z)(this,t)}play(e){return this.item.playPart(this,e)}}class go{constructor(e,t){this.icon=e,this.autoplay=!1,(0,bn.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=Cs.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=>Cs.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 mo(this,e)}getPart(e){return e instanceof mo?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 vo{constructor(e){(0,bn.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(Ke.Z)}getItem(e){return e||1!==this.items.size?this.items.get(e):this.items.values().next().value}add(e){const t=new go(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:d.Z.settings.animationsEnabled&&!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 bo extends vo{constructor(e){super({width:e.width,height:e.height}),(0,bn.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(Ke.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 yo extends bo{constructor(){super({width:36,height:36,getPart:(e,t)=>{const i=Wo;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 wo=i(6733);class So extends bo{constructor(e){super({width:32,height:32,getPart:(e,t)=>{const i=Ko;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=Ko;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=po.Z.getProperty("gc-"+i+"-text-color");return(0,B.oo)(s)}(e):void 0}),this.colored=e,this.container.classList.add("group-call-participant-muted-icon-container");const t=vo.generateEqualParts(4,21);this.add({name:"voice_outlined2",parts:t})}setState(e){return super.setState(function(e){const t=Ko;switch(e){case t.MUTED_BY_ADMIN:case t.MUTED_FOR_ME:return t.MUTED;default:return e}}(e),e)}}const Co="group-call-participant-status";class Lo{constructor(e){this.withIcons=e,this.container=document.createElement("div"),this.container.classList.add(Co+"-container")}setState(e,t){const i=Ko,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(Co+"-icon",Co+"-icon-"+e,t),i}));let n,a;if(e===i.MUTED_FOR_ME)n=(0,S.ag)("VoiceChat.Status.MutedForYou"),a="is-muted";else if(e===i.UNMUTED)n=(0,S.ag)("VoiceChat.Status.Speaking"),a="is-speaking";else if(e===i.HAND)n=(0,S.ag)("VoiceChat.Status.WantsSpeak"),a="is-waiting";else{if(t.about&&!s.length)return void(0,A.Z)(this.container,(0,D.Z)(t.about));n=(0,S.ag)("VoiceChat.Status.Listening"),a="is-listening"}const o=document.createElement("span");o.classList.add(Co,a),o.append(...s,n),(0,O.Z)(this.container,o)}}var Eo=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 Io extends ts.Z{constructor(e){super({getIndex:e=>Eo(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=>Eo(this,void 0,void 0,(function*(){const t=yield this.instance.getParticipantByPeerId(e.id),i=$o(t);e.mutedIcon.setState(i),e.status.setState(i,t)})),onSort:(e,t)=>{(0,f.Z)(e.dom.listEl,this.list,t)},onElementCreate:e=>{const{dom:t}=zi.default.addDialogNew({peerId:e.id,container:!1,avatarSize:this.avatarSize,autonomous:this.autonomous,meAsSaved:!1,rippleEnabled:this.rippleEnabled,lazyLoadQueue:this.lazyLoadQueue});t.listEl.classList.add("group-call-participant");const i=new So(!0),s=new Lo(["presentation","video"]);return(0,O.Z)(t.lastMessageSpan,s.container),t.listEl.append(i.container),e.mutedIcon=i,e.status=s,e.dom=t,e},updateElementWith:le.T2}),this.instance=e,this.avatarSize="abitbigger",this.rippleEnabled=!0,this.autonomous=!0,this.createChatListOptions={dialogSize:72},this.list=zi.default.createChatList(this.createChatListOptions)}destroy(){this.elements.forEach((e=>{this.onElementDestroy(e)}))}onElementDestroy(e){e.mutedIcon.destroy()}}var Mo=i(7529);function Po(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,Ce.jt)((()=>(s(),t.isConnected))),s(),t}const Zo="group-call-participant-video";class ko{constructor(e,t,i){this.managers=e,this.instance=t,this.source=i,this.container=document.createElement("div"),this.container.classList.add(Zo+"-container"),this.info=document.createElement("div"),this.info.classList.add(Zo+"-info"),this.left=document.createElement("div"),this.left.classList.add(Zo+"-info-left"),this.right=document.createElement("div"),this.right.classList.add(Zo+"-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(Zo+"-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,S.ag)("VoiceChat.Status.You"),s.classList.add("peer-title")):(this.peerTitle=new R.Z({peerId:(0,F.Z)(e.peer)}),s=this.peerTitle.element),this.groupCallParticipantMutedIcon=new So(!1),this.groupCallParticipantStatus=new Lo([t]),this.left.append(s,this.groupCallParticipantStatus.container),this.right.append(this.groupCallParticipantMutedIcon.container),i.classList.add(Zo,"call-video"),i.paused&&i.play();const n=Po(i);n.classList.add(Zo+"-blur"),this.container.prepend(n,i),this.updateParticipant(e)}updateParticipant(e){const t=$o(e);this.groupCallParticipantMutedIcon.setState(t),this.groupCallParticipantStatus.setState(t,e)}destroy(){this.groupCallParticipantMutedIcon.destroy()}}class To extends Mo.Z{constructor(e){super(),(0,bn.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,w.fc)(this.container,(e=>{const t=(0,fe.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,F.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 ko(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 xo=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 Ao{constructor(e){this.onOpenProfileClick=()=>{const e=y.Z.getPopups(Yo)[0];e&&e.hide(),Ar.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:()=>xo(this,void 0,void 0,(function*(){(0,li.Z)({peerId:this.targetPeerId,title:new R.Z({peerId:this.targetPeerId}).element,descriptionLangKey:(yield this.managers.appChatsManager.isBroadcast(this.chatId))?"VoiceChat.RemovePeer.Confirm.Channel":"VoiceChat.RemovePeer.Confirm",descriptionLangArgs:[new R.Z({peerId:this.targetPeerId}).element],button:{langKey:"VoiceChat.RemovePeer.Confirm.OK",isDanger:!0}}).then((()=>{this.managers.appChatsManager.kickFromChat(this.chatId,this.targetPeerId)}),Ke.Z)}))}];const{listenerSetter:t}=e;this.managers=e.managers,this.instance=e.instance,this.chatId=this.instance.chatId,this.element=(0,ms.Z)(this.buttons,t),this.element.classList.add("group-call-participant-menu","night"),(0,pt.E)(e.onContextElement,(e=>xo(this,void 0,void 0,(function*(){const t=(0,fe.Z)(e.target,"group-call-participant");if(!t)return;this.element.parentElement!==i&&i.append(this.element),(0,be.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,Os.Z)(this.buttons,(e=>xo(this,void 0,void 0,(function*(){const t=yield e.verify(s);return e.element.classList.toggle("hide",!t),t})))),(0,Ns.Z)(e.touches?e.touches[0]:e,this.element,"right"),mt.Z.openBtnMenu(this.element))}))),t),t.add(d.Z)("group_call_participant",(({groupCallId:e,participant:t})=>{if(this.instance.id===e){const e=(0,F.Z)(t.peer);this.targetPeerId===e&&mt.Z.close()}}));let i=document.body;(0,wo.Ms)(document.body,(()=>{const e=(0,wo.rB)();i=e?y.Z.getPopups(Yo)[0].getContainer():document.body,e||mt.Z.close()}),t)}}class _o{constructor(e){(0,bn.Z)(this,e);const t="group-call-participants",i=new P.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 Io(this.instance),{instance:a,listenerSetter:o}=this;this.contextMenu=new Ao(Object.assign(Object.assign({},e),{onContextElement:n.list,listenerSetter:o,instance:a})),this.groupCallParticipantsVideo=new To(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 xs.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,F.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 xo(this,void 0,void 0,(function*(){(yield e.participants).forEach((e=>{this.updateParticipant(e)}))}))}destroy(){this.sortedList.destroy(),this.groupCallParticipantsVideo.destroy()}}class Fo{constructor(e){this.appendTo=e,this.descriptionIntl=new S.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===co.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 Do{constructor(e){this.appendTo=e,this.peerTitle=new R.Z({peerId:0})}update(e){const{peerTitle:t,appendTo:i}=this,s=e.groupCall,n=e.chatId.toPeerId(!0);s.title?(0,A.Z)(i,(0,D.Z)(s.title)):(t.peerId!==n&&(t.peerId=n,t.update()),t.element.parentElement!==i&&i.append(t.element))}}var Ro=i(2820);function Bo(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,T.Z)(n),i.isDanger&&n.classList.add(s+"-red"),i.isConfirm&&n.classList.add(s+"-green"),i.callback&&(0,w.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,S.ag)(i.text):i.text;t.classList.add(s+"-text","call-button-text"),e.append(n,t),a=e}return a}var No=i(3757);const Oo="movable-element",Uo="movable-element-resize-handler";class Ho extends l.Z{constructor(e){super(!0),this.onResize=()=>{this.fixDimensions(),this.fixPosition(),this.setPosition()},(0,bn.Z)(this,e),this.top=this.left=this.width=this.height=0,this.element.classList.add(Oo),this.addResizeHandlers(),this.setSwipeHandler(),o.Z.addEventListener("resize",this.onResize)}destroyElements(){this.element.classList.remove(Oo),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(Uo,Uo+"-side-"+e),this.element.append(t),t}))}setSwipeHandler(){let e,t,i,s,n;const a=this.swipeHandler=new No.Z({element:this.element,onSwipe:(a,o,r)=>{if(a*=-1,o*=-1,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")?Pe.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")?Pe.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,fe.Z)(t,Uo);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=Pe.Z.height/2-this.height/2,this.left=Pe.Z.width/2-this.width/2,this.setPosition()}fixDimensions(){this.width=(0,Fi.Z)(this.width,this.minWidth,Pe.Z.width),this.height=(0,Fi.Z)(this.height,this.minHeight,Pe.Z.height)}fixPosition(){this.top=(0,Fi.Z)(this.top,0,Pe.Z.height-this.height),this.left=(0,Fi.Z)(this.left,0,Pe.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 zo,jo=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 Go{constructor(e){zo.set(this,void 0),(0,bn.Z)(this,e),this.toggleMovable(!c.Z),this.listenerSetter.add(o.Z)("changeScreen",((e,t)=>{t!==o._.mobile&&e!==o._.mobile||this.toggleMovable(!c.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,zo,"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=jo(this,zo,new Ho(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(),jo(this,zo,void 0,"f")}}}function Vo(e,t,i){return t.forEach((t=>{t.classList.toggle(e,i)})),()=>Vo(e,t,!i)}zo=new WeakMap;var Ko,Wo;function $o(e){const t=Ko;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"}(Ko||(Ko={})),function(e){e[e.HAND=0]="HAND",e[e.MUTED=1]="MUTED",e[e.UNMUTED=2]="UNMUTED"}(Wo||(Wo={}));let qo={width:420,height:640};const Qo="group-call";class Yo extends y.Z{constructor(){super("popup-group-call",{body:!0,withoutOverlay:!0,closable:!0,title:!0}),this.onFullScreenClick=()=>{(0,wo.Dj)(this.container)},this.onToggleControls=e=>{this.container.classList.toggle("show-controls",e),this.buttonsContainer.classList.toggle("show-controls",e)},this.toggleDisability=Vo.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"))?new vs.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,wo.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),Ya.Z.setThemeColor(e?"#000000":void 0))},this.toggleBigLayout=()=>{var e;const t=(0,wo.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(Qo,"night");const e=this.instance=Ua.ZP.groupCall,{listenerSetter:t}=this;if(!k.IS_APPLE_MOBILE){const e=this.btnFullScreen=(0,Sn.Z)("fullscreen"),i=this.btnFullScreen2=(0,Sn.Z)("fullscreen group-call-cfs"),s=this.btnExitFullScreen=(0,Sn.Z)("smallscreen");(0,w.fc)(e,this.onFullScreenClick,{listenerSetter:t}),(0,w.fc)(i,this.onFullScreenClick,{listenerSetter:t}),(0,w.fc)(s,(()=>{(0,wo.C8)()}),{listenerSetter:t}),(0,wo.Ms)(this.container,this.onFullScreenChange,t)}this.btnInvite=(0,Sn.Z)("adduser");const i=this.btnShowColumn=(0,Sn.Z)("rightpanel group-call-only-big");(0,w.fc)(i,this.toggleRightColumn,{listenerSetter:t});const n=document.createElement("div");n.classList.add("group-call-header-info"),this.title.classList.add("group-call-header-title");const a=document.createElement("div");a.classList.add("group-call-header-subtitle"),n.append(this.title,a),this.header.classList.add("group-call-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,Sn.Z)("rightpanel");o.append(...[c,r,this.btnFullScreen2].filter(Boolean)),(0,w.fc)(c,this.toggleRightColumn,{listenerSetter:t}),this.body.prepend(o);const h=new P.ZP(void 0);h.container.classList.add("group-call-big-video-container"),this.container.append(h.container),this.groupCallTitle=new Do(this.title),this.groupCallDescription=new Fo(a),this.groupCallBodyHeaderDescription=new Fo(l),this.constructButtons(),this.groupCallParticipantsVideo=new To({appendTo:h.container,instance:e,listenerSetter:t,displayPinned:!0,onLengthChange:e=>{this.videosCount=e,this.toggleBigLayout()},managers:this.managers}),this.groupCallParticipants=new _o({appendTo:this.body,instance:e,listenerSetter:t,managers:this.managers}),this.movablePanel=new Go({listenerSetter:t,movableOptions:{minWidth:400,minHeight:480,element:this.element,verifyTouchTarget:e=>{const t=e.target;return!((0,fe.Z)(t,"chatlist")||(0,fe.Z)(t,"group-call-button")||(0,fe.Z)(t,"btn-icon")||(0,fe.Z)(t,"group-call-participants-video-container")||(0,wo.rB)())}},onResize:()=>this.toggleBigLayout(),previousState:qo}),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;qo=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("group-call-buttons");const t=Bo.bind(null,Qo,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",!Ro.Z);const n=t({noRipple:!0,callback:(0,ka.Z)(this.onMuteClick,600,!0)});n.classList.add("group-call-microphone-button");const a=this.groupCallMicrophoneIcon=new yo;n.append(a.container);const o=t({icon:"settings_filled"});o.classList.add("btn-disabled"),o.classList.toggle("hide",!Ro.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===co.Z.CLOSED)return this.container.classList.contains("is-full-screen")&&(0,wo.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=Wo;return t.pFlags.can_self_unmute?t.pFlags.muted?i.MUTED:i.UNMUTED:i.HAND}(0,e);this.container.dataset.micState=i===Wo.HAND?"hand":i===Wo.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 Jo=i(9078),Xo=i(3335);class er{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===Xo.Z.CONNECTED){i=document.createElement("span"),i.classList.add("call-description-duration");const t=()=>{i.innerText=(0,Gi.Z)(e.duration,!0)};this.interval=window.setInterval(t,1e3),t()}else{let s;switch(t){case Xo.Z.PENDING:s=e.isOutgoing?"Call.StatusRinging":"Call.StatusCalling";break;case Xo.Z.REQUESTING:s="Call.StatusRequesting";break;case Xo.Z.EXCHANGING_KEYS:s="VoipExchangingKeys";break;case Xo.Z.CLOSED:s=void 0!==e.connectedAt?"Call.StatusEnded":"Call.StatusFailed";break;default:s="Call.StatusConnecting"}i=(0,S.ag)(s),void 0!==this.interval&&(clearInterval(this.interval),this.interval=void 0)}this.container.classList.toggle("has-duration",t===Xo.Z.CONNECTED),(0,O.Z)(this.container,i),this.container.parentElement||this.appendTo.append(this.container)}}class tr extends bo{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 ir="call",sr={width:400,height:580};let nr=Object.assign({},sr);class ar extends y.Z{constructor(e){super("popup-call",{withoutOverlay:!0,closable:!0}),this.instance=e,this.onFullScreenClick=()=>{(0,wo.Dj)(this.container)},this.onFullScreenChange=()=>{const e=(0,wo.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),Ya.Z.setThemeColor(e?"#000000":void 0),this.resizeVideoContainers())},this.videoContainers={};const{container:t,listenerSetter:i}=this;t.classList.add(ir,"night");const n=document.createElement("div");n.classList.add("call-avatar");const a=this.peerId=this.instance.interlocutorUserId.toPeerId(),o=new p.Z;o.classList.add("avatar-full"),o.updateWithOptions({isBig:!0,peerId:a}),n.append(o);const r=new R.Z({peerId:a}).element;r.classList.add("call-title");const d=document.createElement("div");d.classList.add("call-subtitle"),this.description=new er(d);const l=this.emojisSubtitle=document.createElement("div");l.classList.add("call-emojis"),t.append(n,r,d),k.IS_MOBILE?this.header.append(l):(this.btnFullScreen=(0,Sn.Z)("fullscreen"),this.btnExitFullScreen=(0,Sn.Z)("smallscreen hide"),(0,w.fc)(this.btnFullScreen,this.onFullScreenClick,{listenerSetter:i}),(0,w.fc)(this.btnExitFullScreen,(()=>(0,wo.C8)()),{listenerSetter:i}),(0,wo.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("call-party-states"),this.partyMutedState=document.createElement("div"),this.partyMutedState.classList.add("call-party-state");const c=(0,S.ag)("VoipUserMicrophoneIsOff",[new R.Z({peerId:a,onlyFirstName:!0,limitSymbols:18}).element]);c.classList.add("call-party-state-text");const h=new tr(!1,!0);h.setState(!1,!1),this.partyMutedState.append(h.container,c),this.partyStates.append(this.partyMutedState),this.container.append(this.partyStates),this.makeButton=Bo.bind(null,ir,this.listenerSetter),this.constructFirstButtons(),this.constructSecondButtons(),i.add(e)("state",(()=>{this.updateInstance()})),i.add(e)("mediaState",(()=>{this.updateInstance()})),this.movablePanel=new Go({listenerSetter:i,movableOptions:{minWidth:400,minHeight:580,element:this.element,verifyTouchTarget:e=>{const t=e.target;return!((0,fe.Z)(t,"call-button")||(0,fe.Z)(t,"btn-icon")||(0,wo.rB)())}},previousState:this.instance.wasTryingToJoin||this.instance.isOutgoing?nr:Object.assign({},sr)});const u=this.movablePanel.movable;u&&this.listenerSetter.add(u)("resize",(()=>{this.resizeVideoContainers()}));const f=this.controlsHover=new Mo.Z;f.setup({element:this.container,listenerSetter:this.listenerSetter,showOnLeaveToClassName:"call-buttons"}),f.showControls(!1),this.addEventListener("close",(()=>{const{movablePanel:e}=this;nr=e.state,this.microphoneIcon.destroy(),e.destroy()})),this.updateInstance()}getCallInstance(){return this.instance}constructFirstButtons(){const e=this.firstButtonsRow=document.createElement("div");e.classList.add("call-buttons","is-first");const t=Vo.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)}});Ro.Z||(s.classList.add("hide"),this.container.classList.add("no-screen")),this.muteI18nElement=new S.ZP.IntlElement({key:"Call.Mute"});const n=this.btnMute=this.makeButton({text:this.muteI18nElement.element,callback:()=>{this.instance.toggleMuted()}}),a=this.microphoneIcon=new tr(!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("call-buttons","is-second"),this.declineI18nElement=new S.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=document.createElement("div");t.classList.add("call-video-container"),e.classList.add("call-video"),e.paused&&e.play(),(0,w.fc)(t,(()=>{if(!t.classList.contains("small"))return;const e=Object.values(this.videoContainers).find((e=>!e.classList.contains("small")));e.classList.add("small"),e.style.cssText=t.style.cssText,t.classList.remove("small"),t.style.cssText="",this.resizeVideoContainers()}));const i=Po(e);return i.classList.add("call-video-blur"),t.append(i,e),t}updateInstance(){const{instance:e}=this,{connectionState:t}=e;if(t===Xo.Z.CLOSED)return this.container.classList.contains("is-full-screen")&&(0,wo.C8)(),this.btnVideo.classList.add("disabled"),void this.hide();const i=!e.isOutgoing&&t===Xo.Z.PENDING;this.declineI18nElement.compareAndUpdate({key:t===Xo.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,Te.Z)(this.partyMutedState,"is-visible",!!(null==d?void 0:d.muted),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,an.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<Xo.Z.EXCHANGING_KEYS&&Promise.resolve(e.getEmojisFingerprint()).then((e=>{(0,O.Z)(this.emojisSubtitle,(0,D.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,wo.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 or=i(2069),rr=i(9585),dr=i(2493);class lr{constructor(e){this.managers=e,this.onState=()=>{this.updateInstance(this.instance)};const t=this.listenerSetter=new ae.Z;t.add(dr.Z)("instance",(({instance:e})=>{this.instance||this.updateInstance(e)})),t.add(dr.Z)("accepting",(e=>{this.instance!==e&&this.updateInstance(e)})),t.add(Ua.ZP)("instance",(e=>{this.updateInstance(e)})),t.add(d.Z)("group_call_update",(e=>{const t=Ua.ZP.groupCall;(null==t?void 0:t.id)===e.id&&this.updateInstance(t)})),t.add(rr.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 ae.Z,this.instanceListenerSetter.add(e)("state",this.onState),e instanceof Jo.Z?this.currentDescription=this.groupCallDescription:(this.currentDescription=this.callDescription,this.instanceListenerSetter.add(e)("muted",this.onState)),this.container.classList.toggle("is-call",!(e instanceof Jo.Z)));const i=this.instance.isMuted,s=e instanceof Jo.Z?e.state:function(e,t){switch(e){case Xo.Z.CLOSING:case Xo.Z.CLOSED:return co.Z.CLOSED;case Xo.Z.CONNECTED:return t?co.Z.MUTED:co.Z.UNMUTED;default:return co.Z.CONNECTING}}(e.connectionState,i),{weave:n}=this;n.componentDidMount();const a=s===co.Z.CLOSED;(!document.body.classList.contains("is-calling")||t||a)&&(a&&n.setAmplitude(0),(0,Te.Z)(document.body,"is-calling",!a,250,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 Jo.Z)return this.groupCallTitle.update(e);(0,O.Z)(this.center,new R.Z({peerId:e.interlocutorUserId.toPeerId()}).element)}construct(){const{listenerSetter:e}=this,t=this.container=document.createElement("div");t.classList.add("sidebar-header","topbar-call-container");const i=document.createElement("div");i.classList.add("topbar-call-left");const s=this.groupCallMicrophoneIconMini=new tr,n=(0,Sn.Z)();n.append(s.container),i.append(n);const a=(0,ka.Z)((()=>{this.instance.toggleMuted()}),600,!0);(0,w.fc)(n,(e=>{(0,be.Z)(e),a()}),{listenerSetter:e});const o=this.center=document.createElement("div");o.classList.add("topbar-call-center"),this.groupCallTitle=new Do(o),this.groupCallDescription=new Fo(i),this.callDescription=new er(i);const r=document.createElement("div");r.classList.add("topbar-call-right");const d=(0,Sn.Z)("endcall_filled");r.append(d),(0,w.fc)(d,(e=>{(0,be.Z)(e);const{instance:t}=this;t&&(t instanceof Jo.Z?t.hangUp():t.hangUp("phoneCallDiscardReasonHangup"))}),{listenerSetter:e}),(0,w.fc)(t,(()=>{if(this.instance instanceof Jo.Z){if(y.Z.getPopups(Yo).length)return;(new Yo).show()}else if(this.instance instanceof or.Z){if(y.Z.getPopups(ar).find((e=>e.getCallInstance()===this.instance)))return;new ar(this.instance).show()}}),{listenerSetter:e}),t.append(i,o,r);const l=this.weave=new fo,c=l.render("topbar-call-weave");t.prepend(c),document.getElementById("column-center").prepend(t),l.componentDidMount()}}var cr=i(2614),hr=i(6009),ur=i(493),fr=i(2131),pr=i(6702),mr=i(7746),gr=i(2491),vr=i(1722),br=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 yr=new class{constructor(){this.notificationsShown={},this.notificationIndex=0,this.notificationsCount=0,this.soundsPlayed={},this.vibrateSupport=fr.Z,this.faviconEl=document.head.querySelector('link[rel="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&&pr.default.isAvailable||!1;e!==(!1!==this.registeredDevice)&&(e?pr.default.subscribe():pr.default.unsubscribe())}pr.default.setSettings(this.settings)})),on.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,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,ce.Z)(),ro.Z.addEventListener("deactivated",(()=>{this.stop()})),ro.Z.addEventListener("activated",(()=>{this.stopped&&this.start()})),ut.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)})),pr.default.addEventListener("push_init",(e=>{this.pushInited=!0,this.settings.nodesktop||this.settings.nopush?this.unregisterDevice(e):e?this.registerDevice(e):pr.default.subscribe()})),pr.default.addEventListener("push_subscribe",(e=>{this.registerDevice(e)})),pr.default.addEventListener("push_unsubscribe",(e=>{this.unregisterDevice(e)})),d.Z.addEventListener("dialogs_multiupdate",(()=>{this.topMessagesDeferred.resolve()}),{once:!0}),pr.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((()=>br(this,void 0,void 0,(function*(){e.custom.channel_id&&!(yield this.managers.appChatsManager.hasChat(e.custom.channel_id))||t.isUser()&&!(yield this.managers.appUsersManager.hasUser(t))||Ar.setInnerPeer({peerId:t,lastMsgId:(0,ht.Z)(+e.custom.msg_id)})}))))}))}buildNotification({message:e,fwdCount:t,peerReaction:i,peerTypeNotifySettings:s}){return br(this,void 0,void 0,(function*(){const n=e.peerId,a=n.isAnyChat(),o={},r=yield this.managers.appPeersManager.getPeerString(n);let d;if(s.show_previews)if("message"===e._&&e.fwd_from&&t>1)d=S.ZP.format("Notifications.Forwarded",!0,[t]);else{d=yield(0,j.Z)(e,void 0,void 0,!0);const t=null==i?void 0:i.reaction;if("reactionEmoji"===(null==t?void 0:t._)){const e="Notification.Contact.Reacted",i=[(0,mr.Z)(t.emoticon),d];d=S.ZP.format(e,!0,i)}}else d=S.ZP.format("Notifications.New",!0);i&&(o.noIncrement=!0,o.silent=!0);const l=i?(0,F.Z)(i.peer_id):e.fromId;o.title=yield(0,ur.Z)(n,!0,void 0,void 0,this.managers),a&&l!==e.peerId&&(o.title=(yield(0,ur.Z)(l,!0,void 0,void 0,this.managers))+" @ "+o.title),o.title=(0,gr.Z)(o.title),o.onclick=()=>{Ar.setInnerPeer({peerId:n,lastMsgId:e.mid})},o.message=d,o.key="msg"+e.mid,o.tag=r,o.silent=!0;const c=yield this.managers.appPeersManager.getPeerPhoto(n);c?this.managers.appAvatarsManager.loadAvatar(n,c,"photo_small").then((t=>{(e.pFlags.unread||i)&&(o.image=t,this.notify(o))})):this.notify(o)}))}toggleToggler(e=ut.Z.isIdle){if(k.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=S.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 ${St.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="assets/img/favicon.ico"){if(this.prevFavicon===e)return;const t=this.faviconEl.cloneNode();t.href=e,this.faviconEl.parentNode.replaceChild(t,this.faviconEl),this.faviconEl=t,this.prevFavicon=e}notify(e){if(this.stopped)return;e.image||(e.image="assets/img/logo_filled_rounded.png"),e.noIncrement||++this.notificationsCount,this.titleInterval||this.toggleToggler();const t=++this.notificationIndex,i=e.key||"k"+t;this.notificationsShown[i]=!0;const s=(0,_t.Z)();if(this.settings.volume>0&&!this.settings.nosound&&(this.testSound(this.settings.volume),this.soundsPlayed[e.tag]=s),!this.notificationsUiSupport||"Notification"in window&&"granted"!==Notification.permission)return!1;if(this.settings.nodesktop)return this.vibrateSupport&&!this.settings.novibrate?void navigator.vibrate([200,100,200]):void 0;let n;if("Notification"in window){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)}n=new Notification(e.title,{icon:e.image||"",body:e.message||"",tag:e.tag||"",silent:e.silent||!1})}catch(e){return this.notificationsUiSupport=!1,void pr.default.setLocalNotificationsDisabled()}n.onclick=()=>{n.close(),vr.Z.focus(),this.clear(),e.onclick&&e.onclick()},n.onclose=()=>{n.hidden||(delete this.notificationsShown[i],this.clear())},n.show&&n.show(),this.notificationsShown[i]=n,k.IS_MOBILE||setTimeout((()=>{this.hide(i)}),8e3)}}getLocalSettings(){return this.settings}hide(e){const t=this.notificationsShown[e];if(t&&"boolean"!=typeof t)try{t.close&&(t.hidden=!0,t.close())}catch(e){}}soundReset(e){delete this.soundsPlayed[e]}testSound(e){const t=(0,_t.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];if(t){this.notificationsCount>0&&--this.notificationsCount;try{"boolean"!=typeof t&&t.close&&(t.hidden=!0,t.close())}catch(e){}delete this.notificationsShown[e]}}clear(){for(const e in this.notificationsShown){const t=this.notificationsShown[e];try{"boolean"!=typeof t&&t.close&&t.close()}catch(e){}}this.notificationsShown={},this.notificationsCount=0,pr.default.hidePushNotifications()}start(){if(this.updateLocalSettings(),d.Z.addEventListener("settings_updated",this.updateLocalSettings),pr.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.clear(),window.clearInterval(this.titleInterval),this.titleInterval=0,this.setFavicon(),this.stopped=!0}registerDevice(e){if(this.registeredDevice&&(0,$a.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.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}))}};he.GO&&(he.GO.uiNotificationsManager=yr);const wr=yr;var Sr=i(2423),Cr=i(3591),Lr=i(236),Er=i(5936),Ir=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 Mr(e,t=!1){return Ir(this,void 0,void 0,(function*(){const i=[],s=(e,n)=>Ir(this,void 0,void 0,(function*(){if(e.isDirectory){const t=e.createReader();yield new Promise(((e,i)=>{t.readEntries((t=>Ir(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 Pr=i(764);function Zr(e){window[(e.protocol?e.protocol+"_":"")+e.name]=t=>{(0,be.Z)(null);let i,s,n=t.href;const a=new URL(n),o=a.host.match(/(.+?)\.t(?:elegram)?\.me/);o&&(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,Pr.Z)(n));const r=e.callback({pathnameParams:i,uriParams:s},t);return void 0===r&&r}}var kr=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 Tr extends l.Z{constructor(){super(...arguments),this.columnEl=document.getElementById("column-center"),this.offline=!1,this.updateStatusInterval=0,this.setPeerPromise=null,this.tabId=-1,this.chats=[],this.cacheStorage=new Er.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||vn.Z.replaceState();const i=t.split("?"),s=(0,Pr.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,ht.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,Ve.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",!d.Z.settings.animationsEnabled),document.body.classList.toggle("animation-level-1",!1),document.body.classList.toggle("animation-level-2",d.Z.settings.animationsEnabled),this.chatsSelectTabDebounced=(0,Ee.Z)((()=>{const e=this.chat.topbar;e.pinnedMessage&&e.pinnedMessage.setCorrectIndex(0),this.managers.apiFileManager.setQueueId(this.chat.bubbles.lazyLoadQueue.queueId)}),d.Z.settings.animationsEnabled?250:0,!1,!0),Cs.Z.setLoop(d.Z.settings.stickers.loop),s.Z.checkAnimations2(!1);for(const e of this.chats)e.setAutoDownloadMedia();S.ZP.setTimeFormat(d.Z.settings.timeFormat),this.toggleChatGradientAnimation(this.chat)},this.onDocumentPaste=(e,t)=>kr(this,void 0,void 0,(function*(){const i=ln();if(e instanceof DragEvent){const t=e.dataTransfer.types;(t.contains?t.contains("Files"):t.indexOf("Files")>=0)&&(0,be.Z)(e)}const s=yield Mr(e);if(((yield this.canDrag())||i)&&s.length){if(i)return void i.addFiles(s);const e=this.chat.input;e.willAttachType=t||(tn.Z.has(s[0].type)?"media":"document"),y.Z.createPopup(cn,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(S.ZP.lastRequestedLangCode),Qn.Z.construct(e),wr.construct(e),wr.start(),this.log=(0,r.kg)("IM",r.v9.Log|r.v9.Warn|r.v9.Debug|r.v9.Error),this.backgroundPromises={},Lr.h.settings.themes.forEach((e=>{if(e.background.slug){const t="assets/img/"+e.background.slug+".svg"+(k.IS_FIREFOX?"?1":"");this.backgroundPromises[e.background.slug]=Promise.resolve(t)}})),this.selectTab(0),ut.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),vn.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),(0,de.ZP)((()=>{s.Z.setOnlyOnePlayableGroup("lock"),s.Z.checkAnimations2(!0)}),(()=>{s.Z.setOnlyOnePlayableGroup(),s.Z.checkAnimations2(!1)})),k.IS_FIREFOX&&on.Z.oldVersion&&-1===(0,hr.Z)(on.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();Qa.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_typings",(({peerId:e,typings:t})=>{var i;const s=this.chat;if(!s||s.peerId!==e||ft.Z.isOverlayActive||o.Z.activeScreen===o._.mobile&&1!==this.tabId)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,ht.Z)(n.action.msg_id)];if(i&&i.classList.contains("emoji-big")&&(0,Be.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,w.tH)(s)}),1e3*e.t)})),this.managers.appMessagesManager.setTyping(e,{_:"sendMessageEmojiInteractionSeen",emoticon:t.emoticon})}}}));const l=e=>{const t="version"===e,i=new y.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,S.ag)(t?"Deactivated.Version.Title":"Deactivated.Title"));const a=document.createElement("div");a.classList.add("subtitle"),a.append((0,S.ag)(t?"Deactivated.Version.Subtitle":"Deactivated.Subtitle")),s.append(n,a),document.body.classList.add("deactivated");const o=t?()=>{vr.Z.reload()}:()=>{document.body.classList.add("deactivated-backwards"),ro.Z.activateInstance(),setTimeout((()=>{document.body.classList.remove("deactivated","deactivated-backwards")}),333)};i.addEventListener("close",o),i.show()};ro.Z.addEventListener("deactivated",l),ro.Z.deactivatedReason&&l(ro.Z.deactivatedReason),this.addEventListener("chat_changing",(({to:e})=>{this.toggleChatGradientAnimation(e)})),d.Z.addEventListener("service_notification",(e=>{(0,li.Z)({button:{langKey:"OK",isCancel:!0},description:(0,ot.ZP)(e.message)})})),d.Z.addEventListener("payment_sent",(({peerId:e,mid:t,receiptMessage:i})=>kr(this,void 0,void 0,(function*(){const s=yield this.managers.appMessagesManager.getMessageByPeer(e,t);if(!s)return;const n=i.action;(0,me.bC)({langPackKey:"PaymentInfoHint",langPackArguments:[(0,yt.Z)(n.total_amount,n.currency),(0,D.Z)(s.media.title)]})})))),window.onSpoilerClick=e=>{const t=(0,fe.Z)(e.target,"spoiler"),i=(0,fe.Z)(t,"spoilers-container")||t.parentElement,s="is-spoiler-visible",n=i.classList.contains(s);n||((0,be.Z)(e),"click"!==w.pf&&window.addEventListener("click",be.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,Te.Z)(i,s,!0,200,(()=>{i.dataset.spoilerTimeout=""+window.setTimeout((()=>{(0,Te.Z)(i,s,!1,200,(()=>{i.classList.remove("will-change"),delete i.dataset.spoilerTimeout}))}),5e3)}),a)},d.Z.addEventListener("sticker_updated",(({type:e,faved:t})=>{"faved"===e?(0,me.bC)({langPackKey:t?"AddedToFavorites":"RemovedFromFavorites"}):t||(0,me.bC)({langPackKey:"RemovedFromRecent"})})),on.Z.addEventListener("notificationBuild",(e=>{(this.chat.peerId!==e.message.peerId||ut.Z.isIdle)&&wr.buildNotification(e)})),this.addEventListener("peer_changed",(e=>kr(this,void 0,void 0,(function*(){document.body.classList.toggle("has-chat",!!e),this.emojiAnimationContainer.textContent="",this.overrideHash(e),on.Z.updateTabState("chatPeerIds",this.chats.map((e=>e.peerId)).filter(Boolean))})))),ao.Z.setToCache("chatPositions",{}),(De.Z||Ba.Z)&&(this.topbarCall=new lr(e)),De.Z&&(dr.Z.addEventListener("instance",(({instance:e})=>{const t=new ar(e);e.addEventListener("acceptCallOverride",(()=>this.discardCurrentCall(e.interlocutorUserId.toPeerId(),void 0,e).then((()=>(dr.Z.dispatchEvent("accepting",e),!0))).catch((()=>!1)))),t.addEventListener("close",(()=>{const t=dr.Z.currentCall;t&&t!==e&&!e.wasTryingToJoin&&e.hangUp("phoneCallDiscardReasonBusy")}),{once:!0}),t.show()})),dr.Z.addEventListener("incompatible",(e=>kr(this,void 0,void 0,(function*(){(0,me.bC)({langPackKey:"VoipPeerIncompatible",langPackArguments:[yield(0,Bt.Z)({peerId:e.toPeerId()})]})}))))),ro.Z.activateInstance();const c=()=>{lo.default.setAuthorized(!0)};setInterval(c,x.s2),c(),Zr({name:"showMaskedAlert",callback:(e,t)=>{const i=t.href,s=t.cloneNode(!0);s.className="anchor-url",s.innerText=i,s.removeAttribute("onclick"),new vs.Z("popup-masked-url",{titleLangKey:"OpenUrlTitle",descriptionLangKey:"OpenUrlAlert2",descriptionLangArgs:[s],buttons:[{langKey:"Open",callback:()=>{s.click()}}]}).show()}}),Zr({name:"execBotCommand",callback:({uriParams:e})=>{const{command:t,bot:i}=e;this.managers.appMessagesManager.sendText(this.chat.peerId,"/"+t+(i?"@"+i:""))}}),Zr({name:"searchByHashtag",callback:({uriParams:e})=>{const{hashtag:t}=e;t&&this.chat.initSearch("#"+t+" ")}}),[["addstickers",Me.STICKER_SET],["addemoji",Me.EMOJI_SET]].forEach((([e,t])=>{Zr({name:e,callback:({pathnameParams:e})=>{if(!e[1])return;const i={_:t,set:e[1]};this.processInternalLink(i)}}),Zr({name:e,protocol:"tg",callback:({uriParams:e})=>{const i=this.makeLink(t,e);this.processInternalLink(i)}})})),Zr({name:"invoice",callback:({pathnameParams:e})=>{const t={_:Me.INVOICE,slug:e.length>1?e[1]:e[0].slice(1)};this.processInternalLink(t)}}),Zr({name:"joinchat",callback:({pathnameParams:e})=>{const t={_:Me.JOIN_CHAT,invite:e[1]||decodeURIComponent(e[0]).slice(1)};this.processInternalLink(t)}}),Ba.Z&&Zr({name:"voicechat",protocol:"tg",callback:({uriParams:e})=>{const t=this.makeLink(Me.VOICE_CHAT,e);this.processInternalLink(t)}}),Zr({name:"im",callback:({pathnameParams:e,uriParams:t})=>kr(this,void 0,void 0,(function*(){let i;i=Sr.kO.test(e[0])?{_:Me.USER_PHONE_NUMBER,phone:e[0].slice(1)}:"c"===e[0]?{_:Me.PRIVATE_POST,channel:e[1],post:e[2],thread:"thread"in t&&t.thread,comment:t.comment}:{_:Me.MESSAGE,domain:e[0],post:e[1],comment:t.comment,start:"start"in t?t.start:void 0},this.processInternalLink(i)}))}),Zr({name:"resolve",protocol:"tg",callback:({uriParams:e})=>{let t;e.phone?t=this.makeLink(Me.USER_PHONE_NUMBER,e):"telegrampassport"===e.domain||(t=this.makeLink(Me.MESSAGE,e)),this.processInternalLink(t)}}),Zr({name:"privatepost",protocol:"tg",callback:({uriParams:e})=>{const t=this.makeLink(Me.PRIVATE_POST,e);this.processInternalLink(t)}}),Zr({name:"invoice",protocol:"tg",callback:({uriParams:e})=>{const t=this.makeLink(Me.INVOICE,e);this.processInternalLink(t)}}),["joinchat","join"].forEach((e=>{Zr({name:e,protocol:"tg",callback:({uriParams:e})=>{const t=this.makeLink(Me.JOIN_CHAT,e);this.processInternalLink(t)}})})),this.onHashChange(!0),this.attachKeydownListener()}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(d.Z.settings.animationsEnabled&&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(ft.Z.isOverlayActive||e.has(s))return;const a=t.target,r=this.chat;if((!(s.startsWith("Arrow")||t.shiftKey&&"Shift"===s)||n)&&("KeyC"!==t.code||!t.ctrlKey&&!t.metaKey||"INPUT"===a.tagName)){if(!t.altKey||"ArrowUp"!==s&&"ArrowDown"!==s){if("ArrowUp"===s&&"scheduled"!==this.chat.type){if(r.input.editMsgId||!r.input.isInputEmpty())return;this.managers.appMessagesManager.getFirstMessageToEdit(r.peerId,r.threadId).then((e=>{e&&(r.input.initMessageEditing(e.mid),(0,be.Z)(t))}))}else if("ArrowDown"===s)return}else(0,be.Z)(t),this.managers.dialogsStorage.getNextDialog(this.chat.peerId,"ArrowDown"===s,zi.default.filterId).then((e=>{e&&this.setPeer({peerId:e.peerId})}));if((null===(i=null==r?void 0:r.input)||void 0===i?void 0:i.messageInput)&&t.target!==r.input.messageInput&&"INPUT"!==a.tagName&&!a.isContentEditable&&!c.Z&&(!o.Z.isMobile||1===this.tabId)&&!r.selection.isSelecting&&!r.input.recording){r.input.messageInput.focus(),(0,Tt.Z)(r.input.messageInput);const e=new KeyboardEvent(t.type,t);r.input.messageInput.dispatchEvent(e)}}}))}makeLink(e,t){return Object.assign({_:e},t)}processInternalLink(e){return kr(this,void 0,void 0,(function*(){switch(null==e?void 0:e._){case Me.MESSAGE:{const t=e.post?(0,ht.Z)(+e.post):void 0,i=e.comment?(0,ht.Z)(+e.comment):void 0;this.openUsername({userName:e.domain,lastMsgId:t,commentId:i,startParam:e.start});break}case Me.PRIVATE_POST:{const t=e.channel.toChatId(),i=t.toPeerId(!0);if((yield this.managers.appChatsManager.getChat(t)).deleted)try{yield this.managers.appChatsManager.resolveChannel(t)}catch(e){throw(0,me.bC)({langPackKey:"LinkNotFound"}),e}const s=(0,ht.Z)(+e.post),n=e.thread?(0,ht.Z)(+e.thread):void 0;n?this.openThread(i,s,n):this.setInnerPeer({peerId:i,lastMsgId:s,threadId:n});break}case Me.EMOJI_SET:case Me.STICKER_SET:new I.Z({id:e.set},e._===Me.EMOJI_SET).show();break;case Me.JOIN_CHAT:this.managers.appChatsManager.checkChatInvite(e.invite).then((t=>{t.chat&&this.managers.appChatsManager.saveApiChat(t.chat,!0),"chatInviteAlready"!==t._&&"chatInvitePeek"!==t._?new Ue(e.invite,t):this.setInnerPeer({peerId:t.chat.id.toPeerId(!0)})}),(e=>{"INVITE_HASH_EXPIRED"===e.type&&(0,me.Am)((0,S.ag)("InviteExpired"))}));break;case Me.VOICE_CHAT:Ba.Z&&this.joinGroupCall(e.chat_id.toPeerId(!0),e.id);break;case Me.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,me.bC)({langPackKey:"Alert.UserDoesntExists"})}));break;case Me.INVOICE:this.managers.appPaymentsManager.getInputInvoiceBySlug(e.slug).then((e=>{this.managers.appPaymentsManager.getPaymentForm(e).then((t=>{new Ti(void 0,e,t)}))}));break;default:this.log.warn("Not supported internal link:",e)}}))}openUrl(e){const{url:t,onclick:i}=(0,Cr.Z)(e);if(!i)return;const s=document.createElement("a");s.href=t,window[i](s)}openUsername(e){const{userName:t,lastMsgId:i,threadId:s,commentId:n,startParam:a}=e;return this.managers.appUsersManager.resolveUsername(t).then((e=>{const t="user"===e._,o=e.id.toPeerId(!t);return s?this.openThread(o,i,s):n?this.openComment(o,i,n):this.setInnerPeer({peerId:o,lastMsgId:i,startParam:a})}),(e=>{"USERNAME_NOT_OCCUPIED"===e.type?(0,me.bC)({langPackKey:"NoUsernameFound"}):"USERNAME_INVALID"===e.type&&(0,me.bC)({langPackKey:"Alert.UserDoesntExists"})}))}openThread(e,t,i){return this.managers.appMessagesManager.reloadMessages(e,i).then((s=>(s?this.managers.appMessagesManager.generateThreadServiceStartMessage(s):t=void 0,this.setInnerPeer({peerId:e,lastMsgId:t,threadId:i,type:"discussion"}))))}openComment(e,t,i){return this.managers.appMessagesManager.getDiscussionMessage(e,t).then((e=>this.openThread(e.peerId,i,e.mid)))}callUser(e,t){return kr(this,void 0,void 0,(function*(){dr.Z.getCallByUserId(e)||((yield this.managers.appProfileManager.getProfile(e)).pFlags.phone_calls_private?(0,Bt.Z)({peerId:e.toPeerId()}).then((e=>(0,li.Z)({descriptionLangKey:"Call.PrivacyErrorMessage",descriptionLangArgs:[e],button:{langKey:"OK",isCancel:!0}}))):(yield this.discardCurrentCall(e.toPeerId()),dr.Z.startCallInternal(e,"video"===t)))}))}discardCurrentCall(e,t,i){return Ua.ZP.groupCall&&Ua.ZP.groupCall!==t?this.discardGroupCallConfirmation(e):dr.Z.currentCall&&dr.Z.currentCall!==i?this.discardCallConfirmation(e):Promise.resolve()}discardCallConfirmation(e){return kr(this,void 0,void 0,(function*(){const t=dr.Z.currentCall;t&&(yield Promise.all([(0,Bt.Z)({peerId:t.interlocutorUserId.toPeerId(!1)}),(0,Bt.Z)({peerId:e})]).then((([t,i])=>(0,li.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 kr(this,void 0,void 0,(function*(){const t=Ua.ZP.groupCall;t&&(yield Promise.all([(0,Bt.Z)({peerId:t.chatId.toPeerId(!0)}),(0,Bt.Z)({peerId:e})]).then((([t,i])=>(0,li.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"}}))),Ua.ZP.groupCall===t&&(yield t.hangUp()))}))}joinGroupCall(e,t){return kr(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,me.bC)({langPackKey:"VoiceChat.Chat.Ended"});yield(0,li.Z)({descriptionLangKey:"VoiceChat.Chat.StartNew",button:{langKey:"VoiceChat.Chat.StartNew.OK"}})}(()=>{kr(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)}Ua.ZP.joinGroupCall(i,t.id,!0,!1)}))})()}))}setCurrentBackground(e=!1){const t=Ya.Z.getTheme();if(t.background.slug){const i=Lr.h.settings.themes.find((e=>e.name===t.name));return this.getBackground(t.background.slug).then((t=>this.setBackground(t,e)),(()=>(t.background=(0,Xn.Z)(i.background),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=ao.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,Je.Z)(t.bubbles,"desc").filter((e=>e>0&&!t.skippedMids.has(e))),top:e};s[i]=n,this.log("saved chat position:",n)}ao.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=ao.Z.getFromCache("chatPositions");return i&&i[t]}applyCurrentTheme(e,t,i){return t&&(this.backgroundPromises[e]=Promise.resolve(t)),Ya.Z.setTheme(),this.setCurrentBackground(void 0===i?!!e:i)}chatsSelectTab(e,t){if(this.prevTab!==e){if(!1===t&&this.prevTab&&oo([e,this.prevTab].filter(Boolean)),this.prevTab){this.prevTab.classList.remove("active"),this.chatsSelectTabDebounced(),d.Z.settings.animationsEnabled&&!1!==t&&(0,de.YW)((0,Qe.Z)(400),400);const i=(0,Se.Z)(this.prevTab);(0,Se.Z)(e)>i&&vn.Z.pushItem({type:"chat",onPop:e=>{this.setPeer({},e),(0,Pn.Z)()}})}e.classList.add("active"),this.prevTab=e}}init(){document.addEventListener("paste",this.onDocumentPaste,!0),c.Z||this.attachDragAndDropListeners(),this.markupTooltip=new io(this),this.markupTooltip.handleSelection()}attachDragAndDropListeners(){const e=[],t=[];let i=!1;const s=(r,d)=>kr(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=ln(),u=yield Mr(r,!0);if(!c||!(yield this.canDrag())&&!h)return void(n=0);const f=h?o:a,p=h?t:e;if(d&&!p.length){const e=c&&!u.length,t=u.filter((e=>tn.Z.has(e))).length;this.log("drag files",u),h?(h.appendDrops(f),(u.length||e)&&p.push(new no(f,{header:"Preview.Dragging.AddItems",headerArgs:[u.length],onDrop:e=>{s(e,!1),this.log("drop",e),this.onDocumentPaste(e,"document")}}))):((u.length||e)&&p.push(new no(f,{icon:"dragfiles",header:"Chat.DropTitle",subtitle:"Chat.DropAsFilesDesc",onDrop:e=>{s(e,!1),this.log("drop",e),this.onDocumentPaste(e,"document")}})),(t||e)&&p.push(new no(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,Te.Z)(f,"is-visible",d,200,(()=>{d||(p.forEach((e=>{e.destroy()})),p.length=0)})),d?p.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,be.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 kr(this,void 0,void 0,(function*(){const e=this.chat;return!(!(null==e?void 0:e.peerId)||ft.Z.isOverlayActive||!(yield e.canSend("send_media")))}))}overrideHash(e){return kr(this,void 0,void 0,(function*(){let t;if(e){const i=yield this.managers.appPeersManager.getPeerUsername(e);t=i?"@"+i:""+e}vn.Z.overrideHash(t)}))}selectTab(e,t){var i;!1===t&&oo([n.ZP.sidebarEl,this.columnEl,a.ZP.sidebarEl]),document.body.classList.toggle(n.ir,0===e);const s=this.tabId;-1!==s&&this.overrideHash(e>0?null===(i=this.chat)||void 0===i?void 0:i.peerId:void 0),this.log("selectTab",e,s);let r=d.Z.settings.animationsEnabled?(0,le.d1)():Promise.resolve();if(-1!==s&&s!==e&&d.Z.settings.animationsEnabled&&!1!==t&&o.Z.activeScreen!==o._.large){const e=100+(o.Z.isMobile?250:200);r=(0,Qe.Z)(e),(0,de.YW)(r,e)}this.tabId=e,(0,Pn.Z)(),o.Z.isMobile&&2===s&&e<2&&document.body.classList.remove(a.HQ),-1!==s&&e>s&&(e<2||!vn.Z.findItemByType("im"))&&vn.Z.pushItem({type:"im",onPop:e=>{this.setPeer({},e)}});const l=window.onImTabChange;return l&&l(e),r}updateStatus(){return this.managers.appUsersManager.updateMyOnlineStatus(this.offline)}createNewChat(){const e=new Xa(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)vn.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.peerId);const e=a.ZP.getTab(Va);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 kr(this,void 0,void 0,(function*(){this.init&&(this.init(),this.init=null),null!==(i=e.peerId)&&void 0!==i||(e.peerId=m.NM);const{peerId:s,lastMsgId:a}=e,r=this.chat,d=this.chats.indexOf(r);if(s){if(d>0&&r.peerId&&r.peerId!==s){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(d>0)return void this.spliceChats(d,void 0,t);if(o.Z.activeScreen===o._.medium)return void this.selectTab(+!this.tabId,t)}if(s===r.peerId&&o.Z.activeScreen<=o._.medium&&document.body.classList.contains(n.ir))return this.selectTab(1,t),!1;if(s||o.Z.activeScreen!==o._.mobile){const i=yield r.setPeer(s,a,e.startParam),n=(null==i?void 0:i.cached)?i.promise:Promise.resolve();s&&Promise.all([n,r.setBackgroundPromise]).then((()=>{setTimeout((()=>{setTimeout((()=>{this.chatsSelectTab(this.chat.container)}),0),this.selectTab(1,t)}),0)}))}return s?void 0:(this.selectTab(0,t),!1)}))}setInnerPeer(e){var t;const{peerId:i}=e;if(i===m.NM||!i)return;e.threadId&&(e.type="discussion");const s=null!==(t=e.type)&&void 0!==t?t:e.type="chat",n=this.chats.findIndex((e=>e.peerId===i&&e.type===s));if(-1!==n)return this.spliceChats(n+1),this.setPeer(e);const a=this.chat;let o=a;return a.inited&&(o=this.createNewChat()),s&&(o.setType(s),e.threadId&&(o.threadId=e.threadId)),this.dispatchEvent("chat_changing",{from:a,to:o}),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){return kr(this,void 0,void 0,(function*(){const i=e.isUser();if(i&&(yield this.managers.appUsersManager.isBot(e)))return;const s=yield this.managers.appProfileManager.getPeerTypings(e);if(!(null==s?void 0:s.length))return;const n=s[0],a={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"}},o=i?a.private:s.length>1?a.multi:a.chat;let r=n.action;if(s.length>1){const e={};s.forEach((t=>{const i=t.action._;void 0===e[i]&&(e[i]=0),++e[i]})),Object.keys(e).length>1&&(r={_:"sendMessageTypingAction"})}const d=o[r._];if(!d)return;let l,c;if(e.isAnyChat()){const e=new R.Z;l=e.update({peerId:n.userId.toPeerId(!1),onlyFirstName:!0}),c=[e.element,s.length-1],yield l}t||(t=document.createElement("span")).classList.add("online","peer-typing-container"),t.classList.toggle("peer-typing-flex","sendMessageChooseStickerAction"===r._||"sendMessageEmojiInteractionSeen"===r._);let h=t.firstElementChild;if(h?h.dataset.action!==r._&&h.replaceWith(this.getTypingElement(r)):(h=this.getTypingElement(r),t.prepend(h)),"sendMessageEmojiInteractionSeen"===r._){c?c.pop():c=[];const e=(0,cr.Z)((0,D.Z)(r.emoticon));c.push(e)}const u=(0,S.ag)(d,c);return u.classList.add("peer-typing-description"),t.childElementCount>1?t.lastElementChild.replaceWith(u):t.append(u),t}))}getChatStatus(e){return kr(this,void 0,void 0,(function*(){const t=yield this.getPeerTyping(e.toPeerId(!0));if(t)return{cached:!0,result:Promise.resolve(t)};const i=yield this.managers.acknowledged.appProfileManager.getChatFull(e),s=Promise.resolve(i.result).then((t=>kr(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,ra.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,S.v_)([a,(0,S.ag)("OnlineCount",[(0,Ne.Z)(o)])],!1)),a=e}return a}))));return{cached:i.cached,result:s}}))}getUserStatus(e,t){var i;return kr(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,As.Z)(n);if(!n.pFlags.bot){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){return kr(this,void 0,void 0,(function*(){if(!e)return;let i;return i=e.isAnyChat()?this.getChatStatus(e.toChatId()):this.getUserStatus(e.toUserId(),t),i}))}setPeerStatus(e,t,i,s,n,a){return kr(this,void 0,void 0,(function*(){if(!i){const i=t.querySelector(".peer-typing-container");if(i&&(yield this.getPeerTyping(e,i)))return}const o=yield this.getPeerStatus(e,a);if(!n())return;const r=()=>kr(this,void 0,void 0,(function*(){const e=o&&(yield o.result);if(n())return()=>(0,O.Z)(t,e||d)})),d=s?"":"";return!o||o.cached?yield r():i?()=>(t.textContent=d,r().then((e=>e&&e()))):void 0}))}setChoosingStickerTyping(e){this.managers.appMessagesManager.setTyping(this.chat.peerId,{_:e?"sendMessageCancelAction":"sendMessageChooseStickerAction"})}}const xr=new Tr;he.GO&&(he.GO.appImManager=xr);const Ar=xr},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){var t;if(!e)return;let i;if(e.action)i=e.action.photo;else if(e.media){let s=e.media;s.webpage?s=s.webpage:"messageExtendedMedia"===(null===(t=s.extended_media)||void 0===t?void 0:t._)&&(s=s.extended_media.media),i=s.photo||s.document}return i}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]}},7030:(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 f=i(9124);class p 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,f.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(3692),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 M=i(630);class P{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 M.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 M.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 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];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:f,networkCost:p,username:m}=e;if(t)return{candidate:t,sdpMLineIndex:i,sdpMid:s};throw"no sdpString"}static generateOffer(e){return T()?Z.generateOffer(e):x()?k.generateOffer(e):P.generateOffer(e)}static generateAnswer(e){return T()?Z.generateAnswer(e):x()?k.generateAnswer(e):P.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 p({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,f.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:()=>f});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 f 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 f=r.get(h);c&&t.addEventListener("ended",(()=>{this.log("[track] onended"),r.delete(h)}),{once:!0}),a&&d.addTrack(e,t,i);const p=c?e:d.outputStream;if(f)f.paused&&f.play().catch(n.Z),f.srcObject=p;else{if(f=document.createElement(l),f.autoplay=!0,f.srcObject=p,f.volume=1,"undefined"!==f.sinkId){const{outputDeviceId:e}=this;e&&f.setSinkId(e)}c?(f.setAttribute("playsinline","true"),f.muted=!0):o.appendChild(f),r.set(h,f)}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),f=i(3855),p=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 f.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:p.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),f=i(8479),p=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 f=d||r,p={audio:r,video:d};if(n.entries.forEach((e=>{if("sendonly"===e.direction){const t=p[e.type];if(!t)return;n.setEntrySource(e,t.sourceGroups||t.source),n.setEntryPeerId(e,l.Z.myId)}})),u!==f.params){const e=JSON.parse(f.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,f.Z)(d.transport),d.transport.ufrag=o.ufrag,d.transport.pwd=o.pwd,d.transport.fingerprints=[o.fingerprint],d.transport.candidates=[];const l=new p.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 p.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),M=i(9585),P=i(2946),Z=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 M.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,Z.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,P.Z)(e.peer),o=!!e.pFlags.left,r=this.participantsSsrcs.get(a)||[];if(e.presentation&&!o){const{source:t}=(0,Z._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,Z.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),f=i(9125),p=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,f.Z)(),video:t&&(0,m.Z)()},s=new u.Z(h.iK);try{const t=yield(0,p.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)}))}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}}),f=u.createPeerConnection();return f.addEventListener("negotiationneeded",(()=>{u.negotiate()})),f.addEventListener("track",(e=>{o("ontrack",e),h.onTrack(e)})),f.addEventListener("iceconnectionstatechange",(()=>{h.dispatchEvent("state",h.state);const{iceConnectionState:e}=f;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},f=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){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=f(this,c,"f"),t=f(this,h,"f"),i=f(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){f(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 M{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 P,Z,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(P.set(this,void 0),Z.set(this,void 0),k.set(this,void 0),T.set(this,void 0),x(this,P,e,"f"),"string"==typeof t){if(x(this,Z,t,"f"),"m"===e){const e=t.split(" ");x(this,k,new M(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 M?(x(this,k,t,"f"),x(this,Z,t.toString(),"f")):t instanceof y&&(x(this,T,t,"f"),x(this,Z,t.value?`${t.key}:${t.value}`:t.key,"f"))}get key(){return A(this,P,"f")}get value(){return A(this,Z,"f")}get parsed(){return A(this,T,"f")}get mediaLineParts(){return A(this,k,"f")}toString(){return`${this.key}=${this.value}`}}P=new WeakMap,Z=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,Q,Y,J=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},X=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),Q.set(this,void 0),Y.set(this,void 0),J(this,$,e,"f"),J(this,q,e[0],"f"),J(this,Q,J(this,Y,null,"f"),"f")}get lines(){return X(this,$,"f")}get mediaLine(){return X(this,q,"f")}get mediaLineParts(){return X(this,q,"f").mediaLineParts}get mediaType(){return this.mediaLineParts.type}get direction(){if(!X(this,Y,"f")){const e=this.attributes;let t;t=e.get("sendonly").exists?"sendonly":e.get("recvonly").exists?"recvonly":e.get("inactive").exists?"inactive":"sendrecv",J(this,Y,t,"f")}return X(this,Y,"f")}get isSending(){return"sendrecv"===this.direction||"sendonly"===this.direction}get isReceiving(){return"sendrecv"===this.direction||"recvonly"===this.direction}get attributes(){return X(this,Q,"f")||J(this,Q,new W(this.lines),"f"),X(this,Q,"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,Q=new WeakMap,Y=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 p(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,f=u?void 0:t[n],p="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}]:f["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||p||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=f["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})},3785:(e,t,i)=>{"use strict";i.d(t,{Z:()=>r});var s=i(8115),n=i(1229),a=i(7197);const o=new RegExp(`(^${n.Z})`);function r(e,t=!1){if(!e)return"";const i=e.trim().split(" ");if(!i[0])return"";const n=[],r=i[0].match(o),d=(null==r?void 0:r[0])||i[0][0];if(r&&n.push((0,a.Z)(d)),t||1===i.length)return(0,s.Z)(d,void 0,n);const l=i[1].match(o),c=(null==l?void 0:l[0])||i[1][0];return l&&n.push(Object.assign(Object.assign({},(0,a.Z)(c)),{offset:c.length})),(0,s.Z)(d+c,void 0,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}},3066:(e,t,i)=>{"use strict";i.d(t,{Z:()=>a});var s=i(3512),n=i(4776);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(4776);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)("")}},4776:(e,t,i)=>{"use strict";i.d(t,{LD:()=>A,KZ:()=>_,SZ:()=>j,ZP:()=>z,Cx:()=>V,Hc:()=>G});var s=i(2423),n=i(3447),a=i(9976),o=i(8479),r=i(4056),d=i(1379),l=i(6535);function c(e){return e.target="_blank",e.rel="noopener noreferrer",e}var 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 f=u;var p=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),M=i(3624),P=i(5565),Z=i(6854),k=i(645);const T=new ResizeObserver((e=>{for(const t of e)t.target.parentElement.setDimensionsFromRect(t.contentRect)})),x=new w.Z;class A extends HTMLElement{constructor(){super(),this.paused=!0,this.classList.add("custom-emoji")}get docId(){return this.dataset.docId}static create(e){const t=new A;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(this,this.renderer.animationGroup)}disconnectedCallback(){this.isConnected||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(j(!0)):this.replaceChildren())}this.player&&y.Z.removeAnimationByPlayer(this),x&&x.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;this.paused&&(this.paused=!1,this.player instanceof HTMLVideoElement&&(this.player.currentTime=(null===(e=this.renderer.lastPausedVideo)||void 0===e?void 0:e.currentTime)||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}}class _ 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(){R.has(this)||(T.observe(this.canvas),R.add(this),this.connectedCallback=void 0)}disconnectedCallback(){var e;this.isConnected||(T.unobserve(this.canvas),this.customEmojis.forEach((e=>{e.forEach((e=>{e.clear()}))})),R.delete(this),this.playersSynced.clear(),null===(e=this.middlewareHelper)||void 0===e||e.clean(),this.customEmojis.clear(),this.disconnectedCallback=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=N.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,P.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(N.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&&(O(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||!x),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),f=n.customEmojis.get(h),p=2===o.sticker,m="video/webm"===o.mime_type&&!S.Z,g=(p||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:F,managers:r,isCustomEmoji:!0,group:"none",loadPromises:w,middleware:d,exportLoad:a||!1===t?2:1,needFadeIn:!1,loadStickerMiddleware:g&&d?d.create().get((()=>!!P.middlewares.size)):void 0,static:m,onlyThumb:i,withThumb:null!=s?s:!n.clearedElements.has(f)&&void 0,syncedVideo:this.isSelectable});c&&I.then((()=>c.push(...w)));const M={elements:u};if(1===o.sticker||i||m)return this.isSelectable&&(M.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),M)));let P;M.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,P&&(e.syncedPlayer=P,e.paused?e.syncedPlayer.pausedElements.add(e):s.paused&&s.play()),e.isConnected&&y.Z.addAnimation(e,e.renderer.animationGroup)})),(s instanceof b.Z||s instanceof HTMLVideoElement&&this.isSelectable)&&(P.player=s,n.playersSynced.set(f,s)),s instanceof b.Z?(s.group=n.animationGroup,null!==(t=s.overrideRender)&&void 0!==t||(s.overrideRender=e=>{N.set(s,e)})):HTMLVideoElement,g){const e=(0,b.a)(this.size.width,this.size.height);n.canvas.dpr=e,U()}}));const Z=[h,l.width,l.height].join("-");if(g){P=B.get(Z),P||(P={player:void 0,middlewares:new Set,pausedElements:new Set,key:Z},B.set(Z,P));for(const e of u){const t=e.middlewareHelper.get();P.middlewares.add(t),t.onClean((()=>{var i,s;if(P.middlewares.delete(t),!P.middlewares.size){if(P.player){const t=N.get(P.player);if(t&&(null===(s=(i=t).close)||void 0===s||s.call(i),N.delete(P.player)),N.delete(P.player),P.player instanceof b.Z)P.player.overrideRender=L.Z,P.player.remove();else if(P.player instanceof HTMLVideoElement){const t=k.Z.generateName(""+e.docId,0,0,void 0,void 0);delete v._i[t]}P.player=void 0}B.get(P.key)===P&&B.delete(P.key)&&!B.size&&H()}}))}}return I.then((e=>Object.assign(Object.assign({},e),M)))},f=[],p=c.map(((e,t)=>{if(e)return u(e,h);f.push(o[t])})).filter(Boolean),m=f.length?r.appEmojiManager.getCustomEmojiDocuments(f).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=>{x.push({div:e,load:()=>(i.forEach((e=>{x.delete({div:e})})),s())})}))}));return Promise.all(t)})),w=()=>{if(d&&!d())return;const e=g(p),t=m.then((e=>g(e)));return Promise.all([e,t])};return t?t.push({div:n.canvas,load:w}):w(),Promise.all(p).then((()=>Promise.all(h))).then((()=>{}))}))}static create(e){const t=new _;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.disconnectedCallback)||void 0===e||e.call(t)}))):t.middlewareHelper=(0,M.k)(),t}}const F=!0;let D;const R=new Set,B=new Map,N=new Map,O=(e=R)=>{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},U=()=>{D||(D=window.setInterval(O,16.666666666666668),O())},H=()=>{D&&(clearInterval(D),D=void 0)};function z(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),(F||S).append(s),e.classList.add("input-selectable"),!i&&e.append(j(!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,M=null!==(g=t.entities)&&void 0!==g?g:t.entities=(0,l.Z)(C.text),P=null!==(v=t.passEntities)&&void 0!==v?v:t.passEntities={},Z=null!==(b=t.contextSite)&&void 0!==b?b:t.contextSite="Telegram",k="Telegram"!==Z,T=C.text.length,x=M.length;let F;for(;C.i<x;++C.i){let e=M[C.i];if(e.offset>=T){if("messageEntityCaret"!==e._)continue}else e.offset+e.length>T&&(e=(0,o.Z)(e),e.length=T-e.offset);e.length&&(C.lastEntity=e);let i=M[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&&(F||S).append(C.text.slice(C.usedLength,l)),F&&(F=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&&P[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=M[C.i+1];const s=b=A.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)&&!f[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"messageEntityUrl":case"messageEntityTextUrl":if(!t.noLinks||P[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||c(b),s&&b.setAttribute("onclick",s+"(this)")}break;case"messageEntityEmail":t.noLinks||(b=document.createElement("a"),b.href=(0,r.Z)("mailto:"+g),c(b));break;case"messageEntityHashtag":{const e=!t.noLinks&&s.Hk[Z];if(e){const t=g.slice(1);b=document.createElement("a"),b.className="anchor-hashtag",b.href=e.replace("{1}",encodeURIComponent(t)),k?c(b):b.setAttribute("onclick","searchByHashtag(this)")}break}case"messageEntityMentionName":t.noLinks&&!P[e._]||(b=document.createElement("a"),b.href=(D=""+e.user_id,"#"+encodeURIComponent(D)),b.className="follow",b.dataset.follow=""+e.user_id);break;case"messageEntityMention":if(!t.noLinks){const e=g.slice(1),{url:t,onclick:i}=(0,h.Z)("t.me/"+e);b=document.createElement("a"),b.className="mention",b.href=t,i&&b.setAttribute("onclick",`${i}(this)`)}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=M[C.i+1],s&&s.offset<u;)++C.i,C.lastEntity=s,i=M[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${p.pf}`]=window.onSpoilerClick}}for(!I&&v&&(b?b[w]=v:(b||S).append(v)),b&&!b.parentNode&&(F||S).append(b);i&&i.offset<u;)++C.i,(b||S).append(z(C.text,Object.assign(Object.assign({},t),{voodoo:!0}))),i=M[C.i+1];if(C.usedLength<=u?(C.usedLength<u&&((b||S).append(C.text.slice(C.usedLength,u)),C.usedLength=u),F=S,C.lastEntity=void 0):F=e.length>v.length&&b?b:S,t.voodoo)return S}var D;if(C.lastEntity&&(C.usedLength=C.lastEntity.offset+C.lastEntity.length),C.usedLength<T&&(F||S).append(C.text.slice(C.usedLength)),(!t.wrappingDraft||t.customEmojiRenderer)&&E.size){let e=t.customEmojiRenderer;e||(e=_.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&&V(I),S}window.syncedPlayers=B,window.emojiRenderers=R,customElements.define("custom-emoji-element",A),customElements.define("custom-emoji-renderer-element",_);const j=e=>{const t=document.createElement("span");return t.classList.add(e?"input-filler2":"input-filler"),t.textContent=Z.Z,t};function G(e){var t;if((null==e?void 0:e.textContent)!==Z.Z||"false"===(null===(t=null==e?void 0:e.getAttribute)||void 0===t?void 0:t.call(e,"contenteditable"))){if(!e||e.textContent!==Z.Z||e.firstElementChild)return 2;if(e.nodeType===e.ELEMENT_NODE)return 1}return 0}function V(e){const t=(e,t,i)=>{const s=G(t);2===s?e[i](j()):1===s&&t.appendChild(document.createTextNode(Z.Z))};for(const i of e){const{previousSibling:e,nextSibling:s}=i;t(i,e,"before"),t(i,s,"after")}}window.wrapRichText=z},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 f="undefined"!=typeof WebAssembly;var p=i(5471),m=i(4159);const g=new class{constructor(){this.loadPromise=f?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}setLoop(e){for(const t in this.players){const i=this.players[t];i.loop=e,i.autoplay=i._autoplay}}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 f?(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,t=e.group||"",i){return n=this,a=void 0,d=function*(){if(!f)return this.loadPromise;if(this.loaded||(yield this.loadLottieWorkers()),i&&!i())throw(0,p.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=t;const a=this.initPlayer(n,e);return s.Z.addAnimation(a,t),a},new((o=void 0)||(o=Promise))((function(e,t){function i(e){try{r(d.next(e))}catch(e){t(e)}}function s(e){try{r(d.throw(e))}catch(e){t(e)}}function r(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o((function(e){e(n)}))).then(i,s)}r((d=d.apply(n,a||[])).next())}));var n,a,o,d}onDestroy(e){delete this.players[e]}destroyWorkers(){f&&(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.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()}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&&this.onMount(...e),!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:()=>l,N0:()=>s,tB:()=>d,w1:()=>r,zu:()=>c});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}function l(e){return String.fromCharCode(55356,56741+e.charCodeAt(0),55356,56741+e.charCodeAt(1))}function c(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=408.03880fedecb1e421da3b.chunk.js.map