snappymail/rainloop/v/1.3.10.492/static/js/app.min.js
2013-11-12 11:28:48 +04:00

406 lines
No EOL
205 KiB
JavaScript

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