angular.module("c8y.auditLogs").directive("auditLogsFilter",["c8yAudits","c8yDateFormatService",function(i,n){return{require:"ngModel",restrict:"EA",link:function(r,e,t,a){r.dateOpen={},r.viewFilter={},r.types=_.map(i.types,function(e,t){return{name:t,label:e}}),r.datepickerFormat=n.getDateFormat({useUppercaseFormat:!1}),a.$render=function(){if(a.$isEmpty(a.$viewValue))return r.viewFilter={},r.viewFilter;var e=r.viewFilter,t=a.$viewValue;e.type=t.type,e.user=t.user,e.dateFrom=t.dateFrom&&new Date(t.dateFrom),e.dateTo=t.dateTo&&new Date(t.dateTo)},r.apply=function(){var i=_.cloneDeep(r.viewFilter);_.forEach({0:"dateFrom",1:"dateTo"},function(e,t){i[e]&&(i[e]=moment(i[e]).add(t,"days").toISOString())}),a.$setViewValue(i)},r.open=function(e){r.dateOpen[e]=!0},r.clear=function(){r.viewFilter={},a.$setViewValue({})},r.anyFilter=function(){return _.some(_.assign({},a.$modelValue,r.viewFilter),_.identity)}},templateUrl:":::PLUGIN_PATH:::/views/filter.html",scope:{}}}]);