From 06c971c96c7af17262460bfdd64ada0950e8466a Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Fri, 16 Dec 2016 19:39:57 +0300 Subject: [PATCH] Update 2016-12-16T16:39:54.078Z --- js/app.js | 18 +++++++++--------- js/lib/push_worker.js | 7 ++++--- service_worker.js | 2 +- webogram.appcache | 2 +- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/js/app.js b/js/app.js index 83404f62..5740c3d5 100644 --- a/js/app.js +++ b/js/app.js @@ -27,16 +27,16 @@ i.sha256Hash(a)}return{check:l,getState:s,requestRecovery:c,recover:d,updateSett e.state.moreActive=ie=!1,t==ne&&n==ae&&(angular.forEach(a.history,function(e){K.messages.unshift(d.wrapForHistory(e)),K.ids.unshift(e)}),Z=null===a.count||a.history.length&&K.messages.length=a-1?t.history[0]:0,J=t.history[t.history.length-1],e.historyState.skipped=X=Q>0,Z=null===t.count||n&&nt;for(l=0;l0&&angular.forEach(e.selectedMsgs,function(e,t){n.push(t)}),n.length&&_.confirm({type:"MESSAGES_DELETE",count:n.length}).then(function(){d.deleteMessages(n).then(function(){O()})})}function L(e){m.selectPeers({canSend:!0,confirm_type:"FORWARD_PEER",shareLinkPromise:d.getMessageShareLink(e)}).then(function(t){angular.forEach(t,function(t){var n=u.getPeerID(t);d.forwardMessages(n,[e])});var n=o.pop({type:"info",body:s("confirm_modal_forward_to_peer_success"),bodyOutputType:"trustedHtml",clickHandler:function(){i.$broadcast("history_focus",{peerString:t[0]}),o.clear(n)},showCloseButton:!1})})}function j(t){var n=[];t?n.push(t):e.selectedCount>0&&angular.forEach(e.selectedMsgs,function(e,t){n.push(t)}),n.length&&m.selectPeer({canSend:!0}).then(function(e){O(),i.$broadcast("history_focus",{peerString:e,attachment:{_:"fwd_messages",id:n}})})}function H(t){t||1!=e.selectedCount||angular.forEach(e.selectedMsgs,function(e,n){t=n}),t&&(O(),e.$broadcast("reply_selected",t))}function q(t){t||1!=e.selectedCount||angular.forEach(e.selectedMsgs,function(e,n){t=n}),t&&(O(),e.$broadcast("edit_selected",t))}function V(){e.historyState.selectActions?O():(e.historyState.selectActions="selected",e.$broadcast("ui_panel_update"))}function z(t){return"search"==t?void i.$broadcast("history_search",e.curDialog.peerID):(e.historyFilter.mediaType=t||!1,e.curDialog.messageID=!1,K.messages=[],K.ids=[],e.state.empty=!0,void A())}function W(){e.historyFilter.mediaType?z():e.curDialog.messageID?i.$broadcast("history_focus",{peerString:e.curDialog.peer}):A(!0)}e.$watchCollection("curDialog",y),p.attach(),g.start(),h.start(),e.peerHistories=[],e.selectedMsgs={},e.selectedCount=0,e.historyState.selectActions=!1,e.historyState.botActions=!1,e.historyState.channelActions=!1,e.historyState.canDelete=!1,e.historyState.canReply=!1,e.historyState.missedCount=0,e.historyState.skipped=!1,e.state={},e.toggleMessage=N,e.selectedDelete=B,e.selectedForward=j,e.selectedReply=H,e.selectedEdit=q,e.selectedCancel=O,e.selectedFlush=U,e.selectInlineBot=R,e.startBot=T,e.cancelBot=D,e.joinChannel=P,e.togglePeerMuted=F,e.toggleEdit=V,e.toggleMedia=z,e.returnToRecent=W,e.$on("history_edit_toggle",V),e.$on("history_edit_flush",U),e.$on("history_media_toggle",function(e,t){z(t)}),e.$on("history_return_recent",W);var G,K=!1,Y=!1,Z=!1,X=!1,J=0,Q=0,ee=!1,te={photos:"inputMessagesFilterPhotos",video:"inputMessagesFilterVideo",documents:"inputMessagesFilterDocument",audio:"inputMessagesFilterVoice"},ne=0,ae=0,ie=!1,oe=!1,se=0,re=!1,le=!1;e.$on("history_update",angular.noop);var ce=!1;e.$on("stateSynchronized",function(){ce&&(ce==e.curDialog.peerID&&A(),ce=!1)}),e.$on("reply_button_press",function(t,n){var a=e.historyState.replyKeyboard;if(a){var i={replyToMsgID:G<0&&a.mid};switch(n._){case"keyboardButtonRequestPhone":_.confirm({type:"BOT_ACCESS_PHONE"}).then(function(){var e=l.getSelf();d.sendOther(G,{_:"inputMediaContact",phone_number:e.phone,first_name:e.first_name,last_name:e.last_name},i)});break;case"keyboardButtonRequestGeoLocation":_.confirm({type:"BOT_ACCESS_GEO"}).then(function(){return v.getPosition().then(function(e){d.sendOther(G,{_:"inputMediaGeoPoint",geo_point:{_:"inputGeoPoint",lat:e.lat,"long":e["long"]}},i)},function(e){_.alert(s("error_modal_bad_request_title_raw"),s("error_modal_gelocation_na_raw"))})});break;default:d.sendText(G,n.text,i)}}}),e.$on("history_reload",function(t,n){n==e.curDialog.peerID&&A()}),e.$on("history_forbidden",function(n,a){a==e.curDialog.peerID&&t.url("/im"),k(a)}),e.$on("dialog_migrate",function(t,n){if(n.migrateFrom==e.curDialog.peerID){var a=u.getPeerString(n.migrateTo);i.$broadcast("history_focus",{peerString:a})}k(n.migrateFrom)}),e.$on("notify_settings",function(t,n){n.peerID==e.curDialog.peerID&&C()}),e.$on("channel_settings",function(t,n){n.channelID==-e.curDialog.peerID&&C()});var de={};e.$on("history_append",function(t,a){var o=w(a.peerID);if(o){var s=a.peerID==e.curDialog.peerID;if(s){if(e.historyFilter.mediaType||e.historyState.skipped)return void(a.my?W():e.historyState.missedCount++);e.curDialog.messageID&&a.my&&W(),delete e.state.empty}var r=d.wrapForHistory(a.messageID);o.messages.push(r),o.ids.push(a.messageID),d.regroupWrappedHistory(o.messages,-3)&&e.$broadcast("messages_regroup"),s&&(e.historyState.typing.splice(0,e.historyState.typing.length),e.$broadcast("ui_history_append_new",{my:a.my,idleScroll:Y&&!r.pFlags.out&&i.idle.isIDLE}),a.my&&e.historyUnreadAfter&&(delete e.historyUnreadAfter,e.$broadcast("messages_unread_after")),i.idle.isIDLE?!r.pFlags.unread||r.pFlags.out||(o.messages[o.messages.length-2]||{}).pFlags.unread||(e.historyUnreadAfter=r.mid,Y=!0,e.$broadcast("messages_unread_after")):n(function(){d.readHistory(e.curDialog.peerID)}),S(),C())}}),e.$on("history_multiappend",function(t,a){var o=!1,s=!1,r=i.idle.isIDLE;angular.forEach(a,function(t,a){var i=w(a);if(i){var l=a==e.curDialog.peerID,c=i.messages.length,u=t.length;if(l){if(e.historyFilter.mediaType||e.historyState.skipped)return void(e.historyState.missedCount+=u);delete e.state.empty}if((!l||r)&&c>(u>10?10:100))return console.warn(dT(),"Drop too many messages",u,c,r,l,a),void(l?(Q=i.messages[c-1].mid,e.historyState.skipped=X=Q>0,X&&(ce=a,e.$broadcast("ui_history_append"))):k(a));var p,m,g,h=!1,f=!1,m=i.messages[i.messages.length-1],_=!m||!m.pFlags.unread;for(g=0;g0){e=h.parseEmojis(e);var t={replyToMsgID:n.draftMessage.replyToMsgID,clearDraft:!0};do u.sendText(n.curDialog.peerID,e.substr(0,4096),t),e=e.substr(4096),t=angular.copy(t),delete t.clearDraft;while(e.length)}A(),j==n.curDialog.peer&&(j=!1),w(),n.$broadcast("ui_message_send")}function v(){var e=n.draftMessage.text;e=h.parseEmojis(e),u.editMessage(H,e).then(function(){H=!1,w(),n.$broadcast("ui_message_send")})}function y(){var e=n.curDialog.peerID;if(!e)return safeReplaceObject(n.mentions,{}),void n.$broadcast("mentions_update");var a,i=[],o=SearchIndexManager.createIndex(),r=p.getPopularBots().then(function(e){var t=[];return angular.forEach(e,function(e){t.push(e.id)}),t});a=e<0?s.getChatFull(-e).then(function(e){var t=(e.participants||{}).participants||[],n=[];return angular.forEach(t,function(e){n.push(e.user_id)}),n}):t.when([]),t.all({pop:r,chat:a}).then(function(e){var t={},a=e.pop.concat(e.chat);angular.forEach(a,function(e){t[e]||(t[e]=!0,i.push(l.getUser(e)),SearchIndexManager.indexObject(e,l.getUserSearchText(e),o))}),safeReplaceObject(n.mentions,{users:i,index:o}),n.$broadcast("mentions_update")})}function b(){var e=n.curDialog.peerID;return e?void s.getPeerBots(e).then(function(t){if(!t.length)return safeReplaceObject(n.commands,{}),void n.$broadcast("mentions_update");var a=e<0,i=[],o=SearchIndexManager.createIndex();angular.forEach(t,function(e){var t="";if(a){var n=l.getUser(e.id);n&&n.username&&(t+="@"+n.username)}var s=l.getUserSearchText(e.id);angular.forEach(e.commands,function(n,a){var r="/"+a+t;i.push({botID:e.id,value:r,rDescription:h.wrapRichText(n,{noLinks:!0,noLineBreaks:!0})}),SearchIndexManager.indexObject(r,s+" "+a+" "+n,o)})}),safeReplaceObject(n.commands,{list:i,index:o}),n.$broadcast("mentions_update")}):(safeReplaceObject(n.commands,{}),void n.$broadcast("mentions_update"))}function w(e,t){var i=t?c.getPeerID(t):0;if(e!=t&&i)return n.$broadcast("ui_message_before_send"),void a(function(){g.syncDraft(i),w()});if(H=!1,y(),b(),x(),T(),delete n.draftMessage.inlineProgress,n.$broadcast("inline_results",!1),j){if(j==n.curDialog.peer)return n.draftMessage.isBroadcast=c.isBroadcast(n.curDialog.peerID),void n.$broadcast("ui_peer_draft");j=!1}I(),k()}function k(){if(n.curDialog.peerID){var e;e=H?u.getMessageEditData(H).then(function(e){return e.replyToMsgID=H,e},function(e){return console.warn(e),H=!1,k(),t.reject()}):g.getDraft(n.curDialog.peerID),e.then(function(e){if(n.draftMessage.type=H?"edit":"new",n.draftMessage.text=e?e.text:"",n.draftMessage.isBroadcast=c.isBroadcast(n.curDialog.peerID),e.replyToMsgID){var t=e.replyToMsgID;S(t)}else x();n.$broadcast("ui_peer_draft")})}else n.draftMessage.text="",n.$broadcast("ui_peer_draft")}function $(e,t){if(console.log(dT(),"apply draft attach",t),t&&t._)if("share_url"==t._){var i=t.url,o=t.text||" ";j=n.curDialog.peer,a(function(){n.draftMessage.text=i+"\n"+o,n.$broadcast("ui_peer_draft",{customSelection:[i+"\n",o,""]})},1e3)}else if("fwd_messages"==t._)j=n.curDialog.peer,a(function(){n.draftMessage.fwdMessages=t.id,n.$broadcast("ui_peer_reply")},100);else if("inline_query"==t._){var s=t.mention,r=t.query;j=n.curDialog.peer,a(function(){n.draftMessage.text=s+" "+r,n.$broadcast("ui_peer_draft",{customSelection:[s+" "+r,"",""]})},1e3)}}function S(e,t){return H&&t?void x():(n.draftMessage.replyToMsgID=e,n.$broadcast("ui_peer_reply"),L=!1,void(t&&!H&&g.changeDraft(n.curDialog.peerID,{text:n.draftMessage.text,replyToMsgID:e})))}function C(e){H=e,k()}function M(){return!(H||!n.curDialog.peerID)&&void u.getHistory(n.curDialog.peerID).then(function(e){for(var t,n=0;n0,t.nav.hasPrev=b||n<_.length-1,t.canForward=t.canDelete=t.messageID>0}function p(n){var a=_.indexOf(t.messageID),s=a>=0?a+n:0,r=++w,l=s>=_.length?m():e.when();l.then(function(){if(r==w){var e=_[s],a=o.getMessage(e),l=a&&a.media&&(a.media.photo&&a.media.photo.id||a.media.webpage&&a.media.webpage.photo&&a.media.webpage.photo.id);if(!l)return void console.error("Invalid photo message",s,_,e,a);t.messageID=e,t.photoID=l,t.photo=i.wrapForFull(t.photoID),v[t.messageID]=!0,u(),n>0&&b&&_.indexOf(e)+1>=_.length?m():d(n)}})}function m(){return k?k:k=o.getSearch(g,h,f,y).then(function(t){return t.history.length?(y=t.history[t.history.length-1],_=_.concat(t.history),b=_.length=0&&(_=e.history,y=_[_.length-1],u(),d(1)),m()},m);var w=0,k=!1}}]).controller("UserpicModalController",["$q","$scope","$rootScope","$modalInstance","MtpApiManager","AppPhotosManager","AppUsersManager","AppPeersManager","AppMessagesManager","ApiUpdatesManager","PeersSelectService","ErrorService",function(e,t,n,a,i,o,s,r,l,c,d,u){function p(n,a){var i=f.indexOf(t.photoID),s=i>=0?i+n:0,r=++w,l=s>=f.length?g():e.when();l.then(function(){if(r==w){t.photoID=f[s],t.photo=o.wrapForFull(t.photoID),t.photo.thumb={location:o.choosePhotoSize(t.photo,0,0).location};var e;a&&(f.splice(i,1),e=t.count-1),h(e),v[t.photoID]=!0,h(),n>0&&b&&f.indexOf(t.photoID)+1>=f.length?g():m(n)}})}function m(e){var n=e<0?[-1,-2]:[1,2],a=f.indexOf(t.photoID);angular.forEach(n,function(e){var t=f[a+e];void 0!==t&&void 0===v[t]&&(v[t]=!0,o.preloadPhoto(t))})}function g(){return k?k:k=o.getUserPhotos(t.userID,_).then(function(t){return t.photos.length?(_=t.photos[t.photos.length-1],f=f.concat(t.photos),b=f.length0,t.nav.hasPrev=b||n=0&&(f=e.photos,_=f[f.length-1]),b=f.length=200,(Config.Modes.test||Config.Modes.debug)&&(e.needMigrate=!0),p.savePeerSettings(-e.chatID,t.notify_settings),p.getPeerMuted(-e.chatID).then(function(t){e.settings.notifications=!t,e.$watch("settings.notifications",function(t,n){return t!==n&&void p.getPeerSettings(-e.chatID).then(function(n){t?n.mute_until=0:n.mute_until=2e9,p.updatePeerSettings(-e.chatID,n)})})})}),e.leaveGroup=function(){_.confirm({type:"HISTORY_LEAVE_AND_FLUSH"}).then(function(){d.invokeApi("messages.deleteChatUser",{chat_id:r.getChatInput(e.chatID),user_id:{_:"inputUserSelf"}}).then(function(a){h.processUpdateMessage(a),m.flushHistory(-e.chatID).then(function(){t.close(),n.url("/im")})})})},e.inviteToGroup=function(){var t=[];angular.forEach(e.chatFull.participants.participants,function(e){t.push(e.user_id)}),f.selectContacts({disabled:t}).then(function(t){angular.forEach(t,function(t){d.invokeApi("messages.addChatUser",{chat_id:r.getChatInput(e.chatID),user_id:s.getUserInput(t),fwd_limit:100}).then(function(e){h.processUpdateMessage(e)})}),i.$broadcast("history_focus",{peerString:e.chatFull.peerString})})},e.migrateToSuperGroup=function(){_.confirm({type:"SUPERGROUP_MIGRATE"}).then(function(){d.invokeApi("messages.migrateChat",{chat_id:r.getChatInput(e.chatID)}).then(v)})},e.kickFromGroup=function(t){d.invokeApi("messages.deleteChatUser",{chat_id:r.getChatInput(e.chatID),user_id:s.getUserInput(t)}).then(v)},e.flushHistory=function(a){_.confirm({type:a?"HISTORY_FLUSH":"HISTORY_FLUSH_AND_DELETE"}).then(function(){m.flushHistory(-e.chatID,a).then(function(){a?i.$broadcast("history_focus",{peerString:e.chatFull.peerString}):(t.close(),n.url("/im"))})})},e.inviteViaLink=function(){var t=i.$new();t.chatID=e.chatID,o.open({templateUrl:templateUrl("chat_invite_link_modal"),controller:"ChatInviteLinkModalController",scope:t,windowClass:"md_simple_modal_window"})},e.photo={},e.$watch("photo.file",y),e.deletePhoto=function(){e.photo.updating=!0,d.invokeApi("messages.editChatPhoto",{chat_id:r.getChatInput(e.chatID),photo:{_:"inputChatPhotoEmpty"}}).then(v)["finally"](function(){e.photo.updating=!1})},e.editTitle=function(){var t=i.$new();t.chatID=e.chatID,o.open({templateUrl:templateUrl("chat_edit_modal"),controller:"ChatEditModalController",scope:t,windowClass:"md_simple_modal_window mobile_modal"})},e.hasRights=function(t){return r.hasRights(e.chatID,t)}}]).controller("ChannelModalController",["$scope","$timeout","$rootScope","$modal","AppUsersManager","AppChatsManager","AppProfileManager","AppPhotosManager","MtpApiManager","MtpApiFileManager","NotificationsManager","AppMessagesManager","AppPeersManager","ApiUpdatesManager","ContactsSelectService","ErrorService",function(e,t,n,a,i,o,s,r,l,c,d,u,p,m,g,h){function f(t){m.processUpdateMessage(t),n.$broadcast("history_focus",{peerString:e.chatFull.peerString})}function _(t){t&&t.type&&0===t.type.indexOf("image")&&(e.photo.updating=!0,c.uploadFile(t).then(function(t){return l.invokeApi("channels.editPhoto",{channel:o.getChannelInput(e.chatID),photo:{_:"inputChatUploadedPhoto",file:t}}).then(f)})["finally"](function(){e.photo.updating=!1}))}e.chatFull=o.wrapForFull(e.chatID,{}),e.settings={notifications:!0},e.isMegagroup=o.isMegagroup(e.chatID),s.getChannelFull(e.chatID,!0).then(function(t){e.chatFull=o.wrapForFull(e.chatID,t),e.$broadcast("ui_height"),d.savePeerSettings(-e.chatID,t.notify_settings),d.getPeerMuted(-e.chatID).then(function(t){e.settings.notifications=!t,e.$watch("settings.notifications",function(t,n){return t!==n&&void d.getPeerSettings(-e.chatID).then(function(n){t?n.mute_until=0:n.mute_until=2e9,d.updatePeerSettings(-e.chatID,n)})})}),e.chatFull.chat&&e.chatFull.chat.pFlags.creator&&e.chatFull.exported_invite&&"chatInviteEmpty"==e.chatFull.exported_invite._&&s.getChatInviteLink(e.chatID,!0).then(function(t){e.chatFull.exported_invite={_:"chatInviteExported",link:t}})}),e.leaveChannel=function(){return h.confirm({type:e.isMegagroup?"MEGAGROUP_LEAVE":"CHANNEL_LEAVE"}).then(function(){l.invokeApi("channels.leaveChannel",{channel:o.getChannelInput(e.chatID)}).then(f)})},e.deleteChannel=function(){return h.confirm({type:e.isMegagroup?"MEGAGROUP_DELETE":"CHANNEL_DELETE"}).then(function(){l.invokeApi("channels.deleteChannel",{channel:o.getChannelInput(e.chatID)}).then(f)})},e.joinChannel=function(){l.invokeApi("channels.joinChannel",{channel:o.getChannelInput(e.chatID)}).then(f)},e.inviteToChannel=function(){var t=[];angular.forEach((e.chatFull.participants||{}).participants||[],function(e){t.push(e.user_id)}),g.selectContacts({disabled:t}).then(function(t){var n=[];angular.forEach(t,function(e){n.push(i.getUserInput(e))}),l.invokeApi("channels.inviteToChannel",{channel:o.getChannelInput(e.chatID),users:n}).then(f)})},e.kickFromChannel=function(t){l.invokeApi("channels.kickFromChannel",{channel:o.getChannelInput(e.chatID),user_id:i.getUserInput(t),kicked:!0}).then(f)},e.shareLink=function(t){var i=n.$new();return i.chatID=e.chatID,a.open({templateUrl:templateUrl("chat_invite_link_modal"),controller:"ChatInviteLinkModalController",scope:i,windowClass:"md_simple_modal_window"}),cancelEvent(t)},e.photo={},e.$watch("photo.file",_),e.deletePhoto=function(){e.photo.updating=!0,l.invokeApi("channels.editPhoto",{channel:o.getChannelInput(e.chatID),photo:{_:"inputChatPhotoEmpty"}}).then(f)["finally"](function(){e.photo.updating=!1})},e.editChannel=function(){var t=n.$new();t.chatID=e.chatID,a.open({templateUrl:templateUrl(e.isMegagroup?"megagroup_edit_modal":"channel_edit_modal"),controller:"ChannelEditModalController",scope:t,windowClass:"md_simple_modal_window mobile_modal"})},e.goToHistory=function(){n.$broadcast("history_focus",{peerString:e.chatFull.peerString})},e.hasRights=function(t){return o.hasRights(e.chatID,t)}}]).controller("SettingsModalController",["$rootScope","$scope","$timeout","$modal","AppUsersManager","AppChatsManager","AppPhotosManager","MtpApiManager","Storage","NotificationsManager","MtpApiFileManager","PasswordManager","ApiUpdatesManager","ChangelogNotifyService","LayoutSwitchService","WebPushApiManager","AppRuntimeManager","ErrorService","_",function(e,t,n,a,i,o,s,r,l,c,d,u,p,m,g,h,f,_,v){function y(){n.cancel(w),w=!1,u.getState().then(function(e){t.password=e,"account.noPassword"==e._&&e.email_unconfirmed_pattern&&!k&&(w=n(y,5e3))})}function b(e){e&&e.type&&0===e.type.indexOf("image")&&(t.photo.updating=!0,d.uploadFile(e).then(function(e){r.invokeApi("photos.uploadProfilePhoto",{file:e,caption:"",geo_point:{_:"inputGeoPointEmpty"}}).then(function(e){i.saveApiUsers(e.users),r.getUserID().then(function(n){s.savePhoto(e.photo,{user_id:n}),p.processUpdateMessage({_:"updateShort",update:{_:"updateUserPhoto",user_id:n,date:tsNow(!0),photo:i.getUser(n).photo,previous:!0}}),t.photo={}})})})["finally"](function(){delete t.photo.updating}))}t.profile={},t.photo={},t.version=Config.App.version,r.getUserID().then(function(e){t.profile=i.getUser(e)}),r.invokeApi("users.getFullUser",{id:{_:"inputUserSelf"}}).then(function(e){i.saveApiUser(e.user),e.profile_photo&&s.savePhoto(e.profile_photo,{user_id:e.user.id})}),t.notify={volume:.5},t.send={},t.$watch("photo.file",b),t.password={_:"account.noPassword"},y();var w=!1,k=!1;t.changePassword=function(n){if(n=n||{},"cancel_email"==n.action)return _.confirm({type:"PASSWORD_ABORT_SETUP"}).then(function(){u.updateSettings(t.password,{email:""}).then(y)});var i=e.$new();i.password=t.password,angular.extend(i,n);var o=a.open({scope:i,templateUrl:templateUrl("password_update_modal"),controller:"PasswordUpdateModalController",windowClass:"md_simple_modal_window mobile_modal"});o.result["finally"](y)},t.showSessions=function(){a.open({templateUrl:templateUrl("sessions_list_modal"),controller:"SessionsListModalController",windowClass:"md_simple_modal_window mobile_modal"})},t.$on("$destroy",function(){n.cancel(w),k=!0}),t.deletePhoto=function(){t.photo.updating=!0,r.invokeApi("photos.updateProfilePhoto",{id:{_:"inputPhotoEmpty"}}).then(function(e){r.getUserID().then(function(n){p.processUpdateMessage({_:"updateShort",update:{_:"updateUserPhoto",user_id:n,date:tsNow(!0),photo:e,previous:!0}}),t.photo={}})})["finally"](function(){delete t.photo.updating})},t.editProfile=function(){a.open({templateUrl:templateUrl("profile_edit_modal"),controller:"ProfileEditModalController",windowClass:"md_simple_modal_window mobile_modal"})},t.changeUsername=function(){a.open({templateUrl:templateUrl("username_edit_modal"),controller:"UsernameEditModalController",windowClass:"md_simple_modal_window mobile_modal"})},t.terminateSessions=function(){_.confirm({type:"TERMINATE_SESSIONS"}).then(function(){r.invokeApi("auth.resetAuthorizations",{})})},l.get("notify_nodesktop","send_ctrlenter","notify_volume","notify_novibrate","notify_nopreview","notify_nopush").then(function(a){t.notify.desktop=!a[0],t.send.enter=a[1]?"":"1",t.notify.pushAvailable=h.isAvailable,t.notify.push=!a[5],a[2]!==!1?t.notify.volume=a[2]>0&&a[2]<=1?a[2]:0:t.notify.volume=.5,t.notify.canVibrate=c.getVibrateSupport(),t.notify.vibrate=!a[3],t.notify.preview=!a[4],t.notify.volumeOf4=function(){return 1+Math.ceil((t.notify.volume-.1)/.33)},t.toggleSound=function(){t.notify.volume?t.notify.volume=0:t.notify.volume=.5};var i;t.$watch("notify.volume",function(t,a){t!==a&&(l.set({notify_volume:t}),e.$broadcast("settings_changed"),c.clear(),i&&n.cancel(i),i=n(function(){c.testSound(t)},500))}),t.toggleDesktop=function(){t.notify.desktop=!t.notify.desktop,t.notify.desktop?l.remove("notify_nodesktop"):l.set({notify_nodesktop:!0}),e.$broadcast("settings_changed")},t.togglePush=function(){t.notify.push=!t.notify.push,t.notify.push?l.remove("notify_nopush"):l.set({notify_nopush:!0}),e.$broadcast("settings_changed")},t.togglePreview=function(){t.notify.preview=!t.notify.preview,t.notify.preview?l.remove("notify_nopreview"):l.set({notify_nopreview:!0}),e.$broadcast("settings_changed")},t.toggleVibrate=function(){t.notify.vibrate=!t.notify.vibrate,t.notify.vibrate?l.remove("notify_novibrate"):l.set({notify_novibrate:!0}),e.$broadcast("settings_changed")},t.toggleCtrlEnter=function(n){t.send.enter=n,t.send.enter?l.remove("send_ctrlenter"):l.set({send_ctrlenter:!0}),e.$broadcast("settings_changed")}}),t.openChangelog=function(){m.showChangelog(!1)},t.logOut=function(){_.confirm({type:"LOGOUT"}).then(function(){r.logOut().then(function(){location.hash="/login",f.reload()})})},t.switchBackToDesktop=Config.Mobile&&!Config.Navigator.mobile,t.switchToDesktop=function(){g.switchLayout(!1)}}]).controller("ChangelogModalController",["$scope","$modal",function(e,t){if(e.currentVersion=Config.App.version,!e.lastVersion){var n=e.currentVersion.split(".");e.lastVersion=n[0]+"."+n[1]+"."+Math.max(0,n[2]-1)}e.changelogHidden=!1,e.changelogShown=!1,e.canShowVersion=function(t){if(e.changelogShown)return!0;var n=versionCompare(t,e.lastVersion)>=0;return n||(e.changelogHidden=!0),n},e.showAllVersions=function(){e.changelogShown=!0,e.changelogHidden=!1,e.$emit("ui_height"),e.$broadcast("ui_height")},e.changeUsername=function(){t.open({templateUrl:templateUrl("username_edit_modal"),controller:"UsernameEditModalController",windowClass:"md_simple_modal_window mobile_modal"})}}]).controller("ProfileEditModalController",["$scope","$modalInstance","AppUsersManager","MtpApiManager",function(e,t,n,a){e.profile={},e.error={},a.getUserID().then(function(t){var a=n.getUser(t);e.profile={first_name:a.first_name,last_name:a.last_name}}),e.updateProfile=function(){e.profile.updating=!0;var i=3;a.invokeApi("account.updateProfile",{flags:i,first_name:e.profile.first_name||"",last_name:e.profile.last_name||""}).then(function(a){e.error={},n.saveApiUser(a),t.close()},function(n){switch(n.type){case"FIRSTNAME_INVALID":e.error={field:"first_name"},n.handled=!0;break;case"LASTNAME_INVALID":e.error={field:"last_name"},n.handled=!0;break;case"NAME_NOT_MODIFIED":n.handled=!0,t.close()}})["finally"](function(){delete e.profile.updating})}}]).controller("UsernameEditModalController",["$scope","$modalInstance","AppUsersManager","MtpApiManager",function(e,t,n,a){e.profile={},e.error={},a.getUserID().then(function(t){var a=n.getUser(t);e.profile={username:a.username}}),e.updateUsername=function(){e.profile.updating=!0,a.invokeApi("account.updateUsername",{username:e.profile.username||""}).then(function(a){e.checked={},n.saveApiUser(a),t.close()},function(e){"USERNAME_NOT_MODIFIED"==e.type&&(e.handled=!0,t.close())})["finally"](function(){delete e.profile.updating})},e.$watch("profile.username",function(t){return t&&t.length?void a.invokeApi("account.checkUsername",{username:t||""}).then(function(n){e.profile.username==t&&(n?e.checked={success:!0}:e.checked={error:!0})},function(n){if(e.profile.username==t)switch(n.type){case"USERNAME_INVALID":e.checked={error:!0},n.handled=!0}}):void(e.checked={})})}]).controller("SessionsListModalController",["$scope","$q","$timeout","_","MtpApiManager","ErrorService","$modalInstance",function(e,t,n,a,i,o,s){function r(){n.cancel(l),i.invokeApi("account.getAuthorizations").then(function(t){e.sessionsLoaded=!0,e.authorizations=t.authorizations;for(var a,i=0,o=e.authorizations.length;i=5&&n(function(){a==d&&o.invokeApi("contacts.search",{q:t,limit:10}).then(function(t){s.saveApiUsers(t.users),a==d&&angular.forEach(t.results,function(t){var n=t.user_id;i.indexOf(n)==-1&&e.contacts.push({userID:n,user:s.getUser(n),peerString:s.getUserString(n),found:!0})})},function(e){400==e.code&&(e.handled=!0)})},500)}e.contacts=[],e.foundPeers=[],e.search={},e.slice={limit:20,limitDelta:20};var d=0;if(l(),e.disabledContacts={},e.disabled)for(var u=0;u0){var t=[];return angular.forEach(e.selectedContacts,function(e,n){t.push(n)}),i.close(t)}},e.deleteSelected=function(){if(e.selectedCount>0){var t=[];angular.forEach(e.selectedContacts,function(e,n){t.push(n)}),s.deleteContacts(t).then(function(){e.toggleEdit(!1)})}},e.importContact=function(){s.openImportContact().then(function(e){e&&t.$broadcast("history_focus",{peerString:s.getUserString(e)})})}}]).controller("PeerSelectController",["$scope","$modalInstance","$q","AppPeersManager","ErrorService",function(e,t,n,a,i){e.selectedPeers={},e.selectedPeerIDs=[],e.selectedCount=0,e.shareLinkPromise&&(e.shareLink={loading:!0},e.shareLinkPromise.then(function(t){e.shareLink={url:t}},function(){delete e.shareLink})),e.dialogSelect=function(o){if(!e.multiSelect){var s;if(e.confirm_type){var r=a.getPeerID(o),l=a.getPeer(r);s=i.confirm({type:e.confirm_type,peer_id:r,peer_data:l})}else s=n.when();return void s.then(function(){t.close(o)})}var r=a.getPeerID(o);if(e.selectedPeers[r]){delete e.selectedPeers[r],e.selectedCount--;var c=e.selectedPeerIDs.indexOf(r);c>=0&&e.selectedPeerIDs.splice(c,1)}else e.selectedPeers[r]=a.getPeer(r),e.selectedCount++,e.selectedPeerIDs.unshift(r)},e.submitSelected=function(){if(e.selectedCount>0){var n=[];return angular.forEach(e.selectedPeers,function(e,t){n.push(a.getPeerString(t))}),t.close(n)}},e.toggleSearch=function(){e.$broadcast("dialogs_search_toggle")}}]).controller("ChatCreateModalController",["$scope","$modalInstance","$rootScope","MtpApiManager","AppUsersManager","AppChatsManager","ApiUpdatesManager",function(e,t,n,a,i,o,s){e.group={name:""},e.createGroup=function(){if(e.group.name){e.group.creating=!0;var r=[];return angular.forEach(e.userIDs,function(e){r.push(i.getUserInput(e))}),a.invokeApi("messages.createChat",{title:e.group.name,users:r}).then(function(e){if(s.processUpdateMessage(e),e.updates&&e.updates.length){for(var a,i=0,r=e.updates.length;i5184e5?o=n?"mediumDate":"shortDate":i>432e5&&(o=n?"EEEE":"EEE"),t(a,o)}}]).filter("time",["$filter",function(e){var t={},n=e("date"),a=Config.Mobile?"shortTime":"mediumTime";return function(e){return t[e]?t[e]:t[e]=n(1e3*e,a)}}]).filter("myDate",["$filter",function(e){var t={},n=e("date");return function(e){return t[e]?t[e]:t[e]=n(1e3*e,"fullDate")}}]).filter("duration",[function(){return function(e){e=parseInt(e),isNaN(e)&&(e=0);var t=Math.floor(e/3600),n=Math.floor(e%3600/60),a=e%60,i=(t?t+":":"")+n+":"+a;return i=i.replace(/:(\d(?::|$))/g,":0$1")}}]).filter("durationRemains",["$filter",function(e){var t=e("duration");return function(e,n){return"-"+t(n-e)}}]).filter("phoneNumber",[function(){return function(e){var t=" ";return e=(e||"").replace(/\D/g,""),"7"==e.charAt(0)&&11==e.length?"+"+e.charAt(0)+t+"("+e.substr(1,3)+")"+t+e.substr(4,3)+"-"+e.substr(7,2)+"-"+e.substr(9,2):"+"+e}}]).filter("formatSize",[function(){return function(e,t){if(!e)return"0";if(e<1024)return e+" b";if(e<1048576)return Math.round(e/1024)+" KB";var n=e/1048576;return n=t?n.toFixed(1):Math.round(10*n)/10,n+" MB"}}]).filter("formatSizeProgress",["$filter","_",function(e,t){ var n=e("formatSize");return function(e){if(!e.total)return"";var a=n(e.done,!0),i=a.split(" "),o=n(e.total),s=o.split(" ");return s[1]===i[1]?t("format_size_progress_mulitple",{done:i[0],total:s[0],parts:i[1]||""}):t("format_size_progress",{done:a,total:o})}}]).filter("formatShortNumber",[function(){return function(e){if(!e)return"0";if(e<1e3)return e.toString();if(e<9e5){var t=e>1e4?1:10;return Math.round(e/1e3*t)/t+"K"}var t=e>1e7?1:10;return Math.round(e/1e6*t)/t+"M"}}]).filter("nl2br",[function(){return function(e){return e.replace(/\n/g,"
")}}]).filter("shortUrl",[function(){return function(e){return"string"!=typeof e?e:e.replace(/^https?:\/\//,"").replace(/^www\./,"")}}]).filter("richText",["$filter",function(e){var t=e("linky");return function(e){return t(e,"_blank").replace(/\n| /g,"
")}}]).filter("relativeTime",["$filter","_",function(e,t){var n=t.pluralize("relative_time_pluralize_minutes_ago"),a=t.pluralize("relative_time_pluralize_hours_ago"),i=e("dateOrTime");return function(e){var o=Math.abs(tsNow(!0)-e);if(o<60)return t("relative_time_just_now");if(o<3600){var s=Math.floor(o/60);return n(s)}if(o<86400){var r=Math.floor(o/3600);return a(r)}return i(e,!0)}}]),angular.module("myApp.services").service("AppMessagesManager",["$q","$rootScope","$location","$filter","$timeout","$sce","ApiUpdatesManager","AppUsersManager","AppChatsManager","AppPeersManager","AppPhotosManager","AppDocsManager","AppStickersManager","AppMessagesIDsManager","DraftsManager","AppWebPagesManager","AppGamesManager","MtpApiManager","MtpApiFileManager","ServerTimeManager","RichTextProcessor","NotificationsManager","Storage","AppProfileManager","TelegramMeWebService","ErrorService","StatusManager","_",function(e,t,n,a,i,o,s,r,l,c,d,u,p,m,g,h,f,_,v,y,b,w,k,$,S,C,M,x){function I(t,n,a){var i=Te,o=angular.isString(t)&&t.length;if(o){if(!a||Ue.query!==t){Ue.query=t;var s=SearchIndexManager.search(t,Oe);Ue.dialogs=[],angular.forEach(Te.dialogs,function(e){s[e.peerID]&&Ue.dialogs.push(e)}),Ue.count=Ue.dialogs.length}i=Ue}else Ue.query=!1;var r=0;if(n>0)for(r=0;ri.dialogs[r].index);r++);return a=a||20,o||Ze||i.dialogs.length>=r+a?e.when({dialogs:i.dialogs.slice(r,r+a)}):T(a).then(function(){if(r=0,n>0)for(r=0;ri.dialogs[r].index);r++);return{dialogs:i.dialogs.slice(r,r+a)}})}function A(e){for(var t=0;th)&&(h=f.date)}var _=g.saveDraft(n,e.draft);_&&_.date>h&&(h=_.date),e.index=D(h),e.peerID=n,P(e,d);var v=r.pFlags.out?"read_outbox_max_id":"read_inbox_max_id";if(r.mid&&r.mid>e[v]&&(r.pFlags.unread=!0),void 0===Ee[n]&&!r.deleted){var y={count:null,history:[o],pending:[]};Ee[n]=y,j(y,r)&&t.$broadcast("history_reply_markup",{peerID:n})}if(w.savePeerSettings(n,e.notify_settings),a&&e.pts&&s.addChannelState(a,e.pts),!a&&e.unread_count>0&&We&&e.top_message>We){var b=16&r.flags?r.from_id:n;!r.pFlags.unread||r.pFlags.out||r.pFlags.silent||w.getPeerMuted(b).then(function(e){e||ke(r)})}}function T(e){var n=Te.dialogs,a=0,o=0,s=0,d=0;return Xe&&(a=Xe+y.serverTimeOffset,d=65536*Xe),_.invokeApi("messages.getDialogs",{offset_date:a,offset_id:m.getMessageLocalID(o),offset_peer:c.getInputPeerByID(s),limit:e},{timeout:300}).then(function(e){a||S.setAuthorized(!0),r.saveApiUsers(e.users),l.saveApiChats(e.chats),Q(e.messages);var o=!!a,s=!1;angular.forEach(e.dialogs,function(e){E(e),d&&e.index>d&&(it[e.peerID]=e,s=!0),o||c.isChannel(c.getPeerID(e.peer))||(we(e.top_message),o=!0)}),(!e.dialogs.length||!e.count||n.length>=e.count)&&(Ze=!0),s&&!at?at=i(Se,0):t.$broadcast("dialogs_multiupdate",{})})}function D(e){return void 0===e&&(e=tsNow(!0)+y.serverTimeOffset),65536*e+(65535&++Je)}function P(e,t){t&&(!Xe||t=n[0].index)n.unshift(e);else for(i=0;in[i].index){n.splice(i,0,e);break}}function F(t,n,a,i){var o=c.isChannel(t);o&&c.isMegagroup(t);return _.invokeApi("messages.getHistory",{peer:c.getInputPeerByID(t),offset_id:n?m.getMessageLocalID(n):0,add_offset:i||0,limit:a||0},{timeout:300,noErrorBox:!0}).then(function(e){r.saveApiUsers(e.users),l.saveApiChats(e.chats),Q(e.messages),o&&s.addChannelState(-t,e.pts);var n=e.messages.length;return n&&e.messages[n-1].deleted&&(e.messages.splice(n-1,1),n--,e.count--),t<0||!r.isBot(t)||n==a&&a0)for(s=0;si.history[s]);s++);var r=i.history.length;i.history.splice(s,i.history.length-s),angular.forEach(o.messages,function(n){j(i,n)&&t.$broadcast("history_reply_markup",{peerID:e}),i.history.push(n.mid)});var l=i.history.length;a-=l-r;var c=Qe[e],d=et[e],u=void 0!==c||void 0!==d;if(u&&(i.count=Math.max(i.count,l)+1),a>0){if(n=i.history[l-1],u){if(!o.messages.length){if(!d)return i.count=l,!0;n=0,e=d}return N(e,n,a,i)}if(l=0;i--)if(o=xe[n.history[i]],o&&!o.pFlags.out&&o.pFlags.unread){n.unreadOffset=i+1;break}}return e.when(n)}function O(e,n){if(!Qe[e]&&!et[n]&&l.hasChat(-n)){var a=l.getChat(-e);a&&a.migrated_to&&a.migrated_to.channel_id==-n&&(Qe[e]=n,et[n]=e,i(function(){var a=A(e);a.length&&(Te.dialogs.splice(a[1],1),t.$broadcast("dialog_drop",{peerID:e})),t.$broadcast("dialog_migrate",{migrateFrom:e,migrateTo:n})},100))}}function U(e){if(Qe[e])return Qe[e]}function B(e,t,n,a,i){Qe[e]&&(e=Qe[e]);var o=Ee[e],s=0,r=!1,l=!1,c=!1;i=i?Math.min(50,i):0,void 0===o&&(o=Ee[e]={count:null,history:[],pending:[]});var d=!1,u=e;if(et[e]&&(d=!0,t&&t1){var g=p.unread_count;(c=g>50)?p.read_inbox_max_id?(t=p.read_inbox_max_id,a=16,l=16,n=4):(n=20,l=16,s=g-l):(n=Math.max(10,i,g+2),l=g)}else Config.Mobile&&(n=20)}if(t>0)for(r=!0,s=0;so.history[s]){r=!1;break}if(!r&&(null!==o.count&&o.history.length==o.count||o.history.length>=s+(n||1))){a?(a=Math.min(s,a),s=Math.max(0,s-a),n+=a):n=n||(s?20:i||5);var h=o.history.slice(s,s+n);return!t&&o.pending.length&&(h=o.pending.slice().concat(h)),R(e,{count:o.count,history:h,unreadOffset:l,unreadSkip:c})}return a||n||(n=i||20),r&&(s=0),a||c||t&&o.history.indexOf(t)==-1?(a&&(s=-a,n+=a),F(u,t,n,s).then(function(n){o.count=n.count||n.messages.length,d&&o.count++;var a=[];return angular.forEach(n.messages,function(e){a.push(e.mid)}),!t&&o.pending.length&&(a=o.pending.slice().concat(a)),R(e,{count:o.count,history:a,unreadOffset:l,unreadSkip:c})})):N(e,t,n,o).then(function(){if(s=0,t>0)for(s=0;so.history[s]);s++);var a=o.history.slice(s,s+n);return!t&&o.pending.length&&(a=o.pending.slice().concat(a)),R(e,{count:o.count,history:a,unreadOffset:l,unreadSkip:c})})}function L(e){return(Ee[e]||{}).reply_markup||!1}function j(e,t){if(!t.reply_markup&&!t.pFlags.out&&!t.action)return!1;if(t.reply_markup&&"replyInlineMarkup"==t.reply_markup._)return!1;var n=t.reply_markup,a=e.reply_markup;if(n)return!(a&&a.mid>=t.mid)&&(!(n.pFlags.selective&&!(16&t.flags))&&(e.maxOutID&&t.mida.mid||t.mid<0)&&t.message)return a.pFlags.hidden=!0,!0}else(!e.maxOutID||t.mid>e.maxOutID)&&(e.maxOutID=t.mid);return!(!t.action||"messageActionChatDeleteUser"!=t.action._||(a?t.action.user_id!=a.fromID:!r.isBot(t.action.user_id)))&&(e.reply_markup={_:"replyKeyboardHide",mid:t.mid,flags:0,pFlags:{}},!0)}function H(t,n,a,i,o){t=t?parseInt(t):0;var s=[],d=!n,u={peer:t,filter:a},p=d&&angular.equals(Be,u);if(d&&!p&&(Be=u,Le=[]),t&&!i&&!n){var g=Ee[t];if(void 0!==g&&g.history.length){var h,f,v,b={},w=o||20;switch(a._){case"inputMessagesFilterPhotos":b.messageMediaPhoto=!0;break;case"inputMessagesFilterPhotoVideo":b.messageMediaPhoto=!0,b.messageMediaDocument=!0,h="video";break;case"inputMessagesFilterVideo":b.messageMediaDocument=!0,h="video";break;case"inputMessagesFilterDocument":b.messageMediaDocument=!0,h=!1;break;case"inputMessagesFilterVoice":b.messageMediaDocument=!0,h="voice";break;default:return e.when({count:0,history:[]})}for(f=0;f=w)break}}if(s.length=w));f++);}if(s.length||1e3==o)return d&&(Le=listMergeSorted(Le,s)),e.when({count:null,history:s});var $;if(t||!n)$=_.invokeApi("messages.search",{flags:0,peer:c.getInputPeerByID(t),q:n||"",filter:a||{_:"inputMessagesFilterEmpty"},min_date:0,max_date:0,limit:o||20,max_id:m.getMessageLocalID(i)||0},{timeout:300,noErrorBox:!0});else{var S=0,C=0,M=0,x=i&&q(i);x&&x.date&&(S=x.date+y.serverTimeOffset,M=x.id,C=de(x)),$=_.invokeApi("messages.searchGlobal",{q:n,offset_date:S,offset_peer:c.getInputPeerByID(C),offset_id:m.getMessageLocalID(M),limit:o||20},{timeout:300,noErrorBox:!0})}return $.then(function(e){r.saveApiUsers(e.users),l.saveApiChats(e.chats),Q(e.messages);var t=e.count||e.messages.length;return s=[],angular.forEach(e.messages,function(e){var t=de(e);if(t<0){var n=l.getChat(-t);n.migrated_to&&O(t,-n.migrated_to.channel_id)}s.push(e.mid)}),d&&(!i||p&&Le.indexOf(i)>=0)&&(Le=listMergeSorted(Le,s)),{count:t,history:s}},function(t){return 400==t.code&&(t.handled=!0),e.reject(t)})}function q(e){return xe[e]||{deleted:!0}}function V(e){var t=["messageMediaPhoto","messageMediaDocument","messageMediaWebPage","messageMediaPending"];return!("message"!=e._||e.deleted||e.fwd_from||e.via_bot_id||e.media&&t.indexOf(e.media._)==-1||e.fromID&&r.isBot(e.fromID))}function z(e){if(e<=0||!xe[e])return!1;var t=xe[e];return!(!(t&&t.canBeEdited&&t.pFlags.out)||t.date0){var o=l.getChat(t);if(!(o.pFlags.creator||o.pFlags.editor&&o.pFlags.megagroup)){var r=[];if((o.pFlags.editor||o.pFlags.megagroup)&&angular.forEach(e,function(e,a){var i=q(n.mids[t][a]);i.pFlags.out&&r.push(e)}),!r.length)return;e=r}i=_.invokeApi("channels.deleteMessages",{channel:l.getChannelInput(t),id:e}).then(function(n){s.processUpdateMessage({_:"updateShort",update:{_:"updateDeleteChannelMessages",channel_id:t,messages:e,pts:n.pts,pts_count:n.pts_count}})})}else i=_.invokeApi("messages.deleteMessages",{id:e}).then(function(t){s.processUpdateMessage({_:"updateShort",update:{_:"updateDeleteMessages",messages:e,pts:t.pts,pts_count:t.pts_count}})});a.push(i)}),e.all(a)}function K(t){var n=m.getMessageIDInfo(t),a=n[0],i=n[1];if(!i)return e.reject();var o=q(t),s=l.getChat(i);return o&&o.pFlags&&o.pFlags.post&&s.username?_.invokeApi("channels.exportMessageLink",{channel:l.getChannelInput(i),id:a}).then(function(e){return e.link}):e.reject()}function Y(e){var n=c.isChannel(e),a=Ee[e],i=A(e)[0];if(!i||!i.unread_count){if(!a||!a.history.length)return!1;var o,r,d=!1;for(p=a.history.length;p>=0;p--)if(o=a.history[p],r=xe[o],r&&!r.pFlags.out&&r.pFlags.unread){d=!0;break}if(!d)return!1}if(a.readPromise)return a.readPromise;var u;if(u=n?_.invokeApi("channels.readHistory",{channel:l.getChannelInput(-e),max_id:0}):_.invokeApi("messages.readHistory",{peer:c.getInputPeerByID(e),max_id:0}).then(function(e){s.processUpdateMessage({_:"updateShort",update:{_:"updatePts",pts:e.pts,pts_count:e.pts_count}})}),a.readPromise=u.then(function(){i&&(i.unread_count=0,t.$broadcast("dialog_unread",{peerID:e,count:0}),t.$broadcast("messages_read"),a&&a.history.length&&(i.read_inbox_max_id=a.history[0]))})["finally"](function(){delete a.readPromise}),a&&a.history.length){var o,r,p,e,i;for(p=0;p0){var c=e.pFlags.out?"read_outbox_max_id":"read_inbox_max_id";e.pFlags.unread=s>r[c]}else t.isNew&&(e.pFlags.unread=!0);e.reply_to_msg_id&&(e.reply_to_mid=m.getFullMessageID(e.reply_to_msg_id,i)),e.date-=y.serverTimeOffset;var p=e.fwd_from;p&&(e.fwdFromID=p.channel_id?-p.channel_id:p.from_id,p.date-=y.serverTimeOffset),e.peerID=n,e.fromID=e.pFlags.post?n:e.from_id,e.signID=e.pFlags.post&&e.from_id||p&&p.channel_id&&p.from_id,e.via_bot_id>0&&(e.viaBotID=e.via_bot_id);var g={user_id:e.fromID,date:e.date};if(e.media)switch(e.media._){case"messageMediaEmpty":delete e.media;break;case"messageMediaPhoto":d.savePhoto(e.media.photo,g);break;case"messageMediaDocument":u.saveDoc(e.media.document,g);break;case"messageMediaWebPage":h.saveWebPage(e.media.webpage,e.mid,g);break;case"messageMediaGame":f.saveGame(e.media.game,e.mid,g),e.media.handleMessage=!0}if(e.action){var _,v;switch(e.action._){case"messageActionChatEditPhoto":d.savePhoto(e.action.photo,g),o&&(e.action._="messageActionChannelEditPhoto");break;case"messageActionChatEditTitle":o&&(e.action._="messageActionChannelEditTitle");break;case"messageActionChatDeletePhoto":o&&(e.action._="messageActionChannelDeletePhoto");break;case"messageActionChatAddUser":1==e.action.users.length?(e.action.user_id=e.action.users[0],e.fromID==e.action.user_id&&(a?e.action._="messageActionChatJoined":e.action._="messageActionChatReturn")):e.action.users.length>1&&(e.action._="messageActionChatAddUsers");break;case"messageActionChatDeleteUser":e.fromID==e.action.user_id&&(e.action._="messageActionChatLeave");break;case"messageActionChannelMigrateFrom":_=-e.action.chat_id,v=-i;break;case"messageActionChatMigrateTo":_=-i,v=-e.action.channel_id;break;case"messageActionHistoryClear":e.deleted=!0,e.clear_history=!0,e.pFlags.out=!1,e.pFlags.unread=!1}_&&v&&!Qe[_]&&!et[v]&&O(_,v)}if(e.message&&e.message.length){var w=b.parseEntities(e.message),k=e.entities||[];e.totalEntities=b.mergeEntities(w,k,!e.pending)}e.canBeEdited=V(e),t.isEdited||(xe[s]=e)}})}function ee(e,n,a){if(angular.isString(n)){a=a||{};var i=a.entities||[];if(a.viaBotID||(n=b.parseMarkdown(n,i)),n.length){var o,l=le(i),d=Re--,u=[nextRandomInt(4294967295),nextRandomInt(4294967295)],p=bigint(u[0]).shiftLeft(32).add(bigint(u[1])).toString(),h=Ee[e],f=0,v={},w=a.replyToMsgID,k=c.isChannel(e),$=k&&c.isMegagroup(e),S=!(!k||$);void 0===h&&(h=Ee[e]={count:null,history:[],pending:[]});var C=r.getSelf().id;e!=C&&(f|=2,v.out=!0,k||r.isBot(e)||(f|=1,v.unread=!0)),w&&(f|=8),S?(C=0,v.post=!0):f|=256,o={_:"message",id:d,from_id:C,to_id:c.getOutputPeer(e),flags:f,pFlags:v,date:tsNow(!0)+y.serverTimeOffset,message:n,random_id:p,reply_to_msg_id:w,via_bot_id:a.viaBotID,reply_markup:a.reply_markup,entities:i,views:S&&1,pending:!0};var M=function(e){var n=Ie[d];e?(o.error=!0,n&&(n.error=!0)):(delete o.error,n&&delete n.error),t.$broadcast("messages_pending")};o.send=function(){M(!1);var t={};Fe[e]&&(t.afterMessageID=Fe[e].messageID);var i=0;w&&(i|=1),S&&(i|=16),a.clearDraft&&(i|=128);var r;a.viaBotID?r=_.invokeApi("messages.sendInlineBotResult",{flags:i,peer:c.getInputPeerByID(e),random_id:u,reply_to_msg_id:m.getMessageLocalID(w),query_id:a.queryID,id:a.resultID},t):(l.length&&(i|=8),r=_.invokeApi("messages.sendMessage",{flags:i,peer:c.getInputPeerByID(e),message:n,random_id:u,reply_to_msg_id:m.getMessageLocalID(w),entities:l},t)),r.then(function(e){"updateShortSentMessage"==e._?(o.flags=e.flags,o.date=e.date,o.id=e.id,o.media=e.media,o.entities=e.entities,e={_:"updates",users:[],chats:[],seq:0,updates:[{_:"updateMessageID",random_id:p,id:e.id},{_:k?"updateNewChannelMessage":"updateNewMessage",message:o,pts:e.pts,pts_count:e.pts_count}]}):e.updates&&angular.forEach(e.updates,function(e){"updateDraftMessage"==e._&&(e.local=!0)}),s.processUpdateMessage(e)},function(e){M(!0)})["finally"](function(){Fe[e]===t&&delete Fe[e]}),Fe[e]=t},Q([o]),h.pending.unshift(d),t.$broadcast("history_append",{peerID:e,messageID:d,my:!0}),setZeroTimeout(o.send),a.clearDraft&&g.clearDraft(e),De[p]=[e,d]}}}function te(n,a,i){i=i||{};var o,l,d=Re--,u=[nextRandomInt(4294967295),nextRandomInt(4294967295)],p=bigint(u[0]).shiftLeft(32).add(bigint(u[1])).toString(),g=Ee[n],h=0,f={},b=i.replyToMsgID,w=c.isChannel(n),k=w&&c.isMegagroup(n),$=!(!w||k);i.isMedia?["image/jpeg","image/png","image/bmp"].indexOf(a.type)>=0?(o="photo",l="photo."+a.type.split("/")[1]):"audio/"==a.type.substr(0,6)||["video/ogg"].indexOf(a.type)>=0?(o="audio",l="audio."+("ogg"==a.type.split("/")[1]?"ogg":"mp3")):"video/"==a.type.substr(0,6)?(o="video",l="video.mp4"):(o="document",l="document."+a.type.split("/")[1]):(o="document",l="document."+a.type.split("/")[1]),void 0===g&&(g=Ee[n]={count:null,history:[],pending:[]});var S=r.getSelf().id;n!=S&&(h|=2,f.out=!0,w||r.isBot(n)||(h|=1,f.unread=!0)),b&&(h|=8),$?(S=0,f.post=!0):h|=256;var C,M={_:"messageMediaPending",type:o,file_name:a.name||l,size:a.size,progress:{percent:1,total:a.size}},x={_:"message",id:d,from_id:S,to_id:c.getOutputPeer(n),flags:h,pFlags:f,date:tsNow(!0)+y.serverTimeOffset,message:"",media:M,random_id:p,reply_to_msg_id:b,views:$&&1,pending:!0},I=function(e){var n=Ie[d];e?(x.error=!0,n&&(n.error=!0)):(delete x.error,n&&delete n.error),t.$broadcast("messages_pending")},A=!1;x.send=function(){var i=e.defer();Ne.then(function(){A&&!x.error||(A=!1,C=v.uploadFile(a)),C.then(function(e){e.name=l,A=!0;var t;switch(o){case"photo":t={_:"inputMediaUploadedPhoto",flags:0,file:e};break;case"document":default:t={_:"inputMediaUploadedDocument",file:e,mime_type:a.type,caption:"",attributes:[{_:"documentAttributeFilename",file_name:a.name}]}}var i=0;b&&(i|=1),$&&(i|=16),_.invokeApi("messages.sendMedia",{flags:i,peer:c.getInputPeerByID(n),media:t,random_id:u,reply_to_msg_id:m.getMessageLocalID(b)}).then(function(e){s.processUpdateMessage(e)},function(e){return"photo"!=o||400!=e.code||"PHOTO_INVALID_DIMENSIONS"!=e.type&&"PHOTO_SAVE_FILE_INVALID"!=e.type?void I(!0):(e.handled=!0,o="document",void x.send())})},function(e){I(!0)},function(e){M.progress.done=e.done,M.progress.percent=Math.max(1,Math.floor(100*e.done/e.total)),t.$broadcast("history_update",{peerID:n})}),M.progress.cancel=function(){A||(i.resolve(),C.cancel(),se(p))},C["finally"](function(){i.resolve()})}),Ne=i.promise},Q([x]),g.pending.unshift(d),t.$broadcast("history_append",{peerID:n,messageID:d,my:!0}),setZeroTimeout(x.send),De[p]=[n,d]}function ne(e,n,a){a=a||{};var i=Re--,o=[nextRandomInt(4294967295),nextRandomInt(4294967295)],l=bigint(o[0]).shiftLeft(32).add(bigint(o[1])).toString(),h=Ee[e],f=a.replyToMsgID,v=c.isChannel(e),b=v&&c.isMegagroup(e),w=!(!v||b);void 0===h&&(h=Ee[e]={count:null,history:[],pending:[]});var k,$=r.getSelf().id;switch(n._){case"inputMediaPhoto":k={_:"messageMediaPhoto",photo:d.getPhoto(n.id.id),caption:n.caption||""};break;case"inputMediaDocument":var S=u.getDoc(n.id.id);S.sticker&&S.stickerSetInput&&p.pushPopularSticker(S.id),k={_:"messageMediaDocument",document:S,caption:n.caption||""};break;case"inputMediaContact":k={_:"messageMediaContact",phone_number:n.phone_number,first_name:n.first_name,last_name:n.last_name,user_id:0};break;case"inputMediaGeoPoint":k={_:"messageMediaGeo",geo:{_:"geoPoint",lat:n.geo_point.lat,"long":n.geo_point["long"]}};break;case"inputMediaVenue":k={_:"messageMediaVenue",geo:{_:"geoPoint",lat:n.geo_point.lat,"long":n.geo_point["long"]},title:n.title,address:n.address,provider:n.provider,venue_id:n.venue_id};break;case"messageMediaPending":k=n}var C=0,M={};e!=$&&(C|=2,M.out=!0,r.isBot(e)||(C|=1,M.unread=!0)),f&&(C|=8),w?($=0,M.post=!0):C|=256;var x={_:"message",id:i,from_id:$,to_id:c.getOutputPeer(e),flags:C,pFlags:M,date:tsNow(!0)+y.serverTimeOffset,message:"",media:k,random_id:l,reply_to_msg_id:f,via_bot_id:a.viaBotID,reply_markup:a.reply_markup,views:w&&1,pending:!0},I=function(e){var n=Ie[i];e?(x.error=!0,n&&(n.error=!0)):(delete x.error,n&&delete n.error),t.$broadcast("messages_pending")};x.send=function(){var t=0;f&&(t|=1),w&&(t|=16),a.clearDraft&&(t|=128);var i={};Fe[e]&&(i.afterMessageID=Fe[e].messageID);var r;r=a.viaBotID?_.invokeApi("messages.sendInlineBotResult",{flags:t,peer:c.getInputPeerByID(e),random_id:o,reply_to_msg_id:m.getMessageLocalID(f),query_id:a.queryID,id:a.resultID},i):_.invokeApi("messages.sendMedia",{flags:t,peer:c.getInputPeerByID(e),media:n,random_id:o,reply_to_msg_id:m.getMessageLocalID(f)},i),r.then(function(e){e.updates&&angular.forEach(e.updates,function(e){"updateDraftMessage"==e._&&(e.local=!0)}),s.processUpdateMessage(e)},function(e){I(!0)})["finally"](function(){Fe[e]===i&&delete Fe[e]}),Fe[e]=i},Q([x]),h.pending.unshift(i),t.$broadcast("history_append",{peerID:e,messageID:i,my:!0}),setZeroTimeout(x.send),a.clearDraft&&g.clearDraft(e),De[l]=[e,i]}function ae(t,n,a){n=n.sort(),a=a||{};var i=0,o=c.isChannel(t),r=o&&c.isMegagroup(t),l=!(!o||r);l&&(i|=16),a.withMyScore&&(i|=256);var d=m.splitMessageIDsByChannels(n),u=[];return angular.forEach(d.msgIDs,function(e,n){for(var a=e.length,o=[],r=0;r0&&n<=4)||e.pFlags&&e.pFlags.resize||(e.splitCount=n),e.wrapped=!0,angular.forEach(e.rows,function(e){angular.forEach(e.buttons,function(e){e.rText=b.wrapRichText(e.text,{noLinks:!0,noLinebreaks:!0}),"keyboardButtonUrl"==e._&&(e.pUrl=b.wrapUrl(e.url,1))})}),e}function fe(e){var t=q(e),n=t.from_id&&r.getUser(t.from_id),a=n&&n.pFlags.bot&&n.username||!1,i=c.getPeerID(t.to_id),o=a||c.isBot(i)||c.isAnyGroup(i),s={noCommands:!o,fromBot:a,entities:t.totalEntities};if(t.pFlags.mentioned){var l=r.getSelf();l&&(s.highlightUsername=l.username)}return b.wrapRichText(t.message,s)}function _e(){if(He!==!1&&(clearTimeout(He),He=!1),je.length){var e=je.slice();je=[];var n=m.splitMessageIDsByChannels(e);angular.forEach(n.msgIDs,function(e,a){var i;i=a>0?_.invokeApi("channels.getMessages",{channel:l.getChannelInput(a),id:e}):_.invokeApi("messages.getMessages",{id:e}),i.then(function(e){r.saveApiUsers(e.users),l.saveApiChats(e.chats),Q(e.messages),t.$broadcast("messages_downloaded",n.mids[a])})})}}function ve(){if(ze!==!1&&(clearTimeout(ze),ze=!1),Ve.length){var e=Ve.slice();Ve=[];var t=m.splitMessageIDsByChannels(e);angular.forEach(t.msgIDs,function(e,n){_.invokeApi("messages.getMessagesViews",{peer:c.getInputPeerByID(-n),id:e,increment:!0}).then(function(e){if(n){for(var a=t.mids[n],i=[],o=0;o0?u=Math.min(t,d):t<0&&(c=Math.max(0,u+t)),n=c;nWe&&k.set({max_seen_msg:e})}function ke(e,n){n=n||{};var a,i,o=de(e),s={},c=!1,d=w.getNotifySettings();if(e.fwdFromID&&n.fwd_count)c=Ke(n.fwd_count);else if(e.message)c=d.nopreview?x("conversation_message_sent"):b.wrapPlainText(e.message);else if(e.media){var u=!1;switch(e.media._){case"messageMediaPhoto":c=x("conversation_media_photo_raw"),u="🖼";break;case"messageMediaDocument":switch(e.media.document.type){case"gif":c=x("conversation_media_gif_raw"),u="🎬";break;case"sticker":c=x("conversation_media_sticker");var p=e.media.document.stickerEmojiRaw;void 0!==p&&(c=b.wrapPlainText(p)+" "+c);break;case"video":c=x("conversation_media_video_raw"),u="📹";break;case"voice":case"audio":c=x("conversation_media_audio_raw");break;default:e.media.document.file_name?c=b.wrapPlainText("📎 "+e.media.document.file_name):(c=x("conversation_media_document_raw"),u="📎")}break;case"messageMediaGeo":case"messageMediaVenue":c=x("conversation_media_location_raw"),u="📍";break;case"messageMediaContact":c=x("conversation_media_contact_raw");break;case"messageMediaGame":c=b.wrapPlainText("🎮 "+e.media.game.title);break;default:c=x("conversation_media_attachment_raw")}u!==!1&&e.media.caption&&(c=b.wrapPlainText(u+" "+e.media.caption))}else if("messageService"==e._)switch(e.action._){case"messageActionChatCreate":c=x("conversation_group_created_raw");break;case"messageActionChatEditTitle":c=x("conversation_group_renamed_raw");break;case"messageActionChatEditPhoto":c=x("conversation_group_photo_updated_raw");break;case"messageActionChatDeletePhoto":c=x("conversation_group_photo_removed_raw");break;case"messageActionChatAddUser":case"messageActionChatAddUsers":c=x("conversation_invited_user_message_raw");break;case"messageActionChatReturn":c=x("conversation_returned_to_group_raw");break;case"messageActionChatJoined":c=x("conversation_joined_group_raw");break;case"messageActionChatDeleteUser":c=x("conversation_kicked_user_message_raw");break;case"messageActionChatLeave":c=x("conversation_left_group_raw");break;case"messageActionChatJoinedByLink":c=x("conversation_joined_by_link_raw");break;case"messageActionChannelCreate":c=x("conversation_created_channel_raw");break;case"messageActionChannelEditTitle":c=x("conversation_changed_channel_name_raw");break;case"messageActionChannelEditPhoto":c=x("conversation_changed_channel_photo_raw");break;case"messageActionChannelDeletePhoto":c=x("conversation_removed_channel_photo_raw");break;case"messageActionPinMessage":c=x("conversation_pinned_message_raw");break;case"messageActionGameScore":c=Ye(e.action.score)}if(o>0){var m=r.getUser(e.from_id),g=r.getUserPhoto(e.from_id);s.title=(m.first_name||"")+(m.first_name&&m.last_name?" ":"")+(m.last_name||""),s.title||(s.title=m.phone||x("conversation_unknown_user_raw")),i=g,a=r.getUserString(o)}else{if(s.title=l.getChat(-o).title||x("conversation_unknown_chat_raw"),e.from_id>0){var m=r.getUser(e.from_id);s.title=(m.first_name||m.last_name||x("conversation_unknown_user_raw"))+" @ "+s.title}i=l.getChatPhoto(-o),a=l.getChatString(-o)}s.title=b.wrapPlainText(s.title),s.onclick=function(){t.$broadcast("history_focus",{peerString:a,messageID:16&e.flags?e.mid:0})},s.message=c,s.key="msg"+e.mid,s.tag=a,i.location&&!i.location.empty?v.downloadSmallFile(i.location,i.size).then(function(t){e.pFlags.unread&&(s.image=t,w.notify(s))}):w.notify(s)}function $e(){i.cancel(tt),tt=!1,t.$broadcast("history_multiappend",nt),nt={}}function Se(){i.cancel(at),at=!1,angular.forEach(it,function(e){P(e)}),t.$broadcast("dialogs_multiupdate",it),it={}}function Ce(){i.cancel(ot),ot=!1;var e=t.idle.isIDLE&&M.isOtherDeviceActive()?3e4:1e3;angular.forEach(st,function(t){t.isMutedPromise.then(function(n){var a=t.top_message;!n&&a.pFlags.unread&&setTimeout(function(){a.pFlags.unread&&ke(a,{fwd_count:t.fwd_count})},e)})}),st={}}function Me(e){return _.invokeApi("messages.getPeerDialogs",{peers:[c.getInputPeerByID(e)]}).then(function(e){r.saveApiUsers(e.users),l.saveApiChats(e.chats),Q(e.messages);var n={},a=!1;angular.forEach(e.dialogs,function(e){if(e.top_message)E(e),A(e.peerID).length?t.$broadcast("dialog_top",e):(n[e.peerID]=e,a=!0);else{var i=c.getPeerID(e.peer),o=A(i);o.length&&(Te.dialogs.splice(o[1],1),t.$broadcast("dialog_drop",{peerID:i}))}}),a&&t.$broadcast("dialogs_multiupdate",n)})}var xe={},Ie={},Ae={},Ee={},Te={count:null,dialogs:[]},De={},Pe={},Fe={},Ne=e.when(),Re=-1,Oe=SearchIndexManager.createIndex(),Ue={query:!1},Be={},Le=[],je=[],He=!1,qe={},Ve=[],ze=!1,We=!1;Config.Modes.packed&&k.get("max_seen_msg").then(function(e){We=e||0});var Ge=a("dateOrTime"),Ke=x.pluralize("conversation_forwarded_X_messages"),Ye=x.pluralize("conversation_scored_X");w.start();var Ze=!1,Xe=0,Je=0,Qe={},et={},tt=!1,nt={},at=!1,it={},ot=!1,st={};return t.$on("apiUpdate",function(e,n){switch(n._){case"updateMessageID":var a=n.random_id,o=De[a];if(o){var s=o[0],d=c.isChannel(s)?-s:0;Pe[m.getFullMessageID(n.id,d)]=a}break;case"updateNewMessage":case"updateNewChannelMessage":var u=n.message,s=de(u),p=Ee[s];if("updateNewChannelMessage"==n._){var g=l.getChat(-s);if(g.pFlags&&(g.pFlags.left||g.pFlags.kicked))break}if(Q([u],{isNew:!0}),void 0!==p){var h=p.history;if(h.indexOf(u.mid)!=-1)return!1;var f=h[0];h.unshift(u.mid),u.mid>0&&u.mid0&&E&&r.forceUserOnline(s),I=0;IT)&&(u=xe[x],u.pFlags.out==E)){if(!u.pFlags.unread)break;u&&u.pFlags.unread&&(u.pFlags.unread=!1,Ie[x]&&(Ie[x].pFlags.unread=!1,N||(N=!0)),Ae[x]&&(Ae[x].pFlags.unread=!1),u.pFlags.out||(y[0]&&(P=--y[0].unread_count),w.cancel("msg"+x)))}if(y[0]){!E&&P&&y[0].top_message<=T&&(P=y[0].unread_count=0);var R=E?"read_outbox_max_id":"read_inbox_max_id";y[0][R]=T}P!==!1&&t.$broadcast("dialog_unread",{peerID:s,count:P}),N&&t.$broadcast("messages_read");break;case"updateReadMessagesContents":var I,x,u,O,U=n.messages,B=U.length;for(I=0;I0&&(a.count-=e.count,a.count<0&&(a.count=0));for(var s=0;s0,K="channel"==z._&&(z.username||!z.pFlags.left&&!z.pFlags.kicked)&&!0||!1,Y=void 0!==Ee[s];K!=Y&&(delete Ee[s],t.$broadcast("history_forbidden",s)),G!=W&&(W?Me(-d):y[0]&&(Te.dialogs.splice(y[1],1),t.$broadcast("dialog_drop",{peerID:s})));break;case"updateChannelReload":var d=n.channel_id,s=-d,y=A(s);y[0]&&Te.dialogs.splice(y[1],1),delete Ee[s],Me(-d).then(function(){t.$broadcast("history_reload",s)});break;case"updateChannelMessageViews":var Z=n.views,S=m.getFullMessageID(n.id,n.channel_id),u=q(S);u&&u.views&&u.viewss)&&(s=d.date)}}o.index=D(s),P(o),t.$broadcast("dialog_draft",{peerID:a,draft:i,index:o.index})}}),{getConversations:I,getHistory:B,getSearch:H,getMessage:q,getReplyKeyboard:L,readHistory:Y,readMessages:Z,flushHistory:J,deleteMessages:G,sendText:ee,sendFile:te,sendOther:ne,forwardMessages:ae,startBot:ie,shareGame:oe,editMessage:ce,convertMigratedPeer:U,getMessagePeer:de,getMessageThumb:be,getMessageShareLink:K,canMessageBeEdited:V,canEditMessage:z,getMessageEditData:W,clearDialogCache:me,wrapForDialog:ue,wrapForHistory:ge,wrapReplyMarkup:he,wrapSingleMessage:pe,wrapMessageText:fe,regroupWrappedHistory:ye}}]).service("AppMessagesIDsManager",function(){function e(e,t){if(!t||e<=0)return e;e=n(e);var a=i[t];return a||(a=++s*r,o[a]=t,i[t]=a),a+e}function t(e){if(e\n\t\n\t \n\t\n\t
\n\t\t
\n\t\t\t\n\t\t\t\n\t\t
\n\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\n\t\t\n\t\t
\n\t\t\t\n\t\t\t\n\t\t
\n\t
\n\t
\n \n \n\t
\n\t
\n\t\t
\n\t\t \n\t\t
\n\t\t
\n\t\t
\n\t\t
\n\t\t
\n\t\t
\n\t
\n\t \t
\n\t
\n\t
\n\t\n'),e.put("partials/mobile/changelog_modal.html",'
\n\n \n\n \n\n
\n'), -e.put("partials/mobile/channel_modal.html",'
\n\n
\n \n
\n\n \n\n
\n'),e.put("partials/mobile/chat_create_modal.html",'
\n\n
\n \n
\n\n \n\n
'),e.put("partials/mobile/chat_edit_modal.html",'
\n\n
\n \n
\n\n \n\n
'),e.put("partials/mobile/chat_modal.html",'
\n\n
\n \n
\n\n \n\n
\n'),e.put("partials/mobile/contacts_modal.html",'
\n\n
\n \n
\n\n \n\n
\n'),e.put("partials/mobile/country_select_modal.html",'
\n\n
\n \n
\n\n \n\n
\n'),e.put("partials/mobile/dialog.html",'\n\n
\n
\n \n \n
\n\n
\n\n
\n\n
\n \n
\n\n
\n\n
\n \n \n \n
\n\n
\n \n \n \n \n
\n\n
\n  \n
\n\n
\n \n \n \n :\n \n \n \n \n :\n \n \n \n\n \n
\n
\n\n
\n\n
\n'),e.put("partials/mobile/edit_contact_modal.html",'
\n\n
\n \n
\n\n \n\n
'),e.put("partials/mobile/full_gif.html",'\n\n
\n\n
\n
\n \n \n \n \n
\n
\n
GIF
\n
\n\n
\n \n \n
\n \n\n
\n\n
'),e.put("partials/mobile/full_photo.html",'
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n \n \n \n
\n
\n
\n
\n
\n
'),e.put("partials/mobile/full_video.html",'
\n
\n
\n
\n
\n
\n
\n
\n
\n \n
\n
\n \n \n
\n
\n
\n
\n
\n
'),e.put("partials/mobile/game_modal.html",'
\n\n
\n \n
\n\n \n\n
\n'),e.put("partials/mobile/head.html",'
\n \n
\n'), -e.put("partials/mobile/im.html",'
\n\n
\n\n
\n\n
\n
\n \n
\n\n
\n\n
\n

\n

\n \n \n
\n\n \n\n
\n
\n \n
\n\n
\n
\n \n
\n\n
\n
\n \n
\n\n
\n
\n\n
\n\n
\n \n
\n\n
\n
\n\n
\n\n
\n
\n
\n \n \n \n \n
\n\n
\n
\n
\n
\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n
\n\n
\n \n
\n \n
\n
\n
\n
\n \n \n \n
\n
\n
\n \n \n
\n
\n\n
\n\n
\n\n
\n
\n\n
\n \n \n
\n\n
\n \n
\n
\n\n
\n
\n \n \n\n
\n
\n
\n\n
\n \n
\n\n
\n \n \n
\n\n \n\n \n
\n\n\n
\n
\n
\n\n
\n
\n\n
\n\n
\n\n
\n\n
\n
\n\n
\n\n
\n\n
\n\n'),e.put("partials/mobile/import_contact_modal.html",'
\n\n
\n \n
\n\n \n
'),e.put("partials/mobile/login.html",'
\n \n
\n\n\n\n\n'),e.put("partials/mobile/message.html",'
\n\n\n
\n\n
\n
\n
\n
\n
\n
\n \n \n
\n\n \n \n \n\n
\n\n
\n\n \n\n
\n
\n
\n \n
\n
\n \n \n \n \n \n \n \n \n
\n\n
\n
\n\n \n \n\n \n\n
\n \n \n \n \n
\n\n
\n
\n
\n\n
\n\n
\n\n
\n\n
\n
\n\n
\n\n'),e.put("partials/mobile/message_actions_modal.html",'
\n\n
\n \n \n \n \n \n \n
\n\n
\n'),e.put("partials/mobile/message_attach_contact.html",'
\n \n
\n \n \n
\n
\n
'),e.put("partials/mobile/message_attach_document.html",'
\n\n
\n\n
\n\n
\n
\n
\n\n
\n
\n
\n\n \n\n
\n\n \n \n \n \n
\n \n
\n
\n\n
\n
\n \n \n \n
\n
\n \n \n \n
\n
\n \n
\n
\n
\n
\n
\n
\n
\n\n
\n
\n
\n'), -e.put("partials/mobile/message_attach_geo.html",'\n \n'),e.put("partials/mobile/message_attach_pending.html",'
\n
\n \n
\n
\n
\n \n \n
\n
\n \n
\n
\n
\n
\n
\n
\n
\n
\n'),e.put("partials/mobile/message_attach_photo.html",'\n \n\n
'),e.put("partials/mobile/message_attach_venue.html",'
\n\n \n \n \n\n
\n
\n \n
\n
\n
\n\n
\n'),e.put("partials/mobile/message_attach_webpage.html",'
\n
\n
\n
\n \n
\n
\n \n \n \n
\n
\n
\n
\n \n
\n
\n \n \n \n \n \n
\n\n
\n
\n \n \n \n
\n \n
\n
\n
\n
\n'),e.put("partials/mobile/message_service.html",'\n \n \n \n «»\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \n \n \n \n «»\n \n \n \n\n \n \n \n \n \n \n\n \n \n \n\n \n \n \n\n'),e.put("partials/mobile/password_recovery_modal.html",'
\n\n
\n \n
\n\n \n\n
'),e.put("partials/mobile/password_update_modal.html",'
\n\n
\n \n
\n\n \n\n
'),e.put("partials/mobile/peer_select.html",'
\n\n
\n \n
\n\n \n\n
\n'),e.put("partials/mobile/phonebook_modal.html",'
\n\n
\n \n
\n\n \n\n \n\n
\n'),e.put("partials/mobile/photo_modal.html",'
\n
\n
\n \n \n \n
\n\n
\n \n \n \n
\n\n
\n \n
\n \n
\n\n
\n
\n\n\n\n\n\n'),e.put("partials/mobile/profile_edit_modal.html",'
\n\n
\n \n
\n\n \n\n
'),e.put("partials/mobile/sessions_list_modal.html",'
\n\n
\n \n
\n\n \n\n
\n'),e.put("partials/mobile/settings_modal.html",'
\n\n
\n \n
\n\n \n
\n'), -e.put("partials/mobile/stickerset_modal.html",'
\n\n
\n \n
\n\n \n\n
'),e.put("partials/mobile/user_modal.html",'
\n\n
\n \n
\n\n \n\n
\n'),e.put("partials/mobile/username_edit_modal.html",'
\n\n
\n \n
\n\n \n\n
'),e.put("partials/mobile/video_modal.html",'
\n
\n
\n \n \n \n
\n\n
\n \n \n \n
\n\n
\n \n
\n \n
\n\n
\n
\n\n
\n
\n
\n \n \n \n
\n \n
\n
\n\n\n\n'),e.put("partials/desktop/audio_player.html",'
\n\t\n\t \n\t\n\t
\n\t\t
\n\t\t\t\n\t\t\t\n\t\t
\n\t\t[ \n\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\n\t\t]\n\t\t\n\t\t
\n\t\t\t\n\t\t\t\n\t\t
\n\t
\n\t
\n \n \n\t
\n\t
\n\t\t
\n\t\t \n\t\t
\n\t\t
\n\t\t
\n\t\t
\n\t\t
\n\t\t
\n\t
\n\t \t
\n\t \t
\n\t
\n\t
\n\t\n
'),e.put("partials/desktop/changelog_modal.html",'
\n\n
\n
\n
\n \n
\n
\n
\n\n
\n
\n \n
\n
\n
Telegram Web
\n
Version {{currentVersion}}
\n
\n
\n
\n\n
\n
\n \n \n \n
\n
\n\n
\n\n
\n\n
\n
0.5.5
\n
\n
    \n
  • Introducing Drafts: Seamless syncing for unsent messages on all your devices. Drafts are now visible in your chats list.
  • \n
  • Mention people in groups by typing @ and selecting them from the list — even if they don\'t have a username.
  • \n
  • Share links to specific posts in channels via quick forwarding menu (click on the date in a message to try this out).
  • \n
\n\n
\n
\n\n
\n
0.5.4
\n
\n
    \n
  • Introducing Bot API 2.0, the biggest update to our bot platform since June 2015.
  • \n
  • New inline keyboards with callback, \'open URL\' or \'switch to inline mode\' buttons help create seamless interfaces.
  • \n
  • Bots can now update existing messages on the fly as you interact with them.
  • \n
  • Prepare for the rise of location-based bots: all bots can now ask users to share their location.
  • \n
  • Inline bots can now send all attachments supported in Telegram (videos, music, stickers, files, etc.).
  • \n
  • Try out these sample bots to see what\'s coming your way soon: @music, @sticker, @youtube, @foursquare
  • \n
  • Check out the Telegram Blog for more info.
  • \n
  • New quick forwarding in channels (click on the date in a message to try this out).
  • \n
  • Improved performance.
  • \n
\n\n
\n
\n\n
\n
0.5.3
\n
\n
    \n
  • Inline bots: A new way to add bot content to any chat. Type a bot\'s username and your query in the text field to get instant results and send them to your chat partner. Try typing @gif dog in your next chat. Sample bots: @gif, @wiki, @bing, @vid, @bold.
  • \n
  • Check out the Telegram Blog for more info.
  • \n
  • Improved GIFs: 20x faster sending and downloading, nice animated progress
  • \n
  • Click on message date to reply (or to forward from channels).
  • \n
  • Preview images before sending when pasting from clipboard.
  • \n
  • Improved formatting for copy-pasted history fragments (date, time and sender names inserted automatically).
  • \n
\n
\n
\n\n
\n
0.5.2
\n
\n
    \n
  • Unread counters for muted chats now colored in gray.
  • \n
  • Improved previews for sticker sets: Click on a sticker to view the whole set, click on stickers in a set to send right away, added a \'Share\' button.
  • \n
  • Improved performance.
  • \n
\n
\n
\n\n
\n
0.5.1
\n
\n
    \n
  • Groups that have reached their capacity of 200 users can be upgraded to supergroups of up to 1,000 members.
  • \n
  • Check out the Telegram Blog for more info
  • \n
\n
\n
\n\n
\n
0.5.0
\n
\n
    \n
  • Removed annoying "multiple tabs open" error.
  • \n
  • Improved message forwarding.
  • \n
  • Added view counter to messages from channels.
  • \n
  • Improved image loading in Safari and Firefox.
  • \n
\n
\n
\n\n
\n
0.4.9
\n
\n
    \n
  • New emoji and sticker menu, tabs for sticker packs.
  • \n
\n
\n
\n\n
\n
0.4.8
\n
\n
    \n
  • Introducing Channels – a great new way to broadcast your messages to unlimited audiences.
  • \n
  • Check out the Telegram Blog for more info
  • \n
  • Improved performance in Safari on OS X El Capitan.
  • \n
  • Added formatting for fixed-width code, surround text with `single backticks` for inline text and ```triple backticks``` for blocks of pre-formatted text.
  • \n
\n
\n
\n\n
\n
0.4.7
\n
\n
    \n
  • New bot API, free for everyone. If you\'re an engineer, create your own bots for games, services or integrations.\n
  • \n
  • Check out Telegram Blog for more info
  • \n
  • Improved Stickers support: now stickers are loading much faster.
  • \n
  • Click on any custom stickers in chats to view and add sticker sets.
  • \n
  • [Mobile] Reply to a message easily: tap on any message and select "Reply".
  • \n
\n
\n
\n\n
\n
0.4.6
\n
\n \n
\n
\n\n
\n
0.4.5
\n
\n
    \n
  • \n Invite links for group chats:
    \n Check out Telegram Blog for more info\n
  • \n
  • Smart notifications
  • \n
  • \'Listened\' status for voice messages
  • \n
  • Places in locations (venues, landmarks)
  • \n
\n
\n
\n\n
\n
0.4.4
\n
\n
    \n
  • Link Previews:
    \n Get rich link summaries for tweets, YouTube videos, Instagram photos and other content.
  • \n\n
  • Check out Telegram Blog for more info.
  • \n
\n
\n
\n\n
\n
0.4.3
\n
\n
    \n
  • Sessions List:
    \n View your active Telegram sessions (on desktop, tablet and mobile devices) and close specific sessions remotely.
  • \n\n
  • Two-step verification:
    \n Set up an additional password that will be required to log into your Telegram account.
  • \n\n
  • Check out Telegram Blog for more info.
  • \n
\n
\n
\n\n
\n
0.4.2
\n
\n
    \n
  • Optimization for screens with smaller Y-resolutions.
  • \n
  • Supported Spotify URL embeds.
  • \n
  • Mentions of the current user in group chats are now highlighted.
  • \n
\n
\n
\n\n
\n
0.4.1
\n
\n
    \n
  • Reply to specific messages in groups.
  • \n
  • Mention @usernames in groups to notify multiple users.
  • \n
  • Revised notifications in groups: mentioned users and people you reply to will be notified (private chat notification settings apply in this case instead of group settings). Check out Telegram Blog for more info.
  • \n
  • Setting to disable message preview
  • \n
\n
\n
\n\n
\n
0.4.0
\n
\n
    \n
  • Full stickers support
  • \n
  • Multisearch box: instantly find chats, usernames and messages
  • \n
  • Emoji autocomplete: e.g., type :kiss in the message field to see the list. Full cheat sheet »
  • \n
  • Added \'typing\' notification in chats list
  • \n
  • Online members counter in group headers
  • \n
\n
\n
\n\n
\n
0.3.9
\n
\n
    \n
  • [Desktop] Material design completed
  • \n
\n
\n
\n\n
\n
0.3.8
\n
\n
    \n
  • Telegram.me links open right in Telegram Web when authorized
  • \n
  • @username mentions in messages are clickable and open a conversation with the user
  • \n
\n
\n
\n\n
\n
0.3.7
\n
\n
    \n
  • [Desktop] New material design for modal windows
  • \n
  • [Desktop] Forward messages to multiple recipients
  • \n
\n
\n
\n\n
\n
0.3.6
\n
\n
    \n
  • New viewer for photos, videos, documents.
  • \n
  • [FirefoxOS] Improved media downloads.
  • \n
\n
\n
\n\n
\n
0.3.5
\n
\n
    \n
  • Added embedded Soundcloud tracks and playlists.
  • \n
  • Added global user search to contacts list.
  • \n
  • Added switch to mobile version on window resize.
  • \n
  • Migrate to HTTPS notification
  • \n
  • Bugfixes.
  • \n
\n
\n
\n\n
\n
0.3.4
\n
\n
    \n
  • Added embedded Facebook posts and Vimeo videos.
  • \n
  • Improved IE10+ support: downloading files and style fixes.
  • \n
  • Added unsupported media playback warning.
  • \n
  • Bugfixes.
  • \n
\n
\n
\n\n
\n
0.3.3
\n
\n
    \n
  • Added Native Client module: dramatically improved encryption speed; Download and upload speed is now as high as in native applications.
  • \n
  • HTTPS. We recommend you to use https://web.telegram.org.
  • \n
  • Added multiple open tabs warning. Please note, that only one tab with Telegram Web will work.
  • \n
  • Added embedded Instagram, Twitter, Vine, YouTube links.
  • \n
  • Jump to selected spot when playing back audio.
  • \n
  • Bugfixes
  • \n
\n
\n
\n\n
\n
0.3.2
\n
\n
    \n
  • Usernames support: Choose a username right now!
  • \n
  • Search can now find public users by username.
  • \n
  • Most popular emoticons shown in \'recent\' when empty
  • \n
  • [ChromeApp] Added saving window position and size
  • \n
  • Bugfixes
  • \n
\n
\n
\n\n
\n
0.3.1
\n
\n
    \n
  • New languages: Spanish, German and Italian are now available
  • \n
  • New custom-made audio player
  • \n
  • Bad browser page for IE 6-9
  • \n
  • Perfomance improvements and bugfixes
  • \n
\n
\n
\n\n
\n
0.3.0
\n
\n
    \n
  • Log in codes may be received in other Telegram apps
  • \n
  • Partner\'s online status updates automatically
  • \n
  • Added support for non-english hashtags in messages
  • \n
  • Fixed invalid scrollbar width bug
  • \n
  • [Desktop] Added automatic country code detection
  • \n
  • [FirefoxOS] Improved PUSH-notifications for <= 1.1
  • \n
  • [FirefoxOS] Fixed emoji in notifications
  • \n
  • [FirefoxOS] Fixed attachment bug for <= 1.1
  • \n
  • [FirefoxOS] Added phonebook permissions handling
  • \n
  • [FirefoxOS] Added ability to share Gallery photos in Telegram
  • \n
\n
\n
\n\n
\n\n\n \n\n
\n\n
'), +m&&o.fwdFromID&&(s.grouped||(s.grouped="im_grouped_fwd_start"),o.grouped&&n==d-1&&(o.grouped+=" im_grouped_fwd_end"))}else!s&&n||(delete o.grouped,m&&s&&s.grouped&&s.fwdFromID&&(s.grouped+=" im_grouped_fwd_end"));p||l==(s&&s.grouped)||(p=!0),s=o,i=a}return p||r==(s&&s.grouped)||(p=!0),p}function be(e,t,n){var a,i=!1;if(e.media)switch(e.media._){case"messageMediaPhoto":a=d.choosePhotoSize(e.media.photo,t,n);break;case"messageMediaDocument":a=e.media.document.thumb,e.media.document.sticker&&(i=!0)}if(a&&"photoSizeEmpty"!=a._){var o=calcImageInBox(a.w,a.h,t,n,!0),s={width:o.w,height:o.h,location:a.location,size:a.size};return i&&(s.location.sticker=!0),s}return!1}function we(e){We!==!1&&e&&e>We&&k.set({max_seen_msg:e})}function ke(e,n){n=n||{};var a,i,o=de(e),s={},c=!1,d=w.getNotifySettings();if(e.fwdFromID&&n.fwd_count)c=Ke(n.fwd_count);else if(e.message)c=d.nopreview?x("conversation_message_sent"):b.wrapPlainText(e.message);else if(e.media){var u=!1;switch(e.media._){case"messageMediaPhoto":c=x("conversation_media_photo_raw"),u="🖼";break;case"messageMediaDocument":switch(e.media.document.type){case"gif":c=x("conversation_media_gif_raw"),u="🎬";break;case"sticker":c=x("conversation_media_sticker");var p=e.media.document.stickerEmojiRaw;void 0!==p&&(c=b.wrapPlainText(p)+" "+c);break;case"video":c=x("conversation_media_video_raw"),u="📹";break;case"voice":case"audio":c=x("conversation_media_audio_raw");break;default:e.media.document.file_name?c=b.wrapPlainText("📎 "+e.media.document.file_name):(c=x("conversation_media_document_raw"),u="📎")}break;case"messageMediaGeo":case"messageMediaVenue":c=x("conversation_media_location_raw"),u="📍";break;case"messageMediaContact":c=x("conversation_media_contact_raw");break;case"messageMediaGame":c=b.wrapPlainText("🎮 "+e.media.game.title);break;default:c=x("conversation_media_attachment_raw")}u!==!1&&e.media.caption&&(c=b.wrapPlainText(u+" "+e.media.caption))}else if("messageService"==e._)switch(e.action._){case"messageActionChatCreate":c=x("conversation_group_created_raw");break;case"messageActionChatEditTitle":c=x("conversation_group_renamed_raw");break;case"messageActionChatEditPhoto":c=x("conversation_group_photo_updated_raw");break;case"messageActionChatDeletePhoto":c=x("conversation_group_photo_removed_raw");break;case"messageActionChatAddUser":case"messageActionChatAddUsers":c=x("conversation_invited_user_message_raw");break;case"messageActionChatReturn":c=x("conversation_returned_to_group_raw");break;case"messageActionChatJoined":c=x("conversation_joined_group_raw");break;case"messageActionChatDeleteUser":c=x("conversation_kicked_user_message_raw");break;case"messageActionChatLeave":c=x("conversation_left_group_raw");break;case"messageActionChatJoinedByLink":c=x("conversation_joined_by_link_raw");break;case"messageActionChannelCreate":c=x("conversation_created_channel_raw");break;case"messageActionChannelEditTitle":c=x("conversation_changed_channel_name_raw");break;case"messageActionChannelEditPhoto":c=x("conversation_changed_channel_photo_raw");break;case"messageActionChannelDeletePhoto":c=x("conversation_removed_channel_photo_raw");break;case"messageActionPinMessage":c=x("conversation_pinned_message_raw");break;case"messageActionGameScore":c=Ye(e.action.score)}if(o>0){var m=r.getUser(e.from_id),g=r.getUserPhoto(e.from_id);s.title=(m.first_name||"")+(m.first_name&&m.last_name?" ":"")+(m.last_name||""),s.title||(s.title=m.phone||x("conversation_unknown_user_raw")),i=g,a=r.getUserString(o)}else{if(s.title=l.getChat(-o).title||x("conversation_unknown_chat_raw"),e.from_id>0){var m=r.getUser(e.from_id);s.title=(m.first_name||m.last_name||x("conversation_unknown_user_raw"))+" @ "+s.title}i=l.getChatPhoto(-o),a=l.getChatString(-o)}s.title=b.wrapPlainText(s.title),s.onclick=function(){t.$broadcast("history_focus",{peerString:a,messageID:16&e.flags?e.mid:0})},s.message=c,s.key="msg"+e.mid,s.tag=a,i.location&&!i.location.empty?v.downloadSmallFile(i.location,i.size).then(function(t){e.pFlags.unread&&(s.image=t,w.notify(s))}):w.notify(s)}function $e(){i.cancel(tt),tt=!1,t.$broadcast("history_multiappend",nt),nt={}}function Se(){i.cancel(at),at=!1,angular.forEach(it,function(e){P(e)}),t.$broadcast("dialogs_multiupdate",it),it={}}function Ce(){i.cancel(ot),ot=!1;var e=t.idle.isIDLE&&M.isOtherDeviceActive()?3e4:1e3;angular.forEach(st,function(t){t.isMutedPromise.then(function(n){var a=t.top_message;!n&&a.pFlags.unread&&setTimeout(function(){a.pFlags.unread&&ke(a,{fwd_count:t.fwd_count})},e)})}),st={}}function Me(e){return _.invokeApi("messages.getPeerDialogs",{peers:[c.getInputPeerByID(e)]}).then(function(e){r.saveApiUsers(e.users),l.saveApiChats(e.chats),Q(e.messages);var n={},a=!1;angular.forEach(e.dialogs,function(e){if(e.top_message)E(e),A(e.peerID).length?t.$broadcast("dialog_top",e):(n[e.peerID]=e,a=!0);else{var i=c.getPeerID(e.peer),o=A(i);o.length&&(Te.dialogs.splice(o[1],1),t.$broadcast("dialog_drop",{peerID:i}))}}),a&&t.$broadcast("dialogs_multiupdate",n)})}var xe={},Ie={},Ae={},Ee={},Te={count:null,dialogs:[]},De={},Pe={},Fe={},Ne=e.when(),Re=-1,Oe=SearchIndexManager.createIndex(),Ue={query:!1},Be={},Le=[],je=[],He=!1,qe={},Ve=[],ze=!1,We=!1;Config.Modes.packed&&k.get("max_seen_msg").then(function(e){We=e||0});var Ge=a("dateOrTime"),Ke=x.pluralize("conversation_forwarded_X_messages"),Ye=x.pluralize("conversation_scored_X");w.start();var Ze=!1,Xe=0,Je=0,Qe={},et={},tt=!1,nt={},at=!1,it={},ot=!1,st={};return t.$on("apiUpdate",function(e,n){switch(n._){case"updateMessageID":var a=n.random_id,o=De[a];if(o){var s=o[0],d=c.isChannel(s)?-s:0;Pe[m.getFullMessageID(n.id,d)]=a}break;case"updateNewMessage":case"updateNewChannelMessage":var u=n.message,s=de(u),p=Ee[s];if("updateNewChannelMessage"==n._){var g=l.getChat(-s);if(g.pFlags&&(g.pFlags.left||g.pFlags.kicked))break}if(Q([u],{isNew:!0}),void 0!==p){var h=p.history;if(h.indexOf(u.mid)!=-1)return!1;var f=h[0];h.unshift(u.mid),u.mid>0&&u.mid0&&E&&r.forceUserOnline(s),I=0;IT)&&(u=xe[x],u.pFlags.out==E)){if(!u.pFlags.unread)break;u&&u.pFlags.unread&&(u.pFlags.unread=!1,Ie[x]&&(Ie[x].pFlags.unread=!1,N||(N=!0)),Ae[x]&&(Ae[x].pFlags.unread=!1),u.pFlags.out||(y[0]&&(P=--y[0].unread_count),w.cancel("msg"+x)))}if(y[0]){!E&&P&&y[0].top_message<=T&&(P=y[0].unread_count=0);var R=E?"read_outbox_max_id":"read_inbox_max_id";y[0][R]=T}P!==!1&&t.$broadcast("dialog_unread",{peerID:s,count:P}),N&&t.$broadcast("messages_read");break;case"updateReadMessagesContents":var I,x,u,O,U=n.messages,B=U.length;for(I=0;I0&&(a.count-=e.count,a.count<0&&(a.count=0));for(var s=0;s0,K="channel"==z._&&(z.username||!z.pFlags.left&&!z.pFlags.kicked)&&!0||!1,Y=void 0!==Ee[s];K!=Y&&(delete Ee[s],t.$broadcast("history_forbidden",s)),G!=W&&(W?Me(-d):y[0]&&(Te.dialogs.splice(y[1],1),t.$broadcast("dialog_drop",{peerID:s})));break;case"updateChannelReload":var d=n.channel_id,s=-d,y=A(s);y[0]&&Te.dialogs.splice(y[1],1),delete Ee[s],Me(-d).then(function(){t.$broadcast("history_reload",s)});break;case"updateChannelMessageViews":var Z=n.views,S=m.getFullMessageID(n.id,n.channel_id),u=q(S);u&&u.views&&u.viewss)&&(s=d.date)}}o.index=D(s),P(o),t.$broadcast("dialog_draft",{peerID:a,draft:i,index:o.index})}}),{getConversations:I,getHistory:B,getSearch:H,getMessage:q,getReplyKeyboard:L,readHistory:Y,readMessages:Z,flushHistory:J,deleteMessages:G,sendText:ee,sendFile:te,sendOther:ne,forwardMessages:ae,startBot:ie,shareGame:oe,editMessage:ce,convertMigratedPeer:U,getMessagePeer:de,getMessageThumb:be,getMessageShareLink:K,canMessageBeEdited:V,canEditMessage:z,getMessageEditData:W,clearDialogCache:me,wrapForDialog:ue,wrapForHistory:ge,wrapReplyMarkup:he,wrapSingleMessage:pe,wrapMessageText:fe,regroupWrappedHistory:ye}}]).service("AppMessagesIDsManager",function(){function e(e,t){if(!t||e<=0)return e;e=n(e);var a=i[t];return a||(a=++s*r,o[a]=t,i[t]=a),a+e}function t(e){if(e\n\t\n\t \n\t\n\t
\n\t\t
\n\t\t\t\n\t\t\t\n\t\t
\n\t\t[ \n\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\n\t\t]\n\t\t\n\t\t
\n\t\t\t\n\t\t\t\n\t\t
\n\t
\n\t
\n \n \n\t
\n\t
\n\t\t
\n\t\t \n\t\t
\n\t\t
\n\t\t
\n\t\t
\n\t\t
\n\t\t
\n\t
\n\t \t
\n\t \t
\n\t
\n\t
\n\t\n'),e.put("partials/desktop/changelog_modal.html",'
\n\n
\n
\n
\n \n
\n
\n
\n\n
\n
\n \n
\n
\n
Telegram Web
\n
Version {{currentVersion}}
\n
\n
\n
\n\n
\n
\n \n \n \n
\n
\n\n
\n\n
\n\n
\n
0.5.5
\n
\n
    \n
  • Introducing Drafts: Seamless syncing for unsent messages on all your devices. Drafts are now visible in your chats list.
  • \n
  • Mention people in groups by typing @ and selecting them from the list — even if they don\'t have a username.
  • \n
  • Share links to specific posts in channels via quick forwarding menu (click on the date in a message to try this out).
  • \n
\n\n
\n
\n\n
\n
0.5.4
\n
\n
    \n
  • Introducing Bot API 2.0, the biggest update to our bot platform since June 2015.
  • \n
  • New inline keyboards with callback, \'open URL\' or \'switch to inline mode\' buttons help create seamless interfaces.
  • \n
  • Bots can now update existing messages on the fly as you interact with them.
  • \n
  • Prepare for the rise of location-based bots: all bots can now ask users to share their location.
  • \n
  • Inline bots can now send all attachments supported in Telegram (videos, music, stickers, files, etc.).
  • \n
  • Try out these sample bots to see what\'s coming your way soon: @music, @sticker, @youtube, @foursquare
  • \n
  • Check out the Telegram Blog for more info.
  • \n
  • New quick forwarding in channels (click on the date in a message to try this out).
  • \n
  • Improved performance.
  • \n
\n\n
\n
\n\n
\n
0.5.3
\n
\n
    \n
  • Inline bots: A new way to add bot content to any chat. Type a bot\'s username and your query in the text field to get instant results and send them to your chat partner. Try typing @gif dog in your next chat. Sample bots: @gif, @wiki, @bing, @vid, @bold.
  • \n
  • Check out the Telegram Blog for more info.
  • \n
  • Improved GIFs: 20x faster sending and downloading, nice animated progress
  • \n
  • Click on message date to reply (or to forward from channels).
  • \n
  • Preview images before sending when pasting from clipboard.
  • \n
  • Improved formatting for copy-pasted history fragments (date, time and sender names inserted automatically).
  • \n
\n
\n
\n\n
\n
0.5.2
\n
\n
    \n
  • Unread counters for muted chats now colored in gray.
  • \n
  • Improved previews for sticker sets: Click on a sticker to view the whole set, click on stickers in a set to send right away, added a \'Share\' button.
  • \n
  • Improved performance.
  • \n
\n
\n
\n\n
\n
0.5.1
\n
\n
    \n
  • Groups that have reached their capacity of 200 users can be upgraded to supergroups of up to 1,000 members.
  • \n
  • Check out the Telegram Blog for more info
  • \n
\n
\n
\n\n
\n
0.5.0
\n
\n
    \n
  • Removed annoying "multiple tabs open" error.
  • \n
  • Improved message forwarding.
  • \n
  • Added view counter to messages from channels.
  • \n
  • Improved image loading in Safari and Firefox.
  • \n
\n
\n
\n\n
\n
0.4.9
\n
\n
    \n
  • New emoji and sticker menu, tabs for sticker packs.
  • \n
\n
\n
\n\n
\n
0.4.8
\n
\n
    \n
  • Introducing Channels – a great new way to broadcast your messages to unlimited audiences.
  • \n
  • Check out the Telegram Blog for more info
  • \n
  • Improved performance in Safari on OS X El Capitan.
  • \n
  • Added formatting for fixed-width code, surround text with `single backticks` for inline text and ```triple backticks``` for blocks of pre-formatted text.
  • \n
\n
\n
\n\n
\n
0.4.7
\n
\n
    \n
  • New bot API, free for everyone. If you\'re an engineer, create your own bots for games, services or integrations.\n
  • \n
  • Check out Telegram Blog for more info
  • \n
  • Improved Stickers support: now stickers are loading much faster.
  • \n
  • Click on any custom stickers in chats to view and add sticker sets.
  • \n
  • [Mobile] Reply to a message easily: tap on any message and select "Reply".
  • \n
\n
\n
\n\n
\n
0.4.6
\n
\n \n
\n
\n\n
\n
0.4.5
\n
\n
    \n
  • \n Invite links for group chats:
    \n Check out Telegram Blog for more info\n
  • \n
  • Smart notifications
  • \n
  • \'Listened\' status for voice messages
  • \n
  • Places in locations (venues, landmarks)
  • \n
\n
\n
\n\n
\n
0.4.4
\n
\n
    \n
  • Link Previews:
    \n Get rich link summaries for tweets, YouTube videos, Instagram photos and other content.
  • \n\n
  • Check out Telegram Blog for more info.
  • \n
\n
\n
\n\n
\n
0.4.3
\n
\n
    \n
  • Sessions List:
    \n View your active Telegram sessions (on desktop, tablet and mobile devices) and close specific sessions remotely.
  • \n\n
  • Two-step verification:
    \n Set up an additional password that will be required to log into your Telegram account.
  • \n\n
  • Check out Telegram Blog for more info.
  • \n
\n
\n
\n\n
\n
0.4.2
\n
\n
    \n
  • Optimization for screens with smaller Y-resolutions.
  • \n
  • Supported Spotify URL embeds.
  • \n
  • Mentions of the current user in group chats are now highlighted.
  • \n
\n
\n
\n\n
\n
0.4.1
\n
\n
    \n
  • Reply to specific messages in groups.
  • \n
  • Mention @usernames in groups to notify multiple users.
  • \n
  • Revised notifications in groups: mentioned users and people you reply to will be notified (private chat notification settings apply in this case instead of group settings). Check out Telegram Blog for more info.
  • \n
  • Setting to disable message preview
  • \n
\n
\n
\n\n
\n
0.4.0
\n
\n
    \n
  • Full stickers support
  • \n
  • Multisearch box: instantly find chats, usernames and messages
  • \n
  • Emoji autocomplete: e.g., type :kiss in the message field to see the list. Full cheat sheet »
  • \n
  • Added \'typing\' notification in chats list
  • \n
  • Online members counter in group headers
  • \n
\n
\n
\n\n
\n
0.3.9
\n
\n
    \n
  • [Desktop] Material design completed
  • \n
\n
\n
\n\n
\n
0.3.8
\n
\n
    \n
  • Telegram.me links open right in Telegram Web when authorized
  • \n
  • @username mentions in messages are clickable and open a conversation with the user
  • \n
\n
\n
\n\n
\n
0.3.7
\n
\n
    \n
  • [Desktop] New material design for modal windows
  • \n
  • [Desktop] Forward messages to multiple recipients
  • \n
\n
\n
\n\n
\n
0.3.6
\n
\n
    \n
  • New viewer for photos, videos, documents.
  • \n
  • [FirefoxOS] Improved media downloads.
  • \n
\n
\n
\n\n
\n
0.3.5
\n
\n
    \n
  • Added embedded Soundcloud tracks and playlists.
  • \n
  • Added global user search to contacts list.
  • \n
  • Added switch to mobile version on window resize.
  • \n
  • Migrate to HTTPS notification
  • \n
  • Bugfixes.
  • \n
\n
\n
\n\n
\n
0.3.4
\n
\n
    \n
  • Added embedded Facebook posts and Vimeo videos.
  • \n
  • Improved IE10+ support: downloading files and style fixes.
  • \n
  • Added unsupported media playback warning.
  • \n
  • Bugfixes.
  • \n
\n
\n
\n\n
\n
0.3.3
\n
\n
    \n
  • Added Native Client module: dramatically improved encryption speed; Download and upload speed is now as high as in native applications.
  • \n
  • HTTPS. We recommend you to use https://web.telegram.org.
  • \n
  • Added multiple open tabs warning. Please note, that only one tab with Telegram Web will work.
  • \n
  • Added embedded Instagram, Twitter, Vine, YouTube links.
  • \n
  • Jump to selected spot when playing back audio.
  • \n
  • Bugfixes
  • \n
\n
\n
\n\n
\n
0.3.2
\n
\n
    \n
  • Usernames support: Choose a username right now!
  • \n
  • Search can now find public users by username.
  • \n
  • Most popular emoticons shown in \'recent\' when empty
  • \n
  • [ChromeApp] Added saving window position and size
  • \n
  • Bugfixes
  • \n
\n
\n
\n\n
\n
0.3.1
\n
\n
    \n
  • New languages: Spanish, German and Italian are now available
  • \n
  • New custom-made audio player
  • \n
  • Bad browser page for IE 6-9
  • \n
  • Perfomance improvements and bugfixes
  • \n
\n
\n
\n\n
\n
0.3.0
\n
\n
    \n
  • Log in codes may be received in other Telegram apps
  • \n
  • Partner\'s online status updates automatically
  • \n
  • Added support for non-english hashtags in messages
  • \n
  • Fixed invalid scrollbar width bug
  • \n
  • [Desktop] Added automatic country code detection
  • \n
  • [FirefoxOS] Improved PUSH-notifications for <= 1.1
  • \n
  • [FirefoxOS] Fixed emoji in notifications
  • \n
  • [FirefoxOS] Fixed attachment bug for <= 1.1
  • \n
  • [FirefoxOS] Added phonebook permissions handling
  • \n
  • [FirefoxOS] Added ability to share Gallery photos in Telegram
  • \n
\n
\n
\n\n
\n\n\n \n\n
\n\n
'), e.put("partials/desktop/channel_edit_modal.html",'
\n\n
\n\n \n\n
\n\n \n\n
'),e.put("partials/desktop/channel_modal.html",'
\n\n
\n
\n
\n \n \n
\n
\n \n \n
\n
\n\n
\n
\n
\n \n
\n \n
\n
\n
\n
\n \n \n
\n
\n
\n
\n\n
\n
\n
\n \n \n
\n \n \n \n
\n
\n\n
\n\n
\n\n
\n \n\n
\n
\n \n
\n
\n
\n\n
\n
\n \n
\n
\n
\n\n
\n
\n \n \n \n \n
\n
\n
\n
\n\n \n\n
\n \n\n \n \n \n \n\n
\n\n \n\n
\n\n
\n\n
\n\n
\n \n\n
\n\n
\n\n \n \n\n \n\n
\n \n
\n
\n
\n\n
\n\n
\n\n
\n
\n\n\n
\n'),e.put("partials/desktop/chat_create_modal.html",'
\n\n
\n\n \n\n
\n\n \n\n
'),e.put("partials/desktop/chat_edit_modal.html",'
\n\n
\n\n \n\n
\n\n \n\n
'),e.put("partials/desktop/chat_invite_link_modal.html",'
\n\n
\n\n \n\n
\n\n \n\n
'),e.put("partials/desktop/chat_modal.html",'
\n\n
\n
\n
\n \n \n
\n
\n
\n\n
\n
\n
\n \n
\n \n
\n
\n
\n
\n \n \n
\n
\n
\n
\n\n
\n
\n
\n \n \n
\n
\n
\n\n
\n\n
\n\n \n\n \n\n
\n \n\n \n \n \n \n\n
\n\n \n\n \n\n
\n\n
\n\n
\n
\n

\n

\n
    \n
  • \n
  • \n
  • \n
  • \n
\n
\n
\n
\n\n
\n \n\n
\n\n
\n\n \n \n\n \n\n
\n \n
\n
\n
\n\n
\n\n
\n\n
\n
\n\n\n
\n'),e.put("partials/desktop/composer_dropdown.html",'
\n\n \n\n \n\n
    \n\n
    \n\n
    '),e.put("partials/desktop/confirm_modal.html",'
    \n\n
    \n\n
    \n \n \n \n \n \n \n \n\n \n \n \n \n
    \n \n
    \n
    \n \n \n \n \n \n \n \n
    \n \n
    \n \n
    \n
    \n \n \n \n \n \n \n \n \n \n \n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n\n\n\n \n \n \n \n
    \n\n
    \n\n \n\n
    \n'),e.put("partials/desktop/contacts_modal.html",'
    \n\n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    \n \n \n \n \n \n
    \n \n
    \n
    \n\n
    \n\n \n\n
    \n\n
    \n
    \n\n
    \n {0}\n
    \n\n \n\n
    \n
    \n\n
    \n\n
    \n\n \n\n
    \n'),e.put("partials/desktop/country_select_modal.html",'
    \n\n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n\n
    \n\n \n\n
    \n\n
    \n
    \n\n \n\n
    \n
    \n\n
    \n\n
    \n\n
    \n'), e.put("partials/desktop/dialog.html",'\n\n
    \n
    \n \n \n
    \n\n
    \n\n
    \n\n
    \n \n
    \n\n
    \n\n
    \n \n \n \n
    \n\n
    \n \n \n \n \n
    \n\n
    \n  \n
    \n\n
    \n \n \n \n :\n \n \n \n \n :\n \n \n \n\n \n
    \n
    \n\n
    \n\n
    \n'),e.put("partials/desktop/document_modal.html",'\n\n
    \n
    \n
    \n \n \n \n \n \n \n \n \n \n
    \n\n
    \n \n
    \n \n
    \n
    \n \n \n
    \n
    \n\n
    \n\n
    \n
    \n\n'),e.put("partials/desktop/edit_contact_modal.html",'
    \n\n
    \n\n \n\n
    \n\n \n\n
    '),e.put("partials/desktop/embed_modal.html",'\n\n
    \n
    \n
    \n \n \n \n \n \n \n
    \n\n
    \n
    \n \n
    \n
    \n
    \n\n
    \n
    \n
    \n\n'),e.put("partials/desktop/emoji_btn_tooltip.html",'
    \n\n
    \n
    \n\n
    \n \n
    \n\n
    \n
    \n \n
    \n
    \n \n
    \n
    \n\n
    \n
    \n\n \n \n \n\n
    '),e.put("partials/desktop/error_modal.html",'
    \n\n
    \n\n

    \n \n \n \n \n \n \n \n \n \n \n \n \n \n

    \n

    \n \n \n \n

    \n\n
    \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n {0}\n \n \n \n \n \n \n \n\n\n
    \n \n \n {0}\n \n \n \n \n \n
    \n\n
    \n\n
    \n \n
    \n \n
    \n
    \n\n
    \n\n
    \n\n \n\n
    \n'),e.put("partials/desktop/footer.html",''),e.put("partials/desktop/forwarded_messages.html",'
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n \n
    \n
    \n \n \n \n \n
    \n
    \n
    '),e.put("partials/desktop/full_document.html",'
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n \n
    \n
    '),e.put("partials/desktop/full_gif.html",'\n\n
    \n\n
    \n
    \n \n \n \n \n
    \n
    \n
    [GIF]
    \n
    \n\n
    \n \n \n
    \n \n\n
    \n\n
    '),e.put("partials/desktop/full_photo.html",'
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    \n
    \n
    '),e.put("partials/desktop/full_video.html",'
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n \n
    \n
    \n
    \n
    \n
    \n
    '),e.put("partials/desktop/game_modal.html",'\n\n
    \n
    \n
    \n \n \n \n
    \n\n
    \n \n
    \n \n
    \n
    \n \n
    \n
    \n\n
    \n
    \n
    \n\n'),e.put("partials/desktop/head.html",'
    \n
    \n\n
    \n \n
    \n\n
    \n
    \n \n \n \n
    \n\n
    \n\n \n\n \n\n \n \n \n \n \n\n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n\n \n
    \n \n \n \n \n \n
    \n
    \n\n
    \n\n
    \n
    \n
    \n
    '),e.put("partials/desktop/im.html",'
    \n\n
    \n\n
    \n\n
    \n
    \n \n
    \n\n
    \n
    \n
    \n\n
    \n

    \n

    \n \n \n
    \n\n \n\n
    \n
    \n \n
    \n\n
    \n
    \n \n
    \n\n
    \n
    \n \n
    \n\n
    \n
    \n
    \n
    \n\n
    \n\n
    \n
    \n

    \n

    \n \n
    \n
    \n
    \n\n
    \n
    \n
    \n\n
    \n
    \n\n
    \n\n
    \n\n
    \n
    \n\n
    \n
    \n
    \n
    \n
    \n
    \n\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n\n
    \n\n
    \n\n
    \n
    \n
    \n
    \n \n \n \n \n \n \n {{historyState.typing.length - 2}}\n \n
    \n
    \n\n
    \n\n
    \n\n
    \n\n
    \n\n
    \n
    \n\n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n \n \n \n \n \n \n
    \n
    \n\n
    \n\n
    \n\n
    \n\n \n \n \n \n\n
    \n\n
    \n\n
    \n \n \n
    \n\n
    \n \n
    \n
    \n\n
    \n \n
    \n
    \n
    \n \n \n\n
    \n \n
    \n\n
    \n \n\n
    \n \n \n
    \n\n
    \n \n \n
    \n\n
    \n
    \n\n
    \n
    \n
    \n\n
    \n
    \n\n
    \n\n
    \n\n
    \n\n
    \n
    \n\n
    \n\n
    \n\n
    \n\n\n\n\n'), e.put("partials/desktop/import_contact_modal.html",'
    \n\n
    \n\n \n\n
    \n\n \n\n
    '),e.put("partials/desktop/inactive.html",'
    \n
    \n
    \n
    \n \n

    \n
    \n
    \n \n
    \n
    \n
    \n
    '),e.put("partials/desktop/inline_results.html",'\n\n'),e.put("partials/desktop/lang_footer.html",''),e.put("partials/desktop/login.html",'\n\n'),e.put("partials/desktop/media_modal_layout.html",''),e.put("partials/desktop/megagroup_edit_modal.html",'
    \n\n
    \n\n \n\n
    \n\n \n\n
    '),e.put("partials/desktop/message.html",'
    \n\n
    \n\n
    \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n\n \n \n \n\n
    \n\n
    \n \n\n \n \n \n \n\n \n\n
    \n
    \n
    \n \n
    \n
    \n \n \n \n \n
    \n\n
    \n\n \n []  :\n \n\n\n \n\n
    \n \n \n
    \n   [\n \n \n \n
    \n
    \n\n
    \n
    \n
    \n
    \n
    \n
    \n\n\n
    \n\n
    \n
    \n\n
    \n\n'),e.put("partials/desktop/message_attach_contact.html",'
    \n \n
    \n \n \n
    \n
    \n
    '),e.put("partials/desktop/message_attach_document.html",'
    \n\n
    \n\n
    \n\n
    \n
    \n
    \n\n
    \n
    \n
    \n\n
    \n \n \n \n \n \n\n
    \n
    \n [ ]\n \n \n
    \n
    \n \n \n \n \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n\n
    \n\n \n \n \n \n
    \n \n
    \n
    \n\n
    \n
    \n []\n \n \n
    \n
    \n \n \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n\n
    \n
    \n
    \n'),e.put("partials/desktop/message_attach_game.html",'
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n'),e.put("partials/desktop/message_attach_geo.html",'\n \n'),e.put("partials/desktop/message_attach_pending.html",'
    \n
    \n \n
    \n
    \n
    \n \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n'), e.put("partials/desktop/message_attach_photo.html",'\n \n\n
    '),e.put("partials/desktop/message_attach_venue.html",'
    \n\n \n \n \n\n
    \n
    \n \n
    \n
    \n
    \n\n
    \n'),e.put("partials/desktop/message_attach_webpage.html",'
    \n
    \n
    \n \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n \n \n \n \n
    \n\n
    \n
    \n
    \n\n
    \n
    \n \n
    \n
    \n
    \n\n
    \n \n \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n'),e.put("partials/desktop/message_media.html",'
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    '),e.put("partials/desktop/message_service.html",'\n \n \n \n «»\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \n \n \n \n «»\n \n \n \n\n \n \n \n \n \n \n\n \n \n \n\n\n \n \n \n\n'),e.put("partials/desktop/password_recovery_modal.html",'
    \n\n
    \n\n \n\n
    \n\n \n\n
    '),e.put("partials/desktop/password_update_modal.html",'
    \n\n
    \n\n \n\n
    \n\n \n\n
    '),e.put("partials/desktop/peer_select.html",'
    \n\n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n\n
    \n\n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n\n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n\n
    \n\n \n\n \n\n
    \n'),e.put("partials/desktop/photo_modal.html",'\n\n\n\n
    \n
    \n
    \n \n \n \n \n \n \n \n \n \n
    \n\n
    \n \n
    \n \n
    \n
    \n \n \n
    \n
    \n\n
    \n
    \n \n
    \n
    \n
    \n\n
    \n \n \n \n \n \n
    \n
    \n
    \n\n\n\n'),e.put("partials/desktop/pinned_message.html",''),e.put("partials/desktop/profile_edit_modal.html",'
    \n\n
    \n\n \n\n
    \n\n \n\n
    \n'),e.put("partials/desktop/reply_markup.html",'
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    '),e.put("partials/desktop/reply_message.html",'
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n \n \n
    \n
    \n \n \n
    \n
    '),e.put("partials/desktop/sessions_list_modal.html",'
    \n\n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n\n
    \n\n
    \n\n
    \n
    \n\n
    \n \n \n \n
    \n\n \n\n
    \n
    \n\n
    \n\n
    \n\n
    \n'),e.put("partials/desktop/settings_modal.html",'
    \n\n
    \n
    \n
    \n \n \n
    \n
    \n
    \n\n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n\n
    \n
    \n
    \n \n \n
    \n
    \n
    \n\n
    \n\n
    \n\n
    \n \n\n
    \n
    \n
    \n
    \n\n
    \n
    \n \n \n
    \n
    \n
    \n
    \n\n
    \n \n\n \n \n \n \n\n \n \n \n \n\n \n\n \n \n \n \n\n \n \n \n \n\n
    \n
    \n
    \n\n
    \n\n
    \n \n\n \n\n
    \n\n \n\n
    \n\n
    \n\n
    \n'), -e.put("partials/desktop/short_message.html",'\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n'),e.put("partials/desktop/slider.html",'
    \n\t
    \n\t
    \n\t\t
    \n\t
    \n
    '),e.put("partials/desktop/stickerset_modal.html",'
    \n\n
    \n
    \n
    \n \n
    \n
    \n
    \n \n \n
    \n
    \n\n
    \n\n
    \n\n
    \n
    \n\n
    \n \n \n \n
    \n\n
    \n \n
    \n
    \n
    \n
    \n\n
    \n
    \n\n
    \n\n
    \n
    \n \n \n \n
    \n
    \n\n
    \n\n
    \n'),e.put("partials/desktop/user_modal.html",'
    \n\n
    \n
    \n
    \n \n \n
    \n
    \n
    \n\n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n\n
    \n
    \n \n \n \n
    \n
    \n\n\n
    \n\n
    \n\n
    \n \n\n
    \n
    \n
    \n
    \n\n
    \n
    \n \n
    \n
    \n
    \n\n
    \n
    \n \n
    \n
    \n
    \n
    \n\n
    \n \n\n \n \n \n \n\n
    \n\n \n\n
    \n\n
    \n\n
    \n\n'),e.put("partials/desktop/username_edit_modal.html",'
    \n\n
    \n\n \n\n
    \n\n \n\n
    '),e.put("partials/desktop/video_modal.html",'\n\n
    \n
    \n
    \n \n \n \n \n \n \n \n \n \n
    \n\n
    \n \n
    \n \n
    \n
    \n \n \n
    \n
    \n\n
    \n
    \n
    \n\n')}]),function(e,t,n,a){function i(e){ConfigStorage.get("emojis_popular",function(t){var n=[];if(t&&t.length){for(var a=0,i=t.length;a41&&(i=i.slice(0,41)),i.push([e,1])),ConfigStorage.set({emojis_popular:i})})}function s(){if(v===!1){v=SearchIndexManager.createIndex();var e;for(e in f)f.hasOwnProperty(e)&&SearchIndexManager.indexObject(f[e],e,v)}}function r(e){s();var t,n=SearchIndexManager.search(e,v),a=[];for(t in n)n.hasOwnProperty(t)&&a.push(t);return a}var l,c,d,u,p,m,g,h,t={},f={},_={},v=!1,y="joy,kissing_heart,heart,heart_eyes,blush,grin,+1,relaxed,pensive,smile,sob,kiss,unamused,flushed,stuck_out_tongue_winking_eye,see_no_evil,wink,smiley,cry,stuck_out_tongue_closed_eyes,scream,rage,smirk,disappointed,sweat_smile,kissing_closed_eyes,speak_no_evil,relieved,grinning,yum,laughing,ok_hand,neutral_face,confused".split(",");for(l=0,g=n.length;l
    '+this.langpack.im_stickers_tab+'
    ';e=e.replace(/>\s+<");var t=this;this.tooltipEl=$(e).appendTo(document.body),this.tabsEl=$(".composer_emoji_tooltip_tabs",this.tooltipEl),this.categoriesEl=$(".composer_emoji_tooltip_categories",this.tooltipEl),this.stickersCategoriesEl=$(".composer_emoji_tooltip_tab_stickers_content .composer_emoji_tooltip_categories",this.tooltipEl),this.contentEl=$(".composer_emoji_tooltip_content",this.tooltipEl),this.emojiContentEl=$(".composer_emoji_tooltip_content_emoji",this.tooltipEl),this.stickersContentEl=$(".composer_emoji_tooltip_content_stickers",this.tooltipEl),angular.forEach(["emoji","stickers"],function(e,n){var a=$(".composer_emoji_tooltip_tab_"+e,t.tabsEl).on("mousedown",function(e){return t.selectTab(n),cancelEvent(e)});Config.Navigator.touch||a.on("mouseenter mouseleave",function(e){clearTimeout(t.selectTabTimeout),"mouseenter"==e.type&&(t.selectTabTimeout=setTimeout(function(){t.selectTab(n)},300))})});var n="mousedown";return Config.Navigator.touch||(n+=" mouseover mouseout"),this.categoriesEl.on(n,function(e){e=e.originalEvent||e;var n=e.target;if("A"!=n.tagName&&(n=n.parentNode),"A"==n.tagName){var a=parseInt(n.getAttribute("data-category"));if("mousedown"==e.type)return t.selectCategory(a),cancelEvent(e);if(!t.tab){var i="mouseover"==e.type;i&&t.selectCategoryIndex==a||(clearTimeout(t.selectCategoryTimeout),delete t.selectCategoryTimeout,i?(t.selectCategoryIndex=a,t.selectCategoryTimeout=setTimeout(function(){delete t.selectCategoryIndex,delete t.selectCategoryTimeout,t.selectCategory(a)},300)):delete t.selectCategoryIndex)}}}),this.emojiScroller=new Scroller(this.emojiContentEl,{classPrefix:"composer_emoji_tooltip"}),this.stickersScroller=new Scroller(this.stickersContentEl,{classPrefix:"composer_emoji_tooltip"}),this.stickersScroller.onScroll(function(e,n){t.onStickersScroll(e,n)}),this.contentEl.on("mousedown",function(e){e=e.originalEvent||e;var n,a,i,o=$(e.target);return"A"!=o[0].tagName&&(o=$(o[0].parentNode)),(n=o.attr("data-code"))&&(t.onEmojiSelected&&t.onEmojiSelected(n),EmojiHelper.pushPopularEmoji(n)),(a=o.attr("data-sticker"))&&(t.onStickerSelected&&t.onStickerSelected(a),Config.Mobile&&t.hide()),(i=o.attr("data-stickerset"))&&(t.onStickersetSelected&&t.onStickersetSelected(i),t.hide()),cancelEvent(e)}),Config.Navigator.touch||this.tooltipEl.on("mouseenter mouseleave",function(e){"mouseenter"==e.type?t.onMouseEnter():t.onMouseLeave()}),this.selectTab(0),$(window).on("resize",this.updatePosition.bind(this)),!0},EmojiTooltip.prototype.selectCategory=function(e,t){return!(!this.tab&&this.cat===e&&!t)&&($(".active",this.categoriesEl).removeClass("active"),this.cat=e,void(this.tab?(this.activateStickerCategory(),this.updateStickersContents(t)):($(this.categoriesEl[this.tab].childNodes[e]).addClass("active"),this.updateEmojiContents())))},EmojiTooltip.prototype.selectTab=function(e,t){if(this.tab===e&&!t)return!1;this.tab=e,this.selectCategory(0,!0);var n=this;setTimeout(function(){$(n.tooltipEl).toggleClass("composer_emoji_tooltip_tabs_stickers_active",1==e)},0)},EmojiTooltip.prototype.updateEmojiContents=function(){var e=[],t=this,n=26,a=function(){t.emojiContentEl.html(e.join("")),t.emojiScroller.reinit()};if(this.cat>0){var i,o,s,r,l,c=this.cat-1,d=Config.EmojiCategories[c],u=Config.EmojiCategorySpritesheetDimens[c][1],p=d.length;for(s=0;s');a()}else EmojiHelper.getPopularEmoji(function(t){var i,o,s,r,l,c,d,u,p=t.length;for(c=0;c'));a()})},EmojiTooltip.prototype.updateStickersContents=function(e){var t=[],n=[],a=this,i=function(){var t=a.cat?a.stickersetPositions[a.cat][0]:0;a.stickersScroller.scrollTo(t,e?0:200)};if(!e&&a.stickersetPositions.length)return void i();var o=function(e){var o,s,r,l,c,d;for(r=0,c=e.length;r'),o.title&&t.push('',encodeEntities(o.title),""),o.id?n.push(''):n.push(''),l=0,d=o.docIDs.length;l');t.push("")}a.stickersContentEl.html(t.join("")),a.stickersCategoriesEl.html(n.join("")),a.stickersScroller.reinit();var u=[];$(".composer_stickerset_wrap",a.stickersContentEl).each(function(e,t){var n=t.offsetHeight,a=t.offsetTop;u.push([a,n])}),a.stickersetPositions=u,i();var p=[];a.contentEl.find(".composer_sticker_btn").each(function(e,t){e<12?a.replaceStickerImage(t):p.push([t.offsetTop,t])}),a.stickersPreload=p,a.stickersCategoriesEl.find(".composer_sticker_btn").each(function(e,t){a.replaceStickerImage(t)})};this.getStickers(o)},EmojiTooltip.prototype.replaceStickerImage=function(e){e=$(e),this.getStickerImage(e,e.attr("data-sticker"))},EmojiTooltip.prototype.onStickersScroll=function(e,t){var n,a,i=e.clientHeight,o=e.scrollHeight,s=this.stickersetPositions.length,r=!1;if(t<20)r=0;else if(t>o-i-20)r=s-1;else for(a=0;a=n[0]&&t=t&&n[0]<=t+i&&(this.replaceStickerImage(n[1]),this.stickersPreload.splice(a,1),a--,s--);this.cat!==r&&r!==!1&&($(".active",this.categoriesEl).removeClass("active"),this.cat=r,this.activateStickerCategory())},EmojiTooltip.prototype.onStickersChanged=function(){this.tab&&this.updateStickersContents(!0)},EmojiTooltip.prototype.activateStickerCategory=function(){var e=this.categoriesEl[1],t=e.childNodes[this.cat];if(t){$(t).addClass("active");var n=t.offsetLeft,a=t.offsetWidth,i=e.clientWidth;$(e).stop(!0).animate({scrollLeft:n-(i-a)/2},200)}},EmojiTooltip.prototype.updatePosition=function(){var e=this.btnEl.offset();this.tooltipEl.css({top:e.top,left:e.left})},EmojiTooltip.prototype.show=function(){this.updatePosition(),this.tab?this.updateStickersContents(!0):this.updateEmojiContents(),this.tooltipEl.addClass("composer_emoji_tooltip_shown"),this.btnEl.addClass("composer_emoji_insert_btn_on"),delete this.showTimeout,this.shown=!0},EmojiTooltip.prototype.hide=function(){this.tooltipEl&&(this.tooltipEl.removeClass("composer_emoji_tooltip_shown"),this.btnEl.removeClass("composer_emoji_insert_btn_on")),delete this.hideTimeout,delete this.shown},EmojiPanel.prototype.update=function(){var e=[],t=this,n=Config.Mobile?26:20;EmojiHelper.getPopularEmoji(function(a){var i,o,s,r,l,c,d,u,p=a.length;for(c=0;c'));t.containerEl.html(e.join(""))})},MessageComposer.autoCompleteRegEx=/(\s|^)(:|@|\/)([\S]*)$/,MessageComposer.prototype.setUpInput=function(){if(this.inlinePlaceholderWrap=$('
    ').prependTo(this.textareaEl[0].parentNode),this.inlinePlaceholderPrefixEl=$('').appendTo(this.inlinePlaceholderWrap),this.inlinePlaceholderEl=$('').appendTo(this.inlinePlaceholderWrap),"contentEditable"in document.body?this.setUpRich():this.setUpPlaintext(),!Config.Mobile){var e=getScrollWidth();e&&(this.richTextareaEl||this.textareaEl).css({marginRight:-e})}},MessageComposer.prototype.setInlinePlaceholder=function(e,t){this.inlinePlaceholderPrefix=e,this.inlinePlaceholderPrefixEl.html(encodeEntities(e)),this.inlinePlaceholderEl.html(encodeEntities(t)),this.onChange()},MessageComposer.prototype.updateInlinePlaceholder=function(){var e=this.inlinePlaceholderPrefix;if(e){var t=this.textareaEl.val();this.inlinePlaceholderWrap.toggleClass("active",t==e)}},MessageComposer.prototype.setUpAutoComplete=function(){this.scroller=new Scroller(this.autoCompleteEl,{maxHeight:180});var e=this;this.autoCompleteEl.on("mousedown",function(t){t=t.originalEvent||t;for(var n,a,i,o,s=t.target;s&&"A"!=s.tagName;)s=s.parentNode;return s?(s=$(s),(a=s.attr("data-code"))&&(e.onEmojiSelected&&e.onEmojiSelected(a,!0),EmojiHelper.pushPopularEmoji(a)),(n=s.attr("data-mention"))&&e.onMentionSelected(n,s.attr("data-name")),(i=s.attr("data-command"))&&(e.onCommandSelected&&e.onCommandSelected(i),e.hideSuggestions()),(o=s.attr("data-inlineid"))&&(e.onInlineResultSend&&e.onInlineResultSend(o),e.hideSuggestions()),cancelEvent(t)):cancelEvent(t)})},MessageComposer.prototype.setUpRich=function(){this.textareaEl.hide(),this.richTextareaEl=$('
    '),this.textareaEl[0].parentNode.insertBefore(this.richTextareaEl[0],this.textareaEl[0]),this.richTextareaEl.on("keyup keydown",this.onKeyEvent.bind(this)),this.richTextareaEl.on("focus blur",this.onFocusBlur.bind(this)),this.richTextareaEl.on("paste",this.onRichPaste.bind(this)),this.richTextareaEl.on("DOMNodeInserted",this.onRichPasteNode.bind(this)),$(document.body).on("keydown",this.backupSelection.bind(this))},MessageComposer.prototype.setUpPlaintext=function(){this.textareaEl.on("keyup keydown",this.onKeyEvent.bind(this)),this.textareaEl.on("focus blur",this.onFocusBlur.bind(this))},MessageComposer.prototype.onKeyEvent=function(e){var t=this;if("keyup"==e.type){this.checkAutocomplete();var n=!1;if(this.richTextareaEl){clearTimeout(this.updateValueTO);var a=tsNow();void 0===this.keyupStarted&&(this.keyupStarted=a),a-this.keyupStarted>3e3,this.onChange()}if(this.onTyping){var a=tsNow();a-this.lastTyping>5e3&&(n===!1&&(n=(this.richTextareaEl?this.richTextareaEl[0].textContent:this.textareaEl[0].value).length),n!=this.lastLength&&(this.lastTyping=a,this.lastLength=n,this.onTyping()))}}if("keydown"==e.type){var i=!this.autocompleteShown;if(this.autocompleteShown){if(38==e.keyCode||40==e.keyCode){var o,s=40==e.keyCode,r=$(this.autoCompleteEl).find("li.composer_autocomplete_option_active"),l=Array.prototype.slice.call($(this.autoCompleteEl).find("li"));if(r.length){var c=l.indexOf(r[0]),d=c+(s?1:-1);if(o=l[d],r.removeClass("composer_autocomplete_option_active"),o)return $(o).addClass("composer_autocomplete_option_active"),this.scroller.scrollToNode(o),cancelEvent(e)}return o=l[s?0:l.length-1],this.scroller.scrollToNode(o),$(o).addClass("composer_autocomplete_option_active"),cancelEvent(e)}if(13==e.keyCode||9==e.keyCode){var r=$(this.autoCompleteEl).find("li.composer_autocomplete_option_active");r.length||9!=e.keyCode||(r=$(this.autoCompleteEl).find("li:first")),r=r.find("a:first");var u,p,m,g;if(u=r.attr("data-code"))return this.onEmojiSelected(u,!0),EmojiHelper.pushPopularEmoji(u),cancelEvent(e);if(p=r.attr("data-mention"))return this.onMentionSelected(p,r.attr("data-name")),cancelEvent(e);if(m=r.attr("data-command"))return this.onCommandSelected&&this.onCommandSelected(m,9==e.keyCode),cancelEvent(e);if(g=r.attr("data-inlineid"))return t.onInlineResultSend&&t.onInlineResultSend(g),t.hideSuggestions(),cancelEvent(e);i=!0}}if(i&&13==e.keyCode){var h=!1,f=!0;if(this.getSendOnEnter&&!this.getSendOnEnter()&&(f=!1),f&&!e.shiftKey?h=!0:f||!e.ctrlKey&&!e.metaKey||(h=!0),h)return this.onMessageSubmit(e),cancelEvent(e)}if([33,34,35,36,38,39].indexOf(e.keyCode)!=-1&&!e.shiftKey&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&this.richTextareaEl&&!this.richTextareaEl[0].textContent.length)return this.onDirectionKey(e)}},MessageComposer.prototype.backupSelection=function(){ -if(delete this.selection,this.isActive)if(window.getSelection){var e=window.getSelection();e.getRangeAt&&e.rangeCount&&(this.selection=e.getRangeAt(0))}else document.selection&&document.selection.createRange&&(this.selection=document.selection.createRange())},MessageComposer.prototype.restoreSelection=function(){if(!this.selection)return!1;var e=!1;if(window.getSelection){var t=window.getSelection();t.removeAllRanges(),t.addRange(this.selection),e=!0}else document.selection&&this.selection.select&&(this.selection.select(),e=!0);return delete this.selection,e},MessageComposer.prototype.checkAutocomplete=function(e){var t,n;if(this.richTextareaEl){var a=this.richTextareaEl[0],i=getRichValueWithCaret(a),n=i[0],t=i[1]>=0?i[1]:n.length;t||this.cleanRichTextarea(n,!0)}else var a=this.textareaEl[0],t=getFieldSelection(a),n=a.value;if(n&&this.curInlineResults&&this.curInlineResults.text==n)return void this.showInlineSuggestions(this.curInlineResults);e||(n=n.substr(0,t));var o=n.match(MessageComposer.autoCompleteRegEx);if(o){if(this.previousQuery==o[0])return;this.previousQuery=o[0];var s=SearchIndexManager.cleanSearchText(o[3]);if("@"==o[2])if(this.mentions&&this.mentions.index){if(s.length)for(var r,l=SearchIndexManager.search(s,this.mentions.index),c=[],d=0,u=this.mentions.users.length;d=0)||(i.push(n),t.splice(a,1),t.length));o++);this.showEmojiSuggestions(i.concat(t))}else this.hideSuggestions()}else this.showEmojiSuggestions(e)}.bind(this));else if(this.commands&&this.commands.index){if(s.length)for(var p,l=SearchIndexManager.search(s,this.commands.index),m=[],d=0,u=this.commands.list.length;d0&&(this.richTextareaEl.html(""),this.lastLength=0,this.wasEmpty=!0,t))){var n=this;setZeroTimeout(function(){n.focus()})}},MessageComposer.prototype.onRichPasteNode=function(e){var t=(e.originalEvent||e).target,n=(t||{}).src||"",a=!1;if("data:"==n.substr(0,5)){a=!0;var i=dataUrlToBlob(n);this.onFilePaste(i),setZeroTimeout(function(){t.parentNode.replaceChild(document.createTextNode("   "),t)})}else if(n&&!n.match(/img\/blank\.gif/)){var o=document.createTextNode(" "+n+" ");setTimeout(function(){t.parentNode.replaceChild(o,t)},100)}},MessageComposer.prototype.onEmojiSelected=function(e,t){if(this.richTextareaEl){var n=this.richTextareaEl[0];if(this.isActive||this.restoreSelection()||setRichFocus(n),t){var a,i=getRichValueWithCaret(n),o=i[0],s=i[1]>=0?i[1]:o.length,r=o.substr(s),l=o.substr(0,s),c=l.match(/:([\S]*)$/),d=EmojiHelper.emojis[e];a=c&&c[0]?l.substr(0,c.index)+":"+d[1]+":":l+":"+d[1]+":",n.value=f;var u;r.length?(this.selId=(this.selId||0)+1,u=this.getRichHtml(a)+' '+this.getRichHtml(r),this.richTextareaEl.html(u),setRichFocus(n,$("#composer_sel"+this.selId)[0])):(u=this.getRichHtml(a)+" ",this.richTextareaEl.html(u),setRichFocus(n))}else{var u=this.getEmojiHtml(e);if(window.getSelection){var p=window.getSelection();if(p.getRangeAt&&p.rangeCount){var m=document.createElement("div");m.innerHTML=u;var g=m.firstChild,h=p.getRangeAt(0);h.deleteContents(),h.insertNode(document.createTextNode(" ")),h.insertNode(g),h.setStart(g,0),setTimeout(function(){h=document.createRange(),h.setStartAfter(g),h.collapse(!0),p.removeAllRanges(),p.addRange(h)},0)}}else document.selection&&"Control"!=document.selection.type&&document.selection.createRange().pasteHTML(u)}}else{var n=this.textareaEl[0],o=n.value,s=this.isActive?getFieldSelection(n):o.length,r=o.substr(s),l=o.substr(0,s),c=t&&l.match(/:([\S]*)$/),d=EmojiHelper.emojis[e];if(c&&c[0])var f=l.substr(0,c.index)+":"+d[1]+": "+r,_=c.index+d[1].length+3;else var f=l+":"+d[1]+": "+r,_=l.length+d[1].length+3;n.value=f,setFieldSelection(n,_)}this.hideSuggestions(),this.onChange()},MessageComposer.prototype.onMentionsUpdated=function(e){delete this.previousQuery,this.isActive&&this.checkAutocomplete()},MessageComposer.prototype.onMentionSelected=function(e,t){var n=!0;if("#"==e.charAt(0)&&(n=!1,e=e.substr(1),t=t.replace(/\(\)@/,"")),this.richTextareaEl){var a=this.richTextareaEl[0];this.isActive||this.restoreSelection()||setRichFocus(a);var i,o=getRichValueWithCaret(a),s=o[0],r=o[1]>=0?o[1]:s.length,l=s.substr(r),c=s.substr(0,r),d=c.match(/@([\S]*)$/);i=d&&d[0]?c.substr(0,d.index)+"@"+e:c+"@"+e;var u;n?l.length?(this.selId=(this.selId||0)+1,u=this.getRichHtml(i)+' '+this.getRichHtml(l),this.richTextareaEl.html(u),setRichFocus(a,$("#composer_sel"+this.selId)[0])):(u=this.getRichHtml(i)+" ",this.richTextareaEl.html(u),setRichFocus(a)):(this.selId=(this.selId||0)+1,u=this.getRichHtml(i)+' ('+encodeEntities(t)+") "+this.getRichHtml(l),this.richTextareaEl.html(u),setRichFocus(a,$("#composer_sel"+this.selId)[0],!0))}else{var i,p,m,g,a=this.textareaEl[0],s=a.value,r=this.isActive?getFieldSelection(a):s.length,l=s.substr(r),c=s.substr(0,r),d=c.match(/@([\S]*)$/);i=d&&d[0]?c.substr(0,d.index)+"@"+e:c+"@"+e,n?(p=i+"@"+e+" "+l,m=d.index+e.length+2):(p=i+"@"+e+" ("+t+") "+l,m=d.index+e.length+2,g=m+t.length),a.value=p,setFieldSelection(a,m,g)}this.hideSuggestions(),this.onChange()},MessageComposer.prototype.onCommandSelected=function(e,t){if(t)if(this.richTextareaEl)this.richTextareaEl.html(encodeEntities(e)+" "),setRichFocus(this.richTextareaEl[0]);else{var n=this.textareaEl[0];n.value=e+" ",setFieldSelection(n)}else this.onCommandSend(e);this.hideSuggestions(),this.onChange()},MessageComposer.prototype.onChange=function(e){if(this.richTextareaEl){delete this.keyupStarted;var t=getRichValue(this.richTextareaEl[0]);this.textareaEl.val(t).trigger("change")}this.updateInlinePlaceholder()},MessageComposer.prototype.getEmojiHtml=function(e,t){t=t||EmojiHelper.emojis[e];var n=20,a=EmojiHelper.spritesheetPositions[e],i=a[0],o=(a[1],n*a[3]),s=n*a[2];return':'+encodeEntities(t[1])+':'},MessageComposer.prototype.setValue=function(e){this.richTextareaEl?(this.richTextareaEl.html(this.getRichHtml(e)),this.lastLength=e.length,this.wasEmpty=!e.length,this.onKeyEvent({type:"keyup"})):this.textareaEl.val(e)},MessageComposer.prototype.setFocusedValue=function(e){var t=e[0],n=e[1],a=e[2];if(this.richTextareaEl){this.selId=(this.selId||0)+1;var i=this.getRichHtml(t)+''+this.getRichHtml(n)+""+this.getRichHtml(a);this.richTextareaEl.html(i),setRichFocus(this.richTextareaEl[0],$("#composer_sel"+this.selId)[0],!0)}else this.textareaEl.val(t+n+a),setFieldSelection(this.textareaEl[0],t.length,t.length+n.length)},MessageComposer.prototype.getRichHtml=function(e){var t=$("
    ").text(e).html();return t=t.replace(/\n/g,"
    "),t=t.replace(/:([A-Za-z0-9\-\+\*_]+?):/gi,function(e,t){var n=EmojiHelper.shortcuts[t];return void 0!==n?this.getEmojiHtml(n):e}.bind(this)),t=t.replace(/ /g,"  ").replace(/^ | $/g," ")},MessageComposer.prototype.focus=function(){this.richTextareaEl?setZeroTimeout(function(){setRichFocus(this.richTextareaEl[0])}.bind(this)):setFieldSelection(this.textareaEl[0])},MessageComposer.prototype.blur=function(){this.richTextareaEl?this.richTextareaEl[0].blur():this.textareaEl[0].blur()},MessageComposer.prototype.renderSuggestions=function(){this.autoCompleteWrapEl.show(),this.scroller.reinit(),this.updatePosition(),this.autocompleteShown=!0},MessageComposer.prototype.showEmojiSuggestions=function(e){var t=this;setZeroTimeout(function(){t.autoCompleteScope.$apply(function(){t.autoCompleteScope.type="emoji",t.autoCompleteScope.emojiCodes=e}),onContentLoaded(function(){t.renderSuggestions()})})},MessageComposer.prototype.showMentionSuggestions=function(e){var t=this;setZeroTimeout(function(){t.autoCompleteScope.$apply(function(){t.autoCompleteScope.type="mentions",t.autoCompleteScope.mentionUsers=e}),onContentLoaded(function(){t.renderSuggestions()})})},MessageComposer.prototype.showCommandsSuggestions=function(e){var t=this;setZeroTimeout(function(){t.autoCompleteScope.$apply(function(){t.autoCompleteScope.type="commands",t.autoCompleteScope.commands=e}),onContentLoaded(function(){t.renderSuggestions()})})},MessageComposer.prototype.showInlineSuggestions=function(e){if(!e||!e.results.length)return void this.hideSuggestions();var t=this;"inline"==t.autoCompleteScope.type&&t.autoCompleteScope.botResults==e&&t.autocompleteShown||setZeroTimeout(function(){t.autoCompleteScope.$apply(function(){t.autoCompleteScope.type="inline",t.autoCompleteScope.botResults=e}),onContentLoaded(function(){t.renderSuggestions()})})},MessageComposer.prototype.setInlineSuggestions=function(e){this.curInlineResults=e,this.checkAutocomplete()},MessageComposer.prototype.updatePosition=function(){var e=(this.richTextareaEl||this.textareaEl).offset(),t=this.scroller.updateHeight(),n=$((this.richTextareaEl||this.textareaEl)[0].parentNode).outerWidth();this.autoCompleteWrapEl.css({top:e.top-t,left:Config.Mobile?0:e.left,width:Config.Mobile?"100%":n-2}),this.scroller.update()},MessageComposer.prototype.hideSuggestions=function(){this.autoCompleteWrapEl.hide(),delete this.autocompleteShown},MessageComposer.prototype.resetTyping=function(){this.lastTyping=0,this.lastLength=0},MessageComposer.prototype.setPlaceholder=function(e){(this.richTextareaEl||this.textareaEl).attr("placeholder",e)},Scroller.prototype.setUpNano=function(){this.content.wrap('
    '),this.scrollable=$(this.content[0].parentNode),this.scroller=$(this.scrollable[0].parentNode),this.wrap=$(this.scroller[0].parentNode),this.scroller.nanoScroller({preventPageScrolling:!0,tabIndex:-1})},Scroller.prototype.setUpNative=function(){this.content.wrap('
    '),this.scrollable=$(this.content[0].parentNode),this.scrollable.css({overflow:"auto"}),this.maxHeight&&this.scrollable.css({maxHeight:this.maxHeight}),this.minHeight&&this.scrollable.css({minHeight:this.minHeight})},Scroller.prototype.onScroll=function(e){var t=this,n=this.scrollable[0];this.scrollable.on("scroll",function(a){t.isAnimatedScroll||e(n,n.scrollTop)})},Scroller.prototype.update=function(){this.useNano&&$(this.scroller).nanoScroller()},Scroller.prototype.reinit=function(){this.scrollTo(0),this.useNano&&setTimeout(function(){this.updateHeight()}.bind(this),100)},Scroller.prototype.updateHeight=function(){var e;return this.useNano?(this.maxHeight||this.minHeight?(e=this.content[0].offsetHeight,this.maxHeight&&e>this.maxHeight&&(e=this.maxHeight),this.minHeight&&e0){var a=this;this.isAnimatedScroll=!0,this.scrollable.animate({scrollTop:e},t,function(){delete a.isAnimatedScroll,a.useNano&&$(a.scroller).nanoScroller({flash:!0}),a.scrollable.trigger("scroll"),n&&n()})}else this.scrollable[0].scrollTop=e,this.useNano&&$(this.scroller).nanoScroller({flash:!0}),n&&n()},Scroller.prototype.scrollToNode=function(e){e=e[0]||e;var t=e.offsetTop-15,n=e.offsetHeight+30,a=this.scrollable[0].scrollTop,i=this.scrollable[0].clientHeight;a>t?this.scrollTo(t):a

    --- 
     ---
    ',o='
    '+t("unread_messages_split")+"
    ",s="im_message_selected",r="im_message_focus",l="im_message_unread",c="im_message_error",d="im_message_pending";return{templateUrl:templateUrl("message"),link:n}}]).directive("myMessageBody",["$compile","AppPeersManager","AppChatsManager","AppUsersManager","AppMessagesManager","AppInlineBotsManager","RichTextProcessor",function(e,t,n,a,i,o,s){function r(e,t,n){if(n.media&&n.media.handleMessage||"string"!=typeof n.message||!n.message.length)return void $(".im_message_text",t).hide();var a=i.wrapMessageText(n.mid);$(".im_message_text",t).html(a.valueOf())}function l(e,t,n){if(!n.media)return void $(".im_message_media",t).hide();var a=e.$new(!0);a.media=n.media,a.messageId=n.mid,m(a,function(e){$(".im_message_media",t).replaceWith(e)})}function c(e,t,n){if(!n.signID)return void $(".im_message_sign",t).hide();var a=e.$new(!0);a.signID=n.signID,h(a,function(e){$(".im_message_sign",t).replaceWith(e)})}function d(e,t,n){if(!n.reply_markup||"replyInlineMarkup"!=n.reply_markup._)return void $(".im_message_keyboard",t).hide();var a=e.$new(!0);a.markup=i.wrapReplyMarkup(n.reply_markup),a.messageId=n.mid,g(a,function(e){$(".im_message_keyboard",t).replaceWith(e)}),a.$on("reply_inline_button_press",function(e,t){switch(t._){case"keyboardButtonSwitchInline":o.switchInlineButtonClick(n.mid,t);break;case"keyboardButtonCallback":o.callbackButtonClick(n.mid,t);break;case"keyboardButtonGame":o.gameButtonClick(n.mid)}})}function u(e,t,n){r(e,t,n),l(e,t,n),c(e,t,n),d(e,t,n)}function p(e,t,n){var a=e.message;a.dir=!0;var i=a.mid;if(u(e,t,a),a.pending)var o=e.$on("messages_pending",function(){a.mid!=i&&(u(e,t,a),o())});e.$on("message_edit",function(n,i){i.mid==a.mid&&(i.justMedia?l(e,t,a):u(e,t,a))})}var m=e('
    '),g=e('
    '),h=e('
    ');return{link:p,scope:{message:"=myMessageBody"}}}]).directive("myMessageViews",["$filter","AppMessagesManager",function(e,t){function n(e,t){t.html(i(e))}function a(e,a,i){var o=e.$eval(i.myMessageViews),s=t.getMessage(o).views||0;n(s,a),e.$on("message_views",function(e,t){t.mid==o&&n(t.views,a)})}var i=e("formatShortNumber");return{link:a}}]).directive("myReplyMarkup",function(){function e(e,t,n){var a=$(".reply_markup",t),i=new Scroller(a,{classPrefix:"reply_markup",maxHeight:170});e.buttonClick=function(t){e.$emit("reply_button_press",t)},e.$on("ui_keyboard_update",function(t,n){onContentLoaded(function(){i.updateHeight(),i.scrollTo(0),e.$emit("ui_panel_update",{blur:n&&n.enabled})})}),onContentLoaded(function(){i.updateHeight(),e.$emit("ui_panel_update")})}return{templateUrl:templateUrl("reply_markup"),scope:{replyMarkup:"=myReplyMarkup"},link:e}}).directive("myMessageMedia",function(){return{scope:{media:"=myMessageMedia",messageId:"=messageId"},templateUrl:templateUrl("message_media")}}).directive("myMessagePhoto",["AppPhotosManager",function(e){return{scope:{media:"=myMessagePhoto",messageId:"=messageId"},templateUrl:templateUrl("message_attach_photo"),link:function(t,n,a){t.openPhoto=e.openPhoto,t.preloadPhoto=e.preloadPhoto}}}]).directive("myMessageDocument",["AppDocsManager",function(e){return{scope:{media:"=myMessageDocument",messageId:"=messageId"},templateUrl:templateUrl("message_attach_document"),link:function(t,n,a){e.updateDocDownloaded(t.media.document.id),t.docSave=function(){e.saveDocFile(t.media.document.id)},t.docOpen=function(){return t.media.document.withPreview?void e.openDoc(t.media.document.id,t.messageId):t.docSave()},t.videoOpen=function(){e.openVideo(t.media.document.id,t.messageId)}}}}]).directive("myMessageGeo",function(){return{scope:{media:"=myMessageGeo"},templateUrl:templateUrl("message_attach_geo")}}).directive("myMessageVenue",function(){return{scope:{media:"=myMessageVenue"},templateUrl:templateUrl("message_attach_venue")}}).directive("myMessageContact",function(){return{scope:{media:"=myMessageContact"},templateUrl:templateUrl("message_attach_contact")}}).directive("myMessageWebpage",["AppWebPagesManager","AppPhotosManager",function(e,t){return{scope:{media:"=myMessageWebpage",messageId:"=messageId"},templateUrl:templateUrl("message_attach_webpage"),link:function(n){n.openPhoto=t.openPhoto,n.openEmbed=function(t){if(n.media.webpage&&n.media.webpage.embed_url)return e.openEmbed(n.media.webpage.id,n.messageId),cancelEvent(t)},n.$on("webpage_updated",function(e,t){n.media.webpage&&n.media.webpage.id==t.id&&n.$emit("ui_height")})}}}]).directive("myMessageGame",["AppInlineBotsManager","AppMessagesManager",function(e,t){return{scope:{media:"=myMessageGame",messageId:"=messageId"},templateUrl:templateUrl("message_attach_game"),link:function(n,a){function i(e){var i=t.getMessage(n.messageId);if(i.message){var o=t.wrapMessageText(n.messageId);$(".im_message_game_message",a).html(o.valueOf()).show(),$(".im_message_game_description",a).hide()}else $(".im_message_game_message",a).html("").hide(),$(".im_message_game_description",a).show()}n.openGame=function(){e.gameButtonClick(n.messageId)},n.$on("message_edit",function(e,t){t.mid==n.messageId&&i()}),i()}}}]).directive("myMessagePending",function(){return{scope:{media:"=myMessagePending"},templateUrl:templateUrl("message_attach_pending")}}).directive("myInlineReplyMarkup",function(){function e(e,t,n){e.buttonClick=function(t){e.$emit("reply_inline_button_press",t)}}return{templateUrl:templateUrl("reply_markup"),scope:{replyMarkup:"=myInlineReplyMarkup"},link:e}}).directive("myServiceMessage",function(){return{templateUrl:templateUrl("message_service")}}).directive("myShortMessage",function(){return{scope:{message:"=myShortMessage"},templateUrl:templateUrl("short_message")}}).directive("myReplyMessage",["AppMessagesManager","AppPeersManager","$rootScope",function(e,t,n){function a(e,t,n){if(n.watch)e.$parent.$watch(n.myReplyMessage,function(a){var o=e.$parent.$eval(n.edit);i(e,t,a,o)});else{var a=e.$parent.$eval(n.myReplyMessage),o=e.$parent.$eval(n.edit);i(e,t,a,o)}}function i(t,n,a,i){var s=t.replyMessage=e.wrapSingleMessage(a);if(t.isEdit=i||!1,s.loading)var r=t.$on("messages_downloaded",function(i,s){s.indexOf(a)!=-1&&(t.replyMessage=e.wrapForDialog(a),o(t,n),r())});else o(t,n)}function o(a,i){var o=a.replyMessage;return o&&!o.deleted&&o.to_id?(a.thumb=e.getMessageThumb(o,42,42),"A"==i[0].tagName&&i.on("click",function(){var a=e.getMessagePeer(o),i=t.getPeerString(a);n.$broadcast("history_focus",{peerString:i,messageID:o.mid})}),void onContentLoaded(function(){a.$emit("ui_height")})):void $(i).remove()}return{templateUrl:templateUrl("reply_message"),scope:{},link:a}}]).directive("myPinnedMessage",["AppMessagesManager","AppPeersManager","$rootScope",function(e,t,n){function a(t,n,a){var o=t.$parent.$eval(a.myPinnedMessage),s=t.pinnedMessage=e.wrapSingleMessage(o);if(s.loading)var r=t.$on("messages_downloaded",function(a,s){s.indexOf(o)!=-1&&(t.pinnedMessage=e.wrapForDialog(o),i(t,n),r())});else i(t,n)}function i(a,i){var o=a.pinnedMessage;return o&&!o.deleted&&o.to_id?("A"==i[0].tagName&&i.on("click",function(){var a=e.getMessagePeer(o),i=t.getPeerString(a);n.$broadcast("history_focus",{peerString:i,messageID:o.mid})}),void onContentLoaded(function(){a.$emit("ui_height")})):void $(i).remove()}return{templateUrl:templateUrl("pinned_message"),scope:{},link:a}}]).directive("myForwardedMessages",["AppPhotosManager","AppMessagesManager","AppPeersManager","$rootScope",function(e,t,n,a){function i(e,t,n){n.watch?e.$watch("forwardMessages",function(){o(e,t)}):o(e,t)}function o(e,n){var a=e.forwardMessages,i=a.length,o=!1,s=1==i;e.thumb=!1,e.singleMessage=!1,angular.forEach(a,function(n){var a=t.getMessage(n);o===!1?o=a.fromID:o!==a.fromID&&(o=t.getMessagePeer(a)),s&&(e.thumb=t.getMessageThumb(a,42,42),e.singleMessage=t.wrapForDialog(n))}),e.fromID=o,e.count=i,onContentLoaded(function(){e.$emit("ui_height")})}return{templateUrl:templateUrl("forwarded_messages"),scope:{forwardMessages:"=myForwardedMessages"},link:i}}]).directive("myMessageEdited",["_","$timeout","AppMessagesManager",function(e,t,n){function a(e,t,n){var a=e.$parent.$eval(n.myMessageEdited);i(e,t,a)&&e.$on("message_edit",function(a,o){var s=e.$parent.$eval(n.myMessageEdited);o.mid==s&&i(e,t,s)})}function i(e,a,i){var s=n.getMessage(i);return s.canBeEdited?!s.edit_date||(a.html(o).show(),t(function(){e.$destroy()}),!1):(t(function(){e.$destroy(),a.remove()}),!1)}var o=e("message_edited");return{scope:{},link:a}}]).directive("myDialogs",["$modalStack","$transition","$window","$timeout",function(e,t,n,a){function i(t,i,o){function s(n){if(!p&&e.getTop())return!0;if(36==n.keyCode&&!n.shiftKey&&!n.ctrlKey&&n.altKey){var a=$(l).find(".im_dialog_wrap a");return a.length&&($(a[0]).trigger("mousedown"),l.scrollTop=0,$(r).nanoScroller({flash:!0})),cancelEvent(n)}if(27==n.keyCode||9==n.keyCode&&n.shiftKey&&!n.ctrlKey&&!n.metaKey)return p?c.value?$(u).trigger("click"):(t.$emit("esc_no_more"),setTimeout(function(){c.blur(),setTimeout(function(){c.focus()},0)},100)):(setFieldSelection(c),c.value&&c.select()),cancelEvent(n);if(p&&13==n.keyCode&&!Config.Navigator.mobile){var a=$(l).find(".im_dialog_selected")[0]||$(l).find(".im_dialog_wrap a")[0];return a&&!$(a).hasClass("disabled")&&$(a).trigger("mousedown"),cancelEvent(n)}if(!Config.Navigator.osX&&n.altKey&&n.shiftKey&&!n.ctrlKey&&!n.metaKey&&n.keyCode>=49&&n.keyCode<=57||Config.Navigator.osX&&n.ctrlKey&&n.shiftKey&&!n.metaKey&&!n.altKey&&n.keyCode>=49&&n.keyCode<=57){var i=n.keyCode-49,o=$(l).find(".im_dialog_wrap"),s=o[i];return s&&($(s).find("a").trigger("mousedown"),scrollToNode(l,s,r)),cancelEvent(n)}var d,m,g,h=Config.Modes.packed;if(40==n.keyCode||38==n.keyCode?(d=40==n.keyCode,m=!d,g=!n.shiftKey&&n.altKey):h&&9==n.keyCode&&n.ctrlKey&&!n.metaKey&&(d=!n.shiftKey,m=!d,g=!0),d||m){if(!g&&(!p||n.metaKey))return!0;var s,a=!g&&$(l).find(".im_dialog_selected")[0]||$(l).find(".active a.im_dialog")[0],f=a&&a.parentNode;if(f){var s=a[d?"nextSibling":"previousSibling"];if(!s||!s.className||s.className.indexOf("im_dialog_wrap")==-1){var o=$(l).find(".im_dialog_wrap"),_=o.index(a.parentNode),v=_+(d?1:-1);s=o[v]}}else{var o=$(l).find(".im_dialog_wrap");s=d?o[0]:o[o.length-1]}return g?s&&$(s).find("a").trigger("mousedown"):(f&&s&&$(f).find("a").removeClass("im_dialog_selected"),s&&$(s).find("a").addClass("im_dialog_selected")),s&&scrollToNode(l,s,r),cancelEvent(n)}}var r=$(".im_dialogs_wrap",i)[0],l=$(".im_dialogs_scrollable_wrap",i)[0],c=$(".im_dialogs_search_field",i)[0],d=$(".im_dialogs_panel",i)[0],u=$(".im_dialogs_search_clear",i)[0],p=!1;$(c).on("focus blur",function(e){p="focus"==e.type,p||($(l).find(".im_dialog_selected").removeClass("im_dialog_selected"),c.value||t.$emit("ui_dialogs_search_clear"))}),t.$on("dialogs_search_toggle",function(){$(d).addClass("im_dialogs_panel_search"),t.$broadcast("ui_dialogs_search"),$(n).scrollTop(0),a(function(){setFieldSelection(c)})}),t.$on("search_clear",function(){$(d).removeClass("im_dialogs_panel_search"),t.$broadcast("ui_dialogs_search")}),$(document).on("keydown",s),t.$on("$destroy",function(){$(document).off("keydown",s)}),t.$on("ui_dialogs_change",function(){onContentLoaded(function(){var e=$(l).find(".active a.im_dialog")[0];e&&scrollToNode(l,e.parentNode,r)})})}return{link:i}}]).directive("myDialogsList",["$window","$timeout",function(e,t){function n(n,a,i){function o(){if(u&&u.offsetHeight||(u=$(d)[0]),i.modal){var t=$(e).height()-(u?u.offsetHeight:49)-(Config.Mobile?46:100);return t=Math.min(Config.Mobile?350:450,t),$(a).css({height:t}),void g()}c&&c.offsetHeight||(c=$(".tg_page_head")[0]),p&&p.offsetHeight||(p=$(".footer_wrap")[0]),r&&r.offsetHeight||(r=$(".im_dialogs_col_wrap")[0]);var n=p?p.offsetHeight:0;n&&n++,$(a).css({height:$(e).height()-n-(c?c.offsetHeight:48)-(u?u.offsetHeight:58)-parseInt($(r).css("paddingBottom")||0)}),g()}var s=$(".im_dialogs_wrap",a)[0],r=$(".im_dialogs_col_wrap")[0],l=$(".im_dialogs_scrollable_wrap",a)[0],c=$(".tg_page_head")[0],d=Config.Mobile&&i.modal?".mobile_modal_body .im_dialogs_panel":".im_dialogs_panel",u=$(d)[0],p=$(".footer_wrap")[0],m=!1;onContentLoaded(function(){$(s).nanoScroller({preventPageScrolling:!0,tabIndex:-1,iOSNativeScrolling:!0})});var g=function(){onContentLoaded(function(){$(s).nanoScroller()})};n.$on("ui_dialogs_prepend",g),n.$on("ui_dialogs_search",o),n.$on("ui_dialogs_update",o),n.$on("ui_dialogs_append",function(){onContentLoaded(function(){g(),m=!1,t(function(){$(l).trigger("scroll")})})}),n.$on("ui_dialogs_change",function(){onContentLoaded(function(){g(),m=!1,t(function(){$(l).trigger("scroll")})})}),$(l).on("scroll",function(e){a.is(":visible")&&!m&&l.scrollTop>=l.scrollHeight-l.clientHeight-300&&(n.$emit("dialogs_need_more"),m=!0)}),$(e).on("resize",o),o(),setTimeout(o,1e3)}return{link:n}}]).directive("myContactsList",["$window","$timeout",function(e,t){function n(t,n,a){function i(){$(n).css({height:$(e).height()-(s&&s.offsetHeight||0)-(o&&o.offsetHeight||0)-(Config.Mobile?64:200)}),$(r).nanoScroller()}var o=$(".contacts_modal_search")[0],s=$(".contacts_modal_panel")[0],r=$(".contacts_wrap",n)[0];onContentLoaded(function(){$(r).nanoScroller({preventPageScrolling:!0,tabIndex:-1,iOSNativeScrolling:!0}),i()}),$(e).on("resize",i),t.$on("contacts_change",function(){onContentLoaded(i)})}return{link:n}}]).directive("myCountriesList",["$window","$timeout",function(e,t){function n(t,n,a){function i(){$(n).css({height:$(e).height()-(s&&s.offsetHeight||0)-(o&&o.offsetHeight||0)-(Config.Mobile?64:200)}),$(r).nanoScroller()}var o=$(".countries_modal_search")[0],s=$(".countries_modal_panel")[0],r=$(".countries_wrap",n)[0];onContentLoaded(function(){$(r).nanoScroller({preventPageScrolling:!0,tabIndex:-1,iOSNativeScrolling:!0}),i()}),$(e).on("resize",i),t.$on("contacts_change",function(){onContentLoaded(i)})}return{link:n}}]).directive("mySessionsList",["$window","$timeout",function(e,t){function n(t,n,a){function i(){$(n).css({height:Math.min(760,$(e).height()-(Config.Mobile?64:200))}),$(o).nanoScroller()}var o=$(".sessions_wrap",n)[0];onContentLoaded(function(){$(o).nanoScroller({preventPageScrolling:!0,tabIndex:-1,iOSNativeScrolling:!0}),i()}),$(e).on("resize",i)}return{link:n}}]).directive("myStickersList",["$window","$timeout",function(e,t){function n(t,n,a){function i(){$(n).css({height:Math.min(600,$(e).height()-(Config.Mobile?64:200))}),$(o).nanoScroller()}var o=$(".stickerset_wrap",n)[0];onContentLoaded(function(){$(o).nanoScroller({preventPageScrolling:!0,tabIndex:-1,iOSNativeScrolling:!0}),i()}),$(e).on("resize",i)}return{link:n}}]).directive("myHistory",["$window","$timeout","$rootScope","$transition",function(e,t,n,a){function i(i,o,s){function r(e,n){var a,i,o,s=!1;if(!e&&(i=$(".im_message_focus:visible",p)[0])){var r=p.clientHeight,l=p.scrollTop,c=i.offsetTop,d=i.clientHeight;(!l||l+rc+d||n)&&(s=Math.max(0,c-Math.floor(r/2)+26)),A=!1,o=function(){var e=$(i).data("unfocus_promise");e&&(t.cancel(e),$(i).removeClass("im_message_focus_active")),t(function(){$(i).addClass("im_message_focus_active"),e=t(function(){$(i).removeClass("im_message_focus_active"),$(i).data("unfocus_promise",!1)},2800),$(i).data("unfocus_promise",e)})}}else(a=$(".im_message_unread_split:visible",p)[0])?(s=Math.max(0,a.offsetTop-52),A=!1):(s=p.scrollHeight,A=!0);if(s!==!1){var u=function(){S(),t(function(){$(p).trigger("scroll"),E=p.scrollTop}),o&&o()};n?$(p).animate({scrollTop:s},200,u):(p.scrollTop=s,u())}}function l(t){if(o.is(":visible")||$(o[0].parentNode.parentNode).is(":visible")){$(f).is(":visible")&&$(f).css({height:$(y).height()}),_&&_.offsetHeight||(_=$(".tg_page_head")[0]),v&&v.offsetHeight||(v=$(".footer_wrap")[0]);var n=v?v.offsetHeight:0;n&&n++;var a=$(e).height()-h.offsetHeight-(_?_.offsetHeight:48)-n;$(d).css({height:a}),c(),t!==!0&&(A&&onContentLoaded(function(){p.scrollTop=p.scrollHeight,S()}),S(100))}}function c(){$(u).css({marginTop:0});var e=p.offsetHeight-u.offsetHeight-g.offsetHeight-(Config.Mobile?0:39);u.offsetHeight>0&&e>0&&$(u).css({marginTop:e}),$(d).nanoScroller()}var d=$(".im_history_wrap",o)[0],u=$(".im_history_messages",o)[0],p=($(".im_history",o)[0],$(".im_history_scrollable_wrap",o)[0]),m=$(".im_history_scrollable",o)[0],g=$(".im_history_empty_wrap",o)[0],h=$(".im_bottom_panel_wrap",o)[0],f=$(".im_send_form_wrap",o)[0],_=$(".tg_page_head")[0],v=$(".footer_wrap")[0],y=$(".im_send_form",o)[0],b=!1,w=!1;onContentLoaded(function(){p.scrollTop=p.scrollHeight}),$(d).nanoScroller({preventPageScrolling:!0,tabIndex:-1,iOSNativeScrolling:!0});var k,S=function(e){t(function(){$(p).hasClass("im_history_to_bottom")||$(d).nanoScroller()},e||0)},C=!1,M=["transform","webkitTransform","MozTransform","msTransform","OTransform"];for(k=0;k0;if(o)i=p.scrollHeight;else{var s=parseInt($(p).css("paddingRight"));$(m).css({bottom:0,paddingRight:s}),$(p).addClass("im_history_to_bottom")}onContentLoaded(function(){if(o){I=!0,$(u).removeClass("im_history_appending"),p.scrollTop=p.scrollHeight,$(u).css(C,"translate(0px, "+(p.scrollHeight-i)+"px)"),$(d).nanoScroller();var e={};e[C]="translate(0px, 0px)",$(u).addClass("im_history_appending"),a($(u),e).then(function(){I=!1,$(u).removeClass("im_history_appending"),c()})}else $(p).removeClass("im_history_to_bottom"),$(m).css({bottom:"",paddingRight:0}),p.scrollTop=p.scrollHeight,c()})}),i.$on("history_direction_key",function(e,t){var n=!1;switch(console.warn("scroll top",t.keyCode),t.keyCode){case 33:n=p.scrollTop-p.clientHeight;break;case 34:n=p.scrollTop+p.clientHeight;break;case 36:n=0;break;case 35:n=p.scrollHeight}n!==!1&&$(p).stop().animate({scrollTop:n},200)}),i.$on("ui_history_change",function(){var e=parseInt($(p).css("paddingRight"));$(p).addClass("im_history_to_bottom"),p.scrollHeight,$(m).css({bottom:0,paddingRight:e}),onContentLoaded(function(){$(p).removeClass("im_history_to_bottom"),$(m).css({bottom:"",paddingRight:""}),l(!0),b=!1,w=!1,r()})}),i.$on("ui_history_change_scroll",function(e,t){onContentLoaded(function(){r(!1,t)})}),i.$on("ui_history_focus",function(){A||(p.scrollTop=p.scrollHeight,S(),A=!0)}),i.$on("ui_history_prepend",function(){var e=p.scrollHeight,n=p.scrollTop,a=parseInt($(p).css("paddingRight")),o=p.clientHeight;$(p).addClass("im_history_to_bottom"),p.scrollHeight,$(m).css({bottom:-(e-n-o),paddingRight:a});var s=function(){$(p).removeClass("im_history_to_bottom"),$(m).css({bottom:"",paddingRight:""}),E>=0?r():p.scrollTop=n+p.scrollHeight-e,c(),b=!1,t(function(){p.scrollHeight!=e&&$(p).trigger("scroll")}),clearTimeout(l),d()},l=setTimeout(s,0),d=i.$on("$viewContentLoaded",s)}),i.$on("ui_history_append",function(){var e=p.scrollHeight;onContentLoaded(function(){A=!1,c(),w=!1,E>=0&&r(),t(function(){p.scrollHeight!=e&&$(p).trigger("scroll")})})}),i.$on("ui_panel_update",function(e,n){l(),onContentLoaded(function(){l(),n&&n.blur?i.$broadcast("ui_message_blur"):getSelectedText()||i.$broadcast("ui_message_send"),t(function(){$(p).trigger("scroll")})})}),i.$on("ui_selection_clear",function(){window.getSelection?window.getSelection().empty?window.getSelection().empty():window.getSelection().removeAllRanges&&window.getSelection().removeAllRanges():document.selection&&document.selection.empty()}),i.$on("ui_editor_resize",l),i.$on("ui_height",function(){onContentLoaded(l)});var A=!0,E=-1;$(p).on("scroll",function(e){if(o.is(":visible")&&!$(p).hasClass("im_history_to_bottom")&&!I){var t=p.scrollTop;A=t>=p.scrollHeight-p.clientHeight,E>=0&&E!=t&&(E=-1),!b&&t<=300?(b=!0,i.$emit("history_need_more")):!w&&t>=p.scrollHeight-p.clientHeight-300&&(w=!0,i.$emit("history_need_less"))}}),$(e).on("resize",l),l(),onContentLoaded(l)}return{link:i}}]).directive("mySendForm",["_","$q","$timeout","$compile","$modalStack","$http","$interpolate","Storage","AppStickersManager","AppDocsManager","ErrorService","AppInlineBotsManager","FileManager","shouldFocusOnInteraction",function(e,t,n,a,i,o,s,r,l,c,d,u,p,m){function g(o,s,g){function h(){r.get("send_ctrlenter").then(function(e){H=!e})}function f(e){return n(function(){y(),o.draftMessage.send(),L.resetTyping(),B&&B.update(),L.hideSuggestions()},m?0:100),cancelEvent(e)}function _(e){o.$apply(function(){o.draftMessage.inlineResultID=e})}function v(e){return 38==e.keyCode?(o.$emit("last_message_edit"),cancelEvent(e)):(o.$emit("history_direction_key",e),!0)}function y(){j&&(L.onChange(),b())}function b(){var e=j.offsetHeight;q!=e&&(q=e,o.$emit("ui_editor_resize"))}function w(e){if(!(9!=e.keyCode||e.shiftKey||e.ctrlKey||e.metaKey||i.getTop()))return L.focus(),cancelEvent(e)}function k(){onContentLoaded(function(){L.focus()})}function S(e){var n=e.type||"",a=t.when(!1);["image/jpeg","image/gif","image/png","image/bmp"].indexOf(n)>=0&&(a=p.getFileCorrectUrl(e,n)),a.then(function(t){t=t||!1,d.confirm({type:"FILE_CLIPBOARD_PASTE",fileUrl:t}).then(function(){o.draftMessage.files=[e],o.draftMessage.isMedia=!0})})}function C(e){var t,n,a=(e.originalEvent||e).clipboardData,i=a&&a.items||[],s=[];for(n=0;n0){if(1==s.length)return S(s[0]);d.confirm({type:"FILES_CLIPBOARD_PASTE",files:s}).then(function(){o.draftMessage.files=s,o.draftMessage.isMedia=!0})}}function M(e){var t=!1;return x&&1!=x||(x=checkDragEvent(e)?2:1,t=!0),2==x&&(I&&setTimeout(function(){clearTimeout(I),I=!1},0),"dragenter"==e.type||"dragover"==e.type?t&&(Config.Mobile||$(E).hide(),$(P).css({height:F.offsetHeight+2,width:F.offsetWidth}).show()):("drop"==e.type&&o.$apply(function(){o.draftMessage.files=Array.prototype.slice.call(e.originalEvent.dataTransfer.files),o.draftMessage.isMedia=!0}),I=setTimeout(function(){$(P).hide(),Config.Mobile||$(E).show(),x=!1,I=!1},300))),cancelEvent(e)}var x,I,A=$("textarea",s)[0],E=$(".composer_emoji_insert_btn",s)[0],T=$(".composer_emoji_panel",s)[0],D=$("input",s),P=$(".im_send_dropbox_wrap",s)[0],F=$(".im_send_field_wrap",s)[0],N=$(".im_submit",s)[0],R=a(''),O={},U=new EmojiTooltip(E,{getStickers:function(e){l.getStickers().then(e)},getStickerImage:function(e,t){var n=e.attr("data-category"),a=O[t];if(a&&!isInDOM(a[0]))return a.attr("data-category",n),void e.replaceWith(a);var i=o.$new(!0);i.document=c.getDoc(t),R(i,function(a){O[t]=a,a.attr("data-category",n),e.replaceWith(a)})},onStickersetSelected:function(e){l.openStickersetLink(e)},onEmojiSelected:function(e){o.$apply(function(){L.onEmojiSelected(e)})},onStickerSelected:function(e){o.$apply(function(){o.draftMessage.sticker=e})},langpack:{im_emoji_tab:e("im_emoji_tab"),im_stickers_tab:e("im_stickers_tab")}});o.$on("stickers_changed",function(){U.onStickersChanged()});var B;T&&(B=new EmojiPanel(T,{onEmojiSelected:function(e){L.onEmojiSelected(e)}}));var L=new MessageComposer(A,{onTyping:function(){o.$emit("ui_typing")},getSendOnEnter:function(){return H},dropdownDirective:function(e,t){var n=o.$new(!0);a("
    ")(n,function(n,a){e.replaceWith(n),t(a,n)})},mentions:o.mentions,commands:o.commands,onMessageSubmit:f,onDirectionKey:v,onInlineResultSend:_,onFilePaste:S,onCommandSend:function(e){o.$apply(function(){o.draftMessage.command=e})}}),j=L.richTextareaEl&&L.richTextareaEl[0];j&&$(j).on("keydown keyup",b),o.$on("inline_results",function(e,t){var n=Config.Mobile?$(window).width():(F.offsetWidth||382)-2,a=80;t&&u.regroupWrappedResults(t.results,n,a),setZeroTimeout(function(){L.setInlineSuggestions(t)})}),o.$on("inline_placeholder",function(e,t){L.setInlinePlaceholder(t.prefix,t.placeholder)}),D.on("change",function(){var e=this;o.$apply(function(){o.draftMessage.files=Array.prototype.slice.call(e.files),o.draftMessage.isMedia=$(e).hasClass("im_media_attach_input")||Config.Mobile,setTimeout(function(){try{e.value=""}catch(t){}},1e3)})});var H=!0;o.$on("settings_changed",h),h(),$(N).on("mousedown touchstart",f);var q=j&&j.offsetHeight;$(document).on("keydown",w),$("body").on("dragenter dragleave dragover drop",M),$(document).on("paste",C),m&&(o.$on("ui_peer_change",k),o.$on("ui_history_focus",k),o.$on("ui_history_change",k)),o.$on("ui_peer_change",L.resetTyping.bind(L)),o.$on("ui_peer_draft",function(t,n){n=n||{};var a=o.draftMessage.isBroadcast;L.setPlaceholder(e(a?"im_broadcast_field_placeholder_raw":"im_message_field_placeholder_raw")),n.customSelection?(L.setFocusedValue(n.customSelection),b()):(j&&(L.setValue(o.draftMessage.text||""),b()),(m||n&&n.focus)&&L.focus()),onContentLoaded(function(){L.checkAutocomplete(!0)}),U&&Config.Mobile&&U.hide()}),o.$on("ui_peer_reply",function(){onContentLoaded(function(){o.$emit("ui_editor_resize"),m&&L.focus()})}),o.$on("mentions_update",function(){L.onMentionsUpdated()}),o.$on("ui_message_before_send",function(){y()}),o.$on("ui_message_send",function(){m&&k()}),o.$on("ui_message_blur",function(){L.blur()}),o.$on("$destroy",function(){$(document).off("paste",C),$(document).off("keydown",w),$("body").off("dragenter dragleave dragover drop",M),$(N).off("mousedown touchstart"),D.off("change")}),m&&k()}return{link:g,scope:{draftMessage:"=",mentions:"=",commands:"="}}}]).directive("myLoadThumb",["MtpApiFileManager","FileManager",function(e,t){function n(n,a,i){var o=0,s=e.getCachedFile(n.thumb&&n.thumb.location&&!n.thumb.location.empty&&n.thumb.location);s&&a.attr("src",t.getUrl(s,"image/jpeg")),n.thumb&&n.thumb.width&&n.thumb.height&&(a.attr("width",n.thumb.width),a.attr("height",n.thumb.height));var r=n.$watchCollection("thumb.location",function(i){n.thumb&&n.thumb.width&&n.thumb.height&&(a.attr("width",n.thumb.width),a.attr("height",n.thumb.height),n.$emit("ui_height"));var s=++o;if(!i||i.empty)return a.attr("src",n.thumb&&n.thumb.placeholder||"img/blank.gif"),void l();var r=e.getCachedFile(i);return r?(a.attr("src",t.getUrl(r,"image/jpeg")),void l()):(a.attr("src")||a.attr("src",n.thumb.placeholder||"img/blank.gif"),void e.downloadSmallFile(n.thumb.location).then(function(e){s==o&&(a.attr("src",t.getUrl(e,"image/jpeg")),l())},function(e){console.log("Download image failed",e,n.thumb.location,a[0]),s==o&&(a.attr("src",n.thumb.placeholder||"img/blank.gif"),l())}))}),l=i.watch?angular.noop:function(){setTimeout(function(){n.$destroy(),r()},0)}}return{link:n,scope:{thumb:"="}}}]).directive("myLoadFullPhoto",["MtpApiFileManager","FileManager","_",function(e,t,n){function a(a,i,o){var s=$("img",i)[0],r=$(".img_fullsize_with_progress_wrap",i).add(".img_fullsize_progress_wrap",i).add($(s)),l=function(){r.css({width:a.fullPhoto.width,height:a.fullPhoto.height}),a.$emit("ui_height",!0)},c=0;a.$watchCollection("fullPhoto.location",function(){var i=e.getCachedFile(a.thumbLocation),o=++c;if(i?(s.src=t.getUrl(i,"image/jpeg"),l()):s.src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",a.fullPhoto.location){var r;if(a.fullPhoto.size){var d={_:"inputFileLocation",volume_id:a.fullPhoto.location.volume_id,local_id:a.fullPhoto.location.local_id,secret:a.fullPhoto.location.secret};r=e.downloadFile(a.fullPhoto.location.dc_id,d,a.fullPhoto.size)}else r=e.downloadSmallFile(a.fullPhoto.location);a.progress={enabled:!0,percent:0},r.then(function(e){o==c&&(a.progress.enabled=!1,s.src=t.getUrl(e,"image/jpeg"),l())},function(e){console.log("Download image failed",e,a.fullPhoto.location),a.progress.enabled=!1,e&&"FS_BROWSER_UNSUPPORTED"==e.type?a.error={html:n("error_browser_no_local_file_system_image_md",{"moz-link":'{1}',"chrome-link":'{1}',"telegram-link":'{1}'})}:a.error={text:n("error_image_download_failed"),error:e}},function(e){a.progress.percent=Math.max(1,Math.floor(100*e.done/e.total))})}}),l()}return{link:a,transclude:!0,templateUrl:templateUrl("full_photo"),scope:{fullPhoto:"=",thumbLocation:"="}}}]).directive("myLoadVideo",["$sce","AppDocsManager","ErrorService","_",function(e,t,n,a){function i(e,i,o){var s=t.downloadDoc(e.video.id);s.then(function(){e.$emit("ui_height"),onContentLoaded(function(){var e=$("video",i)[0];if(e){var t=!1,a=function(e){t||e.target&&e.target.error&&e.target.error.code!=e.target.error.MEDIA_ERR_DECODE&&e.target.error.code!=e.target.error.MEDIA_ERR_SRC_NOT_SUPPORTED||(t=!0,n.show({error:{type:"MEDIA_TYPE_NOT_SUPPORTED",originalError:e.target&&e.target.error}}))};e.addEventListener("error",a,!0),$(e).on("$destroy",function(){t=!0,e.removeEventListener("error",a)})}})},function(t){console.log("Download video failed",t,e.video),t&&"FS_BROWSER_UNSUPPORTED"==t.type?e.error={html:a("error_browser_no_local_file_system_video_md",{"moz-link":'{1}',"chrome-link":'{1}',"telegram-link":'{1}'})}:e.error={text:a("error_video_download_failed"),error:t}}),e.$emit("ui_height"),e.$on("$destroy",function(){s.cancel()})}return{link:i,transclude:!0,templateUrl:templateUrl("full_video"),scope:{video:"="}}}]).directive("myLoadGif",["AppDocsManager","$timeout",function(e,t){function n(n,a,i){var o=$(".img_gif_image_wrap",a);o.css({width:n.document.thumb.width,height:n.document.thumb.height});var s=!1;n.isActive=!1,n.toggle=function(i){return i&&checkClick(i,!0)?(e.saveDocFile(n.document.id),!1):n.document.url?void onContentLoaded(function(){n.isActive=!n.isActive,n.$emit("ui_height");var e=$("video",a)[0];e&&(n.isActive?e.play():(e.pause(),e.currentTime=0))}):s?(s.cancel(),void(s=!1)):(s=e.downloadDoc(n.document.id),void s.then(function(){t(function(){n.isActive=!0},200)}))}}return{link:n,templateUrl:templateUrl("full_gif"),scope:{document:"="}}}]).directive("myLoadSticker",["_","MtpApiFileManager","FileManager","AppStickersManager",function(e,t,n,a){function i(i,s,r){var l=$("").addClass(r.imgClass),c=!1;l.attr("alt","["+(i.document.stickerEmojiRaw||"")+" "+e("conversation_media_sticker")+"]");var d=r.dim&&i.$parent.$eval(r.dim)||i.document.thumb;r.open&&i.document.stickerSetInput&&s.addClass("clickable").on("click",function(){a.openStickerset(i.document.stickerSetInput)});var u=function(e){l.attr("src",n.getUrl(e)),c||(c=!0,l.appendTo(s))};l.css({width:d.width,height:d.height}),s.css({width:d.width,height:d.height});var p=!1;i.document.thumb.location&&(p=angular.copy(i.document.thumb.location),p.sticker=!0);var m={_:"inputDocumentFileLocation",id:i.document.id,access_hash:i.document.access_hash,dc_id:i.document.dc_id,file_name:i.document.file_name,version:i.document.version,sticker:!0},g=t.getCachedFile(m),h=!1;if(g?h=!0:g=t.getCachedFile(p),g){if(u(g),h)return}else c=!0,l.attr("src",o).appendTo(s);r.thumb&&p?t.downloadSmallFile(p).then(function(e){u(e)},function(e){console.log("Download sticker failed",e,m)}):t.downloadFile(i.document.dc_id,m,i.document.size).then(function(e){u(e)},function(e){console.log("Download sticker failed",e,m)})}var o="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";return{link:i,scope:{document:"="}}}]).directive("myLoadDocument",["MtpApiFileManager","AppDocsManager","FileManager",function(e,t,n){function a(e,t){for(;e&&!$(e).hasClass("modal-dialog");)e=e.parentNode;e&&$(e).width(t+(Config.Mobile?0:32))}function i(i,o,s){var r=$(".document_fullsize_with_progress_wrap",o),l=$(".document_fullsize_wrap",o),c=$(".document_fullsize_img",o),d=$(window).width()-(Config.Mobile?20:32),u=$(window).height()-150;d>800&&(d-=208),i.imageWidth=d,i.imageHeight=u;var p=i.document.thumb;if(p&&"photoSizeEmpty"!=p._){var m=calcImageInBox(p.width,p.height,d,u);i.imageWidth=m.w,i.imageHeight=m.h;var g=e.getCachedFile(p.location);g&&(i.thumbSrc=n.getUrl(g,"image/jpeg"))}i.frameWidth=Math.max(i.imageWidth,Math.min(600,d)),i.frameHeight=i.imageHeight,onContentLoaded(function(){i.$emit("ui_height")}),a(o[0],i.frameWidth);var h,f,_;t.downloadDoc(i.document.id).then(function(e){var t=n.getUrl(e,i.document.mime_type),a=new Image,o=100,s=function(e){if(a.height&&a.width||!--o){f=a.width,_=a.height,clearInterval(h);var n=calcImageInBox(a.width,a.height,d,u,!0),s={w:f,h:_};n.w>=s.w&&n.h>=s.h&&(s.w*=4,s.h*=4);var p=!0;i.toggleZoom=function(){p=!p;var e=(p?s:n).w,t=(p?s:n).h;c.css({width:e,height:t,marginTop:i.frameHeight>t?Math.floor((i.frameHeight-t)/2):0}),l.toggleClass("document_fullsize_zoomed",p)},i.toggleZoom(!1),c.attr("src",t),r.hide(),l.css({width:i.frameWidth,height:i.frameHeight}).show()}};h=setInterval(s,20),a.onload=s,a.src=t,setZeroTimeout(s)})}return{link:i,templateUrl:templateUrl("full_document"),scope:{document:"=myLoadDocument"}}}]).directive("myGeoPointMap",["ExternalResourcesManager",function(e){function t(t,n,a){var i=n.attr("width")||200,o=n.attr("height")||200,s=Config.ExtCredentials.gmaps.api_key,r=i>200?15:13;n.attr("src","img/blank.gif");var l="https://maps.googleapis.com/maps/api/staticmap?sensor=false¢er="+t.point.lat+","+t.point["long"]+"&zoom="+r+"&size="+i+"x"+o+"&scale=2&markers=color:red|size:big|"+t.point.lat+","+t.point["long"],c=!1;c&&(l+="&key="+s),e.downloadByURL(l).then(function(e){n.attr("src",e.valueOf())})}return{link:t,scope:{point:"=myGeoPointMap"}}}]).directive("myLoadingDots",["$interval",function(e){function t(e,t,a){t.html(n(t[0])?'
    ':"...")}function n(e){if(void 0===a&&(a=void 0!==e.style.animationName,a===!1)){var t,n="Webkit Moz O ms Khtml".split(" ");for(t=0;t=a.scrollHeight-a.clientHeight-300&&(i=!0,e.$apply(function(){e.slice.limit+=e.slice.limitDelta||20}),onContentLoaded(function(){i=!1,$(t).nanoScroller()}))})}return{link:e,scope:!0}}).directive("myModalPosition",["$window","$timeout",function(e,t){function n(n,a,i){var o=function(){if(!Config.Mobile||!$(a[0].parentNode.parentNode.parentNode).hasClass("mobile_modal")){var e=a[0].parentNode.offsetHeight,n=a[0].parentNode.parentNode.parentNode,o=$(".media_modal_bottom_panel_wrap",n)[0],s=n.offsetHeight-(o&&o.offsetHeight||0);e1||1==n&&!o)&&(e=t("group_modal_participants",{total:e,online:u(n)}))}n||f||(e=""),s.html(e)};n.$watch(r.myChatStatus,function(e){m=e,v()}),e.$on("chat_full_update",function(e,t){m==t&&v()}),e.$on("user_update",function(e,t){_[t]&&y()}),c[g]=y,n.$on("$destroy",function(){delete c[g]})}var l=0,c={},d=t.pluralize("group_modal_pluralize_participants"),u=t.pluralize("group_modal_pluralize_online_participants"),p=0;return n.getUserID().then(function(e){p=e}),setInterval(s,9e4),{link:r}}]).directive("myPeerMuted",["$rootScope","NotificationsManager",function(e,t){function n(t,n,i){var o=t.$eval(i.myPeerMuted),s=i.mutedClass||"muted",r=e.$on("notify_settings",function(e,t){t.peerID==o&&a(o,n,s)});a(o,n,s),t.$on("$destroy",r)}function a(e,n,a){t.getPeerMuted(e).then(function(e){n.toggleClass(a,e)})}return{link:n}}]).directive("myPeerLink",["AppChatsManager","AppUsersManager",function(e,t){function n(n,a,i){var o,s=i.userOverride&&n.$eval(i.userOverride)||{},r=i["short"]&&n.$eval(i["short"]),l=i.username&&n.$eval(i.username),c=function(){if(a[0].className.indexOf("user_color_")!=-1&&(a[0].className=a[0].className.replace(/user_color_\d+/g,"")),o>0){var c=t.getUser(o),d=l?"@":"",u=l?"username":r?"rFirstName":"rFullName";a.html(d+(s[u]||c[u]||"").valueOf()+(i.verified&&c.pFlags&&c.pFlags.verified?' ':"")),i.color&&n.$eval(i.color)&&a.addClass("user_color_"+c.num)}else{var p=e.getChat(-o);a.html((p.rTitle||"").valueOf()+(i.verified&&p.pFlags&&p.pFlags.verified?' ':""))}};"A"!=a[0].tagName||hasOnlick(a[0])||a.on("click",function(){o>0?t.openUser(o,s):e.openChat(-o)}),i.peerWatch?n.$watch(i.myPeerLink,function(e){o=e,c()}):(o=n.$eval(i.myPeerLink),c()),i.noWatch||(n.$on("user_update",function(e,t){o==t&&c()}),n.$on("chat_update",function(e,t){o==-t&&c()}))}return{link:n}}]).directive("myPeerPhotolink",["AppPeersManager","AppUsersManager","AppChatsManager","MtpApiFileManager","FileManager",function(e,t,n,a,i){function o(o,s,r){s.addClass("peer_photo_init");var l,c,d,u=$(''),p=$(''),m=0,g=!1,h=function(t){if(l==t)return!1;l=t,c=e.getPeer(l);var n="user_bgcolor_"+(c.num||1);return n!=g&&(g&&p.removeClass(g),p.addClass(n),g=n),f(),!0},f=function(){var e=++m;d=c.photo&&angular.copy(c.photo.photo_small);var t=void 0!==d;if(t){var n=a.getCachedFile(c.photo.photo_small);if(n)return p.remove(),void u.prependTo(s).attr("src",i.getUrl(n,"image/jpeg"))}p.attr("data-content",c.initials||"").prependTo(s),u.remove(),t&&a.downloadSmallFile(c.photo.photo_small).then(function(t){e==m&&(p.remove(),u.prependTo(s).attr("src",i.getUrl(t,"image/jpeg")))},function(e){console.log("Download image failed",e,c.photo.photo_small,s[0])})};"A"!=s[0].tagName||r.noOpen||s.on("click",function(e){l>0?t.openUser(l,r.userOverride&&o.$eval(r.userOverride)):n.openChat(-l)}),o.$watch(r.myPeerPhotolink,h),h(o.$eval(r.myPeerPhotolink)),r.watch&&(o.$on("user_update",function(e,t){l==t&&(angular.equals(c.photo&&c.photo.photo_small,d)||f())}),o.$on("chat_update",function(e,t){l==-t&&(angular.equals(c.photo&&c.photo.photo_small,d)||f())}))}return{link:o}}]).directive("myAudioPlayer",["$timeout","$q","Storage","AppDocsManager","AppMessagesManager","ErrorService",function(e,t,n,a,i,o){function s(e){return e!==l&&(l&&l.pause(),void(l=e))}function r(e,t,r){a.updateDocDownloaded(e.audio.id),e.volume=c,e.mediaPlayer={},e.download=function(){a.saveDocFile(e.audio.id)},e.togglePlay=function(){if(e.audio.url)s(e.mediaPlayer.player),e.mediaPlayer.player.playPause();else{if(e.audio.progress&&e.audio.progress.enabled)return;a.downloadDoc(e.audio.id).then(function(){onContentLoaded(function(){var n=$("audio",t)[0]||t[0];if(n){var a=!1,r=function(e){a||e.target&&e.target.error&&e.target.error.code!=e.target.error.MEDIA_ERR_DECODE&&e.target.error.code!=e.target.error.MEDIA_ERR_SRC_NOT_SUPPORTED||(a=!0,o.show({error:{type:"MEDIA_TYPE_NOT_SUPPORTED",originalError:e.target&&e.target.error}}))};n.addEventListener("error",r,!0),e.$on("$destroy",function(){a=!0,n.removeEventListener("error",r)})}setTimeout(function(){s(e.mediaPlayer.player),e.mediaPlayer.player.setVolume(c),e.mediaPlayer.player.play(),e.message&&!e.message.pFlags.out&&e.message.pFlags.media_unread&&i.readMessages([e.message.mid])},300)})})}},e.seek=function(t){e.mediaPlayer&&e.mediaPlayer.player?e.mediaPlayer.player.seek(t):e.togglePlay()},e.setVolume=function(t){c=t,n.set({audio_volume:t}),e.mediaPlayer&&e.mediaPlayer.player&&e.mediaPlayer.player.setVolume(t)}}var l=!1,c=.5;n.get("audio_volume").then(function(e){e>0&&e<=1&&(c=e)});return{link:r,scope:{audio:"=",message:"="},templateUrl:templateUrl("audio_player")}}]).directive("mySlider",["$window",function(e){function t(t,n,a){var i=$(".tg_slider_wrap",n),o=$(".tg_slider_track_fill",n),s=$(".tg_slider_thumb",n),r=i.width(),l=Math.ceil(s.width()),c=a.sliderModel,d=a.sliderOnchange,u=0,p=1,m=!1,g=!1;a.sliderMin&&t.$watch(a.sliderMin,function(e){u=e||0}),a.sliderMax&&t.$watch(a.sliderMax,function(e){p=e||1});var h=function(e){e=e.originalEvent||e;var n=(e.touches&&e.touches[0]?e.touches[0].pageX:e.pageX)-g;return n=Math.min(r,Math.max(0,n)),m=u+n/r*(p-u),d?t.$eval(d,{value:m}):t.$eval(c+"="+m),s.css("left",Math.max(0,n-l)),o.css("width",n),cancelEvent(e)},f=function(){$(e).off("mousemove touchmove",h),$(e).off("mouseup touchend touchcancel touchleave",f)};t.$watch(c,function(e){if(e!=m&&void 0!==e){var t=Math.max(0,(e-u)/(p-u));if(r){var n=Math.ceil(r*t);n=Math.min(r,Math.max(0,n)),s.css("left",Math.max(0,n-l)),o.css("width",n)}else s.css("left",100*t+"%"),o.css("width",100*t+"%");m=!1}}),n.on("dragstart selectstart",cancelEvent),n.on("mousedown touchstart",function(a){if(!r&&(r=i.width(),!r))return console.error("empty width"),cancelEvent(a);f(),a=a.originalEvent||a;var _;if(a.touches&&a.touches[0])g=n.position().left,_=a.touches[0].pageX-g;else if(void 0!==a.offsetX)_=a.offsetX,g=a.pageX-_;else{if(void 0===a.layerX)return cancelEvent(a);_=a.layerX,g=a.pageX-_}return m=u+_/r*(p-u),d?t.$eval(d,{value:m}):t.$eval(c+"="+m),s.css("left",Math.max(0,_-l)),o.css("width",_),$(e).on("mousemove touchmove",h),$(e).on("mouseup touchend touchcancel touchleave",f),cancelEvent(a)})}return{link:t,templateUrl:templateUrl("slider")}}]).directive("myLabeledInput",function(){function e(e,t,n){var a=$(".md-input:first",t),i=($(".md-input-label:first",t),a[0]&&"SPAN"==a[0].tagName),o=!1,s=function(){i?t.toggleClass("md-input-has-value",a.html().length>0):t.toggleClass("md-input-has-value",o||a.val().length>0)};s(),onContentLoaded(function(){s(),setZeroTimeout(function(){t.addClass("md-input-animated")})}),i||a.on("blur focus change",function(e){o="focus"==e.type,t.toggleClass("md-input-focused",o),s()}),e.$on("value_updated",function(){setZeroTimeout(function(){s()})})}return{link:e}}).directive("myCopyField",["toaster","_",function(e,t){function n(e,t,n){t.attr("readonly","true"),t[0].readonly=!0,t.on("click",function(){this.select()}),e.selectEvent&&e.$on(e.selectEvent,function(){setTimeout(function(){t[0].focus(),t[0].select()},100)})}return{scope:{selectEvent:"=myCopyField"},link:n}}]).directive("myCopyLink",["$compile","$timeout","_",function(e,t,n){function a(a,i,o){i.attr("tooltip","{{ttLabel}}"),i.removeAttr("my-copy-link"),i.removeAttr("data-my-copy-link");var s=!1,r=function(){t.cancel(s),s=!1,a.ttLabel=n("conversations_modal_share_url_copy_raw")};r(),e(i)(a);var l=new Clipboard(i[0]);l.on("success",function(e){t.cancel(s),a.$apply(function(){a.ttLabel=n("clipboard_copied_raw")}),s=t(r,2e3)}),l.on("error",function(e){t.cancel(s);var i=Config.Navigator.osX?"clipboard_press_cmd_c":"clipboard_press_ctrl_c";a.$apply(function(){a.ttLabel=n(i+"_raw")}),s=t(r,5e3)}),a.$on("$destroy",function(){l.destroy()})}return{restrict:"A",replace:!1,terminal:!0,priority:1e3,link:a}}]).directive("mySubmitOnEnter",function(){function e(e,t,n){t.on("keydown",function(e){if(13==e.keyCode)return t.trigger("submit"),cancelEvent(e)})}return{link:e}}).directive("myArcProgress",function(){function e(e,t,n){t=Math.max(0,Math.min(t,1));var a=.2;t=a+(1-a)*t,e.css({strokeDasharray:t*n+", "+(1-t)*n})}var t=' ',n=0;return{scope:{progress:"=myArcProgress"},link:function(a,i,o){var s=!o.myArcProgress,r=o.width||i.width()||40,l=o.stroke||r/2*.14,c=r/2,d=c-l/2,u=++n;i.html(t.replace("%id%",u)).addClass("progress-arc-wrap").addClass(s?"progress-arc-intermediate":"progress-arc-percent").css({width:r,height:r}),$(i[0].firstChild).attr("width",r).attr("height",r);var p=$(".progress-arc-bar",i);p.attr("cx",c).attr("cy",c).attr("r",d).css({strokeWidth:l});var m=2*Math.PI*d;s?(e(p,.3,m),p.css({stroke:"url(#grad_intermediate"+u+")"})):a.$watch("progress",function(t){e(p,t/100,m)})}}}).directive("myScrollToOn",function(){return{link:function(e,t,n){var a=n.myScrollToOn,i=function(){onContentLoaded(function(){$("html, body").animate({scrollTop:t.offset().top},200)})};"$init"==a?i():e.$on(a,i)}}}).directive("myComposerDropdown",function(){return{templateUrl:templateUrl("composer_dropdown")}}).directive("myEmojiSuggestions",function(){return{link:function(e,t,n){e.$watchCollection("emojiCodes",function(e){var n,a,i,o,s,r,l,c,d=[],u=Config.Mobile?26:20,p=Math.min(5,e.length);for(r=0;r:'+encodeEntities(a[1][0])+":"));t.html(d.join("")),console.log(dT(),"emoji done")})}}}).directive("myInlineResults",["AppPhotosManager","ExternalResourcesManager","AppDocsManager",function(e,t,n){return{templateUrl:templateUrl("inline_results"),scope:{botResults:"=myInlineResults"},link:function(a,i,o){a.$watch("botResults.results",function(a){angular.forEach(a,function(a){if(a.thumb_url&&!a.thumbUrl&&t.downloadByURL(a.thumb_url).then(function(e){a.thumbUrl=e}),"gif"==a.type&&a.content_url&&!a.contentUrl&&t.downloadByURL(a.content_url).then(function(e){a.contentUrl=e}),"gif"!=a.type&&"sticker"!=a.type||!a.document||n.downloadDoc(a.document.id),"photo"==a.type&&a.photo){var i=e.choosePhotoSize(a.photo,a.thumbW,a.thumbH),o=calcImageInBox(i.w,i.h,a.thumbW,a.thumbH);a.thumb={width:o.w,height:o.h,location:i.location,size:i.size}}if("game"==a.type&&a.photo){var i=e.choosePhotoSize(a.photo,100,100);a.thumb={location:i.location,size:i.size}}})})}}}]).directive("myGameCommunication",["$window",function(e){ -function t(t,n,a){onContentLoaded(function(){var a=$("iframe, webview",n)[0],i=a.contentWindow,o=function(e){if(e=e.originalEvent||e,!e.source||e.source==i){var n=e.data;try{var a=JSON.parse(n)}catch(o){return}a&&a.eventType&&t.$emit("game_frame_event",a)}};$(e).on("message",o),t.$on("$destroy",function(){$(e).off("message",o)})})}return{link:t}}]).directive("myEmojiImage",["RichTextProcessor",function(e){function t(t,n,a){var i=a.myEmojiImage,o=e.wrapRichText(i,{noLinks:!0,noLinebreaks:!0});n.html(o.valueOf())}return{link:t}}]).directive("myExternalEmbed",function(){function e(e,r,l){var c=e.$eval(l.myExternalEmbed);if(c){var d="",u=!1;switch(c[0]){case"youtube":var p=c[1];d='
    <'+s+' type="text/html" frameborder="0" src="https://www.youtube.com/embed/'+p+'?autoplay=0&controls=2" webkitallowfullscreen mozallowfullscreen allowfullscreen>
    ";break;case"vimeo":var p=c[1];d='
    <'+s+' type="text/html" frameborder="0" src="https://player.vimeo.com/video/'+p+'?title=0&byline=0&portrait=0" webkitallowfullscreen mozallowfullscreen allowfullscreen>
    ";break;case"instagram":var m=c[1];d='
    <'+s+' type="text/html" frameborder="0" src="https://instagram.com/p/'+m+'/embed/">
    ";break;case"vine":var g=c[1];d='
    <'+s+' type="text/html" frameborder="0" src="https://vine.co/v/'+g+'/embed/simple">
    ";break;case"soundcloud":var h=c[1];d='
    <'+s+' type="text/html" frameborder="0" src="https://w.soundcloud.com/player/?url='+encodeEntities(encodeURIComponent(h))+'&auto_play=false&hide_related=true&show_comments=false&show_user=true&show_reposts=false&visual=true">
    ";break;case"spotify":var f=c[1];d='
    <'+s+' type="text/html" frameborder="0" allowtransparency="true" src="https://embed.spotify.com/?uri=spotify:'+encodeEntities(encodeURIComponent(f))+'">
    ";break;case"twitter":d='
    ',u=function(){t?window.twttr&&twttr.widgets.load(r[0]):(t=!0,$("