!function(){"use strict";function Preferences(){var _this=this;this.defaults={},this.settings={},this.defaultsPromise=Preferences.$$resource.fetch("jsonDefaults").then(function(data){var labels=_.object(_.map(data.SOGoMailLabelsColors,function(value,key){return"$"==key.charAt(0)?["_"+key,value]:[key,value]}));return data.SOGoMailLabelsColors=labels,data.Vacation&&data.Vacation.autoReplyEmailAddresses&&(data.Vacation.autoReplyEmailAddresses=data.Vacation.autoReplyEmailAddresses.join(",")),data.Forward&&data.Forward.forwardAddress&&(data.Forward.forwardAddress=data.Forward.forwardAddress.join(",")),angular.extend(_this.defaults,data),_this.defaults}),this.settingsPromise=Preferences.$$resource.fetch("jsonSettings").then(function(data){return data.Calendar&&data.Calendar.PreventInvitationsWhitelist?data.Calendar.PreventInvitationsWhitelist=_.map(data.Calendar.PreventInvitationsWhitelist,function(value,key){var match=/^(.+)\s<(\S+)>$/.exec(value);return new Preferences.$User({uid:key,cn:match[1],c_email:match[2]})}):data.Calendar.PreventInvitationsWhitelist=[],angular.extend(_this.settings,data),_this.settings})}Preferences.$factory=["$q","$timeout","$log","sgSettings","Resource","User",function($q,$timeout,$log,Settings,Resource,User){return angular.extend(Preferences,{$q:$q,$timeout:$timeout,$log:$log,$$resource:new Resource(Settings.activeUser("folderURL"),Settings.activeUser()),activeUser:Settings.activeUser(),$User:User}),new Preferences}];try{angular.module("SOGo.PreferencesUI")}catch(e){angular.module("SOGo.PreferencesUI",["SOGo.Common"])}angular.module("SOGo.PreferencesUI").factory("Preferences",Preferences.$factory),Preferences.prototype.ready=function(){return Preferences.$q.all([this.defaultsPromise,this.settingsPromise])},Preferences.prototype.$save=function(){return Preferences.$$resource.save("Preferences",this.$omit(!0)).then(function(data){return data})},Preferences.prototype.$omit=function(deep){var preferences={};angular.forEach(this,function(value,key){"constructor"!=key&&"$"!=key[0]&&(deep?preferences[key]=angular.copy(value):preferences[key]=value)});var labels=_.object(_.map(preferences.defaults.SOGoMailLabelsColors,function(value,key){return"_"==key.charAt(0)&&"$"==key.charAt(1)?[key.substring(1),value]:[key,value]}));if(preferences.defaults.SOGoMailLabelsColors=labels,preferences.defaults.Vacation&&preferences.defaults.Vacation.autoReplyEmailAddresses&&(preferences.defaults.Vacation.autoReplyEmailAddresses=preferences.defaults.Vacation.autoReplyEmailAddresses.split(",")),preferences.defaults.Forward&&preferences.defaults.Forward.forwardAddress&&(preferences.defaults.Forward.forwardAddress=preferences.defaults.Forward.forwardAddress.split(",")),preferences.settings.Calendar&&preferences.settings.Calendar.PreventInvitationsWhitelist){var h={};_.each(preferences.settings.Calendar.PreventInvitationsWhitelist,function(user){h[user.uid]=user.$shortFormat()}),preferences.settings.Calendar.PreventInvitationsWhitelist=h}return preferences}}();
//# sourceMappingURL=Preferences.services.js.map