!function(){"use strict";function m(){var e,t,o=this;if(this.nextAlarm=null,this.nextInboxPoll=null,this.currentToast=m.$q.when(!0),this.lastUid=null,this.notifications={},this.defaults={},this.settings={Mail:{}},e=m.$document[0].getElementById("UserDefaults")){try{t=angular.fromJson(e.textContent||e.innerHTML)}catch(e){m.$log.error("Can't parse user's defaults: "+e.message),t={}}t.SOGoMailLabelsColorsKeys=[],t.SOGoMailLabelsColorsValues=[],_.forEach(t.SOGoMailLabelsColors,function(e,a){t.SOGoMailLabelsColorsKeys.push(a),t.SOGoMailLabelsColorsValues.push(e),"$"==a.charAt(0)&&(Object.defineProperty(t.SOGoMailLabelsColors,"_"+a,Object.getOwnPropertyDescriptor(t.SOGoMailLabelsColors,a)),delete t.SOGoMailLabelsColors[a])}),_.forEach(t.SOGoSieveFilters,function(e){_.forEach(e.actions,function(e){"addflag"==e.method&&"$"==e.argument.charAt(0)&&(e.argument="_"+e.argument)})}),t.SOGoRememberLastModule&&(t.SOGoLoginModule="Last"),t.SOGoMailAutoSave=parseInt(t.SOGoMailAutoSave)||0,t.SOGoMailComposeWindowEnabled=angular.isDefined(t.SOGoMailComposeWindow),t.SOGoMailComposeFontSizeEnabled=0$/.exec(e),e=new m.$User({uid:a,cn:e[1],c_email:e[2]});return e.$$image||(e.$$image=o.avatar(e.c_email,32,{no_404:!0})),e}):t.Calendar.PreventInvitationsWhitelist=[]),angular.extend(o.settings,t)}}m.$factory=["$window","$document","$q","$timeout","$log","$state","$mdDateLocale","$mdToast","sgSettings","Gravatar","Resource","User",function(e,a,t,o,n,i,s,r,l,d,c,u){return angular.extend(m,{$window:e,$document:a,$q:t,$timeout:o,$log:n,$state:i,$mdDateLocaleProvider:s,$toast:r,$gravatar:d,$$resource:new c(l.activeUser("folderURL"),l.activeUser()),$resourcesURL:l.resourcesURL(),$User:u}),new m}];try{angular.module("SOGo.PreferencesUI")}catch(e){angular.module("SOGo.PreferencesUI",["SOGo.Common"])}angular.module("SOGo.PreferencesUI").factory("Preferences",m.$factory),m.prototype.ready=function(){return m.$log.warn("Preferences.ready is deprecated -- access settings/defaults directly."),m.$q.when(!0)},m.prototype.avatar=function(e,a,t){var o=this.defaults.SOGoAlternateAvatar,o=this.defaults.SOGoGravatarEnabled?m.$gravatar(e,a,o,t):[m.$resourcesURL,"img","ic_person_grey_24px.svg"].join("/");return t&&t.dstObject&&t.dstAttr&&(t.dstObject[t.dstAttr]=o),o},m.prototype.hasActiveExternalSieveScripts=function(e){var a=this;if(void 0!==e)this.defaults.hasActiveExternalSieveScripts=e;else{if(void 0!==this.defaults.hasActiveExternalSieveScripts)return this.defaults.hasActiveExternalSieveScripts;this.defaults.hasActiveExternalSieveScripts=!1,m.$$resource.quietFetch("activeExternalSieveScripts").then(function(){a.defaults.hasActiveExternalSieveScripts=!0},function(e){if(a.defaults.hasActiveExternalSieveScripts=!1,404===e.status)return m.$q.resolve(!0)})}},m.prototype.supportsNotifications=function(){return"undefined"!=typeof Notification||(m.$log.warn("Notifications are not available for your browser."),!1)},m.prototype.authorizeNotifications=function(){this.supportsNotifications()&&Notification.requestPermission(function(e){return e})},m.prototype.createNotification=function(e,a,t){var o=this,n=_.pick(t,["body","icon"]);this.supportsNotifications()&&(n.tag=e,n.lang="",n.dir="auto",this.notifications[e]=new Notification(a,n),this.notifications[e].onclick=function(){t.onClick(),o.notifications[e].close()})},m.prototype.viewInboxMessage=function(e){m.$state.get("mail.account")?m.$state.go("mail.account.mailbox.message",{accountId:0,mailboxId:"INBOX",messageId:e}):m.$window.location=m.$$resource.path("Mail","view#!/Mail/0/INBOX/"+e)},m.prototype.pollInbox=function(){var e,u=this;function f(e,a,t,o){e.title=t,e.body=o,e.close=function(){a.hide("ok")}}e={sortingAttributes:{sort:"arrival",asc:0,noHeaders:0,dry:1},filters:[{searchBy:"flags",searchInput:"unseen"}]},this.nextInboxPoll&&m.$timeout.cancel(this.nextInboxPoll),this.inboxSyncToken&&(e.syncToken=this.inboxSyncToken),m.$$resource.post("Mail","0/folderINBOX/changes",e).then(function(e){if(e.syncToken&&(u.inboxSyncToken=e.syncToken,m.$log.debug("New syncToken is "+u.inboxSyncToken)),angular.isDefined(e.headers)&&0','
','
',' email','
',' ','
',"
","
",' ',l("View")," ","
","
",""].join(""),position:"top right",hideDelay:5e3,controller:f,viewInboxMessage:u.viewInboxMessage},u.currentToast=u.currentToast.then(angular.bind(d,i))))}}).finally(function(){var e=u.defaults.SOGoRefreshViewCheck;e&&"manually"!=e&&(u.nextInboxPoll=m.$timeout(angular.bind(u,u.pollInbox),1e3*e.timeInterval()))}),f.$inject=["scope","$mdToast","title","body"]},m.prototype.getAlarms=function(){var n=this,e=new Date,e=Math.floor(e.getTime()/1e3);m.$$resource.fetch("Calendar","alarmslist?browserTime="+e).then(function(e){var a,t,o=e.alarms.sort(function(e,a){e=parseInt(e[2]);return parseInt(a[2])-e});0",'
','
','

{{ summary }}

','
'," ",' ',' ',' ',l("5 minutes")," ",' ',l("10 minutes")," ",' ',l("15 minutes")," ",' ',l("30 minutes")," ",' ',l("45 minutes")," ",' ',l("1 hour")," ",' ',l("1 day")," "," "," ",' ',l("Snooze")," ",' ',l("Close")," ","
","
","
",""].join(""),locals:{url:i},controller:n})}),n.$inject=["scope","url"]})},m.prototype.$save=function(){return m.$$resource.save("Preferences",this.$omit(!0)).then(function(e){return e})},m.prototype.$omit=function(t){var o={},a={};return angular.forEach(this,function(e,a){"constructor"!=a&&"$"!=a[0]&&(o[a]=t?angular.copy(e):e)}),delete o.defaults.locale,o.defaults.SOGoMailLabelsColors={},_.forEach(o.defaults.SOGoMailLabelsColorsKeys,function(e,a){o.defaults.SOGoMailLabelsColors[e]=o.defaults.SOGoMailLabelsColorsValues[a]}),delete o.defaults.SOGoMailLabelsColorsKeys,delete o.defaults.SOGoMailLabelsColorsValues,_.forEach(o.defaults.SOGoSieveFilters,function(e){_.forEach(e.actions,function(e){"addflag"==e.method&&"_"==e.argument.charAt(0)&&"$"==e.argument.charAt(1)&&(e.argument=e.argument.substring(1))})}),_.forEach(o.defaults.AuxiliaryMailAccounts,function(e){var a=[];_.forEach(e.identities,function(e){e.isReadOnly||a.push(_.pick(e,["email","fullName","replyTo","signature","isDefault"]))}),e.identities=a}),o.defaults.SOGoMailComposeWindowEnabled||delete o.defaults.SOGoMailComposeWindow,delete o.defaults.SOGoMailComposeWindowEnabled,o.defaults.SOGoMailComposeFontSizeEnabled||(o.defaults.SOGoMailComposeFontSize=0),delete o.defaults.SOGoMailComposeFontSizeEnabled,o.defaults.Vacation&&(o.defaults.Vacation.startDateEnabled?o.defaults.Vacation.startDate=o.defaults.Vacation.startDate.getTime()/1e3:(delete o.defaults.Vacation.startDateEnabled,o.defaults.Vacation.startDate=0),o.defaults.Vacation.endDateEnabled?o.defaults.Vacation.endDate=o.defaults.Vacation.endDate.getTime()/1e3:(delete o.defaults.Vacation.endDateEnabled,o.defaults.Vacation.endDate=0),o.defaults.Vacation.autoReplyEmailAddresses?o.defaults.Vacation.autoReplyEmailAddresses=_.compact(o.defaults.Vacation.autoReplyEmailAddresses):o.defaults.Vacation.autoReplyEmailAddresses=[]),o.defaults.Forward&&o.defaults.Forward.forwardAddress&&(o.defaults.Forward.forwardAddress=_.compact(o.defaults.Forward.forwardAddress)),o.defaults.SOGoCalendarCategoriesColors={},_.forEach(o.defaults.SOGoCalendarCategories,function(e,a){o.defaults.SOGoCalendarCategoriesColors[e]=o.defaults.SOGoCalendarCategoriesColorsValues[a]}),delete o.defaults.SOGoCalendarCategoriesColorsValues,o.settings.Calendar&&o.settings.Calendar.PreventInvitationsWhitelist&&(_.forEach(o.settings.Calendar.PreventInvitationsWhitelist,function(e){a[e.uid]=e.$shortFormat()}),o.settings.Calendar.PreventInvitationsWhitelist=a),o}}(); //# sourceMappingURL=Preferences.services.js.map