!function(){"use strict";functiona(a,h){a.state("app",{url:"/addressbooks",abstract:!0,views:{addressbooks:{templateUrl:"UIxContactFoldersView",controller:"AddressBooksController",controllerAs:"app"}},resolve:{stateAddressbooks:b}}).state("app.addressbook",{url:"/:addressbookId",views:{addressbook:{templateUrl:"addressbook",controller:"AddressBookController",controllerAs:"addressbook"}},resolve:{stateAddressbook:c}}).state("app.addressbook.new",{url:"/{contactType:(?:card|list)}/new",views:{card:{templateUrl:"UIxContactEditorTemplate",controller:"CardController",controllerAs:"editor"}},resolve:{stateCard:d}}).state("app.addressbook.card",{url:"/:cardId",abstract:!0,views:{card:{template:"<ui-view/>"}},resolve:{stateCard:e},onEnter:f,onExit:g}).state("app.addressbook.card.view",{url:"/view",views:{"card@app.addressbook":{templateUrl:"UIxContactViewTemplate",controller:"CardController",controllerAs:"editor"}}}).state("app.addressbook.card.editor",{url:"/edit",views:{"card@app.addressbook":{templateUrl:"UIxContactEditorTemplate",controller:"CardController",controllerAs:"editor"}}}),h.otherwise("/addressbooks/personal")}functionb(a){returna.$findAll(window.contactFolders)}functionc(a,b,c,d){vare=_.find(d.$findAll(),function(a){returna.id==c.addressbookId});returne?(e.selectedCard=!1,e.$reload(),e):a.reject("Addressbook "+c.addressbookId+" not found")}functiond(a,b,c){vard="v"+a.contactType,e=newc({pid:a.addressbookId,c_component:d});returnb.selectedCard=!0,e}functione(a,b,c){vard;return(d=_.find(c.$cards,function(a){returna.id==b.cardId}))?d.$reload():voida.go("app.addressbook")}functionf(a,b){b.selectedCard=a.cardId}functiong(a){deletec.selectedCard}functionh(a,b,c){a.$on("$stateChangeError",function(a,d,e,f,g,h){b.error(h),c.go("app.addressbook",{addressbookId:"personal"})}),a.$on("$routeChangeError",function(a,c,d,e){b.error(a,c,d,e)})}angular.module("SOGo.ContactsUI",["ngCookies","ui.router","angularFileUpload","ck","SOGo.Common","SOGo.PreferencesUI","SOGo.MailerUI"]).config(a).run(h),a.$inject=["$stateProvider","$urlRouterProvider"],b.$inject=["AddressBook"],c.$inject=["$q","$state","$stateParams","AddressBook"],d.$inject=["$stateParams","stateAddressbook","Card"],e.$inject=["$state","$stateParams","stateAddressbook"],f.$inject=["$stateParams","stateAddressbook"],g.$inject=["stateAddressbook"],h.$inject=["$rootScope","$log","$state"]}(),function(){"use strict";functiona(a,b,c,d,e,f,g,h,i,j,k,m,n){functiono(a){d.go("app.addressbook.card.view",{cardId:a.id})}functionp(a,b){b.selected=!b.selected,B.mode.multiple+=b.selected?1:-1,a.preventDefault(),a.stopPropagation()}functionq(a){d.go("app.addressbook.new",{contactType:a})}functionr(){_.forEach(B.selectedFolder.$cards,function(a){a.selected=!1}),B.mode.multiple=0}functions(){j.confirm(l("Warning"),l("Are you sure you want to delete the selected contacts?"),{ok:l("Delete")}).then(function(){vara=_.filter(B.selectedFolder.$cards,function(a){returna.selected});B.selectedFolder.$deleteCards(a).then(function(){B.mode.multiple=0,B.selectedFolder.selectedCard||d.go("app.addressbook")})})}functiont(a){varb=_.filter(B.selectedFolder.$cards,function(a){returna.selected});B.selectedFolder.$copyCards(b,a).then(function(){})}functionu(){_.forEach(B.selectedFolder.$cards,function(a){a.selected=!0}),B.mode.multiple=B.selectedFolder.$cards.length}functionv(a){B.selectedFolder.$filter("",{sort:a})}functionw(a){returni.$query.sort==a}functionx(){B.mode.search=!1,B.selectedFolder.$filter("")}functiony(a,b){g.$findAll().then(function(c){vard=_.find(c,function(a){if(0===a.id)returna});d.$getMailboxes().then(function(c){d.$newMessage().then(function(c){angular.extend(c.editable,{to:b}),f.show({parent:angular.element(document.body),targetEvent:a,clickOutsideToClose:!1,escapeToClose:!1,templateUrl:"../Mail/UIxMailEditor",controller:"MessageEditorController",controllerAs:"editor",locals:{stateAccount:d,stateMessage:c}})})})})}functionz(a,b,c){vard=[c+" <"+b+">"];B.newMessage(a,d),a.stopPropagation(),a.preventDefault()}functionA(a){varc=_.filter(B.selected