(()=>{function e(i,t,u,c,s,a,n,l,o,d,h,v,g,f,r,p){return{addAssetUI:function(){return r.open({component:"c8yGroupCreateAndAssignModal",ariaLabelledBy:"modal-title",ariaDescribedBy:"modal-body"}).result},editGroup:function(e){t.url("/group/".concat(e.id))},deleteGroup:function(e){return a.remove(e)},deleteGroupWithConfirmation:function(t){var n=0<_.get(t,"childAssets.references.length")||0<_.get(t,"childDevices.references.length"),e=o.isDynamicGroup(t),r=e&&!n?u.when():d.getItemsCount(t).then(function(e){n=0===e});return r.then(function(){return c({title:g("Delete group"),body:n||e?f.getString('You are about to delete group "{{name}}". This operation is irreversible. Do you want to proceed?',t):f.getString('You are about to delete group "{{name}}" and its subgroups recursively. This operation is irreversible. Do you want to proceed?',t),checkboxes:{cascade:{text:g("Also delete all devices inside this group and its subgroups."),checked:!1,showIf:function(){return!(n||e)}}},status:"danger",labels:{ok:g("Delete")}}).then(function(e){return a.remove(t,e)}).then(function(){return v.removeGroupNavigation(t)}).then(function(){return s.success(g("Group deleted."))})})},deleteDeviceWithConfirmation:function(n,e){var t=void 0===n.c8y_IsDevice,r=!_.isUndefined(n.childDevices)&&0<n.childDevices.references.length,o=function(){return!t&&!e&&r};return(r||e||t?u.when():h.getChildDevicesCount(n).then(function(e){r=0<e})).then(function(){return c({title:g("Delete device"),body:f.getString('You are about to delete device "{{name}}". This operation is irreversible. Do you want to proceed?',n),checkboxes:{cascade:{text:g("Also delete child devices of this device."),checked:o(),showIf:o},withDeviceUser:{text:f.getString('Also delete associated device owner "{{ owner }}".',n),checked:!1,showIf:function(){var e=n.c8y_IsDevice,t=n.owner&&l.isDeviceUser({id:n.owner});return Boolean(e&&t)}}},labels:{ok:g("Delete")},status:"danger"}).then(function(e){return a.remove(n,e)}).then(function(){return v.updateAllGroupsOfAChild(n)}).then(function(){return s.success(g("Device deleted."))})})},unassignDevice:function(r,o){var e={title:g("Unassign device"),body:f.getString('You are about to unassign device "{{name}}". Do you want to proceed?',o),status:"warning",size:"sm",labels:{ok:g("Unassign")}};return c(e).then(function(){return p.isApplicationAvailable().then(function(e){if(!e)return null;var e=r.id,t=o,n=u.when();try{return(n=i.get("smartRulesSvc")).listByContext(e).then(function(e){return u.all(e.map(function(e){return n.deactivate(e,t,!1)}))})}catch(e){return n}})}).then(function(){return a.removeChildAsset(r,o)}).then(function(){return v.updateGroupChildren(r)})},assignDevices:function(e){return r.open({component:"c8yGroupDeviceAssignmentModal",resolve:{currentGroup:function(){return e}}}).result.then(function(){return v.updateGroupChildren(e)})},getGroup:function(e){return a.detail(e).then(n.getResData)}}}e.$inject=["$injector","$location","$q","c8yModal","c8yAlert","c8yInventory","c8yBase","c8yUser","c8yDynamicGroups","c8yGroups","c8yDevices","groupTypesHierarchyNavigator","gettext","gettextCatalog","$uibModal","c8ySmartRulesAvailability"],angular.module("c8y.ui").factory("groupsHierarchySvc",e)})();