!function(){"use strict";functiona(a,l){a.state("mail",{url:"/Mail",views:{mailboxes:{templateUrl:"UIxMailMainFrame",controller:"MailboxesController",controllerAs:"app"}},resolve:{stateAccounts:b}}).state("mail.account",{url:"/:accountId",abstract:!0,views:{mailbox:{template:"<ui-view/>"}},resolve:{stateAccount:c}}).state("mail.account.virtualMailbox",{url:"/virtual",views:{"mailbox@mail":{templateUrl:"UIxMailFolderTemplate",controller:"MailboxController",controllerAs:"mailbox"}},resolve:{stateMailbox:g}}).state("mail.account.virtualMailbox.message",{url:"/:mailboxId/:messageId",views:{message:{templateUrl:"UIxMailViewTemplate",controller:"MessageController",controllerAs:"viewer"}},resolve:{stateMailbox:h,stateMessages:f,stateMessage:i},onEnter:j,onExit:k}).state("mail.account.inbox",{url:"/inbox",onEnter:e}).state("mail.account.mailbox",{url:"/:mailboxId",views:{"mailbox@mail":{templateUrl:"UIxMailFolderTemplate",controller:"MailboxController",controllerAs:"mailbox"}},resolve:{stateMailbox:d,stateMessages:f}}).state("mail.account.mailbox.message",{url:"/:messageId",views:{message:{templateUrl:"UIxMailViewTemplate",controller:"MessageController",controllerAs:"viewer"}},onEnter:j,onExit:k,resolve:{stateMessage:i}}),l.otherwise("/Mail/0/inbox")}functionb(a,b,c){vard=c.$findAll(a.mailAccounts),e=[];returnangular.forEach(d,function(a,b){varc=a.$getMailboxes();0===b?e.push(c.then(function(b){returna})):e.push(a)}),b.all(e)}functionc(a,b){return_.find(b,function(b){returnb.id==a.accountId})}functiond(a,b,c,d,e,f){varg,h,i=e(c.mailboxId);returnh=function(a){varb=_.find(a,function(a){returna.path==i});returnb||angular.forEach(a,function(a){!b&&a.children&&a.children.length>0&&(b=h(a.children))}),b},f.selectedFolder&&!f.$virtualMode&&(f.selectedFolder.$isLoading=!0),g=h(d.$mailboxes),g?(g.$topIndex=0,g):b.go("mail.account.inbox")}functione(a,b,c,d){d.$mailboxes.length>0?a.location.hash=b.href("mail.account.mailbox",{accountId:d.id,mailboxId:c(d.$mailboxes[0].path)}):b.go("mail")}functionf(a,b){returna.$virtualMode?[]:b.$filter()}functiong(a,b){returnb.$virtualMode?b.selectedFolder:a.reject("No virtual mailbox defined")}functionh(a,b,c,d){vare=c(d.mailboxId);returnb.$virtualMode?(b.selectedFolder.resetSelectedMessage(),_.find(b.selectedFolder.$mailboxes,function(a){returna.path==e})):a.reject("No virtual mailbox defined for message")}functioni(a,b,c,d,e,f){varg;return(g=_.find(e.$messages,function(a){returna.uid==parseInt(c.messageId)}))?g.$reload({useCache:!0}):voidd.go("mail.account.mailbox",{accountId:e.$account.id,mailboxId:b(e.path)})}functionj(a,b){b.selectedMessage=parseInt(a.messageId)}functionk(a){deletea.selectedMessage}functionl(a,b,c,d){a.$on("$stateChangeError",function(a,e,f,g,h,i){b.error(i),a.preventDefault(),d.selectedFolder=!1,c.go("mail")}),a.$on("$routeChangeError",function(a,c,d,e){b.error(a,c,d,e)})}angular.module("SOGo.MailerUI",["ngCookies","ui.router","ck","angularFileUpload","SOGo.Common","SOGo.ContactsUI","SOGo.SchedulerUI","ngAnimate","SOGo.PreferencesUI"]).config(a).run(l),a.$inject=["$stateProvider","$urlRouterProvider"],b.$inject=["$window","$q","Account"],c.$inject=["$stateParams","stateAccounts"],d.$inject=["$q","$state","$stateParams","stateAccount","decodeUriFilter","Mailbox"],e.$inject=["$window","$state","encodeUriFilter","stateAccount"],f.$inject=["Mailbox","stateMailbox"],g.$inject=["$q","Mailbox"],h.$inject=["$q","Mailbox","decodeUriFilter","$stateParams"],i.$inject=["Mailbox","encodeUriFilter","$stateParams","$state","stateMailbox","stateMessages"],j.$inject=["$stateParams","stateMailbox"],k.$inject=["stateMailbox"],l.$inject=["$rootScope","$log","$state","Mailbox"]}();