%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /www/varak.net/mail2.varak.net_old/static/js/
Upload File :
Create Path :
Current File : //www/varak.net/mail2.varak.net_old/static/js/app-mobile.min.js

/*!
 * Copyright 2004-2014, AfterLogic Corp.
 * Licensed under AGPLv3 license or AfterLogic license
 * if commerical version of the product was purchased.
 * See the LICENSE file for a full license statement.
 */
!function(e,t,s,i,o){"use strict";function n(){this.ie11=!!navigator.userAgent.match(/Trident.*rv[ :]*11\./),this.ie=/msie/.test(navigator.userAgent.toLowerCase())&&!t.opera||this.ie11,this.ieVersion=this.getIeVersion(),this.ie8AndBelow=this.ie&&this.ieVersion<=8,this.ie9AndBelow=this.ie&&this.ieVersion<=9,this.ie10AndAbove=this.ie&&this.ieVersion>=10,this.opera=!!t.opera||/opr/.test(navigator.userAgent.toLowerCase()),this.firefox=/firefox/.test(navigator.userAgent.toLowerCase()),this.chrome=/chrome/.test(navigator.userAgent.toLowerCase())&&!/opr/.test(navigator.userAgent.toLowerCase()),this.chromeIos=/crios/.test(navigator.userAgent.toLowerCase()),this.safari=/safari/.test(navigator.userAgent.toLowerCase())&&!this.chromeIos}function r(){this.sUrl="?/Ajax/",this.requests=s.observableArray([]),this.openedRequestsCount=s.observable(0),this.requests.subscribe(function(){this.openedRequestsCount(this.requests().length)},this)}function a(){this.defaultScreen=yt.Screens.Mailbox,this.currentScreen=yt.Screens.Mailbox,this.lastMailboxHash=s.observable(yt.Screens.Mailbox),this.lastHelpdeskHash=s.observable(yt.Screens.Helpdesk),this.lastSettingsHash=s.observable(yt.Screens.Settings),this.currentHash=s.observable(""),this.previousHash=s.observable("")}function l(){}function h(){this.replyText=s.observable(""),this.replyDraftUid=s.observable(""),this.postponedMailData=null}function c(){this.prefetchStarted=s.observable(!1),this.serverInitializationsDone=s.observable(!1),this.helpdeskInitialized=s.observable(!1),this.fetchersIdentitiesPrefetched=s.observable(!1),this.init()}function u(t,i,o,n,r,a,l,h,c,u){this.fBeforeSelectCallback=null,this.fSelectCallback=i||function(){},this.fDeleteCallback=o||function(){},this.fDblClickCallback=!Ft&&n?n:function(){},this.fEnterCallback=r||function(){},this.bResetCheckedOnClick=vt.isUnd(l)?!1:!!l,this.bCheckOnSelect=vt.isUnd(h)?!1:!!h,this.bUnselectOnCtrl=vt.isUnd(c)?!1:!!c,this.bDisableMultiplySelection=vt.isUnd(u)?!1:!!u,this.useKeyboardKeys=s.observable(!1),this.list=s.observableArray([]),t&&t.subscribe&&t.subscribe(function(e){this.list(e)},this),this.multiplyLineFactor=a,this.oLast=null,this.oListScope=null,this.oScrollScope=null,this.iTimer=0,this.iFactor=1,this.KeyUp=yt.Key.Up,this.KeyDown=yt.Key.Down,this.KeyLeft=yt.Key.Up,this.KeyRight=yt.Key.Down,this.multiplyLineFactor&&(this.multiplyLineFactor.subscribe?this.multiplyLineFactor.subscribe(function(e){this.iFactor=e>0?e:1},this):this.iFactor=vt.pInt(this.multiplyLineFactor),this.KeyUp=yt.Key.Up,this.KeyDown=yt.Key.Down,this.KeyLeft=yt.Key.Left,this.KeyRight=yt.Key.Right,e("html").hasClass("rtl")&&(this.KeyLeft=yt.Key.Right,this.KeyRight=yt.Key.Left)),this.sActionSelector="",this.sSelectabelSelector="",this.sCheckboxSelector="";var d=this;this.listChecked=s.computed({read:function(){var e=_.filter(this.list(),function(e){var t=e.checked(),s=e.selected();return t||d.bCheckOnSelect&&s});return e},write:function(e){e=!!e,_.each(this.list(),function(t){t.checked(e)}),this.list.valueHasMutated()},owner:this}),this.checkAll=s.computed({read:function(){return 0<this.listChecked().length},write:function(e){this.listChecked(!!e)},owner:this}),this.selectorHook=s.observable(null),this.selectorHook.subscribe(function(){var e=this.selectorHook();e&&e.selected(!1)},this,"beforeChange"),this.selectorHook.subscribe(function(e){e&&e.selected(!0)},this),this.itemSelected=s.computed({read:this.selectorHook,write:function(e){this.selectorHook(e),e&&(this.oLast=e)},owner:this}),this.list.subscribe(function(e){if(_.isArray(e)){var t=this.itemSelected();t&&(_.find(e,function(e){return t===e})||this.itemSelected(null))}else this.itemSelected(null)},this),this.listCheckedOrSelected=s.computed({read:function(){var e=this.itemSelected(),t=this.listChecked();return 0<t.length?t:e?[e]:[]},write:function(e){e?this.listChecked(!0):(this.itemSelected(null),this.listChecked(!1))},owner:this}),this.listCheckedAndSelected=s.computed({read:function(){var e=[],t=this.itemSelected(),s=this.listChecked();return s&&(e=s.slice(0)),t&&-1===_.indexOf(s,t)&&e.push(t),e},write:function(e){e?this.listChecked(!0):(this.itemSelected(null),this.listChecked(!1))},owner:this}),this.isIncompleteChecked=s.computed(function(){var e=this.list().length,t=this.listChecked().length;return e>0&&t>0&&e>t},this),this.onKeydownBinded=_.bind(this.onKeydown,this)}function d(){this.openPgp=null,this.openPgpCallbacks=[]}function p(){Data.init()}function g(e,t){this.pgp=e,this.pgpKeyring=new this.pgp.Keyring(new this.pgp.Keyring.localstore(t)),this.keys=s.observableArray([]),this.reloadKeysFromStorage()}function m(e){this.pgpKey=e;var t=this.pgpKey.getPrimaryUser();this.user=t&&t.user?t.user.userId.userid:this.pgpKey.users&&this.pgpKey.users[0]?this.pgpKey.users[0].userId.userid:"",this.emailParts=vt.getEmailParts(this.user)}function f(){this.result=!0,this.errors=null,this.notices=null,this.exceptions=null}function b(){this.alertDesc=s.observable(""),this.closeCallback=null,this.title=s.observable(""),this.okButtonText=s.observable(vt.i18n("MAIN/BUTTON_OK"))}function y(){this.fConfirmCallback=null,this.confirmDesc=s.observable(""),this.title=s.observable(""),this.okButtonText=s.observable(vt.i18n("MAIN/BUTTON_OK")),this.cancelButtonText=s.observable(vt.i18n("MAIN/BUTTON_CANCEL")),this.shown=!1}function v(){this.pgp=null,this.keyArmor=s.observable(""),this.keyArmorFocused=s.observable(!1),this.keys=s.observableArray([]),this.hasExistingKeys=s.observable(!1),this.headlineText=s.computed(function(){return vt.i18n("OPENPGP/INFO_TEXT_INCLUDES_KEYS_PLURAL",{},null,this.keys().length)},this)}function S(e){this.AllowWebMail=!0,this.AllowUsersChangeInterfaceSettings=!0,this.AllowUsersChangeEmailSettings=!0,this.AllowUsersAddNewAccounts=!0,this.SiteName="",this.Languages=[{name:"English",value:"en"}],this.Themes=["Default"],this.DateFormats=[],this.DefaultLanguage="English",this.AttachmentSizeLimit=1024e4,this.ImageUploadSizeLimit=1024e4,this.FileSizeLimit=1024e4,this.AutoSave=!0,this.AutoSaveIntervalSeconds=60,this.IdleSessionTimeout=0,this.AllowInsertImage=!0,this.AllowBodySize=!1,this.MaxBodySize=600,this.MaxSubjectSize=255,this.AllowPrefetch=!0,this.MaxPrefetchBodiesSize=5e4,this.LoginFormType=yt.LoginFormType.Email,this.LoginAtDomainValue="",this.AllowRegistration=!1,this.AllowPasswordReset=!1,this.RegistrationDomains=[],this.RegistrationQuestions=[],this.DemoWebMail=!0,this.DemoWebMailLogin="",this.DemoWebMailPassword="",this.LoginDescription="",this.GoogleAnalyticsAccount="",this.ShowQuotaBar=!1,this.ServerUseUrlRewrite=!1,this.AllowLanguageOnLogin=!1,this.FlagsLangSelect=!1,this.CustomLoginUrl="",this.CustomLogoutUrl="",this.IosDetectOnLogin=!1,this.AllowContactsSharing=!1,this.DefaultLanguageShort="en",this.AllowOpenPgp=e,this.DefaultTab="",this.AllowIosProfile=!0,this.PasswordMinLength=0,this.PasswordMustBeComplex=!1}function A(){this.IdUser=1,this.MailsPerPage=20,this.ContactsPerPage=20,this.iInterval=-1,this.AutoCheckMailInterval=0,this.DefaultTheme="Default",this.DefaultLanguage="English",this.DefaultLanguageShort="en",this.DefaultDateFormat="MM/DD/YYYY",this.defaultTimeFormat=s.observable(yt.TimeFormat.F24),this.ThreadsEnabled=!0,this.useThreads=s.observable(!0),this.SaveRepliedToCurrFolder=!0,this.AllowChangeInputDirection=!1,this.DesktopNotifications=!1,this.AllowCompose=!0,this.AllowReply=!0,this.AllowForward=!0,this.SaveMail=yt.SaveMail.Checked,this.AllowFetcher=!1,this.OutlookSyncEnable=!0,this.MobileSyncEnable=!0,this.ShowPersonalContacts=!0,this.ShowGlobalContacts=!1,this.IsFilesSupported=!1,this.IsHelpdeskSupported=!1,this.IsHelpdeskAgent=!1,this.HelpdeskIframeUrl="",this.ShowContacts=this.ShowPersonalContacts||this.ShowGlobalContacts,this.LastLogin=0,this.IsDemo=!1,this.AllowVoice=!1,this.SipRealm="",this.SipWebsocketProxyUrl="",this.SipOutboundProxyUrl="",this.SipCallerID="",this.SipImpi="",this.SipImpu="",this.SipPassword="",this.VoiceProvider="",this.AllowCalendar=!0,this.CalendarSharing=!1,this.CalendarAppointments=!1,this.CalendarShowWeekEnds=!1,this.CalendarShowWorkDay=!1,this.CalendarWorkDayStarts=0,this.CalendarWorkDayEnds=0,this.CalendarWeekStartsOn=0,this.CalendarDefaultTab=yt.CalendarDefaultTab.Month,this.mobileSync=s.observable(null),this.MobileSyncDemoPass="demo",this.outlookSync=s.observable(null),this.OutlookSyncDemoPass="demo",this.AllowHelpdeskNotifications=!1,this.IsCollaborationSupported=!1,this.AllowFilesSharing=!1,this.DefaultFontName="Tahoma",this.fillDefaultFontName(),this.DefaultFontSize=3,this.fillDefaultFontSize(),this.enableOpenPgp=s.observable(!1),this.AllowAutosaveInDrafts=!0,this.AutosignOutgoingEmails=!1,this.filesEnable=s.observable(!0),this.SocialAccounts=s.observableArray([])}function C(){this.id=s.observable(0),this.email=s.observable(""),this.extensions=s.observableArray([]),this.fetchers=s.observable(null),this.identities=s.observable(null),this.friendlyName=s.observable(""),this.incomingMailLogin=s.observable(""),this.incomingMailPort=s.observable(143),this.incomingMailServer=s.observable(""),this.isInternal=s.observable(!1),this.isLinked=s.observable(!1),this.isDefault=s.observable(!1),this.outgoingMailAuth=s.observable(0),this.outgoingMailLogin=s.observable(""),this.outgoingMailPort=s.observable(25),this.outgoingMailServer=s.observable(""),this.isExtended=s.observable(!1),this.signature=s.observable(null),this.autoresponder=s.observable(null),this.forward=s.observable(null),this.filters=s.observable(null),this.quota=s.observable(0),this.usedSpace=s.observable(0),this.quotaRecieved=s.observable(!1),this.fullEmail=s.computed(function(){return""===this.friendlyName()?this.email():this.friendlyName()+" <"+this.email()+">"},this),this.isCurrent=s.observable(!1),this.isEdited=s.observable(!1),this.extensionsRequested=s.observable(!1),this.removeHint=s.computed(function(){var e="",t="";return this.isDefault()?(Et.User.AllowCalendar&&Et.User.ShowContacts?e=vt.i18n("SETTINGS/ACCOUNTS_REMOVE_CONTACTS_CALENDARS_HINT"):Et.User.AllowCalendar?e=vt.i18n("SETTINGS/ACCOUNTS_REMOVE_CALENDARS_HINT"):Et.User.ShowContacts&&(e=vt.i18n("SETTINGS/ACCOUNTS_REMOVE_CONTACTS_HINT")),t=vt.i18n("SETTINGS/ACCOUNTS_REMOVE_DEFAULT_HINT",{AND_OTHER:e}),Et.Accounts.collection().length>1&&(t+=vt.i18n("SETTINGS/ACCOUNTS_REMOVE_DEFAULT_NOTSINGLE_HINT"))):t=vt.i18n("SETTINGS/ACCOUNTS_REMOVE_HINT"),t},this),this.removeConfirmation=s.computed(function(){return this.isDefault()?this.removeHint()+vt.i18n("SETTINGS/ACCOUNTS_REMOVE_DEFAULT_CONFIRMATION"):vt.i18n("SETTINGS/ACCOUNTS_REMOVE_CONFIRMATION")},this)}function E(){this.defaultId=s.observable(0),this.currentId=s.observable(0),this.editedId=s.observable(0),this.currentId.subscribe(function(e){var t=this.getCurrent();t.requestExtensions(),_.delay(_.bind(function(){this.editedId(e)},this),1e3)},this),this.collection=s.observableArray([])}function T(){this.sName="",this.sEmail="",this.sDisplay="",this.sFull="",this.loaded=s.observable(!1),this.founded=s.observable(!1)}function F(){this.aCollection=[]}function M(){this.iTimeStampInUTC=0,this.oMoment=null}function I(){this.enabled=s.observable(!0),this.email=s.observable(""),this.friendlyName=s.observable(""),this.fullEmail=s.computed(function(){return""!==this.friendlyName()?this.friendlyName()+" <"+this.email()+">":this.email()},this),this.accountId=s.observable(-1),this.id=s.observable(-1),this.signature=s.observable(""),this.useSignature=s.observable(!1)}function w(){this.isIosDevice=It,this.isFolder=s.observable(!1),this.isLink=s.observable(!1),this.linkType=s.observable(yt.FileStorageLinkType.Unknown),this.linkUrl=s.observable(""),this.isPopupItem=s.observable(!1),this.id=s.observable(""),this.fileName=s.observable(""),this.tempName=s.observable(""),this.displayName=s.observable(""),this.extension=s.observable(""),this.fileName.subscribe(function(){var e=this.fileName(),t=e.lastIndexOf(".");this.id(e),this.isFolder()?(this.displayName(e),this.extension("")):(this.displayName(e.substr(0,t)),this.extension(e.substr(t+1)))},this),this.size=s.observable(0),this.friendlySize=s.computed(function(){return vt.friendlySize(this.size())},this),this.content=s.observable(""),this.accountId=s.observable(Et.Accounts?Et.Accounts.defaultId():null),this.hash=s.observable(""),this.thumb=s.observable(!1),this.iframedView=s.observable(!1),this.downloadLink=s.computed(function(){return vt.getDownloadLinkByHash(this.accountId(),this.hash())},this),this.viewLink=s.computed(function(){var e=vt.getViewLinkByHash(this.accountId(),this.hash());return this.iframedView()?vt.getIframeWrappwer(this.accountId(),e):e},this),this.thumbnailSrc=s.observable(""),this.thumbnailLoaded=s.observable(!1),this.thumbnailSessionUid=s.observable(""),this.thumbnailLink=s.computed(function(){return this.thumb()?vt.getViewThumbnailLinkByHash(this.accountId(),this.hash()):""},this),this.type=s.observable(""),this.uploadUid=s.observable(""),this.uploaded=s.observable(!1),this.uploadError=s.observable(!1),this.visibleImportLink=s.computed(function(){return Et.User.enableOpenPgp()&&"asc"===this.extension().toLowerCase()&&""!==this.content()&&!this.isPopupItem()},this),this.isViewMimeType=s.computed(function(){return-1!==e.inArray(this.type(),Rt)||this.iframedView()},this),this.isMessageType=s.observable(!1),this.visibleViewLink=s.computed(function(){return this.isVisibleViewLink()&&!this.isPopupItem()},this),this.visibleDownloadLink=s.computed(function(){return!this.isPopupItem()},this),this.subFiles=s.observableArray([]),this.allowExpandSubFiles=s.observable(!1),this.subFilesLoaded=s.observable(!1),this.subFilesCollapsed=s.observable(!1),this.subFilesStartedLoading=s.observable(!1),this.visibleExpandLink=s.computed(function(){return this.allowExpandSubFiles()&&!this.subFilesCollapsed()&&!this.subFilesStartedLoading()},this),this.visibleExpandingText=s.computed(function(){return this.allowExpandSubFiles()&&!this.subFilesCollapsed()&&this.subFilesStartedLoading()},this),this.visibleSpinner=s.observable(!1),this.statusText=s.observable(""),this.progressPercent=s.observable(0),this.visibleProgress=s.observable(!1),this.uploadStarted=s.observable(!1),this.uploadStarted.subscribe(function(){this.uploadStarted()?(this.uploaded(!1),this.visibleProgress(!0),this.progressPercent(20)):(this.progressPercent(100),this.visibleProgress(!1),this.uploaded(!0))},this),this.allowDrag=s.observable(!1),this.allowSelect=s.observable(!1),this.allowCheck=s.observable(!1),this.allowDelete=s.observable(!1),this.allowUpload=s.observable(!1),this.allowSharing=s.observable(!1),this.allowHeader=s.observable(!1),this.allowDownload=s.observable(!0),this.downloadTitle=s.computed(function(){return this.allowDownload()?vt.i18n("MESSAGE/ATTACHMENT_CLICK_TO_DOWNLOAD",{FILENAME:this.fileName(),SIZE:this.friendlySize()}):""},this)}function P(){this.folderName=s.observable(""),this.messageUid=s.observable(""),this.cid=s.observable(""),this.contentLocation=s.observable(""),this.inline=s.observable(!1),this.linked=s.observable(!1),this.mimePartIndex=s.observable(""),this.messagePart=s.observable(null),w.call(this),this.isMessageType=s.computed(function(){return this.type(),this.mimePartIndex(),"message/rfc822"===this.type()&&""!==this.mimePartIndex()},this)}function R(){this.iAccountId=0,this.account=s.computed(function(){return Et.Accounts.getAccount(this.iAccountId)},this),this.parentFullName=s.observable(""),this.level=s.observable(0),this.name=s.observable(""),this.nameForEdit=s.observable(""),this.fullName=s.observable(""),this.fullNameHash=s.observable(""),this.uidNext=s.observable(""),this.hash=s.observable(""),this.routingHash=s.observable(""),this.delimiter=s.observable(""),this.type=s.observable(yt.FolderTypes.User),this.showUnseenMessages=s.computed(function(){return this.type()!==yt.FolderTypes.Drafts},this),this.withoutThreads=s.computed(function(){return this.type()===yt.FolderTypes.Drafts||this.type()===yt.FolderTypes.Spam||this.type()===yt.FolderTypes.Trash},this),this.messageCount=s.observable(0),this.unseenMessageCount=s.observable(0),this.unseenMessageCount.subscribe(function(){_.delay(_.bind(function(){At.MailCache.countMessages(this)},this),1e3)},this),this.realUnseenMessageCount=s.observable(0),this.enableEmptyFolder=s.computed(function(){return this.messageCount()>0&&(this.type()===yt.FolderTypes.Spam||this.type()===yt.FolderTypes.Trash)},this),this.virtual=s.observable(!1),this.virtualEmpty=s.computed(function(){return this.virtual()&&0===this.messageCount()},this),this.hasExtendedInfo=s.observable(!1),this.selectable=s.observable(!0),this.subscribed=s.observable(!0),this.subscribed.subscribe(function(){if(this.parentFullName()){var e=At.MailCache.folderList().getFolderByFullName(this.parentFullName());e&&At.MailCache.countMessages(e)}},this),this.existen=s.observable(!0),this.isNamespace=s.observable(!1),this.subfoldersMessagesCount=s.observable(0),this.subfolders=s.observableArray([]),this.subfolders.subscribe(function(e){var t=_.any(_.map(e,function(e){return e.subscribed()}));this.canExpand(t)},this),this.canExpand=s.observable(!0),this.expanded=s.observable(!1),this.isCollapseHandler=s.computed(function(){return 0!==this.subfolders().length&&!this.isNamespace()&&this.canExpand()},this),this.messageCountToShow=s.computed(function(){return this.canExpand()?this.showUnseenMessages()?this.unseenMessageCount()+this.subfoldersMessagesCount():this.messageCount():this.showUnseenMessages()?this.unseenMessageCount():this.messageCount()},this),this.isSubFolder=s.computed(function(){return this.level()>0},this),this.selected=s.observable(!1),this.recivedAnim=s.observable(!1).extend({autoResetToFalse:500}),this.hasSubscribedSubfolders=s.computed(function(){return!!s.utils.arrayFirst(this.subfolders(),function(e){return e.subscribed()})},this),this.isSystem=s.computed(function(){return this.type()!==yt.FolderTypes.User?!0:!1},this),this.visible=s.computed(function(){var e=this.subscribed(),t=this.existen(),s=this.selectable(),i=this.hasSubscribedSubfolders(),o=this.isSystem();return e||o||i&&(!t||!s)},this),this.edited=s.observable(!1),this.edited.subscribe(function(e){e===!1&&this.nameForEdit(this.name())},this),this.canBeSelected=s.computed(function(){var e=this.existen(),t=this.selectable();return e&&t},this),this.canSubscribe=s.computed(function(){var e=this.account(),t=!1;return e&&(t=e.extensionExists("DisableManageSubscribe")),!this.isSystem()&&this.canBeSelected()&&!t},this),this.canDelete=s.computed(function(){return!this.isSystem()&&this.hasExtendedInfo()&&0===this.messageCount()&&0===this.subfolders().length},this),this.canRename=s.computed(function(){return!this.isSystem()&&this.canBeSelected()},this),this.subscribeButtonHint=s.computed(function(){return this.canSubscribe()?vt.i18n(this.subscribed()?"SETTINGS/ACCOUNT_FOLDERS_HIDE_FOLDER_HINT":"SETTINGS/ACCOUNT_FOLDERS_SHOW_FOLDER_HINT"):""},this),this.deleteButtonHint=s.computed(function(){return this.canDelete()?vt.i18n("SETTINGS/ACCOUNT_FOLDERS_DELETE_FOLDER_HINT"):""},this),this.usedAs=s.computed(function(){var e="";switch(this.type()){case yt.FolderTypes.Inbox:e=vt.i18n("SETTINGS/ACCOUNT_FOLDERS_USED_AS_INBOX");break;case yt.FolderTypes.Sent:e=vt.i18n("SETTINGS/ACCOUNT_FOLDERS_USED_AS_SENT");break;case yt.FolderTypes.Drafts:e=vt.i18n("SETTINGS/ACCOUNT_FOLDERS_USED_AS_DRAFTS");break;case yt.FolderTypes.Trash:e=vt.i18n("SETTINGS/ACCOUNT_FOLDERS_USED_AS_TRASH");break;case yt.FolderTypes.Spam:e=vt.i18n("SETTINGS/ACCOUNT_FOLDERS_USED_AS_SPAM");break;default:e=""}return e},this),this.oMessages={},this.oUids={},this.aResponseHandlers=[],this.displayName=s.computed(function(){var e=this.name();switch(this.type()){case yt.FolderTypes.Inbox:e=vt.i18n("MAIN/FOLDER_INBOX");break;case yt.FolderTypes.Sent:e=vt.i18n("MAIN/FOLDER_SENT");break;case yt.FolderTypes.Drafts:e=vt.i18n("MAIN/FOLDER_DRAFTS");break;case yt.FolderTypes.Trash:e=vt.i18n("MAIN/FOLDER_TRASH");break;case yt.FolderTypes.Spam:e=vt.i18n("MAIN/FOLDER_SPAM")}return e},this),this.aRequestedUids=[],this.aRequestedThreadUids=[],this.requestedLists=[],this.hasChanges=s.observable(!1),this.hasChanges.subscribe(function(){this.requestedLists=[]},this),this.unseenFilterCommand=vt.createCommand(this,this.executeUnseenFilter,this.showUnseenMessages),this.unseenMessagesTitle=s.computed(function(){return this.showUnseenMessages()?vt.i18n("MAILBOX/TITLE_UNSEEN_MESSAGES_ONLY"):""},this),this.relevantInformationLastMoment=null}function L(){this.iAccountId=0,this.bInitialized=s.observable(!1),this.expandFolders=s.observable(!1),this.expandNames=s.observableArray([]),this.collection=s.observableArray([]),this.options=s.observableArray([]),this.sNamespace="",this.sNamespaceFolder="",this.oStarredFolder=null,this.oNamedCollection={};var e=this,t=function(e){return function(t){t&&t.type(e)}},i=function(t){return{read:function(){return this.collection(),t()?t().fullName():""},write:function(e){t(this.getFolderByFullName(e))},owner:e}};this.totalMessageCount=s.computed(function(){return this.getRecursivelyMessageCount(this.collection())},this),this.currentFolder=s.observable(null),this.inboxFolder=s.observable(null),this.sentFolder=s.observable(null),this.draftsFolder=s.observable(null),this.spamFolder=s.observable(null),this.trashFolder=s.observable(null),this.inboxFolder.subscribe(t(yt.FolderTypes.User),this,"beforeChange"),this.sentFolder.subscribe(t(yt.FolderTypes.User),this,"beforeChange"),this.draftsFolder.subscribe(t(yt.FolderTypes.User),this,"beforeChange"),this.spamFolder.subscribe(t(yt.FolderTypes.User),this,"beforeChange"),this.trashFolder.subscribe(t(yt.FolderTypes.User),this,"beforeChange"),this.inboxFolder.subscribe(t(yt.FolderTypes.Inbox)),this.sentFolder.subscribe(t(yt.FolderTypes.Sent)),this.draftsFolder.subscribe(t(yt.FolderTypes.Drafts)),this.spamFolder.subscribe(t(yt.FolderTypes.Spam)),this.trashFolder.subscribe(t(yt.FolderTypes.Trash)),this.inboxFolderFullName=s.computed(i(this.inboxFolder)),this.sentFolderFullName=s.computed(i(this.sentFolder)),this.draftsFolderFullName=s.computed(i(this.draftsFolder)),this.spamFolderFullName=s.computed(i(this.spamFolder)),this.trashFolderFullName=s.computed(i(this.trashFolder)),this.currentFolderFullName=s.computed(i(this.currentFolder)),this.currentFolderType=s.computed(function(){return this.currentFolder()?this.currentFolder().type():yt.FolderTypes.User},this),this.delimiter=s.computed(function(){return this.inboxFolder()?this.inboxFolder().delimiter():""},this)}function N(){this.accountId=s.observable(0),this.folder=s.observable(""),this.uid=s.observable(""),this.subject=s.observable(""),this.emptySubject=s.computed(function(){return""===vt.trim(this.subject())},this),this.subjectForDisplay=s.computed(function(){return this.emptySubject()?vt.i18n("MAILBOX/EMPTY_SUBJECT"):this.subject()},this),this.messageId=s.observable(""),this.size=s.observable(0),this.friendlySize=s.computed(function(){return vt.friendlySize(this.size())},this),this.textSize=s.observable(0),this.oDateModel=new M,this.fullDate=s.observable(""),this.oFrom=new F,this.fullFrom=s.observable(""),this.oTo=new F,this.to=s.observable(""),this.fromOrToText=s.observable(""),this.oCc=new F,this.cc=s.observable(""),this.oBcc=new F,this.bcc=s.observable(""),this.oSender=new F,this.oReplyTo=new F,this.seen=s.observable(!1),this.flagged=s.observable(!1),this.partialFlagged=s.observable(!1),this.answered=s.observable(!1),this.forwarded=s.observable(!1),this.hasAttachments=s.observable(!1),this.hasIcalAttachment=s.observable(!1),this.hasVcardAttachment=s.observable(!1),this.showCalendarIcon=s.computed(function(){return Et.User.AllowCalendar&&this.hasIcalAttachment()},this),this.threadsAllowed=s.computed(function(){var e=At.MailCache.getFolderByFullName(this.accountId(),this.folder()),t=e&&(e.type()===yt.FolderTypes.Drafts||e.type()===yt.FolderTypes.Spam||e.type()===yt.FolderTypes.Trash);return Et.User.useThreads()&&!t},this),this.threadPart=s.observable(!1),this.threadPart.subscribe(function(){this.threadPart()&&this.partialFlagged(!1)},this),this.threadParentUid=s.observable(""),this.threadUids=s.observableArray([]),this.threadSenders=s.observableArray([]),this.threadSendersText=s.computed(function(){var e=this.threadSenders();return e.length>3?", "+e[0]+vt.i18n("MAILBOX/THREAD_MORE_SENDERS",{COUNT:e.length-1}):e.length>0?(e.unshift(""),e.join(", ")):""},this),this.threadSendersVisible=s.computed(function(){return this.threadSenders().length>0},this),this.threadCount=s.computed(function(){return this.threadUids().length},this),this.threadUnreedCount=s.observable(0),this.threadOpened=s.observable(!1),this.threadLoading=s.observable(!1),this.threadLoadingVisible=s.computed(function(){return this.threadsAllowed()&&this.threadOpened()&&this.threadLoading()},this),this.threadCountVisible=s.computed(function(){return this.threadsAllowed()&&this.threadCount()>0&&!this.threadLoading()},this),this.threadCountForLoad=s.observable(5),this.threadNextLoadingVisible=s.observable(!1),this.threadNextLoadingLinkVisible=s.observable(!1),this.threadFunctionLoadNext=null,this.threadShowAnimation=s.observable(!1),this.threadHideAnimation=s.observable(!1),this.importance=s.observable(yt.Importance.Normal),this.draftInfo=s.observableArray([]),this.sensitivity=s.observable(yt.Sensivity.Nothing),this.hash=s.observable(""),this.downloadLink=s.computed(function(){return this.hash().length>0?vt.getDownloadLinkByHash(this.accountId(),this.hash()):""},this),this.completelyFilled=s.observable(!1),this.checked=s.observable(!1),this.checked.subscribe(function(e){if(!this.threadOpened()&&At.MailCache.useThreadsInCurrentList()){var t=At.MailCache.folderList().getFolderByFullName(this.folder());_.each(this.threadUids(),function(s){var i=t.oMessages[s];i&&i.checked(e)})}},this),this.selected=s.observable(!1),this.deleted=s.observable(!1),this.trimmed=s.observable(!1),this.trimmedTextSize=s.observable(0),this.inReplyTo=s.observable(""),this.references=s.observable(""),this.readingConfirmation=s.observable(""),this.isPlain=s.observable(!1),this.text=s.observable(""),this.textBodyForNewWindow=s.observable(""),this.$text=null,this.rtl=s.observable(!1),this.hasExternals=s.observable(!1),this.isExternalsShown=s.observable(!1),this.isExternalsAlwaysShown=s.observable(!1),this.foundedCids=s.observableArray([]),this.attachments=s.observableArray([]),this.usesAttachmentString=!1,this.allAttachmentsHash="",this.safety=s.observable(!1),this.sourceHeaders=s.observable(""),this.date=s.observable(""),this.ical=s.observable(null),this.vcard=s.observable(null),this.textRaw=s.observable(""),this.encryptedMessage=s.observable(!1),this.signedMessage=s.observable(!1),this.domMessageForPrint=s.observable(null),this.Custom={},At.nowMoment&&At.nowMoment.subscribe(function(){this.updateMomentDate()},this)}function D(){this.resultCount=s.observable(-1),this.search=s.observable(""),this.filters=s.observable(""),this.collection=s.observableArray([]),this.threadUids={}}function x(){this.uid=s.observable(""),this.file=s.observable(""),this.attendee=s.observable(""),this.type=s.observable(""),this.icalType=s.observable(""),this.icalConfig=s.observable(""),this.type.subscribe(function(){var e=this.type().split("-"),t=e.shift(),s=_.find(yt.IcalType,function(e){return t===e},this),i=e.join("-"),o=_.find(yt.IcalConfig,function(e){return i===e},this);t!==s&&(t=yt.IcalType.Save),this.icalType(t),i!==o&&(i=yt.IcalConfig.NeedsAction),this.icalConfig(i)},this),this.isRequestType=s.computed(function(){return this.icalType()===yt.IcalType.Request},this),this.isCancelType=s.computed(function(){return this.icalType()===yt.IcalType.Cancel},this),this.cancelDecision=s.observable(""),this.isReplyType=s.computed(function(){return this.icalType()===yt.IcalType.Reply},this),this.replyDecision=s.observable(""),this.isSaveType=s.computed(function(){return this.icalType()===yt.IcalType.Save},this),this.isJustSaved=s.observable(!1),this.fillDecisions(),this.isAccepted=s.computed(function(){return this.icalConfig()===yt.IcalConfig.Accepted},this),this.isDeclined=s.computed(function(){return this.icalConfig()===yt.IcalConfig.Declined},this),this.isTentative=s.computed(function(){return this.icalConfig()===yt.IcalConfig.Tentative},this),this.location=s.observable(""),this.description=s.observable(""),this.when=s.observable(""),this.calendarId=s.observable(""),this.calendars=s.observableArray([]),Et.SingleMode&&t.opener?(this.calendars(t.opener.App.CalendarCache.calendars()),t.opener.App.CalendarCache.calendars.subscribe(function(){this.calendars(t.opener.App.CalendarCache.calendars())},this)):(this.calendars(At.CalendarCache.calendars()),At.CalendarCache.calendars.subscribe(function(){this.calendars(At.CalendarCache.calendars())},this)),this.selectedCalendarId=s.observable(""),this.chosenCalendarName=s.computed(function(){var e=null;return""!==this.calendarId()&&(e=_.find(this.calendars(),function(e){return e.id===this.calendarId()},this)),e?e.name:""},this),this.calendarIsChosen=s.computed(function(){return""!==this.chosenCalendarName()},this),this.visibleCalendarDropdown=s.computed(function(){return!this.calendarIsChosen()&&this.calendars().length>1&&(this.isRequestType()||this.isSaveType())},this),this.visibleCalendarName=s.computed(function(){return this.calendarIsChosen()},this),this.visibleFirstCalendarName=s.computed(function(){return 1===this.calendars().length&&!this.calendarIsChosen()},this),this.visibleCalendarRow=s.computed(function(){return""!==this.attendee()&&(this.visibleCalendarDropdown()||this.visibleCalendarName()||this.visibleFirstCalendarName())},this),this.visibleRequestButtons=s.computed(function(){return this.isRequestType()&&""!==this.attendee()},this),this.animation=s.observable(!1)}function k(){this.uid=s.observable(""),this.file=s.observable(""),this.name=s.observable(""),this.email=s.observable(""),this.isExists=s.observable(!1),this.isJustSaved=s.observable(!1)}function O(){this.sEmailDefaultType=yt.ContactEmailType.Personal,this.sPhoneDefaultType=yt.ContactPhoneType.Mobile,this.sAddressDefaultType=yt.ContactAddressType.Personal,this.voiceApp=null,At.Phone&&(this.voiceApp=At.Phone.voiceApp),this.idContact=s.observable(""),this.idUser=s.observable(""),this.global=s.observable(!1),this.itsMe=s.observable(!1),this.isNew=s.observable(!1),this.readOnly=s.observable(!1),this.edited=s.observable(!1),this.extented=s.observable(!1),this.personalCollapsed=s.observable(!1),this.businessCollapsed=s.observable(!1),this.otherCollapsed=s.observable(!1),this.groupsCollapsed=s.observable(!1),this.displayName=s.observable(""),this.firstName=s.observable(""),this.lastName=s.observable(""),this.nickName=s.observable(""),this.skype=s.observable(""),this.facebook=s.observable(""),this.displayNameFocused=s.observable(!1),this.primaryEmail=s.observable(this.sEmailDefaultType),this.primaryPhone=s.observable(this.sPhoneDefaultType),this.primaryAddress=s.observable(this.sAddressDefaultType),this.mainPrimaryEmail=s.computed({read:this.primaryEmail,write:function(e){this.primaryEmail(!vt.isUnd(e)&&0<=vt.inArray(e,[yt.ContactEmailType.Personal,yt.ContactEmailType.Business,yt.ContactEmailType.Other])?e:yt.ContactEmailType.Personal)},owner:this}),this.mainPrimaryPhone=s.computed({read:this.primaryPhone,write:function(e){this.primaryPhone(!vt.isUnd(e)&&0<=vt.inArray(e,[yt.ContactPhoneType.Mobile,yt.ContactPhoneType.Personal,yt.ContactPhoneType.Business])?e:yt.ContactPhoneType.Mobile)},owner:this}),this.mainPrimaryAddress=s.computed({read:this.primaryAddress,write:function(e){this.primaryAddress(!vt.isUnd(e)&&0<=vt.inArray(e,[yt.ContactAddressType.Personal,yt.ContactAddressType.Business])?e:yt.ContactAddressType.Personal)},owner:this}),this.personalEmail=s.observable(""),this.personalStreetAddress=s.observable(""),this.personalCity=s.observable(""),this.personalState=s.observable(""),this.personalZipCode=s.observable(""),this.personalCountry=s.observable(""),this.personalWeb=s.observable(""),this.personalFax=s.observable(""),this.personalPhone=s.observable(""),this.personalMobile=s.observable(""),this.businessEmail=s.observable(""),this.businessCompany=s.observable(""),this.businessDepartment=s.observable(""),this.businessJob=s.observable(""),this.businessOffice=s.observable(""),this.businessStreetAddress=s.observable(""),this.businessCity=s.observable(""),this.businessState=s.observable(""),this.businessZipCode=s.observable(""),this.businessCountry=s.observable(""),this.businessWeb=s.observable(""),this.businessFax=s.observable(""),this.businessPhone=s.observable(""),this.otherEmail=s.observable(""),this.otherBirthdayMonth=s.observable("0"),this.otherBirthdayDay=s.observable("0"),this.otherBirthdayYear=s.observable("0"),this.otherNotes=s.observable(""),this.etag=s.observable(""),this.sharedToAll=s.observable(!1),this.birthdayIsEmpty=s.computed(function(){var e="0"===this.otherBirthdayMonth(),t="0"===this.otherBirthdayDay(),s="0"===this.otherBirthdayYear();
return e||t||s},this),this.otherBirthday=s.computed(function(){var e="",t=vt.pInt(this.otherBirthdayYear()),s=vt.pInt(this.otherBirthdayMonth()),i=vt.pInt(this.otherBirthdayDay()),o=new M;return this.birthdayIsEmpty()||(o.setDate(t,s>0?s-1:0,i),e=o.getShortDate()),e},this),this.groups=s.observableArray([]),this.groupsIsEmpty=s.computed(function(){return 0===this.groups().length},this),this.email=s.computed({read:function(){var e="";switch(this.primaryEmail()){case yt.ContactEmailType.Personal:e=this.personalEmail();break;case yt.ContactEmailType.Business:e=this.businessEmail();break;case yt.ContactEmailType.Other:e=this.otherEmail()}return e},write:function(e){switch(this.primaryEmail()){case yt.ContactEmailType.Personal:this.personalEmail(e);break;case yt.ContactEmailType.Business:this.businessEmail(e);break;case yt.ContactEmailType.Other:this.otherEmail(e);break;default:this.primaryEmail(this.sEmailDefaultType),this.email(e)}},owner:this}),this.personalIsEmpty=s.computed(function(){var e=this.personalEmail()!==this.email()?this.personalEmail():"";return""==""+e+this.personalStreetAddress()+this.personalCity()+this.personalState()+this.personalZipCode()+this.personalCountry()+this.personalWeb()+this.personalFax()+this.personalPhone()+this.personalMobile()},this),this.businessIsEmpty=s.computed(function(){var e=this.businessEmail()!==this.email()?this.businessEmail():"";return""==""+e+this.businessCompany()+this.businessDepartment()+this.businessJob()+this.businessOffice()+this.businessStreetAddress()+this.businessCity()+this.businessState()+this.businessZipCode()+this.businessCountry()+this.businessWeb()+this.businessFax()+this.businessPhone()},this),this.otherIsEmpty=s.computed(function(){var e=this.otherEmail()!==this.email()?this.otherEmail():"";return""==""+e+this.otherNotes()&&this.birthdayIsEmpty()},this),this.phone=s.computed({read:function(){var e="";switch(this.primaryPhone()){case yt.ContactPhoneType.Mobile:e=this.personalMobile();break;case yt.ContactPhoneType.Personal:e=this.personalPhone();break;case yt.ContactPhoneType.Business:e=this.businessPhone()}return e},write:function(e){switch(this.primaryPhone()){case yt.ContactPhoneType.Mobile:this.personalMobile(e);break;case yt.ContactPhoneType.Personal:this.personalPhone(e);break;case yt.ContactPhoneType.Business:this.businessPhone(e);break;default:this.primaryPhone(this.sEmailDefaultType),this.phone(e)}},owner:this}),this.address=s.computed({read:function(){var e="";switch(this.primaryAddress()){case yt.ContactAddressType.Personal:e=this.personalStreetAddress();break;case yt.ContactAddressType.Business:e=this.businessStreetAddress()}return e},write:function(e){switch(this.primaryAddress()){case yt.ContactAddressType.Personal:this.personalStreetAddress(e);break;case yt.ContactAddressType.Business:this.businessStreetAddress(e);break;default:this.primaryAddress(this.sEmailDefaultType),this.address(e)}},owner:this}),this.emails=s.computed(function(){var e=[];return""!==this.personalEmail()&&e.push({text:vt.i18n("CONTACTS/OPTION_PERSONAL")+": "+this.personalEmail(),value:yt.ContactEmailType.Personal}),""!==this.businessEmail()&&e.push({text:vt.i18n("CONTACTS/OPTION_BUSINESS")+": "+this.businessEmail(),value:yt.ContactEmailType.Business}),""!==this.otherEmail()&&e.push({text:vt.i18n("CONTACTS/OPTION_OTHER")+": "+this.otherEmail(),value:yt.ContactEmailType.Other}),e},this),this.phones=s.computed(function(){var e=[];return""!==this.personalMobile()&&e.push({text:vt.i18n("CONTACTS/LABEL_MOBILE")+": "+this.personalMobile(),value:yt.ContactPhoneType.Mobile}),""!==this.personalPhone()&&e.push({text:vt.i18n("CONTACTS/OPTION_PERSONAL")+": "+this.personalPhone(),value:yt.ContactPhoneType.Personal}),""!==this.businessPhone()&&e.push({text:vt.i18n("CONTACTS/OPTION_BUSINESS")+": "+this.businessPhone(),value:yt.ContactPhoneType.Business}),e},this),this.addresses=s.computed(function(){var e=[];return""!==this.personalStreetAddress()&&e.push({text:vt.i18n("CONTACTS/OPTION_PERSONAL")+": "+this.personalStreetAddress(),value:yt.ContactAddressType.Personal}),""!==this.businessStreetAddress()&&e.push({text:vt.i18n("CONTACTS/OPTION_BUSINESS")+": "+this.businessStreetAddress(),value:yt.ContactAddressType.Business}),e},this),this.hasEmails=s.computed(function(){return 0<this.emails().length},this),this.extented.subscribe(function(e){e&&(this.personalCollapsed(!this.personalIsEmpty()),this.businessCollapsed(!this.businessIsEmpty()),this.otherCollapsed(!this.otherIsEmpty()),this.groupsCollapsed(!this.groupsIsEmpty()))},this),this.birthdayMonthSelect=O.birthdayMonthSelect,this.birthdayYearSelect=O.birthdayYearSelect,this.birthdayDaySelect=s.computed(function(){for(var e=1,t=vt.pInt(vt.daysInMonth(this.otherBirthdayMonth(),this.otherBirthdayYear())),s="",i=[{text:vt.i18n("DATETIME/DAY"),value:"0"}];t>=e;e++)s=e.toString(),i.push({text:s,value:s});return i},this);for(var e=new Date,t="",i=e.getFullYear(),o=1932;i>=o;i--)t=i.toString(),this.birthdayYearSelect.push({text:t,value:t});this.canBeSave=s.computed(function(){return""!==this.displayName()||!!this.emails().length},this),this.sendMailLink=s.computed(function(){return this.getSendMailLink(this.email())},this),this.sendMailToPersonalLink=s.computed(function(){return this.getSendMailLink(this.personalEmail())},this),this.sendMailToBusinessLink=s.computed(function(){return this.getSendMailLink(this.businessEmail())},this),this.sendMailToOtherLink=s.computed(function(){return this.getSendMailLink(this.otherEmail())},this)}function U(){this.isNew=s.observable(!1),this.readOnly=s.observable(!1),this.idGroup=s.observable(""),this.idUser=s.observable(""),this.name=s.observable(""),this.isOrganization=s.observable(!1),this.email=s.observable(""),this.country=s.observable(""),this.city=s.observable(""),this.company=s.observable(""),this.fax=s.observable(""),this.phone=s.observable(""),this.state=s.observable(""),this.street=s.observable(""),this.web=s.observable(""),this.zip=s.observable(""),this.edited=s.observable(!1),this.nameFocused=s.observable(!1),this.canBeSave=s.computed(function(){return""!==this.name()},this),this.newContactsInGroupCount=s.observable(0),this.newContactsInGroupHint=s.computed(function(){var e=this.newContactsInGroupCount();return this.isNew()&&e>0?vt.i18n("CONTACTS/CONTACT_ADD_TO_NEW_HINT_PLURAL",{COUNT:e},null,e):""},this),this.events=s.observableArray([])}function H(){this.bIsGroup=!1,this.bIsOrganization=!1,this.bReadOnly=!1,this.bItsMe=!1,this.bGlobal=!1,this.sId="",this.sName="",this.sEmail="",this.bSharedToAll=!1,this.deleted=s.observable(!1),this.checked=s.observable(!1),this.selected=s.observable(!1),this.recivedAnim=s.observable(!1).extend({autoResetToFalse:500})}function B(){this.iAccountId=0,this.type=s.observable(!0),this.options=s.observable(0),this.signature=s.observable("")}function G(){this.iAccountId=0,this.enable=!1,this.subject="",this.message=""}function K(){this.FETCHER=!0,this.id=s.observable(0),this.accountId=s.observable(0),this.isEnabled=s.observable(!1),this.isLocked=s.observable(!1),this.email=s.observable(""),this.userName=s.observable(""),this.folder=s.observable(""),this.signatureOptions=s.observable(!1),this.signature=s.observable(""),this.incomingMailServer=s.observable(""),this.incomingMailPort=s.observable(0),this.incomingMailLogin=s.observable(""),this.leaveMessagesOnServer=s.observable(""),this.isOutgoingEnabled=s.observable(!1),this.outgoingMailServer=s.observable(""),this.outgoingMailPort=s.observable(0),this.outgoingMailAuth=s.observable(!1),this.fullEmail=s.computed(function(){return""===this.userName()?this.email():this.userName()+" <"+this.email()+">"},this)}function V(){this.accountId=0,this.collection=s.observableArray([])}function j(){this.iAccountId=0,this.enable=!1,this.email=""}function q(){this.iAccountId=0,this.collection=s.observableArray([])}function W(e){this.iAccountId=e,this.enable=s.observable(!0).extend({reversible:!0}),this.field=s.observable("").extend({reversible:!0}),this.condition=s.observable("").extend({reversible:!0}),this.filter=s.observable("").extend({reversible:!0}),this.action=s.observable("").extend({reversible:!0}),this.folder=s.observable("").extend({reversible:!0})}function z(){this.iAnimationDuration=500,this.iReportDuration=5e3,this.iErrorDuration=1e4,this.loadingMessage=s.observable(""),this.loadingHidden=s.observable(!0),this.loadingVisible=s.observable(!1),this.reportMessage=s.observable(""),this.reportHidden=s.observable(!0),this.reportVisible=s.observable(!1),this.iReportTimeout=-1,this.errorMessage=s.observable(""),this.errorHidden=s.observable(!0),this.errorVisible=s.observable(!1),this.iErrorTimeout=-1,this.isHtmlError=s.observable(!1),this.gray=s.observable(!1)}function Y(){this.mobileApp=Ft,this.allowWebMail=Et.App.AllowWebMail,this.currentAccountId=Et.Accounts.currentId,this.currentAccountId.subscribe(function(){this.changeCurrentAccount()},this),this.tabs=At.headerTabs,this.email=s.observable(""),this.accounts=Et.Accounts.collection,this.currentTab=At.Screens.currentScreen,this.isMailboxTab=s.computed(function(){return this.currentTab()===yt.Screens.Mailbox},this),this.helpdeskUnseenCount=At.helpdeskUnseenCount,this.helpdeskUnseenVisible=s.computed(function(){return this.currentTab()!==yt.Screens.Helpdesk&&!!this.helpdeskUnseenCount()},this),this.mailUnseenCount=At.mailUnseenCount,this.mailUnseenVisible=s.computed(function(){return this.currentTab()!==yt.Screens.Mailbox&&!!this.mailUnseenCount()},this),this.mailboxHash=At.Routing.lastMailboxHash,this.settingsHash=At.Routing.lastSettingsHash,this.contactsRecivedAnim=At.ContactsCache.recivedAnim,this.calendarRecivedAnim=At.CalendarCache.recivedAnim,this.appCustomLogo=s.observable(Et.AppStyleImage||"")}function Q(){Y.call(this)}function $(e,t){this.shown=!1,this.currentPage=s.observable(1),this.count=s.observable(e),this.perPage=s.observable(t),this.firstPage=s.observable(1),this.lastPage=s.observable(1),this.pagesCount=s.computed(function(){var e=Math.ceil(this.count()/this.perPage());return e>0?e:1},this),s.computed(function(){var e=20,t=4,s=this.pagesCount(),i=this.currentPage(),o=i,n=i;if(s>1)for(;;){if(e--,o>1&&(o--,t--),0===t)break;if(s>n&&(n++,t--),0===t)break;if(0===e)break}this.firstPage(o),this.lastPage(n)},this),this.visibleFirst=s.computed(function(){return this.firstPage()>1},this),this.visibleLast=s.computed(function(){return this.lastPage()<this.pagesCount()},this),this.clickPage=_.bind(this.clickPage,this),this.pages=s.computed(function(){var e=this.firstPage(),t=[];if(this.firstPage()<this.lastPage())for(;e<=this.lastPage();e++)t.push({number:e,current:e===this.currentPage(),clickFunc:this.clickPage});return t},this),this.hotKeysBind()}function J(e,i){this.mobileApp=Ft,this.oParent=i,this.creaId="creaId"+Math.random().toString().replace(".",""),this.textFocused=s.observable(!1),this.workareaDom=s.observable(),this.uploaderAreaDom=s.observable(),this.editorUploaderBodyDragOver=s.observable(!1),this.editorUploaderProgress=s.observable(!1),this.colorPickerDropdownDom=s.observable(),this.insertLinkDropdownDom=s.observable(),this.insertImageDropdownDom=s.observable(),this.isEnable=s.observable(!0),this.isEnable.subscribe(function(){this.oCrea&&this.oCrea.setEditable(this.isEnable())},this),this.bInsertImageAsBase64=e,this.bAllowFileUpload=!(e&&void 0===t.File),this.allowInsertImage=s.observable(Et.App.AllowInsertImage),this.lockFontSubscribing=s.observable(!1),this.bAllowImageDragAndDrop=!At.browser.ie10AndAbove,this.aFonts=["Arial","Arial Black","Courier New","Tahoma","Times New Roman","Verdana"],this.sDefaultFont=Et.User.DefaultFontName,this.correctFontFromSettings(),this.selectedFont=s.observable(""),this.selectedFont.subscribe(function(){!this.oCrea||this.lockFontSubscribing()||this.inactive()||this.oCrea.fontName(this.selectedFont())},this),this.iDefaultSize=Et.User.DefaultFontSize,this.selectedSize=s.observable(0),this.selectedSize.subscribe(function(){!this.oCrea||this.lockFontSubscribing()||this.inactive()||this.oCrea.fontSize(this.selectedSize())},this),this.visibleInsertLinkPopup=s.observable(!1),this.linkForInsert=s.observable(""),this.linkFocused=s.observable(!1),this.visibleLinkPopup=s.observable(!1),this.linkPopupTop=s.observable(0),this.linkPopupLeft=s.observable(0),this.linkHref=s.observable(""),this.visibleLinkHref=s.observable(!1),this.visibleImagePopup=s.observable(!1),this.visibleImagePopup.subscribe(function(){this.onImageOut()},this),this.imagePopupTop=s.observable(0),this.imagePopupLeft=s.observable(0),this.imageSelected=s.observable(!1),this.tooltipText=s.observable(""),this.tooltipPopupTop=s.observable(0),this.tooltipPopupLeft=s.observable(0),this.visibleInsertImagePopup=s.observable(!1),this.imageUploaderButton=s.observable(null),this.uploadedImagePathes=s.observableArray([]),this.imagePathFromWeb=s.observable(""),this.visibleFontColorPopup=s.observable(!1),this.oFontColorPicker=new X(vt.i18n("HTMLEDITOR/TEXT_COLOR_CAPTION"),this.setTextColorFromPopup,this),this.oBackColorPicker=new X(vt.i18n("HTMLEDITOR/BACKGROUND_COLOR_CAPTION"),this.setBackColorFromPopup,this),this.activitySource=s.observable(1),this.activitySourceSubscription=null,this.inactive=s.observable(!1),this.inactive.subscribe(function(){var e=this.removeAllTags(this.getText());this.inactive()?(""===e||"&nbsp;"===e)&&(this.setText('<span style="color: #AAAAAA;">'+vt.i18n("HTMLEDITOR/SIGNATURE_PLACEHOLDER")+"</span>"),this.oCrea&&this.oCrea.setBlur()):e===vt.i18n("HTMLEDITOR/SIGNATURE_PLACEHOLDER")&&this.setText("")},this),this.allowChangeInputDirection=vt.isRTL()||Et.User.AllowChangeInputDirection,this.disabled=s.observable(!1)}function X(e,t,i){this.aGreyColors=["rgb(0, 0, 0)","rgb(68, 68, 68)","rgb(102, 102, 102)","rgb(153, 153, 153)","rgb(204, 204, 204)","rgb(238, 238, 238)","rgb(243, 243, 243)","rgb(255, 255, 255)"],this.aBrightColors=["rgb(255, 0, 0)","rgb(255, 153, 0)","rgb(255, 255, 0)","rgb(0, 255, 0)","rgb(0, 255, 255)","rgb(0, 0, 255)","rgb(153, 0, 255)","rgb(255, 0, 255)"],this.aColorLines=[["rgb(244, 204, 204)","rgb(252, 229, 205)","rgb(255, 242, 204)","rgb(217, 234, 211)","rgb(208, 224, 227)","rgb(207, 226, 243)","rgb(217, 210, 233)","rgb(234, 209, 220)"],["rgb(234, 153, 153)","rgb(249, 203, 156)","rgb(255, 229, 153)","rgb(182, 215, 168)","rgb(162, 196, 201)","rgb(159, 197, 232)","rgb(180, 167, 214)","rgb(213, 166, 189)"],["rgb(224, 102, 102)","rgb(246, 178, 107)","rgb(255, 217, 102)","rgb(147, 196, 125)","rgb(118, 165, 175)","rgb(111, 168, 220)","rgb(142, 124, 195)","rgb(194, 123, 160)"],["rgb(204, 0, 0)","rgb(230, 145, 56)","rgb(241, 194, 50)","rgb(106, 168, 79)","rgb(69, 129, 142)","rgb(61, 133, 198)","rgb(103, 78, 167)","rgb(166, 77, 121)"],["rgb(153, 0, 0)","rgb(180, 95, 6)","rgb(191, 144, 0)","rgb(56, 118, 29)","rgb(19, 79, 92)","rgb(11, 83, 148)","rgb(53, 28, 117)","rgb(116, 27, 71)"],["rgb(102, 0, 0)","rgb(120, 63, 4)","rgb(127, 96, 0)","rgb(39, 78, 19)","rgb(12, 52, 61)","rgb(7, 55, 99)","rgb(32, 18, 77)","rgb(76, 17, 48)"]],this.caption=e,this.pickHandler=t,this.pickContext=i,this.colorPickerDom=s.observable(null)}function Z(){this.phone=At.Phone,this.action=this.phone.action,this.report=this.phone.report,this.logs=s.observableArray([]),this.logsToShow=s.observableArray([]),this.spinner=s.observable(!0),this.tooltip=s.observable(vt.i18n("PHONE/NOT_CONNECTED")),this.indicator=s.observable(vt.i18n("PHONE/MISSED_CALLS")),this.dropdownShow=s.observable(!1),this.input=s.observable(""),this.input.subscribe(function(e){this.dropdownShow(""===e&&this.action()===yt.PhoneAction.OnlineActive)},this),this.inputFocus=s.observable(!1),this.inputFocus.subscribe(function(e){e&&""===this.input()&&this.action()===yt.PhoneAction.OnlineActive&&this.dropdownShow(!0)},this),this.phoneAutocompleteItem=s.observable(null),this.action.subscribe(function(e){switch(e){case yt.PhoneAction.Offline:this.tooltip(vt.i18n("PHONE/NOT_CONNECTED"));break;case yt.PhoneAction.OfflineError:this.tooltip(vt.i18n("Connection error"));break;case yt.PhoneAction.OfflineInit:this.tooltip(vt.i18n("PHONE/CONNECTING"));break;case yt.PhoneAction.OfflineActive:break;case yt.PhoneAction.Online:this.tooltip(vt.i18n("PHONE/CONNECTED")),this.input(""),this.report(""),this.timer("stop");break;case yt.PhoneAction.OnlineActive:break;case yt.PhoneAction.Outgoing:this.timer("start");break;case yt.PhoneAction.OutgoingConnect:this.tooltip(vt.i18n("In Call"));break;case yt.PhoneAction.Incoming:break;case yt.PhoneAction.IncomingConnect:this.tooltip(vt.i18n("In Call")),this.report(""),this.timer("start")}},this),e(document).on("click",_.bind(function(t){0===e(t.target).closest(".item.phone").length&&this.action()===yt.PhoneAction.OnlineActive&&(this.action(yt.PhoneAction.Online),this.dropdownShow(!1))},this))}function et(){this.rtl=s.observable(vt.isRTL()),this.allowRegistration=Et.App.AllowRegistration,this.allowPasswordReset=Et.App.AllowPasswordReset,this.oLoginViewModel=new tt,this.allowRegistration&&(this.oRegisterViewModel=new it),this.allowPasswordReset&&(this.oForgotViewModel=new st),this.gotoForgot=this.allowPasswordReset?this.oForgotViewModel.gotoForgot:s.observable(!1),this.gotoRegister=s.observable(!1),this.emailVisible=this.oLoginViewModel.emailVisible,this.loginVisible=this.oLoginViewModel.loginVisible,this.loginDescription=s.observable(Et.App.LoginDescription||""),this.aLanguages=Et.App.Languages,this.currentLanguage=s.observable(Et.App.DefaultLanguage),this.allowLanguages=s.observable(Et.App.AllowLanguageOnLogin),this.viewLanguagesAsDropdown=s.observable(!Et.App.FlagsLangSelect),this.loginCustomLogo=s.observable(Et.LoginStyleImage||""),Ct.runPluginHook&&Ct.runPluginHook("view-model-defined",[this.__name,this])}function tt(){this.allowRegistration=Et.App.AllowRegistration,this.allowPasswordReset=Et.App.AllowPasswordReset,this.email=s.observable(""),this.login=s.observable(""),this.password=s.observable(""),this.emailFocus=s.observable(!1),this.loginFocus=s.observable(!1),this.passwordFocus=s.observable(!1),this.loading=s.observable(!1),this.changingLanguage=s.observable(!1),this.loginFocus.subscribe(function(e){e&&""===this.login()&&this.login(this.email())},this),this.loginFormType=s.observable(Et.App.LoginFormType),this.loginAtDomainValue=s.observable(Et.App.LoginAtDomainValue),this.loginAtDomainValueWithAt=s.computed(function(){var e=this.loginAtDomainValue();return""===e?"":"@"+e},this),this.emailVisible=s.computed(function(){return yt.LoginFormType.Login!==this.loginFormType()},this),this.loginVisible=s.computed(function(){return yt.LoginFormType.Email!==this.loginFormType()},this),this.signMeType=s.observable(Et.App.LoginSignMeType),this.signMe=s.observable(yt.LoginSignMeType.DefaultOn===this.signMeType()),this.signMeType.subscribe(function(){this.signMe(yt.LoginSignMeType.DefaultOn===this.signMeType())},this),this.signMeFocused=s.observable(!1),this.emailDom=s.observable(null),this.loginDom=s.observable(null),this.passwordDom=s.observable(null),this.focusedField="",this.canBeLogin=s.computed(function(){return!this.loading()&&!this.changingLanguage()},this),this.signInButtonText=s.computed(function(){return vt.i18n(this.loading()?"LOGIN/BUTTON_SIGNING_IN":"LOGIN/BUTTON_SIGN_IN")},this),this.loginCommand=vt.createCommand(this,this.signIn,this.canBeLogin),this.email(Et.App.DemoWebMailLogin||""),this.password(Et.App.DemoWebMailPassword||""),Ct.runPluginHook&&Ct.runPluginHook("view-model-defined",[this.__name,this]),this.shake=s.observable(!1).extend({autoResetToFalse:800})}function st(){this.gotoForgot=s.observable(!1),this.gotoForgot.subscribe(function(){this.visibleEmailForm(!0),this.visibleQuestionForm(!1),this.visiblePasswordForm(!1)},this),this.visibleEmailForm=s.observable(!0),this.email=s.observable(""),this.emailFocus=s.observable(!1),this.gettingQuestion=s.observable(!1),this.getQuestionButtonText=s.computed(function(){return vt.i18n(this.gettingQuestion()?"LOGIN/BUTTON_GETTING_QUESTION":"LOGIN/BUTTON_GET_QUESTION")},this),this.allowGetQuestion=s.computed(function(){return!this.gettingQuestion()&&""!==vt.trim(this.email())},this),this.getQuestionCommand=vt.createCommand(this,this.executeGetQuestion,this.allowGetQuestion),this.visibleQuestionForm=s.observable(!1),this.question=s.observable(""),this.answer=s.observable(""),this.answerFocus=s.observable(!1),this.validatingAnswer=s.observable(!1),this.validateAnswerButtonText=s.computed(function(){return vt.i18n(this.validatingAnswer()?"LOGIN/BUTTON_VALIDATING_ANSWER":"LOGIN/BUTTON_VALIDATE_ANSWER")},this),this.allowValidatingAnswer=s.computed(function(){return!this.validatingAnswer()&&""!==vt.trim(this.answer())},this),this.validateAnswerCommand=vt.createCommand(this,this.executeValidateAnswer,this.allowValidatingAnswer),this.visiblePasswordForm=s.observable(!1),this.password=s.observable(""),this.confirmPassword=s.observable(""),this.passwordFocus=s.observable(!1),this.confirmPasswordFocus=s.observable(!1),this.changingPassword=s.observable(!1),this.changePasswordButtonText=s.computed(function(){return vt.i18n(this.changingPassword()?"LOGIN/BUTTON_RESETTING_PASSWORD":"LOGIN/BUTTON_RESET_PASSWORD")},this),this.allowChangePassword=s.computed(function(){var e=vt.trim(this.password()),t=vt.trim(this.confirmPassword()),s=""===e||""===t;return!this.changingPassword()&&!s},this),this.changePasswordCommand=vt.createCommand(this,this.executeChangePassword,this.allowChangePassword),Ct.runPluginHook&&Ct.runPluginHook("view-model-defined",[this.__name,this])}function it(){this.name=s.observable(""),this.login=s.observable(""),this.password=s.observable(""),this.confirmPassword=s.observable(""),this.question=s.observable(""),this.yourQuestion=s.observable(""),this.answer=s.observable(""),this.allowQuestionPart=vt.isNonEmptyArray(Et.App.RegistrationQuestions),this.visibleYourQuestion=s.computed(function(){return this.question()===vt.i18n("LOGIN/OPTION_YOUR_QUESTION")},this),this.nameFocus=s.observable(!1),this.loginFocus=s.observable(!1),this.passwordFocus=s.observable(!1),this.confirmPasswordFocus=s.observable(!1),this.questionFocus=s.observable(!1),this.answerFocus=s.observable(!1),this.yourQuestionFocus=s.observable(!1),this.domains=s.observable(vt.isNonEmptyArray(Et.App.RegistrationDomains)?Et.App.RegistrationDomains:[]),this.domain=s.computed(function(){return 1===this.domains().length?this.domains()[0]:""},this),this.selectedDomain=s.observable(this.domains().length>0?this.domains()[0]:""),this.registrationQuestions=[],this.allowQuestionPart&&(this.registrationQuestions=_.map(_.union("",_.without(Et.App.RegistrationQuestions,"*")),function(e){return{text:""!==e?e:vt.i18n("LOGIN/LABEL_SELECT_QUESTION"),value:e}}),-1!==_.indexOf(Et.App.RegistrationQuestions,"*")&&this.registrationQuestions.push({text:vt.i18n("LOGIN/OPTION_YOUR_QUESTION"),value:vt.i18n("LOGIN/OPTION_YOUR_QUESTION")})),this.loading=s.observable(!1),this.canBeRegister=s.computed(function(){var e=vt.trim(this.login()),t=vt.trim(this.password()),s=vt.trim(this.confirmPassword()),i=vt.trim(this.visibleYourQuestion()?this.yourQuestion():this.question()),o=vt.trim(this.answer()),n=""===e||""===t||""===s||this.allowQuestionPart&&(""===i||""===o);return!this.loading()&&!n},this),this.registerButtonText=s.computed(function(){return vt.i18n(this.loading()?"LOGIN/BUTTON_REGISTERING":"LOGIN/BUTTON_REGISTER")},this),this.registerCommand=vt.createCommand(this,this.registerAccount,this.canBeRegister),Ct.runPluginHook&&Ct.runPluginHook("view-model-defined",[this.__name,this])}function ot(){this.accounts=Et.Accounts.collection,this.mobileApp=Ft,this.folderList=At.MailCache.folderList,this.manageFoldersHash=At.Routing.buildHashFromArray([yt.Screens.Settings,yt.SettingsTab.EmailAccounts,yt.AccountSettingsTab.Folders]),this.quotaProc=s.observable(-1),this.quotaDesc=s.observable(""),s.computed(function(){if(!Et.App||Et.App&&!Et.App.ShowQuotaBar)return!0;At.MailCache.quotaChangeTrigger();var e=Et.Accounts.getCurrent(),t=e?e.quota():0,s=e?e.usedSpace():0,i=t>0?Math.ceil(s/t*100):-1;return i=i>100?100:i,this.quotaProc(i),this.quotaDesc(i>-1?vt.i18n("MAILBOX/QUOTA_TOOLTIP",{PROC:i,QUOTA:vt.friendlySize(1024*t)}):""),!0},this)}function nt(e){this.isPublic=Tt,this.uploaderArea=s.observable(null),this.bDragActive=s.observable(!1),this.bDragActiveComp=s.computed(function(){return this.bDragActive()},this),this.openMessageInNewWindowBinded=e,this.isFocused=s.observable(!1),this.messagesContainer=s.observable(null),this.searchInput=s.observable(""),this.searchInputFrom=s.observable(""),this.searchInputTo=s.observable(""),this.searchInputSubject=s.observable(""),this.searchInputText=s.observable(""),this.searchSpan=s.observable(""),this.highlightTrigger=s.observable(""),this.currentMessage=At.MailCache.currentMessage,this.currentMessage.subscribe(function(){this.isFocused(!1),this.selector.itemSelected(this.currentMessage())},this),this.folderList=At.MailCache.folderList,this.folderList.subscribe(this.onFolderListSubscribe,this),this.folderFullName=s.observable(""),this.filters=s.observable(""),this.uidList=At.MailCache.uidList,this.uidList.subscribe(function(){this.uidList().searchCountSubscription&&(this.uidList().searchCountSubscription.dispose(),this.uidList().searchCountSubscription=void 0),this.uidList().searchCountSubscription=this.uidList().resultCount.subscribe(function(){this.uidList().resultCount()>=0&&this.oPageSwitcher.setCount(this.uidList().resultCount())},this),this.uidList().resultCount()>=0&&this.oPageSwitcher.setCount(this.uidList().resultCount())},this),this.useThreads=s.computed(function(){var e=this.folderList().currentFolder(),t=e&&e.withoutThreads(),s=""===this.uidList().search()&&""===this.uidList().filters();return Et.User.useThreads()&&!t&&s},this),this.collection=At.MailCache.messages,this._search=s.observable(""),this.search=s.computed({read:function(){return vt.trim(this._search())},write:this._search,owner:this}),this.isEmptyList=s.computed(function(){return 0===this.collection().length},this),this.isNotEmptyList=s.computed(function(){return 0!==this.collection().length},this),this.isSearch=s.computed(function(){return this.search().length>0},this),this.isUnseenFilter=s.computed(function(){return this.filters()===yt.FolderFilter.Unseen},this),this.isLoading=At.MailCache.messagesLoading,this.isError=At.MailCache.messagesLoadingError,this.visibleInfoLoading=s.computed(function(){return!this.isSearch()&&this.isLoading()},this),this.visibleInfoSearchLoading=s.computed(function(){return this.isSearch()&&this.isLoading()},this),this.visibleInfoSearchList=s.computed(function(){return this.isSearch()&&!this.isUnseenFilter()&&!this.isLoading()&&!this.isEmptyList()},this),this.visibleInfoMessageListEmpty=s.computed(function(){return!this.isLoading()&&!this.isSearch()&&""===this.filters()&&this.isEmptyList()&&!this.isError()},this),this.visibleInfoStarredFolderEmpty=s.computed(function(){return!this.isLoading()&&!this.isSearch()&&this.filters()===yt.FolderFilter.Flagged&&this.isEmptyList()&&!this.isError()},this),this.visibleInfoSearchEmpty=s.computed(function(){return this.isSearch()&&!this.isUnseenFilter()&&this.isEmptyList()&&!this.isError()&&!this.isLoading()},this),this.visibleInfoMessageListError=s.computed(function(){return!this.isSearch()&&this.isError()},this),this.visibleInfoSearchError=s.computed(function(){return this.isSearch()&&this.isError()},this),this.visibleInfoUnseenFilterList=s.computed(function(){return this.isUnseenFilter()&&!this.isLoading()&&!this.isEmptyList()},this),this.visibleInfoUnseenFilterEmpty=s.computed(function(){return this.isUnseenFilter()&&this.isEmptyList()&&!this.isError()&&!this.isLoading()},this),this.searchText=s.computed(function(){return vt.i18n("MAILBOX/INFO_SEARCH_RESULT",{SEARCH:this.calculateSearchStringForDescription(),FOLDER:this.folderList().currentFolder()?this.folderList().currentFolder().displayName():""})},this),this.unseenFilterText=s.computed(function(){return""===this.search()?vt.i18n("MAILBOX/INFO_UNSEEN_FILTER_RESULT",{FOLDER:this.folderList().currentFolder()?this.folderList().currentFolder().displayName():""}):vt.i18n("MAILBOX/INFO_SEARCH_UNSEEN_FILTER_RESULT",{SEARCH:this.calculateSearchStringForDescription(),FOLDER:this.folderList().currentFolder()?this.folderList().currentFolder().displayName():""})},this),this.unseenFilterEmptyText=s.computed(function(){return vt.i18n(""===this.search()?"MAILBOX/INFO_UNSEEN_FILTER_EMPTY":"MAILBOX/INFO_SEARCH_UNSEEN_FILTER_EMPTY")},this),this.isEnableGroupOperations=s.observable(!1).extend({throttle:250}),this.selector=new u(this.collection,_.bind(this.routeForMessage,this),_.bind(this.onDeletePress,this),_.bind(this.onMessageDblClick,this),_.bind(this.onEnterPress,this)),this.checkedUids=s.computed(function(){var e=this.selector.listChecked(),t=_.map(e,function(e){return e.uid()}),s=At.MailCache.folderList().currentFolder(),i=s?s.getThreadCheckedUidsFromList(e):[],o=_.union(t,i);return o},this),this.checkedOrSelectedUids=s.computed(function(){var e=this.checkedUids();return 0===e.length&&At.MailCache.currentMessage()&&!At.MailCache.currentMessage().deleted()&&(e=[At.MailCache.currentMessage().uid()]),e},this),s.computed(function(){this.isEnableGroupOperations(0<this.selector.listCheckedOrSelected().length)},this),this.checkAll=this.selector.koCheckAll(),this.checkAllIncomplite=this.selector.koCheckAllIncomplete(),this.pageSwitcherLocked=s.observable(!1),this.oPageSwitcher=new $(0,Et.User.MailsPerPage),this.oPageSwitcher.currentPage.subscribe(function(e){var t=this.folderList().currentFolderFullName(),s=!Ft&&this.currentMessage()?this.currentMessage().uid():"",i=this.search();this.pageSwitcherLocked()||this.changeRoutingForMessageList(t,e,s,i,this.filters())},this),this.currentPage=s.observable(0),this.listChangedThrottle=At.browser.firefox||At.browser.ie?s.observable(!1).extend({throttle:10}):s.observable(!1),this.firstCompleteCollection=s.observable(!0),this.collection.subscribe(function(){this.collection().length>0&&this.firstCompleteCollection(!1)},this),this.currentAccountId=Et.Accounts.currentId,this.listChanged=s.computed(function(){return[this.firstCompleteCollection(),this.currentAccountId(),this.folderFullName(),this.filters(),this.search(),this.oPageSwitcher.currentPage()]},this),this.listChanged.subscribe(function(){this.listChangedThrottle(!this.listChangedThrottle())},this),this.bAdvancedSearch=s.observable(!1),this.searchAttachmentsCheckbox=s.observable(!1),this.searchAttachments=s.observable(""),this.searchAttachments.subscribe(function(e){this.searchAttachmentsCheckbox(!!e)},this),this.panelTopDom=s.observable(null),this.extendedDom=s.observable(null),this.searchAttachmentsFocus=s.observable(!1),this.searchFromFocus=s.observable(!1),this.searchSubjectFocus=s.observable(!1),this.searchToFocus=s.observable(!1),this.searchTextFocus=s.observable(!1),this.searchTrigger=s.observable(null),this.searchDateStartFocus=s.observable(!1),this.searchDateEndFocus=s.observable(!1),this.searchDateStartDom=s.observable(null),this.searchDateStart=s.observable(""),this.searchDateEndDom=s.observable(null),this.searchDateEnd=s.observable(""),this.dateFormatDatePicker="yy.mm.dd",this.attachmentsPlaceholder=s.computed(function(){return vt.i18n("MAILBOX/SEARCH_FIELD_HAS_ATTACHMENTS")},this),_.delay(_.bind(function(){this.createDatePickerObject(this.searchDateStartDom()),this.createDatePickerObject(this.searchDateEndDom())},this),1e3)}function rt(e){this.openMessageInNewWindowBinded=e,this.singleMode=s.observable(Et.SingleMode),this.isLoading=s.observable(!1),this.messages=At.MailCache.messages,this.messages.subscribe(this.onMessagesSubscribe,this),this.currentMessage=At.MailCache.currentMessage,this.currentMessage.subscribe(this.onCurrentMessageSubscribe,this),Et.User.defaultTimeFormat.subscribe(this.onCurrentMessageSubscribe,this),this.displayedMessageUid=s.observable(""),this.isCurrentMessage=s.computed(function(){return!!this.currentMessage()},this),this.isCurrentMessageLoaded=s.computed(function(){return this.isCurrentMessage()&&!this.isLoading()},this),this.visibleNoMessageSelectedText=s.computed(function(){return this.messages().length>0&&!this.isCurrentMessage()
},this),this.prevMessageUid=At.MailCache.prevMessageUid,this.nextMessageUid=At.MailCache.nextMessageUid,this.isEnablePrevMessage=s.computed(function(){return"string"==typeof this.prevMessageUid()&&""!==this.prevMessageUid()},this),this.isEnableNextMessage=s.computed(function(){return"string"==typeof this.nextMessageUid()&&""!==this.nextMessageUid()},this),this.isEnableDelete=this.isCurrentMessage,this.isEnableReply=this.isCurrentMessageLoaded,this.isEnableReplyAll=this.isCurrentMessageLoaded,this.isEnableResend=this.isCurrentMessageLoaded,this.isEnableForward=this.isCurrentMessageLoaded,this.isEnablePrint=this.isCurrentMessageLoaded,this.isEnableSave=this.isCurrentMessage,this.allowSaveAsPdf=s.observable(!!Et.AllowSaveAsPdf),this.isEnableSaveAsPdf=s.computed(function(){return this.isCurrentMessageLoaded()&&this.allowSaveAsPdf()},this),this.deleteCommand=vt.createCommand(this,this.executeDeleteMessage,this.isEnableDelete),this.prevMessageCommand=vt.createCommand(this,this.executePrevMessage,this.isEnablePrevMessage),this.nextMessageCommand=vt.createCommand(this,this.executeNextMessage,this.isEnableNextMessage),this.replyCommand=vt.createCommand(this,this.executeReply,this.isEnableReply),this.replyAllCommand=vt.createCommand(this,this.executeReplyAll,this.isEnableReplyAll),this.resendCommand=vt.createCommand(this,this.executeResend,this.isEnableResend),this.forwardCommand=vt.createCommand(this,this.executeForward,this.isEnableForward),this.printCommand=vt.createCommand(this,this.executePrint,this.isEnablePrint),this.saveCommand=vt.createCommand(this,this.executeSave,this.isEnableSave),this.saveAsPdfCommand=vt.createCommand(this,this.executeSaveAsPdf,this.isEnableSaveAsPdf),this.moreCommand=vt.createCommand(this,null,this.isCurrentMessageLoaded),this.ical=s.observable(null),this.icalSubscription=this.ical.subscribe(function(){null!==this.ical()&&(At.CalendarCache.firstRequestCalendarList(),this.icalSubscription.dispose())},this),this.vcard=s.observable(null),this.processed=s.observable(!1),this.visiblePicturesControl=s.observable(!1),this.visibleShowPicturesLink=s.observable(!1),this.visibleAppointmentInfo=s.computed(function(){return null!==this.ical()},this),this.visibleVcardInfo=s.computed(function(){return null!==this.vcard()},this),this.sensitivityText=s.computed(function(){var e="";if(this.currentMessage())switch(this.currentMessage().sensitivity()){case yt.Sensivity.Confidential:e=vt.i18n("MESSAGE/SENSIVITY_CONFIDENTIAL");break;case yt.Sensivity.Personal:e=vt.i18n("MESSAGE/SENSIVITY_PERSONAL");break;case yt.Sensivity.Private:e=vt.i18n("MESSAGE/SENSIVITY_PRIVATE")}return e},this),this.visibleConfirmationControl=s.computed(function(){return this.currentMessage()&&""!==this.currentMessage().readingConfirmation()},this),this.isCurrentNotDraftOrSent=s.computed(function(){var e=At.MailCache.folderList().currentFolder();return e&&e.fullName().length>0&&e.type()!==yt.FolderTypes.Drafts&&e.type()!==yt.FolderTypes.Sent},this),this.isCurrentSentFolder=s.computed(function(){var e=At.MailCache.folderList().currentFolder();return e&&e.fullName().length>0&&e.type()===yt.FolderTypes.Sent},this),this.isCurrentNotDraftFolder=s.computed(function(){var e=At.MailCache.folderList().currentFolder();return e&&e.fullName().length>0&&e.type()!==yt.FolderTypes.Drafts},this),this.isVisibleReplyTool=this.isCurrentNotDraftOrSent,this.isVisibleResendTool=this.isCurrentSentFolder,this.isVisibleForwardTool=this.isCurrentNotDraftFolder,this.uid=s.observable(""),this.folder=s.observable(""),this.subject=s.observable(""),this.emptySubject=s.computed(function(){return""===vt.trim(this.subject())},this),this.subjectForDisplay=s.computed(function(){return this.emptySubject()?vt.i18n("MAILBOX/EMPTY_SUBJECT"):this.subject()},this),this.importance=s.observable(yt.Importance.Normal),this.oFromAddr=s.observable(null),this.from=s.observable(""),this.fromEmail=s.observable(""),this.fullFrom=s.observable(""),this.to=s.observable(""),this.aToAddr=s.observableArray([]),this.cc=s.observable(""),this.aCcAddr=s.observableArray([]),this.bcc=s.observable(""),this.aBccAddr=s.observableArray([]),this.allRecipients=s.observable(""),this.aAllRecipients=s.observableArray([]),this.recipientsContacts=s.observableArray([]),this.currentAccountEmail=s.observable(),this.meSender=vt.i18n("MESSAGE/ME_SENDER"),this.meRecipient=vt.i18n("MESSAGE/ME_RECIPIENT"),this.fullDate=s.observable(""),this.midDate=s.observable(""),this.textBody=s.observable(""),this.textBodyForNewWindow=s.observable(""),this.domTextBody=s.observable(null),this.rtlMessage=s.observable(!1),this.contentHasFocus=s.observable(!1),this.decryptPassword=s.observable(""),this.visibleDecryptControl=s.observable(!1),this.visibleVerifyControl=s.observable(!1),this.fakeHeader=s.computed(function(){return!(this.visiblePicturesControl()||this.visibleConfirmationControl()||""!==this.sensitivityText()||this.visibleDecryptControl()||this.visibleVerifyControl())},this),this.mobileApp=Ft,this.attachments=s.observableArray([]),this.usesAttachmentString=!0,this.attachmentsInString=s.computed(function(){return _.map(this.attachments(),function(e){return e.fileName()},this).join(", ")},this),this.notInlineAttachments=s.computed(function(){return _.filter(this.attachments(),function(e){return!e.linked()})},this),this.visibleDownloadAllAttachments=s.computed(function(){return Et.ZipAttachments&&this.notInlineAttachments().length>1},this),this.visibleSaveAttachmentsToFiles=Et.User.IsFilesSupported,this.visibleDownloadAllAttachmentsSeparately=s.computed(function(){return this.notInlineAttachments().length>1},this),this.visibleExtendedDownload=s.computed(function(){return!this.mobileApp&&(this.visibleDownloadAllAttachments()||this.visibleDownloadAllAttachmentsSeparately()||this.visibleSaveAttachmentsToFiles)},this),this.detailsVisible=s.observable(!1),this.hasNotInlineAttachments=s.computed(function(){return this.notInlineAttachments().length>0},this),this.scrollToAttachment=s.observable(".attachments"),this.hasBodyText=s.computed(function(){return this.textBody().length>0},this),this.visibleAddMenu=s.observable(!1),this.replyText=s.observable(""),this.replyTextFocus=s.observable(!1),this.replyPaneVisible=s.computed(function(){return this.currentMessage()&&this.currentMessage().completelyFilled()},this),this.replySendingStarted=s.observable(!1),this.replySavingStarted=s.observable(!1),this.replyAutoSavingStarted=s.observable(!1),this.requiresPostponedSending=s.observable(!1),this.replyAutoSavingStarted.subscribe(function(){!this.replyAutoSavingStarted()&&this.requiresPostponedSending()&&(At.MessageSender.sendPostponedMail(this.replyDraftUid()),this.requiresPostponedSending(!1))},this),s.computed(function(){(!this.replyTextFocus()||this.replyAutoSavingStarted()||this.replySavingStarted()||this.replySendingStarted())&&this.stopAutosaveTimer(),!this.replyTextFocus()||this.replyAutoSavingStarted()||this.replySavingStarted()||this.replySendingStarted()||this.startAutosaveTimer()},this),this.saveButtonText=s.computed(function(){return vt.i18n(this.replyAutoSavingStarted()?"COMPOSE/TOOL_SAVING":"COMPOSE/TOOL_SAVE")},this),this.replyDraftUid=s.observable(""),this.replyLoadingText=s.computed(function(){return this.replySendingStarted()?vt.i18n("COMPOSE/INFO_SENDING"):this.replySavingStarted()?vt.i18n("COMPOSE/INFO_SAVING"):""},this),this.isEnableSaveQuickReply=s.computed(function(){return this.isCurrentMessageLoaded()&&""!==this.replyText()&&!this.replySavingStarted()&&!this.replyAutoSavingStarted()},this),this.isEnableSendQuickReply=s.computed(function(){return this.isCurrentMessageLoaded()&&""!==this.replyText()&&!this.replySendingStarted()},this),this.saveQuickReplyCommand=vt.createCommand(this,this.executeSaveQuickReply,this.isEnableSaveQuickReply),this.sendQuickReplyCommand=vt.createCommand(this,this.executeSendQuickReplyCommand,this.isEnableSendQuickReply),this.domMessageHeader=s.observable(null),this.domQuickReply=s.observable(null),this.domMessageForPrint=s.observable(null),this.replyTextFocusThrottled=s.observable(!1).extend({throttle:50}),this.replyTextFocus.subscribe(function(){this.replyTextFocusThrottled(this.replyTextFocus())},this),this.isQuickReplyActive=s.computed(function(){return this.replyText().length>0||this.replyTextFocusThrottled()},this),this.jqPanelHelper=null,this.visibleAttachments=s.observable(!1),this.showMessage=function(){this.visibleAttachments(!1)},this.showAttachments=function(){this.visibleAttachments(!0)},this.defaultFontName=Et.User.DefaultFontName,At.nowMoment&&At.nowMoment.subscribe(function(){this.updateMomentDate()},this)}function at(){this.folderList=At.MailCache.folderList,this.domFolderList=s.observable(null),this.openMessageInNewWindowBinded=_.bind(this.openMessageInNewWindow,this),this.oFolderList=new ot,this.oMessageList=new nt(this.openMessageInNewWindowBinded),this.oMessagePane=new rt(this.openMessageInNewWindowBinded),this.isEnableGroupOperations=this.oMessageList.isEnableGroupOperations,this.composeLink=s.observable(At.Routing.buildHashFromArray(At.Links.compose())),this.checkMailCommand=vt.createCommand(this,this.executeCheckMail),this.checkMailIndicator=s.computed(function(){return At.MailCache.checkMailStarted()||At.MailCache.messagesLoading()},this),this.markAsReadCommand=vt.createCommand(this.oMessageList,this.oMessageList.executeMarkAsRead,this.isEnableGroupOperations),this.markAsUnreadCommand=vt.createCommand(this.oMessageList,this.oMessageList.executeMarkAsUnread,this.isEnableGroupOperations),this.markAllReadCommand=vt.createCommand(this.oMessageList,this.oMessageList.executeMarkAllRead),this.moveToFolderCommand=vt.createCommand(this,vt.emptyFunction,this.isEnableGroupOperations),this.deleteCommand=vt.createCommand(this.oMessageList,this.oMessageList.executeDelete,this.isEnableGroupOperations),this.selectedCount=s.computed(function(){return this.oMessageList.checkedUids().length},this),this.emptyTrashCommand=vt.createCommand(At.MailCache,At.MailCache.executeEmptyTrash,this.oMessageList.isNotEmptyList),this.emptySpamCommand=vt.createCommand(At.MailCache,At.MailCache.executeEmptySpam,this.oMessageList.isNotEmptyList),this.spamCommand=vt.createCommand(this.oMessageList,this.oMessageList.executeSpam,this.isEnableGroupOperations),this.notSpamCommand=vt.createCommand(this.oMessageList,this.oMessageList.executeNotSpam,this.isEnableGroupOperations),this.bVisibleComposeMessage=Et.User.AllowCompose,this.isVisibleReplyTool=s.computed(function(){return this.folderList().currentFolder()&&this.folderList().currentFolderFullName().length>0&&this.folderList().currentFolderType()!==yt.FolderTypes.Drafts&&this.folderList().currentFolderType()!==yt.FolderTypes.Sent},this),this.isVisibleForwardTool=s.computed(function(){return this.folderList().currentFolder()&&this.folderList().currentFolderFullName().length>0&&this.folderList().currentFolderType()!==yt.FolderTypes.Drafts},this),this.isSpamFolder=s.computed(function(){return this.folderList().currentFolderType()===yt.FolderTypes.Spam},this),this.allowedSpamAction=s.computed(function(){var e=Et.Accounts.getCurrent();return e?e.extensionExists("AllowSpamFolderExtension")&&!this.isSpamFolder():!1},this),this.allowedNotSpamAction=s.computed(function(){var e=Et.Accounts.getCurrent();return e?e.extensionExists("AllowSpamFolderExtension")&&this.isSpamFolder():!1},this),this.isTrashFolder=s.computed(function(){return this.folderList().currentFolderType()===yt.FolderTypes.Trash},this),this.jqPanelHelper=null,this.mobileApp=Ft,this.selectedPanel=s.observable(yt.MobilePanel.Items),At.MailCache.currentMessage.subscribe(function(){this.gotoMessagePane()},this)}function lt(){var i=this;this.toAddrDom=s.observable(),this.ccAddrDom=s.observable(),this.bccAddrDom=s.observable(),this.folderList=At.MailCache.folderList,this.folderList.subscribe(function(){this.getMessageOnRoute()},this),this.singleMode=s.observable(Et.SingleMode),this.isDemo=s.observable(Et.User.IsDemo),this.sending=s.observable(!1),this.sending.subscribe(this.sendingAndSavingSubscription,this),this.saving=s.observable(!1),this.saving.subscribe(this.sendingAndSavingSubscription,this),this.oHtmlEditor=new J(!1,this),this.textFocused=this.oHtmlEditor.textFocused,this.visibleBcc=s.observable(!1),this.visibleBcc.subscribe(function(){Mt.toggleClass("screen-compose-bcc",this.visibleCc()),_.defer(_.bind(function(){e(this.bccAddrDom()).inputosaurus("resizeInput")},this))},this),this.visibleCc=s.observable(!1),this.visibleCc.subscribe(function(){Mt.toggleClass("screen-compose-cc",this.visibleCc()),_.defer(_.bind(function(){e(this.ccAddrDom()).inputosaurus("resizeInput")},this))},this),this.visibleCounter=s.observable(!1),this.readingConfirmation=s.observable(!1),this.saveMailInSentItems=s.observable(!0),this.useSaveMailInSentItems=s.observable(!1),this.composeUploaderButton=s.observable(null),this.composeUploaderDropPlace=s.observable(null),this.composeUploaderBodyDragOver=s.observable(!1),this.composeUploaderDragOver=s.observable(!1),this.allowDragNDrop=s.observable(!1),this.uploaderBodyDragOver=s.computed(function(){return this.allowDragNDrop()&&this.composeUploaderBodyDragOver()},this),this.uploaderDragOver=s.computed(function(){return this.allowDragNDrop()&&this.composeUploaderDragOver()},this),this.selectedImportance=s.observable(yt.Importance.Normal),this.selectedSensitivity=s.observable(yt.Sensivity.Nothing),this.senderList=s.observableArray([]),this.visibleFrom=s.computed(function(){return this.senderList().length>1},this),this.selectedSender=s.observable(""),this.selectedFetcherOrIdentity=s.observable(null),this.selectedFetcherOrIdentity.subscribe(function(){this.selectedSender(this.selectedFetcherOrIdentity()?this.selectedFetcherOrIdentity().FETCHER===!0?"fetcher"+this.selectedFetcherOrIdentity().id():vt.pString(this.selectedFetcherOrIdentity().id()):"")},this),this.selectedSender.subscribe(function(){var e=Et.Accounts.getAccount(this.senderAccountId()),t=this.selectedSender(),s=null;this.oHtmlEditor.oCrea&&this.oHtmlEditor.oCrea.editableSave(),0===t.indexOf("fetcher")?e.fetchers()&&(t=t.replace("fetcher",""),s=_.find(e.fetchers().collection(),function(e){return e.id()===vt.pInt(t)})):s=_.find(e.identities(),function(e){return e.id()===vt.pInt(t)}),this.changeSelectedFetcherOrIdentity(s)},this),this.selectedIdentityId=s.observable(0),this.senderAccountId=s.observable(Et.Accounts.currentId()),this.signature=s.observable(""),this.prevSignature=s.observable(null),s.computed(function(){var e=At.MessageSender.getClearSignature(this.senderAccountId(),this.selectedFetcherOrIdentity());null===this.prevSignature()?(this.prevSignature(e),this.signature(e)):(this.prevSignature(this.signature()),this.signature(e),this.oHtmlEditor.changeSignatureContent(this.signature(),this.prevSignature()))},this),this.lockToAddr=s.observable(!1),this.toAddr=s.observable("").extend({reversible:!0}),this.toAddr.subscribe(function(){this.lockToAddr()||(e(this.toAddrDom()).val(this.toAddr()),e(this.toAddrDom()).inputosaurus("refresh"))},this),this.lockCcAddr=s.observable(!1),this.ccAddr=s.observable("").extend({reversible:!0}),this.ccAddr.subscribe(function(){this.lockCcAddr()||(e(this.ccAddrDom()).val(this.ccAddr()),e(this.ccAddrDom()).inputosaurus("refresh"))},this),this.lockBccAddr=s.observable(!1),this.bccAddr=s.observable("").extend({reversible:!0}),this.bccAddr.subscribe(function(){this.lockBccAddr()||(e(this.bccAddrDom()).val(this.bccAddr()),e(this.bccAddrDom()).inputosaurus("refresh"))},this),this.recipientEmails=s.computed(function(){var e=[this.toAddr(),this.ccAddr(),this.bccAddr()].join(",").split(","),t=[];return _.each(e,function(e){var s=vt.trim(e),i=null;""!==s&&(i=vt.getEmailParts(s),i.email&&t.push(i.email))}),t},this),this.subject=s.observable("").extend({reversible:!0}),this.counter=s.observable(0),this.commitedTextBody=s.observable(""),this.plainText=s.observable(!1),this.textBody=s.observable(""),this.textBody.subscribe(function(){this.oHtmlEditor.setText(this.textBody(),this.plainText()),this.commitedTextBody(this.oHtmlEditor.getText())},this),this.toAddrFocused=s.observable(!1),this.toAddrFocused.subscribe(function(){this.toAddrFocused()&&e(this.toAddrDom()).inputosaurus("focus")},this),this.ccAddrFocused=s.observable(!1),this.ccAddrFocused.subscribe(function(){this.ccAddrFocused()&&e(this.ccAddrDom()).inputosaurus("focus")},this),this.bccAddrFocused=s.observable(!1),this.bccAddrFocused.subscribe(function(){this.bccAddrFocused()&&e(this.bccAddrDom()).inputosaurus("focus")},this),this.subjectFocused=s.observable(!1),this.draftUid=s.observable(""),this.draftInfo=s.observableArray([]),this.routeType=s.observable(""),this.routeParams=s.observableArray([]),this.inReplyTo=s.observable(""),this.references=s.observable(""),this.bUploadStatus=!1,this.iUploadAttachmentsTimer=0,this.messageUploadAttachmentsStarted=s.observable(!1),this.messageUploadAttachmentsStarted.subscribe(function(e){t.clearTimeout(i.iUploadAttachmentsTimer),e?i.iUploadAttachmentsTimer=t.setTimeout(function(){i.bUploadStatus=!0,At.Api.showLoading(vt.i18n("COMPOSE/INFO_ATTACHMENTS_LOADING"))},4e3):i.bUploadStatus?i.iUploadAttachmentsTimer=t.setTimeout(function(){i.bUploadStatus=!1,At.Api.hideLoading()},1e3):At.Api.hideLoading()},this),this.attachments=s.observableArray([]),this.attachmentsChanged=s.observable(!1),this.attachments.subscribe(function(){this.attachmentsChanged(!0)},this),this.notUploadedAttachments=s.computed(function(){return _.filter(this.attachments(),function(e){return!e.uploaded()})},this),this.allAttachmentsUploaded=s.computed(function(){return 0===this.notUploadedAttachments().length&&!this.messageUploadAttachmentsStarted()},this),this.notInlineAttachments=s.computed(function(){return _.filter(this.attachments(),function(e){return!e.linked()})},this),this.notInlineAttachments.subscribe(function(){Mt.toggleClass("screen-compose-attachments",this.notInlineAttachments().length>0)},this),this.allowStartSending=s.computed(function(){return!this.saving()},this),this.allowStartSending.subscribe(function(){this.allowStartSending()&&this.requiresPostponedSending()&&(At.MessageSender.sendPostponedMail(this.draftUid()),this.requiresPostponedSending(!1))},this),this.requiresPostponedSending=s.observable(!1),this.oJua=null,this.isDraftsCleared=s.observable(!1),this.autoSaveTimer=-1,this.shown=s.observable(!1),this.shown.subscribe(function(){this.shown()||this.stopAutosaveTimer()},this),this.backToListOnSendOrSave=s.observable(!1),this.enableOpenPgp=Et.User.enableOpenPgp,this.pgpSecured=s.observable(!1),this.pgpSecured.subscribe(function(){this.oHtmlEditor.disabled(this.pgpSecured())},this),this.pgpEncrypted=s.observable(!1),this.fromDrafts=s.observable(!1),this.visibleDoPgpButton=s.computed(function(){return this.enableOpenPgp()&&(!this.pgpSecured()||this.pgpEncrypted()&&this.fromDrafts())},this),this.visibleUndoPgpButton=s.computed(function(){return this.enableOpenPgp()&&this.pgpSecured()&&(!this.pgpEncrypted()||!this.fromDrafts())},this),this.isEnableOpenPgpCommand=s.computed(function(){return this.enableOpenPgp()&&!this.pgpSecured()},this),this.backToListCommand=vt.createCommand(this,this.executeBackToList),this.sendCommand=vt.createCommand(this,this.executeSend,this.isEnableSending),this.saveCommand=vt.createCommand(this,this.executeSaveCommand,this.isEnableSaving),this.openPgpCommand=vt.createCommand(this,this.confirmOpenPgp,this.isEnableOpenPgpCommand),this.messageFields=s.observable(null),this.bottomPanel=s.observable(null),this.editableArea=s.observable(null),this.mobileApp=Ft,this.allowFiles=s.observable(!1),this.dropboxConnected=s.observable(!1),this.allowDropbox=s.computed(function(){return Et.SocialDropbox&&this.dropboxConnected()},this),this.dropboxKey=Et.SocialDropboxKey,this.googleConnected=s.observable(!1),this.allowGoogle=s.computed(function(){return Et.SocialGoogle&&this.googleConnected()},this),t.opener&&setTimeout(function(){t.onbeforeunload=function(){return!i.isChanged()||i.isEmpty()||i.sending()||i.saving()?void 0:(i.beforeHide(t.close),"")}},1e3)}function ht(e){this.oJua=null,this.oParent=e,this.visibility=s.observable(!1),this.importing=s.observable(!1)}function ct(){this.importingHelpLink=At.getHelpLink("ImportingContacts"),this.allowWebMail=Et.App.AllowWebMail,this.loadingList=s.observable(!1),this.loadingViewPane=s.observable(!1),this.showPersonalContacts=s.observable(!1),this.showGlobalContacts=s.observable(!1),this.showSharedToAllContacts=s.observable(!1),this.showAllContacts=s.computed(function(){return 1<[this.showPersonalContacts()?"1":"",this.showGlobalContacts()?"1":"",this.showSharedToAllContacts()?"1":""].join("").length},this),this.recivedAnimShare=s.observable(!1).extend({autoResetToFalse:500}),this.recivedAnimUnshare=s.observable(!1).extend({autoResetToFalse:500}),this.selectedGroupType=s.observable(yt.ContactsGroupListType.Personal),this.selectedGroupInList=s.observable(null),this.selectedGroupInList.subscribe(function(){var e=this.selectedGroupInList();e&&e.selected(!1)},this,"beforeChange"),this.selectedGroupInList.subscribe(function(e){e&&this.showPersonalContacts()&&(e.selected(!0),this.selectedGroupType(yt.ContactsGroupListType.SubGroup),this.requestContactList())},this),this.selectedGroup=s.observable(null),this.selectedContact=s.observable(null),this.selectedGroupContactsList=s.observable(null),this.currentGroupId=s.observable(""),this.oContactModel=new O,this.oGroupModel=new U,this.oContactImportViewModel=new ht(this),this.selectedOldItem=s.observable(null),this.selectedItem=s.computed({read:function(){return this.selectedContact()||this.selectedGroup()||null},write:function(e){e instanceof O?(this.oContactImportViewModel.visibility(!1),this.selectedGroup(null),this.selectedContact(e)):e instanceof U?(this.oContactImportViewModel.visibility(!1),this.selectedContact(null),this.selectedGroup(e),this.currentGroupId(e.idGroup())):(this.selectedGroup(null),this.selectedContact(null)),this.loadingViewPane(!1)},owner:this}),this.sortOrder=s.observable(!0),this.sortType=s.observable(yt.ContactSortType.Name),this.collection=s.observableArray([]),this.contactUidForRequest=s.observable(""),this.collection.subscribe(function(){this.collection().length>0&&""!==this.contactUidForRequest()&&(this.requestContact(this.contactUidForRequest()),this.contactUidForRequest(""))},this),this.isSearchFocused=s.observable(!1),this.searchInput=s.observable(""),this.search=s.observable(""),this.groupFullCollection=s.observableArray([]),this.selectedContact.subscribe(function(e){if(e){var t=e.groups();_.each(this.groupFullCollection(),function(e){e.checked(e&&0<=vt.inArray(e.Id(),t))})}},this),this.selectedGroupType.subscribe(function(e){yt.ContactsGroupListType.All!==e||this.showAllContacts()?yt.ContactsGroupListType.Personal===e&&!this.showPersonalContacts()&&this.showGlobalContacts()?this.selectedGroupType(yt.ContactsGroupListType.Global):yt.ContactsGroupListType.Global===e&&!this.showGlobalContacts()&&this.showPersonalContacts()?this.selectedGroupType(yt.ContactsGroupListType.Personal):(yt.ContactsGroupListType.Personal===e||yt.ContactsGroupListType.Global===e||yt.ContactsGroupListType.SharedToAll===e||yt.ContactsGroupListType.All===e)&&(this.selectedGroupInList(null),this.selectedItem(null),this.selector.listCheckedOrSelected(!1),this.requestContactList()):this.selectedGroupType(yt.ContactsGroupListType.Personal)},this),this.pageSwitcherLocked=s.observable(!1),this.oPageSwitcher=new $(0,Et.User.ContactsPerPage),this.oPageSwitcher.currentPage.subscribe(function(){var e=this.selectedGroupType(),t=e===yt.ContactsGroupListType.SubGroup?this.currentGroupId():"";this.pageSwitcherLocked()||At.Routing.setHash(At.Links.contacts(e,t,this.search(),this.oPageSwitcher.currentPage()))},this),this.currentPage=s.observable(1),this.search.subscribe(function(e){this.searchInput(e)},this),this.searchSubmitCommand=vt.createCommand(this,function(){var e=this.selectedGroupType(),t=e===yt.ContactsGroupListType.SubGroup?this.currentGroupId():"";At.Routing.setHash(At.Links.contacts(e,t,this.searchInput()))}),this.selector=new u(this.collection,_.bind(function(e){if(e){var t=this.selectedGroupType(),s=t===yt.ContactsGroupListType.SubGroup?this.currentGroupId():"";At.Routing.setHash(At.Links.contacts(t,s,this.search(),this.oPageSwitcher.currentPage(),e.sId))}},this),_.bind(this.executeDelete,this),_.bind(this.onContactDblClick,this)),this.checkAll=this.selector.koCheckAll(),this.checkAllIncomplite=this.selector.koCheckAllIncomplete(),this.allowContactsSharing=!!Et.App.AllowContactsSharing,this.isCheckedOrSelected=s.computed(function(){return 0<this.selector.listCheckedOrSelected().length},this),this.isEnableAddContacts=this.isCheckedOrSelected,this.isEnableRemoveContactsFromGroup=this.isCheckedOrSelected,this.isEnableDeleting=this.isCheckedOrSelected,this.isEnableSharing=this.isCheckedOrSelected,this.visibleShareCommand=s.computed(function(){return this.showPersonalContacts()&&this.showSharedToAllContacts()&&this.selectedGroupType()===yt.ContactsGroupListType.Personal},this),this.visibleUnshareCommand=s.computed(function(){return this.showPersonalContacts()&&this.showSharedToAllContacts()&&this.selectedGroupType()===yt.ContactsGroupListType.SharedToAll},this),this.isSelectedGroupTypeNotGlobal=s.computed(function(){return this.selectedGroupType()!==yt.ContactsGroupListType.Global},this),this.newContactCommand=vt.createCommand(this,this.executeNewContact,this.isSelectedGroupTypeNotGlobal),this.newGroupCommand=vt.createCommand(this,this.executeNewGroup),this.addContactsCommand=vt.createCommand(this,vt.emptyFunction,this.isEnableAddContacts),this.deleteCommand=vt.createCommand(this,this.executeDelete,this.isEnableDeleting),this.shareCommand=vt.createCommand(this,this.executeShare,this.isEnableSharing),this.removeFromGroupCommand=vt.createCommand(this,this.executeRemoveFromGroup,this.isEnableRemoveContactsFromGroup),this.importCommand=vt.createCommand(this,this.executeImport),this.exportCSVCommand=vt.createCommand(this,this.executeCSVExport),this.exportVCFCommand=vt.createCommand(this,this.executeVCFExport),this.saveCommand=vt.createCommand(this,this.executeSave),this.updateSharedToAllCommand=vt.createCommand(this,this.executeUpdateSharedToAll,function(){return 1===this.selector.listCheckedOrSelected().length}),this.newMessageCommand=vt.createCommand(this,function(){var e=this.selector.listCheckedOrSelected(),t=[];_.isArray(e)&&0<e.length&&(t=_.map(e,function(e){return e.EmailAndName()}),t=_.compact(t),At.Api.openComposeMessage(t.join(", ")))},function(){return 0<this.selector.listCheckedOrSelected().length}),this.selector.listCheckedOrSelected.subscribe(function(e){this.oGroupModel.newContactsInGroupCount(e.length)},this),this.isLoading=this.loadingList,this.isSearch=s.computed(function(){return""!==this.search()},this),this.isEmptyList=s.computed(function(){return 0===this.collection().length},this),this.inGroup=s.computed(function(){return yt.ContactsGroupListType.SubGroup===this.selectedGroupType()},this),this.searchText=s.computed(function(){return vt.i18n("CONTACTS/INFO_SEARCH_RESULT",{SEARCH:this.search()})},this),this.mobileApp=Ft,this.selectedPanel=s.observable(yt.MobilePanel.Items),this.selectedItem.subscribe(function(){var e=this.selectedItem()&&this.selectedItem()instanceof U&&!this.selectedItem().isNew();this.selectedItem()&&!e?this.gotoViewPane():this.gotoContactList()},this)}function ut(){var i=e(t);this.resizeAll=_.debounce(function(){i.resize()},100),this.oScreens={},this.currentScreen=s.observable(""),this.popupVisibility=s.observable(!1),this.informationScreen=s.observable(null),this.popups=[]}function dt(){this.currentAccountId=Et.Accounts.currentId,this.currentAccountId.subscribe(function(e){var t=Et.Accounts.getAccount(e),s=this.oFolderListItems[e],i={Action:"FolderList",AccountID:e};t&&(t.quotaRecieved(!1),this.messagesLoadingError(!1),s?this.folderList(s):(this.messagesLoading(!0),this.folderList(new L),this.messages([]),this.currentMessage(null),At.Ajax.send(i,this.onFolderListResponse,this)))},this),this.editedAccountId=Et.Accounts.editedId,this.editedAccountId.subscribe(function(e){var t=this.oFolderListItems[e],s={};t?this.editedFolderList(t):this.currentAccountId()!==e&&(this.editedFolderList(new L),s={Action:"FolderList",AccountID:e},At.Ajax.send(s,this.onFolderListResponse,this))},this),this.oFolderListItems={},this.quotaChangeTrigger=s.observable(!1),this.checkMailStarted=s.observable(!1),this.checkMailStartedAccountId=s.observable(0),this.defaultFolderList=s.observable(new L),this.folderList=s.observable(new L),this.folderListLoading=s.observable(!1),this.editedFolderList=s.observable(new L),this.newMessagesCount=s.computed(function(){var e=this.folderList().inboxFolder();return e?e.unseenMessageCount():0},this),this.newMessagesCount.subscribe(function(e){At.mailUnseenCount(e>99?"99+":e)},this),this.messages=s.observableArray([]),this.messages.subscribe(function(){this.messages().length>0&&this.messagesLoadingError(!1)},this),this.uidList=s.observable(new D),this.page=s.observable(1),this.messagesLoading=s.observable(!0),this.messagesLoadingError=s.observable(!1),this.currentMessage=s.observable(null),this.currentMessage.subscribe(function(){this.currentMessage()&&Ct.runPluginHook("view-message",[Et.Accounts.currentId(),this.currentMessage().folder(),this.currentMessage().uid()])},this),this.nextMessageUid=s.computed(function(){var e="",s="",i=null,o=null,n=!1;return this.currentMessage()&&Et.SingleMode&&(n=this.currentMessage().threadPart()&&""!==this.currentMessage().threadParentUid(),i=this.folderList().getFolderByFullName(this.currentMessage().folder()),e=this.currentMessage().uid(),Et.ThreadLevel||n?(Et.ThreadLevel=!0,n&&(o=i.getMessageByUid(this.currentMessage().threadParentUid()),o&&(_.each(o.threadUids(),function(t,i,o){t===e&&i>0&&(s=o[i-1])}),(vt.isUnd(s)||""===s)&&(s=o.uid())))):(_.each(this.uidList().collection(),function(t,i,o){t===e&&i>0&&(s=o[i-1])}),vt.isUnd(s)&&(s=""),""===s&&t.opener&&t.opener.App&&t.opener.App.Prefetcher&&t.opener.App.Prefetcher.prefetchNextPage(e))),s},this),this.prevMessageUid=s.computed(function(){var e=this.currentMessage()?this.currentMessage().uid():"",s="",i=null,o=null,n=!1;return this.currentMessage()&&Et.SingleMode&&(n=this.currentMessage().threadPart()&&""!==this.currentMessage().threadParentUid(),i=this.folderList().getFolderByFullName(this.currentMessage().folder()),e=this.currentMessage().uid(),Et.ThreadLevel||n?(Et.ThreadLevel=!0,n?(o=i.getMessageByUid(this.currentMessage().threadParentUid()),o&&(_.each(o.threadUids(),function(t,i,o){t===e&&i+1<o.length&&(s=o[i+1])}),vt.isUnd(s)&&(s=""))):this.currentMessage().threadCount()>0&&(s=this.currentMessage().threadUids()[0])):(_.each(this.uidList().collection(),function(t,i,o){t===e&&i+1<o.length&&(s=o[i+1])}),vt.isUnd(s)&&(s=""),""===s&&t.opener&&t.opener.App&&t.opener.App.Prefetcher&&t.opener.App.Prefetcher.prefetchPrevPage(e))),s},this),this.deletedDraftMessageUid=s.observable(""),this.aResponseHandlers=[],Et.User.useThreads.subscribe(function(){_.each(this.oFolderListItems,function(e){_.each(e.collection(),function(e){e.markHasChanges(),e.removeAllMessageListsFromCacheIfHasChanges()},this)},this),this.messages([])},this),this.iAutoCheckMailTimer=-1,this.waitForUnseenMessages=s.observable(!0),this.iMessageSetSeenCount=0}function pt(){this.contacts={},this.responseHandlers={},this.vcardAttachments=[],this.recivedAnim=s.observable(!1).extend({autoResetToFalse:500})}function gt(){this.calendars=s.observableArray([]),this.calendarsLoadingStarted=s.observable(!1),this.icalAttachments=[],this.recivedAnim=s.observable(!1).extend({autoResetToFalse:500}),this.calendarSettingsChanged=s.observable(!1),this.calendarChanged=s.observable(!1),this.canRequestCalendarList=s.observable(!1)}function mt(){this.browser=new n,this.favico=t.Favico?new t.Favico({animation:"none"}):null,this.Ajax=new r,this.Screens=new ut,this.Api=new d,this.Storage=new p,this.helpdeskUnseenCount=s.observable(0),this.mailUnseenCount=s.observable(0)
}function ft(){mt.call(this),this.headerTabs=s.observableArray([]),this.screensTitle={},this.Phone=null,this.Routing=new a,this.Links=new l,this.MessageSender=new h,this.Prefetcher=new c,this.MailCache=null,this.ContactsCache=new pt,this.CalendarCache=new gt,this.currentScreen=this.Screens.currentScreen,this.currentScreen.subscribe(this.setTitle,this),this.focused=s.observable(!0),this.focused.subscribe(function(){Et.SingleMode||t.opener||this.setTitle()},this),this.filesRecievedAnim=s.observable(!1).extend({autoResetToFalse:500}),this.init(),this.newMessagesCount=this.MailCache.newMessagesCount,this.newMessagesCount.subscribe(this.setTitle,this),this.currentMessage=this.MailCache.currentMessage,this.currentMessage.subscribe(this.setTitle,this),this.notification=null,this.initHeaderInfo(),this.sessionTimeoutFunctions=[],this.initSessionTimeout()}function bt(){ft.call(this)}var yt={},vt={},St=t.pSevenI18N||{},At={},Ct={},Et=t.pSevenAppData||{},Tt=!1,Ft=!1,Mt=e("html"),It=-1<navigator.userAgent.indexOf("iPhone")||-1<navigator.userAgent.indexOf("iPod")||-1<navigator.userAgent.indexOf("iPad"),wt=-1<navigator.userAgent.toLowerCase().indexOf("android"),Pt=It||wt,Rt=["image/jpeg","image/png","image/gif","text/html","text/plain","text/css","text/rfc822-headers","message/delivery-status","application/x-httpd-php","application/javascript","application/pdf"];if(t.Modernizr&&navigator&&t.Modernizr.addTest("pdf",function(){for(var e=navigator.mimeTypes,t=0,s=e.length;s>t;t++)if("application/pdf"===e[t].type)return!0;return!1}),Date.now||(Date.now=function(){return(new Date).getTime()}),Ft=!0,t.Modernizr&&navigator&&t.Modernizr.addTest("native-android-browser",function(){return"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.34 Safari/534.24"===navigator.userAgent}),n.prototype.getIeVersion=function(){var e=navigator.userAgent.toLowerCase(),t=vt.pInt(e.slice(e.indexOf("msie")+4,e.indexOf(";",e.indexOf("msie")+4)));return this.ie11&&(t=11),t},r.prototype.hasOpenedRequests=function(e){return e=vt.isUnd(e)?"":e,this.requests(_.filter(this.requests(),function(t){var s=t&&4===t.Xhr.readyState,i=!t||0===t.Xhr.readyState&&"abort"===t.Xhr.statusText,o=""===e||t&&t.Parameters.Action===e;return t&&!s&&!i&&o})),this.requests().length>0},r.prototype.isSearchMessages=function(){var e=!1;return _.each(this.requests(),function(t){t&&t.Parameters&&"MessageList"===t.Parameters.Action&&""!==t.Parameters.Search&&(e=!0)},this),e},r.prototype.isAllowedActionWithoutAuth=function(e){var t=["Login","LoginLanguageUpdate","Logout","AccountCreate","SetMobile","RegisterAccount","GetForgotAccountQuestion","ValidateForgotAccountQuestion","ChangeForgotAccountPassword"];return-1!==_.indexOf(t,e)},r.prototype.isAllowedExtAction=function(e){return"SocialRegister"===e||"HelpdeskRegister"===e||"HelpdeskForgot"===e||"HelpdeskLogin"===e||"Logout"===e},r.prototype.doSend=function(t,s,i,o){var n=_.bind(o||null,this,t,s,i),r=_.bind(this.fail,this,t,s,i),a=_.bind(this.always,this,t),l=null;Ct.runPluginHook&&Ct.runPluginHook("ajax-default-request",[t.Action,t]),Et.Token&&(t.Token=Et.Token),this.abortRequests(t),vt.log("Ajax request send",t.Action,t),l=e.ajax({url:this.sUrl,type:"POST",async:!0,dataType:"json",data:t,success:n,error:r,complete:a}),this.requests().push({Parameters:t,Xhr:l})},r.prototype.send=function(e,t,s){var i=void 0===e.AccountID,o=i||Et.Accounts.hasAccountWithId(e.AccountID);e&&(Et.Auth&&o||this.isAllowedActionWithoutAuth(e.Action))&&(i&&"Login"!==e.Action&&(e.AccountID=Et.Accounts.currentId()),this.doSend(e,t,s,this.done))},r.prototype.sendExt=function(e,t,s){var i=["SocialRegister","HelpdeskRegister","HelpdeskForgot","HelpdeskLogin","HelpdeskForgotChangePassword","Logout","CalendarList","EventList","FilesPub"],o=-1!==_.indexOf(i,e.Action);e&&(Et.Auth||o)&&(Et.TenantHash&&(e.TenantHash=Et.TenantHash),this.doSend(e,t,s,this.doneExt))},r.prototype.abortRequests=function(e){switch(e.Action){case"MessageMove":case"MessageDelete":this.abortRequestByActionName("MessageList",{Folder:e.Folder}),this.abortRequestByActionName("Message");break;case"MessageList":case"MessageSetSeen":this.abortRequestByActionName("MessageList",{Folder:e.Folder});break;case"MessageSetAllSeen":this.abortRequestByActionName("MessageList",{Folder:e.Folder}),this.abortRequestByActionName("MessageListByUids",{Folder:e.Folder});break;case"FolderClear":this.abortRequestByActionName("MessageList",{Folder:e.Folder}),this.abortRequestByActionName("FolderCounts");break;case"ContactList":case"GlobalContactList":this.abortRequestByActionName("ContactList"),this.abortRequestByActionName("GlobalContactList");break;case"Contact":case"GlobalContact":this.abortRequestByActionName("Contact"),this.abortRequestByActionName("GlobalContact");break;case"EventUpdate":this.abortRequestByActionName("EventUpdate",{calendarId:e.calendarId,uid:e.uid})}},r.prototype.abortRequestByActionName=function(e,t){var s;_.each(this.requests(),function(i,o){if(s=!1,i&&i.Parameters.Action===e)switch(e){case"MessageList":t.Folder===i.Parameters.Folder&&(s=!0);break;case"EventUpdate":t.calendarId===i.Parameters.calendarId&&t.uid===i.Parameters.uid&&(s=!0);break;default:s=!0}s&&(i.Xhr.abort(),this.requests()[o]=void 0)},this),this.requests(_.compact(this.requests()))},r.prototype.abortAllRequests=function(){_.each(this.requests(),function(e){e&&e.Xhr.abort()},this),this.requests([])},r.prototype.done=function(e,t,s,i,o){var n=this.isAllowedActionWithoutAuth(e.Action),r=Et.Accounts.hasAccountWithId(e.AccountID),a=e.AccountID===Et.Accounts.defaultId();if(vt.log("Ajax request done",e.Action,o,vt.getAjaxDataForLog(e.Action,i),e),n||r){if(i&&!i.Result)switch(i.ErrorCode){case yt.Errors.InvalidToken:n||At.tokenProblem();break;case yt.Errors.AuthError:a&&!n&&(this.abortAllRequests(),At.authProblem())}this.executeResponseHandler(t,s,i,e)}},r.prototype.doneExt=function(e,t,s,i){this.executeResponseHandler(t,s,i,e)},r.prototype.fail=function(e,t,s,i,o,n){var r={Result:!1,ErrorCode:0};switch(vt.log("Ajax request fail",e.Action,o,e),o){case"abort":r={Result:!1,ErrorCode:yt.Errors.NotDisplayedError};break;default:case"error":case"parseerror":r=""===n?{Result:!1,ErrorCode:yt.Errors.NotDisplayedError}:{Result:!1,ErrorCode:yt.Errors.DataTransferFailed}}this.executeResponseHandler(t,s,r,e)},r.prototype.executeResponseHandler=function(e,t,s,i){s||(s={Result:!1,ErrorCode:0}),Ct.runPluginHook&&Ct.runPluginHook("ajax-default-response",[i.Action,s]),"function"==typeof e&&e.apply(t,[s,i])},r.prototype.always=function(e,t,s){_.each(this.requests(),function(t,s){t&&_.isEqual(t.Parameters,e)&&(this.requests()[s]=void 0)},this),this.requests(_.compact(this.requests())),vt.checkConnection(e.Action,s),At.Prefetcher&&"abort"!==s&&!this.hasOpenedRequests()&&At.Prefetcher.start()},yt.Screens={Login:"login",Information:"information",Header:"header",Mailbox:"mailbox",SingleMessageView:"single-message-view",Compose:"compose",SingleCompose:"single-compose",Settings:"settings",Contacts:"contacts",Calendar:"calendar",FileStorage:"files",Helpdesk:"helpdesk",SingleHelpdesk:"single-helpdesk"},yt.CalendarDefaultTab={Day:1,Week:2,Month:3},yt.TimeFormat={F24:"0",F12:"1"},yt.Errors={InvalidToken:101,AuthError:102,DataBaseError:104,LicenseProblem:105,DemoLimitations:106,Captcha:107,AccessDenied:108,CanNotGetMessage:202,ImapQuota:205,NotSavedInSentItems:304,NoRequestedMailbox:305,CanNotChangePassword:502,AccountOldPasswordNotCorrect:503,FetcherIncServerNotAvailable:702,FetcherLoginNotCorrect:703,HelpdeskThrowInWebmail:805,HelpdeskUserNotExists:807,HelpdeskUserNotActivated:808,MailServerError:901,DataTransferFailed:1100,NotDisplayedError:1155},yt.FolderTypes={Inbox:1,Sent:2,Drafts:3,Spam:4,Trash:5,Virus:6,Starred:7,System:9,User:10},yt.FolderFilter={Flagged:"flagged",Unseen:"unseen"},yt.LoginFormType={Email:0,Login:3,Both:4},yt.LoginSignMeType={DefaultOff:0,DefaultOn:1,Unuse:2},yt.ReplyType={Reply:"reply",ReplyAll:"reply-all",Resend:"resend",Forward:"forward"},yt.Importance={Low:5,Normal:3,High:1},yt.Sensivity={Nothing:0,Confidential:1,Private:2,Personal:3},yt.ContactEmailType={Personal:"Personal",Business:"Business",Other:"Other"},yt.ContactPhoneType={Mobile:"Mobile",Personal:"Personal",Business:"Business"},yt.ContactAddressType={Personal:"Personal",Business:"Business"},yt.ContactSortType={Email:"Email",Name:"Name",Frequency:"Frequency"},yt.SaveMail={Hidden:0,Checked:1,Unchecked:2},yt.SettingsTab={Common:"common",EmailAccounts:"accounts",Calendar:"calendar",MobileSync:"mobile_sync",OutLookSync:"outlook_sync",Helpdesk:"helpdesk",Pgp:"pgp",Services:"services"},yt.AccountSettingsTab={Properties:"properties",Signature:"signature",Filters:"filters",Autoresponder:"autoresponder",Forward:"forward",Folders:"folders",FetcherInc:"fetcher-inc",FetcherOut:"fetcher-out",FetcherSig:"fetcher-sig",IdentityProperties:"identity-properties",IdentitySignature:"identity-signature"},yt.ContactsGroupListType={Personal:0,SubGroup:1,Global:2,SharedToAll:3,All:4},yt.IcalType={Request:"REQUEST",Reply:"REPLY",Cancel:"CANCEL",Save:"SAVE"},yt.IcalConfig={Accepted:"ACCEPTED",Declined:"DECLINED",Tentative:"TENTATIVE",NeedsAction:"NEEDS-ACTION"},yt.IcalConfigInt={Accepted:1,Declined:2,Tentative:3,NeedsAction:0},yt.Key={Tab:9,Enter:13,Shift:16,Ctrl:17,Esc:27,Space:32,PageUp:33,PageDown:34,End:35,Home:36,Up:38,Down:40,Left:37,Right:39,Del:46,Six:54,a:65,b:66,c:67,f:70,i:73,k:75,n:78,p:80,q:81,r:82,s:83,u:85,v:86,y:89,z:90,F5:116,Comma:188,Dot:190,Dash:192,Apostrophe:222},yt.MouseKey={Left:0,Middle:1,Right:2},yt.FileStorageType={Personal:0,Corporate:1,Shared:2,GoogleDrive:3,Dropbox:4},yt.FileStorageLinkType={Unknown:0,GoogleDrive:1,Dropbox:2},yt.HelpdeskThreadStates={None:0,Pending:1,Waiting:2,Answered:3,Resolved:4,Deferred:5},yt.HelpdeskPostType={Normal:0,Internal:1,System:2},yt.HelpdeskFilters={All:0,Pending:1,Resolved:2,InWork:3,Open:4,Archived:9},yt.CalendarAccess={Full:0,Write:1,Read:2},yt.CalendarEditRecurrenceEvent={None:0,OnlyThisInstance:1,AllEvents:2},yt.CalendarRepeatPeriod={None:0,Daily:1,Weekly:2,Monthly:3,Yearly:4},yt.PhoneAction={Offline:"offline",OfflineError:"offline_error",OfflineInit:"offline_init",OfflineActive:"offline_active",Online:"online",OnlineActive:"online_active",Incoming:"incoming",IncomingConnect:"incoming_connect",Outgoing:"outgoing",OutgoingConnect:"outgoing_connect",Settings:"settings"},yt.HtmlEditorImageSizes={Small:"small",Medium:"medium",Large:"large",Original:"original"},yt.MobilePanel={Groups:1,Items:2,View:3},yt.PgpAction={Import:"import",Generate:"generate",Encrypt:"encrypt",Sign:"sign",EncryptSign:"encrypt-sign",Verify:"ferify",DecryptVerify:"decrypt-ferify"},yt.SocialType={Unknown:0,Google:1,Dropbox:2,Facebook:3,Twitter:4,Vkontakte:5},yt.notificationPermission={Granted:"granted",Denied:"denied",Default:"default"},vt.inArray=e.inArray,vt.isFunc=e.isFunction,vt.trim=e.trim,vt.emptyFunction=function(){},vt.isUnd=function(e){return void 0===e},vt.isNull=function(e){return null===e},vt.isNormal=function(e){return!vt.isUnd(e)&&!vt.isNull(e)},vt.isNumeric=function(e){return vt.isNormal(e)?/^[1-9]+[0-9]*$/.test(e.toString()):!1},vt.pInt=function(e){var s=t.parseInt(e,10);return isNaN(s)&&(s=0),s},vt.pString=function(e){return vt.isNormal(e)?e.toString():""},vt.isNonEmptyArray=function(e,t){return t=t||1,_.isArray(e)&&t<=e.length},vt.pImport=function(e,t,s){e[t]=s},vt.pExport=function(e,t,s){return vt.isUnd(e[t])?s:e[t]},vt.encodeHtml=function(e){return e?e.toString().replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;"):""},vt.i18n=function(e,t,s,i){var o="",n=vt.isUnd(St[e])?vt.isNormal(s)?s:e:St[e];if(vt.isUnd(i)||(n=function(e,t){var s=vt.getPlural(Et.User.DefaultLanguage,e),i=t.split("|");return i&&i[s]?i[s]:i&&i[0]?i[0]:t}(i,n)),vt.isNormal(t))for(o in t)t.hasOwnProperty(o)&&(n=n.replace("%"+o+"%",t[o]));return n},vt.roundNumber=function(e,t){return Math.round(e*Math.pow(10,t))/Math.pow(10,t)},vt.friendlySize=function(e){var t=1024,s=t*t,i=t*t*t;return e=vt.pInt(e),e>=i?vt.roundNumber(e/i,1)+vt.i18n("MAIN/GIGABYTES"):e>=s?vt.roundNumber(e/s,1)+vt.i18n("MAIN/MEGABYTES"):e>=t?vt.roundNumber(e/t,0)+vt.i18n("MAIN/KILOBYTES"):e+vt.i18n("MAIN/BYTES")},vt.timeOutAction=function(){var e={};return function(s,i,o){vt.isUnd(e[s])&&(e[s]=0),t.clearTimeout(e[s]),e[s]=t.setTimeout(i,o)}}(),vt.$log=null,vt.aLog=[],vt.log=function(){function t(e,t){return"string"==typeof t&&t.length>50?t.substring(0,50):t}if(Et&&Et.ClientDebug&&At.browser&&!At.browser.ie9AndBelow){var s=vt.$log||e('<div style="display: none;"></div>').appendTo("body"),i=[];_.each(arguments,function(e){var s="string"==typeof e?e:JSON.stringify(e,t);0===i.length&&(s=" *** "+s+" *** "),i.push(s)}),i.push(moment().format(" *** D MMMM, YYYY, HH:mm:ss *** ")),vt.$log=s,vt.aLog.length>200&&vt.aLog.shift(),vt.aLog.push(vt.encodeHtml(i.join(", "))),s.html(vt.aLog.join("<br /><br />"))}},vt.getAjaxDataForLog=function(e,t){var s=t;if(t&&t.Result)switch(e){case"MessageList":case"MessageListByUids":s={Result:{Uids:t.Result.Uids,UidNext:t.Result.UidNext,FolderHash:t.Result.FolderHash,MessageCount:t.Result.MessageCount,MessageUnseenCount:t.Result.MessageUnseenCount,MessageResultCount:t.Result.MessageResultCount}};break;case"Message":s={Result:{Folder:t.Result.Folder,Uid:t.Result.Uid,Subject:t.Result.Subject,Size:t.Result.Size,TextSize:t.Result.TextSize,From:t.Result.From,To:t.Result.To}};break;case"Messages":s={Result:_.map(t.Result,function(e){return{Uid:e.Uid,Subject:e.Subject}})}}else t&&(s={Result:t.Result,ErrorCode:t.ErrorCode});return s},vt.getEmailParts=function(e){for(var t=e.indexOf('"'),s=e.indexOf('"',t+1),i=e.indexOf("<",s),o=-1,n=-1,r="",a="";-1!==i;)o=i,i=e.indexOf("<",i+1);return i=o,n=e.indexOf(">",i+1),-1===i?a=vt.trim(e):(r=vt.trim(-1===t?e.substring(0,i):e.substring(t+1,s)),a=vt.trim(e.substring(i+1,n))),{name:r,email:a,FullEmail:e}},vt.isCorrectEmail=function(e){return!!e.match(/^[A-Z0-9\"!#\$%\^\{\}`~&'\+\-=_\.]+@[A-Z0-9\.\-]+$/i)},vt.getIncorrectEmailsFromAddressString=function(e){for(var t=e.replace(/"[^"]*"/g,"").replace(/;/g,",").split(","),s=[],i=0,o=t.length,n="",r=null;o>i;i++)n=vt.trim(t[i]),n.length>0&&(r=vt.getEmailParts(vt.trim(t[i])),vt.isCorrectEmail(r.email)||s.push(r.email));return s},vt.getArrayRecipients=function(e){if(!e)return[];for(var t=[],s=vt.trim(e)+" ",i=0,o=0,n=!1,r='"',a=!1,l=!1,h=0,c=s.length,u="",d="",p=null,g=!1,m=0,f=0;c>h;){switch(u=s.substring(h,h+1)){case"'":case'"':n?r===u&&(n=!1):a||l||(r=u,n=!0);break;case"<":n||a||l||(a=!0);break;case">":a&&(a=!1);break;case"(":n||a||l||(l=!0);break;case")":l&&(l=!1);break;default:if(","!==u&&";"!==u&&h!==c-1)break;if(!a&&!l&&!n){if(o=h!==c-1?h:c,d=s.substring(i,o),vt.trim(d).length>0){for(p=vt.getEmailParts(d),g=!1,m=t.length,f=0;m>f;f++)t[f].email===p.email&&(g=!0);!g&&vt.isCorrectEmail(p.email)&&t.push(p)}i=h+1}}h++}return t},vt.getImportContactsLink=function(){return"?/ImportContacts/"},vt.getExportContactsLink=function(e){return"?/Raw/Contacts"+e+"/"},vt.getExportCalendarLinkByHash=function(e,t){return"?/Raw/Calendar/"+e+"/"+t},vt.getDownloadLinkByHash=function(e,t,s,i){return s=vt.isUnd(s)?!1:!!s,i=vt.isUnd(i)?"":i,"?/Raw/Download/"+e+"/"+t+"/"+(s?"1":"0")+(""===i?"":"/"+i)},vt.getViewLinkByHash=function(e,t,s,i){return s=vt.isUnd(s)?!1:!!s,i=vt.isUnd(i)?"":i,"?/Raw/View/"+e+"/"+t+"/"+(s?"1":"0")+(""===i?"":"/"+i)},vt.getIframeLinkByHash=function(e,t,s,i){return s=vt.isUnd(s)?!1:!!s,i=vt.isUnd(i)?"":i,"?/Raw/Iframe/"+e+"/"+t+"/"+(s?"1":"0")+(""===i?"":"/"+i)},vt.getIframeWrappwer=function(e,s){return"?/Raw/Iframe/"+e+"/"+t.encodeURIComponent(s)+"/"},vt.getViewThumbnailLinkByHash=function(e,t,s,i){return s=vt.isUnd(s)?!1:!!s,i=vt.isUnd(i)?"":i,"?/Raw/Thumbnail/"+e+"/"+t+"/"+(s?"1":"0")+(""===i?"":"/"+i)},vt.getFilestorageDownloadLinkByHash=function(e,t,s){var i="?/Raw/FilesDownload/"+e+"/"+t;return vt.isUnd(s)||(i=i+"/0/"+s),i},vt.getFilestorageViewLinkByHash=function(e,t,s){var i="?/Raw/FilesView/"+e+"/"+t;return vt.isUnd(s)||(i=i+"/0/"+s),i},vt.getFilestorageViewThumbnailLinkByHash=function(e,t,s){var i="?/Raw/FilesThumbnail/"+e+"/"+t;return vt.isUnd(s)||(i=i+"/0/"+s),i},vt.getFilestoragePublicViewLinkByHash=function(e){return"?/Window/Files/0/"+e},vt.getFilestoragePublicDownloadLinkByHash=function(e){return"?/Raw/FilesPub/0/"+e},vt.daysInMonth=function(e,t){return e>0&&13>e&&t>0?new Date(t,e,0).getDate():31},vt.getAppPath=function(){return t.location.protocol+"//"+t.location.host+t.location.pathname},vt.WindowOpener={_iDefaultRatio:.8,_aOpenedWins:[],openMessage:function(e,t){if(e){var s=e.folder(),i=e.uid(),o="",n=null;o=At.Routing.buildHashFromArray(t?[yt.Screens.SingleCompose,"drafts",s,i]:[yt.Screens.SingleMessageView,s,"msg"+i]),n=this.openTab(o)}},openTab:function(e){var s=null;return s=t.open(e,"_blank"),s.focus(),s.name=Et.Accounts.currentId(),this._aOpenedWins.push(s),s},open:function(e,s,i){var o=i?",menubar=yes":",menubar=no",n="location=no,toolbar=no,status=no,scrollbars=yes,resizable=yes"+o,r=null;return s=s.replace(/\W/g,""),n+=this._getSizeParameters(),r=t.open(e,s,n),r.focus(),r.name=Et.Accounts.currentId(),this._aOpenedWins.push(r),r},closeAll:function(){for(var e=this._aOpenedWins.length,t=0,s=null;e>t;t++)s=this._aOpenedWins[t],s.closed||s.close();this._aOpenedWins=[]},_getSizeParameters:function(){var e=t.screen.width,s=Math.ceil(e*this._iDefaultRatio),i=Math.ceil((e-s)/2),o=t.screen.height,n=Math.ceil(o*this._iDefaultRatio),r=Math.ceil((o-n)/2);return",width="+s+",height="+n+",top="+r+",left="+i}},vt.delegateRun=function(e,t,s){e&&e[t]&&e[t].apply(e,_.isArray(s)?s:[])},vt.strRepeat=function(e,t){return new Array(t+1).join(e)},vt.deferredUpdate=function(e,s,i,o){!e.__interval&&s?(e.__state=!0,o(e,!0),e.__interval=t.setInterval(function(){e.__state||(o(e,!1),t.clearInterval(e.__interval),e.__interval=null)},i)):s||(e.__state=!1)},vt.draggableMessages=function(){return e('<div class="draggable draggableMessages"><div class="content"><span class="count-text"></span></div></div>').appendTo("#pSevenHidden")},vt.draggableContacts=function(){return e('<div class="draggable draggableContacts"><div class="content"><span class="count-text"></span></div></div>').appendTo("#pSevenHidden")},vt.removeActiveFocus=function(){if(document&&document.activeElement&&document.activeElement.blur){var t=e(document.activeElement);(t.is("input")||t.is("textarea"))&&document.activeElement.blur()}},vt.uiDropHelperAnim=function(s,i){var o=0,n=0,r=0,a=0,l=0,h=0,c=i.helper.clone().appendTo("#pSevenHidden"),u=e(s.target).find(".animGoal"),d=null;u=e(u[0]?u[0]:s.target),d=u&&u[0]?u.offset():null,d&&(o=t.Math.round(d.left),n=t.Math.round(d.top),l=u.width(),h=u.height(),r=o,l>0&&(r+=t.Math.round(l/2)),a=n,h>0&&(a+=t.Math.round(h/2)),c.animate({left:r+"px",top:a+"px","font-size":"0px",opacity:0},800,"easeOutQuint",function(){e(this).remove()}))},vt.isTextFieldFocused=function(){var e=document&&document.activeElement?document.activeElement:null,t=e?e.tagName:null,s=e&&e.type?e.type.toLowerCase():null,i=e?e.contentEditable:null;return"INPUT"===t&&("text"===s||"password"===s||"email"===s)||"TEXTAREA"===t||"IFRAME"===t||"true"===i},vt.removeSelection=function(){t.getSelection?t.getSelection().removeAllRanges():document.selection&&document.selection.empty()},vt.getMonthNamesArray=function(){for(var e=vt.i18n("DATETIME/MONTH_NAMES").split(" "),t=12,s=e.length;t>s;s++)e[s]="";return e},vt.getPlural=function(e,t){var s=0;switch(t=vt.pInt(t),e){case"Arabic":s=0===t?0:1===t?1:2===t?2:t%100>=3&&10>=t%100?3:t%100>=11?4:5;break;case"Bulgarian":s=1===t?0:1;break;case"Chinese-Simplified":s=0;break;case"Chinese-Traditional":s=1===t?0:1;break;case"Czech":s=1===t?0:t>=2&&4>=t?1:2;break;case"Danish":s=1===t?0:1;break;case"Dutch":s=1===t?0:1;break;case"English":s=1===t?0:1;break;case"Estonian":s=1===t?0:1;break;case"Finish":s=1===t?0:1;break;case"French":s=1===t?0:1;break;case"German":s=1===t?0:1;break;case"Greek":s=1===t?0:1;break;case"Hebrew":s=1===t?0:1;break;case"Hungarian":s=1===t?0:1;break;case"Italian":s=1===t?0:1;break;case"Japanese":s=0;break;case"Korean":s=0;break;case"Latvian":s=t%10===1&&t%100!==11?0:0!==t?1:2;break;case"Lithuanian":s=t%10===1&&t%100!==11?0:t%10>=2&&(10>t%100||t%100>=20)?1:2;break;case"Norwegian":s=1===t?0:1;break;case"Persian":s=0;break;case"Polish":s=1===t?0:t%10>=2&&4>=t%10&&(10>t%100||t%100>=20)?1:2;break;case"Portuguese-Portuguese":s=1===t?0:1;break;case"Portuguese-Brazil":s=1===t?0:1;break;case"Romanian":s=1===t?0:0===t||t%100>0&&20>t%100?1:2;break;case"Russian":s=t%10===1&&t%100!==11?0:t%10>=2&&4>=t%10&&(10>t%100||t%100>=20)?1:2;break;case"Serbian":s=t%10===1&&t%100!==11?0:t%10>=2&&4>=t%10&&(10>t%100||t%100>=20)?1:2;break;case"Spanish":s=1===t?0:1;break;case"Swedish":s=1===t?0:1;break;case"Thai":s=0;break;case"Turkish":s=1===t?0:1;break;case"Ukrainian":s=t%10===1&&t%100!==11?0:t%10>=2&&4>=t%10&&(10>t%100||t%100>=20)?1:2;break;default:s=0}return s},vt.getFileExtension=function(e){var t="",s=e.lastIndexOf(".");return s>-1&&(t=e.substr(s+1)),t},vt.getFileNameWithoutExtension=function(e){var t=e,s=e.lastIndexOf(".");return s>-1&&(t=e.substr(0,s)),t},vt.defaultOptionsAfterRender=function(e,t){t&&(vt.isUnd(t.disable)||s.applyBindingsToNode(e,{disable:t.disable},t))},vt.getDateFormatForMoment=function(e){var t="MM/DD/YYYY";switch(e){case"MM/DD/YYYY":t="MM/DD/YYYY";break;case"DD/MM/YYYY":t="DD/MM/YYYY";break;case"DD Month YYYY":t="DD MMMM YYYY"}return t},vt.getDateFormatForDatePicker=function(e){var t="mm/dd/yy";switch(e){case"MM/DD/YYYY":t="mm/dd/yy";break;case"DD/MM/YYYY":t="dd/mm/yy";break;case"DD Month YYYY":t="dd MM yy"}return t},vt.getDateFormatsForSelector=function(){return _.map(Et.App.DateFormats,function(e){switch(e){case"MM/DD/YYYY":return{name:vt.i18n("DATETIME/DATEFORMAT_MMDDYYYY"),value:e};case"DD/MM/YYYY":return{name:vt.i18n("DATETIME/DATEFORMAT_DDMMYYYY"),value:e};case"DD Month YYYY":return{name:vt.i18n("DATETIME/DATEFORMAT_DDMONTHYYYY"),value:e};default:return{name:e,value:e}}})},vt.getTitleForEvent=function(e){var t=e?vt.trim(e.replace(/[\n\r]/," ")):"",s=t.indexOf(" ",180);return s>=0&&(t=t.substring(0,s)+"..."),t.length>200&&(t=t.substring(0,200)+"..."),t},vt.desktopNotify=function(){var e=[],s=0;return function(i){if(Et.User.DesktopNotifications&&t.Notification&&!At.focused())if(i&&"show"===i.action&&t.Notification.permission!==yt.notificationPermission.Denied){var o,n={body:i.body||"",dir:i.dir||"auto",lang:i.lang||"",tag:i.tag||Math.floor(900*Math.random()+100),icon:i.icon||!1},r=function(){o=new t.Notification(i.title,n),o.onclick=function(){i.callback&&i.callback(),o.close()},o.onshow=function(){},o.onclose=function(){},o.onerror=function(){},i.timeout&&(s=setTimeout(function(){o.close()},i.timeout)),e.push(o)};"granted"===t.Notification.permission?r():"default"===t.Notification.permission&&t.Notification.requestPermission(function(e){"granted"===e&&r()})}else i&&"hide"===i.action?_.each(e,function(t,s){i.tag===t.tag&&(t.close(),e.splice(s,1))}):i&&"hideAll"===i.action&&(_.each(e,function(e){e.close()}),e.length=0)}}(),vt.isRTL=function(){return Mt.hasClass("rtl")},vt.validateFileOrFolderName=function(e){return e=vt.trim(e),""!==e&&!/["\/\\*?<>|:]/.test(e)},vt.shadeColor=function(e,s){var i=!1,o=0,n=0,r=0,a=0;return"#"===e[0]&&(e=e.slice(1),i=!0),o=t.parseInt(e,16),n=(o>>16)+s,n>255?n=255:0>n&&(n=0),r=(o>>8&255)+s,r>255?r=255:0>r&&(r=0),a=(255&o)+s,a>255?a=255:0>a&&(a=0),(i?"#":"")+(a|r<<8|n<<16).toString(16)},vt.extend=function(e,t){var s=function(){};s.prototype=t.prototype,e.prototype=new s,e.prototype.constructor=e},vt.thumbQueue=function(){var e={},t={},s=2;return function(i,o,n){o&&n?!(i in t)||t[i]>0?(i in t||(t[i]=s,e[i]=[]),t[i]--,n(o)):e[i].push({imageSrc:o,imageSrcObserver:n,messageUid:i}):e[i]&&e[i].length&&(e[i][0].imageSrcObserver(e[i][0].imageSrc),e[i].shift())}}(),vt.checkConnection=function(){var e=-1,t=(new Date).getTime(),s=0,i=!1;return setInterval(function(){s=(new Date).getTime(),i=s>t+5e3+1e3,t=s,i&&At.Api.hideError(!0)},5e3),function(t,s){clearTimeout(e),"error"!==s?At.Api.hideError(!0):"Ping"===t?(At.Api.showError(vt.i18n("WARNING/NO_INTERNET_CONNECTION"),!1,!0,!0),e=setTimeout(function(){At.Ajax.send({Action:"Ping"})},6e4)):At.Ajax.send({Action:"Ping"})}}(),vt.loadScript=function(e,s,i,o){var n=document.createElement("script");!vt.isUnd(o)&&s&&(t[o]=s),vt.isUnd(i)&&(i={}),_.each(i,function(e,t){n.setAttribute(t,e)}),n.type="text/javascript",n.src=e,document.body.appendChild(n)},vt.registerMailto=function(e){!t.navigator||!vt.isFunc(t.navigator.registerProtocolHandler)||e&&1===At.Storage.getData("MailtoAsked")||(t.navigator.registerProtocolHandler("mailto",vt.getAppPath()+"#"+yt.Screens.Compose+"/to/%s",""!==Et.App.SiteName?Et.App.SiteName:"WebMail"),At.Storage.setData("MailtoAsked",1))},vt.CustomTooltip={_$Region:null,_$ArrowTop:null,_$Text:null,_$ArrowBottom:null,_iArrowBorderLeft:0,_iArrowMarginLeft:0,_iLeftShift:0,_bInitialized:!1,init:function(){this._bInitialized||(this._$Region=e('<span class="custom_tooltip"></span>').appendTo("body").hide(),this._$ArrowTop=e('<span class="custom_tooltip_arrow top"></span>').appendTo(this._$Region),this._$Text=e('<span class="custom_tooltip_text"></span>').appendTo(this._$Region),this._$ArrowBottom=e('<span class="custom_tooltip_arrow bottom"></span>').appendTo(this._$Region),this._iArrowMarginLeft=vt.pInt(this._$ArrowTop.css("margin-left")),this._iArrowBorderLeft=vt.pInt(this._$ArrowTop.css("border-left-width")),this._iLeftShift=this._iArrowBorderLeft+this._iArrowMarginLeft+vt.pInt(this._$Region.css("margin-left")),this._bInitialized=!0),this._$ArrowTop.show(),this._$ArrowBottom.hide(),this._$ArrowTop.css({"margin-left":this._iArrowMarginLeft+"px"}),this._$ArrowBottom.css({"margin-left":this._iArrowMarginLeft+"px"})},show:function(t,s){this.init();var i=s.offset(),o=Math.round(s.innerWidth()/2),n=this._iLeftShift-o;this._$Text.html(t),this._$Region.fadeIn().css({top:i.top+s.height(),left:i.left-n,right:"auto"}),e("body").height()<this._$Region.height()+this._$Region.offset().top&&(this._$ArrowTop.hide(),this._$ArrowBottom.show(),this._$Region.css({top:i.top-this._$Region.height()})),e("body").width()<this._$Region.outerWidth(!0)+this._$Region.offset().left&&(this._$Region.css({left:"auto",right:0}),this._$ArrowTop.css({"margin-left":o+i.left-this._$Region.offset().left-this._iArrowBorderLeft+"px"}))},hide:function(){this._bInitialized&&this._$Region.hide()}},s.bindingHandlers.command={init:function(t,i,o,n){var r=e(t),a=i();if(!a||!a.enabled||!a.canExecute)throw new Error("You are not using command function");r.addClass("command"),s.bindingHandlers[r.is("form")?"submit":"click"].init.apply(n,arguments)},update:function(t,s){var i=!0,o=e(t),n=s();i=n.enabled(),o.toggleClass("command-not-enabled",!i),i&&(i=n.canExecute(),o.toggleClass("unavailable",!i)),o.toggleClass("command-disabled disable disabled",!i),o.toggleClass("command-disabled",!i)}},s.bindingHandlers.simpleTemplate={init:function(t,i){var o=s.utils.unwrapObservable(i()),n=e("#"+o);n&&n[0]&&e(t).html(n.html().replace(/&lt;script(.*?)&gt;/i,"<script$1>").replace(/&lt;\/script(.*?)&gt;/i,"</script>"))}},s.bindingHandlers.findFocused={init:function(t){var s=e(t),i=null;i=s.find(".catch-focus"),i&&1===i.length&&i[0]&&i.on("blur",function(){s.removeClass("focused")}).on("focus",function(){s.addClass("focused")})}},s.bindingHandlers.findFilled={init:function(t){var s=e(t),i=null,o=null;i=s.find(".catch-filled"),i&&1===i.length&&i[0]&&(o=function(){s.toggleClass("filled",""!==i.val())},o(),_.delay(o,200),i.on("change",o))}},s.bindingHandlers.alert={init:function(e,i){t.alert(s.utils.unwrapObservable(i()))},update:function(e,i){t.alert(s.utils.unwrapObservable(i()))}},s.bindingHandlers.onEnter={init:function(i,o,n,r){s.bindingHandlers.event.init(i,function(){return{keyup:function(s,n){n&&13===t.parseInt(n.keyCode,10)&&(e(i).trigger("change"),o().call(this,s))}}},n,r)}},s.bindingHandlers.onCtrlEnter={init:Ft?null:function(i,o,n,r){s.bindingHandlers.event.init(i,function(){return{keydown:function(s,n){return n&&13===t.parseInt(n.keyCode,10)&&n.ctrlKey?(e(i).trigger("change"),o().call(this,s),!1):!0}}},n,r)}},s.bindingHandlers.onEsc={init:Ft?null:function(i,o,n,r){s.bindingHandlers.event.init(i,function(){return{keyup:function(s,n){n&&27===t.parseInt(n.keyCode,10)&&(e(i).trigger("change"),o().call(this,s))}}},n,r)}},s.bindingHandlers.onFocusSelect={init:function(e,t,i,o){s.bindingHandlers.event.init(e,function(){return{focus:function(){e.select()}}},i,o)}},s.bindingHandlers.onEnterChange={init:function(i,o,n,r){s.bindingHandlers.event.init(i,function(){return{keyup:function(s,o){o&&13===t.parseInt(o.keyCode,10)&&e(i).trigger("change")}}},n,r)}},s.bindingHandlers.fadeIn={update:function(t,i){s.utils.unwrapObservable(i())&&e(t).hide().fadeIn("fast")}},s.bindingHandlers.fadeOut={update:function(t,i){s.utils.unwrapObservable(i())&&e(t).fadeOut()}},s.bindingHandlers.csstext={init:function(t,i){t&&t.styleSheet&&!vt.isUnd(t.styleSheet.cssText)?t.styleSheet.cssText=s.utils.unwrapObservable(i()):e(t).text(s.utils.unwrapObservable(i()))},update:function(t,i){t&&t.styleSheet&&!vt.isUnd(t.styleSheet.cssText)?t.styleSheet.cssText=s.utils.unwrapObservable(i()):e(t).text(s.utils.unwrapObservable(i()))}},s.bindingHandlers.i18n={init:function(t,s){var i=e(t).data("i18n"),o=i?vt.i18n(i):i;if(""!==o)switch(s()){case"value":e(t).val(o);break;case"text":e(t).text(o);break;case"html":e(t).html(o);break;case"title":e(t).attr("title",o);break;case"placeholder":e(t).attr({placeholder:o})}}},s.bindingHandlers.link={init:function(t,i){e(t).attr("href",s.utils.unwrapObservable(i()))}},s.bindingHandlers.title={init:function(t,i){e(t).attr("title",s.utils.unwrapObservable(i()))},update:function(t,i){e(t).attr("title",s.utils.unwrapObservable(i()))}},s.bindingHandlers.initDom={init:function(t,s){if(s())if(_.isArray(s()))for(var i=s(),o=i.length-1;o>=0;o--)i[o](e(t));else s()(e(t))}},s.bindingHandlers.customScrollbar={init:Ft?null:function(t,s){if(!Pt){var i=e(t),o=s();o=o,i.addClass("scroll-wrap").customscroll(o),vt.isUnd(o.reset)||(t._customscroll_reset=_.throttle(function(){i.data("customscroll").reset()},100)),!vt.isUnd(o.scrollToTopTrigger)&&vt.isFunc(o.scrollToTopTrigger.subscribe)&&o.scrollToTopTrigger.subscribe(function(){i.data("customscroll")&&i.data("customscroll").scrollToTop()}),!vt.isUnd(o.scrollToBottomTrigger)&&vt.isFunc(o.scrollToBottomTrigger.subscribe)&&o.scrollToBottomTrigger.subscribe(function(){i.data("customscroll")&&i.data("customscroll").scrollToBottom()}),!vt.isUnd(o.scrollTo)&&vt.isFunc(o.scrollTo.subscribe)&&o.scrollTo.subscribe(function(){i.data("customscroll")&&i.data("customscroll").scrollTo(o.scrollTo())})}},update:Ft?null:function(t,s){Pt||(t._customscroll_reset&&t._customscroll_reset(),vt.isUnd(s().top)||e(t).data("customscroll").vertical.set(s().top))}},s.bindingHandlers.customOptions={init:function(){return{controlsDescendantBindings:!0}},update:function(e,t,i,o,n){for(var r=0,a=0,l=s.utils.arrayMap(s.utils.arrayFilter(e.childNodes,function(e){return e.tagName&&"OPTION"===e.tagName&&e.selected}),function(e){return s.selectExtensions.readValue(e)||e.innerText||e.textContent}),h=e.scrollTop,c=s.utils.unwrapObservable(t());e.length>0;)s.cleanNode(e.options[0]),e.remove(0);if(c){"number"!=typeof c.length&&(c=[c]);var u=i().optionsBind;for(r=0,a=c.length;a>r;r++){var d=document.createElement("OPTION"),p=s.utils.unwrapObservable(c[r]);s.selectExtensions.writeValue(d,p),d.appendChild(document.createTextNode(p)),e.appendChild(d),u&&(d.setAttribute("data-bind",u),s.applyBindings(n.createChildContext(p),d))}var g=e.getElementsByTagName("OPTION"),m=0,f=navigator.userAgent.indexOf("MSIE 6")>=0;for(r=0,a=g.length;a>r;r++)s.utils.arrayIndexOf(l,s.selectExtensions.readValue(g[r]))>=0&&(f?g[r].setAttribute("selected",!0):g[r].selected=!0,m++);e.scrollTop=h,m<l.length&&s.utils.triggerEvent(e,"change")}}},s.bindingHandlers.splitter={init:Ft?null:function(t,s){var i=e(t),o=s();setTimeout(function(){i.splitter(_.defaults(o,{}))
},1)}},s.bindingHandlers.dropdown={init:function(s,i,o,n){var r,a,l,h=e(s),c=_.defaults(i(),{disabled:"disabled",expand:"expand",control:!0,container:".dropdown_content",scrollToTopContainer:".scroll-inner",passClick:!0,trueValue:!0}),u=c.control?h.find(".control"):h,d=h.find(".dropdown_helper"),p=h.find(".dropdown_arrow"),g=e(document),m=!1,f=function(){vt.isUnd(c.callback)||c.callback.call(n,h.hasClass(c.expand)?c.trueValue:!1,h)},b=function(e){e.stopPropagation()},y=function(){c.scrollToTopContainer&&h.find(c.scrollToTopContainer).scrollTop(0)},v=function(e){vt.isUnd(e)&&(e=!h.hasClass(c.expand)),!e&&h.hasClass(c.expand)&&y(),h.toggleClass(c.expand,e)},S=function(s){r=d.offset(),vt.isUnd(r)||(a=r.left+10,l=e(t).width()-(a+d.outerWidth()),l>0&&(l=0),d.css("left",s||l+"px"),p.css("left",s||Math.abs(l?l+parseInt(p.css("margin-left")):0)+"px"))};c.passClick||(h.find(c.container).click(b),u.click(b)),v(!1),c.close&&c.close.subscribe&&c.close.subscribe(function(e){e||(g.unbind("click.dropdown"),v(!1)),f()}),h.on("mousedown",function(t){m=e(t.target).hasClass("customscroll-scrollbar")||e(t.target.parentElement).hasClass("customscroll-scrollbar")}),u.click(function(){h.hasClass(c.disabled)||m||(v(),_.defer(function(){f()}),h.hasClass(c.expand)&&(c.close&&c.close.subscribe&&c.close(!0),_.defer(function(){g.on("click.dropdown",function(e){!c.passClick&&e.button===yt.MouseKey.Right||m||(g.unbind("click.dropdown"),c.close&&c.close.subscribe&&c.close(!1),v(!1),f(),S(0)),m=!1})}),S()))})}},s.bindingHandlers.customSelect={init:function(t,s,i,o){var n=e(t),r=_.defaults(s(),{disabled:"disabled",selected:"selected",expand:"expand",control:!0,input:!1,expandState:function(){}}),a=[],l=r.control?n.find(".control"):n,h=n.find(".dropdown_content"),c=n.find(".link"),u=function(t){_.each(a,function(e){e.removeClass(r.selected)});var s=_.find(r.options,function(e){return e[r.optionsValue]===t});return vt.isUnd(s)?s=r.options[0]:(a[_.indexOf(r.options,s)].addClass(r.selected),c.text(e.trim(s[r.optionsText]))),s[r.optionsValue]},d=function(t){h.empty(),a=[],_.each(t?t:r.options,function(t){var s=e('<span class="item"></span>').text(t[r.optionsText]).data("value",t[r.optionsValue]),i=t.isDisabled;i?s.data("isDisabled",i).addClass("disabled"):s.data("isDisabled",i).removeClass("disabled"),a.push(s),h.append(s)},this)};d(),h.on("click",".item",function(){var t=e(this);t.data("isDisabled")||r.value(t.data("value"))}),!r.input&&r.value&&r.value.subscribe&&(r.value.subscribe(function(){var e=u(r.value());r.value()!==e&&r.value(e)},o),r.value.valueHasMutated()),r.input&&r.value&&r.value.subscribe&&(r.value.subscribe(function(){u(r.value())},o),r.value.valueHasMutated()),r.input&&r.value&&r.value.subscribe&&(r.value.subscribe(function(){u(r.value())},o),r.value.valueHasMutated()),r.alarmOptions&&r.alarmOptions.subscribe(function(){d()},o),r.timeOptions&&r.timeOptions.subscribe(function(e){d(e)},o),n.removeClass(r.expand),l.click(function(){if(!n.hasClass(r.disabled)&&(n.toggleClass(r.expand),r.expandState(n.hasClass(r.expand)),n.hasClass(r.expand))){var t=n.find(".dropdown_content"),s=t.find(".selected");s.position()&&(t.scrollTop(0),t.scrollTop(s.position().top-100)),_.defer(function(){e(document).one("click",function(){n.removeClass(r.expand),r.expandState(!1)})})}})}},s.bindingHandlers.moveToFolderFilter={init:function(t,s){var i=e(t),o=s(),n=e(t).find(o.container),r=_.isArray(o.options)?o.options:o.options(),a=o.value?o.value():"",l=_.find(r,function(e){return e[o.optionsValue]===a});l||(a="",o.value("")),i.removeClass("expand"),n.empty(),_.each(r,function(t){var s=e('<span class="item"></span>').text(t[o.optionsText]).data("value",t[o.optionsValue]);a===t[o.optionsValue]&&s.addClass("selected"),t.jq=s,n.append(s)}),n.on("click",".item",function(){var t=e(this).data("value");o.value(t)}),i.click(function(){i.toggleClass("expand"),i.hasClass("expand")&&_.defer(function(){e(document).one("click",function(){i.removeClass("expand")})})})},update:function(t,s){var i=e(t),o=s(),n=_.isArray(o.options)?o.options:o.options(),r=o.value?o.value():"",a=_.find(n,function(e){return e[o.optionsValue]===r}),l=i.find(".link");_.each(n,function(e){e.jq&&e.jq.toggleClass("selected",r===e[o.optionsValue])}),a&&l.text(e.trim(a[o.optionsText]))}},s.bindingHandlers.contactcard={init:Ft?null:function(t,s){var i=e(t),o=!1,n=_.defaults(s(),{disabled:"disabled",expand:"expand",control:!0}),r=n.control?i.find(".control"):i;void 0!==n.trigger&&void 0!==n.trigger.subscribe&&(i.removeClass(n.expand),r.bind({mouseover:function(){!i.hasClass(n.disabled)&&n.trigger()&&(o=!0,_.delay(function(){o&&(void 0!==n.controlWidth&&void 0!==n.controlWidth.subscribe&&n.controlWidth(r.width()),i.addClass(n.expand))},200))},mouseout:function(){n.trigger()&&(o=!1,_.delay(function(){o||i.removeClass(n.expand)},200))}}))}},s.bindingHandlers.checkmail={update:function(t,s){var i=t.oOptions||null,o=t.jqElement||null,n=t.oIconIE||null,r=s(),a=r.state;void 0!==r.state&&(o||(t.jqElement=o=e(t)),i||(t.oOptions=i=_.defaults(r,{activeClass:"process",duration:800})),vt.deferredUpdate(o,a,i.duration,function(e,s){if(At.browser.ie9AndBelow)if(n||(t.oIconIE=n=o.find(".icon")),!n.__intervalIE&&s){var r=0,a="";n.__intervalIE=setInterval(function(){a="0px -"+20*r+"px",r=7>r?r+1:0,n.css({"background-position":a})},1e3/12)}else n.css({"background-position":"0px 0px"}),clearInterval(n.__intervalIE),n.__intervalIE=null;else e.toggleClass(i.activeClass,s)}))}},s.bindingHandlers.heightAdjust={update:function(t,s){var i=t.jqElement||null,o=0,n=s().location,r=s().delay||400;i||(t.jqElement=i=e(t)),_.delay(function(){_.each(s().elements,function(e){var t=e();t&&(o+=t.is(":visible")?t.outerHeight():0)}),"top"===n||void 0===n?i.css({"padding-top":o,"margin-top":-o}):"bottom"===n&&i.css({"padding-bottom":o,"margin-bottom":-o})},r)}},s.bindingHandlers.triggerInview={update:function(t,s){s().trigger().length<=0||_.defer(function(){var i=e(t),o=i.height(),n=s(),r=null,a=null;n=n,r=i.find(n.selector),r.each(function(){this.$el=e(this),this.inviewHeight=this.$el.height(),this.inview=!1}),a=_.debounce(function(){r.each(function(){var e=this.inview||!1,t=this.$el.position().top+parseInt(this.$el.css("margin-top"),10);t>0&&o>t?e||(this.inview=!0,this.$el.trigger("inview")):this.inview=!1})},2e3),i.scroll(a),a()})}},s.bindingHandlers.watchWidth={init:function(t,s){var i=!1;i||s().subscribe(function(){s()(e(t).outerWidth()),i=!0},this)}},s.bindingHandlers.columnCalc={init:function(s,i){var o=e(s),n=i().prop,r=null,a=0;r=o.find(i().itemSelector),void 0!==r[0]&&(a=r.outerWidth(!0),a=1>=a?1:a,n&&e(t).bind("resize",function(){var e=o.width();n(e>0?Math.floor(e/a):1)}))}},s.bindingHandlers.quickReplyAnim={update:Ft?null:function(t,s){var i=t.jqTextarea||null,o=t.jqStatus||null,n=t.jqButtons||null,r=t.jqElement||null,a=t.oPrevActions||null,l=s(),h=null;h=_.defaults(l,{saveAction:!1,sendAction:!1,activeAction:!1}),r||(t.jqElement=r=e(t),t.jqTextarea=i=r.find("textarea"),t.jqStatus=o=r.find(".status"),t.jqButtons=n=r.find(".buttons"),t.oPrevActions=a={saveAction:null,sendAction:null,activeAction:null}),r.is(":visible")&&(At.browser.ie9AndBelow?(!i||r.defualtHeight||i.defualtHeight||(r.defualtHeight=r.outerHeight(),i.defualtHeight=i.outerHeight(),o.defualtHeight=n.outerHeight(),n.defualtHeight=n.outerHeight()),_.defer(function(){var e=a.activeAction!==h.activeAction,t=a.sendAction!==h.sendAction,s=a.saveAction!==h.saveAction;e&&(h.activeAction?(i.animate({height:i.defualtHeight+50},300),r.animate({"max-height":r.defualtHeight+n.defualtHeight+50},300)):(i.animate({height:i.defualtHeight},300),r.animate({"max-height":r.defualtHeight},300))),(t||s)&&(h.sendAction?(r.animate({"max-height":"30px"},300),o.animate({"max-height":"30px",opacity:1},300)):h.saveAction?r.animate({"max-height":0},300):(r.animate({"max-height":r.defualtHeight+n.defualtHeight+50},300),o.animate({"max-height":0,opacity:0},300)))})):(r.toggleClass("saving",h.saveAction),r.toggleClass("sending",h.sendAction),r.toggleClass("active",h.activeAction))),_.defer(function(){a=h})}},s.extenders.reversible=function(e){var t=e();return e.commit=function(){t=e()},e.revert=function(){e(t)},e.commitedValue=function(){return t},e.changed=function(){return t!==e()},e},s.extenders.autoResetToFalse=function(e,s){return e.iTimeout=0,e.subscribe(function(i){i&&(t.clearTimeout(e.iTimeout),e.iTimeout=t.setTimeout(function(){e.iTimeout=0,e(!1)},vt.pInt(s)))}),e},vt.createCommand=function(e,t,i){var o=t?function(){return o.canExecute&&o.canExecute()?t.apply(e,Array.prototype.slice.call(arguments)):!1}:function(){};return o.enabled=s.observable(!0),i=vt.isUnd(i)?!0:i,o.canExecute=s.computed(vt.isFunc(i)?function(){return o.enabled()&&i.call(e)}:function(){return o.enabled()&&!!i}),o},s.bindingHandlers.autocomplete={init:function(t,s){function i(e){return e.split(/,\s*/)}function o(e){return i(e).pop()}var n=s(),r=e(t);n&&r&&r[0]&&r.autocomplete({minLength:1,autoFocus:!0,source:function(e,t){n(o(e.term),t)},search:function(){var e=o(this.value);return e.length<1?!1:!0},focus:function(){return!1},select:function(e,t){var s=i(this.value),o=null;return s.pop(),s.push(t.item.value),s.push(""),this.value=s.join(", ").slice(0,-2),r.trigger("change"),o=function(e){var t=e.value.length;e.blur(),e.focus(),e.setSelectionRange&&e.setSelectionRange(t,t)},o(r[0]),!1}})}},s.bindingHandlers.autocompleteSimple={init:function(t,s){var i=e(t),o=s(),n=o.callback,r=o.dataAccessor;n&&i&&i[0]&&i.autocomplete({minLength:1,autoFocus:!0,position:{collision:"flip"},source:function(e,t){n(e.term,t)},focus:function(){return!1},select:function(e,t){return _.delay(function(){i.trigger("change")},5),r&&r(t.item),!0}})}},s.bindingHandlers.draggablePlace={init:Ft?null:function(t,i,o,n){if(null===i())return null;var r=o?o():null;e(t).draggable({distance:20,handle:".dragHandle",cursorAt:{top:0,left:0},helper:function(e){return i().call(n,e&&e.target?s.dataFor(e.target):null)},start:r&&r.draggableDragStartCallback?r.draggableDragStartCallback:vt.emptyFunction,stop:r&&r.draggableDragStopCallback?r.draggableDragStopCallback:vt.emptyFunction}).on("mousedown",function(){vt.removeActiveFocus()})}},s.bindingHandlers.droppable={init:Ft?null:function(t,s){var i=s(),o=i.valueFunc,n=i.switchObserv;!1!==o&&e(t).droppable({hoverClass:"droppableHover",drop:function(e,t){o(e,t)}}),n&&o!==!1&&(n.subscribe(function(s){e(t).data().droppable&&e(t).droppable(s?"disable":"enable")},this),n.valueHasMutated())}},s.bindingHandlers.draggable={init:Ft?null:function(t,i){e(t).attr("draggable",s.utils.unwrapObservable(i()))}},s.bindingHandlers.autosize={init:function(t,s){var i=e(t),o=s(),n=i.height(),r=i.outerHeight(),a=i.innerHeight(),l=r-a,h=a-n,c=o.minHeight?o.minHeight:0,u=o.maxHeight?o.maxHeight:0,d=o.scrollableHeight?o.scrollableHeight:1e3,p=o.autosizeTrigger?o.autosizeTrigger:null,g=function(e){var t=0;At.browser.firefox&&(t=2*parseInt(i.css("padding-top"),10)),u?setTimeout(function(){i.prop("scrollHeight")<u?(i.height(c-h-l),i.height(i.prop("scrollHeight")+t-h)):i.height(u-h-l)},100):(e||i.prop("scrollHeight")<d)&&setTimeout(function(){i.height(c-h-l),i.height(i.prop("scrollHeight")+t-h)},100)};i.on("keydown",function(){g()}),i.on("paste",function(){g()}),p&&p.subscribe(function(e){g(e)},this),g()}},s.bindingHandlers.customBind={init:function(e,t,i,o){var n=t(),r=n.onKeydown?n.onKeydown:null,a=n.onKeyup?n.onKeyup:null,l=n.onPaste?n.onPaste:null,h=n.onInput?n.onInput:null,c=n.valueObserver?n.valueObserver:null;s.bindingHandlers.event.init(e,function(){return{keydown:function(t,s){return r&&r.call(this,e,s,c),!0},keyup:function(t,s){return a&&a.call(this,e,s,c),!0},paste:function(t,s){return l&&l.call(this,e,s,c),!0},input:function(t,s){return h&&h.call(this,e,s,c),!0}}},i,o)}},s.bindingHandlers.fade={init:function(t,s){var i=e(t),o=e('<span class="faded"></span>'),n=_.defaults(s(),{color:null,css:"fadeout"}),r=n.color,a=n.css,l=function(e){if(""!==e){var t=h(e),s="rgba("+t.r+","+t.g+","+t.b;c(e,s)}},h=function(e){var t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,s=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return e=e.replace(t,function(e,t,s,i){return t+t+s+s+i+i}),s?{r:parseInt(s[1],16),g:parseInt(s[2],16),b:parseInt(s[3],16)}:null},c=function(e,t){vt.isRTL()?o.css("filter","progid:DXImageTransform.Microsoft.gradient(startColorstr='"+e+"', endColorstr='"+e+"',GradientType=1 )").css("background-image","-webkit-gradient(linear, left top, right top, color-stop(0%,"+t+",1)), color-stop(100%,"+t+",0)))").css("background-image","-moz-linear-gradient(left, "+t+",1)0%, "+t+",0)100%)").css("background-image","-webkit-linear-gradient(left, "+t+"1)0%,"+t+",0)100%)").css("background-image","-o-linear-gradient(left, "+t+",1)0%,"+t+",0)100%)").css("background-image","-ms-linear-gradient(left, "+t+",1)0%,"+t+",0)100%)").css("background-image","linear-gradient(left, "+t+",1)0%,"+t+",0)100%)"):o.css("filter","progid:DXImageTransform.Microsoft.gradient(startColorstr='"+e+"', endColorstr='"+e+"',GradientType=1 )").css("background-image","-webkit-gradient(linear, left top, right top, color-stop(0%,"+t+",0)), color-stop(100%,"+t+",1)))").css("background-image","-moz-linear-gradient(left, "+t+",0)0%, "+t+",1)100%)").css("background-image","-webkit-linear-gradient(left, "+t+",0)0%,"+t+",1)100%)").css("background-image","-o-linear-gradient(left, "+t+",0)0%,"+t+",1)100%)").css("background-image","-ms-linear-gradient(left, "+t+",0)0%,"+t+",1)100%)").css("background-image","linear-gradient(left, "+t+",0)0%,"+t+",1)100%)")};i.parent().addClass(a),i.after(o),void 0!==n.color.subscribe&&(l(r()),r.subscribe(function(e){l(e)},this))}},s.bindingHandlers.highlighter={init:function(i,o,n,r){function a(t){if(A){var s=0,i=c.text(),o=i.split(f),n=[],r='<span class="search_highlight">$&</span>';e.each(o,function(t,s){_.any(m,function(e){return e===s})?e.each(s,function(t,s){n.push(e(s.replace(/(.)/,r)))}):e.each(s,function(e,t){n.push(" "===t?document.createTextNode(" "):document.createTextNode(t))})}),t?c.empty().append(n):(s=l(),c.empty().append(n),h(s))}}function l(){var e,s,o,n,r=0;return"undefined"!=typeof t.getSelection?(e=t.getSelection().getRangeAt(0),s=e.cloneRange(),s.selectNodeContents(i),s.setEnd(e.endContainer,e.endOffset),r=s.toString().length):"undefined"!=typeof document.selection&&"Control"!==document.selection.type&&(o=document.selection.createRange(),n=document.body.createTextRange(),n.moveToElementText(i),n.setEndPoint("EndToEnd",o),r=n.text.length),r}function h(e){var s,o,n;if(!i)return!1;if(document.createRange)s=document.createRange(),s.selectNodeContents(i),s.setStart(i,e),s.setEnd(i,e),o=t.getSelection(),o.removeAllRanges(),o.addRange(s);else{if(i.createTextRange)return n=i.createTextRange(),n.collapse(!0),n.moveEnd(e),n.moveStart(e),n.select(),!0;if(i.setSelectionRange)return i.setSelectionRange(e,e),!0}return!1}var c=e(i),u=o(),d=u.valueObserver?u.valueObserver:null,p=u.highlighterValueObserver?u.highlighterValueObserver:null,g=u.highlightTrigger?u.highlightTrigger:null,m=["from:","to:","subject:","text:","email:","has:","date:","text:","body:"],f=function(){var t="";return e.each(m,function(e,s){t=e?t+"|\\b"+s:t+"\\b"+s}),new RegExp("("+t+")","g")}(),b=function(e){return e.replace(/\xC2\xA0/g," ").replace(/\xA0/g," ").replace(/[\s]+/g," ")},y=-1,v=t.navigator.language||t.navigator.userLanguage,S=["zh","zh-TW","zh-CN","zh-HK","zh-SG","zh-MO","ja","ja-JP","ko","ko-KR","vi","vi-VN","th","th-TH"],A=!_.include(S,v);s.bindingHandlers.event.init(i,function(){return{keydown:function(e,t){return t.keyCode!==yt.Key.Enter},keyup:function(e,t){var s=[yt.Key.Left,yt.Key.Right,yt.Key.Home,yt.Key.End],i=-1!==vt.inArray(t.keyCode,s);return t.keyCode===yt.Key.Shift||t.keyCode===yt.Key.Ctrl||t.keyCode===yt.Key.Dash||t.keyCode===yt.Key.Apostrophe||t.keyCode===yt.Key.Six&&t.shiftKey||i||(t.ctrlKey||y===yt.Key.Ctrl)&&t.keyCode===yt.Key.a||(d(b(c.text())),a(!1)),y=t.keyCode,!0},paste:function(){return setTimeout(function(){d(b(c.text())),a(!1)},0),!0}}},n,r),setTimeout(function(){a(!0)},0),g.notifySubscribers(),g.subscribe(function(e){setTimeout(function(){a(!!e)},0)},this),p.subscribe(function(){c.text(d())},this)}},s.bindingHandlers.quoteText={init:function(t,s,i,o){var n=(e(t),e('<span class="button_quote">'+vt.i18n("HELPDESK/BUTTON_QUOTE")+"</span>")),r=s(),a=r.actionHandler,l=!1,h=null,c="";e("#pSevenContent").append(n),e(document.body).on("click",function(t){l=!!e(t.target).parents(".posts")[0],document.getSelection?(h=document.getSelection(),h&&(c=h.toString())):c=document.selection.createRange().text,l&&""!==c.replace(/[\n\r\s]/,"")?n.css({top:t.clientY+20,left:t.clientX+20}).show():n.hide()}),n.on("click",function(){a.call(o,c)})}},s.bindingHandlers.adjustHeightToContent={init:function(t){var s=e(t),i=null,o=null,n=null;_.delay(_.bind(function(){i=e(_.max(s.find(".title .text"),function(e){return e.offsetWidth})),o=i.parent(),n=o.find(".icon"),s.css("min-width",parseInt(o.css("margin-left"))+parseInt(o.css("padding-left"))+parseInt(n.width())+parseInt(n.css("margin-left"))+parseInt(n.css("margin-right"))+parseInt(n.css("padding-left"))+parseInt(n.css("padding-right"))+parseInt(i.width())+parseInt(i.css("margin-left"))+parseInt(i.css("padding-left"))+10)},this),1)}},s.bindingHandlers.customTooltip={update:Ft?null:function(t,s){var i=vt.i18n(s());e(t).attr("title",i)}},a.prototype.init=function(e){this.defaultScreen=e,o.initialized.removeAll(),o.changed.removeAll(),o.initialized.add(this.parseRouting,this),o.changed.add(this.parseRouting,this),o.init(),o.initialized.removeAll()},a.prototype.finalize=function(){o.dispose(),this.setHashFromString("")},a.prototype.setHashFromString=function(e){var t=location.hash===decodeURIComponent(e);return t||(location.hash=e),t},a.prototype.replaceHashWithoutPart=function(e){var t=location.hash.replace(e,"");this.replaceHashFromString(t)},a.prototype.replaceHashFromString=function(e){location.hash!==e&&location.replace(e)},a.prototype.setHash=function(e){return this.setHashFromString(this.buildHashFromArray(e))},a.prototype.replaceHash=function(e){this.replaceHashFromString(this.buildHashFromArray(e))},a.prototype.setPreviousHash=function(){location.hash=this.previousHash()},a.prototype.buildHashFromArray=function(e){var t=0,s=0,i="";if(_.isArray(e))for(s=e.length;s>t;t++)e[t]=encodeURIComponent(e[t]);else e=[encodeURIComponent(e.toString())];return i=e.join("/"),""!==i&&(i="#"+i),i},a.prototype.getHashFromHref=function(){var e=location.href.indexOf("#"),t="";return-1!==e&&(t=location.href.substr(e+1)),t},a.prototype.isSingleMode=function(){var e=this.getScreenFromHash(),t=e===yt.Screens.SingleMessageView||e===yt.Screens.SingleCompose||e===yt.Screens.SingleHelpdesk;return this.currentScreen=e,t},a.prototype.goDirectly=function(e,t){o.stop(),this.setHash(e),this.parseRouting(t),o.init()},a.prototype.historyBackWithoutParsing=function(){o.stop(),location.hash=this.currentHash(),o.init()},a.prototype.getScreenFromHash=function(){var e=this.getHashFromHref(),t=e.split("/");return decodeURIComponent(t.shift())||this.defaultScreen},a.prototype.parseRouting=function(e){var t=At.Screens.getCurrentScreenModel(),s=_.bind(this.chooseScreen,this,e);t&&vt.isFunc(t.beforeHide)?t.beforeHide(s):s()},a.prototype.chooseScreen=function(t){var s=this.getHashFromHref(),i=s.split("/"),o=decodeURIComponent(i.shift())||this.defaultScreen,n=_.find(yt.Screens,function(e){return e===o},this),r=0,a=i.length;for(o===yt.Screens.Mailbox&&this.lastMailboxHash(s),o===yt.Screens.Helpdesk&&this.lastHelpdeskHash(s),o===yt.Screens.Settings&&this.lastSettingsHash(s),this.previousHash(this.currentHash()),this.currentHash(s);a>r;r++)i[r]=decodeURIComponent(i[r]);switch(e.isArray(t)&&(i=_.union(i,t)),this.currentScreen=o,o){case yt.Screens.SingleMessageView:case yt.Screens.SingleCompose:case yt.Screens.SingleHelpdesk:Et.SingleMode=!0,At.Screens.showCurrentScreen(o,i);break;default:n||(o=this.defaultScreen),Et.SingleMode=!1,At.Screens.showNormalScreen(yt.Screens.Header),At.Screens.showCurrentScreen(o,i);break;case yt.Screens.Mailbox:Et.SingleMode=!1,At.Screens.showNormalScreen(yt.Screens.Header),At.Screens.showCurrentScreen(yt.Screens.Mailbox,i)}},l.prototype.mailbox=function(e,t,s,i,o){var n=[yt.Screens.Mailbox];return t=vt.isNormal(t)?vt.pInt(t):1,s=vt.isNormal(s)?vt.pString(s):"",i=vt.isNormal(i)?vt.pString(i):"",o=vt.isNormal(o)?vt.pString(o):"",e&&""!==e&&n.push(e),o&&""!==o&&n.push("filter:"+o),t>1&&n.push("p"+t),s&&""!==s&&n.push("msg"+s),i&&""!==i&&n.push(i),n},l.prototype.inbox=function(){return this.mailbox()},l.prototype.parseMailbox=function(e){var t="INBOX",s=1,i="",o="",n="",r="",a=0;return vt.isNonEmptyArray(e)&&(t=vt.pString(e[a]),a++,e.length>a&&(r=vt.pString(e[a]),r==="filter:"+yt.FolderFilter.Flagged&&(n=yt.FolderFilter.Flagged,a++),r==="filter:"+yt.FolderFilter.Unseen&&(n=yt.FolderFilter.Unseen,a++)),e.length>a&&(r=vt.pString(e[a]),this.isPageParam(r)&&(s=vt.pInt(r.substr(1)),0>=s&&(s=1),a++)),e.length>a&&(r=vt.pString(e[a]),this.isMsgParam(r)&&(i=r.substr(3),a++)),e.length>a&&(o=vt.pString(e[a]))),{Folder:t,Page:s,Uid:i,Search:o,Filters:n}},l.prototype.contacts=function(e,t,s,i,o){var n=[yt.Screens.Contacts];return"number"==typeof e&&n.push(e),t&&""!==t&&n.push(t),s&&""!==s&&n.push(s),vt.isNumeric(i)&&n.push("p"+i),o&&""!==o&&n.push("cnt"+o),n},l.prototype.parseContacts=function(e){var t=0,s=[yt.ContactsGroupListType.Personal,yt.ContactsGroupListType.SharedToAll,yt.ContactsGroupListType.Global,yt.ContactsGroupListType.All],i=yt.ContactsGroupListType.All,o="",n="",r=1,a="";return vt.isNonEmptyArray(e)&&(i=vt.pInt(e[t]),t++,-1===vt.inArray(i,s)&&(i=yt.ContactsGroupListType.SubGroup),i===yt.ContactsGroupListType.SubGroup&&(e.length>t?(o=vt.pString(e[t]),t++):i=yt.ContactsGroupListType.Personal),e.length>t&&!this.isPageParam(e[t])&&!this.isContactParam(e[t])&&(n=vt.pString(e[t]),t++),e.length>t&&this.isPageParam(e[t])&&(r=vt.pInt(e[t].substr(1)),t++,0>=r&&(r=1)),e.length>t&&this.isContactParam(e[t])&&(a=vt.pString(e[t].substr(3)),t++)),{Type:i,GroupId:o,Search:n,Page:r,Uid:a}},l.prototype.isPageParam=function(e){return"p"===e.substr(0,1)&&/^[1-9][\d]*$/.test(e.substr(1))},l.prototype.isContactParam=function(e){return"cnt"===e.substr(0,3)&&/^[1-9][\d]*$/.test(e.substr(3))},l.prototype.isMsgParam=function(e){return"msg"===e.substr(0,3)&&/^[1-9][\d]*$/.test(e.substr(3))},l.prototype.compose=function(){var e=Et.SingleMode?yt.Screens.SingleCompose:yt.Screens.Compose;return[e]},l.prototype.composeFromMessage=function(e,t,s){var i=Et.SingleMode?yt.Screens.SingleCompose:yt.Screens.Compose;return[i,e,t,s]},l.prototype.composeWithToField=function(e){var t=Et.SingleMode?yt.Screens.SingleCompose:yt.Screens.Compose;return[t,"to",e]},l.prototype.parseToAddr=function(e){var t=decodeURI(vt.pString(e)),s=-1!==t.indexOf("mailto:"),i=[],o=[],n="",r="",a="",l="";return s&&(i=t.replace(/^mailto:/,"").split("?"),t=i[0],2===i.length&&(o=i[1].split("&"),_.each(o,function(e){var t=e.split("=");if(2===t.length)switch(t[0]){case"subject":n=t[1];break;case"cc":r=t[1];break;case"bcc":a=t[1];break;case"body":l=t[1]}}))),{to:t,hasMailto:s,subject:n,cc:r,bcc:a,body:l}},h.prototype.setReplyData=function(e,t){this.replyText(e),this.replyDraftUid(t)},h.prototype.send=function(e,t,s,i,o,n,r){var a="",l=At.MailCache.folderList().sentFolderFullName(),h=At.MailCache.folderList().draftsFolderFullName(),c=Et.Accounts.getCurrent().email(),u=t.To.indexOf(c)>-1||t.Cc.indexOf(c)>-1||t.Bcc.indexOf(c)>-1;switch(Et.User.SaveRepliedToCurrFolder&&!u&&vt.isNonEmptyArray(t.DraftInfo,3)&&(l=t.DraftInfo[2]),t.Action=e,t.ShowReport=i,e){case"MessageSend":a=vt.i18n("COMPOSE/INFO_SENDING"),s&&(t.SentFolder=l),""!==t.DraftUid&&(t.DraftFolder=h);break;case"MessageSave":a=vt.i18n("COMPOSE/INFO_SAVING"),t.DraftFolder=h}i&&At.Api.showLoading(a),r?this.postponedMailData={Parameters:t,MessageSendResponseHandler:o,MessageSendResponseContext:n}:At.Ajax.send(t,o,n)},h.prototype.sendPostponedMail=function(e){var t=this.postponedMailData,s=At.MailCache.folderList().draftsFolderFullName();""!==e&&(t.Parameters.DraftUid=e,t.Parameters.DraftFolder=s),this.postponedMailData&&(At.Ajax.send(t.Parameters,t.MessageSendResponseHandler,t.MessageSendResponseContext),this.postponedMailData=null)},h.prototype.sendReplyMessage=function(e,t,s,i,o,n){var r=null,a=null,l=At.MailCache.currentMessage(),h=!1;At.MailCache.currentMessage()&&(r=this.getReplyDataFromMessage(At.MailCache.currentMessage(),yt.ReplyType.ReplyAll,Et.Accounts.currentId(),At.MessageSender.getFetcherOrIdentityByRecipients(l.oTo.aCollection.concat(l.oCc.aCollection),l.accountId()),!1,t,s),a=At.MessageSender.getFetcherOrIdentityByRecipients(l.oTo.aCollection.concat(l.oCc.aCollection),l.accountId()),h=At.MessageSender.isFetcherOrIdentitySameAsChiefAccount(),a&&!h&&(r.FetcherID=a&&a.FETCHER?a.id():"",r.IdentityID=a&&!a.FETCHER?a.id():""),r.Bcc="",r.Importance=yt.Importance.Normal,r.Sensivity=yt.Sensivity.Nothing,r.ReadingConfirmation="0",r.IsQuickReply="1",r.IsHtml="1",r.Attachments=this.convertAttachmentsForSending(r.Attachments),this.send(e,r,Et.User.getSaveMailInSentItems(),!1,i,o,n))},h.prototype.convertAttachmentsForSending=function(e){var t={};return _.each(e,function(e){t[e.tempName()]=[e.fileName(),e.cid(),e.inline()?"1":"0",e.linked()?"1":"0",e.contentLocation()]}),t},h.prototype.onMessageSendOrSaveResponse=function(e,s){var i,o,n,r=Et.SingleMode?t.opener.App:At,a=!!e.Result;switch(At.Api.hideLoading(),s.Action){case"MessageSave":a?(s.ShowReport&&At.Api.showReport(vt.i18n("COMPOSE/REPORT_MESSAGE_SAVED")),e.Result.NewUid||(Et.User.AllowAutosaveInDrafts=!1)):s.ShowReport&&At.Api.showErrorByCode(e,vt.i18n("COMPOSE/ERROR_MESSAGE_SAVING"));break;case"MessageSend":a||e.ErrorCode===yt.Errors.NotSavedInSentItems?(a||e.ErrorCode!==yt.Errors.NotSavedInSentItems?s.IsQuickReply?At.Api.showReport(vt.i18n("COMPOSE/REPORT_MESSAGE_SENT")):r.Api.showReport(vt.i18n("COMPOSE/REPORT_MESSAGE_SENT")):At.Api.showError(vt.i18n("WARNING/SENT_EMAIL_NOT_SAVED")),_.isArray(s.DraftInfo)&&3===s.DraftInfo.length&&(n=s.DraftInfo[0],o=s.DraftInfo[1],i=s.DraftInfo[2],At.MailCache.markMessageReplied(s.AccountID,i,o,n))):At.Api.showErrorByCode(e,vt.i18n("COMPOSE/ERROR_MESSAGE_SENDING")),s.SentFolder&&r.MailCache.removeMessagesFromCacheForFolder(s.SentFolder)}return s.DraftFolder&&r.MailCache.removeMessagesFromCacheForFolder(s.DraftFolder,s.DraftUid),{Action:s.Action,Result:a,NewUid:e.Result?e.Result.NewUid:""}},h.prototype.getReplyDataFromMessage=function(e,t,s,i,o,n,r){var a={DraftInfo:[],DraftUid:"",To:"",Cc:"",Bcc:"",Subject:"",Attachments:[],InReplyTo:e.messageId(),References:this.getReplyReferences(e)},l=[],h=e.oReplyTo.getFull(),c=e.oTo.getFull();switch((""===h||e.oFrom.getFirstEmail()===e.oReplyTo.getFirstEmail()&&""===e.oReplyTo.getFirstName())&&(h=e.oFrom.getFull()),n&&""!==n||(n=this.replyText(),this.replyText("")),"forward"===t?a.Text=n+this.getForwardMessageBody(e,s,i):"resend"===t?(a.Text=e.getConvertedHtml(),a.Cc=e.cc(),a.Bcc=e.bcc()):a.Text=n+this._getReplyMessageBody(e,s,i,o),r?a.DraftUid=r:(a.DraftUid=this.replyDraftUid(),this.replyDraftUid("")),t){case yt.ReplyType.Reply:a.DraftInfo=[yt.ReplyType.Reply,e.uid(),e.folder()],a.To=h,a.Subject=this.subjectCompiler(e.subject(),!0),l=_.filter(e.attachments(),function(e){return e.linked()});break;case yt.ReplyType.ReplyAll:a.DraftInfo=[yt.ReplyType.ReplyAll,e.uid(),e.folder()],a.To=h,a.Cc=this._getReplyAllCcAddr(e,s,i),a.Subject=this.subjectCompiler(e.subject(),!0),l=_.filter(e.attachments(),function(e){return e.linked()});break;case yt.ReplyType.Resend:a.DraftInfo=[yt.ReplyType.Resend,e.uid(),e.folder(),e.cc(),e.bcc()],a.To=c,a.Subject=e.subject(),l=e.attachments();break;case yt.ReplyType.Forward:a.DraftInfo=[yt.ReplyType.Forward,e.uid(),e.folder()],a.Subject=this.subjectCompiler(e.subject(),!1),l=e.attachments()}return _.each(l,function(e){if(e.getCopy){var t=e.getCopy(),s=Date.now().toString();t.getInThumbQueue(s),a.Attachments.push(t)}}),a},h.prototype.getReplyReferences=function(e){var t=e.references(),s=e.messageId(),i=t.indexOf(s);return-1===i&&(t+=" "+s),t},h.prototype._getReplyMessageBody=function(e,t,s,i){var o=vt.i18n("COMPOSE/REPLY_MESSAGE_TITLE",{DATE:e.oDateModel.getDate(),TIME:e.oDateModel.getTime(),SENDER:vt.encodeHtml(e.oFrom.getFull())}),n="<br /><br />"+this.getSignatureText(t,s,i)+'<br /><br /><div data-anchor="reply-title">'+o+"</div><blockquote>"+e.getConvertedHtml()+"</blockquote>";return n},h.prototype.getClearSignature=function(e,t){var s=Et.Accounts.getAccount(e),i=!!(t?t.useSignature?t.useSignature():t.signatureOptions():!0),o="";return s&&i&&(o=t&&t.accountId()===s.id()?t.signature():s.signature()&&parseInt(s.signature().options())?s.signature().signature():""),o},h.prototype.getSignatureText=function(e,t,s){var i=this.getClearSignature(e,t);return s?'<div data-anchor="signature">'+i+"</div>":"<div>"+i+"</div>"},h.prototype.getFetcherOrIdentityByRecipients=function(e,t){var s=Et.Accounts.getAccount(t),i=this.getAccountFetchersIdentitiesList(s),o=!1,n=null;return _.each(e,function(e){o||_.each(i,function(t){o||e.sEmail!==t.email||e.sName!==t.name||(o=!0,n=t.result)})}),o||_.each(e,function(e){o||_.each(i,function(t){o||e.sEmail!==t.email||(o=!0,n=t.result)})}),n},h.prototype.getAccountFetchersIdentitiesList=function(e){var t=[];return e&&(t.push({email:e.email(),name:e.friendlyName(),result:null}),e.fetchers()&&_.each(e.fetchers().collection(),function(e){t.push({email:e.email(),name:e.userName(),result:e})}),_.each(e.identities(),function(e){t.push({email:e.email(),name:e.friendlyName(),result:e})})),t},h.prototype.getForwardMessageBody=function(e,t,s){var i=vt.encodeHtml(e.oCc.getFull()),o=""!==i?vt.i18n("COMPOSE/FORWARD_MESSAGE_BODY_CC",{CCADDR:i}):"",n=vt.i18n("COMPOSE/FORWARD_MESSAGE_TITLE",{FROMADDR:vt.encodeHtml(e.oFrom.getFull()),TOADDR:vt.encodeHtml(e.oTo.getFull()),CCPART:o,FULLDATE:e.oDateModel.getFullDate(),SUBJECT:e.subject()}),r="<br /><br />"+this.getSignatureText(t,s,!0)+'<br /><br /><div data-anchor="reply-title">'+n+"</div><br /><br />"+e.getConvertedHtml();return r},h.prototype._getReplyAllCcAddr=function(e,t,s){var i=new F,o=_.union(e.oTo.aCollection,e.oCc.aCollection,e.oBcc.aCollection),n=_.find(Et.Accounts.collection(),function(e){return e.id()===t},this),r=new T,a=new T;return r.sEmail=n.email(),a.sEmail=s?s.email():"",i.addCollection(o),i.excludeCollection(_.union(e.oFrom.aCollection,[r,a])),i.getFull()},h._subjectPrefixes=_.map(_.uniq([vt.i18n("COMPOSE/REPLY_PREFIX"),vt.i18n("COMPOSE/FORWARD_PREFIX"),"Re","Fwd","НА","HA"]),function(e){return e.toUpperCase()}),h.prototype.subjectCompiler=function(e,s){e=vt.trim(e.replace(/[\s]+/g," "));var i=!0,o=vt.i18n("COMPOSE/REPLY_PREFIX"),n=vt.i18n("COMPOSE/FORWARD_PREFIX"),r=o.toUpperCase(),a=n.toUpperCase(),l=!1,c=!1,u={},d=[],p=[],g=e.split(":");return u[s?o:n]=1,_.each(g,function(e){if(l)p.push(e);else{e=vt.trim(e);var s=e.toUpperCase();e&&-1<_.indexOf(h._subjectPrefixes,s)?(e=r===s?o:e,e=a===s?n:e,u[e]=vt.isUnd(u[e])?1:0+u[e]+1):(c=!1,e&&!l&&_.each(h._subjectPrefixes,function(i){if(!c){var l="",h=new t.RegExp("^"+i+"\\s?[\\[\\(]([\\d]+)[\\]\\)]$","gi").exec(s);h&&h[1]&&(l=vt.trim(e.replace(/[\s]*[\[\(][\d]+[\]\)]$/g,"")),c=!0,l=r===s?o:l,l=a===s?n:l,u[l]=vt.isUnd(u[l])?vt.pInt(h[1]):0+u[l]+vt.pInt(h[1]))}}),c||(l=!0,p.push(e)))}}),_.each(u,function(e,t){e&&d.push(t+(i&&e>1?"["+e+"]":""))}),vt.trim((d.join(": ")+(d.length?": ":"")+p.join(":")).replace(/[\s]+/g," "))},h.prototype.getHtmlFromText=function(e){return e.replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;").replace(/\r/g,"").replace(/\n/g,"<br />")},h.prototype.isFetcherOrIdentitySameAsChiefAccount=function(e){var t=Et.Accounts.getAccount(e||Et.Accounts.currentId()),s=t.email(),i=t.friendlyName(),o=[];return t.identities()&&(o=t.identities()),t.fetchers()&&(o=o.concat(t.fetchers().collection())),_.any(o,function(e){return e.email()===s&&(e.friendlyName?e.friendlyName()===i:e.userName()===i)})},c.prototype.init=function(){setInterval(_.bind(function(){this.start()
},this),2e3)},c.prototype.start=function(){!Et.Auth||Et.SingleMode||At.Ajax.hasOpenedRequests()||(this.prefetchStarted(!1),this.prefetchAll())},c.prototype.prefetchAll=function(){this.prefetchFetchersIdentities(),Et.App.AllowPrefetch?(this.startMessagesPrefetch(),this.startThreadListPrefetch(),this.doServerInitializations(),this.startOtherPagesPrefetch(),this.prefetchStarredMessageList(),this.prefetchUnseenMessageList(),this.startOtherFoldersPrefetch(),this.prefetchAccountQuota(),this.prefetchCalendarList(),this.initHelpdesk()):(this.doServerInitializations(),this.prefetchStarredMessageList(),this.prefetchAccountQuota(),this.prefetchCalendarList(),this.initHelpdesk())},c.prototype.prefetchCalendarList=function(){this.prefetchStarted()||this.prefetchStarted(At.CalendarCache.firstRequestCalendarList())},c.prototype.prefetchFetchersIdentities=function(){Et.SingleMode||this.fetchersIdentitiesPrefetched()||this.prefetchStarted()||!Et.User.AllowFetcher&&!Et.AllowIdentities||(Et.Accounts.populateFetchersIdentities(),this.fetchersIdentitiesPrefetched(!0),this.prefetchStarted(!0))},c.prototype.initHelpdesk=function(){!Et.User.IsHelpdeskSupported||this.prefetchStarted()||this.helpdeskInitialized()||(At.Screens.initHelpdesk(),this.helpdeskInitialized(!0),this.prefetchStarted(!0))},c.prototype.doServerInitializations=function(){Et.SingleMode||this.prefetchStarted()||this.serverInitializationsDone()||(At.Ajax.send({Action:"DoServerInitializations"}),this.serverInitializationsDone(!0),this.prefetchStarted(!0))},c.prototype.prefetchStarredMessageList=function(){if(!this.prefetchStarted()){var e=At.MailCache.folderList(),t=e?e.inboxFolder():null,s=null;t&&!t.hasChanges()&&(s=At.MailCache.requestMessageList(t.fullName(),1,"",yt.FolderFilter.Flagged,!1,!1),s.RequestStarted&&this.prefetchStarted(!0))}},c.prototype.prefetchUnseenMessageList=function(){if(!this.prefetchStarted()){var e=At.MailCache.folderList(),t=e?e.inboxFolder():null,s=null;t&&!t.hasChanges()&&(s=At.MailCache.requestMessageList(t.fullName(),1,"",yt.FolderFilter.Unseen,!1,!1),s.RequestStarted&&this.prefetchStarted(!0))}},c.prototype.startOtherPagesPrefetch=function(){this.prefetchStarted()||this.startPagePrefetch(At.MailCache.page()+1),this.prefetchStarted()||this.startPagePrefetch(At.MailCache.page()-1)},c.prototype.prefetchNextPage=function(e){var t=At.MailCache.uidList(),s=_.indexOf(t.collection(),e),i=Math.ceil(s/Et.User.MailsPerPage)+1;this.startPagePrefetch(i-1)},c.prototype.prefetchPrevPage=function(e){var t=At.MailCache.uidList(),s=_.indexOf(t.collection(),e),i=Math.ceil((s+1)/Et.User.MailsPerPage)+1;this.startPagePrefetch(i)},c.prototype.startPagePrefetch=function(e){var t=At.MailCache.folderList().currentFolder(),s=At.MailCache.uidList(),i=(e-1)*Et.User.MailsPerPage,o=e>0&&i<s.resultCount(),n=null,r=null;t&&!t.hasChanges()&&o&&(n={folder:t.fullName(),page:e,search:s.search()},t.hasListBeenRequested(n)||(r=At.MailCache.requestMessageList(n.folder,n.page,n.search,"",!1,!1),r&&r.RequestStarted&&this.prefetchStarted(!0)))},c.prototype.startOtherFoldersPrefetch=function(){if(!this.prefetchStarted()){var e=At.MailCache.folderList(),t=e.currentFolderFullName(),s=Et.Accounts.getCurrentFetchersAndFiltersFolderNames(),i=e?[e.inboxFolderFullName(),e.sentFolderFullName(),e.draftsFolderFullName(),e.spamFolderFullName()]:[],o=s.length<3?this.getOtherFolderNames(3-s.length):[],n=_.uniq(_.compact(_.union(i,s,o)));_.each(n,_.bind(function(s){t!==s&&this.startFolderPrefetch(e.getFolderByFullName(s))},this))}},c.prototype.getOtherFolderNames=function(e){var t=At.MailCache.folderList().inboxFolder(),s=t?t.subfolders():[],i=_.filter(At.MailCache.folderList().collection(),function(e){return!e.isSystem()},this),o=_.first(_.union(s,i),e);return _.map(o,function(e){return e.fullName()})},c.prototype.startFolderPrefetch=function(e){if(!this.prefetchStarted()&&e){var t=1,s="",i={folder:e.fullName(),page:t,search:s},o=null;e.hasListBeenRequested(i)||(o=At.MailCache.requestMessageList(i.folder,i.page,i.search,"",!1,!1),o&&o.RequestStarted&&this.prefetchStarted(!0))}},c.prototype.startThreadListPrefetch=function(){if(!this.prefetchStarted()){var e=[],t=At.MailCache.getCurrentFolder();_.each(At.MailCache.messages(),function(s){s.threadCount()>0&&_.each(s.threadUids(),function(s){var i=t.oMessages[s];i&&t.hasThreadUidBeenRequested(s)||e.push(s)})},this),e.length>0&&(e=e.slice(0,Et.User.MailsPerPage),t.addRequestedThreadUids(e),t.loadThreadMessages(e),this.prefetchStarted(!0))}},c.prototype.startMessagesPrefetch=function(){if(!this.prefetchStarted()){var e=At.MailCache.currentAccountId(),t=At.MailCache.getCurrentFolder(),s=0,i=Et.App.MaxPrefetchBodiesSize,o=[],n=null,r=2048,a=function(e){var n=!e.deleted()&&!e.completelyFilled(),a=!_.find(o,function(t){return t===e.uid()},this),l=!t.hasUidBeenRequested(e.uid());i>s&&n&&a&&l&&(o.push(e.uid()),s+=e.trimmedTextSize()+r)};t&&t.selected()&&(_.each(At.MailCache.messages(),a),_.each(t.oMessages,a),o.length>0&&(t.addRequestedUids(o),n={AccountID:e,Action:"Messages",Folder:t.fullName(),Uids:o},At.Ajax.send(n,this.onPrefetchResponse,this),this.prefetchStarted(!0)))}},c.prototype.onPrefetchResponse=function(e,t){var s=At.MailCache.getFolderByFullName(t.AccountID,t.Folder);_.isArray(e.Result)&&_.each(e.Result,function(e){s.parseAndCacheMessage(e,!1,!1)})},c.prototype.prefetchAccountQuota=function(){var e=Et.Accounts.getCurrent(),t=Et.App&&Et.App.ShowQuotaBar,s=e&&!e.quotaRecieved();!this.prefetchStarted()&&t&&s&&(e.updateQuotaParams(),this.prefetchStarted(!0))},u.prototype.iTimer=0,u.prototype.bResetCheckedOnClick=!1,u.prototype.bCheckOnSelect=!1,u.prototype.bUnselectOnCtrl=!1,u.prototype.bDisableMultiplySelection=!1,u.prototype.setBeforeSelectCallback=function(e){this.fBeforeSelectCallback=e||null},u.prototype.getLastOrSelected=function(){var e=0,t=null;return _.each(this.list(),function(s){s.checked()&&e++,s.selected()&&(t=s)}),0===e&&t?t:this.oLast},u.prototype.initOnApplyBindings=function(t,i,o,n,r){e(document).on("keydown",this.onKeydownBinded),this.oListScope=n,this.oScrollScope=r,this.sActionSelector=t,this.sSelectabelSelector=i,this.sCheckboxSelector=o;var a=this,l=function(e,t,s){var i=0,o=0,n=null,r=!1,l=!1,h=[],c=!1;if(t=t?t:null,s&&s.shiftKey&&null!==t&&null!==e&&t!==e)for(h=a.list(),c=t.checked(),i=0,o=h.length;o>i;i++)n=h[i],r=!1,(n===e||n===t)&&(r=!0),r&&(l=!l),(l||r)&&n.checked(c);t&&(a.oLast=t)};e(this.oListScope).on("dblclick",t,function(e){var t=s.dataFor(this);!t||!e||e.ctrlKey||e.altKey||e.shiftKey||a.onDblClick(t)}),Pt&&e(this.oListScope).on("touchstart",t,function(t){if(t){var s=t.timeStamp,i=e(this).data("lastTouch")||s,o=s-i,n=t.originalEvent&&t.originalEvent.touches?t.originalEvent.touches.length:0;e(this).data("lastTouch",s),!o||o>250||n>1||(t.preventDefault(),e(this).trigger("dblclick"))}}),e(this.oListScope).on("click",t,function(e){var t=!0,i=null,o=a.getLastOrSelected(),n=s.dataFor(this);n&&e&&(e.shiftKey?(t=!1,a.bDisableMultiplySelection||(null===a.oLast&&(a.oLast=n),n.checked(!n.checked()),l(o,n,e))):e.ctrlKey&&(t=!1,a.bDisableMultiplySelection||(a.oLast=n,i=a.itemSelected(),!i||i.checked()||n.checked()||i.checked(!0),a.bUnselectOnCtrl&&n===a.itemSelected()?(n.checked(!n.selected()),a.itemSelected(null)):n.checked(!n.checked()))),t&&(a.onSelect(n),a.scrollToSelected()))}),e(this.oListScope).on("click",o,function(e){var t=s.dataFor(this);t&&e&&!a.bDisableMultiplySelection&&(e.shiftKey?(null===a.oLast&&(a.oLast=t),l(a.getLastOrSelected(),t,e)):a.oLast=t),e&&e.stopPropagation&&e.stopPropagation()}),e(this.oListScope).on("dblclick",o,function(e){e&&e.stopPropagation&&e.stopPropagation()})},u.prototype.getResultSelection=function(e,t){var s=this,i=!1,o=!1,n=null,r=this.iFactor,a=!!this.multiplyLineFactor,l=0,h=0,c=[];if(!e&&-1<vt.inArray(t,[this.KeyUp,this.KeyDown,this.KeyLeft,this.KeyRight,yt.Key.PageUp,yt.Key.PageDown,yt.Key.Home,yt.Key.End]))c=this.list(),c&&0<c.length&&(-1<vt.inArray(t,[this.KeyDown,this.KeyRight,yt.Key.PageUp,yt.Key.Home])?n=c[0]:-1<vt.inArray(t,[this.KeyUp,this.KeyLeft,yt.Key.PageDown,yt.Key.End])&&(n=c[c.length-1]));else if(e&&(c=this.list(),h=c?c.length:0,h>0))if(yt.Key.Home===t||yt.Key.PageUp===t||yt.Key.End===t||yt.Key.PageDown===t||a&&(yt.Key.Left===t||yt.Key.Right===t)||!a&&(yt.Key.Up===t||yt.Key.Down===t))_.each(c,function(r){if(!i)switch(t){case s.KeyUp:case s.KeyLeft:e===r?i=!0:n=r;break;case yt.Key.Home:case yt.Key.PageUp:n=r,i=!0;break;case s.KeyDown:case s.KeyRight:o?(n=r,i=!0):e===r&&(o=!0);break;case yt.Key.End:case yt.Key.PageDown:n=r}});else if(a&&this.KeyDown===t){for(;h>l;l++)if(e===c[l]){l+=r,l>h-1&&(l-=r),n=c[l];break}}else if(a&&this.KeyUp===t)for(l=h;l>=0;l--)if(e===c[l]){l-=r,0>l&&(l+=r),n=c[l];break}return n},u.prototype.shiftClickResult=function(e,t,s){if(t){var i=!!this.multiplyLineFactor,o=!1,n=!1;-1<vt.inArray(s,i?[yt.Key.Left,yt.Key.Right]:[yt.Key.Up,yt.Key.Down])?t.checked(!t.checked()):-1<vt.inArray(s,i?[yt.Key.Up,yt.Key.Down,yt.Key.PageUp,yt.Key.PageDown,yt.Key.Home,yt.Key.End]:[yt.Key.Left,yt.Key.Right,yt.Key.PageUp,yt.Key.PageDown,yt.Key.Home,yt.Key.End])&&(n=!t.checked(),_.each(this.list(),function(s){var i=!1;(s===e||t===s)&&(o=!o,i=!0),(o||i)&&(s.checked(n),i=!1)}),i&&e&&(s===yt.Key.Up||s===yt.Key.Down)&&e.checked(!e.checked()))}},u.prototype.clickNewSelectPosition=function(e,s){var i=this,o=0,n=null,r=this.itemSelected();n=this.getResultSelection(r,e),n?(s&&this.shiftClickResult(n,r,e),n&&this.fBeforeSelectCallback?(this.fBeforeSelectCallback(n,function(e){e&&(i.itemSelected(n),o=0===i.iTimer?50:150,0!==i.iTimer&&t.clearTimeout(i.iTimer),i.iTimer=t.setTimeout(function(){i.iTimer=0,i.onSelect(n,!1)},o),this.scrollToSelected())}),this.scrollToSelected()):(this.itemSelected(n),o=0===this.iTimer?50:150,0!==this.iTimer&&t.clearTimeout(this.iTimer),this.iTimer=t.setTimeout(function(){i.iTimer=0,i.onSelect(n)},o),this.scrollToSelected())):r&&s&&-1<vt.inArray(e,[this.KeyUp,this.KeyDown,this.KeyLeft,this.KeyRight,yt.Key.PageUp,yt.Key.PageDown,yt.Key.Home,yt.Key.End])&&r.checked(!r.checked())},u.prototype.onKeydown=function(e){var t=!0,s=0;return this.useKeyboardKeys()&&e&&!vt.isTextFieldFocused()&&(s=e.keyCode,e.ctrlKey||this.KeyUp!==s&&this.KeyDown!==s&&this.KeyLeft!==s&&this.KeyRight!==s&&yt.Key.PageUp!==s&&yt.Key.PageDown!==s&&yt.Key.Home!==s&&yt.Key.End!==s?yt.Key.Del!==s||e.ctrlKey||e.shiftKey?yt.Key.Enter===s?0<this.list().length&&!e.ctrlKey&&(this.onEnter(this.itemSelected()),t=!1):!e.ctrlKey||e.altKey||e.shiftKey||yt.Key.a!==s||(this.checkAll(!(this.checkAll()&&!this.isIncompleteChecked())),t=!1):0<this.list().length&&(this.onDelete(),t=!1):(this.clickNewSelectPosition(s,e.shiftKey),t=!1)),t},u.prototype.onDelete=function(){this.fDeleteCallback.call(this,this.listCheckedOrSelected())},u.prototype.onEnter=function(e){var t=this;e&&this.fBeforeSelectCallback?this.fBeforeSelectCallback(e,function(s){s&&(t.itemSelected(e),t.fEnterCallback.call(this,e))}):(this.itemSelected(e),this.fEnterCallback.call(this,e))},u.prototype.selectionFunc=function(e){this.itemSelected(null),this.bResetCheckedOnClick&&this.listChecked(!1),this.itemSelected(e),this.fSelectCallback.call(this,e)},u.prototype.onSelect=function(e,t){if(t=vt.isUnd(t)?!0:!!t,this.fBeforeSelectCallback&&t){var s=this;this.fBeforeSelectCallback(e,function(t){t&&s.selectionFunc(e)})}else this.selectionFunc(e)},u.prototype.onDblClick=function(e){this.fDblClickCallback.call(this,e)},u.prototype.koCheckAll=function(){return s.computed({read:this.checkAll,write:this.checkAll,owner:this})},u.prototype.koCheckAllIncomplete=function(){return s.computed({read:this.isIncompleteChecked,write:this.isIncompleteChecked,owner:this})},u.prototype.scrollToSelected=function(){if(!this.oListScope||!this.oScrollScope)return!1;var t=20,s=e(this.sSelectabelSelector,this.oScrollScope),i=s.position(),o=this.oScrollScope.height(),n=s.outerHeight();return i&&(i.top<0||i.top+n>o)?(this.oScrollScope.scrollTop(i.top<0?this.oScrollScope.scrollTop()+i.top-t:this.oScrollScope.scrollTop()+i.top-o+n+t),!0):!1},d.prototype.openComposeMessage=function(e){At.Routing.setHash(At.Links.composeWithToField(e))},d.prototype.downloadByUrl=function(s){var i=null;Pt?t.open(s):(i=e('<iframe style="display: none;"></iframe>').appendTo(document.body),i.attr("src",s),setTimeout(function(){i.remove()},6e4))},d.prototype.isPgpSupported=function(){return!(!t.crypto||!t.crypto.getRandomValues)},d.prototype.pgp=function(s,i){if(vt.isFunc(s))if(this.openPgp)s(this.openPgp);else if(this.isPgpSupported()){null!==this.openPgpCallbacks?this.openPgpCallbacks.push(s):s(!1);var o=this;this.openPgpRequest||(this.openPgpRequest=!0,e.ajax({url:"static/js/openpgp.js",dataType:"script",cache:!0,complete:function(){o.openPgp=t.openpgp?new g(t.openpgp,"user_"+(i||"0")+"_"):!1,null!==o.openPgpCallbacks&&_.each(o.openPgpCallbacks,function(e){e(o.openPgp)}),o.openPgpCallbacks=null}}))}else s(!1)},d.prototype.showLoading=function(e){At.Screens.showLoading(e)},d.prototype.hideLoading=function(){At.Screens.hideLoading()},d.prototype.showReport=function(e,t){At.Screens.showReport(e,t)},d.prototype.showError=function(e,t,s,i){At.Screens.showError(e,t,s,i)},d.prototype.hideError=function(e){At.Screens.hideError(e)},d.prototype.showPgpErrorByCode=function(e,t,s){var i=vt.isNonEmptyArray(e.errors)?e.errors:[],o=vt.isNonEmptyArray(e.notices)?e.notices:[],n=[],r=[],a="",l=!1,h=!0;if(_.each(_.union(i,o),function(e){if(2===e.length)switch(e[0]){case f.Enum.GenerateKeyError:a=vt.i18n("OPENPGP/ERROR_GENERATE_KEY");break;case f.Enum.ImportKeyError:a=vt.i18n("OPENPGP/ERROR_IMPORT_KEY");break;case f.Enum.ImportNoKeysFoundError:a=vt.i18n("OPENPGP/ERROR_IMPORT_NO_KEY_FOUNDED");break;case f.Enum.PrivateKeyNotFoundError:case f.Enum.PrivateKeyNotFoundNotice:r.push(e[1]);break;case f.Enum.PublicKeyNotFoundError:h=!1,n.push(e[1]);break;case f.Enum.PublicKeyNotFoundNotice:n.push(e[1]);break;case f.Enum.KeyIsNotDecodedError:t===yt.PgpAction.DecryptVerify?a=vt.i18n("OPENPGP/ERROR_DECRYPT")+" "+vt.i18n("OPENPGP/ERROR_KEY_NOT_DECODED",{USER:e[1]}):(t===yt.PgpAction.Sign||t===yt.PgpAction.EncryptSign)&&(a=vt.i18n("OPENPGP/ERROR_SIGN")+" "+vt.i18n("OPENPGP/ERROR_KEY_NOT_DECODED",{USER:e[1]}));break;case f.Enum.SignError:a=vt.i18n("OPENPGP/ERROR_SIGN");break;case f.Enum.VerifyError:a=vt.i18n("OPENPGP/ERROR_VERIFY");break;case f.Enum.EncryptError:a=vt.i18n("OPENPGP/ERROR_ENCRYPT");break;case f.Enum.DecryptError:a=vt.i18n("OPENPGP/ERROR_DECRYPT");break;case f.Enum.SignAndEncryptError:a=vt.i18n("OPENPGP/ERROR_ENCRYPT_OR_SIGN");break;case f.Enum.VerifyAndDecryptError:a=vt.i18n("OPENPGP/ERROR_DECRYPT_OR_VERIFY");break;case f.Enum.DeleteError:a=vt.i18n("OPENPGP/ERROR_DELETE_KEY");break;case f.Enum.VerifyErrorNotice:a=vt.i18n("OPENPGP/ERROR_VERIFY");break;case f.Enum.NoSignDataNotice:l=!0}}),n.length>0?(n=_.without(n,""),n.length>0?a=vt.i18n("OPENPGP/ERROR_NO_PUBLIC_KEYS_FOR_USERS_PLURAL",{USERS:n.join(", ")},null,n.length):t===yt.PgpAction.Verify&&(a=vt.i18n("OPENPGP/ERROR_NO_PUBLIC_KEY_FOUND_FOR_VERIFY")),h&&""!==a&&(a+=" "+vt.i18n("OPENPGP/ERROR_MESSAGE_WAS_NOT_VERIFIED"))):r.length>0&&(r=_.without(r,""),r.length>0?a=vt.i18n("OPENPGP/ERROR_NO_PRIVATE_KEYS_FOR_USERS_PLURAL",{USERS:r.join(", ")},null,r.length):t===yt.PgpAction.DecryptVerify&&(a=vt.i18n("OPENPGP/ERROR_NO_PRIVATE_KEY_FOUND_FOR_DECRYPT"))),""===a&&!l){switch(t){case yt.PgpAction.Generate:a=vt.i18n("OPENPGP/ERROR_GENERATE_KEY");break;case yt.PgpAction.Import:a=vt.i18n("OPENPGP/ERROR_IMPORT_KEY");break;case yt.PgpAction.DecryptVerify:a=vt.i18n("OPENPGP/ERROR_DECRYPT");break;case yt.PgpAction.Verify:a=vt.i18n("OPENPGP/ERROR_VERIFY");break;case yt.PgpAction.Encrypt:a=vt.i18n("OPENPGP/ERROR_ENCRYPT");break;case yt.PgpAction.EncryptSign:a=vt.i18n("OPENPGP/ERROR_ENCRYPT_OR_SIGN");break;case yt.PgpAction.Sign:a=vt.i18n("OPENPGP/ERROR_SIGN")}a=s}return""!==a&&At.Api.showError(a),l},d.prototype.showErrorByCode=function(e,t){var s=e.ErrorCode,i=e.ErrorMessage||"";switch(""!==i&&(i=" ("+i+")"),s){default:t&&t.length>0?this.showError(t+i):""!==i&&this.showError(i);break;case yt.Errors.AuthError:this.showError(vt.i18n("WARNING/LOGIN_PASS_INCORRECT")+i);break;case yt.Errors.DemoLimitations:this.showError(vt.i18n("DEMO/WARNING_THIS_FEATURE_IS_DISABLED")+i);break;case yt.Errors.Captcha:this.showError(vt.i18n("WARNING/CAPTCHA_IS_INCORRECT")+i);break;case yt.Errors.CanNotGetMessage:this.showError(vt.i18n("MESSAGE/ERROR_MESSAGE_DELETED")+i);break;case yt.Errors.NoRequestedMailbox:this.showError(t+" "+vt.i18n("COMPOSE/ERROR_INVALID_ADDRESS",{ADDRESS:e.Mailbox})+i);break;case yt.Errors.CanNotChangePassword:this.showError(vt.i18n("WARNING/UNABLE_CHANGE_PASSWORD")+i);break;case yt.Errors.AccountOldPasswordNotCorrect:this.showError(vt.i18n("WARNING/CURRENT_PASSWORD_NOT_CORRECT")+i);break;case yt.Errors.FetcherIncServerNotAvailable:this.showError(vt.i18n("WARNING/FETCHER_SAVE_ERROR")+i);break;case yt.Errors.FetcherLoginNotCorrect:this.showError(vt.i18n("WARNING/FETCHER_SAVE_ERROR")+i);break;case yt.Errors.HelpdeskUserNotExists:this.showError(vt.i18n("HELPDESK/ERROR_FORGOT_NO_ACCOUNT")+i);break;case yt.Errors.MailServerError:this.showError(vt.i18n("WARNING/CANT_CONNECT_TO_SERVER")+i);break;case yt.Errors.DataTransferFailed:this.showError(vt.i18n("WARNING/DATA_TRANSFER_FAILED")+i);break;case yt.Errors.NotDisplayedError:""!==i&&this.showError(i)}},Ct.addScreenToHeader=function(e,t,s,i,o){At.addScreenToHeader(e,t,s,i,o,!0)},Ct.aSettingsTabs=[],Ct.addSettingsTab=function(e){e.prototype.TabName&&(yt.SettingsTab[e.prototype.TabName]=e.prototype.TabName,Ct.aSettingsTabs.push(e))},Ct.getPluginsSettingsTabs=function(){return Ct.aSettingsTabs},Ct.getSetting=function(e){return Et.App[e]},Ct.getPluginSettings=function(e){return Et&&Et.Plugins?Et.Plugins[e]:null},Ct.oPluginHooks={},Ct.addPluginHook=function(t,s){vt.isFunc(s)&&(e.isArray(this.oPluginHooks[t])||(this.oPluginHooks[t]=[]),this.oPluginHooks[t].push(s))},Ct.runPluginHook=function(t,s){e.isArray(this.oPluginHooks[t])&&(s=s||[],_.each(this.oPluginHooks[t],function(e){e.apply(null,s)}))},Ct.sendAjaxRequest=function(e,t,s){At.Ajax.send(e,t,s)},Ct.i18n=vt.i18n,Ct.getArrayRecipients=vt.getArrayRecipients,Ct.getEmailParts=vt.getEmailParts,Ct.showAlertPopup=function(e){At.Screens.showPopup(b,[e])},Ct.showConfirmPopup=function(e,t){At.Screens.showPopup(y,[e,t])},Ct.showReport=function(e,t){At.Screens.showReport(e,t)},Ct.showError=function(e){At.Screens.showError(e)},Ct.getPrimaryAccountData=function(){var e=Et.Accounts.getDefault();return{Id:e.id(),Email:e.email(),FriendlyName:e.friendlyName()}},Ct.getCurrentAccountData=function(){var e=Et.Accounts.getCurrent();return{Id:e.id(),Email:e.email(),FriendlyName:e.friendlyName()}},Ct.isMobile=function(){return Et.IsMobile},p.prototype.setData=function(e,t){Data.setVar(e,t)},p.prototype.removeData=function(e){Data.setVar(e,"")},p.prototype.getData=function(e){return Data.getVar(e)},p.prototype.hasData=function(e){return Data.hasVar(e)},g.prototype.pgp=null,g.prototype.pgpKeyring=null,g.prototype.keys=[],g.prototype.getKeys=function(){return this.keys()},g.prototype.getKeysObservable=function(){return this.keys},g.prototype.reloadKeysFromStorage=function(){var e=[],t=this.pgpKeyring.getAllKeys();_.each(t,function(t){t&&t.primaryKey&&e.push(new m(t))}),this.keys(e)},g.prototype.convertToNativeKeys=function(e){return _.map(e,function(e){return e&&e.pgpKey?e.pgpKey:e})},g.prototype.cloneKey=function(e){var t=null;return e&&(t=this.pgp.key.readArmored(e.armor()),t&&!t.err&&t.keys&&t.keys[0]?(t=t.keys[0],t&&t.primaryKey||(t=null)):t=null),t},g.prototype.decryptKeyHelper=function(e,t,s,i){if(t)try{t.decrypt(vt.pString(s)),t&&t.primaryKey&&t.primaryKey.isDecrypted||e.addError(f.Enum.KeyIsNotDecodedError,i||"")}catch(o){e.addExceptionMessage(o,f.Enum.KeyIsNotDecodedError,i||"")}else e.addError(f.Enum.KeyIsNotDecodedError,i||"")},g.prototype.verifyMessageHelper=function(e,t,s){var i=!1,o=null,n=[],r=[],a=[];if(s&&s.getSigningKeyIds)if(r=s.getSigningKeyIds(),r&&0<r.length)if(a=this.findKeysByEmails([t],!0),a&&0!==a.length){n=[];try{n=s.verify(this.convertToNativeKeys(a))}catch(l){e.addNotice(f.Enum.VerifyErrorNotice,t)}n&&0<n.length&&(o=_.find(n,function(e){return e&&e.keyid&&e.valid}),o&&o.keyid&&a&&a[0]&&o.keyid.toHex().toLowerCase()===a[0].getId()?i=!0:e.addNotice(f.Enum.VerifyErrorNotice,t))}else e.addNotice(f.Enum.PublicKeyNotFoundNotice,t);else e.addNotice(f.Enum.NoSignDataNotice);else e.addError(f.Enum.UnknownError);return i||e.hasNotices()||e.addNotice(f.Enum.VerifyErrorNotice),i},g.prototype.generateKey=function(e,t,s){var i=new f,o=null;try{o=this.pgp.generateKeyPair({userId:e,numBits:vt.pInt(s),passphrase:vt.trim(t)})}catch(n){i.addExceptionMessage(n)}if(o&&o.privateKeyArmored)try{this.pgpKeyring.privateKeys.importKey(o.privateKeyArmored),this.pgpKeyring.publicKeys.importKey(o.publicKeyArmored),this.pgpKeyring.store()}catch(n){i.addExceptionMessage(n,f.Enum.GenerateKeyError)}else i.addError(f.Enum.GenerateKeyError);return this.reloadKeysFromStorage(),i},g.prototype.splitKeys=function(e){var t=[],s=0,i=30,o=null,n=vt.trim(e),r=/[\-]{3,6}BEGIN[\s]PGP[\s](PRIVATE|PUBLIC)[\s]KEY[\s]BLOCK[\-]{3,6}[\s\S]+?[\-]{3,6}END[\s]PGP[\s](PRIVATE|PUBLIC)[\s]KEY[\s]BLOCK[\-]{3,6}/gi;for(n=n.replace(/[\r\n]([a-zA-Z0-9]{2,}:[^\r\n]+)[\r\n]+([a-zA-Z0-9\/\\+=]{10,})/g,"\n$1---xyx---$2").replace(/[\n\r]+/g,"\n").replace(/---xyx---/g,"\n\n");;){if(o=r.exec(n),!o||0>i)break;o[0]&&o[1]&&o[2]&&o[1]===o[2]&&("PRIVATE"===o[1]||"PUBLIC"===o[1])&&(t.push([o[1],o[0]]),s++),i--}return t},g.prototype.importKeys=function(e){e=vt.trim(e);var t=0,s=0,i=new f,o=null,n=[];if(!e)return i.addError(f.Enum.InvalidArgumentErrors);for(n=this.splitKeys(e),t=0;t<n.length;t++)if(o=n[t],"PRIVATE"===o[0])try{this.pgpKeyring.privateKeys.importKey(o[1]),s++}catch(r){i.addExceptionMessage(r,f.Enum.ImportKeyError,"private")}else if("PUBLIC"===o[0])try{this.pgpKeyring.publicKeys.importKey(o[1]),s++}catch(r){i.addExceptionMessage(r,f.Enum.ImportKeyError,"public")}return s>0?this.pgpKeyring.store():i.addError(f.Enum.ImportNoKeysFoundError),this.reloadKeysFromStorage(),i},g.prototype.getArmorInfo=function(e){e=vt.trim(e);var t=0,s=0,i=null,o=[],n=null,r=[];if(!e)return!1;for(r=this.splitKeys(e),t=0;t<r.length;t++)if(n=r[t],"PRIVATE"===n[0])try{i=this.pgp.key.readArmored(n[1]),i&&!i.err&&i.keys&&i.keys[0]&&o.push(new m(i.keys[0])),s++}catch(a){o.push(null)}else if("PUBLIC"===n[0])try{i=this.pgp.key.readArmored(n[1]),i&&!i.err&&i.keys&&i.keys[0]&&o.push(new m(i.keys[0])),s++}catch(a){o.push(null)}return o},g.prototype.findKeyByID=function(e,t){t=!!t,e=e.toLowerCase();var s=_.find(this.keys(),function(s){var i=!1,o=null;return s&&t===s.isPublic()&&(o=s.pgpKey.getKeyIds(),o&&(i=_.find(o,function(t){return t&&t.toHex&&e===t.toHex().toLowerCase()}))),!!i});return s?s:null},g.prototype.findKeysByEmails=function(e,t,s){t=!!t;var i=[],o=this.keys();return _.each(e,function(e){var n=_.find(o,function(s){return s&&t===s.isPublic()&&e===s.getEmail()});n?i.push(n):s&&s.addError(t?f.Enum.PublicKeyNotFoundError:f.Enum.PrivateKeyNotFoundError,e)}),i},g.prototype.decryptAndVerify=function(e,t,s,i){var o=this,n=null,r=null,a=null,l=null,h=null,c=new f,u=[];if(n=this.pgp.message.readArmored(e),n&&n.decrypt)if(u=n.getEncryptionKeyIds(),u&&(a=null,r=null,_.each(u,function(e){r||(r=o.findKeyByID(e.toHex(),!1),r&&t!==r.getEmail()&&(r=null))}),r&&(a=r),a||_.each(u,function(e){a||(a=o.findKeyByID(e.toHex(),!1))})),a){if(l=this.cloneKey(this.convertToNativeKeys([a])[0]),this.decryptKeyHelper(c,l,i,a.getEmail()),l&&!c.hasErrors())try{h=n.decrypt(l)}catch(d){c.addExceptionMessage(d,f.Enum.DecryptError),h=null}h&&!c.hasErrors()&&(this.verifyMessageHelper(c,s,h),c.result=h.getText())}else c.addError(f.Enum.PrivateKeyNotFoundError);return c},g.prototype.verify=function(e,t){var s=null,i=new f;return s=this.pgp.cleartext.readArmored(e),s&&s.getText&&s.verify?(this.verifyMessageHelper(i,t,s),i.result=s.getText()):i.addError(f.Enum.CanNotReadMessage),i},g.prototype.encrypt=function(e,t){var s=new f,i=this.findKeysByEmails(t,!0,s);if(!s.hasErrors())try{s.result=this.pgp.encryptMessage(this.convertToNativeKeys(i),e)}catch(o){s.addExceptionMessage(o,f.Enum.EncryptError)}return s},g.prototype.sign=function(e,t,s){var i=new f,o=null,n=null,r=this.findKeysByEmails([t],!1,i);if(!i.hasErrors()&&(o=this.convertToNativeKeys(r)[0],n=this.cloneKey(o),this.decryptKeyHelper(i,n,s,t),n&&!i.hasErrors()))try{i.result=this.pgp.signClearMessage([n],e)}catch(a){i.addExceptionMessage(a,f.Enum.SignError,t)}return i},g.prototype.signAndEncrypt=function(e,t,s,i){var o=null,n=null,r=new f,a=this.findKeysByEmails([t],!1,r),l=this.findKeysByEmails(s,!0,r);if(!r.hasErrors()&&(o=this.convertToNativeKeys(a)[0],n=this.cloneKey(o),this.decryptKeyHelper(r,n,i,t),n&&!r.hasErrors()))try{r.result=this.pgp.signAndEncryptMessage(this.convertToNativeKeys(l),n,e)}catch(h){r.addExceptionMessage(h,f.Enum.SignAndEncryptError)}return r},g.prototype.deleteKey=function(e){var t=new f;if(e)try{this.pgpKeyring[e.isPrivate()?"privateKeys":"publicKeys"].removeForId(e.getFingerprint()),this.pgpKeyring.store()}catch(s){t.addExceptionMessage(s,f.Enum.DeleteError)}else t.addError(e?f.Enum.UnknownError:f.Enum.InvalidArgumentError);return this.reloadKeysFromStorage(),t},m.prototype.pgpKey=null,m.prototype.emailParts=null,m.prototype.user="",m.prototype.getId=function(){return this.pgpKey.primaryKey.getKeyId().toHex().toLowerCase()},m.prototype.getEmail=function(){return this.emailParts.email||this.user},m.prototype.getUser=function(){return this.user},m.prototype.getFingerprint=function(){return this.pgpKey.primaryKey.getFingerprint()},m.prototype.getBitSize=function(){return this.pgpKey.primaryKey.getBitSize()},m.prototype.getArmor=function(){return this.pgpKey.armor()},m.prototype.isPrivate=function(){return!!this.pgpKey.isPrivate()},m.prototype.isPublic=function(){return!this.isPrivate()},f.Enum={UnknownError:0,UnknownNotice:1,InvalidArgumentError:2,GenerateKeyError:10,ImportKeyError:20,ImportNoKeysFoundError:21,PrivateKeyNotFoundError:30,PublicKeyNotFoundError:31,KeyIsNotDecodedError:32,SignError:40,VerifyError:41,EncryptError:42,DecryptError:43,SignAndEncryptError:44,VerifyAndDecryptError:45,CanNotReadMessage:50,CanNotReadKey:51,DeleteError:60,PublicKeyNotFoundNotice:70,PrivateKeyNotFoundNotice:71,VerifyErrorNotice:72,NoSignDataNotice:73},f.prototype.result=!1,f.prototype.errors=null,f.prototype.notices=null,f.prototype.addError=function(e,t){return this.result=!1,this.errors=this.errors||[],this.errors.push([e||f.Enum.UnknownError,t||""]),this},f.prototype.addNotice=function(e,t){return this.notices=this.notices||[],this.notices.push([e||f.Enum.UnknownNotice,t||""]),this},f.prototype.addExceptionMessage=function(e,t,s){return e&&(this.result=!1,this.exceptions=this.exceptions||[],this.exceptions.push(""+(e.name||"unknown")+": "+(e.message||""))),vt.isUnd(t)||this.addError(t,s),this},f.prototype.hasErrors=function(){return this.errors&&0<this.errors.length},f.prototype.hasNotices=function(){return this.notices&&0<this.notices.length},b.prototype.onShow=function(e,t,s,i){this.alertDesc(e),this.closeCallback=t||null,this.title(s||""),this.okButtonText(i||vt.i18n("MAIN/BUTTON_OK"))},b.prototype.popupTemplate=function(){return"Popups_AlertPopupViewModel"},b.prototype.onEnterHandler=function(){this.close()},b.prototype.close=function(){vt.isFunc(this.closeCallback)&&this.closeCallback(),this.closeCommand()},y.prototype.onShow=function(e,t,s,i,o){this.title(s||""),this.okButtonText(i||vt.i18n("MAIN/BUTTON_OK")),this.cancelButtonText(o||vt.i18n("MAIN/BUTTON_CANCEL")),vt.isFunc(t)&&(this.fConfirmCallback=t,this.confirmDesc(e)),this.shown=!0},y.prototype.onHide=function(){this.shown=!1},y.prototype.popupTemplate=function(){return"Popups_ConfirmPopupViewModel"},y.prototype.onEnterHandler=function(){this.yesClick()},y.prototype.yesClick=function(){this.shown&&this.fConfirmCallback&&this.fConfirmCallback(!0),this.closeCommand()},y.prototype.noClick=function(){this.fConfirmCallback&&this.fConfirmCallback(!1),this.closeCommand()},y.prototype.onEscHandler=function(){this.noClick()},v.prototype.onShow=function(e,t){this.pgp=e,this.keyArmor(t||""),this.keyArmorFocused(!0),this.keys([]),this.hasExistingKeys(!1),""!==this.keyArmor()&&this.checkArmor()},v.prototype.popupTemplate=function(){return"Popups_ImportOpenPgpKeyPopupViewModel"},v.prototype.checkArmor=function(){var e=null,t=[],i=this.pgp,o=!1;""===this.keyArmor()?this.keyArmorFocused(!0):i&&(e=i.getArmorInfo(this.keyArmor()),vt.isNonEmptyArray(e)&&_.each(e,function(e){if(e){var n=i.findKeyByID(e.getId(),e.isPublic()),r=null!==n,a=e.isPublic()?"OPENPGP/PUBLIC_KEY_ADD_INFO":"OPENPGP/PRIVATE_KEY_ADD_INFO";o=o||r,t.push({armor:e.getArmor(),email:e.user,id:e.getId(),addInfo:vt.i18n(a,{LENGTH:e.getBitSize()}),needToImport:s.observable(!r),disabled:r})}}),0===t.length&&At.Api.showError(vt.i18n("OPENPGP/ERROR_IMPORT_NO_KEY_FOUNDED")),this.keys(t),this.hasExistingKeys(o))},v.prototype.importKey=function(){var e=null,t=[];this.pgp&&(_.each(this.keys(),function(e){e.needToImport()&&t.push(e.armor)}),t.length>0?(e=this.pgp.importKeys(t.join("")),e&&e.result&&At.Api.showReport(vt.i18n("OPENPGP/REPORT_KEY_SUCCESSFULLY_IMPORTED_PLURAL",{},null,t.length)),e&&!e.result&&At.Api.showPgpErrorByCode(e,yt.PgpAction.Import,vt.i18n("OPENPGP/ERROR_IMPORT_KEY")),this.closeCommand()):At.Api.showError(vt.i18n("OPENPGP/ERROR_IMPORT_NO_KEY_SELECTED")))},S.prototype.parse=function(e){this.AllowWebMail=!!e.AllowWebMail,this.AllowUsersChangeInterfaceSettings=!!e.AllowUsersChangeInterfaceSettings,this.AllowUsersChangeEmailSettings=!!e.AllowUsersChangeEmailSettings,this.AllowUsersAddNewAccounts=vt.isUnd(e.AllowUsersAddNewAccounts)?this.AllowUsersChangeEmailSettings:!!e.AllowUsersAddNewAccounts,this.SiteName=vt.pString(e.SiteName),this.Languages=e.Languages,this.Themes=e.Themes,this.DateFormats=e.DateFormats,this.AttachmentSizeLimit=vt.pInt(e.AttachmentSizeLimit),this.ImageUploadSizeLimit=vt.pInt(e.ImageUploadSizeLimit),this.FileSizeLimit=vt.pInt(e.FileSizeLimit),this.AutoSave=!!e.AutoSave,this.IdleSessionTimeout=60*vt.pInt(e.IdleSessionTimeout)*1e3,this.AllowInsertImage=!!e.AllowInsertImage,this.AllowBodySize=!!e.AllowBodySize,this.MaxBodySize=vt.pInt(e.MaxBodySize),this.MaxSubjectSize=vt.pInt(e.MaxSubjectSize),this.AllowPrefetch=!!e.AllowPrefetch,this.LoginFormType=vt.pInt(e.LoginFormType),this.LoginSignMeType=vt.pInt(e.LoginSignMeType),this.LoginAtDomainValue=vt.pString(e.LoginAtDomainValue),this.AllowRegistration=!!e.AllowRegistration,this.AllowPasswordReset=!!e.AllowPasswordReset,this.RegistrationDomains=e.RegistrationDomains,this.RegistrationQuestions=_.without(e.RegistrationQuestions,""),this.DemoWebMail=!!e.DemoWebMail,this.DemoWebMailLogin=vt.pString(e.DemoWebMailLogin),this.DemoWebMailPassword=vt.pString(e.DemoWebMailPassword),this.GoogleAnalyticsAccount=e.GoogleAnalyticsAccount,this.ShowQuotaBar=!!e.ShowQuotaBar,this.ServerUseUrlRewrite=!!e.ServerUseUrlRewrite,this.AllowLanguageOnLogin=!Ft&&!!e.AllowLanguageOnLogin,this.FlagsLangSelect=!!e.FlagsLangSelect,this.DefaultLanguage=vt.pString(e.DefaultLanguage),this.LoginDescription=vt.pString(e.LoginDescription),this.CustomLoginUrl=vt.pString(e.CustomLoginUrl),this.CustomLogoutUrl=vt.pString(e.CustomLogoutUrl),this.IosDetectOnLogin=!!e.IosDetectOnLogin,this.AllowContactsSharing=!!e.AllowContactsSharing,""!==e.DefaultLanguageShort&&(this.DefaultLanguageShort=e.DefaultLanguageShort),this.DefaultTab=e.DefaultTab,this.AllowIosProfile=!!e.AllowIosProfile,this.PasswordMinLength=e.PasswordMinLength,this.PasswordMustBeComplex=!!e.PasswordMustBeComplex},A.prototype.fillDefaultFontName=function(){var e=vt.pString(Et.HtmlEditorDefaultFontName);""!==e&&(this.DefaultFontName=e)},A.prototype.fillDefaultFontSize=function(){var e=vt.pInt(Et.HtmlEditorDefaultFontSize);-1!==vt.inArray(e,[2,3,5,7])&&(this.DefaultFontSize=e)},A.prototype.getSaveMailInSentItems=function(){var e=!0;switch(this.SaveMail){case yt.SaveMail.Unchecked:e=!1;break;case yt.SaveMail.Checked:case yt.SaveMail.Hidden:e=!0
}return e},A.prototype.getUseSaveMailInSentItems=function(){var e=!1;switch(this.SaveMail){case yt.SaveMail.Unchecked:case yt.SaveMail.Checked:e=!0;break;case yt.SaveMail.Hidden:e=!1}return e},A.prototype.parse=function(e){var t=null;null!==e&&(this.IdUser=vt.pInt(e.IdUser),this.MailsPerPage=vt.pInt(e.MailsPerPage),this.ContactsPerPage=vt.pInt(e.ContactsPerPage),this.AutoCheckMailInterval=vt.pInt(e.AutoCheckMailInterval),this.DefaultTheme=vt.pString(e.DefaultTheme),this.DefaultLanguage=vt.pString(e.DefaultLanguage),this.DefaultLanguageShort=vt.pString(e.DefaultLanguageShort),this.DefaultDateFormat=vt.pString(e.DefaultDateFormat),this.defaultTimeFormat(vt.pString(e.DefaultTimeFormat)),this.ThreadsEnabled=!!e.ThreadsEnabled,this.useThreads(!!e.UseThreads),this.SaveRepliedToCurrFolder=!!e.SaveRepliedMessagesToCurrentFolder,this.DesktopNotifications=!!e.DesktopNotifications,this.AllowChangeInputDirection=!!e.AllowChangeInputDirection,this.AllowCompose=!!e.AllowCompose,this.AllowReply=!!e.AllowReply,this.AllowForward=!!e.AllowForward,this.SaveMail=vt.pInt(e.SaveMail),this.AllowFetcher=!!e.AllowFetcher,this.OutlookSyncEnable=!!e.OutlookSyncEnable,this.MobileSyncEnable=!!e.MobileSyncEnable,this.ShowPersonalContacts=!!e.ShowPersonalContacts,this.ShowGlobalContacts=!!e.ShowGlobalContacts,this.ShowContacts=this.ShowPersonalContacts||this.ShowGlobalContacts,this.IsFilesSupported=!!e.IsFilesSupported&&!Ft,this.IsFilesSupported=!!e.IsFilesSupported&&!Ft,this.filesEnable(!!e.FilesEnable&&!Ft),this.IsHelpdeskSupported=!!e.IsHelpdeskSupported&&!Ft,this.IsHelpdeskAgent=!!e.IsHelpdeskAgent,this.LastLogin=vt.pInt(e.LastLogin),this.AllowCalendar=!!e.AllowCalendar&&!Ft,this.CalendarSharing=!!e.CalendarSharing,this.CalendarAppointments=!!e.CalendarAppointments,this.IsDemo=!!e.IsDemo,this.AllowVoice=!!e.AllowVoice,this.SipRealm=e.SipRealm,this.SipWebsocketProxyUrl=e.SipWebsocketProxyUrl,this.SipOutboundProxyUrl=e.SipOutboundProxyUrl,this.SipCallerID=e.SipCallerID,this.SipImpi=e.SipImpi,this.SipImpu=e.SipImpu,this.SipPassword=e.SipPassword,this.VoiceProvider=e.VoiceProvider,this.AllowHelpdeskNotifications=e.AllowHelpdeskNotifications,this.IsCollaborationSupported=!!e.IsCollaborationSupported,this.AllowFilesSharing=!!e.AllowFilesSharing,this.enableOpenPgp(!!e.EnableOpenPgp),this.AllowAutosaveInDrafts=!!e.AllowAutosaveInDrafts&&(Et.App?Et.App.AutoSave:!1),t=e.Calendar,t&&(this.CalendarShowWeekEnds=!!t.ShowWeekEnds,this.CalendarShowWorkDay=!!t.ShowWorkDay,this.CalendarWorkDayStarts=vt.pInt(t.WorkDayStarts),this.CalendarWorkDayEnds=vt.pInt(t.WorkDayEnds),this.CalendarWeekStartsOn=vt.pInt(t.WeekStartsOn),this.CalendarDefaultTab=vt.pInt(t.DefaultTab)),this.SocialAccounts(e.SocialAccounts))},A.prototype.updateCommonSettings=function(e,t,s,i,o,n,r,a,l,h,c){var u=this.defaultTimeFormat()!==r;this.MailsPerPage=e,this.ContactsPerPage=t,this.AutoCheckMailInterval=s,At.MailCache.setAutocheckmailTimer(),this.DefaultTheme=i,this.DefaultLanguage=o,this.DefaultDateFormat=n,this.defaultTimeFormat(r),this.useThreads("1"===a),this.SaveRepliedToCurrFolder="1"===l,this.AllowChangeInputDirection="1"===c,this.DesktopNotifications="1"===h,u&&At.nowMoment.valueHasMutated()},A.prototype.updateOpenPgpSettings=function(e,t){this.enableOpenPgp("1"===e),this.AllowAutosaveInDrafts="1"===t},A.prototype.updateCalendarSettings=function(e,t,s,i,o,n){this.CalendarShowWeekEnds=e,this.CalendarShowWorkDay=t,this.CalendarWorkDayStarts=s,this.CalendarWorkDayEnds=i,this.CalendarWeekStartsOn=o,this.CalendarDefaultTab=n},A.prototype.updateHelpdeskSettings=function(e){this.AllowHelpdeskNotifications=e},A.prototype.onSyncSettingsResponse=function(e){e.Result?(this.mobileSync(e.Result.Mobile),this.outlookSync(e.Result.Outlook)):At.Api.showErrorByCode(e)},A.prototype.requestSyncSettings=function(){(null===this.mobileSync()||null===this.outlookSync())&&At.Ajax.send({Action:"SyncSettings"},this.onSyncSettingsResponse,this)},C.prototype.init=function(e,t,s){this.id(e),this.email(t),this.friendlyName(s)},C.prototype.onQuotaParamsResponse=function(e){e&&e.Result&&_.isArray(e.Result)&&1<e.Result.length&&(this.quota(vt.pInt(e.Result[1])),this.usedSpace(vt.pInt(e.Result[0])),At.MailCache.quotaChangeTrigger(!At.MailCache.quotaChangeTrigger())),this.quotaRecieved(!0)},C.prototype.updateQuotaParams=function(){var e={Action:"Quota",AccountID:this.id()};Et.App&&Et.App.ShowQuotaBar&&At.Ajax.send(e,this.onQuotaParamsResponse,this)},C.prototype.parse=function(e,t){var s=new B;this.init(parseInt(e.AccountID,10),vt.pString(e.Email),vt.pString(e.FriendlyName)),s.parse(this.id(),e.Signature),this.signature(s),this.isCurrent(t===this.id()),this.isEdited(t===this.id())},C.prototype.requestExtensions=function(){if(!this.extensionsRequested()&&At.Ajax){var e=t.jstz?t.jstz.determine():null;At.Ajax.send({AccountID:this.id(),Action:"IsAuth",ClientTimeZone:e?e.name():""},this.onIsAuthResponse,this)}},C.prototype.onIsAuthResponse=function(e){var t=!!e.Result,s=t?e.Result.Extensions:[];t&&(this.setExtensions(s),this.extensionsRequested(!0))},C.prototype.setExtensions=function(e){_.isArray(e)&&this.extensions(e)},C.prototype.extensionExists=function(e){return-1===_.indexOf(this.extensions(),e)?!1:!0},C.prototype.updateExtended=function(e){e&&(this.isExtended(!0),vt.isNormal(e.FriendlyName)&&this.friendlyName(e.FriendlyName),vt.isNormal(e.IncomingMailLogin)&&this.incomingMailLogin(e.IncomingMailLogin),vt.isNormal(e.IncomingMailPort)&&this.incomingMailPort(e.IncomingMailPort),vt.isNormal(e.IncomingMailServer)&&this.incomingMailServer(e.IncomingMailServer),vt.isNormal(e.IsInternal)&&this.isInternal(e.IsInternal),vt.isNormal(e.IsLinked)&&this.isLinked(e.IsLinked),vt.isNormal(e.IsDefault)&&this.isDefault(e.IsDefault),vt.isNormal(e.OutgoingMailAuth)&&this.outgoingMailAuth(e.OutgoingMailAuth),vt.isNormal(e.OutgoingMailLogin)&&this.outgoingMailLogin(e.OutgoingMailLogin),vt.isNormal(e.OutgoingMailPort)&&this.outgoingMailPort(e.OutgoingMailPort),vt.isNormal(e.OutgoingMailServer)&&this.outgoingMailServer(e.OutgoingMailServer),this.setExtensions(e.Extensions))},C.prototype.changeAccount=function(){Et.Accounts.changeCurrentAccount(this.id())},C.prototype.getFetcherOrIdentityByEmail=function(e){var t=this.fetchers()?this.fetchers().collection():[],s=null;return s=_.find(t,function(t){return t.email()===e}),s||(s=_.find(this.identities()||[],function(t){return t.email()===e})),s},C.prototype.getFetchersIdentitiesEmails=function(){var e=this.fetchers()?this.fetchers().collection():[],t=this.identities()||[],s=[];return _.each(e,function(e){s.push(e.email())}),_.each(t,function(e){s.push(e.email())}),s},E.prototype.changeCurrentAccount=function(e){var t=this.getCurrent(),s=this.getAccount(e);s&&this.currentId()!==e&&(t.isCurrent(!1),this.currentId(e),s.isCurrent(!0),At.Routing.setHash(At.Links.inbox()))},E.prototype.changeEditedAccount=function(e){var t=this.getEdited(),s=this.getAccount(e);s&&this.editedId()!==e&&(t.isEdited(!1),this.editedId(e),s.isEdited(!0))},E.prototype.parse=function(e,t){var s=null,i=!1,o=null;_.isArray(t)&&this.collection(_.map(t,function(t){var s=new C;return s.parse(t,e),s.id()===e&&(i=!0),s})),!i&&this.collection.length>0&&(s=this.collection()[0],e=s.id(),i=!0),i&&(this.defaultId(e),this.currentId(e),this.editedId(e)),o=this.getDefault(),o&&_.defer(function(){o.isDefault(!0)})},E.prototype.getAccount=function(e){var t=_.find(this.collection(),function(t){return t.id()===e},this);return t},E.prototype.getCurrent=function(){var e=_.find(this.collection(),function(e){return e.id()===this.currentId()},this);return e},E.prototype.getDefault=function(){var e=_.find(this.collection(),function(e){return e.id()===this.defaultId()},this);return e},E.prototype.getEmail=function(){var e="",t=Et.Accounts.getCurrent();return t&&(e=t.email()),e},E.prototype.getEdited=function(){var e=_.find(this.collection(),function(e){return e.id()===this.editedId()},this);return e},E.prototype.addAccount=function(e){this.collection.push(e)},E.prototype.deleteAccount=function(e){this.currentId()===e&&this.changeCurrentAccount(this.defaultId()),this.editedId()===e&&this.changeEditedAccount(this.defaultId()),this.collection.remove(function(t){return t.id()===e})},E.prototype.hasAccountWithId=function(e){var t=_.find(this.collection(),function(t){return t.id()===e},this);return!!t},E.prototype.populateFetchersIdentities=function(){this.populateFetchers(),this.populateIdentities()},E.prototype.populateFetchers=function(){Et.User.AllowFetcher&&At.Ajax.send({Action:"FetcherList",AccountID:Et.Accounts.defaultId()},this.onFetcherListResponse,this)},E.prototype.onFetcherListResponse=function(e){var t=null,s=this.getDefault();vt.isNonEmptyArray(e.Result)&&(t=new V,t.parse(Et.Accounts.defaultId(),e.Result)),s.fetchers(t)},E.prototype.populateIdentities=function(){Et.AllowIdentities&&At.Ajax.send({Action:"GetIdentities"},this.onIdentitiesResponse,this)},E.prototype.onIdentitiesResponse=function(e){var t={};vt.isNonEmptyArray(e.Result)&&_.each(e.Result,function(e){var s=new I,i=-1;s.parse(e),i=s.accountId(),t[i]||(t[i]=[]),t[i].push(s)}),_.each(this.collection(),function(e){var s=t[e.id()];vt.isNonEmptyArray(s)||(s=[]),e.identities(s)})},E.prototype.populateIdentitiesFromSourceAccount=function(e){e&&_.each(this.collection(),function(t){var s=e.getAccount(t.id());s&&(t.fetchers(s.fetchers()),t.identities(s.identities()),t.signature(s.signature()))})},E.prototype.getAllFullEmails=function(){var e=[];return _.each(this.collection(),function(t){t&&(e.push(t.fullEmail()),t.fetchers()&&vt.isNonEmptyArray(t.fetchers().collection())&&_.each(t.fetchers().collection(),function(t){t.isOutgoingEnabled()&&""!==t.fullEmail()&&e.push(t.fullEmail())}),vt.isNonEmptyArray(t.identities())&&_.each(t.identities(),function(t){e.push(t.fullEmail())}))}),e},E.prototype.getCurrentFetchersAndFiltersFolderNames=function(){var e=this.getCurrent(),t=[];return e&&(e.filters()&&_.each(e.filters().collection(),function(e){t.push(e.folder())},this),e.fetchers()&&_.each(e.fetchers().collection(),function(e){t.push(e.folder())},this)),t},E.prototype.getAttendee=function(e){var t=[],s="";return _.each(this.collection(),function(e){t=e.isCurrent()?_.union(e.email(),e.getFetchersIdentitiesEmails(),t):_.union(t,e.email(),e.getFetchersIdentitiesEmails())}),t=_.uniq(t),_.each(t,_.bind(function(t){if(""===s){var i=_.find(e,function(e){return e===t});i===t&&(s=t)}},this)),s},T.prototype.parse=function(e){null!==e&&(this.sName=vt.pString(e.DisplayName),"string"!=typeof this.sName&&(this.sName=""),this.sEmail=vt.pString(e.Email),"string"!=typeof this.sEmail&&(this.sEmail=""),this.sDisplay=this.sName.length>0?this.sName:this.sEmail,this.setFull())},T.prototype.getEmail=function(){return this.sEmail},T.prototype.getName=function(){return this.sName},T.prototype.getDisplay=function(){return this.sDisplay},T.prototype.setFull=function(){var e="";e=this.sEmail.length>0?this.sName.length>0?this.sName+" <"+this.sEmail+">":this.sEmail:this.sName,this.sFull=e},T.prototype.getFull=function(){return this.sFull},T.prototype.oPopup=null,T.prototype.oTitle=null,T.prototype.bPopupOpened=!1,T.prototype.iCloseTimeoutId=0,T.prototype.mouseoverEvent=function(t,s){this.oPopup&&0!==this.oPopup.length||(this.oPopup=e("div.item_viewer[data-email='"+this.sEmail+"']"),this.oPopup.length>0&&this.oPopup.on("mouseenter",_.bind(this.openPopup,this)).on("mouseleave",_.bind(this.mouseoutEvent,this))),this.oTitle=e(s.currentTarget),this.oPopup.length>0&&this.openPopup(s)},T.prototype.openPopup=function(){this.bPopupOpened=!0,clearTimeout(this.iCloseTimeoutId),setTimeout(_.bind(function(){var s,i,o,n=this.oTitle.offset();this.bPopupOpened&&n.left+n.top!==0&&(s=n.left+10,i=n.top+this.oTitle.height()+6,o=e(t).width()-(s+396),o>0&&(o=0),this.oPopup.addClass("expand").css("top",i+"px").css("left",s+o+"px").appendTo("body"))},this),180)},T.prototype.mouseoutEvent=function(){this.bPopupOpened&&this.oPopup&&this.oTitle&&(this.bPopupOpened=!1,this.iCloseTimeoutId=setTimeout(_.bind(function(){this.bPopupOpened||this.oPopup.removeClass("expand")},this),200))},F.prototype.parse=function(e){this.aCollection=_.map(e,function(e){var t=new T;return t.parse(e),t})},F.prototype.addCollection=function(e){_.each(e,function(e){var t=_.find(this.aCollection,function(t){return e.sEmail===t.sEmail});t||this.aCollection.push(e)},this)},F.prototype.excludeCollection=function(e){_.each(e,function(e){this.aCollection=_.filter(this.aCollection,function(t){return e.sEmail!==t.sEmail})},this)},F.prototype.getFirstEmail=function(){return this.aCollection.length>0?this.aCollection[0].getEmail():""},F.prototype.getFirstName=function(){return this.aCollection.length>0?this.aCollection[0].getName():""},F.prototype.getFirstDisplay=function(){return this.aCollection.length>0?this.aCollection[0].getDisplay():""},F.prototype.getDisplay=function(e,t){var s=_.map(this.aCollection,function(s){return e&&t===s.sEmail?e:s.getDisplay(e)});return s.join(", ")},F.prototype.getFull=function(){var e=_.map(this.aCollection,function(e){return e.getFull()});return e.join(", ")},F.prototype.getEmails=function(){var e=_.map(this.aCollection,function(e){return e.getEmail()});return e},M.prototype.parse=function(e){this.iTimeStampInUTC=e,this.oMoment=moment.unix(this.iTimeStampInUTC)},M.prototype.setDate=function(e,t,s){this.oMoment=moment([e,t,s])},M.prototype.getTimeFormat=function(){return Et.User.defaultTimeFormat()===yt.TimeFormat.F24?"HH:mm":"hh:mm A"},M.prototype.getFullDate=function(){return this.oMoment?this.oMoment.format("ddd, MMM D, YYYY, "+this.getTimeFormat()):""},M.prototype.getMidDate=function(){return this.getShortDate(!0)},M.prototype.getShortDate=function(e){var t="",s=null;return this.oMoment&&(s=moment(),s.format("L")===this.oMoment.format("L")?t=this.oMoment.format(this.getTimeFormat()):(t=s.clone().subtract("days",1).format("L")===this.oMoment.format("L")?vt.i18n("DATETIME/YESTERDAY"):this.oMoment.format(s.year()===this.oMoment.year()?"MMM D":"MMM D, YYYY"),(vt.isUnd(e)?1:!e)||(t+=", "+this.oMoment.format(this.getTimeFormat())))),t},M.prototype.getDate=function(){return this.oMoment?this.oMoment.format("ddd, MMM D, YYYY"):""},M.prototype.getTime=function(){return this.oMoment?this.oMoment.format(this.getTimeFormat()):""},M.prototype.convertDate=function(e){var t=vt.getDateFormatForMoment(Et.User.DefaultDateFormat)+" "+this.getTimeFormat();return moment(1e3*e).format(t)},M.prototype.getTimeStampInUTC=function(){return this.iTimeStampInUTC},I.prototype.parse=function(e){"Object/CIdentity"===e["@Object"]&&(this.enabled(!!e.Enabled),this.email(vt.pString(e.Email)),this.friendlyName(vt.pString(e.FriendlyName)),this.accountId(vt.pInt(e.IdAccount)),this.id(vt.pInt(e.IdIdentity)),this.signature(vt.pString(e.Signature)),this.useSignature(!!e.UseSignature))},w.prototype.dataObjectName="",w.prototype.isVisibleViewLink=function(){return this.uploaded()&&!this.uploadError()&&this.isViewMimeType()},w.prototype.parse=function(e,t){e["@Object"]===this.dataObjectName&&(this.fileName(vt.pString(e.FileName)),this.tempName(vt.pString(e.TempName)),""===this.tempName()&&this.tempName(this.fileName()),this.type(vt.pString(e.MimeType)),this.size(e.EstimatedSize?parseInt(e.EstimatedSize,10):parseInt(e.SizeInBytes,10)),this.content(vt.pString(e.Content)),this.thumb(!!e.Thumb),this.hash(vt.pString(e.Hash)),this.accountId(t),this.allowExpandSubFiles(!!e.Expand),this.iframedView(!!e.Iframed),this.uploadUid(this.hash()),this.uploaded(!0),vt.isFunc(this.additionalParse)&&this.additionalParse(e))},w.prototype.getInThumbQueue=function(e){this.thumbnailSessionUid(e),this.thumb()&&(!this.linked||this.linked&&!this.linked())&&vt.thumbQueue(this.thumbnailSessionUid(),this.thumbnailLink(),this.thumbnailSrc)},w.prototype.downloadFile=function(e){this.allowDownload()&&(e&&e.Api&&e.Api.downloadByUrl||(e=At),e&&this.downloadLink().length>0&&"#"!==this.downloadLink()&&e.Api.downloadByUrl(this.downloadLink()))},w.prototype.onExpandAttachmentResponse=function(e){this.subFiles([]),vt.isNonEmptyArray(e.Result)&&(_.each(e.Result,_.bind(function(e){var t=this.getInstance();e["@Object"]=this.dataObjectName,t.parse(e,this.accountId()),this.subFiles.push(t)},this)),this.subFilesLoaded(!0),this.subFilesCollapsed(!0)),this.subFilesStartedLoading(!1)},w.prototype.expandFile=function(){this.subFilesLoaded()?this.subFilesCollapsed(!0):(this.subFilesStartedLoading(!0),At.Ajax.send({Action:"ExpandAttachment",RawKey:this.hash()},this.onExpandAttachmentResponse,this))},w.prototype.collapseFile=function(){this.subFilesCollapsed(!1)},w.prototype.getInstance=function(){return new w},w.prototype.importFile=function(){var e=this.content(),t=_.bind(function(t){t&&At.Screens.showPopup(v,[t,e])},this);At.Api.pgp(t,Et.User.IdUser)},w.prototype.viewFile=function(){this.viewCommonFile()},w.prototype.viewCommonFile=function(){var e=null,t=vt.getAppPath()+this.viewLink();this.visibleViewLink()&&this.viewLink().length>0&&"#"!==this.viewLink()&&(this.isLink()&&(t=this.linkUrl()),e=this.iframedView()?vt.WindowOpener.openTab(t):vt.WindowOpener.open(t,t,!1),e&&e.focus())},w.prototype.eventDragStart=function(e,t){var s=t.originalEvent||t;return e&&s&&s.dataTransfer&&s.dataTransfer.setData&&s.dataTransfer.setData("DownloadURL",this.generateTransferDownloadUrl()),!0},w.prototype.generateTransferDownloadUrl=function(){var e=this.downloadLink();return"http"!==e.substr(0,4)&&(e=t.location.protocol+"//"+t.location.host+t.location.pathname+e),this.type()+":"+this.fileName()+":"+e},w.prototype.onUploadSelect=function(e,t){this.fileName(t.FileName),this.type(t.Type),this.size(vt.pInt(t.Size)),this.uploadUid(e),this.uploaded(!1),this.visibleSpinner(!1),this.statusText(""),this.progressPercent(0),this.visibleProgress(!1)},w.prototype.onUploadStart=function(){this.visibleSpinner(!0),this.visibleProgress(!0)},w.prototype.onUploadProgress=function(e,t){t>0&&(this.progressPercent(Math.ceil(e/t*100)),this.visibleProgress(!0))},w.prototype.onUploadComplete=function(e,t,s){var i=!t||!s||s.Error||!1,o=vt.i18n(s&&"size"===s.Error?"COMPOSE/UPLOAD_ERROR_SIZE":"COMPOSE/UPLOAD_ERROR_UNKNOWN");this.visibleSpinner(!1),this.progressPercent(0),this.visibleProgress(!1),this.uploaded(!0),this.uploadError(i),this.statusText(i?o:vt.i18n("COMPOSE/UPLOAD_COMPLETE")),i||(this.fillDataAfterUploadComplete(s,e),setTimeout(function(e){return function(){e.statusText("")}}(this),3e3))},w.prototype.fillDataAfterUploadComplete=function(){},w.prototype.onImageLoad=function(){this.thumb()&&!this.thumbnailLoaded()&&(this.thumbnailLoaded(!0),vt.thumbQueue(this.thumbnailSessionUid()))},vt.extend(P,w),P.prototype.dataObjectName="Object/CApiMailAttachment",P.prototype.getInstance=function(){return new P},P.prototype.getCopy=function(){var e=new P;return e.copyProperties(this),e},P.prototype.copyProperties=function(e){this.fileName(e.fileName()),this.tempName(e.tempName()),this.size(e.size()),this.accountId(e.accountId()),this.hash(e.hash()),this.type(e.type()),this.cid(e.cid()),this.contentLocation(e.contentLocation()),this.inline(e.inline()),this.linked(e.linked()),this.thumb(e.thumb()),this.thumbnailSrc(e.thumbnailSrc()),this.thumbnailLoaded(e.thumbnailLoaded()),this.statusText(e.statusText()),this.uploaded(e.uploaded()),this.iframedView(e.iframedView())},P.prototype.isVisibleViewLink=function(){return this.uploaded()&&!this.uploadError()&&(this.isViewMimeType()||this.isMessageType())},P.prototype.additionalParse=function(e){this.mimePartIndex(vt.pString(e.MimePartIndex)),this.cid(vt.pString(e.CID)),this.contentLocation(vt.pString(e.ContentLocation)),this.inline(!!e.IsInline),this.linked(!!e.IsLinked)},P.prototype.setMessageData=function(e,t){this.folderName(e),this.messageUid(t)},P.prototype.onMessageResponse=function(e){var t=e.Result,s=new N;t&&this.oNewWindow&&(s.parse(t,e.AccountID,!1,!0),this.messagePart(s),this.messagePart().viewMessage(this.oNewWindow),this.oNewWindow=void 0)},P.prototype.viewFile=function(){this.isMessageType()?this.viewMessageFile():this.viewCommonFile()},P.prototype.viewMessageFile=function(){var t=null,s='<div style="margin: 30px; text-align: center; font: normal 14px Tahoma;">'+vt.i18n("MAIN/LOADING")+"</div>";t=vt.WindowOpener.open("",this.fileName()),t&&(this.messagePart()?this.messagePart().viewMessage(t):(e(t.document.body).html(s),this.oNewWindow=t,At.Ajax.send({Action:"Message",Folder:this.folderName(),Uid:this.messageUid(),Rfc822MimeIndex:this.mimePartIndex()},this.onMessageResponse,this)),t.focus())},P.prototype.viewCommonFile=function(){var e=null,t=vt.getAppPath()+this.viewLink();this.visibleViewLink()&&this.viewLink().length>0&&"#"!==this.viewLink()&&(t=vt.getAppPath()+this.viewLink(),e=this.iframedView()?vt.WindowOpener.openTab(t):vt.WindowOpener.open(t,t,!1),e&&e.focus())},P.prototype.fillDataAfterUploadComplete=function(e,t){this.cid(t),this.tempName(e.Result.Attachment.TempName),this.type(e.Result.Attachment.MimeType),this.size(e.Result.Attachment.Size),this.hash(e.Result.Attachment.Hash),this.iframedView(e.Result.Attachment.Iframed),this.accountId(e.AccountID)},P.prototype.parseFromUpload=function(e,t){this.fileName(e.Name.toString()),this.tempName(e.TempName?e.TempName.toString():this.fileName()),this.type(e.MimeType.toString()),this.size(parseInt(e.Size,10)),this.hash(e.Hash),this.accountId(t),this.uploadUid(this.hash()),this.uploaded(!0),this.uploadStarted(!1)},P.prototype.errorFromUpload=function(){this.uploaded(!0),this.uploadError(!0),this.uploadStarted(!1),this.statusText(vt.i18n("COMPOSE/UPLOAD_ERROR_UNKNOWN"))},R.prototype.getMessageByUid=function(e){return this.oMessages[e]},R.prototype.getFlaggedMessageUids=function(){var e=[];return _.each(this.oMessages,function(t){t.flagged()&&e.push(t.uid())}),e},R.prototype.setMessageUnflaggedByUid=function(e){var t=this.oMessages[e];t&&t.flagged(!1)},R.prototype.hideThreadMessages=function(e){_.each(e.threadUids(),function(e){var t=this.oMessages[e];t&&(t.deleted()||(t.threadShowAnimation(!1),t.threadHideAnimation(!0),setTimeout(function(){t.threadHideAnimation(!1)},1e3)))},this)},R.prototype.getThreadMessages=function(e){var t=[],s=[],i=[],o=0,n=null,r=50;return _.each(e.threadUids(),function(a){if(o<e.threadCountForLoad()){var l=this.oMessages[a];l?l.deleted()||(l.markAsThreadPart(r,e.uid()),t.push(l),i.push(l.uid()),o++,n=l):(s.push(a),i.push(a),o++)}else i.push(a)},this),e.threadLoading()||this.loadThreadMessages(s),e.changeThreadUids(i,t.length),n&&t.length<e.threadUids().length&&n.showNextLoadingLink(_.bind(e.increaseThreadCountForLoad,e)),this.addThreadUidsToUidLists(e.uid(),e.threadUids()),t},R.prototype.computeThreadData=function(e){{var t=0,s=!1,i=[];e.oFrom.getFirstEmail()}_.each(e.threadUids(),function(e){var i=this.oMessages[e];i&&!i.deleted()&&(i.seen()||t++,i.flagged()&&(s=!0))},this),e.threadUnreedCount(t),e.partialFlagged(s),e.threadSenders(i)},R.prototype.addThreadUidsToUidLists=function(e,t){_.each(this.oUids,function(s){_.each(s,function(s){s.addThreadUids(e,t)})})},R.prototype.loadThreadMessages=function(e){if(e.length>0){var t={Action:"MessageListByUids",Folder:this.fullName(),Uids:e};At.Ajax.send(t,this.onMessageListByUidsResponse,this)}},R.prototype.getThreadCheckedUidsFromList=function(e){var t=this,s=[];return _.each(e,function(e){e.threadCount()>0&&!e.threadOpened()&&_.each(e.threadUids(),function(e){var i=t.oMessages[e];i&&!i.deleted()&&i.checked()&&s.push(e)})}),s},R.prototype.parseAndCacheMessage=function(e,t,s){var i=e.Uid.toString(),o=this.oMessages[i]?this.oMessages[i]:new N;return o.parse(e,this.iAccountId,t,s),this.oMessages[o.uid()]=o,o},R.prototype.onMessageListByUidsResponse=function(e){var t=e.Result;t&&"Collection/MessageCollection"===t["@Object"]&&(_.each(t["@Collection"],function(e){this.parseAndCacheMessage(e,!0,!0)},this),At.MailCache.showOpenedThreads(this.fullName()))},R.prototype.addRequestedUids=function(e){this.aRequestedUids=_.union(this.aRequestedUids,e)},R.prototype.hasUidBeenRequested=function(e){return-1!==_.indexOf(this.aRequestedUids,e)},R.prototype.addRequestedThreadUids=function(e){this.aRequestedThreadUids=_.union(this.aRequestedThreadUids,e)},R.prototype.hasThreadUidBeenRequested=function(e){return-1!==_.indexOf(this.aRequestedThreadUids,e)},R.prototype.hasListBeenRequested=function(e){var t=_.where(this.requestedLists,e),s=t.length>0;return s||this.requestedLists.push(e),s},R.prototype.markMessageReplied=function(e,t){var s=this.oMessages[e];if(s)switch(t){case yt.ReplyType.Reply:case yt.ReplyType.ReplyAll:s.answered(!0);break;case yt.ReplyType.Forward:s.forwarded(!0)}},R.prototype.removeAllMessages=function(){var e=null;this.oMessages={},this.oUids={},this.messageCount(0),this.unseenMessageCount(0),this.realUnseenMessageCount(0),e=this.getUidList("",""),e.resultCount(0)},R.prototype.removeAllMessageListsFromCacheIfHasChanges=function(){this.hasChanges()&&(this.oUids={},this.requestedLists=[],this.aRequestedThreadUids=[],this.hasChanges(!1))},R.prototype.removeFlaggedMessageListsFromCache=function(){_.each(this.oUids,function(e,t){delete this.oUids[t][yt.FolderFilter.Flagged]},this)},R.prototype.removeUnseenMessageListsFromCache=function(){_.each(this.oUids,function(e,t){delete this.oUids[t][yt.FolderFilter.Unseen]},this)},R.prototype.setRelevantInformation=function(e,t,s,i,o){var n=this.hasExtendedInfo()&&(this.hash()!==t||this.realUnseenMessageCount()!==i);return this.uidNext(e),this.hash(t),this.hasExtendedInfo()&&o||(this.messageCount(s),this.unseenMessageCount(i),0===i&&this.unseenMessageCount.valueHasMutated()),this.realUnseenMessageCount(i),this.hasExtendedInfo(!0),n&&this.markHasChanges(),this.relevantInformationLastMoment=moment(),n},R.prototype.markHasChanges=function(){this.hasChanges(!0)},R.prototype.addMessagesCountsDiff=function(e,t){var s=this.messageCount()+e,i=this.unseenMessageCount()+t;0>s&&(s=0),this.messageCount(s),0>i&&(i=0),i>s&&(i=s),this.unseenMessageCount(i)},R.prototype.markDeletedByUids=function(e){var t=0,s=0;return _.each(e,function(e){var i=this.oMessages[e];i&&(t++,i.seen()||s++,i.deleted(!0))},this),this.addMessagesCountsDiff(-t,-s),{MinusDiff:t,UnseenMinusDiff:s}},R.prototype.revertDeleted=function(e){var t=0,s=0;return _.each(e,function(e){var i=this.oMessages[e];i&&i.deleted()&&(t++,i.seen()||s++,i.deleted(!1))},this),this.addMessagesCountsDiff(t,s),{PlusDiff:t,UnseenPlusDiff:s}},R.prototype.commitDeleted=function(e){_.each(e,_.bind(function(e){delete this.oMessages[e]},this)),_.each(this.oUids,function(t){_.each(t,function(t){t.deleteUids(e)})})},R.prototype.getUidList=function(e,t){var s=null;return void 0===this.oUids[e]&&(this.oUids[e]={}),void 0===this.oUids[e][t]&&(s=new D,s.search(e),s.filters(t),this.oUids[e][t]=s),this.oUids[e][t]},R.prototype.parse=function(e,t){var s="",i=At.Storage.getData("folderAccordion")||[];return"Object/Folder"===e["@Object"]?(this.parentFullName(t),s=vt.pString(e.Name),this.name(s),this.nameForEdit(s),this.fullName(vt.pString(e.FullNameRaw)),this.fullNameHash(vt.pString(e.FullNameHash)),this.routingHash(At.Routing.buildHashFromArray([yt.Screens.Mailbox,this.fullName()])),this.delimiter(e.Delimiter),this.type(e.Type),this.subscribed(e.IsSubscribed),this.selectable(e.IsSelectable),this.existen(e.IsExists),e.Extended&&this.setRelevantInformation(e.Extended.UidNext.toString(),e.Extended.Hash,e.Extended.MessageCount,e.Extended.MessageUnseenCount,!1),_.find(i,function(e){return e===this.name()},this)&&this.expanded(!0),e.SubFolders):null},R.prototype.onMessageResponse=function(e,t){var s=e.Result,i=null,o=s?s.Uid.toString():t.Uid.toString(),n=this.oMessages[o],r=n?n.selected():!1;s?(n=this.parseAndCacheMessage(s,!1,!1),n&&n.ical()&&n.ical().isReplyType()&&At.CalendarCache&&At.CalendarCache.calendarChanged(!0)):(r&&(At.Api.showErrorByCode(e,vt.i18n("WARNING/UNKNOWN_ERROR")),At.Routing.replaceHashWithoutPart("/msg"+o)),n=null),i=this.aResponseHandlers[o],i&&(i.handler.call(i.context,n,o),delete this.aResponseHandlers[o])},R.prototype.getCompletelyFilledMessage=function(e,t,s){var i=this.oMessages[e],o={Action:"Message",Folder:this.fullName(),Uid:e};e.length>0&&(i&&i.completelyFilled()&&!i.trimmed()?t&&s&&t.call(s,i,e):(t&&s&&(this.aResponseHandlers[e]={handler:t,context:s}),At.Ajax.send(o,this.onMessageResponse,this)))},R.prototype.showExternalPictures=function(e){var t=this.oMessages[e];void 0!==t&&t.showExternalPictures()},R.prototype.alwaysShowExternalPicturesForSender=function(e){_.each(this.oMessages,function(t){var s=t.oFrom.aCollection;s.length>0&&s[0].sEmail===e&&t.alwaysShowExternalPicturesForSender()},this)},R.prototype.executeGroupOperation=function(e,t,s){var i=0;_.each(this.oMessages,function(o){t.length>0?_.each(t,function(t){o&&o.uid()===t&&o[e]()!==s&&(o[e](s),i++)}):o[e](s)}),0===t.length&&(i=s?this.unseenMessageCount():this.messageCount()-this.unseenMessageCount()),"seen"===e&&i>0&&(s?this.addMessagesCountsDiff(0,-i):this.addMessagesCountsDiff(0,i),this.markHasChanges())},R.prototype.emptyFolder=function(){var e=vt.i18n("MAILBOX/CONFIRM_EMPTY_FOLDER"),t=_.bind(this.clearFolder,this);this.enableEmptyFolder()&&At.Screens.showPopup(y,[e,t])},R.prototype.clearFolder=function(e){var t={Action:"FolderClear",Folder:this.fullName()};this.enableEmptyFolder()&&e&&(At.Ajax.send(t),this.removeAllMessages(),At.MailCache.onClearFolder(this))},R.prototype.getNameWhithLevel=function(){var e=this.level();return!this.isNamespace()&&e>0&&e--,vt.strRepeat(" ",3*e)+this.name()},R.prototype.onAccordion=function(e,t){var s=!this.expanded(),i=At.Storage.getData("folderAccordion")||[];s?i.push(this.name()):i=_.reject(i,function(e){return e===this.name()},this),At.Storage.setData("folderAccordion",i),this.expanded(s),At.MailCache.countMessages(this),t.stopPropagation()},R.prototype.executeUnseenFilter=function(){var e=!1;return this.showUnseenMessages()?(At.MailCache.waitForUnseenMessages(!0),e=At.Routing.setHash(At.Links.mailbox(this.fullName(),1,"","",yt.FolderFilter.Unseen)),e&&At.MailCache.changeCurrentMessageList(this.fullName(),1,"",yt.FolderFilter.Unseen),!1):!0},L.prototype.getFoldersWithoutCountInfo=function(){var e=_.compact(_.map(this.oNamedCollection,function(e,t){return e.canBeSelected()&&!e.hasExtendedInfo()?t:null}));return e},L.prototype.setCurrentFolder=function(e,t){var s=this.getFolderByFullName(e);null===s&&(s=this.inboxFolder()),null!==s&&(this.currentFolder()&&(this.currentFolder().selected(!1),this.oStarredFolder&&this.oStarredFolder.selected(!1)),this.currentFolder(s),t===yt.FolderFilter.Flagged?this.oStarredFolder&&this.oStarredFolder.selected(!0):this.currentFolder().selected(!0))},L.prototype.getFolderByType=function(e){switch(e){case yt.FolderTypes.Inbox:return this.inboxFolder();case yt.FolderTypes.Sent:return this.sentFolder();case yt.FolderTypes.Drafts:return this.draftsFolder();case yt.FolderTypes.Trash:return this.trashFolder();case yt.FolderTypes.Spam:return this.spamFolder()}return null},L.prototype.getFolderByFullName=function(e){var t=this.oNamedCollection[e];return t?t:null},L.prototype.parse=function(e,t,s){this.iAccountId=e,this.sNamespace=vt.pString(t.Namespace),this.bInitialized(!0),this.sNamespaceFolder=this.sNamespace.length>0?this.sNamespace.substring(0,this.sNamespace.length-1):this.sNamespace,this.expandFolders(Et.MailExpandFolders&&!At.Storage.hasData("folderAccordion")),At.Storage.hasData("folderAccordion")||At.Storage.setData("folderAccordion",[]),this.collection(this.parseRecursively(t["@Collection"],s))},L.prototype.parseRecursively=function(e,t,s,i){var o=this,n=[],r=0,a=0,l=null,h="",c=null,u=[],d=!1,p=this.expandFolders(),g=Et.Accounts.getAccount(this.iAccountId),m=function(){var e=o.getFolderByType(yt.FolderTypes.Spam);g&&g.extensionExists("AllowSpamFolderExtension")||(e.type(yt.FolderTypes.User),o.spamFolder(null))},f=function(){g&&g.extensionsRequested()&&(m(),g.extensionsRequestedSubscription.dispose(),g.extensionsRequestedSubscription=void 0)};if(i=i||"",vt.isUnd(s)&&(s=-1),s++,_.isArray(e)){for(a=e.length;a>r;r++){switch(h=vt.pString(e[r].FullNameRaw),l=t[h],l||(l=new R),l.iAccountId=this.iAccountId,c=l.parse(e[r],i),p&&null!==c&&(l.expanded(!0),this.expandNames().push(vt.pString(e[r].Name))),d=this.sNamespace===l.fullName()+l.delimiter(),l.isNamespace(d),l.level(s),this.oNamedCollection[l.fullName()]=l,l.type()){case yt.FolderTypes.Inbox:this.inboxFolder(l);
break;case yt.FolderTypes.Sent:this.sentFolder(l);break;case yt.FolderTypes.Drafts:this.draftsFolder(l);break;case yt.FolderTypes.Trash:this.trashFolder(l);break;case yt.FolderTypes.Spam:this.spamFolder(l),g.extensionsRequested()?m():g.extensionsRequestedSubscription=g.extensionsRequested.subscribe(f)}n.push(l),null===c&&l.type()===yt.FolderTypes.Inbox?(this.createStarredFolder(l.fullName(),s),this.oStarredFolder&&n.push(this.oStarredFolder)):null!==c&&(u=this.parseRecursively(c["@Collection"],t,s,l.fullName()),l.type()===yt.FolderTypes.Inbox&&(l.isNamespace()?(this.createStarredFolder(l.fullName(),s+1),this.oStarredFolder&&u.unshift(this.oStarredFolder)):(this.createStarredFolder(l.fullName(),s),this.oStarredFolder&&n.push(this.oStarredFolder))),l.subfolders(u))}p&&At.Storage.setData("folderAccordion",this.expandNames())}return n},L.prototype.createStarredFolder=function(e,t){var s=new R;s.iAccountId=this.iAccountId,s.virtual(!0),s.level(t),s.fullName(e),s.name(vt.i18n("MAIN/FOLDER_STARRED")),s.type(yt.FolderTypes.Starred),s.routingHash(At.Routing.buildHashFromArray(At.Links.mailbox(s.fullName(),1,"","",yt.FolderFilter.Flagged))),this.oStarredFolder=s},L.prototype.getOptions=function(e,t,s,i){var o="    ",n=function(e){var r=0,a=0,l=null,h=[];for(vt.isUnd(t)&&(t=!1),vt.isUnd(s)&&(s=!1),vt.isUnd(i)&&(i=!1),r=0,a=e.length;a>r;r++)l=e[r],l.virtual()||(l.type()===yt.FolderTypes.Inbox||!s)&&s||h.push({name:l.name(),fullName:l.fullName(),displayName:new Array(l.level()+1).join(o)+l.name(),translatedDisplayName:new Array(l.level()+1).join(o)+l.displayName(),disable:l.isSystem()&&!t||!i&&!l.canBeSelected()}),h=h.concat(n(l.subfolders()));return h},r=n(this.collection());return""!==e&&r.unshift({name:e,fullName:"",displayName:e,translatedDisplayName:e,disable:!1}),r},L.prototype.getRecursivelyMessageCount=function(e){var t=0,s=0,i=null,o=0;for(t=0,s=e.length;s>t;t++)i=e[t],i.virtual()||(o+=i.messageCount()+this.getRecursivelyMessageCount(i.subfolders()));return o},L.prototype.deleteFolder=function(e){var t=function(s){return e&&e.fullName()===s.fullName()?!0:(s.subfolders.remove(t),!1)};this.collection.remove(t)},N.prototype.viewMessage=function(t){var s=this.getDomText(vt.getAppPath()),i="";this.textBodyForNewWindow(s.html()),i=e(this.domMessageForPrint()).html(),t&&(e(t.document.body).html(i),t.focus(),_.each(this.attachments(),function(s){var i=e(t.document.body).find("[data-hash='download-"+s.hash()+"']");i.on("click",_.bind(s.downloadFile,s,At)),i=e(t.document.body).find("[data-hash='view-"+s.hash()+"']"),i.on("click",_.bind(s.viewFile,s))},this))},N.prototype.fillFromOrToText=function(){var e=At.MailCache.getFolderByFullName(this.accountId(),this.folder()),t=Et.Accounts.getAccount(this.accountId());this.fromOrToText(e.type()===yt.FolderTypes.Drafts||e.type()===yt.FolderTypes.Sent?this.oTo.getDisplay(vt.i18n("MESSAGE/ME_RECIPIENT"),t.email()):this.oFrom.getDisplay(vt.i18n("MESSAGE/ME_SENDER"),t.email()))},N.prototype.changeThreadUids=function(e,t){this.threadUids(e),this.threadLoading(t<Math.min(this.threadUids().length,this.threadCountForLoad()))},N.prototype.showNextLoadingLink=function(e){this.threadNextLoadingLinkVisible()&&(this.threadNextLoadingVisible(!0),this.threadFunctionLoadNext=e)},N.prototype.increaseThreadCountForLoad=function(){this.threadCountForLoad(this.threadCountForLoad()+5),At.MailCache.showOpenedThreads(this.folder())},N.prototype.loadNextMessages=function(){this.threadFunctionLoadNext&&(this.threadFunctionLoadNext(),this.threadNextLoadingLinkVisible(!1),this.threadFunctionLoadNext=null)},N.prototype.markAsThreadPart=function(e,t){var s=this;this.threadPart(!0),this.threadParentUid(t),this.threadUids([]),this.threadNextLoadingVisible(!1),this.threadNextLoadingLinkVisible(!0),this.threadFunctionLoadNext=null,this.threadHideAnimation(!1),setTimeout(function(){s.threadShowAnimation(!0)},e)},N.prototype.parse=function(e,t,s,i){var o=null,n=null,r="",a="";i&&this.threadPart(s),this.threadPart()||this.threadParentUid(""),"Object/MessageListItem"===e["@Object"]&&(this.seen(!!e.IsSeen),this.flagged(!!e.IsFlagged),this.answered(!!e.IsAnswered),this.forwarded(!!e.IsForwarded),e.Custom&&(this.Custom=e.Custom)),("Object/Message"===e["@Object"]||"Object/MessageListItem"===e["@Object"])&&(this.accountId(t),this.folder(e.Folder),this.uid(vt.pString(e.Uid)),this.subject(vt.pString(e.Subject)),this.messageId(vt.pString(e.MessageId)),this.size(e.Size),this.textSize(e.TextSize),this.oDateModel.parse(e.TimeStampInUTC),this.oFrom.parse(e.From),this.oTo.parse(e.To),this.fillFromOrToText(),this.oCc.parse(e.Cc),this.oBcc.parse(e.Bcc),this.oSender.parse(e.Sender),this.oReplyTo.parse(e.ReplyTo),this.fullDate(this.oDateModel.getFullDate()),this.fullFrom(this.oFrom.getFull()),this.to(this.oTo.getFull()),this.cc(this.oCc.getFull()),this.bcc(this.oBcc.getFull()),this.hasAttachments(!!e.HasAttachments),this.hasIcalAttachment(!!e.HasIcalAttachment),this.hasVcardAttachment(!!e.HasVcardAttachment),"Object/MessageListItem"===e["@Object"]&&i&&this.threadUids(_.map(e.Threads,function(e){return e.toString()},this)),this.importance(e.Priority),_.isArray(e.DraftInfo)&&this.draftInfo(e.DraftInfo),this.sensitivity(e.Sensitivity),this.hash(vt.pString(e.Hash)),"Object/Message"===e["@Object"]&&(this.trimmed(e.Trimmed),this.trimmedTextSize(e.TrimmedTextSize),this.inReplyTo(e.InReplyTo),this.references(e.References),this.readingConfirmation(e.ReadingConfirmation),r=vt.pString(e.Html),a=vt.pString(e.Plain),""!==r?(this.text(r),this.isPlain(!1)):(this.textRaw(e.PlainRaw),-1!==this.textRaw().indexOf("-----BEGIN PGP MESSAGE-----")?(this.text("<pre>"+vt.encodeHtml(this.textRaw())+"</pre>"),this.encryptedMessage(!0)):-1!==this.textRaw().indexOf("-----BEGIN PGP SIGNED MESSAGE-----")?(this.text("<pre>"+vt.encodeHtml(this.textRaw())+"</pre>"),this.signedMessage(!0)):this.text(""!==a?"<div>"+a+"</div>":""),this.isPlain(!0)),this.$text=null,this.isExternalsShown(!1),this.rtl(e.Rtl),this.hasExternals(!!e.HasExternals),this.foundedCids(e.FoundedCIDs),this.parseAttachments(e.Attachments,t),this.safety(e.Safety),this.sourceHeaders(e.Headers),null!==e.ICAL&&(o=new x,o.parse(e.ICAL,Et.Accounts.getAttendee(this.oTo.getEmails())),this.ical(o)),null!==e.VCARD&&(n=new k,n.parse(e.VCARD),this.vcard(n)),this.completelyFilled(!0)),this.updateMomentDate())},N.prototype.updateMomentDate=function(){this.date(this.oDateModel.getShortDate(moment().clone().subtract("days",1).format("L")===moment.unix(this.oDateModel.getTimeStampInUTC()).format("L")))},N.prototype.getDomText=function(t,s){var i=this.$text;return t=t||"",(null===this.$text||""!==t)&&(this.completelyFilled()?(this.$text=e(this.text()),this.showInlinePictures(t),this.safety()===!0&&this.alwaysShowExternalPicturesForSender(),s&&this.isExternalsShown()&&this.showExternalPictures(),i=this.$text):i=e("")),i.clone()},N.prototype.getConvertedHtml=function(e,t){var s=this.getDomText(e,t);return s.length>0?s.wrap("<p>").parent().html():""},N.prototype.parseAttachments=function(e,t){if(_.isArray(e)){var s=Date.now().toString();this.attachments(_.map(e,function(e){var i=new P;return i.parse(e,t),i.getInThumbQueue(s),i.setMessageData(this.folder(),this.uid()),i},this))}},N.prototype.parseAddressArray=function(e){var t=[];return _.isArray(e)&&(t=_.map(e,function(e){var t=new T;return t.parse(e),t})),t},N.prototype.findAttachmentByCid=function(e){return _.find(this.attachments(),function(t){return t.cid()===e})},N.prototype.findAttachmentByContentLocation=function(e){return _.find(this.attachments(),function(t){return t.contentLocation()===e})},N.prototype.showInlinePictures=function(t){var s=this;this.foundedCids().length>0&&(e("[data-x-src-cid]",this.$text).each(function(){var i=e(this).attr("data-x-src-cid"),o=s.findAttachmentByCid(i);o&&o.viewLink().length>0&&e(this).attr("src",t+o.viewLink())}),e("[data-x-style-cid]",this.$text).each(function(){var t="",i=e(this).attr("data-x-style-cid-name"),o=e(this).attr("data-x-style-cid"),n=s.findAttachmentByCid(o);n&&n.viewLink().length>0&&""!==i&&(t=vt.trim(e(this).attr("style")),t=""===t?"":";"===t.substr(-1)?t+" ":t+"; ",e(this).attr("style",t+i+": url('"+n.viewLink()+"')"))})),e("[data-x-src-location]",this.$text).each(function(){var i=e(this).attr("data-x-src-location"),o=s.findAttachmentByContentLocation(i);o||(o=s.findAttachmentByCid(i)),o&&o.viewLink().length>0&&e(this).attr("src",t+o.viewLink())})},N.prototype.showExternalPictures=function(){e("[data-x-src]",this.$text).each(function(){e(this).attr("src",e(this).attr("data-x-src")).removeAttr("data-x-src")}),e("[data-x-style-url]",this.$text).each(function(){var t=vt.trim(e(this).attr("style"));t=""===t?"":";"===t.substr(-1)?t+" ":t+"; ",e(this).attr("style",t+e(this).attr("data-x-style-url")).removeAttr("data-x-style-url")}),this.isExternalsShown(!0)},N.prototype.alwaysShowExternalPicturesForSender=function(){this.completelyFilled()&&(this.isExternalsAlwaysShown(!0),this.isExternalsShown()||this.showExternalPictures())},N.prototype.openThread=function(){if(this.threadCountVisible()){var e=this.folder();this.threadOpened(!this.threadOpened()),this.threadOpened()?At.MailCache.showOpenedThreads(e):(At.MailCache.hideThreads(this),setTimeout(function(){At.MailCache.showOpenedThreads(e)},500))}},N.prototype.downloadAllAttachments=function(){if(""!==this.allAttachmentsHash)At.Api.downloadByUrl(vt.getDownloadLinkByHash(this.accountId(),this.allAttachmentsHash));else{var e=_.filter(this.attachments(),function(e){return!e.linked()}),t=_.map(e,function(e){return e.hash()});At.Ajax.send({Action:"MessageZipAttachments",Hashes:t},this.onMessageZipAttachments,this)}},N.prototype.onMessageZipAttachments=function(e){e.Result&&(this.allAttachmentsHash=e.Result,At.Api.downloadByUrl(vt.getDownloadLinkByHash(this.accountId(),this.allAttachmentsHash)))},N.prototype.saveAttachmentsToFiles=function(){var e=_.filter(this.attachments(),function(e){return!e.linked()}),t=_.map(e,function(e){return e.hash()});At.filesRecievedAnim(!0),At.Ajax.send({Action:"MessageAttachmentsSaveToFiles",Attachments:t},this.onMessageAttachmentsSaveToFilesResponse,this)},N.prototype.onMessageAttachmentsSaveToFilesResponse=function(e,t){var s=0,i=t.Attachments.length;e.Result&&_.each(t.Attachments,function(t){void 0!==e.Result[t]&&s++}),0===s?At.Api.showError(vt.i18n("MESSAGE/ERROR_ATTACHMENTS_SAVED_TO_FILES")):i>s?At.Api.showError(vt.i18n("MESSAGE/WARNING_ATTACHMENTS_SAVED_TO_FILES",{SAVED_COUNT:s,TOTAL_COUNT:i})):At.Api.showReport(vt.i18n("MESSAGE/REPORT_ATTACHMENTS_SAVED_TO_FILES"))},N.prototype.downloadAllAttachmentsSeparately=function(){_.each(this.attachments(),function(e){e.linked()||e.downloadFile(At)})},N.prototype.toJSON=function(){return{uid:this.uid(),accountId:this.accountId(),to:this.to(),subject:this.subject(),threadPart:this.threadPart(),threadUids:this.threadUids(),threadOpened:this.threadOpened()}},D.prototype.addThreadUids=function(e,t){-1!==_.indexOf(this.collection(),e)&&(this.threadUids[e]=t)},D.prototype.setUidsAndCount=function(e){"Collection/MessageCollection"===e["@Object"]&&(_.each(e.Uids,function(t,s){this.collection()[s+e.Offset]=t.toString()},this),this.resultCount(e.MessageResultCount))},D.prototype.getUidsForOffset=function(e,t){for(var s=0,i=this.collection().length,o="",n=0,r=[],a=null;i>s;s++)s>=e&&n<Et.User.MailsPerPage&&(o=this.collection()[s],a=t[o],(a&&!a.deleted()||void 0===o)&&(n++,void 0!==o&&r.push(o)));return r},D.prototype.deleteUids=function(e){for(var t=0,s=this.collection().length,i="",o=[],n=0;s>t;t++)i=this.collection()[t],-1===_.indexOf(e,i)?o.push(i):n++;this.collection(o),this.resultCount(this.resultCount()-n)},x.prototype.fillDecisions=function(){var e=Et.Accounts.getCurrent(),t=e?e.email():"";switch(this.cancelDecision(vt.i18n("MESSAGE/APPOINTMENT_CANCELED",{SENDER:t})),this.icalConfig()){case yt.IcalConfig.Accepted:this.replyDecision(vt.i18n("MESSAGE/APPOINTMENT_ACCEPTED",{SENDER:t}));break;case yt.IcalConfig.Declined:this.replyDecision(vt.i18n("MESSAGE/APPOINTMENT_DECLINED",{SENDER:t}));break;case yt.IcalConfig.Tentative:this.replyDecision(vt.i18n("MESSAGE/APPOINTMENT_TENTATIVELY_ACCEPTED",{SENDER:t}))}},x.prototype.parse=function(e,t){var s="";e&&"Object/CApiMailIcs"===e["@Object"]&&(s=vt.pString(e.Description),this.uid(vt.pString(e.Uid)),this.file(vt.pString(e.File)),this.attendee(vt.pString(e.Attendee)||t),this.type(e.Type),this.location(vt.pString(e.Location)),this.description(s.replace(/\r/g,"").replace(/\n/g,"<br />")),this.when(vt.pString(e.When)),this.calendarId(vt.pString(e.CalendarId)),this.selectedCalendarId(vt.pString(e.CalendarId)),At.CalendarCache.addIcal(this))},x.prototype.acceptAppointment=function(){this.calendarId(this.selectedCalendarId()),this.changeAndSaveConfig(yt.IcalConfig.Accepted)},x.prototype.tentativeAppointment=function(){this.calendarId(this.selectedCalendarId()),this.changeAndSaveConfig(yt.IcalConfig.Tentative)},x.prototype.declineAppointment=function(){this.calendarId(""),this.selectedCalendarId(""),this.changeAndSaveConfig(yt.IcalConfig.Declined)},x.prototype.changeAndSaveConfig=function(e){this.icalConfig()!==e&&(this.icalConfig()===e||e===yt.IcalConfig.Declined&&this.icalConfig()===yt.IcalConfig.NeedsAction||At.CalendarCache.recivedAnim(!0),this.changeConfig(e),this.doAppointmentAction())},x.prototype.changeConfig=function(e){this.type(this.icalType()+"-"+e),Et.SingleMode&&t.opener?t.opener.App.CalendarCache.markIcalTypeByFile(this.file(),this.type(),this.cancelDecision(),this.replyDecision(),this.calendarId(),this.selectedCalendarId()):At.CalendarCache.markIcalTypeByFile(this.file(),this.type(),this.cancelDecision(),this.replyDecision(),this.calendarId(),this.selectedCalendarId())},x.prototype.onAppointmentActionResponse=function(e){e.Result?At.CalendarCache&&At.CalendarCache.calendarChanged(!0):At.Api.showErrorByCode(e,vt.i18n("WARNING/UNKNOWN_ERROR"))},x.prototype.doAppointmentAction=function(){var e={Action:"AppointmentAction",AppointmentAction:this.icalConfig(),CalendarId:this.selectedCalendarId(),File:this.file(),Attendee:this.attendee()};At.Ajax.send(e,this.onAppointmentActionResponse,this)},x.prototype.onAddEventResponse=function(e){e.Result?(e.Result.Uid&&this.uid(e.Result.Uid),At.CalendarCache&&At.CalendarCache.calendarChanged(!0)):At.Api.showErrorByCode(e)},x.prototype.addEvent=function(){var e={Action:"SaveIcs",CalendarId:this.selectedCalendarId(),File:this.file()};At.Ajax.send(e,this.onAddEventResponse,this),this.isJustSaved(!0),this.calendarId(this.selectedCalendarId()),setTimeout(_.bind(function(){this.isJustSaved(!1)},this),2e4),At.CalendarCache.recivedAnim(!0)},x.prototype.onEventDelete=function(){this.calendarId(""),this.selectedCalendarId(""),this.changeConfig(yt.IcalConfig.NeedsAction)},x.prototype.onEventTentative=function(){this.changeConfig(yt.IcalConfig.Tentative)},x.prototype.onEventAccept=function(){this.changeConfig(yt.IcalConfig.Accepted)},x.prototype.firstCalendarName=function(){return this.calendars()[0]?this.calendars()[0].name:""},x.prototype.updateAttendeeStatus=function(e){if(this.icalType()===yt.IcalType.Cancel||this.icalType()===yt.IcalType.Reply){var t={Action:"UpdateAttendeeStatus",File:this.file(),FromEmail:e};At.Ajax.send(t,this.onUpdateAttendeeStatusResponse,this)}},x.prototype.onUpdateAttendeeStatusResponse=function(e){e.Result&&At.CalendarCache&&(At.CalendarCache.recivedAnim(!0),At.CalendarCache.calendarChanged(!0))},k.prototype.parse=function(e){e&&"Object/CApiMailVcard"===e["@Object"]&&(this.uid(vt.pString(e.Uid)),this.file(vt.pString(e.File)),this.name(vt.pString(e.Name)),this.email(vt.pString(e.Email)),this.isExists(!!e.Exists),At.ContactsCache.addVcard(this))},k.prototype.onAddContactResponse=function(e){e&&e.Result&&e.Result.Uid&&this.uid(e.Result.Uid)},k.prototype.addContact=function(){var e={Action:"SaveVcf",File:this.file()};At.Ajax.send(e,this.onAddContactResponse,this),this.isJustSaved(!0),this.isExists(!0),setTimeout(_.bind(function(){this.isJustSaved(!1)},this),2e4),At.ContactsCache.recivedAnim(!0),Et.SingleMode&&t.opener?t.opener.App.ContactsCache.markVcardExistentByFile(this.file()):At.ContactsCache.markVcardExistentByFile(this.file())},O.birthdayMonths=vt.getMonthNamesArray(),O.birthdayMonthSelect=[{text:vt.i18n("DATETIME/MONTH"),value:"0"},{text:O.birthdayMonths[0],value:"1"},{text:O.birthdayMonths[1],value:"2"},{text:O.birthdayMonths[2],value:"3"},{text:O.birthdayMonths[3],value:"4"},{text:O.birthdayMonths[4],value:"5"},{text:O.birthdayMonths[5],value:"6"},{text:O.birthdayMonths[6],value:"7"},{text:O.birthdayMonths[7],value:"8"},{text:O.birthdayMonths[8],value:"9"},{text:O.birthdayMonths[9],value:"10"},{text:O.birthdayMonths[10],value:"11"},{text:O.birthdayMonths[11],value:"12"}],O.birthdayYearSelect=[{text:vt.i18n("DATETIME/YEAR"),value:"0"}],O.prototype.getSendMailLink=function(e){var t=this.getFullEmail(e),s=At.Links.composeWithToField(t),i=At.Routing.buildHashFromArray(s);return i},O.prototype.clear=function(){this.isNew(!1),this.readOnly(!1),this.idContact(""),this.idUser(""),this.global(!1),this.itsMe(!1),this.edited(!1),this.extented(!1),this.personalCollapsed(!1),this.businessCollapsed(!1),this.otherCollapsed(!1),this.groupsCollapsed(!1),this.displayName(""),this.firstName(""),this.lastName(""),this.nickName(""),this.skype(""),this.facebook(""),this.primaryEmail(this.sEmailDefaultType),this.primaryPhone(this.sPhoneDefaultType),this.primaryAddress(this.sAddressDefaultType),this.personalEmail(""),this.personalStreetAddress(""),this.personalCity(""),this.personalState(""),this.personalZipCode(""),this.personalCountry(""),this.personalWeb(""),this.personalFax(""),this.personalPhone(""),this.personalMobile(""),this.businessEmail(""),this.businessCompany(""),this.businessDepartment(""),this.businessJob(""),this.businessOffice(""),this.businessStreetAddress(""),this.businessCity(""),this.businessState(""),this.businessZipCode(""),this.businessCountry(""),this.businessWeb(""),this.businessFax(""),this.businessPhone(""),this.otherEmail(""),this.otherBirthdayMonth("0"),this.otherBirthdayDay("0"),this.otherBirthdayYear("0"),this.otherNotes(""),this.etag(""),this.sharedToAll(!1),this.groups([])},O.prototype.switchToNew=function(){this.clear(),this.edited(!0),this.extented(!1),this.isNew(!0),Ft||this.displayNameFocused(!0)},O.prototype.switchToView=function(){this.edited(!1),this.extented(!1)},O.prototype.toObject=function(){var e={ContactId:this.idContact(),PrimaryEmail:this.primaryEmail(),PrimaryPhone:this.primaryPhone(),PrimaryAddress:this.primaryAddress(),UseFriendlyName:"1",Title:"",FullName:this.displayName(),FirstName:this.firstName(),LastName:this.lastName(),NickName:this.nickName(),Global:this.global()?"1":"0",ItsMe:this.itsMe()?"1":"0",Skype:this.skype(),Facebook:this.facebook(),HomeEmail:this.personalEmail(),HomeStreet:this.personalStreetAddress(),HomeCity:this.personalCity(),HomeState:this.personalState(),HomeZip:this.personalZipCode(),HomeCountry:this.personalCountry(),HomeFax:this.personalFax(),HomePhone:this.personalPhone(),HomeMobile:this.personalMobile(),HomeWeb:this.personalWeb(),BusinessEmail:this.businessEmail(),BusinessCompany:this.businessCompany(),BusinessJobTitle:this.businessJob(),BusinessDepartment:this.businessDepartment(),BusinessOffice:this.businessOffice(),BusinessStreet:this.businessStreetAddress(),BusinessCity:this.businessCity(),BusinessState:this.businessState(),BusinessZip:this.businessZipCode(),BusinessCountry:this.businessCountry(),BusinessFax:this.businessFax(),BusinessPhone:this.businessPhone(),BusinessWeb:this.businessWeb(),OtherEmail:this.otherEmail(),Notes:this.otherNotes(),ETag:this.etag(),BirthdayDay:this.otherBirthdayDay(),BirthdayMonth:this.otherBirthdayMonth(),BirthdayYear:this.otherBirthdayYear(),SharedToAll:this.sharedToAll()?"1":"0",GroupsIds:this.groups()};return e},O.prototype.parse=function(e){if(e&&"Object/CContact"===e["@Object"]){var t=0,s=0,i=0,o=[];switch(this.idContact(vt.pExport(e,"IdContact","").toString()),this.idUser(vt.pExport(e,"IdUser","").toString()),this.global(!!vt.pExport(e,"Global",!1)),this.itsMe(!!vt.pExport(e,"ItsMe",!1)),this.readOnly(!!vt.pExport(e,"ReadOnly",!1)),this.displayName(vt.pExport(e,"FullName","")),this.firstName(vt.pExport(e,"FirstName","")),this.lastName(vt.pExport(e,"LastName","")),this.nickName(vt.pExport(e,"NickName","")),this.skype(vt.pExport(e,"Skype","")),this.facebook(vt.pExport(e,"Facebook","")),t=vt.pInt(vt.pExport(e,"PrimaryEmail",0))){case 1:t=yt.ContactEmailType.Business;break;case 2:t=yt.ContactEmailType.Other;break;default:case 0:t=yt.ContactEmailType.Personal}switch(this.primaryEmail(t),s=vt.pInt(vt.pExport(e,"PrimaryPhone",0))){case 2:s=yt.ContactPhoneType.Business;break;case 1:s=yt.ContactPhoneType.Personal;break;default:case 0:s=yt.ContactPhoneType.Mobile}switch(this.primaryPhone(s),i=vt.pInt(vt.pExport(e,"PrimaryAddress",0))){case 1:i=yt.ContactAddressType.Business;break;default:case 0:i=yt.ContactAddressType.Personal}this.primaryAddress(i),this.personalEmail(vt.pExport(e,"HomeEmail","")),this.personalStreetAddress(vt.pExport(e,"HomeStreet","")),this.personalCity(vt.pExport(e,"HomeCity","")),this.personalState(vt.pExport(e,"HomeState","")),this.personalZipCode(vt.pExport(e,"HomeZip","")),this.personalCountry(vt.pExport(e,"HomeCountry","")),this.personalWeb(vt.pExport(e,"HomeWeb","")),this.personalFax(vt.pExport(e,"HomeFax","")),this.personalPhone(vt.pExport(e,"HomePhone","")),this.personalMobile(vt.pExport(e,"HomeMobile","")),this.businessEmail(vt.pExport(e,"BusinessEmail","")),this.businessCompany(vt.pExport(e,"BusinessCompany","")),this.businessDepartment(vt.pExport(e,"BusinessDepartment","")),this.businessJob(vt.pExport(e,"BusinessJobTitle","")),this.businessOffice(vt.pExport(e,"BusinessOffice","")),this.businessStreetAddress(vt.pExport(e,"BusinessStreet","")),this.businessCity(vt.pExport(e,"BusinessCity","")),this.businessState(vt.pExport(e,"BusinessState","")),this.businessZipCode(vt.pExport(e,"BusinessZip","")),this.businessCountry(vt.pExport(e,"BusinessCountry","")),this.businessWeb(vt.pExport(e,"BusinessWeb","")),this.businessFax(vt.pExport(e,"BusinessFax","")),this.businessPhone(vt.pExport(e,"BusinessPhone","")),this.otherEmail(vt.pExport(e,"OtherEmail","")),this.otherBirthdayMonth(vt.pExport(e,"BirthdayMonth","0").toString()),this.otherBirthdayDay(vt.pExport(e,"BirthdayDay","0").toString()),this.otherBirthdayYear(vt.pExport(e,"BirthdayYear","0").toString()),this.otherNotes(vt.pExport(e,"Notes","")),this.etag(vt.pExport(e,"ETag","")),this.sharedToAll(!!vt.pExport(e,"SharedToAll",!1)),o=vt.pExport(e,"GroupsIds",[]),_.isArray(o)&&this.groups(o)}},O.prototype.getFullEmail=function(e){var t=e;return""!==this.displayName()&&(t=""!==e?'"'+this.displayName()+'" <'+e+">":this.displayName()),t},O.prototype.getEmailsString=function(){return _.uniq(_.without([this.email(),this.personalEmail(),this.businessEmail(),this.otherEmail()],"")).join(",")},O.prototype.viewAllMails=function(){At.MailCache.searchMessagesInInbox("email:"+this.getEmailsString())},O.prototype.sendThisContact=function(){At.Routing.goDirectly(At.Links.compose(),["vcard",this])},O.prototype.isStrLink=function(e){return/^http/.test(e)},O.prototype.onCallClick=function(e){At.Phone.call(e)},O.prototype.viewAllMailsWithContact=function(){var e=this.getEmailsString();Et.SingleMode&&t.opener&&t.opener.App?(t.opener.App.MailCache.searchMessagesInCurrentFolder("email:"+e),t.opener.focus(),t.close()):At.MailCache.searchMessagesInCurrentFolder("email:"+e)},U.prototype.clear=function(){this.isNew(!1),this.idGroup(""),this.idUser(""),this.name(""),this.nameFocused(!1),this.edited(!1),this.isOrganization(!1),this.email(""),this.country(""),this.city(""),this.company(""),this.fax(""),this.phone(""),this.state(""),this.street(""),this.web(""),this.zip(""),this.events([])},U.prototype.populate=function(e){this.isNew(e.isNew()),this.idGroup(e.idGroup()),this.idUser(e.idUser()),this.name(e.name()),this.nameFocused(e.nameFocused()),this.edited(e.edited()),this.isOrganization(e.isOrganization()),this.email(e.email()),this.country(e.country()),this.city(e.city()),this.company(e.company()),this.fax(e.fax()),this.phone(e.phone()),this.state(e.state()),this.street(e.street()),this.web(e.web()),this.zip(e.zip())},U.prototype.switchToNew=function(){this.clear(),this.edited(!0),this.isNew(!0),Ft||this.nameFocused(!0)},U.prototype.switchToView=function(){this.edited(!1)},U.prototype.toObject=function(){return{GroupId:this.idGroup(),Name:this.name(),IsOrganization:this.isOrganization()?"1":"0",Email:this.email(),Country:this.country(),City:this.city(),Company:this.company(),Fax:this.fax(),Phone:this.phone(),State:this.state(),Street:this.street(),Web:this.web(),Zip:this.zip()}},H.prototype.parse=function(e){e&&"Object/CContactListItem"===vt.pExport(e,"@Object","")&&(this.sId=vt.pString(e.Id),this.sName=vt.pString(e.Name),this.sEmail=vt.pString(e.Email),this.bIsGroup=!!e.IsGroup,this.bIsOrganization=!!e.IsOrganization,this.bReadOnly=!!e.ReadOnly,this.bItsMe=!!e.ItsMe,this.bGlobal=!!e.Global,this.bSharedToAll=!!e.SharedToAll)},H.prototype.IsGroup=function(){return this.bIsGroup},H.prototype.Global=function(){return this.bGlobal},H.prototype.ReadOnly=function(){return this.bReadOnly},H.prototype.ItsMe=function(){return this.bItsMe},H.prototype.Id=function(){return this.sId},H.prototype.Name=function(){return this.sName},H.prototype.Email=function(){return this.sEmail},H.prototype.EmailAndName=function(){return this.sName&&this.sEmail&&0<this.sName.length&&0<this.sEmail.length?'"'+this.sName+'" <'+this.sEmail+">":this.sEmail},H.prototype.IsSharedToAll=function(){return this.bSharedToAll},H.prototype.IsOrganization=function(){return this.bIsOrganization},B.prototype.parse=function(e,t){this.iAccountId=e,this.options(parseInt(t.Options,10)),this.signature(t.Signature)},G.prototype.parse=function(e,t){this.iAccountId=e,this.enable=!!t.Enable,this.subject=vt.pString(t.Subject),this.message=vt.pString(t.Message)},V.prototype.parse=function(e,t){this.accountId=e;var s=[],i=0,o=0,n=null,r=null;if(_.isArray(t))for(o=t.length;o>i;i++)r=t[i],n=new K,n.id(r.IdFetcher),n.accountId(r.IdAccount),n.isEnabled(r.IsEnabled),n.isLocked(r.IsLocked),n.email(r.Email),n.userName(r.Name),n.folder(r.Folder),n.signatureOptions(!!r.SignatureOptions),n.signature(r.Signature),n.incomingMailServer(r.IncomingMailServer),n.incomingMailPort(r.IncomingMailPort),n.incomingMailLogin(r.IncomingMailLogin),n.leaveMessagesOnServer(r.LeaveMessagesOnServer),n.isOutgoingEnabled(r.IsOutgoingEnabled),n.outgoingMailServer(r.OutgoingMailServer),n.outgoingMailPort(r.OutgoingMailPort),n.outgoingMailAuth(r.OutgoingMailAuth),s.push(n);this.collection(s)},V.prototype.getFetcher=function(e){var t=null,s=0,i=0,o=this.collection();for(i=o.length;i>s;s++)o[s].id()===e&&(t=o[s]);return t},j.prototype.parse=function(e,t){this.iAccountId=e,this.enable=!!t.Enable,this.email=vt.pString(t.Email)},q.prototype.parse=function(e,t){var s=0,i=t.length,o=null;if(this.iAccountId=e,_.isArray(t))for(i=t.length;i>s;s++)o=new W(e),o.parse(t[s]),this.collection.push(o)},W.prototype.parse=function(e){this.enable(!!e.Enable),this.field(vt.pInt(e.Field)),this.condition(vt.pInt(e.Condition)),this.filter(vt.pString(e.Filter)),this.action(vt.pInt(e.Action)),this.folder(vt.pString(e.FolderFullName)),this.commit()},W.prototype.revert=function(){this.enable.revert(),this.field.revert(),this.condition.revert(),this.filter.revert(),this.action.revert(),this.folder.revert()},W.prototype.commit=function(){this.enable.commit(),this.field.commit(),this.condition.commit(),this.filter.commit(),this.action.commit(),this.folder.commit()},W.prototype.toString=function(){var e=[this.enable(),this.field(),this.condition(),this.filter(),this.action(),this.folder()];return e.join(":")},z.prototype.showLoading=function(e){this.loadingMessage(e&&""!==e?e:vt.i18n("MAIN/LOADING")),this.loadingVisible(!0),_.defer(_.bind(function(){this.loadingHidden(!1)},this))},z.prototype.hideLoading=function(){this.loadingHidden(!0),setTimeout(_.bind(function(){this.loadingHidden()&&this.loadingVisible(!1)},this),this.iAnimationDuration)},z.prototype.showReport=function(e,t){var s=this;t=t||this.iReportDuration,e&&""!==e?(this.reportMessage(e),this.reportVisible(!0),_.defer(function(){s.reportHidden(!1)}),clearTimeout(this.iReportTimeout),this.iReportTimeout=setTimeout(function(){s.reportHidden(!0),setTimeout(function(){s.reportHidden()&&s.reportVisible(!1)},this.iAnimationDuration)},t)):(this.reportHidden(!0),this.reportVisible(!1))},z.prototype.showError=function(e,t,s,i){e&&""!==e?(this.gray(!!i),this.errorMessage(e),this.isHtmlError(t),this.errorVisible(!0),_.defer(_.bind(function(){this.errorHidden(!1)},this)),clearTimeout(this.iErrorTimeout),s||(this.iErrorTimeout=setTimeout(_.bind(function(){this.selfHideError()},this),this.iErrorDuration))):this.selfHideError()},z.prototype.selfHideError=function(){this.errorHidden(!0),setTimeout(_.bind(function(){this.errorHidden()&&this.errorVisible(!1)},this),this.iAnimationDuration)},z.prototype.hideError=function(e){e=vt.isUnd(e)?!1:!!e,e===this.gray()&&this.selfHideError()},Y.prototype.onRoute=function(){this.changeCurrentAccount()},Y.prototype.changeCurrentAccount=function(){this.email(Et.Accounts.getEmail())},Y.prototype.logout=function(){At.logout()},Y.prototype.switchToFullVersion=function(){At.Ajax.send({Action:"SetMobile",Mobile:0},function(){t.location.reload()},this)},_.extend(Q.prototype,Y.prototype),$.prototype.hotKeysBind=function(){e(document).on("keydown",e.proxy(function(e){if(this.shown&&!vt.isTextFieldFocused()){var t=e.keyCode;e.ctrlKey&&t===yt.Key.Left?this.clickPreviousPage():e.ctrlKey&&t===yt.Key.Right&&this.clickNextPage()}},this))},$.prototype.hide=function(){this.shown=!1},$.prototype.show=function(){this.shown=!0},$.prototype.clear=function(){this.currentPage(1),this.count(0)},$.prototype.setCount=function(e){this.count(e),this.currentPage()>this.pagesCount()&&this.currentPage(this.pagesCount())},$.prototype.setPage=function(e,t){this.perPage(t),this.currentPage(e>this.pagesCount()?this.pagesCount():e)},$.prototype.clickPage=function(e){var t=e.number;1>t&&(t=1),t>this.pagesCount()&&(t=this.pagesCount()),this.currentPage(t)},$.prototype.clickFirstPage=function(){this.currentPage(1)},$.prototype.clickPreviousPage=function(){var e=this.currentPage()-1;1>e&&(e=1),this.currentPage(e)},$.prototype.clickNextPage=function(){var e=this.currentPage()+1;e>this.pagesCount()&&(e=this.pagesCount()),this.currentPage(e)},$.prototype.clickLastPage=function(){this.currentPage(this.pagesCount())},J.prototype.init=function(){e(document.body).on("click",_.bind(function(){this.closeAllPopups()},this)),e(this.colorPickerDropdownDom()).on("click",function(e){e.stopPropagation()}),e(this.insertLinkDropdownDom()).on("click",function(e){e.stopPropagation()}),e(this.insertImageDropdownDom()).on("click",function(e){e.stopPropagation()}),this.initEditorUploader()},J.prototype.correctFontFromSettings=function(){var e=this.sDefaultFont,t=!1;_.each(this.aFonts,function(s){s.toLowerCase()===e.toLowerCase()&&(e=s,t=!0)}),t?this.sDefaultFont=e:this.aFonts.push(e)},J.prototype.showLinkPopup=function(t){var s=e(this.workareaDom()),i=s.position(),o=t.position(),n=t.height();this.linkHref(t.attr("href")||t.text()),this.linkPopupLeft(Math.round(o.left+i.left)),this.linkPopupTop(Math.round(o.top+n+i.top)),this.visibleLinkPopup(!0)},J.prototype.hideLinkPopup=function(){this.visibleLinkPopup(!1)},J.prototype.showChangeLink=function(){this.visibleLinkHref(!0),this.hideLinkPopup()},J.prototype.changeLink=function(){this.oCrea.changeLink(this.linkHref()),this.hideChangeLink()},J.prototype.hideChangeLink=function(){this.visibleLinkHref(!1)},J.prototype.showImagePopup=function(t,s){var i=e(this.workareaDom()),o=i.position(),n=i.offset();this.imagePopupLeft(Math.round(s.pageX+o.left-n.left)),this.imagePopupTop(Math.round(s.pageY+o.top-n.top)),this.visibleImagePopup(!0)},J.prototype.hideImagePopup=function(){this.visibleImagePopup(!1)},J.prototype.resizeImage=function(e){var t={width:"auto",height:"auto"};
switch(e){case yt.HtmlEditorImageSizes.Small:t.width="300px";break;case yt.HtmlEditorImageSizes.Medium:t.width="600px";break;case yt.HtmlEditorImageSizes.Large:t.width="1200px";break;case yt.HtmlEditorImageSizes.Original:t.width="auto"}this.oCrea.changeCurrentImage(t),this.visibleImagePopup(!1)},J.prototype.onImageOver=function(t){if("IMG"===t.target.nodeName&&!this.visibleImagePopup()){this.imageSelected(!0),this.tooltipText(vt.i18n("HTMLEDITOR/CLICK_TO_EDIT_IMAGE"));var s=this,i=e(this.workareaDom());i.bind("mousemove.image",function(e){var t=i.position(),o=i.offset();s.tooltipPopupTop(Math.round(e.pageY+t.top-o.top)),s.tooltipPopupLeft(Math.round(e.pageX+t.left-o.left))})}return!0},J.prototype.onImageOut=function(){if(this.imageSelected()){this.imageSelected(!1);var t=e(this.workareaDom());t.unbind("mousemove.image")}return!0},J.prototype.initCrea=function(e,t,s){this.oCrea||(this.init(),this.oCrea=new Crea({creaId:this.creaId,fontNameArray:this.aFonts,defaultFontName:this.sDefaultFont,defaultFontSize:this.iDefaultSize,isRtl:vt.isRTL(),enableDrop:!1,onCursorMove:_.bind(this.setFontValuesFromText,this),onFocus:_.bind(this.onCreaFocus,this),onBlur:_.bind(this.onCreaBlur,this),onUrlIn:_.bind(this.showLinkPopup,this),onUrlOut:_.bind(this.hideLinkPopup,this),onImageSelect:_.bind(this.showImagePopup,this),onImageBlur:_.bind(this.hideImagePopup,this),onItemOver:_.bind(this.onImageOver,this),onItemOut:_.bind(this.onImageOut,this),openInsertLinkDialog:_.bind(this.insertLink,this)}),this.oCrea.start(this.isEnable())),this.oCrea.setTabIndex(s),this.oCrea.clearUndoRedo(),this.setText(e,t),this.setFontValuesFromText(),this.uploadedImagePathes([]),this.selectedFont(this.sDefaultFont),this.selectedSize(this.iDefaultSize)},J.prototype.setFocus=function(){this.oCrea&&this.oCrea.setFocus(!1)},J.prototype.changeSignatureContent=function(e,t){this.oCrea&&this.oCrea.changeSignatureContent(e,t)},J.prototype.setFontValuesFromText=function(){this.lockFontSubscribing(!0),this.selectedFont(this.oCrea.getFontName()),this.selectedSize(this.oCrea.getFontSizeInNumber()),this.lockFontSubscribing(!1)},J.prototype.isUndoAvailable=function(){return this.oCrea?this.oCrea.isUndoAvailable():!1},J.prototype.getPlainText=function(){return this.oCrea?this.oCrea.getPlainText():""},J.prototype.getText=function(e){return this.oCrea?this.oCrea.getText(e):""},J.prototype.setText=function(e,t){this.oCrea&&(t?this.oCrea.setPlainText(e):this.oCrea.setText(e),this.inactive.valueHasMutated())},J.prototype.undoAndClearRedo=function(){this.oCrea&&(this.oCrea.undo(),this.oCrea.clearRedo())},J.prototype.getNotDefaultText=function(){var e=this.getText();return this.removeAllTags(e)!==vt.i18n("HTMLEDITOR/SIGNATURE_PLACEHOLDER")?e:""},J.prototype.removeAllTags=function(e){return e.replace(/<style>.*<\/style>/g,"").replace(/<[^>]*>/g,"")},J.prototype.setActivitySource=function(e){this.activitySource=e,null!==this.activitySourceSubscription&&this.activitySourceSubscription.dispose(),this.activitySourceSubscription=this.activitySource.subscribe(function(){this.inactive(0===vt.pInt(this.activitySource()))},this),this.inactive(0===vt.pInt(this.activitySource()))},J.prototype.onCreaFocus=function(){this.oCrea&&(this.closeAllPopups(),this.activitySource(1),this.textFocused(!0))},J.prototype.onCreaBlur=function(){this.oCrea&&this.textFocused(!1)},J.prototype.closeAllPopups=function(){this.visibleInsertLinkPopup(!1),this.visibleInsertImagePopup(!1),this.visibleFontColorPopup(!1)},J.prototype.insertHtml=function(e){this.oCrea&&(this.oCrea.isFocused()||this.oCrea.setFocus(!0),this.oCrea.insertHtml(e,!1))},J.prototype.insertLink=function(){this.visibleInsertLinkPopup()||(this.linkForInsert(this.getMailtoLink(this.oCrea.getSelectedText())),this.closeAllPopups(),this.visibleInsertLinkPopup(!0),this.linkFocused(!0))},J.prototype.insertLinkFromPopup=function(e,t){this.linkForInsert().length>0&&(this.linkForInsert(this.getMailtoLink(this.linkForInsert())),this.oCrea.insertLink(this.linkForInsert())),this.closeInsertLinkPopup(e,t)},J.prototype.closeInsertLinkPopup=function(e,t){this.visibleInsertLinkPopup(!1),t&&t.stopPropagation()},J.prototype.textColor=function(){this.closeAllPopups(),this.visibleFontColorPopup(!0),this.oFontColorPicker.onShow(),this.oBackColorPicker.onShow()},J.prototype.colorToHex=function(e){if("#"===e.substr(0,1))return e;for(var t=/(.*?)rgb\((\d+), (\d+), (\d+)\)/.exec(e),s=parseInt(t[2],10),i=parseInt(t[3],10),o=parseInt(t[4],10),n=o|i<<8|s<<16,r=n.toString(16);r.length<6;)r="0"+r;return t[1]+"#"+r},J.prototype.setTextColorFromPopup=function(e){this.oCrea.textColor(this.colorToHex(e)),this.visibleFontColorPopup(!1)},J.prototype.setBackColorFromPopup=function(e){this.oCrea.backgroundColor(this.colorToHex(e)),this.visibleFontColorPopup(!1)},J.prototype.insertImage=function(){return this.allowInsertImage()&&!this.visibleInsertImagePopup()&&(this.imagePathFromWeb(""),this.closeAllPopups(),this.visibleInsertImagePopup(!0),this.initUploader()),!0},J.prototype.insertWebImageFromPopup=function(e,t){this.allowInsertImage()&&this.imagePathFromWeb().length>0&&this.oCrea.insertImage(this.imagePathFromWeb()),this.closeInsertImagePopup(e,t)},J.prototype.insertComputerImageFromPopup=function(t,s){var i=vt.getViewLinkByHash(Et.Accounts.currentId(),s.Hash),o=!1;this.allowInsertImage()&&i.length>0&&(o=this.oCrea.insertImage(i),o&&(e(this.oCrea.$editableArea).find('img[src="'+i+'"]').attr("data-x-src-cid",t),s.CID=t,this.uploadedImagePathes.push(s))),this.closeInsertImagePopup()},J.prototype.closeInsertImagePopup=function(e,t){this.visibleInsertImagePopup(!1),t&&t.stopPropagation()},J.prototype.initUploader=function(){this.imageUploaderButton()&&!this.oJua&&(this.oJua=new Jua({action:"?/Upload/Attachment/",name:"jua-uploader",queueSize:2,clickElement:this.imageUploaderButton(),disableMultiple:!0,disableAjaxUpload:!1,disableDragAndDrop:!0,hidden:{Token:function(){return Et.Token},AccountID:function(){return Et.Accounts.currentId()}}}),this.bInsertImageAsBase64?this.oJua.on("onSelect",_.bind(this.onEditorDrop,this)):this.oJua.on("onSelect",_.bind(this.onFileUploadSelect,this)).on("onComplete",_.bind(this.onFileUploadComplete,this)))},J.prototype.initEditorUploader=function(){if(Et.App.AllowInsertImage&&this.uploaderAreaDom()&&!this.editorUploader){var e=null,t=null;this.oParent&&this.oParent.composeUploaderDragOver&&this.oParent.onFileUploadProgress&&this.oParent.onFileUploadStart&&this.oParent.onFileUploadComplete?(e=_.bind(function(){this.editorUploaderBodyDragOver(!0),this.oParent.composeUploaderDragOver(!0)},this),t=_.bind(function(){this.editorUploaderBodyDragOver(!1),this.oParent.composeUploaderDragOver(!1)},this),this.editorUploader=new Jua({action:"?/Upload/Attachment/",name:"jua-uploader",queueSize:1,dragAndDropElement:this.bAllowImageDragAndDrop?this.uploaderAreaDom():null,disableMultiple:!0,disableAjaxUpload:!1,disableDragAndDrop:!this.bAllowImageDragAndDrop,hidden:{Token:function(){return Et.Token},AccountID:function(){return Et.Accounts.currentId()}}}),this.editorUploader.on("onDragEnter",_.bind(this.oParent.composeUploaderDragOver,this.oParent,!0)).on("onDragLeave",_.bind(this.oParent.composeUploaderDragOver,this.oParent,!1)).on("onBodyDragEnter",e).on("onBodyDragLeave",t).on("onProgress",_.bind(this.oParent.onFileUploadProgress,this.oParent)).on("onSelect",_.bind(this.onEditorDrop,this)).on("onStart",_.bind(this.oParent.onFileUploadStart,this.oParent)).on("onComplete",_.bind(this.oParent.onFileUploadComplete,this.oParent))):(e=_.bind(this.editorUploaderBodyDragOver,this,!0),t=_.bind(this.editorUploaderBodyDragOver,this,!1),this.editorUploader=new Jua({queueSize:1,dragAndDropElement:this.bAllowImageDragAndDrop?this.uploaderAreaDom():null,disableMultiple:!0,disableAjaxUpload:!1,disableDragAndDrop:!this.bAllowImageDragAndDrop}),this.editorUploader.on("onBodyDragEnter",e).on("onBodyDragLeave",t).on("onSelect",_.bind(this.onEditorDrop,this)))}},J.prototype.onEditorDrop=function(e,s){var i=null,o=null,n=this,r=!1,a=Math.random().toString();if(s&&s.File&&s.File.type)if(Et.App.AllowInsertImage&&0===s.File.type.indexOf("image/"))o=s.File,Et.App.ImageUploadSizeLimit>0&&o.size>Et.App.ImageUploadSizeLimit?At.Screens.showPopup(b,[vt.i18n("COMPOSE/UPLOAD_ERROR_SIZE")]):(i=new t.FileReader,r=this.oCrea.isFocused(),r||this.oCrea.setFocus(!0),this.oCrea.insertHtml('<img id="'+o.name+"_"+a+'" src="skins/Default/images/wait.gif" />',!0),r||this.oCrea.fixFirefoxCursorBug(),i.onload=function(e){n.oCrea.$editableArea.find('img[id="'+o.name+"_"+a+'"]').attr("src",e.target.result),n.oCrea.editableSave()},i.readAsDataURL(o));else{if(this.oParent&&this.oParent.onFileUploadSelect)return this.oParent.onFileUploadSelect(e,s),!0;At.browser.ie10AndAbove||At.Screens.showPopup(b,[vt.i18n("HTMLEDITOR/UPLOAD_ERROR_NOT_IMAGE")])}return!1},J.prototype.isFileImage=function(t){if("string"==typeof t.Type)return-1!==t.Type.indexOf("image");var s=t.FileName.lastIndexOf("."),i=t.FileName.substr(s+1),o=["jpg","jpeg","gif","tif","tiff","png"];return-1!==e.inArray(i,o)},J.prototype.onFileUploadSelect=function(e,t){return this.isFileImage(t)?(this.closeInsertImagePopup(),!0):(At.Screens.showPopup(b,[vt.i18n("HTMLEDITOR/UPLOAD_ERROR_NOT_IMAGE")]),!1)},J.prototype.onFileUploadComplete=function(e,t,s){var i="";s&&s.Result?s.Result.Error?(i=vt.i18n("size"===s.Result.Error?"COMPOSE/UPLOAD_ERROR_SIZE":"COMPOSE/UPLOAD_ERROR_UNKNOWN"),At.Screens.showPopup(b,[i])):(this.oCrea.setFocus(!0),this.insertComputerImageFromPopup(e,s.Result.Attachment)):At.Screens.showPopup(b,[vt.i18n("COMPOSE/UPLOAD_ERROR_UNKNOWN")])},J.prototype.getMailtoLink=function(e){return vt.isCorrectEmail(e)?"mailto:"+e:e},X.prototype.onShow=function(){e(this.colorPickerDom()).find("span.color-item").on("click",function(t){return function(){t.setColorFromPopup(e(this).data("color"))}}(this))},X.prototype.setColorFromPopup=function(e){this.pickHandler.call(this.pickContext,e)},Z.prototype.answer=function(){this.action(yt.PhoneAction.IncomingConnect)},Z.prototype.multiAction=function(){var e=this.action();e===yt.PhoneAction.OfflineActive?this.action(yt.PhoneAction.Offline):e===yt.PhoneAction.Online?(this.action(yt.PhoneAction.OnlineActive),this.getLogs(),_.delay(_.bind(function(){this.inputFocus(!0)},this),500)):e===yt.PhoneAction.OnlineActive&&this.validateNumber()?(this.phone&&(this.phone.phoneToCall(this.input()),this.action(yt.PhoneAction.Outgoing)),this.inputFocus(!1)):e!==yt.PhoneAction.OnlineActive||this.validateNumber()?(e===yt.PhoneAction.Outgoing||e===yt.PhoneAction.Incoming||e===yt.PhoneAction.OutgoingConnect||e===yt.PhoneAction.IncomingConnect)&&(this.action(yt.PhoneAction.Online),this.dropdownShow(!1)):(this.action(yt.PhoneAction.Online),this.dropdownShow(!1))},Z.prototype.autocompleteCallback=function(e,t){var s={Action:"ContactSuggestions",Search:e,PhoneOnly:"1"};this.phoneAutocompleteItem(null),e=vt.trim(e),""!==e&&At.Ajax.send(s,function(e){var s=[];e&&e.Result&&e.Result.List&&(_.each(e.Result.List,function(e){_.each(e.Phones,function(t){s.push({label:""!==e.Name?e.Name+" <"+e.Email+">":e.Email,value:t,frequency:e.Frequency})},this)},this),s=_.sortBy(_.compact(s),function(e){return-e.frequency})),t(s)},this)},Z.prototype.validateNumber=function(){return/^[^a-zA-Z\u00BF-\u1FFF\u2C00-\uD7FF]+$/g.test(this.input())},Z.prototype.onLogItem=function(e){this.input(e.phoneToCall),this.dropdownShow(!1)},Z.prototype.getLogs=function(){this.spinner(!0),this.logs([]),this.logsToShow([]),this.phone.getLogs(this.onLogsResponse,this)},Z.prototype.onLogsResponse=function(e){e&&e.Result&&(this.logs([]),_.each(e.Result,function(e){e.phoneToCall=this.phone.getCleanedPhone("incoming"===e.UserDirection?e.From:e.To),e.phoneToShow=e.UserDisplayName?e.UserDisplayName:e.phoneToCall,e.phoneToShow&&this.logs.push(e)},this),this.logs(_.sortBy(this.logs(),function(e){return-Date.parse(e.StartTime)}).slice(0,100)),this.seeMore()),this.spinner(!1)},Z.prototype.seeMore=function(){this.logsToShow(this.logs().slice(0,this.logsToShow().length+10))},Z.prototype.timer=function(){var e=0,t=0,s=0,i=function(e){var t=e.toString();return 1===t.length?t="0"+t:t};return function(o){"start"===o?(t=0,s=0,e=setInterval(_.bind(function(){60===t&&(t=0,s++),this.report(vt.i18n("PHONE/PASSED_TIME")+" "+i(s)+":"+i(t)),t++},this),1e3)):"stop"===o&&clearInterval(e)}}(),et.prototype.__name="CWrapLoginViewModel",et.prototype.onShow=function(){this.oLoginViewModel.onShow&&this.oLoginViewModel.onShow()},et.prototype.onApplyBindings=function(){this.oLoginViewModel.onApplyBindings&&this.oLoginViewModel.onApplyBindings()},et.prototype.changeLanguage=function(e){e&&this.allowLanguages()&&(this.currentLanguage(e),this.oLoginViewModel.changingLanguage(!0),At.Ajax.send({Action:"LoginLanguageUpdate",Language:e},function(){t.location.reload()},this))},tt.prototype.__name="CLoginViewModel",tt.prototype.onApplyBindings=function(){Mt.addClass("non-adjustable-valign")},tt.prototype.onShow=function(){this.fillFields()},tt.prototype.fillFields=function(){_.delay(_.bind(function(){this.focusFields()},this),1)},tt.prototype.focusFields=function(){this.emailVisible()&&""===this.email()?this.emailFocus(!0):this.loginVisible()&&""===this.login()&&this.loginFocus(!0)},tt.prototype.signIn=function(){e(".check_autocomplete_input").trigger("input").trigger("change").trigger("keydown");var t=this.loginFormType(),s=this.email(),i=this.login(),o=this.password();this.loading()||this.changingLanguage()||""===vt.trim(o)||!(yt.LoginFormType.Login===t&&""!==vt.trim(i)||yt.LoginFormType.Email===t&&""!==vt.trim(s)||yt.LoginFormType.Both===t&&""!==vt.trim(s))?this.shake(!0):this.sendRequest()},tt.prototype.onResponse=function(e){!1===e.Result?(this.loading(!1),this.shake(!0),At.Api.showErrorByCode(e,vt.i18n("WARNING/LOGIN_PASS_INCORRECT"))):t.location.reload()},tt.prototype.sendRequest=function(){var e={Action:"Login",Email:this.emailVisible()?this.email():"",IncLogin:this.loginVisible()?this.login():"",IncPassword:this.password(),SignMe:this.signMe()?"1":"0"};this.loading(!0),At.Ajax.send(e,this.onResponse,this)},st.prototype.__name="CForgotViewModel",st.prototype.executeGetQuestion=function(){var e={Action:"GetForgotAccountQuestion",Email:this.email()};this.gettingQuestion(!0),At.Ajax.send(e,this.onGetQuestionResponse,this)},st.prototype.onGetQuestionResponse=function(e){var t="";this.gettingQuestion(!1),!1===e.Result?At.Api.showErrorByCode(e,vt.i18n("LOGIN/ERROR_GETTING_QUESTION")):(t=vt.pString(e.Result.Question),""===t?At.Api.showError(vt.i18n("LOGIN/ERROR_PASSWORD_RESET_NOT_AVAILABLE")):(this.question(t),this.visibleEmailForm(!1),this.visibleQuestionForm(!0),this.visiblePasswordForm(!1)))},st.prototype.executeValidateAnswer=function(){var e={Action:"ValidateForgotAccountQuestion",Email:this.email(),Question:this.question(),Answer:this.answer()};this.validatingAnswer(!0),At.Ajax.send(e,this.onValidateAnswerResponse,this)},st.prototype.onValidateAnswerResponse=function(e){this.validatingAnswer(!1),!1===e.Result?At.Api.showErrorByCode(e,vt.i18n("LOGIN/ERROR_WRONG_ANSWER")):(this.visibleEmailForm(!1),this.visibleQuestionForm(!1),this.visiblePasswordForm(!0))},st.prototype.executeChangePassword=function(){if(this.password()!==this.confirmPassword())At.Api.showError(vt.i18n("WARNING/PASSWORDS_DO_NOT_MATCH"));else{var e={Action:"ChangeForgotAccountPassword",Email:this.email(),Question:this.question(),Answer:this.answer(),Password:this.password()};this.changingPassword(!0),At.Ajax.send(e,this.onChangePasswordResponse,this)}},st.prototype.onChangePasswordResponse=function(e){this.changingPassword(!1),!1===e.Result?At.Api.showErrorByCode(e,vt.i18n("LOGIN/ERROR_RESETTING_PASSWORD")):(this.gotoForgot(!1),At.Api.showReport(vt.i18n("LOGIN/REPORT_PASSWORD_CHANGED")))},it.prototype.__name="CRegisterViewModel",it.prototype.registerAccount=function(){if(this.password()!==this.confirmPassword())At.Api.showError(vt.i18n("WARNING/PASSWORDS_DO_NOT_MATCH"));else{var e={Action:"RegisterAccount",Name:this.name(),Email:this.login()+"@"+this.selectedDomain(),Password:this.password(),Question:this.allowQuestionPart?this.visibleYourQuestion()?this.yourQuestion():this.question():"",Answer:this.allowQuestionPart?this.answer():""};this.loading(!0),At.Ajax.send(e,this.onResponse,this)}},it.prototype.onResponse=function(e){!1===e.Result?(this.loading(!1),At.Api.showErrorByCode(e,vt.i18n("WARNING/LOGIN_PASS_INCORRECT"))):t.location.reload()},nt.prototype.createDatePickerObject=function(t){e(t).datepicker({showOtherMonths:!0,selectOtherMonths:!0,monthNames:vt.getMonthNamesArray(),dayNamesMin:vt.i18n("DATETIME/DAY_NAMES_MIN").split(" "),firstDay:Et.User.CalendarWeekStartsOn,showOn:"focus",dateFormat:this.dateFormatDatePicker}),e(t).mousedown(function(){e("#ui-datepicker-div").toggle()})},nt.prototype.changeRoutingForMessageList=function(e,t,s,i,o){var n=At.Routing.setHash(At.Links.mailbox(e,t,s,i,o));n&&i.length>0&&this.search()===i&&this.listChangedThrottle(!this.listChangedThrottle())},nt.prototype.onEnterPress=function(e){e.openThread()},nt.prototype.onMessageDblClick=function(e){var t=this.folderList().getFolderByFullName(e.folder());t.type()===yt.FolderTypes.Drafts?At.Routing.setHash(At.Links.composeFromMessage("drafts",e.folder(),e.uid())):this.openMessageInNewWindowBinded(e)},nt.prototype.onFolderListSubscribe=function(){this.setCurrentFolder(),this.requestMessageList()},nt.prototype.onShow=function(){this.selector.useKeyboardKeys(!0),this.oPageSwitcher.show(),this.oJua&&this.oJua.setDragAndDropEnabledStatus(!0)},nt.prototype.onHide=function(){this.selector.useKeyboardKeys(!1),this.oPageSwitcher.hide(),this.oJua&&this.oJua.setDragAndDropEnabledStatus(!1)},nt.prototype.onRoute=function(e){var t=At.Links.parseMailbox(e),s=this.currentPage()!==t.Page||this.folderFullName()!==t.Folder||this.filters()!==t.Filters||t.Filters===yt.FolderFilter.Unseen&&At.MailCache.waitForUnseenMessages()||this.search()!==t.Search,i=Et.User.MailsPerPage!==this.oPageSwitcher.perPage();this.pageSwitcherLocked(!0),this.folderFullName()!==t.Folder||this.search()!==t.Search||this.filters()!==t.Filters?this.oPageSwitcher.clear():this.oPageSwitcher.setPage(t.Page,Et.User.MailsPerPage),this.pageSwitcherLocked(!1),t.Page!==this.oPageSwitcher.currentPage()&&At.Routing.replaceHash(At.Links.mailbox(t.Folder,this.oPageSwitcher.currentPage(),t.Uid,t.Search,t.Filters)),this.currentPage(this.oPageSwitcher.currentPage()),this.folderFullName(t.Folder),this.filters(t.Filters),this.search(t.Search),this.searchInput(this.search()),this.searchSpan.notifySubscribers(),this.setCurrentFolder(),(s||i||0===this.collection().length)&&(t.Filters===yt.FolderFilter.Unseen&&At.MailCache.waitForUnseenMessages(!0),this.requestMessageList()),this.highlightTrigger.notifySubscribers(!0)},nt.prototype.setCurrentFolder=function(){this.folderList().setCurrentFolder(this.folderFullName(),this.filters())},nt.prototype.requestMessageList=function(){var e=this.folderList().currentFolderFullName(),t=this.oPageSwitcher.currentPage();e.length>0?At.MailCache.changeCurrentMessageList(e,t,this.search(),this.filters()):At.MailCache.checkCurrentFolderList()},nt.prototype.calculateSearchStringFromAdvancedForm=function(){var t=this.searchInputFrom(),s=this.searchInputTo(),i=this.searchInputSubject(),o=this.searchInputText(),n=this.searchAttachmentsCheckbox(),r=(this.searchAttachments(),this.searchDateStart()),a=this.searchDateEnd(),l=[],h=function(t){return t=e.trim(t).replace(/"/g,'\\"'),(-1<t.indexOf(" ")||-1<t.indexOf('"'))&&(t='"'+t+'"'),t};return""!==t&&l.push("from:"+h(t)),""!==s&&l.push("to:"+h(s)),""!==i&&l.push("subject:"+h(i)),""!==o&&l.push("text:"+h(o)),n&&l.push("has:attachments"),(""!==r||""!==a)&&l.push("date:"+h(r)+"/"+h(a)),l.join(" ")},nt.prototype.onSearchClick=function(){var e=this.folderList().currentFolderFullName(),t=1,s=this.searchInput();this.bAdvancedSearch()&&(s=this.calculateSearchStringFromAdvancedForm(),this.searchInput(s),this.bAdvancedSearch(!1)),this.changeRoutingForMessageList(e,t,"",s,this.filters())},nt.prototype.onRetryClick=function(){this.requestMessageList()},nt.prototype.onClearSearchClick=function(){var e=this.folderList().currentFolderFullName(),t=this.currentMessage()?this.currentMessage().uid():"",s="",i=1;this.clearAdvancedSearch(),this.changeRoutingForMessageList(e,i,t,s,this.filters())},nt.prototype.onClearFilterClick=function(){var e=this.folderList().currentFolderFullName(),t=this.currentMessage()?this.currentMessage().uid():"",s="",i=1,o="";this.clearAdvancedSearch(),this.changeRoutingForMessageList(e,i,t,s,o)},nt.prototype.onStopSearchClick=function(){this.onClearSearchClick()},nt.prototype.routeForMessage=function(e){if(null!==e){var t=this.folderList().currentFolder(),s=this.folderList().currentFolderFullName(),i=this.oPageSwitcher.currentPage(),o=e.uid(),n=this.search();""!==o&&(Ft&&t.type()===yt.FolderTypes.Drafts?At.Routing.setHash(At.Links.composeFromMessage("drafts",e.folder(),e.uid())):(this.changeRoutingForMessageList(s,i,o,n,this.filters()),Ft&&At.MailCache.currentMessage()&&o===At.MailCache.currentMessage().uid()&&At.MailCache.currentMessage.valueHasMutated()))}},nt.prototype.onApplyBindings=function(t){var i=this,o=_.bind(function(e){e&&e.stopPropagation&&e.stopPropagation()},this);e(".message_list",t).on("click",function(){i.isFocused(!1)}).on("click",".message_sub_list .item .flag",function(e){i.onFlagClick(s.dataFor(this)),e&&e.stopPropagation&&e.stopPropagation()}).on("dblclick",".message_sub_list .item .flag",o).on("click",".message_sub_list .item .thread",o).on("dblclick",".message_sub_list .item .thread",o),this.selector.initOnApplyBindings(".message_sub_list .item",".message_sub_list .item.selected",".message_sub_list .item .custom_checkbox",e(".message_list",t),e(".message_list_scroll.scroll-inner",t)),this.initUploader()},nt.prototype.onFlagClick=function(e){At.MailCache.executeGroupOperation("MessageSetFlagged",[e.uid()],"flagged",!e.flagged())},nt.prototype.executeMarkAsRead=function(){At.MailCache.executeGroupOperation("MessageSetSeen",this.checkedOrSelectedUids(),"seen",!0)},nt.prototype.executeMarkAsUnread=function(){At.MailCache.executeGroupOperation("MessageSetSeen",this.checkedOrSelectedUids(),"seen",!1)},nt.prototype.executeMarkAllRead=function(){At.MailCache.executeGroupOperation("MessageSetAllSeen",[],"seen",!0)},nt.prototype.executeMoveToFolder=function(e){At.MailCache.moveMessagesToFolder(e,this.checkedOrSelectedUids())},nt.prototype.executeCopyToFolder=function(e){At.MailCache.copyMessagesToFolder(e,this.checkedOrSelectedUids())},nt.prototype.onDeletePress=function(e){var t=_.map(e,function(e){return e.uid()});t.length>0&&this.deleteMessages(t)},nt.prototype.executeDelete=function(){this.deleteMessages(this.checkedOrSelectedUids())},nt.prototype.deleteMessages=function(e){var t=this.folderList().currentFolderFullName(),s=this.folderList().trashFolder(),i=s&&t===s.fullName(),o=this.folderList().spamFolder(),n=o&&t===o.fullName(),r=function(t){t&&At.MailCache.deleteMessages(e)};n?At.MailCache.deleteMessages(e):i?At.Screens.showPopup(y,[vt.i18n("MAILBOX/CONFIRM_MESSAGES_DELETE"),r]):s?At.MailCache.moveMessagesToFolder(s.fullName(),this.checkedOrSelectedUids()):s||At.Screens.showPopup(y,[vt.i18n("MAILBOX/CONFIRM_MESSAGES_DELETE_NO_TRASH_FOLDER"),r])},nt.prototype.executeSpam=function(){var e=this.folderList().spamFolderFullName();this.folderList().currentFolderFullName()!==e&&At.MailCache.moveMessagesToFolder(e,this.checkedOrSelectedUids())},nt.prototype.executeNotSpam=function(){var e=this.folderList().inboxFolder();e&&this.folderList().currentFolderFullName()!==e.fullName()&&At.MailCache.moveMessagesToFolder(e.fullName(),this.checkedOrSelectedUids())},nt.prototype.clearAdvancedSearch=function(){this.searchInputFrom(""),this.searchInputTo(""),this.searchInputSubject(""),this.searchInputText(""),this.bAdvancedSearch(!1),this.searchAttachmentsCheckbox(!1),this.searchAttachments(""),this.searchDateStart(""),this.searchDateEnd("")},nt.prototype.onAdvancedSearchClick=function(){this.bAdvancedSearch(!this.bAdvancedSearch())},nt.prototype.calculateSearchStringForDescription=function(){return'<span class="part">'+vt.encodeHtml(this.search())+"</span>"},nt.prototype.initUploader=function(){var e=this;this.uploaderArea()&&(this.oJua=new Jua({action:"?/Upload/Message/",name:"jua-uploader",queueSize:2,dragAndDropElement:this.uploaderArea(),disableAjaxUpload:this.isPublic,disableFolderDragAndDrop:this.isPublic,disableDragAndDrop:this.isPublic,hidden:{Token:function(){return Et.Token},AccountID:function(){return Et.Accounts.currentId()},AdditionalData:function(){return JSON.stringify({Folder:e.folderFullName()})}}}),this.oJua.on("onDrop",_.bind(this.onMessageDrop,this)).on("onComplete",_.bind(this.onMessageUploadComplete,this)).on("onBodyDragEnter",_.bind(this.bDragActive,this,!0)).on("onBodyDragLeave",_.bind(this.bDragActive,this,!1)))},nt.prototype.onMessageDrop=function(e){e&&e.File&&e.File.type&&0===e.File.type.indexOf("message/")||At.Api.showError(vt.i18n("MAILBOX/ERROR_UPLOAD_EML"))},nt.prototype.onMessageUploadComplete=function(e,t,s){var i=!t||!s||s.Error||!1;i?At.Api.showError(vt.i18n("MAILBOX/ERROR_UPLOAD_EML")):At.MailCache.executeCheckMail()},rt.prototype.resizeDblClick=function(t,s){""!==s.target.className&&s.target.className.search(/add_contact|icon|link|title|subject|link|date/)&&(s.preventDefault(),s.stopPropagation?s.stopPropagation():s.cancelBubble=!0,vt.removeSelection(),this.jqPanelHelper||(this.jqPanelHelper=e(".MailLayout .panel_helper")),this.jqPanelHelper.trigger("resize",[5,"min",!0]))},rt.prototype.notifySender=function(){this.currentMessage()&&""!==this.currentMessage().readingConfirmation()&&(At.Ajax.send({Action:"MessageSendConfirmation",Confirmation:this.currentMessage().readingConfirmation(),Subject:vt.i18n("MESSAGE/RETURN_RECEIPT_MAIL_SUBJECT"),Text:vt.i18n("MESSAGE/RETURN_RECEIPT_MAIL_TEXT",{EMAIL:Et.Accounts.getEmail(),SUBJECT:this.subject()}),ConfirmFolder:this.currentMessage().folder(),ConfirmUid:this.currentMessage().uid()}),this.currentMessage().readingConfirmation(""))},rt.prototype.onMessagesSubscribe=function(){!this.currentMessage()&&this.uid().length>0&&At.MailCache.setCurrentMessage(this.uid(),this.folder())},rt.prototype.onCurrentMessageSubscribe=function(){var s=null,i=null,o=this.currentMessage(),n=o?Et.Accounts.getAccount(o.accountId()):null;if(this.singleMode()&&t.opener&&t.opener.oReplyDataFromViewPane?(this.replyText(t.opener.oReplyDataFromViewPane.ReplyText),this.replyDraftUid(t.opener.oReplyDataFromViewPane.ReplyDraftUid),t.opener.oReplyDataFromViewPane=null):o&&o.uid()===this.displayedMessageUid()||(this.replyText(""),this.replyDraftUid("")),o&&this.uid()===o.uid()){if(this.subject(o.subject()),this.importance(o.importance()),this.from(o.oFrom.getDisplay()),this.fromEmail(o.oFrom.getFirstEmail()),this.fullFrom(o.oFrom.getFull()),this.oFromAddr(o.oFrom.aCollection.length>0?o.oFrom.aCollection[0]:null),this.to(o.oTo.getFull()),this.aToAddr(o.oTo.aCollection),this.cc(o.oCc.getFull()),this.aCcAddr(o.oCc.aCollection),this.bcc(o.oBcc.getFull()),this.aBccAddr(o.oBcc.aCollection),this.currentAccountEmail(n.email()),this.aAllRecipients(_.uniq(_.union(this.aToAddr(),this.aCcAddr(),this.aBccAddr()))),this.mobileApp||this.requestContactsByEmail(_.union(o.oFrom.aCollection,this.aAllRecipients())),this.midDate(o.oDateModel.getMidDate()),this.fullDate(o.oDateModel.getFullDate()),this.isLoading(""!==o.uid()&&!o.completelyFilled()),this.setMessageBody(),this.rtlMessage(o.rtl()),this.singleMode()){var r=[],a=Date.now().toString();_.each(o.attachments(),_.bind(function(e){var t=new P;t.copyProperties(e),t.getInThumbQueue(a),r.push(t)},this)),this.attachments(r)}else this.attachments(o.attachments());if(null!==this.ical()&&this.ical().animation(!1),s=o.ical(),s&&this.singleMode()&&(s=this.getIcalCopy(s)),this.ical(s),null!==this.ical()&&(_.defer(_.bind(function(){null!==this.ical()&&this.ical().animation(!0)},this)),this.ical().updateAttendeeStatus(this.fromEmail())),i=o.vcard(),i&&this.singleMode()&&(i=this.getVcardCopy(i)),this.vcard(i),!o.completelyFilled()||o.trimmed()){var l=o.completelyFilled()?o.trimmed:o.completelyFilled;this.singleMode()?o.completelyFilledSingleModeSubscription=l.subscribe(this.onCurrentMessageSubscribe,this):o.completelyFilledSubscription=l.subscribe(this.onCurrentMessageSubscribe,this)}else o.completelyFilledSubscription?(o.completelyFilledSubscription.dispose(),o.completelyFilledSubscription=void 0):o.completelyFilledSingleModeSubscription&&(o.completelyFilledSingleModeSubscription.dispose(),o.completelyFilledSingleModeSubscription=void 0)}else this.isLoading(!1),e(this.domTextBody()).empty().data("displayed-message-uid",""),this.displayedMessageUid(""),this.rtlMessage(!1),this.attachments([]),this.visiblePicturesControl(!1),this.visibleShowPicturesLink(!1),this.ical(null),this.vcard(null),this.decryptPassword(""),this.visibleDecryptControl(!1),this.visibleVerifyControl(!1)},rt.prototype.updateMomentDate=function(){var e=this.currentMessage();e&&e.oDateModel&&(this.midDate(e.oDateModel.getMidDate()),this.fullDate(e.oDateModel.getFullDate()))},rt.prototype.fromMouseoverEvent=function(e,t){this.oFromAddr()&&this.oFromAddr().mouseoverEvent(e,t)},rt.prototype.fromMouseoutEvent=function(e,t){this.oFromAddr()&&this.oFromAddr().mouseoutEvent(e,t)},rt.prototype.requestContactsByEmail=function(e){_.each(e,_.bind(function(e){At.ContactsCache.getContactByEmail(e.sEmail,this.onContactResponse,this)},this))},rt.prototype.onContactResponse=function(e,t){e&&(this.recipientsContacts.push(e),this.recipientsContacts(_.uniq(this.recipientsContacts()))),_.each(_.union([this.oFromAddr()],this.aAllRecipients()),function(s){s&&s.sEmail===t&&(s.loaded(!0),e&&s.founded(!0))})},rt.prototype.getVcardCopy=function(e){var t=new k;return t.uid(e.uid()),t.file(e.file()),t.name(e.name()),t.email(e.email()),t.isExists(e.isExists()),t.isJustSaved(e.isJustSaved()),t},rt.prototype.getIcalCopy=function(e){var t=new x;return t.uid(e.uid()),t.file(e.file()),t.attendee(e.attendee()),t.type(e.type()),t.cancelDecision(e.cancelDecision()),t.replyDecision(e.replyDecision()),t.isJustSaved(e.isJustSaved()),t.location(e.location()),t.description(e.description()),t.when(e.when()),t.calendarId(e.calendarId()),t.selectedCalendarId(e.selectedCalendarId()),t.calendars(e.calendars()),t.animation(e.animation()),t},rt.prototype.setMessageBody=function(){if(this.currentMessage()){var t=this.currentMessage(),s=t.text(),i=s.length,o=5e6,n=e(this.domTextBody()),r=[];this.textBody(s),_.defer(_.bind(function(){if(this.currentMessage()){var e=this.currentMessage();n.data("displayed-message-uid")===e.uid()&&(r=this.getBlockquotesStatus()),n.empty(),e.isPlain()||i>o?(n.html(s),this.visiblePicturesControl(!1)):(n.append(e.getDomText().html()),this.visiblePicturesControl(e.hasExternals()&&!e.isExternalsAlwaysShown()),this.visibleShowPicturesLink(!e.isExternalsShown()),this.doHidingBlockquotes(r)),this.decryptPassword(""),this.visibleDecryptControl(Et.User.enableOpenPgp()&&e.encryptedMessage()),this.visibleVerifyControl(Et.User.enableOpenPgp()&&e.signedMessage()),n.data("displayed-message-uid",e.uid()),this.displayedMessageUid(e.uid())}},this))}},rt.prototype.getBlockquotesStatus=function(){var t=[];return e(e("blockquote",e(this.domTextBody())).get()).each(function(){var s=e(this);s.hasClass("blockquote_before_toggle")&&t.push(s.hasClass("collapsed"))}),t},rt.prototype.doHidingBlockquotes=function(t){var s=120,i=80,o=0;e(e("blockquote",e(this.domTextBody())).get()).each(function(){var n=e(this),r=n.parents("blockquote"),a=e('<span class="blockquote_toggle"></span>').html(vt.i18n("MESSAGE/SHOW_QUOTED_TEXT")),l=!0;0===r.length&&n.height()>s&&(n.addClass("blockquote_before_toggle").after(a).wrapInner('<div class="blockquote_content"></div>'),a.bind("click",function(){l?(n.height("auto"),a.html(vt.i18n("MESSAGE/HIDE_QUOTED_TEXT")),l=!1):(n.height(i),a.html(vt.i18n("MESSAGE/SHOW_QUOTED_TEXT")),l=!0),n.toggleClass("collapsed",l)}),o<t.length&&(l=t[o],o++),n.height(l?i:"auto").toggleClass("collapsed",l))
})},rt.prototype.onRoute=function(e){var t=At.Links.parseMailbox(e);""!==this.replyText()&&this.uid()!==t.Uid&&this.saveReplyMessage(!1),this.uid(t.Uid),this.folder(t.Folder),At.MailCache.setCurrentMessage(this.uid(),this.folder()),this.contentHasFocus(!0)},rt.prototype.showPictures=function(){At.MailCache.showExternalPictures(!1),this.visibleShowPicturesLink(!1),this.setMessageBody()},rt.prototype.alwaysShowPictures=function(){var e=this.currentMessage()?this.currentMessage().oFrom.getFirstEmail():"";e.length>0&&At.Ajax.send({Action:"EmailSafety",Email:e}),At.MailCache.showExternalPictures(!0),this.visiblePicturesControl(!1),this.setMessageBody()},rt.prototype.showDetails=function(){this.detailsVisible(!0)},rt.prototype.hideDetails=function(){this.detailsVisible(!1)},rt.prototype.openInNewWindow=function(){this.openMessageInNewWindowBinded(this.currentMessage())},rt.prototype.addToContacts=function(e,t){this.processed()||(this.processed(!0),At.ContactsCache.addToContacts(t,e,this.onAddToContactsResponse,this))},rt.prototype.onAddToContactsResponse=function(e,t){e.Result&&""!==t.HomeEmail&&(At.Api.showReport(vt.i18n("CONTACTS/REPORT_CONTACT_SUCCESSFULLY_ADDED")),At.ContactsCache.clearInfoAboutEmail(t.HomeEmail),At.ContactsCache.getContactByEmail(t.HomeEmail,this.onContactResponse,this)),this.processed(!1)},rt.prototype.getReplyHtmlText=function(){return'<div style="font-family: '+this.defaultFontName+'; font-size: 16px">'+At.MessageSender.getHtmlFromText(this.replyText())+"</div>"},rt.prototype.executeReplyOrForward=function(e){this.currentMessage()&&(At.MessageSender.setReplyData(this.getReplyHtmlText(),this.replyDraftUid()),this.replyText(""),this.replyDraftUid(""),At.Routing.setHash(At.Links.composeFromMessage(e,this.currentMessage().folder(),this.currentMessage().uid())))},rt.prototype.executeDeleteMessage=function(){this.singleMode()&&this.currentMessage()&&t.opener&&t.opener.App&&t.opener.App.MailCache?(t.opener.App.MailCache.deleteMessages([this.currentMessage().uid()]),t.close()):this.mobileApp&&this.currentMessage()&&At.MailCache.deleteMessages([this.currentMessage().uid()])},rt.prototype.executePrevMessage=function(){this.isEnablePrevMessage()&&this.moveToSingleMessageView(this.prevMessageUid())},rt.prototype.executeNextMessage=function(){this.isEnableNextMessage()&&this.moveToSingleMessageView(this.nextMessageUid())},rt.prototype.moveToSingleMessageView=function(e){var t=At.MailCache.folderList().currentFolderFullName(),s=[yt.Screens.SingleMessageView,t,"msg"+e];At.Routing.setHash(s)},rt.prototype.executeReply=function(){this.executeReplyOrForward(yt.ReplyType.Reply)},rt.prototype.executeReplyAll=function(){this.executeReplyOrForward(yt.ReplyType.ReplyAll)},rt.prototype.executeResend=function(){this.executeReplyOrForward(yt.ReplyType.Resend)},rt.prototype.executeForward=function(){this.executeReplyOrForward(yt.ReplyType.Forward)},rt.prototype.executePrint=function(){var t=this.currentMessage(),s=t?vt.WindowOpener.open("",this.subject()+"-print"):null,i="";t&&s&&(this.textBodyForNewWindow(t.getConvertedHtml(vt.getAppPath(),!0)),i=e(this.domMessageForPrint()).html(),e(s.document.body).html(i),s.print())},rt.prototype.executeSave=function(){this.currentMessage()&&At.Api.downloadByUrl(this.currentMessage().downloadLink())},rt.prototype.executeSaveAsPdf=function(){if(this.currentMessage()){var t=this.currentMessage().getDomText(),s=this.currentMessage().accountId(),i=function(e){try{var t=document.createElement("canvas"),s=null;t.width=e.width,t.height=e.height,s=t.getContext("2d"),s.drawImage(e,0,0),e.src=t.toDataURL("image/png")}catch(i){}};e("img[data-x-src-cid]",t).each(function(){i(this)}),At.Ajax.send({Action:"PdfFromHtml",Subject:this.subject(),Html:t.html()},function(e){e&&e.Result&&e.Result.Hash?At.Api.downloadByUrl(vt.getDownloadLinkByHash(s,e.Result.Hash)):At.Api.showError(vt.i18n("WARNING/CREATING_PDF_ERROR"))},this)}},rt.prototype.changeAddMenuVisibility=function(){var e=!this.visibleAddMenu();this.visibleAddMenu(e)},rt.prototype.onMessageSendOrSaveResponse=function(e,t){var s=At.MessageSender.onMessageSendOrSaveResponse(e,t);switch(s.Action){case"MessageSend":this.replySendingStarted(!1),s.Result&&this.replyText("");break;case"MessageSave":s.Result&&this.replyDraftUid(s.NewUid),this.replySavingStarted(!1),this.replyAutoSavingStarted(!1)}},rt.prototype.executeSendQuickReplyCommand=function(){this.isEnableSendQuickReply()&&(this.replySendingStarted(!0),this.requiresPostponedSending(this.replyAutoSavingStarted()),At.MessageSender.sendReplyMessage("MessageSend",this.getReplyHtmlText(),this.replyDraftUid(),this.onMessageSendOrSaveResponse,this,this.requiresPostponedSending()),this.replyTextFocus(!1))},rt.prototype.executeSaveQuickReply=function(){this.saveReplyMessage(!1)},rt.prototype.saveReplyMessage=function(e){this.isEnableSaveQuickReply()&&(e?this.replyAutoSavingStarted(!0):this.replySavingStarted(!0),At.MessageSender.sendReplyMessage("MessageSave",this.getReplyHtmlText(),this.replyDraftUid(),this.onMessageSendOrSaveResponse,this))},rt.prototype.stopAutosaveTimer=function(){t.clearTimeout(this.autoSaveTimer)},rt.prototype.startAutosaveTimer=function(){if(this.isEnableSaveQuickReply()){var e=_.bind(this.saveReplyMessage,this,!0);this.stopAutosaveTimer(),Et.User.AllowAutosaveInDrafts&&(this.autoSaveTimer=t.setTimeout(e,1e3*Et.App.AutoSaveIntervalSeconds))}},rt.prototype.downloadAllAttachments=function(){this.currentMessage()&&this.currentMessage().downloadAllAttachments()},rt.prototype.saveAttachmentsToFiles=function(){this.currentMessage()&&this.currentMessage().saveAttachmentsToFiles()},rt.prototype.downloadAllAttachmentsSeparately=function(){this.currentMessage()&&this.currentMessage().downloadAllAttachmentsSeparately()},rt.prototype.onApplyBindings=function(t){At.registerSessionTimeoutFunction(_.bind(function(){""!==this.replyText()&&this.saveReplyMessage(!1)},this)),e(t).on("mousedown","a",function(t){if(t&&3!==t.which){var s=e(this).attr("href");if(s&&"mailto:"===s.toString().toLowerCase().substr(0,7))return At.Api.openComposeMessage(s.toString().substr(7)),!1}return!0}),this.hotKeysBind()},rt.prototype.hotKeysBind=function(){e(document).on("keydown",e.proxy(function(e){var t=At.Screens.currentScreen()===yt.Screens.Mailbox&&e&&!e.ctrlKey&&!e.shiftKey&&!vt.isTextFieldFocused()&&this.isEnableReply();t&&e.keyCode===yt.Key.q?(e.preventDefault(),this.replyTextFocus(!0)):t&&e.keyCode===yt.Key.r&&this.executeReply()},this))},rt.prototype.showSourceHeaders=function(){var t=this.currentMessage(),s=t&&t.completelyFilled()?vt.WindowOpener.open("",this.subject()+"-headers"):null;s&&e(s.document.body).html("<pre>"+vt.encodeHtml(t.sourceHeaders())+"</pre>")},rt.prototype.onDecryptMessageClick=function(){this.currentMessage()&&this.currentMessage().encryptedMessage()&&this.decryptVerifyMessage(!1)},rt.prototype.onVerifyMessageClick=function(){this.currentMessage()&&this.currentMessage().signedMessage()&&this.decryptVerifyMessage(!0)},rt.prototype.decryptVerifyMessage=function(e){var t=_.bind(function(t){var s=this.currentMessage();t&&s&&(e&&s.signedMessage()?this.verifyMessage(t):s.encryptedMessage()&&this.decryptMessage(t))},this);At.Api.pgp(t,Et.User.IdUser)},rt.prototype.decryptMessage=function(e){var t=this.currentMessage(),s=t.textRaw(),i=Et.Accounts.getEmail(),o=t.oFrom.getFirstEmail(),n=this.decryptPassword(),r=e.decryptAndVerify(s,i,o,n),a=!1;r&&r.result&&!r.errors&&(t.text("<pre>"+vt.encodeHtml(r.result)+"</pre>"),t.$text=null,t.encryptedMessage(!1),this.decryptPassword(""),this.visibleDecryptControl(!1),this.setMessageBody(),At.Api.showReport(r.notices?vt.i18n("OPENPGP/REPORT_MESSAGE_SUCCESSFULLY_DECRYPTED"):vt.i18n("OPENPGP/REPORT_MESSAGE_SUCCESSFULLY_DECRYPTED_AND_VERIFIED"))),r&&(r.errors||r.notices)&&(a=At.Api.showPgpErrorByCode(r,yt.PgpAction.DecryptVerify),a&&At.Api.showReport(vt.i18n("OPENPGP/REPORT_MESSAGE_SUCCESSFULLY_DECRYPTED_AND_NOT_SIGNED")))},rt.prototype.verifyMessage=function(e){var t=this.currentMessage(),s=t.textRaw(),i=t.oFrom.getFirstEmail(),o=e.verify(s,i);o&&o.result&&!o.errors&&!o.notices&&(t.text("<pre>"+vt.encodeHtml(o.result)+"</pre>"),t.$text=null,t.signedMessage(!1),this.visibleVerifyControl(!1),this.setMessageBody(),At.Api.showReport(vt.i18n("OPENPGP/REPORT_MESSAGE_SUCCESSFULLY_VERIFIED"))),o&&(o.errors||o.notices)&&At.Api.showPgpErrorByCode(o,yt.PgpAction.Verify)},rt.prototype.testFunction=function(){At.Api.pgp(function(){})},at.prototype.executeCheckMail=function(){At.MailCache.checkMessageFlags(),At.MailCache.executeCheckMail()},at.prototype.openMessageInNewWindow=function(e){var s=this.folderList().getFolderByFullName(e.folder()),i=s.type()===yt.FolderTypes.Drafts;!this.oMessagePane.currentMessage()||this.oMessagePane.currentMessage().uid()!==e.uid()||""===this.oMessagePane.replyText()&&""===this.oMessagePane.replyDraftUid()||(t.oReplyDataFromViewPane={ReplyText:this.oMessagePane.replyText(),ReplyDraftUid:this.oMessagePane.replyDraftUid()},this.oMessagePane.replyText(""),this.oMessagePane.replyDraftUid("")),vt.WindowOpener.openMessage(e,i)},at.prototype.gotoFolderList=function(){this.changeSelectedPanel(yt.MobilePanel.Groups)},at.prototype.gotoMessageList=function(){return this.changeSelectedPanel(yt.MobilePanel.Items),!0},at.prototype.gotoMessagePane=function(){At.MailCache.currentMessage()?this.changeSelectedPanel(yt.MobilePanel.View):this.gotoMessageList()},at.prototype.changeSelectedPanel=function(e){this.mobileApp&&this.selectedPanel()!==e&&this.selectedPanel(e)},at.prototype.resizeDblClick=function(t,s){s.preventDefault(),s.stopPropagation?s.stopPropagation():s.cancelBubble=!0,vt.removeSelection(),this.jqPanelHelper||(this.jqPanelHelper=e(".MailLayout .panel_helper")),this.jqPanelHelper.trigger("resize",[600,"max"])},at.prototype.onRoute=function(e){this.oMessageList.onRoute(e),this.oMessagePane.onRoute(e)},at.prototype.onShow=function(){this.oMessageList.onShow()},at.prototype.onHide=function(){this.oMessageList.onHide()},at.prototype.onApplyBindings=function(){var t=this;this.oMessageList.onApplyBindings(this.$viewModel),this.oMessagePane.onApplyBindings(this.$viewModel),e(this.domFolderList()).on("click","span.folder",function(s){s.ctrlKey?t.oMessageList.executeCopyToFolder(e(this).data("folder")):t.oMessageList.executeMoveToFolder(e(this).data("folder"))}),this.hotKeysBind()},at.prototype.hotKeysBind=function(){e(document).on("keydown",e.proxy(function(e){var s=e.keyCode,i=e&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&!vt.isTextFieldFocused()&&At.Screens.currentScreen()===yt.Screens.Mailbox,o=this.oMessageList,n=o.collection()[0],r=n&&At.MailCache.currentMessage()&&n.uid()===At.MailCache.currentMessage().uid();i&&s===yt.Key.s||i&&r&&s===yt.Key.Up?(e.preventDefault(),this.searchFocus()):o.isFocused()&&e&&s===yt.Key.Down&&n?(e.preventDefault(),o.isFocused(!1),o.routeForMessage(n)):i&&s===yt.Key.n&&(t.location.href="#compose")},this))},at.prototype.dragAndDropHelper=function(t){t&&t.checked(!0);var s=vt.draggableMessages(),i=this.oMessageList.checkedOrSelectedUids(),o=i.length;return s.data("p7-message-list-folder",this.folderList().currentFolderFullName()),s.data("p7-message-list-uids",i),e(".count-text",s).text(vt.i18n("MAILBOX/DRAG_TEXT_PLURAL",{COUNT:o},null,o)),s},at.prototype.messagesDrop=function(e,t,s){if(e){var i=s&&s.helper?s.helper:null,o=i?i.data("p7-message-list-folder"):"",n=i?i.data("p7-message-list-uids"):null;""!==o&&null!==n&&(vt.uiDropHelperAnim(t,s),t.ctrlKey?this.oMessageList.executeCopyToFolder(e.fullName()):this.oMessageList.executeMoveToFolder(e.fullName()))}},at.prototype.searchFocus=function(){this.oMessageList.selector.useKeyboardKeys()&&!vt.isTextFieldFocused()&&this.oMessageList.isFocused(!0)},at.prototype.backToList=function(){At.Routing.setPreviousHash()},at.prototype.onVolumerClick=function(e,t){t.stopPropagation()},lt.prototype.__name="CComposeViewModel",lt.prototype.changeSelectedFetcherOrIdentity=function(e){e?e.id()!==(this.selectedFetcherOrIdentity()&&this.selectedFetcherOrIdentity().id())&&this.selectedFetcherOrIdentity(e):null!==this.selectedFetcherOrIdentity()&&this.selectedFetcherOrIdentity(null)},lt.prototype.isEnableSending=function(){var e=0===this.toAddr().length&&0===this.ccAddr().length&&0===this.bccAddr().length,t=0!==this.folderList().iAccountId;return t&&!this.sending()&&!e&&this.allAttachmentsUploaded()},lt.prototype.isEnableSaving=function(){var e=this.folderList()&&0!==this.folderList().iAccountId;return this.shown()&&e&&!this.sending()&&!this.saving()},lt.prototype.onApplyBindings=function(){At.registerSessionTimeoutFunction(_.bind(this.executeSave,this,!1));var t=_.bind(function(e,t){this.autocompleteCallback(e.term,t)},this);this.allowDropbox&&vt.loadScript("https://www.dropbox.com/static/api/2/dropins.js",null,{id:"dropboxjs","data-app-key":this.dropboxKey}),this.initUploader(),e(this.toAddrDom()).inputosaurus({width:"auto",parseOnBlur:!0,autoCompleteSource:t,change:_.bind(function(e){this.lockToAddr(!0),this.setRecipient(this.toAddr,e.target.value),this.lockToAddr(!1)},this),copy:_.bind(function(e){this.inputosaurusBuffer=e},this),paste:_.bind(function(){var e=this.inputosaurusBuffer||"";return this.inputosaurusBuffer="",e},this),mobileDevice:Pt}),e(this.ccAddrDom()).inputosaurus({width:"auto",parseOnBlur:!0,autoCompleteSource:t,change:_.bind(function(e){this.lockCcAddr(!0),this.setRecipient(this.ccAddr,e.target.value),this.lockCcAddr(!1)},this),copy:_.bind(function(e){this.inputosaurusBuffer=e},this),paste:_.bind(function(){var e=this.inputosaurusBuffer||"";return this.inputosaurusBuffer="",e},this),mobileDevice:Pt}),e(this.bccAddrDom()).inputosaurus({width:"auto",parseOnBlur:!0,autoCompleteSource:t,change:_.bind(function(e){this.lockBccAddr(!0),this.setRecipient(this.bccAddr,e.target.value),this.lockBccAddr(!1)},this),copy:_.bind(function(e){this.inputosaurusBuffer=e},this),paste:_.bind(function(){var e=this.inputosaurusBuffer||"";return this.inputosaurusBuffer="",e},this),mobileDevice:Pt}),this.hotKeysBind()},lt.prototype.hotKeysBind=function(){e(document).on("keydown",e.proxy(function(e){if(e&&e.ctrlKey&&!e.altKey&&!e.shiftKey){var t=e.keyCode,s=At.Screens.currentScreen(),i=s===yt.Screens.Compose||s===yt.Screens.SingleCompose,o=i&&e&&e.ctrlKey,n=this.editableArea(),r=yt.Key;!n&&this.oHtmlEditor.oCrea&&this.editableArea(this.oHtmlEditor.oCrea.$editableArea[0]),o&&t===r.s?(e.preventDefault(),e.returnValue=!1,this.isEnableSaving()&&this.saveCommand()):o&&t===r.Enter&&""!==this.toAddr()&&this.sendCommand()}},this))},lt.prototype.getMessageOnRoute=function(){var e=this.routeParams(),t="",s="";""!==this.routeType()&&3===e.length&&(t=e[1],s=e[2],At.MailCache.getMessage(t,s,this.onMessageResponse,this)),this.routeParams([])},lt.prototype.onShow=function(){this.useSaveMailInSentItems(Et.User.getUseSaveMailInSentItems()),this.saveMailInSentItems(Et.User.getSaveMailInSentItems()),this.oHtmlEditor.initCrea(this.textBody(),this.plainText(),"7"),this.commitedTextBody(this.oHtmlEditor.getText()),this.shown(!0),this.backToListOnSendOrSave(!1),this.startAutosaveTimer(),this.focusAfterFilling(),Mt.addClass("screen-compose"),this.oJua&&this.oJua.setDragAndDropEnabledStatus(!0),this.getSocialAccounts()},lt.prototype.onRoute=function(e){var s="",i={};switch(this.plainText(!1),this.pgpSecured(!1),this.pgpEncrypted(!1),this.fromDrafts(!1),this.changeSenderAccountId(Et.Accounts.currentId()),this.bUploadStatus=!1,t.clearTimeout(this.iUploadAttachmentsTimer),this.messageUploadAttachmentsStarted(!1),this.draftUid(""),this.draftInfo.removeAll(),this.setDataFromMessage(new N),this.isDraftsCleared(!1),this.routeType(e.length>0?e[0]:""),this.routeType()){case yt.ReplyType.Reply:case yt.ReplyType.ReplyAll:case yt.ReplyType.Resend:case yt.ReplyType.Forward:case"drafts":this.routeParams(e),0!==this.folderList().iAccountId&&this.getMessageOnRoute();break;default:s=At.MessageSender.getSignatureText(this.senderAccountId(),null,!0),Et.SingleMode&&t.opener&&t.opener.oMessageParametersFromCompose?(this.setMessageDataInSingleMode(t.opener.oMessageParametersFromCompose),t.opener.oMessageParametersFromCompose=void 0):""!==s&&this.textBody("<br /><br />"+s+"<br />"),"to"===this.routeType()&&2===e.length&&(i=At.Links.parseToAddr(e[1]),this.setRecipient(this.toAddr,i.to),i.hasMailto&&(this.subject(i.subject),this.setRecipient(this.ccAddr,i.cc),this.setRecipient(this.bccAddr,i.bcc),this.textBody(i.body))),"vcard"===this.routeType()&&2===e.length&&this.addContactAsAttachment(e[1]),"file"===this.routeType()&&2===e.length&&this.addFilesAsAttachment(e[1]),"data-as-file"===this.routeType()&&3===e.length&&this.addDataAsAttachment(e[1],e[2])}this.visibleCc(""!==this.ccAddr()),this.visibleBcc(""!==this.bccAddr()),this.commit(),this.focusAfterFilling(),this.allowFiles(Et.User.IsFilesSupported&&Et.User.filesEnable())},lt.prototype.focusAfterFilling=function(){0===this.toAddr().length?(this.toAddrFocused(!0),this.toAddrFocused.valueHasMutated()):0===this.subject().length?this.subjectFocused(!0):this.oHtmlEditor.setFocus()},lt.prototype.beforeHide=function(e){var t=vt.i18n("COMPOSE/CONFIRM_DISCARD_CHANGES"),s=_.bind(function(t){t&&vt.isFunc(e)?(this.commit(),e()):At.Routing.historyBackWithoutParsing(yt.Screens.Compose)},this);!this.isChanged()||this.isEmpty()||this.sending()||this.saving()?vt.isFunc(e)&&e():At.Screens.showPopup(y,[t,s])},lt.prototype.onHide=function(){this.isChanged()&&!this.isEmpty()&&this.executeSave(!0),this.shown(!1),this.stopAutosaveTimer(),this.toAddrFocused(!1),this.ccAddrFocused(!1),this.bccAddrFocused(!1),this.subjectFocused(!1),this.oHtmlEditor.closeAllPopups(),this.oHtmlEditor.visibleLinkPopup(!1),this.messageUploadAttachmentsStarted(!1),Mt.removeClass("screen-compose").removeClass("screen-compose-cc").removeClass("screen-compose-bcc").removeClass("screen-compose-attachments"),this.oJua&&this.oJua.setDragAndDropEnabledStatus(!1)},lt.prototype.sendingAndSavingSubscription=function(){(this.sending()||this.saving())&&this.stopAutosaveTimer(),this.sending()||this.saving()||this.startAutosaveTimer()},lt.prototype.stopAutosaveTimer=function(){t.clearTimeout(this.autoSaveTimer)},lt.prototype.startAutosaveTimer=function(){if(this.shown()&&!this.pgpSecured()){var e=_.bind(this.executeSave,this,!0);this.stopAutosaveTimer(),Et.User.AllowAutosaveInDrafts&&(this.autoSaveTimer=t.setTimeout(e,1e3*Et.App.AutoSaveIntervalSeconds))}},lt.prototype.setRecipient=function(e,t){e()===t?e.valueHasMutated():e(t)},lt.prototype.onMessageResponse=function(e){var t=null,s=null,i=e.oTo.aCollection.concat(e.oCc.aCollection),o=!1;if(null===e)this.setDataFromMessage(new N);else{switch(s=At.MessageSender.getFetcherOrIdentityByRecipients(i,e.accountId()),o=At.MessageSender.isFetcherOrIdentitySameAsChiefAccount(this.senderAccountId()),this.routeType()){case yt.ReplyType.Reply:case yt.ReplyType.ReplyAll:s&&!o&&this.changeSelectedFetcherOrIdentity(s),t=At.MessageSender.getReplyDataFromMessage(e,this.routeType(),this.senderAccountId(),s,!0),this.draftInfo(t.DraftInfo),this.draftUid(t.DraftUid),this.setRecipient(this.toAddr,t.To),this.setRecipient(this.ccAddr,t.Cc),this.setRecipient(this.bccAddr,t.Bcc),this.subject(t.Subject),this.textBody(t.Text),this.attachments(t.Attachments),this.inReplyTo(t.InReplyTo),this.references(t.References);break;case yt.ReplyType.Forward:t=At.MessageSender.getReplyDataFromMessage(e,this.routeType(),this.senderAccountId(),s,!0),this.draftInfo(t.DraftInfo),this.draftUid(t.DraftUid),this.setRecipient(this.toAddr,t.To),this.setRecipient(this.ccAddr,t.Cc),this.subject(t.Subject),this.textBody(t.Text),this.attachments(t.Attachments),this.inReplyTo(t.InReplyTo),this.references(t.References);break;case yt.ReplyType.Resend:this.setDataFromMessage(e);break;case"drafts":e.subject().substring(0,3)!==vt.i18n("COMPOSE/FORWARD_PREFIX")&&this.changeSelectedFetcherOrIdentity(s),this.draftUid(e.uid()),this.setDataFromMessage(e),this.fromDrafts(!0)}this.routeType("")}this.attachments().length>0&&this.requestAttachmentsTempName(),this.visibleCc(""!==this.ccAddr()),this.visibleBcc(""!==this.bccAddr()),this.commit(),this.focusAfterFilling()},lt.prototype.changeSenderAccountId=function(e,t,s){Et.Accounts.hasAccountWithId(e)?this.senderAccountId(e):Et.Accounts.hasAccountWithId(this.senderAccountId())||this.senderAccountId(Et.Accounts.currentId()),this.fillSenderList(t,s)},lt.prototype.fillSenderList=function(e,t){var s=[],i=Et.Accounts.getAccount(this.senderAccountId());i&&(s.push({fullEmail:i.fullEmail(),id:""}),i.fetchers()?_.each(i.fetchers().collection(),function(e){var t=e.fullEmail();e.isOutgoingEnabled()&&t.length>0&&s.push({fullEmail:t,id:"fetcher"+e.id()})},this):i.fetchersSubscribtion||(i.fetchersSubscribtion=i.fetchers.subscribe(function(){this.fillSenderList(e,t)},this)),_.isArray(i.identities())?_.each(i.identities(),function(e){e.enabled()&&s.push({fullEmail:e.fullEmail(),id:vt.pString(e.id())})},this):i.identitiesSubscribtion||(i.identitiesSubscribtion=i.identities.subscribe(function(){this.fillSenderList(e,t)},this))),this.senderList(s.length>0?s:[]),e&&""!==e?this.changeSelectedSenderByEmail(e):this.changeSelectedFetcherOrIdentity(t||null)},lt.prototype.changeSelectedSenderByEmail=function(e){var t=Et.Accounts.getAccount(this.senderAccountId()),s=t?t.getFetcherOrIdentityByEmail(e):null;s&&s.id()&&t.email()!==e&&this.changeSelectedFetcherOrIdentity(s)},lt.prototype.setDataFromMessage=function(e){var t="",s=!1,i=!1;e.isPlain()?(s=-1!==e.textRaw().indexOf("-----BEGIN PGP MESSAGE-----"),i=-1!==e.textRaw().indexOf("-----BEGIN PGP SIGNED MESSAGE-----"),i||s?(t=e.textRaw(),this.pgpSecured(!0),this.pgpEncrypted(s)):t=e.textRaw()):t=e.getConvertedHtml(),this.draftInfo(e.draftInfo()),this.inReplyTo(e.inReplyTo()),this.references(e.references()),this.setRecipient(this.toAddr,e.oTo.getFull()),this.setRecipient(this.ccAddr,e.oCc.getFull()),this.setRecipient(this.bccAddr,e.oBcc.getFull()),this.subject(e.subject()),this.attachments(e.attachments()),this.plainText(e.isPlain()),this.textBody(t),this.selectedImportance(e.importance()),this.selectedSensitivity(e.sensitivity()),this.readingConfirmation(e.readingConfirmation()),this.changeSenderAccountId(e.accountId(),e.oFrom.getFirstEmail())},lt.prototype.addDataAsAttachment=function(e,t){var s="data-as-attachment-"+Math.random(),i={Action:"DataAsAttachmentUpload",Data:e,FileName:t,Hash:s},o=new P;this.subject(t.substr(0,t.length-4)),o.fileName(t),o.hash(s),o.uploadStarted(!0),this.attachments.push(o),this.messageUploadAttachmentsStarted(!0),At.Ajax.send(i,this.onDataAsAttachmentUpload,this)},lt.prototype.onDataAsAttachmentUpload=function(e,t){var s=e.Result,i=t.Hash,o=_.find(this.attachments(),function(e){return e.hash()===i});this.messageUploadAttachmentsStarted(!1),o&&(s&&s.Attachment?o.parseFromUpload(s.Attachment,e.AccountID):o.errorFromUpload())},lt.prototype.addFilesAsAttachment=function(e){var t=null,s=[],i=null;_.each(e,function(e){t=new P,t.fileName(e.fileName()),t.hash(e.hash()),t.thumb(e.thumb()),t.uploadStarted(!0),this.attachments.push(t),s.push(e.hash())},this),s.length>0&&(i={Action:"FilesUpload",Hashes:s},this.messageUploadAttachmentsStarted(!0),At.Ajax.send(i,this.onFilesUpload,this))},lt.prototype.onFilesUpload=function(t,s){var i=t.Result,o=s.Hashes,n=Date.now().toString();this.messageUploadAttachmentsStarted(!1),e.isArray(i)?_.each(i,function(e){var s=_.find(this.attachments(),function(t){return t.hash()===e.Hash});s&&(s.parseFromUpload(e,t.AccountID),s.hash(e.NewHash),s.getInThumbQueue(n))},this):_.each(o,function(e){var t=_.find(this.attachments(),function(t){return t.hash()===e});t&&t.errorFromUpload()},this)},lt.prototype.addContactAsAttachment=function(e){var t=new P,s=null;e&&(t.fileName("contact-"+e.idContact()+".vcf"),t.uploadStarted(!0),this.attachments.push(t),s={Action:"ContactVCardUpload",ContactId:e.idContact(),Global:e.global()?"1":"0",Name:t.fileName()},this.messageUploadAttachmentsStarted(!0),At.Ajax.send(s,this.onContactVCardUpload,this))},lt.prototype.onContactVCardUpload=function(e,t){var s=e.Result,i=null;this.messageUploadAttachmentsStarted(!1),s?(i=_.find(this.attachments(),function(e){return e.fileName()===s.Name&&e.uploadStarted()}),i&&i.parseFromUpload(s,e.AccountID)):(i=_.find(this.attachments(),function(e){return e.fileName()===t.Name&&e.uploadStarted()}),i&&i.errorFromUpload())},lt.prototype.requestAttachmentsTempName=function(){var e=_.map(this.attachments(),function(e){return e.uploadUid(e.hash()),e.uploadStarted(!0),e.hash()}),t={Action:"MessageUploadAttachments",Attachments:e};e.length>0&&(this.messageUploadAttachmentsStarted(!0),At.Ajax.send(t,this.onMessageUploadAttachmentsResponse,this))},lt.prototype.onMessageUploadAttachmentsResponse=function(e,t){var s=t.Attachments;this.messageUploadAttachmentsStarted(!1),e.Result?_.each(e.Result,_.bind(this.setAttachTepmNameByHash,this)):(_.each(s,function(e){var t=_.find(this.attachments(),function(t){return t.hash()===e});t&&t.errorFromUpload()},this),At.Api.showError(vt.i18n("COMPOSE/UPLOAD_ERROR_REPLY_ATTACHMENTS")))},lt.prototype.setAttachTepmNameByHash=function(e,t){_.each(this.attachments(),function(s){s.hash()===e&&(s.tempName(t),s.uploadStarted(!1))})},lt.prototype.setMessageDataInSingleMode=function(e){this.draftInfo(e.draftInfo),this.draftUid(e.draftUid),this.inReplyTo(e.inReplyTo),this.references(e.references),this.setRecipient(this.toAddr,e.toAddr),this.setRecipient(this.ccAddr,e.ccAddr),this.setRecipient(this.bccAddr,e.bccAddr),this.subject(e.subject),this.attachments(_.map(e.attachments,function(e){var t=new P;return t.parse(e,this.senderAccountId()),t},this)),this.textBody(e.textBody),this.selectedImportance(e.selectedImportance),this.selectedSensitivity(e.selectedSensitivity),this.readingConfirmation(e.readingConfirmation),this.changeSenderAccountId(e.senderAccountId,"",e.selectedFetcherOrIdentity)},lt.prototype.isEmpty=function(){var e=vt.trim(this.toAddr()),t=vt.trim(this.ccAddr()),s=vt.trim(this.bccAddr()),i=vt.trim(this.subject()),o=this.oHtmlEditor.getText(),n=vt.trim(o.replace(/<br *\/{0,1}>/gi,"\n").replace(/<[^>]*>/g,"").replace(/&nbsp;/g," "));return""===e&&""===t&&""===s&&""===i&&0===this.attachments().length&&""===n},lt.prototype.commit=function(){this.toAddr.commit(),this.ccAddr.commit(),this.bccAddr.commit(),this.subject.commit(),this.commitedTextBody(this.oHtmlEditor.getText()),this.attachmentsChanged(!1)},lt.prototype.isChanged=function(){var t=""===e(this.toAddrDom()).inputosaurus("getNotParsedValue"),s=""===e(this.ccAddrDom()).inputosaurus("getNotParsedValue"),i=""===e(this.bccAddrDom()).inputosaurus("getNotParsedValue");return this.toAddr.changed()||!t||this.ccAddr.changed()||!s||this.bccAddr.changed()||!i||this.subject.changed()||this.commitedTextBody()!==this.oHtmlEditor.getText()||this.attachmentsChanged()},lt.prototype.executeBackToList=function(){Et.SingleMode?t.close():this.shown()&&At.Routing.setPreviousHash(),this.backToListOnSendOrSave(!1)},lt.prototype.onFileUploadSelect=function(e,t){var s,i=vt.i18n("COMPOSE/UPLOAD_ERROR_FILENAME_SIZE",{FILENAME:t.FileName,MAXSIZE:vt.friendlySize(Et.App.AttachmentSizeLimit)});return Et.App.AttachmentSizeLimit>0&&t.Size>Et.App.AttachmentSizeLimit?(At.Screens.showPopup(b,[i]),!1):(s=new P,s.onUploadSelect(e,t),this.attachments.push(s),!0)},lt.prototype.getAttachmentByUid=function(e){return _.find(this.attachments(),function(t){return t.uploadUid()===e})},lt.prototype.onFileUploadStart=function(e){var t=this.getAttachmentByUid(e);t&&t.onUploadStart()},lt.prototype.onFileUploadProgress=function(e,t,s){var i=this.getAttachmentByUid(e);i&&i.onUploadProgress(t,s)},lt.prototype.onFileUploadComplete=function(e,t,s){var i=this.getAttachmentByUid(e),o=Date.now().toString();i&&(i.onUploadComplete(e,t,s),"image"===i.type().substr(0,5)&&(i.thumb(!0),i.getInThumbQueue(o)))},lt.prototype.onFileRemove=function(e){var t=this.getAttachmentByUid(e);this.oJua&&this.oJua.cancel(e),this.attachments.remove(t)},lt.prototype.initUploader=function(){this.composeUploaderButton()&&(this.oJua=new Jua({action:"?/Upload/Attachment/",name:"jua-uploader",queueSize:2,clickElement:this.composeUploaderButton(),dragAndDropElement:this.composeUploaderDropPlace(),disableAjaxUpload:!1,disableFolderDragAndDrop:!1,disableDragAndDrop:!1,hidden:{Token:function(){return Et.Token},AccountID:function(){return Et.Accounts.currentId()}}}),this.oJua.on("onDragEnter",_.bind(this.composeUploaderDragOver,this,!0)).on("onDragLeave",_.bind(this.composeUploaderDragOver,this,!1)).on("onBodyDragEnter",_.bind(this.composeUploaderBodyDragOver,this,!0)).on("onBodyDragLeave",_.bind(this.composeUploaderBodyDragOver,this,!1)).on("onProgress",_.bind(this.onFileUploadProgress,this)).on("onSelect",_.bind(this.onFileUploadSelect,this)).on("onStart",_.bind(this.onFileUploadStart,this)).on("onComplete",_.bind(this.onFileUploadComplete,this)),this.allowDragNDrop(this.oJua.isDragAndDropSupported()))},lt.prototype.getSendSaveParameters=function(e){var t=At.MessageSender.convertAttachmentsForSending(this.attachments());return _.each(this.oHtmlEditor.uploadedImagePathes(),function(e){t[e.TempName]=[e.Name,e.CID,"1","1"]}),{AccountID:this.senderAccountId(),FetcherID:this.selectedFetcherOrIdentity()&&this.selectedFetcherOrIdentity().FETCHER?this.selectedFetcherOrIdentity().id():"",IdentityID:this.selectedFetcherOrIdentity()&&!this.selectedFetcherOrIdentity().FETCHER?this.selectedFetcherOrIdentity().id():"",DraftInfo:this.draftInfo(),DraftUid:this.draftUid(),To:this.toAddr(),Cc:this.ccAddr(),Bcc:this.bccAddr(),Subject:this.subject(),Text:this.plainText()?this.oHtmlEditor.getPlainText():this.oHtmlEditor.getText(e),IsHtml:this.plainText()?"0":"1",Importance:this.selectedImportance(),Sensivity:this.selectedSensitivity(),ReadingConfirmation:this.readingConfirmation()?"1":"0",Attachments:t,InReplyTo:this.inReplyTo(),References:this.references()}},lt.prototype.onMessageSendOrSaveResponse=function(e,t){var s=At.MessageSender.onMessageSendOrSaveResponse(e,t);switch(this.commit(),s.Action){case"MessageSave":s.Result&&s.NewUid&&this.draftUid(s.NewUid),this.saving(!1);break;case"MessageSend":s.Result&&(At.MailCache.deletedDraftMessageUid(this.draftUid()),this.backToListOnSendOrSave()&&this.executeBackToList()),this.sending(!1)}},lt.prototype.verifyDataForSending=function(){var e=vt.getIncorrectEmailsFromAddressString(this.toAddr()),t=vt.getIncorrectEmailsFromAddressString(this.ccAddr()),s=vt.getIncorrectEmailsFromAddressString(this.bccAddr()),i=_.union(e,t,s),o=vt.i18n("COMPOSE/WARNING_INPUT_CORRECT_EMAILS")+i.join(", ");return i.length>0?(At.Screens.showPopup(b,[o]),!1):!0},lt.prototype.executeSend=function(e){var t=e===!0;this.isEnableSending()&&this.verifyDataForSending()&&(!t&&this.enableOpenPgp()&&Et.User.AutosignOutgoingEmails&&!this.pgpSecured()?this.openPgpPopup(!0):(this.sending(!0),this.requiresPostponedSending(!this.allowStartSending()),At.MessageSender.send("MessageSend",this.getSendSaveParameters(!0),this.saveMailInSentItems(),!0,this.onMessageSendOrSaveResponse,this,this.requiresPostponedSending())),this.backToListOnSendOrSave(!0))},lt.prototype.executeSaveCommand=function(){this.executeSave(!1)},lt.prototype.executeSave=function(e){var t=vt.i18n("OPENPGP/CONFIRM_SAVE_ENCRYPTED_DRAFT"),s=vt.i18n("COMPOSE/TOOL_SAVE"),i=_.bind(function(t){t&&(this.saving(!0),At.MessageSender.send("MessageSave",this.getSendSaveParameters(!1),this.saveMailInSentItems(),!e,this.onMessageSendOrSaveResponse,this))},this);this.isEnableSaving()&&(!e||this.isChanged()?!e&&this.pgpSecured()?At.Screens.showPopup(y,[t,i,"",s]):i(!0):e&&this.startAutosaveTimer(),this.backToListOnSendOrSave(!0))},lt.prototype.changeBccVisibility=function(){this.visibleBcc(!this.visibleBcc()),this.visibleBcc()?this.bccAddrFocused(!0):this.toAddrFocused(!0)},lt.prototype.changeCcVisibility=function(){this.visibleCc(!this.visibleCc()),this.visibleCc()?this.ccAddrFocused(!0):this.toAddrFocused(!0)},lt.prototype.getMessageDataForSingleMode=function(){var e=_.map(this.attachments(),function(e){return{"@Object":"Object/CApiMailAttachment",FileName:e.fileName(),TempName:e.tempName(),MimeType:e.type(),MimePartIndex:e.mimePartIndex(),EstimatedSize:e.size(),CID:e.cid(),ContentLocation:e.contentLocation(),IsInline:e.inline(),IsLinked:e.linked(),Hash:e.hash()}
});return{draftInfo:this.draftInfo(),draftUid:this.draftUid(),inReplyTo:this.inReplyTo(),references:this.references(),senderAccountId:this.senderAccountId(),selectedFetcherOrIdentity:this.selectedFetcherOrIdentity(),toAddr:this.toAddr(),ccAddr:this.ccAddr(),bccAddr:this.bccAddr(),subject:this.subject(),attachments:e,textBody:this.oHtmlEditor.getText(),selectedImportance:this.selectedImportance(),selectedSensitivity:this.selectedSensitivity(),readingConfirmation:this.readingConfirmation()}},lt.prototype.openInNewWindow=function(){t.oMessageParametersFromCompose=this.getMessageDataForSingleMode(),vt.WindowOpener.openTab("#"+yt.Screens.SingleCompose),this.commit(),this.executeBackToList()},lt.prototype.autocompleteCallback=function(e,t){var s={Action:"ContactSuggestions",Search:e};e=vt.trim(e),""!==e?At.Ajax.send(s,function(e){var s=[];e&&e.Result&&e.Result&&e.Result.List&&(s=_.map(e.Result.List,function(e){var t="",s=e.Email;return e.IsGroup?t=e.Name&&0<vt.trim(e.Name).length?'"'+e.Name+'" ('+e.Email+")":"("+e.Email+")":e.Name&&0<vt.trim(e.Name).length?(t='"'+e.Name+'" <'+e.Email+">",s=t):t=e.Email,{label:t,value:s,frequency:e.Frequency}}),s=_.compact(s)),t(s)},this):t([])},lt.prototype.onShowFilesPopupClick=function(){var e=_.bind(this.addFilesAsAttachment,this);At.Screens.showPopup(FileStoragePopup,[e])},lt.prototype.onShowGoogleDriveClick=function(){At.Screens.showPopup(GooglePickerPopup,[_.bind(this.googlePickerCallback,this)])},lt.prototype.googlePickerCallback=function(e,t){var s=null,i=[],o={},n=this;_.each(e,function(e){s=(new P).fileName(e.name).hash(e.id).size(e.sizeBytes).uploadStarted(!0).type(e.mimeType),"image"===s.type().substr(0,5)&&s.thumb(!0),n.attachments.push(s),i.push(e.id)},this),o={Action:"FilesUploadByLink",Links:i,LinksAsIds:!0,AccessToken:t},this.messageUploadAttachmentsStarted(!0),At.Ajax.send(o,this.onFilesUpload,this)},lt.prototype.onShowDropBoxClick=function(){var e=null,s=[],i={},o=this,n={success:function(t){_.each(t,function(t){e=(new P).fileName(t.name).hash(t.link).size(t.bytes).uploadStarted(!0).thumb(!!t.thumbnailLink),o.attachments.push(e),s.push(t.link)},o),i={Action:"FilesUploadByLink",Links:s},o.messageUploadAttachmentsStarted(!0),At.Ajax.send(i,o.onFilesUpload,o)},cancel:function(){},linkType:"direct",multiselect:!0};this.allowDropbox&&t.Dropbox&&t.Dropbox.choose(n)},lt.prototype.confirmOpenPgp=function(){var e=vt.i18n("OPENPGP/CONFIRM_HTML_TO_PLAIN_FORMATTING"),t=_.bind(function(e){e&&this.openPgpPopup(!1)},this);this.notInlineAttachments().length>0&&(e+="\r\n\r\n"+vt.i18n("OPENPGP/CONFIRM_HTML_TO_PLAIN_ATTACHMENTS")),At.Screens.showPopup(y,[e,t])},lt.prototype.openPgpPopup=function(e){var t=this.oHtmlEditor.getPlainText(),s=_.bind(function(t,s){e||(this.stopAutosaveTimer(),this.executeSave(!0)),this.plainText(!0),this.textBody(t),this.pgpSecured(!0),this.pgpEncrypted(s),e&&this.executeSend(!0)},this),i=_.bind(function(){e&&this.executeSend(!0)},this);At.Screens.showPopup(COpenPgpEncryptPopup,[t,Et.Accounts.getEmail(),this.recipientEmails(),e,s,i])},lt.prototype.undoPgp=function(){var e=this.textBody(),t=[];this.pgpSecured()&&(this.plainText(!1),this.fromDrafts()&&!this.pgpEncrypted()?(t=e.split("-----BEGIN PGP SIGNED MESSAGE-----"),2===t.length&&(e=t[1]),t=e.split("-----BEGIN PGP SIGNATURE-----"),2===t.length&&(e=t[0]),t=e.split("\r\n\r\n"),t.length>0&&(t.shift(),e=t.join("\r\n\r\n")),e="<div>"+e.replace(/\r\n/gi,"<br />")+"</div>",this.textBody(e)):this.oHtmlEditor.undoAndClearRedo(),this.pgpSecured(!1),this.pgpEncrypted(!1))},lt.prototype.getSocialAccounts=function(){this.googleConnected(!1),this.dropboxConnected(!1),_.each(Et.User.SocialAccounts(),function(e){"Object/CSocial"===e["@Object"]&&(e.Type===yt.SocialType.Google?this.googleConnected(!0):e.Type===yt.SocialType.Dropbox&&this.dropboxConnected(!0))},this)},ht.prototype.onFileImportStart=function(){this.importing(!0)},ht.prototype.onFileImportComplete=function(e,t,s){if(this.importing(!1),this.oParent.requestContactList(),t&&s&&s.Result){var i=vt.pInt(s.Result.ImportedCount);i>0?At.Api.showReport(vt.i18n("CONTACTS/CONTACT_IMPORT_HINT_PLURAL",{NUM:i},null,i)):At.Api.showError(vt.i18n("WARNING/CONTACTS_IMPORT_NO_CONTACTS"))}else At.Api.showError(vt.i18n("WARNING/CONTACTS_IMPORT_ERROR"))},ht.prototype.onApplyBindings=function(t){this.oJua=new Jua({action:"?/Upload/Contacts/",name:"jua-uploader",queueSize:1,clickElement:e("#jue_import_button",t),disableAjaxUpload:!1,disableDragAndDrop:!0,disableMultiple:!0,hidden:{Token:function(){return Et.Token},AccountID:function(){return Et.Accounts.currentId()}}}),this.oJua.on("onStart",_.bind(this.onFileImportStart,this)).on("onComplete",_.bind(this.onFileImportComplete,this))},ct.prototype.groupDropdownToggle=function(e){this.currentGroupDropdown(e)},ct.prototype.gotoGroupList=function(){this.changeSelectedPanel(yt.MobilePanel.Groups)},ct.prototype.gotoContactList=function(){return this.changeSelectedPanel(yt.MobilePanel.Items),!0},ct.prototype.gotoViewPane=function(){this.changeSelectedPanel(yt.MobilePanel.View)},ct.prototype.backToContactList=function(){var e=this.selectedGroupType(),t=e===yt.ContactsGroupListType.SubGroup?this.currentGroupId():"";At.Routing.setHash(At.Links.contacts(e,t,this.search(),this.oPageSwitcher.currentPage()))},ct.prototype.changeSelectedPanel=function(e){this.mobileApp&&this.selectedPanel(e)},ct.prototype.executeSave=function(e){var t={},s=[];e===this.selectedItem()&&this.selectedItem().canBeSave()?e instanceof O&&!e.readOnly()?(_.each(this.groupFullCollection(),function(e){e&&e.checked()&&s.push(e.Id())}),e.groups(s),t=e.toObject(),t.Action=e.isNew()?"ContactCreate":"ContactUpdate",t.SharedToAll=e.isNew()?yt.ContactsGroupListType.SharedToAll===this.selectedGroupType()?"1":"0":e.sharedToAll()?"1":"0",e.edited()&&e.edited(!1),e.isNew()&&this.selectedItem(null),(this.selectedGroupType()===yt.ContactsGroupListType.Global||this.selectedGroupType()===yt.ContactsGroupListType.All)&&this.recivedAnimUnshare(!0),At.Ajax.send(t,this.onContactCreateResponse,this)):e instanceof U&&!e.readOnly()&&(t=e.toObject(),t.Action=e.isNew()?"GroupCreate":"GroupUpdate",this.gotoGroupList(),e.edited()&&e.edited(!1),e.isNew()&&!this.mobileApp&&this.selectedItem(null),At.Ajax.send(t,this.onGroupCreateResponse,this)):At.Api.showError(vt.i18n("CONTACTS/ERROR_EMPTY_CONTACT"))},ct.prototype.executeNewContact=function(){if(this.showPersonalContacts()){var e=this.selectedGroupInList();this.oContactModel.switchToNew(),this.oContactModel.groups(e?[e.Id()]:[]),this.selectedItem(this.oContactModel),this.selector.itemSelected(null),this.gotoViewPane()}},ct.prototype.executeNewGroup=function(){this.oGroupModel.switchToNew(),this.selectedItem(this.oGroupModel),this.selector.itemSelected(null),this.gotoViewPane()},ct.prototype.executeDelete=function(){var e=_.filter(this.selector.listCheckedOrSelected(),function(e){return!e.ReadOnly()}),t=e.length,s=vt.i18n("CONTACTS/CONFIRM_DELETE_CONTACT_PLURAL",{},null,t),i=_.bind(function(t){t&&this.deleteContacts(e)},this);At.Screens.showPopup(y,[s,i])},ct.prototype.deleteContacts=function(e){var t=this,s=this.selectedContact(),i=_.map(e,function(e){return e.Id()});0<i.length&&(_.each(e,function(e){e&&(At.ContactsCache.clearInfoAboutEmail(e.Email()),!s||e.IsGroup()||e.ReadOnly()||s.readOnly()||s.idContact()!==e.Id()||(s=null,this.selectedContact(null)))},this),_.each(this.collection(),function(t){-1<vt.inArray(t,e)&&t.deleted(!0)}),_.delay(function(){t.collection.remove(function(e){return e.deleted()})},500),At.Ajax.send({Action:"ContactDelete",ContactsId:i.join(","),SharedToAll:yt.ContactsGroupListType.SharedToAll===this.selectedGroupType()?"1":"0"},this.requestContactList,this),At.ContactsCache.markVcardsNonexistentByUid(i))},ct.prototype.executeRemoveFromGroup=function(){var e=this,t=this.selectedGroupInList(),s=this.selector.listCheckedOrSelected(),i=_.map(s,function(e){return e.ReadOnly()?"":e.Id()});i=_.compact(i),t&&0<i.length&&(_.each(this.collection(),function(e){-1<vt.inArray(e,s)&&e.deleted(!0)}),_.delay(function(){e.collection.remove(function(e){return e.deleted()})},500),At.Ajax.send({Action:"RemoveContactsFromGroup",GroupId:t.Id(),ContactsId:i.join(",")},this.requestContactList,this))},ct.prototype.executeImport=function(){this.selectedItem(null),this.oContactImportViewModel.visibility(!0),this.selector.itemSelected(null),this.selectedGroupType(yt.ContactsGroupListType.Personal),this.gotoViewPane()},ct.prototype.executeCSVExport=function(){At.Api.downloadByUrl(vt.getExportContactsLink("csv"))},ct.prototype.executeVCFExport=function(){At.Api.downloadByUrl(vt.getExportContactsLink("vcf"))},ct.prototype.executeCancel=function(){var e=this.selectedItem();e&&(e instanceof O&&!e.readOnly()?e.isNew()?this.selectedItem(null):e.edited()&&e.edited(!1):e instanceof U&&!e.readOnly()&&(e.isNew()?this.selectedItem(null):e.edited()&&(this.selectedItem(this.selectedOldItem()),e.edited(!1)),this.gotoGroupList())),this.oContactImportViewModel.visibility(!1)},ct.prototype.executeAddContactsToGroup=function(e,t){e&&_.isArray(t)&&0<t.length&&(e.recivedAnim(!0),At.Ajax.send({Action:"AddContactsToGroup",GroupId:e.Id(),ContactsId:t},this.onAddContactsToGroupResponse,this))},ct.prototype.executeAddContactsToGroupId=function(e,t){e&&_.isArray(t)&&0<t.length&&At.Ajax.send({Action:"AddContactsToGroup",GroupId:e,ContactsId:t},this.onAddContactsToGroupResponse,this)},ct.prototype.onAddContactsToGroupResponse=function(){this.requestContactList(),this.selector.itemSelected()&&this.requestContact(this.selector.itemSelected().sId)},ct.prototype.executeAddSelectedContactsToGroup=function(e){var t=this.selector.listCheckedOrSelected(),s=[];e&&_.isArray(t)&&0<t.length&&_.each(t,function(e){e&&!e.IsGroup()&&s.push([e.Id(),e.Global()?"1":"0"])},this),this.executeAddContactsToGroup(e,s)},ct.prototype.groupsInContactView=function(e){var t=[],s=[];return e&&!e.groupsIsEmpty()&&(s=e.groups(),t=_.filter(this.groupFullCollection(),function(e){return 0<=vt.inArray(e.Id(),s)})),t},ct.prototype.onShow=function(){this.selector.useKeyboardKeys(!0),this.oPageSwitcher.show(),this.oPageSwitcher.perPage(Et.User.ContactsPerPage)},ct.prototype.onHide=function(){this.selector.listCheckedOrSelected(!1),this.selector.useKeyboardKeys(!1),this.selectedItem(null),this.oPageSwitcher.hide()},ct.prototype.onApplyBindings=function(){this.selector.initOnApplyBindings(".contact_sub_list .item",".contact_sub_list .selected.item",".contact_sub_list .item .custom_checkbox",e(".contact_list",this.$viewModel),e(".contact_list_scroll.scroll-inner",this.$viewModel));var t=this;this.$viewModel.on("click",".content .item.add_to .dropdown_helper .item",function(){e(this).hasClass("new-group")?t.executeNewGroup():t.executeAddSelectedContactsToGroup(s.dataFor(this))}),this.showPersonalContacts(!!Et.User.ShowPersonalContacts),this.showGlobalContacts(!!Et.User.ShowGlobalContacts),this.showSharedToAllContacts(!!Et.App.AllowContactsSharing),this.selectedGroupType.valueHasMutated(),this.oContactImportViewModel.onApplyBindings(this.$viewModel),this.requestGroupFullList(),this.hotKeysBind()},ct.prototype.hotKeysBind=function(){var t=!1;e(document).on("keydown",_.bind(function(e){var s=e.keyCode,i=this.collection()[0],o=this.isSearchFocused(),n=!1,r=At.Screens.currentScreen()===yt.Screens.Contacts;r&&!vt.isTextFieldFocused()&&!o&&e&&s===yt.Key.s?(e.preventDefault(),this.searchFocus()):i&&(n=i.selected(),i&&o&&e&&s===yt.Key.Down?(this.isSearchFocused(!1),this.selector.itemSelected(i),t=!0):!o&&t&&n&&e&&s===yt.Key.Up?(this.isSearchFocused(!0),this.selector.itemSelected(!1),t=!1):n?t=!0:n||(t=!1))},this))},ct.prototype.requestContactList=function(){this.loadingList(!0),At.Ajax.send({Action:yt.ContactsGroupListType.Global===this.selectedGroupType()?"GlobalContactList":"ContactList",Offset:(this.oPageSwitcher.currentPage()-1)*Et.User.ContactsPerPage,Limit:Et.User.ContactsPerPage,SortField:this.sortType(),SortOrder:this.sortOrder()?"1":"0",Search:this.search(),GroupId:this.selectedGroupInList()?this.selectedGroupInList().Id():"",SharedToAll:yt.ContactsGroupListType.SharedToAll===this.selectedGroupType()?"1":"0",All:yt.ContactsGroupListType.All===this.selectedGroupType()?"1":"0"},this.onContactListResponse,this)},ct.prototype.requestGroupFullList=function(){At.Ajax.send({Action:"GroupFullList"},this.onGroupListResponse,this)},ct.prototype.requestContact=function(e){this.loadingViewPane(!0);var t=_.find(this.collection(),function(t){return t.sId===e});t&&(this.selector.itemSelected(t),At.Ajax.send({Action:t.Global()?"GlobalContact":"Contact",ContactId:t.Id(),SharedToAll:t.IsSharedToAll()?"1":"0"},this.onContactResponse,this))},ct.prototype.requestContactById=function(e,t){this.loadingViewPane(!0),e&&At.Ajax.send({Action:t?"GlobalContact":"Contact",ContactId:e},this.onContactResponse,this)},ct.prototype.editGroup=function(e){var t=new U;t.populate(e),this.selectedOldItem(t),e.edited(!0)},ct.prototype.changeGroupType=function(e){At.Routing.setHash(At.Links.contacts(e))},ct.prototype.onViewGroupClick=function(e){At.Routing.setHash(At.Links.contacts(yt.ContactsGroupListType.SubGroup,e.Id()))},ct.prototype.onRoute=function(e){var t=At.Links.parseContacts(e),s=[yt.ContactsGroupListType.Personal,yt.ContactsGroupListType.SharedToAll,yt.ContactsGroupListType.Global,yt.ContactsGroupListType.All],i=this.selectedGroupType()===yt.ContactsGroupListType.SubGroup?this.currentGroupId():"",o=this.selectedGroupType()!==t.Type||i!==t.GroupId||this.search()!==t.Search,n=!0,r=!1;this.pageSwitcherLocked(!0),o?this.oPageSwitcher.clear():this.oPageSwitcher.setPage(t.Page,Et.User.ContactsPerPage),this.pageSwitcherLocked(!1),t.Page!==this.oPageSwitcher.currentPage()&&At.Routing.replaceHash(At.Links.contacts(t.Type,t.GroupId,t.Search,this.oPageSwitcher.currentPage())),this.currentPage()!==t.Page&&(this.currentPage(t.Page),r=!0),-1!==vt.inArray(t.Type,s)?this.selectedGroupType(t.Type):i!==t.GroupId&&(n=this.viewGroup(t.GroupId),n?r=!1:At.Routing.replaceHash(At.Links.contacts())),this.search()!==t.Search&&(this.search(t.Search),r=!0),this.contactUidForRequest(""),t.Uid?0===this.collection().length?this.contactUidForRequest(t.Uid):this.requestContact(t.Uid):(this.selector.itemSelected(null),this.gotoContactList()),r&&this.requestContactList()},ct.prototype.viewGroup=function(e){var t=_.find(this.groupFullCollection(),function(t){return t&&t.Id()===e});return t&&(this.oGroupModel.clear(),t.IsOrganization()?this.requestGroup(t):this.oGroupModel.idGroup(t.Id()).name(t.Name()),this.selectedGroupInList(t),this.selectedItem(this.oGroupModel),this.selector.itemSelected(null),this.selector.listCheckedOrSelected(!1),At.Ajax.send({Action:"GroupEvents",GroupId:e},this.onGroupEventsResponse,this)),!!t},ct.prototype.deleteGroup=function(e){e&&(At.Ajax.send({Action:"GroupDelete",GroupId:e},this.requestGroupFullList,this),this.selectedGroupType(yt.ContactsGroupListType.Personal),this.groupFullCollection.remove(function(t){return t&&t.Id()===e}))},ct.prototype.mailGroup=function(e){e&&At.Ajax.send({Action:"ContactList",Offset:0,Limit:99,SortField:yt.ContactSortType.Email,SortOrder:"1",GroupId:e.idGroup()},function(e){if(e&&e.Result&&e.Result.List){var t=0,s=0,i=[],o=null,n=[],r=e.Result.List;for(s=r.length;s>t;t++)r[t]&&"Object/CContactListItem"===vt.pExport(r[t],"@Object","")&&(o=new H,o.parse(r[t]),n.push(o));i=_.map(n,function(e){return e.EmailAndName()}),i=_.compact(i),At.Api.openComposeMessage(i.join(", "))}},this)},ct.prototype.dragAndDropHelper=function(t){t&&t.checked(!0);var s=this.selector.itemSelected(),i=vt.draggableMessages(),o=this.selector.listCheckedOrSelected().length,n=o>0?_.map(this.selector.listCheckedOrSelected(),function(e){return[e.Id(),e.Global()?"1":"0"]}):[];return s&&!s.checked()&&s.checked(!0),i.data("p7-contatcs-type",this.selectedGroupType()),i.data("p7-contatcs-uids",n),e(".count-text",i).text(vt.i18n("CONTACTS/DRAG_TEXT_PLURAL",{COUNT:o},null,o)),i},ct.prototype.contactsDrop=function(e,t,s){if(e){var i=s&&s.helper?s.helper:null,o=i?i.data("p7-contatcs-uids"):null;null!==o&&(vt.uiDropHelperAnim(t,s),this.executeAddContactsToGroup(e,o))}},ct.prototype.contactsDropToGroupType=function(e,t,s){var i=s&&s.helper?s.helper:null,o=i?i.data("p7-contatcs-type"):null,n=i?i.data("p7-contatcs-uids"):null;e!==o&&null!==o&&null!==n&&(vt.uiDropHelperAnim(t,s),this.executeShare())},ct.prototype.searchFocus=function(){this.selector.useKeyboardKeys()&&!vt.isTextFieldFocused()&&this.isSearchFocused(!0)},ct.prototype.onContactDblClick=function(){var e=this.selectedContact();e&&At.Api.openComposeMessage(e.email())},ct.prototype.onClearSearchClick=function(){this.searchInput(""),this.searchSubmitCommand()},ct.prototype.onContactResponse=function(e){if(e&&e.Action&&e.Result){var t=new O,s=this.selector.itemSelected();t.parse(e.Result),s&&s.Id()===t.idContact()&&this.selectedItem(t)}},ct.prototype.onContactCreateResponse=function(e){e&&e.Action&&e.Result&&(At.Api.showReport(vt.i18n("ContactCreate"===e.Action?"CONTACTS/REPORT_CONTACT_SUCCESSFULLY_ADDED":"CONTACTS/REPORT_CONTACT_SUCCESSFULLY_UPDATED")),this.requestContactList())},ct.prototype.onContactListResponse=function(e){if(e&&e.Action&&e.Result){var t=0,s=0,i=[],o="GlobalContactList"===e.Action,n=this.selector.itemSelected(),r=null,a=this.selector.listChecked(),l=a&&0<a.length?_.map(a,function(e){return e.Id()}):[],h=null;for(s=e.Result.List.length;s>t;t++)e.Result.List[t]&&"Object/CContactListItem"===vt.pExport(e.Result.List[t],"@Object","")&&(h=new H,h.parse(e.Result.List[t],o),i.push(h));n&&(r=_.find(i,function(e){return n.Id()===e.Id()})),l&&0<l.length&&_.each(i,function(e){e.checked(-1<vt.inArray(e.Id(),l))}),this.collection(i),this.loadingList(!1),this.oPageSwitcher.setCount(vt.pInt(e.Result.ContactCount)),r&&this.selector.itemSelected(r),this.selectedGroupContactsList(e.Result.List)}},ct.prototype.viewAllMails=function(){var e=this.selectedGroupContactsList(),t="email:";e&&(_.each(e,function(e){_.each(e.Emails,function(e){t=t+e+","})}),At.MailCache.searchMessagesInInbox(t))},ct.prototype.onGroupListResponse=function(e){if(e&&e.Action&&e.Result){var t=0,s=0,i=[],o=_.find(this.groupFullCollection(),function(e){return e.selected()}),n=null;for(this.groupFullCollection(i),s=e.Result.length;s>t;t++)e.Result[t]&&"Object/CContactListItem"===vt.pExport(e.Result[t],"@Object","")&&(n=new H,n.parse(e.Result[t]),n.IsGroup()&&(o&&o.Id()===n.Id()&&this.selectedGroupInList(n),i.push(n)));this.groupFullCollection(i)}},ct.prototype.onGroupCreateResponse=function(e){if(e&&e.Action&&e.Result){var t=_.map(this.selector.listChecked(),function(e){return[e.Id(),e.Global()?"1":"0"]});this.executeAddContactsToGroupId(e.Result.IdGroup,t),this.mobileApp||(this.selectedItem(null),this.selector.itemSelected(null)),At.Api.showReport(vt.i18n("CONTACTS/REPORT_GROUP_SUCCESSFULLY_ADDED")),this.requestContactList(),this.requestGroupFullList()}},ct.prototype.executeShare=function(){var e=this,t=this.selector.listCheckedOrSelected(),s=this.selectedContact(),i=_.map(t,function(e){return e.ReadOnly()?"":e.Id()});i=_.compact(i),0<i.length&&(_.each(t,function(e){e&&(At.ContactsCache.clearInfoAboutEmail(e.Email()),!s||e.IsGroup()||e.ReadOnly()||s.readOnly()||s.idContact()!==e.Id()||(s=null,this.selectedContact(null)))},this),_.each(this.collection(),function(e){-1<vt.inArray(e,t)&&e.deleted(!0)}),_.delay(function(){e.collection.remove(function(e){return e.deleted()})},500),yt.ContactsGroupListType.SharedToAll===this.selectedGroupType()?this.recivedAnimUnshare(!0):this.recivedAnimShare(!0),At.Ajax.send({Action:"ContactUpdateSharedToAll",ContactsId:i.join(","),SharedToAll:yt.ContactsGroupListType.SharedToAll===this.selectedGroupType()?"1":"0"},this.onContactUpdateSharedToAllResponse,this))},ct.prototype.onContactUpdateSharedToAllResponse=function(){},ct.prototype.requestGroup=function(e){this.loadingViewPane(!0),e&&At.Ajax.send({Action:"Group",GroupId:e.Id()},this.onGroupResponse,this)},ct.prototype.onGroupResponse=function(e){if(e&&e.Action&&e.Result){var t=e.Result;this.oGroupModel.idGroup(t.IdGroup).name(t.Name).isOrganization(t.IsOrganization).company(t.Company).country(t.Country).state(t.State).city(t.City).street(t.Street).zip(t.Zip).phone(t.Phone).fax(t.Fax).email(t.Email).web(t.Web)}},ct.prototype.onGroupEventsResponse=function(e){if(e&&e.Action&&e.Result){var t=e.Result;this.oGroupModel.events(t)}},ct.prototype.reload=function(){this.requestContactList()},ut.prototype.initScreens=function(){},ut.prototype.initLayout=function(){},ut.prototype.init=function(){this.initScreens(),this.initLayout(),e("#pSevenContent").addClass("single_mode"),_.defer(function(){Et.SingleMode||e("#pSevenContent").removeClass("single_mode")}),this.informationScreen(this.showNormalScreen(yt.Screens.Information))},ut.prototype.getCurrentScreenModel=function(){var e=this.oScreens[this.currentScreen()],t="undefined"!=typeof e?e.Model:null;return t},ut.prototype.showCurrentScreen=function(e,t){var s=this.oScreens[this.currentScreen()],i="undefined"!=typeof s?s.Model:null;this.currentScreen()!==e&&(i&&s.bInitialized&&i.hideViewModel(),this.currentScreen(e)),this.showNormalScreen(e,t),this.resizeAll()},ut.prototype.showNormalScreen=function(e,t){var s=e,i=this.oScreens[s];return i&&(i.bInitialized="boolean"!=typeof i.bInitialized?!1:i.bInitialized,i.bInitialized||(i.Model=this.initViewModel(i.Model,i.TemplateName),i.bInitialized=!0),i.Model.showViewModel(t)),i?i.Model:null},ut.prototype.initViewModel=function(t,i){var o=null,n=null;return o=new t,n=e('div[data-view-model="'+i+'"]').attr("data-bind","template: {name: '"+i+"'}").hide(),o.$viewModel=n,o.bShown=!1,o.showViewModel=function(e){this.$viewModel.show(),"function"==typeof this.onRoute&&this.onRoute(e),this.bShown||("function"==typeof this.onShow&&this.onShow(e),Ct.runPluginHook&&this.__name&&Ct.runPluginHook("view-model-on-show",[this.__name,this]),this.bShown=!0)},o.hideViewModel=function(){this.$viewModel.hide(),"function"==typeof this.onHide&&this.onHide(),this.bShown=!1},s.applyBindings(o,n[0]),"function"==typeof o.onApplyBindings&&o.onApplyBindings(n),o},ut.prototype.showPopup=function(t,i){if(t){if(!t.__builded){var o=null,n=new t,r=n.popupTemplate?n.popupTemplate():"";""!==r&&(o=e('div[data-view-model="'+r+'"]').attr("data-bind","template: {name: '"+r+"'}").removeClass("visible").hide(),o&&1===o.length&&(n.visibility=s.observable(!1),t.__builded=!0,t.__vm=n,n.$viewModel=o,t.__dom=o,n.showViewModel=vt.createCommand(n,function(){At&&At.Screens&&At.Screens.showPopup(t)}),n.closeCommand=vt.createCommand(n,function(){At&&At.Screens&&At.Screens.hidePopup(t)}),s.applyBindings(n,o[0]),vt.delegateRun(n,"onApplyBindings",[o])))}t.__vm&&t.__dom&&(t.__dom.show(),_.delay(function(){t.__dom.addClass("visible")},50),t.__vm.visibility(!0),vt.delegateRun(t.__vm,"onShow",i),this.popupVisibility(!0),this.popups.push(t),this.keyupPopupBinded=_.bind(this.keyupPopup,this,t.__vm),e(document).on("keyup",this.keyupPopupBinded))}},ut.prototype.keyupPopup=function(e,s){if(s){var i=t.parseInt(s.keyCode,10);yt.Key.Esc===i&&(e.onEscHandler?e.onEscHandler():e.closeCommand()),yt.Key.Enter!==i&&yt.Key.Space!==i||!e.onEnterHandler||e.onEnterHandler()}},ut.prototype.hidePopup=function(t){t&&t.__vm&&t.__dom&&(this.keyupPopupBinded&&(e(document).off("keyup",this.keyupPopupBinded),this.keyupPopupBinded=void 0),t.__dom.removeClass("visible").hide(),t.__vm.visibility(!1),vt.delegateRun(t.__vm,"onHide"),this.popupVisibility(!1),this.popups=_.without(this.popups,t))},ut.prototype.hideAllPopup=function(){_.each(this.popups,function(e){this.hidePopup(e)},this)},ut.prototype.showLoading=function(e){this.informationScreen()&&this.informationScreen().showLoading(e)},ut.prototype.hideLoading=function(){this.informationScreen()&&this.informationScreen().hideLoading()},ut.prototype.showReport=function(e,t){this.informationScreen()&&this.informationScreen().showReport(e,t)},ut.prototype.showError=function(e,t,s,i){this.informationScreen()&&this.informationScreen().showError(e,t,s,i)},ut.prototype.hideError=function(e){this.informationScreen()&&this.informationScreen().hideError(e)},ut.prototype.initHelpdesk=function(){var e=this.oScreens[yt.Screens.Helpdesk];Et.User.IsHelpdeskSupported&&e&&!e.bInitialized&&(e.Model=this.initViewModel(e.Model,e.TemplateName),e.bInitialized=!0)},ut.prototype.initScreens=function(){this.oScreens[yt.Screens.Information]={Model:z,TemplateName:"Common_InformationViewModel"},this.oScreens[yt.Screens.Login]={Model:et,TemplateName:"Login_WrapLoginViewModel"},this.oScreens[yt.Screens.Header]={Model:Q,TemplateName:"Common_HeaderMobileViewModel"},this.oScreens[yt.Screens.Mailbox]={Model:at,TemplateName:"Mail_LayoutSidePane_MailViewModel"},this.oScreens[yt.Screens.SingleMessageView]={Model:rt,TemplateName:"Mail_LayoutSidePane_MessagePaneViewModel"},this.oScreens[yt.Screens.Compose]={Model:lt,TemplateName:"Mail_ComposeViewModel"}},ut.prototype.initLayout=function(){e("#pSevenContent").append(e("#Layout").html())},dt.prototype.init=function(){var e=null;At.Ajax.openedRequestsCount.subscribe(function(){0===At.Ajax.openedRequestsCount()&&_.delay(_.bind(function(){0===At.Ajax.openedRequestsCount()&&(this.checkMailStarted(!1),this.folderListLoading(!1),this.messagesLoading(!1))},this),10)},this),Et.SingleMode&&t.opener&&(e=t.opener.App.MailCache,this.oFolderListItems=e.oFolderListItems,this.uidList(e.uidList()),e.uidList.subscribe(_.bind(function(){this.uidList(e.uidList())},this)),t.name&&this.currentAccountId(vt.pInt(t.name))),this.currentAccountId.valueHasMutated()},dt.prototype.getCurrentFolder=function(){return this.folderList().currentFolder()},dt.prototype.getFolderByFullName=function(e,t){var s=this.oFolderListItems[e];return s?s.getFolderByFullName(t):null},dt.prototype.checkCurrentFolderList=function(){var e=Et.Accounts.currentId(),t=this.oFolderListItems[e];t||this.messagesLoading()||(this.messagesLoading(!0),this.messagesLoadingError(!1),this.getFolderList(e))},dt.prototype.getFolderList=function(e){var t={Action:"FolderList"};vt.isUnd(e)||(t.AccountID=e),this.folderListLoading(!0),At.Ajax.send(t,this.onFolderListResponse,this)},dt.prototype.markMessageReplied=function(e,t,s,i){var o=this.oFolderListItems[e],n=null;o&&(n=o.getFolderByFullName(t),n&&n.markMessageReplied(s,i))},dt.prototype.hideThreads=function(e){Et.User.useThreads()&&e.folder()===this.folderList().currentFolderFullName()&&!e.threadOpened()&&this.folderList().currentFolder().hideThreadMessages(e)},dt.prototype.showOpenedThreads=function(e){this.messages(this.getMessagesWithThreads(e,this.uidList(),this.messages()))},dt.prototype.useThreadsInCurrentList=function(e){e=e||this.uidList();var t=this.folderList().currentFolder(),s=t&&t.withoutThreads(),i=""===e.search()&&""===e.filters();return Et.User.useThreads()&&!s&&i},dt.prototype.getMessagesWithThreads=function(e,t,s){var i=[],o=[],n=this.folderList().currentFolder();return n&&e===n.fullName()&&this.useThreadsInCurrentList(t)?(o=_.filter(s,function(e){return!e.threadPart()}),_.each(o,function(e){var t=[];i.push(e),e.threadCount()>0&&(e.threadOpened()&&(t=this.folderList().currentFolder().getThreadMessages(e),i=_.union(i,t)),n.computeThreadData(e))},this),i):s},dt.prototype.setMessagesFromUidList=function(e,t,s,i){var o=e.getUidsForOffset(t,s),n=_.map(o,function(e){return s[e]},this),r=n.length;return i&&(this.messages(this.getMessagesWithThreads(this.folderList().currentFolderFullName(),e,n)),t+r<e.resultCount()&&r<Et.User.MailsPerPage&&(e.filters()!==yt.FolderFilter.Unseen||this.waitForUnseenMessages())&&this.messagesLoading(!0),this.currentMessage()&&(this.currentMessage().deleted()||this.currentMessage().folder()!==this.folderList().currentFolderFullName())&&this.currentMessage(null)),o},dt.prototype.executeCheckMail=function(){var e=this.oFolderListItems[this.currentAccountId()],t=e?e.inboxFolder():null,s=t?t.uidNext():"",i=Et.Accounts.getCurrentFetchersAndFiltersFolderNames(),o=e?[e.inboxFolderFullName(),e.spamFolderFullName(),e.currentFolderFullName()]:[],n=e?e.iAccountId:0,r=this.checkMailStarted()&&this.checkMailStartedAccountId()===n,a=null;At.Ajax.hasOpenedRequests("FolderCounts")&&r||!(o.length>0)||(o=_.uniq(_.compact(_.union(o,i))),a={Action:"FolderCounts",Folders:o,AccountID:n,InboxUidnext:s},this.checkMailStarted(!0),this.checkMailStartedAccountId(n),At.Ajax.send(a,this.onFolderCountsResponse,this))},dt.prototype.setAutocheckmailTimer=function(){clearTimeout(this.iAutoCheckMailTimer),!Et.SingleMode&&Et.User.AutoCheckMailInterval>0&&(this.iAutoCheckMailTimer=setTimeout(function(){At.Ajax.isSearchMessages()||At.MailCache.executeCheckMail()},60*Et.User.AutoCheckMailInterval*1e3))},dt.prototype.checkMessageFlags=function(){var e=this.folderList().inboxFolder(),t=e?e.getFlaggedMessageUids():[],s={Action:"MessageFlags",Folder:this.folderList().inboxFolderFullName(),Uids:t};t>0&&At.Ajax.send(s,this.onMessageFlagsResponse,this)},dt.prototype.onMessageFlagsResponse=function(e){var t=this.folderList().inboxFolder();e.Result&&_.each(e.Result,function(e,s){-1===_.indexOf(e,"\\flagged")&&t.setMessageUnflaggedByUid(s)}),t.removeFlaggedMessageListsFromCache(),At.Prefetcher.prefetchStarredMessageList()},dt.prototype.changeCurrentMessageList=function(e,t,s,i){this.requestCurrentMessageList(e,t,s,i,!0)},dt.prototype.requestCurrentMessageList=function(e,t,s,i,o){var n=this.requestMessageList(e,t,s,i||"",!0,o||!1),r=60*Et.User.AutoCheckMailInterval*1e3,a=n.Folder.relevantInformationLastMoment?moment().diff(n.Folder.relevantInformationLastMoment):r+1;this.uidList(n.UidList),this.page(t),this.messagesLoading(n.DataExpected),this.messagesLoadingError(!1),!n.DataExpected&&r>0&&a>r&&this.executeCheckMail()},dt.prototype.requestMessageList=function(e,t,s,i,o,n){var r=this.oFolderListItems[this.currentAccountId()],a=r?r.getFolderByFullName(e):null,l=a&&a.withoutThreads(),h=Et.User.useThreads()&&!l&&""===s&&""===i,c=a?a.getUidList(s,i):null,u=c&&-1===c.resultCount(),d=(t-1)*Et.User.MailsPerPage,p={Action:"MessageList",Folder:e,Offset:d,Limit:Et.User.MailsPerPage,Search:s,Filters:i,UseThreads:h?"1":"0"},g=!1,m=!1,f=o?this.onCurrentMessageListResponse:this.onMessageListResponse,b=[];return a.type()===yt.FolderTypes.Inbox&&(p.InboxUidnext=a.uidNext()),u&&c.search()===this.uidList().search()&&c.filters()===this.uidList().filters()&&(c=this.uidList()),c&&(b=this.setMessagesFromUidList(c,d,a.oMessages,n)),c&&(m=u||d+b.length<c.resultCount()&&b.length<Et.User.MailsPerPage,g=a.hasChanges()||m),g?At.Ajax.send(p,f,this):this.waitForUnseenMessages(!1),{UidList:c,RequestStarted:g,DataExpected:m,Folder:a}},dt.prototype.executeEmptyTrash=function(){var e=this.folderList().trashFolder();e&&e.emptyFolder()},dt.prototype.executeEmptySpam=function(){var e=this.folderList().spamFolder();e&&e.emptyFolder()},dt.prototype.onClearFolder=function(e){if(e&&e.selected()){this.messages.removeAll(),this.currentMessage(null);var t=e?e.getUidList(this.uidList().search(),this.uidList().filters()):null;this.uidList(t?t:new D),this.checkMailStarted(!1),this.setAutocheckmailTimer()}},dt.prototype.moveMessagesToFolder=function(e,t,s){if(t.length>0){var i=this.folderList().currentFolder(),o=this.folderList().getFolderByFullName(e),n={Action:"MessageMove",Folder:i?i.fullName():"",ToFolder:e,Uids:t.join(",")},r=null;i&&o&&(r=i.markDeletedByUids(t),o.addMessagesCountsDiff(r.MinusDiff,r.UnseenMinusDiff),(vt.isUnd(s)?0:!s)||o.recivedAnim(!0),this.excludeDeletedMessages(),o.markHasChanges(),At.Ajax.send(n,this.onMoveMessagesResponse,this),o&&o.type()===yt.FolderTypes.Trash&&Ct.runPluginHook("move-messages-to-trash",[Et.Accounts.currentId(),n.Folder,t]),o&&o.type()===yt.FolderTypes.Spam&&Ct.runPluginHook("move-messages-to-spam",[Et.Accounts.currentId(),n.Folder,t]))}},dt.prototype.copyMessagesToFolder=function(e,t,s){if(t.length>0){var i=this.folderList().currentFolder(),o=this.folderList().getFolderByFullName(e),n={Action:"MessageCopy",Folder:i?i.fullName():"",ToFolder:e,Uids:t.join(",")};i&&o&&((vt.isUnd(s)?0:!s)||o.recivedAnim(!0),o.markHasChanges(),At.Ajax.send(n,this.onCopyMessagesResponse,this),o&&o.type()===yt.FolderTypes.Trash&&Ct.runPluginHook("copy-messages-to-trash",[Et.Accounts.currentId(),n.Folder,t]),o&&o.type()===yt.FolderTypes.Spam&&Ct.runPluginHook("copy-messages-to-spam",[Et.Accounts.currentId(),n.Folder,t]))
}},dt.prototype.excludeDeletedMessages=function(){_.delay(_.bind(function(){var e=this.folderList().currentFolder(),t=(this.page()-1)*Et.User.MailsPerPage;this.setMessagesFromUidList(this.uidList(),t,e.oMessages,!0)},this),500)},dt.prototype.removeMessagesFromCacheForFolder=function(e,t){var s=this.folderList().getFolderByFullName(e),i=this.folderList().currentFolderFullName();s&&(s.type()===yt.FolderTypes.Drafts&&(s.markDeletedByUids([t]),s.commitDeleted([t])),s.markHasChanges(),e===i&&this.requestCurrentMessageList(i,this.page(),this.uidList().search(),"",!0))},dt.prototype.deleteMessages=function(e){var t=this.folderList().currentFolder();t&&this.deleteMessagesFromFolder(t,e)},dt.prototype.deleteMessagesFromFolder=function(e,t){var s={Action:"MessageDelete",Folder:e.fullName(),Uids:t.join(",")};e.markDeletedByUids(t),this.excludeDeletedMessages(),At.Ajax.send(s,this.onMoveMessagesResponse,this),Ct.runPluginHook("delete-messages",[Et.Accounts.currentId(),s.Folder,t])},dt.prototype.showExternalPictures=function(e){var t=[],s=null;this.currentMessage()&&(t=this.currentMessage().oFrom.aCollection,s=this.folderList().getFolderByFullName(this.currentMessage().folder()),e&&t.length>0?s.alwaysShowExternalPicturesForSender(t[0].sEmail):s.showExternalPictures(this.currentMessage().uid()))},dt.prototype.setCurrentMessage=function(e,t){var s=Et.SingleMode?this.folderList().getFolderByFullName(t):this.folderList().currentFolder(),i=s&&e?s.oMessages[e]:null;i&&!i.deleted()?(this.currentMessage(i),this.currentMessage().seen()||this.executeGroupOperation("MessageSetSeen",[this.currentMessage().uid()],"seen",!0),s.getCompletelyFilledMessage(e,this.onCurrentMessageResponse,this)):this.currentMessage(null)},dt.prototype.onCurrentMessageResponse=function(e,t){var s=this.currentMessage()?this.currentMessage().uid():"";null===e&&s===t?this.currentMessage(null):e&&s===t&&this.currentMessage.valueHasMutated()},dt.prototype.getMessage=function(e,t,s,i){var o=this.folderList().getFolderByFullName(e);o&&o.getCompletelyFilledMessage(t,s,i)},dt.prototype.executeGroupOperation=function(e,t,s,i){var o=this.folderList().currentFolder(),n={Action:e,Folder:o?o.fullName():"",Uids:t.join(","),SetAction:i?1:0},r=(this.page()-1)*Et.User.MailsPerPage,a=t.length,l=this.folderList().oStarredFolder?this.folderList().oStarredFolder.messageCount():0,h=o.getUidList("",yt.FolderFilter.Flagged);o&&("MessageSetSeen"===n.Action&&this.iMessageSetSeenCount++,At.Ajax.send(n,this.onExecuteGroupOperationResponse,this),o.executeGroupOperation(s,t,i),o.type()===yt.FolderTypes.Inbox&&"flagged"===s&&(this.uidList().filters()===yt.FolderFilter.Flagged?i||(this.uidList().deleteUids(t),this.folderList().oStarredFolder&&this.folderList().oStarredFolder.messageCount(h.resultCount())):(o.removeFlaggedMessageListsFromCache(),""===this.uidList().search()&&this.folderList().oStarredFolder&&this.folderList().oStarredFolder.messageCount(i?l+a:l-a>0?l-a:0))),"seen"===s&&o.removeUnseenMessageListsFromCache(),(this.uidList().filters()!==yt.FolderFilter.Unseen||this.waitForUnseenMessages())&&this.setMessagesFromUidList(this.uidList(),r,o.oMessages,!0))},dt.prototype.onExecuteGroupOperationResponse=function(e,t){"MessageSetSeen"===t.Action&&(this.iMessageSetSeenCount--,this.iMessageSetSeenCount<0&&(this.iMessageSetSeenCount=0),this.folderList().currentFolder()&&0===this.iMessageSetSeenCount&&(this.uidList().filters()!==yt.FolderFilter.Unseen||this.waitForUnseenMessages())&&this.requestCurrentMessageList(this.folderList().currentFolder().fullName(),this.page(),this.uidList().search(),this.uidList().filters(),!1))},dt.prototype.onFolderListResponse=function(e,t){var s=new L,i=parseInt(e.AccountID,10),o=this.oFolderListItems[i],n=o?o.oNamedCollection:{};e.Result===!1?(At.Api.showErrorByCode(e),t.AccountID===this.currentAccountId()&&0===this.messages().length&&(this.messagesLoading(!1),this.messagesLoadingError(!0))):(s.parse(i,e.Result,n),this.oFolderListItems[i]=s,setTimeout(_.bind(this.getAllFolderCounts,this,i),2e3),this.currentAccountId()===i&&this.folderList(s),this.editedAccountId()===i&&this.editedFolderList(s),Et.Accounts.defaultId()===i&&this.defaultFolderList(s)),this.folderListLoading(!1)},dt.prototype.setCurrentFolderList=function(e){var t=e.iAccountId;t===this.currentAccountId()&&t!==this.folderList().iAccountId&&this.folderList(e)},dt.prototype.getAllFolderCounts=function(e){var t=this.oFolderListItems[e],s=t.inboxFolder(),i=s?s.uidNext():"",o=t?t.getFoldersWithoutCountInfo():[],n={Action:"FolderCounts",Folders:o,AccountID:e,InboxUidnext:i};o.length>0&&At.Ajax.send(n,this.onFolderCountsResponse,this)},dt.prototype.onFolderCountsResponse=function(e){var t=!1,s=e.AccountID,i=this.oFolderListItems[s],o=this.folderList().currentFolderFullName(),n=this.currentAccountId()===s;e.Result===!1?At.Api.showErrorByCode(e):(_.each(e.Result&&e.Result.Counts,function(e,s){if(_.isArray(e)&&e.length>3){var r=e[0],a=e[1],l=e[2],h=e[3],c=!1,u=!1,d=null;i&&(d=i.getFolderByFullName(s),d&&(u=n&&d.fullName()===o,c=d.setRelevantInformation(l,h,r,a,u),u&&c&&this.uidList().filters()!==yt.FolderFilter.Unseen&&(this.requestCurrentMessageList(d.fullName(),this.page(),this.uidList().search(),this.uidList().filters(),!1),t=!0)))}},this),this.showNotificationsForNewMessages(e)),this.checkMailStarted(t),this.checkMailStarted()||this.setAutocheckmailTimer()},dt.prototype.showNotificationsForNewMessages=function(e){var t=0,s={};e.Result.New&&e.Result.New.length&&(t=e.Result.New.length,s={action:"show",icon:"skins/wm_logo_140x140.png",title:vt.i18n("NOTIFICATION/NEW_MESSAGE_PLURAL",{COUNT:t},null,t),timeout:5e3},1===t&&(s.body=vt.i18n("MESSAGE/HEADER_SUBJECT")+": "+e.Result.New[0].Subject+"\r\n"+vt.i18n("MESSAGE/HEADER_FROM")+": "+_.map(e.Result.New[0].From,function(e){return""!==e.DisplayName?e.DisplayName:e.Email}).join(", ")),At.desktopNotify(s))},dt.prototype.onCurrentMessageListResponse=function(e,t){if(this.checkMailStarted(!1),e.Result){if(this.messagesLoadingError(!1),this.parseMessageList(e,t),""!==this.deletedDraftMessageUid()){var s=this.deletedDraftMessageUid(),i=_.find(e.Result["@Collection"],function(e){return e.Uid===s});i||(this.setCurrentMessage("",""),this.deletedDraftMessageUid(""))}}else At.Api.showErrorByCode(e),this.messagesLoading()!==!0||0!==this.messages().length&&e.ErrorCode===yt.Errors.NotDisplayedError||this.messagesLoadingError(!0),this.messagesLoading(!1),this.setAutocheckmailTimer()},dt.prototype.onMessageListResponse=function(e,t){e&&e.Result&&this.parseMessageList(e,t)},dt.prototype.parseMessageList=function(e,t){var s=e.Result,i=this.oFolderListItems[e.AccountID],o=null,n=null,r="1"===t.UseThreads,a=!1,l=this.currentAccountId()===e.AccountID&&this.folderList().currentFolderFullName()===s.FolderName,h=l&&this.uidList().search()===s.Search&&this.uidList().filters()===s.Filters,c=this.page()===s.Offset/Et.User.MailsPerPage+1,u=[];this.showNotificationsForNewMessages(e),s!==!1&&"Collection/MessageCollection"===s["@Object"]&&(o=i.getFolderByFullName(s.FolderName),o.setRelevantInformation(s.UidNext.toString(),s.FolderHash,s.MessageCount,s.MessageUnseenCount,l&&!h),a=o.hasChanges(),o.removeAllMessageListsFromCacheIfHasChanges(),n=o.getUidList(s.Search,s.Filters),n.setUidsAndCount(s),_.each(s["@Collection"],function(e){var t=o.parseAndCacheMessage(e,!1,r);u.push(t)},this),Ct.runPluginHook("response-custom-messages",[e.AccountID,o.fullName(),u]),h&&(this.uidList(n),c&&(n.filters()!==yt.FolderFilter.Unseen||this.waitForUnseenMessages())&&(this.setMessagesFromUidList(n,s.Offset,o.oMessages,!0),this.messagesLoading(!1),this.waitForUnseenMessages(!1),this.setAutocheckmailTimer())),!a||!l||h&&c||this.uidList().filters()===yt.FolderFilter.Unseen||this.requestCurrentMessageList(this.folderList().currentFolderFullName(),this.page(),this.uidList().search(),this.uidList().filters(),!1),o.type()===yt.FolderTypes.Inbox&&n.filters()===yt.FolderFilter.Flagged&&""===n.search()&&this.folderList().oStarredFolder&&this.folderList().oStarredFolder.messageCount(n.resultCount()))},dt.prototype.onMoveMessagesResponse=function(e,t){var s=e.Result,i=this.folderList().getFolderByFullName(t.Folder),o=this.folderList().getFolderByFullName(t.ToFolder),n=o&&o.type()===yt.FolderTypes.Trash,r=o&&o.type()===yt.FolderTypes.Spam,a=null,l=vt.i18n(n?"MAILBOX/CONFIRM_MESSAGES_DELETE_WITHOUT_TRASH":"MAILBOX/CONFIRM_MESSAGES_MARK_SPAM_WITHOUT_SPAM"),h=_.bind(function(e){e&&i&&this.deleteMessagesFromFolder(i,t.Uids.split(","))},this),c=this.folderList().currentFolder(),u=c.fullName();s===!1?(a=i.revertDeleted(t.Uids.split(",")),o?(o.addMessagesCountsDiff(-a.PlusDiff,-a.UnseenPlusDiff),e.ErrorCode===yt.Errors.ImapQuota&&(n||r)?At.Screens.showPopup(y,[l,h]):At.Api.showErrorByCode(e,vt.i18n("MAILBOX/ERROR_MOVING_MESSAGES"))):At.Api.showErrorByCode(e,vt.i18n("MAILBOX/ERROR_DELETING_MESSAGES"))):i.commitDeleted(t.Uids.split(",")),u===i.fullName()||o&&u===o.fullName()?(c.markHasChanges(),this.uidList().filters()!==yt.FolderFilter.Unseen&&this.uidList().filters()!==yt.FolderFilter.Flagged&&this.requestCurrentMessageList(u,this.page(),this.uidList().search(),"",!1)):u!==i.fullName()?At.Prefetcher.startFolderPrefetch(i):o&&u!==o.fullName()&&At.Prefetcher.startFolderPrefetch(o)},dt.prototype.onCopyMessagesResponse=function(e,t){var s=e.Result,i=this.folderList().getFolderByFullName(t.Folder),o=this.folderList().getFolderByFullName(t.ToFolder),n=this.folderList().currentFolder(),r=n.fullName();s===!1&&At.Api.showErrorByCode(e,vt.i18n("MAILBOX/ERROR_COPYING_MESSAGES")),r===i.fullName()||o&&r===o.fullName()?(n.markHasChanges(),this.requestCurrentMessageList(r,this.page(),this.uidList().search(),"",!1)):r!==i.fullName()?At.Prefetcher.startFolderPrefetch(i):o&&r!==o.fullName()&&At.Prefetcher.startFolderPrefetch(o)},dt.prototype.searchMessagesInCurrentFolder=function(e){var t=this.folderList().currentFolderFullName()||"INBOX",s=this.currentMessage()?this.currentMessage().uid():"",i=this.uidList().filters();At.Routing.setHash(At.Links.mailbox(t,1,s,e,i))},dt.prototype.searchMessagesInInbox=function(e){At.Routing.setHash(At.Links.mailbox(this.folderList().inboxFolderFullName()||"INBOX",1,"",e,""))},dt.prototype.countMessages=function(e){var t=[],s=function(e){_.each(e.subfolders(),function(e){e.subscribed()&&(t.push(e.unseenMessageCount()),e.subfolders().length&&e.subscribed()&&s(e))},this)};e.expanded()||e.isNamespace()?e.subfoldersMessagesCount(0):(s(e),e.subfoldersMessagesCount(_.reduce(t,function(e,t){return e+t},0)))},pt.prototype.clearInfoAboutEmail=function(e){this.contacts[e]=void 0},pt.prototype.getContactByEmail=function(e,t,s){if(Et.User.ShowContacts){var i=this.contacts[e],o={Action:"ContactByEmail",Email:e};void 0!==i?t.apply(s,[i,e]):(this.responseHandlers[e]={Handler:t,Context:s},At.Ajax.send(o,this.onContactByEmailResponse,this))}},pt.prototype.onContactByEmailResponse=function(e,t){var s=null,i=this.responseHandlers[t.Email];e.Result&&(s=new O,s.parse(e.Result)),this.contacts[t.Email]=s,i&&(i.Handler.apply(i.Context,[s,t.Email]),this.responseHandlers[t.Email]=void 0)},pt.prototype.addVcard=function(e){this.vcardAttachments.push(e)},pt.prototype.markVcardsNonexistentByUid=function(e){_.each(this.vcardAttachments,function(t){-1!==_.indexOf(e,t.uid())&&t.isExists(!1)})},pt.prototype.markVcardExistentByFile=function(e){_.each(this.vcardAttachments,function(t){t.file()===e&&t.isExists(!0)})},pt.prototype.addToContacts=function(e,t,s,i){var o={Action:"ContactCreate",PrimaryEmail:"Home",UseFriendlyName:"1",FullName:e,HomeEmail:t};At.Ajax.send(o,s,i),At.ContactsCache.recivedAnim(!0)},gt.prototype.addIcal=function(e){this.icalAttachments.push(e),0===this.calendars().length&&this.canRequestCalendarList()&&this.requestCalendarList()},gt.prototype.firstRequestCalendarList=function(){return this.canRequestCalendarList(!0),this.icalAttachments.length>0&&0===this.calendars().length&&this.requestCalendarList(),this.calendarsLoadingStarted()},gt.prototype.onCalendarListResponse=function(e){if(e&&e.Result){var t=Et.Accounts,s=t.currentId(),i=t.getAccount(s).email(),o=_.filter(e.Result,function(e){return e.Owner===i||e.Access===yt.CalendarAccess.Full||e.Access===yt.CalendarAccess.Write});this.calendars(_.map(o,function(e){return{name:e.Name+" <"+e.Owner+">",id:e.Id}}))}this.calendarsLoadingStarted(!1)},gt.prototype.requestCalendarList=function(){this.calendarsLoadingStarted()||(At.Ajax.send({Action:"CalendarList"},this.onCalendarListResponse,this),this.calendarsLoadingStarted(!0))},gt.prototype.markIcalNonexistent=function(e){_.each(this.icalAttachments,function(t){e===t.uid()&&t.onEventDelete()})},gt.prototype.markIcalTypeByFile=function(e,t,s,i,o,n){_.each(this.icalAttachments,function(r){e===r.file()&&(r.type(t),r.cancelDecision(s),r.replyDecision(i),r.calendarId(o),r.selectedCalendarId(n))})},gt.prototype.markIcalTentative=function(e){_.each(this.icalAttachments,function(t){e===t.uid()&&t.onEventTentative()})},gt.prototype.markIcalAccepted=function(e){_.each(this.icalAttachments,function(t){e===t.uid()&&t.onEventAccept()})},mt.prototype.init=function(){},mt.prototype.collectScreensData=function(){},mt.prototype.run=function(){},mt.prototype.momentDateTriggerCallback=function(){var e=s.dataFor(this);e&&e.updateMomentDate&&e.updateMomentDate()},mt.prototype.fastMomentDateTrigger=function(){e(".moment-date-trigger-fast").each(this.momentDateTriggerCallback)},mt.prototype.setTitle=function(e){document.title=".",document.title=e||""},_.extend(ft.prototype,mt.prototype),ft.prototype.initPhone=function(){return null},ft.prototype.init=function(){var i=this,o=Et.User,n=new A,r=Et.Accounts,a=new E,l=Et.App,h=new S(!!l.AllowOpenPGP&&this.Api.isPgpSupported());h.parse(l),Et.App=h,n.parse(o),Et.User=n,a.parse(vt.pInt(Et.Default),r),Et.Accounts=a,this.MailCache=new dt,this.Phone=this.initPhone(n.AllowVoice&&!this.browser.ie&&!Ft),this.useGoogleAnalytics(),this.collectScreensData(),e(t).unload(function(){vt.WindowOpener.closeAll()}),this.nowMoment=s.observable(moment()),t.setInterval(function(){i.fastMomentDateTrigger(),moment().diff(i.nowMoment(),"days")>0&&i.nowMoment(moment())},6e4)},ft.prototype.collectScreensData=function(){},ft.prototype.registerHelpdeskUpdateFunction=function(e){this.fHelpdeskUpdate=e},ft.prototype.updateHelpdesk=function(){this.fHelpdeskUpdate&&this.fHelpdeskUpdate()},ft.prototype.useGoogleAnalytics=function(){var e=null,s=null;Et.App.GoogleAnalyticsAccount&&0<Et.App.GoogleAnalyticsAccount.length&&(t._gaq=t._gaq||[],t._gaq.push(["_setAccount",Et.App.GoogleAnalyticsAccount]),t._gaq.push(["_trackPageview"]),e=document.createElement("script"),e.type="text/javascript",e.async=!0,e.src=("https:"===document.location.protocol?"https://ssl":"http://www")+".google-analytics.com/ga.js",s=document.getElementsByTagName("script")[0],s.parentNode.insertBefore(e,s))},ft.prototype.tokenProblem=function(){var e="window.location.reload(); return false;",t=vt.i18n("WARNING/TOKEN_PROBLEM_HTML",{RELOAD_FUNC:e});Et.Auth=!1,At.Api.showError(t,!0,!0)},ft.prototype.logout=function(e){var t={Action:"Logout"};e&&(t.LastErrorCode=e),At.Ajax.send(t,this.onLogout,this),Et.Auth=!1},ft.prototype.authProblem=function(){this.logout(yt.Errors.AuthError)},ft.prototype.onLogout=function(){vt.WindowOpener.closeAll(),At.Routing.finalize(),""!==Et.App.CustomLogoutUrl?t.location.href=Et.App.CustomLogoutUrl:t.location.reload()},ft.prototype.getAccounts=function(){return Et.Accounts},ft.prototype.run=function(){if(this.Screens.init(),It&&Et&&Et.Auth&&Et.App.IosDetectOnLogin&&At.browser.safari&&Et.App.AllowIosProfile?t.location.href="?ios":Et&&Et.Auth?(Et.SingleMode=this.Routing.isSingleMode(),Et.SingleMode&&t.opener&&Et.Accounts.populateIdentitiesFromSourceAccount(t.opener.App.getAccounts()),Et.App.AllowWebMail&&this.MailCache.init(),Et.HelpdeskRedirect&&this.Routing.currentScreen!==yt.Screens.Helpdesk&&this.Routing.setHash([yt.Screens.Helpdesk]),""!==Et.App.DefaultTab?this.Routing.init(Et.App.DefaultTab):Et.App.AllowWebMail?this.Routing.init(yt.Screens.Mailbox):this.headerTabs()[0]&&this.Routing.init(this.headerTabs()[0].name)):Et&&""!==Et.App.CustomLoginUrl?t.location.href=Et.App.CustomLoginUrl:(this.Screens.showCurrentScreen(yt.Screens.Login),Et&&Et.LastErrorCode===yt.Errors.AuthError&&this.Api.showError(vt.i18n("WARNING/AUTH_PROBLEM"),!1,!0)),this.Phone&&t.localStorage){var s=this;e(t).on("storage",function(){"false"!==t.localStorage.getItem("phoneLoad")&&t.localStorage.setItem("phoneLoad","false")}),t.localStorage.setItem("phoneLoad",Math.floor(900*Math.random()+100).toString()),t.setTimeout(function(){Et.SingleMode||!s.Phone||"false"===t.localStorage.getItem("phoneLoad")&&!t.sessionStorage.getItem("phoneTab")||(s.Phone.init(),t.sessionStorage.setItem("phoneTab","true"))},1e3)}vt.registerMailto(this.browser.firefox)},ft.prototype.getHelpLink=function(e){return Et&&Et.Links&&Et.Links[e]?Et.Links[e]:""},ft.prototype.addScreenToHeader=function(e,t,i,o,n,r,a){var l=this.Routing.buildHashFromArray([e]),h=this;e===yt.Screens.Helpdesk&&(l=s.computed(function(){return"#"+h.Routing.lastHelpdeskHash()})),yt.Screens[e]=e,this.Screens.oScreens[e]={Model:n,TemplateName:o},this.headerTabs.push({name:e,title:t,hash:l,koVisibleTab:r,koRecivedAnim:a}),this.screensTitle[e]=i},ft.prototype.registerSessionTimeoutFunction=function(e){this.sessionTimeoutFunctions.push(e)},ft.prototype.initSessionTimeout=function(){this.setSessionTimeout(),e("body").on("click",_.bind(this.setSessionTimeout,this)).on("keydown",_.bind(this.setSessionTimeout,this))},ft.prototype.setSessionTimeout=function(){clearTimeout(this.iSessionTimeout),Et&&Et.Auth&&Et.App.IdleSessionTimeout&&(this.iSessionTimeout=setTimeout(_.bind(this.logoutBySessionTimeout,this),Et.App.IdleSessionTimeout))},ft.prototype.logoutBySessionTimeout=function(){Et.Auth&&(_.each(this.sessionTimeoutFunctions,function(e){e()}),_.delay(_.bind(this.logout,this),500))},ft.prototype.initHeaderInfo=function(){this.browser.ie?e(document).bind("focusin",_.bind(this.onFocus,this)).bind("focusout",_.bind(this.onBlur,this)):e(t).bind("focus",_.bind(this.onFocus,this)).bind("blur",_.bind(this.onBlur,this))},ft.prototype.onFocus=function(){this.focused(!0)},ft.prototype.onBlur=function(){this.focused(!1)},ft.prototype.setTitle=function(e){var t=this.newMessagesCount(),s="";e=e||"",e=this.focused()||0===t||!Et.App.AllowWebMail?this.getTitleByScreen():vt.i18n("TITLE/HAS_UNSEEN_MESSAGES_PLURAL",{COUNT:t},null,t)+" - "+Et.Accounts.getEmail(),this.favico&&(s=t>99?"99+":t,this.favico._cachevalue!==s&&(this.favico._cachevalue=s,this.favico.badge(s))),document.title=".",document.title=e},ft.prototype.getTitleByScreen=function(){var e="",t="";try{this.MailCache.currentMessage()&&(t=this.MailCache.currentMessage().subject())}catch(s){}switch(this.currentScreen()){case yt.Screens.Login:e=vt.i18n("TITLE/LOGIN",null,"");break;case yt.Screens.Mailbox:e=Et.Accounts.getEmail()+" - "+vt.i18n("TITLE/MAILBOX");break;case yt.Screens.Compose:case yt.Screens.SingleCompose:e=Et.Accounts.getEmail()+" - "+vt.i18n("TITLE/COMPOSE");break;case yt.Screens.SingleMessageView:e=Et.Accounts.getEmail()+" - "+vt.i18n("TITLE/VIEW_MESSAGE"),t&&(e=t+" - "+e);break;default:this.screensTitle[this.currentScreen()]&&(e=this.screensTitle[this.currentScreen()])}return""===e?e=Et.App.SiteName:e+=Et.App.SiteName&&""!==Et.App.SiteName?" - "+Et.App.SiteName:"",e},ft.prototype.desktopNotify=function(e,t,s,i,o,n){vt.desktopNotify(e,t,s,i,o,n)},_.extend(bt.prototype,ft.prototype),bt.prototype.collectScreensData=function(){Et.User.ShowContacts&&this.addScreenToHeader("contacts",vt.i18n("HEADER/CONTACTS"),vt.i18n("TITLE/CONTACTS"),"Contacts_ContactsViewModel",ct,!0,this.ContactsCache.recivedAnim)},At=new bt,t.App=At,-1===Et.IsMobile){var Lt=t.matchMedia("all and (min-width: 768px)").matches?0:1;t.App.Ajax.send({Action:"SetMobile",Mobile:Lt},function(){Lt?t.location.reload():e(function(){_.defer(function(){At.run()})})},this)}else e(function(){_.defer(function(){At.run()})});t.Modernizr&&navigator&&t.Modernizr.addTest("mobile",function(){return Ft}),t.AfterLogicApi=Ct,t.Enums=yt,Mt.removeClass("no-js").addClass("js"),Mt.hasClass("pdf")&&(Rt.push("application/pdf"),Rt.push("application/x-pdf"))}(jQuery,window,ko,crossroads,hasher);

Zerion Mini Shell 1.0