function _slicedToArray(t,e){return _arrayWithHoles(t)||_iterableToArrayLimit(t,e)||_unsupportedIterableToArray(t,e)||_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(t,e){var n;if(t)return"string"==typeof t?_arrayLikeToArray(t,e):"Map"===(n="Object"===(n={}.toString.call(t).slice(8,-1))&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(t,e):void 0}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function _iterableToArrayLimit(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,a,o,i,c=[],l=!0,s=!1;try{if(o=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(c.push(r.value),c.length!==e);l=!0);}catch(t){s=!0,a=t}finally{try{if(!l&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(s)throw a}}return c}}function _arrayWithHoles(t){if(Array.isArray(t))return t}(()=>{function t(t,e,a,o,i){var c=10,l=this;function n(t){return l.mo=t,l.mo}function r(t){var n,t=_.get(t,"c8y_Status.instances"),t=_.map(t,function(t,e){return e});_.isEmpty(t)||(l.instances=(t=t,n=moment().format(),t.reduce(function(t,e){return t[e]={name:e,dateFrom:n},t},{})))}function s(){var t=_slicedToArray(Object.keys(l.instances),1)[0];l.selectedInstance=_.cloneDeep(_.get(l,["instances",t]))}function u(){return m(!0),d(l.mo.applicationId,l.selectedInstance.name).then(function(t){return f(t)})}function m(t){l.isRequestPending=t}function d(t,e,n,r){return a.getLogs(t,e,{dateFrom:n,dateTo:r}).finally(function(){m(!1)})}function f(t,e,n,r){var r=3<arguments.length&&void 0!==r&&r;m(!1),_.isEmpty(t.logs)?(n=a.getWarningMessageForMissingLogs(e,n),o.info(n)):(r&&(n=e,r=(r=t).dateFrom)&&moment(r).diff(n,"minutes")>c&&o.add({text:i.getString("No logs available from {{ expectedDateFrom | absoluteDateTimeFormat:'LL, LTS':'+0000' }},\n            instead loaded closest logs from {{ actualDateFrom | absoluteDateTimeFormat:'LL, LTS':'+0000' }}.",{expectedDateFrom:n,actualDateFrom:r}),type:"info",timeout:5e3}),_.assign(l.selectedInstance,t))}_.assign(l,{$onInit:function(){e.getApplicationMO(t.applicationId).then(n).then(r).then(s).then(u)},selectedInstance:void 0,nextBtnClick:function(){m(!0);var t=l.mo.applicationId,e=l.selectedInstance.name,n=moment(_.get(l,"selectedInstance.dateTo")).format();return d(t,e,n,void 0).then(function(t){return f(t,n)})},backBtnClick:function(){m(!0);var t=l.mo.applicationId,e=l.selectedInstance.name,n=moment(_.get(l,"selectedInstance.dateFrom")).format();return d(t,e,void 0,n).then(function(t){return f(t,void 0,n)})},loadLatestLogs:u,onInstanceChange:function(t){l.selectedInstance=_.cloneDeep(t),u()},loadLogsFromDate:function(t){m(!0);var e=a.formatDateChosenByUser(moment(t)),t=l.mo.applicationId,n=l.selectedInstance.name;return d(t,n,e).then(function(t){return f(t,e,t.dateTo,!0)})},beginningBtnClick:function(){m(!0);var t=l.mo.applicationId,e=l.selectedInstance.name;return d(t,e,"1970-01-01T00:00:00+00:00").then(function(t){return f(t,t.dateFrom,t.dateTo)})},isRequestPending:void 0})}t.$inject=["$routeParams","c8yApplication","c8yApplicationLogs","c8yAlert","gettextCatalog"],angular.module("c8y.appLogs").component("c8yAppLogs",{bindings:{basePath:"@"},templateUrl:":::PLUGIN_PATH:::/app-logs/app-logs.html",controller:t,controllerAs:"vm"})})();