function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ownKeys(t,e){var r,o=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),o.push.apply(o,r)),o}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(r),!0).forEach(function(e){_defineProperty(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function _defineProperty(e,t,r){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _toPropertyKey(e){e=_toPrimitive(e,"string");return"symbol"==_typeof(e)?e:e+""}function _toPrimitive(e,t){if("object"!=_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);r=r.call(e,t||"default");if("object"!=_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(()=>{function e(e,u,o,r,n,i,p){var y={c8y_BrokerSourceInactive:{icon:"c8y-group-remote-inactive",iconOpen:"c8y-group-remote-inactive"},c8y_BrokerSource:{icon:"c8y-group-remote",iconOpen:"c8y-group-remote-open"},c8y_DeviceGroup:{icon:"c8y-group",iconOpen:"c8y-group-open"},c8y_DynamicGroup:{icon:"c8y-group-smart",iconOpen:"c8y-group-smart-open"},other:{icon:"circle",iconClass:"statusUnknown"}};return{getGroupItems:c,getItemsCount:function(e){return r.children(e,"childAssets",{skipDetail:!0,params:{pageSize:1,withTotalPages:!0,withChildren:!1}}).then(function(e){return e.data.statistics.totalPages})},getGroupAssetsAndDevices:function(r){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},t=o.createListFilter(function(e){var e=e.id,t=_.map(_.get(r,"childAdditions.references"),_.property("managedObject.id"));return!_.includes(t,e)});return c(r,e).then(t)},getGroupTypeItems:function(t){return n.getLookup().then(function(e){return[e[t]]}).then(s)},getTopLevelGroups:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},r=e||!1;return t.onlyRoots=!0,i.mustHaveAnyRole(["ROLE_INVENTORY_READ","ROLE_MANAGED_OBJECT_READ"]).then(function(){return n.get().then(_.property("groups")).then(function(e){return(r?function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},e=(e.push({type:p.getType()}),s(e,t));t.skipChildCount||(e=e.then(function(e){return p.addChildCountProperty(e,t)}));return e}:s)(e,t)})},a)},isGroup:f,getGroupInfo:t,getIconSpecs:function(e){return t(e).iconSpecs},getIconSpecsForType:function(e){return _.get(y,e,{})}};function c(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};return r.listQuery((e=e,{__bygroupid:o.getId(e)}),_objectSpread({withParents:!0},t),!0)}function s(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},e={__filter:{__and:[{__not:{__has:"c8y_IsDynamicGroup.invisible"}},{type:{__in:_.map(e,"type")}}]}};return r.listQuery(e,t,!0)}function a(){return r.list({fragmentType:"c8y_IsDeviceGroup",pageSize:1e3,onlyRoots:!0})}function f(e){return!!e.c8y_IsDeviceGroup||"c8y_DeviceGroup"===e.type}function t(e){var t,r=f(e),o=u.get("c8yDevices").isDevice(e),n=p.isDynamicGroup(e),i=u.get("c8yDeviceGroup"),c=i.hasBrokerSource(e);return r?t=c?i.isBrokerSourceActive(e)?"c8y_BrokerSource":"c8y_BrokerSourceInactive":p.isDynamicGroup(e)?"c8y_DynamicGroup":"c8y_DeviceGroup":n?t="c8y_DynamicGroup":o||(t="other"),{isGroup:r,isDynamicGroup:n,hasBrokerSource:c,iconSpecs:_.get(y,t,{})}}}e.$inject=["$q","$injector","c8yBase","c8yInventory","c8yGroupTypesConfig","c8yPermissions","c8yDynamicGroups"],angular.module("c8y.core").factory("c8yGroups",e)})();