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,a,o,i,u=[],c=!0,l=!1;try{if(o=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=o.call(r)).done)&&(u.push(n.value),u.length!==t);c=!0);}catch(e){l=!0,a=e}finally{try{if(!c&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(l)throw a}}return u}}function _arrayWithHoles(e){if(Array.isArray(e))return e}(()=>{function e(n,a,o,e,r,t){var i=a.cleanFields,u="event/events",c={headers:a.contentHeaders("event","event")},l=["creationTime","id","self","source","text","time","type","c8y_IsBinary"],t={type:t("Type"),text:t("Text")};function s(e){e=e.id||e;return a.url("".concat(u,"/").concat(e))}function y(e,t){var r=a.url(u),t=t||{},e=(t.params=a.timeOrderFilter(a.pageSizeNoTotalFilter(e)),a.cleanListCallback("events",y,t.params));return n.get(r,t).then(e)}function f(e){e=s(e);return n.get(e)}function p(e){var t=a.url(u),r=_.cloneDeep(c);return n.post(t,e,r)}function d(e){var t=s(e),e=i(e,l),r=_.cloneDeep(c);return n.put(t,e,r)}return e.enhanceWithKeysUtil({target:{list:y,detail:f,create:p,update:d,save:function(e){return(e.id?d:p)(e)},createCounter:function(e){var t,r=_.get(e,"source"),r="/events/".concat(r||"*"),r=new o.Counter(y,r),n=[o.defaultPropertyMaps.date,o.defaultPropertyMaps.source];return e.type&&(t=e.type,n.push([function(e){return t===e.type}])),delete e.type,r.filter(e,n),r},isEventBinary:function(e){return new RegExp("/event/events/[0-9]+/binaries").test(e)},getEventIdFromUrl:function(e){var t=new RegExp("([0-9]+)/binaries");return _slicedToArray(e.match(t),2)[1]},downloadAsText:function(e){e=e;var e=a.url("".concat(u,"/").concat(e,"/binaries")),t={headers:r.headers(),responseType:"text",transformResponse:function(e){return e}};return n.get(e,t)},getContentType:function(e){return f(e).then(function(e){return _.get(e,"data.c8y_IsBinary.type")})}},reservedKeys:l,standardKeys:t})}e.$inject=["$http","c8yBase","c8yCounter","c8yUtil","c8yAuth","gettext"],angular.module("c8y.core").factory("c8yEvents",e)})();