function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){var r;if(e)return"string"==typeof e?_arrayLikeToArray(e,t):"Map"===(r="Object"===(r={}.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function _iterableToArrayLimit(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,o,a,c=[],s=!0,l=!1;try{if(o=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=o.call(r)).done)&&(c.push(n.value),c.length!==t);s=!0);}catch(e){l=!0,i=e}finally{try{if(!s&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw i}}return c}}function _arrayWithHoles(e){if(Array.isArray(e))return e}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 e(i,n,o,a,t,r,c,s,l){var u=20,d={};function f(e){i.properties=[],d={},i.renderedDevices=d,i.parentId=e.device&&e.device.id||e.options&&e.options.parentId,s.list().then(angular.bind(l,l.filterAndExtendWithStoredProperties,i.child.config.options.properties)).then(p).then(function(e){i.properties=e,i.parentId?(e=>o.detailRealtime(e,i))(i.parentId).then(y).then(h):i.devices=_.map(i.devices,m)})}function p(e){return _.filter(e,"__active")}function y(e){t.isGroup(e)||(i.devices||(i.devices=[]),i.devices.push(e))}function h(){return e=i.parentId,t={pageSize:u},r=a.createListMapper(function(e){return e.managedObject}),n.all([g(e,"childAssets",t).then(r),g(e,"childDevices",t).then(r)]).then(a.combineLists).then(v);var e,t,r}function g(t,r,e){var n=a.cleanListCallback("references",function(e){return g(t,r,e)},e,!0);return o.children(t,r,{params:e}).then(n)}function v(e){i.devices||(i.devices=[]),e.forEach(function(e){o.detailRealtime(e,i),i.devices.push(e)}),i.paging=e.paging}function e(e,t){for(var r=e,n=0;n<(t||[]).length&&null!=r;n++)r=r[t[n]];return r}function b(e){var t,r,e=_slicedToArray((e=_.isArray(e)?e.join("."):e).match(/^(-?)(.*)$/),3),n=e[1],e=e[2],n="-"===n?"desc":"asc";-1<e.indexOf("lastMeasurement")?i.devices=_.orderBy(i.devices,[function(e){if("object"!==_typeof(e[r])&&""!==e[r]){e=String(e[r]).split("|");if(2===e.length)return moment(e[0],"L, LTS").toDate()}},(t=r=e,function(e){if("object"!==_typeof(e[t])&&""!==e[t])return 2===(e=String(e[t]).split("|")).length?parseFloat(e[1]):parseFloat(e[0])})],[n,n]):i.devices=_.orderBy(i.devices,e,n),i.$broadcast("c8yScrollLoad::refresh")}function m(e){return c.attach(e),r.attach(e,i.properties),e}i.$watch("child.config",function(e,t){e&&!_.isEqual(e,t)&&f(i.child.config)}),_.assign(i,{getArrows:function(e){return!!i.child.config.options.arrows[e]},orderBy:b,orderDownBy:function(e){_.isArray(e)&&(e=e.join("."));b("-".concat(e))},loadNext:function(){i.paging.loading=!0,i.paging.next().then(v).finally(function(){i.paging.loading=!1})},buildFields:e,getAssetLinkIfNeeded:function(e,t){var r=null;(e=>e===_.findIndex(i.properties,function(e){e=e.renderType;return _.isUndefined(e)}))(t)&&(r=l.getAssetLink(e));return r},setArrows:function(e){i.child.config.options.arrows[e]=!i.child.config.options.arrows[e]},renderedDevices:d,renderDevice:function(e){var t=e.id;d[t]||(m(e),d[t]=!0)},renderedAllDevices:function(){return Boolean(i.devices&&i.devices.length===_.keys(d).length)}}),f(i.child.config)}e.$inject=["$scope","$q","c8yInventory","c8yBase","c8yGroups","c8yComputedProperties","c8yObjectActions","c8yPropertiesLibrary","assetsSvc"],angular.module("c8y.assets").controller("AssetsCtrl",e)})();