!function(){"use strict";function p(){var e,t,a,o,i=this;if(this.nextAlarm=null,this.nextInboxPoll=null,this.currentToast=p.$q.when(!0),this.lastUid=null,this.notifications={},this.defaults={},this.settings={Mail:{}},e=p.$document[0].getElementById("UserDefaults")){try{t=angular.fromJson(e.textContent||e.innerHTML)}catch(e){p.$log.error("Can't parse user's defaults: "+e.message),t={}}if(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.SOGoMailAutoMarkAsReadDelay=parseInt(t.SOGoMailAutoMarkAsReadDelay)||0,t.SOGoMailAutoMarkAsReadEnabled=0<=t.SOGoMailAutoMarkAsReadDelay,0$/.exec(e),a=new p.$User({uid:a,cn:e[1],c_email:e[2]});return a.$$image||(a.$$image=i.avatar(a.c_email,32,{no_404:!0})),a}):t.Calendar.PreventInvitationsWhitelist=[]),angular.extend(i.settings,t)}}p.$factory=["$window","$document","$rootScope","$q","$timeout","$log","$state","$mdDateLocale","$mdToast","sgConstant","sgSettings","Gravatar","Resource","User",function(e,a,t,o,i,n,s,r,l,d,c,u,f,m){return angular.extend(p,{$window:e,$document:a,$rootScope:t,$q:o,$timeout:i,$log:n,$state:s,$mdDateLocaleProvider:r,$toast:l,$gravatar:u,$$resource:new f(c.activeUser("folderURL"),c.activeUser()),$resourcesURL:c.resourcesURL(),$User:m,$sgConstant:d}),new p}];try{angular.module("SOGo.PreferencesUI")}catch(e){angular.module("SOGo.PreferencesUI",["SOGo.Common"])}angular.module("SOGo.PreferencesUI").factory("Preferences",p.$factory),p.prototype.ready=function(){return p.$log.warn("Preferences.ready is deprecated -- access settings/defaults directly."),p.$q.when(!0)},p.prototype.avatar=function(e,a,t){var o=this.defaults.SOGoAlternateAvatar,e=this.defaults.SOGoGravatarEnabled?p.$gravatar(e,a,o,t):[p.$resourcesURL,"img","ic_person_grey_24px.svg"].join("/");return t&&t.dstObject&&t.dstAttr&&(t.dstObject[t.dstAttr]=e),e},p.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,p.$$resource.quietFetch("activeExternalSieveScripts").then(function(){a.defaults.hasActiveExternalSieveScripts=!0},function(e){if(a.defaults.hasActiveExternalSieveScripts=!1,404===e.status)return p.$q.resolve(!0)})}},p.prototype.supportsNotifications=function(){return"undefined"!=typeof Notification||(p.$log.warn("Notifications are not available for your browser."),!1)},p.prototype.isItemSecretQuestion=function(){return"SecretQuestion"==this.defaults.SOGoPasswordRecoveryMode},p.prototype.isItemSecondaryEmail=function(){return"SecondaryEmail"==this.defaults.SOGoPasswordRecoveryMode},p.prototype.authorizeNotifications=function(){this.supportsNotifications()&&Notification.requestPermission(function(e){return e})},p.prototype.createNotification=function(e,a,t){var o=this,i=_.pick(t,["body","icon"]);this.supportsNotifications()&&(i.tag=e,i.lang="",i.dir="auto",this.notifications[e]=new Notification(a,i),this.notifications[e].onclick=function(){t.onClick(),o.notifications[e].close()})},p.prototype.viewInboxMessage=function(e){p.$state.get("mail.account")?p.$state.go("mail.account.mailbox.message",{accountId:0,mailboxId:"INBOX",messageId:e}):p.$window.location=p.$$resource.path("Mail","view#!/Mail/0/INBOX/"+e)},p.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")}}return e={sortingAttributes:{sort:"arrival",asc:0,noHeaders:0,dry:1},filters:[{searchBy:"flags",searchInput:"unseen"}]},this.nextInboxPoll&&p.$timeout.cancel(this.nextInboxPoll),this.inboxSyncToken&&(e.syncToken=this.inboxSyncToken),f.$inject=["scope","$mdToast","title","body"],p.$$resource.post("Mail","0/folderINBOX/changes",e).then(function(e){if(e.syncToken&&(u.inboxSyncToken=e.syncToken,p.$log.debug("New syncToken is "+u.inboxSyncToken)),angular.isDefined(e.headers)&&0','
','
',' email','
',' ','
',"
","
",' ',l("View")," ","
","
",""].join(""),position:p.$sgConstant.toastPosition,hideDelay:5e3,controller:f,viewInboxMessage:u.viewInboxMessage},u.currentToast=u.currentToast.then(angular.bind(r,n))))}}).finally(function(){var e=u.defaults.SOGoRefreshViewCheck;e&&"manually"!=e&&(u.nextInboxPoll=p.$timeout(angular.bind(u,u.pollInbox),1e3*e.timeInterval()))})},p.prototype.getAlarms=function(){var i=this,e=new Date,e=Math.floor(e.getTime()/1e3);p.$$resource.fetch("Calendar","alarmslist?browserTime="+e).then(function(e){var a,t,o,e=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:n},controller:i})}),i.$inject=["scope","url"]})},p.prototype.$save=function(){return p.$$resource.save("Preferences",this.$omit(!0)).then(function(e){return e})},p.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.SOGoMailAutoMarkAsReadEnabled?"immediate"==o.defaults.SOGoMailAutoMarkAsReadMode&&(o.defaults.SOGoMailAutoMarkAsReadDelay=0):o.defaults.SOGoMailAutoMarkAsReadDelay=-1,delete o.defaults.SOGoMailAutoMarkAsReadEnabled,delete o.defaults.SOGoMailAutoMarkAsReadMode,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,delete o.defaults.Vacation.startDate),o.defaults.Vacation.endDateEnabled?o.defaults.Vacation.endDate=o.defaults.Vacation.endDate.getTime()/1e3:(delete o.defaults.Vacation.endDateEnabled,delete o.defaults.Vacation.endDate),o.defaults.Vacation.startTimeEnabled?(o.defaults.Vacation.startTime=o.defaults.Vacation.startTime.format(this.$mdDateLocaleProvider,"%H:%M"),o.defaults.Vacation.endTimeEnabled?o.defaults.Vacation.endTime=o.defaults.Vacation.endTime.format(this.$mdDateLocaleProvider,"%H:%M"):(delete o.defaults.Vacation.endTimeEnabled,delete o.defaults.Vacation.endTime)):(delete o.defaults.Vacation.startTimeEnabled,delete o.defaults.Vacation.startTime,delete o.defaults.Vacation.endTimeEnabled,delete o.defaults.Vacation.endTime),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.Notification&&o.defaults.Notification.notificationAddress&&(o.defaults.Notification.notificationAddress=_.compact(o.defaults.Notification.notificationAddress)),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