function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread 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 _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}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}(()=>{e.$inject=["c8yBase","c8yUser","c8yInventory","c8yExportApis","c8yExportFilters","gettext","gettextCatalog","c8yReportsService"],angular.module("c8y.cockpit.export").service("exportConfig",e);var m="c8y_ExportConfiguration",f={name:"",exportType:"csv",queryParameters:{},apiList:[]};function e(t,e,r,n,a,i,o,l){var s=[{name:"source",label:i("Object to export"),template:":::PLUGIN_PATH:::/views/filters/source.html",def:[a.SourceFilter,"source"]},{name:"dateType",label:i("Time range"),template:":::PLUGIN_PATH:::/views/filters/dateRange.html",def:[a.DateRangeFilter,"dateType"]}],u=[{name:"Alarms",icon:"bell",label:i("Alarms"),def:[n.Api,"Alarms"]},{name:"Events",icon:"online1",label:i("Events"),def:[n.Api,"Events"]},{name:"ManagedObjects",icon:"cubes",label:i("Managed objects"),def:[n.Api,"ManagedObjects"]},{name:"Measurements",icon:"line-chart",label:i("Measurements"),def:[n.MeasurementsApi],template:":::PLUGIN_PATH:::/views/apis/measurements.html"}];function c(e){for(var t=arguments.length,a=new Array(1<t?t-1:0),r=1;r<t;r++)a[r-1]=arguments[r];return _.map(e,function(e){var t=e.def,r=_.tail(t),n=new((n=_).bind.apply(n,_toConsumableArray([t[0],t[0]].concat(r).concat(a))));return _.assign(n,_.omit(e,"def","name")),n})}this.getFilters=function(e,t){return c(s,e,t)},this.getApis=function(e){return c(u,e)},this.getFileTypes=function(){return[{name:"CSV",type:"csv"},{name:"Excel (.xlsx)",type:"vnd.ms-excel"}]},this.list=function(){return r.list({fragmentType:m,pageSize:200})},this.create=function(e){return _.merge(_.cloneDeep(f),e)},this.detail=function(e){return r.detail(e).then(t.getResData)},this.save=function(e){return e.id?r.save(e).then(function(){return e}):(e[m]={},r.createConfirm(e).then(t.getResData))},this.remove=function(e){return l.removeConfiguration(e)},this.getSmartRuleDefaults=function(t){return e.current().then(function(e){return{name:o.getString('Send "{{name}}" via email',t),c8y_Context:{context:"exportConfiguration",id:t.id},config:{exportConfiguration:_.pick(t,["id","name"]),exportConfigurationId:t.id,to:e.email,subject:o.getString('Export of "{{name}}"',t)}}})}}})();