(()=>{function e(o,e,l,t,n,i,s){var r=this;function a(e){r.role=e,c();e=e.roles;e=(e||{}).references||[],r.selectedPermissions=_.map(e,"role.id")}function c(){t.listGlobalPermissions().then(u)}function u(e){r.permissions=e}function m(){r.globalRoleDetailForm.$setDirty()}function d(e){return r.saving=!0,e.finally(function(){r.saving=!1}),e}_.assign(r,{$onInit:function(){(()=>{var e=r.id,n=r.duplicateId;("new"===e?(e=>{var n=t.newGlobalRole(e);return n.then(function(){e&&s(m)}),n})(n):(e=>l.global.detail(e).then(o.getResData))(e)).then(a)})(),c()},STRINGS:t.STRINGS,helpLink:i.getUserGuideLink(t.STRINGS.LINKS.ROLES_INVENTORY),onSaveName:function(e){return d(t.saveGlobalRoleName(r.role,e))},cancel:t.list,save:function(){return d(t.saveGlobalRole(r.role,r.selectedPermissions))},hasAppPermissions:function(){var o=/^ROLE_APPLICATION/;return _.some(r.selectedPermissions,function(e,n){return e&&o.test(n)})},getRoleName:n.getName,onSelectedRolesChange:function(e){r.selectedPermissions=e,m()}})}e.$inject=["c8yBase","c8yPermissions","c8yRoles","c8yRolesUi","c8yPropertyValueTransformService","c8yDocs","$timeout"],angular.module("c8y.roles").component("c8yRoleDetailGlobal",{templateUrl:":::PLUGIN_PATH:::/detail/roleDetailGlobal.html",bindings:{id:"<",duplicateId:"<",tabName:"<"},controllerAs:"vm",controller:e})})();