From 39c7381d886b9c881e85bc2340e14297f454465f Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Mon, 2 Nov 2015 18:27:58 +0300 Subject: [PATCH] merged with master --- app.manifest | 24 ++++++++++++------------ js/app.js | 2 +- webogram.appcache | 24 ++++++++++++------------ 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/app.manifest b/app.manifest index 7cfde2f8..421f934e 100644 --- a/app.manifest +++ b/app.manifest @@ -1,5 +1,5 @@ CACHE MANIFEST -# Time: Mon Nov 02 2015 15:40:42 GMT+0300 (MSK) +# Time: Mon Nov 02 2015 18:26:21 GMT+0300 (MSK) CACHE: @@ -8,7 +8,6 @@ favicon_unread.ico css/app.css css/desktop.css css/mobile.css -js/app.js img/Manytabs.png img/Manytabs_2x.png img/Telegram.png @@ -25,18 +24,9 @@ img/iphone_home120.png img/iphone_startup.png img/logo_share.png img/sound_a.mp3 +js/app.js nacl/mtproto_crypto.nmf nacl/mtproto_crypto.pexe -js/lib/bin_utils.js -js/lib/crypto_worker.js -js/lib/polyfill.js -js/locales/de-de.json -js/locales/en-us.json -js/locales/es-es.json -js/locales/it-it.json -js/locales/nl-nl.json -js/locales/pt-br.json -js/locales/ru-ru.json img/changelog/card_wecandoit.png img/icons/AboutLogos.png img/icons/AboutLogos_2x.png @@ -71,6 +61,16 @@ img/placeholders/UserAvatar7@2x.png img/placeholders/UserAvatar8@2x.png img/placeholders/VideoThumbConversation.gif img/placeholders/VideoThumbModal.gif +js/lib/bin_utils.js +js/lib/crypto_worker.js +js/lib/polyfill.js +js/locales/de-de.json +js/locales/en-us.json +js/locales/es-es.json +js/locales/it-it.json +js/locales/nl-nl.json +js/locales/pt-br.json +js/locales/ru-ru.json vendor/closure/long.js vendor/cryptoJS/crypto.js vendor/jsbn/jsbn_combined.js diff --git a/js/app.js b/js/app.js index bb325247..7033e6db 100644 --- a/js/app.js +++ b/js/app.js @@ -20,7 +20,7 @@ s.chooseSave(r,i,o).then(function(e){e&&a.downloadFile(u.location.dc_id,p,u.size })}),!0):void e.$broadcast("history_focus",{peerString:n.getPeerString(t),startParam:c[3]})}),!0;if(c=t.match(/^join\?invite=(.+)$/))return a.openChatInviteLink(c[1]),!0;if(c=t.match(/^addstickers\?set=(.+)$/))return s.openStickersetLink(c[1]),!0;if(c=t.match(/^msg_url\?url=([^&]+)(?:&text=(.*))?$/))return o.selectPeer({confirm_type:"SHARE_URL"}).then(function(t){var n=decodeURIComponent(c[1]),i=c[2]?decodeURIComponent(c[2]):"";e.$broadcast("history_focus",{peerString:t,attachment:{_:"share_url",url:n,text:i}})}),!0;if(l&&(c=t.match(/^unsafe_url\?url=([^&]+)/))){var t=decodeURIComponent(c[1]);return r.confirm({type:"JUMP_EXT_URL",url:t}).then(function(){window.open(t,"_blank")}),!0}if(l&&(c=t.match(/^bot_command\?command=(.+?)(?:&bot=(.+))?$/))){var d=e.selectedPeerID,u="/"+c[1];return 0>d&&c[2]&&(u+="@"+c[2]),a.sendText(d,u),e.$broadcast("history_focus",{peerString:n.getPeerString(d)}),!0}return!1}function d(){if(!p){if(p=!0,"registerProtocolHandler"in navigator){try{navigator.registerProtocolHandler("tg","#im?tgaddr=%s","Telegram Web")}catch(t){}try{navigator.registerProtocolHandler("web+tg","#im?tgaddr=%s","Telegram Web")}catch(t){}}$(document).on("click",function(e){var t=e.target;if(t&&"A"==t.tagName&&!t.onclick&&!t.onmousedown){var n=$(t).attr("href")||t.href||"",i=n.match(u);if(i&&c(i[3],!0))return cancelEvent(e)}}),e.$on("$routeUpdate",l),l()}}var u=/^(web\+)?tg:(\/\/)?(.+)/,p=!1;return{start:d}}]),angular.module("myApp.controllers",["myApp.i18n"]).controller("AppWelcomeController",["$scope","$location","MtpApiManager","ErrorService","ChangelogNotifyService","LayoutSwitchService",function(e,t,n,i,a,o){n.getUserID().then(function(e){return e?void t.url("/im"):"http:"!=location.protocol||Config.Modes.http||-1==Config.App.domains.indexOf(location.hostname)?void t.url("/login"):void(location.href=location.href.replace(/^http:/,"https:"))}),a.checkUpdate(),o.start()}]).controller("AppLoginController",["$scope","$rootScope","$location","$timeout","$modal","$modalStack","MtpApiManager","ErrorService","NotificationsManager","PasswordManager","ChangelogNotifyService","IdleManager","LayoutSwitchService","TelegramMeWebService","_",function(e,t,n,i,a,o,s,r,l,c,d,u,p,m,h){function g(){var t=(navigator.language||"").toLowerCase(),n=Config.LangCountries[t],i=!Config.Navigator.mobile;if(f(-1==["en","en-us","en-uk"].indexOf(t)?void 0!==n?n:t.indexOf("-")>0?t.split("-")[1].toUpperCase():"US":"US"),i){var a=e.credentials.phone_country;s.invokeApi("help.getNearestDc",{},{dcID:2,createNetworker:!0}).then(function(t){a==e.credentials.phone_country&&f(t.country),t.nearest_dc!=t.this_dc&&s.getNetworker(t.nearest_dc,{createNetworker:!0})})}}function f(e){if(e){var t,n;for(t=0;to&&!a.indexOf(i)&&(o=i.length,s=h(Config.CountryCodes[t][1]+"_raw"));e.credentials.phone_full=a,e.credentials.phone_country_name=s||h("login_controller_unknown_country_raw")}function y(e){s.setUserAuth(k.dcID,{id:e.user.id}),i.cancel(S),n.url("/im")}function b(){i.cancel(S),e.credentials.viaApp||(--e.callPending.remaining?S=i(b,1e3):(e.callPending.success=!1,s.invokeApi("auth.sendCall",{phone_number:e.credentials.phone_full,phone_code_hash:e.credentials.phone_code_hash},k).then(function(){e.callPending.success=!0})))}function w(){return c.getState(k).then(function(t){return e.password=t})}o.dismissAll(),u.start(),s.getUserID().then(function(e){return e?void n.url("/im"):"http:"!=location.protocol||Config.Modes.http||-1==Config.App.domains.indexOf(location.hostname)?void m.setAuthorized(!1):void(location.href=location.href.replace(/^http:/,"https:"))});var k={dcID:2,createNetworker:!0},$=!1;e.credentials={phone_country:"",phone_country_name:"",phone_number:"",phone_full:""},e.progress={},e.callPending={},e.about={},e.chooseCountry=function(){var e=a.open({templateUrl:templateUrl("country_select_modal"),controller:"CountrySelectModalController",windowClass:"countries_modal_window mobile_modal",backdrop:"single"});e.result.then(_)},e.$watch("credentials.phone_country",v),e.$watch("credentials.phone_number",v),g();var S;e.sendCode=function(){i.cancel(S),r.confirm({type:"LOGIN_PHONE_CORRECT",country_code:e.credentials.phone_country,phone_number:e.credentials.phone_number}).then(function(){e.progress.enabled=!0,onContentLoaded(function(){e.$broadcast("ui_height")});var n=tsNow();s.invokeApi("auth.sendCode",{phone_number:e.credentials.phone_full,sms_type:5,api_id:Config.App.id,api_hash:Config.App.hash,lang_code:navigator.language||"en"},k).then(function(t){e.progress.enabled=!1,e.credentials.phone_code_hash=t.phone_code_hash,e.credentials.phone_occupied=t.phone_registered,e.credentials.viaApp="auth.sentAppCode"==t._,e.callPending.remaining=t.send_call_timeout||60,e.error={},e.about={},b(),onContentLoaded(function(){e.$broadcast("ui_height")})},function(t){switch(e.progress.enabled=!1,console.log("sendCode error",t),t.type){case"PHONE_NUMBER_INVALID":e.error={field:"phone"},t.handled=!0}})["finally"](function(){(t.idle.isIDLE||tsNow()-n>6e4)&&l.notify({title:"Telegram",message:"Your authorization key was successfully generated! Open the app to log in.",tag:"auth_key"})})})},e.sendSms=function(){e.credentials.viaApp&&(delete e.credentials.viaApp,s.invokeApi("auth.sendSms",{phone_number:e.credentials.phone_full,phone_code_hash:e.credentials.phone_code_hash},k).then(b))},e.editPhone=function(){i.cancel(S),delete e.credentials.phone_code_hash,delete e.credentials.phone_unoccupied,delete e.credentials.phone_code_valid,delete e.credentials.viaApp,delete e.callPending.remaining,delete e.callPending.success},e.logIn=function(t){var n="auth.signIn",i={phone_number:e.credentials.phone_full,phone_code_hash:e.credentials.phone_code_hash,phone_code:e.credentials.phone_code};t&&(n="auth.signUp",angular.extend(i,{first_name:e.credentials.first_name||"",last_name:e.credentials.last_name||""})),e.progress.enabled=!0,s.invokeApi(n,i,k).then(y,function(t){if(e.progress.enabled=!1,400==t.code&&"PHONE_NUMBER_UNOCCUPIED"==t.type)return t.handled=!0,e.credentials.phone_code_valid=!0,e.credentials.phone_unoccupied=!0,void(e.about={});if(400==t.code&&"PHONE_NUMBER_OCCUPIED"==t.type)return t.handled=!0,e.logIn(!1);if(401==t.code&&"SESSION_PASSWORD_NEEDED"==t.type)return e.progress.enabled=!0,w().then(function(){e.progress.enabled=!1,e.credentials.phone_code_valid=!0,e.credentials.password_needed=!0,e.about={}}),void(t.handled=!0);switch(t.type){case"FIRSTNAME_INVALID":e.error={field:"first_name"},t.handled=!0;break;case"LASTNAME_INVALID":e.error={field:"last_name"},t.handled=!0;break;case"PHONE_CODE_INVALID":e.error={field:"phone_code"},delete e.credentials.phone_code_valid,t.handled=!0;break;case"PHONE_CODE_EXPIRED":e.editPhone(),t.handled=!0}})},e.checkPassword=function(){return c.check(e.password,e.credentials.password,k).then(y,function(t){switch(t.type){case"PASSWORD_HASH_INVALID":e.error={field:"password"},t.handled=!0}})},e.forgotPassword=function(n){return c.requestRecovery(e.password,k).then(function(n){var i=t.$new();i.recovery=n,i.options=k;var o=a.open({scope:i,templateUrl:templateUrl("password_recovery_modal"),controller:"PasswordRecoveryModalController",windowClass:"md_simple_modal_window mobile_modal"});o.result.then(function(t){t&&t.user?y(t):e.canReset=!0})},function(t){switch(t.type){case"PASSWORD_EMPTY":e.logIn(),t.handled=!0;break;case"PASSWORD_RECOVERY_NA":i(function(){e.canReset=!0},1e3),t.handled=!0}}),cancelEvent(n)},e.resetAccount=function(){r.confirm({type:"RESET_ACCOUNT"}).then(function(){e.progress.enabled=!0,s.invokeApi("account.deleteAccount",{reason:"Forgot password"},k).then(function(){delete e.progress.enabled,delete e.credentials.password_needed,e.credentials.phone_unoccupied=!0},function(){delete e.progress.enabled})})},d.checkUpdate(),p.start()}]).controller("AppIMController",["$q","qSync","$scope","$location","$routeParams","$modal","$rootScope","$modalStack","MtpApiManager","AppUsersManager","AppChatsManager","AppPeersManager","ContactsSelectService","ChangelogNotifyService","ErrorService","AppRuntimeManager","HttpsMigrateService","LayoutSwitchService","LocationParamsService","AppStickersManager",function(e,t,n,i,a,o,s,r,l,c,d,u,p,m,h,g,f,_,v,y){function b(){if(a.q){if(a.q!==$&&(n.search.query=$=a.q,void 0!==n.curDialog))return!1}else $=!1;var e=w||{};w=!1,e.messageID=parseInt(e.messageID)||!1,e.startParam=e.startParam;var i;a.p&&"@"==a.p.charAt(0)?(void 0===n.curDialog&&(n.curDialog={}),i=u.resolveUsername(a.p.substr(1)).then(function(e){return t.when(u.getPeerString(e))})):i=t.when(a.p),i.then(function(t){n.curDialog=angular.extend({peer:t},e),k&&(n.$broadcast("peer_draft_attachment",k),k=!1)})}n.$on("$routeUpdate",b);var w=!1,k=!1;n.$on("history_focus",function(e,t){if(r.dismissAll(),t.peerString!=n.curDialog.peer||t.messageID!=n.curDialog.messageID||t.startParam){var o=u.getPeerID(t.peerString),s=u.getPeer(o).username,l=s?"@"+s:t.peerString;w=t.messageID||t.startParam?{messageID:t.messageID,startParam:t.startParam}:!1,t.attachment&&(k=t.attachment),a.p!=l?i.url("/im?p="+l):b()}else n.$broadcast(t.messageID?"ui_history_change_scroll":"ui_history_focus")}),n.$on("esc_no_more",function(){s.$apply(function(){i.url("/im")})}),n.isLoggedIn=!0,n.isEmpty={},n.search={},n.historyFilter={mediaType:!1},n.historyPeer={},n.historyState={selectActions:!1,botActions:!1,channelActions:!1,canReply:!1,canDelete:!1,actions:function(){return n.historyState.selectActions?"selected":n.historyState.botActions?"bot":n.historyState.channelActions?"channel":!1},typing:[],missedCount:0,skipped:!1},n.openSettings=function(){o.open({templateUrl:templateUrl("settings_modal"),controller:"SettingsModalController",windowClass:"settings_modal_window mobile_modal",backdrop:"single"})},n.openFaq=function(){var e="https://telegram.org/faq";switch(Config.I18n.locale){case"es-es":e+="/es";break;case"it-it":e+="/it";break;case"de-de":e+="/de";break;case"ko-ko":e+="/ko";break;case"pt-br":e+="/br"}window.open(e,"_blank")},n.openContacts=function(){p.selectContact().then(function(e){n.dialogSelect(c.getUserString(e))})},n.openGroup=function(){p.selectContacts({action:"new_group"}).then(function(e){if(1==e.length)n.dialogSelect(c.getUserString(e[0]));else if(e.length>1){var t=s.$new();t.userIDs=e,o.open({templateUrl:templateUrl("chat_create_modal"),controller:"ChatCreateModalController",scope:t,windowClass:"md_simple_modal_window mobile_modal",backdrop:"single"})}})},n.importContact=function(){c.openImportContact().then(function(e){e&&s.$broadcast("history_focus",{peerString:c.getUserString(e)})})},n.searchClear=function(){n.search.query="",n.$broadcast("search_clear")},n.dialogSelect=function(e,t){var i={peerString:e};t?i.messageID=t:n.search.query&&n.searchClear(),s.$broadcast("history_focus",i)},n.logOut=function(){h.confirm({type:"LOGOUT"}).then(function(){l.logOut().then(function(){location.hash="/login",g.reload()})})},n.openChangelog=function(){m.showChangelog(!1)},n.showPeerInfo=function(){n.curDialog.peerID>0?c.openUser(n.curDialog.peerID):n.curDialog.peerID<0&&d.openChat(-n.curDialog.peerID)},n.toggleEdit=function(){n.$broadcast("history_edit_toggle")},n.selectedFlush=function(){n.$broadcast("history_edit_flush")},n.toggleMedia=function(e){n.$broadcast("history_media_toggle",e)},n.returnToRecent=function(){n.$broadcast("history_return_recent")},n.toggleSearch=function(){n.$broadcast("dialogs_search_toggle")},b();var $=!1;m.checkUpdate(),f.start(),_.start(),v.start(),y.start()}]).controller("AppImDialogsController",["$scope","$location","$q","$timeout","$routeParams","MtpApiManager","AppUsersManager","AppChatsManager","AppMessagesManager","AppProfileManager","AppPeersManager","PhonebookContactsService","ErrorService","AppRuntimeManager",function(e,t,n,i,a,o,s,r,l,c,d,u){function p(t){for(var n=0;n=5&&i(function(){t==$&&o.invokeApi("contacts.search",{q:e.search.query,limit:10}).then(function(n){s.saveApiUsers(n.users),r.saveApiChats(n.chats),t==$&&(e.foundPeers=[],angular.forEach(n.results,function(t){var n=d.getPeerID(t);if(void 0===S[n]){if(e.canSend&&d.isChannel(n)&&!r.hasRights(-n,"send"))return;e.foundPeers.push({id:n,username:d.getPeer(n).username,peerString:s.getUserString(n)})}}))},function(e){400==e.code&&(e.handled=!0)})},500),e.search.query&&!e.noMessages&&(v=!0,h())}e.dialogs=[],e.contacts=[],e.foundPeers=[],e.foundMessages=[],void 0===e.search&&(e.search={}),void 0===e.isEmpty&&(e.isEmpty={}),e.phonebookAvailable=u.isAvailable();var _,v=!1,y=0,b=0,w=!1,k=0,$=0,S={},C={};e.$on("dialogs_need_more",function(){g()}),e.$on("dialog_unread",function(t,n){angular.forEach(e.dialogs,function(e){e.peerID==n.peerID&&(e.unreadCount=n.count)})}),e.$on("dialogs_multiupdate",function(t,n){if(void 0!==e.search.query&&e.search.query.length)return!1;var i=[],a={};angular.forEach(n,function(t,n){e.noUsers&&n>0||(a[t.index]=t,i.push(t.index))}),i.sort();var o,s,r=e.dialogs.length;for(o=0;r>o;o++)s=e.dialogs[o],n[s.peerID]&&(e.dialogs.splice(o,1),o--,r--);for(r=i.length,o=0;r>o;o++)s=a[i[o]],e.dialogs.unshift(l.wrapForDialog(s.top_message,s));delete e.isEmpty.dialogs,S[s.peerID]||(S[s.peerID]=!0,_&&f())}),e.$on("dialog_flush",function(e,t){p(t.peerID)}),e.$on("dialog_drop",function(e,t){p(t.peerID)}),e.$on("history_delete",function(t,n){for(var i=0;i-1?i=e.peerHistories[o]:(i={peerID:t,messages:[],ids:[]},e.peerHistories.unshift(i),a=e.peerHistories.length-s,a>0&&e.peerHistories.splice(s-1,a),i)}function v(t){var n;for(n=0;nq||!s.isBot(q)||e.historyFilter.mediaType||e.curDialog.messageID?!1:e.state.empty||V&&1==V.messages.length&&V.messages[0].action&&"messageActionBotIntro"==V.messages[0].action._?"start":e.curDialog.startParam?"param":!1,t!=e.historyState.botActions&&e.$broadcast("ui_panel_update")}function k(){var t,n=e.historyState.channelActions;if(q&&c.isChannel(q)&&(t=r.getChat(-q))){var i=t.pFlags.creator||t.pFlags.editor;i?e.historyState.channelActions=!1:t.pFlags.left?e.historyState.channelActions="join":(e.historyState.channelActions||(e.historyState.channelActions="mute"),h.getPeerMuted(q).then(function(t){e.historyState.channelActions=t?"unmute":"mute"})),e.historyState.canReply=i,e.historyState.canDelete=i||t.pFlags.moderator}else e.historyState.channelActions=!1,e.historyState.canReply=!0,e.historyState.canDelete=!0;n!=e.historyState.channelActions&&e.$broadcast("ui_panel_update")}function S(){var t=v(q);if(t&&-1!=t.ids.indexOf(e.curDialog.messageID)){e.historyUnread={};var i=e.curDialog.messageID||0;e.$broadcast("messages_focus",i),e.$broadcast("ui_history_change_scroll",!0),n.cancel(H),i&&(H=n(function(){e.curDialog.messageID==i&&e.$broadcast("messages_focus",0)},2800))}else x()}function C(){if(G){if(et)return void(at=!0);at=!1,it=!0;var t=J,n=++nt,i=0,a=20;l.getHistory(e.curDialog.inputPeer,Y,i,a).then(function(i){if(it=!1,t==J&&n==nt){var o,s;for(o=i.history.length-1;o>=0;o--)s=i.history[o],s>Y&&(V.messages.push(l.wrapForHistory(s)),V.ids.push(s));i.history.length?(Y=i.history.length>=a?i.history[0]:0,l.regroupWrappedHistory(V.messages,-a)&&e.$broadcast("messages_regroup"),delete e.state.empty,e.$broadcast("ui_history_append")):Y=0,e.historyState.skipped=G=Y>0,tt&&M()}})}}function M(){if(W){if(it)return void(tt=!0);tt=!1,et=!0;var t=J,n=++Q,i=e.historyFilter.mediaType&&{_:X[e.historyFilter.mediaType]},a=Config.Mobile?20:0,o=i?l.getSearch(e.curDialog.inputPeer,"",i,K,a):l.getHistory(e.curDialog.inputPeer,K,a);o.then(function(i){et=!1,t==J&&n==Q&&(angular.forEach(i.history,function(e){V.messages.unshift(l.wrapForHistory(e)),V.ids.unshift(e)}),W=null===i.count||i.history.length&&V.messages.length=a-1?t.history[0]:0,K=t.history[t.history.length-1],e.historyState.skipped=G=Y>0,W=null===t.count||i&&it;for(d=0;d0&&angular.forEach(e.selectedMsgs,function(e,t){n.push(t)}),n.length&&g.confirm({type:"MESSAGES_DELETE",count:n.length}).then(function(){l.deleteMessages(n).then(function(){N()})})}function U(t){var n=[];t?n.push(t):e.selectedCount>0&&angular.forEach(e.selectedMsgs,function(e,t){n.push(t)}),n.length&&u.selectPeer({canSend:!0}).then(function(e){N(),a.$broadcast("history_focus",{peerString:e,attachment:{_:"fwd_messages",id:n}})})}function R(t){t||1!=e.selectedCount||angular.forEach(e.selectedMsgs,function(e,n){t=n}),t&&(N(),e.$broadcast("reply_selected",t))}function L(){e.historyState.selectActions?N():(e.historyState.selectActions="selected",e.$broadcast("ui_panel_update"))}function B(t){e.historyFilter.mediaType=t||!1,e.curDialog.messageID=!1,V.messages=[],V.ids=[],e.state.empty=!0,x()}function j(){e.historyFilter.mediaType?B():e.curDialog.messageID?a.$broadcast("history_focus",{peerString:e.curDialog.peer}):x(!0)}e.$watchCollection("curDialog",f),d.attach(),p.start(),m.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=P,e.selectedDelete=O,e.selectedForward=U,e.selectedReply=R,e.selectedCancel=N,e.selectedFlush=F,e.startBot=E,e.cancelBot=I,e.joinChannel=T,e.togglePeerMuted=D,e.toggleEdit=L,e.toggleMedia=B,e.returnToRecent=j,e.$on("history_edit_toggle",L),e.$on("history_edit_flush",F),e.$on("history_media_toggle",function(e,t){B(t)}),e.$on("history_return_recent",j);var q,H,V=!1,z=!1,W=!1,G=!1,K=0,Y=0,Z=!1,X={photos:"inputMessagesFilterPhotos",video:"inputMessagesFilterVideo",documents:"inputMessagesFilterDocument",audio:"inputMessagesFilterAudio"},J=0,Q=0,et=!1,tt=!1,nt=0,it=!1,at=!1;e.$on("history_update",angular.noop);var ot=!1;e.$on("stateSynchronized",function(){ot&&(ot==e.curDialog.peerID&&x(),ot=!1)}),e.$on("reply_button_press",function(t,n){var i=e.historyState.replyKeyboard;i&&l.sendText(q,n.text,{replyToMsgID:0>q&&i.mid})}),e.$on("history_reload",function(t,n){n==e.curDialog.peerID&&x()}),e.$on("history_forbidden",function(n,i){i==e.curDialog.peerID&&t.url("/im"),y(i)}),e.$on("notify_settings",function(t,n){n.peerID==e.curDialog.peerID&&k()}),e.$on("channel_settings",function(t,n){n.channelID==-e.curDialog.peerID&&k()});var st={};e.$on("history_append",function(t,i){var o=v(i.peerID);if(o){var s=i.peerID==e.curDialog.peerID;if(s){if(e.historyFilter.mediaType||e.historyState.skipped)return void(i.my?j():e.historyState.missedCount++);e.curDialog.messageID&&i.my&&j(),delete e.state.empty}var r=l.wrapForHistory(i.messageID);o.messages.push(r),o.ids.push(i.messageID),l.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:i.my,idleScroll:z&&!r.out&&a.idle.isIDLE}),i.my&&e.historyUnreadAfter&&(delete e.historyUnreadAfter,e.$broadcast("messages_unread_after")),a.idle.isIDLE?!r.unread||r.out||(o.messages[o.messages.length-2]||{}).unread||(e.historyUnreadAfter=r.mid,z=!0,e.$broadcast("messages_unread_after")):n(function(){l.readHistory(e.curDialog.inputPeer)}),w(),k())}}),e.$on("history_multiappend",function(t,i){var o=!1,s=!1,r=a.idle.isIDLE;angular.forEach(i,function(t,i){var a=v(i);if(a){var c=i==e.curDialog.peerID,d=a.messages.length,u=t.length;if(c){if(e.historyFilter.mediaType||e.historyState.skipped)return void(e.historyState.missedCount+=u);delete e.state.empty}if(u>10){if(!c)return void y(i);if(d>10&&(Y=a.messages[d-1].mid,e.historyState.skipped=G=Y>0,G))return ot=i,void e.$broadcast("ui_history_append")}var p,m,h,g=!1,f=!1,m=a.messages[a.messages.length-1],_=!m||!m.unread;for(h=0;u>h;h++)p=t[h],K>p||-1!==a.ids.indexOf(p)||(m=l.wrapForHistory(p),a.messages.push(m),a.ids.push(p),!f&&r&&(m.unread&&!m.out&&_?f=p:_=!m.unread),!g&&m.out&&(g=!0));l.regroupWrappedHistory(a.messages,-u-2)&&(o=!0),c&&(e.historyState.typing.length&&e.historyState.typing.splice(0,e.historyState.typing.length),e.$broadcast("ui_history_append_new",{idleScroll:z&&!g&&r}),r?f&&(e.historyUnreadAfter=f,z=!0,s=!0):n(function(){l.readHistory(e.curDialog.inputPeer)}),w(),k())}}),o&&e.$broadcast("messages_regroup"),s&&e.$broadcast("messages_unread_after")}),e.$on("history_delete",function(t,n){var i=v(n.peerID);if(i){var a,o=[];for(a=0;a0){t=t.replace(/:([a-z0-9\-\+\*_]+?):/gi,function(e,t){var n=EmojiHelper.shortcuts[t];return void 0!==n?EmojiHelper.emojis[n][0]:e});var n=0,i={replyToMsgID:e.draftMessage.replyToMessage&&e.draftMessage.replyToMessage.mid};do!function(e,t,n){setTimeout(function(){c.sendText(e,t,i)},n)}(e.curDialog.peerID,t.substr(0,4096),n),t=t.substr(4096),n+=100;while(t.length)}b(),I==e.curDialog.peer&&(I=!1),g(),e.$broadcast("ui_message_send")}),cancelEvent(n)}function m(){var t=e.curDialog.peerID;return!t||t>0?(safeReplaceObject(e.mentions,{}),void e.$broadcast("mentions_update")):void a.getChatFull(-t).then(function(t){var n=(t.participants||{}).participants||[],i=[],a=SearchIndexManager.createIndex();angular.forEach(n,function(e){var t=s.getUser(e.user_id);t.username&&(i.push(t),SearchIndexManager.indexObject(t.id,s.getUserSearchText(t.id),a))}),safeReplaceObject(e.mentions,{users:i,index:a}),e.$broadcast("mentions_update")})}function h(){var t=e.curDialog.peerID;a.getPeerBots(t).then(function(t){if(!t.length)return safeReplaceObject(e.commands,{}),void e.$broadcast("mentions_update");var n=t.length>1,i=[],a=SearchIndexManager.createIndex(); angular.forEach(t,function(e){var t="";if(n){var o=s.getUser(e.id);o&&o.username&&(t+="@"+o.username)}var r=s.getUserSearchText(e.id);angular.forEach(e.commands,function(n,o){var s="/"+o+t;i.push({botID:e.id,value:s,rDescription:u.wrapRichText(n,{noLinks:!0,noLineBreaks:!0})}),SearchIndexManager.indexObject(s,r+" "+o+" "+n,a)})}),safeReplaceObject(e.commands,{list:i,index:a}),e.$broadcast("mentions_update")})}function g(t){if(m(),h(),v(),k(),I){if(I==e.curDialog.peer)return e.draftMessage.isBroadcast=r.isChannel(e.curDialog.peerID),void e.$broadcast("ui_peer_draft");I=!1}y(),t?i.get("draft"+e.curDialog.peerID).then(function(t){e.draftMessage.text=t||"",e.draftMessage.isBroadcast=r.isChannel(e.curDialog.peerID),e.$broadcast("ui_peer_draft")}):(e.draftMessage.text="",e.$broadcast("ui_peer_draft"))}function f(n,i){if(i&&i._)if("share_url"==i._){var a=i.url,o=i.text||"";I=e.curDialog.peer,t(function(){e.draftMessage.text=a+"\n"+o,e.$broadcast("ui_peer_draft",{customSelection:[a+"\n",o,""]})},1e3)}else"fwd_messages"==i._&&(I=e.curDialog.peer,e.draftMessage.fwdMessages=i.id,e.$broadcast("ui_peer_reply"))}function _(t){e.draftMessage.replyToMessage=c.wrapForDialog(t),e.$broadcast("ui_peer_reply"),E=!1}function v(){var t=e.draftMessage.replyToMessage;t&&e.historyState.replyKeyboard&&e.historyState.replyKeyboard.mid==t.mid&&!e.historyState.replyKeyboard.pFlags.hidden&&(e.historyState.replyKeyboard.pFlags.hidden=!0,e.$broadcast("ui_keyboard_update")),delete e.draftMessage.replyToMessage,e.$broadcast("ui_peer_reply")}function y(){e.draftMessage.fwdMessages&&e.draftMessage.fwdMessages.length&&(delete e.draftMessage.fwdMessages,e.$broadcast("ui_peer_reply"),I==e.curDialog.peer&&(I=!1))}function b(){if(e.draftMessage.fwdMessages&&e.draftMessage.fwdMessages.length){var t=e.draftMessage.fwdMessages.slice();y(),setTimeout(function(){c.forwardMessages(e.curDialog.peerID,t)},0)}}function w(t){return e.draftMessage.text=e.draftMessage.text&&"/"==e.draftMessage.text.charAt(0)?"":"/",e.$broadcast("ui_peer_draft",{focus:!0}),cancelEvent(t)}function k(){var t=e.curDialog.peerID,n=c.getReplyKeyboard(t);n&&(n=c.wrapReplyMarkup(n)),e.historyState.replyKeyboard=n;var i=n&&!n.pFlags.hidden&&("replyKeyboardForceReply"==n._||"replyKeyboardMarkup"==n._&&0>t);i?(_(n.mid),E=!0):E&&v();var a=n&&!n.pFlags.hidden&&"replyKeyboardMarkup"==n._;e.$broadcast("ui_keyboard_update",{enabled:a}),e.$emit("ui_panel_update",{blur:a})}function $(t){var n=e.historyState.replyKeyboard;return n&&(n.pFlags.hidden=!n.pFlags.hidden,k()),cancelEvent(t)}function S(t){if(t&&t.length){e.historyFilter.mediaType||e.historyState.skipped||c.readHistory(e.curDialog.inputPeer);var n={};n["draft"+e.curDialog.peerID]=t,i.set(n)}else i.remove("draft"+e.curDialog.peerID)}function C(){return"inputPeerChannel"==e.curDialog.inputPeer._?!1:void n.invokeApi("messages.setTyping",{peer:e.curDialog.inputPeer,action:{_:"sendMessageTypingAction"}})}function M(t){if(angular.isArray(t)&&t.length){var n={replyToMsgID:e.draftMessage.replyToMessage&&e.draftMessage.replyToMessage.mid,isMedia:e.draftMessage.isMedia};delete e.draftMessage.replyToMessage,t[0].lastModified&&t.sort(function(e,t){return e.lastModified-t.lastModified});for(var i=0;ie?[-1,-2]:[1,2],i=v.indexOf(t.messageID);angular.forEach(n,function(e){var t=v[i+e];if(void 0!==t&&void 0===y[t]){y[t]=!0;var n=o.getMessage(t),s=n.media.photo.id;a.preloadPhoto(s)}})}function u(e){var n=v.indexOf(t.messageID);w?e&&(t.count=Math.max(e,v.length)):t.count=v.length,t.pos=t.count-n,t.nav.hasNext=n>0,t.nav.hasPrev=w||n0}function p(n){var i=v.indexOf(t.messageID),s=i>=0?i+n:0,r=++k,l=s>=v.length?m():e.when();l.then(function(){if(r==k){var e=v[s],i=o.getMessage(e),l=i&&i.media&&(i.media.photo&&i.media.photo.id||i.media.webpage&&i.media.webpage.photo&&i.media.webpage.photo.id);if(!l)return void console.error("Invalid photo message",s,v,e,i);t.messageID=e,t.photoID=l,t.photo=a.wrapForFull(t.photoID),y[t.messageID]=!0,u(),n>0&&w&&v.indexOf(e)+1>=v.length?m():d(n)}})}function m(){return $?$:$=o.getSearch(g,f,_,b).then(function(t){return t.history.length?(b=t.history[t.history.length-1],v=v.concat(t.history),w=v.length=0&&(v=e.history,b=v[v.length-1],u(),d(1)),m()},m);var k=0,$=!1}}]).controller("UserpicModalController",["$q","$scope","$rootScope","$modalInstance","MtpApiManager","AppPhotosManager","AppUsersManager","AppPeersManager","AppMessagesManager","ApiUpdatesManager","PeersSelectService","ErrorService",function(e,t,n,i,a,o,s,r,l,c,d,u){function p(n,i){var a=f.indexOf(t.photoID),s=a>=0?a+n:0,r=++w,l=s>=f.length?h():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;i&&(f.splice(a,1),e=t.count-1),g(e),v[t.photoID]=!0,g(),n>0&&b&&f.indexOf(t.photoID)+1>=f.length?h():m(n)}})}function m(e){var n=0>e?[-1,-2]:[1,2],i=f.indexOf(t.photoID);angular.forEach(n,function(e){var t=f[i+e];void 0!==t&&void 0===v[t]&&(v[t]=!0,o.preloadPhoto(t))})}function h(){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.lengthi?-i:0;c.startBot(e.user.id,a).then(function(){n.$broadcast("history_focus",{peerString:t})})})},e.sendCommand=function(t){c.sendText(e.userID,"/"+t),n.$broadcast("history_focus",{peerString:m})},e.toggleBlock=function(t){s.invokeApi(t?"contacts.block":"contacts.unblock",{id:o.getUserInput(e.userID)}).then(function(){e.blocked=t})},e.shareContact=function(){u.selectPeer({confirm_type:"SHARE_CONTACT_PEER",canSend:!0}).then(function(t){var i=d.getPeerID(t);c.sendOther(i,{_:"inputMediaContact",phone_number:e.user.phone,first_name:e.user.first_name,last_name:e.user.last_name,user_id:e.user.id}),n.$broadcast("history_focus",{peerString:t})})}}]).controller("ChatModalController",["$scope","$timeout","$rootScope","$modal","AppUsersManager","AppChatsManager","AppProfileManager","AppPhotosManager","MtpApiManager","MtpApiFileManager","NotificationsManager","AppMessagesManager","AppPeersManager","ApiUpdatesManager","ContactsSelectService","ErrorService",function(e,t,n,i,a,o,s,r,l,c,d,u,p,m,h,g){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("messages.editChatPhoto",{chat_id:o.getChatInput(e.chatID),photo:{_:"inputChatUploadedPhoto",file:t,crop:{_:"inputPhotoCropAuto"}}}).then(f)})["finally"](function(){e.photo.updating=!1}))}e.chatFull=o.wrapForFull(e.chatID,{}),e.settings={notifications:!0},s.getChatFull(e.chatID).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?!1:void d.getPeerSettings(-e.chatID).then(function(n){n.mute_until=t?0:2e9,d.updatePeerSettings(-e.chatID,n)})})})}),e.leaveGroup=function(){l.invokeApi("messages.deleteChatUser",{chat_id:o.getChatInput(e.chatID),user_id:{_:"inputUserSelf"}}).then(f)},e.returnToGroup=function(){l.invokeApi("messages.addChatUser",{chat_id:o.getChatInput(e.chatID),user_id:{_:"inputUserSelf"}}).then(f)},e.inviteToGroup=function(){var t=[];angular.forEach(e.chatFull.participants.participants,function(e){t.push(e.user_id)}),h.selectContacts({disabled:t}).then(function(t){angular.forEach(t,function(t){l.invokeApi("messages.addChatUser",{chat_id:o.getChatInput(e.chatID),user_id:a.getUserInput(t),fwd_limit:100}).then(function(e){m.processUpdateMessage(e)})}),n.$broadcast("history_focus",{peerString:e.chatFull.peerString})})},e.kickFromGroup=function(t){l.invokeApi("messages.deleteChatUser",{chat_id:o.getChatInput(e.chatID),user_id:a.getUserInput(t)}).then(f)},e.flushHistory=function(){g.confirm({type:"HISTORY_FLUSH"}).then(function(){u.flushHistory(p.getInputPeerByID(-e.chatID)).then(function(){n.$broadcast("history_focus",{peerString:e.chatFull.peerString})})})},e.inviteViaLink=function(){var t=n.$new();t.chatID=e.chatID,i.open({templateUrl:templateUrl("chat_invite_link_modal"),controller:"ChatInviteLinkModalController",scope:t,windowClass:"md_simple_modal_window"})},e.photo={},e.$watch("photo.file",_),e.deletePhoto=function(){e.photo.updating=!0,l.invokeApi("messages.editChatPhoto",{chat_id:o.getChatInput(e.chatID),photo:{_:"inputChatPhotoEmpty"}}).then(f)["finally"](function(){e.photo.updating=!1})},e.editTitle=function(){var t=n.$new();t.chatID=e.chatID,i.open({templateUrl:templateUrl("chat_edit_modal"),controller:"ChatEditModalController",scope:t,windowClass:"md_simple_modal_window mobile_modal"})}}]).controller("ChannelModalController",["$scope","$timeout","$rootScope","$modal","AppUsersManager","AppChatsManager","AppProfileManager","AppPhotosManager","MtpApiManager","MtpApiFileManager","NotificationsManager","AppMessagesManager","AppPeersManager","ApiUpdatesManager","ContactsSelectService","ErrorService",function(e,t,n,i,a,o,s,r,l,c,d,u,p,m,h,g){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,crop:{_:"inputPhotoCropAuto"}}}).then(f)})["finally"](function(){e.photo.updating=!1}))}e.chatFull=o.wrapForFull(e.chatID,{}),e.settings={notifications:!0},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?!1:void d.getPeerSettings(-e.chatID).then(function(n){n.mute_until=t?0:2e9,d.updatePeerSettings(-e.chatID,n)})})})}),e.leaveChannel=function(){l.invokeApi("channels.leaveChannel",{channel:o.getChannelInput(e.chatID)}).then(f)},e.deleteChannel=function(){return g.confirm({type:"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)}),h.selectContacts({disabled:t}).then(function(t){var n=[];angular.forEach(t,function(e){n.push(a.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:a.getUserInput(t),kicked:!0}).then(f)},e.shareLink=function(t){var a=n.$new();return a.chatID=e.chatID,i.open({templateUrl:templateUrl("chat_invite_link_modal"),controller:"ChatInviteLinkModalController",scope:a,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,i.open({templateUrl:templateUrl("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})}}]).controller("SettingsModalController",["$rootScope","$scope","$timeout","$modal","AppUsersManager","AppChatsManager","AppPhotosManager","MtpApiManager","Storage","NotificationsManager","MtpApiFileManager","PasswordManager","ApiUpdatesManager","ChangelogNotifyService","LayoutSwitchService","AppRuntimeManager","ErrorService","_",function(e,t,n,i,a,o,s,r,l,c,d,u,p,m,h,g,f){function _(){n.cancel(y),y=!1,u.getState().then(function(e){t.password=e,"account.noPassword"==e._&&e.email_unconfirmed_pattern&&!b&&(y=n(_,5e3))})}function v(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"},crop:{_:"inputPhotoCropAuto"}}).then(function(e){a.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:a.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=a.getUser(e)}),r.invokeApi("users.getFullUser",{id:{_:"inputUserSelf"}}).then(function(e){a.saveApiUser(e.user),s.savePhoto(e.profile_photo,{user_id:e.user.id})}),t.notify={volume:.5},t.send={},t.$watch("photo.file",v),t.password={_:"account.noPassword"},_();var y=!1,b=!1;t.changePassword=function(n){if(n=n||{},"cancel_email"==n.action)return f.confirm({type:"PASSWORD_ABORT_SETUP"}).then(function(){u.updateSettings(t.password,{email:""}).then(_)});var a=e.$new();a.password=t.password,angular.extend(a,n);var o=i.open({scope:a,templateUrl:templateUrl("password_update_modal"),controller:"PasswordUpdateModalController",windowClass:"md_simple_modal_window mobile_modal"});o.result["finally"](_)},t.showSessions=function(){i.open({templateUrl:templateUrl("sessions_list_modal"),controller:"SessionsListModalController",windowClass:"md_simple_modal_window mobile_modal"})},t.$on("$destroy",function(){n.cancel(y),b=!0}),t.deletePhoto=function(){t.photo.updating=!0,r.invokeApi("photos.updateProfilePhoto",{id:{_:"inputPhotoEmpty"},crop:{_:"inputPhotoCropAuto"}}).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(){i.open({templateUrl:templateUrl("profile_edit_modal"),controller:"ProfileEditModalController",windowClass:"md_simple_modal_window mobile_modal"})},t.changeUsername=function(){i.open({templateUrl:templateUrl("username_edit_modal"),controller:"UsernameEditModalController",windowClass:"md_simple_modal_window mobile_modal"})},t.terminateSessions=function(){f.confirm({type:"TERMINATE_SESSIONS"}).then(function(){r.invokeApi("auth.resetAuthorizations",{})})},l.get("notify_nodesktop","send_ctrlenter","notify_volume","notify_novibrate","notify_nopreview").then(function(i){t.notify.desktop=!i[0],t.send.enter=i[1]?"":"1",t.notify.volume=i[2]!==!1?i[2]>0&&i[2]<=1?i[2]:0:.5,t.notify.canVibrate=c.getVibrateSupport(),t.notify.vibrate=!i[3],t.notify.preview=!i[4],t.notify.volumeOf4=function(){return 1+Math.ceil((t.notify.volume-.1)/.33)},t.toggleSound=function(){t.notify.volume=t.notify.volume?0:.5};var a;t.$watch("notify.volume",function(t,i){t!==i&&(l.set({notify_volume:t}),e.$broadcast("settings_changed"),c.clear(),a&&n.cancel(a),a=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.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(){f.confirm({type:"LOGOUT"}).then(function(){r.logOut().then(function(){location.hash="/login",g.reload()})})},t.switchBackToDesktop=Config.Mobile&&!Config.Navigator.mobile,t.switchToDesktop=function(){h.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,i){e.profile={},e.error={},i.getUserID().then(function(t){e.profile=n.getUser(t)}),e.updateProfile=function(){e.profile.updating=!0,i.invokeApi("account.updateProfile",{first_name:e.profile.first_name||"",last_name:e.profile.last_name||""}).then(function(i){e.error={},n.saveApiUser(i),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,i){e.profile={},e.error={},i.getUserID().then(function(t){e.profile=angular.copy(n.getUser(t))}),e.updateUsername=function(){e.profile.updating=!0,i.invokeApi("account.updateUsername",{username:e.profile.username||""}).then(function(i){e.checked={},n.saveApiUser(i),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 i.invokeApi("account.checkUsername",{username:t||""}).then(function(n){e.profile.username==t&&(e.checked=n?{success:!0}:{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,i,a,o){function s(){n.cancel(r),a.invokeApi("account.getAuthorizations").then(function(t){e.sessionsLoaded=!0,e.authorizations=t.authorizations;for(var i,a=0,o=e.authorizations.length;o>a;a++)i=e.authorizations[a],i.current=1==(1&i.flags);e.authorizations.sort(function(e,t){return e.current?-1:t.current?1:t.date_active-e.date_active}),l||(r=n(s,5e3))})}e.slice={limit:20,limitDelta:20};var r=!1,l=!1;e.terminateSession=function(e){o.confirm({type:"TERMINATE_SESSION"}).then(function(){a.invokeApi("account.resetAuthorization",{hash:e}).then(s)})},e.terminateAllSessions=function(){o.confirm({type:"TERMINATE_SESSIONS"}).then(function(){a.invokeApi("auth.resetAuthorizations",{})})},s(),e.$on("apiUpdate",function(e,t){"updateNewAuthorization"==t._&&s()}),e.$on("$destroy",function(){n.cancel(r),l=!0})}]).controller("PasswordUpdateModalController",["$scope","$q","_","PasswordManager","MtpApiManager","ErrorService","$modalInstance",function(e,t,n,i,a,o,s){switch(e.passwordSettings={},e.updatePassword=function(){delete e.passwordSettings.error_field;var a;if("disable"==e.action)a=t.when();else{if(!e.passwordSettings.new_password)return e.passwordSettings.error_field="new_password",e.$broadcast("new_password_focus"),!1;if(e.passwordSettings.new_password!=e.passwordSettings.confirm_password)return e.passwordSettings.error_field="confirm_password",e.$broadcast("confirm_password_focus"),!1;a=e.passwordSettings.email?t.when():o.confirm({type:"RECOVERY_EMAIL_EMPTY"})}e.passwordSettings.loading=!0,a.then(function(){i.updateSettings(e.password,{cur_password:e.passwordSettings.cur_password||"",new_password:e.passwordSettings.new_password,email:e.passwordSettings.email,hint:e.passwordSettings.hint}).then(function(){delete e.passwordSettings.loading,s.close(!0),"disable"==e.action?o.alert(n("error_modal_password_disabled_title_raw"),n("error_modal_password_disabled_descripion_raw")):o.alert(n("error_modal_password_success_title_raw"),n("error_modal_password_success_descripion_raw"))},function(t){switch(t.type){case"PASSWORD_HASH_INVALID":case"NEW_PASSWORD_BAD":e.passwordSettings.error_field="cur_password",t.handled=!0,e.$broadcast("cur_password_focus");break;case"NEW_PASSWORD_BAD":e.passwordSettings.error_field="new_password",t.handled=!0;break;case"EMAIL_INVALID":e.passwordSettings.error_field="email",t.handled=!0;break;case"EMAIL_UNCONFIRMED":o.alert(n("error_modal_email_unconfirmed_title_raw"),n("error_modal_email_unconfirmed_descripion_raw")),s.close(!0),t.handled=!0}delete e.passwordSettings.loading})})},e.action){case"disable":e.passwordSettings.new_password="";break;case"create":onContentLoaded(function(){e.$broadcast("new_password_focus")})}e.$watch("passwordSettings.new_password",function(t){var n=t&&t.length||0;e.passwordSettings.hint=n?3>=n?"***":t.charAt(0)+new Array(n-1).join("*")+t.charAt(n-1):"",e.$broadcast("value_updated")})}]).controller("PasswordRecoveryModalController",["$scope","$q","_","PasswordManager","MtpApiManager","ErrorService","$modalInstance",function(e,t,n,i,a,o,s){e.checkCode=function(){e.recovery.updating=!0,i.recover(e.recovery.code,e.options).then(function(e){o.alert(n("error_modal_password_disabled_title_raw"),n("error_modal_password_disabled_descripion_raw")),s.close(e)},function(t){switch(delete e.recovery.updating,t.type){case"CODE_EMPTY":case"CODE_INVALID":e.recovery.error_field="code",t.handled=!0;break;case"PASSWORD_EMPTY":case"PASSWORD_RECOVERY_NA":case"PASSWORD_RECOVERY_EXPIRED":s.dismiss(),t.handled=!0}})}}]).controller("ContactsModalController",["$scope","$timeout","$modal","$modalInstance","MtpApiManager","AppUsersManager","ErrorService",function(e,t,n,i,a,o){function s(){e.selectedContacts={},e.selectedCount=0}function r(n){var i=++l,s=[];o.getContacts(n).then(function(t){i==l&&(e.contacts=[],e.slice.limit=20,angular.forEach(t,function(t){var n={userID:t,user:o.getUser(t)}; s.push(t),e.contacts.push(n)}),e.contactsEmpty=n?!1:!e.contacts.length,e.$broadcast("contacts_change"))}),n&&n.length>=5&&t(function(){i==l&&a.invokeApi("contacts.search",{q:n,limit:10}).then(function(t){o.saveApiUsers(t.users),i==l&&angular.forEach(t.results,function(t){var n=t.user_id;-1==s.indexOf(n)&&e.contacts.push({userID:n,user:o.getUser(n),peerString:o.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 l=0;if(s(),e.disabledContacts={},e.disabled)for(var c=0;c0){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)}),o.deleteContacts(t).then(function(){e.toggleEdit(!1)})}},e.importContact=function(){o.openImportContact()}}]).controller("PeerSelectController",["$scope","$modalInstance","$q","AppPeersManager","ErrorService",function(e,t,n,i,a){e.selectedPeers={},e.selectedPeerIDs=[],e.selectedCount=0,e.dialogSelect=function(o){if(!e.multiSelect){var s;if(e.confirm_type){var r=i.getPeerID(o),l=i.getPeer(r);s=a.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=i.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]=i.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(i.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,i,a,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(a.getUserInput(e))}),i.invokeApi("messages.createChat",{title:e.group.name,users:r}).then(function(e){if(s.processUpdateMessage(e),e.updates&&e.updates.length){for(var i,a=0,r=e.updates.length;r>a;a++)if(i=e.updates[a],"updateNewMessage"==i._){n.$broadcast("history_focus",{peerString:o.getChatString(i.message.to_id.chat_id)});break}t.close()}})["finally"](function(){delete e.group.creating})}}}]).controller("ChatEditModalController",["$scope","$modalInstance","$rootScope","MtpApiManager","AppUsersManager","AppChatsManager","ApiUpdatesManager",function(e,t,n,i,a,o,s){var r=o.getChat(e.chatID);e.group={name:r.title},e.updateGroup=function(){if(e.group.name){if(e.group.name==r.title)return t.close();e.group.updating=!0;var a;return a=o.isChannel(e.chatID)?i.invokeApi("channels.editTitle",{channel:o.getChannelInput(e.chatID),title:e.group.name}):i.invokeApi("messages.editChatTitle",{chat_id:o.getChatInput(e.chatID),title:e.group.name}),a.then(function(t){s.processUpdateMessage(t);var i=o.getChatString(e.chatID);n.$broadcast("history_focus",{peerString:i})})["finally"](function(){delete e.group.updating})}}}]).controller("ChannelEditModalController",["$q","$scope","$modalInstance","$rootScope","MtpApiManager","AppUsersManager","AppChatsManager","AppProfileManager","ApiUpdatesManager",function(e,t,n,i,a,o,s,r,l){function c(){return a.invokeApi("channels.editTitle",{channel:s.getChannelInput(t.chatID),title:t.channel.title}).then(function(e){l.processUpdateMessage(e)})}function d(){return a.invokeApi("channels.editAbout",{channel:s.getChannelInput(t.chatID),about:t.channel.about})}var u=s.getChat(t.chatID),p={title:u.title};t.channel={title:u.title},r.getChannelFull(t.chatID).then(function(e){p.about=e.about,t.channel.about=e.about}),t.updateChannel=function(){if(t.channel.title.length){var n=[];return t.channel.title!=p.title&&n.push(c()),t.channel.about!=p.about&&n.push(d()),e.all(n).then(function(){var e=s.getChatString(t.chatID);i.$broadcast("history_focus",{peerString:e})})["finally"](function(){delete t.channel.updating})}}}]).controller("ChatInviteLinkModalController",["_","$scope","$timeout","$modalInstance","AppChatsManager","AppProfileManager","ErrorService",function(e,t,n,i,a,o,s){function r(){n(function(){t.$broadcast("ui_invite_select")},100)}function l(e){var n=a.getChat(t.chatID);return n.username?(t.exportedInvite={link:"https://telegram.me/"+n.username,"short":!0},void r()):(e&&(t.exportedInvite.revoking=!0),void o.getChatInviteLink(t.chatID,e).then(function(e){t.exportedInvite={link:e,canRevoke:!0},r()})["finally"](function(){delete t.exportedInvite.revoking}))}t.exportedInvite={link:e("group_invite_link_loading_raw")};var c=a.isChannel(t.chatID);t.revokeLink=function(){s.confirm({type:c?"REVOKE_CHANNEL_INVITE_LINK":"REVOKE_GROUP_INVITE_LINK"}).then(function(){l(!0)})},l()}]).controller("ImportContactModalController",["$scope","$modalInstance","$rootScope","AppUsersManager","ErrorService","PhonebookContactsService",function(e,t,n,i,a,o){void 0===e.importContact&&(e.importContact={}),e.phonebookAvailable=o.isAvailable(),e.doImport=function(){e.importContact&&e.importContact.phone&&(e.progress={enabled:!0},i.importContact(e.importContact.phone,e.importContact.first_name||"",e.importContact.last_name||"").then(function(e){e||a.show({error:{code:404,type:"USER_NOT_USING_TELEGRAM"}}),t.close(e)})["finally"](function(){delete e.progress.enabled}))},e.importPhonebook=function(){o.openPhonebookImport().result.then(function(e){e?t.close(e[0]):t.dismiss()})}}]).controller("CountrySelectModalController",["$scope","$modalInstance","$rootScope","_",function(e,t,n,i){e.search={},e.slice={limit:20,limitDelta:20};for(var a=SearchIndexManager.createIndex(),o=0;o5184e5?o=n?"mediumDate":"shortDate":a>432e5&&(o=n?"EEEE":"EEE"),t(i,o)}}]).filter("time",["$filter",function(e){var t={},n=e("date"),i=Config.Mobile?"shortTime":"mediumTime";return function(e){return t[e]?t[e]:t[e]=n(1e3*e,i)}}]).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=e%60,n=Math.floor((e-t)/60);return 10>t&&(t="0"+t),n+":"+t}}]).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(1024>e)return e+" b";if(1048576>e)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){var i=n(e.done,!0),a=i.split(" "),o=n(e.total),s=o.split(" ");return s[1]===a[1]?t("format_size_progress_mulitple",{done:a[0],total:s[0],parts:a[1]||""}):t("format_size_progress",{done:i,total:o})}}]).filter("formatShortNumber",[function(){return function(e){if(!e)return"0";if(1e3>e)return e.toString();if(9e5>e){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("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"),i=t.pluralize("relative_time_pluralize_hours_ago"),a=e("dateOrTime");return function(e){var o=1e3*e,s=Math.abs(tsNow()-o);if(6e4>s)return t("relative_time_just_now");if(36e5>s){var r=Math.floor(s/6e4);return n(r)}if(864e5>s){var l=Math.floor(s/36e5);return i(l)}return a(e,!0)}}]),angular.module("myApp.services").service("AppMessagesManager",["$q","$rootScope","$location","$filter","$timeout","$sce","ApiUpdatesManager","AppUsersManager","AppChatsManager","AppPeersManager","AppPhotosManager","AppVideoManager","AppDocsManager","AppStickersManager","AppAudioManager","AppWebPagesManager","MtpApiManager","MtpApiFileManager","RichTextProcessor","NotificationsManager","PeersSelectService","Storage","AppProfileManager","FileManager","TelegramMeWebService","ErrorService","StatusManager","_",function(e,t,n,i,a,o,s,r,l,c,d,u,p,m,h,g,f,_,v,y,b,w,k,$,S,C,M,x){function A(t,n,i){var a=Mt,o=angular.isString(t)&&t.length;if(o){if(!i||Pt.query!==t){Pt.query=t;var s=SearchIndexManager.search(t,Dt);Pt.dialogs=[],angular.forEach(Mt.dialogs,function(e){s[e.peerID]&&Pt.dialogs.push(e)}),Pt.count=Pt.dialogs.length}a=Pt}else Pt.query=!1;var r=0;if(n>0)for(r=0;ra.dialogs[r].index);r++);return i=i||20,o||Kt&&Zt||a.dialogs.length>=r+i&&a.dialogs[r+i-1].index>=Qt?e.when({dialogs:a.dialogs.slice(r,r+i)}):e.all([T(),D(Xt,i)]).then(function(){if(r=0,n>0)for(r=0;ra.dialogs[r].index);r++);return{dialogs:a.dialogs.slice(r,r+i)}})}function E(e){for(var t=0;tr)&&(r=d.date),t.index=P(r),t.peerID=n,N(t),o.mid&&o.mid>t.read_inbox_max_id&&(o.unread=!0),void 0===Ct[n]){var u={count:null,history:[a],pending:[]};Ct[n]=u}y.savePeerSettings(n,t.notify_settings),s.addChannelState(e,t.pts)}function T(){return Yt?Yt:Yt=f.invokeApi("channels.getDialogs",{offset:0,limit:100},{timeout:300}).then(function(e){r.saveApiUsers(e.users),l.saveApiChats(e.chats),J(e.messages),angular.forEach(e.dialogs,function(e){var t=c.getPeerID(e.peer),n=-t;I(n,e),s.addChannelState(n,e.pts)}),Kt=!0})}function D(e,n){return f.invokeApi("messages.getDialogs",{offset:e,limit:n},{timeout:300}).then(function(n){e||S.setAuthorized(!0),n.count&&e>=n.count&&(n.dialogs=[]),r.saveApiUsers(n.users),l.saveApiChats(n.chats),J(n.messages),n.dialogs.length?e||gt(n.dialogs[0].top_message):Zt=!0,angular.forEach(n.dialogs,function(e){var n=c.getPeerID(e.peer),i=c.getPeerSearchText(n);SearchIndexManager.indexObject(n,i,Dt);var a=W(e.top_message);if(e.index=P(a.date),e.peerID=n,N(e),void 0===Ct[n]){var o={count:null,history:[e.top_message],pending:[]};Ct[n]=o,V(o,a)&&t.$broadcast("history_reply_markup",{peerID:n})}if(y.savePeerSettings(n,e.notify_settings),e.unread_count>0&&zt&&e.top_message>zt){var s=16&a.flags?a.from_id:n;a.unread&&!a.out&&y.getPeerMuted(s).then(function(e){e||ft(a)})}})})}function P(e){return void 0===e&&(e=tsNow(!0)+jt),65536*e+(65535&++Jt)}function N(e){var t=Mt.dialogs,n=E(e.peerID)[1],i=e.index,a="dialog"==e._;void 0!==n?t.splice(n,1):a&&(Xt++,Qt>i&&(Qt=i));var o,s=t.length;if(!s||i=t[0].index)t.unshift(e);else for(o=0;s>o;o++)if(i>t[o].index){t.splice(o,0,e);break}}function F(t,n,i,a){var o,d=c.getPeerID(t),u=c.isChannel(d);return o=u?f.invokeApi("channels.getImportantHistory",{channel:l.getChannelInput(-d),offset_id:n?R(n):0,add_offset:a||0,limit:i||0},{timeout:300,noErrorBox:!0}):f.invokeApi("messages.getHistory",{peer:t,offset_id:n?R(n):0,add_offset:a||0,limit:i||0},{timeout:300,noErrorBox:!0}),o.then(function(e){return r.saveApiUsers(e.users),l.saveApiChats(e.chats),J(e.messages),u&&s.addChannelState(-d,e.pts),0>d||!r.isBot(d)||e.messages.length==i&&i=e)return e;e=R(e);var n=en[t];return n||(n=++nn*an,tn[n]=t,en[t]=n),n+e}function U(e){if(an>e)return[e,0];var t=e%an,n=tn[e-t];return[t,n]}function R(e){return e?e%an:0}function L(e){var t,n,i,a,o={},s={};for(t=0;t0)for(s=0;sa.history[s]);s++);return a.history.splice(s,a.history.length-s),angular.forEach(o.messages,function(n){V(a,n)&&t.$broadcast("history_reply_markup",{peerID:c.getPeerID(e)}),a.history.push(n.mid)}),i-=o.messages.length,i>0&&a.history.length=0;a--)if(o=kt[n.history[a]],o&&!o.out&&o.unread){n.unreadOffset=a+1;break}}return e.when(n)}function q(e,t,n,i,a){var o=c.getPeerID(e),s=Ct[o],r=0,l=!1,d=!1,u=!1;if(a=a?Math.min(50,a):0,void 0===s&&(s=Ct[o]={count:null,history:[],pending:[]}),!n&&!t){var p=E(o)[0];if(p&&p.unread_count>1){var m=p.unread_count;(u=m>50)?p.read_inbox_max_id?(t=p.read_inbox_max_id,i=16,d=16,n=4):(n=20,d=16,r=m-d):(n=Math.max(10,a,m+2),d=m)}else Config.Mobile&&(n=20)}if(t>0)for(l=!0,r=0;rs.history[r]){l=!1;break}if(!l&&(null!==s.count&&s.history.length==s.count||s.history.length>=r+(n||1))){i?(i=Math.min(r,i),r=Math.max(0,r-i),n+=i):n=n||(r?20:a||5);var h=s.history.slice(r,r+n);return!t&&s.pending.length&&(h=s.pending.slice().concat(h)),j(o,{count:s.count,history:h,unreadOffset:d,unreadSkip:u})}return i||n||(n=a||20),l&&(r=0),i||u||t&&-1==s.history.indexOf(t)?(i&&(r=-i,n+=i),F(e,t,n,r).then(function(e){s.count=e.count||e.messages.length;var n=[];return angular.forEach(e.messages,function(e){n.push(e.mid)}),!t&&s.pending.length&&(n=s.pending.slice().concat(n)),j(o,{count:s.count,history:n,unreadOffset:d,unreadSkip:u})})):B(e,t,n,s).then(function(){if(r=0,t>0)for(r=0;rs.history[r]);r++);var e=s.history.slice(r,r+n);return!t&&s.pending.length&&(e=s.pending.slice().concat(e)),j(o,{count:s.count,history:e,unreadOffset:d,unreadSkip:u})})}function H(e){return(Ct[e]||{}).reply_markup||!1}function V(e,t){if(!t.reply_markup&&!t.out&&!t.action)return!1;var n=t.reply_markup,i=e.reply_markup;if(n)return i&&i.mid>=t.mid?!1:!n.pFlags.selective||16&t.flags?(e.maxOutID&&t.midi.mid||t.mid<0)&&t.message)return i.pFlags.hidden=!0,!0}else(!e.maxOutID||t.mid>e.maxOutID)&&(e.maxOutID=t.mid);return t.action&&"messageActionChatDeleteUser"==t.action._&&(i?t.action.user_id==i.fromID:r.isBot(t.action.user_id))?(e.reply_markup={_:"replyKeyboardHide",mid:t.mid,flags:0,pFlags:{}},!0):!1}function z(t,n,i,a,o){var s=[],d=!n,u=c.getPeerID(t),p={peer:u,filter:i},m=d&&angular.equals(Nt,p);if(d&&!m&&(Nt=p,Ft=[]),!a&&!n){var h=Ct[u];if(void 0!==h&&h.history.length){var g,_,v={},y=o||20;switch(i._){case"inputMessagesFilterPhotos":v.messageMediaPhoto=!0;break;case"inputMessagesFilterVideo":v.messageMediaVideo=!0;break;case"inputMessagesFilterPhotoVideo":v.messageMediaPhoto=!0,v.messageMediaVideo=!0;break;case"inputMessagesFilterDocument":v.messageMediaDocument=!0;break;case"inputMessagesFilterAudio":v.messageMediaAudio=!0}for(g=0;g=y)));g++);}if(s.length=y));g++);}return s.length||1e3==o?(d&&(Ft=listMergeSorted(Ft,s)),e.when({count:null,history:s})):f.invokeApi("messages.search",{flags:0,peer:t,q:n||"",filter:i||{_:"inputMessagesFilterEmpty"},min_date:0,max_date:0,limit:o||20,max_id:a||0},{timeout:300,noErrorBox:!0}).then(function(e){r.saveApiUsers(e.users),l.saveApiChats(e.chats),J(e.messages);var t=e.count||e.messages.length;return s=[],angular.forEach(e.messages,function(e){s.push(e.mid)}),d&&(Ft=listMergeSorted(Ft,s)),{count:t,history:s}},function(t){return 400==t.code&&(t.handled=!0),e.reject(t)})}function W(e){return kt[e]||{deleted:!0}}function G(t){var n=L(t),i=[];return angular.forEach(n.msgIDs,function(e,t){var a;if(t>0){var o=l.getChat(t);if(!o.pFlags.creator){var r=[];if(o.pFlags.editor&&angular.forEach(e,function(e,i){var a=W(n.mids[t][i]);a.out&&r.push(e)}),!r.length)return;e=r}a=f.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 a=f.invokeApi("messages.deleteMessages",{id:e}).then(function(t){s.processUpdateMessage({_:"updateShort",update:{_:"updateDeleteMessages",messages:e,pts:t.pts,pts_count:t.pts_count}})});i.push(a)}),e.all(i)}function K(t,n,i){return s.processUpdateMessage({_:"updateShort",update:{_:"updatePts",pts:n.pts,pts_count:n.pts_count}}),n.offset?f.invokeApi(i,{peer:t,offset:n.offset,max_id:0}).then(function(e){return K(t,e,i)}):e.when()}function Y(e){var n=c.getPeerID(e),i=c.isChannel(n),a=Ct[n],o=E(n)[0];if(!o||!o.unread_count){if(!a||!a.history.length)return!1;var s,r,d=!1;for(p=a.history.length;p>=0;p--)if(s=a.history[p],r=kt[s],r&&!r.out&&r.unread){d=!0;break}if(!d)return!1}if(a.readPromise)return a.readPromise;var u;if(u=i?f.invokeApi("channels.readHistory",{channel:l.getChannelInput(-n),max_id:0}):f.invokeApi("messages.readHistory",{peer:e,offset:0,max_id:0}).then(function(t){return K(e,t,"messages.readHistory")}),a.readPromise=u.then(function(){o&&(o.unread_count=0,t.$broadcast("dialog_unread",{peerID:n,count:0}),t.$broadcast("messages_read"),a&&a.history.length&&(o.read_inbox_max_id=a.history[0]))})["finally"](function(){delete a.readPromise}),a&&a.history.length){var s,r,p,n,o;for(p=0;po.read_inbox_max_id:!0}else e.unread=1&e.flags?!0:!1;e.reply_to_msg_id&&(e.reply_to_mid=O(e.reply_to_msg_id,i)),e.date-=jt,e.toID=t,e.fromID=e.from_id||t,e.fwd_from_id&&(e.fwdFromID=c.getPeerID(e.fwd_from_id));var s={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,s);break;case"messageMediaVideo":u.saveVideo(e.media.video,s);break;case"messageMediaDocument":p.saveDoc(e.media.document,s);break;case"messageMediaAudio":h.saveAudio(e.media.audio);break;case"messageMediaWebPage":g.saveWebPage(e.media.webpage,e.mid,s)}if(e.action&&("messageActionChatEditPhoto"==e.action._?(d.savePhoto(e.action.photo,s),n&&(e.action._="messageActionChannelEditPhoto")):n&&("messageActionChatEditTitle"==e.action._&&(e.action._="messageActionChannelEditTitle"),"messageActionChatDeletePhoto"==e.action._&&(e.action._="messageActionChannelDeletePhoto"))),e.reply_markup&&(e.reply_markup.pFlags={resize:(1&e.reply_markup.flags)>0,one_time:(2&e.reply_markup.flags)>0,selective:(4&e.reply_markup.flags)>0}),e.message&&e.message.length){var r=v.parseEntities(e.message),l=e.entities||[];e.totalEntities=v.mergeEntities(r,l,!e.pending)}}})}function Q(e,n,i){if(angular.isString(n)&&n.length){i=i||{};var a,o=Tt--,l=[nextRandomInt(4294967295),nextRandomInt(4294967295)],d=bigint(l[0]).shiftLeft(32).add(bigint(l[1])).toString(),u=Ct[e],p=c.getInputPeerByID(e),m=0,h=i.replyToMsgID,g=c.isChannel(e),_=g?!0:!1,y=[];n=v.parseMarkdown(n,y),void 0===u&&(u=Ct[e]={count:null,history:[],pending:[]});var b=r.getSelf().id;e!=b&&(m|=2,g||r.isBot(e)||(m|=1)),h&&(m|=8),_?b=0:m|=256,a={_:"message",id:o,from_id:b,to_id:c.getOutputPeer(e),flags:m,date:tsNow(!0)+jt,message:n,random_id:d,reply_to_msg_id:h,entities:y,views:_&&1,pending:!0};var w=function(e){var n=$t[o];e?(a.error=!0,n&&(n.error=!0)):(delete a.error,n&&delete n.error),t.$broadcast("messages_pending")};a.send=function(){w(!1);var t={};Et[e]&&(t.afterMessageID=Et[e].messageID);var i=0;h&&(i|=1),y.length&&(i|=8),_&&(i|=16),f.invokeApi("messages.sendMessage",{flags:i,peer:p,message:n,random_id:l,reply_to_msg_id:R(h),entities:y},t).then(function(e){"updateShortSentMessage"==e._&&(a.flags=e.flags,a.date=e.date,a.id=e.id,a.media=e.media,a.entities=e.entities,e={_:"updates",users:[],chats:[],seq:0,updates:[{_:"updateMessageID",random_id:d,id:e.id},{_:g?"updateNewChannelMessage":"updateNewMessage",message:a,pts:e.pts,pts_count:e.pts_count}]}),s.processUpdateMessage(e)},function(){w(!0)})["finally"](function(){Et[e]===t&&delete Et[e]}),Et[e]=t},J([a]),u.pending.unshift(o),t.$broadcast("history_append",{peerID:e,messageID:o,my:!0}),a.send(),xt[d]=[e,o]}}function et(n,i,a){a=a||{};var o,l,d=Tt--,u=[nextRandomInt(4294967295),nextRandomInt(4294967295)],p=bigint(u[0]).shiftLeft(32).add(bigint(u[1])).toString(),m=Ct[n],h=c.getInputPeerByID(n),g=0,v=a.replyToMsgID,y=c.isChannel(n),b=y?!0:!1;a.isMedia?["image/jpeg","image/png","image/bmp"].indexOf(i.type)>=0?(o="photo",l="photo."+i.type.split("/")[1]):"audio/"==i.type.substr(0,6)||["video/ogg"].indexOf(i.type)>=0?(o="audio",l="audio."+("ogg"==i.type.split("/")[1]?"ogg":"mp3")):"video/"==i.type.substr(0,6)?(o="video",l="video.mp4"):(o="document",l="document."+i.type.split("/")[1]):(o="document",l="document."+i.type.split("/")[1]),void 0===m&&(m=Ct[n]={count:null,history:[],pending:[]});var w=r.getSelf().id;n!=w&&(g|=2,y||r.isBot(n)||(g|=1)),v&&(g|=8),b?w=0:g|=256;var k,$={_:"messageMediaPending",type:o,file_name:i.name||l,size:i.size,progress:{percent:1,total:i.size}},S={_:"message",id:d,from_id:w,to_id:c.getOutputPeer(n),flags:g,date:tsNow(!0)+jt,message:"",media:$,random_id:p,reply_to_msg_id:v,views:b&&1,pending:!0},C=function(e){var n=$t[d];e?(S.error=!0,n&&(n.error=!0)):(delete S.error,n&&delete n.error),t.$broadcast("messages_pending")},M=!1;S.send=function(){var a=e.defer();It.then(function(){(!M||S.error)&&(M=!1,k=_.uploadFile(i)),k.then(function(e){e.name=l,M=!0;var t;switch(o){case"photo":t={_:"inputMediaUploadedPhoto",file:e};break;case"video":t={_:"inputMediaUploadedVideo",file:e,duration:0,w:0,h:0,mime_type:i.type};break;case"audio":t={_:"inputMediaUploadedAudio",file:e,duration:0,mime_type:i.type};break;case"document":default:t={_:"inputMediaUploadedDocument",file:e,mime_type:i.type,attributes:[{_:"documentAttributeFilename",file_name:i.name}]}}var n=0;v&&(n|=1),b&&(n|=16),f.invokeApi("messages.sendMedia",{flags:n,peer:h,media:t,random_id:u,reply_to_msg_id:R(v)}).then(function(e){s.processUpdateMessage(e)},function(e){return"photo"==o&&400==e.code&&"PHOTO_INVALID_DIMENSIONS"==e.type?(e.handled=!0,o="document",void S.send()):void C(!0)})},function(){C(!0)},function(e){$.progress.done=e.done,$.progress.percent=Math.max(1,Math.floor(100*e.done/e.total)),t.$broadcast("history_update",{peerID:n})}),$.progress.cancel=function(){M||(a.resolve(),k.cancel(),at(p))},k["finally"](function(){a.resolve()})}),It=a.promise},J([S]),m.pending.unshift(d),t.$broadcast("history_append",{peerID:n,messageID:d,my:!0}),S.send(),xt[p]=[n,d]}function tt(e,n,i){i=i||{};var a=Tt--,o=[nextRandomInt(4294967295),nextRandomInt(4294967295)],l=bigint(o[0]).shiftLeft(32).add(bigint(o[1])).toString(),u=Ct[e],h=c.getInputPeerByID(e),g=i.replyToMsgID,_=c.isChannel(e),v=_?!0:!1;void 0===u&&(u=Ct[e]={count:null,history:[],pending:[]});var y,b=r.getSelf().id;switch(n._){case"inputMediaContact":y=angular.extend({},n,{_:"messageMediaContact"});break;case"inputMediaPhoto":y={_:"messageMediaPhoto",photo:d.getPhoto(n.id.id)};break;case"inputMediaDocument":var w=p.getDoc(n.id.id);w.sticker&&w.stickerSetInput&&m.pushPopularSticker(w.id),y={_:"messageMediaDocument",document:w}}var k=0;e!=b&&(k|=2,r.isBot(e)||(k|=1)),g&&(k|=8),v?b=0:k|=256;var $={_:"message",id:a,from_id:b,to_id:c.getOutputPeer(e),flags:k,date:tsNow(!0)+jt,message:"",media:y,random_id:l,reply_to_msg_id:g,views:v&&1,pending:!0},S=function(e){var n=$t[a];e?($.error=!0,n&&(n.error=!0)):(delete $.error,n&&delete n.error),t.$broadcast("messages_pending")};$.send=function(){var t=0;g&&(t|=1),v&&(t|=16);var i={};Et[e]&&(i.afterMessageID=Et[e].messageID),f.invokeApi("messages.sendMedia",{flags:t,peer:h,media:n,random_id:o,reply_to_msg_id:R(g)},i).then(function(e){s.processUpdateMessage(e)},function(){S(!0)})["finally"](function(){Et[e]===i&&delete Et[e]}),Et[e]=i},J([$]),u.pending.unshift(a),t.$broadcast("history_append",{peerID:e,messageID:a,my:!0}),$.send(),xt[l]=[e,a]}function nt(e,t){t=t.sort();var n,i=0,a=[],o=[],r=t.length,l=U(t[0])[1],d=c.isChannel(e),u=d?!0:!1;for(u&&(i|=16),n=0;r>n;n++)a.push(R(t[n])),o.push([nextRandomInt(4294967295),nextRandomInt(4294967295)]);var p={};return Et[e]&&(p.afterMessageID=Et[e].messageID),f.invokeApi("messages.forwardMessages",{flags:i,from_peer:c.getInputPeerByID(-l),id:a,random_id:o,to_peer:c.getInputPeerByID(e)},p).then(function(e){s.processUpdateMessage(e)})["finally"](function(){Et[e]===p&&delete Et[e]})}function it(e,t,n){if(n){var i=bigint(nextRandomInt(4294967295)).shiftLeft(32).add(bigint(nextRandomInt(4294967295))).toString();return f.invokeApi("messages.startBot",{bot:r.getUserInput(e),chat_id:l.getChatInput(t),random_id:i,start_param:n})}{var a=t?-t:e;c.getInputPeerByID(a)}return t?f.invokeApi("messages.addChatUser",{chat_id:l.getChatInput(t),user_id:r.getUserInput(e)}).then(function(e){s.processUpdateMessage(e)},function(n){if(n&&"USER_ALREADY_PARTICIPANT"==n.type){var i=r.getUser(e);Q(-t,"/start@"+i.username),n.handled=!0}}):Q(e,"/start")}function at(e){var t=xt[e];if(console.log("pending",e,t),t){var n=t[0],i=t[1],a=Ct[n],o=a.pending.indexOf(i);return s.processUpdateMessage({_:"updateShort",update:{_:"updateDeleteMessages",messages:[i]}}),-1!=o&&a.pending.splice(o,1),delete $t[i],delete kt[i],!0}return!1}function ot(e,n){var i=xt[e];if(i){var a,o,s=i[0],r=i[1],l=Ct[s],c=l.pending.indexOf(r); -return-1!=c&&l.pending.splice(c,1),(a=kt[r])&&(delete a.pending,delete a.error,delete a.random_id,delete a.send),(o=$t[r])&&($t[n.mid]=angular.extend(o,ct(n.mid)),delete o.pending,delete o.error,delete o.random_id,delete o.send,t.$broadcast("messages_pending")),delete $t[r],delete kt[r],a}return!1}function st(e){return f.invokeApi("messages.checkChatInvite",{hash:e}).then(function(n){var i;if("chatInviteAlready"==n._){if(l.saveApiChat(n.chat),!n.chat.pFlags.left)return t.$broadcast("history_focus",{peerString:l.getChatString(n.chat.id)});i=n.chat.title}else i=n.title;C.confirm({type:1&n.flags?"JOIN_CHANNEL_BY_LINK":"JOIN_GROUP_BY_LINK",title:i}).then(function(){return f.invokeApi("messages.importChatInvite",{hash:e}).then(function(e){if(s.processUpdateMessage(e),e.chats&&1==e.chats.length)t.$broadcast("history_focus",{peerString:l.getChatString(e.chats[0].id)});else if(e.updates&&e.updates.length)for(var n,i=0,a=e.updates.length;a>i;i++)if(n=e.updates[i],"updateNewMessage"==n._){t.$broadcast("history_focus",{peerString:l.getChatString(n.message.to_id.chat_id)});break}})})})}function rt(e){var t=e.to_id&&c.getPeerID(e.to_id)||0;return 0>t?t:e.out||2&e.flags?t:e.from_id}function lt(e,t){var n=e&&void 0!==t,i=t&&t.unread_count;if(n&&void 0!==St[e])return delete St[e].typing,St[e];var a=angular.copy(kt[e]);if(!a||!a.to_id){if(!t||!t.peerID)return a;a={_:"message",to_id:c.getOutputPeer(t.peerID),deleted:!0,date:tsNow(!0)},a.deleted=!0}return a.peerID=rt(a),a.peerData=c.getPeer(a.peerID),a.peerString=c.getPeerString(a.peerID),a.unreadCount=i,"messageService"==a._&&a.action.user_id&&(a.action.user=r.getUser(a.action.user_id)),a.message&&a.message.length&&(a.richMessage=v.wrapRichText(a.message.substr(0,64),{noLinks:!0,noLinebreaks:!0})),a.dateText=Wt(a.date),n&&(St[e]=a),a}function ct(e){if(void 0!==$t[e])return $t[e];var t=angular.copy(kt[e])||{id:e};t.media&&void 0!==t.media.progress&&(t.media.progress=kt[e].media.progress);var n=t.from_id&&r.getUser(t.from_id),i=n&&n.pFlags.bot&&n.username||!1,a=i||t.to_id&&(t.to_id.chat_id||t.to_id.user_id&&r.isBot(t.to_id.user_id));if(t.media)switch(t.media.caption&&t.media.caption.length&&(t.media.rCaption=v.wrapRichText(t.media.caption,{noCommands:!a,fromBot:i})),t.media._){case"messageMediaPhoto":t.media.photo=d.wrapForHistory(t.media.photo.id);break;case"messageMediaVideo":t.media.video=u.wrapForHistory(t.media.video.id);break;case"messageMediaDocument":t.media.document=p.wrapForHistory(t.media.document.id);break;case"messageMediaAudio":t.media.audio=h.wrapForHistory(t.media.audio.id);break;case"messageMediaGeo":var s="https://maps.google.com/?q="+t.media.geo.lat+","+t.media.geo["long"];t.media.mapUrl=o.trustAsResourceUrl(s);break;case"messageMediaVenue":var s;s="foursquare"==t.media.provider&&t.media.venue_id?"https://foursquare.com/v/"+encodeURIComponent(t.media.venue_id):"https://maps.google.com/?q="+t.media.geo.lat+","+t.media.geo["long"],t.media.mapUrl=o.trustAsResourceUrl(s);break;case"messageMediaContact":t.media.rFullName=v.wrapRichText(t.media.first_name+" "+(t.media.last_name||""),{noLinks:!0,noLinebreaks:!0});break;case"messageMediaWebPage":if(!t.media.webpage||"webPageEmpty"==t.media.webpage._||Config.Mobile){delete t.media;break}t.media.webpage=g.wrapForHistory(t.media.webpage.id)}else if(t.action)switch(t.action._){case"messageActionChatEditPhoto":case"messageActionChannelEditPhoto":t.action.photo=d.wrapForHistory(t.action.photo.id);break;case"messageActionChatCreate":case"messageActionChatEditTitle":case"messageActionChannelCreate":case"messageActionChannelEditTitle":t.action.rTitle=v.wrapRichText(t.action.title,{noLinks:!0,noLinebreaks:!0})||x("chat_title_deleted");break;case"messageActionBotIntro":t.action.rDescription=v.wrapRichText(t.action.description,{noCommands:!a,fromBot:i})}var l=t.reply_to_mid;return l&&(kt[l]?t.reply_to_msg=lt(l):(t.reply_to_msg={mid:l,loading:!0},-1==Ot.indexOf(l)&&(Ot.push(l),Ut===!1&&(Ut=setTimeout(ut,100))))),$t[e]=t}function dt(e){if(!e||"replyKeyboardHide"==e._)return!1;if(e.wrapped)return e;var t=e.rows&&e.rows.length||0;return t>0&&4>=t&&!e.pFlags.resize&&(e.splitCount=t),e.wrapped=!0,angular.forEach(e.rows,function(e){angular.forEach(e.buttons,function(e){e.rText=v.wrapRichText(e.text,{noLinks:!0,noLinebreaks:!0})})}),nextRandomInt(1)&&(e.rows=e.rows.slice(0,2)),e}function ut(){if(Ut!==!1&&(clearTimeout(Ut),Ut=!1),Ot.length){var e=Ot.slice();Ot=[];var n=L(e);angular.forEach(n.msgIDs,function(e,i){var a;a=i>0?f.invokeApi("channels.getMessages",{channel:l.getChannelInput(i),id:e}):f.invokeApi("messages.getMessages",{id:e}),a.then(function(e){r.saveApiUsers(e.users),l.saveApiChats(e.chats),J(e.messages),t.$broadcast("messages_downloaded",n.mids[i])})})}}function pt(){if(Bt!==!1&&(clearTimeout(Bt),Bt=!1),Lt.length){var e=Lt.slice();Lt=[];var t=L(e);angular.forEach(t.msgIDs,function(e,n){f.invokeApi("messages.getMessagesViews",{peer:c.getInputPeerByID(-n),id:e,increment:!0}).then(function(e){if(n){for(var i=t.mids[n],a=[],o=0;o0?u=Math.min(t,d):0>t&&(c=Math.max(0,u+t)),n=c;u>n;n++){if(o=e[n],i=Math.floor((o.date+wt)/86400),l=s&&s.grouped,r=o.grouped,i===a?o.needDate&&(delete o.needDate,p=!0):(!n||s)&&(o.needDate||(o.needDate=!0,p=!0)),o.fwdFromID&&o.media&&o.media.document&&(o.media.document.sticker||o.media.document.audioTitle)&&(o.fromID!=(s||{}).fromID||!(s||{}).fwdFromID)&&(delete o.fwdFromID,o._="message"),o.views&&!Rt[o.mid]&&(Rt[o.mid]=!0,Lt.push(o.mid),Bt===!1&&(Bt=setTimeout(pt,1e4))),s&&o.fromID==s.fromID&&!s.fwdFromID==!o.fwdFromID&&!s.action&&!o.action&&o.datezt&&w.set({max_seen_msg:e})}function ft(e,n){n=n||{};var i,a,o=rt(e),s={},c=!1,d=y.getNotifySettings();if(e.fwdFromID&&n.fwd_count)c=Gt(n.fwd_count);else if(e.message)c=d.nopreview?x("conversation_message_sent"):v.wrapPlainText(e.message);else if(e.media)switch(e.media._){case"messageMediaPhoto":c=x("conversation_media_photo_raw");break;case"messageMediaVideo":c=x("conversation_media_video_raw");break;case"messageMediaDocument":if(e.media.document.sticker){c=x("conversation_media_sticker");var u=e.media.document.stickerEmojiRaw;void 0!==u&&(c=v.wrapPlainText(u)+" ("+c+")")}else c=e.media.document.file_name||x("conversation_media_document_raw");break;case"messageMediaAudio":c=x("conversation_media_audio_raw");break;case"messageMediaGeo":case"messageMediaVenue":c=x("conversation_media_location_raw");break;case"messageMediaContact":c=x("conversation_media_contact_raw");break;default:c=x("conversation_media_attachment_raw")}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":c=x(e.action.user_id==e.from_id?"conversation_returned_to_group":"conversation_invited_user_message_raw");break;case"messageActionChatDeleteUser":c=x(e.action.user_id==e.from_id?"conversation_left_group":"conversation_kicked_user_message_raw");break;case"messageActionChatJoinedByLink":c=x("conversation_joined_by_link");break;case"messageActionChannelCreate":c=x("conversation_created_channel");break;case"messageActionChannelEditTitle":c=x("conversation_changed_channel_name");break;case"messageActionChannelEditPhoto":c=x("conversation_changed_channel_photo");break;case"messageActionChannelDeletePhoto":c=x("conversation_removed_channel_photo")}if(o>0){var p=r.getUser(e.from_id),m=r.getUserPhoto(e.from_id);s.title=(p.first_name||"")+(p.first_name&&p.last_name?" ":"")+(p.last_name||""),s.title||(s.title=p.phone||x("conversation_unknown_user_raw")),a=m,i=r.getUserString(o)}else{if(s.title=l.getChat(-o).title||x("conversation_unknown_chat_raw"),e.from_id>0){var p=r.getUser(e.from_id);s.title=(p.first_name||p.last_name||x("conversation_unknown_user_raw"))+" @ "+s.title}a=l.getChatPhoto(-o),i=l.getChatString(-o)}s.title=v.wrapPlainText(s.title),s.onclick=function(){t.$broadcast("history_focus",{peerString:i,messageID:16&e.flags?e.mid:0})},s.message=c,s.image=a.placeholder,s.key="msg"+e.mid,s.tag=i,a.location&&!a.location.empty?_.downloadSmallFile(a.location,a.size).then(function(t){s.image=$.getUrl(t,"image/jpeg"),e.unread&&y.notify(s)}):y.notify(s)}function _t(){a.cancel(on),on=!1,t.$broadcast("history_multiappend",sn),sn={}}function vt(){a.cancel(rn),rn=!1,angular.forEach(ln,function(e){N(e)}),t.$broadcast("dialogs_multiupdate",ln),ln={}}function yt(){a.cancel(cn),cn=!1;var e=t.idle.isIDLE&&M.isOtherDeviceActive()?3e4:1e3;angular.forEach(dn,function(t){t.isMutedPromise.then(function(n){var i=t.top_message;!n&&i.unread&&setTimeout(function(){i.unread&&ft(i,{fwd_count:t.fwd_count})},e)})}),dn={}}function bt(n){var i=-n,a=c.getInputPeerByID(i);return e.all([k.getChannelFull(n,!0),q(a,0)]).then(function(e){var a=e[0],o=e[1],s=o.history[0],r={_:"dialogChannel",peer:c.getOutputPeer(i),top_message:s,top_important_message:s,read_inbox_max_id:a.read_inbox_max_id,unread_count:a.unread_count,unread_important_count:a.unread_important_count,notify_settings:a.notify_settings};I(n,r);var l={};l[i]=r,t.$broadcast("dialogs_multiupdate",l)})}var wt,kt={},$t={},St={},Ct={},Mt={count:null,dialogs:[]},xt={},At={},Et={},It=e.when(),Tt=-1,Dt=SearchIndexManager.createIndex(),Pt={query:!1},Nt={},Ft=[],Ot=[],Ut=!1,Rt={},Lt=[],Bt=!1,jt=0,qt=tsNow(!0),Ht=qt-qt%86400,Vt=new Date;w.get("server_time_offset").then(function(e){e&&(jt=e)});var zt=!1;Config.Modes.packed&&w.get("max_seen_msg").then(function(e){zt=e||0});var Wt=i("dateOrTime"),Gt=x.pluralize("conversation_forwarded_X_messages");Vt.setHours(0),Vt.setMinutes(0),Vt.setSeconds(0),wt=Ht-Math.floor(+Vt/1e3),y.start();var Kt=!1,Yt=!1,Zt=!1,Xt=0,Jt=0,Qt=Math.pow(2,50),en={},tn={},nn=0,an=4294967296;window.navigator.mozSetMessageHandler&&window.navigator.mozSetMessageHandler("activity",function(e){var n=e.source;console.log(dT(),"Received activity",n.name,n.data),"share"===n.name&&n.data.blobs.length>0&&b.selectPeers({confirm_type:"EXT_SHARE_PEER"}).then(function(e){angular.forEach(e,function(e){var t=c.getPeerID(e);angular.forEach(n.data.blobs,function(e){et(t,e,{isMedia:!0})})}),1==e.length&&t.$broadcast("history_focus",{peerString:e[0]})})});var on=!1,sn={},rn=!1,ln={},cn=!1,dn={};return t.$on("apiUpdate",function(e,n){switch(n._){case"updateMessageID":var i=n.random_id,o=xt[i];if(o){var s=o[0],d=c.isChannel(s)?-s:0;At[O(n.id,d)]=i}break;case"updateNewMessage":case"updateNewChannelMessage":var u=n.message,s=rt(u),p=Ct[s];if("updateNewChannelMessage"==n._&&!(16&u.flags||2&u.flags||0==(256&u.flags)))break;if(J([u]),void 0!==p){var m=p.history;if(-1!=m.indexOf(u.mid))return!1;var h=m[0];m.unshift(u.mid),u.mid>0&&u.mid0&&S&&r.forceUserOnline(s),$=0;x>$;$++)if(k=m[$],!(k>C)&&(u=kt[k],u.out==S)){if(!u.unread)break;u&&u.unread&&(u.unread=!1,$t[k]&&($t[k].unread=!1,A||(A=!0)),St[k]&&(St[k].unread=!1),u.out||(_&&(M=--_[0].unread_count),y.cancel("msg"+k)))}M!==!1&&t.$broadcast("dialog_unread",{peerID:s,count:M}),A&&t.$broadcast("messages_read");break;case"updateReadMessagesContents":var $,k,u,I,T=n.messages,D=T.length;for($=0;D>$;$++)k=T[$],(u=kt[k])&&delete u.media_unread,(I=$t[k])&&delete I.media_unread;break;case"updateDeleteMessages":case"updateDeleteChannelMessages":var k,u,$,s,_,m,N={},d=n.channel_id;for($=0;$0&&(a.count-=e.count,a.count<0&&(a.count=0));for(var r=0;r0,L="channel"==F._&&(F.username||!F.pFlags.left&&!F.pFlags.kicked)&&!0||!1,B=void 0!==Ct[s];L!=B&&(delete Ct[s],t.$broadcast("history_forbidden",s)),R!=U&&(U?bt(d):_[0]&&(Mt.dialogs.splice(_[1],1),t.$broadcast("dialog_drop",{peerID:s})));break;case"updateChannelReload":var d=n.channel_id,s=-d,_=E(s);_[0]&&Mt.dialogs.splice(_[1],1),delete Ct[s],bt(d).then(function(){t.$broadcast("history_reload",s)});break;case"updateChannelMessageViews":var j=n.views,q=O(n.id,n.channel_id),u=W(q);u&&u.views&&u.views\n \n \n \n
\n
\n \n \n
\n \n \n \n \n \n \n \n \n \n
\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/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.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'),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'),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'),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\n \n\n \n
\n
\n\n
\n
\n'),e.put("partials/desktop/dialog_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'),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 {0}\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 \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
\n
\n
\n
\n\n
\n
GIF
\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/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 {{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'),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/lang_footer.html",''),e.put("partials/desktop/login.html",'\n\n'),e.put("partials/desktop/media_modal_layout.html",''),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 The message is not supported on your version of Telegram Web. Update the app to view: web.telegram.org.\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'),e.put("partials/desktop/message_attach_geo.html",'\n \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
\n'),e.put("partials/desktop/message_attach_video.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/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/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'),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/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
'),e.put("partials/desktop/reply_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
'),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'),e.put("partials/desktop/slider.html",'
\n
\n
\n
\n
\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'),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'),e.put("partials/desktop/welcome.html",""),e.put("partials/mobile/audio_player.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
'),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\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
\n
\n
\n
\n\n
\n
GIF
\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/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
'),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 The message is not supported on your version of Telegram Web. Update the app to view: web.telegram.org.\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'),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'),e.put("partials/mobile/message_attach_geo.html",'\n \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'),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
\n'),e.put("partials/mobile/message_attach_video.html",'\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'),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/mobile/welcome.html","") +return-1!=c&&l.pending.splice(c,1),(a=kt[r])&&(delete a.pending,delete a.error,delete a.random_id,delete a.send),(o=$t[r])&&($t[n.mid]=angular.extend(o,ct(n.mid)),delete o.pending,delete o.error,delete o.random_id,delete o.send,t.$broadcast("messages_pending")),delete $t[r],delete kt[r],a}return!1}function st(e){return f.invokeApi("messages.checkChatInvite",{hash:e}).then(function(n){var i;if("chatInviteAlready"==n._){if(l.saveApiChat(n.chat),!n.chat.pFlags.left)return t.$broadcast("history_focus",{peerString:l.getChatString(n.chat.id)});i=n.chat.title}else i=n.title;C.confirm({type:1&n.flags?"JOIN_CHANNEL_BY_LINK":"JOIN_GROUP_BY_LINK",title:i}).then(function(){return f.invokeApi("messages.importChatInvite",{hash:e}).then(function(e){if(s.processUpdateMessage(e),e.chats&&1==e.chats.length)t.$broadcast("history_focus",{peerString:l.getChatString(e.chats[0].id)});else if(e.updates&&e.updates.length)for(var n,i=0,a=e.updates.length;a>i;i++)if(n=e.updates[i],"updateNewMessage"==n._){t.$broadcast("history_focus",{peerString:l.getChatString(n.message.to_id.chat_id)});break}})})})}function rt(e){var t=e.to_id&&c.getPeerID(e.to_id)||0;return 0>t?t:e.out||2&e.flags?t:e.from_id}function lt(e,t){var n=e&&void 0!==t,i=t&&t.unread_count;if(n&&void 0!==St[e])return delete St[e].typing,St[e];var a=angular.copy(kt[e]);if(!a||!a.to_id){if(!t||!t.peerID)return a;a={_:"message",to_id:c.getOutputPeer(t.peerID),deleted:!0,date:tsNow(!0)},a.deleted=!0}return a.peerID=rt(a),a.peerData=c.getPeer(a.peerID),a.peerString=c.getPeerString(a.peerID),a.unreadCount=i,"messageService"==a._&&a.action.user_id&&(a.action.user=r.getUser(a.action.user_id)),a.message&&a.message.length&&(a.richMessage=v.wrapRichText(a.message.substr(0,64),{noLinks:!0,noLinebreaks:!0})),a.dateText=Wt(a.date),n&&(St[e]=a),a}function ct(e){if(void 0!==$t[e])return $t[e];var t=angular.copy(kt[e])||{id:e};t.media&&void 0!==t.media.progress&&(t.media.progress=kt[e].media.progress);var n=t.from_id&&r.getUser(t.from_id),i=n&&n.pFlags.bot&&n.username||!1,a=i||t.to_id&&(t.to_id.chat_id||t.to_id.user_id&&r.isBot(t.to_id.user_id));if(t.media)switch(t.media.caption&&t.media.caption.length&&(t.media.rCaption=v.wrapRichText(t.media.caption,{noCommands:!a,fromBot:i})),t.media._){case"messageMediaPhoto":t.media.photo=d.wrapForHistory(t.media.photo.id);break;case"messageMediaVideo":t.media.video=u.wrapForHistory(t.media.video.id);break;case"messageMediaDocument":t.media.document=p.wrapForHistory(t.media.document.id);break;case"messageMediaAudio":t.media.audio=h.wrapForHistory(t.media.audio.id);break;case"messageMediaGeo":var s="https://maps.google.com/?q="+t.media.geo.lat+","+t.media.geo["long"];t.media.mapUrl=o.trustAsResourceUrl(s);break;case"messageMediaVenue":var s;s="foursquare"==t.media.provider&&t.media.venue_id?"https://foursquare.com/v/"+encodeURIComponent(t.media.venue_id):"https://maps.google.com/?q="+t.media.geo.lat+","+t.media.geo["long"],t.media.mapUrl=o.trustAsResourceUrl(s);break;case"messageMediaContact":t.media.rFullName=v.wrapRichText(t.media.first_name+" "+(t.media.last_name||""),{noLinks:!0,noLinebreaks:!0});break;case"messageMediaWebPage":if(!t.media.webpage||"webPageEmpty"==t.media.webpage._||Config.Mobile){delete t.media;break}t.media.webpage=g.wrapForHistory(t.media.webpage.id)}else if(t.action)switch(t.action._){case"messageActionChatEditPhoto":case"messageActionChannelEditPhoto":t.action.photo=d.wrapForHistory(t.action.photo.id);break;case"messageActionChatCreate":case"messageActionChatEditTitle":case"messageActionChannelCreate":case"messageActionChannelEditTitle":t.action.rTitle=v.wrapRichText(t.action.title,{noLinks:!0,noLinebreaks:!0})||x("chat_title_deleted");break;case"messageActionBotIntro":t.action.rDescription=v.wrapRichText(t.action.description,{noCommands:!a,fromBot:i})}var l=t.reply_to_mid;return l&&(kt[l]?t.reply_to_msg=lt(l):(t.reply_to_msg={mid:l,loading:!0},-1==Ot.indexOf(l)&&(Ot.push(l),Ut===!1&&(Ut=setTimeout(ut,100))))),$t[e]=t}function dt(e){if(!e||"replyKeyboardHide"==e._)return!1;if(e.wrapped)return e;var t=e.rows&&e.rows.length||0;return t>0&&4>=t&&!e.pFlags.resize&&(e.splitCount=t),e.wrapped=!0,angular.forEach(e.rows,function(e){angular.forEach(e.buttons,function(e){e.rText=v.wrapRichText(e.text,{noLinks:!0,noLinebreaks:!0})})}),nextRandomInt(1)&&(e.rows=e.rows.slice(0,2)),e}function ut(){if(Ut!==!1&&(clearTimeout(Ut),Ut=!1),Ot.length){var e=Ot.slice();Ot=[];var n=L(e);angular.forEach(n.msgIDs,function(e,i){var a;a=i>0?f.invokeApi("channels.getMessages",{channel:l.getChannelInput(i),id:e}):f.invokeApi("messages.getMessages",{id:e}),a.then(function(e){r.saveApiUsers(e.users),l.saveApiChats(e.chats),J(e.messages),t.$broadcast("messages_downloaded",n.mids[i])})})}}function pt(){if(Bt!==!1&&(clearTimeout(Bt),Bt=!1),Lt.length){var e=Lt.slice();Lt=[];var t=L(e);angular.forEach(t.msgIDs,function(e,n){f.invokeApi("messages.getMessagesViews",{peer:c.getInputPeerByID(-n),id:e,increment:!0}).then(function(e){if(n){for(var i=t.mids[n],a=[],o=0;o0?u=Math.min(t,d):0>t&&(c=Math.max(0,u+t)),n=c;u>n;n++){if(o=e[n],i=Math.floor((o.date+wt)/86400),l=s&&s.grouped,r=o.grouped,i===a?o.needDate&&(delete o.needDate,p=!0):(!n||s)&&(o.needDate||(o.needDate=!0,p=!0)),o.fwdFromID&&o.media&&o.media.document&&(o.media.document.sticker||o.media.document.audioTitle)&&(o.fromID!=(s||{}).fromID||!(s||{}).fwdFromID)&&(delete o.fwdFromID,o._="message"),o.views&&!Rt[o.mid]&&(Rt[o.mid]=!0,Lt.push(o.mid),Bt===!1&&(Bt=setTimeout(pt,1e4))),s&&o.fromID==s.fromID&&!s.fwdFromID==!o.fwdFromID&&!s.action&&!o.action&&o.datezt&&w.set({max_seen_msg:e})}function ft(e,n){n=n||{};var i,a,o=rt(e),s={},c=!1,d=y.getNotifySettings();if(e.fwdFromID&&n.fwd_count)c=Gt(n.fwd_count);else if(e.message)c=d.nopreview?x("conversation_message_sent"):v.wrapPlainText(e.message);else if(e.media)switch(e.media._){case"messageMediaPhoto":c=x("conversation_media_photo_raw");break;case"messageMediaVideo":c=x("conversation_media_video_raw");break;case"messageMediaDocument":if(e.media.document.sticker){c=x("conversation_media_sticker");var u=e.media.document.stickerEmojiRaw;void 0!==u&&(c=v.wrapPlainText(u)+" ("+c+")")}else c=e.media.document.file_name||x("conversation_media_document_raw");break;case"messageMediaAudio":c=x("conversation_media_audio_raw");break;case"messageMediaGeo":case"messageMediaVenue":c=x("conversation_media_location_raw");break;case"messageMediaContact":c=x("conversation_media_contact_raw");break;default:c=x("conversation_media_attachment_raw")}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":c=x(e.action.user_id==e.from_id?"conversation_returned_to_group":"conversation_invited_user_message_raw");break;case"messageActionChatDeleteUser":c=x(e.action.user_id==e.from_id?"conversation_left_group":"conversation_kicked_user_message_raw");break;case"messageActionChatJoinedByLink":c=x("conversation_joined_by_link");break;case"messageActionChannelCreate":c=x("conversation_created_channel");break;case"messageActionChannelEditTitle":c=x("conversation_changed_channel_name");break;case"messageActionChannelEditPhoto":c=x("conversation_changed_channel_photo");break;case"messageActionChannelDeletePhoto":c=x("conversation_removed_channel_photo")}if(o>0){var p=r.getUser(e.from_id),m=r.getUserPhoto(e.from_id);s.title=(p.first_name||"")+(p.first_name&&p.last_name?" ":"")+(p.last_name||""),s.title||(s.title=p.phone||x("conversation_unknown_user_raw")),a=m,i=r.getUserString(o)}else{if(s.title=l.getChat(-o).title||x("conversation_unknown_chat_raw"),e.from_id>0){var p=r.getUser(e.from_id);s.title=(p.first_name||p.last_name||x("conversation_unknown_user_raw"))+" @ "+s.title}a=l.getChatPhoto(-o),i=l.getChatString(-o)}s.title=v.wrapPlainText(s.title),s.onclick=function(){t.$broadcast("history_focus",{peerString:i,messageID:16&e.flags?e.mid:0})},s.message=c,s.image=a.placeholder,s.key="msg"+e.mid,s.tag=i,a.location&&!a.location.empty?_.downloadSmallFile(a.location,a.size).then(function(t){s.image=$.getUrl(t,"image/jpeg"),e.unread&&y.notify(s)}):y.notify(s)}function _t(){a.cancel(on),on=!1,t.$broadcast("history_multiappend",sn),sn={}}function vt(){a.cancel(rn),rn=!1,angular.forEach(ln,function(e){N(e)}),t.$broadcast("dialogs_multiupdate",ln),ln={}}function yt(){a.cancel(cn),cn=!1;var e=t.idle.isIDLE&&M.isOtherDeviceActive()?3e4:1e3;angular.forEach(dn,function(t){t.isMutedPromise.then(function(n){var i=t.top_message;!n&&i.unread&&setTimeout(function(){i.unread&&ft(i,{fwd_count:t.fwd_count})},e)})}),dn={}}function bt(n){var i=-n,a=c.getInputPeerByID(i);return e.all([k.getChannelFull(n,!0),q(a,0)]).then(function(e){var a=e[0],o=e[1],s=o.history[0],r={_:"dialogChannel",peer:c.getOutputPeer(i),top_message:s,top_important_message:s,read_inbox_max_id:a.read_inbox_max_id,unread_count:a.unread_count,unread_important_count:a.unread_important_count,notify_settings:a.notify_settings};I(n,r);var l={};l[i]=r,t.$broadcast("dialogs_multiupdate",l)})}var wt,kt={},$t={},St={},Ct={},Mt={count:null,dialogs:[]},xt={},At={},Et={},It=e.when(),Tt=-1,Dt=SearchIndexManager.createIndex(),Pt={query:!1},Nt={},Ft=[],Ot=[],Ut=!1,Rt={},Lt=[],Bt=!1,jt=0,qt=tsNow(!0),Ht=qt-qt%86400,Vt=new Date;w.get("server_time_offset").then(function(e){e&&(jt=e)});var zt=!1;Config.Modes.packed&&w.get("max_seen_msg").then(function(e){zt=e||0});var Wt=i("dateOrTime"),Gt=x.pluralize("conversation_forwarded_X_messages");Vt.setHours(0),Vt.setMinutes(0),Vt.setSeconds(0),wt=Ht-Math.floor(+Vt/1e3),y.start();var Kt=!1,Yt=!1,Zt=!1,Xt=0,Jt=0,Qt=Math.pow(2,50),en={},tn={},nn=0,an=4294967296;window.navigator.mozSetMessageHandler&&window.navigator.mozSetMessageHandler("activity",function(e){var n=e.source;console.log(dT(),"Received activity",n.name,n.data),"share"===n.name&&n.data.blobs.length>0&&b.selectPeers({confirm_type:"EXT_SHARE_PEER"}).then(function(e){angular.forEach(e,function(e){var t=c.getPeerID(e);angular.forEach(n.data.blobs,function(e){et(t,e,{isMedia:!0})})}),1==e.length&&t.$broadcast("history_focus",{peerString:e[0]})})});var on=!1,sn={},rn=!1,ln={},cn=!1,dn={};return t.$on("apiUpdate",function(e,n){switch(n._){case"updateMessageID":var i=n.random_id,o=xt[i];if(o){var s=o[0],d=c.isChannel(s)?-s:0;At[O(n.id,d)]=i}break;case"updateNewMessage":case"updateNewChannelMessage":var u=n.message,s=rt(u),p=Ct[s];if("updateNewChannelMessage"==n._&&!(16&u.flags||2&u.flags||0==(256&u.flags)))break;if(J([u]),void 0!==p){var m=p.history;if(-1!=m.indexOf(u.mid))return!1;var h=m[0];m.unshift(u.mid),u.mid>0&&u.mid0&&S&&r.forceUserOnline(s),$=0;x>$;$++)if(k=m[$],!(k>C)&&(u=kt[k],u.out==S)){if(!u.unread)break;u&&u.unread&&(u.unread=!1,$t[k]&&($t[k].unread=!1,A||(A=!0)),St[k]&&(St[k].unread=!1),u.out||(_&&(M=--_[0].unread_count),y.cancel("msg"+k)))}M!==!1&&t.$broadcast("dialog_unread",{peerID:s,count:M}),A&&t.$broadcast("messages_read");break;case"updateReadMessagesContents":var $,k,u,I,T=n.messages,D=T.length;for($=0;D>$;$++)k=T[$],(u=kt[k])&&delete u.media_unread,(I=$t[k])&&delete I.media_unread;break;case"updateDeleteMessages":case"updateDeleteChannelMessages":var k,u,$,s,_,m,N={},d=n.channel_id;for($=0;$0&&(a.count-=e.count,a.count<0&&(a.count=0));for(var r=0;r0,L="channel"==F._&&(F.username||!F.pFlags.left&&!F.pFlags.kicked)&&!0||!1,B=void 0!==Ct[s];L!=B&&(delete Ct[s],t.$broadcast("history_forbidden",s)),R!=U&&(U?bt(d):_[0]&&(Mt.dialogs.splice(_[1],1),t.$broadcast("dialog_drop",{peerID:s})));break;case"updateChannelReload":var d=n.channel_id,s=-d,_=E(s);_[0]&&Mt.dialogs.splice(_[1],1),delete Ct[s],bt(d).then(function(){t.$broadcast("history_reload",s)});break;case"updateChannelMessageViews":var j=n.views,q=O(n.id,n.channel_id),u=W(q);u&&u.views&&u.views\n \n \n \n
\n
\n \n \n
\n \n \n \n \n \n \n \n \n \n
\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/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.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'),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'),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'),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\n \n\n \n
\n
\n\n
\n
\n'),e.put("partials/desktop/dialog_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'),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 {0}\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 \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
\n
\n
\n
\n\n
\n
GIF
\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/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 {{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'),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/lang_footer.html",''),e.put("partials/desktop/login.html",'\n\n'),e.put("partials/desktop/media_modal_layout.html",''),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 The message is not supported on your version of Telegram Web. Update the app to view: web.telegram.org.\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'),e.put("partials/desktop/message_attach_geo.html",'\n \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
\n'),e.put("partials/desktop/message_attach_video.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/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/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'),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/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
'),e.put("partials/desktop/reply_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
'),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'),e.put("partials/desktop/slider.html",'
\n
\n
\n
\n
\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'),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'),e.put("partials/desktop/welcome.html",""),e.put("partials/mobile/audio_player.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
'),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\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
\n
\n
\n
\n\n
\n
GIF
\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/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
'),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 The message is not supported on your version of Telegram Web. Update the app to view: web.telegram.org.\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'),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'),e.put("partials/mobile/message_attach_geo.html",'\n \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'),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
\n'),e.put("partials/mobile/message_attach_video.html",'\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'),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/mobile/welcome.html","") }]),function(e,t,n,i){function a(e){ConfigStorage.get("emojis_popular",function(t){var n=[];if(t&&t.length){for(var i=0,a=t.length;a>i;i++)n.push({code:t[i][0],rate:t[i][1]});return void e(n)}ConfigStorage.get("emojis_recent",function(t){t=t||y||[];for(var i,a,o=0,s=t.length;s>o;o++)i=t[o],Array.isArray(i)&&(i=i[0]),i&&"string"==typeof i&&(":"==i.charAt(0)&&(i=i.substr(1,i.length-2)),(a=f[i])&&n.push({code:a,rate:1}));e(n)})})}function o(e){a(function(t){for(var n=!1,i=t.length,a=[],o=0;i>o;o++)t[o].code==e&&(n=!0,t[o].rate++),a.push([t[o].code,t[o].rate]);n?a.sort(function(e,t){return t[1]-e[1]}):(a.length>41&&(a=a.slice(0,41)),a.push([e,1])),ConfigStorage.set({emojis_popular:a})})}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),i=[];for(t in n)n.hasOwnProperty(t)&&i.push(t);return i}var l,c,d,u,p,m,h,g,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,h=n.length;h>l;l++)for(m=i[l][1],c=0,g=n[l].length;g>c;c++)d=n[l][c],p=Config.Emoji[d],u=p[1][0],t[d]=[p[0],u],f[u]=d,_[d]=[l,c,Math.floor(c/m),c%m];e.EmojiHelper={emojis:t,shortcuts:f,spritesheetPositions:_,getPopularEmoji:a,pushPopularEmoji:o,indexEmojis:s,searchEmojis:r}}(window,Config.Emoji,Config.EmojiCategories,Config.EmojiCategorySpritesheetDimens),EmojiTooltip.prototype.onMouseEnter=function(e){this.hideTimeout?(clearTimeout(this.hideTimeout),delete this.hideTimeout):e&&!this.showTimeout&&(this.showTimeout=setTimeout(this.show.bind(this),100))},EmojiTooltip.prototype.onMouseLeave=function(e){if(this.hideTimeout)e&&this.showTimeout&&(clearTimeout(this.showTimeout),delete this.showTimeout);else{var t=this;this.hideTimeout=setTimeout(function(){t.hide()},600)}},EmojiTooltip.prototype.createTooltip=function(){if(this.tooltipEl)return!1;var e='
'+this.langpack.im_emoji_tab+'
'+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 i=$(".composer_emoji_tooltip_tab_"+e,t.tabsEl).on("mousedown",function(e){return t.selectTab(n),cancelEvent(e)});Config.Navigator.touch||i.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 i=parseInt(n.getAttribute("data-category"));if("mousedown"==e.type)return t.selectCategory(i),cancelEvent(e);if(!t.tab){var a="mouseover"==e.type;a&&t.selectCategoryIndex==i||(clearTimeout(t.selectCategoryTimeout),delete t.selectCategoryTimeout,a?(t.selectCategoryIndex=i,t.selectCategoryTimeout=setTimeout(function(){delete t.selectCategoryIndex,delete t.selectCategoryTimeout,t.selectCategory(i)},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,i,a,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)),(i=o.attr("data-sticker"))&&(t.onStickerSelected&&t.onStickerSelected(i),Config.Mobile&&t.hide()),(a=o.attr("data-stickerset"))&&(t.onStickersetSelected&&t.onStickersetSelected(a),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.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()))):!1},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,i=function(){t.emojiContentEl.html(e.join("")),t.emojiScroller.reinit()};if(this.cat>0){var a,o,s,r,l,c=this.cat-1,d=Config.EmojiCategories[c],u=Config.EmojiCategorySpritesheetDimens[c][1],p=d.length;for(s=0;p>s;s++)a=d[s],o=Config.Emoji[a],r=n*(s%u),l=n*Math.floor(s/u),e.push('');i()}else EmojiHelper.getPopularEmoji(function(t){var a,o,s,r,l,c,d,u,p=t.length;for(c=0;p>c;c++)a=t[c].code,(o=Config.Emoji[a])&&(s=EmojiHelper.spritesheetPositions[a],l=s[0],r=s[1],d=n*s[3],u=n*s[2],e.push(''));i()})},EmojiTooltip.prototype.updateStickersContents=function(e){var t=[],n=[],i=this,a=function(){var t=i.cat?i.stickersetPositions[i.cat][0]:0;i.stickersScroller.scrollTo(t,e?0:200)};if(!e&&i.stickersetPositions.length)return void a();var o=function(e){var o,s,r,l,c,d;for(r=0,c=e.length;c>r;r++)if(o=e[r],o.docIDs.length){for(t.push('
'),o.title&&t.push('',encodeEntities(o.title),""),n.push(o.id?'':''),l=0,d=o.docIDs.length;d>l;l++)s=o.docIDs[l],t.push('');t.push("
")}i.stickersContentEl.html(t.join("")),i.stickersCategoriesEl.html(n.join("")),i.stickersScroller.reinit();var u=[];$(".composer_stickerset_wrap",i.stickersContentEl).each(function(e,t){var n=t.offsetHeight,i=t.offsetTop;u.push([i,n])}),i.stickersetPositions=u,a();var p=[];i.contentEl.find(".composer_sticker_btn").each(function(e,t){12>e?i.replaceStickerImage(t):p.push([t.offsetTop,t])}),i.stickersPreload=p,i.stickersCategoriesEl.find(".composer_sticker_btn").each(function(e,t){i.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,i,a=e.clientHeight,o=e.scrollHeight,s=this.stickersetPositions.length,r=!1;if(20>t)r=0;else if(t>o-a-20)r=s-1;else for(i=0;s>i;i++)if(n=this.stickersetPositions[i],t>=n[0]&&ti;i++)n=this.stickersPreload[i],n[0]>=t&&n[0]<=t+a&&(this.replaceStickerImage(n[1]),this.stickersPreload.splice(i,1),i--,s--);this.cat!==r&&r!==!1&&($(".active",this.categoriesEl).removeClass("active"),this.cat=r,this.activateStickerCategory())},EmojiTooltip.prototype.activateStickerCategory=function(){var e=this.categoriesEl[1],t=e.childNodes[this.cat];if(t){$(t).addClass("active");var n=t.offsetLeft,i=t.offsetWidth,a=e.clientWidth;$(e).animate({scrollLeft:n-(a-i)/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(i){var a,o,s,r,l,c,d,u,p=i.length;for(c=0;p>c;c++)a=i[c].code,(o=Config.Emoji[a])&&(s=EmojiHelper.spritesheetPositions[a],l=s[0],r=s[1],d=n*s[3],u=n*s[2],e.push(''));t.containerEl.html(e.join(""))})},MessageComposer.autoCompleteRegEx=/(\s|^)(:|@|\/)([A-Za-z0-9\-\+\*@_]*)$/,MessageComposer.prototype.setUpInput=function(){if("contentEditable"in document.body?this.setUpRich():this.setUpPlaintext(),!Config.Mobile){var e=getScrollWidth();e&&(this.richTextareaEl||this.textareaEl).css({marginRight:-e})}},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){if("keyup"==e.type){this.checkAutocomplete();var t=!1;if(this.richTextareaEl){clearTimeout(this.updateValueTO);var n=tsNow();void 0===this.keyupStarted&&(this.keyupStarted=n),n-this.keyupStarted>1e4?this.onChange():(t=this.richTextareaEl[0].textContent.length,this.wasEmpty!=!t?(this.wasEmpty=!this.wasEmpty,this.onChange()):this.updateValueTO=setTimeout(this.onChange.bind(this),1e3))}if(this.onTyping){var n=tsNow();n-this.lastTyping>5e3&&(t===!1&&(t=(this.richTextareaEl?this.richTextareaEl[0].textContent:this.textareaEl[0].value).length),t!=this.lastLength&&(this.lastTyping=n,this.lastLength=t,this.onTyping()))}}if("keydown"==e.type){var i=!this.autocompleteShown;if(this.autocompleteShown){if(38==e.keyCode||40==e.keyCode){var a=40==e.keyCode,o=$(this.autoCompleteEl).find(".composer_autocomplete_option_active");if(o.length){var s=o[0].parentNode,r=s[a?"nextSibling":"previousSibling"];if(o.removeClass("composer_autocomplete_option_active"),r)return $(r).find("a").addClass("composer_autocomplete_option_active"),this.scroller.scrollToNode(r),cancelEvent(e)}var l=this.autoCompleteEl[0].childNodes,r=l[a?0:l.length-1];return this.scroller.scrollToNode(r),$(r).find("a").addClass("composer_autocomplete_option_active"),cancelEvent(e)}if(13==e.keyCode||9==e.keyCode){var o=$(this.autoCompleteEl).find(".composer_autocomplete_option_active");o.length||9!=e.keyCode||(o=$(this.autoCompleteEl[0].childNodes[0]).find("a"));var c,d,u;if(c=o.attr("data-code"))return this.onEmojiSelected(c,!0),EmojiHelper.pushPopularEmoji(c),cancelEvent(e);if(d=o.attr("data-mention"))return this.onMentionSelected(d),cancelEvent(e);if(u=o.attr("data-command"))return this.onCommandSelected&&this.onCommandSelected(u,9==e.keyCode),cancelEvent(e);i=!0}}if(i&&13==e.keyCode){var p=!1,m=!0;if(this.getSendOnEnter&&!this.getSendOnEnter()&&(m=!1),m&&!e.shiftKey?p=!0:m||!e.ctrlKey&&!e.metaKey||(p=!0),p)return this.onMessageSubmit(e),cancelEvent(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 i=this.richTextareaEl[0],a=getRichValueWithCaret(i),n=a[0],t=a[1]>=0?a[1]:n.length;t||this.cleanRichTextarea(n,!0)}else var i=this.textareaEl[0],t=getFieldSelection(i),n=i.value;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;u>d;d++)r=this.mentions.users[d],l[r.id]&&c.push(r);else var c=this.mentions.users;c.length?this.showMentionSuggestions(c):this.hideSuggestions()}else this.hideSuggestions();else if(o[1]||"/"!=o[2])":"==o[2]&&EmojiHelper.getPopularEmoji(function(e){if(s.length){var t=EmojiHelper.searchEmojis(s);if(t.length){for(var n,i,a=[],o=0,r=e.length;r>o&&(n=e[o].code,i=t.indexOf(n),!(i>=0)||(a.push(n),t.splice(i,1),t.length));o++);this.showEmojiSuggestions(a.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;u>d;d++)p=this.commands.list[d],l[p.value]&&m.push(p);else var m=this.commands.list;m.length?this.showCommandsSuggestions(m):this.hideSuggestions()}else this.hideSuggestions()}else delete this.previousQuery,this.hideSuggestions()},MessageComposer.prototype.onFocusBlur=function(e){this.isActive="focus"==e.type,this.isActive?setTimeout(this.checkAutocomplete.bind(this),100):(this.cleanRichTextarea(),this.hideSuggestions()),this.richTextareaEl&&document.execCommand("enableObjectResizing",!this.isActive,!this.isActive)},MessageComposer.prototype.onRichPaste=function(e){var t,n=(e.originalEvent||e).clipboardData,i=n&&n.items||[];for(t=0;t0&&(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||"",i=!1;if("data:"==n.substr(0,5)){i=!0;var a=dataUrlToBlob(n);this.onFilePaste(a),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 i,a=getRichValueWithCaret(n),o=a[0],s=a[1]>=0?a[1]:o.length,r=o.substr(s),l=o.substr(0,s),c=l.match(/:([A-Za-z0-9\-\+\*_]*)$/),d=EmojiHelper.emojis[e];i=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(i)+' '+this.getRichHtml(r),this.richTextareaEl.html(u),setRichFocus(n,$("#composer_sel"+this.selId)[0])):(u=this.getRichHtml(i)+" ",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 h=m.firstChild,g=p.getRangeAt(0);g.deleteContents(),g.insertNode(document.createTextNode(" ")),g.insertNode(h),g.setStart(h,0),setTimeout(function(){g=document.createRange(),g.setStartAfter(h),g.collapse(!0),p.removeAllRanges(),p.addRange(g)},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(/:([A-Za-z0-9\-\+\*_]*)$/),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(){delete this.previousQuery,this.isActive&&this.checkAutocomplete()},MessageComposer.prototype.onMentionSelected=function(e){if(this.richTextareaEl){var t=this.richTextareaEl[0];this.isActive||this.restoreSelection()||setRichFocus(t);var n,i=getRichValueWithCaret(t),a=i[0],o=i[1]>=0?i[1]:a.length,s=a.substr(o),r=a.substr(0,o),l=r.match(/@([A-Za-z0-9\-\+\*_]*)$/);n=l&&l[0]?r.substr(0,l.index)+"@"+e:r+"@"+e,t.value=d;var c;s.length?(this.selId=(this.selId||0)+1,c=this.getRichHtml(n)+' '+this.getRichHtml(s),this.richTextareaEl.html(c),setRichFocus(t,$("#composer_sel"+this.selId)[0])):(c=this.getRichHtml(n)+" ",this.richTextareaEl.html(c),setRichFocus(t))}else{var t=this.textareaEl[0],a=t.value,o=this.isActive?getFieldSelection(t):a.length,s=a.substr(o),r=a.substr(0,o),l=r.match(/@([A-Za-z0-9\-\+\*_]*)$/);if(l&&l[0])var d=r.substr(0,l.index)+"@"+e+" "+s,u=l.index+e.length+2;else var d=r+":"+e+": "+s,u=r.length+e.length+2;t.value=d,setFieldSelection(t,u)}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(){this.richTextareaEl&&(delete this.keyupStarted,this.textareaEl.val(getRichValue(this.richTextareaEl[0])).trigger("change"))},MessageComposer.prototype.getEmojiHtml=function(e,t){t=t||EmojiHelper.emojis[e];var n=20,i=EmojiHelper.spritesheetPositions[e],a=i[0],o=(i[1],n*i[3]),s=n*i[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],i=e[2];if(this.richTextareaEl){this.selId=(this.selId||0)+1;var a=this.getRichHtml(t)+''+this.getRichHtml(n)+""+this.getRichHtml(i);this.richTextareaEl.html(a),setRichFocus(this.richTextareaEl[0],$("#composer_sel"+this.selId)[0],!0)}else this.textareaEl.val(t+n+i),setFieldSelection(this.textareaEl[0],t.length,t.length+n.length)},MessageComposer.prototype.getRichHtml=function(e){return $("
").text(e).html().replace(/\n/g,"
").replace(/:([A-Za-z0-9\-\+\*_]+?):/gi,function(e,t){var n=EmojiHelper.shortcuts[t];return void 0!==n?this.getEmojiHtml(n):e}.bind(this))},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(e){this.autoCompleteEl.html(e.join("")),this.autoCompleteWrapEl.show(),this.scroller.reinit(),this.updatePosition(),this.autocompleteShown=!0},MessageComposer.prototype.showEmojiSuggestions=function(e){var t,n,i,a,o,s,r,l,c=[],d=Config.Mobile?26:20,u=Math.min(5,e.length);for(s=0;u>s;s++)t=e[s],t.code&&(t=t.code),(n=Config.Emoji[t])&&(i=EmojiHelper.spritesheetPositions[t],o=i[0],a=i[1],r=d*i[3],l=d*i[2],c.push('
  • :'+encodeEntities(n[1][0])+":
  • "));this.renderSuggestions(c)},MessageComposer.prototype.showMentionSuggestions=function(e){var t,n,i=[],a=e.length;for(n=0;a>n;n++)t=e[n],i.push('
  • '+t.rFullName+'@'+t.username+"
  • ");this.renderSuggestions(i);var o=this;this.autoCompleteEl.find(".composer_user_photo").each(function(e,t){o.getPeerImage($(t),t.getAttribute("data-user-id"))})},MessageComposer.prototype.showCommandsSuggestions=function(e){var t,n,i=[],a=Math.min(200,e.length);for(n=0;a>n;n++)t=e[n],i.push('
  • '+encodeEntities(t.value)+''+t.rDescription+"
  • ");this.renderSuggestions(i);var o=this,s={};this.autoCompleteEl.find(".composer_user_photo").each(function(e,t){var n=!0,i=t.getAttribute("data-user-id");s[i]||(s[i]=!0,n=!1),o.getPeerImage($(t),i,n)})},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(){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 i=this;this.isAnimatedScroll=!0,this.scrollable.animate({scrollTop:e},t,function(){delete i.isAnimatedScroll,i.useNano&&$(i.scroller).nanoScroller({flash:!0}),i.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,i=this.scrollable[0].scrollTop,a=this.scrollable[0].clientHeight;i>t?this.scrollTo(t):t+n-a>i&&this.scrollTo(t+n-a)},angular.module("myApp.directives",["myApp.filters"]).directive("myHead",function(){return{restrict:"AE",templateUrl:templateUrl("head")}}).directive("myLangFooter",function(){return{restrict:"AE",templateUrl:templateUrl("lang_footer")}}).directive("myFooter",function(){return{restrict:"AE",templateUrl:templateUrl("footer")}}).directive("myDialog",function(){return{restrict:"AE",templateUrl:templateUrl("dialog")}}).directive("myMessage",["$filter","_",function(e,t){function n(e,t){var n,u,p=!1,m=!1,h=!1,g=!1,f=!1,_=!1,v=!1,y=function(){p!=(e.selectedMsgs[e.historyMessage.mid]||!1)&&(p=!p,t.toggleClass(s,p))},b=function(){m!=e.historyMessage.grouped&&(m&&t.removeClass(m),m=e.historyMessage.grouped,m&&t.addClass(m)),_!=(e.historyMessage.needDate||!1)&&(_=!_,_?n?n.show():(n=$(a),$(n[0].firstChild).text(i(e.historyMessage.date)),u?n.insertBefore(u):n.prependTo(t)):n.hide())};y(),b(),e.$on("messages_select",y),e.$on("messages_regroup",b),e.$on("messages_focus",function(n,i){i==e.historyMessage.mid!=h&&(h=!h,t.toggleClass(r,h))});var w;if(!e.historyMessage.out&&(e.historyMessage.unread||e.historyMessage.unreadAfter)){var k=function(){e.peerHistory.peerID==e.historyPeer.id&&v!=(e.historyUnreadAfter==e.historyMessage.mid)&&(v=!v,v?u?u.show():u=$(o).prependTo(t):(u.hide(),w&&w()))};k(),w=e.$on("messages_unread_after",k)}if(e.historyMessage.unread&&e.historyMessage.out){t.addClass(l);var S=e.$on("messages_read",function(){e.historyMessage.unread||(t.removeClass(l),S(),w&&!v&&w())})}if(e.historyMessage.error||e.historyMessage.pending){var C=function(){f!=(e.historyMessage.pending||!1)&&(f=!f,t.toggleClass(d,f)),g!=(e.historyMessage.error||!1)&&(g=!g,t.toggleClass(c,g)),g||f||M()},M=e.$on("messages_pending",C);C()}}var i=e("myDate"),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("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 h=c[1];d='
    <'+s+' type="text/html" frameborder="0" src="https://vine.co/v/'+h+'/embed/simple">
    ";break;case"soundcloud":var g=c[1];d='
    <'+s+' type="text/html" frameborder="0" src="https://w.soundcloud.com/player/?url='+encodeEntities(encodeURIComponent(g))+'&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,$("