!function(e){let t=new function(){let t=this;t.width=ko.observable(e("#main").outerWidth()),t.showCheckUpdatesWarning=ko.observable(!1),t.checkUpdatesStatus=ko.observable(),t.defaultSkew=ko.observable().extend({number:!0,min:1}),t.loading=ko.observable(!0),t.deleteEventsMenu=ko.observableArray(Menu.JSONToMenu([{id:"5",name:"After 1 month",description:"1 month"},{id:"6",name:"After 3 months",description:"3 months"},{id:"7",name:"After 6 months",description:"6 months"},{id:"8",name:"After 1 year",description:"1 year"},{id:"9",name:"After 3 years",description:"3 years"},{id:"10",name:"Never",description:"never"}])),t.deleteEventsLabel=ko.computed((function(){return Menu.getSelectedNames(t.deleteEventsMenu(),null)})),t.deleteAnalyticsMenu=ko.observableArray(Menu.JSONToMenu([{id:"5",name:"After 1 month",description:"1 month"},{id:"6",name:"After 3 months",description:"3 months"},{id:"7",name:"After 6 months",description:"6 months"},{id:"8",name:"After 1 year",description:"1 year"},{id:"9",name:"After 3 years",description:"3 years"}])),t.deleteAnalyticsLabel=ko.computed((function(){return Menu.getSelectedNames(t.deleteAnalyticsMenu(),null)})),t.serialize=function(){return{auditdefaultpassword:t.systemmessages.auditDefaultPassword(),auditmd5password:t.systemmessages.auditMD5Password(),versioncheckmonit:t.systemmessages.newMonitNotification(),versioncheckmmonit:t.systemmessages.newMMonitNotification(),purgeevents:Menu.getSelectedValues(t.deleteEventsMenu(),"id")[0],purgeanalytics:Menu.getSelectedValues(t.deleteAnalyticsMenu(),"id")[0],defaultskew:t.defaultSkew()}},t.setVersionCheckStatus=function(e){t.checkUpdatesStatus(e),t.systemmessages.newMonitNotification()||t.systemmessages.newMMonitNotification()?""==e?(t.checkUpdatesStatus("Initializing"),t.showCheckUpdatesWarning(!1)):"Success"!=e?t.showCheckUpdatesWarning(!0):t.showCheckUpdatesWarning(!1):t.showCheckUpdatesWarning(!1)},t.update=function(){t.loading()||e.ajax({url:"../../admin/settings/update",data:t.serialize(),type:"POST",timeout:3e4,error:MMONIT.error.json,success:function(s,n,i){let o=e.parseJSON(s);t.setVersionCheckStatus(o.description)}})},t.systemmessages={auditDefaultPassword:ko.observable(!1),auditMD5Password:ko.observable(!1),newMMonitNotification:ko.observable(!1),newMonitNotification:ko.observable(!1),toggleAuditDefaultPassword:function(e,s){s.stopPropagation(),t.systemmessages.auditDefaultPassword(!t.systemmessages.auditDefaultPassword()),t.update()},toggleAuditMD5Password:function(e,s){s.stopPropagation(),t.systemmessages.auditMD5Password(!t.systemmessages.auditMD5Password()),t.update()},toggleNewMMonitNotification:function(e,s){s.stopPropagation(),t.systemmessages.newMMonitNotification(!t.systemmessages.newMMonitNotification()),t.update()},toggleNewMonitNotification:function(e,s){s.stopPropagation(),t.systemmessages.newMonitNotification(!t.systemmessages.newMonitNotification()),t.update()}},t.displayCheckUpdatesWarning=function(t,s){s.stopPropagation(),e(s.currentTarget).tooltip("show")},t.hideCheckUpdatesWarning=function(t,s){s.stopPropagation(),e(s.currentTarget).tooltip("hide")},t.purgeEventsSelection=ko.observable(t.deleteEventsMenu().length-1),t.selectPurgeEvents=function(s){s.id!==Menu.getSelectedValues(t.deleteEventsMenu(),"id")[0]&&(t.purgeEventsSelection(s),"10"==s.id?t.selectPurgeEventsConfirm():e("#confirmDeleteEvents").modal("show"))},t.selectPurgeEventsConfirm=function(){Menu.select(t.deleteEventsMenu(),t.purgeEventsSelection().id),t.update()},t.purgeAnalyticsSelection=ko.observable(t.deleteAnalyticsMenu.length-1),t.selectPurgeAnalytics=function(s){s.id!==Menu.getSelectedValues(t.deleteAnalyticsMenu(),"id")[0]&&(t.purgeAnalyticsSelection(s),e("#confirmDeleteAnalytics").modal("show"))},t.selectPurgeAnalyticsConfirm=function(e){Menu.select(t.deleteAnalyticsMenu(),t.purgeAnalyticsSelection().id),t.update()},t.setDefaultSkew=function(e,s){s.stopPropagation(),t.update()},e.ajax({url:"../../admin/settings/get",type:"GET",dataType:"json",timeout:3e4,error:MMONIT.error.json,success:function(e){t.systemmessages.auditDefaultPassword(e.audit.defaultpassword),t.systemmessages.auditMD5Password(e.audit.md5password),t.systemmessages.newMonitNotification(e.versioncheck.monit),t.systemmessages.newMMonitNotification(e.versioncheck.mmonit),t.setVersionCheckStatus(e.versioncheck.status),Menu.select(t.deleteEventsMenu(),e.dataretention.purgeevents),Menu.select(t.deleteAnalyticsMenu(),e.dataretention.purgeanalytics),t.defaultSkew(e.hosts.defaultskew),t.loading(!1)}})};ko.applyBindings(t),e(window).on("resize orientationchange",(function(s){t.width(e("#main").outerWidth())}))}(jQuery);