}functionnewMessage($event){varmessage;if(messageDialog===null){message=vm.account.$newMessage();messageDialog=$mdDialog.show({parent:angular.element(document.body),targetEvent:$event,clickOutsideToClose:false,escapeToClose:false,templateUrl:"UIxMailEditor",controller:"MessageEditorController",controllerAs:"editor",locals:{stateAccounts:vm.accounts,stateMessage:message,stateRecipients:[]}}).finally(function(){messageDialog=null})}}}angular.module("SOGo.MailerUI").controller("MailboxController",MailboxController)})();(function(){"use strict";MailboxesController.$inject=["$state","$timeout","$mdDialog","$mdMedia","$mdSidenav","sgFocus","encodeUriFilter","Dialog","sgSettings","Account","Mailbox","VirtualMailbox","User","Preferences","stateAccounts"];functionMailboxesController($state,$timeout,$mdDialog,$mdMedia,$mdSidenav,focus,encodeUriFilter,Dialog,Settings,Account,Mailbox,VirtualMailbox,User,Preferences,stateAccounts){varvm=this,account,mailbox;vm.service=Mailbox;vm.accounts=stateAccounts;vm.newFolder=newFolder;vm.delegate=delegate;vm.editFolder=editFolder;vm.revertEditing=revertEditing;vm.selectFolder=selectFolder;vm.saveFolder=saveFolder;vm.compactFolder=compactFolder;vm.emptyTrashFolder=emptyTrashFolder;vm.exportMails=exportMails;vm.confirmDelete=confirmDelete;vm.markFolderRead=markFolderRead;vm.share=share;vm.metadataForFolder=metadataForFolder;vm.setFolderAs=setFolderAs;vm.refreshUnseenCount=refreshUnseenCount;vm.showingAdvancedSearch=false;vm.currentSearchParam="";vm.addSearchParam=addSearchParam;vm.newSearchParam=newSearchParam;vm.showAdvancedSearch=showAdvancedSearch;vm.hideAdvancedSearch=hideAdvancedSearch;vm.toggleAdvancedSearch=toggleAdvancedSearch;vm.search={options:{"":l("Select a criteria"),subject:l("Enter Subject"),from:l("Enter From"),to:l("Enter To"),cc:l("Enter Cc"),body:l("Enter Body")},mailbox:"INBOX",subfolders:1,match:"AND",params:[]};if($state.current.name=="mail"&&vm.accounts.length>0&&vm.accounts[0].$mailboxes.length>0){account=vm.accounts[0];mailbox=account.$mailboxes[0];$state.go("mail.account.mailbox",{accountId:account.id,mailboxId:encodeUriFilter(mailbox.path)})}functionshowAdvancedSearch(path){vm.showingAdvancedSearch=true;vm.search.mailbox=path}functionhideAdvancedSearch(){vm.showingAdvancedSearch=false;vm.service.$virtualMode=false;account=vm.accounts[0];mailbox=vm.searchPreviousMailbox;$state.go("mail.account.mailbox",{accountId:account.id,mailboxId:encodeUriFilter(mailbox.path)})}functiontoggleAdvancedSearch(){if(Mailbox.selectedFolder.$isLoading){vm.virtualMailbox.stopSearch()}else{varroot,mailboxes=[],_visit=function(folders){_.each(folders,function(o){mailboxes.push(o);if(o.children&&o.children.length>0){_visit(o.children)}})};vm.virtualMailbox=newVirtualMailbox(vm.accounts[0]);if(!Mailbox.$virtualMode)vm.searchPreviousMailbox=Mailbox.selectedFolder;Mailbox.selectedFolder=vm.virtualMailbox;Mailbox.$virtualMode=true;if(angular.isDefined(vm.search.mailbox)){root=vm.accounts[0].$getMailboxByPath(vm.search.mailbox);mailboxes.push(root);if(vm.search.subfolders&&root.children.length)_visit(root.children)}else{mailboxes=vm.accounts[0].$flattenMailboxes()}vm.virtualMailbox.setMailboxes(mailboxes);vm.virtualMailbox.startSearch(vm.search.match,vm.search.params);$state.go("mail.account.virtualMailbox",{accountId:vm.accounts[0].id})}}functionaddSearchParam(v){vm.currentSearchParam=v;focus("advancedSearch");returnfalse}functionnewSearchParam(pattern){if(pattern.length&&vm.currentSearchParam.length){varn=0,searchParam=vm.currentSearchParam;if(pattern.startsWith("!")){n=1;pattern=pattern.substring(1).trim()}vm.currentSearchParam="";return{searchBy:searchParam,searchInput:pattern,negative:n}}}functionnewFolder(parentFolder){Dialog.prompt(l("New folder"),l("Enter the new name of your folder :")).then(function(name){parentFolder.$newMailbox(parentFolder.id,name).then(function(){},function(data,status){Dialog.alert(l('An error occured while creating the mailbox "%{0}".',name),l(data.error))})})}functiondelegate(account){$mdDialog.show({templateUrl:account.id+"/delegation",controller:Ma