snappymail/rainloop/v/0.0.0/static/js/admin.min.js

4 lines
No EOL
89 KiB
JavaScript

/*! RainLoop Webmail Admin Module (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
!function(a,b,c,d,e,f){"use strict";function g(){this.sBase="#/",this.sCdnStaticDomain=db.settingsGet("CdnStaticDomain"),this.sVersion=db.settingsGet("Version"),this.sSpecSuffix=db.settingsGet("AuthAccountHash")||"0",this.sServer=(db.settingsGet("IndexFile")||"./")+"?",this.sCdnStaticDomain=""===this.sCdnStaticDomain?this.sCdnStaticDomain:"/"===this.sCdnStaticDomain.substr(-1)?this.sCdnStaticDomain:this.sCdnStaticDomain+"/"}function h(){}function i(){}function j(){var a=[i,h],b=f.find(a,function(a){return a.supported()});b&&(b=b,this.oDriver=new b)}function k(){}function l(a,b){this.sPosition=T.pString(a),this.sTemplate=T.pString(b),this.viewModelName="",this.viewModelVisibility=c.observable(!1),"Popups"===this.sPosition&&(this.modalVisibility=c.observable(!1)),this.viewModelDom=null}function m(a,b){this.sScreenName=a,this.aViewModels=T.isArray(b)?b:[]}function n(){this.sDefaultScreenName="",this.oScreens={},this.oBoot=null,this.oCurrentScreen=null,this.popupVisibility=c.observable(!1),this.popupVisibility.subscribe(function(a){db&&db.popupVisibility(a)})}function o(a,b){this.email=a||"",this.name=b||"",this.privateType=null,this.clearDuplicateName()}function p(){l.call(this,"Popups","PopupsDomain"),this.edit=c.observable(!1),this.saving=c.observable(!1),this.savingError=c.observable(""),this.whiteListPage=c.observable(!1),this.testing=c.observable(!1),this.testingDone=c.observable(!1),this.testingImapError=c.observable(!1),this.testingSmtpError=c.observable(!1),this.imapServerFocus=c.observable(!1),this.smtpServerFocus=c.observable(!1),this.name=c.observable(""),this.imapServer=c.observable(""),this.imapPort=c.observable(Q.Values.ImapDefaulPort),this.imapSecure=c.observable(R.ServerSecure.None),this.imapShortLogin=c.observable(!1),this.smtpServer=c.observable(""),this.smtpPort=c.observable(Q.Values.SmtpDefaulPort),this.smtpSecure=c.observable(R.ServerSecure.None),this.smtpShortLogin=c.observable(!1),this.smtpAuth=c.observable(!0),this.whiteList=c.observable(""),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=c.computed(function(){var a=this.name();return this.edit()?'Edit Domain "'+a+'"':"Add Domain"+(""===a?"":' "'+a+'"')},this),this.domainIsComputed=c.computed(function(){return""!==this.name()&&""!==this.imapServer()&&""!==this.imapPort()&&""!==this.smtpServer()&&""!==this.smtpPort()},this),this.canBeTested=c.computed(function(){return!this.testing()&&this.domainIsComputed()},this),this.canBeSaved=c.computed(function(){return!this.saving()&&this.domainIsComputed()},this),this.createOrAddCommand=T.createCommand(this,function(){this.saving(!0),db.remote().createOrUpdateDomain(f.bind(this.onDomainCreateOrSaveResponse,this),!this.edit(),this.name(),this.imapServer(),this.imapPort(),this.imapSecure(),this.imapShortLogin(),this.smtpServer(),this.smtpPort(),this.smtpSecure(),this.smtpShortLogin(),this.smtpAuth(),this.whiteList())},this.canBeSaved),this.testConnectionCommand=T.createCommand(this,function(){this.whiteListPage(!1),this.testingDone(!1),this.testingImapError(!1),this.testingSmtpError(!1),this.testing(!0),db.remote().testConnectionForDomain(f.bind(this.onTestConnectionResponse,this),this.imapServer(),this.imapPort(),this.imapSecure(),this.smtpServer(),this.smtpPort(),this.smtpSecure(),this.smtpAuth())},this.canBeTested),this.whiteListCommand=T.createCommand(this,function(){this.whiteListPage(!this.whiteListPage())}),n.constructorEnd(this)}function q(){l.call(this,"Popups","PopupsPlugin");var a=this;this.onPluginSettingsUpdateResponse=f.bind(this.onPluginSettingsUpdateResponse,this),this.saveError=c.observable(""),this.name=c.observable(""),this.readme=c.observable(""),this.configures=c.observableArray([]),this.hasReadme=c.computed(function(){return""!==this.readme()},this),this.hasConfiguration=c.computed(function(){return 0<this.configures().length},this),this.readmePopoverConf={placement:"top",trigger:"hover",title:"About",content:function(){return a.readme()}},this.saveCommand=T.createCommand(this,function(){var a={};a.Name=this.name(),f.each(this.configures(),function(b){var c=b.value();(!1===c||!0===c)&&(c=c?"1":"0"),a["_"+b.Name]=c},this),this.saveError(""),db.remote().pluginSettingsUpdate(this.onPluginSettingsUpdateResponse,a)},this.hasConfiguration),n.constructorEnd(this)}function r(){l.call(this,"Popups","PopupsActivate");var a=this;this.domain=c.observable(""),this.key=c.observable(""),this.key.focus=c.observable(!1),this.activationSuccessed=c.observable(!1),this.licenseTrigger=db.data().licenseTrigger,this.activateProcess=c.observable(!1),this.activateText=c.observable(""),this.activateText.isError=c.observable(!1),this.key.subscribe(function(){this.activateText(""),this.activateText.isError(!1)},this),this.activationSuccessed.subscribe(function(a){a&&this.licenseTrigger(!this.licenseTrigger())},this),this.activateCommand=T.createCommand(this,function(){this.activateProcess(!0),this.validateSubscriptionKey()?db.remote().licensingActivate(function(b,c){a.activateProcess(!1),R.StorageResultType.Success===b&&c.Result?!0===c.Result?(a.activationSuccessed(!0),a.activateText("Subscription Key Activated Successfully"),a.activateText.isError(!1)):(a.activateText(c.Result),a.activateText.isError(!0),a.key.focus(!0)):c.ErrorCode?(a.activateText(T.getNotification(c.ErrorCode)),a.activateText.isError(!0),a.key.focus(!0)):(a.activateText(T.getNotification(R.Notification.UnknownError)),a.activateText.isError(!0),a.key.focus(!0))},this.domain(),this.key()):(this.activateProcess(!1),this.activateText("Invalid Subscription Key"),this.activateText.isError(!0),this.key.focus(!0))},function(){return!this.activateProcess()&&""!==this.domain()&&""!==this.key()&&!this.activationSuccessed()}),n.constructorEnd(this)}function s(){l.call(this,"Popups","PopupsLanguages"),this.exp=c.observable(!1),this.languages=c.computed(function(){return f.map(db.data().languages(),function(a){return{key:a,selected:c.observable(!1),fullName:T.convertLangName(a)}})}),db.data().mainLanguage.subscribe(function(){this.resetMainLanguage()},this),n.constructorEnd(this)}function t(){l.call(this,"Right","AdminLogin"),this.login=c.observable(""),this.password=c.observable(""),this.loginError=c.observable(!1),this.passwordError=c.observable(!1),this.loginFocus=c.observable(!1),this.login.subscribe(function(){this.loginError(!1)},this),this.password.subscribe(function(){this.passwordError(!1)},this),this.submitRequest=c.observable(!1),this.submitError=c.observable(""),this.submitCommand=T.createCommand(this,function(){return this.loginError(""===T.trim(this.login())),this.passwordError(""===T.trim(this.password())),this.loginError()||this.passwordError()?!1:(this.submitRequest(!0),db.remote().adminLogin(f.bind(function(a,b){R.StorageResultType.Success===a&&b&&"AdminLogin"===b.Action?b.Result?db.loginAndLogoutReload():b.ErrorCode&&(this.submitRequest(!1),this.submitError(T.getNotification(b.ErrorCode))):(this.submitRequest(!1),this.submitError(T.getNotification(R.Notification.UnknownError)))},this),this.login(),this.password()),!0)},function(){return!this.submitRequest()}),n.constructorEnd(this)}function u(a){l.call(this,"Left","AdminMenu"),this.menu=a.menu,n.constructorEnd(this)}function v(){l.call(this,"Right","AdminPane"),this.adminDomain=c.observable(db.settingsGet("AdminDomain")),this.version=c.observable(db.settingsGet("Version")),n.constructorEnd(this)}function w(){var a=db.data();this.mainLanguage=a.mainLanguage,this.mainTheme=a.mainTheme,this.language=a.language,this.theme=a.theme,this.allowThemes=a.allowThemes,this.allowCustomTheme=a.allowCustomTheme,this.allowLanguagesOnSettings=a.allowLanguagesOnSettings,this.allowAdditionalAccounts=a.allowAdditionalAccounts,this.allowIdentities=a.allowIdentities,this.title=c.observable(db.settingsGet("Title")),this.loadingDesc=c.observable(db.settingsGet("LoadingDescription")),this.themesOptions=c.computed(function(){return f.map(a.themes(),function(a){return{optValue:a,optText:T.convertThemeName(a)}})}),this.mainLanguageFullName=c.computed(function(){return T.convertLangName(this.mainLanguage())},this),this.weakPassword=!!db.settingsGet("WeakPassword"),this.titleTrigger=c.observable(R.SaveSettingsStep.Idle),this.languageTrigger=c.observable(R.SaveSettingsStep.Idle),this.themeTrigger=c.observable(R.SaveSettingsStep.Idle),this.loadingDescTrigger=c.observable(R.SaveSettingsStep.Idle)}function x(){var a=db.data();this.allowCustomLogin=a.allowCustomLogin,this.determineUserLanguage=a.determineUserLanguage,this.defaultDomain=c.observable(db.settingsGet("LoginDefaultDomain")),this.allowLanguagesOnLogin=a.allowLanguagesOnLogin,this.defaultDomainTrigger=c.observable(R.SaveSettingsStep.Idle)}function y(){this.contactsSupported=!!db.settingsGet("ContactsIsSupported"),this.enableContacts=c.observable(!!db.settingsGet("ContactsEnable")),this.pdoDsn=c.observable(db.settingsGet("ContactsPdoDsn")),this.pdoUser=c.observable(db.settingsGet("ContactsPdoUser")),this.pdoPassword=c.observable(db.settingsGet("ContactsPdoPassword")),this.pdoDsnTrigger=c.observable(R.SaveSettingsStep.Idle),this.pdoUserTrigger=c.observable(R.SaveSettingsStep.Idle),this.pdoPasswordTrigger=c.observable(R.SaveSettingsStep.Idle),this.testing=c.observable(!1),this.testContactsSuccess=c.observable(!1),this.testContactsError=c.observable(!1),this.testContactsErrorMessage=c.observable(""),this.testContactsCommand=T.createCommand(this,function(){this.testContactsSuccess(!1),this.testContactsError(!1),this.testContactsErrorMessage(""),this.testing(!0),db.remote().testContacts(this.onTestContactsResponse,{ContactsPdoDsn:this.pdoDsn(),ContactsPdoUser:this.pdoUser(),ContactsPdoPassword:this.pdoPassword()})},function(){return""!==this.pdoDsn()&&""!==this.pdoUser()}),this.onTestContactsResponse=f.bind(this.onTestContactsResponse,this)}function z(){var a=db.data();this.domains=a.domains,this.domainsLoading=a.domainsLoading,this.iDomainForDeletionTimeout=0,this.visibility=c.computed(function(){return a.domainsLoading()?"visible":"hidden"},this),this.domainForDeletion=c.observable(null).extend({toggleSubscribe:[this,function(a){a&&a.deleteAccess(!1)},function(a){a&&(a.deleteAccess(!0),this.startDomainForDeletionTimeout())}]})}function A(){this.csrfProtection=c.observable(!!db.settingsGet("UseTokenProtection")),this.adminLogin=c.observable(db.settingsGet("AdminLogin")),this.adminPassword=c.observable(""),this.adminPasswordNew=c.observable(""),this.adminPasswordUpdateError=c.observable(!1),this.adminPasswordUpdateSuccess=c.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.saveNewAdminPasswordCommand=T.createCommand(this,function(){this.adminPasswordUpdateError(!1),this.adminPasswordUpdateSuccess(!1),db.remote().saveNewAdminPassword(this.onNewAdminPasswordResponse,{Password:this.adminPassword(),NewPassword:this.adminPasswordNew()})},function(){return""!==this.adminPassword()&&""!==this.adminPasswordNew()}),this.onNewAdminPasswordResponse=f.bind(this.onNewAdminPasswordResponse,this)}function B(){var a=db.data();this.googleEnable=a.googleEnable,this.googleClientID=a.googleClientID,this.googleClientSecret=a.googleClientSecret,this.googleTrigger1=c.observable(R.SaveSettingsStep.Idle),this.googleTrigger2=c.observable(R.SaveSettingsStep.Idle),this.facebookEnable=a.facebookEnable,this.facebookAppID=a.facebookAppID,this.facebookAppSecret=a.facebookAppSecret,this.facebookTrigger1=c.observable(R.SaveSettingsStep.Idle),this.facebookTrigger2=c.observable(R.SaveSettingsStep.Idle),this.twitterEnable=a.twitterEnable,this.twitterConsumerKey=a.twitterConsumerKey,this.twitterConsumerSecret=a.twitterConsumerSecret,this.twitterTrigger1=c.observable(R.SaveSettingsStep.Idle),this.twitterTrigger2=c.observable(R.SaveSettingsStep.Idle),this.dropboxEnable=a.dropboxEnable,this.dropboxApiKey=a.dropboxApiKey,this.dropboxTrigger1=c.observable(R.SaveSettingsStep.Idle)}function C(){var a=db.data();this.enabledPlugins=c.observable(!!db.settingsGet("EnabledPlugins")),this.pluginsError=c.observable(""),this.plugins=a.plugins,this.pluginsLoading=a.pluginsLoading,this.visibility=c.computed(function(){return a.pluginsLoading()?"visible":"hidden"},this),this.onPluginLoadRequest=f.bind(this.onPluginLoadRequest,this),this.onPluginDisableRequest=f.bind(this.onPluginDisableRequest,this)}function D(){var a=db.data();this.packagesError=c.observable(""),this.packages=a.packages,this.packagesLoading=a.packagesLoading,this.packagesReal=a.packagesReal,this.packagesMainUpdatable=a.packagesMainUpdatable,this.packagesCurrent=c.computed(function(){return f.filter(this.packages(),function(a){return a&&""!==a.installed&&!a.compare})},this),this.packagesAvailableForUpdate=c.computed(function(){return f.filter(this.packages(),function(a){return a&&""!==a.installed&&!!a.compare})},this),this.packagesAvailableForInstallation=c.computed(function(){return f.filter(this.packages(),function(a){return a&&""===a.installed})},this),this.visibility=c.computed(function(){return a.packagesLoading()?"visible":"hidden"},this)}function E(){this.licensing=db.data().licensing,this.licensingProcess=db.data().licensingProcess,this.licenseValid=db.data().licenseValid,this.licenseExpired=db.data().licenseExpired,this.licenseError=db.data().licenseError,this.licenseTrigger=db.data().licenseTrigger,this.adminDomain=c.observable(""),this.subscriptionEnabled=c.observable(!!db.settingsGet("SubscriptionEnabled")),this.licenseTrigger.subscribe(function(){this.subscriptionEnabled()&&db.reloadLicensing(!0)},this)}function F(){T.initDataConstructorBySettings(this)}function G(){F.call(this),this.domainsLoading=c.observable(!1).extend({throttle:100}),this.domains=c.observableArray([]),this.pluginsLoading=c.observable(!1).extend({throttle:100}),this.plugins=c.observableArray([]),this.packagesReal=c.observable(!0),this.packagesMainUpdatable=c.observable(!0),this.packagesLoading=c.observable(!1).extend({throttle:100}),this.packages=c.observableArray([]),this.licensing=c.observable(!1),this.licensingProcess=c.observable(!1),this.licenseValid=c.observable(!1),this.licenseExpired=c.observable(0),this.licenseError=c.observable(""),this.licenseTrigger=c.observable(!1)}function H(){this.oRequests={}}function I(){H.call(this),this.oRequests={}}function J(){this.oEmailsPicsHashes={},this.oServices={}}function K(){J.call(this)}function L(a){m.call(this,"settings",a),this.menu=c.observableArray([]),this.oCurrentSubScreen=null,this.oViewModelPlace=null}function M(){m.call(this,"login",[t])}function N(){L.call(this,[u,v])}function O(){k.call(this),this.oSettings=null,this.oPlugins=null,this.oLink=null,this.oLocal=null,this.isLocalAutocomplete=!0,this.popupVisibility=c.observable(!1),this.iframe=b('<iframe style="display:none" src="javascript:;" />').appendTo("body"),ab.on("error",function(a){db&&a&&a.originalEvent&&a.originalEvent.message&&-1===T.inArray(a.originalEvent.message,["Script error.","Uncaught Error: Error calling method on NPObject."])&&db.remote().jsError(T.emptyFunction,a.originalEvent.message,a.originalEvent.filename,a.originalEvent.lineno,location&&location.toString?location.toString():"",_.attr("class"),T.microtime()-W.now)})}function P(){O.call(this),this.oData=null,this.oRemote=null,this.oCache=null}var Q={},R={},S={},T={},U={},V={},W={},X={settings:[],"settings-removed":[],"settings-disabled":[]},Y=null,Z=a.rainloopAppData||{},$=a.rainloopI18N||{},_=b("html"),ab=b(a),bb=b(a.document),cb=a.Notification&&a.Notification.requestPermission?a.Notification:null,db=null;W.now=(new Date).getTime(),W.minuteTick=c.observable(!0),W.fiveMinuteTick=c.observable(!0),W.langChangeTick=c.observable(!0),W.iAjaxErrorCount=0,W.iTokenErrorCount=0,W.iMessageBodyCacheCount=0,W.bUnload=!1,W.sUserAgent=(navigator.userAgent||"").toLowerCase(),W.bIsiOSDevice=-1<W.sUserAgent.indexOf("iphone")||-1<W.sUserAgent.indexOf("ipod")||-1<W.sUserAgent.indexOf("ipad"),W.bIsAndroidDevice=-1<W.sUserAgent.indexOf("android"),W.bMobileDevice=W.bIsiOSDevice||W.bIsAndroidDevice,W.bDisableNanoScroll=W.bMobileDevice,W.bAnimationSupported=!W.bMobileDevice&&_.hasClass("csstransitions"),W.sAnimationType="",Q.Defaults={},Q.Values={},Q.DataImages={},Q.Defaults.MessagesPerPage=20,Q.Defaults.ContactsPerPage=20,Q.Defaults.MessagesPerPageArray=[10,20,30,50,100],Q.Defaults.DefaultAjaxTimeout=2e4,Q.Defaults.SearchAjaxTimeout=12e4,Q.Defaults.SendMessageAjaxTimeout=2e5,Q.Defaults.SaveMessageAjaxTimeout=2e5,Q.Values.UnuseOptionValue="__UNUSE__",Q.Values.GmailFolderName="[Gmail]",Q.Values.ClientSideCookieIndexName="rlcsc",Q.Values.ImapDefaulPort=143,Q.Values.ImapDefaulSecurePort=993,Q.Values.SmtpDefaulPort=25,Q.Values.SmtpDefaulSecurePort=465,Q.Values.MessageBodyCacheLimit=15,Q.Values.AjaxErrorLimit=7,Q.Values.TokenErrorLimit=10,Q.DataImages.UserDotPic="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2P8DwQACgAD/il4QJ8AAAAASUVORK5CYII=",Q.DataImages.TranspPic="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2NkAAIAAAoAAggA9GkAAAAASUVORK5CYII=",R.StorageResultType={Success:"success",Abort:"abort",Error:"error",Unload:"unload"},R.State={Empty:10,Login:20,Auth:30},R.StateType={Webmail:0,Admin:1},R.FolderType={Inbox:10,SentItems:11,Draft:12,Trash:13,Spam:14,User:99},R.LoginSignMeTypeAsString={DefaultOff:"defaultoff",DefaultOn:"defaulton",Unused:"unused"},R.LoginSignMeType={DefaultOff:0,DefaultOn:1,Unused:2},R.ComposeType={Empty:"empty",Reply:"reply",ReplyAll:"replyall",Forward:"forward",ForwardAsAttachment:"forward-as-attachment",Draft:"draft"},R.UploadErrorCode={Normal:0,FileIsTooBig:1,FilePartiallyUploaded:2,FileNoUploaded:3,MissingTempFolder:4,FileOnSaveingError:5,FileType:98,Unknown:99},R.SetSystemFoldersNotification={None:0,Sent:1,Draft:2,Spam:3,Trash:4},R.ClientSideKeyName={FoldersLashHash:0,MessagesInboxLastHash:1,MailBoxListSize:2,ExpandedFolders:3,FolderListSize:4},R.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},R.MessageSetAction={SetSeen:0,UnsetSeen:1,SetFlag:2,UnsetFlag:3},R.MessageSelectAction={All:0,None:1,Invert:2,Unseen:3,Seen:4,Flagged:5,Unflagged:6},R.DesktopNotifications={Allowed:0,NotAllowed:1,Denied:2,NotSupported:9},R.MessagePriority={Low:5,Normal:3,High:1},R.EditorDefaultType={Html:"Html",Plain:"Plain"},R.CustomThemeType={Light:"Light",Dark:"Dark"},R.ServerSecure={None:0,SSL:1,TLS:2},R.SearchDateType={All:-1,Days3:3,Days7:7,Month:30},R.EmailType={Defailt:0,Facebook:1,Google:2},R.SaveSettingsStep={Animate:-2,Idle:-1,TrueResult:1,FalseResult:0},R.InterfaceAnimation={None:"None",Normal:"Normal",Full:"Full"},R.ContactPropertyType={Unknown:0,FullName:10,FirstName:15,SurName:16,MiddleName:17,Nick:18,EmailPersonal:30,EmailBussines:31,EmailOther:32,PhonePersonal:50,PhoneBussines:51,PhoneOther:52,MobilePersonal:60,MobileBussines:61,MobileOther:62,FaxPesonal:70,FaxBussines:71,FaxOther:72,Facebook:90,Skype:91,GitHub:92,Description:110,Custom:250},R.Notification={InvalidToken:101,AuthError:102,AccessError:103,ConnectionError:104,CaptchaError:105,SocialFacebookLoginAccessDisable:106,SocialTwitterLoginAccessDisable:107,SocialGoogleLoginAccessDisable:108,DomainNotAllowed:109,AccountNotAllowed:110,CantGetMessageList:201,CantGetMessage:202,CantDeleteMessage:203,CantMoveMessage:204,CantCopyMessage:205,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,UnknownNotification:999,UnknownError:999},T.trim=b.trim,T.inArray=b.inArray,T.isArray=f.isArray,T.isFunc=f.isFunction,T.isUnd=f.isUndefined,T.isNull=f.isNull,T.emptyFunction=function(){},T.isNormal=function(a){return!T.isUnd(a)&&!T.isNull(a)},T.windowResize=f.debounce(function(b){T.isUnd(b)?ab.resize():a.setTimeout(function(){ab.resize()},b)},50),T.isPosNumeric=function(a,b){return T.isNormal(a)?(T.isUnd(b)?0:!b)?/^[1-9]+[0-9]*$/.test(a.toString()):/^[0-9]*$/.test(a.toString()):!1},T.pInt=function(b){return T.isNormal(b)&&""!==b?a.parseInt(b,10):0},T.pString=function(a){return T.isNormal(a)?""+a:""},T.isNonEmptyArray=function(a){return T.isArray(a)&&0<a.length},T.exportPath=function(b,c,d){for(var e=null,f=b.split("."),g=d||a;f.length&&(e=f.shift());)f.length||T.isUnd(c)?g=g[e]?g[e]:g[e]={}:g[e]=c},T.pImport=function(a,b,c){a[b]=c},T.pExport=function(a,b,c){return T.isUnd(a[b])?c:a[b]},T.encodeHtml=function(a){return T.isNormal(a)?a.toString().replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;"):""},T.splitPlainText=function(a,b){var c="",d="",e=a,f=0,g=0;for(b=T.isUnd(b)?100:b;e.length>b;)d=e.substring(0,b),f=d.lastIndexOf(" "),g=d.lastIndexOf("\n"),-1!==g&&(f=g),-1===f&&(f=b),c+=d.substring(0,f)+"\n",e=e.substring(f+1);return c+e},T.timeOutAction=function(){var b={};return function(c,d,e){T.isUnd(b[c])&&(b[c]=0),a.clearTimeout(b[c]),b[c]=a.setTimeout(d,e)}}(),T.timeOutActionSecond=function(){var b={};return function(c,d,e){b[c]||(b[c]=a.setTimeout(function(){d(),b[c]=0},e))}}(),T.audio=function(){var b=!1;return function(c,d){if(!1===b)if(W.bIsiOSDevice)b=null;else{var e=!1,f=!1,g=a.Audio?new a.Audio:null;g&&g.canPlayType&&g.play?(e=""!==g.canPlayType('audio/mpeg; codecs="mp3"'),e||(f=""!==g.canPlayType('audio/ogg; codecs="vorbis"')),e||f?(b=g,b.preload="none",b.loop=!1,b.autoplay=!1,b.muted=!1,b.src=e?c:d):b=null):b=null}return b}}(),T.hos=function(a,b){return a&&Object.hasOwnProperty?Object.hasOwnProperty.call(a,b):!1},T.i18n=function(a,b,c){var d="",e=T.isUnd($[a])?T.isUnd(c)?a:c:$[a];if(!T.isUnd(b)&&!T.isNull(b))for(d in b)T.hos(b,d)&&(e=e.replace("%"+d+"%",b[d]));return e},T.i18nToNode=function(a){f.defer(function(){b(".i18n",a).each(function(){var a=b(this),c="";c=a.data("i18n-text"),c?a.text(T.i18n(c)):(c=a.data("i18n-html"),c&&a.html(T.i18n(c)),c=a.data("i18n-placeholder"),c&&a.attr("placeholder",T.i18n(c)))})})},T.i18nToDoc=function(){a.rainloopI18N&&($=a.rainloopI18N||{},T.i18nToNode(bb),W.langChangeTick(!W.langChangeTick())),a.rainloopI18N={}},T.initOnStartOrLangChange=function(a,b,c){a&&a.call(b),c?W.langChangeTick.subscribe(function(){a&&a.call(b),c.call(b)}):a&&W.langChangeTick.subscribe(a,b)},T.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)},T.removeInFocus=function(){if(document&&document.activeElement&&document.activeElement.blur){var a=b(document.activeElement);(a.is("input")||a.is("textarea"))&&document.activeElement.blur()}},T.removeSelection=function(){if(a&&a.getSelection){var b=a.getSelection();b&&b.removeAllRanges&&b.removeAllRanges()}else document&&document.selection&&document.selection.empty&&document.selection.empty()},T.replySubjectAdd=function(b,c,d){var e=null,f=T.trim(c);return null===(e=new a.RegExp("^"+b+"[\\s]?\\:(.*)$","gi").exec(c))||T.isUnd(e[1])?null===(e=new a.RegExp("^("+b+"[\\s]?[\\[\\(]?)([\\d]+)([\\]\\)]?[\\s]?\\:.*)$","gi").exec(c))||T.isUnd(e[1])||T.isUnd(e[2])||T.isUnd(e[3])?f=b+": "+c:(f=e[1]+(T.pInt(e[2])+1)+e[3],f=e[1]+(T.pInt(e[2])+1)+e[3]):f=b+"[2]: "+e[1],f=f.replace(/[\s]+/g," "),(T.isUnd(d)?!0:d)?T.fixLongSubject(f):f},T.fixLongSubject=function(b){var c=0,d=null;b=T.trim(b.replace(/[\s]+/," "));do d=/^Re(\[([\d]+)\]|):[\s]{0,3}Re(\[([\d]+)\]|):/gi.exec(b),a.console.log(b),a.console.log(d),(!d||T.isUnd(d[0]))&&(d=null),d&&(c=0,c+=T.isUnd(d[2])?1:0+T.pInt(d[2]),c+=T.isUnd(d[4])?1:0+T.pInt(d[4]),b=b.replace(/^Re(\[[\d]+\]|):[\s]{0,3}Re(\[[\d]+\]|):/gi,"Re"+(c>0?"["+c+"]":"")+":"));while(d);return b=b.replace(/[\s]+/," ")},T.roundNumber=function(a,b){return Math.round(a*Math.pow(10,b))/Math.pow(10,b)},T.friendlySize=function(a){return a=T.pInt(a),a>=1073741824?T.roundNumber(a/1073741824,1)+"GB":a>=1048576?T.roundNumber(a/1048576,1)+"MB":a>=1024?T.roundNumber(a/1024,0)+"KB":a+"B"},T.log=function(b){a.console&&a.console.log&&a.console.log(b)},T.getNotification=function(a){return a=T.pInt(a),T.isUnd(S[a])?"":S[a]},T.initNotificationLanguage=function(){S[R.Notification.InvalidToken]=T.i18n("NOTIFICATIONS/INVALID_TOKEN"),S[R.Notification.AuthError]=T.i18n("NOTIFICATIONS/AUTH_ERROR"),S[R.Notification.AccessError]=T.i18n("NOTIFICATIONS/ACCESS_ERROR"),S[R.Notification.ConnectionError]=T.i18n("NOTIFICATIONS/CONNECTION_ERROR"),S[R.Notification.CaptchaError]=T.i18n("NOTIFICATIONS/CAPTCHA_ERROR"),S[R.Notification.SocialFacebookLoginAccessDisable]=T.i18n("NOTIFICATIONS/SOCIAL_FACEBOOK_LOGIN_ACCESS_DISABLE"),S[R.Notification.SocialTwitterLoginAccessDisable]=T.i18n("NOTIFICATIONS/SOCIAL_TWITTER_LOGIN_ACCESS_DISABLE"),S[R.Notification.SocialGoogleLoginAccessDisable]=T.i18n("NOTIFICATIONS/SOCIAL_GOOGLE_LOGIN_ACCESS_DISABLE"),S[R.Notification.DomainNotAllowed]=T.i18n("NOTIFICATIONS/DOMAIN_NOT_ALLOWED"),S[R.Notification.AccountNotAllowed]=T.i18n("NOTIFICATIONS/ACCOUNT_NOT_ALLOWED"),S[R.Notification.CantGetMessageList]=T.i18n("NOTIFICATIONS/CANT_GET_MESSAGE_LIST"),S[R.Notification.CantGetMessage]=T.i18n("NOTIFICATIONS/CANT_GET_MESSAGE"),S[R.Notification.CantDeleteMessage]=T.i18n("NOTIFICATIONS/CANT_DELETE_MESSAGE"),S[R.Notification.CantMoveMessage]=T.i18n("NOTIFICATIONS/CANT_MOVE_MESSAGE"),S[R.Notification.CantCopyMessage]=T.i18n("NOTIFICATIONS/CANT_MOVE_MESSAGE"),S[R.Notification.CantSaveMessage]=T.i18n("NOTIFICATIONS/CANT_SAVE_MESSAGE"),S[R.Notification.CantSendMessage]=T.i18n("NOTIFICATIONS/CANT_SEND_MESSAGE"),S[R.Notification.InvalidRecipients]=T.i18n("NOTIFICATIONS/INVALID_RECIPIENTS"),S[R.Notification.CantCreateFolder]=T.i18n("NOTIFICATIONS/CANT_CREATE_FOLDER"),S[R.Notification.CantRenameFolder]=T.i18n("NOTIFICATIONS/CANT_RENAME_FOLDER"),S[R.Notification.CantDeleteFolder]=T.i18n("NOTIFICATIONS/CANT_DELETE_FOLDER"),S[R.Notification.CantDeleteNonEmptyFolder]=T.i18n("NOTIFICATIONS/CANT_DELETE_NON_EMPTY_FOLDER"),S[R.Notification.CantSubscribeFolder]=T.i18n("NOTIFICATIONS/CANT_SUBSCRIBE_FOLDER"),S[R.Notification.CantUnsubscribeFolder]=T.i18n("NOTIFICATIONS/CANT_UNSUBSCRIBE_FOLDER"),S[R.Notification.CantSaveSettings]=T.i18n("NOTIFICATIONS/CANT_SAVE_SETTINGS"),S[R.Notification.CantSavePluginSettings]=T.i18n("NOTIFICATIONS/CANT_SAVE_PLUGIN_SETTINGS"),S[R.Notification.DomainAlreadyExists]=T.i18n("NOTIFICATIONS/DOMAIN_ALREADY_EXISTS"),S[R.Notification.CantInstallPackage]=T.i18n("NOTIFICATIONS/CANT_INSTALL_PACKAGE"),S[R.Notification.CantDeletePackage]=T.i18n("NOTIFICATIONS/CANT_DELETE_PACKAGE"),S[R.Notification.InvalidPluginPackage]=T.i18n("NOTIFICATIONS/INVALID_PLUGIN_PACKAGE"),S[R.Notification.UnsupportedPluginPackage]=T.i18n("NOTIFICATIONS/UNSUPPORTED_PLUGIN_PACKAGE"),S[R.Notification.LicensingServerIsUnavailable]=T.i18n("NOTIFICATIONS/LICENSING_SERVER_IS_UNAVAILABLE"),S[R.Notification.LicensingExpired]=T.i18n("NOTIFICATIONS/LICENSING_EXPIRED"),S[R.Notification.LicensingBanned]=T.i18n("NOTIFICATIONS/LICENSING_BANNED"),S[R.Notification.DemoSendMessageError]=T.i18n("NOTIFICATIONS/DEMO_SEND_MESSAGE_ERROR"),S[R.Notification.AccountAlreadyExists]=T.i18n("NOTIFICATIONS/ACCOUNT_ALREADY_EXISTS"),S[R.Notification.MailServerError]=T.i18n("NOTIFICATIONS/MAIL_SERVER_ERROR"),S[R.Notification.UnknownNotification]=T.i18n("NOTIFICATIONS/UNKNOWN_ERROR"),S[R.Notification.UnknownError]=T.i18n("NOTIFICATIONS/UNKNOWN_ERROR")},T.getUploadErrorDescByCode=function(a){var b="";switch(T.pInt(a)){case R.UploadErrorCode.FileIsTooBig:b=T.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG");break;case R.UploadErrorCode.FilePartiallyUploaded:b=T.i18n("UPLOAD/ERROR_FILE_PARTIALLY_UPLOADED");break;case R.UploadErrorCode.FileNoUploaded:b=T.i18n("UPLOAD/ERROR_NO_FILE_UPLOADED");break;case R.UploadErrorCode.MissingTempFolder:b=T.i18n("UPLOAD/ERROR_MISSING_TEMP_FOLDER");break;case R.UploadErrorCode.FileOnSaveingError:b=T.i18n("UPLOAD/ERROR_ON_SAVING_FILE");break;case R.UploadErrorCode.FileType:b=T.i18n("UPLOAD/ERROR_FILE_TYPE");break;default:b=T.i18n("UPLOAD/ERROR_UNKNOWN")}return b},T.killCtrlAandS=function(b){if(b=b||a.event){var c=b.target||b.srcElement,d=b.keyCode||b.which;if(b.ctrlKey&&d===R.EventKeyCode.S)return b.preventDefault(),void 0;if(c&&c.tagName&&c.tagName.match(/INPUT|TEXTAREA/i))return;b.ctrlKey&&d===R.EventKeyCode.A&&(a.getSelection?a.getSelection().removeAllRanges():a.document.selection&&a.document.selection.clear&&a.document.selection.clear(),b.preventDefault())}},T.createCommand=function(a,b,d){var e=b?function(){return e.canExecute&&e.canExecute()&&b.apply(a,Array.prototype.slice.call(arguments)),!1}:function(){};return e.enabled=c.observable(!0),d=T.isUnd(d)?!0:d,e.canExecute=T.isFunc(d)?c.computed(function(){return e.enabled()&&d.call(a)}):c.computed(function(){return e.enabled()&&!!d}),e},T.initDataConstructorBySettings=function(b){b.editorDefaultType=c.observable(R.EditorDefaultType.Html),b.showImages=c.observable(!1),b.interfaceAnimation=c.observable(R.InterfaceAnimation.Full),W.sAnimationType=R.InterfaceAnimation.Full,b.allowThemes=c.observable(!0),b.allowCustomLogin=c.observable(!1),b.allowLanguagesOnSettings=c.observable(!0),b.allowLanguagesOnLogin=c.observable(!0),b.desktopNotifications=c.observable(!1),b.useThreads=c.observable(!0),b.replySameFolder=c.observable(!0),b.usePreviewPane=c.observable(!0),b.useCheckboxesInList=c.observable(!0),b.interfaceAnimation.subscribe(function(a){if(W.bMobileDevice||a===R.InterfaceAnimation.None)_.removeClass("rl-anim rl-anim-full").addClass("no-rl-anim"),W.sAnimationType=R.InterfaceAnimation.None;else switch(a){case R.InterfaceAnimation.Full:_.removeClass("no-rl-anim").addClass("rl-anim rl-anim-full"),W.sAnimationType=a;break;case R.InterfaceAnimation.Normal:_.removeClass("no-rl-anim rl-anim-full").addClass("rl-anim"),W.sAnimationType=a}}),b.interfaceAnimation.valueHasMutated(),b.desktopNotificationsPermisions=c.computed(function(){b.desktopNotifications();var c=R.DesktopNotifications.NotSupported;if(cb&&cb.permission)switch(cb.permission.toLowerCase()){case"granted":c=R.DesktopNotifications.Allowed;break;case"denied":c=R.DesktopNotifications.Denied;break;case"default":c=R.DesktopNotifications.NotAllowed}else a.webkitNotifications&&a.webkitNotifications.checkPermission&&(c=a.webkitNotifications.checkPermission());return c}),b.useDesktopNotifications=c.computed({read:function(){return b.desktopNotifications()&&R.DesktopNotifications.Allowed===b.desktopNotificationsPermisions()},write:function(a){if(a){var c=b.desktopNotificationsPermisions();R.DesktopNotifications.Allowed===c?b.desktopNotifications(!0):R.DesktopNotifications.NotAllowed===c?cb.requestPermission(function(){b.desktopNotifications.valueHasMutated(),R.DesktopNotifications.Allowed===b.desktopNotificationsPermisions()?b.desktopNotifications()?b.desktopNotifications.valueHasMutated():b.desktopNotifications(!0):b.desktopNotifications()?b.desktopNotifications(!1):b.desktopNotifications.valueHasMutated()}):b.desktopNotifications(!1)}else b.desktopNotifications(!1)}}),b.language=c.observable(""),b.languages=c.observableArray([]),b.mainLanguage=c.computed({read:b.language,write:function(a){a!==b.language()?-1<T.inArray(a,b.languages())?b.language(a):0<b.languages().length&&b.language(b.languages()[0]):b.language.valueHasMutated()}}),b.theme=c.observable(""),b.themes=c.observableArray([]),b.mainTheme=c.computed({read:b.theme,write:function(a){if(a!==b.theme()){var c=b.themes();-1<T.inArray(a,c)?b.theme(a):0<c.length&&b.theme(c[0])
}else b.theme.valueHasMutated()}}),b.allowCustomTheme=c.observable(!1),b.allowAdditionalAccounts=c.observable(!1),b.allowIdentities=c.observable(!1),b.determineUserLanguage=c.observable(!1),b.messagesPerPage=c.observable(Q.Defaults.MessagesPerPage),b.mainMessagesPerPage=b.messagesPerPage,b.mainMessagesPerPage=c.computed({read:b.messagesPerPage,write:function(a){-1<T.inArray(T.pInt(a),Q.Defaults.MessagesPerPageArray)?a!==b.messagesPerPage()&&b.messagesPerPage(a):b.messagesPerPage.valueHasMutated()}}),b.facebookEnable=c.observable(!1),b.facebookAppID=c.observable(""),b.facebookAppSecret=c.observable(""),b.twitterEnable=c.observable(!1),b.twitterConsumerKey=c.observable(""),b.twitterConsumerSecret=c.observable(""),b.googleEnable=c.observable(!1),b.googleClientID=c.observable(""),b.googleClientSecret=c.observable(""),b.dropboxEnable=c.observable(!1),b.dropboxApiKey=c.observable(""),b.contactsIsAllowed=c.observable(!1)},T.createMomentDate=function(a){return c.computed(function(){return W.minuteTick(),this.moment().fromNow()},a)},T.createMomentShortDate=function(a){return c.computed(function(){var a="",b=moment(),c=this.moment(),d=this.momentDate();return a=4>=b.diff(c,"hours")?d:b.format("L")===c.format("L")?T.i18n("MESSAGE_LIST/TODAY_AT",{TIME:c.format("LT")}):b.clone().subtract("days",1).format("L")===c.format("L")?T.i18n("MESSAGE_LIST/YESTERDAY_IN",{TIME:c.format("LT")}):b.year()===c.year()?c.format("D MMM."):c.format("LL")},a)},T.isFolderExpanded=function(a){var b=db.local().get(R.ClientSideKeyName.ExpandedFolders);return f.isArray(b)&&-1!==f.indexOf(b,a)},T.setExpandedFolder=function(a,b){var c=db.local().get(R.ClientSideKeyName.ExpandedFolders);f.isArray(c)||(c=[]),b?(c.push(a),c=f.uniq(c)):c=f.without(c,a),db.local().set(R.ClientSideKeyName.ExpandedFolders,c)},T.initLayoutResizer=function(a,c,d,e,g,h,i,j){e=e||300,g=g||500,h=h||g-e/2,i=i||300;var k=0,l=b(a),m=b(c),n=b(d),o=db.local().get(j)||h,p=function(a,b,c){if(b||c){var d=n.width(),e=b?b.size.width/d*100:null;null===e&&c&&(e=l.width()/d*100),null!==e&&(l.css({width:"",height:"",right:""+(100-e)+"%"}),m.css({width:"",height:"",left:""+e+"%"}))}},q=function(b,c){if(c&&c.element&&c.element[0].id&&"#"+c.element[0].id==""+a){var d=n.width();k=d-i,k=g>k?k:g,l.resizable("option","maxWidth",k),c.size&&c.size.width&&db.local().set(j,c.size.width),p(null,null,!0)}};o&&l.width(o),k=n.width()-i,k=g>k?k:g,l.resizable({minWidth:e,maxWidth:k,handles:"e",resize:p,stop:p}),p(null,null,!0),ab.resize(f.throttle(q,400))},T.initBlockquoteSwitcher=function(a){if(a){var c=b("blockquote:not(.rl-bq-switcher)",a).filter(function(){return 0===b(this).parent().closest("blockquote",a).length});c&&0<c.length&&c.each(function(){var a=b(this),c=a.height();(0===c||c>100)&&(a.addClass("rl-bq-switcher hidden-bq"),b('<span class="rlBlockquoteSwitcher"><i class="icon-ellipsis" /></span>').insertBefore(a).click(function(){a.toggleClass("hidden-bq"),T.windowResize()}).after("<br />").before("<br />"))})}},T.removeBlockquoteSwitcher=function(a){a&&(b(a).find("blockquote.rl-bq-switcher").each(function(){b(this).removeClass("rl-bq-switcher hidden-bq")}),b(a).find(".rlBlockquoteSwitcher").each(function(){b(this).remove()}))},T.extendAsViewModel=function(a,b,c){b&&(c||(c=l),b.__name=a,U.regViewModelHook(a,b),f.extend(b.prototype,c.prototype))},T.addSettingsViewModel=function(a,b,c,d,e){a.__rlSettingsData={Label:c,Template:b,Route:d,IsDefault:!!e},X.settings.push(a)},T.removeSettingsViewModel=function(a){X["settings-removed"].push(a)},T.disableSettingsViewModel=function(a){X["settings-disabled"].push(a)},T.convertThemeName=function(a){return T.trim(a.replace(/[^a-zA-Z]/g," ").replace(/([A-Z])/g," $1").replace(/[\s]+/g," "))},T.quoteName=function(a){return a.replace(/["]/g,'\\"')},T.microtime=function(){return(new Date).getTime()},T.convertLangName=function(a,b){return T.i18n("LANGS_NAMES"+(!0===b?"_EN":"")+"/LANG_"+a.toUpperCase().replace(/[^a-zA-Z0-9]+/,"_"),null,a)},T.fakeMd5=function(a){var b="",c="0123456789abcdefghijklmnopqrstuvwxyz";for(a=T.isUnd(a)?32:T.pInt(a);b.length<a;)b+=c.substr(Math.round(Math.random()*c.length),1);return b},T.convertPlainTextToHtml=function(a){return a.toString().replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;").replace(/\r/g,"").replace(/\n/g,"<br />")},T.draggeblePlace=function(){return b('<div class="draggablePlace"><span class="text"></span>&nbsp;<i class="icon-envelope icon-white"></i></div>').appendTo("#rl-hidden")},T.defautOptionsAfterRender=function(a,b){b&&!T.isUnd(b.disable)&&c.applyBindingsToNode(a,{disable:b.disable},b)},T.windowPopupKnockout=function(c,d,e,f){var g=null,h=a.open(""),i="__OpenerApplyBindingsUid"+T.fakeMd5()+"__",j=b("#"+d);a[i]=function(){if(h&&h.document.body&&j&&j[0]){var d=b(h.document.body);b("#rl-content",d).html(j.html()),b("html",h.document).addClass("external "+b("html").attr("class")),T.i18nToNode(d),n.prototype.applyExternal(c,b("#rl-content",d)[0]),a[i]=null,f(h)}},h.document.open(),h.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>'+T.encodeHtml(e)+'</title></head><body><div id="rl-content"></div></body></html>'),h.document.close(),g=h.document.createElement("script"),g.type="text/javascript",g.innerHTML="if(window&&window.opener&&window.opener['"+i+"']){window.opener['"+i+"']();window.opener['"+i+"']=null}",h.document.getElementsByTagName("head")[0].appendChild(g)},T.settingsSaveHelperFunction=function(a,b,c,d){return c=c||null,d=T.isUnd(d)?1e3:T.pInt(d),function(e,g,h,i,j){b.call(c,g&&g.Result?R.SaveSettingsStep.TrueResult:R.SaveSettingsStep.FalseResult),a&&a.call(c,e,g,h,i,j),f.delay(function(){b.call(c,R.SaveSettingsStep.Idle)},d)}},T.settingsSaveHelperSimpleFunction=function(a,b){return T.settingsSaveHelperFunction(null,a,b,1e3)},T.resizeAndCrop=function(b,c,d){var e=new a.Image;e.onload=function(){var a=[0,0],b=document.createElement("canvas"),e=b.getContext("2d");b.width=c,b.height=c,a=this.width>this.height?[this.width-this.height,0]:[0,this.height-this.width],e.fillStyle="#fff",e.fillRect(0,0,c,c),e.drawImage(this,a[0]/2,a[1]/2,this.width-a[0],this.height-a[1],0,0,c,c),d(b.toDataURL("image/jpeg"))},e.src=b},T.computedPagenatorHelper=function(a,b){return function(){var c=0,d=0,e=2,f=[],g=a(),h=b(),i=function(a,b,c){var d={current:a===g,name:T.isUnd(c)?a.toString():c.toString(),custom:T.isUnd(c)?!1:!0,title:T.isUnd(c)?"":a.toString(),value:a.toString()};(T.isUnd(b)?0:!b)?f.unshift(d):f.push(d)};if(h>1||h>0&&g>h){for(g>h?(i(h),c=h,d=h):((3>=g||g>=h-2)&&(e+=2),i(g),c=g,d=g);e>0;)if(c-=1,d+=1,c>0&&(i(c,!1),e--),h>=d)i(d,!0),e--;else if(0>=c)break;3===c?i(2,!1):c>3&&i(Math.round((c-1)/2),!1,"..."),h-2===d?i(h-1,!0):h-2>d&&i(Math.round((h+d)/2),!0,"..."),c>1&&i(1,!1),h>d&&i(h,!0)}return f}},V={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",urlsafe_encode:function(a){return V.encode(a).replace(/[+]/g,"-").replace(/[\/]/g,"_").replace(/[=]/g,".")},encode:function(a){var b,c,d,e,f,g,h,i="",j=0;for(a=V._utf8_encode(a);j<a.length;)b=a.charCodeAt(j++),c=a.charCodeAt(j++),d=a.charCodeAt(j++),e=b>>2,f=(3&b)<<4|c>>4,g=(15&c)<<2|d>>6,h=63&d,isNaN(c)?g=h=64:isNaN(d)&&(h=64),i=i+this._keyStr.charAt(e)+this._keyStr.charAt(f)+this._keyStr.charAt(g)+this._keyStr.charAt(h);return i},decode:function(a){var b,c,d,e,f,g,h,i="",j=0;for(a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");j<a.length;)e=this._keyStr.indexOf(a.charAt(j++)),f=this._keyStr.indexOf(a.charAt(j++)),g=this._keyStr.indexOf(a.charAt(j++)),h=this._keyStr.indexOf(a.charAt(j++)),b=e<<2|f>>4,c=(15&f)<<4|g>>2,d=(3&g)<<6|h,i+=String.fromCharCode(b),64!==g&&(i+=String.fromCharCode(c)),64!==h&&(i+=String.fromCharCode(d));return V._utf8_decode(i)},_utf8_encode:function(a){a=a.replace(/\r\n/g,"\n");for(var b="",c=0,d=a.length,e=0;d>c;c++)e=a.charCodeAt(c),128>e?b+=String.fromCharCode(e):e>127&&2048>e?(b+=String.fromCharCode(e>>6|192),b+=String.fromCharCode(63&e|128)):(b+=String.fromCharCode(e>>12|224),b+=String.fromCharCode(e>>6&63|128),b+=String.fromCharCode(63&e|128));return b},_utf8_decode:function(a){for(var b="",c=0,d=0,e=0,f=0;c<a.length;)d=a.charCodeAt(c),128>d?(b+=String.fromCharCode(d),c++):d>191&&224>d?(e=a.charCodeAt(c+1),b+=String.fromCharCode((31&d)<<6|63&e),c+=2):(e=a.charCodeAt(c+1),f=a.charCodeAt(c+2),b+=String.fromCharCode((15&d)<<12|(63&e)<<6|63&f),c+=3);return b}},c.bindingHandlers.tooltip={init:function(a,d){if(!W.bMobileDevice){var e=b(a).data("tooltip-class")||"",f=b(a).data("tooltip-placement")||"top";b(a).tooltip({delay:{show:500,hide:100},html:!0,placement:f,trigger:"hover",title:function(){return'<span class="tooltip-class '+e+'">'+T.i18n(c.utils.unwrapObservable(d()))+"</span>"}})}}},c.bindingHandlers.tooltip2={init:function(a,c){var d=b(a).data("tooltip-class")||"",e=b(a).data("tooltip-placement")||"top";b(a).tooltip({delay:{show:500,hide:100},html:!0,placement:e,title:function(){return'<span class="tooltip-class '+d+'">'+c()()+"</span>"}})}},c.bindingHandlers.dropdown={init:function(a){b(a).closest(".dropdown").on("click",".e-item",function(){b(a).dropdown("toggle")})}},c.bindingHandlers.popover={init:function(a,d){b(a).popover(c.utils.unwrapObservable(d()))}},c.bindingHandlers.resizecrop={init:function(a){b(a).addClass("resizecrop").resizecrop({width:"100",height:"100",wrapperCSS:{"border-radius":"10px"}})},update:function(a,c){c()(),b(a).resizecrop({width:"100",height:"100"})}},c.bindingHandlers.onEnter={init:function(c,d,e,f){b(c).on("keypress",function(e){e&&13===a.parseInt(e.keyCode,10)&&(b(c).trigger("change"),d().call(f))})}},c.bindingHandlers.onEsc={init:function(c,d,e,f){b(c).on("keypress",function(e){e&&27===a.parseInt(e.keyCode,10)&&(b(c).trigger("change"),d().call(f))})}},c.bindingHandlers.modal={init:function(a,d){b(a).modal({keyboard:!1,show:c.utils.unwrapObservable(d())}).on("hidden",function(){d()(!1)})},update:function(a,d){var e=c.utils.unwrapObservable(d());b(a).modal(e?"show":"hide"),f.delay(function(){b(a).toggleClass("popup-active",e)},1)}},c.bindingHandlers.i18nInit={init:function(a){T.i18nToNode(a)}},c.bindingHandlers.i18nUpdate={update:function(a,b){c.utils.unwrapObservable(b()),T.i18nToNode(a)}},c.bindingHandlers.link={update:function(a,d){b(a).attr("href",c.utils.unwrapObservable(d()))}},c.bindingHandlers.title={update:function(a,d){b(a).attr("title",c.utils.unwrapObservable(d()))}},c.bindingHandlers.textF={init:function(a,d){b(a).text(c.utils.unwrapObservable(d()))}},c.bindingHandlers.initDom={init:function(a,b){b()(a)}},c.bindingHandlers.initResizeTrigger={init:function(a,d){var e=c.utils.unwrapObservable(d());b(a).css({height:e[1],"min-height":e[1]})},update:function(a,d){var e=c.utils.unwrapObservable(d()),f=T.pInt(e[1]),g=0,h=b(a).offset().top;h>0&&(h+=T.pInt(e[2]),g=ab.height()-h,g>f&&(f=g),b(a).css({height:f,"min-height":f}))}},c.bindingHandlers.appendDom={update:function(a,d){b(a).hide().empty().append(c.utils.unwrapObservable(d())).show()}},c.bindingHandlers.draggable={init:function(d,e,f){if(!W.bMobileDevice){var g=100,h=3,i=f(),j=i&&i.droppableSelector?i.droppableSelector:"",k={distance:20,handle:".dragHandle",cursorAt:{top:22,left:3},refreshPositions:!0,scroll:!0};j&&(k.drag=function(c){b(j).each(function(){var d=null,e=null,f=b(this),i=f.offset(),j=i.top+f.height();a.clearInterval(f.data("timerScroll")),f.data("timerScroll",!1),c.pageX>=i.left&&c.pageX<=i.left+f.width()&&(c.pageY>=j-g&&c.pageY<=j&&(d=function(){f.scrollTop(f.scrollTop()+h),T.windowResize()},f.data("timerScroll",a.setInterval(d,10)),d()),c.pageY>=i.top&&c.pageY<=i.top+g&&(e=function(){f.scrollTop(f.scrollTop()-h),T.windowResize()},f.data("timerScroll",a.setInterval(e,10)),e()))})},k.stop=function(){b(j).each(function(){a.clearInterval(b(this).data("timerScroll")),b(this).data("timerScroll",!1)})}),k.helper=function(a){return e()(a&&a.target?c.dataFor(a.target):null,!!a.shiftKey)},b(d).draggable(k).on("mousedown",function(){T.removeInFocus()})}}},c.bindingHandlers.droppable={init:function(a,c,d){if(!W.bMobileDevice){var e=c(),f=d(),g=f&&f.droppableOver?f.droppableOver:null,h=f&&f.droppableOut?f.droppableOut:null,i={tolerance:"pointer",hoverClass:"droppableHover"};e&&(i.drop=function(a,b){e(a,b)},g&&(i.over=function(a,b){g(a,b)}),h&&(i.out=function(a,b){h(a,b)}),b(a).droppable(i))}}},c.bindingHandlers.nano={init:function(a){W.bDisableNanoScroll||b(a).addClass("nano").nanoScroller({iOSNativeScrolling:!1,preventPageScrolling:!0})}},c.bindingHandlers.saveTrigger1={init:function(a){var c=b(a);c.data("save-trigger-type",c.is("input[type=text]")?"input":"custom"),"custom"===c.data("save-trigger-type")?c.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"):c.addClass("settings-saved-trigger-input")},update:function(a,d){var e=c.utils.unwrapObservable(d()),f=b(a),g="custom"===f.data("save-trigger-type"),h=g?"":"-input";switch(e.toString()){case"1":f.find(".sst-animated"+h+",.sst-error"+h).hide().removeClass("sst-visible"+h).end().find(".sst-success"+h).show().addClass("sst-visible"+h);break;case"0":f.find(".sst-animated"+h+",.sst-success"+h).hide().removeClass("sst-visible"+h).end().find(".sst-error"+h).show().addClass("sst-visible"+h);break;case"-2":f.find(".sst-error"+h+",.sst-success"+h).hide().removeClass("sst-visible"+h).end().find(".sst-animated"+h).show().addClass("sst-visible"+h);break;default:f.find(".sst-animated"+h).hide().end().find(".sst-error"+h+",.sst-success"+h).removeClass("sst-visible"+h)}}},c.bindingHandlers.saveTrigger={init:function(a){var c=b(a);c.data("save-trigger-type",c.is("input[type=text],select,textarea")?"input":"custom"),"custom"===c.data("save-trigger-type")?c.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"):c.addClass("settings-saved-trigger-input")},update:function(a,d){var e=c.utils.unwrapObservable(d()),f=b(a);if("custom"===f.data("save-trigger-type"))switch(e.toString()){case"1":f.find(".animated,.error").hide().removeClass("visible").end().find(".success").show().addClass("visible");break;case"0":f.find(".animated,.success").hide().removeClass("visible").end().find(".error").show().addClass("visible");break;case"-2":f.find(".error,.success").hide().removeClass("visible").end().find(".animated").show().addClass("visible");break;default:f.find(".animated").hide().end().find(".error,.success").removeClass("visible")}else switch(e.toString()){case"1":f.addClass("success").removeClass("error");break;case"0":f.addClass("error").removeClass("success");break;case"-2":break;default:f.removeClass("error success")}}},c.bindingHandlers.emailsTags={init:function(a,c){var d=b(a),e=c();d.inputosaurus({parseOnBlur:!0,inputDelimiters:[",",";"],autoCompleteSource:function(a,b){db.getAutocomplete(a.term,function(a){b(f.map(a,function(a){return a.toLine(!1)}))})},parseHook:function(a){return f.map(a,function(a){var b=T.trim(a),c=null;return""!==b?(c=new o,c.mailsoParse(b),c.clearDuplicateName(),[c.toLine(!1),c]):[b,null]})},change:f.bind(function(a){d.data("EmailsTagsValue",a.target.value),e(a.target.value)},this)}),e.subscribe(function(a){d.data("EmailsTagsValue")!==a&&(d.val(a),d.inputosaurus("refresh"))})}},c.bindingHandlers.command={init:function(a,d,e,f){var g=b(a),h=d();if(!h||!h.enabled||!h.canExecute)throw new Error("You are not using command function");g.addClass("command"),c.bindingHandlers[g.is("form")?"submit":"click"].init.apply(f,arguments)},update:function(a,c){var d=!0,e=b(a),f=c();d=f.enabled(),e.toggleClass("command-not-enabled",!d),d&&(d=f.canExecute(),e.toggleClass("command-can-not-be-execute",!d)),e.toggleClass("command-disabled disable disabled",!d),(e.is("input")||e.is("button"))&&e.prop("disabled",!d)}},c.extenders.trimmer=function(a){var b=c.computed({read:a,write:function(b){a(T.trim(b.toString()))},owner:this});return b(a()),b},c.extenders.reversible=function(a){var b=a();return a.commit=function(){b=a()},a.reverse=function(){a(b)},a.commitedValue=function(){return b},a},c.extenders.toggleSubscribe=function(a,b){return a.subscribe(b[1],b[0],"beforeChange"),a.subscribe(b[2],b[0]),a},c.extenders.falseTimeout=function(b,c){return b.iTimeout=0,b.subscribe(function(d){d&&(a.clearTimeout(b.iTimeout),b.iTimeout=a.setTimeout(function(){b(!1),b.iTimeout=0},T.pInt(c)))}),b},c.observable.fn.validateNone=function(){return this.hasError=c.observable(!1),this},c.observable.fn.validateEmail=function(){return this.hasError=c.observable(!1),this.subscribe(function(a){a=T.trim(a),this.hasError(""!==a&&!/^[^@\s]+@[^@\s]+$/.test(a))},this),this.valueHasMutated(),this},c.observable.fn.validateSimpleEmail=function(){return this.hasError=c.observable(!1),this.subscribe(function(a){a=T.trim(a),this.hasError(""!==a&&!/^.+@.+$/.test(a))},this),this.valueHasMutated(),this},c.observable.fn.validateFunc=function(a){return this.hasFuncError=c.observable(!1),T.isFunc(a)&&(this.subscribe(function(b){this.hasFuncError(!a(b))},this),this.valueHasMutated()),this},g.prototype.root=function(){return this.sBase},g.prototype.attachmentDownload=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/Download/"+a},g.prototype.attachmentPreview=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/View/"+a},g.prototype.attachmentPreviewAsPlain=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ViewAsPlain/"+a},g.prototype.upload=function(){return this.sServer+"/Upload/"+this.sSpecSuffix+"/"},g.prototype.uploadBackground=function(){return this.sServer+"/UploadBackground/"+this.sSpecSuffix+"/"},g.prototype.append=function(){return this.sServer+"/Append/"+this.sSpecSuffix+"/"},g.prototype.change=function(b){return this.sServer+"/Change/"+this.sSpecSuffix+"/"+a.encodeURIComponent(b)+"/"},g.prototype.ajax=function(a){return this.sServer+"/Ajax/"+this.sSpecSuffix+"/"+a},g.prototype.messageViewLink=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ViewAsPlain/"+a},g.prototype.messageDownloadLink=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/Download/"+a},g.prototype.inbox=function(){return this.sBase+"mailbox/Inbox"},g.prototype.settings=function(a){var b=this.sBase+"settings";return T.isUnd(a)||""===a||(b+="/"+a),b},g.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},g.prototype.mailBox=function(a,b,c){b=T.isNormal(b)?T.pInt(b):1,c=T.pString(c);var d=this.sBase+"mailbox/";return""!==a&&(d+=encodeURI(a)),b>1&&(d=d.replace(/[\/]+$/,""),d+="/p"+b),""!==c&&(d=d.replace(/[\/]+$/,""),d+="/"+encodeURI(c)),d},g.prototype.phpInfo=function(){return this.sServer+"Info"},g.prototype.langLink=function(a){return this.sServer+"/Lang/0/"+encodeURI(a)+"/"+this.sVersion+"/"},g.prototype.getUserPicUrlFromHash=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/UserPic/"+a+"/"+this.sVersion+"/"},g.prototype.emptyContactPic=function(){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/static/css/images/empty-contact.png"},g.prototype.sound=function(a){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/static/sounds/"+a},g.prototype.themePreviewLink=function(a){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/themes/"+encodeURI(a)+"/images/preview.png"},g.prototype.notificationMailIcon=function(){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/static/css/images/icom-message-notification.png"},g.prototype.socialGoogle=function(){return this.sServer+"SocialGoogle"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")},g.prototype.socialTwitter=function(){return this.sServer+"SocialTwitter"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")},g.prototype.socialFacebook=function(){return this.sServer+"SocialFacebook"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")},U.oViewModelsHooks={},U.oSimpleHooks={},U.regViewModelHook=function(a,b){b&&(b.__hookName=a)},U.addHook=function(a,b){T.isFunc(b)&&(T.isArray(U.oSimpleHooks[a])||(U.oSimpleHooks[a]=[]),U.oSimpleHooks[a].push(b))},U.runHook=function(a,b){T.isArray(U.oSimpleHooks[a])&&(b=b||[],f.each(U.oSimpleHooks[a],function(a){a.apply(null,b)}))},U.mainSettingsGet=function(a){return db?db.settingsGet(a):null},U.remoteRequest=function(a,b,c,d,e,f){db&&db.remote().defaultRequest(a,b,c,d,e,f)},U.settingsGet=function(a,b){var c=U.mainSettingsGet("Plugins");return c=c&&T.isUnd(c[a])?null:c[a],c?T.isUnd(c[b])?null:c[b]:null},h.supported=function(){return!0},h.prototype.set=function(a,c){var d=b.cookie(Q.Values.ClientSideCookieIndexName),e=!1,f=null;try{f=null===d?null:JSON.parse(d),f||(f={}),f[a]=c,b.cookie(Q.Values.ClientSideCookieIndexName,JSON.stringify(f),{expires:30}),e=!0}catch(g){}return e},h.prototype.get=function(a){var c=b.cookie(Q.Values.ClientSideCookieIndexName),d=null;try{d=null===c?null:JSON.parse(c),d=d&&!T.isUnd(d[a])?d[a]:null}catch(e){}return d},i.supported=function(){return!!a.localStorage},i.prototype.set=function(b,c){var d=a.localStorage[Q.Values.ClientSideCookieIndexName]||null,e=!1,f=null;try{f=null===d?null:JSON.parse(d),f||(f={}),f[b]=c,a.localStorage[Q.Values.ClientSideCookieIndexName]=JSON.stringify(f),e=!0}catch(g){}return e},i.prototype.get=function(b){var c=a.localStorage[Q.Values.ClientSideCookieIndexName]||null,d=null;try{d=null===c?null:JSON.parse(c),d=d&&!T.isUnd(d[b])?d[b]:null}catch(e){}return d},j.prototype.oDriver=null,j.prototype.set=function(a,b){return this.oDriver?this.oDriver.set("p"+a,b):!1},j.prototype.get=function(a){return this.oDriver?this.oDriver.get("p"+a):null},k.prototype.bootstart=function(){},l.prototype.sPosition="",l.prototype.sTemplate="",l.prototype.viewModelName="",l.prototype.viewModelDom=null,l.prototype.viewModelTemplate=function(){return this.sTemplate},l.prototype.viewModelPosition=function(){return this.sPosition},l.prototype.cancelCommand=l.prototype.closeCommand=function(){},m.prototype.oCross=null,m.prototype.sScreenName="",m.prototype.aViewModels=[],m.prototype.viewModels=function(){return this.aViewModels},m.prototype.screenName=function(){return this.sScreenName},m.prototype.routes=function(){return null},m.prototype.__cross=function(){return this.oCross},m.prototype.__start=function(){var a=this.routes(),b=null,c=null;T.isNonEmptyArray(a)&&(c=f.bind(this.onRoute||T.emptyFunction,this),b=d.create(),f.each(a,function(a){b.addRoute(a[0],c).rules=a[1]}),this.oCross=b)},n.constructorEnd=function(a){T.isFunc(a.__constructor_end)&&a.__constructor_end.call(a)},n.prototype.sDefaultScreenName="",n.prototype.oScreens={},n.prototype.oBoot=null,n.prototype.oCurrentScreen=null,n.prototype.showLoading=function(){b("#rl-loading").show()},n.prototype.hideLoading=function(){b("#rl-loading").hide()},n.prototype.routeOff=function(){e.changed.active=!1},n.prototype.routeOn=function(){e.changed.active=!0},n.prototype.setBoot=function(a){return T.isNormal(a)&&(this.oBoot=a),this},n.prototype.screen=function(a){return""===a||T.isUnd(this.oScreens[a])?null:this.oScreens[a]},n.prototype.delegateRun=function(a,b,c){a&&a[b]&&a[b].apply(a,T.isArray(c)?c:[])},n.prototype.buildViewModel=function(a,d){if(a&&!a.__builded){var e=new a(d),f=e.viewModelPosition(),g=b("#rl-content #rl-"+f.toLowerCase()),h=null;a.__builded=!0,a.__vm=e,e.data=db.data(),e.viewModelName=a.__name,g&&1===g.length?(h=b("<div>").addClass("rl-view-model").addClass("RL-"+e.viewModelTemplate()).hide().attr("data-bind",'template: {name: "'+e.viewModelTemplate()+'"}, i18nInit: true'),h.appendTo(g),e.viewModelDom=h,a.__dom=h,"Popups"===f&&(e.cancelCommand=e.closeCommand=T.createCommand(e,function(){Y.hideScreenPopup(a)})),U.runHook("view-model-pre-build",[a.__name,e,h]),c.applyBindings(e,h[0]),this.delegateRun(e,"onBuild",[h]),U.runHook("view-model-post-build",[a.__name,e,h])):T.log("Cannot find view model position: "+f)}return a?a.__vm:null},n.prototype.applyExternal=function(a,b){a&&b&&c.applyBindings(a,b)},n.prototype.hideScreenPopup=function(a){a&&a.__vm&&a.__dom&&(a.__dom.hide(),a.__vm.modalVisibility(!1),this.delegateRun(a.__vm,"onHide"),this.popupVisibility(!1))},n.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),U.runHook("view-model-on-show",[a.__name,a.__vm,b||[]])))},n.prototype.screenOnRoute=function(a,b){var c=this,d=null,e=null;""===T.pString(a)&&(a=this.sDefaultScreenName),""!==a&&(d=this.screen(a),d||(d=this.screen(this.sDefaultScreenName),d&&(b=a+"/"+b,a=this.sDefaultScreenName)),d&&d.__started&&(d.__builded||(d.__builded=!0,T.isNonEmptyArray(d.viewModels())&&f.each(d.viewModels(),function(a){this.buildViewModel(a,d)},this),this.delegateRun(d,"onBuild")),f.defer(function(){c.oCurrentScreen&&(c.delegateRun(c.oCurrentScreen,"onHide"),T.isNonEmptyArray(c.oCurrentScreen.viewModels())&&f.each(c.oCurrentScreen.viewModels(),function(a){a.__vm&&a.__dom&&"Popups"!==a.__vm.viewModelPosition()&&(a.__dom.hide(),a.__vm.viewModelVisibility(!1),c.delegateRun(a.__vm,"onHide"))})),c.oCurrentScreen=d,c.oCurrentScreen&&(c.delegateRun(c.oCurrentScreen,"onShow"),U.runHook("screen-on-show",[c.oCurrentScreen.screenName(),c.oCurrentScreen]),T.isNonEmptyArray(c.oCurrentScreen.viewModels())&&f.each(c.oCurrentScreen.viewModels(),function(a){a.__vm&&a.__dom&&"Popups"!==a.__vm.viewModelPosition()&&(a.__dom.show(),a.__vm.viewModelVisibility(!0),c.delegateRun(a.__vm,"onShow"),U.runHook("view-model-on-show",[a.__name,a.__vm]))},c)),e=d.__cross(),e&&e.parse(b)})))},n.prototype.startScreens=function(a){f.each(a,function(a){var b=new a,c=b?b.screenName():"";b&&""!==c&&(""===this.sDefaultScreenName&&(this.sDefaultScreenName=c),this.oScreens[c]=b)},this),f.each(this.oScreens,function(a){a&&!a.__started&&a.__start&&(a.__started=!0,a.__start(),U.runHook("screen-pre-start",[a.screenName(),a]),this.delegateRun(a,"onStart"),U.runHook("screen-post-start",[a.screenName(),a]))},this);var b=d.create();b.addRoute(/^([a-zA-Z0-9\-]*)\/?(.*)$/,f.bind(this.screenOnRoute,this)),e.initialized.add(b.parse,b),e.changed.add(b.parse,b),e.init()},n.prototype.setHash=function(a,b,c){a="#"===a.substr(0,1)?a.substr(1):a,a="/"===a.substr(0,1)?a.substr(1):a,c=T.isUnd(c)?!1:!!c,(T.isUnd(b)?1:!b)?(e.changed.active=!0,e[c?"replaceHash":"setHash"](a),e.setHash(a)):(e.changed.active=!1,e[c?"replaceHash":"setHash"](a),e.changed.active=!0)},n.prototype.bootstart=function(){return this.oBoot&&this.oBoot.bootstart&&this.oBoot.bootstart(),this},Y=new n,o.newInstanceFromJson=function(a){var b=new o;return b.initByJson(a)?b:null},o.prototype.name="",o.prototype.email="",o.prototype.privateType=null,o.prototype.clear=function(){this.email="",this.name="",this.privateType=null},o.prototype.validate=function(){return""!==this.name||""!==this.email},o.prototype.hash=function(a){return"#"+(a?"":this.name)+"#"+this.email+"#"},o.prototype.clearDuplicateName=function(){this.name===this.email&&(this.name="")},o.prototype.type=function(){return null===this.privateType&&(this.email&&"@facebook.com"===this.email.substr(-13)&&(this.privateType=R.EmailType.Facebook),null===this.privateType&&(this.privateType=R.EmailType.Default)),this.privateType},o.prototype.search=function(a){return-1<(this.name+" "+this.email).toLowerCase().indexOf(a.toLowerCase())},o.prototype.parse=function(a){this.clear(),a=T.trim(a);var b=/(?:"([^"]+)")? ?<?(.*?@[^>,]+)>?,? ?/g,c=b.exec(a);c?(this.name=c[1]||"",this.email=c[2]||"",this.clearDuplicateName()):/^[^@]+@[^@]+$/.test(a)&&(this.name="",this.email=a)},o.prototype.initByJson=function(a){var b=!1;return a&&"Object/Email"===a["@Object"]&&(this.name=T.trim(a.Name),this.email=T.trim(a.Email),b=""!==this.email,this.clearDuplicateName()),b},o.prototype.toLine=function(a,b,c){var d="";return""!==this.email&&(b=T.isUnd(b)?!1:!!b,c=T.isUnd(c)?!1:!!c,a&&""!==this.name?d=b?'<a href="mailto:'+T.encodeHtml('"'+this.name+'" <'+this.email+">")+'" target="_blank" tabindex="-1">'+T.encodeHtml(this.name)+"</a>":c?T.encodeHtml(this.name):this.name:(d=this.email,""!==this.name?b?d=T.encodeHtml('"'+this.name+'" <')+'<a href="mailto:'+T.encodeHtml('"'+this.name+'" <'+this.email+">")+'" target="_blank" tabindex="-1">'+T.encodeHtml(d)+"</a>"+T.encodeHtml(">"):(d='"'+this.name+'" <'+d+">",c&&(d=T.encodeHtml(d))):b&&(d='<a href="mailto:'+T.encodeHtml(this.email)+'" target="_blank" tabindex="-1">'+T.encodeHtml(this.email)+"</a>"))),d},o.prototype.select2Result=function(){var a="",b=db.cache().getUserPic(this.email);return a+=""!==b?'<img class="select2-user-pic pull-left" src="'+T.encodeHtml(b)+'" />':'<img class="select2-user-pic pull-left" src="'+db.link().emptyContactPic()+'" />',R.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),a+""},o.prototype.select2Selection=function(a){var c="";if(R.EmailType.Facebook===this.type()){if(c=0<this.name.length?this.name:this.email,""!==c)return b("<pan>").text(c).appendTo(a),a.append('<i class="icon-facebook select2-icon"></i>'),null}else c=0<this.name.length?this.name+" ("+this.email+")":this.email;return c},o.prototype.mailsoParse=function(a){if(a=T.trim(a),""===a)return!1;for(var b=function(a,b,c){a+="";var d=a.length;return 0>b&&(b+=d),d="undefined"==typeof c?d:0>c?c+d:c+b,b>=a.length||0>b||b>d?!1:a.slice(b,d)},c=function(a,b,c,d){return 0>c&&(c+=a.length),d=void 0!==d?d:a.length,0>d&&(d=d+a.length-c),a.slice(0,c)+b.substr(0,d)+b.slice(d)+a.slice(c+d)},d="",e="",f="",g=!1,h=!1,i=!1,j=null,k=0,l=0,m=0;m<a.length;){switch(a.substr(m,1)){case'"':g||h||i?h||i||(l=m,d=b(a,k+1,l-k-1),a=c(a,"",k,l-k+1),l=0,m=0,k=0,g=!1):(g=!0,k=m);break;case"<":g||h||i||(m>0&&0===d.length&&(d=b(a,0,m)),h=!0,k=m);break;case">":h&&(l=m,e=b(a,k+1,l-k-1),a=c(a,"",k,l-k+1),l=0,m=0,k=0,h=!1);break;case"(":g||h||i||(i=!0,k=m);break;case")":i&&(l=m,f=b(a,k+1,l-k-1),a=c(a,"",k,l-k+1),l=0,m=0,k=0,i=!1);break;case"\\":m++}m++}return 0===e.length&&(j=a.match(/[^@\s]+@\S+/i),j&&j[0]?e=j[0]:d=a),e.length>0&&0===d.length&&0===f.length&&(d=a.replace(e,"")),e=T.trim(e).replace(/^[<]+/,"").replace(/[>]+$/,""),d=T.trim(d).replace(/^["']+/,"").replace(/["']+$/,""),f=T.trim(f).replace(/^[(]+/,"").replace(/[)]+$/,""),d=d.replace(/\\\\(.)/,"$1"),f=f.replace(/\\\\(.)/,"$1"),this.name=d,this.email=e,this.clearDuplicateName(),!0},o.prototype.inputoTagLine=function(){return 0<this.name.length?this.name+" ("+this.email+")":this.email},T.extendAsViewModel("PopupsDomainViewModel",p),p.prototype.onTestConnectionResponse=function(a,b){this.testing(!1),R.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))},p.prototype.onDomainCreateOrSaveResponse=function(a,b){this.saving(!1),R.StorageResultType.Success===a&&b?b.Result?(db.reloadDomainList(),this.closeCommand()):R.Notification.DomainAlreadyExists===b.ErrorCode&&this.savingError("Domain already exists"):this.savingError("Unknown error")},p.prototype.onHide=function(){this.whiteListPage(!1)},p.prototype.onShow=function(a){this.saving(!1),this.whiteListPage(!1),this.testing(!1),this.testingDone(!1),this.testingImapError(!1),this.testingSmtpError(!1),this.clearForm(),a&&(this.edit(!0),this.name(T.trim(a.Name)),this.imapServer(T.trim(a.IncHost)),this.imapPort(T.pInt(a.IncPort)),this.imapSecure(T.trim(a.IncSecure)),this.imapShortLogin(!!a.IncShortLogin),this.smtpServer(T.trim(a.OutHost)),this.smtpPort(T.pInt(a.OutPort)),this.smtpSecure(T.trim(a.OutSecure)),this.smtpShortLogin(!!a.OutShortLogin),this.smtpAuth(!!a.OutAuth),this.whiteList(T.trim(a.WhiteList)))
},p.prototype.clearForm=function(){this.edit(!1),this.whiteListPage(!1),this.savingError(""),this.name(""),this.imapServer(""),this.imapPort(Q.Values.ImapDefaulPort),this.imapSecure(R.ServerSecure.None),this.imapShortLogin(!1),this.smtpServer(""),this.smtpPort(Q.Values.SmtpDefaulPort),this.smtpSecure(R.ServerSecure.None),this.smtpShortLogin(!1),this.smtpAuth(!0),this.whiteList("")},T.extendAsViewModel("PopupsPluginViewModel",q),q.prototype.onPluginSettingsUpdateResponse=function(a,b){R.StorageResultType.Success===a&&b&&b.Result?this.cancelCommand():(this.saveError(""),b&&b.ErrorCode?this.saveError(T.getNotification(b.ErrorCode)):this.saveError(T.getNotification(R.Notification.CantSavePluginSettings)))},q.prototype.onShow=function(a){if(this.name(),this.readme(),this.configures([]),a){this.name(a.Name),this.readme(a.Readme);var b=a.Config;T.isNonEmptyArray(b)&&this.configures(f.map(b,function(a){return{value:c.observable(a[0]),Name:a[1],Type:a[2],Label:a[3],Default:a[4],Desc:a[5]}}))}},T.extendAsViewModel("PopupsActivateViewModel",r),r.prototype.onShow=function(){this.domain(db.settingsGet("AdminDomain")),this.activateProcess()||(this.key(""),this.activateText(""),this.activateText.isError(!1),this.activationSuccessed(!1),this.key.focus(!0))},r.prototype.validateSubscriptionKey=function(){var a=this.key();return""===a||!!/^RL[\d]+-[A-Z0-9\-]+Z$/.test(T.trim(a))},T.extendAsViewModel("PopupsLanguagesViewModel",s),s.prototype.languageEnName=function(a){return T.convertLangName(a,!0)},s.prototype.resetMainLanguage=function(){var a=db.data().mainLanguage();f.each(this.languages(),function(b){b.selected(b.key===a)})},s.prototype.onShow=function(){this.exp(!0),this.resetMainLanguage()},s.prototype.onHide=function(){this.exp(!1)},s.prototype.changeLanguage=function(a){db.data().mainLanguage(a),this.cancelCommand()},T.extendAsViewModel("AdminLoginViewModel",t),t.prototype.onShow=function(){Y.routeOff(),f.delay(f.bind(function(){this.loginFocus(!0)},this),100)},t.prototype.onHide=function(){this.loginFocus(!1)},T.extendAsViewModel("AdminMenuViewModel",u),u.prototype.link=function(a){return"#/"+a},T.extendAsViewModel("AdminPaneViewModel",v),v.prototype.logoutClick=function(){db.remote().adminLogout(function(){db.loginAndLogoutReload()})},T.addSettingsViewModel(w,"AdminSettingsGeneral","General","general",!0),w.prototype.onBuild=function(){var a=this;f.delay(function(){var b=T.settingsSaveHelperSimpleFunction(a.titleTrigger,a),c=T.settingsSaveHelperSimpleFunction(a.languageTrigger,a),d=T.settingsSaveHelperSimpleFunction(a.themeTrigger,a),e=T.settingsSaveHelperSimpleFunction(a.loadingDescTrigger,a);a.title.subscribe(function(a){db.remote().saveAdminConfig(b,{Title:T.trim(a)})}),a.loadingDesc.subscribe(function(a){db.remote().saveAdminConfig(e,{LoadingDescription:T.trim(a)})}),a.language.subscribe(function(a){db.remote().saveAdminConfig(c,{Language:T.trim(a)})}),a.theme.subscribe(function(a){db.remote().saveAdminConfig(d,{Theme:T.trim(a)})}),a.allowCustomTheme.subscribe(function(a){db.remote().saveAdminConfig(null,{AllowCustomTheme:a?"1":"0"})}),a.allowAdditionalAccounts.subscribe(function(a){db.remote().saveAdminConfig(null,{AllowAdditionalAccounts:a?"1":"0"})}),a.allowIdentities.subscribe(function(a){db.remote().saveAdminConfig(null,{AllowIdentities:a?"1":"0"})}),a.allowThemes.subscribe(function(a){db.remote().saveAdminConfig(null,{AllowThemes:a?"1":"0"})}),a.allowLanguagesOnSettings.subscribe(function(a){db.remote().saveAdminConfig(null,{AllowLanguagesOnSettings:a?"1":"0"})})},50)},w.prototype.selectLanguage=function(){Y.showScreenPopup(s)},T.addSettingsViewModel(x,"AdminSettingsLogin","Login","login"),x.prototype.onBuild=function(){var a=this;f.delay(function(){var b=T.settingsSaveHelperSimpleFunction(a.defaultDomainTrigger,a);a.determineUserLanguage.subscribe(function(a){db.remote().saveAdminConfig(null,{DetermineUserLanguage:a?"1":"0"})}),a.allowCustomLogin.subscribe(function(a){db.remote().saveAdminConfig(null,{AllowCustomLogin:a?"1":"0"})}),a.allowLanguagesOnLogin.subscribe(function(a){db.remote().saveAdminConfig(null,{AllowLanguagesOnLogin:a?"1":"0"})}),a.defaultDomain.subscribe(function(a){db.remote().saveAdminConfig(b,{LoginDefaultDomain:T.trim(a)})})},50)},T.addSettingsViewModel(y,"AdminSettingsContacts","Contacts","contacts"),y.prototype.onTestContactsResponse=function(a,b){this.testContactsSuccess(!1),this.testContactsError(!1),this.testContactsErrorMessage(""),R.StorageResultType.Success===a&&b&&b.Result&&b.Result.Result?this.testContactsSuccess(!0):(this.testContactsError(!0),this.testContactsErrorMessage(b.Result.Message||"")),this.testing(!1)},y.prototype.onShow=function(){this.testContactsSuccess(!1),this.testContactsError(!1),this.testContactsErrorMessage("")},y.prototype.onBuild=function(){var a=this;f.delay(function(){var b=T.settingsSaveHelperSimpleFunction(a.pdoDsnTrigger,a),c=T.settingsSaveHelperSimpleFunction(a.pdoUserTrigger,a),d=T.settingsSaveHelperSimpleFunction(a.pdoPasswordTrigger,a);a.enableContacts.subscribe(function(a){db.remote().saveAdminConfig(null,{ContactsEnable:a?"1":"0"})}),a.pdoDsn.subscribe(function(a){db.remote().saveAdminConfig(b,{ContactsPdoDsn:T.trim(a)})}),a.pdoUser.subscribe(function(a){db.remote().saveAdminConfig(c,{ContactsPdoUser:T.trim(a)})}),a.pdoPassword.subscribe(function(a){db.remote().saveAdminConfig(d,{ContactsPdoPassword:T.trim(a)})})},50)},T.addSettingsViewModel(z,"AdminSettingsDomains","Domains","domains"),z.prototype.startDomainForDeletionTimeout=function(){var b=this;a.clearInterval(this.iDomainForDeletionTimeout),this.iDomainForDeletionTimeout=a.setTimeout(function(){b.domainForDeletion(null)},3e3)},z.prototype.createDomain=function(){Y.showScreenPopup(p)},z.prototype.deleteDomain=function(a){this.domains.remove(a),db.remote().domainDelete(f.bind(this.onDomainListChangeRequest,this),a.name)},z.prototype.disableDomain=function(a){a.disabled(!a.disabled()),db.remote().domainDisable(f.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=c.dataFor(this);a&&db.remote().domain(f.bind(b.onDomainLoadRequest,b),a.name)}),db.reloadDomainList()},z.prototype.onDomainLoadRequest=function(a,b){R.StorageResultType.Success===a&&b&&b.Result&&Y.showScreenPopup(p,[b.Result])},z.prototype.onDomainListChangeRequest=function(){db.reloadDomainList()},T.addSettingsViewModel(A,"AdminSettingsSecurity","Security","security"),A.prototype.onNewAdminPasswordResponse=function(a,b){R.StorageResultType.Success===a&&b&&b.Result?(this.adminPassword(""),this.adminPasswordNew(""),this.adminPasswordUpdateSuccess(!0)):this.adminPasswordUpdateError(!0)},A.prototype.onBuild=function(){this.csrfProtection.subscribe(function(a){db.remote().saveAdminConfig(T.emptyFunction,{TokenProtection:a?"1":"0"})})},A.prototype.onHide=function(){this.adminPassword(""),this.adminPasswordNew("")},A.prototype.phpInfoLink=function(){return db.link().phpInfo()},T.addSettingsViewModel(B,"AdminSettingsSocial","Social","social"),B.prototype.onBuild=function(){var a=this;f.delay(function(){var b=T.settingsSaveHelperSimpleFunction(a.facebookTrigger1,a),c=T.settingsSaveHelperSimpleFunction(a.facebookTrigger2,a),d=T.settingsSaveHelperSimpleFunction(a.twitterTrigger1,a),e=T.settingsSaveHelperSimpleFunction(a.twitterTrigger2,a),f=T.settingsSaveHelperSimpleFunction(a.googleTrigger1,a),g=T.settingsSaveHelperSimpleFunction(a.googleTrigger2,a),h=T.settingsSaveHelperSimpleFunction(a.dropboxTrigger1,a);a.facebookEnable.subscribe(function(a){db.remote().saveAdminConfig(T.emptyFunction,{FacebookEnable:a?"1":"0"})}),a.facebookAppID.subscribe(function(a){db.remote().saveAdminConfig(b,{FacebookAppID:T.trim(a)})}),a.facebookAppSecret.subscribe(function(a){db.remote().saveAdminConfig(c,{FacebookAppSecret:T.trim(a)})}),a.twitterEnable.subscribe(function(a){db.remote().saveAdminConfig(T.emptyFunction,{TwitterEnable:a?"1":"0"})}),a.twitterConsumerKey.subscribe(function(a){db.remote().saveAdminConfig(d,{TwitterConsumerKey:T.trim(a)})}),a.twitterConsumerSecret.subscribe(function(a){db.remote().saveAdminConfig(e,{TwitterConsumerSecret:T.trim(a)})}),a.googleEnable.subscribe(function(a){db.remote().saveAdminConfig(T.emptyFunction,{GoogleEnable:a?"1":"0"})}),a.googleClientID.subscribe(function(a){db.remote().saveAdminConfig(f,{GoogleClientID:T.trim(a)})}),a.googleClientSecret.subscribe(function(a){db.remote().saveAdminConfig(g,{GoogleClientSecret:T.trim(a)})}),a.dropboxEnable.subscribe(function(a){db.remote().saveAdminConfig(T.emptyFunction,{DropboxEnable:a?"1":"0"})}),a.dropboxApiKey.subscribe(function(a){db.remote().saveAdminConfig(h,{DropboxApiKey:T.trim(a)})})},50)},T.addSettingsViewModel(C,"AdminSettingsPlugins","Plugins","plugins"),C.prototype.disablePlugin=function(a){a.disabled(!a.disabled()),db.remote().pluginDisable(this.onPluginDisableRequest,a.name,a.disabled())},C.prototype.configurePlugin=function(a){db.remote().plugin(this.onPluginLoadRequest,a.name)},C.prototype.onBuild=function(){this.enabledPlugins.subscribe(function(a){db.remote().saveAdminConfig(T.emptyFunction,{EnabledPlugins:a?"1":"0"})})},C.prototype.onShow=function(){this.pluginsError(""),db.reloadPluginList()},C.prototype.onPluginLoadRequest=function(a,b){R.StorageResultType.Success===a&&b&&b.Result&&Y.showScreenPopup(q,[b.Result])},C.prototype.onPluginDisableRequest=function(a,b){R.StorageResultType.Success===a&&b&&!b.Result&&b.ErrorCode&&(R.Notification.UnsupportedPluginPackage===b.ErrorCode&&b.ErrorMessage&&""!==b.ErrorMessage?this.pluginsError(b.ErrorMessage):this.pluginsError(T.getNotification(b.ErrorCode))),db.reloadPluginList()},T.addSettingsViewModel(D,"AdminSettingsPackages","Packages","packages"),D.prototype.onShow=function(){this.packagesError("")},D.prototype.onBuild=function(){db.reloadPackagesList()},D.prototype.requestHelper=function(b,c){var d=this;return function(e,g){R.StorageResultType.Success===e&&g&&g.Result||(g&&g.ErrorCode?d.packagesError(T.getNotification(g.ErrorCode)):d.packagesError(T.getNotification(c?R.Notification.CantInstallPackage:R.Notification.CantDeletePackage))),f.each(db.data().packages(),function(a){a&&b&&a.loading()&&b.file===a.file&&(b.loading(!1),a.loading(!1))}),R.StorageResultType.Success===e&&g&&g.Result&&g.Result.Reload?a.location.reload():db.reloadPackagesList()}},D.prototype.deletePackage=function(a){a&&(a.loading(!0),db.remote().packageDelete(this.requestHelper(a,!1),a))},D.prototype.installPackage=function(a){a&&(a.loading(!0),db.remote().packageInstall(this.requestHelper(a,!0),a))},T.addSettingsViewModel(E,"AdminSettingsLicensing","Licensing","licensing"),E.prototype.onBuild=function(){this.subscriptionEnabled()&&db.reloadLicensing(!1)},E.prototype.onShow=function(){this.adminDomain(db.settingsGet("AdminDomain"))},E.prototype.showActivationForm=function(){Y.showScreenPopup(r)},E.prototype.licenseExpiredMomentValue=function(){var a=moment.unix(this.licenseExpired());return a.format("LL")+" ("+a.from(moment())+")"},F.prototype.populateDataOnStart=function(){var a=db.settingsGet("Languages"),b=db.settingsGet("Themes");T.isArray(a)&&this.languages(a),T.isArray(b)&&this.themes(b),this.mainLanguage(db.settingsGet("Language")),this.mainTheme(db.settingsGet("Theme")),this.allowCustomTheme(!!db.settingsGet("AllowCustomTheme")),this.allowAdditionalAccounts(!!db.settingsGet("AllowAdditionalAccounts")),this.allowIdentities(!!db.settingsGet("AllowIdentities")),this.determineUserLanguage(!!db.settingsGet("DetermineUserLanguage")),this.allowThemes(!!db.settingsGet("AllowThemes")),this.allowCustomLogin(!!db.settingsGet("AllowCustomLogin")),this.allowLanguagesOnLogin(!!db.settingsGet("AllowLanguagesOnLogin")),this.allowLanguagesOnSettings(!!db.settingsGet("AllowLanguagesOnSettings")),this.editorDefaultType(db.settingsGet("EditorDefaultType")),this.showImages(!!db.settingsGet("ShowImages")),this.interfaceAnimation(db.settingsGet("InterfaceAnimation")),this.mainMessagesPerPage(db.settingsGet("MPP")),this.desktopNotifications(!!db.settingsGet("DesktopNotifications")),this.useThreads(!!db.settingsGet("UseThreads")),this.replySameFolder(!!db.settingsGet("ReplySameFolder")),this.usePreviewPane(!!db.settingsGet("UsePreviewPane")),this.useCheckboxesInList(!!db.settingsGet("UseCheckboxesInList")),this.facebookEnable(!!db.settingsGet("AllowFacebookSocial")),this.facebookAppID(db.settingsGet("FacebookAppID")),this.facebookAppSecret(db.settingsGet("FacebookAppSecret")),this.twitterEnable(!!db.settingsGet("AllowTwitterSocial")),this.twitterConsumerKey(db.settingsGet("TwitterConsumerKey")),this.twitterConsumerSecret(db.settingsGet("TwitterConsumerSecret")),this.googleEnable(!!db.settingsGet("AllowGoogleSocial")),this.googleClientID(db.settingsGet("GoogleClientID")),this.googleClientSecret(db.settingsGet("GoogleClientSecret")),this.dropboxEnable(!!db.settingsGet("AllowDropboxSocial")),this.dropboxApiKey(db.settingsGet("DropboxApiKey")),this.contactsIsAllowed(!!db.settingsGet("ContactsIsAllowed"))},f.extend(G.prototype,F.prototype),G.prototype.populateDataOnStart=function(){F.prototype.populateDataOnStart.call(this)},H.prototype.oRequests={},H.prototype.defaultResponse=function(b,c,d,e,g,h){var i=function(){R.StorageResultType.Success!==d&&W.bUnload&&(d=R.StorageResultType.Unload),R.StorageResultType.Success===d&&e&&!e.Result?(e&&-1<T.inArray(e.ErrorCode,[R.Notification.AuthError,R.Notification.AccessError,R.Notification.ConnectionError,R.Notification.DomainNotAllowed,R.Notification.AccountNotAllowed,R.Notification.MailServerError,R.Notification.UnknownNotification,R.Notification.UnknownError])&&W.iAjaxErrorCount++,e&&R.Notification.InvalidToken===e.ErrorCode&&W.iTokenErrorCount++,Q.Values.TokenErrorLimit<W.iTokenErrorCount&&db.loginAndLogoutReload(!0),(e.Logout||Q.Values.AjaxErrorLimit<W.iAjaxErrorCount)&&(a.__rlah_clear&&a.__rlah_clear(),db.loginAndLogoutReload(!0))):R.StorageResultType.Success===d&&e&&e.Result&&(W.iAjaxErrorCount=0,W.iTokenErrorCount=0),b&&(U.runHook("ajax-default-response",[c,R.StorageResultType.Success===d?e:null,d,g,h]),b(d,R.StorageResultType.Success===d?e:null,g,c,h))};switch(d){case"success":d=R.StorageResultType.Success;break;case"abort":d=R.StorageResultType.Abort;break;default:d=R.StorageResultType.Error}R.StorageResultType.Error===d?f.delay(i,300):i()},H.prototype.ajaxRequest=function(c,d,e,g,h){var i=this,j=""===g,k={},l=(new a.Date).getTime(),m=null,n="";return d=d||{},e=T.isNormal(e)?e:2e4,g=T.isUnd(g)?"":T.pString(g),h=T.isArray(h)?h:[],n=d.Action||"",n&&0<h.length&&f.each(h,function(a){i.oRequests[a]&&(i.oRequests[a].__aborted=!0,i.oRequests[a].abort&&i.oRequests[a].abort(),i.oRequests[a]=null)}),j&&(d.XToken=db.settingsGet("Token")),m=b.ajax({type:j?"POST":"GET",url:db.link().ajax(g),async:!0,dataType:"json",data:j?d:{},headers:k,timeout:e,global:!0}),m.always(function(b,e){var f=!1;b&&b.Time&&(f=T.pInt(b.Time)>(new a.Date).getTime()-l),n&&i.oRequests[n]&&(i.oRequests[n].__aborted&&(e="abort"),i.oRequests[n]=null),i.defaultResponse(c,n,e,b,f,d)}),n&&0<h.length&&-1<T.inArray(n,h)&&(this.oRequests[n]&&(this.oRequests[n].__aborted=!0,this.oRequests[n].abort&&this.oRequests[n].abort(),this.oRequests[n]=null),this.oRequests[n]=m),m},H.prototype.defaultRequest=function(a,b,c,d,e,f){c=c||{},c.Action=b,e=T.pString(e),U.runHook("ajax-default-request",[b,c,e]),this.ajaxRequest(a,c,T.isUnd(d)?Q.Defaults.DefaultAjaxTimeout:T.pInt(d),e,f)},H.prototype.noop=function(a){this.defaultRequest(a,"Noop")},H.prototype.jsError=function(a,b,c,d,e,f,g){this.defaultRequest(a,"JsError",{Message:b,FileName:c,LineNo:d,Location:e,HtmlCapa:f,TimeOnPage:g})},H.prototype.jsInfo=function(a,b,c,d){this.defaultRequest(a,"JsInfo",{Type:b,Data:c,IsError:(T.isUnd(d)?1:!d)?"0":"1"})},H.prototype.jsVersion=function(a,b){this.defaultRequest(a,"Version",{Version:b})},f.extend(I.prototype,H.prototype),I.prototype.adminLogin=function(a,b,c){this.defaultRequest(a,"AdminLogin",{Login:b,Password:c})},I.prototype.adminLogout=function(a){this.defaultRequest(a,"AdminLogout")},I.prototype.saveAdminConfig=function(a,b){this.defaultRequest(a,"AdminSettingsUpdate",b)},I.prototype.domainList=function(a){this.defaultRequest(a,"AdminDomainList")},I.prototype.pluginList=function(a){this.defaultRequest(a,"AdminPluginList")},I.prototype.packagesList=function(a){this.defaultRequest(a,"AdminPackagesList")},I.prototype.packageInstall=function(a,b){this.defaultRequest(a,"AdminPackageInstall",{Id:b.id,Type:b.type,File:b.file},6e4)},I.prototype.packageDelete=function(a,b){this.defaultRequest(a,"AdminPackageDelete",{Id:b.id})},I.prototype.domain=function(a,b){this.defaultRequest(a,"AdminDomainLoad",{Name:b})},I.prototype.plugin=function(a,b){this.defaultRequest(a,"AdminPluginLoad",{Name:b})},I.prototype.domainDelete=function(a,b){this.defaultRequest(a,"AdminDomainDelete",{Name:b})},I.prototype.domainDisable=function(a,b,c){return this.defaultRequest(a,"AdminDomainDisable",{Name:b,Disabled:c?"1":"0"})},I.prototype.pluginSettingsUpdate=function(a,b){return this.defaultRequest(a,"AdminPluginSettingsUpdate",b)},I.prototype.licensing=function(a,b){return this.defaultRequest(a,"AdminLicensing",{Force:b?"1":"0"})},I.prototype.licensingActivate=function(a,b,c){return this.defaultRequest(a,"AdminLicensingActivate",{Domain:b,Key:c})},I.prototype.pluginDisable=function(a,b,c){return this.defaultRequest(a,"AdminPluginDisable",{Name:b,Disabled:c?"1":"0"})},I.prototype.createOrUpdateDomain=function(a,b,c,d,e,f,g,h,i,j,k,l,m){this.defaultRequest(a,"AdminDomainSave",{Create:b?"1":"0",Name:c,IncHost:d,IncPort:e,IncSecure:f,IncShortLogin:g?"1":"0",OutHost:h,OutPort:i,OutSecure:j,OutShortLogin:k?"1":"0",OutAuth:l?"1":"0",WhiteList:m})},I.prototype.testConnectionForDomain=function(a,b,c,d,e,f,g,h){this.defaultRequest(a,"AdminDomainTest",{IncHost:b,IncPort:c,IncSecure:d,OutHost:e,OutPort:f,OutSecure:g,OutAuth:h?"1":"0"})},I.prototype.testContacts=function(a,b){this.defaultRequest(a,"AdminContactsTest",b)},I.prototype.saveNewAdminPassword=function(a,b){this.defaultRequest(a,"AdminPasswordUpdate",b)},I.prototype.adminPing=function(a){this.defaultRequest(a,"AdminPing")},J.prototype.oEmailsPicsHashes={},J.prototype.oServices={},J.prototype.clear=function(){this.oServices={},this.oEmailsPicsHashes={}},J.prototype.getUserPic=function(a){var b="",c="",d=a.toLowerCase(),e=T.isUnd(this.oEmailsPicsHashes[a])?"":this.oEmailsPicsHashes[a];return""===e?(c=d.substr(a.indexOf("@")+1),b=""!==c&&this.oServices[c]?this.oServices[c]:""):b=db.link().getUserPicUrlFromHash(e),b},J.prototype.setServicesData=function(a){this.oServices=a},J.prototype.setEmailsPicsHashesData=function(a){this.oEmailsPicsHashes=a},f.extend(K.prototype,J.prototype),f.extend(L.prototype,m.prototype),L.prototype.onRoute=function(a){var d=this,e=null,g=null,h=null,i=null;g=f.find(X.settings,function(b){return b&&b.__rlSettingsData&&a===b.__rlSettingsData.Route}),g&&(f.find(X["settings-removed"],function(a){return a&&a===g})&&(g=null),g&&f.find(X["settings-disabled"],function(a){return a&&a===g})&&(g=null)),g?(g.__builded&&g.__vm?e=g.__vm:(h=this.oViewModelPlace,h&&1===h.length?(g=g,e=new g,i=b("<div></div>").addClass("rl-settings-view-model").hide().attr("data-bind",'template: {name: "'+g.__rlSettingsData.Template+'"}, i18nInit: true'),i.appendTo(h),e.data=db.data(),e.viewModelDom=i,e.__rlSettingsData=g.__rlSettingsData,g.__dom=i,g.__builded=!0,g.__vm=e,c.applyBindings(e,i[0]),Y.delegateRun(e,"onBuild",[i])):T.log("Cannot find sub settings view model position: SettingsSubScreen")),e&&f.defer(function(){d.oCurrentSubScreen&&(Y.delegateRun(d.oCurrentSubScreen,"onHide"),d.oCurrentSubScreen.viewModelDom.hide()),d.oCurrentSubScreen=e,d.oCurrentSubScreen&&(d.oCurrentSubScreen.viewModelDom.show(),Y.delegateRun(d.oCurrentSubScreen,"onShow"),f.each(d.menu(),function(a){a.selected(e&&e.__rlSettingsData&&a.route===e.__rlSettingsData.Route)}),b("#rl-content .b-settings .b-content .content").scrollTop(0)),T.windowResize()})):Y.setHash(db.link().settings(),!1,!0)},L.prototype.onHide=function(){this.oCurrentSubScreen&&this.oCurrentSubScreen.viewModelDom&&(Y.delegateRun(this.oCurrentSubScreen,"onHide"),this.oCurrentSubScreen.viewModelDom.hide())},L.prototype.onBuild=function(){f.each(X.settings,function(a){a&&a.__rlSettingsData&&!f.find(X["settings-removed"],function(b){return b&&b===a})&&this.menu.push({route:a.__rlSettingsData.Route,label:a.__rlSettingsData.Label,selected:c.observable(!1),disabled:!!f.find(X["settings-disabled"],function(b){return b&&b===a})})},this),this.oViewModelPlace=b("#rl-content #rl-settings-subscreen")},L.prototype.routes=function(){var a=f.find(X.settings,function(a){return a&&a.__rlSettingsData&&a.__rlSettingsData.IsDefault}),b=a?a.__rlSettingsData.Route:"general",c={subname:/^(.*)$/,normalize_:function(a,c){return c.subname=T.isUnd(c.subname)?b:T.pString(c.subname),[c.subname]}};return[["{subname}/",c],["{subname}",c],["",c]]},f.extend(M.prototype,m.prototype),M.prototype.onShow=function(){db.setTitle("")},f.extend(N.prototype,L.prototype),N.prototype.onShow=function(){db.setTitle("")},f.extend(O.prototype,k.prototype),O.prototype.oSettings=null,O.prototype.oLink=null,O.prototype.download=function(b){var c=null,d=null,e=navigator.userAgent.toLowerCase();return e&&(e.indexOf("chrome")>-1||e.indexOf("chrome")>-1)&&(c=document.createElement("a"),c.href=b,document.createEvent&&(d=document.createEvent("MouseEvents"),d&&d.initEvent&&c.dispatchEvent))?(d.initEvent("click",!0,!0),c.dispatchEvent(d),!0):(W.bMobileDevice?(a.open(b,"_self"),a.focus()):this.iframe.attr("src",b),!0)},O.prototype.link=function(){return null===this.oLink&&(this.oLink=new g),this.oLink},O.prototype.local=function(){return null===this.oLocal&&(this.oLocal=new j),this.oLocal},O.prototype.settingsGet=function(a){return null===this.oSettings&&(this.oSettings=T.isNormal(Z)?Z:{}),T.isUnd(this.oSettings[a])?null:this.oSettings[a]},O.prototype.settingsSet=function(a,b){null===this.oSettings&&(this.oSettings=T.isNormal(Z)?Z:{}),this.oSettings[a]=b},O.prototype.setTitle=function(b){b=(0<b.length?b+" - ":"")+db.settingsGet("Title")||"",a.document.title="_",a.document.title=b},O.prototype.loginAndLogoutReload=function(b,c){var d=T.pString(db.settingsGet("CustomLogoutLink")),e=!!db.settingsGet("InIframe");b=T.isUnd(b)?!1:!!b,c=T.isUnd(c)?!1:!!c,b&&c&&a.close&&a.close(),b&&""!==d&&a.location.href!==d?f.delay(function(){e&&a.parent?a.parent.location.href=d:a.location.href=d},100):(Y.routeOff(),Y.setHash(db.link().root(),!0),Y.routeOff(),f.delay(function(){e&&a.parent?a.parent.location.reload():a.location.reload()},100))},O.prototype.getAutocomplete=function(a,b){b([],a)},O.prototype.bootstart=function(){T.initOnStartOrLangChange(function(){T.initNotificationLanguage()},null),f.delay(function(){T.windowResize()},1e3)},f.extend(P.prototype,O.prototype),P.prototype.oData=null,P.prototype.oRemote=null,P.prototype.oCache=null,P.prototype.data=function(){return null===this.oData&&(this.oData=new G),this.oData},P.prototype.remote=function(){return null===this.oRemote&&(this.oRemote=new I),this.oRemote},P.prototype.cache=function(){return null===this.oCache&&(this.oCache=new K),this.oCache},P.prototype.reloadDomainList=function(){db.data().domainsLoading(!0),db.remote().domainList(function(a,b){if(db.data().domainsLoading(!1),R.StorageResultType.Success===a&&b&&b.Result){var d=f.map(b.Result,function(a,b){return{name:b,disabled:c.observable(!a),deleteAccess:c.observable(!1)}},this);db.data().domains(d)}})},P.prototype.reloadPluginList=function(){db.data().pluginsLoading(!0),db.remote().pluginList(function(a,b){if(db.data().pluginsLoading(!1),R.StorageResultType.Success===a&&b&&b.Result){var d=f.map(b.Result,function(a){return{name:a.Name,disabled:c.observable(!a.Enabled),configured:c.observable(!!a.Configured)}},this);db.data().plugins(d)}})},P.prototype.reloadPackagesList=function(){db.data().packagesLoading(!0),db.data().packagesReal(!0),db.remote().packagesList(function(a,b){if(db.data().packagesLoading(!1),R.StorageResultType.Success===a&&b&&b.Result){db.data().packagesReal(!!b.Result.Real),db.data().packagesMainUpdatable(!!b.Result.MainUpdatable);var d=[],e={};f.each(db.data().packages(),function(a){a&&a.loading()&&(e[a.file]=a)}),T.isArray(b.Result.List)&&(d=f.compact(f.map(b.Result.List,function(a){return a?(a.loading=c.observable(!T.isUnd(e[a.file])),"core"!==a.type||a.canBeInstalled?a:null):null}))),db.data().packages(d)}else db.data().packagesReal(!1)})},P.prototype.reloadLicensing=function(a){a=T.isUnd(a)?!1:!!a,db.data().licensingProcess(!0),db.data().licenseError(""),db.remote().licensing(function(a,b){db.data().licensingProcess(!1),R.StorageResultType.Success===a&&b&&b.Result&&T.isNormal(b.Result.Expired)?(db.data().licenseValid(!0),db.data().licenseExpired(T.pInt(b.Result.Expired)),db.data().licenseError(""),db.data().licensing(!0)):b&&b.ErrorCode&&-1<T.inArray(T.pInt(b.ErrorCode),[R.Notification.LicensingServerIsUnavailable,R.Notification.LicensingExpired])?(db.data().licenseError(T.getNotification(T.pInt(b.ErrorCode))),db.data().licensing(!0)):R.StorageResultType.Abort===a?(db.data().licenseError(T.getNotification(R.Notification.LicensingServerIsUnavailable)),db.data().licensing(!0)):db.data().licensing(!1)},a)},P.prototype.bootstart=function(){O.prototype.bootstart.call(this),db.data().populateDataOnStart(),Y.hideLoading(),db.settingsGet("AllowAdminPanel")?db.settingsGet("Auth")?(Y.startScreens([N]),W.bMobileDevice||f.defer(function(){T.initLayoutResizer("#rl-top-resizer-left","#rl-top-resizer-right","#rl-center",120,300,200,600,R.ClientSideKeyName.FolderListSize)})):Y.startScreens([M]):(Y.routeOff(),Y.setHash(db.link().root(),!0),Y.routeOff(),f.defer(function(){a.location.href="/"})),a.SimplePace&&a.SimplePace.set(100)},db=new P,_.addClass(W.bMobileDevice?"mobile":"no-mobile"),ab.keydown(T.killCtrlAandS).keyup(T.killCtrlAandS),ab.unload(function(){W.bUnload=!0}),a.rl=a.rl||{},a.rl.addHook=U.addHook,a.rl.settingsGet=U.mainSettingsGet,a.rl.remoteRequest=U.remoteRequest,a.rl.pluginSettingsGet=U.settingsGet,a.rl.addSettingsViewModel=T.addSettingsViewModel,a.rl.createCommand=T.createCommand,a.rl.EmailModel=o,a.rl.Enums=R,a.__RLBOOT=function(c){b(function(){a.rainloopTEMPLATES&&a.rainloopTEMPLATES[0]?(b("#rl-templates").html(a.rainloopTEMPLATES[0]),a.setInterval(function(){W.minuteTick(!W.minuteTick())},6e4),a.setInterval(function(){W.fiveMinuteTick(!W.fiveMinuteTick())},3e5),f.delay(function(){a.rainloopAppData={},a.rainloopI18N={},a.rainloopTEMPLATES={},Y.setBoot(db).bootstart(),_.addClass("rl-started")},50)):c(!1),a.__RLBOOT=null})},a.SimplePace&&a.SimplePace.add(10)}(window,jQuery,ko,crossroads,hasher,_);