(()=>{function e(e,t,s){c.$inject=["$route","$q"],o.$inject=["$location","c8yBase","c8yModal","c8yAlert","c8yTenantPolicies","gettextCatalog"];var d="tenantpolicies",p="c8y-tenant-policies",n="".concat(d,"/:tenantPolicyId"),f="".concat(d,"/new"),i={template:"<c8y-tenant-policy-list/>"},a={template:'<c8y-tenant-policy-detail id="$resolve.id"/>',resolve:{id:c}},y=s("Tenant policies");return{config:function(){e.when(d,i),e.when(n,a),t.addNavigation({name:y,parent:s("Tenants"),icon:p,path:d,routerLinkExact:!1,showIf:["c8yUserUtil",function(e){return e.canUserManageTenant()}]})},$get:o};function c(e,t){e=e.current.params.tenantPolicyId;return/^(\d+|new)$/.test(e)?e:t.reject()}function o(t,n,i,a,c,o){var e;return{TITLE:y,ROUTE_NEW:f,ICON:p,edit:function(e){t.path("".concat(d,"/").concat(n.getId(e)))},toList:function(){t.path(d)},defaultObject:r,removeConfirm:function(e){return i({status:"danger",size:"sm",title:s("Delete tenant policy"),body:o.getString('Are you sure you want to delete tenant policy "{{name}}"?',e),labels:{ok:s("Delete")}}).then(_.partial(c.remove,e)).then(_.partial(l,e))},duplicate:function(e){r.default=_.cloneDeep(_.pick(e,["name","description","options","retentions"])),t.path(f)},removeDuplicate:function(){clearTimeout(e),e=setTimeout(function(){delete r.default},100)},isDuplicate:function(){return!!r.default},saveName:function(e,t){e.name=t,e.id&&c.save(_.pick(e,["id","name"])).then(_.partial(u,e))}};function r(){return r.default||{name:o.getString("New tenant policy"),description:o.getString("New tenant policy description"),options:[],retentions:[]}}function l(e){e=o.getString('Tenant policy "{{name}}" deleted',e);a.success(e)}function u(e){e=o.getString('Tenant policy name changed to "{{name}}"',e);a.success(e)}}}e.$inject=["c8yViewsProvider","c8yNavigatorProvider","gettext"],angular.module("c8y.tenantPolicies").provider("c8yTenantPoliciesConfig",e)})();