From dc4e257cace889886c0d04706c04d4c5c086726a Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Tue, 5 May 2015 19:51:08 +0300 Subject: [PATCH] merged with master --- app.manifest | 2 +- js/app.js | 2 +- js/locales/de-de.json | 1 + js/locales/es-es.json | 1 + js/locales/it-it.json | 1 + js/locales/nl-nl.json | 1 + js/locales/pt-br.json | 1 + webogram.appcache | 2 +- 8 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app.manifest b/app.manifest index b4a8265d..90669ddc 100644 --- a/app.manifest +++ b/app.manifest @@ -1,5 +1,5 @@ CACHE MANIFEST -# Time: Tue May 05 2015 18:39:00 GMT+0300 (MSK) +# Time: Tue May 05 2015 19:50:09 GMT+0300 (MSK) CACHE: diff --git a/js/app.js b/js/app.js index 2d3fac16..23e8493d 100644 --- a/js/app.js +++ b/js/app.js @@ -18,7 +18,7 @@ l.storeLongP(0,0,"auth_key_id"),l.storeLong(i.generateID(),"msg_id"),l.storeInt( }):v.notify(d)}function Q(){a.cancel(Mt),Mt=!1,t.$broadcast("history_multiappend",At),At={}}function et(){a.cancel(xt),xt=!1,t.$broadcast("dialogs_multiupdate",Et),Et={}}function tt(){a.cancel(Tt),Tt=!1;var e=t.idle.isIDLE&&S.isOtherDeviceActive()?3e4:1e3;angular.forEach(It,function(t){t.isMutedPromise.then(function(n){var i=t.top_message;!n&&i.unread&&setTimeout(function(){i.unread&&J(i,{fwd_count:t.fwd_count})},e)})}),It={}}var nt,it={},at={},ot={},st={},rt={count:null,dialogs:[]},lt={},ct={},dt={},ut=e.when(),pt=-1,mt=SearchIndexManager.createIndex(),ht={query:!1},gt={},ft=[],_t=[],vt=!1,yt=0,bt=tsNow(!0),wt=bt-bt%86400,$t=new Date;b.get("server_time_offset").then(function(e){e&&(yt=e)});var kt=!1;Config.Modes.packed&&b.get("max_seen_msg").then(function(e){kt=e||0});var St=i("dateOrTime"),Ct=C.pluralize("conversation_forwarded_X_messages");$t.setHours(0),$t.setMinutes(0),$t.setSeconds(0),nt=wt-Math.floor(+$t/1e3),v.start(),window.navigator.mozSetMessageHandler&&window.navigator.mozSetMessageHandler("activity",function(e){var n=e.source;console.log(dT(),"Received activity",n.name,n.data),"share"===n.name&&n.data.blobs.length>0&&y.selectPeers({confirm_type:"EXT_SHARE_PEER"}).then(function(e){angular.forEach(e,function(e){var t=c.getPeerID(e);angular.forEach(n.data.blobs,function(e){B(t,e,{isMedia:!0})})}),1==e.length&&t.$broadcast("history_focus",{peerString:e[0]})})});var Mt=!1,At={},xt=!1,Et={},Tt=!1,It={};return t.$on("apiUpdate",function(e,n){switch(n._){case"updateMessageID":ct[n.id]=n.random_id;break;case"updateNewMessage":var i=n.message,o=V(i),s=st[o];if(void 0!==s){var l=s.history;if(-1!=l.indexOf(i.id))return!1;var d=l[0];l.unshift(i.id),i.id>0&&i.id0&&(rt.dialogs.splice(h[1],1),rt.dialogs.unshift(m)),m.top_message=i.id,g&&m.unread_count++):(SearchIndexManager.indexObject(o,c.getPeerSearchText(o),mt),m={peerID:o,unread_count:g?1:0,top_message:i.id},rt.dialogs.unshift(m)),Et[o]=m,xt||(xt=a(et,0)),g&&(t.selectedPeerID!=o||t.idle.isIDLE)){var f=16&i.flags?i.from_id:o,_=It[f];void 0===_&&(_=It[f]={isMutedPromise:v.getPeerMuted(f),fwd_count:0,from_id:0}),_.from_id!=i.from_id&&(_.from_id=i.from_id,_.fwd_count=0),i.fwd_from_id&&_.fwd_count++,_.top_message=i,Tt||(Tt=a(tt,1e3))}X(i.id);break;case"updateReadHistoryInbox":case"updateReadHistoryOutbox":var y,i,b,w=n.max_id,$="updateReadHistoryOutbox"==n._,o=c.getPeerID(n.peer),h=Z(o),l=(st[o]||{}).history||[],k=!1,S=l.length,C=!1;for(o>0&&$&&r.forceUserOnline(o),b=0;S>b;b++)if(y=l[b],!(y>w)&&(i=it[y],i.out==$)){if(!i.unread)break;i&&i.unread&&(i.unread=!1,at[y]&&(at[y].unread=!1,C||(C=!0)),ot[y]&&(ot[y].unread=!1),i.out||(h&&(k=--h[0].unread_count),v.cancel("msg"+y)))}k!==!1&&t.$broadcast("dialog_unread",{peerID:o,count:k}),C&&t.$broadcast("messages_read");break;case"updateReadMessagesContents":var b,y,i,M,A=n.messages,x=A.length;for(b=0;x>b;b++)y=A[b],(i=it[y])&&delete i.media_unread,(M=at[y])&&delete M.media_unread;break;case"updateDeleteMessages":var y,i,b,o,h,l,E={};for(b=0;bo&&(i=e,a=o)}),i}function c(e,t,n){return i.invokeApi("photos.getUserPhotos",{user_id:e,offset:0,limit:n||20,max_id:t||0}).then(function(e){o.saveApiUsers(e.users);for(var t=[],n=0;n800&&(i-=208);var s=l(n,i,o);s&&!s.preloaded&&(s.preloaded=!0,s.size?a.downloadFile(s.location.dc_id,{_:"inputFileLocation",volume_id:s.location.volume_id,local_id:s.location.local_id,secret:s.location.secret},s.size):a.downloadSmallFile(s.location))}}function u(e){return f[e]||{_:"photoEmpty"}}function p(e,t){t=t||{};var n=angular.copy(f[e])||{_:"photoEmpty"},i=t.website?100:Math.min(_-80,Config.Mobile?210:260),a=t.website?100:Math.min(v-100,Config.Mobile?210:260),o=l(n,i,a),s={placeholder:"img/placeholders/PhotoThumbConversation.gif",width:i,height:a};if(o&&"photoSizeEmpty"!=o._){var r=calcImageInBox(o.w,o.h,i,a);s.width=r.w,s.height=r.h,s.location=o.location,s.size=o.size}else s.width=100,s.height=100;return n.thumb=s,n}function m(e){var n=p(e),i=$(window).width()-(Config.Mobile?0:32),a=$(t).height()-(Config.Mobile?0:116);!Config.Mobile&&i>800&&(i-=208);var o=l(n,i,a),s={placeholder:"img/placeholders/PhotoThumbModal.gif"};if(s.width=i,s.height=a,o&&"photoSizeEmpty"!=o._){var r=calcImageInBox(o.w,o.h,i,a,!0);s.width=r.w,s.height=r.h,s.modalWidth=Math.max(s.width,Math.min(400,i)),s.location=o.location,s.size=o.size}return n.full=s,n}function h(t,i){if(!t||"0"===t)return!1;var a=n.$new(!0);a.photoID=t;var o="PhotoModalController";i&&i.p>0?(o="UserpicModalController",a.userID=i.p):i&&i.p<0?(o="ChatpicModalController",a.chatID=-i.p):i&&i.m>0&&(a.messageID=i.m,i.w&&(a.webpageID=i.w));e.open({templateUrl:templateUrl("photo_modal"),windowTemplateUrl:templateUrl("media_modal_layout"),controller:o,scope:a,windowClass:"photo_modal_window"})}function g(e){var n=f[e],i="jpg",o="image/jpeg",r="photo"+e+"."+i,c=Math.max(screen.width||0,$(window).width()-36,800),d=Math.max(screen.height||0,$(t).height()-150,800),u=l(n,c,d),p={_:"inputFileLocation",volume_id:u.location.volume_id,local_id:u.location.local_id,secret:u.location.secret};s.chooseSave(r,i,o).then(function(e){e&&a.downloadFile(u.location.dc_id,p,u.size,{mime:o,toFileEntry:e}).then(function(){},function(e){console.log("photo download failed",e)})},function(){var e=a.getCachedFile(p);return e?s.download(e,o,r):void a.downloadFile(u.location.dc_id,p,u.size,{mime:o}).then(function(e){s.download(e,o,r)},function(e){console.log("photo download failed",e)})})}var f={},_=$(window).width(),v=$(window).height();return n.preloadPhoto=d,n.openPhoto=h,{savePhoto:r,preloadPhoto:d,getUserPhotos:c,getPhoto:u,choosePhotoSize:l,wrapForHistory:p,wrapForFull:m,openPhoto:h,downloadPhoto:g}}]).service("AppWebPagesManager",["$modal","$sce","$window","$rootScope","MtpApiManager","AppPhotosManager","RichTextProcessor",function(e,t,n,i,a,o,s){function r(e,t){e.photo&&"photo"===e.photo._?o.savePhoto(e.photo):delete e.photo,e.rTitle=s.wrapRichText(e.title||e.author,{noLinks:!0,noLinebreaks:!0});var n="";if("GitHub"==e.site_name){var a=e.url.match(/(https?:\/\/github\.com\/[^\/]+\/[^\/]+)/);a&&(n=a[0]+"/issues/{1}")}if(e.rDescription=s.wrapRichText(e.description,{contextSite:e.site_name||"external",contextHashtag:n}),t&&(void 0===p[e.id]&&(p[e.id]={}),p[e.id][t]=!0,u[e.id]=e),void 0===u[e.id]?u[e.id]=e:safeReplaceObject(u[e.id],e),!t&&void 0!==p[e.id]){var r=[];angular.forEach(p[e.id],function(e,t){r.push(t)}),i.$broadcast("webpage_updated",{id:e.id,msgs:r})}}function l(t,n){var a=i.$new(!0);a.webpageID=t,a.messageID=n,e.open({templateUrl:templateUrl("embed_modal"),windowTemplateUrl:templateUrl("media_modal_layout"),controller:"EmbedModalController",scope:a,windowClass:"photo_modal_window"})}function c(e){var t=angular.copy(u[e])||{_:"webPageEmpty"};return t.photo&&t.photo.id&&(t.photo=o.wrapForHistory(t.photo.id,{website:"photo"!=t.type&&"video"!=t.type})),t}function d(e){var i=c(e);if(!i.embed_url)return i;var a=$(window).width()-(Config.Mobile?0:10),o=$(n).height()-(Config.Mobile?92:150);!Config.Mobile&&a>800&&(a-=208);var s={width:a,height:o};if(i.embed_width&&i.embed_height){var r=calcImageInBox(i.embed_width,i.embed_height,a,o);s.width=r.w,s.height=r.h}else s.height=s.width=Math.min(a,o);var l=Config.Modes.chrome_packed?"webview":"iframe",d="iframe"!=i.embed_type?i.embed_type||"text/html":"text/html",u="<"+l+' src="'+encodeEntities(i.embed_url)+'" type="'+encodeEntities(d)+'" frameborder="0" border="0" webkitallowfullscreen mozallowfullscreen allowfullscreen width="'+s.width+'" height="'+s.height+'" style="width: '+s.width+"px; height: "+s.height+'px;">";return s.html=t.trustAs("html",u),i.full=s,i}var u={},p={};return i.$on("apiUpdate",function(e,t){switch(t._){case"updateWebPage":r(t.webpage)}}),{saveWebPage:r,openEmbed:l,wrapForFull:d,wrapForHistory:c}}]).service("AppVideoManager",["$sce","$rootScope","$modal","$window","MtpApiFileManager","AppUsersManager","FileManager","qSync",function(e,t,n,i,a,o,s,r){function l(e){g[e.id]=e,e.thumb&&"photoCachedSize"==e.thumb._&&(a.saveSmallFile(e.thumb.location,e.thumb.bytes),e.thumb.size=e.thumb.bytes.length,delete e.thumb.bytes,e.thumb._="photoSize")}function c(e){if(void 0!==f[e])return f[e];var t=angular.copy(g[e]),n=Math.min(_-80,Config.Mobile?210:150),i=Math.min(v-100,Config.Mobile?210:150),a=t.thumb,o={placeholder:"img/placeholders/VideoThumbConversation.gif",width:n,height:i};return a&&"photoSizeEmpty"!=a._&&(a.w/a.h>n/i?o.height=parseInt(a.h*n/a.w):(o.width=parseInt(a.w*i/a.h),o.width>n&&(o.height=parseInt(o.height*n/o.width),o.width=n)),o.location=a.location,o.size=a.size),t.thumb=o,f[e]=t}function d(e){var t=c(e),n=Math.min($(window).width()-(Config.Mobile?0:60),542),a=$(i).height()-(Config.Mobile?92:150),o={placeholder:"img/placeholders/VideoThumbModal.gif",width:n,height:a};if(t.w&&t.h){var s=calcImageInBox(t.w,t.h,n,a);o.width=s.w,o.height=s.h}else o.height=o.width=Math.min(n,a);return t.full=o,t.fullThumb=angular.copy(t.thumb),t.fullThumb.width=o.width,t.fullThumb.height=o.height,t}function u(e,i){var a=t.$new(!0);return a.videoID=e,a.messageID=i,n.open({templateUrl:templateUrl("video_modal"),windowTemplateUrl:templateUrl("media_modal_layout"),controller:"VideoModalController",scope:a,windowClass:"video_modal_window"})}function p(e){var t=g[e],n=f[e]||t||{},i={_:"inputVideoFileLocation",id:e,access_hash:t.access_hash};void 0===n.downloaded&&a.getDownloadedFile(i,t.size).then(function(){n.downloaded=!0},function(){n.downloaded=!1})}function m(n,i){var o=g[n],l=f[n]||o||{},c=o.mime_type||"video/ogg",d={_:"inputVideoFileLocation",id:n,access_hash:o.access_hash};if(l.downloaded&&!i){var u=a.getCachedFile(d);if(u)return r.when(u)}l.progress={enabled:!l.downloaded,percent:1,total:o.size};var p=a.downloadFile(o.dc_id,d,o.size,{mime:c,toFileEntry:i});return p.then(function(t){s.getFileCorrectUrl(t,c).then(function(t){l.url=e.trustAsResourceUrl(t)}),delete l.progress,l.downloaded=!0,console.log("video save done")},function(e){console.log("video download failed",e),l.progress.enabled=!1},function(e){console.log("dl progress",e),l.progress.enabled=!0,l.progress.done=e.done,l.progress.percent=Math.max(1,Math.floor(100*e.done/e.total)),t.$broadcast("history_update")}),l.progress.cancel=p.cancel,p}function h(e){{var t=g[e],n=t.mime_type||"video/mp4",i=n.split(".")[1]||"mp4",a="t_video"+e+"."+i;f[e]||t||{}}s.chooseSave(a,i,n).then(function(t){t&&m(e,t)},function(){m(e).then(function(e){s.download(e,n,a)})})}var g={},f={},_=$(window).width(),v=$(window).height();return{saveVideo:l,wrapForHistory:c,wrapForFull:d,openVideo:u,updateVideoDownloaded:p,downloadVideo:m,saveVideoFile:h}}]).service("AppDocsManager",["$sce","$rootScope","$modal","$window","$q","RichTextProcessor","MtpApiFileManager","FileManager","qSync",function(e,t,n,i,a,o,s,r,l){function c(e){f[e.id]=e,e.thumb&&"photoCachedSize"==e.thumb._&&(s.saveSmallFile(e.thumb.location,e.thumb.bytes),e.thumb.size=e.thumb.bytes.length,delete e.thumb.bytes,e.thumb._="photoSize"),angular.forEach(e.attributes,function(t){switch(t._){case"documentAttributeFilename":e.file_name=t.file_name;break;case"documentAttributeVideo":case"documentAttributeAudio":e.duration=t.duration;break;case"documentAttributeSticker":e.sticker=1;var n=t.alt||EmojiHelper.stickers[e.id];void 0!==n&&(e.sticker=2,e.stickerEmoji=o.wrapRichText(n,{noLinks:!0,noLinebreaks:!0}));break;case"documentAttributeImageSize":e.w=t.w,e.h=t.h}}),e.file_name=e.file_name||""}function d(e){return f[e]||{_:"documentEmpty"}}function u(e){if(void 0!==_[e])return _[e];var t,n,i=angular.copy(f[e]),a="image/gif"==i.mime_type,o="image/"==i.mime_type.substr(0,6)&&i.sticker,s=i.thumb;a?(t=Math.min(v-80,260),n=Math.min(y-100,260)):o?(t=Math.min(v-80,Config.Mobile?210:260),n=Math.min(y-100,Config.Mobile?210:260)):t=n=100;var r={width:t,height:n};if(s&&"photoSizeEmpty"!=s._){var l=calcImageInBox(s.w,s.h,t,n);r.width=l.w,r.height=l.h,r.location=s.location,r.size=s.size}else if(o){var l=calcImageInBox(i.w,i.h,t,n);r.width=l.w,r.height=l.h}else r=!1;return i.thumb=r,i.withPreview=!Config.Mobile&&i.mime_type.match(/^(image\/)/)?1:0,a&&i.thumb?i.isSpecial="gif":o?i.isSpecial="sticker":"audio/"==i.mime_type.substr(0,6)&&(i.isSpecial="audio"),_[e]=i}function p(e){var t=f[e],n=_[e]||t||{},i={_:"inputDocumentFileLocation",id:e,access_hash:t.access_hash};void 0===n.downloaded&&s.getDownloadedFile(i,t.size).then(function(){n.downloaded=!0},function(){n.downloaded=!1})}function m(n,i){var a=f[n],o=_[n]||a||{},c={_:"inputDocumentFileLocation",id:n,access_hash:a.access_hash};if(o.downloaded&&!i){var d=s.getCachedFile(c);if(d)return l.when(d)}o.progress={enabled:!o.downloaded,percent:1,total:a.size};var u=s.downloadFile(a.dc_id,c,a.size,{mime:a.mime_type||"application/octet-stream",toFileEntry:i});return u.then(function(t){delete o.progress,t&&(r.getFileCorrectUrl(t,a.mime_type).then(function(t){o.url=e.trustAsResourceUrl(t)}),o.downloaded=!0),console.log("file save done")},function(e){console.log("document download failed",e),o.progress.enabled=!1},function(e){console.log("dl progress",e),o.progress.enabled=!0,o.progress.done=e.done,o.progress.percent=Math.max(1,Math.floor(100*e.done/e.total)),t.$broadcast("history_update")}),o.progress.cancel=u.cancel,u}function h(e,i){var a=t.$new(!0);a.docID=e,a.messageID=i;n.open({templateUrl:templateUrl("document_modal"),windowTemplateUrl:templateUrl("media_modal_layout"),controller:"DocumentModalController",scope:a,windowClass:"document_modal_window"})}function g(e){var t=f[e],n=(_[e]||t||{},(t.file_name.split(".",2)||[])[1]||"");r.chooseSave(t.file_name,n,t.mime_type).then(function(t){t&&m(e,t)},function(){m(e).then(function(e){r.download(e,t.mime_type,t.file_name)})})}var f={},_={},v=$(window).width(),y=$(window).height();return{saveDoc:c,getDoc:d,wrapForHistory:u,updateDocDownloaded:p,downloadDoc:m,openDoc:h,saveDocFile:g}}]).service("AppAudioManager",["$sce","$rootScope","$modal","$window","MtpApiFileManager","FileManager","qSync",function(e,t,n,i,a,o,s){function r(e){p[e.id]=e}function l(e){if(void 0!==m[e])return m[e];var t=angular.copy(p[e]);return m[e]=t}function c(e){var t=p[e],n=m[e]||t||{},i={_:"inputAudioFileLocation",id:e,access_hash:t.access_hash};void 0===n.downloaded&&a.getDownloadedFile(i,t.size).then(function(){n.downloaded=!0},function(){n.downloaded=!1})}function d(n,i){var r=p[n],l=m[n]||r||{},c=r.mime_type||"audio/ogg",d={_:"inputAudioFileLocation",id:n,access_hash:r.access_hash};if(l.downloaded&&!i){var u=a.getCachedFile(d);if(u)return s.when(u)}l.progress={enabled:!l.downloaded,percent:1,total:r.size};var h=a.downloadFile(r.dc_id,d,r.size,{mime:c,toFileEntry:i});return h.then(function(t){o.getFileCorrectUrl(t,c).then(function(t){l.url=e.trustAsResourceUrl(t)}),delete l.progress,l.downloaded=!0,console.log("audio save done")},function(e){console.log("audio download failed",e),l.progress.enabled=!1},function(e){console.log("dl progress",e),l.progress.enabled=!0,l.progress.done=e.done,l.progress.percent=Math.max(1,Math.floor(100*e.done/e.total)),t.$broadcast("history_update")}),l.progress.cancel=h.cancel,h}function u(e){{var t=p[e],n=t.mime_type||"audio/ogg",i=n.split(".")[1]||"ogg",a="t_audio"+e+"."+i;m[e]||t||{}}o.chooseSave(a,i,n).then(function(t){t&&d(e,t)},function(){d(e).then(function(e){o.download(e,n,a)})})}var p={},m={};return{saveAudio:r,wrapForHistory:l,updateAudioDownloaded:c,downloadAudio:d,saveAudioFile:u}}]).service("AppStickersManager",["$q","FileManager","MtpApiManager","MtpApiFileManager","AppDocsManager","Storage",function(e,t,n,i,a,o){function s(){h||(h=!0,setTimeout(d,1e3),setInterval(r,9e5))}function r(){d().then(u)}function l(e){return EmojiHelper.stickers[e]||!1}function c(e){if(m!==e.hash){m=e.hash;var t,n,i,o;for(i=e.documents.length,t=0;i>t;t++)a.saveDoc(e.documents[t]);var s,r,l,c={};for(p=[],i=e.packs.length,t=0;i>t;t++)for(s=e.packs[t],r=s.emoticon,o=s.documents.length,n=0;o>n;n++)l=s.documents[n],void 0===EmojiHelper.stickers[l]&&(EmojiHelper.stickers[l]=r),void 0===c[l]&&(c[l]=!0,p.push(l))}return p}function d(){return o.get("all_stickers").then(function(e){var t=Config.Schema.API.layer;return e.layer!=t&&(e=!1),e&&e.date>tsNow(!0)?c(e):n.invokeApi("messages.getAllStickers",{hash:e&&e.hash||""}).then(function(n){return"messages.allStickersNotModified"==n._&&(n=e),n.date=tsNow(!0)+3600,n.layer=t,delete n._,o.set({all_stickers:n}),c(n)})})}function u(){var n=[];return angular.forEach(p,function(e){var o=a.getDoc(e),s=i.downloadSmallFile(o.thumb.location).then(function(n){return WebpManager.isWebpSupported()?{id:e,src:t.getUrl(n,"image/webp")}:t.getByteArray(n).then(function(t){return{id:e,src:WebpManager.getPngUrlFromData(t)}})});n.push(s)}),e.all(n)}var p=[],m=!1,h=!1;return{start:s,getStickerEmoji:l,getStickers:d,getStickersImages:u}}]).service("ApiUpdatesManager",["$rootScope","MtpNetworkerFactory","AppUsersManager","AppChatsManager","AppPeersManager","MtpApiManager",function(e,t,n,i,a,o){function s(){var e=h.seq+1,t=v[e];if(!t)return!1;for(var n,i,a=t.updates,n=0,i=a.length;i>n;n++)p(a[n]);return h.seq=t.seq,t.date&&h.date=f.seqAwaiting&&(f.ptsAwaiting?delete f.seqAwaiting:(clearTimeout(f.timeout),f=!1)),!0}function r(){if(!y.length)return!1;y.sort(function(e,t){return e.pts-t.pts});for(var e,t=h.pts,n=!1,i=!1,a=0,o=y.length;o>a;a++)e=y[a],t+=e.pts_count,t>=e.pts&&(n=e.pts,i=a);if(!n)return!1;for(h.pts=n,a=0;i>=a;a++)e=y[a],p(e);return y.splice(i,o-i),!y.length&&f&&(f.seqAwaiting?delete f.ptsAwaiting:(clearTimeout(f.timeout),f=!1)),!0}function l(){_||d()}function c(e){var t={date:e.date,seq:e.seq,seqStart:e.seq_start};switch(e._){case"updatesTooLong":case"new_session_created":l();break;case"updateShort":u(e.update,t);break;case"updateShortMessage":case"updateShortChatMessage":var o=2&e.flags,s=e.from_id||(o?g:e.user_id),r=e.chat_id?-e.chat_id:o?e.user_id:g;u({_:"updateNewMessage",message:{_:"message",flags:e.flags,id:e.id,from_id:s,to_id:a.getOutputPeer(r),date:e.date,message:e.message,fwd_from_id:e.fwd_from_id,fwd_date:e.fwd_date,reply_to_msg_id:e.reply_to_msg_id},pts:e.pts,pts_count:e.pts_count},t);break;case"updatesCombined":case"updates":n.saveApiUsers(e.users),i.saveApiChats(e.chats),angular.forEach(e.updates,function(e){u(e,t)});break;default:console.warn(dT(),"Unknown update message",e)}}function d(){_||(_=!0,v={},y=[]),f&&(clearTimeout(f.timeout),f=!1),o.invokeApi("updates.getDifference",{pts:h.pts,date:h.date,qts:-1}).then(function(t){if("updates.differenceEmpty"==t._)return console.log(dT(),"apply empty diff",t.seq),h.date=t.date,h.seq=t.seq,_=!1,e.$broadcast("stateSynchronized"),!1;n.saveApiUsers(t.users),i.saveApiChats(t.chats),angular.forEach(t.other_updates,function(e){p(e)}),angular.forEach(t.new_messages,function(e){p({_:"updateNewMessage",message:e,pts:h.pts,pts_count:0})});var a=t.intermediate_state||t.state;h.seq=a.seq,h.pts=a.pts,h.date=a.date,console.log(dT(),"apply diff",h.seq,h.pts),"updates.differenceSlice"==t._?d():(e.$broadcast("stateSynchronized"),_=!1)})}function u(e,t){if(_)return!1;if("updateNewMessage"==e._){var a=e.message;if(a.from_id&&!n.hasUser(a.from_id)||a.fwd_from_id&&!n.hasUser(a.fwd_from_id)||a.to_id.user_id&&!n.hasUser(a.to_id.user_id)||a.to_id.chat_id&&!i.hasChat(a.to_id.chat_id))return console.warn(dT(),"Short update not enough data",a),l(),!1}var o,c;if(e.pts){var u=h.pts+(e.pts_count||0);if(u0){var m=t.seq,g=t.seqStart||m;if(g!=h.seq+1&&g>h.seq)return console.warn(dT(),"Seq hole",h,f&&f.seqAwaiting),void 0===v[g]&&(v[g]={seq:m,date:t.date,updates:[]}),v[g].updates.push(e),f||(f={timeout:setTimeout(function(){d()},5e3)}),(!f.seqAwaiting||f.seqAwaiting-1)return n=Math.floor(t/a),i=t%a,{category:o,row:n,column:i};return console.error("emoji not found in spritesheet",e),null}function i(i,s){if(!i||!i.length)return"";s=s||{};for(var u,p,m,h,g=i,v=[],y=s.contextSite||"Telegram",b="Telegram"!=y,w=!1;u=g.match(f);){if(v.push(encodeEntities(g.substr(0,u.index))),u[3]){var $=!s.noLinks&&A[y];if($){var k="";s.highlightUsername&&s.highlightUsername.toLowerCase()==u[3].toLowerCase()&&(k='class="im_message_mymention"'),v.push(u[1],"',encodeEntities(u[2]+u[3]),"")}else v.push(u[1],encodeEntities(u[2]+u[3]))}else if(u[4])if(s.noLinks)v.push(encodeEntities(u[0]));else if(_.test(u[4]))v.push('',encodeEntities(u[4]),"");else{var p=!1,S=u[5],C=u[6],x="";if(C){if(S||"xn--"!==C.substr(0,4)&&-1===Config.TLD.indexOf(C.toLowerCase())||(S="http://"),S){var E=a(u[4]);E.length!==u[4].length&&(x=u[4].substring(E.length),u[4]=E),p=(u[5]?"":S)+u[4]}var T;if("me"==C&&(T=p.match(/^https?:\/\/telegram\.me\/(.+)/))){var I=T[1].split("/");switch(I[0]){case"joinchat":p="tg://join?invite="+I[1];break;default:p="tg://resolve?domain="+I[0]}}}else p=(u[5]?"":"http://")+u[4];p?(v.push('',encodeEntities(u[4]),"",x),s.extractUrlEmbed&&!s.extractedUrlEmbed&&(s.extractedUrlEmbed=o(p))):v.push(encodeEntities(u[0]))}else if(u[7])v.push(s.noLinebreaks?" ":"
");else if(u[8])(r=l[u[8]])&&(h=n(r))?(m=encodeEntities(c[r][1][0]),w=!0,v.push('',":",m,":")):v.push(encodeEntities(u[8]));else if(u[10]){var $=!s.noLinks&&M[y]||s.contextHashtag;$?v.push(encodeEntities(u[9]),"',encodeEntities(u[10]),""):v.push(encodeEntities(u[9]),encodeEntities(u[10]))}g=g.substr(u.index+u[0].length)}return v.push(encodeEntities(g)),i=t(v.join("")),w&&(i=i.replace(/\ufe0f|️|�|‍/g,"",i),i=i.replace(//g,'')),e.trustAs("html",i)}function a(e){for(var t=e.length,n=e.split("(").length-1,i=e.split(")").length-1;i>n&&")"===e.charAt(t-1);)e=e.substr(0,t-1),i--,t--;return n>i&&(e=e.replace(/\)+$/,"")),e}function o(e){var t;if(t=e.match(v))return["youtube",t[1]];if(t=e.match(y))return["vimeo",t[1]];if(t=e.match(b))return["instagram",t[1]];if(t=e.match(w))return["vine",t[1]];if(t=e.match(S)){var n="explore,upload,pages,terms-of-use,mobile,jobs,imprint".split(","),i="sets".split(",");if(-1==n.indexOf(t[1])&&-1==i.indexOf(t[2]))return["soundcloud",t[0]]}else if(t=e.match(C))return["spotify",t[3].replace("/",":")];if(!Config.Modes.chrome_packed){if(t=e.match($))return["twitter",t[0]];if(t=e.match(k))return void 0!=t[2]?["facebook","https://www.facebook.com/"+t[2]+"/posts/"+t[1]]:["facebook",t[0]]}return!1}function s(e,t){if(u)return e;if(!e||!e.length)return"";t=t||{},e=e.replace(/\ufe0f/g,"",e);for(var n,i,a=e,e=[];n=a.match(f);)e.push(a.substr(0,n.index)),e.push(n[8]?(r=l[n[8]])&&(i=c[r][1][0])?":"+i+":":n[0]:n[0]),a=a.substr(n.index+n[0].length);return e.push(a),e.join("")}var r,l={},c=Config.Emoji,d=18,u=-1!=navigator.userAgent.search(/OS X|iPhone|iPad|iOS|Android/i),p="\\u0023\\u20E3|\\u00a9|\\u00ae|\\u203c|\\u2049|\\u2139|[\\u2194-\\u2199]|\\u21a9|\\u21aa|\\u231a|\\u231b|\\u23e9|[\\u23ea-\\u23ec]|\\u23f0|\\u24c2|\\u25aa|\\u25ab|\\u25b6|\\u2611|\\u2614|\\u26fd|\\u2705|\\u2709|[\\u2795-\\u2797]|\\u27a1|\\u27b0|\\u27bf|\\u2934|\\u2935|[\\u2b05-\\u2b07]|\\u2b1b|\\u2b1c|\\u2b50|\\u2b55|\\u3030|\\u303d|\\u3297|\\u3299|[\\uE000-\\uF8FF\\u270A-\\u2764\\u2122\\u25C0\\u25FB-\\u25FE\\u2615\\u263a\\u2648-\\u2653\\u2660-\\u2668\\u267B\\u267F\\u2693\\u261d\\u26A0-\\u26FA\\u2708\\u2702\\u2601\\u260E]|[\\u2600\\u26C4\\u26BE\\u23F3\\u2764]|\\uD83D[\\uDC00-\\uDFFF]|\\uD83C[\\uDDE8-\\uDDFA�]\\uD83C[\\uDDEA-\\uDDFA�]|[0-9]\\u20e3|\\uD83C[\\uDC00-\\uDFFF]";for(r in c)l[c[r][0]]=r;var m="a-z\\u00c0-\\u00d6\\u00d8-\\u00f6\\u00f8-\\u00ff\\u0100-\\u024f\\u0253\\u0254\\u0256\\u0257\\u0259\\u025b\\u0263\\u0268\\u026f\\u0272\\u0289\\u028b\\u02bb\\u0300-\\u036f\\u1e00-\\u1eff\\u0400-\\u04ff\\u0500-\\u0527\\u2de0-\\u2dff\\ua640-\\ua69f\\u0591-\\u05bf\\u05c1-\\u05c2\\u05c4-\\u05c5\\u05c7\\u05d0-\\u05ea\\u05f0-\\u05f4\\ufb1d-\\ufb28\\ufb2a-\\ufb36\\ufb38-\\ufb3c\\ufb3e\\ufb40-\\ufb41\\ufb43-\\ufb44\\ufb46-\\ufb4f\\u0610-\\u061a\\u0620-\\u065f\\u066e-\\u06d3\\u06d5-\\u06dc\\u06de-\\u06e8\\u06ea-\\u06ef\\u06fa-\\u06fc\\u06ff\\u0750-\\u077f\\u08a0\\u08a2-\\u08ac\\u08e4-\\u08fe\\ufb50-\\ufbb1\\ufbd3-\\ufd3d\\ufd50-\\ufd8f\\ufd92-\\ufdc7\\ufdf0-\\ufdfb\\ufe70-\\ufe74\\ufe76-\\ufefc\\u200c\\u0e01-\\u0e3a\\u0e40-\\u0e4e\\u1100-\\u11ff\\u3130-\\u3185\\uA960-\\uA97F\\uAC00-\\uD7AF\\uD7B0-\\uD7FF\\u3003\\u3005\\u303b\\uff21-\\uff3a\\uff41-\\uff5a\\uff66-\\uff9f\\uffa1-\\uffdc",h="0-9_"+m,g="((?:https?|ftp)://|mailto:)?(?:\\S{1,64}(?::\\S{0,64})?@)?(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])(?:\\.(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])){3}|["+m+"0-9]["+m+"0-9-]{0,64}(?:\\.["+m+"0-9]["+m+"0-9-]{0,64}){0,10}(?:\\.(xn--[0-9a-z]{2,16}|["+m+"]{2,24})))(?::\\d{2,5})?(?:/(?:\\S{0,255}[^\\s.;,(\\[\\]{}<>\"'])?)?",f=new RegExp("(^|\\s)(@)([a-zA-Z\\d_]{5,32})|("+g+")|(\\n)|("+p+")|(^|\\s)(#["+h+"]{2,64})","i"),_=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,v=/^(?:https?:\/\/)?(?:www\.)?youtu(?:|\.be|be\.com|\.b)(?:\/v\/|\/watch\\?v=|e\/|(?:\/\??#)?\/watch(?:.+)v=)(.{11})(?:\&[^\s]*)?/,y=/^(?:https?:\/\/)?(?:www\.)?vimeo\.com\/(\d+)/,b=/^https?:\/\/(?:instagr\.am\/p\/|instagram\.com\/p\/)([a-zA-Z0-9\-\_]+)/i,w=/^https?:\/\/vine\.co\/v\/([a-zA-Z0-9\-\_]+)/i,$=/^https?:\/\/twitter\.com\/.+?\/status\/\d+/i,k=/^https?:\/\/(?:www\.|m\.)?facebook\.com\/(?:.+?\/posts\/\d+|(?:story\.php|permalink\.php)\?story_fbid=(\d+)(?:&substory_index=\d+)?&id=(\d+))/i,S=/^https?:\/\/(?:soundcloud\.com|snd\.sc)\/([a-zA-Z0-9%\-\_]+)\/([a-zA-Z0-9%\-\_]+)/i,C=/(https?:\/\/(open\.spotify\.com|play\.spotify\.com|spoti\.fi)\/(.+)|spotify:(.+))/i,M={Telegram:"#/im?q=%23{1}",Twitter:"https://twitter.com/hashtag/{1}",Instagram:"https://instagram.com/explore/tags/{1}/","Google Plus":"https://plus.google.com/explore/{1}"},A={Telegram:"#/im?p=%40{1}",Twitter:"https://twitter.com/{1}",Instagram:"https://instagram.com/{1}/",GitHub:"https://github.com/{1}"};return{wrapRichText:i,wrapPlainText:s}}]).service("StatusManager",["$timeout","$rootScope","MtpApiManager","AppUsersManager","IdleManager",function(e,t,n,i){function a(){d||(d=!0,t.$watch("idle.isIDLE",s),t.$watch("offline",s))}function o(e){var a=tsNow();if(!(e&&!c||!e&&5e4>a-c||t.offline))return c=e?0:a,i.setUserStatus(u,e),n.invokeApi("account.updateStatus",{offline:e},{noErrorBox:!0})}function s(){l&&e.cancel(l),t.idle.isIDLE?l=e(function(){o(!0)},5e3):(o(!1),l=e(s,6e4))}function r(){return p?tsNow()>p?(p=!1,!1):!0:!1}var l,c=0,d=!1,u=0,p=!1;return n.getUserID().then(function(e){u=e}),t.$on("apiUpdate",function(e,t){"updateUserStatus"==t._&&t.user_id==u&&(p=tsNow()+("userStatusOnline"==t.status._?3e5:0))}),{start:a,isOtherDeviceActive:r}}]).service("NotificationsManager",["$rootScope","$window","$interval","$q","_","MtpApiManager","AppPeersManager","IdleManager","Storage","AppRuntimeManager",function(e,t,n,i,a,o,s,r,l,c){function d(){l.get("notify_nodesktop","notify_volume","notify_novibrate","notify_nopreview").then(function(e){z.nodesktop=e[0],z.volume=e[1]===!1?.5:e[1],z.novibrate=e[2],z.nopreview=e[3]})}function u(){return z}function p(e){return void 0!==B[e]?B[e]:B[e]=o.invokeApi("account.getNotifySettings",{peer:{_:"inputNotifyPeer",peer:s.getInputPeerByID(e)}})}function m(e){if(e=e||"favicon.ico",T!==e){var t=document.createElement("link");t.rel="shortcut icon",t.type="image/x-icon",t.href=e,F.parentNode.replaceChild(t,F),F=t,T=e}}function h(e,t){B[e]=i.when(t)}function g(e,t){h(e,t);var n=angular.copy(t);return n._="inputPeerNotifySettings",o.invokeApi("account.updateNotifySettings",{peer:{_:"inputNotifyPeer",peer:s.getInputPeerByID(e)},settings:n})}function f(e){return p(e).then(function(e){return"peerNotifySettings"==e._&&1e3*e.mute_until>tsNow()})}function _(){if(d(),e.$on("settings_changed",d),C(),!I)return!1;"Notification"in window&&"granted"!==Notification.permission&&"denied"!==Notification.permission&&$(t).on("click",v);try{"onbeforeunload"in window&&$(t).on("beforeunload",S)}catch(n){}}function v(){Notification.requestPermission(),$(t).off("click",v)}function y(e){Config.Navigator.ffos?e.image="https://raw.githubusercontent.com/zhukov/webogram/master/app/img/icons/icon60.png":e.image||(e.image="img/icons/icon60.png"),N++;var t=tsNow();if(z.volume>0&&(!e.tag||!U[e.tag]||t>U[e.tag]+6e4)&&(b(z.volume),U[e.tag]=t),!I||"Notification"in window&&"granted"!==Notification.permission)return!1;if(z.nodesktop){if(O&&!z.novibrate)return void navigator.vibrate([200,100,200])}else{var n,i=++P,a=e.key||"k"+i;if("Notification"in window)n=new Notification(e.title,{icon:e.image||"",body:e.message||"",tag:e.tag||""}); else if("mozNotification"in navigator)n=navigator.mozNotification.createNotification(e.title,e.message||"",e.image||"");else{if(!A)return;window.external.msSiteModeClearIconOverlay(),window.external.msSiteModeSetIconOverlay("img/icons/icon16.png",e.title),window.external.msSiteModeActivate(),n={index:i}}n.onclick=function(){n.close(),c.focus(),S(),e.onclick&&e.onclick()},n.onclose=function(){delete D[a],S()},n.show&&n.show(),D[a]=n}}function b(e){var t=tsNow();if(!(L&&L>t&&R==e)){L=t+1e3,R=e;var n="img/sound_a.mp3",i=$("#notify_sound").html('');i.find("audio")[0].volume=e}}function w(e){var t=D[e];if(t){N>0&&N--;try{t.close?t.close():A&&t.index==P&&window.external.msSiteModeClearIconOverlay()}catch(n){}delete N[e]}}function k(e){delete U[e]}function S(){A?window.external.msSiteModeClearIconOverlay():angular.forEach(D,function(e){try{e.close&&e.close()}catch(t){}}),D={},N=0}function C(){if(V)return!1;if(navigator.push&&Config.Navigator.ffos&&Config.Modes.packed){var e=navigator.push.register();e.onsuccess=function(){clearTimeout(G),console.log(dT(),"Push registered",e.result),V=e.result,o.invokeApi("account.registerDevice",{token_type:4,token:V,device_model:navigator.userAgent||"Unknown UserAgent",system_version:navigator.platform||"Unknown Platform",app_version:Config.App.version,app_sandbox:!1,lang_code:navigator.language||"en"})},e.onerror=function(e){console.error("Push register error",e,e.toString()),G=setTimeout(C,W),W=Math.min(3e4,1.5*W)}}}function M(){return O}navigator.vibrate=navigator.vibrate||navigator.mozVibrate||navigator.webkitVibrate;var A=!1;try{window.external&&window.external.msIsSiteMode()&&(A=!0)}catch(x){}var E,T,I=A||"Notification"in window||"mozNotification"in navigator,D={},P=0,N=0,U={},O=!!navigator.vibrate,L=!1,R=!1,B={},F=$('link[rel="icon"]:first')[0],q=a.pluralize("page_title_pluralize_notifications"),j=document.title,H=!1,z={};e.$watch("idle.isIDLE",function(e){e||S(),Config.Navigator.mobile||(n.cancel(E),e?(j=document.title,E=n(function(){var e=tsNow();!N||e%2e3>1e3?H&&(H=!1,document.title=j,m()):(H=!0,document.title=q(N),m("favicon_unread.ico"))},1e3)):(H=!1,document.title=j,m()))}),e.$on("apiUpdate",function(e,t){switch(t._){case"updateNotifySettings":if("notifyPeer"==t.peer._){var n=s.getPeerID(t.peer.peer);h(n,t.notify_settings)}}});var V=!1;return window.navigator.mozSetMessageHandler&&(window.navigator.mozSetMessageHandler("push",function(t){console.log(dT(),"received push",t),e.$broadcast("push_received")}),window.navigator.mozSetMessageHandler("push-register",function(e){console.log(dT(),"received push",e),V=!1,C()})),{start:_,notify:y,cancel:w,clear:S,soundReset:k,getPeerSettings:p,getPeerMuted:f,savePeerSettings:h,updatePeerSettings:g,updateNotifySettings:d,getNotifySettings:u,getVibrateSupport:M,testSound:b};var W,G}]).service("PasswordManager",["$timeout","$q","$rootScope","MtpApiManager","CryptoWorker","MtpSecureRandom",function(e,t,n,i,a,o){function s(e){return i.invokeApi("account.getPassword",{},e).then(function(e){return e})}function r(e,n){var a,s,r={new_settings:{_:"account.passwordInputSettings",flags:0,hint:n.hint||""}};if(a="string"==typeof n.cur_password&&n.cur_password.length>0?u(e.current_salt,n.cur_password):t.when([]),"string"==typeof n.new_password&&n.new_password.length>0){var l=new Array(8),c=bufferConcat(e.new_salt,l);o.nextBytes(l),s=u(c,n.new_password),r.new_settings.new_salt=c,r.new_settings.flags|=1}else"string"==typeof n.new_password&&(r.new_settings.flags|=1,r.new_settings.new_salt=[]),s=t.when([]);return"string"==typeof n.email&&(r.new_settings.flags|=2,r.new_settings.email=n.email||""),t.all([a,s]).then(function(e){return r.current_password_hash=e[0],r.new_settings.new_password_hash=e[1],i.invokeApi("account.updatePasswordSettings",r)})}function l(e,t,n){return u(e.current_salt,t).then(function(e){return i.invokeApi("auth.checkPassword",{password_hash:e},n)})}function c(e,t){return i.invokeApi("auth.requestPasswordRecovery",{},t)}function d(e,t){return i.invokeApi("auth.recoverPassword",{code:e},t)}function u(e,t){for(var n=unescape(encodeURIComponent(t)),i=new ArrayBuffer(n.length),o=new Uint8Array(i),s=0,r=n.length;r>s;s++)o[s]=n.charCodeAt(s);return i=bufferConcat(bufferConcat(e,o),e),a.sha256Hash(i)}return{check:l,getState:s,requestRecovery:c,recover:d,updateSettings:r}}]).service("ErrorService",["$rootScope","$modal","$window",function(e,t,n){function i(n,i){if(s>=1)return console.log("Skip error box, too many open",s,n,i),!1;i=i||{};var a=e.$new();angular.extend(a,n),s++;var o=t.open({templateUrl:templateUrl("error_modal"),scope:a,windowClass:i.windowClass||"error_modal_window"});return o.result["finally"](function(){s--}),o}function a(e,t){return i({title:e,description:t})}function o(n,i){i=i||{};var a=e.$new();angular.extend(a,n);var o=t.open({templateUrl:templateUrl("confirm_modal"),scope:a,windowClass:i.windowClass||"confirm_modal_window"});return o.result}var s=0;return n.safeConfirm=function(e,t){"string"==typeof e&&(e={message:e}),o(e).then(function(e){t(e||!0)},function(){t(!1)})},{show:i,alert:a,confirm:o}}]).service("PeersSelectService",["$rootScope","$modal",function(e,t){function n(n){var i=e.$new();return i.multiSelect=!1,n&&angular.extend(i,n),t.open({templateUrl:templateUrl("peer_select"),controller:"PeerSelectController",scope:i,windowClass:"peer_select_window mobile_modal"}).result}function i(i){if(Config.Mobile)return n(i).then(function(e){return[e]});var a=e.$new();return a.multiSelect=!0,i&&angular.extend(a,i),t.open({templateUrl:templateUrl("peer_select"),controller:"PeerSelectController",scope:a,windowClass:"peer_select_window mobile_modal"}).result}return{selectPeer:n,selectPeers:i}}]).service("ContactsSelectService",["$rootScope","$modal",function(e,t){function n(n,i){i=i||{};var a=e.$new();return a.multiSelect=n,angular.extend(a,i),!a.action&&n&&(a.action="select"),t.open({templateUrl:templateUrl("contacts_modal"),controller:"ContactsModalController",scope:a,windowClass:"contacts_modal_window mobile_modal"}).result}return{selectContacts:function(e){return n(!0,e)},selectContact:function(e){return n(!1,e)}}}]).service("ChangelogNotifyService",["Storage","$rootScope","$modal",function(e,t,n){function i(){e.get("last_version").then(function(t){t!=Config.App.version&&(t&&a(t),e.set({last_version:Config.App.version}))})}function a(e){var i=t.$new();i.lastVersion=e,n.open({controller:"ChangelogModalController",templateUrl:templateUrl("changelog_modal"),scope:i,windowClass:"changelog_modal_window mobile_modal"})}return{checkUpdate:i,showChangelog:a}}]).service("HttpsMigrateService",["ErrorService","Storage",function(e,t){function n(){t.get("https_dismiss").then(function(n){(!n||tsNow()>n+432e5)&&e.confirm({type:"MIGRATE_TO_HTTPS"}).then(function(){var e;try{e=window.open("https://web.telegram.org","_blank")}catch(t){}e||(location="https://web.telegram.org")},function(){t.set({https_dismiss:tsNow()})})})}function i(){a||"http:"!=location.protocol||Config.Modes.http||-1==Config.App.domains.indexOf(location.hostname)||(a=!0,setTimeout(n,12e4))}var a=!1;return{start:i,check:n}}]).service("LayoutSwitchService",["ErrorService","Storage","AppRuntimeManager","$window",function(e,t,n,i){function a(e){ConfigStorage.noPrefix(),t.set({layout_selected:e?"mobile":"desktop",layout_width:$(window).width()}).then(function(){n.reload()})}function o(n){if(!l){var i=$(window).width(),o=600>i;!i||!n&&(Config.Navigator.mobile?800>=i:o)||o!=Config.Mobile&&(ConfigStorage.noPrefix(),t.get("layout_width").then(function(n){return i==n?!1:(l=!0,void e.confirm({type:o?"SWITCH_MOBILE_VERSION":"SWITCH_DESKTOP_VERSION"}).then(function(){a(o)},function(){ConfigStorage.noPrefix(),t.set({layout_width:i}),l=!1}))}))}}function s(){r||Config.Navigator.mobile||(r=!0,o(),$(i).on("resize",o))}var r=!1,l=!1;return{start:s,switchLayout:a}}]).service("TelegramMeWebService",["Storage",function(e){function t(t){return n?!1:void e.get("tgme_sync").then(function(n){var i=tsNow(!0);if(t&&n&&n.canRedirect==t&&n.ts+86400>i)return!1;e.set({tgme_sync:{canRedirect:t,ts:i}});var a=$("