!function(){"use strict";functiona(a,l){if(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"),navigator&&navigator.registerProtocolHandler){varm=window.location.origin+window.ApplicationBaseURL+"UIxMailPopupView#!/Mail/0/INBOX/new?%s";navigator.registerProtocolHandler("mailto",m,"SOGo")}}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){varf,g,h=d(b.mailboxId);returng=function(a){varb=_.find(a,function(a){returna.path==h});returnb||angular.forEach(a,function(a){!b&&a.children&&a.children.length>0&&(b=g(a.children))}),b},e.selectedFolder&&!e.$virtualMode&&(e.selectedFolder.$isLoading=!0),f=g(c.$mailboxes),f?(f.$topIndex=0,f.selectFolder(),f):a.reject("Mailbox doesn't exist")}functione(a,b,c){vard=a.injector().getAsync("stateAccount");returnd.then(function(d){returnd.$mailboxes.length>0?a.router.stateService.target("mail.account.mailbox",{accountId:d.id,mailboxId:b(d.$mailboxes[0].path)}):(c.selectedFolder=!1,a.router.stateService.target("mail"))})}functionf(a,b,c,d){vare;returnc.$virtualMode?[]:e=d?d.$filter().catch(function(){returna.reject("Mailbox not found")}):a.reject("Mailbox doesn't exist")}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,e){a.DebugEnabled||d.defaultErrorHandler(function(){}),b.onError({to:"mail.**"},function(a){"mail"!=a.to().name&&!a.ignored()&&a.error().message.indexOf("superseded")<0&&(c.error("transition error to "+a.to().name),e.selectedFolder=!1,d.go("mail"))})}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","$stateParams","stateAccount","decodeUriFilter","Mailbox"],e.$inject=["$transition$","encodeUriFilter","Mailbox"],f.$inject=["$q","$state","Mailbox","stateMailbox"],g.$inject=["$q","Mailbox"],h.$inject=["$q","Mailbox","decodeUriFilter","$stateParams"],i.$inject=["Mailbox","encodeUriFilter","$stateParams","$state","stateMailbox","stateMessag