diff --git a/app.manifest b/app.manifest index b77edb99..6e799c6a 100644 --- a/app.manifest +++ b/app.manifest @@ -1,5 +1,5 @@ CACHE MANIFEST -# Time: Tue Apr 19 2016 22:53:14 GMT+0300 (MSK) +# Time: Wed Apr 20 2016 20:43:59 GMT+0300 (MSK) CACHE: diff --git a/css/app.css b/css/app.css index 248a35a8..2bf0ad52 100644 --- a/css/app.css +++ b/css/app.css @@ -1379,6 +1379,8 @@ i.icon-verified{display:inline-block;width:17px;height:17px;vertical-align:text- .im_dialogs_scrollable_wrap .active a.im_dialog:hover,.im_dialogs_scrollable_wrap .active a.im_dialog_selected{background-color:#6490b1} .im_dialogs_modal_list{padding-top:10px} .im_dialog_message_wrap{overflow:hidden;word-wrap:break-word} +.im_dialog_message_typing,.im_dialog_message_wtyping .im_dialog_message_notyping{display:none} +.im_dialog_message_wtyping .im_dialog_message_typing{display:block} a.im_dialog .im_dialog_chat_from_wrap,a.im_dialog .im_short_message_media,a.im_dialog .im_short_message_service{color:#3a6d99} a.im_dialog .im_short_message_text{color:grey} a.im_dialog:hover .im_short_message_text,a.im_dialog_selected .im_short_message_text{color:#698192} @@ -1578,10 +1580,14 @@ a.im_message_fwd_photo{position:absolute;margin-top:1px} .im_history_to_bottom .im_history_empty,.im_history_to_bottom .im_history_not_selected{display:none} .im_history_loading{width:35px;margin:0 auto;visibility:hidden} .im_history_loading.vertical-aligned{visibility:visible} -.im_history_loading_more{display:block;width:26px;margin:0 auto;padding:20px 0 0;visibility:hidden} +.im_history_loading_more{display:block;width:26px;height:46px;margin:0 auto;padding:20px 0 0;visibility:hidden} +.im_history_loading_more .progress-arc-wrap{display:none} .im_history_loading_more.im_history_loading_more_active{visibility:visible} +.im_history_loading_more.im_history_loading_more_active .progress-arc-wrap{display:block} .im_history_loading_less{display:block;width:26px;margin:0 auto;visibility:hidden} +.im_history_loading_less .progress-arc-wrap{display:none} .im_history_loading_less.im_history_loading_less_active{visibility:visible} +.im_history_loading_less.im_history_loading_less_active .progress-arc-wrap{display:block} .im_send_panel_wrap{margin:0 auto;padding:10px 15px 30px} .im_send_form_wrap{position:relative} .im_send_form{margin:0 auto;position:absolute;bottom:0} @@ -1614,10 +1620,13 @@ img.img_fullsize{margin:0 auto} .media_modal_author{color:inherit;font-weight:700} .media_modal_author:hover{color:inherit} .non_osx .media_modal_author{font-size:12px} -.composer_progress_icon_wrap{opacity:0;position:absolute;right:3px;top:2px;width:22px;height:22px;overflow:hidden;margin-top:1px;pointer-events:none;padding:0;transition:opacity cubic-bezier(.25,.46,.45,.94) .2s} -.composer_progress_enabled .composer_progress_icon_wrap{opacity:1} -.composer_emoji_insert_btn{opacity:1;display:block;position:absolute;right:3px;top:2px;cursor:pointer;padding:0;width:22px;height:22px;margin-top:1px;transition:opacity cubic-bezier(.25,.46,.45,.94) .2s} -.composer_progress_enabled .composer_emoji_insert_btn{opacity:0} +.composer_progress_enabled-add,.composer_progress_enabled-remove{transition-duration:.2s} +.composer_progress_icon_wrap{position:absolute;right:3px;top:2px;width:22px;height:22px;overflow:hidden;margin-top:1px;pointer-events:none;padding:0;display:none;opacity:0} +.composer_progress_enabled-add .composer_progress_icon_wrap,.composer_progress_enabled-remove .composer_progress_icon_wrap{transition:opacity cubic-bezier(.25,.46,.45,.94) .2s;display:block} +.composer_progress_enabled .composer_progress_icon_wrap{display:block;opacity:1} +.composer_emoji_insert_btn{position:absolute;right:3px;top:2px;cursor:pointer;padding:0;width:22px;height:22px;margin-top:1px;display:block;opacity:1} +.composer_progress_enabled .composer_emoji_insert_btn{display:none;opacity:0} +.composer_progress_enabled-add .composer_emoji_insert_btn,.composer_progress_enabled-remove .composer_emoji_insert_btn{transition:opacity cubic-bezier(.25,.46,.45,.94) .2s;display:block} .icon-emoji{display:inline-block;width:22px;height:22px;vertical-align:top;opacity:.8;background-image:url(../img/icons/General.png);background-repeat:no-repeat;background-position:-9px -335px} .is_2x .icon-emoji{background-image:url(../img/icons/General_2x.png);background-size:40px 948px} .composer_emoji_tooltip{display:none;position:absolute;z-index:999;width:286px;margin-left:-133px;margin-top:-330px;border:1px solid #dfdfdf;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;-webkit-box-shadow:0 1px 1px rgba(0,0,0,.1);-moz-box-shadow:0 1px 1px rgba(0,0,0,.1);box-shadow:0 1px 1px rgba(0,0,0,.1);background:#fff;padding:0} diff --git a/js/app.js b/js/app.js index e652b319..b87b4d2d 100644 --- a/js/app.js +++ b/js/app.js @@ -21,7 +21,7 @@ return sha1a=new Uint8Array(e.sha1a),sha1b=new Uint8Array(e.sha1b),sha1c=new Uin }else w=!1}):void f():void 0}function f(){_=!0;var t=++$;s.getContacts(e.search.query).then(function(n){t==$&&(e.contacts=[],angular.forEach(n,function(t){void 0===C[t]&&e.contacts.push({userID:t,user:s.getUser(t),peerString:s.getUserString(t)})}),n.length?delete e.isEmpty.contacts:e.search.query||(e.isEmpty.contacts=!0),e.$broadcast("ui_dialogs_append"))}),e.search.query&&e.search.query.length>=5&&a(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===C[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,g())}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,C={},S={};e.$on("dialogs_need_more",function(){h()}),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 a=[],i={};angular.forEach(n,function(t,n){e.noUsers&&n>0||(i[t.index]=t,a.push(t.index))}),a.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--,l.clearDialogCache(s.mid));for(r=a.length,o=0;r>o;o++)s=i[a[o]],e.dialogs.unshift(l.wrapForDialog(s.top_message,s));delete e.isEmpty.dialogs,C[s.peerID]||(C[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 a=0;a-1?a=e.peerHistories[o]:(a={peerID:t,messages:[],ids:[]},e.peerHistories.unshift(a),i=e.peerHistories.length-s,i>0&&e.peerHistories.splice(s-1,i),a)}function b(t){var n;for(n=0;nV||!s.isBot(V)||e.historyFilter.mediaType||e.curDialog.messageID?!1:e.state.empty||W&&1==W.messages.length&&W.messages[0].action&&"messageActionBotIntro"==W.messages[0].action._?"start":e.curDialog.startParam?"param":!1,t!=e.historyState.botActions&&e.$broadcast("ui_panel_update")}function C(){var t,n=e.historyState.channelActions;if(V&&c.isChannel(V)&&(t=r.getChat(-V))){var a=r.hasRights(-V,"send");a?e.historyState.channelActions=!1:t.pFlags.left?e.historyState.channelActions="join":(e.historyState.channelActions||(e.historyState.channelActions="mute"),g.getPeerMuted(V).then(function(t){e.historyState.channelActions=t?"unmute":"mute"})),e.historyState.canReply=a,e.historyState.canDelete=a||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=b(V);if(t&&-1!=t.ids.indexOf(e.curDialog.messageID)){e.historyUnread={};var a=e.curDialog.messageID||0;e.$broadcast("messages_focus",a),e.$broadcast("ui_history_change_scroll",!0),n.cancel(z),a&&(z=n(function(){e.curDialog.messageID==a&&e.$broadcast("messages_focus",0)},2800))}else I()}function M(){if(Y){if(nt)return void(st=!0);st=!1,e.state.lessActive=ot=!0;var t=et,n=++it,a=0,i=20;l.getHistory(e.curDialog.peerID,X,a,i).then(function(a){if(e.state.lessActive=ot=!1,t==et&&n==it){var o,s;for(o=a.history.length-1;o>=0;o--)s=a.history[o],s>X&&(W.messages.push(l.wrapForHistory(s)),W.ids.push(s));a.history.length?(X=a.history.length>=i?a.history[0]:0,l.regroupWrappedHistory(W.messages,-i)&&e.$broadcast("messages_regroup"),delete e.state.empty,e.$broadcast("ui_history_append")):X=0,e.historyState.skipped=Y=X>0,at&&x()}})}}function x(){if(K){if(ot)return void(at=!0);at=!1,e.state.moreActive=nt=!0;var t=et,n=++tt,a=e.historyFilter.mediaType&&{_:Q[e.historyFilter.mediaType]},i=Config.Mobile?20:0,o=a?l.getSearch(e.curDialog.peerID,"",a,Z,i):l.getHistory(e.curDialog.peerID,Z,i);o.then(function(a){e.state.moreActive=nt=!1,t==et&&n==tt&&(angular.forEach(a.history,function(e){W.messages.unshift(l.wrapForHistory(e)),W.ids.unshift(e)}),K=null===a.count||a.history.length&&W.messages.length=o-1?t.history[0]:0,Z=t.history[t.history.length-1],e.historyState.skipped=Y=X>0,K=null===t.count||a&&at;for(c=0;c0&&angular.forEach(e.selectedMsgs,function(e,t){n.push(t)}),n.length&&h.confirm({type:"MESSAGES_DELETE",count:n.length}).then(function(){l.deleteMessages(n).then(function(){N()})})}function B(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(),i.$broadcast("history_focus",{peerString:e,attachment:{_:"fwd_messages",id:n}})})}function L(t){t||1!=e.selectedCount||angular.forEach(e.selectedMsgs,function(e,n){t=n}),t&&(N(),e.$broadcast("reply_selected",t))}function j(){e.historyState.selectActions?N():(e.historyState.selectActions="selected",e.$broadcast("ui_panel_update"))}function q(t){e.historyFilter.mediaType=t||!1,e.curDialog.messageID=!1,W.messages=[],W.ids=[],e.state.empty=!0,I()}function H(){e.historyFilter.mediaType?q():e.curDialog.messageID?i.$broadcast("history_focus",{peerString:e.curDialog.peer}):I(!0)}e.$watchCollection("curDialog",v),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=F,e.selectedDelete=O,e.selectedForward=B,e.selectedReply=L,e.selectedCancel=N,e.selectedFlush=U,e.selectInlineBot=R,e.startBot=E,e.cancelBot=T,e.joinChannel=D,e.togglePeerMuted=P,e.toggleEdit=j,e.toggleMedia=q,e.returnToRecent=H,e.$on("history_edit_toggle",j),e.$on("history_edit_flush",U),e.$on("history_media_toggle",function(e,t){q(t)}),e.$on("history_return_recent",H);var V,z,W=!1,G=!1,K=!1,Y=!1,Z=0,X=0,J=!1,Q={photos:"inputMessagesFilterPhotos",video:"inputMessagesFilterVideo",documents:"inputMessagesFilterDocument",audio:"inputMessagesFilterVoice"},et=0,tt=0,nt=!1,at=!1,it=0,ot=!1,st=!1;e.$on("history_update",angular.noop);var rt=!1;e.$on("stateSynchronized",function(){rt&&(rt==e.curDialog.peerID&&I(),rt=!1)}),e.$on("reply_button_press",function(t,n){var a=e.historyState.replyKeyboard;if(a){var i={replyToMsgID:0>V&&a.mid};switch(n._){case"keyboardButtonRequestPhone":h.confirm({type:"BOT_ACCESS_PHONE"}).then(function(){var e=s.getSelf();l.sendOther(V,{_:"inputMediaContact",phone_number:e.phone,first_name:e.first_name,last_name:e.last_name},i)});break;case"keyboardButtonRequestGeoLocation":h.confirm({type:"BOT_ACCESS_GEO"}).then(function(){return f.getPosition().then(function(e){l.sendOther(V,{_:"inputMediaGeoPoint",geo_point:{_:"inputGeoPoint",lat:e.lat,"long":e["long"]}},i)},function(){h.alert(_("error_modal_bad_request_title_raw"),_("error_modal_gelocation_na_raw"))})});break;default:l.sendText(V,n.text,i)}}}),e.$on("history_reload",function(t,n){n==e.curDialog.peerID&&I()}),e.$on("history_forbidden",function(n,a){a==e.curDialog.peerID&&t.url("/im"),w(a)}),e.$on("dialog_migrate",function(t,n){if(n.migrateFrom==e.curDialog.peerID){var a=c.getPeerString(n.migrateTo);i.$broadcast("history_focus",{peerString:a})}w(n.migrateFrom)}),e.$on("notify_settings",function(t,n){n.peerID==e.curDialog.peerID&&C()}),e.$on("channel_settings",function(t,n){n.channelID==-e.curDialog.peerID&&C()});var lt={};e.$on("history_append",function(t,a){var o=b(a.peerID);if(o){var s=a.peerID==e.curDialog.peerID;if(s){if(e.historyFilter.mediaType||e.historyState.skipped)return void(a.my?H():e.historyState.missedCount++);e.curDialog.messageID&&a.my&&H(),delete e.state.empty}var r=l.wrapForHistory(a.messageID);o.messages.push(r),o.ids.push(a.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:a.my,idleScroll:G&&!r.pFlags.out&&i.idle.isIDLE}),a.my&&e.historyUnreadAfter&&(delete e.historyUnreadAfter,e.$broadcast("messages_unread_after")),i.idle.isIDLE?!r.pFlags.unread||r.pFlags.out||(o.messages[o.messages.length-2]||{}).pFlags.unread||(e.historyUnreadAfter=r.mid,G=!0,e.$broadcast("messages_unread_after")):n(function(){l.readHistory(e.curDialog.peerID)}),$(),C())}}),e.$on("history_multiappend",function(t,a){var o=!1,s=!1,r=i.idle.isIDLE;angular.forEach(a,function(t,a){var i=b(a);if(i){var c=a==e.curDialog.peerID,d=i.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((!c||r)&&d>(u>10?10:100))return console.warn(dT(),"Drop too many messages",u,d,r,c,a),void(c?(X=i.messages[d-1].mid,e.historyState.skipped=Y=X>0,Y&&(rt=a,e.$broadcast("ui_history_append"))):w(a));var p,m,g,h=!1,f=!1,m=i.messages[i.messages.length-1],_=!m||!m.pFlags.unread;for(g=0;u>g;g++)p=t[g],Z>p||-1!==i.ids.indexOf(p)||(m=l.wrapForHistory(p),i.messages.push(m),i.ids.push(p),!f&&r&&(m.pFlags.unread&&!m.pFlags.out&&_?f=p:_=!m.pFlags.unread),!h&&m.pFlags.out&&(h=!0));l.regroupWrappedHistory(i.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:G&&!h&&r}),r?f&&(e.historyUnreadAfter=f,G=!0,s=!0):n(function(){l.readHistory(e.curDialog.peerID)}),$(),C())}}),o&&e.$broadcast("messages_regroup"),s&&e.$broadcast("messages_unread_after")}),e.$on("history_delete",function(t,n){var a=b(n.peerID);if(a){var i,o=[];for(i=0;i0){e=m.parseEmojis(e);var n={replyToMsgID:t.draftMessage.replyToMessage&&t.draftMessage.replyToMessage.mid};do d.sendText(t.curDialog.peerID,e.substr(0,4096),n),e=e.substr(4096);while(e.length)}k(),F==t.curDialog.peer&&(F=!1),_(),t.$broadcast("ui_message_send")}),cancelEvent(e)}function h(){var n=t.curDialog.peerID;if(!n)return safeReplaceObject(t.mentions,{}),void t.$broadcast("mentions_update");var a,i=[],s=SearchIndexManager.createIndex(),l=u.getPopularBots().then(function(e){var t=[];return angular.forEach(e,function(e){t.push(e.id)}),t});a=0>n?o.getChatFull(-n).then(function(e){var t=(e.participants||{}).participants||[],n=[];return angular.forEach(t,function(e){n.push(e.user_id)}),n}):e.when([]),e.all({pop:l,chat:a}).then(function(e){var n={},a=e.pop.concat(e.chat);angular.forEach(a,function(e){if(!n[e]){n[e]=!0;var t=r.getUser(e);t.username&&(i.push(t),SearchIndexManager.indexObject(t.id,r.getUserSearchText(t.id),s))}}),safeReplaceObject(t.mentions,{users:i,index:s}),t.$broadcast("mentions_update")})}function f(){var e=t.curDialog.peerID;return e?void o.getPeerBots(e).then(function(n){if(!n.length)return safeReplaceObject(t.commands,{}),void t.$broadcast("mentions_update");var a=0>e,i=[],o=SearchIndexManager.createIndex();angular.forEach(n,function(e){var t="";if(a){var n=r.getUser(e.id);n&&n.username&&(t+="@"+n.username)}var s=r.getUserSearchText(e.id);angular.forEach(e.commands,function(n,a){var r="/"+a+t;i.push({botID:e.id,value:r,rDescription:m.wrapRichText(n,{noLinks:!0,noLineBreaks:!0})}),SearchIndexManager.indexObject(r,s+" "+a+" "+n,o)})}),safeReplaceObject(t.commands,{list:i,index:o}),t.$broadcast("mentions_update")}):(safeReplaceObject(t.commands,{}),void t.$broadcast("mentions_update"))}function _(e){if(h(),f(),b(),C(),delete t.draftMessage.inlineProgress,t.$broadcast("inline_results",!1),F){if(F==t.curDialog.peer)return t.draftMessage.isBroadcast=l.isChannel(t.curDialog.peerID)&&!l.isMegagroup(t.curDialog.peerID),void t.$broadcast("ui_peer_draft");F=!1}w(),e?i.get("draft"+t.curDialog.peerID).then(function(e){t.draftMessage.text=e||"",t.draftMessage.isBroadcast=l.isChannel(t.curDialog.peerID)&&!l.isMegagroup(t.curDialog.peerID),t.$broadcast("ui_peer_draft")}):(t.draftMessage.text="",t.$broadcast("ui_peer_draft"))}function v(e,a){if(a&&a._)if("share_url"==a._){var o=a.url,s=a.text||" ";F=t.curDialog.peer,n(function(){t.draftMessage.text=o+"\n"+s,t.$broadcast("ui_peer_draft",{customSelection:[o+"\n",s,""]})},1e3)}else if("fwd_messages"==a._){F=t.curDialog.peer,t.draftMessage.fwdMessages=a.id,t.$broadcast("ui_peer_reply");var r=l.getPeerID(t.curDialog.peer);i.get("draft"+r).then(function(e){t.draftMessage.text=e||"",t.$broadcast("ui_peer_draft")})}else if("inline_query"==a._){var c=a.mention,d=a.query;F=t.curDialog.peer,n(function(){t.draftMessage.text=c+" "+d,t.$broadcast("ui_peer_draft",{customSelection:[c+" "+d,"",""]})},1e3)}}function y(e){t.draftMessage.replyToMessage=d.wrapForDialog(e),t.$broadcast("ui_peer_reply"),P=!1}function b(){var e=t.draftMessage.replyToMessage;e&&t.historyState.replyKeyboard&&t.historyState.replyKeyboard.mid==e.mid&&!t.historyState.replyKeyboard.pFlags.hidden&&(t.historyState.replyKeyboard.pFlags.hidden=!0,t.$broadcast("ui_keyboard_update")),delete t.draftMessage.replyToMessage,t.$broadcast("ui_peer_reply")}function w(){t.draftMessage.fwdMessages&&t.draftMessage.fwdMessages.length&&(delete t.draftMessage.fwdMessages,t.$broadcast("ui_peer_reply"),F==t.curDialog.peer&&(F=!1))}function k(){if(t.draftMessage.fwdMessages&&t.draftMessage.fwdMessages.length){var e=t.draftMessage.fwdMessages.slice();w(),setZeroTimeout(function(){d.forwardMessages(t.curDialog.peerID,e)})}}function $(e){return t.draftMessage.text=t.draftMessage.text&&"/"==t.draftMessage.text.charAt(0)?"":"/",t.$broadcast("ui_peer_draft",{focus:!0}),cancelEvent(e)}function C(){var e=t.curDialog.peerID,n=d.getReplyKeyboard(e);n&&(n=d.wrapReplyMarkup(n)),t.historyState.replyKeyboard=n;var a=n&&!n.pFlags.hidden&&("replyKeyboardForceReply"==n._||"replyKeyboardMarkup"==n._&&0>e);a?(y(n.mid),P=!0):P&&b();var i=n&&!n.pFlags.hidden&&"replyKeyboardMarkup"==n._;t.$broadcast("ui_keyboard_update",{enabled:i}),t.$emit("ui_panel_update",{blur:i})}function S(e){var n=t.historyState.replyKeyboard;return n&&(n.pFlags.hidden=!n.pFlags.hidden,C()),cancelEvent(e)}function M(e){if(e&&e.length){t.historyFilter.mediaType||t.historyState.skipped||d.readHistory(t.curDialog.peerID);var n={};n["draft"+t.curDialog.peerID]=e,i.set(n)}else i.remove("draft"+t.curDialog.peerID);x(e)}function x(a){N&&n.cancel(N);var i=++O;if(!a||!a.length)return delete t.draftMessage.inlineProgress,void t.$broadcast("inline_results",!1);var o=a.match(R);if(!o)return delete t.draftMessage.inlineProgress,void t.$broadcast("inline_results",!1);var s,r=o[1];t.draftMessage.inlineProgress=!0,s=U&&U.username==r?e.when(U):u.resolveInlineMention(r),s.then(function(e){i==O&&(U=e,t.$broadcast("inline_placeholder",{prefix:"@"+r+o[2],placeholder:e.placeholder}),N&&n.cancel(N),N=n(function(){var n=m.parseEmojis(o[3]);u.getInlineResults(t.curDialog.peerID,e.id,n,e.geo,"").then(function(e){N=!1,i==O&&(e.text=a,t.$broadcast("inline_results",e),delete t.draftMessage.inlineProgress)},function(){t.$broadcast("inline_results",!1),delete t.draftMessage.inlineProgress})},500))},function(){t.$broadcast("inline_results",!1),delete t.draftMessage.inlineProgress})}function I(){return l.isChannel(t.curDialog.peerID)&&!l.isMegagroup(t.curDialog.peerID)?!1:void a.invokeApi("messages.setTyping",{peer:l.getInputPeerByID(t.curDialog.peerID),action:{_:"sendMessageTypingAction"}})}function A(e){if(angular.isArray(e)&&e.length){var n={replyToMsgID:t.draftMessage.replyToMessage&&t.draftMessage.replyToMessage.mid,isMedia:t.draftMessage.isMedia};delete t.draftMessage.replyToMessage,e[0].lastModified&&e.sort(function(e,t){return e.lastModified-t.lastModified});for(var a=0;ae?[-1,-2]:[1,2],a=_.indexOf(t.messageID);angular.forEach(n,function(e){var t=_[a+e];if(void 0!==t&&void 0===v[t]){v[t]=!0;var n=o.getMessage(t),s=n.media.photo.id;i.preloadPhoto(s)}})}function u(e){var n=_.indexOf(t.messageID);b?e&&(t.count=Math.max(e,_.length)):t.count=_.length,t.pos=t.count-n,t.nav.hasNext=n>0,t.nav.hasPrev=b||n<_.length-1,t.canForward=t.canDelete=t.messageID>0}function p(n){var a=_.indexOf(t.messageID),s=a>=0?a+n:0,r=++w,l=s>=_.length?m():e.when();l.then(function(){if(r==w){var e=_[s],a=o.getMessage(e),l=a&&a.media&&(a.media.photo&&a.media.photo.id||a.media.webpage&&a.media.webpage.photo&&a.media.webpage.photo.id);if(!l)return void console.error("Invalid photo message",s,_,e,a);t.messageID=e,t.photoID=l,t.photo=i.wrapForFull(t.photoID),v[t.messageID]=!0,u(),n>0&&b&&_.indexOf(e)+1>=_.length?m():d(n)}})}function m(){return k?k:k=o.getSearch(g,h,f,y).then(function(t){return t.history.length?(y=t.history[t.history.length-1],_=_.concat(t.history),b=_.length=0&&(_=e.history,y=_[_.length-1],u(),d(1)),m()},m);var w=0,k=!1}}]).controller("UserpicModalController",["$q","$scope","$rootScope","$modalInstance","MtpApiManager","AppPhotosManager","AppUsersManager","AppPeersManager","AppMessagesManager","ApiUpdatesManager","PeersSelectService","ErrorService",function(e,t,n,a,i,o,s,r,l,c,d,u){function p(n,a){var i=f.indexOf(t.photoID),s=i>=0?i+n:0,r=++w,l=s>=f.length?g():e.when();l.then(function(){if(r==w){t.photoID=f[s],t.photo=o.wrapForFull(t.photoID),t.photo.thumb={location:o.choosePhotoSize(t.photo,0,0).location};var e;a&&(f.splice(i,1),e=t.count-1),h(e),v[t.photoID]=!0,h(),n>0&&b&&f.indexOf(t.photoID)+1>=f.length?g():m(n)}})}function m(e){var n=0>e?[-1,-2]:[1,2],a=f.indexOf(t.photoID);angular.forEach(n,function(e){var t=f[a+e];void 0!==t&&void 0===v[t]&&(v[t]=!0,o.preloadPhoto(t))})}function g(){return k?k:k=o.getUserPhotos(t.userID,_).then(function(t){return t.photos.length?(_=t.photos[t.photos.length-1],f=f.concat(t.photos),b=f.length0,t.nav.hasPrev=b||n=0&&(f=e.photos,_=f[f.length-1]),b=f.lengtha?-a:0;c.startBot(e.user.id,i).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 a=d.getPeerID(t);c.sendOther(a,{_:"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,a,i,o,s,r,l,c,d,u,p,m,g,h){function f(t){m.processUpdateMessage(t),n.$broadcast("history_focus",{peerString:e.chatFull.peerString})}function _(t){t&&t.type&&0===t.type.indexOf("image")&&(e.photo.updating=!0,c.uploadFile(t).then(function(t){return l.invokeApi("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},e.maxParticipants=200,s.getChatFull(e.chatID).then(function(t){e.chatFull=o.wrapForFull(e.chatID,t),e.$broadcast("ui_height"),e.canMigrate=e.chatFull&&e.chatFull.participants&&e.chatFull.participants.participants&&e.chatFull.participants.participants.length>=200,(Config.Modes.test||Config.Modes.debug)&&(e.canMigrate=!0),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)}),g.selectContacts({disabled:t}).then(function(t){angular.forEach(t,function(t){l.invokeApi("messages.addChatUser",{chat_id:o.getChatInput(e.chatID),user_id:i.getUserInput(t),fwd_limit:100}).then(function(e){m.processUpdateMessage(e)})}),n.$broadcast("history_focus",{peerString:e.chatFull.peerString})})},e.migrateToSuperGroup=function(){h.confirm({type:"SUPERGROUP_MIGRATE"}).then(function(){l.invokeApi("messages.migrateChat",{chat_id:o.getChatInput(e.chatID)}).then(f)})},e.kickFromGroup=function(t){l.invokeApi("messages.deleteChatUser",{chat_id:o.getChatInput(e.chatID),user_id:i.getUserInput(t)}).then(f)},e.flushHistory=function(){h.confirm({type:"HISTORY_FLUSH"}).then(function(){u.flushHistory(-e.chatID).then(function(){n.$broadcast("history_focus",{peerString:e.chatFull.peerString})})})},e.inviteViaLink=function(){var t=n.$new();t.chatID=e.chatID,a.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,a.open({templateUrl:templateUrl("chat_edit_modal"),controller:"ChatEditModalController",scope:t,windowClass:"md_simple_modal_window mobile_modal"})},e.hasRights=function(t){return o.hasRights(e.chatID,t)}}]).controller("ChannelModalController",["$scope","$timeout","$rootScope","$modal","AppUsersManager","AppChatsManager","AppProfileManager","AppPhotosManager","MtpApiManager","MtpApiFileManager","NotificationsManager","AppMessagesManager","AppPeersManager","ApiUpdatesManager","ContactsSelectService","ErrorService",function(e,t,n,a,i,o,s,r,l,c,d,u,p,m,g,h){function f(t){m.processUpdateMessage(t),n.$broadcast("history_focus",{peerString:e.chatFull.peerString})}function _(t){t&&t.type&&0===t.type.indexOf("image")&&(e.photo.updating=!0,c.uploadFile(t).then(function(t){return l.invokeApi("channels.editPhoto",{channel:o.getChannelInput(e.chatID),photo:{_:"inputChatUploadedPhoto",file:t,crop:{_:"inputPhotoCropAuto"}}}).then(f)})["finally"](function(){e.photo.updating=!1}))}e.chatFull=o.wrapForFull(e.chatID,{}),e.settings={notifications:!0},e.isMegagroup=o.isMegagroup(e.chatID),s.getChannelFull(e.chatID,!0).then(function(t){e.chatFull=o.wrapForFull(e.chatID,t),e.$broadcast("ui_height"),d.savePeerSettings(-e.chatID,t.notify_settings),d.getPeerMuted(-e.chatID).then(function(t){e.settings.notifications=!t,e.$watch("settings.notifications",function(t,n){return t===n?!1:void d.getPeerSettings(-e.chatID).then(function(n){n.mute_until=t?0:2e9,d.updatePeerSettings(-e.chatID,n)})})}),e.chatFull.chat&&e.chatFull.chat.pFlags.creator&&e.chatFull.exported_invite&&"chatInviteEmpty"==e.chatFull.exported_invite._&&s.getChatInviteLink(e.chatID,!0).then(function(t){e.chatFull.exported_invite={_:"chatInviteExported",link:t}})}),e.leaveChannel=function(){l.invokeApi("channels.leaveChannel",{channel:o.getChannelInput(e.chatID)}).then(f)},e.deleteChannel=function(){return h.confirm({type:e.isMegagroup?"MEGAGROUP_DELETE":"CHANNEL_DELETE"}).then(function(){l.invokeApi("channels.deleteChannel",{channel:o.getChannelInput(e.chatID)}).then(f)})},e.joinChannel=function(){l.invokeApi("channels.joinChannel",{channel:o.getChannelInput(e.chatID)}).then(f)},e.inviteToChannel=function(){var t=[];angular.forEach((e.chatFull.participants||{}).participants||[],function(e){t.push(e.user_id)}),g.selectContacts({disabled:t}).then(function(t){var n=[];angular.forEach(t,function(e){n.push(i.getUserInput(e))}),l.invokeApi("channels.inviteToChannel",{channel:o.getChannelInput(e.chatID),users:n}).then(f)})},e.kickFromChannel=function(t){l.invokeApi("channels.kickFromChannel",{channel:o.getChannelInput(e.chatID),user_id:i.getUserInput(t),kicked:!0}).then(f)},e.shareLink=function(t){var i=n.$new();return i.chatID=e.chatID,a.open({templateUrl:templateUrl("chat_invite_link_modal"),controller:"ChatInviteLinkModalController",scope:i,windowClass:"md_simple_modal_window"}),cancelEvent(t)},e.photo={},e.$watch("photo.file",_),e.deletePhoto=function(){e.photo.updating=!0,l.invokeApi("channels.editPhoto",{channel:o.getChannelInput(e.chatID),photo:{_:"inputChatPhotoEmpty"}}).then(f)["finally"](function(){e.photo.updating=!1})},e.editChannel=function(){var t=n.$new();t.chatID=e.chatID,a.open({templateUrl:templateUrl(e.isMegagroup?"megagroup_edit_modal":"channel_edit_modal"),controller:"ChannelEditModalController",scope:t,windowClass:"md_simple_modal_window mobile_modal"})},e.goToHistory=function(){n.$broadcast("history_focus",{peerString:e.chatFull.peerString})},e.hasRights=function(t){return o.hasRights(e.chatID,t)}}]).controller("SettingsModalController",["$rootScope","$scope","$timeout","$modal","AppUsersManager","AppChatsManager","AppPhotosManager","MtpApiManager","Storage","NotificationsManager","MtpApiFileManager","PasswordManager","ApiUpdatesManager","ChangelogNotifyService","LayoutSwitchService","AppRuntimeManager","ErrorService","_",function(e,t,n,a,i,o,s,r,l,c,d,u,p,m,g,h,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){i.saveApiUsers(e.users),r.getUserID().then(function(n){s.savePhoto(e.photo,{user_id:n}),p.processUpdateMessage({_:"updateShort",update:{_:"updateUserPhoto",user_id:n,date:tsNow(!0),photo:i.getUser(n).photo,previous:!0}}),t.photo={}})})})["finally"](function(){delete t.photo.updating}))}t.profile={},t.photo={},t.version=Config.App.version,r.getUserID().then(function(e){t.profile=i.getUser(e)}),r.invokeApi("users.getFullUser",{id:{_:"inputUserSelf"}}).then(function(e){i.saveApiUser(e.user),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 i=e.$new();i.password=t.password,angular.extend(i,n);var o=a.open({scope:i,templateUrl:templateUrl("password_update_modal"),controller:"PasswordUpdateModalController",windowClass:"md_simple_modal_window mobile_modal"});o.result["finally"](_)},t.showSessions=function(){a.open({templateUrl:templateUrl("sessions_list_modal"),controller:"SessionsListModalController",windowClass:"md_simple_modal_window mobile_modal"})},t.$on("$destroy",function(){n.cancel(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(){a.open({templateUrl:templateUrl("profile_edit_modal"),controller:"ProfileEditModalController",windowClass:"md_simple_modal_window mobile_modal"})},t.changeUsername=function(){a.open({templateUrl:templateUrl("username_edit_modal"),controller:"UsernameEditModalController",windowClass:"md_simple_modal_window mobile_modal"})},t.terminateSessions=function(){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(a){t.notify.desktop=!a[0],t.send.enter=a[1]?"":"1",t.notify.volume=a[2]!==!1?a[2]>0&&a[2]<=1?a[2]:0:.5,t.notify.canVibrate=c.getVibrateSupport(),t.notify.vibrate=!a[3],t.notify.preview=!a[4],t.notify.volumeOf4=function(){return 1+Math.ceil((t.notify.volume-.1)/.33)},t.toggleSound=function(){t.notify.volume=t.notify.volume?0:.5};var i;t.$watch("notify.volume",function(t,a){t!==a&&(l.set({notify_volume:t}),e.$broadcast("settings_changed"),c.clear(),i&&n.cancel(i),i=n(function(){c.testSound(t)},500))}),t.toggleDesktop=function(){t.notify.desktop=!t.notify.desktop,t.notify.desktop?l.remove("notify_nodesktop"):l.set({notify_nodesktop:!0}),e.$broadcast("settings_changed")},t.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",h.reload()})})},t.switchBackToDesktop=Config.Mobile&&!Config.Navigator.mobile,t.switchToDesktop=function(){g.switchLayout(!1)}}]).controller("ChangelogModalController",["$scope","$modal",function(e,t){if(e.currentVersion=Config.App.version,!e.lastVersion){var n=e.currentVersion.split(".");e.lastVersion=n[0]+"."+n[1]+"."+Math.max(0,n[2]-1)}e.changelogHidden=!1,e.changelogShown=!1,e.canShowVersion=function(t){if(e.changelogShown)return!0;var n=versionCompare(t,e.lastVersion)>=0;return n||(e.changelogHidden=!0),n},e.showAllVersions=function(){e.changelogShown=!0,e.changelogHidden=!1,e.$emit("ui_height"),e.$broadcast("ui_height")},e.changeUsername=function(){t.open({templateUrl:templateUrl("username_edit_modal"),controller:"UsernameEditModalController",windowClass:"md_simple_modal_window mobile_modal"})}}]).controller("ProfileEditModalController",["$scope","$modalInstance","AppUsersManager","MtpApiManager",function(e,t,n,a){e.profile={},e.error={},a.getUserID().then(function(t){e.profile=n.getUser(t)}),e.updateProfile=function(){e.profile.updating=!0,a.invokeApi("account.updateProfile",{first_name:e.profile.first_name||"",last_name:e.profile.last_name||""}).then(function(a){e.error={},n.saveApiUser(a),t.close()},function(n){switch(n.type){case"FIRSTNAME_INVALID":e.error={field:"first_name"},n.handled=!0;break;case"LASTNAME_INVALID":e.error={field:"last_name"},n.handled=!0;break;case"NAME_NOT_MODIFIED":n.handled=!0,t.close()}})["finally"](function(){delete e.profile.updating})}}]).controller("UsernameEditModalController",["$scope","$modalInstance","AppUsersManager","MtpApiManager",function(e,t,n,a){e.profile={},e.error={},a.getUserID().then(function(t){e.profile=angular.copy(n.getUser(t))}),e.updateUsername=function(){e.profile.updating=!0,a.invokeApi("account.updateUsername",{username:e.profile.username||""}).then(function(a){e.checked={},n.saveApiUser(a),t.close()},function(e){"USERNAME_NOT_MODIFIED"==e.type&&(e.handled=!0,t.close())})["finally"](function(){delete e.profile.updating})},e.$watch("profile.username",function(t){return t&&t.length?void a.invokeApi("account.checkUsername",{username:t||""}).then(function(n){e.profile.username==t&&(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,a,i,o){function s(){n.cancel(r),i.invokeApi("account.getAuthorizations").then(function(t){e.sessionsLoaded=!0,e.authorizations=t.authorizations;for(var a,i=0,o=e.authorizations.length;o>i;i++)a=e.authorizations[i],a.current=1==(1&a.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(){i.invokeApi("account.resetAuthorization",{hash:e}).then(s)})},e.terminateAllSessions=function(){o.confirm({type:"TERMINATE_SESSIONS"}).then(function(){i.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,a,i,o,s){switch(e.passwordSettings={},e.updatePassword=function(){delete e.passwordSettings.error_field;var i;if("disable"==e.action)i=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;i=e.passwordSettings.email?t.when():o.confirm({type:"RECOVERY_EMAIL_EMPTY"})}e.passwordSettings.loading=!0,i.then(function(){a.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,a,i,o,s){e.checkCode=function(){e.recovery.updating=!0,a.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,a,i,o){function s(){e.selectedContacts={},e.selectedCount=0}function r(n){var a=++l,s=[];o.getContacts(n).then(function(t){a==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(){a==l&&i.invokeApi("contacts.search",{q:n,limit:10}).then(function(t){o.saveApiUsers(t.users),a==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)}),a.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,a,i){e.selectedPeers={},e.selectedPeerIDs=[],e.selectedCount=0,e.dialogSelect=function(o){if(!e.multiSelect){var s;if(e.confirm_type){var r=a.getPeerID(o),l=a.getPeer(r);s=i.confirm({type:e.confirm_type,peer_id:r,peer_data:l})}else s=n.when();return void s.then(function(){t.close(o)})}var r=a.getPeerID(o);if(e.selectedPeers[r]){delete e.selectedPeers[r],e.selectedCount--;var c=e.selectedPeerIDs.indexOf(r);c>=0&&e.selectedPeerIDs.splice(c,1)}else e.selectedPeers[r]=a.getPeer(r),e.selectedCount++,e.selectedPeerIDs.unshift(r)},e.submitSelected=function(){if(e.selectedCount>0){var n=[];return angular.forEach(e.selectedPeers,function(e,t){n.push(a.getPeerString(t))}),t.close(n)}},e.toggleSearch=function(){e.$broadcast("dialogs_search_toggle")}}]).controller("ChatCreateModalController",["$scope","$modalInstance","$rootScope","MtpApiManager","AppUsersManager","AppChatsManager","ApiUpdatesManager",function(e,t,n,a,i,o,s){e.group={name:""},e.createGroup=function(){if(e.group.name){e.group.creating=!0;var r=[];return angular.forEach(e.userIDs,function(e){r.push(i.getUserInput(e))}),a.invokeApi("messages.createChat",{title:e.group.name,users:r}).then(function(e){if(s.processUpdateMessage(e),e.updates&&e.updates.length){for(var a,i=0,r=e.updates.length;r>i;i++)if(a=e.updates[i],"updateNewMessage"==a._){n.$broadcast("history_focus",{peerString:o.getChatString(a.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,a,i,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 i;return i=o.isChannel(e.chatID)?a.invokeApi("channels.editTitle",{channel:o.getChannelInput(e.chatID),title:e.group.name}):a.invokeApi("messages.editChatTitle",{chat_id:o.getChatInput(e.chatID),title:e.group.name}),i.then(function(t){s.processUpdateMessage(t);var a=o.getChatString(e.chatID);n.$broadcast("history_focus",{peerString:a})})["finally"](function(){delete e.group.updating})}}}]).controller("ChannelEditModalController",["$q","$scope","$modalInstance","$rootScope","MtpApiManager","AppUsersManager","AppChatsManager","AppProfileManager","ApiUpdatesManager",function(e,t,n,a,i,o,s,r,l){function c(){return i.invokeApi("channels.editTitle",{channel:s.getChannelInput(t.chatID),title:t.channel.title}).then(function(e){l.processUpdateMessage(e)})}function d(){return i.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()),t.channel.updating=!0,e.all(n).then(function(){var e=s.getChatString(t.chatID);a.$broadcast("history_focus",{peerString:e})})["finally"](function(){delete t.channel.updating})}}}]).controller("ChatInviteLinkModalController",["_","$scope","$timeout","$modalInstance","AppChatsManager","AppProfileManager","ErrorService",function(e,t,n,a,i,o,s){function r(){n(function(){t.$broadcast("ui_invite_select")},100)}function l(e){var n=i.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=i.isChannel(t.chatID),d=i.isMegagroup(t.chatID);t.revokeLink=function(){s.confirm({type:c&&!d?"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,a,i,o){void 0===e.importContact&&(e.importContact={}),e.phonebookAvailable=o.isAvailable(),e.doImport=function(){e.importContact&&e.importContact.phone&&(e.progress={enabled:!0},a.importContact(e.importContact.phone,e.importContact.first_name||"",e.importContact.last_name||"").then(function(e){e||i.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,a){e.search={},e.slice={limit:20,limitDelta:20};for(var i=SearchIndexManager.createIndex(),o=0;o5184e5?o=n?"mediumDate":"shortDate":i>432e5&&(o=n?"EEEE":"EEE"),t(a,o)}}]).filter("time",["$filter",function(e){var t={},n=e("date"),a=Config.Mobile?"shortTime":"mediumTime";return function(e){return t[e]?t[e]:t[e]=n(1e3*e,a)}}]).filter("myDate",["$filter",function(e){var t={},n=e("date");return function(e){return t[e]?t[e]:t[e]=n(1e3*e,"fullDate")}}]).filter("duration",[function(){return function(e){e=parseInt(e),isNaN(e)&&(e=0);var t=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){if(!e.total)return"";var a=n(e.done,!0),i=a.split(" "),o=n(e.total),s=o.split(" ");return s[1]===i[1]?t("format_size_progress_mulitple",{done:i[0],total:s[0],parts:i[1]||""}):t("format_size_progress",{done:a,total:o})}}]).filter("formatShortNumber",[function(){return function(e){if(!e)return"0";if(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"),a=t.pluralize("relative_time_pluralize_hours_ago"),i=e("dateOrTime");return function(e){var o=Math.abs(tsNow(!0)-e);if(60>o)return t("relative_time_just_now");if(3600>o){var s=Math.floor(o/60);return n(s)}if(86400>o){var r=Math.floor(o/3600);return a(r)}return i(e,!0)}}]),angular.module("myApp.services").service("AppMessagesManager",["$q","$rootScope","$location","$filter","$timeout","$sce","ApiUpdatesManager","AppUsersManager","AppChatsManager","AppPeersManager","AppPhotosManager","AppDocsManager","AppStickersManager","AppWebPagesManager","MtpApiManager","MtpApiFileManager","RichTextProcessor","NotificationsManager","Storage","AppProfileManager","TelegramMeWebService","ErrorService","StatusManager","_",function(e,t,n,a,i,o,s,r,l,c,d,u,p,m,g,h,f,_,v,y,b,w,k,$){function C(t,n,a){var i=Ct,o=angular.isString(t)&&t.length;if(o){if(!a||Tt.query!==t){Tt.query=t;var s=SearchIndexManager.search(t,Et);Tt.dialogs=[],angular.forEach(Ct.dialogs,function(e){s[e.peerID]&&Tt.dialogs.push(e)}),Tt.count=Tt.dialogs.length}i=Tt}else Tt.query=!1;var r=0;if(n>0)for(r=0;ri.dialogs[r].index);r++);return a=a||20,o||Wt||i.dialogs.length>=r+a?e.when({dialogs:i.dialogs.slice(r,r+a)}):x(a).then(function(){if(r=0,n>0)for(r=0;ri.dialogs[r].index);r++);return{dialogs:i.dialogs.slice(r,r+a)}})}function S(e){for(var t=0;tu)&&(u=p.date),t.index=I(u),t.peerID=n,A(t,d),r.mid&&r.mid>t.read_inbox_max_id&&(r.pFlags.unread=!0),void 0===$t[n]){var m={count:null,history:[o],pending:[]};$t[n]=m}_.savePeerSettings(n,t.notify_settings),t.pts&&s.addChannelState(e,t.pts)}function x(e){var n=Ct.dialogs,a=0,i=0,o=0;return Gt&&(a=Gt+Bt),g.invokeApi("messages.getDialogs",{offset_date:a,offset_id:P(i),offset_peer:c.getInputPeerByID(o),limit:e},{timeout:300}).then(function(e){a||b.setAuthorized(!0),r.saveApiUsers(e.users),l.saveApiChats(e.chats),Y(e.messages);var i=a?!0:!1;angular.forEach(e.dialogs,function(e){var n=c.getPeerID(e.peer);if("dialogChannel"==e._){var a=-n;M(a,e),s.addChannelState(a,e.pts)}else{if(0>n){var o=l.getChat(-n);if(o&&o.migrated_to&&o.pFlags.deactivated){var r=c.getPeerID(o.migrated_to);return Yt[n]=r,void(Zt[r]=n)}}var d=c.getPeerSearchText(n);SearchIndexManager.indexObject(n,d,Et);var u=H(e.top_message);if(e.index=I(u.date),e.peerID=n,A(e,u.date),i||(mt(e.top_message),i=!0),void 0===$t[n]){var p={count:null,history:[e.top_message],pending:[]};$t[n]=p,j(p,u)&&t.$broadcast("history_reply_markup",{peerID:n})}if(_.savePeerSettings(n,e.notify_settings),e.unread_count>0&&Ht&&e.top_message>Ht){var m=16&u.flags?u.from_id:n;!u.pFlags.unread||u.pFlags.out||u.pFlags.silent||_.getPeerMuted(m).then(function(e){e||gt(u)})}}}),(!e.dialogs.length||!e.count||n.length>=e.count)&&(Wt=!0)})}function I(e){return void 0===e&&(e=tsNow(!0)+Bt),65536*e+(65535&++Kt)}function A(e,t){t&&(!Gt||Gt>t)&&(Gt=t);var n=Ct.dialogs,a=S(e.peerID)[1];void 0!==a&&n.splice(a,1);var i,o=e.index,s=n.length;if(!s||o=n[0].index)n.unshift(e);else for(i=0;s>i;i++)if(o>n[i].index){n.splice(i,0,e);break}}function E(t,n,a,i){var o,d=c.isChannel(t),u=d&&c.isMegagroup(t);return o=d&&!u?g.invokeApi("channels.getImportantHistory",{channel:l.getChannelInput(-t),offset_id:n?P(n):0,add_offset:i||0,limit:a||0},{timeout:300,noErrorBox:!0}):g.invokeApi("messages.getHistory",{peer:c.getInputPeerByID(t),offset_id:n?P(n):0,add_offset:i||0,limit:a||0},{timeout:300,noErrorBox:!0}),o.then(function(e){return r.saveApiUsers(e.users),l.saveApiChats(e.chats),Y(e.messages),d&&s.addChannelState(-t,e.pts),0>t||!r.isBot(t)||e.messages.length==a&&a=e)return e;e=P(e);var n=Xt[t];return n||(n=++Qt*en,Jt[n]=t,Xt[t]=n),n+e}function D(e){if(en>e)return[e,0];var t=e%en,n=Jt[e-t];return[t,n]}function P(e){return e?e%en:0}function F(e){var t,n,a,i,o={},s={};for(t=0;t0)for(s=0;si.history[s]);s++);var r=i.history.length;i.history.splice(s,i.history.length-s),angular.forEach(o.messages,function(n){j(i,n)&&t.$broadcast("history_reply_markup",{peerID:e}),i.history.push(n.mid)});var l=i.history.length;a-=l-r;var c=Yt[e],d=Zt[e],u=void 0!==c||void 0!==d;if(u&&(i.count=Math.max(i.count,l)+1),a>0){if(n=i.history[l-1],u){if(!o.messages.length){if(!d)return i.count=l,!0;n=0,e=d}return R(e,n,a,i)}if(l=0;i--)if(o=bt[n.history[i]],o&&!o.pFlags.out&&o.pFlags.unread){n.unreadOffset=i+1;break}}return e.when(n)}function U(e,n){if(!Yt[e]&&!Zt[n]&&l.hasChat(-n)){var a=l.getChat(-e);a&&a.migrated_to&&a.migrated_to.channel_id==-n&&(Yt[e]=n,Zt[n]=e,i(function(){var a=S(e);a.length&&(Ct.dialogs.splice(a[1],1),t.$broadcast("dialog_drop",{peerID:e})),t.$broadcast("dialog_migrate",{migrateFrom:e,migrateTo:n})},100))}}function O(e){return Yt[e]?Yt[e]:void 0}function B(e,t,n,a,i){Yt[e]&&(e=Yt[e]);var o=$t[e],s=0,r=!1,l=!1,c=!1;i=i?Math.min(50,i):0,void 0===o&&(o=$t[e]={count:null,history:[],pending:[]});var d=!1,u=e;if(Zt[e]&&(d=!0,t&&en>t&&(u=Zt[e])),!n&&!t){var p=S(e)[0];if(p&&p.unread_count>1){var m=p.unread_count;(c=m>50)?p.read_inbox_max_id?(t=p.read_inbox_max_id,a=16,l=16,n=4):(n=20,l=16,s=m-l):(n=Math.max(10,i,m+2),l=m)}else Config.Mobile&&(n=20)}if(t>0)for(r=!0,s=0;so.history[s]){r=!1;break}if(!r&&(null!==o.count&&o.history.length==o.count||o.history.length>=s+(n||1))){a?(a=Math.min(s,a),s=Math.max(0,s-a),n+=a):n=n||(s?20:i||5);var g=o.history.slice(s,s+n);return!t&&o.pending.length&&(g=o.pending.slice().concat(g)),N(e,{count:o.count,history:g,unreadOffset:l,unreadSkip:c})}return a||n||(n=i||20),r&&(s=0),a||c||t&&-1==o.history.indexOf(t)?(a&&(s=-a,n+=a),E(u,t,n,s).then(function(n){o.count=n.count||n.messages.length,d&&o.count++;var a=[];return angular.forEach(n.messages,function(e){a.push(e.mid)}),!t&&o.pending.length&&(a=o.pending.slice().concat(a)),N(e,{count:o.count,history:a,unreadOffset:l,unreadSkip:c})})):R(e,t,n,o).then(function(){if(s=0,t>0)for(s=0;so.history[s]);s++);var a=o.history.slice(s,s+n);return!t&&o.pending.length&&(a=o.pending.slice().concat(a)),N(e,{count:o.count,history:a,unreadOffset:l,unreadSkip:c})})}function L(e){return($t[e]||{}).reply_markup||!1}function j(e,t){if(!t.reply_markup&&!t.pFlags.out&&!t.action)return!1;if(t.reply_markup&&"replyInlineMarkup"==t.reply_markup._)return!1;var n=t.reply_markup,a=e.reply_markup;if(n)return a&&a.mid>=t.mid?!1:!n.pFlags.selective||16&t.flags?(e.maxOutID&&t.mida.mid||t.mid<0)&&t.message)return a.pFlags.hidden=!0,!0}else(!e.maxOutID||t.mid>e.maxOutID)&&(e.maxOutID=t.mid);return t.action&&"messageActionChatDeleteUser"==t.action._&&(a?t.action.user_id==a.fromID:r.isBot(t.action.user_id))?(e.reply_markup={_:"replyKeyboardHide",mid:t.mid,flags:0,pFlags:{}},!0):!1}function q(t,n,a,i,o){var s=[],d=!n,u={peer:t,filter:a},p=d&&angular.equals(Dt,u);if(d&&!p&&(Dt=u,Pt=[]),t&&!i&&!n){var m=$t[t];if(void 0!==m&&m.history.length){var h,f,_,v={},y=o||20;switch(a._){case"inputMessagesFilterPhotos":v.messageMediaPhoto=!0;break;case"inputMessagesFilterPhotoVideo":v.messageMediaPhoto=!0,v.messageMediaDocument=!0,h="video";break;case"inputMessagesFilterVideo":v.messageMediaDocument=!0,h="video";break;case"inputMessagesFilterDocument":v.messageMediaDocument=!0,h=!1;break;case"inputMessagesFilterVoice":v.messageMediaDocument=!0,h="voice"}for(f=0;f=y)break}}if(s.length=y));f++);}if(s.length||1e3==o)return d&&(Pt=listMergeSorted(Pt,s)),e.when({count:null,history:s});var w;if(t||!n){var k=0;c.isChannel(t)&&!c.isMegagroup(t)&&(k|=1),w=g.invokeApi("messages.search",{flags:k,peer:c.getInputPeerByID(t),q:n||"",filter:a||{_:"inputMessagesFilterEmpty"},min_date:0,max_date:0,limit:o||20,max_id:i||0},{timeout:300,noErrorBox:!0})}else{var $=0,C=0,S=0,M=i&&H(i);M&&M.date&&($=M.date+Bt,S=M.id,C=it(M)),w=g.invokeApi("messages.searchGlobal",{q:n,offset_date:$,offset_peer:c.getInputPeerByID(C),offset_id:P(S),limit:o||20},{timeout:300,noErrorBox:!0})}return w.then(function(e){r.saveApiUsers(e.users),l.saveApiChats(e.chats),Y(e.messages);var t=e.count||e.messages.length;return s=[],angular.forEach(e.messages,function(e){var t=it(e);if(0>t){var n=l.getChat(-t);n.migrated_to&&U(t,-n.migrated_to.channel_id)}s.push(e.mid)}),d&&(Pt=listMergeSorted(Pt,s)),{count:t,history:s}},function(t){return 400==t.code&&(t.handled=!0),e.reject(t)})}function H(e){return bt[e]||{deleted:!0}}function V(t){var n=F(t),a=[];return angular.forEach(n.msgIDs,function(e,t){var i;if(t>0){var o=l.getChat(t);if(!(o.pFlags.creator||o.pFlags.editor&&o.pFlags.megagroup)){var r=[];if((o.pFlags.editor||o.pFlags.megagroup)&&angular.forEach(e,function(e,a){var i=H(n.mids[t][a]);i.pFlags.out&&r.push(e)}),!r.length)return;e=r}i=g.invokeApi("channels.deleteMessages",{channel:l.getChannelInput(t),id:e}).then(function(n){s.processUpdateMessage({_:"updateShort",update:{_:"updateDeleteChannelMessages",channel_id:t,messages:e,pts:n.pts,pts_count:n.pts_count}})})}else i=g.invokeApi("messages.deleteMessages",{id:e}).then(function(t){s.processUpdateMessage({_:"updateShort",update:{_:"updateDeleteMessages",messages:e,pts:t.pts,pts_count:t.pts_count}})});a.push(i)}),e.all(a)}function z(e){var n=c.isChannel(e),a=$t[e],i=S(e)[0];if(!i||!i.unread_count){if(!a||!a.history.length)return!1;var o,r,d=!1;for(p=a.history.length;p>=0;p--)if(o=a.history[p],r=bt[o],r&&!r.pFlags.out&&r.pFlags.unread){d=!0;break}if(!d)return!1}if(a.readPromise)return a.readPromise;var u;if(u=n?g.invokeApi("channels.readHistory",{channel:l.getChannelInput(-e),max_id:0}):g.invokeApi("messages.readHistory",{peer:c.getInputPeerByID(e),max_id:0}).then(function(e){s.processUpdateMessage({_:"updateShort",update:{_:"updatePts",pts:e.pts,pts_count:e.pts_count}})}),a.readPromise=u.then(function(){i&&(i.unread_count=0,t.$broadcast("dialog_unread",{peerID:e,count:0}),t.$broadcast("messages_read"),a&&a.history.length&&(i.read_inbox_max_id=a.history[0]))})["finally"](function(){delete a.readPromise}),a&&a.history.length){var o,r,p,e,i;for(p=0;pr.read_inbox_max_id:!0}e.reply_to_msg_id&&(e.reply_to_mid=T(e.reply_to_msg_id,i)),e.date-=Bt;var p=e.fwd_from;p&&(e.fwdFromID=p.from_id?p.from_id:-p.channel_id,p.date-=Bt),e.toID=n,e.fromID=e.from_id||n,e.via_bot_id>0&&(e.viaBotID=e.via_bot_id);var g={user_id:e.fromID,date:e.date};if(e.media)switch(e.media._){case"messageMediaEmpty":delete e.media;break;case"messageMediaPhoto":d.savePhoto(e.media.photo,g);break;case"messageMediaDocument":u.saveDoc(e.media.document,g);break;case"messageMediaWebPage":m.saveWebPage(e.media.webpage,e.mid,g)}if(e.action){var h,_;switch(e.action._){case"messageActionChatEditPhoto":d.savePhoto(e.action.photo,g),o&&(e.action._="messageActionChannelEditPhoto");break;case"messageActionChatEditTitle":o&&(e.action._="messageActionChannelEditTitle");break;case"messageActionChatDeletePhoto":o&&(e.action._="messageActionChannelDeletePhoto");break;case"messageActionChatAddUser":1==e.action.users.length?(e.action.user_id=e.action.users[0],e.fromID==e.action.user_id&&(e.action._=a?"messageActionChatJoined":"messageActionChatReturn")):e.action.users.length>1&&(e.action._="messageActionChatAddUsers");break;case"messageActionChatDeleteUser":e.fromID==e.action.user_id&&(e.action._="messageActionChatLeave");break;case"messageActionChannelMigrateFrom":h=-e.action.chat_id,_=-i;break;case"messageActionChatMigrateTo":h=-i,_=-e.action.channel_id}h&&_&&!Yt[h]&&!Zt[_]&&U(h,_)}if(e.message&&e.message.length){var v=f.parseEntities(e.message),y=e.entities||[];e.totalEntities=f.mergeEntities(v,y,!e.pending)}t||(bt[s]=e)}})}function Z(e,n,a){if(angular.isString(n)&&n.length){a=a||{};var i,o=At--,l=[nextRandomInt(4294967295),nextRandomInt(4294967295)],d=bigint(l[0]).shiftLeft(32).add(bigint(l[1])).toString(),u=$t[e],p=0,m={},h=a.replyToMsgID,_=c.isChannel(e),v=_&&c.isMegagroup(e),y=_&&!v?!0:!1,b=a.entities||[];a.viaBotID||(n=f.parseMarkdown(n,b)),void 0===u&&(u=$t[e]={count:null,history:[],pending:[]});var w=r.getSelf().id;e!=w&&(p|=2,m.out=!0,_||r.isBot(e)||(p|=1,m.unread=!0)),h&&(p|=8),y?w=0:p|=256,i={_:"message",id:o,from_id:w,to_id:c.getOutputPeer(e),flags:p,pFlags:m,date:tsNow(!0)+Bt,message:n,random_id:d,reply_to_msg_id:h,via_bot_id:a.viaBotID,reply_markup:a.reply_markup,entities:b,views:y&&1,pending:!0};var k=function(e){var n=wt[o];e?(i.error=!0,n&&(n.error=!0)):(delete i.error,n&&delete n.error),t.$broadcast("messages_pending")};i.send=function(){k(!1);var t={};xt[e]&&(t.afterMessageID=xt[e].messageID);var o=0;h&&(o|=1),y&&(o|=16);var r;a.viaBotID?r=g.invokeApi("messages.sendInlineBotResult",{flags:o,peer:c.getInputPeerByID(e),random_id:l,reply_to_msg_id:P(h),query_id:a.queryID,id:a.resultID},t):(b.length&&(o|=8),r=g.invokeApi("messages.sendMessage",{flags:o,peer:c.getInputPeerByID(e),message:n,random_id:l,reply_to_msg_id:P(h),entities:b},t)),r.then(function(e){"updateShortSentMessage"==e._&&(i.flags=e.flags,i.date=e.date,i.id=e.id,i.media=e.media,i.entities=e.entities,e={_:"updates",users:[],chats:[],seq:0,updates:[{_:"updateMessageID",random_id:d,id:e.id},{_:_?"updateNewChannelMessage":"updateNewMessage",message:i,pts:e.pts,pts_count:e.pts_count}]}),s.processUpdateMessage(e)},function(){k(!0)})["finally"](function(){xt[e]===t&&delete xt[e]}),xt[e]=t},Y([i]),u.pending.unshift(o),t.$broadcast("history_append",{peerID:e,messageID:o,my:!0}),setZeroTimeout(i.send),St[d]=[e,o]}}function X(n,a,i){i=i||{};var o,l,d=At--,u=[nextRandomInt(4294967295),nextRandomInt(4294967295)],p=bigint(u[0]).shiftLeft(32).add(bigint(u[1])).toString(),m=$t[n],f=0,_={},v=i.replyToMsgID,y=c.isChannel(n),b=y&&c.isMegagroup(n),w=y&&!b?!0:!1;i.isMedia?["image/jpeg","image/png","image/bmp"].indexOf(a.type)>=0?(o="photo",l="photo."+a.type.split("/")[1]):"audio/"==a.type.substr(0,6)||["video/ogg"].indexOf(a.type)>=0?(o="audio",l="audio."+("ogg"==a.type.split("/")[1]?"ogg":"mp3")):"video/"==a.type.substr(0,6)?(o="video",l="video.mp4"):(o="document",l="document."+a.type.split("/")[1]):(o="document",l="document."+a.type.split("/")[1]),console.log(o,l,a.type),void 0===m&&(m=$t[n]={count:null,history:[],pending:[]});var k=r.getSelf().id;n!=k&&(f|=2,_.out=!0,y||r.isBot(n)||(f|=1,_.unread=!0)),v&&(f|=8),w?k=0:f|=256;var $,C={_:"messageMediaPending",type:o,file_name:a.name||l,size:a.size,progress:{percent:1,total:a.size}},S={_:"message",id:d,from_id:k,to_id:c.getOutputPeer(n),flags:f,pFlags:_,date:tsNow(!0)+Bt,message:"",media:C,random_id:p,reply_to_msg_id:v,views:w&&1,pending:!0},M=function(e){var n=wt[d];e?(S.error=!0,n&&(n.error=!0)):(delete S.error,n&&delete n.error),t.$broadcast("messages_pending")},x=!1;S.send=function(){var i=e.defer();It.then(function(){(!x||S.error)&&(x=!1,$=h.uploadFile(a)),$.then(function(e){e.name=l,x=!0;var t;switch(o){case"photo":t={_:"inputMediaUploadedPhoto",file:e};break;case"document":default:t={_:"inputMediaUploadedDocument",file:e,mime_type:a.type,caption:"",attributes:[{_:"documentAttributeFilename",file_name:a.name}]}}var i=0;v&&(i|=1),w&&(i|=16),g.invokeApi("messages.sendMedia",{flags:i,peer:c.getInputPeerByID(n),media:t,random_id:u,reply_to_msg_id:P(v)}).then(function(e){s.processUpdateMessage(e)},function(e){return"photo"!=o||400!=e.code||"PHOTO_INVALID_DIMENSIONS"!=e.type&&"PHOTO_SAVE_FILE_INVALID"!=e.type?void M(!0):(e.handled=!0,o="document",void S.send())})},function(){M(!0)},function(e){C.progress.done=e.done,C.progress.percent=Math.max(1,Math.floor(100*e.done/e.total)),t.$broadcast("history_update",{peerID:n})}),C.progress.cancel=function(){x||(i.resolve(),$.cancel(),tt(p))},$["finally"](function(){i.resolve()})}),It=i.promise},Y([S]),m.pending.unshift(d),t.$broadcast("history_append",{peerID:n,messageID:d,my:!0}),setZeroTimeout(S.send),St[p]=[n,d]}function J(e,n,a){a=a||{};var i=At--,o=[nextRandomInt(4294967295),nextRandomInt(4294967295)],l=bigint(o[0]).shiftLeft(32).add(bigint(o[1])).toString(),m=$t[e],h=a.replyToMsgID,f=c.isChannel(e),_=f&&c.isMegagroup(e),v=f&&!_?!0:!1;void 0===m&&(m=$t[e]={count:null,history:[],pending:[]});var y,b=r.getSelf().id;switch(n._){case"inputMediaPhoto":y={_:"messageMediaPhoto",photo:d.getPhoto(n.id.id),caption:n.caption||""};break;case"inputMediaDocument":var w=u.getDoc(n.id.id);w.sticker&&w.stickerSetInput&&p.pushPopularSticker(w.id),y={_:"messageMediaDocument",document:w,caption:n.caption||""};break;case"inputMediaContact":y={_:"messageMediaContact",phone_number:n.phone_number,first_name:n.first_name,last_name:n.last_name,user_id:0};break;case"inputMediaGeoPoint":y={_:"messageMediaGeo",geo:{_:"geoPoint",lat:n.geo_point.lat,"long":n.geo_point["long"]}};break;case"inputMediaVenue":y={_:"messageMediaVenue",geo:{_:"geoPoint",lat:n.geo_point.lat,"long":n.geo_point["long"]},title:n.title,address:n.address,provider:n.provider,venue_id:n.venue_id};break;case"messageMediaPending":y=n}var k=0,$={};e!=b&&(k|=2,$.out=!0,r.isBot(e)||(k|=1,$.unread=!0)),h&&(k|=8),v?b=0:k|=256;var C={_:"message",id:i,from_id:b,to_id:c.getOutputPeer(e),flags:k,pFlags:$,date:tsNow(!0)+Bt,message:"",media:y,random_id:l,reply_to_msg_id:h,via_bot_id:a.viaBotID,reply_markup:a.reply_markup,views:v&&1,pending:!0},S=function(e){var n=wt[i];e?(C.error=!0,n&&(n.error=!0)):(delete C.error,n&&delete n.error),t.$broadcast("messages_pending")};C.send=function(){var t=0;h&&(t|=1),v&&(t|=16);var i={};xt[e]&&(i.afterMessageID=xt[e].messageID);var r;r=a.viaBotID?g.invokeApi("messages.sendInlineBotResult",{flags:t,peer:c.getInputPeerByID(e),random_id:o,reply_to_msg_id:P(h),query_id:a.queryID,id:a.resultID},i):g.invokeApi("messages.sendMedia",{flags:t,peer:c.getInputPeerByID(e),media:n,random_id:o,reply_to_msg_id:P(h)},i),r.then(function(e){s.processUpdateMessage(e)},function(){S(!0)})["finally"](function(){xt[e]===i&&delete xt[e]}),xt[e]=i},Y([C]),m.pending.unshift(i),t.$broadcast("history_append",{peerID:e,messageID:i,my:!0}),setZeroTimeout(C.send),St[l]=[e,i]}function Q(t,n){n=n.sort();var a=0,i=c.isChannel(t),o=i&&c.isMegagroup(t),r=i&&!o?!0:!1;r&&(a|=16);var l=F(n),d=[];return angular.forEach(l.msgIDs,function(e,n){for(var i=e.length,o=[],r=0;i>r;r++)o.push([nextRandomInt(4294967295),nextRandomInt(4294967295)]);var l={};xt[t]&&(l.afterMessageID=xt[t].messageID);var u=g.invokeApi("messages.forwardMessages",{flags:a,from_peer:c.getInputPeerByID(-n),id:e,random_id:o,to_peer:c.getInputPeerByID(t)},l).then(function(e){s.processUpdateMessage(e)})["finally"](function(){xt[t]===l&&delete xt[t]});xt[t]=l,d.push(u)}),e.all(d)}function et(e,t,n){var a=t?-t:e;if(n){var i=bigint(nextRandomInt(4294967295)).shiftLeft(32).add(bigint(nextRandomInt(4294967295))).toString();return g.invokeApi("messages.startBot",{bot:r.getUserInput(e),peer:c.getInputPeerByID(a),random_id:i,start_param:n}).then(function(e){s.processUpdateMessage(e)})}return t?l.isChannel(t)?g.invokeApi("channels.inviteToChannel",{channel:l.getChannelInput(t),users:[r.getUserInput(e)]}).then(function(e){s.processUpdateMessage(e),Z(a,"/start@"+bot.username)},function(t){if(t&&"USER_ALREADY_PARTICIPANT"==t.type){var n=r.getUser(e);Z(a,"/start@"+n.username),t.handled=!0}}):g.invokeApi("messages.addChatUser",{chat_id:l.getChatInput(t),user_id:r.getUserInput(e)}).then(function(e){s.processUpdateMessage(e),Z(a,"/start@"+bot.username)},function(t){if(t&&"USER_ALREADY_PARTICIPANT"==t.type){var n=r.getUser(e);Z(a,"/start@"+n.username),t.handled=!0}}):Z(a,"/start")}function tt(e){var t=St[e];if(console.log("pending",e,t),t){var n=t[0],a=t[1],i=$t[n],o=i.pending.indexOf(a);return s.processUpdateMessage({_:"updateShort",update:{_:"updateDeleteMessages",messages:[a]}}),-1!=o&&i.pending.splice(o,1),delete wt[a],delete bt[a],!0}return!1}function nt(e,n){var a=St[e];if(a){var i,o,s=a[0],r=a[1],l=$t[s],c=l.pending.indexOf(r);return-1!=c&&l.pending.splice(c,1),(i=bt[r])&&(delete i.pending,delete i.error,delete i.random_id,delete i.send),(o=wt[r])&&(wt[n.mid]=angular.extend(o,rt(n.mid)),delete o.pending,delete o.error,delete o.random_id,delete o.send,t.$broadcast("messages_pending")),delete wt[r],delete bt[r],i}return!1}function at(e){return g.invokeApi("messages.checkChatInvite",{hash:e}).then(function(n){var a;if("chatInviteAlready"==n._){if(l.saveApiChat(n.chat),!n.chat.pFlags.left)return t.$broadcast("history_focus",{peerString:l.getChatString(n.chat.id)});a=n.chat.title}else a=n.title;w.confirm({type:n.pFlags.channel&&!n.pFlags.megagroup?"JOIN_CHANNEL_BY_LINK":"JOIN_GROUP_BY_LINK",title:a}).then(function(){return g.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,a=0,i=e.updates.length;i>a;a++)if(n=e.updates[a],"updateNewMessage"==n._){t.$broadcast("history_focus",{peerString:l.getChatString(n.message.to_id.chat_id)});break}})})})}function it(e){var t=e.to_id&&c.getPeerID(e.to_id)||0;return 0>t?t:e.pFlags&&e.pFlags.out||2&e.flags?t:e.from_id}function ot(e,t){var n=e&&void 0!==t,a=t&&t.unread_count;if(n&&void 0!==kt[e])return delete kt[e].typing,kt[e].unreadCount=a,kt[e];var i=angular.copy(bt[e]);if(!i||!i.to_id){if(!t||!t.peerID)return i;i={_:"message",to_id:c.getOutputPeer(t.peerID),deleted:!0,date:tsNow(!0),pFlags:{}},i.deleted=!0}return i.peerID=it(i),i.peerData=c.getPeer(i.peerID),i.peerString=c.getPeerString(i.peerID),i.unreadCount=a,"messageService"==i._&&i.action.user_id&&(i.action.user=r.getUser(i.action.user_id)),i.message&&i.message.length&&(i.richMessage=f.wrapRichText(i.message.substr(0,64),{noLinks:!0,noLinebreaks:!0})),i.dateText=Vt(i.date),n&&(kt[e]=i),i}function st(e){delete kt[e]}function rt(e){if(void 0!==wt[e])return wt[e];var t=angular.copy(bt[e])||{id:e};t.media&&void 0!==t.media.progress&&(t.media.progress=bt[e].media.progress);var n=t.from_id&&r.getUser(t.from_id),a=n&&n.pFlags.bot&&n.username||!1,i=a||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=f.wrapRichText(t.media.caption,{noCommands:!i,fromBot:a})),t.media._){case"messageMediaPhoto":t.media.photo=d.wrapForHistory(t.media.photo.id);break;case"messageMediaDocument":t.media.document=u.wrapForHistory(t.media.document.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=f.wrapRichText(t.media.first_name+" "+(t.media.last_name||""),{noLinks:!0,noLinebreaks:!0});break;case"messageMediaWebPage":if(!t.media.webpage||"webPageEmpty"==t.media.webpage._){delete t.media;break}t.media.webpage=m.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=f.wrapRichText(t.action.title,{noLinebreaks:!0})||$("chat_title_deleted");break;case"messageActionBotIntro":t.action.rDescription=f.wrapRichText(t.action.description,{noCommands:!i,fromBot:a})}var l=t.reply_to_mid;return l&&(bt[l]?t.reply_to_msg=ot(l):(t.reply_to_msg={mid:l,loading:!0},-1==Ft.indexOf(l)&&(Ft.push(l),Rt===!1&&(Rt=setTimeout(ct,100))))),wt[e]=t}function lt(e){if(!e||"replyKeyboardHide"==e._)return!1;if(e.wrapped)return e;var t="replyInlineMarkup"==e._,n=e.rows&&e.rows.length||0;return!(!t&&n>0&&4>=n)||e.pFlags&&e.pFlags.resize||(e.splitCount=n),e.wrapped=!0,angular.forEach(e.rows,function(e){angular.forEach(e.buttons,function(e){e.rText=f.wrapRichText(e.text,{noLinks:!0,noLinebreaks:!0}),"keyboardButtonUrl"==e._&&(e.pUrl=f.wrapUrl(e.url,!0))})}),e}function ct(){if(Rt!==!1&&(clearTimeout(Rt),Rt=!1),Ft.length){var e=Ft.slice();Ft=[];var n=F(e);angular.forEach(n.msgIDs,function(e,a){var i;i=a>0?g.invokeApi("channels.getMessages",{channel:l.getChannelInput(a),id:e}):g.invokeApi("messages.getMessages",{id:e}),i.then(function(e){r.saveApiUsers(e.users),l.saveApiChats(e.chats),Y(e.messages),t.$broadcast("messages_downloaded",n.mids[a])})})}}function dt(){if(Ot!==!1&&(clearTimeout(Ot),Ot=!1),Ut.length){var e=Ut.slice();Ut=[];var t=F(e);angular.forEach(t.msgIDs,function(e,n){g.invokeApi("messages.getMessagesViews",{peer:c.getInputPeerByID(-n),id:e,increment:!0}).then(function(e){if(n){for(var a=t.mids[n],i=[],o=0;o0?u=Math.min(t,d):0>t&&(c=Math.max(0,u+t)),n=c;u>n;n++){if(o=e[n],a=Math.floor((o.date+yt)/86400),l=s&&s.grouped,r=o.grouped,a===i?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&&!Nt[o.mid]&&(Nt[o.mid]=!0,Ut.push(o.mid),Ot===!1&&(Ot=setTimeout(dt,1e4))),s&&s.fromID==o.fromID&&!s.fwdFromID==!o.fwdFromID&&s.viaBotID==o.viaBotID&&!s.action&&!o.action&&o.dateHt&&v.set({max_seen_msg:e})}function gt(e,n){n=n||{};var a,i,o=it(e),s={},c=!1,d=_.getNotifySettings();if(e.fwdFromID&&n.fwd_count)c=zt(n.fwd_count);else if(e.message)c=d.nopreview?$("conversation_message_sent"):f.wrapPlainText(e.message);else if(e.media)switch(e.media._){case"messageMediaPhoto":c=$("conversation_media_photo_raw");break;case"messageMediaDocument":switch(e.media.document.type){case"gif":c=$("conversation_media_gif_raw");break;case"sticker":c=$("conversation_media_sticker");var u=e.media.document.stickerEmojiRaw;void 0!==u&&(c=f.wrapPlainText(u)+" "+c);break;case"video":c=$("conversation_media_video_raw");break;case"voice":case"audio":c=$("conversation_media_audio_raw");break;default:c=e.media.document.file_name||$("conversation_media_document_raw")}break;case"messageMediaGeo":case"messageMediaVenue":c=$("conversation_media_location_raw");break;case"messageMediaContact":c=$("conversation_media_contact_raw");break;default:c=$("conversation_media_attachment_raw")}else if("messageService"==e._)switch(e.action._){case"messageActionChatCreate":c=$("conversation_group_created_raw");break;case"messageActionChatEditTitle":c=$("conversation_group_renamed_raw");break;case"messageActionChatEditPhoto":c=$("conversation_group_photo_updated_raw");break;case"messageActionChatDeletePhoto":c=$("conversation_group_photo_removed_raw");break;case"messageActionChatAddUser":case"messageActionChatAddUsers":c=$("conversation_invited_user_message_raw_raw");break;case"messageActionChatReturn":c=$("conversation_returned_to_group_raw");break;case"messageActionChatJoined":c=$("conversation_joined_group_raw");break;case"messageActionChatDeleteUser":c=$("conversation_kicked_user_message_raw");break;case"messageActionChatLeave":c=$("conversation_left_group_raw");break;case"messageActionChatJoinedByLink":c=$("conversation_joined_by_link_raw");break;case"messageActionChannelCreate":c=$("conversation_created_channel_raw");break;case"messageActionChannelEditTitle":c=$("conversation_changed_channel_name_raw");break;case"messageActionChannelEditPhoto":c=$("conversation_changed_channel_photo_raw");break;case"messageActionChannelDeletePhoto":c=$("conversation_removed_channel_photo_raw")}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||$("conversation_unknown_user_raw")),i=m,a=r.getUserString(o)}else{if(s.title=l.getChat(-o).title||$("conversation_unknown_chat_raw"),e.from_id>0){var p=r.getUser(e.from_id);s.title=(p.first_name||p.last_name||$("conversation_unknown_user_raw"))+" @ "+s.title}i=l.getChatPhoto(-o),a=l.getChatString(-o)}s.title=f.wrapPlainText(s.title),s.onclick=function(){t.$broadcast("history_focus",{peerString:a,messageID:16&e.flags?e.mid:0})},s.message=c,s.key="msg"+e.mid,s.tag=a,i.location&&!i.location.empty?h.downloadSmallFile(i.location,i.size).then(function(t){e.pFlags.unread&&(s.image=t,_.notify(s))}):_.notify(s)}function ht(){i.cancel(tn),tn=!1,t.$broadcast("history_multiappend",nn),nn={}}function ft(){i.cancel(an),an=!1,angular.forEach(on,function(e){A(e)}),t.$broadcast("dialogs_multiupdate",on),on={}}function _t(){i.cancel(sn),sn=!1;var e=t.idle.isIDLE&&k.isOtherDeviceActive()?3e4:1e3;angular.forEach(rn,function(t){t.isMutedPromise.then(function(n){var a=t.top_message;!n&&a.pFlags.unread&&setTimeout(function(){a.pFlags.unread&>(a,{fwd_count:t.fwd_count})},e)})}),rn={}}function vt(n){var a=-n;return e.all([y.getChannelFull(n,!0),B(a,0)]).then(function(e){var i=e[0],o=e[1],s=o.history[0],r={_:"dialogChannel",peer:c.getOutputPeer(a),top_message:s,top_important_message:s,read_inbox_max_id:i.read_inbox_max_id,unread_count:i.unread_count,unread_important_count:i.unread_important_count,notify_settings:i.notify_settings};M(n,r);var l={};l[a]=r,t.$broadcast("dialogs_multiupdate",l)})}var yt,bt={},wt={},kt={},$t={},Ct={count:null,dialogs:[]},St={},Mt={},xt={},It=e.when(),At=-1,Et=SearchIndexManager.createIndex(),Tt={query:!1},Dt={},Pt=[],Ft=[],Rt=!1,Nt={},Ut=[],Ot=!1,Bt=0,Lt=tsNow(!0),jt=Lt-Lt%86400,qt=new Date;v.get("server_time_offset").then(function(e){e&&(Bt=e)});var Ht=!1;Config.Modes.packed&&v.get("max_seen_msg").then(function(e){Ht=e||0});var Vt=a("dateOrTime"),zt=$.pluralize("conversation_forwarded_X_messages");qt.setHours(0),qt.setMinutes(0),qt.setSeconds(0),yt=jt-Math.floor(+qt/1e3),_.start();var Wt=!1,Gt=0,Kt=0,Yt={},Zt={},Xt={},Jt={},Qt=0,en=4294967296,tn=!1,nn={},an=!1,on={},sn=!1,rn={};return t.$on("apiUpdate",function(e,n){switch(n._){case"updateMessageID":var a=n.random_id,o=St[a];if(o){var s=o[0],d=c.isChannel(s)?-s:0;Mt[T(n.id,d)]=a}break;case"updateNewMessage":case"updateNewChannelMessage":var u=n.message,s=it(u),p=$t[s];if("updateNewChannelMessage"==n._){if(!l.isMegagroup(-s)&&!(u.pFlags.out||u.pFlags.mention||u.pFlags.post))break;var m=l.getChat(-s);if(m.pFlags&&(m.pFlags.left||m.pFlags.kicked))break}if(Y([u]),void 0!==p){var g=p.history;if(-1!=g.indexOf(u.mid))return!1;var h=g[0];g.unshift(u.mid),u.mid>0&&u.mid0&&E&&r.forceUserOnline(s),A=0;F>A;A++)if(x=g[A],!(x>D)&&(u=bt[x],u.pFlags.out==E)){if(!u.pFlags.unread)break;u&&u.pFlags.unread&&(u.pFlags.unread=!1,wt[x]&&(wt[x].pFlags.unread=!1,R||(R=!0)),kt[x]&&(kt[x].pFlags.unread=!1),u.pFlags.out||(y&&(P=--y[0].unread_count),_.cancel("msg"+x)))}!E&&y&&(P&&y[0].top_message<=D&&(P=y[0].unread_count=0),y[0]||console.error("empty found dialog",y,n),y[0].read_inbox_max_id=D),P!==!1&&t.$broadcast("dialog_unread",{peerID:s,count:P}),R&&t.$broadcast("messages_read");break;case"updateReadMessagesContents":var A,x,u,N,U=n.messages,O=U.length;for(A=0;O>A;A++)x=U[A],(u=bt[x])&&delete u.pFlags.media_unread,(N=wt[x])&&delete N.pFlags.media_unread;break;case"updateDeleteMessages":case"updateDeleteChannelMessages":var x,u,A,s,y,g,B={},d=n.channel_id;for(A=0;A0&&(i.count-=e.count,i.count<0&&(i.count=0));for(var r=0;r0,z="channel"==L._&&(L.username||!L.pFlags.left&&!L.pFlags.kicked)&&!0||!1,W=void 0!==$t[s];z!=W&&(delete $t[s],t.$broadcast("history_forbidden",s)),V!=q&&(q?vt(d):y[0]&&(Ct.dialogs.splice(y[1],1),t.$broadcast("dialog_drop",{peerID:s})));break;case"updateChannelReload":var d=n.channel_id,s=-d,y=S(s);y[0]&&Ct.dialogs.splice(y[1],1),delete $t[s],vt(d).then(function(){t.$broadcast("history_reload",s)});break;case"updateChannelMessageViews":var G=n.views,$=T(n.id,n.channel_id),u=H($);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
\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.3
\n
\n
    \n
  • Inline bots: A new way to add bot content to any chat. Type a bot\'s username and your query in the text field to get instant results and send them to your chat partner. Try typing @gif dog in your next chat. Sample bots: @gif, @wiki, @bing, @vid, @bold.
  • \n
  • Check out the Telegram Blog for more info.
  • \n
  • Improved GIFs: 20x faster sending and downloading, nice animated progress
  • \n
  • Click on message date to reply (or to forward from channels).
  • \n
  • Preview images before sending when pasting from clipboard.
  • \n
  • Improved formatting for copy-pasted history fragments (date, time and sender names inserted automatically).
  • \n
\n
\n
\n\n
\n
0.5.2
\n
\n
    \n
  • Unread counters for muted chats now colored in gray.
  • \n
  • Improved previews for sticker sets: Click on a sticker to view the whole set, click on stickers in a set to send right away, added a \'Share\' button.
  • \n
  • Improved performance.
  • \n
\n
\n
\n\n
\n
0.5.1
\n
\n
    \n
  • Groups that have reached their capacity of 200 users can be upgraded to supergroups of up to 1,000 members.
  • \n
  • Check out the Telegram Blog for more info
  • \n
\n
\n
\n\n
\n
0.5.0
\n
\n
    \n
  • Removed annoying "multiple tabs open" error.
  • \n
  • Improved message forwarding.
  • \n
  • Added view counter to messages from channels.
  • \n
  • Improved image loading in Safari and Firefox.
  • \n
\n
\n
\n\n
\n
0.4.9
\n
\n
    \n
  • New emoji and sticker menu, tabs for sticker packs.
  • \n
\n
\n
\n\n
\n
0.4.8
\n
\n
    \n
  • Introducing Channels – a great new way to broadcast your messages to unlimited audiences.
  • \n
  • Check out the Telegram Blog for more info
  • \n
  • Improved performance in Safari on OS X El Capitan.
  • \n
  • Added formatting for fixed-width code, surround text with `single backticks` for inline text and ```triple backticks``` for blocks of pre-formatted text.
  • \n
\n
\n
\n\n
\n
0.4.7
\n
\n
    \n
  • New bot API, free for everyone. If you\'re an engineer, create your own bots for games, services or integrations.\n
  • \n
  • Check out Telegram Blog for more info
  • \n
  • Improved Stickers support: now stickers are loading much faster.
  • \n
  • Click on any custom stickers in chats to view and add sticker sets.
  • \n
  • [Mobile] Reply to a message easily: tap on any message and select "Reply".
  • \n
\n
\n
\n\n
\n
0.4.6
\n
\n \n
\n
\n\n
\n
0.4.5
\n
\n
    \n
  • \n Invite links for group chats:
    \n Check out Telegram Blog for more info\n
  • \n
  • Smart notifications
  • \n
  • \'Listened\' status for voice messages
  • \n
  • Places in locations (venues, landmarks)
  • \n
\n
\n
\n\n
\n
0.4.4
\n
\n
    \n
  • Link Previews:
    \n Get rich link summaries for tweets, YouTube videos, Instagram photos and other content.
  • \n\n
  • Check out Telegram Blog for more info.
  • \n
\n
\n
\n\n
\n
0.4.3
\n
\n
    \n
  • Sessions List:
    \n View your active Telegram sessions (on desktop, tablet and mobile devices) and close specific sessions remotely.
  • \n\n
  • Two-step verification:
    \n Set up an additional password that will be required to log into your Telegram account.
  • \n\n
  • Check out Telegram Blog for more info.
  • \n
\n
\n
\n\n
\n
0.4.2
\n
\n
    \n
  • Optimization for screens with smaller Y-resolutions.
  • \n
  • Supported Spotify URL embeds.
  • \n
  • Mentions of the current user in group chats are now highlighted.
  • \n
\n
\n
\n\n
\n
0.4.1
\n
\n
    \n
  • Reply to specific messages in groups.
  • \n
  • Mention @usernames in groups to notify multiple users.
  • \n
  • Revised notifications in groups: mentioned users and people you reply to will be notified (private chat notification settings apply in this case instead of group settings). Check out Telegram Blog for more info.
  • \n
  • Setting to disable message preview
  • \n
\n
\n
\n\n
\n
0.4.0
\n
\n
    \n
  • Full stickers support
  • \n
  • Multisearch box: instantly find chats, usernames and messages
  • \n
  • Emoji autocomplete: e.g., type :kiss in the message field to see the list. Full cheat sheet »
  • \n
  • Added \'typing\' notification in chats list
  • \n
  • Online members counter in group headers
  • \n
\n
\n
\n\n
\n
0.3.9
\n
\n
    \n
  • [Desktop] Material design completed
  • \n
\n
\n
\n\n
\n
0.3.8
\n
\n
    \n
  • Telegram.me links open right in Telegram Web when authorized
  • \n
  • @username mentions in messages are clickable and open a conversation with the user
  • \n
\n
\n
\n\n
\n
0.3.7
\n
\n
    \n
  • [Desktop] New material design for modal windows
  • \n
  • [Desktop] Forward messages to multiple recipients
  • \n
\n
\n
\n\n
\n
0.3.6
\n
\n
    \n
  • New viewer for photos, videos, documents.
  • \n
  • [FirefoxOS] Improved media downloads.
  • \n
\n
\n
\n\n
\n
0.3.5
\n
\n
    \n
  • Added embedded Soundcloud tracks and playlists.
  • \n
  • Added global user search to contacts list.
  • \n
  • Added switch to mobile version on window resize.
  • \n
  • Migrate to HTTPS notification
  • \n
  • Bugfixes.
  • \n
\n
\n
\n\n
\n
0.3.4
\n
\n
    \n
  • Added embedded Facebook posts and Vimeo videos.
  • \n
  • Improved IE10+ support: downloading files and style fixes.
  • \n
  • Added unsupported media playback warning.
  • \n
  • Bugfixes.
  • \n
\n
\n
\n\n
\n
0.3.3
\n
\n
    \n
  • Added Native Client module: dramatically improved encryption speed; Download and upload speed is now as high as in native applications.
  • \n
  • HTTPS. We recommend you to use https://web.telegram.org.
  • \n
  • Added multiple open tabs warning. Please note, that only one tab with Telegram Web will work.
  • \n
  • Added embedded Instagram, Twitter, Vine, YouTube links.
  • \n
  • Jump to selected spot when playing back audio.
  • \n
  • Bugfixes
  • \n
\n
\n
\n\n
\n
0.3.2
\n
\n
    \n
  • Usernames support: Choose a username right now!
  • \n
  • Search can now find public users by username.
  • \n
  • Most popular emoticons shown in \'recent\' when empty
  • \n
  • [ChromeApp] Added saving window position and size
  • \n
  • Bugfixes
  • \n
\n
\n
\n\n
\n
0.3.1
\n
\n
    \n
  • New languages: Spanish, German and Italian are now available
  • \n
  • New custom-made audio player
  • \n
  • Bad browser page for IE 6-9
  • \n
  • Perfomance improvements and bugfixes
  • \n
\n
\n
\n\n
\n
0.3.0
\n
\n
    \n
  • Log in codes may be received in other Telegram apps
  • \n
  • Partner\'s online status updates automatically
  • \n
  • Added support for non-english hashtags in messages
  • \n
  • Fixed invalid scrollbar width bug
  • \n
  • [Desktop] Added automatic country code detection
  • \n
  • [FirefoxOS] Improved PUSH-notifications for <= 1.1
  • \n
  • [FirefoxOS] Fixed emoji in notifications
  • \n
  • [FirefoxOS] Fixed attachment bug for <= 1.1
  • \n
  • [FirefoxOS] Added phonebook permissions handling
  • \n
  • [FirefoxOS] Added ability to share Gallery photos in Telegram
  • \n
\n
\n
\n\n
\n\n\n \n\n
\n\n
'),e.put("partials/desktop/channel_edit_modal.html",'
\n\n
\n\n \n\n
\n\n \n\n
'),e.put("partials/desktop/channel_modal.html",'
\n\n
\n
\n
\n \n \n
\n
\n \n \n
\n
\n\n
\n
\n
\n \n
\n \n
\n
\n
\n
\n \n \n
\n
\n
\n
\n\n
\n
\n
\n \n \n
\n \n \n \n
\n
\n\n
\n\n
\n\n
\n \n\n
\n
\n \n
\n
\n
\n\n
\n
\n \n
\n
\n
\n\n
\n
\n \n \n \n \n
\n
\n
\n
\n\n \n\n
\n \n\n \n \n \n \n\n
\n\n \n\n
\n\n
\n\n
\n\n
\n \n\n
\n\n
\n\n \n \n\n \n\n
\n \n
\n
\n
\n\n
\n\n
\n\n
\n
\n\n\n
\n'),e.put("partials/desktop/chat_create_modal.html",'
\n\n
\n\n \n\n
\n\n \n\n
'),e.put("partials/desktop/chat_edit_modal.html",'
\n\n
\n\n \n\n
\n\n \n\n
'),e.put("partials/desktop/chat_invite_link_modal.html",'
\n\n
\n\n \n\n
\n\n \n\n
'),e.put("partials/desktop/chat_modal.html",'
\n\n
\n
\n
\n \n \n
\n
\n
\n\n
\n
\n
\n \n
\n \n
\n
\n
\n
\n \n \n
\n
\n
\n
\n\n
\n
\n
\n \n \n
\n
\n
\n\n
\n\n
\n\n \n\n \n\n
\n \n\n \n \n \n \n\n
\n\n \n\n \n\n
\n\n
\n\n
\n
\n

\n

\n
    \n
  • \n
  • \n
  • \n
  • \n
\n
\n
\n
\n\n
\n \n\n
\n\n
\n\n \n \n\n \n\n
\n \n
\n
\n
\n\n
\n\n
\n\n
\n
\n\n\n
\n'),e.put("partials/desktop/composer_dropdown.html",'
\n\n \n\n \n\n
    \n\n
    \n\n
    '),e.put("partials/desktop/confirm_modal.html",'
    \n\n
    \n\n
    \n \n \n \n \n \n\n \n \n \n \n
    \n \n
    \n
    \n \n \n \n \n \n \n \n
    \n \n
    \n \n
    \n
    \n \n \n \n \n \n \n \n \n \n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n\n\n\n \n \n \n \n
    \n\n
    \n\n \n\n
    \n'),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'),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
    '),e.put("partials/desktop/full_document.html",'
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n \n
    \n
    '),e.put("partials/desktop/full_gif.html",'\n\n
    \n\n
    \n
    \n \n \n \n \n
    \n
    \n
    [GIF]
    \n
    \n\n
    \n \n \n
    \n \n\n
    \n\n
    '),e.put("partials/desktop/full_photo.html",'
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    \n
    \n
    '),e.put("partials/desktop/full_video.html",'
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n \n
    \n
    \n
    \n
    \n
    \n
    '),e.put("partials/desktop/head.html",'
    \n
    \n\n
    \n \n
    \n\n
    \n
    \n \n \n \n
    \n\n
    \n\n \n\n \n\n \n \n \n \n \n\n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n\n \n
    \n \n \n \n \n \n
    \n
    \n\n
    \n\n
    \n
    \n
    \n
    '),e.put("partials/desktop/im.html",'
    \n\n
    \n\n
    \n\n
    \n
    \n \n
    \n\n
    \n
    \n
    \n\n
    \n

    \n

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

    \n

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

    \n
    \n
    \n \n
    \n
    \n
    \n
    '),e.put("partials/desktop/inline_results.html",'\n\n'),e.put("partials/desktop/lang_footer.html",''),e.put("partials/desktop/login.html",'\n\n'),e.put("partials/desktop/media_modal_layout.html",''),e.put("partials/desktop/megagroup_edit_modal.html",'
    \n\n
    \n\n \n\n
    \n\n \n\n
    '),e.put("partials/desktop/message.html",'
    \n\n\n
    \n\n
    \n
    \n
    \n
    \n
    \n
    \n \n \n
    \n\n \n \n \n\n
    \n\n
    \n \n\n \n \n \n \n\n \n\n
    \n
    \n
    \n \n
    \n
    \n \n
    \n\n
    \n\n \n []  :\n \n\n\n \n\n
    \n \n \n
    \n   [\n \n \n \n
    \n
    \n\n
    \n
    \n
    \n
    \n
    \n\n\n
    \n\n
    \n
    \n\n
    \n\n'),e.put("partials/desktop/message_attach_contact.html",'
    \n \n
    \n \n \n
    \n
    \n
    '),e.put("partials/desktop/message_attach_document.html",'
    \n\n
    \n\n
    \n\n
    \n
    \n
    \n\n
    \n
    \n
    \n\n
    \n \n \n \n \n \n\n
    \n
    \n [ ]\n \n \n
    \n
    \n \n \n \n \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n\n
    \n\n \n \n \n \n
    \n \n
    \n
    \n\n
    \n
    \n []\n \n \n
    \n
    \n \n \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n\n
    \n
    \n
    \n'),e.put("partials/desktop/message_attach_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_webpage.html",'
    \n
    \n
    \n \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n \n \n \n \n
    \n\n
    \n
    \n
    \n\n
    \n
    \n \n
    \n
    \n
    \n\n
    \n \n \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n'),e.put("partials/desktop/message_media.html",'
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    '),e.put("partials/desktop/message_service.html",'\n \n \n \n «»\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \n \n \n \n «»\n \n \n \n\n \n \n \n\n\n \n \n \n\n'),e.put("partials/desktop/password_recovery_modal.html",'
    \n\n
    \n\n \n\n
    \n\n \n\n
    '),e.put("partials/desktop/password_update_modal.html",'
    \n\n
    \n\n \n\n
    \n\n \n\n
    '),e.put("partials/desktop/peer_select.html",'
    \n\n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n\n
    \n\n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n\n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n\n
    \n\n \n\n \n\n
    \n'),e.put("partials/desktop/photo_modal.html",'\n\n\n\n
    \n
    \n
    \n \n \n \n \n \n \n \n \n \n
    \n\n
    \n \n
    \n \n
    \n
    \n \n \n
    \n
    \n\n
    \n
    \n \n
    \n
    \n
    \n\n
    \n \n \n \n \n \n
    \n
    \n
    \n\n\n\n'),e.put("partials/desktop/pinned_message.html",''),e.put("partials/desktop/profile_edit_modal.html",'
    \n\n
    \n\n \n\n
    \n\n \n\n
    \n'),e.put("partials/desktop/reply_markup.html",'
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    '),e.put("partials/desktop/reply_message.html",'
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n \n
    \n
    \n \n \n
    \n
    '),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/short_message.html",'\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n'),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
    \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'),e.put("partials/mobile/edit_contact_modal.html",'
    \n\n
    \n \n
    \n\n \n\n
    '),e.put("partials/mobile/full_gif.html",'\n\n
    \n\n
    \n
    \n \n \n \n \n
    \n
    \n
    GIF
    \n
    \n\n
    \n \n \n
    \n \n\n
    \n\n
    '),e.put("partials/mobile/full_photo.html",'
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n \n \n
    \n
    \n
    \n
    \n
    \n
    '),e.put("partials/mobile/full_video.html",'
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n \n \n
    \n
    \n
    \n
    \n
    \n
    '),e.put("partials/mobile/head.html",'
    \n \n
    \n'),e.put("partials/mobile/im.html",'
    \n\n
    \n\n
    \n\n
    \n
    \n \n
    \n\n
    \n\n
    \n

    \n

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

    --- 
     ---
    ',o='
    '+t("unread_messages_split")+"
    ",s="im_message_selected",r="im_message_focus",l="im_message_unread",c="im_message_error",d="im_message_pending";return{templateUrl:templateUrl("message"),link:n}}]).directive("myMessageBody",["$compile","AppPeersManager","AppChatsManager","AppUsersManager","AppMessagesManager","AppInlineBotsManager","RichTextProcessor",function(e,t,n,a,i,o,s){function r(e,i,o){if("string"!=typeof o.message||!o.message.length)return void $(".im_message_text",i).hide();var r=o.from_id&&a.getUser(o.from_id),l=r&&r.pFlags.bot&&r.username||!1,c=t.getPeerID(o.to_id),d=l||0>c&&!(n.isChannel(-c)&&!n.isMegagroup(-c))||c>0&&a.isBot(c),u={noCommands:!d,fromBot:l,entities:o.totalEntities};if(o.pFlags.mentioned){var p=a.getSelf();p&&(u.highlightUsername=p.username)}var m=s.wrapRichText(o.message,u);$(".im_message_text",i).html(m.valueOf())}function l(e,t,n){if(!n.media)return void $(".im_message_media",t).hide();var a=e.$new(!0);a.media=n.media,a.messageId=n.mid,u(a,function(e){$(".im_message_media",t).replaceWith(e) -})}function c(e,t,n){if(!n.reply_markup||"replyInlineMarkup"!=n.reply_markup._)return void $(".im_message_keyboard",t).hide();var a=e.$new(!0);a.markup=i.wrapReplyMarkup(n.reply_markup),a.messageId=n.mid,p(a,function(e){$(".im_message_keyboard",t).replaceWith(e)}),a.$on("reply_inline_button_press",function(e,t){switch(t._){case"keyboardButtonSwitchInline":o.switchInlineButtonClick(n.mid,t);break;case"keyboardButtonCallback":o.callbackButtonClick(n.mid,t)}})}function d(e,t){var n=e.message;n.dir=!0;var a=n.mid;if(r(e,t,n),l(e,t,n),c(e,t,n),n.pending)var i=e.$on("messages_pending",function(){n.mid!=a&&(r(e,t,n),i())});e.$on("message_edit",function(a,i){i.mid==n.mid&&(r(e,t,n),l(e,t,n),c(e,t,n),e.$emit("ui_height"))})}var u=e('
    '),p=e('
    ');return{link:d,scope:{message:"=myMessageBody"}}}]).directive("myMessageViews",["$filter","AppMessagesManager",function(e,t){function n(e,t){t.html(i(e))}function a(e,a,i){var o=e.$eval(i.myMessageViews),s=t.getMessage(o).views||0;n(s,a),e.$on("message_views",function(e,t){t.mid==o&&n(t.views,a)})}var i=e("formatShortNumber");return{link:a}}]).directive("myReplyMarkup",function(){function e(e,t){var n=$(".reply_markup",t),a=new Scroller(n,{classPrefix:"reply_markup",maxHeight:170});e.buttonClick=function(t){e.$emit("reply_button_press",t)},e.$on("ui_keyboard_update",function(t,n){onContentLoaded(function(){a.updateHeight(),a.scrollTo(0),e.$emit("ui_panel_update",{blur:n&&n.enabled})})}),onContentLoaded(function(){a.updateHeight(),e.$emit("ui_panel_update")})}return{templateUrl:templateUrl("reply_markup"),scope:{replyMarkup:"=myReplyMarkup"},link:e}}).directive("myMessageMedia",function(){return{scope:{media:"=myMessageMedia",messageId:"=messageId"},templateUrl:templateUrl("message_media")}}).directive("myMessagePhoto",["AppPhotosManager",function(e){return{scope:{media:"=myMessagePhoto",messageId:"=messageId"},templateUrl:templateUrl("message_attach_photo"),link:function(t){t.openPhoto=e.openPhoto,t.preloadPhoto=e.preloadPhoto}}}]).directive("myMessageDocument",["AppDocsManager",function(e){return{scope:{media:"=myMessageDocument",messageId:"=messageId"},templateUrl:templateUrl("message_attach_document"),link:function(t){e.updateDocDownloaded(t.media.document.id),t.docSave=function(){e.saveDocFile(t.media.document.id)},t.docOpen=function(){return t.media.document.withPreview?void e.openDoc(t.media.document.id,t.messageId):t.docSave()},t.videoOpen=function(){e.openVideo(t.media.document.id,t.messageId)}}}}]).directive("myMessageGeo",function(){return{scope:{media:"=myMessageGeo"},templateUrl:templateUrl("message_attach_geo")}}).directive("myMessageVenue",function(){return{scope:{media:"=myMessageVenue"},templateUrl:templateUrl("message_attach_venue")}}).directive("myMessageContact",function(){return{scope:{media:"=myMessageContact"},templateUrl:templateUrl("message_attach_contact")}}).directive("myMessageWebpage",["AppWebPagesManager","AppPhotosManager",function(e,t){return{scope:{media:"=myMessageWebpage",messageId:"=messageId"},templateUrl:templateUrl("message_attach_webpage"),link:function(n){n.openPhoto=t.openPhoto,n.openEmbed=function(t){return n.media.webpage&&n.media.webpage.embed_url?(e.openEmbed(n.media.webpage.id,n.messageId),cancelEvent(t)):void 0},n.$on("webpage_updated",function(e,t){n.media.webpage&&n.media.webpage.id==t.id&&n.$emit("ui_height")})}}}]).directive("myMessagePending",function(){return{scope:{media:"=myMessagePending"},templateUrl:templateUrl("message_attach_pending")}}).directive("myInlineReplyMarkup",function(){function e(e){e.buttonClick=function(t){e.$emit("reply_inline_button_press",t)}}return{templateUrl:templateUrl("reply_markup"),scope:{replyMarkup:"=myInlineReplyMarkup"},link:e}}).directive("myServiceMessage",function(){return{templateUrl:templateUrl("message_service")}}).directive("myShortMessage",function(){return{scope:{message:"=myShortMessage"},templateUrl:templateUrl("short_message")}}).directive("myReplyMessage",["AppMessagesManager","AppPeersManager","$rootScope",function(e,t,n){function a(e,t,n){n.watch?e.$watch("replyMessage",function(){i(e,t)}):i(e,t)}function i(t,n){var a=t.replyMessage;if(a.loading)var i=a.mid,s=t.$on("messages_downloaded",function(a,r){-1!=r.indexOf(i)&&(t.replyMessage=e.wrapForDialog(i),o(t,n),s())});else o(t,n)}function o(a,i){var o=a.replyMessage;return o&&!o.deleted&&o.to_id?(a.thumb=e.getMessageThumb(o,42,42),"A"==i[0].tagName&&i.on("click",function(){var a=e.getMessagePeer(o),i=t.getPeerString(a);n.$broadcast("history_focus",{peerString:i,messageID:o.mid})}),void onContentLoaded(function(){a.$emit("ui_height")})):void $(i).remove()}return{templateUrl:templateUrl("reply_message"),scope:{replyMessage:"=myReplyMessage"},link:a}}]).directive("myPinnedMessage",["AppMessagesManager","AppPeersManager","$rootScope",function(e,t,n){function a(t,n){var a=t.pinnedMessage;if(a.loading)var o=a.mid,s=t.$on("messages_downloaded",function(a,r){-1!=r.indexOf(o)&&(t.pinnedMessage=e.wrapForDialog(o),i(t,n),s())});else i(t,n)}function i(a,i){var o=a.pinnedMessage;return o&&!o.deleted&&o.to_id?("A"==i[0].tagName&&i.on("click",function(){var a=e.getMessagePeer(o),i=t.getPeerString(a);n.$broadcast("history_focus",{peerString:i,messageID:o.mid})}),void onContentLoaded(function(){a.$emit("ui_height")})):void $(i).remove()}return{templateUrl:templateUrl("pinned_message"),scope:{pinnedMessage:"=myPinnedMessage"},link:a}}]).directive("myForwardedMessages",["AppPhotosManager","AppMessagesManager","AppPeersManager","$rootScope",function(e,t){function n(e,t,n){n.watch?e.$watch("forwardMessages",function(){a(e,t)}):a(e,t)}function a(e){var n=e.forwardMessages,a=n.length,i=!1,o=1==a;e.thumb=!1,e.singleMessage=!1,angular.forEach(n,function(n){var a=t.getMessage(n);i===!1?i=a.fromID:i!==a.fromID&&(i=t.getMessagePeer(a)),o&&(e.thumb=t.getMessageThumb(a,42,42),e.singleMessage=t.wrapForDialog(n))}),e.fromID=i,e.count=a,onContentLoaded(function(){e.$emit("ui_height")})}return{templateUrl:templateUrl("forwarded_messages"),scope:{forwardMessages:"=myForwardedMessages"},link:n}}]).directive("myDialogs",["$modalStack","$transition","$window","$timeout",function(e,t,n,a){function i(t,i){function o(n){if(!u&&e.getTop())return!0;if(36==n.keyCode&&!n.shiftKey&&!n.ctrlKey&&n.altKey){var a=$(r).find(".im_dialog_wrap a");return a.length&&($(a[0]).trigger("mousedown"),r.scrollTop=0,$(s).nanoScroller({flash:!0})),cancelEvent(n)}if(27==n.keyCode||9==n.keyCode&&n.shiftKey&&!n.ctrlKey&&!n.metaKey)return u?l.value?$(d).trigger("click"):(t.$emit("esc_no_more"),setTimeout(function(){l.blur(),l.focus()},100)):(setFieldSelection(l),l.value&&l.select()),cancelEvent(n);if(u&&13==n.keyCode&&!Config.Navigator.mobile){var a=$(r).find(".im_dialog_selected")[0]||$(r).find(".im_dialog_wrap a")[0];return a&&$(a).trigger("mousedown"),cancelEvent(n)}if(n.altKey&&n.shiftKey&&!n.ctrlKey&&!n.metaKey&&n.keyCode>=49&&n.keyCode<=57){var i=n.keyCode-49,o=$(r).find(".im_dialog_wrap"),c=o[i];return c&&($(c).find("a").trigger("mousedown"),scrollToNode(r,c,s)),cancelEvent(n)}var p,m,g,h=Config.Modes.packed;if(40==n.keyCode||38==n.keyCode?(p=40==n.keyCode,m=!p,g=!n.shiftKey&&n.altKey):h&&9==n.keyCode&&n.ctrlKey&&!n.metaKey&&(p=!n.shiftKey,m=!p,g=!0),p||m){if(!g&&(!u||n.metaKey))return!0;var c,a=!g&&$(r).find(".im_dialog_selected")[0]||$(r).find(".active a.im_dialog")[0],f=a&&a.parentNode;if(f){var c=a[p?"nextSibling":"previousSibling"];if(!c||!c.className||-1==c.className.indexOf("im_dialog_wrap")){var o=$(r).find(".im_dialog_wrap"),_=o.index(a.parentNode),v=_+(p?1:-1);c=o[v]}}else{var o=$(r).find(".im_dialog_wrap");c=p?o[0]:o[o.length-1]}return g?c&&$(c).find("a").trigger("mousedown"):(f&&c&&$(f).find("a").removeClass("im_dialog_selected"),c&&$(c).find("a").addClass("im_dialog_selected")),c&&scrollToNode(r,c,s),cancelEvent(n)}}var s=$(".im_dialogs_wrap",i)[0],r=$(".im_dialogs_scrollable_wrap",i)[0],l=$(".im_dialogs_search_field",i)[0],c=$(".im_dialogs_panel",i)[0],d=$(".im_dialogs_search_clear",i)[0],u=!1;$(l).on("focus blur",function(e){u="focus"==e.type,u||($(r).find(".im_dialog_selected").removeClass("im_dialog_selected"),l.value||t.$emit("ui_dialogs_search_clear"))}),t.$on("dialogs_search_toggle",function(){$(c).addClass("im_dialogs_panel_search"),t.$broadcast("ui_dialogs_search"),$(n).scrollTop(0),a(function(){setFieldSelection(l)})}),t.$on("search_clear",function(){$(c).removeClass("im_dialogs_panel_search"),t.$broadcast("ui_dialogs_search")}),$(document).on("keydown",o),t.$on("$destroy",function(){$(document).off("keydown",o)}),t.$on("ui_dialogs_change",function(){onContentLoaded(function(){var e=$(r).find(".active a.im_dialog")[0];e&&scrollToNode(r,e.parentNode,s)})})}return{link:i}}]).directive("myDialogsList",["$window","$timeout",function(e,t){function n(n,a,i){function o(){if(u&&u.offsetHeight||(u=$(d)[0]),i.modal){var t=$(e).height()-(u?u.offsetHeight:49)-(Config.Mobile?46:100);return t=Math.min(Config.Mobile?350:450,t),$(a).css({height:t}),void g()}c&&c.offsetHeight||(c=$(".tg_page_head")[0]),p&&p.offsetHeight||(p=$(".footer_wrap")[0]),r&&r.offsetHeight||(r=$(".im_dialogs_col_wrap")[0]);var n=p?p.offsetHeight:0;n&&n++,$(a).css({height:$(e).height()-n-(c?c.offsetHeight:48)-(u?u.offsetHeight:58)-parseInt($(r).css("paddingBottom")||0)}),g()}var s=$(".im_dialogs_wrap",a)[0],r=$(".im_dialogs_col_wrap")[0],l=$(".im_dialogs_scrollable_wrap",a)[0],c=$(".tg_page_head")[0],d=Config.Mobile&&i.modal?".mobile_modal_body .im_dialogs_panel":".im_dialogs_panel",u=$(d)[0],p=$(".footer_wrap")[0],m=!1;onContentLoaded(function(){$(s).nanoScroller({preventPageScrolling:!0,tabIndex:-1,iOSNativeScrolling:!0})});var g=function(){onContentLoaded(function(){$(s).nanoScroller()})};n.$on("ui_dialogs_prepend",g),n.$on("ui_dialogs_search",o),n.$on("ui_dialogs_update",o),n.$on("ui_dialogs_append",function(){onContentLoaded(function(){g(),m=!1,t(function(){$(l).trigger("scroll")})})}),n.$on("ui_dialogs_change",function(){onContentLoaded(function(){g(),m=!1,t(function(){$(l).trigger("scroll")})})}),$(l).on("scroll",function(){a.is(":visible")&&!m&&l.scrollTop>=l.scrollHeight-l.clientHeight-300&&(n.$emit("dialogs_need_more"),m=!0)}),$(e).on("resize",o),o(),setTimeout(o,1e3)}return{link:n}}]).directive("myContactsList",["$window","$timeout",function(e){function t(t,n){function a(){$(n).css({height:$(e).height()-(o&&o.offsetHeight||0)-(i&&i.offsetHeight||0)-(Config.Mobile?64:200)}),$(s).nanoScroller()}var i=$(".contacts_modal_search")[0],o=$(".contacts_modal_panel")[0],s=$(".contacts_wrap",n)[0];onContentLoaded(function(){$(s).nanoScroller({preventPageScrolling:!0,tabIndex:-1,iOSNativeScrolling:!0}),a()}),$(e).on("resize",a),t.$on("contacts_change",function(){onContentLoaded(a)})}return{link:t}}]).directive("myCountriesList",["$window","$timeout",function(e){function t(t,n){function a(){$(n).css({height:$(e).height()-(o&&o.offsetHeight||0)-(i&&i.offsetHeight||0)-(Config.Mobile?64:200)}),$(s).nanoScroller()}var i=$(".countries_modal_search")[0],o=$(".countries_modal_panel")[0],s=$(".countries_wrap",n)[0];onContentLoaded(function(){$(s).nanoScroller({preventPageScrolling:!0,tabIndex:-1,iOSNativeScrolling:!0}),a()}),$(e).on("resize",a),t.$on("contacts_change",function(){onContentLoaded(a)})}return{link:t}}]).directive("mySessionsList",["$window","$timeout",function(e){function t(t,n){function a(){$(n).css({height:Math.min(760,$(e).height()-(Config.Mobile?64:200))}),$(i).nanoScroller()}var i=$(".sessions_wrap",n)[0];onContentLoaded(function(){$(i).nanoScroller({preventPageScrolling:!0,tabIndex:-1,iOSNativeScrolling:!0}),a()}),$(e).on("resize",a)}return{link:t}}]).directive("myStickersList",["$window","$timeout",function(e){function t(t,n){function a(){$(n).css({height:Math.min(600,$(e).height()-(Config.Mobile?64:200))}),$(i).nanoScroller()}var i=$(".stickerset_wrap",n)[0];onContentLoaded(function(){$(i).nanoScroller({preventPageScrolling:!0,tabIndex:-1,iOSNativeScrolling:!0}),a()}),$(e).on("resize",a)}return{link:t}}]).directive("myHistory",["$window","$timeout","$rootScope","$transition",function(e,t,n,a){function i(i,o){function s(e,n){var a,i,o=!1;if(!e&&(i=$(".im_message_focus:visible",u)[0])){var s=u.clientHeight,r=u.scrollTop,l=i.offsetTop,c=i.clientHeight;(!r||l>r+s||r>l+c||n)&&(o=Math.max(0,l-Math.floor(s/2)+26)),I=!1}else(a=$(".im_message_unread_split:visible",u)[0])?(o=Math.max(0,a.offsetTop-52),I=!1):(o=u.scrollHeight,I=!0);if(o!==!1){var d=function(){k(),t(function(){$(u).trigger("scroll"),A=u.scrollTop})};n?$(u).animate({scrollTop:o},200,d):(u.scrollTop=o,d())}}function r(t){if(o.is(":visible")||$(o[0].parentNode.parentNode).is(":visible")){$(h).is(":visible")&&$(h).css({height:$(v).height()}),f&&f.offsetHeight||(f=$(".tg_page_head")[0]),_&&_.offsetHeight||(_=$(".footer_wrap")[0]);var n=_?_.offsetHeight:0;n&&n++;var a=$(e).height()-g.offsetHeight-(f?f.offsetHeight:48)-n;$(c).css({height:a}),l(),t!==!0&&(I&&onContentLoaded(function(){u.scrollTop=u.scrollHeight,k()}),k(100))}}function l(){$(d).css({marginTop:0});var e=u.offsetHeight-d.offsetHeight-m.offsetHeight-(Config.Mobile?0:39);d.offsetHeight>0&&e>0&&$(d).css({marginTop:e}),$(c).nanoScroller()}var c=$(".im_history_wrap",o)[0],d=$(".im_history_messages",o)[0],u=($(".im_history",o)[0],$(".im_history_scrollable_wrap",o)[0]),p=$(".im_history_scrollable",o)[0],m=$(".im_history_empty_wrap",o)[0],g=$(".im_bottom_panel_wrap",o)[0],h=$(".im_send_form_wrap",o)[0],f=$(".tg_page_head")[0],_=$(".footer_wrap")[0],v=$(".im_send_form",o)[0],y=!1,b=!1;onContentLoaded(function(){u.scrollTop=u.scrollHeight}),$(c).nanoScroller({preventPageScrolling:!0,tabIndex:-1,iOSNativeScrolling:!0});var w,k=function(e){t(function(){$(u).hasClass("im_history_to_bottom")||$(c).nanoScroller()},e||0)},C=!1,S=["transform","webkitTransform","MozTransform","msTransform","OTransform"];for(w=0;w0;if(o)i=u.scrollHeight;else{var r=parseInt($(u).css("paddingRight"));$(p).css({bottom:0,paddingRight:r}),$(u).addClass("im_history_to_bottom")}onContentLoaded(function(){if(o){x=!0,$(d).removeClass("im_history_appending"),u.scrollTop=u.scrollHeight,$(d).css(C,"translate(0px, "+(u.scrollHeight-i)+"px)"),$(c).nanoScroller();var e={};e[C]="translate(0px, 0px)",$(d).addClass("im_history_appending"),a($(d),e).then(function(){x=!1,$(d).removeClass("im_history_appending"),l()})}else $(u).removeClass("im_history_to_bottom"),$(p).css({bottom:"",paddingRight:0}),u.scrollTop=u.scrollHeight,l()})}),i.$on("ui_history_change",function(){var e=parseInt($(u).css("paddingRight"));$(u).addClass("im_history_to_bottom"),u.scrollHeight,$(p).css({bottom:0,paddingRight:e}),onContentLoaded(function(){$(u).removeClass("im_history_to_bottom"),$(p).css({bottom:"",paddingRight:""}),r(!0),y=!1,b=!1,s()})}),i.$on("ui_history_change_scroll",function(e,t){onContentLoaded(function(){s(!1,t)})}),i.$on("ui_history_focus",function(){I||(u.scrollTop=u.scrollHeight,k(),I=!0)}),i.$on("ui_history_prepend",function(){var e=u.scrollHeight,n=u.scrollTop,a=parseInt($(u).css("paddingRight")),o=u.clientHeight;$(u).addClass("im_history_to_bottom"),u.scrollHeight,$(p).css({bottom:-(e-n-o),paddingRight:a});var r=function(){$(u).removeClass("im_history_to_bottom"),$(p).css({bottom:"",paddingRight:""}),A>=0?s():u.scrollTop=n+u.scrollHeight-e,l(),y=!1,t(function(){u.scrollHeight!=e&&$(u).trigger("scroll")}),clearTimeout(c),d()},c=setTimeout(r,0),d=i.$on("$viewContentLoaded",r)}),i.$on("ui_history_append",function(){var e=u.scrollHeight;onContentLoaded(function(){I=!1,l(),b=!1,A>=0&&s(),t(function(){u.scrollHeight!=e&&$(u).trigger("scroll")})})}),i.$on("ui_panel_update",function(e,n){r(),onContentLoaded(function(){r(),n&&n.blur?i.$broadcast("ui_message_blur"):getSelectedText()||i.$broadcast("ui_message_send"),t(function(){$(u).trigger("scroll")})})}),i.$on("ui_selection_clear",function(){window.getSelection?window.getSelection().empty?window.getSelection().empty():window.getSelection().removeAllRanges&&window.getSelection().removeAllRanges():document.selection&&document.selection.empty()}),i.$on("ui_editor_resize",r),i.$on("ui_height",function(){onContentLoaded(r)});var I=!0,A=-1;$(u).on("scroll",function(){if(o.is(":visible")&&!$(u).hasClass("im_history_to_bottom")&&!x){var e=u.scrollTop;I=e>=u.scrollHeight-u.clientHeight,A>=0&&A!=e&&(A=-1),!y&&300>=e?(y=!0,i.$emit("history_need_more")):!b&&e>=u.scrollHeight-u.clientHeight-300&&(b=!0,i.$emit("history_need_less"))}}),$(e).on("resize",r),r(),onContentLoaded(r)}return{link:i}}]).directive("mySendForm",["_","$q","$timeout","$compile","$modalStack","$http","$interpolate","Storage","AppStickersManager","AppDocsManager","ErrorService","AppInlineBotsManager","FileManager","shouldFocusOnInteraction",function(e,t,n,a,i,o,s,r,l,c,d,u,p,m){function g(o,s){function g(){r.get("send_ctrlenter").then(function(e){L=!e})}function h(e){return n(function(){_(),o.draftMessage.send(),O.resetTyping(),U&&U.update()},m?0:100),cancelEvent(e)}function f(e){o.$apply(function(){o.draftMessage.inlineResultID=e})}function _(){B&&(O.onChange(),v())}function v(){var e=B.offsetHeight;j!=e&&(j=e,o.$emit("ui_editor_resize"))}function y(e){return 9!=e.keyCode||e.shiftKey||e.ctrlKey||e.metaKey||i.getTop()?void 0:(O.focus(),cancelEvent(e))}function b(){onContentLoaded(function(){O.focus()})}function w(e){var n=e.type||"",a=t.when(!1);["image/jpeg","image/gif","image/png","image/bmp"].indexOf(n)>=0&&(a=p.getFileCorrectUrl(e,n)),a.then(function(t){t=t||!1,d.confirm({type:"FILE_CLIPBOARD_PASTE",fileUrl:t}).then(function(){o.draftMessage.files=[e],o.draftMessage.isMedia=!0})})}function k(e){var t,n,a=(e.originalEvent||e).clipboardData,i=a&&a.items||[],s=[];for(n=0;n0){if(1==s.length)return w(s[0]);d.confirm({type:"FILES_CLIPBOARD_PASTE",files:s}).then(function(){o.draftMessage.files=s,o.draftMessage.isMedia=!0})}}function C(e){var t=!1;return S&&1!=S||(S=checkDragEvent(e)?2:1,t=!0),2==S&&(M&&setTimeout(function(){clearTimeout(M),M=!1},0),"dragenter"==e.type||"dragover"==e.type?t&&(Config.Mobile||$(I).hide(),$(T).css({height:D.offsetHeight+2,width:D.offsetWidth}).show()):("drop"==e.type&&o.$apply(function(){o.draftMessage.files=Array.prototype.slice.call(e.originalEvent.dataTransfer.files),o.draftMessage.isMedia=!0}),M=setTimeout(function(){$(T).hide(),Config.Mobile||$(I).show(),S=!1,M=!1},300))),cancelEvent(e)}var S,M,x=$("textarea",s)[0],I=$(".composer_emoji_insert_btn",s)[0],A=$(".composer_emoji_panel",s)[0],E=$("input",s),T=$(".im_send_dropbox_wrap",s)[0],D=$(".im_send_field_wrap",s)[0],P=$(".im_submit",s)[0],F=a(''),R={},N=new EmojiTooltip(I,{getStickers:function(e){l.getStickers().then(e)},getStickerImage:function(e,t){var n=e.attr("data-category"),a=R[t];if(a&&!isInDOM(a[0]))return a.attr("data-category",n),void e.replaceWith(a);var i=o.$new(!0);i.document=c.getDoc(t),F(i,function(a){R[t]=a,a.attr("data-category",n),e.replaceWith(a)})},onStickersetSelected:function(e){l.openStickersetLink(e)},onEmojiSelected:function(e){o.$apply(function(){O.onEmojiSelected(e)})},onStickerSelected:function(e){o.$apply(function(){o.draftMessage.sticker=e})},langpack:{im_emoji_tab:e("im_emoji_tab"),im_stickers_tab:e("im_stickers_tab")}});o.$on("stickers_changed",function(){N.onStickersChanged()});var U;A&&(U=new EmojiPanel(A,{onEmojiSelected:function(e){O.onEmojiSelected(e)}}));var O=new MessageComposer(x,{onTyping:function(){o.$emit("ui_typing")},getSendOnEnter:function(){return L},dropdownDirective:function(e,t){{var n=o.$new(!0);a("
    ")(n,function(n,a){e.replaceWith(n),t(a,n)})}},mentions:o.mentions,commands:o.commands,onMessageSubmit:h,onInlineResultSend:f,onFilePaste:w,onCommandSend:function(e){o.$apply(function(){o.draftMessage.command=e})}}),B=O.richTextareaEl&&O.richTextareaEl[0];B&&$(B).on("keydown keyup",v),o.$on("inline_results",function(e,t){var n=Config.Mobile?$(window).width():(D.offsetWidth||382)-2,a=80;t&&u.regroupWrappedResults(t.results,n,a),setZeroTimeout(function(){O.setInlineSuggestions(t)})}),o.$on("inline_placeholder",function(e,t){O.setInlinePlaceholder(t.prefix,t.placeholder)}),E.on("change",function(){var e=this;o.$apply(function(){o.draftMessage.files=Array.prototype.slice.call(e.files),o.draftMessage.isMedia=$(e).hasClass("im_media_attach_input")||Config.Mobile,setTimeout(function(){try{e.value=""}catch(t){}},1e3)})});var L=!0;o.$on("settings_changed",g),g(),$(P).on("mousedown touchstart",h);var j=B&&B.offsetHeight;$(document).on("keydown",y),$("body").on("dragenter dragleave dragover drop",C),$(document).on("paste",k),m&&(o.$on("ui_peer_change",b),o.$on("ui_history_focus",b),o.$on("ui_history_change",b)),o.$on("ui_peer_change",O.resetTyping.bind(O)),o.$on("ui_peer_draft",function(t,n){n=n||{};var a=o.draftMessage.isBroadcast;O.setPlaceholder(e(a?"im_broadcast_field_placeholder_raw":"im_message_field_placeholder_raw")),n.customSelection?(O.setFocusedValue(n.customSelection),v()):(B&&(O.setValue(o.draftMessage.text||""),v()),(m||n&&n.focus)&&O.focus()),onContentLoaded(function(){O.checkAutocomplete(!0)}),N&&Config.Mobile&&N.hide()}),o.$on("ui_peer_reply",function(){onContentLoaded(function(){o.$emit("ui_editor_resize"),m&&O.focus()})}),o.$on("mentions_update",function(){O.onMentionsUpdated()}),o.$on("ui_message_before_send",function(){_()}),o.$on("ui_message_send",function(){m&&b()}),o.$on("ui_message_blur",function(){O.blur()}),o.$on("$destroy",function(){$(document).off("paste",k),$(document).off("keydown",y),$("body").off("dragenter dragleave dragover drop",C),$(P).off("mousedown touchstart"),E.off("change")}),m&&b()}return{link:g,scope:{draftMessage:"=",mentions:"=",commands:"="}}}]).directive("myLoadThumb",["MtpApiFileManager","FileManager",function(e,t){function n(n,a,i){var o=0,s=e.getCachedFile(n.thumb&&n.thumb.location&&!n.thumb.location.empty&&n.thumb.location);s&&a.attr("src",t.getUrl(s,"image/jpeg")),n.thumb&&n.thumb.width&&n.thumb.height&&(a.attr("width",n.thumb.width),a.attr("height",n.thumb.height));var r=n.$watchCollection("thumb.location",function(i){n.thumb&&n.thumb.width&&n.thumb.height&&(a.attr("width",n.thumb.width),a.attr("height",n.thumb.height),n.$emit("ui_height"));var s=++o;if(!i||i.empty)return a.attr("src",n.thumb&&n.thumb.placeholder||"img/blank.gif"),void l();var r=e.getCachedFile(i);return r?(a.attr("src",t.getUrl(r,"image/jpeg")),void l()):(a.attr("src")||a.attr("src",n.thumb.placeholder||"img/blank.gif"),void e.downloadSmallFile(n.thumb.location).then(function(e){s==o&&(a.attr("src",t.getUrl(e,"image/jpeg")),l())},function(e){console.log("Download image failed",e,n.thumb.location,a[0]),s==o&&(a.attr("src",n.thumb.placeholder||"img/blank.gif"),l())}))}),l=i.watch?angular.noop:function(){setTimeout(function(){n.$destroy(),r()},0)}}return{link:n,scope:{thumb:"="}}}]).directive("myLoadFullPhoto",["MtpApiFileManager","FileManager","_",function(e,t,n){function a(a,i){var o=$("img",i)[0],s=$(".img_fullsize_with_progress_wrap",i).add(".img_fullsize_progress_wrap",i).add($(o)),r=function(){s.css({width:a.fullPhoto.width,height:a.fullPhoto.height}),a.$emit("ui_height",!0)},l=0;a.$watchCollection("fullPhoto.location",function(){var i=e.getCachedFile(a.thumbLocation),s=++l;if(i?(o.src=t.getUrl(i,"image/jpeg"),r()):o.src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",a.fullPhoto.location){var c;if(a.fullPhoto.size){var d={_:"inputFileLocation",volume_id:a.fullPhoto.location.volume_id,local_id:a.fullPhoto.location.local_id,secret:a.fullPhoto.location.secret};c=e.downloadFile(a.fullPhoto.location.dc_id,d,a.fullPhoto.size)}else c=e.downloadSmallFile(a.fullPhoto.location);a.progress={enabled:!0,percent:0},c.then(function(e){s==l&&(a.progress.enabled=!1,o.src=t.getUrl(e,"image/jpeg"),r())},function(e){console.log("Download image failed",e,a.fullPhoto.location),a.progress.enabled=!1,a.error=e&&"FS_BROWSER_UNSUPPORTED"==e.type?{html:n("error_browser_no_local_file_system_image_md",{"moz-link":'{1}',"chrome-link":'{1}',"telegram-link":'{1}'})}:{text:n("error_image_download_failed"),error:e}},function(e){a.progress.percent=Math.max(1,Math.floor(100*e.done/e.total))})}}),r()}return{link:a,transclude:!0,templateUrl:templateUrl("full_photo"),scope:{fullPhoto:"=",thumbLocation:"="}}}]).directive("myLoadVideo",["$sce","AppDocsManager","ErrorService","_",function(e,t,n,a){function i(e,i){var o=t.downloadDoc(e.video.id);o.then(function(){e.$emit("ui_height"),onContentLoaded(function(){var e=$("video",i)[0];if(e){var t=!1,a=function(e){t||e.target&&e.target.error&&e.target.error.code!=e.target.error.MEDIA_ERR_DECODE&&e.target.error.code!=e.target.error.MEDIA_ERR_SRC_NOT_SUPPORTED||(t=!0,n.show({error:{type:"MEDIA_TYPE_NOT_SUPPORTED",originalError:e.target&&e.target.error}}))};e.addEventListener("error",a,!0),$(e).on("$destroy",function(){t=!0,e.removeEventListener("error",a)})}})},function(t){console.log("Download video failed",t,e.video),e.error=t&&"FS_BROWSER_UNSUPPORTED"==t.type?{html:a("error_browser_no_local_file_system_video_md",{"moz-link":'{1}',"chrome-link":'{1}',"telegram-link":'{1}'})}:{text:a("error_video_download_failed"),error:t}}),e.$emit("ui_height"),e.$on("$destroy",function(){o.cancel()})}return{link:i,transclude:!0,templateUrl:templateUrl("full_video"),scope:{video:"="}}}]).directive("myLoadGif",["AppDocsManager","$timeout",function(e,t){function n(n,a){var i=$(".img_gif_image_wrap",a);i.css({width:n.document.thumb.width,height:n.document.thumb.height});var o=!1;n.isActive=!1,n.toggle=function(i){return i&&checkClick(i,!0)?(e.saveDocFile(n.document.id),!1):n.document.url?void onContentLoaded(function(){n.isActive=!n.isActive,n.$emit("ui_height");var e=$("video",a)[0];e&&(n.isActive?e.play():(e.pause(),e.currentTime=0))}):o?(o.cancel(),void(o=!1)):(o=e.downloadDoc(n.document.id),void o.then(function(){t(function(){n.isActive=!0},200)}))}}return{link:n,templateUrl:templateUrl("full_gif"),scope:{document:"="}}}]).directive("myLoadSticker",["_","MtpApiFileManager","FileManager","AppStickersManager",function(e,t,n,a){function i(i,s,r){var l=$("").addClass(r.imgClass),c=!1;l.attr("alt","["+(i.document.stickerEmojiRaw||"")+" "+e("conversation_media_sticker")+"]");var d=r.dim&&i.$parent.$eval(r.dim)||i.document.thumb;r.open&&i.document.stickerSetInput&&s.addClass("clickable").on("click",function(){a.openStickerset(i.document.stickerSetInput)});var u=function(e){l.attr("src",n.getUrl(e)),c||(c=!0,l.appendTo(s))};l.css({width:d.width,height:d.height}),s.css({width:d.width,height:d.height});var p=!1;i.document.thumb.location&&(p=angular.copy(i.document.thumb.location),p.sticker=!0);var m={_:"inputDocumentFileLocation",id:i.document.id,access_hash:i.document.access_hash,dc_id:i.document.dc_id,file_name:i.document.file_name,sticker:!0},g=t.getCachedFile(m),h=!1;if(g?h=!0:g=t.getCachedFile(p),g){if(u(g),h)return}else c=!0,l.attr("src",o).appendTo(s);r.thumb&&p?t.downloadSmallFile(p).then(function(e){u(e)},function(e){console.log("Download sticker failed",e,m)}):t.downloadFile(i.document.dc_id,m,i.document.size).then(function(e){u(e)},function(e){console.log("Download sticker failed",e,m)})}var o="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";return{link:i,scope:{document:"="}}}]).directive("myLoadDocument",["MtpApiFileManager","AppDocsManager","FileManager",function(e,t,n){function a(e,t){for(;e&&!$(e).hasClass("modal-dialog");)e=e.parentNode;e&&$(e).width(t+(Config.Mobile?0:32))}function i(i,o){var s=$(".document_fullsize_with_progress_wrap",o),r=$(".document_fullsize_wrap",o),l=$(".document_fullsize_img",o),c=$(window).width()-(Config.Mobile?20:32),d=$(window).height()-150;c>800&&(c-=208),i.imageWidth=c,i.imageHeight=d;var u=i.document.thumb;if(u&&"photoSizeEmpty"!=u._){var p=calcImageInBox(u.width,u.height,c,d);i.imageWidth=p.w,i.imageHeight=p.h;var m=e.getCachedFile(u.location);m&&(i.thumbSrc=n.getUrl(m,"image/jpeg"))}i.frameWidth=Math.max(i.imageWidth,Math.min(600,c)),i.frameHeight=i.imageHeight,onContentLoaded(function(){i.$emit("ui_height")}),a(o[0],i.frameWidth);var g,h,f;t.downloadDoc(i.document.id).then(function(e){var t=n.getUrl(e,i.document.mime_type),a=new Image,o=100,u=function(){if(a.height&&a.width||!--o){h=a.width,f=a.height,clearInterval(g);var e=calcImageInBox(a.width,a.height,c,d,!0),n={w:h,h:f};e.w>=n.w&&e.h>=n.h&&(n.w*=4,n.h*=4);var u=!0;i.toggleZoom=function(){u=!u;var t=(u?n:e).w,a=(u?n:e).h;l.css({width:t,height:a,marginTop:i.frameHeight>a?Math.floor((i.frameHeight-a)/2):0}),r.toggleClass("document_fullsize_zoomed",u)},i.toggleZoom(!1),l.attr("src",t),s.hide(),r.css({width:i.frameWidth,height:i.frameHeight}).show()}};g=setInterval(u,20),a.onload=u,a.src=t,setZeroTimeout(u)})}return{link:i,templateUrl:templateUrl("full_document"),scope:{document:"=myLoadDocument"}}}]).directive("myGeoPointMap",["ExternalResourcesManager",function(e){function t(t,n){var a=n.attr("width")||200,i=n.attr("height")||200,o=Config.ExtCredentials.gmaps.api_key,s=a>200?15:13;n.attr("src","img/blank.gif");var r="https://maps.googleapis.com/maps/api/staticmap?sensor=false¢er="+t.point.lat+","+t.point["long"]+"&zoom="+s+"&size="+a+"x"+i+"&scale=2&key="+o;e.downloadByURL(r).then(function(e){n.attr("src",e.valueOf())})}return{link:t,scope:{point:"=myGeoPointMap"}}}]).directive("myLoadingDots",["$interval",function(){function e(e,n){n.html(t(n[0])?'
    ':"...")}function t(e){if(void 0===n&&(n=void 0!==e.style.animationName,n===!1)){var t,a="Webkit Moz O ms Khtml".split(" ");for(t=0;t=n.scrollHeight-n.clientHeight-300&&(a=!0,e.$apply(function(){e.slice.limit+=e.slice.limitDelta||20}),onContentLoaded(function(){a=!1,$(t).nanoScroller()}))})}return{link:e,scope:!0} +o.grouped=m&&o.fwdFromID&&o.fwdFromID==s.fwdFromID&&o.viaBotID==s.viaBotID?g?"im_grouped_fwd_short":"im_grouped_fwd":!o.fwdFromID&&g?"im_grouped_short":"im_grouped",m&&o.fwdFromID&&(s.grouped||(s.grouped="im_grouped_fwd_start"),o.grouped&&n==d-1&&(o.grouped+=" im_grouped_fwd_end"))}else(s||!n)&&(delete o.grouped,m&&s&&s.grouped&&s.fwdFromID&&(s.grouped+=" im_grouped_fwd_end"));p||l==(s&&s.grouped)||(p=!0),s=o,i=a}return p||r==(s&&s.grouped)||(p=!0),p}function pt(e,t,n){var a,i=!1;if(e.media)switch(e.media._){case"messageMediaPhoto":a=d.choosePhotoSize(e.media.photo,t,n);break;case"messageMediaDocument":a=e.media.document.thumb,e.media.document.sticker&&(i=!0)}if(a&&"photoSizeEmpty"!=a._){var o=calcImageInBox(a.w,a.h,t,n,!0),s={width:o.w,height:o.h,location:a.location,size:a.size};return i&&(s.location.sticker=!0),s}return!1}function mt(e){Ht!==!1&&e&&e>Ht&&v.set({max_seen_msg:e})}function gt(e,n){n=n||{};var a,i,o=it(e),s={},c=!1,d=_.getNotifySettings();if(e.fwdFromID&&n.fwd_count)c=zt(n.fwd_count);else if(e.message)c=d.nopreview?$("conversation_message_sent"):f.wrapPlainText(e.message);else if(e.media)switch(e.media._){case"messageMediaPhoto":c=$("conversation_media_photo_raw");break;case"messageMediaDocument":switch(e.media.document.type){case"gif":c=$("conversation_media_gif_raw");break;case"sticker":c=$("conversation_media_sticker");var u=e.media.document.stickerEmojiRaw;void 0!==u&&(c=f.wrapPlainText(u)+" "+c);break;case"video":c=$("conversation_media_video_raw");break;case"voice":case"audio":c=$("conversation_media_audio_raw");break;default:c=e.media.document.file_name||$("conversation_media_document_raw")}break;case"messageMediaGeo":case"messageMediaVenue":c=$("conversation_media_location_raw");break;case"messageMediaContact":c=$("conversation_media_contact_raw");break;default:c=$("conversation_media_attachment_raw")}else if("messageService"==e._)switch(e.action._){case"messageActionChatCreate":c=$("conversation_group_created_raw");break;case"messageActionChatEditTitle":c=$("conversation_group_renamed_raw");break;case"messageActionChatEditPhoto":c=$("conversation_group_photo_updated_raw");break;case"messageActionChatDeletePhoto":c=$("conversation_group_photo_removed_raw");break;case"messageActionChatAddUser":case"messageActionChatAddUsers":c=$("conversation_invited_user_message_raw_raw");break;case"messageActionChatReturn":c=$("conversation_returned_to_group_raw");break;case"messageActionChatJoined":c=$("conversation_joined_group_raw");break;case"messageActionChatDeleteUser":c=$("conversation_kicked_user_message_raw");break;case"messageActionChatLeave":c=$("conversation_left_group_raw");break;case"messageActionChatJoinedByLink":c=$("conversation_joined_by_link_raw");break;case"messageActionChannelCreate":c=$("conversation_created_channel_raw");break;case"messageActionChannelEditTitle":c=$("conversation_changed_channel_name_raw");break;case"messageActionChannelEditPhoto":c=$("conversation_changed_channel_photo_raw");break;case"messageActionChannelDeletePhoto":c=$("conversation_removed_channel_photo_raw")}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||$("conversation_unknown_user_raw")),i=m,a=r.getUserString(o)}else{if(s.title=l.getChat(-o).title||$("conversation_unknown_chat_raw"),e.from_id>0){var p=r.getUser(e.from_id);s.title=(p.first_name||p.last_name||$("conversation_unknown_user_raw"))+" @ "+s.title}i=l.getChatPhoto(-o),a=l.getChatString(-o)}s.title=f.wrapPlainText(s.title),s.onclick=function(){t.$broadcast("history_focus",{peerString:a,messageID:16&e.flags?e.mid:0})},s.message=c,s.key="msg"+e.mid,s.tag=a,i.location&&!i.location.empty?h.downloadSmallFile(i.location,i.size).then(function(t){e.pFlags.unread&&(s.image=t,_.notify(s))}):_.notify(s)}function ht(){i.cancel(tn),tn=!1,t.$broadcast("history_multiappend",nn),nn={}}function ft(){i.cancel(an),an=!1,angular.forEach(on,function(e){A(e)}),t.$broadcast("dialogs_multiupdate",on),on={}}function _t(){i.cancel(sn),sn=!1;var e=t.idle.isIDLE&&k.isOtherDeviceActive()?3e4:1e3;angular.forEach(rn,function(t){t.isMutedPromise.then(function(n){var a=t.top_message;!n&&a.pFlags.unread&&setTimeout(function(){a.pFlags.unread&>(a,{fwd_count:t.fwd_count})},e)})}),rn={}}function vt(n){var a=-n;return e.all([y.getChannelFull(n,!0),B(a,0)]).then(function(e){var i=e[0],o=e[1],s=o.history[0],r={_:"dialogChannel",peer:c.getOutputPeer(a),top_message:s,top_important_message:s,read_inbox_max_id:i.read_inbox_max_id,unread_count:i.unread_count,unread_important_count:i.unread_important_count,notify_settings:i.notify_settings};M(n,r);var l={};l[a]=r,t.$broadcast("dialogs_multiupdate",l)})}var yt,bt={},wt={},kt={},$t={},Ct={count:null,dialogs:[]},St={},Mt={},xt={},It=e.when(),At=-1,Et=SearchIndexManager.createIndex(),Tt={query:!1},Dt={},Pt=[],Ft=[],Rt=!1,Nt={},Ut=[],Ot=!1,Bt=0,Lt=tsNow(!0),jt=Lt-Lt%86400,qt=new Date;v.get("server_time_offset").then(function(e){e&&(Bt=e)});var Ht=!1;Config.Modes.packed&&v.get("max_seen_msg").then(function(e){Ht=e||0});var Vt=a("dateOrTime"),zt=$.pluralize("conversation_forwarded_X_messages");qt.setHours(0),qt.setMinutes(0),qt.setSeconds(0),yt=jt-Math.floor(+qt/1e3),_.start();var Wt=!1,Gt=0,Kt=0,Yt={},Zt={},Xt={},Jt={},Qt=0,en=4294967296,tn=!1,nn={},an=!1,on={},sn=!1,rn={};return t.$on("apiUpdate",function(e,n){switch(n._){case"updateMessageID":var a=n.random_id,o=St[a];if(o){var s=o[0],d=c.isChannel(s)?-s:0;Mt[T(n.id,d)]=a}break;case"updateNewMessage":case"updateNewChannelMessage":var u=n.message,s=it(u),p=$t[s];if("updateNewChannelMessage"==n._){if(!l.isMegagroup(-s)&&!(u.pFlags.out||u.pFlags.mention||u.pFlags.post))break;var m=l.getChat(-s);if(m.pFlags&&(m.pFlags.left||m.pFlags.kicked))break}if(Y([u]),void 0!==p){var g=p.history;if(-1!=g.indexOf(u.mid))return!1;var h=g[0];g.unshift(u.mid),u.mid>0&&u.mid0&&E&&r.forceUserOnline(s),A=0;F>A;A++)if(x=g[A],!(x>D)&&(u=bt[x],u.pFlags.out==E)){if(!u.pFlags.unread)break;u&&u.pFlags.unread&&(u.pFlags.unread=!1,wt[x]&&(wt[x].pFlags.unread=!1,R||(R=!0)),kt[x]&&(kt[x].pFlags.unread=!1),u.pFlags.out||(y&&(P=--y[0].unread_count),_.cancel("msg"+x)))}!E&&y&&(P&&y[0].top_message<=D&&(P=y[0].unread_count=0),y[0]||console.error("empty found dialog",y,n),y[0].read_inbox_max_id=D),P!==!1&&t.$broadcast("dialog_unread",{peerID:s,count:P}),R&&t.$broadcast("messages_read");break;case"updateReadMessagesContents":var A,x,u,N,U=n.messages,O=U.length;for(A=0;O>A;A++)x=U[A],(u=bt[x])&&delete u.pFlags.media_unread,(N=wt[x])&&delete N.pFlags.media_unread;break;case"updateDeleteMessages":case"updateDeleteChannelMessages":var x,u,A,s,y,g,B={},d=n.channel_id;for(A=0;A0&&(i.count-=e.count,i.count<0&&(i.count=0));for(var r=0;r0,z="channel"==L._&&(L.username||!L.pFlags.left&&!L.pFlags.kicked)&&!0||!1,W=void 0!==$t[s];z!=W&&(delete $t[s],t.$broadcast("history_forbidden",s)),V!=q&&(q?vt(d):y[0]&&(Ct.dialogs.splice(y[1],1),t.$broadcast("dialog_drop",{peerID:s})));break;case"updateChannelReload":var d=n.channel_id,s=-d,y=S(s);y[0]&&Ct.dialogs.splice(y[1],1),delete $t[s],vt(d).then(function(){t.$broadcast("history_reload",s)});break;case"updateChannelMessageViews":var G=n.views,$=T(n.id,n.channel_id),u=H($);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
    \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.3
    \n
    \n
      \n
    • Inline bots: A new way to add bot content to any chat. Type a bot\'s username and your query in the text field to get instant results and send them to your chat partner. Try typing @gif dog in your next chat. Sample bots: @gif, @wiki, @bing, @vid, @bold.
    • \n
    • Check out the Telegram Blog for more info.
    • \n
    • Improved GIFs: 20x faster sending and downloading, nice animated progress
    • \n
    • Click on message date to reply (or to forward from channels).
    • \n
    • Preview images before sending when pasting from clipboard.
    • \n
    • Improved formatting for copy-pasted history fragments (date, time and sender names inserted automatically).
    • \n
    \n
    \n
    \n\n
    \n
    0.5.2
    \n
    \n
      \n
    • Unread counters for muted chats now colored in gray.
    • \n
    • Improved previews for sticker sets: Click on a sticker to view the whole set, click on stickers in a set to send right away, added a \'Share\' button.
    • \n
    • Improved performance.
    • \n
    \n
    \n
    \n\n
    \n
    0.5.1
    \n
    \n
      \n
    • Groups that have reached their capacity of 200 users can be upgraded to supergroups of up to 1,000 members.
    • \n
    • Check out the Telegram Blog for more info
    • \n
    \n
    \n
    \n\n
    \n
    0.5.0
    \n
    \n
      \n
    • Removed annoying "multiple tabs open" error.
    • \n
    • Improved message forwarding.
    • \n
    • Added view counter to messages from channels.
    • \n
    • Improved image loading in Safari and Firefox.
    • \n
    \n
    \n
    \n\n
    \n
    0.4.9
    \n
    \n
      \n
    • New emoji and sticker menu, tabs for sticker packs.
    • \n
    \n
    \n
    \n\n
    \n
    0.4.8
    \n
    \n
      \n
    • Introducing Channels – a great new way to broadcast your messages to unlimited audiences.
    • \n
    • Check out the Telegram Blog for more info
    • \n
    • Improved performance in Safari on OS X El Capitan.
    • \n
    • Added formatting for fixed-width code, surround text with `single backticks` for inline text and ```triple backticks``` for blocks of pre-formatted text.
    • \n
    \n
    \n
    \n\n
    \n
    0.4.7
    \n
    \n
      \n
    • New bot API, free for everyone. If you\'re an engineer, create your own bots for games, services or integrations.\n
    • \n
    • Check out Telegram Blog for more info
    • \n
    • Improved Stickers support: now stickers are loading much faster.
    • \n
    • Click on any custom stickers in chats to view and add sticker sets.
    • \n
    • [Mobile] Reply to a message easily: tap on any message and select "Reply".
    • \n
    \n
    \n
    \n\n
    \n
    0.4.6
    \n
    \n \n
    \n
    \n\n
    \n
    0.4.5
    \n
    \n
      \n
    • \n Invite links for group chats:
      \n Check out Telegram Blog for more info\n
    • \n
    • Smart notifications
    • \n
    • \'Listened\' status for voice messages
    • \n
    • Places in locations (venues, landmarks)
    • \n
    \n
    \n
    \n\n
    \n
    0.4.4
    \n
    \n
      \n
    • Link Previews:
      \n Get rich link summaries for tweets, YouTube videos, Instagram photos and other content.
    • \n\n
    • Check out Telegram Blog for more info.
    • \n
    \n
    \n
    \n\n
    \n
    0.4.3
    \n
    \n
      \n
    • Sessions List:
      \n View your active Telegram sessions (on desktop, tablet and mobile devices) and close specific sessions remotely.
    • \n\n
    • Two-step verification:
      \n Set up an additional password that will be required to log into your Telegram account.
    • \n\n
    • Check out Telegram Blog for more info.
    • \n
    \n
    \n
    \n\n
    \n
    0.4.2
    \n
    \n
      \n
    • Optimization for screens with smaller Y-resolutions.
    • \n
    • Supported Spotify URL embeds.
    • \n
    • Mentions of the current user in group chats are now highlighted.
    • \n
    \n
    \n
    \n\n
    \n
    0.4.1
    \n
    \n
      \n
    • Reply to specific messages in groups.
    • \n
    • Mention @usernames in groups to notify multiple users.
    • \n
    • Revised notifications in groups: mentioned users and people you reply to will be notified (private chat notification settings apply in this case instead of group settings). Check out Telegram Blog for more info.
    • \n
    • Setting to disable message preview
    • \n
    \n
    \n
    \n\n
    \n
    0.4.0
    \n
    \n
      \n
    • Full stickers support
    • \n
    • Multisearch box: instantly find chats, usernames and messages
    • \n
    • Emoji autocomplete: e.g., type :kiss in the message field to see the list. Full cheat sheet »
    • \n
    • Added \'typing\' notification in chats list
    • \n
    • Online members counter in group headers
    • \n
    \n
    \n
    \n\n
    \n
    0.3.9
    \n
    \n
      \n
    • [Desktop] Material design completed
    • \n
    \n
    \n
    \n\n
    \n
    0.3.8
    \n
    \n
      \n
    • Telegram.me links open right in Telegram Web when authorized
    • \n
    • @username mentions in messages are clickable and open a conversation with the user
    • \n
    \n
    \n
    \n\n
    \n
    0.3.7
    \n
    \n
      \n
    • [Desktop] New material design for modal windows
    • \n
    • [Desktop] Forward messages to multiple recipients
    • \n
    \n
    \n
    \n\n
    \n
    0.3.6
    \n
    \n
      \n
    • New viewer for photos, videos, documents.
    • \n
    • [FirefoxOS] Improved media downloads.
    • \n
    \n
    \n
    \n\n
    \n
    0.3.5
    \n
    \n
      \n
    • Added embedded Soundcloud tracks and playlists.
    • \n
    • Added global user search to contacts list.
    • \n
    • Added switch to mobile version on window resize.
    • \n
    • Migrate to HTTPS notification
    • \n
    • Bugfixes.
    • \n
    \n
    \n
    \n\n
    \n
    0.3.4
    \n
    \n
      \n
    • Added embedded Facebook posts and Vimeo videos.
    • \n
    • Improved IE10+ support: downloading files and style fixes.
    • \n
    • Added unsupported media playback warning.
    • \n
    • Bugfixes.
    • \n
    \n
    \n
    \n\n
    \n
    0.3.3
    \n
    \n
      \n
    • Added Native Client module: dramatically improved encryption speed; Download and upload speed is now as high as in native applications.
    • \n
    • HTTPS. We recommend you to use https://web.telegram.org.
    • \n
    • Added multiple open tabs warning. Please note, that only one tab with Telegram Web will work.
    • \n
    • Added embedded Instagram, Twitter, Vine, YouTube links.
    • \n
    • Jump to selected spot when playing back audio.
    • \n
    • Bugfixes
    • \n
    \n
    \n
    \n\n
    \n
    0.3.2
    \n
    \n
      \n
    • Usernames support: Choose a username right now!
    • \n
    • Search can now find public users by username.
    • \n
    • Most popular emoticons shown in \'recent\' when empty
    • \n
    • [ChromeApp] Added saving window position and size
    • \n
    • Bugfixes
    • \n
    \n
    \n
    \n\n
    \n
    0.3.1
    \n
    \n
      \n
    • New languages: Spanish, German and Italian are now available
    • \n
    • New custom-made audio player
    • \n
    • Bad browser page for IE 6-9
    • \n
    • Perfomance improvements and bugfixes
    • \n
    \n
    \n
    \n\n
    \n
    0.3.0
    \n
    \n
      \n
    • Log in codes may be received in other Telegram apps
    • \n
    • Partner\'s online status updates automatically
    • \n
    • Added support for non-english hashtags in messages
    • \n
    • Fixed invalid scrollbar width bug
    • \n
    • [Desktop] Added automatic country code detection
    • \n
    • [FirefoxOS] Improved PUSH-notifications for <= 1.1
    • \n
    • [FirefoxOS] Fixed emoji in notifications
    • \n
    • [FirefoxOS] Fixed attachment bug for <= 1.1
    • \n
    • [FirefoxOS] Added phonebook permissions handling
    • \n
    • [FirefoxOS] Added ability to share Gallery photos in Telegram
    • \n
    \n
    \n
    \n\n
    \n\n\n \n\n
    \n\n
    '),e.put("partials/desktop/channel_edit_modal.html",'
    \n\n
    \n\n \n\n
    \n\n \n\n
    '),e.put("partials/desktop/channel_modal.html",'
    \n\n
    \n
    \n
    \n \n \n
    \n
    \n \n \n
    \n
    \n\n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    \n\n
    \n
    \n
    \n \n \n
    \n \n \n \n
    \n
    \n\n
    \n\n
    \n\n
    \n \n\n
    \n
    \n \n
    \n
    \n
    \n\n
    \n
    \n \n
    \n
    \n
    \n\n
    \n
    \n \n \n \n \n
    \n
    \n
    \n
    \n\n \n\n
    \n \n\n \n \n \n \n\n
    \n\n \n\n
    \n\n
    \n\n
    \n\n
    \n \n\n
    \n\n
    \n\n \n \n\n \n\n
    \n \n
    \n
    \n
    \n\n
    \n\n
    \n\n
    \n
    \n\n\n
    \n'),e.put("partials/desktop/chat_create_modal.html",'
    \n\n
    \n\n \n\n
    \n\n \n\n
    '),e.put("partials/desktop/chat_edit_modal.html",'
    \n\n
    \n\n \n\n
    \n\n \n\n
    '),e.put("partials/desktop/chat_invite_link_modal.html",'
    \n\n
    \n\n \n\n
    \n\n \n\n
    '),e.put("partials/desktop/chat_modal.html",'
    \n\n
    \n
    \n
    \n \n \n
    \n
    \n
    \n\n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n \n
    \n
    \n
    \n
    \n\n
    \n
    \n
    \n \n \n
    \n
    \n
    \n\n
    \n\n
    \n\n \n\n \n\n
    \n \n\n \n \n \n \n\n
    \n\n \n\n \n\n
    \n\n
    \n\n
    \n
    \n

    \n

    \n
      \n
    • \n
    • \n
    • \n
    • \n
    \n
    \n
    \n
    \n\n
    \n \n\n
    \n\n
    \n\n \n \n\n \n\n
    \n \n
    \n
    \n
    \n\n
    \n\n
    \n\n
    \n
    \n\n\n
    \n'),e.put("partials/desktop/composer_dropdown.html",'
    \n\n \n\n \n\n
      \n\n
      \n\n
      '),e.put("partials/desktop/confirm_modal.html",'
      \n\n
      \n\n
      \n \n \n \n \n \n\n \n \n \n \n
      \n \n
      \n
      \n \n \n \n \n \n \n \n
      \n \n
      \n \n
      \n
      \n \n \n \n \n \n \n \n \n \n \n
      \n
      \n
      \n
      \n
      \n
      \n
      \n
      \n \n
      \n
      \n \n
      \n
      \n
      \n
      \n
      \n \n
      \n
      \n
      \n
      \n\n\n\n \n \n \n \n
      \n\n
      \n\n \n\n
      \n'),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'),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
      '),e.put("partials/desktop/full_document.html",'
      \n
      \n
      \n
      \n
      \n
      \n
      \n
      \n
      \n
      \n \n
      \n
      \n
      \n \n
      \n
      '),e.put("partials/desktop/full_gif.html",'\n\n
      \n\n
      \n
      \n \n \n \n \n
      \n
      \n
      [GIF]
      \n
      \n\n
      \n \n \n
      \n \n\n
      \n\n
      '),e.put("partials/desktop/full_photo.html",'
      \n
      \n
      \n
      \n
      \n
      \n
      \n
      \n
      \n
      \n \n \n \n
      \n
      \n
      \n
      \n
      \n
      '),e.put("partials/desktop/full_video.html",'
      \n
      \n
      \n
      \n
      \n
      \n
      \n
      \n
      \n \n
      \n
      \n \n \n
      \n
      \n
      \n
      \n
      \n
      '),e.put("partials/desktop/head.html",'
      \n
      \n\n
      \n \n
      \n\n
      \n
      \n \n \n \n
      \n\n
      \n\n \n\n \n\n \n \n \n \n \n\n
      \n
      \n \n
      \n
      \n \n
      \n
      \n \n
      \n
      \n \n
      \n\n \n
      \n \n \n \n \n \n
      \n
      \n\n
      \n\n
      \n
      \n
      \n
      '),e.put("partials/desktop/im.html",'
      \n\n
      \n\n
      \n\n
      \n
      \n \n
      \n\n
      \n
      \n
      \n\n
      \n

      \n

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

      \n

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

      \n
      \n
      \n \n
      \n
      \n
      \n
      '),e.put("partials/desktop/inline_results.html",'\n\n'),e.put("partials/desktop/lang_footer.html",''),e.put("partials/desktop/login.html",'\n\n'),e.put("partials/desktop/media_modal_layout.html",''),e.put("partials/desktop/megagroup_edit_modal.html",'
      \n\n
      \n\n \n\n
      \n\n \n\n
      '),e.put("partials/desktop/message.html",'
      \n\n\n
      \n\n
      \n
      \n
      \n
      \n
      \n
      \n \n \n
      \n\n \n \n \n\n
      \n\n
      \n \n\n \n \n \n \n\n \n\n
      \n
      \n
      \n \n
      \n
      \n \n
      \n\n
      \n\n \n []  :\n \n\n\n \n\n
      \n \n \n
      \n   [\n \n \n \n
      \n
      \n\n
      \n
      \n
      \n
      \n
      \n\n\n
      \n\n
      \n
      \n\n
      \n\n'),e.put("partials/desktop/message_attach_contact.html",'
      \n \n
      \n \n \n
      \n
      \n
      '),e.put("partials/desktop/message_attach_document.html",'
      \n\n
      \n\n
      \n\n
      \n
      \n
      \n\n
      \n
      \n
      \n\n
      \n \n \n \n \n \n\n
      \n
      \n [ ]\n \n \n
      \n
      \n \n \n \n \n \n
      \n
      \n \n
      \n
      \n
      \n
      \n
      \n
      \n
      \n
      \n\n
      \n\n \n \n \n \n
      \n \n
      \n
      \n\n
      \n
      \n []\n \n \n
      \n
      \n \n \n \n
      \n
      \n \n
      \n
      \n
      \n
      \n
      \n
      \n
      \n\n
      \n
      \n
      \n'),e.put("partials/desktop/message_attach_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_webpage.html",'
      \n
      \n
      \n \n
      \n
      \n \n \n \n
      \n
      \n
      \n
      \n \n
      \n
      \n \n \n \n \n \n
      \n\n
      \n
      \n
      \n\n
      \n
      \n \n
      \n
      \n
      \n\n
      \n \n \n \n
      \n
      \n \n
      \n
      \n
      \n
      \n'),e.put("partials/desktop/message_media.html",'
      \n
      \n
      \n
      \n
      \n
      \n
      \n
      \n
      \n \n
      \n
      '),e.put("partials/desktop/message_service.html",'\n \n \n \n «»\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \n \n \n \n «»\n \n \n \n\n \n \n \n\n\n \n \n \n\n'),e.put("partials/desktop/password_recovery_modal.html",'
      \n\n
      \n\n \n\n
      \n\n \n\n
      '),e.put("partials/desktop/password_update_modal.html",'
      \n\n
      \n\n \n\n
      \n\n \n\n
      '),e.put("partials/desktop/peer_select.html",'
      \n\n
      \n
      \n
      \n \n
      \n
      \n
      \n
      \n\n
      \n\n
      \n
      \n \n
      \n
      \n
      \n
      \n \n
      \n
      \n \n
      \n\n
      \n
      \n \n
      \n
      \n
      \n
      \n
      \n\n
      \n\n \n\n \n\n
      \n'),e.put("partials/desktop/photo_modal.html",'\n\n\n\n
      \n
      \n
      \n \n \n \n \n \n \n \n \n \n
      \n\n
      \n \n
      \n \n
      \n
      \n \n \n
      \n
      \n\n
      \n
      \n \n
      \n
      \n
      \n\n
      \n \n \n \n \n \n
      \n
      \n
      \n\n\n\n'),e.put("partials/desktop/pinned_message.html",''),e.put("partials/desktop/profile_edit_modal.html",'
      \n\n
      \n\n \n\n
      \n\n \n\n
      \n'),e.put("partials/desktop/reply_markup.html",'
      \n
      \n
      \n
      \n \n \n
      \n
      \n
      \n
      '),e.put("partials/desktop/reply_message.html",'
      \n
      \n
      \n \n
      \n
      \n \n
      \n
      \n \n \n
      \n
      \n \n \n
      \n
      '),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/short_message.html",'\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n'),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
      \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'),e.put("partials/mobile/edit_contact_modal.html",'
      \n\n
      \n \n
      \n\n \n\n
      '),e.put("partials/mobile/full_gif.html",'\n\n
      \n\n
      \n
      \n \n \n \n \n
      \n
      \n
      GIF
      \n
      \n\n
      \n \n \n
      \n \n\n
      \n\n
      '),e.put("partials/mobile/full_photo.html",'
      \n
      \n
      \n
      \n
      \n
      \n
      \n
      \n
      \n
      \n \n \n \n
      \n
      \n
      \n
      \n
      \n
      '),e.put("partials/mobile/full_video.html",'
      \n
      \n
      \n
      \n
      \n
      \n
      \n
      \n
      \n \n
      \n
      \n \n \n
      \n
      \n
      \n
      \n
      \n
      '),e.put("partials/mobile/head.html",'
      \n \n
      \n'),e.put("partials/mobile/im.html",'
      \n\n
      \n\n
      \n\n
      \n
      \n \n
      \n\n
      \n\n
      \n

      \n

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

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