(()=>{function e(o){function e(e){var t=this;t._id=String(Math.random()).substr(2),e.addItem(t),t.chart=e,t.maxLabelLength=50,t.maxValueUnitLength=30,t.init()}function c(e,t){var a,n,i=o("absoluteDate");return"HOURLY"===e._aggregation?(a=new Date(t),n=new Date(t),a.setMinutes(0,0,0),n.setHours(a.getHours()+1,0,0,0),"".concat(i(a,"mediumDate")," ").concat(i(a,"shortTime")," - ").concat(i(n,"shortTime"))):"MINUTELY"===e._aggregation?(a=new Date(t),n=new Date(t),a.setSeconds(0,0),n.setMinutes(a.getMinutes()+1,0,0),"".concat(i(a,"mediumDate")," ").concat(i(a,"shortTime")," - ").concat(i(n,"shortTime"))):"DAILY"===e._aggregation?i(t,"mediumDate"):i(t)}return e.prototype={tplMain:$('<div class="c8y-chart-hover-box"></div>'),tplTime:$('<div class="clock"><i class="dlt-c8y-icon-clock-o"></i><span class="time"></span></div>'),tplRow:$('\n        <div class="series">\n          <div class="value-holder"><i class="dlt-c8y-icon-circle"></i><span class="label"></span><span class="value"></span></div>\n          <div class="time-holder"><i class="dlt-c8y-icon-clock-o"></i><span class="time"></span></div>\n        </div>\n      '),init:function(){var t=this,e=$("body"),a=(t.el=$("<div>").append(t.tplMain.clone()).find(".c8y-chart-hover-box"),t.el);t.el.append(t.tplTime.clone()),t.clock=a.find(".clock .time"),t.el.hide(),e.append(a),t.mouseMove=function(e){t._mx=e.pageX,t._my=e.pageY},t.chart.el.on("mousemove",t.mouseMove)},destroy:function(){this.el.remove()},render:function(e){var n=this,t=n.chart.series,i=n.el;i.is(":hidden")||(e&&(e=c(n.chart,e),n.clock.text(e)),_.forEach(t,function(e){var t=e._hoverRow,a=(t||(a=n.tplRow.clone(),e._hoverRow={el:a,circle:a.find(".dlt-c8y-icon-circle"),label:a.find(".label"),value:a.find(".value"),time:a.find(".time")},t=e._hoverRow,a.data("seriedata",e),i.append(a)),t.circle.css({color:e.dataPoint.color}),e.dataPoint.label),a=a.length>n.maxLabelLength?"".concat(a.substring(0,n.maxLabelLength),"…"):a,a=(t.label.text(a),e.hoverValue()),a=a.length>n.maxValueUnitLength?"".concat(a.substring(0,n.maxValueUnitLength),"…"):a;t.value.text(a),"--"!==e.hoverTime()?t.time.text(c(n.chart,e.hoverTime())):t.time.text(e.hoverTime())}),i.find(".series").filter(function(){return!_.includes(t,$(this).data("seriedata"))}).remove())},onMove:function(e,t){var a=this,n=a.chart,i=(_.get(n,"selectedPoint.date")&&!n.mouseIn&&(i=$(n.el).offset(),a._mx=i.left+t+10,a._my=i.top),a.el.width()),t=n.box().width<t+n.margins.l+i,n=window.scrollY+window.innerHeight,i=this.el.outerHeight(),o="auto",c=t?-($("body").width()-a._mx):a._mx+1,l=a._my+20,n=(n<l+i&&(l=n-i),{left:t?o:0,right:t?0:o,transform:"translate(".concat(c,"px,").concat(l,"px)")});a.render(e),a.el.css(n)}},e}e.$inject=["$filter"],angular.module("c8y.core.measurements2").factory("c8yHoverInfo",e)})();