v1.3.1.443

This commit is contained in:
RainLoop Team 2013-10-16 22:52:37 +04:00
parent f32876928e
commit 91a9f85659
400 changed files with 636 additions and 612 deletions

View file

@ -1 +1 @@
1.3.0.442
1.3.1.443

View file

@ -1 +0,0 @@
2a1a1807cd7966d3a257c08a3c750e49d2975e43

View file

@ -1 +0,0 @@
1.3.0.442

View file

@ -1,143 +0,0 @@
(function(h,j,d,ma,y,i){function o(){this.sBase="#/";this.sCdnStaticDomain=e.settingsGet("CdnStaticDomain");this.sVersion=e.settingsGet("Version");this.sSpecSuffix=e.settingsGet("AuthAccountHash")||"0";this.sServer="./?";this.sCdnStaticDomain=""===this.sCdnStaticDomain?this.sCdnStaticDomain:"/"===this.sCdnStaticDomain.substr(-1)?this.sCdnStaticDomain:this.sCdnStaticDomain+"/"}function L(){}function M(){}function N(){var a=i.find([M,L],function(a){return a.supported()});a&&(this.oDriver=new a)}function na(){}
function t(a,b){this.sPosition=c.pString(a);this.sTemplate=c.pString(b);this.viewModelName="";this.viewModelVisibility=d.observable(!1);"Popups"===this.sPosition&&(this.modalVisibility=d.observable(!1));this.viewModelDom=null}function w(a,b){this.sScreenName=a;this.aViewModels=c.isArray(b)?b:[]}function m(){this.sDefaultScreenName="";this.oScreens={};this.oCurrentScreen=this.oBoot=null;this.popupVisibility=d.observable(!1);this.popupVisibility.subscribe(function(a){e&&e.popupVisibility(a)})}function r(a,
b){this.email=a||"";this.name=b||"";this.privateType=null;this.clearDuplicateName()}function B(){t.call(this,"Popups","PopupsDomain");this.edit=d.observable(!1);this.saving=d.observable(!1);this.savingError=d.observable("");this.testing=d.observable(!1);this.testingDone=d.observable(!1);this.testingImapError=d.observable(!1);this.testingSmtpError=d.observable(!1);this.imapServerFocus=d.observable(!1);this.smtpServerFocus=d.observable(!1);this.name=d.observable("");this.imapServer=d.observable("");
this.imapPort=d.observable(l.Values.ImapDefaulPort);this.imapSecure=d.observable(f.ServerSecure.None);this.smtpServer=d.observable("");this.smtpPort=d.observable(l.Values.SmtpDefaulPort);this.smtpSecure=d.observable(f.ServerSecure.None);this.smtpAuth=d.observable(!0);this.imapServerFocus.subscribe(function(a){a&&(""!==this.name()&&""===this.imapServer())&&this.imapServer(this.name())},this);this.smtpServerFocus.subscribe(function(a){a&&(""!==this.imapServer()&&""===this.smtpServer())&&this.smtpServer(this.imapServer())},
this);this.headerText=d.computed(function(){var a=this.name();return this.edit()?'Edit Domain "'+a+'"':"Add Domain"+(""===a?"":' "'+a+'"')},this);this.domainIsComputed=d.computed(function(){return""!==this.name()&&""!==this.imapServer()&&""!==this.imapPort()&&""!==this.smtpServer()&&""!==this.smtpPort()},this);this.canBeTested=d.computed(function(){return!this.testing()&&this.domainIsComputed()},this);this.canBeSaved=d.computed(function(){return!this.saving()&&this.domainIsComputed()},this);this.createOrAddCommand=
c.createCommand(this,function(){this.saving(!0);e.remote().createOrUpdateDomain(i.bind(this.onDomainCreateOrSaveResponse,this),!this.edit(),this.name(),this.imapServer(),this.imapPort(),this.imapSecure(),this.smtpServer(),this.smtpPort(),this.smtpSecure(),this.smtpAuth())},this.canBeSaved);this.testConnectionCommand=c.createCommand(this,function(){this.testingDone(!1);this.testingImapError(!1);this.testingSmtpError(!1);this.testing(!0);e.remote().testConnectionForDomain(i.bind(this.onTestConnectionResponse,
this),this.imapServer(),this.imapPort(),this.imapSecure(),this.smtpServer(),this.smtpPort(),this.smtpSecure(),this.smtpAuth())},this.canBeTested)}function O(){t.call(this,"Popups","PopupsPlugin");this.onPluginSettingsUpdateResponse=i.bind(this.onPluginSettingsUpdateResponse,this);this.saveError=d.observable("");this.name=d.observable("");this.readme=d.observable("");this.configures=d.observableArray([]);this.hasReadme=d.computed(function(){return""!==this.readme()},this);this.hasConfiguration=d.computed(function(){return 0<
this.configures().length},this);this.saveCommand=c.createCommand(this,function(){var a={};a.Name=this.name();i.each(this.configures(),function(b){var g=b.value();if(!1===g||!0===g)g=g?"1":"0";a["_"+b.Name]=g},this);this.saveError("");e.remote().pluginSettingsUpdate(this.onPluginSettingsUpdateResponse,a)},this.hasConfiguration)}function P(){t.call(this,"Popups","PopupsActivate");this.domain=d.observable("");this.key=d.observable("");this.key.focus=d.observable(!1);this.activationSuccessed=d.observable(!1);
this.licenseTrigger=e.data().licenseTrigger;this.activateProcess=d.observable(!1);this.activateText=d.observable("");this.activateText.isError=d.observable(!1);this.key.subscribe(function(){this.activateText("");this.activateText.isError(!1)},this);this.activationSuccessed.subscribe(function(a){a&&this.licenseTrigger(!this.licenseTrigger())},this)}function Q(){t.call(this,"Right","AdminLogin");this.login=d.observable("");this.password=d.observable("");this.loginError=d.observable(!1);this.passwordError=
d.observable(!1);this.loginFocus=d.observable(!1);this.login.subscribe(function(){this.loginError(!1)},this);this.password.subscribe(function(){this.passwordError(!1)},this);this.submitRequest=d.observable(!1);this.submitError=d.observable("");this.submitCommand=c.createCommand(this,function(){this.loginError(""===c.trim(this.login()));this.passwordError(""===c.trim(this.password()));if(this.loginError()||this.passwordError())return!1;this.submitRequest(!0);e.remote().adminLogin(i.bind(function(a,
b){f.StorageResultType.Success===a&&b&&"AdminLogin"===b.Action?b.Result?e.loginAndLogoutReload():b.ErrorCode&&(this.submitRequest(!1),this.submitError(c.getNotification(b.ErrorCode))):(this.submitRequest(!1),this.submitError(c.getNotification(f.Notification.UnknownError)))},this),this.login(),this.password());return!0},function(){return!this.submitRequest()})}function Y(a){t.call(this,"Left","AdminMenu");this.menu=a.menu}function Z(){t.call(this,"Right","AdminPane");this.adminDomain=d.observable(e.settingsGet("AdminDomain"))}
function oa(){var a=e.data();this.mainLanguage=a.mainLanguage;this.mainTheme=a.mainTheme;this.language=a.language;this.theme=a.theme;this.allowCustomTheme=a.allowCustomTheme;this.allowAdditionalAccounts=a.allowAdditionalAccounts;this.title=d.observable(e.settingsGet("Title"));this.version=e.settingsGet("Version");this.themesOptions=d.computed(function(){return i.map(a.themes(),function(a){return{optValue:a,optText:c.convertThemeName(a)}})});this.languagesOptions=d.computed(function(){return i.map(a.languages(),
function(a){return{optValue:a,optText:c.convertLangName(a)}})});this.contactsSupported=e.settingsGet("ContactsIsSupported");this.titleTrigger=d.observable(f.SaveSettingsStep.Idle);this.languageTrigger=d.observable(f.SaveSettingsStep.Idle);this.themeTrigger=d.observable(f.SaveSettingsStep.Idle)}function z(){var a=e.data();this.domains=a.domains;this.domainsLoading=a.domainsLoading;this.iDomainForDeletionTimeout=0;this.visibility=d.computed(function(){return a.domainsLoading()?"visible":"hidden"},this);
this.domainForDeletion=d.observable(null).extend({toggleSubscribe:[this,function(a){a&&a.deleteAccess(!1)},function(a){a&&(a.deleteAccess(!0),this.startDomainForDeletionTimeout())}]})}function J(){this.licensing=e.data().licensing;this.licensingProcess=e.data().licensingProcess;this.licenseValid=e.data().licenseValid;this.licenseExpired=e.data().licenseExpired;this.licenseError=e.data().licenseError;this.licenseTrigger=e.data().licenseTrigger;this.adminDomain=d.observable("");this.subscriptionEnabled=
d.observable(!!e.settingsGet("SubscriptionEnabled"));this.licenseTrigger.subscribe(function(){this.subscriptionEnabled()&&e.reloadLicensing(!0)},this)}function K(){this.csrfProtection=d.observable(!!e.settingsGet("UseTokenProtection"));this.usageStatistics=d.observable(!!e.settingsGet("UsageStatistics"));this.adminLogin=d.observable(e.settingsGet("AdminLogin"));this.adminPassword=d.observable("");this.adminPasswordNew=d.observable("");this.adminPasswordUpdateError=d.observable(!1);this.adminPasswordUpdateSuccess=
d.observable(!1);this.adminPassword.subscribe(function(){this.adminPasswordUpdateError(!1);this.adminPasswordUpdateSuccess(!1)},this);this.adminPasswordNew.subscribe(function(){this.adminPasswordUpdateError(!1);this.adminPasswordUpdateSuccess(!1)},this);this.onNewAdminPasswordResponse=i.bind(this.onNewAdminPasswordResponse,this);this.saveNewAdminPasswordCommand=c.createCommand(this,function(){this.adminPasswordUpdateError(!1);this.adminPasswordUpdateSuccess(!1);e.remote().saveNewAdminPassword(this.onNewAdminPasswordResponse,
{Password:this.adminPassword(),NewPassword:this.adminPasswordNew()})},function(){return""!==this.adminPassword()&&""!==this.adminPasswordNew()})}function pa(){var a=e.data();this.googleEnable=a.googleEnable;this.googleClientID=a.googleClientID;this.googleClientSecret=a.googleClientSecret;this.googleTrigger1=d.observable(f.SaveSettingsStep.Idle);this.googleTrigger2=d.observable(f.SaveSettingsStep.Idle);this.facebookEnable=a.facebookEnable;this.facebookAppID=a.facebookAppID;this.facebookAppSecret=a.facebookAppSecret;
this.facebookTrigger1=d.observable(f.SaveSettingsStep.Idle);this.facebookTrigger2=d.observable(f.SaveSettingsStep.Idle);this.twitterEnable=a.twitterEnable;this.twitterConsumerKey=a.twitterConsumerKey;this.twitterConsumerSecret=a.twitterConsumerSecret;this.twitterTrigger1=d.observable(f.SaveSettingsStep.Idle);this.twitterTrigger2=d.observable(f.SaveSettingsStep.Idle);this.dropboxEnable=a.dropboxEnable;this.dropboxApiKey=a.dropboxApiKey;this.dropboxTrigger1=d.observable(f.SaveSettingsStep.Idle)}function C(){var a=
e.data();this.enabledPlugins=d.observable(!!e.settingsGet("EnabledPlugins"));this.pluginsError=d.observable("");this.plugins=a.plugins;this.pluginsLoading=a.pluginsLoading;this.visibility=d.computed(function(){return a.pluginsLoading()?"visible":"hidden"},this);this.onPluginLoadRequest=i.bind(this.onPluginLoadRequest,this);this.onPluginDisableRequest=i.bind(this.onPluginDisableRequest,this)}function G(){var a=e.data();this.packagesError=d.observable("");this.packages=a.packages;this.packagesLoading=
a.packagesLoading;this.packagesReal=a.packagesReal;this.packagesMainUpdatable=a.packagesMainUpdatable;this.packagesCurrent=d.computed(function(){return i.filter(this.packages(),function(a){return a&&""!==a.installed&&!a.compare})},this);this.packagesAvailableForUpdate=d.computed(function(){return i.filter(this.packages(),function(a){return a&&""!==a.installed&&!!a.compare})},this);this.packagesAvailableForInstallation=d.computed(function(){return i.filter(this.packages(),function(a){return a&&""===
a.installed})},this);this.visibility=d.computed(function(){return a.packagesLoading()?"visible":"hidden"},this)}function aa(){c.initDataConstructorBySettings(this)}function ba(){c.initDataConstructorBySettings(this);this.domainsLoading=d.observable(!1).extend({throttle:100});this.domains=d.observableArray([]);this.pluginsLoading=d.observable(!1).extend({throttle:100});this.plugins=d.observableArray([]);this.packagesReal=d.observable(!0);this.packagesMainUpdatable=d.observable(!0);this.packagesLoading=
d.observable(!1).extend({throttle:100});this.packages=d.observableArray([]);this.licensing=d.observable(!1);this.licensingProcess=d.observable(!1);this.licenseValid=d.observable(!1);this.licenseExpired=d.observable(0);this.licenseError=d.observable("");this.licenseTrigger=d.observable(!1)}function D(){this.oRequests={}}function p(){this.oRequests={};this.oRequests={}}function A(){this.oEmailsPicsHashes={};this.oServices={}}function qa(){A.call(this)}function H(a){w.call(this,"settings",a);this.menu=
d.observableArray([]);this.oCurrentSubScreen=null}function ca(){w.call(this,"login",[Q])}function da(){H.call(this,[Y,Z])}function u(){this.oLocal=this.oLink=this.oPlugins=this.oSettings=null;this.isLocalAutocomplete=!0;this.popupVisibility=d.observable(!1);this.iframe=j('<iframe style="display:none" src="javascript:;" />').appendTo("body");E.on("error",function(a){e&&(a&&a.originalEvent&&a.originalEvent.message&&-1===c.inArray(a.originalEvent.message,["Uncaught Error: Error calling method on NPObject."]))&&
(c.log(""+a.originalEvent.message+" ("+a.originalEvent.filename+":"+a.originalEvent.lineno+")"),e.remote().jsError(c.emptyFunction,a.originalEvent.message,a.originalEvent.filename,a.originalEvent.lineno,location&&location.hash?location.hash:"",R.attr("class")))})}function v(){u.call(this);this.oCache=this.oRemote=this.oData=null}var l={},f={},k={},c={},n={},S,ea,F,fa,I,ga=d.observable(!0),T=d.observable(!0),s=null,U=h.rainloopAppData||{},ha=h.rainloopI18N||{},R=j("html"),E=j(h),ra=j(h.document),V=
[],ia=[],ja=[],W=h.Notification&&h.Notification.requestPermission?h.Notification:null,e=null;S=0;ea=!1;F=(navigator.userAgent||"").toLowerCase();fa=-1<F.indexOf("iphone")||-1<F.indexOf("ipod")||-1<F.indexOf("ipad");F=-1<F.indexOf("android");I=fa||F;l.Defaults={};l.Values={};l.DataImages={};l.Defaults.MessagesPerPage=25;l.Defaults.DefaultAjaxTimeout=2E4;l.Defaults.SearchAjaxTimeout=12E4;l.Defaults.SendMessageAjaxTimeout=2E5;l.Defaults.SaveMessageAjaxTimeout=2E5;l.Values.UnuseOptionValue="__UNUSE__";
l.Values.GmailFolderName="[Gmail]";l.Values.ClientSideCookieIndexName="rlcsc";l.Values.ImapDefaulPort=143;l.Values.ImapDefaulSecurePort=993;l.Values.SmtpDefaulPort=25;l.Values.SmtpDefaulSecurePort=465;l.DataImages.UserDotPic="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2P8DwQACgAD/il4QJ8AAAAASUVORK5CYII=";l.DataImages.TranspPic="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2NkAAIAAAoAAggA9GkAAAAASUVORK5CYII=";f.StorageResultType=
{Success:"success",Abort:"abort",Error:"error",Unload:"unload"};f.State={Empty:10,Login:20,Auth:30};f.StateType={Webmail:0,Admin:1};f.FolderType={Inbox:10,SentItems:11,Draft:12,Trash:13,Spam:14,User:99};f.LoginSignMeTypeAsString={DefaultOff:"defaultoff",DefaultOn:"defaulton",Unused:"unused"};f.LoginSignMeType={DefaultOff:0,DefaultOn:1,Unused:2};f.ComposeType={Empty:"empty",Reply:"reply",ReplyAll:"replyall",Forward:"forward",ForwardAsAttachment:"forward-as-attachment",Draft:"draft"};f.UploadErrorCode=
{Normal:0,FileIsTooBig:1,FilePartiallyUploaded:2,FileNoUploaded:3,MissingTempFolder:4,FileOnSaveingError:5,FileType:98,Unknown:99};f.SetSystemFoldersNotification={None:0,Sent:1,Draft:2,Spam:3,Trash:4};f.ClientSideKeyName={FoldersLashHash:0,MessagesInboxLastHash:1,MailBoxListSize:2,ExpandedFolders:3};f.EventKeyCode={Backspace:8,Enter:13,Esc:27,PageUp:33,PageDown:34,Left:37,Right:39,Up:38,Down:40,End:35,Home:36,Insert:45,Delete:46,A:65,S:83};f.MessageSetAction={SetSeen:0,UnsetSeen:1,SetFlag:2,UnsetFlag:3};
f.MessageSelectAction={All:0,None:1,Invert:2,Unseen:3,Seen:4,Flagged:5,Unflagged:6};f.DesctopNotifications={Allowed:0,NotAllowed:1,Denied:2,NotSupported:9};f.MessagePriority={Low:5,Normal:3,High:1};f.EditorDefaultType={Html:"Html",Plain:"Plain"};f.CustomThemeType={Light:"Light",Dark:"Dark"};f.ServerSecure={None:0,SSL:1,TLS:2};f.SearchDateType={All:-1,Days3:3,Days7:7,Month:30};f.EmailType={Defailt:0,Facebook:1,Google:2};f.SaveSettingsStep={Animate:-2,Idle:-1,TrueResult:1,FalseResult:0};f.Notification=
{InvalidToken:101,AuthError:102,AccessError:103,ConnectionError:104,CaptchaError:105,SocialFacebookLoginAccessDisable:106,SocialTwitterLoginAccessDisable:107,SocialGoogleLoginAccessDisable:108,DomainNotAllowed:109,CantGetMessageList:201,CantGetMessage:202,CantDeleteMessage:203,CantMoveMessage:204,CantSaveMessage:301,CantSendMessage:302,InvalidRecipients:303,CantCreateFolder:400,CantRenameFolder:401,CantDeleteFolder:402,CantSubscribeFolder:403,CantUnsubscribeFolder:404,CantDeleteNonEmptyFolder:405,
CantSaveSettings:501,CantSavePluginSettings:502,DomainAlreadyExists:601,CantInstallPackage:701,CantDeletePackage:702,InvalidPluginPackage:703,UnsupportedPluginPackage:704,LicensingServerIsUnavailable:710,LicensingExpired:711,LicensingBanned:712,DemoSendMessageError:750,AccountAlreadyExists:801,MailServerError:901,UnknownError:999};c.trim=j.trim;c.inArray=j.inArray;c.isArray=i.isArray;c.isFunc=i.isFunction;c.isUnd=i.isUndefined;c.isNull=i.isNull;c.emptyFunction=function(){};c.isNormal=function(a){return!c.isUnd(a)&&
!c.isNull(a)};c.windowResize=i.debounce(function(a){c.isUnd(a)?E.resize():h.setTimeout(function(){E.resize()},a)},50);c.isPosNumeric=function(a,b){return c.isNormal(a)?c.isUnd(b)||b?/^[0-9]*$/.test(a.toString()):/^[1-9]+[0-9]*$/.test(a.toString()):!1};c.pInt=function(a){return c.isNormal(a)&&""!==a?h.parseInt(a,10):0};c.pString=function(a){return c.isNormal(a)?a+"":""};c.isNonEmptyArray=function(a){return c.isArray(a)&&0<a.length};c.exportPath=function(a,b,g){for(var q=null,a=a.split("."),g=g||h;a.length&&
(q=a.shift());)!a.length&&!c.isUnd(b)?g[q]=b:g=g[q]?g[q]:g[q]={}};c.pImport=function(a,b,g){a[b]=g};c.pExport=function(a,b,g){return c.isUnd(a[b])?g:a[b]};c.encodeHtml=function(a){return c.isNormal(a)?a.toString().replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;"):""};c.splitPlainText=function(a,b){for(var g="",q="",d=a,e=0,f=0,b=c.isUnd(b)?100:b;d.length>b;)q=d.substring(0,b),e=q.lastIndexOf(" "),f=q.lastIndexOf("\n"),-1!==f&&(e=f),-1===
e&&(e=b),g+=q.substring(0,e)+"\n",d=d.substring(e+1);return g+d};var X={};c.timeOutAction=function(a,b,g){c.isUnd(X[a])&&(X[a]=0);h.clearTimeout(X[a]);X[a]=h.setTimeout(b,g)};var la={};c.timeOutActionSecond=function(a,b,g){la[a]||(la[a]=h.setTimeout(function(){b();la[a]=0},g))};var x=!1;c.audio=function(a,b){if(!1===x)if(fa)x=null;else{var g=!1,c=!1,d=h.Audio?new h.Audio:null;d&&d.canPlayType&&d.play?((g=""!==d.canPlayType('audio/mpeg; codecs="mp3"'))||(c=""!==d.canPlayType('audio/ogg; codecs="vorbis"')),
g||c?(x=d,x.preload="none",x.loop=!1,x.autoplay=!1,x.muted=!1,x.src=g?a:b):x=null):x=null}return x};c.hos=function(a,b){return a&&Object.hasOwnProperty?Object.hasOwnProperty.call(a,b):!1};c.i18n=function(a,b,g){var d="",a=c.isUnd(ha[a])?c.isUnd(g)?a:g:ha[a];if(!c.isUnd(b)&&!c.isNull(b))for(d in b)c.hos(b,d)&&(a=a.replace("%"+d+"%",b[d]));return a};c.i18nToNode=function(a){i.defer(function(){j(".i18n",a).each(function(){var a=j(this),g="";(g=a.data("i18n-text"))?a.text(c.i18n(g)):((g=a.data("i18n-html"))&&
a.html(c.i18n(g)),(g=a.data("i18n-placeholder"))&&a.attr("placeholder",c.i18n(g)))})})};c.i18nToDoc=function(){h.rainloopI18N&&(ha=h.rainloopI18N||{},c.i18nToNode(ra),T(!T()));h.rainloopI18N={}};c.initOnStartOrLangChange=function(a,b,g){a&&a.call(b);g?T.subscribe(function(){a&&a.call(b);g.call(b)}):a&&T.subscribe(a,b)};c.inFocus=function(){var a=document.activeElement;return a&&("INPUT"===a.tagName||"TEXTAREA"===a.tagName||"IFRAME"===a.tagName||"DIV"===a.tagName&&"editorHtmlArea"===a.className&&a.contentEditable)};
c.removeInFocus=function(){if(document&&document.activeElement&&document.activeElement.blur){var a=j(document.activeElement);(a.is("input")||a.is("textarea"))&&document.activeElement.blur()}};c.removeSelection=function(){if(h&&h.getSelection){var a=h.getSelection();a&&a.removeAllRanges&&a.removeAllRanges()}else document&&(document.selection&&document.selection.empty)&&document.selection.empty()};c.replySubjectAdd=function(a,b){var g=null,d=c.trim(b);null!==(g=(new h.RegExp("^"+a+"[\\s]?\\:(.*)$",
"gi")).exec(b))&&!c.isUnd(g[1])?d=a+"[2]: "+g[1]:null!==(g=(new h.RegExp("^("+a+"[\\s]?[\\[\\(]?)([\\d]+)([\\]\\)]?[\\s]?\\:.*)$","gi")).exec(b))&&!c.isUnd(g[1])&&!c.isUnd(g[2])&&!c.isUnd(g[3])?(c.pInt(g[2]),d=g[1]+(c.pInt(g[2])+1)+g[3]):d=a+": "+b;return d};c.roundNumber=function(a,b){return Math.round(a*Math.pow(10,b))/Math.pow(10,b)};c.friendlySize=function(a){a=c.pInt(a);return 1073741824<=a?c.roundNumber(a/1073741824,1)+"GB":1048576<=a?c.roundNumber(a/1048576,1)+"MB":1024<=a?c.roundNumber(a/
1024,0)+"KB":a+"B"};c.log=function(a){h.console&&h.console.log&&h.console.log(a)};c.getNotification=function(a){a=c.pInt(a);return c.isUnd(k[a])?"":k[a]};c.initNotificationLanguage=function(){k[f.Notification.InvalidToken]=c.i18n("NOTIFICATIONS/INVALID_TOKEN");k[f.Notification.AuthError]=c.i18n("NOTIFICATIONS/AUTH_ERROR");k[f.Notification.AccessError]=c.i18n("NOTIFICATIONS/ACCESS_ERROR");k[f.Notification.ConnectionError]=c.i18n("NOTIFICATIONS/CONNECTION_ERROR");k[f.Notification.CaptchaError]=c.i18n("NOTIFICATIONS/CAPTCHA_ERROR");
k[f.Notification.SocialFacebookLoginAccessDisable]=c.i18n("NOTIFICATIONS/SOCIAL_FACEBOOK_LOGIN_ACCESS_DISABLE");k[f.Notification.SocialTwitterLoginAccessDisable]=c.i18n("NOTIFICATIONS/SOCIAL_TWITTER_LOGIN_ACCESS_DISABLE");k[f.Notification.SocialGoogleLoginAccessDisable]=c.i18n("NOTIFICATIONS/SOCIAL_GOOGLE_LOGIN_ACCESS_DISABLE");k[f.Notification.DomainNotAllowed]=c.i18n("NOTIFICATIONS/DOMAIN_NOT_ALLOWED");k[f.Notification.CantGetMessageList]=c.i18n("NOTIFICATIONS/CANT_GET_MESSAGE_LIST");k[f.Notification.CantGetMessage]=
c.i18n("NOTIFICATIONS/CANT_GET_MESSAGE");k[f.Notification.CantDeleteMessage]=c.i18n("NOTIFICATIONS/CANT_DELETE_MESSAGE");k[f.Notification.CantMoveMessage]=c.i18n("NOTIFICATIONS/CANT_MOVE_MESSAGE");k[f.Notification.CantSaveMessage]=c.i18n("NOTIFICATIONS/CANT_SAVE_MESSAGE");k[f.Notification.CantSendMessage]=c.i18n("NOTIFICATIONS/CANT_SEND_MESSAGE");k[f.Notification.InvalidRecipients]=c.i18n("NOTIFICATIONS/INVALID_RECIPIENTS");k[f.Notification.CantCreateFolder]=c.i18n("NOTIFICATIONS/CANT_CREATE_FOLDER");
k[f.Notification.CantRenameFolder]=c.i18n("NOTIFICATIONS/CANT_RENAME_FOLDER");k[f.Notification.CantDeleteFolder]=c.i18n("NOTIFICATIONS/CANT_DELETE_FOLDER");k[f.Notification.CantDeleteNonEmptyFolder]=c.i18n("NOTIFICATIONS/CANT_DELETE_NON_EMPTY_FOLDER");k[f.Notification.CantSubscribeFolder]=c.i18n("NOTIFICATIONS/CANT_SUBSCRIBE_FOLDER");k[f.Notification.CantUnsubscribeFolder]=c.i18n("NOTIFICATIONS/CANT_UNSUBSCRIBE_FOLDER");k[f.Notification.CantSaveSettings]=c.i18n("NOTIFICATIONS/CANT_SAVE_SETTINGS");
k[f.Notification.CantSavePluginSettings]=c.i18n("NOTIFICATIONS/CANT_SAVE_PLUGIN_SETTINGS");k[f.Notification.DomainAlreadyExists]=c.i18n("NOTIFICATIONS/DOMAIN_ALREADY_EXISTS");k[f.Notification.CantInstallPackage]=c.i18n("NOTIFICATIONS/CANT_INSTALL_PACKAGE");k[f.Notification.CantDeletePackage]=c.i18n("NOTIFICATIONS/CANT_DELETE_PACKAGE");k[f.Notification.InvalidPluginPackage]=c.i18n("NOTIFICATIONS/INVALID_PLUGIN_PACKAGE");k[f.Notification.UnsupportedPluginPackage]=c.i18n("NOTIFICATIONS/UNSUPPORTED_PLUGIN_PACKAGE");
k[f.Notification.LicensingServerIsUnavailable]=c.i18n("NOTIFICATIONS/LICENSING_SERVER_IS_UNAVAILABLE");k[f.Notification.LicensingExpired]=c.i18n("NOTIFICATIONS/LICENSING_EXPIRED");k[f.Notification.LicensingBanned]=c.i18n("NOTIFICATIONS/LICENSING_BANNED");k[f.Notification.DemoSendMessageError]=c.i18n("NOTIFICATIONS/DEMO_SEND_MESSAGE_ERROR");k[f.Notification.AccountAlreadyExists]=c.i18n("NOTIFICATIONS/ACCOUNT_ALREADY_EXISTS");k[f.Notification.MailServerError]=c.i18n("NOTIFICATIONS/MAIL_SERVER_ERROR");
k[f.Notification.UnknownError]=c.i18n("NOTIFICATIONS/UNKNOWN_ERROR")};c.getUploadErrorDescByCode=function(a){var b="";switch(c.pInt(a)){case f.UploadErrorCode.FileIsTooBig:b=c.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG");break;case f.UploadErrorCode.FilePartiallyUploaded:b=c.i18n("UPLOAD/ERROR_FILE_PARTIALLY_UPLOADED");break;case f.UploadErrorCode.FileNoUploaded:b=c.i18n("UPLOAD/ERROR_NO_FILE_UPLOADED");break;case f.UploadErrorCode.MissingTempFolder:b=c.i18n("UPLOAD/ERROR_MISSING_TEMP_FOLDER");break;case f.UploadErrorCode.FileOnSaveingError:b=
c.i18n("UPLOAD/ERROR_ON_SAVING_FILE");break;case f.UploadErrorCode.FileType:b=c.i18n("UPLOAD/ERROR_FILE_TYPE");break;default:b=c.i18n("UPLOAD/ERROR_UNKNOWN")}return b};c.killCtrlAandS=function(a){if(a=a||h.event){var b=a.target||a.srcElement,g=a.keyCode||a.which;if(a.ctrlKey&&g===f.EventKeyCode.S)a.preventDefault();else if((!b||!b.tagName||!b.tagName.match(/INPUT|TEXTAREA/i))&&a.ctrlKey&&g===f.EventKeyCode.A)h.getSelection?h.getSelection().removeAllRanges():h.document.selection&&h.document.selection.clear&&
h.document.selection.clear(),a.preventDefault()}};c.createCommand=function(a,b,g){var q=b?function(){q.canExecute&&q.canExecute()&&b.apply(a,Array.prototype.slice.call(arguments));return!1}:function(){};q.enabled=d.observable(!0);g=c.isUnd(g)?!0:g;q.canExecute=c.isFunc(g)?d.computed(function(){return q.enabled()&&g.call(a)}):d.computed(function(){return q.enabled()&&!!g});return q};c.initDataConstructorBySettings=function(a){a.ignoreFolderSubscribe=d.observable(!1);a.editorDefaultType=d.observable(f.EditorDefaultType.Html);
a.showImages=d.observable(!1);a.showAnimation=d.observable(!1);a.desktopNotifications=d.observable(!1);a.useThreads=d.observable(!0);a.replySameFolder=d.observable(!0);a.usePreviewPane=d.observable(!0);a.useCheckboxesInList=d.observable(!0);a.showAnimation.subscribe(function(a){I?R.removeClass("rl-anim").addClass("no-rl-anim"):R.toggleClass("rl-anim",a).toggleClass("no-rl-anim",!a)});a.showAnimation.valueHasMutated();a.desktopNotificationsPermisions=d.computed(function(){a.desktopNotifications();
var b=f.DesctopNotifications.NotSupported;if(W&&W.permission)switch(W.permission.toLowerCase()){case "granted":b=f.DesctopNotifications.Allowed;break;case "denied":b=f.DesctopNotifications.Denied;break;case "default":b=f.DesctopNotifications.NotAllowed}else h.webkitNotifications&&h.webkitNotifications.checkPermission&&(b=h.webkitNotifications.checkPermission());return b});a.useDesktopNotifications=d.computed({read:function(){return a.desktopNotifications()&&f.DesctopNotifications.Allowed===a.desktopNotificationsPermisions()},
write:function(b){b?(b=a.desktopNotificationsPermisions(),f.DesctopNotifications.Allowed===b?a.desktopNotifications(!0):f.DesctopNotifications.NotAllowed===b?W.requestPermission(function(){a.desktopNotifications.valueHasMutated();h.console.log(a.desktopNotificationsPermisions());f.DesctopNotifications.Allowed===a.desktopNotificationsPermisions()?a.desktopNotifications()?a.desktopNotifications.valueHasMutated():a.desktopNotifications(!0):a.desktopNotifications()?a.desktopNotifications(!1):a.desktopNotifications.valueHasMutated()}):
a.desktopNotifications(!1)):a.desktopNotifications(!1)}});a.language=d.observable("");a.languages=d.observableArray([]);a.mainLanguage=d.computed({read:a.language,write:function(b){b!==a.language()?-1<c.inArray(b,a.languages())?a.language(b):0<a.languages().length&&a.language(a.languages()[0]):a.language.valueHasMutated()}});a.theme=d.observable("");a.themes=d.observableArray([]);a.mainTheme=d.computed({read:a.theme,write:function(b){if(b!==a.theme()){var g=a.themes();-1<c.inArray(b,g)?a.theme(b):
0<g.length&&a.theme(g[0])}else a.theme.valueHasMutated()}});a.allowCustomTheme=d.observable(!0);a.allowAdditionalAccounts=d.observable(!0);a.messagesPerPage=d.observable(l.Defaults.MessagesPerPage);a.mainMessagesPerPage=a.messagesPerPage;a.mainMessagesPerPage=d.computed({read:a.messagesPerPage,write:function(b){-1<c.inArray(c.pInt(b),[10,20,30,50,100,150,200])?b!==a.messagesPerPage()&&a.messagesPerPage(b):a.messagesPerPage.valueHasMutated()}});a.facebookEnable=d.observable(!1);a.facebookAppID=d.observable("");
a.facebookAppSecret=d.observable("");a.twitterEnable=d.observable(!1);a.twitterConsumerKey=d.observable("");a.twitterConsumerSecret=d.observable("");a.googleEnable=d.observable(!1);a.googleClientID=d.observable("");a.googleClientSecret=d.observable("");a.dropboxEnable=d.observable(!1);a.dropboxApiKey=d.observable("");a.contactsIsSupported=d.observable(!1)};c.createMomentDate=function(a){return d.computed(function(){ga();return this.moment().fromNow()},a)};c.createMomentShortDate=function(a){return d.computed(function(){var a=
"",a=moment(),g=this.moment(),d=this.momentDate();return a=4>=a.diff(g,"hours")?d:a.format("L")===g.format("L")?c.i18n("MESSAGE_LIST/TODAY_AT",{TIME:g.format("LT")}):a.clone().subtract("days",1).format("L")===g.format("L")?c.i18n("MESSAGE_LIST/YESTERDAY_IN",{TIME:g.format("LT")}):a.year()===g.year()?g.format("D MMM."):g.format("LL")},a)};c.isFolderExpanded=function(a){var b=e.local().get(f.ClientSideKeyName.ExpandedFolders);return i.isArray(b)&&-1!==i.indexOf(b,a)};c.setExpandedFolder=function(a,
b){var g=e.local().get(f.ClientSideKeyName.ExpandedFolders);i.isArray(g)||(g=[]);b?(g.push(a),g=i.uniq(g)):g=i.without(g,a);e.local().set(f.ClientSideKeyName.ExpandedFolders,g)};c.initLayoutResizer=function(a,b,g,c){var d=j(a),ka=j(b),h=j(g),a=e.local().get(f.ClientSideKeyName.MailBoxListSize),k=function(a,b,g){if(b||g)a=h.width(),b=b?100*(b.size.width/a):null,null===b&&g&&(b=100*(d.width()/a)),null!==b&&(d.css({width:"",height:"",right:""+(100-b)+"%"}),ka.css({width:"",height:"",left:""+b+"%"}))};
a&&d.width(a);d.resizable({minWidth:350,maxWidth:h.width()-250,handles:"e",resize:k,stop:k});k(null,null,!0);E.resize(i.throttle(function(a,b){if(c&&c()){var g=h.width();d.resizable("option","maxWidth",g-250);b&&(b.size&&b.size.width)&&e.local().set(f.ClientSideKeyName.MailBoxListSize,b.size.width);k(null,null,!0)}},400))};c.initBlockquoteSwitcher=function(a){if(a){var b=j("blockquote:not(.rl-bq-switcher)",a).filter(function(){return 0===j(this).parent().closest("blockquote",a).length});b&&0<b.length&&
b.each(function(){var a=j(this),b=a.height();if(0===b||100<b)a.addClass("rl-bq-switcher hidden-bq"),j('<span class="rlBlockquoteSwitcher"><i class="icon-ellipsis" /></span>').insertBefore(a).click(function(){a.toggleClass("hidden-bq");c.windowResize()}).after("<br />").before("<br />")})}};c.removeBlockquoteSwitcher=function(a){a&&(j(a).find("blockquote.rl-bq-switcher").each(function(){j(this).removeClass("rl-bq-switcher hidden-bq")}),j(a).find(".rlBlockquoteSwitcher").each(function(){j(this).remove()}))};
c.extendAsViewModel=function(a,b){b&&(b.__name=a,n.regViewModelHook(a,b),i.extend(b.prototype,t.prototype))};c.addSettingsViewModel=function(a,b,g,c,d){a.__rlSettingsData={Label:g,Template:b,Route:c,IsDefault:!!d};V.push(a)};c.removeSettingsViewModel=function(a){ia.push(a)};c.disableSettingsViewModel=function(a){ja.push(a)};c.convertThemeName=function(a){return c.trim(a.replace(/[^a-zA-Z]/g," ").replace(/([A-Z])/g," $1").replace(/[\s]+/g," "))};c.convertLangName=function(a){return c.i18n("LANGS_NAMES/LANG_"+
a.toUpperCase().replace(/[^a-zA-Z0-9]+/,"_"),null,a)};c.fakeMd5=function(a){for(var b="",a=c.isUnd(a)?32:c.pInt(a);b.length<a;)b+="0123456789abcdefghijklmnopqrstuvwxyz".substr(h.Math.round(36*h.Math.random()),1);return b};c.convertPlainTextToHtml=function(a){return a.toString().replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;").replace(/\r/g,"").replace(/\n/g,"<br />")};c.draggeblePlace=function(){return j('<div class="draggablePlace"><span class="text"></span>&nbsp;<i class="icon-envelope icon-white"></i></div>').appendTo("#rl-hidden")};
c.defautOptionsAfterRender=function(a,b){b&&!c.isUnd(b.disable)&&d.applyBindingsToNode(a,{disable:b.disable},b)};c.windowPopupKnockout=function(a,b,g,d){var e=null,f=h.open(""),i="__OpenerApplyBindingsUid"+c.fakeMd5()+"__",k=j("#"+b);h[i]=function(){if(f&&f.document.body&&k&&k[0]){var b=j(f.document.body);j("#rl-content",b).html(k.html());j("html",f.document).addClass("external "+j("html").attr("class"));c.i18nToNode(b);m.prototype.applyExternal(a,j("#rl-content",b)[0]);h[i]=null;d(f)}};f.document.open();
f.document.write('<html><head><meta charset="utf-8" /><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /><meta name="viewport" content="user-scalable=no" /><meta name="apple-mobile-web-app-capable" content="yes" /><meta name="robots" content="noindex, nofollow, noodp" /><title>'+c.encodeHtml(g)+'</title></head><body><div id="rl-content"></div></body></html>');f.document.close();e=f.document.createElement("script");e.innerHTML="if(window&&window.opener&&window.opener['"+i+"']){window.opener['"+
i+"']();window.opener['"+i+"']=null}";f.document.getElementsByTagName("head")[0].appendChild(e)};c.settingsSaveHelperFunction=function(a,b,g,d){g=g||null;d=c.isUnd(d)?1E3:c.pInt(d);return function(c,e,h,j,ta){b.call(g,e&&e.Result?f.SaveSettingsStep.TrueResult:f.SaveSettingsStep.FalseResult);a&&a.call(g,c,e,h,j,ta);i.delay(function(){b.call(g,f.SaveSettingsStep.Idle)},d)}};c.settingsSaveHelperSimpleFunction=function(a,b){return c.settingsSaveHelperFunction(null,a,b,1E3)};c.resizeAndCrop=function(a,
b,c){var d=new Image;d.onload=function(){var a=[0,0],d=document.createElement("canvas"),e=d.getContext("2d");d.width=b;d.height=b;a=this.width>this.height?[this.width-this.height,0]:[0,this.height-this.width];e.fillStyle="#fff";e.fillRect(0,0,b,b);e.drawImage(this,a[0]/2,a[1]/2,this.width-a[0],this.height-a[1],0,0,b,b);c(d.toDataURL("image/jpeg"))};d.src=a};d.bindingHandlers.tooltip={init:function(a,b){if(!I){var g=j(a).data("tooltip-class")||"";j(a).tooltip({delay:{show:500,hide:100},html:!0,trigger:"hover",
title:function(){return'<span class="tooltip-class '+g+'">'+c.i18n(d.utils.unwrapObservable(b()))+"</span>"}})}}};d.bindingHandlers.tooltip2={init:function(a,b){var c=j(a).data("tooltip-class")||"";j(a).tooltip({delay:{show:500,hide:100},html:!0,title:function(){return'<span class="tooltip-class '+c+'">'+b()()+"</span>"}})}};d.bindingHandlers.popover={init:function(a,b){var g=d.utils.unwrapObservable(b());j(a).popover({trigger:g[2]||"click",placement:g[3]||"right",title:function(){return c.i18n(g[0]||
"")},content:function(){return c.i18n(g[1]||"")}})}};d.bindingHandlers.resizecrop={init:function(a){j(a).addClass("resizecrop").resizecrop({width:"100",height:"100",wrapperCSS:{"border-radius":"10px"}})},update:function(a,b){b()();j(a).resizecrop({width:"100",height:"100"})}};d.bindingHandlers.onEnter={init:function(a,b,c,d){j(a).on("keypress",function(c){c&&13===h.parseInt(c.keyCode,10)&&(j(a).trigger("change"),b().call(d))})}};d.bindingHandlers.onEsc={init:function(a,b,c,d){j(a).on("keypress",function(c){c&&
27===h.parseInt(c.keyCode,10)&&(j(a).trigger("change"),b().call(d))})}};d.bindingHandlers.modal={init:function(a,b){j(a).modal({keyboard:!1,show:d.utils.unwrapObservable(b())}).on("hidden",function(){b()(!1)})},update:function(a,b){var c=d.utils.unwrapObservable(b());j(a).modal(c?"show":"hide");i.delay(function(){j(a).toggleClass("popup-active",c)},1)}};d.bindingHandlers.i18nInit={init:function(a){c.i18nToNode(a)}};d.bindingHandlers.i18nUpdate={update:function(a,b){d.utils.unwrapObservable(b());c.i18nToNode(a)}};
d.bindingHandlers.link={update:function(a,b){j(a).attr("href",d.utils.unwrapObservable(b()))}};d.bindingHandlers.title={update:function(a,b){j(a).attr("title",d.utils.unwrapObservable(b()))}};d.bindingHandlers.textF={init:function(a,b){j(a).text(d.utils.unwrapObservable(b()))}};d.bindingHandlers.initDom={init:function(a,b){b()(a)}};d.bindingHandlers.initResizeTrigger={init:function(a,b){var c=d.utils.unwrapObservable(b());j(a).css({height:c[1],"min-height":c[1]})},update:function(a,b){var g=d.utils.unwrapObservable(b()),
e=c.pInt(g[1]),f=0,f=j(a).offset().top;0<f&&(f+=c.pInt(g[2]),f=E.height()-f,e<f&&(e=f),j(a).css({height:e,"min-height":e}))}};d.bindingHandlers.appendDom={update:function(a,b){j(a).hide().empty().append(d.utils.unwrapObservable(b())).show()}};d.bindingHandlers.draggable={init:function(a,b){j(a).draggable({distance:20,handle:".dragHandle",cursorAt:{top:22,left:3},helper:function(a){return b()(a&&a.target?d.dataFor(a.target):null)}}).on("mousedown",function(){c.removeInFocus()})}};d.bindingHandlers.droppable=
{init:function(a,b){var c=b();!1!==c&&j(a).droppable({tolerance:"pointer",hoverClass:"droppableHover",drop:function(a,b){c(a,b)}})}};d.bindingHandlers.nano={init:function(a){I||j(a).addClass("nano").nanoScroller({iOSNativeScrolling:!1,preventPageScrolling:!0})}};d.bindingHandlers.saveTrigger={init:function(a){j(a).append('&nbsp;&nbsp;<i class="icon-spinner-2 animated"></i><i class="icon-remove error"></i><i class="icon-ok success"></i>').addClass("settings-saved-trigger")},update:function(a,b){var c=
d.utils.unwrapObservable(b()),e=j(a);switch(c.toString()){case "1":e.find(".animated,.error").hide().removeClass("visible").end().find(".success").show().addClass("visible");break;case "0":e.find(".animated,.success").hide().removeClass("visible").end().find(".error").show().addClass("visible");break;case "-2":e.find(".error,.success").hide().removeClass("visible").end().find(".animated").show().addClass("visible");break;default:e.find(".animated").hide().end().find(".error,.success").removeClass("visible")}}};
d.bindingHandlers.select2={init:function(a,b){var g=0,f=null,sa=new h.RegExp(/[a-zA-Z0-9\.\-_]+@[a-zA-Z0-9\.\-_]+/),ka=new h.RegExp(/(.+) [<]?([^\s<@]+@[a-zA-Z0-9\.\-_]+)[>]?/),k=function(){return""},l=function(a){e.getAutocomplete(a.term,a.page,function(b,c){a.callback({more:!!c,results:i.map(b,function(a){var b=a.toLine(!1);return{id:b,text:b,c:a}})})})};j(a).addClass("ko-select2").select2({query:function(a){a&&(0===g?(l(a),g=h.setTimeout(c.emptyFunction,200)):(h.clearInterval(g),g=h.setTimeout(function(){l(a)},
200)))},formatSelection:function(a,b){var c=a&&a.c?a.c.select2Selection(b):a.text;if(null!==c)return c},formatResult:function(a,b,c,g){b=a&&a.c?a.c.select2Result(b):"";return""===b?g(a.text):b},createSearchChoice:function(a,b){return 0===b.length&&sa.test(a)?{id:a,text:a}:null},formatNoMatches:k,formatSearching:function(){return c.i18n("SUGGESTIONS/SEARCHING_DESC")},formatInputTooShort:k,formatSelectionTooBig:k,multiple:!0,tokenSeparators:[",",";"],minimumInputLength:2,selectOnBlur:!1,closeOnSelect:!0,
openOnEnter:!1});d.utils.domNodeDisposal.addDisposeCallback(a,function(){j(a).select2("destroy")});j(a).on("change",function(){for(var a=j(this).select2("data"),g=0,d=a.length,e=null,h=[];g<d;g++)if((e=a[g])&&e.id)e.c||(e.c=new r,(f=ka.exec(c.trim(e.id)))&&!c.isUnd(f[2])?(e.c.name=f[1],e.c.email=f[2]):e.c.email=e.id),h.push(e.c);b()(h)})},update:function(a,b){for(var c=d.utils.unwrapObservable(b()),e=0,f=c.length,h=null,i="",k=[];e<f;e++)h=c[e],i=h.toLine(!1),k.push({id:i,text:i,c:h});j(a).select2("data",
k)}};d.bindingHandlers.command={init:function(a,b,c,e){var f=j(a),h=b();if(!h||!h.enabled||!h.canExecute)throw Error("You are not using command function");f.addClass("command");d.bindingHandlers[f.is("form")?"submit":"click"].init.apply(e,arguments)},update:function(a,b){var c=!0,d=j(a),e=b(),c=e.enabled();d.toggleClass("command-not-enabled",!c);c&&(c=e.canExecute(),d.toggleClass("command-can-not-be-execute",!c));d.toggleClass("command-disabled disable disabled",!c);(d.is("input")||d.is("button"))&&
d.prop("disabled",!c)}};d.extenders.trimmer=function(a){var b=d.computed({read:a,write:function(b){a(c.trim(b.toString()))},owner:this});b(a());return b};d.extenders.reversible=function(a){var b=a();a.commit=function(){b=a()};a.reverse=function(){a(b)};a.commitedValue=function(){return b};return a};d.extenders.toggleSubscribe=function(a,b){a.subscribe(b[1],b[0],"beforeChange");a.subscribe(b[2],b[0]);return a};d.extenders.falseTimeout=function(a,b){a.iTimeout=0;a.subscribe(function(g){g&&(h.clearTimeout(a.iTimeout),
a.iTimeout=h.setTimeout(function(){a(!1);a.iTimeout=0},c.pInt(b)))});return a};d.observable.fn.validateEmail=function(){this.hasError=d.observable(!1);this.subscribe(function(a){a=c.trim(a);this.hasError(""!==a&&!/^[^@\s]+@[^@\s]+$/.test(a))},this);this.valueHasMutated();return this};d.observable.fn.validateFunc=function(a){this.hasFuncError=d.observable(!1);c.isFunc(a)&&(this.subscribe(function(b){this.hasFuncError(!a(b))},this),this.valueHasMutated());return this};o.prototype.root=function(){return this.sBase};
o.prototype.attachmentDownload=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/Download/"+a};o.prototype.attachmentPreview=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/View/"+a};o.prototype.attachmentPreviewAsPlain=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ViewAsPlain/"+a};o.prototype.upload=function(){return this.sServer+"/Upload/"+this.sSpecSuffix+"/"};o.prototype.uploadBackground=function(){return this.sServer+"/UploadBackground/"+this.sSpecSuffix+"/"};
o.prototype.append=function(){return this.sServer+"/Append/"+this.sSpecSuffix+"/"};o.prototype.change=function(a){return this.sServer+"/Change/"+this.sSpecSuffix+"/"+h.encodeURIComponent(a)+"/"};o.prototype.ajax=function(a){return this.sServer+"/Ajax/"+this.sSpecSuffix+"/"+a};o.prototype.messageViewLink=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ViewAsPlain/"+a};o.prototype.messageDownloadLink=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/Download/"+a};o.prototype.inbox=
function(){return this.sBase+"mailbox/Inbox"};o.prototype.settings=function(a){var b=this.sBase+"settings";!c.isUnd(a)&&""!==a&&(b+="/"+a);return b};o.prototype.admin=function(a){var b=this.sBase;switch(a){case "AdminDomains":b+="domains";break;case "AdminSecurity":b+="security";break;case "AdminLicensing":b+="licensing"}return b};o.prototype.mailBox=function(a,b,g){var b=c.isNormal(b)?c.pInt(b):1,g=c.pString(g),d=this.sBase+"mailbox/";""!==a&&(d+=encodeURI(a));1<b&&(d=d.replace(/[\/]+$/,""),d+="/p"+
b);""!==g&&(d=d.replace(/[\/]+$/,""),d+="/"+encodeURI(g));return d};o.prototype.phpInfo=function(){return this.sServer+"Info"};o.prototype.langLink=function(a){return this.sServer+"/Lang/0/"+encodeURI(a)+"/"+this.sVersion+"/"};o.prototype.getUserPicUrlFromHash=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/UserPic/"+a+"/"+this.sVersion+"/"};o.prototype.emptyContactPic=function(){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/static/css/images/empty-contact.png"};
o.prototype.sound=function(a){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/static/sounds/"+a};o.prototype.themePreviewLink=function(a){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/themes/"+encodeURI(a)+"/images/preview.png"};o.prototype.notificationMailIcon=function(){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/static/css/images/icom-message-notification.png"};o.prototype.socialGoogle=
function(){return this.sServer+"SocialGoogle"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")};o.prototype.socialTwitter=function(){return this.sServer+"SocialTwitter"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")};o.prototype.socialFacebook=function(){return this.sServer+"SocialFacebook"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")};n.oViewModelsHooks={};n.oSimpleHooks={};n.regViewModelHook=function(a,b){b&&(b.__hookName=a)};n.addHook=function(a,b){c.isFunc(b)&&(c.isArray(n.oSimpleHooks[a])||
(n.oSimpleHooks[a]=[]),n.oSimpleHooks[a].push(b))};n.runHook=function(a,b){c.isArray(n.oSimpleHooks[a])&&(b=b||[],i.each(n.oSimpleHooks[a],function(a){a.apply(null,b)}))};n.mainSettingsGet=function(a){return e?e.settingsGet(a):null};n.remoteRequest=function(a,b,c,d,f,h){e&&e.remote().defaultRequest(a,b,c,d,f,h)};n.settingsGet=function(a,b){var g=n.mainSettingsGet("Plugins");return(g=g&&c.isUnd(g[a])?null:g[a])?c.isUnd(g[b])?null:g[b]:null};L.supported=function(){return!0};L.prototype.set=function(a,
b){var c=j.cookie(l.Values.ClientSideCookieIndexName),d=null;try{(d=null===c?null:JSON.parse(c))||(d={}),d[a]=b,j.cookie(l.Values.ClientSideCookieIndexName,JSON.stringify(d),{expires:30})}catch(e){}return d};L.prototype.get=function(a){var b=j.cookie(l.Values.ClientSideCookieIndexName),g=null;try{g=(g=null===b?null:JSON.parse(b))&&!c.isUnd(g[a])?g[a]:null}catch(d){}return g};M.supported=function(){return!!h.localStorage};M.prototype.set=function(a,b){var c=h.localStorage[l.Values.ClientSideCookieIndexName]||
null,d=null;try{(d=null===c?null:JSON.parse(c))||(d={}),d[a]=b,h.localStorage[l.Values.ClientSideCookieIndexName]=JSON.stringify(d)}catch(e){}return d};M.prototype.get=function(a){var b=h.localStorage[l.Values.ClientSideCookieIndexName]||null,g=null;try{g=(g=null===b?null:JSON.parse(b))&&!c.isUnd(g[a])?g[a]:null}catch(d){}return g};N.prototype.oDriver=null;N.prototype.set=function(a,b){return this.oDriver?this.oDriver.set("p"+a,b):!1};N.prototype.get=function(a){return this.oDriver?this.oDriver.get("p"+
a):null};na.prototype.bootstart=function(){};t.prototype.sPosition="";t.prototype.sTemplate="";t.prototype.viewModelName="";t.prototype.viewModelDom=null;t.prototype.viewModelTemplate=function(){return this.sTemplate};t.prototype.viewModelPosition=function(){return this.sPosition};t.prototype.cancelCommand=t.prototype.closeCommand=function(){};w.prototype.oCross=null;w.prototype.sScreenName="";w.prototype.aViewModels=[];w.prototype.viewModels=function(){return this.aViewModels};w.prototype.screenName=
function(){return this.sScreenName};w.prototype.routes=function(){return null};w.prototype.__cross=function(){return this.oCross};w.prototype.__start=function(){var a=this.routes(),b=null,g=null;c.isNonEmptyArray(a)&&(g=i.bind(this.onRoute||c.emptyFunction,this),b=ma.create(),i.each(a,function(a){b.addRoute(a[0],g).rules=a[1]}),this.oCross=b)};m.prototype.sDefaultScreenName="";m.prototype.oScreens={};m.prototype.oBoot=null;m.prototype.oCurrentScreen=null;m.prototype.showLoading=function(){j("#rl-loading").show()};
m.prototype.hideLoading=function(){j("#rl-loading").hide()};m.prototype.routeOff=function(){y.changed.active=!1};m.prototype.routeOn=function(){y.changed.active=!0};m.prototype.setBoot=function(a){c.isNormal(a)&&(this.oBoot=a);return this};m.prototype.screen=function(a){return""!==a&&!c.isUnd(this.oScreens[a])?this.oScreens[a]:null};m.prototype.delegateRun=function(a,b,g){a&&a[b]&&a[b].apply(a,c.isArray(g)?g:[])};m.prototype.buildViewModel=function(a,b){if(a&&!a.__builded){var g=new a(b),f=g.viewModelPosition(),
h=j("#rl-content #rl-"+f.toLowerCase()),i=null;a.__builded=!0;a.__vm=g;g.data=e.data();g.viewModelName=a.__name;h&&1===h.length?(i=j("<div>").addClass("rl-view-model").addClass("RL-"+g.viewModelTemplate()).hide().attr("data-bind",'template: {name: "'+g.viewModelTemplate()+'"}, i18nInit: true'),i.appendTo(h),g.viewModelDom=i,a.__dom=i,"Popups"===f&&(g.cancelCommand=g.closeCommand=c.createCommand(g,function(){s.hideScreenPopup(a)})),n.runHook("view-model-pre-build",[a.__name,g,i]),d.applyBindings(g,
i[0]),this.delegateRun(g,"onBuild",[i]),n.runHook("view-model-post-build",[a.__name,g,i])):c.log("Cannot find view model position: "+f)}return a?a.__vm:null};m.prototype.applyExternal=function(a,b){a&&b&&d.applyBindings(a,b)};m.prototype.hideScreenPopup=function(a){a&&(a.__vm&&a.__dom)&&(a.__dom.hide(),a.__vm.modalVisibility(!1),this.delegateRun(a.__vm,"onHide"),this.popupVisibility(!1),i.defer(function(){a.__dom.find(".ko-select2").select2("close")}))};m.prototype.showScreenPopup=function(a,b){a&&
(this.buildViewModel(a),a.__vm&&a.__dom&&(a.__dom.show(),a.__vm.modalVisibility(!0),this.delegateRun(a.__vm,"onShow",b||[]),this.popupVisibility(!0),n.runHook("view-model-on-show",[a.__name,a.__vm,b||[]])))};m.prototype.screenOnRoute=function(a,b){var g=this,d=null,e=null;""===c.pString(a)&&(a=this.sDefaultScreenName);if(""!==a){d=this.screen(a);if(!d&&(d=this.screen(this.sDefaultScreenName)))b=a+"/"+b,a=this.sDefaultScreenName;d&&d.__started&&(d.__builded||(d.__builded=!0,c.isNonEmptyArray(d.viewModels())&&
i.each(d.viewModels(),function(a){this.buildViewModel(a,d)},this),this.delegateRun(d,"onBuild")),i.defer(function(){if(g.oCurrentScreen){g.delegateRun(g.oCurrentScreen,"onHide");c.isNonEmptyArray(g.oCurrentScreen.viewModels())&&i.each(g.oCurrentScreen.viewModels(),function(a){if(a.__vm&&a.__dom&&"Popups"!==a.__vm.viewModelPosition()){a.__dom.hide();a.__vm.viewModelVisibility(false);g.delegateRun(a.__vm,"onHide")}})}g.oCurrentScreen=d;if(g.oCurrentScreen){g.delegateRun(g.oCurrentScreen,"onShow");n.runHook("screen-on-show",
[g.oCurrentScreen.screenName(),g.oCurrentScreen]);c.isNonEmptyArray(g.oCurrentScreen.viewModels())&&i.each(g.oCurrentScreen.viewModels(),function(a){if(a.__vm&&a.__dom&&"Popups"!==a.__vm.viewModelPosition()){a.__dom.show();a.__vm.viewModelVisibility(true);g.delegateRun(a.__vm,"onShow");n.runHook("view-model-on-show",[a.__name,a.__vm])}},g)}(e=d.__cross())&&e.parse(b)}))}};m.prototype.startScreens=function(a){i.each(a,function(a){var c=(a=new a)?a.screenName():"";a&&""!==c&&(""===this.sDefaultScreenName&&
(this.sDefaultScreenName=c),this.oScreens[c]=a)},this);i.each(this.oScreens,function(a){a&&(!a.__started&&a.__start)&&(a.__started=!0,a.__start(),n.runHook("screen-pre-start",[a.screenName(),a]),this.delegateRun(a,"onStart"),n.runHook("screen-post-start",[a.screenName(),a]))},this);a=ma.create();a.addRoute(/^([a-zA-Z0-9\-]*)\/?(.*)$/,i.bind(this.screenOnRoute,this));y.initialized.add(a.parse,a);y.changed.add(a.parse,a);y.init()};m.prototype.setHash=function(a,b){a="#"===a.substr(0,1)?a.substr(1):
a;a="/"===a.substr(0,1)?a.substr(1):a;(c.isUnd(b)?0:b)?(y.changed.active=!1,y.setHash(a),y.changed.active=!0):(y.changed.active=!0,y.setHash(a))};m.prototype.bootstart=function(){this.oBoot&&this.oBoot.bootstart&&this.oBoot.bootstart();return this};s=new m;r.newInstanceFromJson=function(a){var b=new r;return b.initByJson(a)?b:null};r.prototype.name="";r.prototype.email="";r.prototype.privateType=null;r.prototype.validate=function(){return""!==this.name||""!==this.email};r.prototype.hash=function(a){return"#"+
(a?"":this.name)+"#"+this.email+"#"};r.prototype.clearDuplicateName=function(){this.name===this.email&&(this.name="")};r.prototype.type=function(){if(null===this.privateType&&(this.email&&"@facebook.com"===this.email.substr(-13)&&(this.privateType=f.EmailType.Facebook),null===this.privateType))this.privateType=f.EmailType.Default;return this.privateType};r.prototype.search=function(a){return-1<(this.name+" "+this.email).toLowerCase().indexOf(a.toLowerCase())};r.prototype.parse=function(a){var a=c.trim(a),
b=/(?:"([^"]+)")? ?<?(.*?@[^>,]+)>?,? ?/g.exec(a);b?(this.name=b[1]||"",this.email=b[2]||"",this.clearDuplicateName()):/^[^@]+@[^@]+$/.test(a)&&(this.name="",this.email=a)};r.prototype.initByJson=function(a){var b=!1;a&&"Object/Email"===a["@Object"]&&(this.name=c.trim(a.Name),this.email=c.trim(a.Email),b=""!==this.email,this.clearDuplicateName());return b};r.prototype.toLine=function(a,b){var d="";""!==this.email&&(b=c.isUnd(b)?!1:!!b,a&&""!==this.name?d=b?'<a href="mailto:'+c.encodeHtml('"'+this.name+
'" <'+this.email+">")+'" target="_blank" tabindex="-1">'+c.encodeHtml(this.name)+"</a>":this.name:(d=this.email,""!==this.name?d=b?c.encodeHtml('"'+this.name+'" <')+'<a href="mailto:'+c.encodeHtml('"'+this.name+'" <'+this.email+">")+'" target="_blank" tabindex="-1">'+c.encodeHtml(d)+"</a>"+c.encodeHtml(">"):'"'+this.name+'" <'+d+">":b&&(d='<a href="mailto:'+c.encodeHtml(this.email)+'" target="_blank" tabindex="-1">'+c.encodeHtml(this.email)+"</a>")));return d};r.prototype.select2Result=function(){var a=
"",b=e.cache().getUserPic(this.email),a=""!==b?a+('<img class="select2-user-pic pull-left" src="'+c.encodeHtml(b)+'" />'):a+('<img class="select2-user-pic pull-left" src="'+e.link().emptyContactPic()+'" />');f.EmailType.Facebook===this.type()?(a+=""+(0<this.name.length?this.name:this.email),a+='<i class="icon-facebook pull-right select2-icon-result" />'):a+=""+(0<this.name.length?this.email+' <span class="select2-subname">('+this.name+")</span>":this.email);return a+""};r.prototype.select2Selection=
function(a){var b="";if(f.EmailType.Facebook===this.type()){if(b=0<this.name.length?this.name:this.email,""!==b)return j("<pan>").text(b).appendTo(a),a.append('<i class="icon-facebook select2-icon"></i>'),null}else b=0<this.name.length?this.name+" ("+this.email+")":this.email;return b};c.extendAsViewModel("PopupsDomainViewModel",B);B.prototype.onTestConnectionResponse=function(a,b){this.testing(!1);f.StorageResultType.Success===a&&b.Result?(this.testingDone(!0),this.testingImapError(!1===b.Result.Imap),
this.testingSmtpError(!1===b.Result.Smtp)):(this.testingImapError(!0),this.testingSmtpError(!0))};B.prototype.onDomainCreateOrSaveResponse=function(a,b){this.saving(!1);f.StorageResultType.Success===a&&b?b.Result?(e.reloadDomainList(),this.closeCommand()):f.Notification.DomainAlreadyExists===b.ErrorCode&&this.savingError("Domain already exists"):this.savingError("Unknown error")};B.prototype.onShow=function(a){this.saving(!1);this.testing(!1);this.testingDone(!1);this.testingImapError(!1);this.testingSmtpError(!1);
this.clearForm();a&&(this.edit(!0),this.name(c.trim(a.Name)),this.imapServer(c.trim(a.IncHost)),this.imapPort(c.pInt(a.IncPort)),this.imapSecure(c.trim(a.IncSecure)),this.smtpServer(c.trim(a.OutHost)),this.smtpPort(c.pInt(a.OutPort)),this.smtpSecure(c.trim(a.OutSecure)),this.smtpAuth(!!a.OutAuth))};B.prototype.clearForm=function(){this.edit(!1);this.savingError("");this.name("");this.imapServer("");this.imapPort(l.Values.ImapDefaulPort);this.imapSecure(f.ServerSecure.None);this.smtpServer("");this.smtpPort(l.Values.SmtpDefaulPort);
this.smtpSecure(f.ServerSecure.None);this.smtpAuth(!0)};c.extendAsViewModel("PopupsPluginViewModel",O);O.prototype.onPluginSettingsUpdateResponse=function(a,b){f.StorageResultType.Success===a&&b&&b.Result?this.cancelCommand():(this.saveError(""),b&&b.ErrorCode?this.saveError(c.getNotification(b.ErrorCode)):this.saveError(c.getNotification(f.Notification.CantSavePluginSettings)))};O.prototype.onShow=function(a){this.name();this.readme();this.configures([]);a&&(this.name(a.Name),this.readme(a.Readme),
a=a.Config,c.isNonEmptyArray(a)&&this.configures(i.map(a,function(a){return{value:d.observable(a[0]),Name:a[1],Type:a[2],Label:a[3],Default:a[4],Desc:a[5]}})))};c.extendAsViewModel("PopupsActivateViewModel",P);P.prototype.onShow=function(){this.domain(e.settingsGet("AdminDomain"));this.activateProcess()||(this.key(""),this.activateText(""),this.activateText.isError(!1),this.activationSuccessed(!1),this.key.focus(!0))};P.prototype.validateSubscriptionKey=function(){var a=this.key();return""===a||!!/^RL[\d]+-[A-Z0-9\-]+Z$/.test(c.trim(a))};
c.extendAsViewModel("AdminLoginViewModel",Q);Q.prototype.onShow=function(){s.routeOff();i.delay(i.bind(function(){this.loginFocus(!0)},this),100)};Q.prototype.onHide=function(){this.loginFocus(!1)};c.extendAsViewModel("AdminMenuViewModel",Y);Y.prototype.link=function(a){return"#/"+a};c.extendAsViewModel("AdminPaneViewModel",Z);Z.prototype.logoutClick=function(){e.remote().adminLogout(function(){e.loginAndLogoutReload()})};c.addSettingsViewModel(oa,"AdminGeneral","General","general",!0);oa.prototype.onBuild=
function(){var a=this;i.delay(function(){var b=c.settingsSaveHelperSimpleFunction(a.titleTrigger,a),d=c.settingsSaveHelperSimpleFunction(a.languageTrigger,a),f=c.settingsSaveHelperSimpleFunction(a.themeTrigger,a);a.title.subscribe(function(a){e.remote().saveAdminConfig(b,{Title:c.trim(a)})});a.language.subscribe(function(a){e.remote().saveAdminConfig(d,{Language:c.trim(a)})});a.theme.subscribe(function(a){e.remote().saveAdminConfig(f,{Theme:c.trim(a)})});a.allowCustomTheme.subscribe(function(a){e.remote().saveAdminConfig(null,
{AllowCustomTheme:a?"1":"0"})});a.allowAdditionalAccounts.subscribe(function(a){e.remote().saveAdminConfig(null,{AllowAdditionalAccounts:a?"1":"0"})})},50)};c.addSettingsViewModel(z,"AdminDomains","Domains","domains");z.prototype.startDomainForDeletionTimeout=function(){var a=this;h.clearInterval(this.iDomainForDeletionTimeout);this.iDomainForDeletionTimeout=h.setTimeout(function(){a.domainForDeletion(null)},3E3)};z.prototype.createDomain=function(){s.showScreenPopup(B)};z.prototype.deleteDomain=
function(a){this.domains.remove(a);e.remote().domainDelete(i.bind(this.onDomainListChangeRequest,this),a.name)};z.prototype.disableDomain=function(a){a.disabled(!a.disabled());e.remote().domainDisable(i.bind(this.onDomainListChangeRequest,this),a.name,a.disabled())};z.prototype.onBuild=function(a){var b=this;a.on("click",".b-admin-domains-list-table .e-item .e-action",function(){var a=d.dataFor(this);a&&e.remote().domain(i.bind(b.onDomainLoadRequest,b),a.name)});e.reloadDomainList()};z.prototype.onDomainLoadRequest=
function(a,b){f.StorageResultType.Success===a&&(b&&b.Result)&&s.showScreenPopup(B,[b.Result])};z.prototype.onDomainListChangeRequest=function(){e.reloadDomainList()};c.addSettingsViewModel(J,"AdminLicensing","Licensing","licensing");J.prototype.onBuild=function(){this.subscriptionEnabled()&&e.reloadLicensing(!1)};J.prototype.onShow=function(){this.adminDomain(e.settingsGet("AdminDomain"))};J.prototype.showActivationForm=function(){s.showScreenPopup(P)};J.prototype.licenseExpiredMomentValue=function(){var a=
moment.unix(this.licenseExpired());return a.format("LL")+" ("+a.from(moment())+")"};c.addSettingsViewModel(K,"AdminSecurity","Security","security");K.prototype.onNewAdminPasswordResponse=function(a,b){f.StorageResultType.Success===a&&b&&b.Result?(this.adminPassword(""),this.adminPasswordNew(""),this.adminPasswordUpdateSuccess(!0)):this.adminPasswordUpdateError(!0)};K.prototype.onBuild=function(){this.csrfProtection.subscribe(function(a){e.remote().saveAdminConfig(c.emptyFunction,{TokenProtection:a?
"1":"0"})});this.usageStatistics.subscribe(function(a){e.remote().saveAdminConfig(c.emptyFunction,{UsageStatistics:a?"1":"0"})})};K.prototype.onHide=function(){this.adminPassword("");this.adminPasswordNew("")};K.prototype.phpInfoLink=function(){return e.link().phpInfo()};c.addSettingsViewModel(pa,"AdminSocial","Social","social");pa.prototype.onBuild=function(){var a=this;i.delay(function(){var b=c.settingsSaveHelperSimpleFunction(a.facebookTrigger1,a),d=c.settingsSaveHelperSimpleFunction(a.facebookTrigger2,
a),f=c.settingsSaveHelperSimpleFunction(a.twitterTrigger1,a),h=c.settingsSaveHelperSimpleFunction(a.twitterTrigger2,a),i=c.settingsSaveHelperSimpleFunction(a.googleTrigger1,a),j=c.settingsSaveHelperSimpleFunction(a.googleTrigger2,a),k=c.settingsSaveHelperSimpleFunction(a.dropboxTrigger1,a);a.facebookEnable.subscribe(function(a){e.remote().saveAdminConfig(c.emptyFunction,{FacebookEnable:a?"1":"0"})});a.facebookAppID.subscribe(function(a){e.remote().saveAdminConfig(b,{FacebookAppID:c.trim(a)})});a.facebookAppSecret.subscribe(function(a){e.remote().saveAdminConfig(d,
{FacebookAppSecret:c.trim(a)})});a.twitterEnable.subscribe(function(a){e.remote().saveAdminConfig(c.emptyFunction,{TwitterEnable:a?"1":"0"})});a.twitterConsumerKey.subscribe(function(a){e.remote().saveAdminConfig(f,{TwitterConsumerKey:c.trim(a)})});a.twitterConsumerSecret.subscribe(function(a){e.remote().saveAdminConfig(h,{TwitterConsumerSecret:c.trim(a)})});a.googleEnable.subscribe(function(a){e.remote().saveAdminConfig(c.emptyFunction,{GoogleEnable:a?"1":"0"})});a.googleClientID.subscribe(function(a){e.remote().saveAdminConfig(i,
{GoogleClientID:c.trim(a)})});a.googleClientSecret.subscribe(function(a){e.remote().saveAdminConfig(j,{GoogleClientSecret:c.trim(a)})});a.dropboxEnable.subscribe(function(a){e.remote().saveAdminConfig(c.emptyFunction,{DropboxEnable:a?"1":"0"})});a.dropboxApiKey.subscribe(function(a){e.remote().saveAdminConfig(k,{DropboxApiKey:c.trim(a)})})},50)};c.addSettingsViewModel(C,"AdminPlugins","Plugins","plugins");C.prototype.disablePlugin=function(a){a.disabled(!a.disabled());e.remote().pluginDisable(this.onPluginDisableRequest,
a.name,a.disabled())};C.prototype.configurePlugin=function(a){e.remote().plugin(this.onPluginLoadRequest,a.name)};C.prototype.onBuild=function(){this.enabledPlugins.subscribe(function(a){e.remote().saveAdminConfig(c.emptyFunction,{EnabledPlugins:a?"1":"0"})})};C.prototype.onShow=function(){this.pluginsError("");e.reloadPluginList()};C.prototype.onPluginLoadRequest=function(a,b){f.StorageResultType.Success===a&&(b&&b.Result)&&s.showScreenPopup(O,[b.Result])};C.prototype.onPluginDisableRequest=function(a,
b){f.StorageResultType.Success===a&&b&&!b.Result&&b.ErrorCode&&(f.Notification.UnsupportedPluginPackage===b.ErrorCode&&b.ErrorMessage&&""!==b.ErrorMessage?this.pluginsError(b.ErrorMessage):this.pluginsError(c.getNotification(b.ErrorCode)));e.reloadPluginList()};c.addSettingsViewModel(G,"AdminPackages","Packages","packages");G.prototype.onShow=function(){this.packagesError("")};G.prototype.onBuild=function(){e.reloadPackagesList()};G.prototype.requestHelper=function(a,b){var d=this;return function(q,
j){if(f.StorageResultType.Success!==q||!j||!j.Result)j&&j.ErrorCode?d.packagesError(c.getNotification(j.ErrorCode)):d.packagesError(c.getNotification(b?f.Notification.CantInstallPackage:f.Notification.CantDeletePackage));i.each(e.data().packages(),function(b){b&&(a&&b.loading()&&a.file===b.file)&&(a.loading(!1),b.loading(!1))});f.StorageResultType.Success===q&&j&&j.Result&&j.Result.Reload?h.location.reload():e.reloadPackagesList()}};G.prototype.deletePackage=function(a){a&&(a.loading(!0),e.remote().packageDelete(this.requestHelper(a,
!1),a))};G.prototype.installPackage=function(a){a&&(a.loading(!0),e.remote().packageInstall(this.requestHelper(a,!0),a))};aa.prototype.populateDataOnStart=function(){var a=e.settingsGet("Languages"),b=e.settingsGet("Themes");c.isArray(a)&&this.languages(a);c.isArray(b)&&this.themes(b);this.mainLanguage(e.settingsGet("Language"));this.mainTheme(e.settingsGet("Theme"));this.allowCustomTheme(!!e.settingsGet("AllowCustomTheme"));this.allowAdditionalAccounts(!!e.settingsGet("AllowAdditionalAccounts"));
this.ignoreFolderSubscribe(!!e.settingsGet("IgnoreFolderSubscribe"));this.editorDefaultType(e.settingsGet("EditorDefaultType"));this.showImages(!!e.settingsGet("ShowImages"));this.showAnimation(!!e.settingsGet("ShowAnimation"));this.mainMessagesPerPage(e.settingsGet("MPP"));this.desktopNotifications(!!e.settingsGet("DesktopNotifications"));this.useThreads(!!e.settingsGet("UseThreads"));this.replySameFolder(!!e.settingsGet("ReplySameFolder"));this.usePreviewPane(!!e.settingsGet("UsePreviewPane"));
this.useCheckboxesInList(!!e.settingsGet("UseCheckboxesInList"));this.facebookEnable(!!e.settingsGet("AllowFacebookSocial"));this.facebookAppID(e.settingsGet("FacebookAppID"));this.facebookAppSecret(e.settingsGet("FacebookAppSecret"));this.twitterEnable(!!e.settingsGet("AllowTwitterSocial"));this.twitterConsumerKey(e.settingsGet("TwitterConsumerKey"));this.twitterConsumerSecret(e.settingsGet("TwitterConsumerSecret"));this.googleEnable(!!e.settingsGet("AllowGoogleSocial"));this.googleClientID(e.settingsGet("GoogleClientID"));
this.googleClientSecret(e.settingsGet("GoogleClientSecret"));this.dropboxEnable(!!e.settingsGet("AllowDropboxSocial"));this.dropboxApiKey(e.settingsGet("DropboxApiKey"));this.contactsIsSupported(!!e.settingsGet("ContactsIsSupported"))};i.extend(ba.prototype,aa.prototype);ba.prototype.populateDataOnStart=function(){aa.prototype.populateDataOnStart.call(this)};D.prototype.oRequests={};D.prototype.defaultResponse=function(a,b,c,d,j,k){var l=function(){f.StorageResultType.Success!==c&&ea&&(c=f.StorageResultType.Unload);
if(f.StorageResultType.Success===c&&d&&!d.Result){if(d&&f.Notification.AuthError===d.ErrorCode&&S++,d.Logout||5<S)h.__rlah_clear&&h.__rlah_clear(),e.loginAndLogoutReload(!0)}else f.StorageResultType.Success===c&&(d&&d.Result)&&(S=0);a&&(n.runHook("ajax-default-response",[b,f.StorageResultType.Success===c?d:null,c,j,k]),a(c,f.StorageResultType.Success===c?d:null,j,b,k))};switch(c){case "success":c=f.StorageResultType.Success;break;case "abort":c=f.StorageResultType.Abort;break;default:c=f.StorageResultType.Error}f.StorageResultType.Error===
c?i.delay(l,300):l()};D.prototype.ajaxRequest=function(a,b,d,f,k){var l=this,n=""===f,o=(new h.Date).getTime(),p=null,m="",b=b||{},d=c.isNormal(d)?d:2E4,f=c.isUnd(f)?"":c.pString(f),k=c.isArray(k)?k:[];(m=b.Action||"")&&0<k.length&&i.each(k,function(a){l.oRequests[a]&&(l.oRequests[a].__aborted=!0,l.oRequests[a].abort&&l.oRequests[a].abort(),l.oRequests[a]=null)});n&&(b.XToken=e.settingsGet("Token"));p=j.ajax({type:n?"POST":"GET",url:e.link().ajax(f),async:!0,dataType:"json",data:n?b:{},headers:{},
timeout:d,global:!0});p.always(function(d,g){var e=!1;d&&d.Time&&(e=c.pInt(d.Time)>(new h.Date).getTime()-o);m&&l.oRequests[m]&&(l.oRequests[m].__aborted&&(g="abort"),l.oRequests[m]=null);l.defaultResponse(a,m,g,d,e,b)});m&&(0<k.length&&-1<c.inArray(m,k))&&(this.oRequests[m]&&(this.oRequests[m].__aborted=!0,this.oRequests[m].abort&&this.oRequests[m].abort(),this.oRequests[m]=null),this.oRequests[m]=p);return p};D.prototype.defaultRequest=function(a,b,d,e,f,h){d=d||{};d.Action=b;f=c.pString(f);n.runHook("ajax-default-request",
[b,d,f]);this.ajaxRequest(a,d,c.isUnd(e)?l.Defaults.DefaultAjaxTimeout:c.pInt(e),f,h)};D.prototype.noop=function(a){this.defaultRequest(a,"Noop")};D.prototype.jsError=function(a,b,c,d,e,f){this.defaultRequest(a,"JsError",{Message:b,FileName:c,LineNo:d,LocationHash:e,HtmlCapa:f})};i.extend(p.prototype,D.prototype);p.prototype.adminLogin=function(a,b,c){this.defaultRequest(a,"AdminLogin",{Login:b,Password:c})};p.prototype.adminLogout=function(a){this.defaultRequest(a,"AdminLogout")};p.prototype.saveAdminConfig=
function(a,b){this.defaultRequest(a,"AdminSettingsUpdate",b)};p.prototype.domainList=function(a){this.defaultRequest(a,"AdminDomainList")};p.prototype.pluginList=function(a){this.defaultRequest(a,"AdminPluginList")};p.prototype.packagesList=function(a){this.defaultRequest(a,"AdminPackagesList")};p.prototype.packageInstall=function(a,b){this.defaultRequest(a,"AdminPackageInstall",{Id:b.id,Type:b.type,File:b.file})};p.prototype.packageDelete=function(a,b){this.defaultRequest(a,"AdminPackageDelete",
{Id:b.id})};p.prototype.domain=function(a,b){this.defaultRequest(a,"AdminDomainLoad",{Name:b})};p.prototype.plugin=function(a,b){this.defaultRequest(a,"AdminPluginLoad",{Name:b})};p.prototype.domainDelete=function(a,b){this.defaultRequest(a,"AdminDomainDelete",{Name:b})};p.prototype.domainDisable=function(a,b,c){return this.defaultRequest(a,"AdminDomainDisable",{Name:b,Disabled:c?"1":"0"})};p.prototype.pluginSettingsUpdate=function(a,b){return this.defaultRequest(a,"AdminPluginSettingsUpdate",b)};
p.prototype.licensing=function(a,b){return this.defaultRequest(a,"AdminLicensing",{Force:b?"1":"0"})};p.prototype.licensingActivate=function(a,b,c){return this.defaultRequest(a,"AdminLicensingActivate",{Domain:b,Key:c})};p.prototype.pluginDisable=function(a,b,c){return this.defaultRequest(a,"AdminPluginDisable",{Name:b,Disabled:c?"1":"0"})};p.prototype.createOrUpdateDomain=function(a,b,c,d,e,f,h,i,j,k){this.defaultRequest(a,"AdminDomainSave",{Create:b?"1":"0",Name:c,IncHost:d,IncPort:e,IncSecure:f,
OutHost:h,OutPort:i,OutSecure:j,OutAuth:k?"1":"0"})};p.prototype.testConnectionForDomain=function(a,b,c,d,e,f,h,i){this.defaultRequest(a,"AdminDomainTest",{IncHost:b,IncPort:c,IncSecure:d,OutHost:e,OutPort:f,OutSecure:h,OutAuth:i?"1":"0"})};p.prototype.saveNewAdminPassword=function(a,b){this.defaultRequest(a,"AdminPasswordUpdate",b)};p.prototype.adminPing=function(a){this.defaultRequest(a,"AdminPing")};A.prototype.oEmailsPicsHashes={};A.prototype.oServices={};A.prototype.clear=function(){this.oServices=
{};this.oEmailsPicsHashes={}};A.prototype.getUserPic=function(a){var b="",b="",b=a.toLowerCase(),d=c.isUnd(this.oEmailsPicsHashes[a])?"":this.oEmailsPicsHashes[a];""===d?(b=b.substr(a.indexOf("@")+1),b=""!==b&&this.oServices[b]?this.oServices[b]:""):b=e.link().getUserPicUrlFromHash(d);return b};A.prototype.setServicesData=function(a){this.oServices=a};A.prototype.setEmailsPicsHashesData=function(a){this.oEmailsPicsHashes=a};i.extend(qa.prototype,A.prototype);i.extend(H.prototype,w.prototype);H.prototype.onRoute=
function(a){var b=this,g=null,f=null,h=null,k=null;if(f=i.find(V,function(b){return b&&b.__rlSettingsData&&a===b.__rlSettingsData.Route}))i.find(ia,function(a){return a&&a===f})&&(f=null),f&&i.find(ja,function(a){return a&&a===f})&&(f=null);f&&(f.__builded&&f.__vm?g=f.__vm:(h=j("#rl-content #rl-settings-subscreen"))&&1===h.length?(g=new f,k=j("<div></div>").addClass("rl-settings-view-model").hide().attr("data-bind",'template: {name: "'+f.__rlSettingsData.Template+'"}, i18nInit: true'),k.appendTo(h),
g.data=e.data(),g.viewModelDom=k,g.__rlSettingsData=f.__rlSettingsData,f.__dom=k,f.__builded=!0,f.__vm=g,d.applyBindings(g,k[0]),s.delegateRun(g,"onBuild",[k])):c.log("Cannot find sub settings view model position: SettingsSubScreen"),g&&i.defer(function(){if(b.oCurrentSubScreen){s.delegateRun(b.oCurrentSubScreen,"onHide");b.oCurrentSubScreen.viewModelDom.hide()}b.oCurrentSubScreen=g;if(b.oCurrentSubScreen){b.oCurrentSubScreen.viewModelDom.show();s.delegateRun(b.oCurrentSubScreen,"onShow");i.each(b.menu(),
function(a){a.selected(g&&g.__rlSettingsData&&a.route===g.__rlSettingsData.Route)})}c.windowResize()}))};H.prototype.onBuild=function(){i.each(V,function(a){a&&(a.__rlSettingsData&&!i.find(ia,function(b){return b&&b===a}))&&this.menu.push({route:a.__rlSettingsData.Route,label:a.__rlSettingsData.Label,selected:d.observable(!1),disabled:!!i.find(ja,function(b){return b&&b===a})})},this)};H.prototype.routes=function(){var a=i.find(V,function(a){return a&&a.__rlSettingsData&&a.__rlSettingsData.IsDefault}),
b=a?a.__rlSettingsData.Route:"general",a={subname:/^(.*)$/,normalize_:function(a,d){d.subname=c.isUnd(d.subname)?b:c.pString(d.subname);return[d.subname]}};return[["{subname}/",a],["{subname}",a],["",a]]};i.extend(ca.prototype,w.prototype);ca.prototype.onShow=function(){e.setTitle("")};i.extend(da.prototype,H.prototype);da.prototype.onShow=function(){e.setTitle("")};i.extend(u.prototype,na.prototype);u.prototype.oSettings=null;u.prototype.oLink=null;u.prototype.download=function(a){I?this.iframe.attr("src",
a):h.open(a)};u.prototype.link=function(){null===this.oLink&&(this.oLink=new o);return this.oLink};u.prototype.local=function(){null===this.oLocal&&(this.oLocal=new N);return this.oLocal};u.prototype.settingsGet=function(a){null===this.oSettings&&(this.oSettings=c.isNormal(U)?U:{});return c.isUnd(this.oSettings[a])?null:this.oSettings[a]};u.prototype.settingsSet=function(a,b){null===this.oSettings&&(this.oSettings=c.isNormal(U)?U:{});this.oSettings[a]=b};u.prototype.setTitle=function(a){a=(0<a.length?
a+" - ":"")+this.settingsGet("Title")||"";a!==h.document.title&&(h.document.title=a)};u.prototype.loginAndLogoutReload=function(a,b){var d=c.pString(this.settingsGet("CustomLogoutLink")),f=!!this.settingsGet("InIframe"),a=c.isUnd(a)?!1:!!a,b=c.isUnd(b)?!1:!!b;a&&(b&&h.close)&&h.close();a&&""!==d&&h.location.href!==d?i.defer(function(){f&&h.parent?h.parent.location.href=d:h.location.href=d}):(s.routeOff(),s.setHash(e.link().root(),!0),s.routeOff(),i.defer(function(){f&&h.parent?h.parent.location.reload():
h.location.reload()}))};u.prototype.getAutocomplete=function(a,b,c){c([],a)};u.prototype.bootstart=function(){c.initOnStartOrLangChange(function(){c.initNotificationLanguage()},null);i.delay(function(){c.windowResize()},1E3)};i.extend(v.prototype,u.prototype);v.prototype.oData=null;v.prototype.oRemote=null;v.prototype.oCache=null;v.prototype.data=function(){null===this.oData&&(this.oData=new ba);return this.oData};v.prototype.remote=function(){null===this.oRemote&&(this.oRemote=new p);return this.oRemote};
v.prototype.cache=function(){null===this.oCache&&(this.oCache=new qa);return this.oCache};v.prototype.reloadDomainList=function(){e.data().domainsLoading(!0);e.remote().domainList(function(a,b){e.data().domainsLoading(!1);if(f.StorageResultType.Success===a&&b&&b.Result){var c=i.map(b.Result,function(a,b){return{name:b,disabled:d.observable(!a),deleteAccess:d.observable(!1)}},this);e.data().domains(c)}})};v.prototype.reloadPluginList=function(){e.data().pluginsLoading(!0);e.remote().pluginList(function(a,
b){e.data().pluginsLoading(!1);if(f.StorageResultType.Success===a&&b&&b.Result){var c=i.map(b.Result,function(a){return{name:a.Name,disabled:d.observable(!a.Enabled),configured:d.observable(!!a.Configured)}},this);e.data().plugins(c)}})};v.prototype.reloadPackagesList=function(){e.data().packagesLoading(!0);e.data().packagesReal(!0);e.remote().packagesList(function(a,b){e.data().packagesLoading(!1);if(f.StorageResultType.Success===a&&b&&b.Result){e.data().packagesReal(!!b.Result.Real);e.data().packagesMainUpdatable(!!b.Result.MainUpdatable);
var g=[],h={};i.each(e.data().packages(),function(a){a&&a.loading()&&(h[a.file]=a)});c.isArray(b.Result.List)&&(g=i.map(b.Result.List,function(a){a.loading=d.observable(!c.isUnd(h[a.file]));return a},this));e.data().packages(g)}else e.data().packagesReal(!1)})};v.prototype.reloadLicensing=function(a){a=c.isUnd(a)?!1:!!a;e.data().licensingProcess(!0);e.data().licenseError("");e.remote().licensing(function(a,d){e.data().licensingProcess(!1);f.StorageResultType.Success===a&&d&&d.Result&&c.isNormal(d.Result.Expired)?
(e.data().licenseValid(!0),e.data().licenseExpired(c.pInt(d.Result.Expired)),e.data().licenseError(""),e.data().licensing(!0)):d&&d.ErrorCode&&-1<c.inArray(c.pInt(d.ErrorCode),[f.Notification.LicensingServerIsUnavailable,f.Notification.LicensingExpired])?(e.data().licenseError(c.getNotification(c.pInt(d.ErrorCode))),e.data().licensing(!0)):f.StorageResultType.Abort===a?(e.data().licenseError(c.getNotification(f.Notification.LicensingServerIsUnavailable)),e.data().licensing(!0)):e.data().licensing(!1)},
a)};v.prototype.bootstart=function(){u.prototype.bootstart.call(this);e.data().populateDataOnStart();s.hideLoading();this.settingsGet("Auth")?s.startScreens([da]):s.startScreens([ca]);h.SimplePace&&h.SimplePace.set(100)};e=new v;j(function(){h.setTimeout(function(){s.setBoot(e).bootstart()},10);h.setInterval(function(){ga(!ga())},6E4);i.delay(function(){h.rainloopAppData={};h.rainloopI18N={}},100)});R.addClass(I?"mobile":"no-mobile");E.keydown(c.killCtrlAandS).keyup(c.killCtrlAandS);E.unload(function(){ea=
!0});h.rl=h.rl||{};h.rl.addHook=n.addHook;h.rl.settingsGet=n.mainSettingsGet;h.rl.remoteRequest=n.remoteRequest;h.rl.pluginSettingsGet=n.settingsGet;h.rl.addSettingsViewModel=c.addSettingsViewModel;h.rl.createCommand=c.createCommand;h.rl.EmailModel=r;h.rl.Enums=f;h.SimplePace&&h.SimplePace.add(10)})(window,jQuery,ko,crossroads,hasher,_);

View file

@ -1,376 +0,0 @@
(function(h,j,f,Wa,P,Z,sa,i){function B(){this.sBase="#/";this.sCdnStaticDomain=e.settingsGet("CdnStaticDomain");this.sVersion=e.settingsGet("Version");this.sSpecSuffix=e.settingsGet("AuthAccountHash")||"0";this.sServer="./?";this.sCdnStaticDomain=""===this.sCdnStaticDomain?this.sCdnStaticDomain:"/"===this.sCdnStaticDomain.substr(-1)?this.sCdnStaticDomain:this.sCdnStaticDomain+"/"}function q(a,b,d,l){this.oOptions=l=j.extend({DisableHtml:!1,onSwitch:!1,LangSwitcherConferm:"EDITOR_TEXT_SWITCHER_CONFIRM",
LangSwitcherTextLabel:"EDITOR_SWITCHER_TEXT_LABEL",LangSwitcherHtmlLabel:"EDITOR_SWITCHER_HTML_LABEL"},c.isUnd(l)?{}:l);this.bOnlyPlain=!!this.oOptions.DisableHtml;this.fOnSwitch=this.oOptions.onSwitch;this.textarea=j(a).empty().addClass("editorTextArea");this.htmlarea=j(b).empty().addClass("editorHtmlArea").prop("contentEditable","true");this.toolbar=j(d).empty().addClass("editorToolbar");q.htmlInitEditor.apply(this);q.htmlInitToolbar.apply(this);q.htmlAttachEditorEvents.apply(this);this.bOnlyPlain&&
this.toolbar.hide()}function K(a,b,d,l,e){this.list=a;this.selectedItem=b;this.selectedItem.extend({toggleSubscribe:[null,function(a){a&&a.selected(!1)},function(a){a&&a.selected(!0)}]});this.oContentScrollable=this.oContentVisible=null;this.sItemSelector=d;this.sItemSelectedSelector=l;this.sItemCheckedSelector=e;this.sLastUid="";this.oCallbacks={};this.iSelectTimer=0;this.bUseKeyboard=!0;this.emptyFunction=function(){};this.useItemSelectCallback=!0;this.throttleSelection=!1;this.selectedItem.subscribe(function(a){this.useItemSelectCallback&&
(this.throttleSelection?(this.throttleSelection=!1,this.selectItemCallbacksThrottle(a)):this.selectItemCallbacks(a))},this);var f=this,g=[],k=null;this.list.subscribe(function(){var a=this,b=this.list();c.isArray(b)&&i.each(b,function(b){b.checked()&&g.push(a.getItemUid(b));null===k&&b.selected()&&(k=a.getItemUid(b))})},this,"beforeChange");this.list.subscribe(function(a){this.useItemSelectCallback=!1;this.selectedItem(null);if(c.isArray(a)){var b=this,d=g.length;i.each(a,function(a){0<d&&-1<c.inArray(b.getItemUid(a),
g)&&(a.checked(!0),d--);null!==k&&k===b.getItemUid(a)&&(a.selected(!0),k=null,b.selectedItem(a))})}this.useItemSelectCallback=!0;g=[];k=null},this);this.list.setSelectedByUid=function(a){f.selectByUid(a,!1)};this.selectItemCallbacksThrottle=i.debounce(this.selectItemCallbacks,300)}function ta(){}function ua(){}function va(){var a=i.find([ua,ta],function(a){return a.supported()});a&&(this.oDriver=new a)}function Xa(){}function C(a,b){this.sPosition=c.pString(a);this.sTemplate=c.pString(b);this.viewModelName=
"";this.viewModelVisibility=f.observable(!1);"Popups"===this.sPosition&&(this.modalVisibility=f.observable(!1));this.viewModelDom=null}function J(a,b){this.sScreenName=a;this.aViewModels=c.isArray(b)?b:[]}function E(){this.sDefaultScreenName="";this.oScreens={};this.oCurrentScreen=this.oBoot=null;this.popupVisibility=f.observable(!1);this.popupVisibility.subscribe(function(a){e&&e.popupVisibility(a)})}function F(a,b){this.email=a||"";this.name=b||"";this.privateType=null;this.clearDuplicateName()}
function ka(){this.idContact=0;this.name=this.listName=this.imageHash="";this.emails=[];this.checked=f.observable(!1);this.selected=f.observable(!1);this.deleted=f.observable(!1)}function D(){this.fileName=this.mimeType="";this.estimatedSize=0;this.friendlySize="";this.isLinked=this.isInline=!1;this.mimeIndex=this.uid=this.folder=this.download=this.cidWithOutTags=this.cid=""}function M(a,b,d,l,e,r){this.id=a;this.isInline=c.isUnd(l)?!1:!!l;this.isLinked=c.isUnd(e)?!1:!!e;this.CID=c.isUnd(r)?"":r;
this.fromMessage=!1;this.fileName=f.observable(b);this.size=f.observable(c.isUnd(d)?null:d);this.tempName=f.observable("");this.progress=f.observable("");this.error=f.observable("");this.waiting=f.observable(!0);this.uploading=f.observable(!1);this.enabled=f.observable(!0);this.friendlySize=f.computed(function(){return null===this.size()?"":c.friendlySize(this.size())},this)}function m(){this.requestHash=this.uid=this.folderFullNameRaw="";this.subject=f.observable("");this.size=f.observable(0);this.dateTimeStampInUTC=
f.observable(0);this.priority=f.observable(g.MessagePriority.Normal);this.fromEmailString=f.observable("");this.toEmailsString=f.observable("");this.senderEmailsString=f.observable("");this.prefetched=!1;this.emails=[];this.from=[];this.to=[];this.cc=[];this.bcc=[];this.replyTo=[];this.newForAnimation=f.observable(!1);this.deleted=f.observable(!1);this.unseen=f.observable(!1);this.flagged=f.observable(!1);this.answered=f.observable(!1);this.forwarded=f.observable(!1);this.selected=f.observable(!1);
this.checked=f.observable(!1);this.hasAttachments=f.observable(!1);this.moment=f.observable(Z());this.fullFormatDateValue=f.computed(function(){return m.calculateFullFromatDateValue(this.dateTimeStampInUTC())},this);this.fullFormatDateValue=f.computed(function(){return m.calculateFullFromatDateValue(this.dateTimeStampInUTC())},this);this.momentDate=c.createMomentDate(this);this.momentShortDate=c.createMomentShortDate(this);this.dateTimeStampInUTC.subscribe(function(a){var b=Z().unix();this.moment(Z.unix(b<
a?b:a))},this);this.body=null;this.isHtml=f.observable(!1);this.hasImages=f.observable(!1);this.attachments=f.observableArray([]);this.priority=f.observable(g.MessagePriority.Normal);this.aDraftInfo=[];this.sReferences=this.sInReplyTo=this.sMessageId="";this.parentUid=f.observable(0);this.threads=f.observableArray([]);this.threadsLen=f.observable(0);this.hasUnseenSubMessage=f.observable(!1);this.hasFlaggedSubMessage=f.observable(!1);this.lastInCollapsedThread=f.observable(!1);this.lastInCollapsedThreadLoading=
f.observable(!1);this.threadsLenResult=f.computed(function(){var a=this.threadsLen();return 0===this.parentUid()&&0<a?a+1:""},this)}function G(){this.name=f.observable("");this.namespace=this.delimiter=this.fullNameHash=this.fullNameRaw=this.fullName="";this.deep=0;this.selectable=!1;this.existen=!0;this.isUnpaddigFolder=this.isGmailFolder=this.isNamespaceFolder=!1;this.type=f.observable(g.FolderType.User);this.selected=f.observable(!1);this.edited=f.observable(!1);this.collapsed=f.observable(!0);
this.subScribed=f.observable(!0);this.subFolders=f.observableArray([]);this.deleteAccess=f.observable(!1);this.actionBlink=f.observable(!1).extend({falseTimeout:1E3});this.nameForEdit=f.observable("");this.name.subscribe(function(a){this.nameForEdit(a)},this);this.edited.subscribe(function(a){a&&this.nameForEdit(this.name())},this);this.canBeEdited=f.computed(function(){return g.FolderType.User===this.type()},this);this.privateMessageCountAll=f.observable(0);this.privateMessageCountUnread=f.observable(0);
this.collapsedPrivate=f.observable(!0)}function La(a,b){this.email=a;this.deleteAccess=f.observable(!1);this.canBeDalete=f.observable(b)}function wa(){C.call(this,"Popups","PopupsFolderClear");this.selectedFolder=f.observable(null);this.clearingProcess=f.observable(!1);this.clearingError=f.observable("");this.folderFullNameForClear=f.computed(function(){var a=this.selectedFolder();return a?a.printableFullName():""},this);this.folderNameForClear=f.computed(function(){var a=this.selectedFolder();return a?
a.localName():""},this);this.dangerDescHtml=f.computed(function(){return c.i18n("POPUPS_CLEAR_FOLDER/DANGER_DESC_HTML_1",{FOLDER:this.folderNameForClear()})},this);this.clearCommand=c.createCommand(this,function(){var a=this,b=this.selectedFolder();b&&(e.data().message(null),e.data().messageList([]),this.clearingProcess(!0),e.cache().setFolderHash(b.fullNameRaw,""),e.remote().folderClear(function(b,l){a.clearingProcess(!1);g.StorageResultType.Success===b&&l&&l.Result?(e.reloadMessageList(!0),a.cancelCommand()):
l&&l.ErrorCode?a.clearingError(c.getNotification(l.ErrorCode)):a.clearingError(c.getNotification(g.Notification.MailServerError))},b.fullNameRaw))},function(){var a=this.selectedFolder();return!this.clearingProcess()&&null!==a})}function ba(){C.call(this,"Popups","PopupsFolderCreate");c.initOnStartOrLangChange(function(){this.sNoParentText=c.i18n("POPUPS_CREATE_FOLDER/SELECT_NO_PARENT")},this);this.folderName=f.observable("");this.focusTrigger=f.observable(!1);this.selectedParentValue=f.observable(t.Values.UnuseOptionValue);
this.parentFolderSelectList=f.computed(function(){var a=e.data(),b=[],d=null,l=a.folderList();b.push(["",this.sNoParentText]);""!==a.namespace&&(d=function(b){return a.namespace!==b.fullNameRaw.substr(0,a.namespace.length)});return e.folderListOptionsBuilder([],l,[],b,null,d,null,function(a){return a?a.isSystemFolder()?a.name()+" "+a.manageFolderSystemName():a.name():""})},this);this.createFolder=c.createCommand(this,function(){var a=e.data(),b=this.selectedParentValue();""===b&&1<a.namespace.length&&
(b=a.namespace.substr(0,a.namespace.length-1));a.foldersCreating(!0);e.remote().folderCreate(function(a,b){e.data().foldersCreating(!1);g.StorageResultType.Success===a&&b&&b.Result?e.folders(!1):e.data().foldersListError(b&&b.ErrorCode?c.getNotification(b.ErrorCode):c.i18n("NOTIFICATIONS/CANT_CREATE_FOLDER"))},this.folderName(),b);this.cancelCommand()},function(){return this.simpleFolderNameValidation(this.folderName())});this.defautOptionsAfterRender=c.defautOptionsAfterRender}function X(){C.call(this,
"Popups","PopupsFolderSystem");c.initOnStartOrLangChange(function(){this.sChooseOnText=c.i18n("POPUPS_SYSTEM_FOLDERS/SELECT_CHOOSE_ONE");this.sUnuseText=c.i18n("POPUPS_SYSTEM_FOLDERS/SELECT_UNUSE_NAME")},this);this.notification=f.observable("");this.folderSelectList=f.computed(function(){return e.folderListOptionsBuilder([],e.data().folderList(),e.data().folderListSystemNames(),[["",this.sChooseOnText],[t.Values.UnuseOptionValue,this.sUnuseText]])},this);var a=e.data(),b=this,d=null,l=null;this.sentFolder=
a.sentFolder;this.draftFolder=a.draftFolder;this.spamFolder=a.spamFolder;this.trashFolder=a.trashFolder;d=i.debounce(function(){e.settingsSet("SentFolder",b.sentFolder());e.settingsSet("DraftFolder",b.draftFolder());e.settingsSet("SpamFolder",b.spamFolder());e.settingsSet("TrashFolder",b.trashFolder());e.remote().saveSystemFolders(c.emptyFunction,{SentFolder:b.sentFolder(),DraftFolder:b.draftFolder(),SpamFolder:b.spamFolder(),TrashFolder:b.trashFolder()})},1E3);l=function(){e.settingsSet("SentFolder",
b.sentFolder());e.settingsSet("DraftFolder",b.draftFolder());e.settingsSet("SpamFolder",b.spamFolder());e.settingsSet("TrashFolder",b.trashFolder());d()};this.sentFolder.subscribe(l);this.draftFolder.subscribe(l);this.spamFolder.subscribe(l);this.trashFolder.subscribe(l);this.defautOptionsAfterRender=c.defautOptionsAfterRender}function y(){C.call(this,"Popups","PopupsCompose");this.aDraftInfo=this.oEditor=null;this.sInReplyTo="";this.bFromDraft=!1;this.sReferences="";this.bReloadFolder=!1;var a=this,
b=function(a){for(var b=0,d=a.length,c=[];b<d;b++)c.push(a[b].toLine(!1));return c.join(", ")},d=function(a){!1===this.showCcAndBcc()&&0<a.length&&this.showCcAndBcc(!0)};this.resizer=f.observable(!1).extend({throttle:50});this.to=f.observableArray([]);this.cc=f.observableArray([]);this.bcc=f.observableArray([]);this.subject=f.observable("");this.sendError=f.observable(!1);this.sendSuccessButSaveError=f.observable(!1);this.savedError=f.observable(!1);this.savedTime=f.observable(0);this.savedOrSendingText=
f.observable("");this.emptyToError=f.observable(!1);this.showCcAndBcc=f.observable(!1);this.cc.subscribe(d,this);this.bcc.subscribe(d,this);this.draftFolder=f.observable("");this.draftUid=f.observable("");this.sending=f.observable(!1);this.saving=f.observable(!1);this.attachments=f.observableArray([]);this.attachmentsInProcess=f.computed(function(){return i.filter(this.attachments(),function(a){return a&&""===a.tempName()})},this);this.attachmentsInReady=f.computed(function(){return i.filter(this.attachments(),
function(a){return a&&""!==a.tempName()})},this);this.attachments.subscribe(function(){this.triggerForResize()},this);this.isDraftFolderMessage=f.computed(function(){return""!==this.draftFolder()&&""!==this.draftUid()},this);this.composeUploaderButton=f.observable(null);this.composeUploaderDropPlace=f.observable(null);this.dragAndDropEnabled=f.observable(!1);this.dragAndDropOver=f.observable(!1).extend({throttle:1});this.dragAndDropVisible=f.observable(!1).extend({throttle:1});this.attacheMultipleAllowed=
f.observable(!1);this.addAttachmentEnabled=f.observable(!1);this.composeEditorTextArea=f.observable(null);this.composeEditorHtmlArea=f.observable(null);this.composeEditorToolbar=f.observable(null);this.to.subscribe(function(a){this.emptyToError()&&0<a.length&&this.emptyToError(!1)},this);this.canBeSended=f.computed(function(){return!this.sending()&&!this.saving()&&0===this.attachmentsInProcess().length&&0<this.to().length},this);this.canBeSendedOrSaved=f.computed(function(){return!this.sending()&&
!this.saving()},this);this.deleteCommand=c.createCommand(this,function(){var a=null,b=this.draftFolder(),d=this.draftUid();this.bFromDraft&&(a=e.data().message())&&(b===a.folderFullNameRaw&&d===a.uid)&&e.data().message(null);e.data().currentFolderFullNameRaw()===this.draftFolder()&&i.each(e.data().messageList(),function(a){a&&(b===a.folderFullNameRaw&&d===a.uid)&&a.deleted(true)});e.data().messageListIsNotCompleted(!0);e.remote().messagesDelete(function(){e.cache().setFolderHash(b,"");e.reloadMessageList()},
this.draftFolder(),[this.draftUid()]);this.bReloadFolder=!1;s.hideScreenPopup(y)},function(){return this.isDraftFolderMessage()});this.sendMessageResponse=i.bind(this.sendMessageResponse,this);this.saveMessageResponse=i.bind(this.saveMessageResponse,this);this.sendCommand=c.createCommand(this,function(){var a=this.to(),d=e.data().sentFolder(),f=[];if(0===a.length)this.emptyToError(!0);else if(e.data().replySameFolder()&&c.isArray(this.aDraftInfo)&&(3===this.aDraftInfo.length&&c.isNormal(this.aDraftInfo[2])&&
0<this.aDraftInfo[2].length)&&(d=this.aDraftInfo[2]),""===d)s.showScreenPopup(X,[g.SetSystemFoldersNotification.Sent]);else{this.sendError(!1);this.sending(!0);this.bReloadFolder=!0;if(c.isArray(this.aDraftInfo)&&3===this.aDraftInfo.length&&(f=e.cache().getMessageFlagsFromCache(this.aDraftInfo[2],this.aDraftInfo[1])))"forward"===this.aDraftInfo[0]?f[3]=!0:f[2]=!0,e.cache().setMessageFlagsToCache(this.aDraftInfo[2],this.aDraftInfo[1],f),e.reloadFlagsCurrentMessageListAndMessageFromCache();d=t.Values.UnuseOptionValue===
d?"":d;e.cache().setFolderHash(this.draftFolder(),"");e.cache().setFolderHash(d,"");e.remote().sendMessage(this.sendMessageResponse,this.draftFolder(),this.draftUid(),d,b(a),b(this.cc()),b(this.bcc()),this.subject(),this.oEditor.isHtml(),this.oEditor.getTextForRequest(),this.prepearAttachmentsForSendOrSave(),this.aDraftInfo,this.sInReplyTo,this.sReferences)}},this.canBeSendedOrSaved);this.saveCommand=c.createCommand(this,function(){e.data().draftFolderNotEnabled()?s.showScreenPopup(X,[g.SetSystemFoldersNotification.Draft]):
(this.savedError(!1),this.saving(!0),this.bReloadFolder=!0,e.cache().setFolderHash(e.data().draftFolder(),""),e.remote().saveMessage(this.saveMessageResponse,this.draftFolder(),this.draftUid(),e.data().draftFolder(),b(this.to()),b(this.cc()),b(this.bcc()),this.subject(),this.oEditor.isHtml(),this.oEditor.getTextForRequest(),this.prepearAttachmentsForSendOrSave(),this.aDraftInfo,this.sInReplyTo,this.sReferences))},this.canBeSendedOrSaved);xa.subscribe(function(){this.modalVisibility()&&(!e.data().draftFolderNotEnabled()&&
!this.isEmptyForm(!1)&&!this.saving()&&!this.sending()&&!this.savedError())&&this.saveCommand()},this);c.initOnStartOrLangChange(null,this,function(){this.oEditor&&this.oEditor.initLanguage(c.i18n("EDITOR/TEXT_SWITCHER_CONFIRM"),c.i18n("EDITOR/TEXT_SWITCHER_PLAINT_TEXT"),c.i18n("EDITOR/TEXT_SWITCHER_RICH_FORMATTING"))});this.showCcAndBcc.subscribe(function(){this.triggerForResize()},this);this.dropboxEnabled=f.observable(e.settingsGet("DropboxApiKey")?!0:!1);this.dropboxCommand=c.createCommand(this,
function(){Dropbox.choose({success:function(b){b&&(b[0]&&b[0].link)&&a.addDropboxAttachment(b[0])},linkType:"direct",multiselect:!1});return!0},function(){return this.dropboxEnabled()});this.modalVisibility.subscribe(function(a){!a&&this.bReloadFolder&&(this.bReloadFolder=!1,e.reloadMessageList())},this);this.driveEnabled=f.observable(!1);this.driveCommand=c.createCommand(this,function(){return!0},function(){return this.driveEnabled()})}function L(){C.call(this,"Popups","PopupsContacts");var a=this;
this.imageUploader=f.observable(null);this.imageDom=f.observable(null);this.imageTrigger=f.observable(!1);this.search=f.observable("");this.contacts=f.observableArray([]);this.contacts.loading=f.observable(!1).extend({throttle:200});this.currentContact=f.observable(null);this.emptySelection=f.observable(!0);this.viewClearSearch=f.observable(!1);this.viewID=f.observable("");this.viewName=f.observable("");this.viewName.focused=f.observable(!1);this.viewEmail=f.observable("").validateEmail();this.viewEmail.focused=
f.observable(!1);this.viewImageUrl=f.observable(e.link().emptyContactPic());this.viewSaving=f.observable(!1);this.useCheckboxesInList=e.data().useCheckboxesInList;this.search.subscribe(function(){this.reloadContactList()},this);this.contacts.subscribe(function(){c.windowResize()},this);this.viewImageUrl.subscribe(function(a){this.imageDom().src=a},this);this.contactsChecked=f.computed(function(){return i.filter(this.contacts(),function(a){return a.checked()})},this);this.contactsCheckedOrSelected=
f.computed(function(){var a=this.contactsChecked(),d=this.currentContact();return i.union(a,d?[d]:[])},this);this.contactsCheckedOrSelectedUids=f.computed(function(){return i.map(this.contactsCheckedOrSelected(),function(a){return a.idContact})},this);this.newCommand=c.createCommand(this,function(){this.populateViewContact(null)});this.selector=new K(this.contacts,this.currentContact,".e-contact-item .actionHandle",".e-contact-item.selected",".e-contact-item .checkboxItem");this.selector.on("onItemSelect",
i.bind(function(a){this.populateViewContact(a?a:null)},this));this.selector.on("onItemGetUid",function(a){return a?a.generateUid():""});this.selector.on("onDelete",i.bind(function(){this.deleteCommand()},this));this.newCommand=c.createCommand(this,function(){this.populateViewContact(null);this.currentContact(null)});this.deleteCommand=c.createCommand(this,function(){this.deleteSelectedContacts()},function(){return 0<this.contactsCheckedOrSelected().length});this.newMessageCommand=c.createCommand(this,
function(){var a=this.contactsCheckedOrSelected(),d=[];c.isNonEmptyArray(a)&&(d=i.map(a,function(a){return a&&a.emails&&(a=new F(a.emails[0]||"",a.name),a.validate())?a:null}),d=i.compact(d));c.isNonEmptyArray(a)&&(s.hideScreenPopup(L),s.showScreenPopup(y,[g.ComposeType.Empty,null,d]))},function(){return 0<this.contactsCheckedOrSelected().length});this.clearCommand=c.createCommand(this,function(){this.search("")});this.saveCommand=c.createCommand(this,function(){var b=c.fakeMd5(),d=this.imageTrigger();
this.viewSaving(!0);e.remote().contactSave(function(l,f){a.viewSaving(!1);g.StorageResultType.Success===l&&(f&&f.Result&&f.Result.RequestUid===b&&0<c.pInt(f.Result.ResultID))&&(""===a.viewID()&&a.viewID(c.pInt(f.Result.ResultID)),a.reloadContactList(),d&&e.emailsPicsHashes())},b,this.viewID(),this.viewName(),this.viewEmail(),d?this.imageDom().src:"")},function(){var a=this.viewName(),d=this.viewEmail();return!this.viewSaving()&&(""!==a||""!==d)})}function ca(){C.call(this,"Popups","PopupsAdvancedSearch");
this.fromFocus=f.observable(!1);this.from=f.observable("");this.to=f.observable("");this.subject=f.observable("");this.text=f.observable("");this.selectedDateValue=f.observable(-1);this.hasAttachments=f.observable(!1);this.searchCommand=c.createCommand(this,function(){var a=this.buildSearchString();""!==a&&e.data().mainMessageListSearch(a);this.cancelCommand()})}function da(){C.call(this,"Popups","PopupsAddAccount");this.email=f.observable("");this.login=f.observable("");this.password=f.observable("");
this.emailError=f.observable(!1);this.loginError=f.observable(!1);this.passwordError=f.observable(!1);this.email.subscribe(function(){this.emailError(!1)},this);this.login.subscribe(function(){this.loginError(!1)},this);this.password.subscribe(function(){this.passwordError(!1)},this);this.allowCustomLogin=f.observable(!1);this.submitRequest=f.observable(!1);this.submitError=f.observable("");this.emailFocus=f.observable(!1);this.loginFocus=f.observable(!1);this.addAccountCommand=c.createCommand(this,
function(){this.emailError(""===c.trim(this.email()));this.passwordError(""===c.trim(this.password()));if(this.emailError()||this.passwordError())return!1;this.submitRequest(!0);e.remote().accountAdd(i.bind(function(a,b){this.submitRequest(!1);g.StorageResultType.Success===a&&b&&"AccountAdd"===b.Action?b.Result?(e.accounts(),this.cancelCommand()):b.ErrorCode&&this.submitError(c.getNotification(b.ErrorCode)):this.submitError(c.getNotification(g.Notification.UnknownError))},this),this.email(),this.login(),
this.password());return!0},function(){return!this.submitRequest()});this.loginFocus.subscribe(function(a){a&&(""===this.login()&&""!==this.email())&&this.login(this.email())},this)}function la(){C.call(this,"Right","Login");this.email=f.observable("");this.login=f.observable("");this.password=f.observable("");this.signMe=f.observable(!1);this.logoMain=f.observable("RainLoop");this.emailError=f.observable(!1);this.loginError=f.observable(!1);this.passwordError=f.observable(!1);this.emailFocus=f.observable(!1);
this.loginFocus=f.observable(!1);this.submitFocus=f.observable(!1);this.email.subscribe(function(){this.emailError(!1)},this);this.login.subscribe(function(){this.loginError(!1)},this);this.password.subscribe(function(){this.passwordError(!1)},this);this.allowCustomLogin=f.observable(!1);this.submitRequest=f.observable(!1);this.submitError=f.observable("");this.signMeType=f.observable(g.LoginSignMeType.Unused);this.signMeType.subscribe(function(a){this.signMe(g.LoginSignMeType.DefaultOn===a)},this);
this.signMeVisibility=f.computed(function(){return g.LoginSignMeType.Unused!==this.signMeType()},this);this.submitCommand=c.createCommand(this,function(){this.emailError(""===c.trim(this.email()));this.passwordError(""===c.trim(this.password()));if(this.emailError()||this.passwordError())return!1;this.submitRequest(!0);e.remote().login(i.bind(function(a,b){g.StorageResultType.Success===a&&b&&"Login"===b.Action?b.Result?e.loginAndLogoutReload():b.ErrorCode?(this.submitRequest(!1),this.submitError(c.getNotification(b.ErrorCode))):
this.submitRequest(!1):(this.submitRequest(!1),this.submitError(c.getNotification(g.Notification.UnknownError)))},this),this.email(),this.login(),this.password(),!!this.signMe());return!0},function(){return!this.submitRequest()});this.facebookLoginEnabled=f.observable(!1);this.facebookCommand=c.createCommand(this,function(){h.open(e.link().socialFacebook(),"Facebook","left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes");return!0},function(){return!this.submitRequest()&&
this.facebookLoginEnabled()});this.googleLoginEnabled=f.observable(!1);this.googleCommand=c.createCommand(this,function(){h.open(e.link().socialGoogle(),"Google","left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes");return!0},function(){return!this.submitRequest()&&this.googleLoginEnabled()});this.twitterLoginEnabled=f.observable(!1);this.twitterCommand=c.createCommand(this,function(){h.open(e.link().socialTwitter(),"Twitter","left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes");
return!0},function(){return!this.submitRequest()&&this.twitterLoginEnabled()});this.loginFocus.subscribe(function(a){a&&(""===this.login()&&""!==this.email())&&this.login(this.email())},this)}function Q(){C.call(this,"Right","SystemDropDown");var a=e.data();this.accounts=a.accounts;this.accountEmail=a.accountEmail;this.accountsLoading=a.accountsLoading;this.allowAddAccount=e.settingsGet("AllowAdditionalAccounts");this.loading=f.computed(function(){return this.accountsLoading()},this);this.accountClick=
i.bind(this.accountClick,this)}function Ya(){Q.call(this)}function Za(){Q.call(this)}function ea(){C.call(this,"Left","MailFolderList");this.folderList=e.data().folderList;this.folderListSystem=e.data().folderListSystem;this.allowContacts=!!e.settingsGet("ContactsIsSupported")}function z(){C.call(this,"Right","MailMessageList");this.sLastUid=null;this.emptySubjectValue="";var a=e.data();this.popupVisibility=e.popupVisibility;this.messageList=a.messageList;this.currentMessage=a.currentMessage;this.isMessageSelected=
a.isMessageSelected;this.messageListSearch=a.messageListSearch;this.messageListError=a.messageListError;this.folderMenuForMove=a.folderMenuForMove;this.useCheckboxesInList=a.useCheckboxesInList;this.mainMessageListSearch=a.mainMessageListSearch;this.messageListEndFolder=a.messageListEndFolder;this.messageListChecked=a.messageListChecked;this.messageListCheckedOrSelected=a.messageListCheckedOrSelected;this.messageListCheckedOrSelectedUidsWithSubMails=a.messageListCheckedOrSelectedUidsWithSubMails;
this.messageListCompleteLoadingThrottle=a.messageListCompleteLoadingThrottle;c.initOnStartOrLangChange(function(){this.emptySubjectValue=c.i18n("MESSAGE_LIST/EMPTY_SUBJECT_TEXT")},this);this.userQuota=a.userQuota;this.userUsageSize=a.userUsageSize;this.userUsageProc=a.userUsageProc;this.dragOver=f.observable(!1).extend({throttle:1});this.dragOverEnter=f.observable(!1).extend({throttle:1});this.dragOverArea=f.observable(null);this.dragOverBodyArea=f.observable(null);this.messageListItemTemplate=f.computed(function(){return a.usePreviewPane()?
"MailMessageListItem":"MailMessageListItemNoPreviewPane"});this.messageListSearchDesc=f.computed(function(){var b=a.messageListEndSearch();return""===b?"":c.i18n("MESSAGE_LIST/SEARCH_RESULT_FOR",{SEARCH:b})});this.messageListPagenator=f.computed(function(){var b=0,d=0,l=2,e=[],f=a.messageListPage(),g=a.messageListPageCount(),k=function(a,b,d){a={current:a===f,name:c.isUnd(d)?a.toString():d.toString(),custom:c.isUnd(d)?!1:!0,title:c.isUnd(d)?"":a.toString(),value:a.toString()};c.isUnd(b)||b?e.push(a):
e.unshift(a)};if(1<g||0<g&&g<f){if(g<f)k(g),d=b=g;else{if(3>=f||g-2<=f)l+=2;k(f);d=b=f}for(;0<l;)if(b-=1,d+=1,0<b&&(k(b,!1),l--),g>=d)k(d,!0),l--;else if(0>=b)break;3===b?k(2,!1):3<b&&k(Math.round((b-1)/2),!1,"...");g-2===d?k(g-1,!0):g-2>d&&k(Math.round((g+d)/2),!0,"...");1<b&&k(1,!1);g>d&&k(g,!0)}return e},this);this.checkAll=f.computed({read:function(){return 0<e.data().messageListCheckedOrSelected().length},write:function(a){a=!!a;i.each(e.data().messageList(),function(d){d.checked(a)});a||e.data().message(null)}});
this.inputMessageListSearchFocus=f.observable(!1);this.sLastSearchValue="";this.inputProxyMessageListSearch=f.computed({read:this.mainMessageListSearch,write:function(a){this.sLastSearchValue=a},owner:this});this.isIncompleteChecked=f.computed(function(){var a=e.data().messageList().length,d=e.data().messageListCheckedOrSelected().length;return 0<a&&0<d&&a>d},this);this.hasMessages=f.computed(function(){return 0<this.messageList().length},this);this.hasCheckedLines=f.computed(function(){return 0<
this.messageListChecked().length},this);this.hasCheckedOrSelectedLines=f.computed(function(){return 0<this.messageListCheckedOrSelected().length},this);this.isSpamFolder=f.computed(function(){return e.data().spamFolder()===this.messageListEndFolder()},this);this.isTrashFolder=f.computed(function(){return e.data().trashFolder()===this.messageListEndFolder()},this);this.canBeMoved=this.hasCheckedOrSelectedLines;this.clearCommand=c.createCommand(this,function(){s.showScreenPopup(wa,[e.data().currentFolder()])});
this.multyForwardCommand=c.createCommand(this,function(){s.showScreenPopup(y,[g.ComposeType.ForwardAsAttachment,e.data().messageListCheckedOrSelected()])},this.canBeMoved);this.deleteWithoutMoveCommand=c.createCommand(this,function(){this.deleteSelectedMessageFromCurrentFolder(g.FolderType.Trash,!1)},this.canBeMoved);this.deleteCommand=c.createCommand(this,function(){this.deleteSelectedMessageFromCurrentFolder(g.FolderType.Trash,!0)},this.canBeMoved);this.spamCommand=c.createCommand(this,function(){this.deleteSelectedMessageFromCurrentFolder(g.FolderType.Spam,
!0)},this.canBeMoved);this.moveCommand=c.createCommand(this,c.emptyFunction,this.canBeMoved);this.setCommand=c.createCommand(this,c.emptyFunction,this.hasCheckedLines);this.checkCommand=c.createCommand(this,c.emptyFunction,this.hasCheckedLines);this.reloadCommand=c.createCommand(this,function(){e.data().messageListCompleteLoadingThrottle()||e.reloadMessageList(!1,!0)});this.quotaTooltip=i.bind(this.quotaTooltip,this);this.selector=new K(this.messageList,this.currentMessage,".messageListItem .actionHandle",
".messageListItem.selected",".messageListItem .checkboxMessage");this.selector.on("onItemSelect",i.bind(function(b){b?(a.message(a.staticMessageList.populateByMessageListItem(b)),this.populateMessageBody(a.message())):a.message(null)},this));this.selector.on("onItemGetUid",function(a){return a?a.generateUid():""});this.selector.on("onDelete",i.bind(function(){0<e.data().messageListCheckedOrSelected().length&&this.deleteCommand()},this))}function H(){C.call(this,"Right","MailMessageView");var a="",
b=e.data(),d=this,l=function(a){return c.createCommand(d,function(){this.replyOrforward(a)},d.canBeRepliedOrForwarded)};this.oMessageScrollerDom=null;this.message=b.message;this.messageLoading=b.messageLoading;this.messageLoadingThrottle=b.messageLoadingThrottle;this.messagesBodiesDom=b.messagesBodiesDom;this.useThreads=b.useThreads;this.replySameFolder=b.replySameFolder;this.usePreviewPane=b.usePreviewPane;this.isMessageSelected=b.isMessageSelected;this.messageActiveDom=b.messageActiveDom;this.messageError=
b.messageError;this.fullScreenMode=b.messageFullScreenMode;this.showFullInfo=f.observable(!1);this.canBeRepliedOrForwarded=this.messageVisibility=f.computed(function(){return!this.messageLoadingThrottle()&&!!this.message()},this);this.closeMessage=c.createCommand(this,function(){b.message(null)});this.replyCommand=l(g.ComposeType.Reply);this.replyAllCommand=l(g.ComposeType.ReplyAll);this.forwardCommand=l(g.ComposeType.Forward);this.forwardAsAttachmentCommand=l(g.ComposeType.ForwardAsAttachment);this.messageVisibilityCommand=
c.createCommand(this,c.emptyFunction,this.messageVisibility);this.viewSubject=f.observable("");this.viewFromShort=f.observable("");this.viewToShort=f.observable("");this.viewFrom=f.observable("");this.viewTo=f.observable("");this.viewCc=f.observable("");this.viewBcc=f.observable("");this.viewDate=f.observable("");this.viewMoment=f.observable("");this.viewLineAsCcc=f.observable("");this.viewHasImages=f.observable(!1);this.viewHasVisibleAttachments=f.observable(!1);this.viewAttachments=f.observableArray([]);
this.viewIsHtml=f.observable(!1);this.viewViewLink=f.observable("");this.viewDownloadLink=f.observable("");this.viewUserPic=f.observable(t.DataImages.UserDotPic);this.viewUserPicVisible=f.observable(!1);this.message.subscribe(function(b){this.messageActiveDom(null);b&&(this.viewSubject(b.subject()),this.viewFromShort(b.fromToLine(!0,!0)),this.viewToShort(b.toToLine(!0,!0)),this.viewFrom(b.fromToLine(!1)),this.viewTo(b.toToLine(!1)),this.viewCc(b.ccToLine(!1)),this.viewBcc(b.bccToLine(!1)),this.viewDate(b.fullFormatDateValue()),
this.viewMoment(b.momentDate()),this.viewLineAsCcc(b.lineAsCcc()),this.viewHasImages(b.hasImages()),this.viewHasVisibleAttachments(b.hasVisibleAttachments()),this.viewAttachments(b.attachments()),this.viewIsHtml(b.isHtml()),this.viewViewLink(b.viewLink()),this.viewDownloadLink(b.downloadLink()),a=e.cache().getUserPic(b.fromAsSingleEmail()),a!==this.viewUserPic()&&(this.viewUserPicVisible(!1),this.viewUserPic(t.DataImages.UserDotPic),""!==a&&(this.viewUserPicVisible(!0),this.viewUserPic(a))))},this);
this.fullScreenMode.subscribe(function(a){a?Y.addClass("rl-message-fullscreen"):Y.removeClass("rl-message-fullscreen")});this.messageActiveDom.subscribe(function(){this.scrollMessageToTop();c.windowResize()},this)}function ya(a){C.call(this,"Left","SettingsMenu");this.menu=a.menu}function za(){C.call(this,"Right","SettingsPane")}function Ma(){var a=e.data();this.mainLanguage=a.mainLanguage;this.mainMessagesPerPage=a.mainMessagesPerPage;this.editorDefaultType=a.editorDefaultType;this.showImages=a.showImages;
this.showAnimation=a.showAnimation;this.useDesktopNotifications=a.useDesktopNotifications;this.useThreads=a.useThreads;this.replySameFolder=a.replySameFolder;this.usePreviewPane=a.usePreviewPane;this.useCheckboxesInList=a.useCheckboxesInList;this.languagesOptions=f.computed(function(){return i.map(a.languages(),function(a){return{optValue:a,optText:c.convertLangName(a)}})});this.isDesctopNotificationsSupported=f.computed(function(){return g.DesctopNotifications.NotSupported!==a.desktopNotificationsPermisions()});
this.isDesctopNotificationsDenied=f.computed(function(){return g.DesctopNotifications.NotSupported===a.desktopNotificationsPermisions()||g.DesctopNotifications.Denied===a.desktopNotificationsPermisions()});this.languageTrigger=f.observable(g.SaveSettingsStep.Idle).extend({throttle:100});this.mppTrigger=f.observable(g.SaveSettingsStep.Idle)}function $a(){var a=e.data();this.displayName=a.displayName;this.replyTo=a.replyTo;this.signature=a.signature;this.nameTrigger=f.observable(g.SaveSettingsStep.Idle);
this.replyTrigger=f.observable(g.SaveSettingsStep.Idle);this.signatureTrigger=f.observable(g.SaveSettingsStep.Idle)}function ma(){this.accounts=e.data().accounts;this.processText=f.computed(function(){return e.data().accountsLoading()?c.i18n("SETTINGS_ACCOUNTS/LOADING_PROCESS"):""},this);this.visibility=f.computed(function(){return""===this.processText()?"hidden":"visible"},this);this.accountForDeletion=f.observable(null).extend({falseTimeout:3E3}).extend({toggleSubscribe:[this,function(a){a&&a.deleteAccess(!1)},
function(a){a&&a.deleteAccess(!0)}]})}function Na(){var a=e.data();this.googleEnable=a.googleEnable;this.googleActions=a.googleActions;this.googleLoggined=a.googleLoggined;this.googleUserName=a.googleUserName;this.facebookEnable=a.facebookEnable;this.facebookActions=a.facebookActions;this.facebookLoggined=a.facebookLoggined;this.facebookUserName=a.facebookUserName;this.twitterEnable=a.twitterEnable;this.twitterActions=a.twitterActions;this.twitterLoggined=a.twitterLoggined;this.twitterUserName=a.twitterUserName;
this.connectGoogle=c.createCommand(this,function(){this.googleLoggined()||e.googleConnect()},function(){return!this.googleLoggined()&&!this.googleActions()});this.disconnectGoogle=c.createCommand(this,function(){e.googleDisconnect()});this.connectFacebook=c.createCommand(this,function(){this.facebookLoggined()||e.facebookConnect()},function(){return!this.facebookLoggined()&&!this.facebookActions()});this.disconnectFacebook=c.createCommand(this,function(){e.facebookDisconnect()});this.connectTwitter=
c.createCommand(this,function(){this.twitterLoggined()||e.twitterConnect()},function(){return!this.twitterLoggined()&&!this.twitterActions()});this.disconnectTwitter=c.createCommand(this,function(){e.twitterDisconnect()})}function na(){this.changeProcess=f.observable(!1);this.passwordUpdateError=f.observable(!1);this.passwordUpdateSuccess=f.observable(!1);this.currentPassword=f.observable("");this.newPassword=f.observable("");this.currentPassword.subscribe(function(){this.passwordUpdateError(!1);
this.passwordUpdateSuccess(!1)},this);this.newPassword.subscribe(function(){this.passwordUpdateError(!1);this.passwordUpdateSuccess(!1)},this);this.saveNewPasswordCommand=c.createCommand(this,function(){this.changeProcess(!0);this.passwordUpdateError(!1);this.passwordUpdateSuccess(!1);e.remote().changePassword(this.onChangePasswordResponse,this.currentPassword(),this.newPassword())},function(){return!this.changeProcess()&&""!==this.currentPassword()&&""!==this.newPassword()});this.onChangePasswordResponse=
i.bind(this.onChangePasswordResponse,this)}function R(){var a=e.data();this.ignoreFolderSubscribe=a.ignoreFolderSubscribe;this.foldersListError=a.foldersListError;this.folderList=a.folderList;this.processText=f.computed(function(){var a=e.data(),d=a.foldersLoading(),l=a.foldersCreating(),f=a.foldersDeleting(),a=a.foldersRenaming();return l?c.i18n("SETTINGS_FOLDERS/CREATING_PROCESS"):f?c.i18n("SETTINGS_FOLDERS/DELETING_PROCESS"):a?c.i18n("SETTINGS_FOLDERS/RENAMING_PROCESS"):d?c.i18n("SETTINGS_FOLDERS/LOADING_PROCESS"):
""},this);this.visibility=f.computed(function(){return""===this.processText()?"hidden":"visible"},this);this.folderForDeletion=f.observable(null).extend({falseTimeout:3E3}).extend({toggleSubscribe:[this,function(a){a&&a.deleteAccess(!1)},function(a){a&&a.deleteAccess(!0)}]});this.folderForEdit=f.observable(null).extend({toggleSubscribe:[this,function(a){a&&a.edited(!1)},function(a){a&&a.canBeEdited()&&a.edited(!0)}]})}function Aa(){var a=this;this.mainTheme=e.data().mainTheme;this.customThemeType=
f.observable(e.settingsGet("CustomThemeType"));this.customThemeImg=f.observable(e.settingsGet("CustomThemeImg"));this.themesObjects=f.observableArray([]);this.customThemeUploaderProgress=f.observable(!1);this.customThemeUploaderButton=f.observable(null);this.showCustomThemeConfig=f.computed(function(){return"Custom"===this.mainTheme()},this);this.showCustomThemeConfig.subscribe(function(){c.windowResize()});this.themeTrigger=f.observable(g.SaveSettingsStep.Idle).extend({throttle:100});this.oLastAjax=
null;this.iTimer=0;e.data().theme.subscribe(function(b){i.each(this.themesObjects(),function(a){a.selected(b===a.name)});var d=j("#rlThemeLink"),l=j("#rlThemeStyle"),f=d.attr("href");f||(f=l.attr("data-href"));f&&(f=f.toString().replace(/\/-\/[^\/]+\/\-\//,"/-/"+b+"/-/"),f=f.toString().replace(/\/Css\/[^\/]+\/User\//,"/Css/"+("Custom"===b&&h.__rlah?h.__rlah()||"0":"0")+"/User/"),"Json/"!==f.substring(f.length-5,f.length)&&(f+="Json/"),h.clearTimeout(a.iTimer),a.themeTrigger(g.SaveSettingsStep.Animate),
this.oLastAjax&&this.oLastAjax.abort&&this.oLastAjax.abort(),this.oLastAjax=j.ajax({url:f,dataType:"json"}).done(function(b){if(b&&c.isArray(b)&&2===b.length){if(d&&d[0]&&(!l||!l[0]))l=j('<style id="rlThemeStyle"></style>'),d.after(l),d.remove();l&&l[0]&&l.attr("data-href",f).attr("data-theme",b[0]).text(b[1]);a.themeTrigger(g.SaveSettingsStep.TrueResult)}}).always(function(){a.iTimer=h.setTimeout(function(){a.themeTrigger(g.SaveSettingsStep.Idle)},1E3);a.oLastAjax=null}));e.remote().saveSettings(null,
{Theme:b})},this)}function Oa(){c.initDataConstructorBySettings(this)}function S(){c.initDataConstructorBySettings(this);var a=function(a){return function(){var b=e.cache().getFolderFromCacheList(a());b&&b.type(g.FolderType.User)}},b=function(a){return function(b){(b=e.cache().getFolderFromCacheList(b))&&b.type(a)}};this.devPassword=this.devLogin=this.devEmail="";this.accountEmail=f.observable("");this.accountLogin=f.observable("");this.projectHash=f.observable("");this.threading=!1;this.lastFoldersHash=
"";this.remoteChangePassword=this.remoteSuggestions=!1;this.sentFolder=f.observable("");this.draftFolder=f.observable("");this.spamFolder=f.observable("");this.trashFolder=f.observable("");this.sentFolder.subscribe(a(this.sentFolder),this,"beforeChange");this.draftFolder.subscribe(a(this.draftFolder),this,"beforeChange");this.spamFolder.subscribe(a(this.spamFolder),this,"beforeChange");this.trashFolder.subscribe(a(this.trashFolder),this,"beforeChange");this.sentFolder.subscribe(b(g.FolderType.SentItems),
this);this.draftFolder.subscribe(b(g.FolderType.Draft),this);this.spamFolder.subscribe(b(g.FolderType.Spam),this);this.trashFolder.subscribe(b(g.FolderType.Trash),this);this.draftFolderNotEnabled=f.computed(function(){return""===this.draftFolder()||t.Values.UnuseOptionValue===this.draftFolder()},this);this.displayName=f.observable("");this.signature=f.observable("");this.replyTo=f.observable("");this.accounts=f.observableArray([]);this.accountsLoading=f.observable(!1);this.namespace="";this.folderList=
f.observableArray([]);this.foldersListError=f.observable("");this.foldersLoading=f.observable(!1);this.foldersCreating=f.observable(!1);this.foldersDeleting=f.observable(!1);this.foldersRenaming=f.observable(!1);this.currentFolder=f.observable(null).extend({toggleSubscribe:[null,function(a){a&&a.selected(!1)},function(a){a&&a.selected(!0)}]});this.currentFolderFullNameRaw=f.computed(function(){return this.currentFolder()?this.currentFolder().fullNameRaw:""},this);this.currentFolderFullName=f.computed(function(){return this.currentFolder()?
this.currentFolder().fullName:""},this);this.currentFolderFullNameHash=f.computed(function(){return this.currentFolder()?this.currentFolder().fullNameHash:""},this);this.currentFolderName=f.computed(function(){return this.currentFolder()?this.currentFolder().name():""},this);this.folderListSystemNames=f.computed(function(){var a=["INBOX"],b=this.folderList(),e=this.sentFolder(),f=this.draftFolder(),g=this.spamFolder(),k=this.trashFolder();c.isArray(b)&&0<b.length&&(""!==e&&t.Values.UnuseOptionValue!==
e&&a.push(e),""!==f&&t.Values.UnuseOptionValue!==f&&a.push(f),""!==g&&t.Values.UnuseOptionValue!==g&&a.push(g),""!==k&&t.Values.UnuseOptionValue!==k&&a.push(k));return a},this);this.folderListSystem=f.computed(function(){return i.compact(i.map(this.folderListSystemNames(),function(a){return e.cache().getFolderFromCacheList(a)}))},this);this.folderMenuForMove=f.computed(function(){return e.folderListOptionsBuilder(this.folderListSystem(),this.folderList(),[this.currentFolderFullNameRaw()],null,null,
null,null,function(a){return a?a.localName():""})},this);this.staticMessageList=[];this.messageList=f.observableArray([]);this.messageListCount=f.observable(0);this.messageListSearch=f.observable("");this.messageListPage=f.observable(1);this.messageListThreadFolder=f.observable("");this.messageListThreadUids=f.observableArray([]);this.messageListThreadFolder.subscribe(function(){this.messageListThreadUids([])},this);this.messageListEndSearch=f.observable("");this.messageListEndFolder=f.observable("");
this.messageListPageCount=f.computed(function(){var a=Math.ceil(this.messageListCount()/this.messagesPerPage());return 0===a?1:a},this);this.mainMessageListSearch=f.computed({read:this.messageListSearch,write:function(a){s.setHash(e.link().mailBox(this.currentFolderFullNameHash(),1,c.trim(a.toString())))},owner:this});this.messageListError=f.observable("");this.messageListLoading=f.observable(!1);this.messageListIsNotCompleted=f.observable(!1);this.messageListCompleteLoadingThrottle=f.observable(!1).extend({throttle:200});
this.messageListCompleteLoading=f.computed(function(){var a=this.messageListLoading(),b=this.messageListIsNotCompleted();return a||b},this);this.messageListCompleteLoading.subscribe(function(a){this.messageListCompleteLoadingThrottle(a)},this);this.messageList.subscribe(i.debounce(function(a){i.each(a,function(a){a.newForAnimation()&&a.newForAnimation(!1)})},500));this.staticMessageList=new m;this.message=f.observable(null);this.messageLoading=f.observable(!1);this.messageLoadingThrottle=f.observable(!1).extend({throttle:50});
this.messageLoading.subscribe(function(a){this.messageLoadingThrottle(a)},this);this.messageFullScreenMode=f.observable(!1);this.messageError=f.observable("");this.messagesBodiesDom=f.observable(null);this.messagesBodiesDom.subscribe(function(a){a&&!(a instanceof jQuery)&&this.messagesBodiesDom(j(a))},this);this.messageActiveDom=f.observable(null);this.isMessageSelected=f.computed(function(){return null!==this.message()},this);this.currentMessage=f.observable(null);this.message.subscribe(function(a){null===
a&&this.currentMessage(null)},this);this.messageListChecked=f.computed(function(){return i.filter(this.messageList(),function(a){return a.checked()})},this);this.messageListCheckedOrSelected=f.computed(function(){var a=this.messageListChecked(),b=this.currentMessage();return i.union(a,b?[b]:[])},this);this.messageListCheckedUids=f.computed(function(){var a=[];i.each(this.messageListChecked(),function(b){b&&(a.push(b.uid),0<b.threadsLen()&&(0===b.parentUid()&&b.lastInCollapsedThread())&&(a=i.union(a,
b.threads())))});return a},this);this.messageListCheckedOrSelectedUidsWithSubMails=f.computed(function(){var a=[];i.each(this.messageListCheckedOrSelected(),function(b){b&&(a.push(b.uid),0<b.threadsLen()&&(0===b.parentUid()&&b.lastInCollapsedThread())&&(a=i.union(a,b.threads())))});return a},this);this.userQuota=f.observable(0);this.userUsageSize=f.observable(0);this.userUsageProc=f.computed(function(){var a=this.userQuota(),b=this.userUsageSize();return 0<a?Math.ceil(100*(b/a)):0},this);this.useKeyboardShortcuts=
f.observable(!0);this.googleActions=f.observable(!1);this.googleLoggined=f.observable(!1);this.googleUserName=f.observable("");this.facebookActions=f.observable(!1);this.facebookLoggined=f.observable(!1);this.facebookUserName=f.observable("");this.twitterActions=f.observable(!1);this.twitterLoggined=f.observable(!1);this.twitterUserName=f.observable("");this.customThemeType=f.observable(g.CustomThemeType.Light)}function aa(){this.oRequests={}}function p(){this.oRequests={};this.oRequests={}}function T(){this.oEmailsPicsHashes=
{};this.oServices={}}function v(){T.call(this);this.oFoldersCache={};this.oFoldersNamesCache={};this.oFolderHashCache={};this.oFolderUidNextCache={};this.oMessageListHashCache={};this.oMessageFlagsCache={};this.oNewMessage={};this.oRequestedMessage={}}function fa(a){J.call(this,"settings",a);this.menu=f.observableArray([]);this.oCurrentSubScreen=null}function Ba(){J.call(this,"login",[la])}function U(){J.call(this,"mailbox",[Ya,ea,z,H]);this.oLastRoute={};var a=e.data();this.mailBoxScreenVisibily=
f.observable(!1);this.resizeTrigger=f.computed(function(){var b=this.mailBoxScreenVisibily(),d=a.messageFullScreenMode();return a.usePreviewPane()&&!d&&b?!0:!1},this)}function Pa(){fa.call(this,[Za,ya,za]);c.initOnStartOrLangChange(function(){this.sSettingsTitle=c.i18n("TITLES/SETTINGS")},this,function(){e.setTitle(this.sSettingsTitle)})}function I(){this.oLocal=this.oLink=this.oPlugins=this.oSettings=null;this.isLocalAutocomplete=!0;this.popupVisibility=f.observable(!1);this.iframe=j('<iframe style="display:none" src="javascript:;" />').appendTo("body");
N.on("error",function(a){e&&(a&&a.originalEvent&&a.originalEvent.message&&-1===c.inArray(a.originalEvent.message,["Uncaught Error: Error calling method on NPObject."]))&&(c.log(""+a.originalEvent.message+" ("+a.originalEvent.filename+":"+a.originalEvent.lineno+")"),e.remote().jsError(c.emptyFunction,a.originalEvent.message,a.originalEvent.filename,a.originalEvent.lineno,location&&location.hash?location.hash:"",Y.attr("class")))})}function A(){I.call(this);this.oCache=this.oRemote=this.oData=null;
this.iSuggestionsLimit=c.pInt(this.settingsGet("SuggestionsLimit"));this.iSuggestionsLimit=0===this.iSuggestionsLimit?20:this.iSuggestionsLimit;this.quotaDebounce=i.debounce(this.quota,3E4)}var t={},g={},u={},c={},x={},ga={},Ca,Qa,oa,Ra,ab,ha,xa=f.observable(!0),ia=f.observable(!0),s=null,Da=h.rainloopAppData||{},Sa=h.rainloopI18N||{},Y=j("html"),N=j(h),Ea=j(h.document),Fa=[],Ta=[],Ua=[],ja=h.Notification&&h.Notification.requestPermission?h.Notification:null,e=null;Ca=0;Qa=!1;oa=(navigator.userAgent||
"").toLowerCase();Ra=-1<oa.indexOf("iphone")||-1<oa.indexOf("ipod")||-1<oa.indexOf("ipad");ab=-1<oa.indexOf("android");ha=Ra||ab;t.Defaults={};t.Values={};t.DataImages={};t.Defaults.MessagesPerPage=25;t.Defaults.DefaultAjaxTimeout=2E4;t.Defaults.SearchAjaxTimeout=12E4;t.Defaults.SendMessageAjaxTimeout=2E5;t.Defaults.SaveMessageAjaxTimeout=2E5;t.Values.UnuseOptionValue="__UNUSE__";t.Values.GmailFolderName="[Gmail]";t.Values.ClientSideCookieIndexName="rlcsc";t.Values.ImapDefaulPort=143;t.Values.ImapDefaulSecurePort=
993;t.Values.SmtpDefaulPort=25;t.Values.SmtpDefaulSecurePort=465;t.DataImages.UserDotPic="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2P8DwQACgAD/il4QJ8AAAAASUVORK5CYII=";t.DataImages.TranspPic="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2NkAAIAAAoAAggA9GkAAAAASUVORK5CYII=";g.StorageResultType={Success:"success",Abort:"abort",Error:"error",Unload:"unload"};g.State={Empty:10,Login:20,Auth:30};g.StateType={Webmail:0,Admin:1};g.FolderType=
{Inbox:10,SentItems:11,Draft:12,Trash:13,Spam:14,User:99};g.LoginSignMeTypeAsString={DefaultOff:"defaultoff",DefaultOn:"defaulton",Unused:"unused"};g.LoginSignMeType={DefaultOff:0,DefaultOn:1,Unused:2};g.ComposeType={Empty:"empty",Reply:"reply",ReplyAll:"replyall",Forward:"forward",ForwardAsAttachment:"forward-as-attachment",Draft:"draft"};g.UploadErrorCode={Normal:0,FileIsTooBig:1,FilePartiallyUploaded:2,FileNoUploaded:3,MissingTempFolder:4,FileOnSaveingError:5,FileType:98,Unknown:99};g.SetSystemFoldersNotification=
{None:0,Sent:1,Draft:2,Spam:3,Trash:4};g.ClientSideKeyName={FoldersLashHash:0,MessagesInboxLastHash:1,MailBoxListSize:2,ExpandedFolders:3};g.EventKeyCode={Backspace:8,Enter:13,Esc:27,PageUp:33,PageDown:34,Left:37,Right:39,Up:38,Down:40,End:35,Home:36,Insert:45,Delete:46,A:65,S:83};g.MessageSetAction={SetSeen:0,UnsetSeen:1,SetFlag:2,UnsetFlag:3};g.MessageSelectAction={All:0,None:1,Invert:2,Unseen:3,Seen:4,Flagged:5,Unflagged:6};g.DesctopNotifications={Allowed:0,NotAllowed:1,Denied:2,NotSupported:9};
g.MessagePriority={Low:5,Normal:3,High:1};g.EditorDefaultType={Html:"Html",Plain:"Plain"};g.CustomThemeType={Light:"Light",Dark:"Dark"};g.ServerSecure={None:0,SSL:1,TLS:2};g.SearchDateType={All:-1,Days3:3,Days7:7,Month:30};g.EmailType={Defailt:0,Facebook:1,Google:2};g.SaveSettingsStep={Animate:-2,Idle:-1,TrueResult:1,FalseResult:0};g.Notification={InvalidToken:101,AuthError:102,AccessError:103,ConnectionError:104,CaptchaError:105,SocialFacebookLoginAccessDisable:106,SocialTwitterLoginAccessDisable:107,
SocialGoogleLoginAccessDisable:108,DomainNotAllowed:109,CantGetMessageList:201,CantGetMessage:202,CantDeleteMessage:203,CantMoveMessage:204,CantSaveMessage:301,CantSendMessage:302,InvalidRecipients:303,CantCreateFolder:400,CantRenameFolder:401,CantDeleteFolder:402,CantSubscribeFolder:403,CantUnsubscribeFolder:404,CantDeleteNonEmptyFolder:405,CantSaveSettings:501,CantSavePluginSettings:502,DomainAlreadyExists:601,CantInstallPackage:701,CantDeletePackage:702,InvalidPluginPackage:703,UnsupportedPluginPackage:704,
LicensingServerIsUnavailable:710,LicensingExpired:711,LicensingBanned:712,DemoSendMessageError:750,AccountAlreadyExists:801,MailServerError:901,UnknownError:999};c.trim=j.trim;c.inArray=j.inArray;c.isArray=i.isArray;c.isFunc=i.isFunction;c.isUnd=i.isUndefined;c.isNull=i.isNull;c.emptyFunction=function(){};c.isNormal=function(a){return!c.isUnd(a)&&!c.isNull(a)};c.windowResize=i.debounce(function(a){c.isUnd(a)?N.resize():h.setTimeout(function(){N.resize()},a)},50);c.isPosNumeric=function(a,b){return c.isNormal(a)?
c.isUnd(b)||b?/^[0-9]*$/.test(a.toString()):/^[1-9]+[0-9]*$/.test(a.toString()):!1};c.pInt=function(a){return c.isNormal(a)&&""!==a?h.parseInt(a,10):0};c.pString=function(a){return c.isNormal(a)?a+"":""};c.isNonEmptyArray=function(a){return c.isArray(a)&&0<a.length};c.exportPath=function(a,b,d){for(var l=null,a=a.split("."),d=d||h;a.length&&(l=a.shift());)!a.length&&!c.isUnd(b)?d[l]=b:d=d[l]?d[l]:d[l]={}};c.pImport=function(a,b,d){a[b]=d};c.pExport=function(a,b,d){return c.isUnd(a[b])?d:a[b]};c.encodeHtml=
function(a){return c.isNormal(a)?a.toString().replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;"):""};c.splitPlainText=function(a,b){for(var d="",l="",e=a,f=0,g=0,b=c.isUnd(b)?100:b;e.length>b;)l=e.substring(0,b),f=l.lastIndexOf(" "),g=l.lastIndexOf("\n"),-1!==g&&(f=g),-1===f&&(f=b),d+=l.substring(0,f)+"\n",e=e.substring(f+1);return d+e};var Ga={};c.timeOutAction=function(a,b,d){c.isUnd(Ga[a])&&(Ga[a]=0);h.clearTimeout(Ga[a]);Ga[a]=h.setTimeout(b,
d)};var Va={};c.timeOutActionSecond=function(a,b,d){Va[a]||(Va[a]=h.setTimeout(function(){b();Va[a]=0},d))};var O=!1;c.audio=function(a,b){if(!1===O)if(Ra)O=null;else{var d=!1,c=!1,e=h.Audio?new h.Audio:null;e&&e.canPlayType&&e.play?((d=""!==e.canPlayType('audio/mpeg; codecs="mp3"'))||(c=""!==e.canPlayType('audio/ogg; codecs="vorbis"')),d||c?(O=e,O.preload="none",O.loop=!1,O.autoplay=!1,O.muted=!1,O.src=d?a:b):O=null):O=null}return O};c.hos=function(a,b){return a&&Object.hasOwnProperty?Object.hasOwnProperty.call(a,
b):!1};c.i18n=function(a,b,d){var l="",a=c.isUnd(Sa[a])?c.isUnd(d)?a:d:Sa[a];if(!c.isUnd(b)&&!c.isNull(b))for(l in b)c.hos(b,l)&&(a=a.replace("%"+l+"%",b[l]));return a};c.i18nToNode=function(a){i.defer(function(){j(".i18n",a).each(function(){var a=j(this),d="";(d=a.data("i18n-text"))?a.text(c.i18n(d)):((d=a.data("i18n-html"))&&a.html(c.i18n(d)),(d=a.data("i18n-placeholder"))&&a.attr("placeholder",c.i18n(d)))})})};c.i18nToDoc=function(){h.rainloopI18N&&(Sa=h.rainloopI18N||{},c.i18nToNode(Ea),ia(!ia()));
h.rainloopI18N={}};c.initOnStartOrLangChange=function(a,b,d){a&&a.call(b);d?ia.subscribe(function(){a&&a.call(b);d.call(b)}):a&&ia.subscribe(a,b)};c.inFocus=function(){var a=document.activeElement;return a&&("INPUT"===a.tagName||"TEXTAREA"===a.tagName||"IFRAME"===a.tagName||"DIV"===a.tagName&&"editorHtmlArea"===a.className&&a.contentEditable)};c.removeInFocus=function(){if(document&&document.activeElement&&document.activeElement.blur){var a=j(document.activeElement);(a.is("input")||a.is("textarea"))&&
document.activeElement.blur()}};c.removeSelection=function(){if(h&&h.getSelection){var a=h.getSelection();a&&a.removeAllRanges&&a.removeAllRanges()}else document&&(document.selection&&document.selection.empty)&&document.selection.empty()};c.replySubjectAdd=function(a,b){var d=null,l=c.trim(b);null!==(d=(new h.RegExp("^"+a+"[\\s]?\\:(.*)$","gi")).exec(b))&&!c.isUnd(d[1])?l=a+"[2]: "+d[1]:null!==(d=(new h.RegExp("^("+a+"[\\s]?[\\[\\(]?)([\\d]+)([\\]\\)]?[\\s]?\\:.*)$","gi")).exec(b))&&!c.isUnd(d[1])&&
!c.isUnd(d[2])&&!c.isUnd(d[3])?(c.pInt(d[2]),l=d[1]+(c.pInt(d[2])+1)+d[3]):l=a+": "+b;return l};c.roundNumber=function(a,b){return Math.round(a*Math.pow(10,b))/Math.pow(10,b)};c.friendlySize=function(a){a=c.pInt(a);return 1073741824<=a?c.roundNumber(a/1073741824,1)+"GB":1048576<=a?c.roundNumber(a/1048576,1)+"MB":1024<=a?c.roundNumber(a/1024,0)+"KB":a+"B"};c.log=function(a){h.console&&h.console.log&&h.console.log(a)};c.getNotification=function(a){a=c.pInt(a);return c.isUnd(u[a])?"":u[a]};c.initNotificationLanguage=
function(){u[g.Notification.InvalidToken]=c.i18n("NOTIFICATIONS/INVALID_TOKEN");u[g.Notification.AuthError]=c.i18n("NOTIFICATIONS/AUTH_ERROR");u[g.Notification.AccessError]=c.i18n("NOTIFICATIONS/ACCESS_ERROR");u[g.Notification.ConnectionError]=c.i18n("NOTIFICATIONS/CONNECTION_ERROR");u[g.Notification.CaptchaError]=c.i18n("NOTIFICATIONS/CAPTCHA_ERROR");u[g.Notification.SocialFacebookLoginAccessDisable]=c.i18n("NOTIFICATIONS/SOCIAL_FACEBOOK_LOGIN_ACCESS_DISABLE");u[g.Notification.SocialTwitterLoginAccessDisable]=
c.i18n("NOTIFICATIONS/SOCIAL_TWITTER_LOGIN_ACCESS_DISABLE");u[g.Notification.SocialGoogleLoginAccessDisable]=c.i18n("NOTIFICATIONS/SOCIAL_GOOGLE_LOGIN_ACCESS_DISABLE");u[g.Notification.DomainNotAllowed]=c.i18n("NOTIFICATIONS/DOMAIN_NOT_ALLOWED");u[g.Notification.CantGetMessageList]=c.i18n("NOTIFICATIONS/CANT_GET_MESSAGE_LIST");u[g.Notification.CantGetMessage]=c.i18n("NOTIFICATIONS/CANT_GET_MESSAGE");u[g.Notification.CantDeleteMessage]=c.i18n("NOTIFICATIONS/CANT_DELETE_MESSAGE");u[g.Notification.CantMoveMessage]=
c.i18n("NOTIFICATIONS/CANT_MOVE_MESSAGE");u[g.Notification.CantSaveMessage]=c.i18n("NOTIFICATIONS/CANT_SAVE_MESSAGE");u[g.Notification.CantSendMessage]=c.i18n("NOTIFICATIONS/CANT_SEND_MESSAGE");u[g.Notification.InvalidRecipients]=c.i18n("NOTIFICATIONS/INVALID_RECIPIENTS");u[g.Notification.CantCreateFolder]=c.i18n("NOTIFICATIONS/CANT_CREATE_FOLDER");u[g.Notification.CantRenameFolder]=c.i18n("NOTIFICATIONS/CANT_RENAME_FOLDER");u[g.Notification.CantDeleteFolder]=c.i18n("NOTIFICATIONS/CANT_DELETE_FOLDER");
u[g.Notification.CantDeleteNonEmptyFolder]=c.i18n("NOTIFICATIONS/CANT_DELETE_NON_EMPTY_FOLDER");u[g.Notification.CantSubscribeFolder]=c.i18n("NOTIFICATIONS/CANT_SUBSCRIBE_FOLDER");u[g.Notification.CantUnsubscribeFolder]=c.i18n("NOTIFICATIONS/CANT_UNSUBSCRIBE_FOLDER");u[g.Notification.CantSaveSettings]=c.i18n("NOTIFICATIONS/CANT_SAVE_SETTINGS");u[g.Notification.CantSavePluginSettings]=c.i18n("NOTIFICATIONS/CANT_SAVE_PLUGIN_SETTINGS");u[g.Notification.DomainAlreadyExists]=c.i18n("NOTIFICATIONS/DOMAIN_ALREADY_EXISTS");
u[g.Notification.CantInstallPackage]=c.i18n("NOTIFICATIONS/CANT_INSTALL_PACKAGE");u[g.Notification.CantDeletePackage]=c.i18n("NOTIFICATIONS/CANT_DELETE_PACKAGE");u[g.Notification.InvalidPluginPackage]=c.i18n("NOTIFICATIONS/INVALID_PLUGIN_PACKAGE");u[g.Notification.UnsupportedPluginPackage]=c.i18n("NOTIFICATIONS/UNSUPPORTED_PLUGIN_PACKAGE");u[g.Notification.LicensingServerIsUnavailable]=c.i18n("NOTIFICATIONS/LICENSING_SERVER_IS_UNAVAILABLE");u[g.Notification.LicensingExpired]=c.i18n("NOTIFICATIONS/LICENSING_EXPIRED");
u[g.Notification.LicensingBanned]=c.i18n("NOTIFICATIONS/LICENSING_BANNED");u[g.Notification.DemoSendMessageError]=c.i18n("NOTIFICATIONS/DEMO_SEND_MESSAGE_ERROR");u[g.Notification.AccountAlreadyExists]=c.i18n("NOTIFICATIONS/ACCOUNT_ALREADY_EXISTS");u[g.Notification.MailServerError]=c.i18n("NOTIFICATIONS/MAIL_SERVER_ERROR");u[g.Notification.UnknownError]=c.i18n("NOTIFICATIONS/UNKNOWN_ERROR")};c.getUploadErrorDescByCode=function(a){var b="";switch(c.pInt(a)){case g.UploadErrorCode.FileIsTooBig:b=c.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG");
break;case g.UploadErrorCode.FilePartiallyUploaded:b=c.i18n("UPLOAD/ERROR_FILE_PARTIALLY_UPLOADED");break;case g.UploadErrorCode.FileNoUploaded:b=c.i18n("UPLOAD/ERROR_NO_FILE_UPLOADED");break;case g.UploadErrorCode.MissingTempFolder:b=c.i18n("UPLOAD/ERROR_MISSING_TEMP_FOLDER");break;case g.UploadErrorCode.FileOnSaveingError:b=c.i18n("UPLOAD/ERROR_ON_SAVING_FILE");break;case g.UploadErrorCode.FileType:b=c.i18n("UPLOAD/ERROR_FILE_TYPE");break;default:b=c.i18n("UPLOAD/ERROR_UNKNOWN")}return b};c.killCtrlAandS=
function(a){if(a=a||h.event){var b=a.target||a.srcElement,d=a.keyCode||a.which;if(a.ctrlKey&&d===g.EventKeyCode.S)a.preventDefault();else if((!b||!b.tagName||!b.tagName.match(/INPUT|TEXTAREA/i))&&a.ctrlKey&&d===g.EventKeyCode.A)h.getSelection?h.getSelection().removeAllRanges():h.document.selection&&h.document.selection.clear&&h.document.selection.clear(),a.preventDefault()}};c.createCommand=function(a,b,d){var l=b?function(){l.canExecute&&l.canExecute()&&b.apply(a,Array.prototype.slice.call(arguments));
return!1}:function(){};l.enabled=f.observable(!0);d=c.isUnd(d)?!0:d;l.canExecute=c.isFunc(d)?f.computed(function(){return l.enabled()&&d.call(a)}):f.computed(function(){return l.enabled()&&!!d});return l};c.initDataConstructorBySettings=function(a){a.ignoreFolderSubscribe=f.observable(!1);a.editorDefaultType=f.observable(g.EditorDefaultType.Html);a.showImages=f.observable(!1);a.showAnimation=f.observable(!1);a.desktopNotifications=f.observable(!1);a.useThreads=f.observable(!0);a.replySameFolder=f.observable(!0);
a.usePreviewPane=f.observable(!0);a.useCheckboxesInList=f.observable(!0);a.showAnimation.subscribe(function(a){ha?Y.removeClass("rl-anim").addClass("no-rl-anim"):Y.toggleClass("rl-anim",a).toggleClass("no-rl-anim",!a)});a.showAnimation.valueHasMutated();a.desktopNotificationsPermisions=f.computed(function(){a.desktopNotifications();var b=g.DesctopNotifications.NotSupported;if(ja&&ja.permission)switch(ja.permission.toLowerCase()){case "granted":b=g.DesctopNotifications.Allowed;break;case "denied":b=
g.DesctopNotifications.Denied;break;case "default":b=g.DesctopNotifications.NotAllowed}else h.webkitNotifications&&h.webkitNotifications.checkPermission&&(b=h.webkitNotifications.checkPermission());return b});a.useDesktopNotifications=f.computed({read:function(){return a.desktopNotifications()&&g.DesctopNotifications.Allowed===a.desktopNotificationsPermisions()},write:function(b){b?(b=a.desktopNotificationsPermisions(),g.DesctopNotifications.Allowed===b?a.desktopNotifications(!0):g.DesctopNotifications.NotAllowed===
b?ja.requestPermission(function(){a.desktopNotifications.valueHasMutated();h.console.log(a.desktopNotificationsPermisions());g.DesctopNotifications.Allowed===a.desktopNotificationsPermisions()?a.desktopNotifications()?a.desktopNotifications.valueHasMutated():a.desktopNotifications(!0):a.desktopNotifications()?a.desktopNotifications(!1):a.desktopNotifications.valueHasMutated()}):a.desktopNotifications(!1)):a.desktopNotifications(!1)}});a.language=f.observable("");a.languages=f.observableArray([]);
a.mainLanguage=f.computed({read:a.language,write:function(b){b!==a.language()?-1<c.inArray(b,a.languages())?a.language(b):0<a.languages().length&&a.language(a.languages()[0]):a.language.valueHasMutated()}});a.theme=f.observable("");a.themes=f.observableArray([]);a.mainTheme=f.computed({read:a.theme,write:function(b){if(b!==a.theme()){var d=a.themes();-1<c.inArray(b,d)?a.theme(b):0<d.length&&a.theme(d[0])}else a.theme.valueHasMutated()}});a.allowCustomTheme=f.observable(!0);a.allowAdditionalAccounts=
f.observable(!0);a.messagesPerPage=f.observable(t.Defaults.MessagesPerPage);a.mainMessagesPerPage=a.messagesPerPage;a.mainMessagesPerPage=f.computed({read:a.messagesPerPage,write:function(b){-1<c.inArray(c.pInt(b),[10,20,30,50,100,150,200])?b!==a.messagesPerPage()&&a.messagesPerPage(b):a.messagesPerPage.valueHasMutated()}});a.facebookEnable=f.observable(!1);a.facebookAppID=f.observable("");a.facebookAppSecret=f.observable("");a.twitterEnable=f.observable(!1);a.twitterConsumerKey=f.observable("");
a.twitterConsumerSecret=f.observable("");a.googleEnable=f.observable(!1);a.googleClientID=f.observable("");a.googleClientSecret=f.observable("");a.dropboxEnable=f.observable(!1);a.dropboxApiKey=f.observable("");a.contactsIsSupported=f.observable(!1)};c.createMomentDate=function(a){return f.computed(function(){xa();return this.moment().fromNow()},a)};c.createMomentShortDate=function(a){return f.computed(function(){var a="",a=Z(),d=this.moment(),l=this.momentDate();return a=4>=a.diff(d,"hours")?l:a.format("L")===
d.format("L")?c.i18n("MESSAGE_LIST/TODAY_AT",{TIME:d.format("LT")}):a.clone().subtract("days",1).format("L")===d.format("L")?c.i18n("MESSAGE_LIST/YESTERDAY_IN",{TIME:d.format("LT")}):a.year()===d.year()?d.format("D MMM."):d.format("LL")},a)};c.isFolderExpanded=function(a){var b=e.local().get(g.ClientSideKeyName.ExpandedFolders);return i.isArray(b)&&-1!==i.indexOf(b,a)};c.setExpandedFolder=function(a,b){var d=e.local().get(g.ClientSideKeyName.ExpandedFolders);i.isArray(d)||(d=[]);b?(d.push(a),d=i.uniq(d)):
d=i.without(d,a);e.local().set(g.ClientSideKeyName.ExpandedFolders,d)};c.initLayoutResizer=function(a,b,d,c){var f=j(a),r=j(b),w=j(d),a=e.local().get(g.ClientSideKeyName.MailBoxListSize),k=function(a,b,d){if(b||d)a=w.width(),b=b?100*(b.size.width/a):null,null===b&&d&&(b=100*(f.width()/a)),null!==b&&(f.css({width:"",height:"",right:""+(100-b)+"%"}),r.css({width:"",height:"",left:""+b+"%"}))};a&&f.width(a);f.resizable({minWidth:350,maxWidth:w.width()-250,handles:"e",resize:k,stop:k});k(null,null,!0);
N.resize(i.throttle(function(a,b){if(c&&c()){var d=w.width();f.resizable("option","maxWidth",d-250);b&&(b.size&&b.size.width)&&e.local().set(g.ClientSideKeyName.MailBoxListSize,b.size.width);k(null,null,!0)}},400))};c.initBlockquoteSwitcher=function(a){if(a){var b=j("blockquote:not(.rl-bq-switcher)",a).filter(function(){return 0===j(this).parent().closest("blockquote",a).length});b&&0<b.length&&b.each(function(){var a=j(this),b=a.height();if(0===b||100<b)a.addClass("rl-bq-switcher hidden-bq"),j('<span class="rlBlockquoteSwitcher"><i class="icon-ellipsis" /></span>').insertBefore(a).click(function(){a.toggleClass("hidden-bq");
c.windowResize()}).after("<br />").before("<br />")})}};c.removeBlockquoteSwitcher=function(a){a&&(j(a).find("blockquote.rl-bq-switcher").each(function(){j(this).removeClass("rl-bq-switcher hidden-bq")}),j(a).find(".rlBlockquoteSwitcher").each(function(){j(this).remove()}))};c.extendAsViewModel=function(a,b){b&&(b.__name=a,x.regViewModelHook(a,b),i.extend(b.prototype,C.prototype))};c.addSettingsViewModel=function(a,b,d,c,e){a.__rlSettingsData={Label:d,Template:b,Route:c,IsDefault:!!e};Fa.push(a)};
c.removeSettingsViewModel=function(a){Ta.push(a)};c.disableSettingsViewModel=function(a){Ua.push(a)};c.convertThemeName=function(a){return c.trim(a.replace(/[^a-zA-Z]/g," ").replace(/([A-Z])/g," $1").replace(/[\s]+/g," "))};c.convertLangName=function(a){return c.i18n("LANGS_NAMES/LANG_"+a.toUpperCase().replace(/[^a-zA-Z0-9]+/,"_"),null,a)};c.fakeMd5=function(a){for(var b="",a=c.isUnd(a)?32:c.pInt(a);b.length<a;)b+="0123456789abcdefghijklmnopqrstuvwxyz".substr(h.Math.round(36*h.Math.random()),1);return b};
c.convertPlainTextToHtml=function(a){return a.toString().replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;").replace(/\r/g,"").replace(/\n/g,"<br />")};c.draggeblePlace=function(){return j('<div class="draggablePlace"><span class="text"></span>&nbsp;<i class="icon-envelope icon-white"></i></div>').appendTo("#rl-hidden")};c.defautOptionsAfterRender=function(a,b){b&&!c.isUnd(b.disable)&&f.applyBindingsToNode(a,{disable:b.disable},b)};c.windowPopupKnockout=function(a,b,d,l){var e=null,f=
h.open(""),g="__OpenerApplyBindingsUid"+c.fakeMd5()+"__",k=j("#"+b);h[g]=function(){if(f&&f.document.body&&k&&k[0]){var b=j(f.document.body);j("#rl-content",b).html(k.html());j("html",f.document).addClass("external "+j("html").attr("class"));c.i18nToNode(b);E.prototype.applyExternal(a,j("#rl-content",b)[0]);h[g]=null;l(f)}};f.document.open();f.document.write('<html><head><meta charset="utf-8" /><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /><meta name="viewport" content="user-scalable=no" /><meta name="apple-mobile-web-app-capable" content="yes" /><meta name="robots" content="noindex, nofollow, noodp" /><title>'+
c.encodeHtml(d)+'</title></head><body><div id="rl-content"></div></body></html>');f.document.close();e=f.document.createElement("script");e.innerHTML="if(window&&window.opener&&window.opener['"+g+"']){window.opener['"+g+"']();window.opener['"+g+"']=null}";f.document.getElementsByTagName("head")[0].appendChild(e)};c.settingsSaveHelperFunction=function(a,b,d,l){d=d||null;l=c.isUnd(l)?1E3:c.pInt(l);return function(c,e,f,k,h){b.call(d,e&&e.Result?g.SaveSettingsStep.TrueResult:g.SaveSettingsStep.FalseResult);
a&&a.call(d,c,e,f,k,h);i.delay(function(){b.call(d,g.SaveSettingsStep.Idle)},l)}};c.settingsSaveHelperSimpleFunction=function(a,b){return c.settingsSaveHelperFunction(null,a,b,1E3)};c.resizeAndCrop=function(a,b,d){var c=new Image;c.onload=function(){var a=[0,0],c=document.createElement("canvas"),l=c.getContext("2d");c.width=b;c.height=b;a=this.width>this.height?[this.width-this.height,0]:[0,this.height-this.width];l.fillStyle="#fff";l.fillRect(0,0,b,b);l.drawImage(this,a[0]/2,a[1]/2,this.width-a[0],
this.height-a[1],0,0,b,b);d(c.toDataURL("image/jpeg"))};c.src=a};ga={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",urlsafe_encode:function(a){return ga.encode(a).replace(/[+]/g,"-").replace(/[\/]/g,"_").replace(/[=]/g,".")},encode:function(a){for(var b="",d,c,e,f,g,k,i=0,a=ga._utf8_encode(a);i<a.length;)d=a.charCodeAt(i++),c=a.charCodeAt(i++),e=a.charCodeAt(i++),f=d>>2,d=(d&3)<<4|c>>4,g=(c&15)<<2|e>>6,k=e&63,isNaN(c)?g=k=64:isNaN(e)&&(k=64),b=b+this._keyStr.charAt(f)+
this._keyStr.charAt(d)+this._keyStr.charAt(g)+this._keyStr.charAt(k);return b},decode:function(a){for(var b="",d,c,e,f,g,k=0,a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");k<a.length;)d=this._keyStr.indexOf(a.charAt(k++)),c=this._keyStr.indexOf(a.charAt(k++)),f=this._keyStr.indexOf(a.charAt(k++)),g=this._keyStr.indexOf(a.charAt(k++)),d=d<<2|c>>4,c=(c&15)<<4|f>>2,e=(f&3)<<6|g,b+=String.fromCharCode(d),64!==f&&(b+=String.fromCharCode(c)),64!==g&&(b+=String.fromCharCode(e));return ga._utf8_decode(b)},_utf8_encode:function(a){for(var a=
a.replace(/\r\n/g,"\n"),b="",d=0,c=a.length,e=0;d<c;d++)e=a.charCodeAt(d),128>e?b+=String.fromCharCode(e):(127<e&&2048>e?b+=String.fromCharCode(e>>6|192):(b+=String.fromCharCode(e>>12|224),b+=String.fromCharCode(e>>6&63|128)),b+=String.fromCharCode(e&63|128));return b},_utf8_decode:function(a){for(var b="",d=0,c=0,e=0,f=0;d<a.length;)c=a.charCodeAt(d),128>c?(b+=String.fromCharCode(c),d++):191<c&&224>c?(e=a.charCodeAt(d+1),b+=String.fromCharCode((c&31)<<6|e&63),d+=2):(e=a.charCodeAt(d+1),f=a.charCodeAt(d+
2),b+=String.fromCharCode((c&15)<<12|(e&63)<<6|f&63),d+=3);return b}};f.bindingHandlers.tooltip={init:function(a,b){if(!ha){var d=j(a).data("tooltip-class")||"";j(a).tooltip({delay:{show:500,hide:100},html:!0,trigger:"hover",title:function(){return'<span class="tooltip-class '+d+'">'+c.i18n(f.utils.unwrapObservable(b()))+"</span>"}})}}};f.bindingHandlers.tooltip2={init:function(a,b){var d=j(a).data("tooltip-class")||"";j(a).tooltip({delay:{show:500,hide:100},html:!0,title:function(){return'<span class="tooltip-class '+
d+'">'+b()()+"</span>"}})}};f.bindingHandlers.popover={init:function(a,b){var d=f.utils.unwrapObservable(b());j(a).popover({trigger:d[2]||"click",placement:d[3]||"right",title:function(){return c.i18n(d[0]||"")},content:function(){return c.i18n(d[1]||"")}})}};f.bindingHandlers.resizecrop={init:function(a){j(a).addClass("resizecrop").resizecrop({width:"100",height:"100",wrapperCSS:{"border-radius":"10px"}})},update:function(a,b){b()();j(a).resizecrop({width:"100",height:"100"})}};f.bindingHandlers.onEnter=
{init:function(a,b,d,c){j(a).on("keypress",function(d){d&&13===h.parseInt(d.keyCode,10)&&(j(a).trigger("change"),b().call(c))})}};f.bindingHandlers.onEsc={init:function(a,b,d,c){j(a).on("keypress",function(d){d&&27===h.parseInt(d.keyCode,10)&&(j(a).trigger("change"),b().call(c))})}};f.bindingHandlers.modal={init:function(a,b){j(a).modal({keyboard:!1,show:f.utils.unwrapObservable(b())}).on("hidden",function(){b()(!1)})},update:function(a,b){var d=f.utils.unwrapObservable(b());j(a).modal(d?"show":"hide");
i.delay(function(){j(a).toggleClass("popup-active",d)},1)}};f.bindingHandlers.i18nInit={init:function(a){c.i18nToNode(a)}};f.bindingHandlers.i18nUpdate={update:function(a,b){f.utils.unwrapObservable(b());c.i18nToNode(a)}};f.bindingHandlers.link={update:function(a,b){j(a).attr("href",f.utils.unwrapObservable(b()))}};f.bindingHandlers.title={update:function(a,b){j(a).attr("title",f.utils.unwrapObservable(b()))}};f.bindingHandlers.textF={init:function(a,b){j(a).text(f.utils.unwrapObservable(b()))}};
f.bindingHandlers.initDom={init:function(a,b){b()(a)}};f.bindingHandlers.initResizeTrigger={init:function(a,b){var d=f.utils.unwrapObservable(b());j(a).css({height:d[1],"min-height":d[1]})},update:function(a,b){var d=f.utils.unwrapObservable(b()),l=c.pInt(d[1]),e=0,e=j(a).offset().top;0<e&&(e+=c.pInt(d[2]),e=N.height()-e,l<e&&(l=e),j(a).css({height:l,"min-height":l}))}};f.bindingHandlers.appendDom={update:function(a,b){j(a).hide().empty().append(f.utils.unwrapObservable(b())).show()}};f.bindingHandlers.draggable=
{init:function(a,b){j(a).draggable({distance:20,handle:".dragHandle",cursorAt:{top:22,left:3},helper:function(a){return b()(a&&a.target?f.dataFor(a.target):null)}}).on("mousedown",function(){c.removeInFocus()})}};f.bindingHandlers.droppable={init:function(a,b){var d=b();!1!==d&&j(a).droppable({tolerance:"pointer",hoverClass:"droppableHover",drop:function(a,b){d(a,b)}})}};f.bindingHandlers.nano={init:function(a){ha||j(a).addClass("nano").nanoScroller({iOSNativeScrolling:!1,preventPageScrolling:!0})}};
f.bindingHandlers.saveTrigger={init:function(a){j(a).append('&nbsp;&nbsp;<i class="icon-spinner-2 animated"></i><i class="icon-remove error"></i><i class="icon-ok success"></i>').addClass("settings-saved-trigger")},update:function(a,b){var d=f.utils.unwrapObservable(b()),c=j(a);switch(d.toString()){case "1":c.find(".animated,.error").hide().removeClass("visible").end().find(".success").show().addClass("visible");break;case "0":c.find(".animated,.success").hide().removeClass("visible").end().find(".error").show().addClass("visible");
break;case "-2":c.find(".error,.success").hide().removeClass("visible").end().find(".animated").show().addClass("visible");break;default:c.find(".animated").hide().end().find(".error,.success").removeClass("visible")}}};f.bindingHandlers.select2={init:function(a,b){var d=0,l=null,g=new h.RegExp(/[a-zA-Z0-9\.\-_]+@[a-zA-Z0-9\.\-_]+/),r=new h.RegExp(/(.+) [<]?([^\s<@]+@[a-zA-Z0-9\.\-_]+)[>]?/),w=function(){return""},k=function(a){e.getAutocomplete(a.term,a.page,function(b,d){a.callback({more:!!d,results:i.map(b,
function(a){var b=a.toLine(!1);return{id:b,text:b,c:a}})})})};j(a).addClass("ko-select2").select2({query:function(a){a&&(0===d?(k(a),d=h.setTimeout(c.emptyFunction,200)):(h.clearInterval(d),d=h.setTimeout(function(){k(a)},200)))},formatSelection:function(a,b){var d=a&&a.c?a.c.select2Selection(b):a.text;if(null!==d)return d},formatResult:function(a,b,d,c){b=a&&a.c?a.c.select2Result(b):"";return""===b?c(a.text):b},createSearchChoice:function(a,b){return 0===b.length&&g.test(a)?{id:a,text:a}:null},formatNoMatches:w,
formatSearching:function(){return c.i18n("SUGGESTIONS/SEARCHING_DESC")},formatInputTooShort:w,formatSelectionTooBig:w,multiple:!0,tokenSeparators:[",",";"],minimumInputLength:2,selectOnBlur:!1,closeOnSelect:!0,openOnEnter:!1});f.utils.domNodeDisposal.addDisposeCallback(a,function(){j(a).select2("destroy")});j(a).on("change",function(){for(var a=j(this).select2("data"),d=0,e=a.length,f=null,g=[];d<e;d++)if((f=a[d])&&f.id)f.c||(f.c=new F,(l=r.exec(c.trim(f.id)))&&!c.isUnd(l[2])?(f.c.name=l[1],f.c.email=
l[2]):f.c.email=f.id),g.push(f.c);b()(g)})},update:function(a,b){for(var d=f.utils.unwrapObservable(b()),c=0,e=d.length,g=null,w="",k=[];c<e;c++)g=d[c],w=g.toLine(!1),k.push({id:w,text:w,c:g});j(a).select2("data",k)}};f.bindingHandlers.command={init:function(a,b,d,c){var e=j(a),g=b();if(!g||!g.enabled||!g.canExecute)throw Error("You are not using command function");e.addClass("command");f.bindingHandlers[e.is("form")?"submit":"click"].init.apply(c,arguments)},update:function(a,b){var d=!0,c=j(a),
e=b(),d=e.enabled();c.toggleClass("command-not-enabled",!d);d&&(d=e.canExecute(),c.toggleClass("command-can-not-be-execute",!d));c.toggleClass("command-disabled disable disabled",!d);(c.is("input")||c.is("button"))&&c.prop("disabled",!d)}};f.extenders.trimmer=function(a){var b=f.computed({read:a,write:function(b){a(c.trim(b.toString()))},owner:this});b(a());return b};f.extenders.reversible=function(a){var b=a();a.commit=function(){b=a()};a.reverse=function(){a(b)};a.commitedValue=function(){return b};
return a};f.extenders.toggleSubscribe=function(a,b){a.subscribe(b[1],b[0],"beforeChange");a.subscribe(b[2],b[0]);return a};f.extenders.falseTimeout=function(a,b){a.iTimeout=0;a.subscribe(function(d){d&&(h.clearTimeout(a.iTimeout),a.iTimeout=h.setTimeout(function(){a(!1);a.iTimeout=0},c.pInt(b)))});return a};f.observable.fn.validateEmail=function(){this.hasError=f.observable(!1);this.subscribe(function(a){a=c.trim(a);this.hasError(""!==a&&!/^[^@\s]+@[^@\s]+$/.test(a))},this);this.valueHasMutated();
return this};f.observable.fn.validateFunc=function(a){this.hasFuncError=f.observable(!1);c.isFunc(a)&&(this.subscribe(function(b){this.hasFuncError(!a(b))},this),this.valueHasMutated());return this};B.prototype.root=function(){return this.sBase};B.prototype.attachmentDownload=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/Download/"+a};B.prototype.attachmentPreview=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/View/"+a};B.prototype.attachmentPreviewAsPlain=function(a){return this.sServer+
"/Raw/"+this.sSpecSuffix+"/ViewAsPlain/"+a};B.prototype.upload=function(){return this.sServer+"/Upload/"+this.sSpecSuffix+"/"};B.prototype.uploadBackground=function(){return this.sServer+"/UploadBackground/"+this.sSpecSuffix+"/"};B.prototype.append=function(){return this.sServer+"/Append/"+this.sSpecSuffix+"/"};B.prototype.change=function(a){return this.sServer+"/Change/"+this.sSpecSuffix+"/"+h.encodeURIComponent(a)+"/"};B.prototype.ajax=function(a){return this.sServer+"/Ajax/"+this.sSpecSuffix+"/"+
a};B.prototype.messageViewLink=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ViewAsPlain/"+a};B.prototype.messageDownloadLink=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/Download/"+a};B.prototype.inbox=function(){return this.sBase+"mailbox/Inbox"};B.prototype.settings=function(a){var b=this.sBase+"settings";!c.isUnd(a)&&""!==a&&(b+="/"+a);return b};B.prototype.admin=function(a){var b=this.sBase;switch(a){case "AdminDomains":b+="domains";break;case "AdminSecurity":b+="security";
break;case "AdminLicensing":b+="licensing"}return b};B.prototype.mailBox=function(a,b,d){var b=c.isNormal(b)?c.pInt(b):1,d=c.pString(d),e=this.sBase+"mailbox/";""!==a&&(e+=encodeURI(a));1<b&&(e=e.replace(/[\/]+$/,""),e+="/p"+b);""!==d&&(e=e.replace(/[\/]+$/,""),e+="/"+encodeURI(d));return e};B.prototype.phpInfo=function(){return this.sServer+"Info"};B.prototype.langLink=function(a){return this.sServer+"/Lang/0/"+encodeURI(a)+"/"+this.sVersion+"/"};B.prototype.getUserPicUrlFromHash=function(a){return this.sServer+
"/Raw/"+this.sSpecSuffix+"/UserPic/"+a+"/"+this.sVersion+"/"};B.prototype.emptyContactPic=function(){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/static/css/images/empty-contact.png"};B.prototype.sound=function(a){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/static/sounds/"+a};B.prototype.themePreviewLink=function(a){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/themes/"+encodeURI(a)+
"/images/preview.png"};B.prototype.notificationMailIcon=function(){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/static/css/images/icom-message-notification.png"};B.prototype.socialGoogle=function(){return this.sServer+"SocialGoogle"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")};B.prototype.socialTwitter=function(){return this.sServer+"SocialTwitter"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")};B.prototype.socialFacebook=function(){return this.sServer+
"SocialFacebook"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")};x.oViewModelsHooks={};x.oSimpleHooks={};x.regViewModelHook=function(a,b){b&&(b.__hookName=a)};x.addHook=function(a,b){c.isFunc(b)&&(c.isArray(x.oSimpleHooks[a])||(x.oSimpleHooks[a]=[]),x.oSimpleHooks[a].push(b))};x.runHook=function(a,b){c.isArray(x.oSimpleHooks[a])&&(b=b||[],i.each(x.oSimpleHooks[a],function(a){a.apply(null,b)}))};x.mainSettingsGet=function(a){return e?e.settingsGet(a):null};x.remoteRequest=function(a,b,d,c,f,g){e&&
e.remote().defaultRequest(a,b,d,c,f,g)};x.settingsGet=function(a,b){var d=x.mainSettingsGet("Plugins");return(d=d&&c.isUnd(d[a])?null:d[a])?c.isUnd(d[b])?null:d[b]:null};q.prototype.initLanguage=function(a,b,d){this.oOptions.LangSwitcherConferm=a;this.oOptions.LangSwitcherTextLabel=b;this.oOptions.LangSwitcherHtmlLabel=d};q.prototype.execCom=function(a,b,d){h.document&&(h.document.execCommand(a,b||!1,d||null),this.updateTextArea())};q.prototype.getEditorSelection=function(){var a=null;h.getSelection?
a=h.getSelection():h.document.getSelection?a=h.document.getSelection():h.document.selection&&(a=h.document.selection);return a};q.prototype.getEditorRange=function(){var a=this.getEditorSelection();return!a||0===a.rangeCount?null:a.getRangeAt?a.getRangeAt(0):a.createRange()};q.prototype.ec=function(a,b,d){this.execCom(a,b,d)};q.prototype.heading=function(a){this.ec("formatblock",!1,j.browser.msie?"Heading "+a:"h"+a)};q.prototype.insertImage=function(a){this.isHtml()&&!this.bOnlyPlain&&(this.htmlarea.focus(),
this.ec("insertImage",!1,a))};q.prototype.focus=function(){this.isHtml()&&!this.bOnlyPlain?this.htmlarea.focus():this.textarea.focus()};q.prototype.setcolor=function(a,b){var d=null,d="";j.browser.msie&&9>c.pInt(j.browser.version)?(d=this.getEditorRange())&&d.execCommand("forecolor"===a?"ForeColor":"BackColor",!1,b):(d=j.browser.msie?"forecolor"===a?"ForeColor":"BackColor":"forecolor"===a?"foreColor":"backColor",this.ec(d,!1,b))};q.prototype.isHtml=function(){return!0===this.bOnlyPlain?!1:this.textarea.is(":hidden")};
q.prototype.toHtmlString=function(){return this.editor.innerHTML};q.prototype.toString=function(){return this.editor.innerText};q.prototype.updateTextArea=function(){this.textarea.val(this.toHtmlString())};q.prototype.updateHtmlArea=function(){this.editor.innerHTML=this.textarea.val()};q.prototype.setRawText=function(a,b){b&&!this.bOnlyPlain?(this.isHtml()||(this.textarea.val(""),this.switchToHtml()),this.textarea.val(a.toString()),this.updateHtmlArea()):(this.textarea.val(a.toString()),this.updateHtmlArea(),
this.switchToPlain(!1))};q.prototype.clear=function(){this.textarea.val("");this.editor.innerHTML="";this.bOnlyPlain?(this.toolbar.hide(),this.switchToPlain(!1)):this.switchToHtml()};q.prototype.getTextForRequest=function(){this.isHtml()&&this.updateTextArea();return this.textarea.val()};q.prototype.getTextFromHtml=function(a){var b="",d=function(){if(arguments&&1<arguments.length){var a=c.trim(arguments[1]).replace(/__bq__start__([\s\S\n\r]*)__bq__end__/gm,d),a="\n> "+c.trim(a).replace(/\n/gm,"\n> ")+
"\n>\n";return a.replace(/\n([> ]+)/gm,function(){return arguments&&1<arguments.length?"\n"+c.trim(arguments[1].replace(/[\s]/,""))+" ":""})}return""},e=function(){if(arguments&&1<arguments.length){var a=c.trim(arguments[1]);0<a.length&&(a=a.replace(/<div[^>]*>([\s\S]*)<\/div>/gmi,e),a="\n"+c.trim(a)+"\n");return a}return""},a=c.isUnd(a)?!0:!!a,b=this.toHtmlString().replace(/[\s]+/gm," ").replace(/<br\s?\/?>/gmi,"\n").replace(/<\/h\d>/gi,"\n").replace(/<\/p>/gi,"\n\n").replace(/<\/li>/gi,"\n").replace(/<\/td>/gi,
"\n").replace(/<\/tr>/gi,"\n").replace(/<hr[^>]*>/gmi,"\n_______________________________\n\n").replace(/<img [^>]*>/gmi,"").replace(/<div[^>]*>([\s\S]*)<\/div>/gmi,e).replace(/<blockquote[^>]*>/gmi,"\n__bq__start__\n").replace(/<\/blockquote>/gmi,"\n__bq__end__\n").replace(/<a [^>]*>([\s\S]*?)<\/a>/gmi,function(){return arguments&&1<arguments.length?c.trim(arguments[1]):""}).replace(/&nbsp;/gi," ").replace(/<[^>]*>/gm,"").replace(/&gt;/gi,">").replace(/&lt;/gi,"<").replace(/&amp;/gi,"&").replace(/&\w{2,6};/gi,
"");return(a?c.splitPlainText(b):b).replace(/\n[ \t]+/gm,"\n").replace(/[\n]{3,}/gm,"\n\n").replace(/__bq__start__([\s\S]*)__bq__end__/gm,d).replace(/__bq__start__/gm,"").replace(/__bq__end__/gm,"")};q.prototype.getHtmlFromText=function(){return c.convertPlainTextToHtml(this.textarea.val())};q.prototype.switchToggle=function(){this.isHtml()?this.switchToPlain():this.switchToHtml()};q.prototype.switchToPlain=function(a){var a=c.isUnd(a)?!0:a,b=this.getTextFromHtml(),d=i.bind(function(a){a&&(this.toolbar.addClass("editorHideToolbar"),
j(".editorSwitcher",this.toolbar).text(this.switcherLinkText(!1)),this.textarea.val(b),this.textarea.show(),this.htmlarea.hide(),this.fOnSwitch&&this.fOnSwitch(!1))},this);!a||0===c.trim(b).length?d(!0):d(h.confirm(this.oOptions.LangSwitcherConferm))};q.prototype.switcherLinkText=function(a){return a?this.oOptions.LangSwitcherTextLabel:this.oOptions.LangSwitcherHtmlLabel};q.prototype.switchToHtml=function(){this.toolbar.removeClass("editorHideToolbar");j(".editorSwitcher",this.toolbar).text(this.switcherLinkText(!0));
this.textarea.val(this.getHtmlFromText());this.updateHtmlArea();this.textarea.hide();this.htmlarea.show();this.fOnSwitch&&this.fOnSwitch(!0)};q.prototype.addButton=function(a,b){var d=this;j("<div />").addClass("editorToolbarButtom").append(j('<a tabindex="-1" href="javascript:void(0);"></a>').addClass(a)).attr("title",b).click(function(b){c.isUnd(q.htmlFunctions[a])?h.alert(a):q.htmlFunctions[a].apply(d,[j(this),b])}).appendTo(this.toolbar)};q.htmlInitToolbar=function(){if(!this.bOnlyPlain){this.addButton("bold",
"Bold");this.addButton("italic","Italic");this.addButton("underline","Underline");this.addButton("strikethrough","Strikethrough");this.addButton("removeformat","removeformat");this.addButton("justifyleft","justifyleft");this.addButton("justifycenter","justifycenter");this.addButton("justifyright","justifyright");this.addButton("horizontalrule","horizontalrule");this.addButton("orderedlist","orderedlist");this.addButton("unorderedlist","unorderedlist");this.addButton("indent","indent");this.addButton("outdent",
"outdent");this.addButton("forecolor","forecolor");var a=this;j("<span />").addClass("editorSwitcher").text(a.switcherLinkText(!0)).click(function(){a.switchToggle()}).appendTo(a.toolbar)}};q.htmlInitEditor=function(){this.editor=this.htmlarea[0];this.editor.innerHTML=this.textarea.val()};q.htmlAttachEditorEvents=function(){var a=this,b=function(b){if(b=(b&&b.originalEvent?b.originalEvent:b)||h.event){b.stopPropagation();b.preventDefault();var d=null,c=null;if((b=b.files||(b.dataTransfer?b.dataTransfer.files:
null))&&1===b.length&&b[0]&&b[0].type&&0===b[0].type.indexOf("image/")){var c=b[0],d=new h.FileReader,e=c;d.onload=function(b){a.insertImage(b.target.result,e.name)};d.readAsDataURL(c)}}a.htmlarea.removeClass("editorDragOver")},d=function(){a.htmlarea.removeClass("editorDragOver")},c=function(b){b.stopPropagation();b.preventDefault();a.htmlarea.addClass("editorDragOver")},e=function(b){(b=b&&b.clipboardData?b.clipboardData:b&&b.originalEvent&&b.originalEvent.clipboardData?b.originalEvent.clipboardData:
null)&&b.items&&i.each(b.items,function(b){if(b&&(b.type&&0===b.type.indexOf("image/"))&&b.getAsFile){var d=null,c=b.getAsFile();c&&(d=new h.FileReader,d.onload=function(b){a.insertImage(b.target.result,c.name)},d.readAsDataURL(c))}})};!this.bOnlyPlain&&(h.File&&h.FileReader&&h.FileList)&&(this.htmlarea.bind("dragover",c),this.htmlarea.bind("dragleave",d),this.htmlarea.bind("drop",b),this.htmlarea.bind("paste",e))};for(var kb=q,pa=[],bb=[],V=0,Ha=0,Ia=0,Ja=0,Ka="",V=0;256>V;V+=85)Ka=V.toString(16),
pa.push(1===Ka.length?"0"+Ka:Ka);Ja=pa.length;for(V=0;V<Ja;V++)for(Ha=0;Ha<Ja;Ha++)for(Ia=0;Ia<Ja;Ia++)bb.push("#"+pa[V]+""+pa[Ha]+""+pa[Ia]);kb.htmlColorPickerColors=bb;var lb=q,cb=j(h.document),db=!1,qa=j('<div style="position: absolute;" class="editorFontStylePicker"><div class="editorFpFonts"></div></div>'),eb=qa.find(".editorFpFonts"),fb=function(){};j.each("Arial;Arial Black;Courier New;Tahoma;Times New Roman;Verdana".split(";"),function(a,b){eb.append(j('<a href="javascript:void(0);" tabindex="-1" class="editorFpFont" style="font-family: '+
b+';">'+b+"</a>").click(function(){fb(b)}));eb.append("<br />")});qa.hide();lb.htmlFontPicker=function(a,b,d){db||(qa.appendTo(d),db=!0);fb=b;cb.unbind("click.fpNamespace");h.setTimeout(function(){cb.one("click.fpNamespace",function(){qa.hide()})},500);b=j(a).position();qa.css("top",5+b.top+j(a).height()+"px").css("left",b.left+"px").show()};var mb=q,gb=j(h.document),hb=!1,ra=j('<div style="position: absolute;" class="editorColorPicker"><div class="editorCpColors"></div></div>'),ib=ra.find(".editorCpColors"),
jb=function(){};j.each(q.htmlColorPickerColors,function(a,b){ib.append('<a href="javascript:void(0);" tabindex="-1" class="editorCpColor" style="background-color: '+b+';"></a>')});ra.hide();j(".editorCpColor",ib).click(function(a){var b=1,d="#000000",a=j(a.target).css("background-color"),d=a.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);if(null!==d){for(delete d[0];3>=b;++b)d[b]=c.pInt(d[b]).toString(16),1===d[b].length&&(d[b]="0"+d[b]);d="#"+d.join("")}else d=a;jb(d)});mb.htmlColorPicker=function(a,
b,d){hb||(ra.appendTo(d),hb=!0);d=j(a).position();jb=b;gb.unbind("click.cpNamespace");h.setTimeout(function(){gb.one("click.cpNamespace",function(){ra.hide()})},100);ra.css("top",5+d.top+j(a).height()+"px").css("left",d.left+"px").show()};q.htmlFunctions={bold:function(){this.ec("bold")},italic:function(){this.ec("italic")},underline:function(){this.ec("underline")},strikethrough:function(){this.ec("strikethrough")},indent:function(){this.ec("indent")},outdent:function(){this.ec("outdent")},justifyleft:function(){this.ec("justifyLeft")},
justifycenter:function(){this.ec("justifyCenter")},justifyright:function(){this.ec("justifyRight")},horizontalrule:function(){this.ec("insertHorizontalRule",!1,"ht")},removeformat:function(){this.ec("removeFormat")},orderedlist:function(){this.ec("insertorderedlist")},unorderedlist:function(){this.ec("insertunorderedlist")},forecolor:function(a){q.htmlColorPicker(a,i.bind(function(a){this.setcolor("forecolor",a)},this),this.toolbar)},backcolor:function(a){q.htmlColorPicker(a,i.bind(function(a){this.setcolor("backcolor",
a)},this),this.toolbar)},fontname:function(a){q.htmlFontPicker(a,i.bind(function(a){this.ec("fontname",!1,a)},this),this.toolbar)}};K.prototype.selectItemCallbacks=function(a){(this.oCallbacks.onItemSelect||this.emptyFunction)(a)};K.prototype.init=function(a,b){this.oContentVisible=a;this.oContentScrollable=b;if(this.oContentVisible&&this.oContentScrollable){var d=this;j(this.oContentVisible).on("click",this.sItemSelector,function(a){d.actionClick(f.dataFor(this),a)}).on("click",this.sItemCheckedSelector,
function(a){var b=f.dataFor(this);b&&(a&&a.shiftKey?d.actionClick(b,a):(d.sLastUid=d.getItemUid(b),b.selected()?(b.checked(!1),d.selectedItem(null)):b.checked(!b.checked())))});j(h.document).on("keydown",function(a){var b=!0;if(a&&d.bUseKeyboard&&!c.inFocus())if(-1<c.inArray(a.keyCode,[g.EventKeyCode.Up,g.EventKeyCode.Down,g.EventKeyCode.Insert,g.EventKeyCode.Home,g.EventKeyCode.End,g.EventKeyCode.PageUp,g.EventKeyCode.PageDown]))d.newSelectPosition(a.keyCode,a.shiftKey),b=!1;else if(g.EventKeyCode.Delete===
a.keyCode&&!a.ctrlKey&&!a.shiftKey){if(d.oCallbacks.onDelete)d.oCallbacks.onDelete();b=!1}return b})}};K.prototype.selectByUid=function(a,b){this.useItemSelectCallback=b=c.isUnd(b)?!0:!!b;var d=i.find(this.list(),function(b){return a===this.getItemUid(b)},this);d&&this.selectedItem(d);this.useItemSelectCallback=!0};K.prototype.useKeyboard=function(a){this.bUseKeyboard=!!a};K.prototype.getItemUid=function(a){var b="",d=this.oCallbacks.onItemGetUid||null;d&&a&&(b=d(a));return b.toString()};K.prototype.newSelectPosition=
function(a,b){var d=this,c=0,e=!1,f=!1,w=null,k=this.list(),j=k?k.length:0,o=this.selectedItem();if(0<j)if(o){if(o)if(g.EventKeyCode.Down===a||g.EventKeyCode.Up===a||g.EventKeyCode.Insert===a)i.each(k,function(b){if(!f)switch(a){case g.EventKeyCode.Up:o===b?f=!0:w=b;break;case g.EventKeyCode.Down:case g.EventKeyCode.Insert:e?(w=b,f=!0):o===b&&(e=!0)}});else if(g.EventKeyCode.Home===a||g.EventKeyCode.End===a)g.EventKeyCode.Home===a?w=k[0]:g.EventKeyCode.End===a&&(w=k[k.length-1]);else if(g.EventKeyCode.PageDown===
a)for(;c<j;c++){if(o===k[c]){c+=10;c=j-1<c?j-1:c;w=k[c];break}}else if(g.EventKeyCode.PageUp===a)for(c=j;0<=c;c--)if(o===k[c]){c-=10;c=0>c?0:c;w=k[c];break}}else if(g.EventKeyCode.Down===a||g.EventKeyCode.Insert===a||g.EventKeyCode.Home===a||g.EventKeyCode.PageUp===a)w=k[0];else if(g.EventKeyCode.Up===a||g.EventKeyCode.End===a||g.EventKeyCode.PageDown===a)w=k[k.length-1];w?(o&&(b?(g.EventKeyCode.Up===a||g.EventKeyCode.Down===a)&&o.checked(!o.checked()):g.EventKeyCode.Insert===a&&o.checked(!o.checked())),
this.throttleSelection=!0,this.selectedItem(w),this.throttleSelection=!0,0!==this.iSelectTimer?(h.clearTimeout(this.iSelectTimer),this.iSelectTimer=h.setTimeout(function(){d.iSelectTimer=0;d.actionClick(w)},1E3)):(this.iSelectTimer=h.setTimeout(function(){d.iSelectTimer=0},200),this.actionClick(w)),this.scrollToSelected()):o&&(b&&(g.EventKeyCode.Up===a||g.EventKeyCode.Down===a)?o.checked(!o.checked()):g.EventKeyCode.Insert===a&&o.checked(!o.checked()))};K.prototype.scrollToSelected=function(){if(!this.oContentVisible||
!this.oContentScrollable)return!1;var a=j(this.sItemSelectedSelector,this.oContentScrollable),b=a.position(),d=this.oContentVisible.height(),a=a.outerHeight();return b&&(0>b.top||b.top+a>d)?(0>b.top?this.oContentScrollable.scrollTop(this.oContentScrollable.scrollTop()+b.top-20):this.oContentScrollable.scrollTop(this.oContentScrollable.scrollTop()+b.top-d+a+20),!0):!1};K.prototype.eventClickFunction=function(a,b){var d=this.getItemUid(a),c=0,e=0,f=null,g="",k=!1,i=!1,h=[],j=!1;if(b&&b.shiftKey&&""!==
d&&""!==this.sLastUid&&d!==this.sLastUid){h=this.list();j=a.checked();c=0;for(e=h.length;c<e;c++){f=h[c];g=this.getItemUid(f);k=!1;if(g===this.sLastUid||g===d)k=!0;k&&(i=!i);(i||k)&&f.checked(j)}}this.sLastUid=""===d?"":d};K.prototype.actionClick=function(a,b){if(a){var d=!0,c=this.getItemUid(a);b&&(b.shiftKey?(d=!1,""===this.sLastUid&&(this.sLastUid=c),a.checked(!a.checked()),this.eventClickFunction(a,b)):b.ctrlKey&&(d=!1,this.sLastUid=c,a.checked(!a.checked())));d&&(this.selectedItem(a),this.sLastUid=
c)}};K.prototype.on=function(a,b){this.oCallbacks[a]=b};ta.supported=function(){return!0};ta.prototype.set=function(a,b){var d=j.cookie(t.Values.ClientSideCookieIndexName),c=null;try{(c=null===d?null:JSON.parse(d))||(c={}),c[a]=b,j.cookie(t.Values.ClientSideCookieIndexName,JSON.stringify(c),{expires:30})}catch(e){}return c};ta.prototype.get=function(a){var b=j.cookie(t.Values.ClientSideCookieIndexName),d=null;try{d=(d=null===b?null:JSON.parse(b))&&!c.isUnd(d[a])?d[a]:null}catch(e){}return d};ua.supported=
function(){return!!h.localStorage};ua.prototype.set=function(a,b){var d=h.localStorage[t.Values.ClientSideCookieIndexName]||null,c=null;try{(c=null===d?null:JSON.parse(d))||(c={}),c[a]=b,h.localStorage[t.Values.ClientSideCookieIndexName]=JSON.stringify(c)}catch(e){}return c};ua.prototype.get=function(a){var b=h.localStorage[t.Values.ClientSideCookieIndexName]||null,d=null;try{d=(d=null===b?null:JSON.parse(b))&&!c.isUnd(d[a])?d[a]:null}catch(e){}return d};va.prototype.oDriver=null;va.prototype.set=
function(a,b){return this.oDriver?this.oDriver.set("p"+a,b):!1};va.prototype.get=function(a){return this.oDriver?this.oDriver.get("p"+a):null};Xa.prototype.bootstart=function(){};C.prototype.sPosition="";C.prototype.sTemplate="";C.prototype.viewModelName="";C.prototype.viewModelDom=null;C.prototype.viewModelTemplate=function(){return this.sTemplate};C.prototype.viewModelPosition=function(){return this.sPosition};C.prototype.cancelCommand=C.prototype.closeCommand=function(){};J.prototype.oCross=null;
J.prototype.sScreenName="";J.prototype.aViewModels=[];J.prototype.viewModels=function(){return this.aViewModels};J.prototype.screenName=function(){return this.sScreenName};J.prototype.routes=function(){return null};J.prototype.__cross=function(){return this.oCross};J.prototype.__start=function(){var a=this.routes(),b=null,d=null;c.isNonEmptyArray(a)&&(d=i.bind(this.onRoute||c.emptyFunction,this),b=Wa.create(),i.each(a,function(a){b.addRoute(a[0],d).rules=a[1]}),this.oCross=b)};E.prototype.sDefaultScreenName=
"";E.prototype.oScreens={};E.prototype.oBoot=null;E.prototype.oCurrentScreen=null;E.prototype.showLoading=function(){j("#rl-loading").show()};E.prototype.hideLoading=function(){j("#rl-loading").hide()};E.prototype.routeOff=function(){P.changed.active=!1};E.prototype.routeOn=function(){P.changed.active=!0};E.prototype.setBoot=function(a){c.isNormal(a)&&(this.oBoot=a);return this};E.prototype.screen=function(a){return""!==a&&!c.isUnd(this.oScreens[a])?this.oScreens[a]:null};E.prototype.delegateRun=
function(a,b,d){a&&a[b]&&a[b].apply(a,c.isArray(d)?d:[])};E.prototype.buildViewModel=function(a,b){if(a&&!a.__builded){var d=new a(b),l=d.viewModelPosition(),g=j("#rl-content #rl-"+l.toLowerCase()),r=null;a.__builded=!0;a.__vm=d;d.data=e.data();d.viewModelName=a.__name;g&&1===g.length?(r=j("<div>").addClass("rl-view-model").addClass("RL-"+d.viewModelTemplate()).hide().attr("data-bind",'template: {name: "'+d.viewModelTemplate()+'"}, i18nInit: true'),r.appendTo(g),d.viewModelDom=r,a.__dom=r,"Popups"===
l&&(d.cancelCommand=d.closeCommand=c.createCommand(d,function(){s.hideScreenPopup(a)})),x.runHook("view-model-pre-build",[a.__name,d,r]),f.applyBindings(d,r[0]),this.delegateRun(d,"onBuild",[r]),x.runHook("view-model-post-build",[a.__name,d,r])):c.log("Cannot find view model position: "+l)}return a?a.__vm:null};E.prototype.applyExternal=function(a,b){a&&b&&f.applyBindings(a,b)};E.prototype.hideScreenPopup=function(a){a&&(a.__vm&&a.__dom)&&(a.__dom.hide(),a.__vm.modalVisibility(!1),this.delegateRun(a.__vm,
"onHide"),this.popupVisibility(!1),i.defer(function(){a.__dom.find(".ko-select2").select2("close")}))};E.prototype.showScreenPopup=function(a,b){a&&(this.buildViewModel(a),a.__vm&&a.__dom&&(a.__dom.show(),a.__vm.modalVisibility(!0),this.delegateRun(a.__vm,"onShow",b||[]),this.popupVisibility(!0),x.runHook("view-model-on-show",[a.__name,a.__vm,b||[]])))};E.prototype.screenOnRoute=function(a,b){var d=this,e=null,f=null;""===c.pString(a)&&(a=this.sDefaultScreenName);if(""!==a){e=this.screen(a);if(!e&&
(e=this.screen(this.sDefaultScreenName)))b=a+"/"+b,a=this.sDefaultScreenName;e&&e.__started&&(e.__builded||(e.__builded=!0,c.isNonEmptyArray(e.viewModels())&&i.each(e.viewModels(),function(a){this.buildViewModel(a,e)},this),this.delegateRun(e,"onBuild")),i.defer(function(){if(d.oCurrentScreen){d.delegateRun(d.oCurrentScreen,"onHide");c.isNonEmptyArray(d.oCurrentScreen.viewModels())&&i.each(d.oCurrentScreen.viewModels(),function(a){if(a.__vm&&a.__dom&&"Popups"!==a.__vm.viewModelPosition()){a.__dom.hide();
a.__vm.viewModelVisibility(false);d.delegateRun(a.__vm,"onHide")}})}d.oCurrentScreen=e;if(d.oCurrentScreen){d.delegateRun(d.oCurrentScreen,"onShow");x.runHook("screen-on-show",[d.oCurrentScreen.screenName(),d.oCurrentScreen]);c.isNonEmptyArray(d.oCurrentScreen.viewModels())&&i.each(d.oCurrentScreen.viewModels(),function(a){if(a.__vm&&a.__dom&&"Popups"!==a.__vm.viewModelPosition()){a.__dom.show();a.__vm.viewModelVisibility(true);d.delegateRun(a.__vm,"onShow");x.runHook("view-model-on-show",[a.__name,
a.__vm])}},d)}(f=e.__cross())&&f.parse(b)}))}};E.prototype.startScreens=function(a){i.each(a,function(a){var d=(a=new a)?a.screenName():"";a&&""!==d&&(""===this.sDefaultScreenName&&(this.sDefaultScreenName=d),this.oScreens[d]=a)},this);i.each(this.oScreens,function(a){a&&(!a.__started&&a.__start)&&(a.__started=!0,a.__start(),x.runHook("screen-pre-start",[a.screenName(),a]),this.delegateRun(a,"onStart"),x.runHook("screen-post-start",[a.screenName(),a]))},this);a=Wa.create();a.addRoute(/^([a-zA-Z0-9\-]*)\/?(.*)$/,
i.bind(this.screenOnRoute,this));P.initialized.add(a.parse,a);P.changed.add(a.parse,a);P.init()};E.prototype.setHash=function(a,b){a="#"===a.substr(0,1)?a.substr(1):a;a="/"===a.substr(0,1)?a.substr(1):a;(c.isUnd(b)?0:b)?(P.changed.active=!1,P.setHash(a),P.changed.active=!0):(P.changed.active=!0,P.setHash(a))};E.prototype.bootstart=function(){this.oBoot&&this.oBoot.bootstart&&this.oBoot.bootstart();return this};s=new E;F.newInstanceFromJson=function(a){var b=new F;return b.initByJson(a)?b:null};F.prototype.name=
"";F.prototype.email="";F.prototype.privateType=null;F.prototype.validate=function(){return""!==this.name||""!==this.email};F.prototype.hash=function(a){return"#"+(a?"":this.name)+"#"+this.email+"#"};F.prototype.clearDuplicateName=function(){this.name===this.email&&(this.name="")};F.prototype.type=function(){if(null===this.privateType&&(this.email&&"@facebook.com"===this.email.substr(-13)&&(this.privateType=g.EmailType.Facebook),null===this.privateType))this.privateType=g.EmailType.Default;return this.privateType};
F.prototype.search=function(a){return-1<(this.name+" "+this.email).toLowerCase().indexOf(a.toLowerCase())};F.prototype.parse=function(a){var a=c.trim(a),b=/(?:"([^"]+)")? ?<?(.*?@[^>,]+)>?,? ?/g.exec(a);b?(this.name=b[1]||"",this.email=b[2]||"",this.clearDuplicateName()):/^[^@]+@[^@]+$/.test(a)&&(this.name="",this.email=a)};F.prototype.initByJson=function(a){var b=!1;a&&"Object/Email"===a["@Object"]&&(this.name=c.trim(a.Name),this.email=c.trim(a.Email),b=""!==this.email,this.clearDuplicateName());
return b};F.prototype.toLine=function(a,b){var d="";""!==this.email&&(b=c.isUnd(b)?!1:!!b,a&&""!==this.name?d=b?'<a href="mailto:'+c.encodeHtml('"'+this.name+'" <'+this.email+">")+'" target="_blank" tabindex="-1">'+c.encodeHtml(this.name)+"</a>":this.name:(d=this.email,""!==this.name?d=b?c.encodeHtml('"'+this.name+'" <')+'<a href="mailto:'+c.encodeHtml('"'+this.name+'" <'+this.email+">")+'" target="_blank" tabindex="-1">'+c.encodeHtml(d)+"</a>"+c.encodeHtml(">"):'"'+this.name+'" <'+d+">":b&&(d='<a href="mailto:'+
c.encodeHtml(this.email)+'" target="_blank" tabindex="-1">'+c.encodeHtml(this.email)+"</a>")));return d};F.prototype.select2Result=function(){var a="",b=e.cache().getUserPic(this.email),a=""!==b?a+('<img class="select2-user-pic pull-left" src="'+c.encodeHtml(b)+'" />'):a+('<img class="select2-user-pic pull-left" src="'+e.link().emptyContactPic()+'" />');g.EmailType.Facebook===this.type()?(a+=""+(0<this.name.length?this.name:this.email),a+='<i class="icon-facebook pull-right select2-icon-result" />'):
a+=""+(0<this.name.length?this.email+' <span class="select2-subname">('+this.name+")</span>":this.email);return a+""};F.prototype.select2Selection=function(a){var b="";if(g.EmailType.Facebook===this.type()){if(b=0<this.name.length?this.name:this.email,""!==b)return j("<pan>").text(b).appendTo(a),a.append('<i class="icon-facebook select2-icon"></i>'),null}else b=0<this.name.length?this.name+" ("+this.email+")":this.email;return b};ka.prototype.parse=function(a){var b=!1;a&&"Object/Contact"===a["@Object"]&&
(this.idContact=c.pInt(a.IdContact),this.listName=c.pString(a.ListName),this.name=c.pString(a.Name),this.emails=c.isNonEmptyArray(a.Emails)?a.Emails:[],this.imageHash=c.pString(a.ImageHash),b=!0);return b};ka.prototype.srcAttr=function(){return""===this.imageHash?e.link().emptyContactPic():e.link().getUserPicUrlFromHash(this.imageHash)};ka.prototype.generateUid=function(){return""+this.idContact};ka.prototype.lineAsCcc=function(){var a=[];this.deleted()&&a.push("deleted");this.selected()&&a.push("selected");
this.checked()&&a.push("checked");return a.join(" ")};D.newInstanceFromJson=function(a){var b=new D;return b.initByJson(a)?b:null};D.prototype.mimeType="";D.prototype.fileName="";D.prototype.estimatedSize=0;D.prototype.friendlySize="";D.prototype.isInline=!1;D.prototype.isLinked=!1;D.prototype.cid="";D.prototype.cidWithOutTags="";D.prototype.download="";D.prototype.folder="";D.prototype.uid="";D.prototype.mimeIndex="";D.prototype.initByJson=function(a){var b=!1;a&&"Object/Attachment"===a["@Object"]&&
(this.mimeType=a.MimeType,this.fileName=a.FileName,this.estimatedSize=c.pInt(a.EstimatedSize),this.isInline=!!a.IsInline,this.isLinked=!!a.IsLinked,this.cid=a.CID,this.download=a.Download,this.folder=a.Folder,this.uid=a.Uid,this.mimeIndex=a.MimeIndex,this.friendlySize=c.friendlySize(this.estimatedSize),this.cidWithOutTags=this.cid.replace(/^<+/,"").replace(/>+$/,""),b=!0);return b};D.prototype.isImage=function(){return"image/"===this.mimeType.substr(0,6)};D.prototype.isText=function(){return"text/"===
this.mimeType.substr(0,5)};D.prototype.linkDownload=function(){return e.link().attachmentDownload(this.download)};D.prototype.linkPreview=function(){return e.link().attachmentPreview(this.download)};D.prototype.linkPreviewAsPlain=function(){return e.link().attachmentPreviewAsPlain(this.download)};D.prototype.generateTransferDownloadUrl=function(){var a=this.linkDownload();"http"!==a.substr(0,4)&&(a=h.location.protocol+"//"+h.location.host+h.location.pathname+a);return this.mimeType+":"+this.fileName+
":"+a};D.prototype.eventDragStart=function(a,b){var d=b.originalEvent||b;a&&(d&&d.dataTransfer&&d.dataTransfer.setData)&&d.dataTransfer.setData("DownloadURL",this.generateTransferDownloadUrl());return!0};D.prototype.iconClass=function(){var a=this.mimeType.toLocaleString().split("/"),b="icon-file";a&&a[1]&&("image"===a[0]?b="icon-image":"text"===a[0]?b="icon-file-xml":"audio"===a[0]?b="icon-music":"video"===a[0]?b="icon-film":-1<c.inArray(a[1],"zip 7z tar rar gzip bzip bzip2 x-zip x-7z x-rar x-tar x-gzip x-bzip x-bzip2 x-zip-compressed x-7z-compressed x-rar-compressed".split(" "))?
b="icon-file-zip":-1<c.inArray(a[1],["pdf","x-pdf"])?b="icon-file-pdf":-1<c.inArray(a[1],["exe","x-exe","x-winexe","bat"])?b="icon-console":-1<c.inArray(a[1],"rtf msword vnd.msword vnd.openxmlformats-officedocument.wordprocessingml.document vnd.openxmlformats-officedocument.wordprocessingml.template vnd.ms-word.document.macroEnabled.12 vnd.ms-word.template.macroEnabled.12".split(" "))?b="icon-file-word":-1<c.inArray(a[1],"excel ms-excel vnd.ms-excel vnd.openxmlformats-officedocument.spreadsheetml.sheet vnd.openxmlformats-officedocument.spreadsheetml.template vnd.ms-excel.sheet.macroEnabled.12 vnd.ms-excel.template.macroEnabled.12 vnd.ms-excel.addin.macroEnabled.12 vnd.ms-excel.sheet.binary.macroEnabled.12".split(" "))?
b="icon-file-excel":-1<c.inArray(a[1],"powerpoint ms-powerpoint vnd.ms-powerpoint vnd.openxmlformats-officedocument.presentationml.presentation vnd.openxmlformats-officedocument.presentationml.template vnd.openxmlformats-officedocument.presentationml.slideshow vnd.ms-powerpoint.addin.macroEnabled.12 vnd.ms-powerpoint.presentation.macroEnabled.12 vnd.ms-powerpoint.template.macroEnabled.12 vnd.ms-powerpoint.slideshow.macroEnabled.12".split(" "))&&(b="icon-file-powerpoint"));return b};M.prototype.id=
"";M.prototype.isInline=!1;M.prototype.isLinked=!1;M.prototype.CID="";M.prototype.fromMessage=!1;M.prototype.cancel=c.emptyFunction;M.prototype.initByUploadJson=function(a){var b=!1;a&&(this.fileName(a.Name),this.size(c.isUnd(a.Size)?0:c.pInt(a.Size)),this.tempName(c.isUnd(a.TempName)?"":a.TempName),this.isInline=!1,b=!0);return b};m.newInstanceFromJson=function(a){var b=new m;return b.initByJson(a)?b:null};m.calculateFullFromatDateValue=function(a){return Z.unix(a).format("LLL")};m.emailsToLine=
function(a,b,d){var e=[],f=0,g=0;if(c.isNonEmptyArray(a)){f=0;for(g=a.length;f<g;f++)e.push(a[f].toLine(b,d))}return e.join(", ")};m.initEmailsFromJson=function(a){var b=0,d=0,e=null,f=[];if(c.isNonEmptyArray(a)){b=0;for(d=a.length;b<d;b++)(e=F.newInstanceFromJson(a[b]))&&f.push(e)}return f};m.replyHelper=function(a,b,d){if(a&&0<a.length)for(var e=0,f=a.length;e<f;e++)c.isUnd(b[a[e].email])&&(b[a[e].email]=!0,d.push(a[e]))};m.prototype.initByJson=function(a){var b=!1;a&&"Object/Message"===a["@Object"]&&
(this.folderFullNameRaw=a.Folder,this.uid=a.Uid,this.requestHash=a.RequestHash,this.prefetched=!1,this.size(c.pInt(a.Size)),this.from=m.initEmailsFromJson(a.From),this.to=m.initEmailsFromJson(a.To),this.cc=m.initEmailsFromJson(a.Cc),this.bcc=m.initEmailsFromJson(a.Bcc),this.replyTo=m.initEmailsFromJson(a.ReplyTo),this.subject(a.Subject),this.dateTimeStampInUTC(c.pInt(a.DateTimeStampInUTC)),this.hasAttachments(!!a.HasAttachments),this.fromEmailString(m.emailsToLine(this.from,!0)),this.toEmailsString(m.emailsToLine(this.to,
!0)),this.parentUid(c.pInt(a.ParentThread)),this.threads(c.isArray(a.Threads)?a.Threads:[]),this.threadsLen(c.pInt(a.ThreadsLen)),this.initFlagsByJson(a),this.computeSenderEmail(),b=!0);return b};m.prototype.computeSenderEmail=function(){var a=e.data().sentFolder(),b=e.data().draftFolder();this.senderEmailsString(this.folderFullNameRaw===a||this.folderFullNameRaw===b?this.toEmailsString():this.fromEmailString())};m.prototype.initUpdateByMessageJson=function(a){var b=!1,d=g.MessagePriority.Normal;
a&&"Object/Message"===a["@Object"]&&(d=c.pInt(a.Priority),this.priority(-1<c.inArray(d,[g.MessagePriority.High,g.MessagePriority.Low])?d:g.MessagePriority.Normal),this.aDraftInfo=a.DraftInfo,this.sMessageId=a.MessageId,this.sInReplyTo=a.InReplyTo,this.sReferences=a.References,this.hasAttachments(!!a.HasAttachments),this.foundedCIDs=c.isArray(a.FoundedCIDs)?a.FoundedCIDs:[],this.attachments(this.initAttachmentsFromJson(a.Attachments)),this.computeSenderEmail(),b=!0);return b};m.prototype.initAttachmentsFromJson=
function(a){var b=0,d=0,e=null,f=[];if(a&&"Collection/AttachmentCollection"===a["@Object"]&&c.isNonEmptyArray(a["@Collection"])){b=0;for(d=a["@Collection"].length;b<d;b++)if(e=D.newInstanceFromJson(a["@Collection"][b]))""!==e.cidWithOutTags&&(0<this.foundedCIDs.length&&0<=c.inArray(e.cidWithOutTags,this.foundedCIDs))&&(e.isLinked=!0),f.push(e)}return f};m.prototype.initFlagsByJson=function(a){var b=!1;a&&"Object/Message"===a["@Object"]&&(this.unseen(!a.IsSeen),this.flagged(!!a.IsFlagged),this.answered(!!a.IsAnswered),
this.forwarded(!!a.IsForwarded),b=!0);return b};m.prototype.fromToLine=function(a,b){return m.emailsToLine(this.from,a,b)};m.prototype.toToLine=function(a,b){return m.emailsToLine(this.to,a,b)};m.prototype.ccToLine=function(a,b){return m.emailsToLine(this.cc,a,b)};m.prototype.bccToLine=function(a,b){return m.emailsToLine(this.bcc,a,b)};m.prototype.lineAsCcc=function(){var a=[];this.deleted()&&a.push("deleted");this.selected()&&a.push("selected");this.checked()&&a.push("checked");this.flagged()&&a.push("flagged");
this.unseen()&&a.push("unseen");this.answered()&&a.push("answered");this.forwarded()&&a.push("forwarded");this.hasAttachments()&&a.push("withAttachments");this.newForAnimation()&&a.push("new");""===this.subject()&&a.push("emptySubject");0<this.parentUid()&&a.push("hasParentMessage");0<this.threadsLen()&&a.push("hasChildrenMessage");this.hasUnseenSubMessage()&&a.push("hasUnseenSubMessage");this.hasFlaggedSubMessage()&&a.push("hasFlaggedSubMessage");return a.join(" ")};m.prototype.hasVisibleAttachments=
function(){return!!i.find(this.attachments(),function(a){return!a.isLinked})};m.prototype.findAttachmentByCid=function(a){var b=null,d=this.attachments();c.isNonEmptyArray(d)&&(a=a.replace(/^<+/,"").replace(/>+$/,""),b=i.find(d,function(b){return a===b.cidWithOutTags}));return b||null};m.prototype.messageId=function(){return this.sMessageId};m.prototype.inReplyTo=function(){return this.sInReplyTo};m.prototype.references=function(){return this.sReferences};m.prototype.fromAsSingleEmail=function(){return c.isArray(this.from)&&
this.from[0]?this.from[0].email:""};m.prototype.viewLink=function(){return e.link().messageViewLink(this.requestHash)};m.prototype.downloadLink=function(){return e.link().messageDownloadLink(this.requestHash)};m.prototype.replyEmails=function(a){var b=[],a=c.isUnd(a)?{}:a;m.replyHelper(this.replyTo,a,b);0===b.length&&m.replyHelper(this.from,a,b);return b};m.prototype.replyAllEmails=function(a){var b=[],d=[],a=c.isUnd(a)?{}:a;m.replyHelper(this.replyTo,a,b);0===b.length&&m.replyHelper(this.from,a,
b);m.replyHelper(this.to,a,b);m.replyHelper(this.cc,a,d);return[b,d]};m.prototype.textBodyToString=function(){return this.body?this.body.html():""};m.prototype.attachmentsToStringLine=function(){var a=i.map(this.attachments(),function(a){return a.fileName+" ("+a.friendlySize+")"});return a&&0<a.length?a.join(", "):""};m.prototype.getDataForWindowPopup=function(){return{popupFrom:this.fromToLine(!1),popupTo:this.toToLine(!1),popupCc:this.ccToLine(!1),popupBcc:this.bccToLine(!1),popupSubject:this.subject(),
popupDate:this.fullFormatDateValue(),popupAttachments:this.attachmentsToStringLine(),popupBody:this.textBodyToString()}};m.prototype.viewPopupMessage=function(a){c.windowPopupKnockout(this.getDataForWindowPopup(),"PopupsWindowSimpleMessage",this.subject(),function(b){b&&(b.document&&b.document.body)&&(j("img.lazy",b.document.body).each(function(a,b){var c=j(b),e=c.data("original"),f=c.attr("src");0<=a&&(e&&!f)&&c.attr("src",e)}),a&&h.setTimeout(function(){b.print()},100))})};m.prototype.printMessage=
function(){this.viewPopupMessage(!0)};m.prototype.generateUid=function(){return this.folderFullNameRaw+"/"+this.uid};m.prototype.populateByMessageListItem=function(a){this.folderFullNameRaw=a.folderFullNameRaw;this.uid=a.uid;this.requestHash=a.requestHash;this.subject(a.subject());this.size(a.size());this.dateTimeStampInUTC(a.dateTimeStampInUTC());this.priority(a.priority());this.fromEmailString(a.fromEmailString());this.toEmailsString(a.toEmailsString());this.emails=a.emails;this.from=a.from;this.to=
a.to;this.cc=a.cc;this.bcc=a.bcc;this.replyTo=a.replyTo;this.unseen(a.unseen());this.flagged(a.flagged());this.answered(a.answered());this.forwarded(a.forwarded());this.selected(a.selected());this.checked(a.checked());this.hasAttachments(a.hasAttachments());this.moment(a.moment());this.body=null;this.priority(g.MessagePriority.Normal);this.aDraftInfo=[];this.sReferences=this.sInReplyTo=this.sMessageId="";this.parentUid(a.parentUid());this.threads(a.threads());this.threadsLen(a.threadsLen());this.computeSenderEmail();
return this};m.prototype.showExternalImages=function(a){this.body&&this.body.data("rl-has-images")&&(a=c.isUnd(a)?!1:a,this.hasImages(!1),this.body.data("rl-has-images",!1),j("[data-x-src]",this.body).each(function(){a&&j(this).is("img")?j(this).addClass("lazy").attr("data-original",j(this).attr("data-x-src")).removeAttr("data-x-src"):j(this).attr("src",j(this).attr("data-x-src")).removeAttr("data-x-src")}),j("[data-x-style-url]",this.body).each(function(){var a=c.trim(j(this).attr("style")),a=""===
a?"":";"===a.substr(-1)?a+" ":a+"; ";j(this).attr("style",a+j(this).attr("data-x-style-url")).removeAttr("data-x-style-url")}),a&&(j("img.lazy",this.body).addClass("lazy-inited").lazyload({threshold:400,effect:"fadeIn",skip_invisible:!1,container:j(".RL-MailMessageView .messageView .messageItem .content")[0]}),N.resize()),c.windowResize(500))};m.prototype.showInternalImages=function(a){if(this.body&&!this.body.data("rl-init-internal-images")){var a=c.isUnd(a)?!1:a,b=this;this.body.data("rl-init-internal-images",
!0);j("[data-x-src-cid]",this.body).each(function(){var d=b.findAttachmentByCid(j(this).attr("data-x-src-cid"));d&&d.download&&(a&&j(this).is("img")?j(this).addClass("lazy").attr("data-original",d.linkPreview()):j(this).attr("src",d.linkPreview()))});j("[data-x-style-cid]",this.body).each(function(){var a="",d="",e=b.findAttachmentByCid(j(this).attr("data-x-style-cid"));e&&e.linkPreview&&(d=j(this).attr("data-x-style-cid-name"),""!==d&&(a=c.trim(j(this).attr("style")),a=""===a?"":";"===a.substr(-1)?
a+" ":a+"; ",j(this).attr("style",a+d+": url('"+e.linkPreview()+"')")))});if(a){var d=j("img.lazy",b.body),e=j(".RL-MailMessageView .messageView .messageItem .content")[0];i.delay(function(){d.addClass("lazy-inited").lazyload({threshold:400,effect:"fadeIn",skip_invisible:!1,container:e})},300)}c.windowResize(500)}};G.newInstanceFromJson=function(a){var b=new G;return b.initByJson(a)?b.initComputed():null};G.prototype.initComputed=function(){this.hasSubScribedSubfolders=f.computed(function(){return!!i.find(this.subFolders(),
function(a){return a.subScribed()})},this);this.visible=f.computed(function(){var a=this.subScribed(),b=this.hasSubScribedSubfolders();return a||b&&(!this.existen||!this.selectable)},this);this.isSystemFolder=f.computed(function(){return g.FolderType.User!==this.type()},this);this.hidden=f.computed(function(){var a=this.isSystemFolder(),b=this.hasSubScribedSubfolders();return this.isGmailFolder||a&&this.isNamespaceFolder||a&&!b},this);this.selectableForFolderList=f.computed(function(){return!this.isSystemFolder()&&
this.selectable},this);this.messageCountAll=f.computed({read:this.privateMessageCountAll,write:function(a){c.isPosNumeric(a,!0)?this.privateMessageCountAll(a):this.privateMessageCountAll.valueHasMutated()},owner:this});this.messageCountUnread=f.computed({read:this.privateMessageCountUnread,write:function(a){c.isPosNumeric(a,!0)?this.privateMessageCountUnread(a):this.privateMessageCountUnread.valueHasMutated()},owner:this});this.printableUnreadCount=f.computed(function(){var a=this.messageCountAll(),
b=this.messageCountUnread(),d=this.type();return 0<b&&(g.FolderType.Inbox===d||g.FolderType.Spam===d)?""+b:0<a&&g.FolderType.Draft===d?""+a:""},this);this.canBeDeleted=f.computed(function(){return!this.isSystemFolder()&&0===this.subFolders().length&&"INBOX"!==this.fullNameRaw},this);this.canBeSubScribed=f.computed(function(){return!this.isSystemFolder()&&this.selectable&&"INBOX"!==this.fullNameRaw},this);this.visible.subscribe(function(){c.timeOutAction("folder-list-folder-visibility-change",function(){N.trigger("folder-list-folder-visibility-change")},
100)});this.localName=f.computed(function(){ia();var a=this.type(),b=this.name();if(this.isSystemFolder())switch(a){case g.FolderType.Inbox:b=c.i18n("FOLDER_LIST/INBOX_NAME");break;case g.FolderType.SentItems:b=c.i18n("FOLDER_LIST/SENT_NAME");break;case g.FolderType.Draft:b=c.i18n("FOLDER_LIST/DRAFTS_NAME");break;case g.FolderType.Spam:b=c.i18n("FOLDER_LIST/SPAM_NAME");break;case g.FolderType.Trash:b=c.i18n("FOLDER_LIST/TRASH_NAME")}return b},this);this.manageFolderSystemName=f.computed(function(){ia();
var a="",b=this.type(),d=this.name();if(this.isSystemFolder())switch(b){case g.FolderType.Inbox:a="("+c.i18n("FOLDER_LIST/INBOX_NAME")+")";break;case g.FolderType.SentItems:a="("+c.i18n("FOLDER_LIST/SENT_NAME")+")";break;case g.FolderType.Draft:a="("+c.i18n("FOLDER_LIST/DRAFTS_NAME")+")";break;case g.FolderType.Spam:a="("+c.i18n("FOLDER_LIST/SPAM_NAME")+")";break;case g.FolderType.Trash:a="("+c.i18n("FOLDER_LIST/TRASH_NAME")+")"}if(""!==a&&"("+d+")"===a||"(inbox)"===a.toLowerCase())a="";return a},
this);this.collapsed=f.computed({read:function(){return!this.hidden()&&this.collapsedPrivate()},write:function(a){this.collapsedPrivate(a)},owner:this});return this};G.prototype.fullName="";G.prototype.fullNameRaw="";G.prototype.fullNameHash="";G.prototype.delimiter="";G.prototype.namespace="";G.prototype.deep=0;G.prototype.isNamespaceFolder=!1;G.prototype.isGmailFolder=!1;G.prototype.isUnpaddigFolder=!1;G.prototype.collapsedCss=function(){return this.hasSubScribedSubfolders()?this.collapsed()?"icon-arrow-right-3 e-collapsed-sign":
"icon-arrow-down-3 e-collapsed-sign":"icon-none e-collapsed-sign"};G.prototype.initByJson=function(a){var b=!1;a&&"Object/Folder"===a["@Object"]&&(this.name(a.Name),this.delimiter=a.Delimiter,this.fullName=a.FullName,this.fullNameRaw=a.FullNameRaw,this.fullNameHash=a.FullNameHash,this.deep=a.FullNameRaw.split(this.delimiter).length-1,this.selectable=!!a.IsSelectable,this.existen=!!a.IsExisten,this.subScribed(!!a.IsSubscribed),this.type("INBOX"===this.fullNameRaw?g.FolderType.Inbox:g.FolderType.User),
b=!0);return b};G.prototype.printableFullName=function(){return this.fullName.split(this.delimiter).join(" / ")};La.prototype.email="";La.prototype.changeAccountLink=function(){return e.link().change(this.email)};c.extendAsViewModel("PopupsFolderClearViewModel",wa);wa.prototype.clearPopup=function(){this.clearingProcess(!1);this.selectedFolder(null)};wa.prototype.onShow=function(a){this.clearPopup();a&&this.selectedFolder(a)};c.extendAsViewModel("PopupsFolderCreateViewModel",ba);ba.prototype.sNoParentText=
"";ba.prototype.simpleFolderNameValidation=function(a){return/^[^\\\/]+$/g.test(c.trim(a))};ba.prototype.clearPopup=function(){this.folderName("");this.selectedParentValue("");this.focusTrigger(!1)};ba.prototype.onShow=function(){this.clearPopup();this.focusTrigger(!0)};c.extendAsViewModel("PopupsFolderSystemViewModel",X);X.prototype.sChooseOnText="";X.prototype.sUnuseText="";X.prototype.onShow=function(a){var b="",a=c.isUnd(a)?g.SetSystemFoldersNotification.None:a;switch(a){case g.SetSystemFoldersNotification.Sent:b=
c.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_SENT");break;case g.SetSystemFoldersNotification.Draft:b=c.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_DRAFTS");break;case g.SetSystemFoldersNotification.Spam:b=c.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_SPAM");break;case g.SetSystemFoldersNotification.Trash:b=c.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_TRASH")}this.notification(b)};c.extendAsViewModel("PopupsComposeViewModel",y);y.prototype.formattedFrom=function(){var a=e.data().displayName(),b=e.data().accountEmail();
return""===a?b:a+" ("+b+")"};y.prototype.sendMessageResponse=function(a,b){var d=!1;this.sending(!1);g.StorageResultType.Success===a&&(b&&b.Result)&&(d=!0,this.modalVisibility()&&s.delegateRun(this,"closeCommand"));this.modalVisibility()&&!d&&(b&&g.Notification.CantSaveMessage===b.ErrorCode?(this.sendSuccessButSaveError(!0),h.alert(c.trim(c.i18n("COMPOSE/SAVED_ERROR_ON_SEND")))):(this.sendError(!0),h.alert(c.getNotification(b.ErrorCode?b.ErrorCode:g.Notification.CantSendMessage))))};y.prototype.saveMessageResponse=
function(a,b){var d=!1,f=null;this.saving(!1);if(g.StorageResultType.Success===a&&(b&&b.Result)&&(b.Result.NewFolder&&b.Result.NewUid)&&(this.bFromDraft&&(f=e.data().message())&&(this.draftFolder()===f.folderFullNameRaw&&this.draftUid()===f.uid)&&e.data().message(null),this.draftFolder(b.Result.NewFolder),this.draftUid(b.Result.NewUid),this.modalVisibility()))this.savedTime(h.Math.round((new h.Date).getTime()/1E3)),this.savedOrSendingText(0<this.savedTime()?c.i18n("COMPOSE/SAVED_TIME",{TIME:Z.unix(this.savedTime()-
1).format("LT")}):""),d=!0,this.bFromDraft&&e.cache().setFolderHash(this.draftFolder(),"");!this.modalVisibility()&&!d&&(this.savedError(!0),this.savedOrSendingText(c.getNotification(g.Notification.CantSaveMessage)))};y.prototype.onHide=function(){s.routeOn()};y.prototype.onShow=function(a,b,d){s.routeOff();var f=this,W="",r="",w="",k="",h="",o=null,k=o="",m=[],W={},k=e.data().accountEmail(),n=[],n=r=null,m=!1,a=a||g.ComposeType.Empty;(b=b||null)&&c.isNormal(b)&&(n=c.isArray(b)&&1===b.length?b[0]:
!c.isArray(b)?b:null);null!==k&&(W[k]=!0);this.reset();c.isNonEmptyArray(d)&&this.to(d);if(""!==a&&n){k=n.fullFormatDateValue();h=n.subject();r=n.aDraftInfo;o=j(n.body).clone();c.removeBlockquoteSwitcher(o);o=o.html();switch(a){case g.ComposeType.Reply:this.to(n.replyEmails(W));this.subject(c.replySubjectAdd("Re",h));this.prepearMessageAttachments(n,a);this.aDraftInfo=["reply",n.uid,n.folderFullNameRaw];this.sInReplyTo=n.sMessageId;this.sReferences=c.trim(this.sInReplyTo+" "+n.sReferences);m=!0;break;
case g.ComposeType.ReplyAll:m=n.replyAllEmails(W);this.to(m[0]);this.cc(m[1]);this.subject(c.replySubjectAdd("Re",h));this.prepearMessageAttachments(n,a);this.aDraftInfo=["reply",n.uid,n.folderFullNameRaw];this.sInReplyTo=n.sMessageId;this.sReferences=c.trim(this.sInReplyTo+" "+n.references());m=!0;break;case g.ComposeType.Forward:this.subject(c.replySubjectAdd("Fwd",h));this.prepearMessageAttachments(n,a);this.aDraftInfo=["forward",n.uid,n.folderFullNameRaw];this.sInReplyTo=n.sMessageId;this.sReferences=
c.trim(this.sInReplyTo+" "+n.sReferences);break;case g.ComposeType.ForwardAsAttachment:this.subject(c.replySubjectAdd("Fwd",h));this.prepearMessageAttachments(n,a);this.aDraftInfo=["forward",n.uid,n.folderFullNameRaw];this.sInReplyTo=n.sMessageId;this.sReferences=c.trim(this.sInReplyTo+" "+n.sReferences);break;case g.ComposeType.Draft:this.to(n.to),this.cc(n.cc),this.bcc(n.bcc),this.bFromDraft=!0,this.draftFolder(n.folderFullNameRaw),this.draftUid(n.uid),this.subject(h),this.prepearMessageAttachments(n,
a),this.aDraftInfo=c.isNonEmptyArray(r)&&3===r.length?r:null,this.sInReplyTo=n.sInReplyTo,this.sReferences=n.sReferences}if(this.oEditor){switch(a){case g.ComposeType.Reply:case g.ComposeType.ReplyAll:W=n.fromToLine(!1,!0);k=c.i18n("COMPOSE/REPLY_MESSAGE_TITLE",{DATETIME:k,EMAIL:W});o="<br /><br />"+k+":<blockquote><br />"+o+"</blockquote>";break;case g.ComposeType.Forward:W=n.fromToLine(!1,!0);r=n.toToLine(!1,!0);w=n.ccToLine(!1,!0);o="<br /><br /><br />"+c.i18n("COMPOSE/FORWARD_MESSAGE_TOP_TITLE")+
"<br />"+c.i18n("COMPOSE/FORWARD_MESSAGE_TOP_FROM")+": "+W+"<br />"+c.i18n("COMPOSE/FORWARD_MESSAGE_TOP_TO")+": "+r+(0<w.length?"<br />"+c.i18n("COMPOSE/FORWARD_MESSAGE_TOP_CC")+": "+w:"")+"<br />"+c.i18n("COMPOSE/FORWARD_MESSAGE_TOP_SENT")+": "+c.encodeHtml(k)+"<br />"+c.i18n("COMPOSE/FORWARD_MESSAGE_TOP_SUBJECT")+": "+c.encodeHtml(h)+"<br /><br />"+o;break;case g.ComposeType.ForwardAsAttachment:o=""}this.oEditor.setRawText(o,n.isHtml)}}else this.oEditor&&g.ComposeType.Empty===a?this.oEditor.setRawText("<br />"+
c.convertPlainTextToHtml(e.data().signature()),g.EditorDefaultType.Html===e.data().editorDefaultType()):c.isNonEmptyArray(b)&&i.each(b,function(a){f.addMessageAsAttachment(a)});n=this.getAttachmentsDownloadsForUpload();c.isNonEmptyArray(n)&&e.remote().messageUploadAttachments(function(a,b){if(g.StorageResultType.Success===a&&b&&b.Result){var d=null,c="";if(!f.viewModelVisibility())for(c in b.Result)b.Result.hasOwnProperty(c)&&(d=f.getAttachmentById(b.Result[c]))&&d.tempName(c)}else f.setMessageAttachmentFailedDowbloadText()},
n);m&&this.oEditor&&this.oEditor.focus();this.triggerForResize()};y.prototype.onBuild=function(){this.initEditor();this.initUploader();var a=this,b=null;N.on("keydown",function(b){var c=!0;b&&(a.modalVisibility()&&e.data().useKeyboardShortcuts())&&(b.ctrlKey&&g.EventKeyCode.S===b.keyCode)&&(a.saveCommand(),c=!1);return c});N.on("resize",function(){a.triggerForResize()});this.dropboxEnabled()&&(b=document.createElement("script"),b.type="text/javascript",b.src="https://www.dropbox.com/static/api/1/dropins.js",
j(b).attr("id","dropboxjs").attr("data-app-key",e.settingsGet("DropboxApiKey")),document.body.appendChild(b))};y.prototype.getAttachmentById=function(a){for(var b=this.attachments(),d=0,c=b.length;d<c;d++)if(b[d]&&a===b[d].id)return b[d];return null};y.prototype.initEditor=function(){if(this.composeEditorTextArea()&&this.composeEditorHtmlArea()&&this.composeEditorToolbar()){var a=this;this.oEditor=new q(this.composeEditorTextArea(),this.composeEditorHtmlArea(),this.composeEditorToolbar(),{onSwitch:function(b){b||
a.removeLinkedAttachments()}});this.oEditor.initLanguage(c.i18n("EDITOR/TEXT_SWITCHER_CONFIRM"),c.i18n("EDITOR/TEXT_SWITCHER_PLAINT_TEXT"),c.i18n("EDITOR/TEXT_SWITCHER_RICH_FORMATTING"))}};y.prototype.initUploader=function(){if(this.composeUploaderButton()){var a={},b=c.pInt(e.settingsGet("AttachmentLimit")),d=new sa({action:e.link().upload(),name:"uploader",queueSize:2,multipleSizeLimit:50,disableFolderDragAndDrop:!1,clickElement:this.composeUploaderButton(),dragAndDropElement:this.composeUploaderDropPlace(),
onDragEnter:i.bind(function(){this.dragAndDropOver(!0)},this),onDragLeave:i.bind(function(){this.dragAndDropOver(!1)},this),onBodyDragEnter:i.bind(function(){this.dragAndDropVisible(!0)},this),onBodyDragLeave:i.bind(function(){this.dragAndDropVisible(!1)},this),onProgress:i.bind(function(b,d,e){var f=null;c.isUnd(a[b])?(f=this.getAttachmentById(b))&&(a[b]=f):f=a[b];f&&f.progress(" - "+Math.floor(100*(d/e))+"%")},this),onSelect:i.bind(function(a,e){this.dragAndDropOver(!1);var f=this,g=c.isUnd(e.FileName)?
"":e.FileName.toString(),i=c.isNormal(e.Size)?c.pInt(e.Size):null,g=new M(a,g,i);g.cancel=function(){f.attachments.remove(function(b){return b&&b.id===a});d&&d.cancel(a)};this.attachments.push(g);return 0<i&&0<b&&b<i?(g.error(c.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG")),!1):!0},this),onStart:i.bind(function(b){var d=null;c.isUnd(a[b])?(d=this.getAttachmentById(b))&&(a[b]=d):d=a[b];d&&(d.waiting(!1),d.uploading(!0))},this),onComplete:i.bind(function(b,d,e){var f="",g=null,i=null,h=this.getAttachmentById(b),
i=d&&e&&e.Result&&e.Result.Attachment?e.Result.Attachment:null,g=e&&e.Result&&e.Result.ErrorCode?e.Result.ErrorCode:null;null!==g?f=c.getUploadErrorDescByCode(g):i||(f=c.i18n("UPLOAD/ERROR_UNKNOWN"));h&&(""!==f&&0<f.length?h.waiting(!1).uploading(!1).error(f):i&&(h.waiting(!1).uploading(!1),h.initByUploadJson(i)),c.isUnd(a[b])&&delete a[b])},this)});d?this.addAttachmentEnabled(!0).dragAndDropEnabled(d.isDragAndDropSupported()):this.addAttachmentEnabled(!1).dragAndDropEnabled(!1)}};y.prototype.prepearAttachmentsForSendOrSave=
function(){var a={};i.each(this.attachmentsInReady(),function(b){b&&(""!==b.tempName()&&b.enabled())&&(a[b.tempName()]=[b.fileName(),b.isInline?"1":"0",b.CID])});return a};y.prototype.addMessageAsAttachment=function(a){if(a){var b=this,d=null,d=a.subject(),d=".eml"===d.substr(-4).toLowerCase()?d:d+".eml",d=new M(a.requestHash,d,a.size());d.fromMessage=!0;var c=a.requestHash;d.cancel=function(){b.attachments.remove(function(a){return a&&a.id===c})};d.waiting(!1).uploading(!0);this.attachments.push(d)}};
y.prototype.addDropboxAttachment=function(a){var b=this,d=c.pInt(e.settingsGet("AttachmentLimit")),f=null,i=a.bytes,f=new M(a.link,a.name,i);f.fromMessage=!1;var r=a.link;f.cancel=function(){b.attachments.remove(function(a){return a&&a.id===r})};f.waiting(!1).uploading(!0);this.attachments.push(f);if(0<i&&0<d&&d<i)return f.uploading(!1),f.error(c.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG")),!1;e.remote().composeUploadExternals(function(a,b){var d=!1;f.uploading(!1);g.StorageResultType.Success===a&&(b&&b.Result)&&
b.Result[f.id]&&(d=!0,f.tempName(b.Result[f.id]));d||f.error(c.getUploadErrorDescByCode(g.UploadErrorCode.FileNoUploaded))},[a.link]);return!0};y.prototype.prepearMessageAttachments=function(a,b){if(a){var d=this,e=c.isNonEmptyArray(a.attachments())?a.attachments():[],f=0,i=e.length,h=null,k=null,j=function(a){return function(){d.attachments.remove(function(b){return b&&b.id===a})}};if(g.ComposeType.ForwardAsAttachment===b)this.addMessageAsAttachment(a);else for(;f<i;f++)k=e[f],h=new M(k.download,
k.fileName,k.estimatedSize,k.isInline,k.isLinked,k.cid),h.fromMessage=!0,h.cancel=j(k.download),h.waiting(!1).uploading(!0),this.attachments.push(h)}};y.prototype.removeLinkedAttachments=function(){this.attachments.remove(function(a){return a&&a.isLinked})};y.prototype.setMessageAttachmentFailedDowbloadText=function(){i.each(this.attachments(),function(a){a&&a.fromMessage&&a.waiting(!1).uploading(!1).error(c.getUploadErrorDescByCode(g.UploadErrorCode.FileNoUploaded))},this)};y.prototype.isEmptyForm=
function(a){a=(a=c.isUnd(a)?!0:!!a)?0===this.attachments().length:0===this.attachmentsInReady().length;return 0===this.to().length&&0===this.cc().length&&0===this.bcc().length&&0===this.subject().length&&a&&""===this.oEditor.getTextForRequest()};y.prototype.reset=function(){this.to([]);this.cc([]);this.bcc([]);this.subject("");this.aDraftInfo=null;this.sInReplyTo="";this.bFromDraft=!1;this.sReferences="";this.bReloadFolder=!1;this.sendError(!1);this.sendSuccessButSaveError(!1);this.savedError(!1);
this.savedTime(0);this.savedOrSendingText("");this.emptyToError(!1);this.showCcAndBcc(!1);this.attachments([]);this.dragAndDropOver(!1);this.dragAndDropVisible(!1);this.draftFolder("");this.draftUid("");this.sending(!1);this.saving(!1);this.oEditor&&this.oEditor.clear()};y.prototype.getAttachmentsDownloadsForUpload=function(){return i.map(i.filter(this.attachments(),function(a){return a&&""===a.tempName()}),function(a){return a.id})};y.prototype.triggerForResize=function(){this.resizer(!this.resizer())};
c.extendAsViewModel("PopupsContactsViewModel",L);L.prototype.removeCheckedOrSelectedContactsFromList=function(){var a=this,b=this.contacts,d=this.currentContact(),c=this.contactsCheckedOrSelected();0<c.length&&(i.each(c,function(b){d&&d.idContact===b.idContact&&(d=null,a.currentContact(null));b.deleted(!0)}),i.delay(function(){i.each(c,function(a){b.remove(a)})},500))};L.prototype.deleteSelectedContacts=function(){0<this.contactsCheckedOrSelected().length&&(e.remote().contactsDelete(i.bind(this.deleteResponse,
this),this.contactsCheckedOrSelectedUids()),this.removeCheckedOrSelectedContactsFromList())};L.prototype.deleteResponse=function(a,b){500<(g.StorageResultType.Success===a&&b&&b.Time?c.pInt(b.Time):0)?this.reloadContactList():i.delay(function(a){return function(){a.reloadContactList()}}(this),500)};L.prototype.populateViewContact=function(a){this.imageTrigger(!1);this.emptySelection(!1);a?(this.viewID(a.idContact),this.viewName(a.name),this.viewEmail(a.emails[0]||""),this.viewImageUrl(a.srcAttr())):
(this.viewID(""),this.viewName(""),this.viewEmail(""),this.viewImageUrl(e.link().emptyContactPic()))};L.prototype.reloadContactList=function(){var a=this;this.contacts.loading(!0);e.remote().contacts(function(b,d){var e=[];g.StorageResultType.Success===b&&(d&&d.Result&&d.Result.List)&&c.isNonEmptyArray(d.Result.List)&&(e=i.map(d.Result.List,function(a){var b=new ka;return b.parse(a)?b:null}),e=i.compact(e));a.contacts(e);a.viewClearSearch(""!==a.search());a.contacts.loading(!1);""!==a.viewID()&&(!a.currentContact()&&
a.contacts.setSelectedByUid)&&a.contacts.setSelectedByUid(""+a.viewID())},this.search())};L.prototype.onBuild=function(a){this.initUploader();this.oContentVisible=j(".b-list-content",a);this.oContentScrollable=j(".content",this.oContentVisible);this.selector.init(this.oContentVisible,this.oContentScrollable);this.viewImageUrl.valueHasMutated();f.computed(function(){var a=this.modalVisibility(),d=e.data().useKeyboardShortcuts();this.selector.useKeyboard(a&&d)},this).extend({notify:"always"})};L.prototype.initUploader=
function(){var a=this,b=null;h.File&&(h.FileReader&&this.imageUploader())&&(b=new sa({queueSize:1,multipleSizeLimit:1,clickElement:this.imageUploader(),disableDragAndDrop:!0,disableMultiple:!0,onSelect:function(b,e){if(e&&e.File&&e.File.type){var f=null,g=e.File;e.File.type.match(/image.*/)?(f=new h.FileReader,f.onload=function(b){b&&(b.target&&b.target.result)&&c.resizeAndCrop(b.target.result,150,function(b){a.viewImageUrl(b);a.imageTrigger(!0)})},f.readAsDataURL(g)):h.alert("this file is not an image.")}return!1}}));
return b};L.prototype.onShow=function(){s.routeOff();this.reloadContactList()};L.prototype.onHide=function(){s.routeOn();this.currentContact(null);this.emptySelection(!0);this.search("");i.each(this.contacts(),function(a){a.checked(!1)})};c.extendAsViewModel("PopupsAdvancedSearchViewModel",ca);ca.prototype.buildSearchStringValue=function(a){-1<a.indexOf(" ")&&(a='"'+a+'"');return a};ca.prototype.buildSearchString=function(){var a=[],b=c.trim(this.from()),d=c.trim(this.to()),e=c.trim(this.subject()),
f=c.trim(this.text());b&&""!==b&&a.push("from:"+this.buildSearchStringValue(b));d&&""!==d&&a.push("to:"+this.buildSearchStringValue(d));e&&""!==e&&a.push("subject:"+this.buildSearchStringValue(e));this.hasAttachments()&&a.push("has:attachments");-1<this.selectedDateValue()&&a.push("date:"+Z().subtract("days",this.selectedDateValue()).format("YYYY.MM.DD")+"/");f&&""!==f&&a.push("text:"+this.buildSearchStringValue(f));return c.trim(a.join(" "))};ca.prototype.clearPopup=function(){this.from("");this.to("");
this.subject("");this.text("");this.selectedDateValue(-1);this.hasAttachments(!1);this.fromFocus(!0)};ca.prototype.onShow=function(){this.clearPopup();this.fromFocus(!0)};c.extendAsViewModel("PopupsAddAccountViewModel",da);da.prototype.clearPopup=function(){this.email("");this.login("");this.password("");this.emailError(!1);this.loginError(!1);this.passwordError(!1);this.submitRequest(!1);this.submitError("")};da.prototype.onShow=function(){this.clearPopup();this.emailFocus(!0)};da.prototype.onBuild=
function(){this.allowCustomLogin(!!e.settingsGet("AllowCustomLogin"))};c.extendAsViewModel("LoginViewModel",la);la.prototype.onShow=function(){s.routeOff();i.delay(i.bind(function(){""!==this.email()&&""!==this.password()?this.submitFocus(!0):this.emailFocus(!0)},this),100)};la.prototype.onHide=function(){this.submitFocus(!1);this.emailFocus(!1)};la.prototype.onBuild=function(){var a=this,b=e.settingsGet("JsHash"),d=function(b){b=c.pInt(b);0===b?(a.submitRequest(!0),e.loginAndLogoutReload()):a.submitError(c.getNotification(b))};
this.allowCustomLogin(!!e.settingsGet("AllowCustomLogin"));this.facebookLoginEnabled(!!e.settingsGet("AllowFacebookSocial"));this.twitterLoginEnabled(!!e.settingsGet("AllowTwitterSocial"));this.googleLoginEnabled(!!e.settingsGet("AllowGoogleSocial"));switch((e.settingsGet("SignMe")||"unused").toLowerCase()){case g.LoginSignMeTypeAsString.DefaultOff:this.signMeType(g.LoginSignMeType.DefaultOff);break;case g.LoginSignMeTypeAsString.DefaultOn:this.signMeType(g.LoginSignMeType.DefaultOn);break;default:case g.LoginSignMeTypeAsString.Unused:this.signMeType(g.LoginSignMeType.Unused)}this.email(e.data().devEmail);
this.login(e.data().devLogin);this.password(e.data().devPassword);this.googleLoginEnabled()&&(h["rl_"+b+"_google_login_service"]=d);this.facebookLoginEnabled()&&(h["rl_"+b+"_facebook_login_service"]=d);this.twitterLoginEnabled()&&(h["rl_"+b+"_twitter_login_service"]=d)};i.extend(Q.prototype,C.prototype);Q.prototype.accountClick=function(a,b){if(a&&b&&!c.isUnd(b.which)&&1===b.which){var d=this;this.accountsLoading(!0);i.delay(function(){d.accountsLoading(!1)},1E3)}return!0};Q.prototype.emailTitle=
function(){return e.data().accountEmail()};Q.prototype.settingsClick=function(){s.setHash(e.link().settings())};Q.prototype.addAccountClick=function(){this.allowAddAccount&&s.showScreenPopup(da)};Q.prototype.logoutClick=function(){e.remote().logout(function(){h.__rlah_clear&&h.__rlah_clear();e.loginAndLogoutReload(!0,e.settingsGet("ParentEmail")&&0<e.settingsGet("ParentEmail").length)})};i.extend(Ya.prototype,Q.prototype);i.extend(Za.prototype,Q.prototype);c.extendAsViewModel("MailBoxFolderListViewModel",
ea);ea.prototype.onBuild=function(a){a.on("click",".b-folders .e-item .e-link .e-collapsed-sign",function(a){var d=f.dataFor(this),e=!1;d&&a&&(e=d.collapsed(),c.setExpandedFolder(d.fullNameHash,e),d.collapsed(!e),a.preventDefault(),a.stopPropagation())}).on("click",".b-folders .e-item .e-link.selectable",function(a){a.preventDefault();if(a=f.dataFor(this))e.data().usePreviewPane()||e.data().message(null),a.fullNameRaw===e.data().currentFolderFullNameRaw()&&e.cache().setFolderHash(a.fullNameRaw,""),
s.setHash(e.link().mailBox(a.fullNameHash))})};ea.prototype.messagesDrop=function(a,b){if(a&&b&&b.helper){var d=b.helper.data("rl-folder"),e=b.helper.data("rl-uids");z&&(z.__vm&&c.isNormal(d)&&c.isArray(e))&&z.__vm.moveMessagesToFolder(d,e,a.fullNameRaw)}};ea.prototype.composeClick=function(){s.showScreenPopup(y)};ea.prototype.contactsClick=function(){this.allowContacts&&s.showScreenPopup(L)};c.extendAsViewModel("MailBoxMessageListViewModel",z);z.prototype.emptySubjectValue="";z.prototype.searchEnterAction=
function(){this.mainMessageListSearch(this.sLastSearchValue);this.inputMessageListSearchFocus(!1)};z.prototype.cancelSearch=function(){this.mainMessageListSearch("");this.inputMessageListSearchFocus(!1)};z.prototype.removeMessagesFromList=function(a,b,d,f){var d=c.isNormal(d)?d:"",f=c.isUnd(f)?!1:!!f,g=0,r=e.data(),h=e.cache().getFolderFromCacheList(a),k=""===d?null:e.cache().getFolderFromCacheList(d||""),j=r.currentFolderFullNameRaw(),o=r.message(),m=j===a?i.filter(r.messageList(),function(a){return a&&
-1<c.inArray(a.uid,b)}):[];f||i.each(m,function(a){a&&a.unseen()&&g++});h&&!f&&(h.messageCountAll(0<=h.messageCountAll()-b.length?h.messageCountAll()-b.length:0),0<g&&h.messageCountUnread(0<=h.messageCountUnread()-g?h.messageCountUnread()-g:0));k&&!f&&(k.messageCountAll(k.messageCountAll()+b.length),0<g&&k.messageCountUnread(k.messageCountUnread()+g));0<m.length&&(i.each(m,function(a){if(o&&o.requestHash===a.requestHash){o=null;r.message(null)}a.deleted(true)}),i.delay(function(){i.each(m,function(a){r.messageList.remove(a)})},
400),f||(e.data().messageListIsNotCompleted(!0),e.cache().setFolderHash(a,""),c.isNormal(d)&&e.cache().setFolderHash(d||"","")))};z.prototype.removeCheckedOrSelectedMessagesFromList=function(a){this.removeMessagesFromList(e.data().currentFolderFullNameRaw(),i.map(e.data().messageListCheckedOrSelected(),function(a){return a.uid}),a)};z.prototype.moveOrDeleteResponse=function(a,b){g.StorageResultType.Success===a&&e.data().currentFolder()&&(b&&c.isArray(b.Result)&&2===b.Result.length?e.cache().setFolderHash(b.Result[0],
b.Result[1]):(b&&g.Notification.CantMoveMessage===b.ErrorCode&&h.alert(c.getNotification(g.Notification.CantMoveMessage)),e.cache().setFolderHash(e.data().currentFolderFullNameRaw(),"")),e.reloadMessageList(),e.quotaDebounce())};z.prototype.moveMessagesToFolder=function(a,b,d){if(a!==d&&c.isArray(b)&&0<b.length){var f=e.cache().getFolderFromCacheList(a),g=e.cache().getFolderFromCacheList(d);if(f&&g)return e.remote().messagesMove(i.bind(this.moveOrDeleteResponse,this),f.fullNameRaw,g.fullNameRaw,b),
g.actionBlink(!0),this.removeMessagesFromList(a,b,d),!0}return!1};z.prototype.moveSelectedMessagesToFolder=function(a){return this.canBeMoved()?this.moveMessagesToFolder(e.data().currentFolderFullNameRaw(),e.data().messageListCheckedOrSelectedUidsWithSubMails(),a):!1};z.prototype.deleteSelectedMessageFromCurrentFolder=function(a,b){if(this.canBeMoved()){var b=c.isUnd(b)?!0:!!b,d=e.cache().getFolderFromCacheList(g.FolderType.Spam===a?e.data().spamFolder():e.data().trashFolder());!d&&b?s.showScreenPopup(X,
[g.FolderType.Spam===a?g.SetSystemFoldersNotification.Spam:g.SetSystemFoldersNotification.Trash]):!b||d&&(t.Values.UnuseOptionValue===d.fullNameRaw||e.data().currentFolderFullNameRaw()===d.fullNameRaw)?(e.remote().messagesDelete(i.bind(this.moveOrDeleteResponse,this),e.data().currentFolderFullNameRaw(),e.data().messageListCheckedOrSelectedUidsWithSubMails()),this.removeCheckedOrSelectedMessagesFromList()):d&&(e.remote().messagesMove(i.bind(this.moveOrDeleteResponse,this),e.data().currentFolderFullNameRaw(),
d.fullNameRaw,e.data().messageListCheckedOrSelectedUidsWithSubMails()),d.actionBlink(!0),this.removeCheckedOrSelectedMessagesFromList(d.fullNameRaw))}};z.prototype.dragAndDronHelper=function(a){a&&a.checked(!0);a=c.draggeblePlace();a.data("rl-folder",e.data().currentFolderFullNameRaw());a.data("rl-uids",e.data().messageListCheckedOrSelectedUidsWithSubMails());a.find(".text").text(e.data().messageListCheckedOrSelectedUidsWithSubMails().length);return a};z.prototype.onMessageResponse=function(a,b,d){var f=
e.data();f.messageLoading(!1);g.StorageResultType.Success===a&&b&&b.Result?f.setMessage(b,d):g.StorageResultType.Unload===a?(f.message(null),f.messageError("")):g.StorageResultType.Abort!==a&&(f.message(null),f.messageError(b&&b.ErrorCode?c.getNotification(b.ErrorCode):c.getNotification(g.Notification.UnknownError)))};z.prototype.populateMessageBody=function(a){a&&(e.remote().message(this.onMessageResponse,a.folderFullNameRaw,a.uid)?e.data().messageLoading(!0):c.log("Error: Unknown message request: "+
a.folderFullNameRaw+" ~ "+a.uid+" [e-101]"))};z.prototype.setAction=function(a,b,d){var f=[],h=null,r=e.cache(),j=0;c.isUnd(d)&&(d=e.data().messageListChecked());f=i.map(d,function(a){return a.uid});if(""!==a&&0<f.length){switch(b){case g.MessageSetAction.SetSeen:i.each(d,function(a){a.unseen()&&j++;a.unseen(!1);r.storeMessageFlagsToCache(a)});(h=r.getFolderFromCacheList(a))&&h.messageCountUnread(h.messageCountUnread()-j);e.remote().messageSetSeen(c.emptyFunction,a,f,!0);break;case g.MessageSetAction.UnsetSeen:i.each(d,
function(a){a.unseen()&&j++;a.unseen(!0);r.storeMessageFlagsToCache(a)});(h=r.getFolderFromCacheList(a))&&h.messageCountUnread(h.messageCountUnread()-j+f.length);e.remote().messageSetSeen(c.emptyFunction,a,f,!1);break;case g.MessageSetAction.SetFlag:i.each(d,function(a){a.flagged(!0);r.storeMessageFlagsToCache(a)});e.remote().messageSetFlagged(c.emptyFunction,a,f,!0);break;case g.MessageSetAction.UnsetFlag:i.each(d,function(a){a.flagged(!1);r.storeMessageFlagsToCache(a)}),e.remote().messageSetFlagged(c.emptyFunction,
a,f,!1)}e.reloadFlagsCurrentMessageListAndMessageFromCache()}};z.prototype.setActionForAll=function(a,b){var d=null,f=e.data().messageList(),h=e.cache();if(""!==a&&(d=h.getFolderFromCacheList(a))){switch(b){case g.MessageSetAction.SetSeen:if(d=h.getFolderFromCacheList(a))i.each(f,function(a){a.unseen(!1)}),d.messageCountUnread(0),h.clearMessageFlagsFromCacheByFolder(a);e.remote().messageSetSeenToAll(c.emptyFunction,a,!0);break;case g.MessageSetAction.UnsetSeen:if(d=h.getFolderFromCacheList(a))i.each(f,
function(a){a.unseen(!0)}),d.messageCountUnread(d.messageCountAll()),h.clearMessageFlagsFromCacheByFolder(a);e.remote().messageSetSeenToAll(c.emptyFunction,a,!1)}e.reloadFlagsCurrentMessageListAndMessageFromCache()}};z.prototype.listSetSeen=function(){this.setAction(e.data().currentFolderFullNameRaw(),g.MessageSetAction.SetSeen,e.data().messageListCheckedOrSelected())};z.prototype.listSetAllSeen=function(){this.setActionForAll(e.data().currentFolderFullNameRaw(),g.MessageSetAction.SetSeen)};z.prototype.listUnsetSeen=
function(){this.setAction(e.data().currentFolderFullNameRaw(),g.MessageSetAction.UnsetSeen,e.data().messageListCheckedOrSelected())};z.prototype.listSetFlags=function(){this.setAction(e.data().currentFolderFullNameRaw(),g.MessageSetAction.SetFlag,e.data().messageListCheckedOrSelected())};z.prototype.listUnsetFlags=function(){this.setAction(e.data().currentFolderFullNameRaw(),g.MessageSetAction.UnsetFlag,e.data().messageListCheckedOrSelected())};z.prototype.onBuild=function(a){var b=this,d=e.data();
this.oContentVisible=j(".b-content",a);this.oContentScrollable=j(".content",this.oContentVisible);this.oContentVisible.on("click",".fullThreadHandle",function(){var a=[],b=f.dataFor(this);b&&!b.lastInCollapsedThreadLoading()&&(e.data().messageListThreadFolder(b.folderFullNameRaw),a=e.data().messageListThreadUids(),b.lastInCollapsedThread()?a.push(0<b.parentUid()?b.parentUid():b.uid):a=i.without(a,0<b.parentUid()?b.parentUid():b.uid),e.data().messageListThreadUids(i.uniq(a)),b.lastInCollapsedThreadLoading(!0),
b.lastInCollapsedThread(!b.lastInCollapsedThread()),e.reloadMessageList());return!1});this.selector.init(this.oContentVisible,this.oContentScrollable);Ea.on("keydown",function(a){var f=!0,i=a?a.keyCode:0;if(a&&b.viewModelVisibility()&&d.useKeyboardShortcuts()&&!e.popupVisibility()&&!d.messageFullScreenMode()&&!c.inFocus()&&(d.usePreviewPane()||!d.message()&&(g.EventKeyCode.Delete===i||g.EventKeyCode.A===i))&&a.ctrlKey&&g.EventKeyCode.A===i)b.checkAll(!(b.checkAll()&&!b.isIncompleteChecked())),f=!1;
return f});a.on("click",".pagenator .page",function(){var a=f.dataFor(this);a&&s.setHash(e.link().mailBox(d.currentFolderFullNameHash(),a.value,d.messageListSearch()))}).on("click",".messageList .checkboxCkeckAll",function(){b.checkAll(!b.checkAll())}).on("click",".messageList .messageListItem .flagParent",function(){var a=f.dataFor(this),e=d.messageListCheckedOrSelected(),h=[];a&&(0<e.length&&(h=i.map(e,function(a){return a.uid})),0<h.length&&-1<c.inArray(a.uid,h)?b.setAction(a.folderFullNameRaw,
a.flagged()?g.MessageSetAction.UnsetFlag:g.MessageSetAction.SetFlag,e):b.setAction(a.folderFullNameRaw,a.flagged()?g.MessageSetAction.UnsetFlag:g.MessageSetAction.SetFlag,[a]))});f.computed(function(){var a=e.data(),b=this.viewModelVisibility(),d=e.popupVisibility(),c=a.useKeyboardShortcuts(),a=a.messageFullScreenMode();this.selector.useKeyboard(b&&c&&!a&&!d)},this).extend({notify:"always"});this.initUploaderForAppend()};z.prototype.composeClick=function(){s.showScreenPopup(y)};z.prototype.advancedSearchClick=
function(){s.showScreenPopup(ca)};z.prototype.quotaTooltip=function(){return c.i18n("MESSAGE_LIST/QUOTA_SIZE",{SIZE:c.friendlySize(this.userUsageSize()),PROC:this.userUsageProc(),LIMIT:c.friendlySize(this.userQuota())})};z.prototype.initUploaderForAppend=function(){return!e.settingsGet("AllowAppendMessage")||!this.dragOverArea()?!1:!!new sa({action:e.link().append(),name:"AppendFile",queueSize:1,multipleSizeLimit:1,disableFolderDragAndDrop:!0,hidden:{Folder:function(){return e.data().currentFolderFullNameRaw()}},
dragAndDropElement:this.dragOverArea(),dragAndDropBodyElement:this.dragOverBodyArea(),onDragEnter:i.bind(function(){this.dragOverEnter(true)},this),onDragLeave:i.bind(function(){this.dragOverEnter(false)},this),onBodyDragEnter:i.bind(function(){this.dragOver(true)},this),onBodyDragLeave:i.bind(function(){this.dragOver(false)},this),onSelect:i.bind(function(a,b){if(a&&b&&"message/rfc822"===b.Type){e.data().messageListLoading(true);return true}return false}),onComplete:i.bind(function(){e.reloadMessageList(true,
true)},this)})};c.extendAsViewModel("MailBoxMessageViewViewModel",H);H.prototype.scrollToTop=function(){var a=j(".messageItem.nano .content",this.viewModelDom);a&&a[0]?a.scrollTop(0):j(".messageItem",this.viewModelDom).scrollTop(0);c.windowResize()};H.prototype.fullScreen=function(){this.fullScreenMode(!0);c.windowResize()};H.prototype.unFullScreen=function(){this.fullScreenMode(!1);c.windowResize()};H.prototype.toggleFullScreen=function(){c.removeSelection();this.fullScreenMode(!this.fullScreenMode());
c.windowResize()};H.prototype.replyOrforward=function(a){s.showScreenPopup(y,[a,e.data().message()])};H.prototype.onBuild=function(a){var b=this,d=e.data();Ea.on("keydown",function(a){var e=!0,a=a?a.keyCode:0;if(0<a&&(g.EventKeyCode.Backspace===a||g.EventKeyCode.Esc===a)&&b.viewModelVisibility()&&d.useKeyboardShortcuts()&&!c.inFocus()&&d.message())b.fullScreenMode(!1),d.usePreviewPane()||d.message(null),e=!1;return e});j(".attachmentsPlace",a).magnificPopup({delegate:".magnificPopupImage:visible",
type:"image",preload:[1,1],gallery:{enabled:!0},callbacks:{open:function(){d.useKeyboardShortcuts(!1)},close:function(){d.useKeyboardShortcuts(!0)}},mainClass:"mfp-fade",removalDelay:300});a.on("click",".attachmentsPlace .attachmentPreview",function(a){a&&a.stopPropagation&&a.stopPropagation()}).on("click",".attachmentsPlace .attachmentItem",function(){var a=f.dataFor(this);a&&a.download&&e.download(a.linkDownload())});this.oMessageScrollerDom=(this.oMessageScrollerDom=a.find(".messageItem .content"))&&
this.oMessageScrollerDom[0]?this.oMessageScrollerDom:null};H.prototype.isDraftFolder=function(){return e.data().message()&&e.data().draftFolder()===e.data().message().folderFullNameRaw};H.prototype.isSentFolder=function(){return e.data().message()&&e.data().sentFolder()===e.data().message().folderFullNameRaw};H.prototype.isDraftOrSentFolder=function(){return this.isDraftFolder()||this.isSentFolder()};H.prototype.composeClick=function(){s.showScreenPopup(y)};H.prototype.editMessage=function(){e.data().message()&&
s.showScreenPopup(y,[g.ComposeType.Draft,e.data().message()])};H.prototype.scrollMessageToTop=function(){this.oMessageScrollerDom&&this.oMessageScrollerDom.scrollTop(0)};H.prototype.showImages=function(a){a&&a.showExternalImages&&a.showExternalImages(!0)};c.extendAsViewModel("SettingsMenuViewModel",ya);ya.prototype.link=function(a){return e.link().settings(a)};ya.prototype.backToMailBoxClick=function(){s.setHash(e.link().inbox())};c.extendAsViewModel("SettingsPaneViewModel",za);za.prototype.onShow=
function(){e.data().message(null)};za.prototype.backToMailBoxClick=function(){s.setHash(e.link().inbox())};c.addSettingsViewModel(Ma,"SettingsGeneral","SETTINGS_LABELS/LABEL_GENERAL_NAME","general",!0);Ma.prototype.onBuild=function(){var a=this;i.delay(function(){var b=e.data(),d=c.settingsSaveHelperSimpleFunction(a.mppTrigger,a);b.language.subscribe(function(b){a.languageTrigger(g.SaveSettingsStep.Animate);j.ajax({url:e.link().langLink(b),dataType:"script",cache:!0}).done(function(){c.i18nToDoc();
a.languageTrigger(g.SaveSettingsStep.TrueResult)}).fail(function(){a.languageTrigger(g.SaveSettingsStep.FalseResult)}).always(function(){i.delay(function(){a.languageTrigger(g.SaveSettingsStep.Idle)},1E3)});e.remote().saveSettings(c.emptyFunction,{Language:b})});b.editorDefaultType.subscribe(function(a){e.remote().saveSettings(c.emptyFunction,{EditorDefaultType:a})});b.messagesPerPage.subscribe(function(a){e.remote().saveSettings(d,{MPP:a})});b.showImages.subscribe(function(a){e.remote().saveSettings(c.emptyFunction,
{ShowImages:a?"1":"0"})});b.showAnimation.subscribe(function(a){e.remote().saveSettings(c.emptyFunction,{ShowAnimation:a?"1":"0"})});b.useDesktopNotifications.subscribe(function(a){c.timeOutAction("SaveDesktopNotifications",function(){e.remote().saveSettings(c.emptyFunction,{DesktopNotifications:a?"1":"0"})},3E3)});b.replySameFolder.subscribe(function(a){c.timeOutAction("SaveReplySameFolder",function(){e.remote().saveSettings(c.emptyFunction,{ReplySameFolder:a?"1":"0"})},3E3)});b.useThreads.subscribe(function(a){b.messageList([]);
e.remote().saveSettings(c.emptyFunction,{UseThreads:a?"1":"0"})});b.usePreviewPane.subscribe(function(a){b.messageList.valueHasMutated();e.remote().saveSettings(c.emptyFunction,{UsePreviewPane:a?"1":"0"})});b.useCheckboxesInList.subscribe(function(a){e.remote().saveSettings(c.emptyFunction,{UseCheckboxesInList:a?"1":"0"})})},50)};Ma.prototype.onShow=function(){e.data().desktopNotifications.valueHasMutated()};c.addSettingsViewModel($a,"SettingsPersonal","SETTINGS_LABELS/LABEL_PERSONAL_NAME","personal");
$a.prototype.onBuild=function(){var a=this;i.delay(function(){var b=e.data(),d=c.settingsSaveHelperSimpleFunction(a.nameTrigger,a),f=c.settingsSaveHelperSimpleFunction(a.replyTrigger,a),g=c.settingsSaveHelperSimpleFunction(a.signatureTrigger,a);b.displayName.subscribe(function(a){e.remote().saveSettings(d,{DisplayName:a})});b.replyTo.subscribe(function(a){e.remote().saveSettings(f,{ReplyTo:a})});b.signature.subscribe(function(a){e.remote().saveSettings(g,{Signature:a})})},50)};c.addSettingsViewModel(ma,
"SettingsAccounts","SETTINGS_LABELS/LABEL_ACCOUNTS_NAME","accounts");ma.prototype.addNewAccount=function(){s.showScreenPopup(da)};ma.prototype.deleteAccount=function(a){if(a&&a.deleteAccess()){this.accountForDeletion(null);var b=function(b){return a===b};a&&(e.data().accounts.remove(b),e.remote().accountDelete(function(){e.accounts()},a.email))}};c.addSettingsViewModel(Na,"SettingsSocial","SETTINGS_LABELS/LABEL_SOCIAL_NAME","social");c.addSettingsViewModel(na,"SettingsChangePassword","SETTINGS_LABELS/LABEL_CHANGE_PASSWORD_NAME",
"change-password");na.prototype.onHide=function(){this.changeProcess(!1);this.currentPassword("");this.newPassword("")};na.prototype.onChangePasswordResponse=function(a,b){this.changeProcess(!1);g.StorageResultType.Success===a&&b&&b.Result?(this.currentPassword(""),this.newPassword(""),this.passwordUpdateSuccess(!0)):this.passwordUpdateError(!0)};c.addSettingsViewModel(R,"SettingsFolders","SETTINGS_LABELS/LABEL_FOLDERS_NAME","folders");R.prototype.folderEditOnEnter=function(a){var b=a?c.trim(a.nameForEdit()):
"";""!==b&&a.name()!==b&&(e.local().set(g.ClientSideKeyName.FoldersLashHash,""),e.data().foldersRenaming(!0),e.remote().folderRename(function(a,b){e.data().foldersRenaming(!1);if(g.StorageResultType.Success!==a||!b||!b.Result)e.data().foldersListError(b&&b.ErrorCode?c.getNotification(b.ErrorCode):c.i18n("NOTIFICATIONS/CANT_RENAME_FOLDER"));e.folders(!1)},a.fullNameRaw,b),e.cache().removeFolderFromCacheList(a.fullNameRaw),a.name(b));a.edited(!1)};R.prototype.folderEditOnEsc=function(a){a&&a.edited(!1)};
R.prototype.onShow=function(){e.data().foldersListError("")};R.prototype.createFolder=function(){s.showScreenPopup(ba)};R.prototype.systemFolder=function(){s.showScreenPopup(X)};R.prototype.deleteFolder=function(a){if(a&&a.canBeDeleted()&&a.deleteAccess()&&0===a.privateMessageCountAll()){this.folderForDeletion(null);var b=function(d){if(a===d)return!0;d.subFolders.remove(b);return!1};a&&(e.local().set(g.ClientSideKeyName.FoldersLashHash,""),e.data().folderList.remove(b),e.data().foldersDeleting(!0),
e.remote().folderDelete(function(a,b){e.data().foldersDeleting(!1);if(g.StorageResultType.Success!==a||!b||!b.Result)e.data().foldersListError(b&&b.ErrorCode?c.getNotification(b.ErrorCode):c.i18n("NOTIFICATIONS/CANT_DELETE_FOLDER"));e.folders(!1)},a.fullNameRaw),e.cache().removeFolderFromCacheList(a.fullNameRaw))}else 0<a.privateMessageCountAll()&&e.data().foldersListError(c.getNotification(g.Notification.CantDeleteNonEmptyFolder))};R.prototype.subscribeFolder=function(a){e.local().set(g.ClientSideKeyName.FoldersLashHash,
"");e.remote().folderSetSubscribe(c.emptyFunction,a.fullNameRaw,!0);a.subScribed(!0)};R.prototype.unSubscribeFolder=function(a){e.local().set(g.ClientSideKeyName.FoldersLashHash,"");e.remote().folderSetSubscribe(c.emptyFunction,a.fullNameRaw,!1);a.subScribed(!1)};c.addSettingsViewModel(Aa,"SettingsThemes","SETTINGS_LABELS/LABEL_THEMES_NAME","themes");Aa.prototype.removeCustomThemeImg=function(){this.customThemeImg("")};Aa.prototype.onBuild=function(){var a=this,b=e.data().theme();this.themesObjects(i.map(e.data().themes(),
function(a){return{name:a,nameDisplay:c.convertThemeName(a),selected:f.observable(a===b),themePreviewSrc:e.link().themePreviewLink(a)}}));i.delay(function(){a.customThemeType.subscribe(function(a){e.remote().saveSettings(function(){e.data().theme.valueHasMutated()},{CustomThemeType:a})});a.customThemeImg.subscribe(function(a){e.remote().saveSettings(function(){e.data().theme.valueHasMutated()},{CustomThemeImg:a})})},50);this.initCustomThemeUploader()};Aa.prototype.initCustomThemeUploader=function(){return this.customThemeUploaderButton()?
!!new sa({action:e.link().uploadBackground(),name:"uploader",queueSize:1,multipleSizeLimit:1,disableFolderDragAndDrop:!0,clickElement:this.customThemeUploaderButton(),onSelect:i.bind(function(a,b){var d=c.isUnd(b.FileName)?"":b.FileName.toString(),d=d.substring(d.length-4,d.length),e=c.isNormal(b.Size)?c.pInt(b.Size):null;return-1===c.inArray(d,["jpeg",".jpg",".png"])?(h.alert(c.i18n("SETTINGS_THEMES/ERROR_FILE_TYPE_ERROR")),!1):1048576<e?(h.alert(c.i18n("SETTINGS_THEMES/ERROR_FILE_IS_TOO_BIG")),
!1):!0},this),onStart:i.bind(function(){this.customThemeUploaderProgress(!0)},this),onComplete:i.bind(function(a,b,d){!b||!d||!d.Result?h.alert(d&&d.ErrorCode?c.getUploadErrorDescByCode(d.ErrorCode):c.getUploadErrorDescByCode(g.UploadErrorCode.Unknown)):this.customThemeImg(d.Result);this.customThemeUploaderProgress(!1)},this)}):!1};Oa.prototype.populateDataOnStart=function(){var a=e.settingsGet("Languages"),b=e.settingsGet("Themes");c.isArray(a)&&this.languages(a);c.isArray(b)&&this.themes(b);this.mainLanguage(e.settingsGet("Language"));
this.mainTheme(e.settingsGet("Theme"));this.allowCustomTheme(!!e.settingsGet("AllowCustomTheme"));this.allowAdditionalAccounts(!!e.settingsGet("AllowAdditionalAccounts"));this.ignoreFolderSubscribe(!!e.settingsGet("IgnoreFolderSubscribe"));this.editorDefaultType(e.settingsGet("EditorDefaultType"));this.showImages(!!e.settingsGet("ShowImages"));this.showAnimation(!!e.settingsGet("ShowAnimation"));this.mainMessagesPerPage(e.settingsGet("MPP"));this.desktopNotifications(!!e.settingsGet("DesktopNotifications"));
this.useThreads(!!e.settingsGet("UseThreads"));this.replySameFolder(!!e.settingsGet("ReplySameFolder"));this.usePreviewPane(!!e.settingsGet("UsePreviewPane"));this.useCheckboxesInList(!!e.settingsGet("UseCheckboxesInList"));this.facebookEnable(!!e.settingsGet("AllowFacebookSocial"));this.facebookAppID(e.settingsGet("FacebookAppID"));this.facebookAppSecret(e.settingsGet("FacebookAppSecret"));this.twitterEnable(!!e.settingsGet("AllowTwitterSocial"));this.twitterConsumerKey(e.settingsGet("TwitterConsumerKey"));
this.twitterConsumerSecret(e.settingsGet("TwitterConsumerSecret"));this.googleEnable(!!e.settingsGet("AllowGoogleSocial"));this.googleClientID(e.settingsGet("GoogleClientID"));this.googleClientSecret(e.settingsGet("GoogleClientSecret"));this.dropboxEnable(!!e.settingsGet("AllowDropboxSocial"));this.dropboxApiKey(e.settingsGet("DropboxApiKey"));this.contactsIsSupported(!!e.settingsGet("ContactsIsSupported"))};i.extend(S.prototype,Oa.prototype);S.prototype.populateDataOnStart=function(){Oa.prototype.populateDataOnStart.call(this);
this.accountEmail(e.settingsGet("Email"));this.accountLogin(e.settingsGet("Login"));this.projectHash(e.settingsGet("ProjectHash"));this.displayName(e.settingsGet("DisplayName"));this.replyTo(e.settingsGet("ReplyTo"));this.signature(e.settingsGet("Signature"));this.lastFoldersHash=e.local().get(g.ClientSideKeyName.FoldersLashHash);this.remoteSuggestions=!!e.settingsGet("RemoteSuggestions");this.remoteChangePassword=!!e.settingsGet("RemoteChangePassword");this.threading=!!e.settingsGet("UseImapThread");
this.devEmail=e.settingsGet("DevEmail");this.devLogin=e.settingsGet("DevLogin");this.devPassword=e.settingsGet("DevPassword")};S.prototype.initUidNextAndNewMessages=function(a,b,d){if("INBOX"===a&&c.isNormal(b)&&""!==b){if(c.isArray(d)&&0<d.length){var f=e.cache(),g=0,r=d.length,j=function(a,b,d){var c=null;if(ja&&e.data().useDesktopNotifications()&&(c=new ja(b,{body:d,icon:a})))c.show&&c.show(),h.setTimeout(function(a){return function(){a.cancel?a.cancel():a.close&&a.close()}}(c),7E3)};i.each(d,
function(b){f.addNewMessageCache(a,b.Uid)});if(3<r)j(e.link().notificationMailIcon(),e.data().accountEmail(),c.i18n("MESSAGE_LIST/NEW_MESSAGE_NOTIFICATION",{COUNT:r}));else for(;g<r;g++)j(e.link().notificationMailIcon(),m.emailsToLine(m.initEmailsFromJson(d[g].From),!1),d[g].Subject)}e.cache().setFolderUidNext(a,b)}};S.prototype.folderResponseParseRec=function(a,b,d){for(var f=0,g=0,i=null,h=null,j="",i=[],m=[],d=!!d,f=0,g=b.length;f<g;f++)if(i=b[f]){j=i.FullNameRaw;h=e.cache().getFolderFromCacheList(j);
if(!h&&(h=G.newInstanceFromJson(i)))if(e.cache().setFolderToCacheList(j,h),e.cache().setFolderFullNameRaw(h.fullNameHash,j),h.isGmailFolder=t.Values.GmailFolderName.toLowerCase()===j.toLowerCase(),""!==a&&a===h.fullNameRaw+h.delimiter&&(h.isNamespaceFolder=!0),h.isNamespaceFolder||h.isGmailFolder)h.isUnpaddigFolder=!0;h&&(h.collapsed(!c.isFolderExpanded(h.fullNameHash)),!d&&i.Extended&&(i.Extended.Hash&&e.cache().setFolderHash(h.fullNameRaw,i.Extended.Hash),c.isNormal(i.Extended.MessageCount)&&h.messageCountAll(i.Extended.MessageCount),
c.isNormal(i.Extended.MessageUnseenCount)&&h.messageCountUnread(i.Extended.MessageUnseenCount)),(i=i.SubFolders)&&("Collection/FolderCollection"===i["@Object"]&&i["@Collection"]&&c.isArray(i["@Collection"]))&&h.subFolders(this.folderResponseParseRec(a,i["@Collection"],d)),m.push(h))}return m};S.prototype.setFolders=function(a,b){var d=[],f=!1,h=e.data(),i=0===h.folderList().length,j=function(a){return""===a||t.Values.UnuseOptionValue===a||null!==e.cache().getFolderFromCacheList(a)?a:""};a&&(a.Result&&
"Collection/FolderCollection"===a.Result["@Object"]&&a.Result["@Collection"]&&c.isArray(a.Result["@Collection"]))&&(c.isUnd(a.Result.Namespace)||(h.namespace=a.Result.Namespace),d=this.folderResponseParseRec(h.namespace,a.Result["@Collection"],!!b),h.folderList(d),a.Result.SystemFolders&&""===""+e.settingsGet("SentFolder")+e.settingsGet("DraftFolder")+e.settingsGet("SpamFolder")+e.settingsGet("TrashFolder")&&(e.settingsSet("SentFolder",a.Result.SystemFolders[2]||null),e.settingsSet("DraftFolder",
a.Result.SystemFolders[3]||null),e.settingsSet("SpamFolder",a.Result.SystemFolders[4]||null),e.settingsSet("TrashFolder",a.Result.SystemFolders[5]||null),f=!0),h.sentFolder(j(e.settingsGet("SentFolder"))),h.draftFolder(j(e.settingsGet("DraftFolder"))),h.spamFolder(j(e.settingsGet("SpamFolder"))),h.trashFolder(j(e.settingsGet("TrashFolder"))),f&&e.remote().saveSystemFolders(c.emptyFunction,{SentFolder:h.sentFolder(),DraftFolder:h.draftFolder(),SpamFolder:h.spamFolder(),TrashFolder:h.trashFolder()}),
b||e.local().set(g.ClientSideKeyName.FoldersLashHash,a.Result.FoldersHash),i&&b&&e.folders(!1))};S.prototype.hideMessageBodies=function(){var a=this.messagesBodiesDom();a&&a.find(".b-text-part").hide()};S.prototype.setMessage=function(a,b){var d=!1,f=!1,g=!1,h=null,f=null,d="",i=this.messagesBodiesDom(),k=this.message();if(a&&k&&a.Result&&"Object/Message"===a.Result["@Object"]&&k.folderFullNameRaw===a.Result.Folder&&k.uid===a.Result.Uid){this.messageError("");k.initUpdateByMessageJson(a.Result);e.cache().addRequestedMessage(k.folderFullNameRaw,
k.uid);b||k.initFlagsByJson(a.Result);if(i=i&&i[0]?i:null)d="rl-"+k.requestHash.replace(/[^a-zA-Z0-9]/g,""),f=i.find("#"+d),!f||!f[0]?(f=!!a.Result.HasExternals,g=!!a.Result.HasInternals,h=j('<div id="'+d+'" />').hide(),c.isNormal(a.Result.Html)&&""!==a.Result.Html?(d=!0,h.html(a.Result.Html.toString()).addClass("b-text-part html")):c.isNormal(a.Result.Plain)&&""!==a.Result.Plain?(d=!1,h.html(a.Result.Plain.toString()).addClass("b-text-part plain")):d=!1,i.append(h),h.data("rl-is-html",d),h.data("rl-has-images",
f),k.isHtml(h.data("rl-is-html")),k.hasImages(h.data("rl-has-images")),k.body=h,g&&k.showInternalImages(!0),k.hasImages()&&this.showImages()&&k.showExternalImages(!0)):(k.isHtml(f.data("rl-is-html")),k.hasImages(f.data("rl-has-images")),k.body=f),this.messageActiveDom(k.body),this.hideMessageBodies(),k.body.show(),h&&c.initBlockquoteSwitcher(h);e.cache().initMessageFlagsFromCache(k);k.unseen()&&e.setMessageSeen(k);c.windowResize()}};S.prototype.setMessageList=function(a,b){if(a&&a.Result&&"Collection/MessageCollection"===
a.Result["@Object"]&&a.Result["@Collection"]&&c.isArray(a.Result["@Collection"])){var d=e.data(),f=e.cache(),h=null,i=0,j=0,k=0,s=0,o=[],t=d.staticMessageList,n=null,p=null,q=null,u=0,v=!1,k=c.pInt(a.Result.MessageResultCount),s=c.pInt(a.Result.Offset);c.isNonEmptyArray(a.Result.LastCollapsedThreadUids)&&(h=a.Result.LastCollapsedThreadUids);if((q=e.cache().getFolderFromCacheList(c.isNormal(a.Result.Folder)?a.Result.Folder:""))&&!b)e.cache().setFolderHash(a.Result.Folder,a.Result.FolderHash),c.isNormal(a.Result.MessageCount)&&
q.messageCountAll(a.Result.MessageCount),c.isNormal(a.Result.MessageUnseenCount)&&(c.pInt(q.messageCountUnread())!==c.pInt(a.Result.MessageUnseenCount)&&(v=!0),q.messageCountUnread(a.Result.MessageUnseenCount)),this.initUidNextAndNewMessages(q.fullNameRaw,a.Result.UidNext,a.Result.NewMessages);v&&q&&e.cache().clearMessageFlagsFromCacheByFolder(q.fullNameRaw);i=0;for(j=a.Result["@Collection"].length;i<j;i++)if((n=a.Result["@Collection"][i])&&"Object/Message"===n["@Object"]){p=t[i];if(!p||!p.initByJson(n))p=
m.newInstanceFromJson(n);p&&(f.hasNewMessageAndRemoveFromCache(p.folderFullNameRaw,p.uid)&&5>=u&&(u++,p.newForAnimation(!0)),p.deleted(!1),b?e.cache().initMessageFlagsFromCache(p):e.cache().storeMessageFlagsToCache(p),p.lastInCollapsedThread(h&&-1<c.inArray(c.pInt(p.uid),h)?!0:!1),o.push(p))}d.messageListCount(k);d.messageListSearch(c.isNormal(a.Result.Search)?a.Result.Search:"");d.messageListEndSearch(c.isNormal(a.Result.Search)?a.Result.Search:"");d.messageListEndFolder(c.isNormal(a.Result.Folder)?
a.Result.Folder:"");d.messageListPage(Math.ceil(s/d.messagesPerPage()+1));d.messageList(o);d.messageListIsNotCompleted(!1);(p=d.message())&&d.messageList.setSelectedByUid&&d.messageList.setSelectedByUid(p.generateUid());t.length<o.length&&(d.staticMessageList=o);f.clearNewMessageCache();q&&(b||v||e.data().useThreads())&&e.folderInformation(q.fullNameRaw,o)}else e.data().messageListCount(0),e.data().messageList([]),e.data().messageListError(c.getNotification(a&&a.ErrorCode?a.ErrorCode:g.Notification.CantGetMessageList))};
aa.prototype.oRequests={};aa.prototype.defaultResponse=function(a,b,d,c,f,j){var w=function(){g.StorageResultType.Success!==d&&Qa&&(d=g.StorageResultType.Unload);if(g.StorageResultType.Success===d&&c&&!c.Result){if(c&&g.Notification.AuthError===c.ErrorCode&&Ca++,c.Logout||5<Ca)h.__rlah_clear&&h.__rlah_clear(),e.loginAndLogoutReload(!0)}else g.StorageResultType.Success===d&&(c&&c.Result)&&(Ca=0);a&&(x.runHook("ajax-default-response",[b,g.StorageResultType.Success===d?c:null,d,f,j]),a(d,g.StorageResultType.Success===
d?c:null,f,b,j))};switch(d){case "success":d=g.StorageResultType.Success;break;case "abort":d=g.StorageResultType.Abort;break;default:d=g.StorageResultType.Error}g.StorageResultType.Error===d?i.delay(w,300):w()};aa.prototype.ajaxRequest=function(a,b,d,f,g){var r=this,w=""===f,k=(new h.Date).getTime(),m=null,o="",b=b||{},d=c.isNormal(d)?d:2E4,f=c.isUnd(f)?"":c.pString(f),g=c.isArray(g)?g:[];(o=b.Action||"")&&0<g.length&&i.each(g,function(a){r.oRequests[a]&&(r.oRequests[a].__aborted=!0,r.oRequests[a].abort&&
r.oRequests[a].abort(),r.oRequests[a]=null)});w&&(b.XToken=e.settingsGet("Token"));m=j.ajax({type:w?"POST":"GET",url:e.link().ajax(f),async:!0,dataType:"json",data:w?b:{},headers:{},timeout:d,global:!0});m.always(function(d,e){var f=!1;d&&d.Time&&(f=c.pInt(d.Time)>(new h.Date).getTime()-k);o&&r.oRequests[o]&&(r.oRequests[o].__aborted&&(e="abort"),r.oRequests[o]=null);r.defaultResponse(a,o,e,d,f,b)});o&&(0<g.length&&-1<c.inArray(o,g))&&(this.oRequests[o]&&(this.oRequests[o].__aborted=!0,this.oRequests[o].abort&&
this.oRequests[o].abort(),this.oRequests[o]=null),this.oRequests[o]=m);return m};aa.prototype.defaultRequest=function(a,b,d,e,f,g){d=d||{};d.Action=b;f=c.pString(f);x.runHook("ajax-default-request",[b,d,f]);this.ajaxRequest(a,d,c.isUnd(e)?t.Defaults.DefaultAjaxTimeout:c.pInt(e),f,g)};aa.prototype.noop=function(a){this.defaultRequest(a,"Noop")};aa.prototype.jsError=function(a,b,d,c,e,f){this.defaultRequest(a,"JsError",{Message:b,FileName:d,LineNo:c,LocationHash:e,HtmlCapa:f})};i.extend(p.prototype,
aa.prototype);p.prototype.folders=function(a,b){var d=e.data().lastFoldersHash;(b=c.isUnd(b)?!1:!!b)&&""!==d?this.defaultRequest(a,"Folders",{},null,"Folders/"+e.data().projectHash()+"-"+d,["Folders"]):this.defaultRequest(a,"Folders",{},null,"",["Folders"])};p.prototype.login=function(a,b,d,c,e){this.defaultRequest(a,"Login",{Email:b,Login:d,Password:c,SignMe:e?"1":"0"})};p.prototype.accountAdd=function(a,b,d,c){this.defaultRequest(a,"AccountAdd",{Email:b,Login:d,Password:c})};p.prototype.accountDelete=
function(a,b){this.defaultRequest(a,"AccountDelete",{EmailToDelete:b})};p.prototype.accounts=function(a){this.defaultRequest(a,"Accounts")};p.prototype.messageList=function(a,b,d,f,g,h){var b=c.pString(b),i=e.data(),j=e.cache().getFolderHash(b),h=c.isUnd(h)?!1:!!h,d=c.isUnd(d)?0:c.pInt(d),f=c.isUnd(d)?20:c.pInt(f),g=c.pString(g);""!==j?this.defaultRequest(a,"MessageList",{},""===g?t.Defaults.DefaultAjaxTimeout:t.Defaults.SearchAjaxTimeout,"MessageList/"+ga.urlsafe_encode([b,d,f,g,i.projectHash(),
j,"INBOX"===b?e.cache().getFolderUidNext(b):"",i.threading&&i.useThreads()?"1":"0",i.threading&&b===i.messageListThreadFolder()?i.messageListThreadUids().join(","):""].join(String.fromCharCode(0))),h?[]:["MessageList"]):this.defaultRequest(a,"MessageList",{Folder:b,Offset:d,Limit:f,Search:g,UidNext:"INBOX"===b?e.cache().getFolderUidNext(b):"",UseThreads:e.data().threading&&e.data().useThreads()?"1":"0",ExpandedThreadUid:i.threading&&b===i.messageListThreadFolder()?i.messageListThreadUids().join(","):
""},""===g?t.Defaults.DefaultAjaxTimeout:t.Defaults.SearchAjaxTimeout,"",h?[]:["MessageList"])};p.prototype.messageUploadAttachments=function(a,b){this.defaultRequest(a,"MessageUploadAttachments",{Attachments:b},999E3)};p.prototype.message=function(a,b,d){b=c.pString(b);d=c.pInt(d);return e.cache().getFolderFromCacheList(b)&&0<d?(this.defaultRequest(a,"Message",{},null,"Message/"+ga.urlsafe_encode([b,d,e.data().projectHash(),e.data().threading&&e.data().useThreads()?"1":"0"].join(String.fromCharCode(0))),
["Message"]),!0):!1};p.prototype.composeUploadExternals=function(a,b){this.defaultRequest(a,"ComposeUploadExternals",{Externals:b},999E3)};p.prototype.folderInformation=function(a,b,d){var f=!0,g=e.cache(),h=[];c.isArray(d)&&0<d.length&&(f=!1,i.each(d,function(a){g.getMessageFlagsFromCache(a.folderFullNameRaw,a.uid)||h.push(a.uid);0<a.threads().length&&i.each(a.threads(),function(b){g.getMessageFlagsFromCache(a.folderFullNameRaw,b)||h.push(b)})}),0<h.length&&(f=!0));f?this.defaultRequest(a,"FolderInformation",
{Folder:b,FlagsUids:c.isArray(h)?h.join(","):"",UidNext:"INBOX"===b?e.cache().getFolderUidNext(b):""}):e.data().useThreads()&&e.reloadFlagsCurrentMessageListAndMessageFromCache()};p.prototype.logout=function(a){this.defaultRequest(a,"Logout")};p.prototype.messageSetFlagged=function(a,b,d,c){this.defaultRequest(a,"MessageSetFlagged",{Folder:b,Uids:d.join(","),SetAction:c?"1":"0"})};p.prototype.messageSetSeen=function(a,b,d,c){this.defaultRequest(a,"MessageSetSeen",{Folder:b,Uids:d.join(","),SetAction:c?
"1":"0"})};p.prototype.messageSetSeenToAll=function(a,b,d){this.defaultRequest(a,"MessageSetSeenToAll",{Folder:b,SetAction:d?"1":"0"})};p.prototype.saveMessage=function(a,b,d,c,e,f,g,h,i,j,m,n,p,q){this.defaultRequest(a,"SaveMessage",{MessageFolder:b,MessageUid:d,DraftFolder:c,To:e,Cc:f,Bcc:g,Subject:h,TextIsHtml:i?"1":"0",Text:j,DraftInfo:n,InReplyTo:p,References:q,Attachments:m},t.Defaults.SaveMessageAjaxTimeout)};p.prototype.sendMessage=function(a,b,d,c,e,f,g,h,i,j,m,n,p,q){this.defaultRequest(a,
"SendMessage",{MessageFolder:b,MessageUid:d,SentFolder:c,To:e,Cc:f,Bcc:g,Subject:h,TextIsHtml:i?"1":"0",Text:j,DraftInfo:n,InReplyTo:p,References:q,Attachments:m},t.Defaults.SendMessageAjaxTimeout)};p.prototype.saveSystemFolders=function(a,b){this.defaultRequest(a,"SystemFoldersUpdate",b)};p.prototype.saveSettings=function(a,b){this.defaultRequest(a,"SettingsUpdate",b)};p.prototype.changePassword=function(a,b,d){this.defaultRequest(a,"ChangePassword",{PrevPassword:b,NewPassword:d})};p.prototype.folderCreate=
function(a,b,d){this.defaultRequest(a,"FolderCreate",{Folder:b,Parent:d},null,"",["Folders"])};p.prototype.folderDelete=function(a,b){this.defaultRequest(a,"FolderDelete",{Folder:b},null,"",["Folders"])};p.prototype.folderRename=function(a,b,d){this.defaultRequest(a,"FolderRename",{Folder:b,NewFolderName:d},null,"",["Folders"])};p.prototype.folderClear=function(a,b){this.defaultRequest(a,"FolderClear",{Folder:b})};p.prototype.folderSetSubscribe=function(a,b,d){this.defaultRequest(a,"FolderSubscribe",
{Folder:b,Subscribe:d?"1":"0"})};p.prototype.messagesMove=function(a,b,d,c){this.defaultRequest(a,"MessageMove",{FromFolder:b,ToFolder:d,Uids:c.join(",")},null,"",["MessageList","Message"])};p.prototype.messagesDelete=function(a,b,d){this.defaultRequest(a,"MessageDelete",{Folder:b,Uids:d.join(",")},null,"",["MessageList","Message"])};p.prototype.appDelayStart=function(a){this.defaultRequest(a,"AppDelayStart")};p.prototype.quota=function(a){this.defaultRequest(a,"Quota")};p.prototype.contacts=function(a,
b){this.defaultRequest(a,"Contacts",{Search:b},null,"",["Contacts"])};p.prototype.contactSave=function(a,b,d,e,f,g){d=c.trim(d);this.defaultRequest(a,"ContactSave",{RequestUid:b,Uid:d,Name:e,Email:f,ImageData:g})};p.prototype.contactsDelete=function(a,b){this.defaultRequest(a,"ContactsDelete",{Uids:b.join(",")})};p.prototype.suggestions=function(a,b,d){this.defaultRequest(a,"Suggestions",{Query:b,Page:d},null,"",["Suggestions"])};p.prototype.servicesPics=function(a){this.defaultRequest(a,"ServicesPics")};
p.prototype.emailsPicsHashes=function(a){this.defaultRequest(a,"EmailsPicsHashes")};p.prototype.facebookUser=function(a){this.defaultRequest(a,"SocialFacebookUserInformation")};p.prototype.facebookDisconnect=function(a){this.defaultRequest(a,"SocialFacebookDisconnect")};p.prototype.twitterUser=function(a){this.defaultRequest(a,"SocialTwitterUserInformation")};p.prototype.twitterDisconnect=function(a){this.defaultRequest(a,"SocialTwitterDisconnect")};p.prototype.googleUser=function(a){this.defaultRequest(a,
"SocialGoogleUserInformation")};p.prototype.googleDisconnect=function(a){this.defaultRequest(a,"SocialGoogleDisconnect")};p.prototype.socialUsers=function(a){this.defaultRequest(a,"SocialUsers")};T.prototype.oEmailsPicsHashes={};T.prototype.oServices={};T.prototype.clear=function(){this.oServices={};this.oEmailsPicsHashes={}};T.prototype.getUserPic=function(a){var b="",b="",b=a.toLowerCase(),d=c.isUnd(this.oEmailsPicsHashes[a])?"":this.oEmailsPicsHashes[a];""===d?(b=b.substr(a.indexOf("@")+1),b=""!==
b&&this.oServices[b]?this.oServices[b]:""):b=e.link().getUserPicUrlFromHash(d);return b};T.prototype.setServicesData=function(a){this.oServices=a};T.prototype.setEmailsPicsHashesData=function(a){this.oEmailsPicsHashes=a};i.extend(v.prototype,T.prototype);v.prototype.oFoldersCache={};v.prototype.oFoldersNamesCache={};v.prototype.oFolderHashCache={};v.prototype.oFolderUidNextCache={};v.prototype.oMessageListHashCache={};v.prototype.oMessageFlagsCache={};v.prototype.oBodies={};v.prototype.oNewMessage=
{};v.prototype.oRequestedMessage={};v.prototype.clear=function(){T.prototype.clear.call(this);this.oFoldersCache={};this.oFoldersNamesCache={};this.oFolderHashCache={};this.oFolderUidNextCache={};this.oMessageListHashCache={};this.oMessageFlagsCache={};this.oBodies={}};v.prototype.getMessageKey=function(a,b){return a+"#"+b};v.prototype.addRequestedMessage=function(a,b){this.oRequestedMessage[this.getMessageKey(a,b)]=!0};v.prototype.hasRequestedMessage=function(a,b){return!0===this.oRequestedMessage[this.getMessageKey(a,
b)]};v.prototype.addNewMessageCache=function(a,b){this.oNewMessage[this.getMessageKey(a,b)]=!0};v.prototype.hasNewMessageAndRemoveFromCache=function(a,b){return this.oNewMessage[this.getMessageKey(a,b)]?(this.oNewMessage[this.getMessageKey(a,b)]=null,!0):!1};v.prototype.clearNewMessageCache=function(){this.oNewMessage={}};v.prototype.getFolderFullNameRaw=function(a){return""!==a&&this.oFoldersNamesCache[a]?this.oFoldersNamesCache[a]:""};v.prototype.setFolderFullNameRaw=function(a,b){this.oFoldersNamesCache[a]=
b};v.prototype.getFolderHash=function(a){return""!==a&&this.oFolderHashCache[a]?this.oFolderHashCache[a]:""};v.prototype.setFolderHash=function(a,b){this.oFolderHashCache[a]=b};v.prototype.getFolderUidNext=function(a){return""!==a&&this.oFolderUidNextCache[a]?this.oFolderUidNextCache[a]:""};v.prototype.setFolderUidNext=function(a,b){this.oFolderUidNextCache[a]=b};v.prototype.getFolderFromCacheList=function(a){return""!==a&&this.oFoldersCache[a]?this.oFoldersCache[a]:null};v.prototype.setFolderToCacheList=
function(a,b){this.oFoldersCache[a]=b};v.prototype.removeFolderFromCacheList=function(a){this.setFolderToCacheList(a,null)};v.prototype.getMessageFlagsFromCache=function(a,b){return this.oMessageFlagsCache[a]&&this.oMessageFlagsCache[a][b]?this.oMessageFlagsCache[a][b]:null};v.prototype.setMessageFlagsToCache=function(a,b,d){this.oMessageFlagsCache[a]||(this.oMessageFlagsCache[a]={});this.oMessageFlagsCache[a][b]=d};v.prototype.clearMessageFlagsFromCacheByFolder=function(a){this.oMessageFlagsCache[a]=
{}};v.prototype.initMessageFlagsFromCache=function(a){if(a){var b=this,d=this.getMessageFlagsFromCache(a.folderFullNameRaw,a.uid),e=null,f=null;d&&4===d.length&&(a.unseen(d[0]),a.flagged(d[1]),a.answered(d[2]),a.forwarded(d[3]));0<a.threads().length&&(e=i.find(a.threads(),function(d){return(d=b.getMessageFlagsFromCache(a.folderFullNameRaw,d))&&4===d.length&&!!d[0]}),f=i.find(a.threads(),function(d){return(d=b.getMessageFlagsFromCache(a.folderFullNameRaw,d))&&4===d.length&&!!d[1]}),a.hasUnseenSubMessage(e&&
0<c.pInt(e)),a.hasFlaggedSubMessage(f&&0<c.pInt(f)))}};v.prototype.storeMessageFlagsToCache=function(a){a&&this.setMessageFlagsToCache(a.folderFullNameRaw,a.uid,[a.unseen(),a.flagged(),a.answered(),a.forwarded()])};v.prototype.storeMessageFlagsToCacheByFolderAndUid=function(a,b,d){c.isArray(d)&&4===d.length&&this.setMessageFlagsToCache(a,b,d)};i.extend(fa.prototype,J.prototype);fa.prototype.onRoute=function(a){var b=this,d=null,g=null,h=null,r=null;if(g=i.find(Fa,function(b){return b&&b.__rlSettingsData&&
a===b.__rlSettingsData.Route}))i.find(Ta,function(a){return a&&a===g})&&(g=null),g&&i.find(Ua,function(a){return a&&a===g})&&(g=null);g&&(g.__builded&&g.__vm?d=g.__vm:(h=j("#rl-content #rl-settings-subscreen"))&&1===h.length?(d=new g,r=j("<div></div>").addClass("rl-settings-view-model").hide().attr("data-bind",'template: {name: "'+g.__rlSettingsData.Template+'"}, i18nInit: true'),r.appendTo(h),d.data=e.data(),d.viewModelDom=r,d.__rlSettingsData=g.__rlSettingsData,g.__dom=r,g.__builded=!0,g.__vm=d,
f.applyBindings(d,r[0]),s.delegateRun(d,"onBuild",[r])):c.log("Cannot find sub settings view model position: SettingsSubScreen"),d&&i.defer(function(){if(b.oCurrentSubScreen){s.delegateRun(b.oCurrentSubScreen,"onHide");b.oCurrentSubScreen.viewModelDom.hide()}b.oCurrentSubScreen=d;if(b.oCurrentSubScreen){b.oCurrentSubScreen.viewModelDom.show();s.delegateRun(b.oCurrentSubScreen,"onShow");i.each(b.menu(),function(a){a.selected(d&&d.__rlSettingsData&&a.route===d.__rlSettingsData.Route)})}c.windowResize()}))};
fa.prototype.onBuild=function(){i.each(Fa,function(a){a&&(a.__rlSettingsData&&!i.find(Ta,function(b){return b&&b===a}))&&this.menu.push({route:a.__rlSettingsData.Route,label:a.__rlSettingsData.Label,selected:f.observable(!1),disabled:!!i.find(Ua,function(b){return b&&b===a})})},this)};fa.prototype.routes=function(){var a=i.find(Fa,function(a){return a&&a.__rlSettingsData&&a.__rlSettingsData.IsDefault}),b=a?a.__rlSettingsData.Route:"general",a={subname:/^(.*)$/,normalize_:function(a,e){e.subname=c.isUnd(e.subname)?
b:c.pString(e.subname);return[e.subname]}};return[["{subname}/",a],["{subname}",a],["",a]]};i.extend(Ba.prototype,J.prototype);Ba.prototype.onShow=function(){e.setTitle(c.i18n("TITLES/LOGIN"))};i.extend(U.prototype,J.prototype);U.prototype.oLastRoute={};U.prototype.onShow=function(){var a=e.data().accountEmail();e.setTitle((""===a?"":a+" - ")+c.i18n("TITLES/MAILBOX"));this.mailBoxScreenVisibily(!0)};U.prototype.onHide=function(){this.mailBoxScreenVisibily(!1)};U.prototype.onRoute=function(a,b,d){var c=
e.data(),a=e.cache().getFolderFullNameRaw(a);if(a=e.cache().getFolderFromCacheList(a))c.currentFolder(a).messageListPage(b).messageListSearch(d),!c.usePreviewPane()&&c.message()&&c.message(null),e.reloadMessageList()};U.prototype.onStart=function(){var a=e.data(),b=function(){c.windowResize()};e.settingsGet("AllowAdditionalAccounts")&&e.accounts();i.delay(function(){e.quota()},5E3);i.delay(function(){"INBOX"!==a.currentFolderFullNameRaw()&&e.folderInformation("INBOX")},1E3);i.delay(function(){var b=
e.data().spamFolder();b!==a.currentFolderFullNameRaw()&&e.folderInformation(b)},1500);i.delay(function(){var b=e.data().draftFolder();b!==a.currentFolderFullNameRaw()&&e.folderInformation(b)},2E3);i.delay(function(){e.remote().appDelayStart(c.emptyFunction)},35E3);h.setInterval(function(){e.folderInformation("INBOX")},12E4);h.setInterval(function(){e.quota()},3E5);Y.toggleClass("rl-no-preview-pane",!a.usePreviewPane());a.folderList.subscribe(b);a.messageList.subscribe(b);a.message.subscribe(b);a.usePreviewPane.subscribe(function(b){Y.toggleClass("rl-no-preview-pane",
!b);a.messageList.valueHasMutated()})};U.prototype.onBuild=function(){i.defer(i.bind(function(){c.initLayoutResizer("#rl-resizer-left","#rl-resizer-right","#rl-right",this.resizeTrigger)},this))};U.prototype.routes=function(){var a=function(a,d){d[0]=c.pString(d[0]);d[1]=c.pInt(d[1]);d[1]=0>=d[1]?1:d[1];d[2]=c.pString(d[2]);""===a&&(d[0]="Inbox",d[1]=1);return[decodeURI(d[0]),d[1],decodeURI(d[2])]};return[[/^([a-zA-Z0-9]+)\/p([1-9][0-9]*)\/(.+)\/?$/,{normalize_:a}],[/^([a-zA-Z0-9]+)\/p([1-9][0-9]*)\/?$/,
{normalize_:a}],[/^([a-zA-Z0-9]+)\/(.+)\/?$/,{normalize_:function(a,d){d[0]=c.pString(d[0]);d[1]=c.pString(d[1]);""===a&&(d[0]="Inbox");return[decodeURI(d[0]),1,decodeURI(d[1])]}}],[/^([^\/]*)$/,{normalize_:a}]]};i.extend(Pa.prototype,fa.prototype);Pa.prototype.onShow=function(){e.setTitle(this.sSettingsTitle)};i.extend(I.prototype,Xa.prototype);I.prototype.oSettings=null;I.prototype.oLink=null;I.prototype.download=function(a){ha?this.iframe.attr("src",a):h.open(a)};I.prototype.link=function(){null===
this.oLink&&(this.oLink=new B);return this.oLink};I.prototype.local=function(){null===this.oLocal&&(this.oLocal=new va);return this.oLocal};I.prototype.settingsGet=function(a){null===this.oSettings&&(this.oSettings=c.isNormal(Da)?Da:{});return c.isUnd(this.oSettings[a])?null:this.oSettings[a]};I.prototype.settingsSet=function(a,b){null===this.oSettings&&(this.oSettings=c.isNormal(Da)?Da:{});this.oSettings[a]=b};I.prototype.setTitle=function(a){a=(0<a.length?a+" - ":"")+this.settingsGet("Title")||
"";a!==h.document.title&&(h.document.title=a)};I.prototype.loginAndLogoutReload=function(a,b){var d=c.pString(this.settingsGet("CustomLogoutLink")),f=!!this.settingsGet("InIframe"),a=c.isUnd(a)?!1:!!a,b=c.isUnd(b)?!1:!!b;a&&(b&&h.close)&&h.close();a&&""!==d&&h.location.href!==d?i.defer(function(){f&&h.parent?h.parent.location.href=d:h.location.href=d}):(s.routeOff(),s.setHash(e.link().root(),!0),s.routeOff(),i.defer(function(){f&&h.parent?h.parent.location.reload():h.location.reload()}))};I.prototype.getAutocomplete=
function(a,b,d){d([],a)};I.prototype.bootstart=function(){c.initOnStartOrLangChange(function(){c.initNotificationLanguage()},null);i.delay(function(){c.windowResize()},1E3)};i.extend(A.prototype,I.prototype);A.prototype.oData=null;A.prototype.oRemote=null;A.prototype.oCache=null;A.prototype.data=function(){null===this.oData&&(this.oData=new S);return this.oData};A.prototype.remote=function(){null===this.oRemote&&(this.oRemote=new p);return this.oRemote};A.prototype.cache=function(){null===this.oCache&&
(this.oCache=new v);return this.oCache};A.prototype.reloadFlagsCurrentMessageListAndMessageFromCache=function(){var a=e.cache();i.each(e.data().messageList(),function(b){a.initMessageFlagsFromCache(b)});a.initMessageFlagsFromCache(e.data().message())};A.prototype.reloadMessageList=function(a,b){var d=e.data(),f=(d.messageListPage()-1)*d.messagesPerPage();(c.isUnd(b)?0:b)&&e.cache().setFolderHash(d.currentFolderFullNameRaw(),"");if(c.isUnd(a)?0:a)d.messageListPage(1),f=0;d.messageListLoading(!0);e.remote().messageList(function(a,
b,e){g.StorageResultType.Success===a&&b&&b.Result?(d.messageListError(""),d.messageListLoading(!1),d.setMessageList(b,e)):g.StorageResultType.Unload===a?(d.messageListError(""),d.messageListLoading(!1)):g.StorageResultType.Abort!==a&&(d.messageList([]),d.messageListLoading(!1),d.messageListError(b&&b.ErrorCode?c.getNotification(b.ErrorCode):c.i18n("NOTIFICATIONS/CANT_GET_MESSAGE_LIST")))},d.currentFolderFullNameRaw(),f,d.messagesPerPage(),d.messageListSearch())};A.prototype.recacheInboxMessageList=
function(){e.remote().messageList(c.emptyFunction,"INBOX",0,e.data().messagesPerPage(),"",!0)};A.prototype.folders=function(a,b){this.data().foldersLoading(!0);this.remote().folders(i.bind(function(a,c,f){e.data().foldersLoading(!1);g.StorageResultType.Success===a?(this.data().setFolders(c,f),b&&b(!0)):b&&b(!1)},this),a)};A.prototype.accounts=function(){e.data().accountsLoading(!0);e.remote().accounts(function(a,b){e.data().accountsLoading(!1);if(g.StorageResultType.Success===a&&c.isArray(b.Result)){var d=
e.settingsGet("ParentEmail"),d=""===d?e.data().accountEmail():d;e.data().accounts(i.map(b.Result,function(a){return new La(a,a!==d)}))}})};A.prototype.quota=function(){this.remote().quota(function(a,b){g.StorageResultType.Success===a&&(b&&b.Result&&c.isArray(b.Result)&&2===b.Result.length&&c.isPosNumeric(b.Result[0],!0)&&c.isPosNumeric(b.Result[1],!0))&&(e.data().userQuota(1024*c.pInt(b.Result[1])),e.data().userUsageSize(1024*c.pInt(b.Result[0])))})};A.prototype.folderInformation=function(a,b){this.remote().folderInformation(function(a,
b){if(g.StorageResultType.Success===a&&b&&b.Result&&b.Result.Hash&&b.Result.Folder){var f=e.cache().getFolderHash(b.Result.Folder),h=e.cache().getFolderFromCacheList(b.Result.Folder),i=!1,j="",m=[],m=!1,o=null;if(h){b.Result.Hash&&e.cache().setFolderHash(b.Result.Folder,b.Result.Hash);c.isNormal(b.Result.MessageCount)&&h.messageCountAll(b.Result.MessageCount);c.isNormal(b.Result.MessageUnseenCount)&&(c.pInt(h.messageCountUnread())!==c.pInt(b.Result.MessageUnseenCount)&&(m=!0),h.messageCountUnread(b.Result.MessageUnseenCount));
m&&e.cache().clearMessageFlagsFromCacheByFolder(h.fullNameRaw);if(b.Result.Flags){for(j in b.Result.Flags)b.Result.Flags.hasOwnProperty(j)&&(i=!0,o=b.Result.Flags[j],e.cache().storeMessageFlagsToCacheByFolderAndUid(h.fullNameRaw,j.toString(),[!o.IsSeen,!!o.IsFlagged,!!o.IsAnswered,!!o.IsForwarded]));i&&e.reloadFlagsCurrentMessageListAndMessageFromCache()}e.data().initUidNextAndNewMessages(h.fullNameRaw,b.Result.UidNext,b.Result.NewMessages);b.Result.Hash!==f||""===f?h.fullNameRaw===e.data().currentFolderFullNameRaw()?
e.reloadMessageList():"INBOX"===h.fullNameRaw&&e.recacheInboxMessageList():m&&h.fullNameRaw===e.data().currentFolderFullNameRaw()&&(m=e.data().messageList(),c.isNonEmptyArray(m)&&e.folderInformation(h.fullNameRaw,m))}}},a,b)};A.prototype.setMessageSeen=function(a){if(a.unseen()){a.unseen(!1);var b=e.cache().getFolderFromCacheList(a.folderFullNameRaw);b&&b.messageCountUnread(0<=b.messageCountUnread()-1?b.messageCountUnread()-1:0);e.cache().storeMessageFlagsToCache(a);e.reloadFlagsCurrentMessageListAndMessageFromCache()}e.remote().messageSetSeen(c.emptyFunction,
a.folderFullNameRaw,[a.uid],!0)};A.prototype.googleConnect=function(){h.open(e.link().socialGoogle(),"Google","left=200,top=100,width=650,height=600,menubar=no,status=no,resizable=yes,scrollbars=yes")};A.prototype.twitterConnect=function(){h.open(e.link().socialTwitter(),"Twitter","left=200,top=100,width=650,height=350,menubar=no,status=no,resizable=yes,scrollbars=yes")};A.prototype.facebookConnect=function(){h.open(e.link().socialFacebook(),"Facebook","left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes")};
A.prototype.socialUsers=function(a){var b=e.data();a&&(b.googleActions(!0),b.facebookActions(!0),b.twitterActions(!0));e.remote().socialUsers(function(a,c){if(g.StorageResultType.Success===a&&c&&c.Result){b.googleUserName(c.Result.Google||"");b.facebookUserName(c.Result.Facebook||"");b.twitterUserName(c.Result.Twitter||"")}else{b.googleUserName("");b.facebookUserName("");b.twitterUserName("")}b.googleLoggined(""!==b.googleUserName());b.facebookLoggined(""!==b.facebookUserName());b.twitterLoggined(""!==
b.twitterUserName());b.googleActions(false);b.facebookActions(false);b.twitterActions(false)})};A.prototype.googleDisconnect=function(){e.data().googleActions(!0);e.remote().googleDisconnect(function(){e.socialUsers()})};A.prototype.facebookDisconnect=function(){e.data().facebookActions(!0);e.remote().facebookDisconnect(function(){e.socialUsers()})};A.prototype.twitterDisconnect=function(){e.data().twitterActions(!0);e.remote().twitterDisconnect(function(){e.socialUsers()})};A.prototype.folderListOptionsBuilder=
function(a,b,d,f,i,j,m,k,p){var o=0,q=0,n=null,s=[],p=!c.isNormal(p)?0<a.length:p,i=!c.isNormal(i)?0:i;c.isArray(d)||(d=[]);c.isArray(f)||(f=[]);o=0;for(q=f.length;o<q;o++)s.push({id:f[o][0],name:f[o][1],disable:!1});o=0;for(q=a.length;o<q;o++)if(n=a[o],c.isNormal(m)?m.call(null,n):1)s.push({id:n.fullNameRaw,system:!0,name:c.isNormal(k)?k.call(null,n):n.name(),disable:!n.selectable||-1<c.inArray(n.fullNameRaw,d)||(c.isNormal(j)?j.call(null,n):!1)});o=0;for(q=b.length;o<q;o++){n=b[o];if(!n.isGmailFolder&&
(n.subScribed()||!n.existen))if(c.isNormal(m)?m.call(null,n):1)if(g.FolderType.User===n.type()||!p||!n.isNamespaceFolder&&0<n.subFolders().length)s.push({id:n.fullNameRaw,system:!1,name:(new h.Array(n.deep+1-i)).join("\u00a0\u00a0\u00a0\u00a0")+(c.isNormal(k)?k.call(null,n):n.name()),disable:!n.selectable||-1<c.inArray(n.fullNameRaw,d)||g.FolderType.User!==n.type()||(c.isNormal(j)?j.call(null,n):!1)});n.isUnpaddigFolder&&i++;s=s.concat(e.folderListOptionsBuilder([],n.subFolders(),d,[],i,j,m,k,p))}return s};
A.prototype.getAutocomplete=function(a,b,d){var f=[];e.remote().suggestions(function(a,b){g.StorageResultType.Success===a&&b&&b.Result&&c.isArray(b.Result.List)?(f=i.map(b.Result.List,function(a){return a&&a[0]?new F(a[0],a[1]):null}),d(i.compact(f),!!b.Result.More)):g.StorageResultType.Abort!==a&&d([],!1)},a,b)};A.prototype.emailsPicsHashes=function(){e.remote().emailsPicsHashes(function(a,b){g.StorageResultType.Success===a&&(b&&b.Result)&&e.cache().setEmailsPicsHashesData(b.Result)})};A.prototype.bootstart=
function(){I.prototype.bootstart.call(this);e.data().populateDataOnStart();var a=this.settingsGet("JsHash"),b=this.settingsGet("AllowGoogleSocial"),d=this.settingsGet("AllowFacebookSocial"),f=this.settingsGet("AllowTwitterSocial");!this.settingsGet("RemoteChangePassword")&&na&&c.removeSettingsViewModel(na);!this.settingsGet("AllowAdditionalAccounts")&&ma&&c.removeSettingsViewModel(ma);!b&&(!d&&!f&&Na)&&c.removeSettingsViewModel(Na);c.initOnStartOrLangChange(function(){j.extend(!0,j.magnificPopup.defaults,
{tClose:c.i18n("MAGNIFIC_POPUP/CLOSE"),tLoading:c.i18n("MAGNIFIC_POPUP/LOADING"),gallery:{tPrev:c.i18n("MAGNIFIC_POPUP/GALLERY_PREV"),tNext:c.i18n("MAGNIFIC_POPUP/GALLERY_NEXT"),tCounter:c.i18n("MAGNIFIC_POPUP/GALLERY_COUNTER")},image:{tError:c.i18n("MAGNIFIC_POPUP/IMAGE_ERROR")},ajax:{tError:c.i18n("MAGNIFIC_POPUP/AJAX_ERROR")}})},this);h.SimplePace&&h.SimplePace.set(70);this.settingsGet("Auth")?(this.setTitle(c.i18n("TITLES/LOADING")),this.folders(!0,i.bind(function(a){s.hideLoading();if(a){s.startScreens([U,
Pa]);Ea.on("mousedown","#rl-center a",function(a){if(a&&3!==a.which){var a=null,b=j(this).attr("href");if(b&&"mailto:"===b.toString().toLowerCase().substr(0,7)){a=new F;a.parse(h.decodeURI(b.toString().substr(7)));if(a&&a.email){s.showScreenPopup(y,[g.ComposeType.Empty,null,[a]]);return false}}}return true});(b||d||f)&&e.socialUsers(true);i.delay(function(){e.emailsPicsHashes();e.remote().servicesPics(function(a,b){g.StorageResultType.Success===a&&(b&&b.Result)&&e.cache().setServicesData(b.Result)})},
1E3);x.runHook("rl-start-user-screens")}else{s.startScreens([Ba]);x.runHook("rl-start-login-screens")}h.SimplePace&&h.SimplePace.set(100)},this))):(s.hideLoading(),s.startScreens([Ba]),x.runHook("rl-start-login-screens"),h.SimplePace&&h.SimplePace.set(100));b&&(h["rl_"+a+"_google_service"]=function(){e.data().googleActions(true);e.socialUsers()});d&&(h["rl_"+a+"_facebook_service"]=function(){e.data().facebookActions(true);e.socialUsers()});f&&(h["rl_"+a+"_twitter_service"]=function(){e.data().twitterActions(true);
e.socialUsers()});x.runHook("rl-start-screens")};e=new A;j(function(){h.setTimeout(function(){s.setBoot(e).bootstart()},10);h.setInterval(function(){xa(!xa())},6E4);i.delay(function(){h.rainloopAppData={};h.rainloopI18N={}},100)});Y.addClass(ha?"mobile":"no-mobile");N.keydown(c.killCtrlAandS).keyup(c.killCtrlAandS);N.unload(function(){Qa=!0});h.rl=h.rl||{};h.rl.addHook=x.addHook;h.rl.settingsGet=x.mainSettingsGet;h.rl.remoteRequest=x.remoteRequest;h.rl.pluginSettingsGet=x.settingsGet;h.rl.addSettingsViewModel=
c.addSettingsViewModel;h.rl.createCommand=c.createCommand;h.rl.EmailModel=F;h.rl.Enums=g;h.SimplePace&&h.SimplePace.add(10)})(window,jQuery,ko,crossroads,hasher,moment,Jua,_);

View file

@ -0,0 +1 @@
ad5376b08217bfdc79eb10ae6e06cc76345e7fc2

View file

@ -0,0 +1 @@
1.3.1.443

View file

@ -0,0 +1,7 @@
imap_host = "imap-mail.outlook.com"
imap_port = 993
imap_secure = "SSL"
smpt_host = "smtp-mail.outlook.com"
smpt_port = 587
smpt_secure = "TLS"
smpt_auth = On

View file

@ -162,6 +162,7 @@ class ImapClient extends \MailSo\Net\NetClient
* @param string $sLogin
* @param string $sPassword
* @param string $sProxyAuthUser = ''
* @param bool $bUseAuthPlainIfSupported = false
*
* @return \MailSo\Imap\ImapClient
*
@ -169,7 +170,7 @@ class ImapClient extends \MailSo\Net\NetClient
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function Login($sLogin, $sPassword, $sProxyAuthUser = '')
public function Login($sLogin, $sPassword, $sProxyAuthUser = '', $bUseAuthPlainIfSupported = false)
{
if (!\MailSo\Base\Validator::NotEmptyString($sLogin, true) ||
!\MailSo\Base\Validator::NotEmptyString($sPassword, true))
@ -186,7 +187,7 @@ class ImapClient extends \MailSo\Net\NetClient
try
{
if ($this->IsSupported('AUTH=PLAIN'))
if ($bUseAuthPlainIfSupported && $this->IsSupported('AUTH=PLAIN'))
{
if ($this->oLogger)
{
@ -198,6 +199,12 @@ class ImapClient extends \MailSo\Net\NetClient
}
else
{
if ($this->oLogger)
{
$this->oLogger->AddSecret($this->EscapeString($sLogin));
$this->oLogger->AddSecret($this->EscapeString($sPassword));
}
$this->SendRequestWithCheck('LOGIN',
array(
$this->EscapeString($sLogin),

Some files were not shown because too many files have changed in this diff Show more