/*! grafana - v4.5.1 - 2017-09-19
 * Copyright (c) 2017 Torkel Ödegaard; Licensed Apache-2.0 */

System.register(["lodash","moment","./event"],function(a,b){"use strict";var c,d,e,f;b&&b.id;return{setters:[function(a){c=a},function(a){d=a},function(a){e=a}],execute:function(){f=function(){function a(a,b,c){this.panelCtrl=a,this.elem=b,this.popoverSrv=c}return a.prototype.editorClosed=function(){console.log("editorClosed"),this.event=null,this.panelCtrl.render()},a.prototype.updateTime=function(a){var b=!0;return this.event?b=!1:(this.event=new e.AnnotationEvent,this.event.dashboardId=this.panelCtrl.dashboard.id,this.event.panelId=this.panelCtrl.panel.id),this.event.time=d.default(a.from),this.event.isRegion=!1,a.to&&(this.event.timeEnd=d.default(a.to),this.event.isRegion=!0),b?(this.popoverSrv.show({element:this.elem[0],classNames:"drop-popover drop-popover--form",position:"bottom center",openOn:null,template:'<event-editor panel-ctrl="panelCtrl" event="event" close="dismiss()"></event-editor>',onClose:this.editorClosed.bind(this),model:{event:this.event,panelCtrl:this.panelCtrl}}),void this.panelCtrl.render()):void this.panelCtrl.render()},a.prototype.addFlotEvents=function(a,b){if(this.event||0!==a.length){var d={$__alerting:{color:"rgba(237, 46, 24, 1)",position:"BOTTOM",markerSize:5},$__ok:{color:"rgba(11, 237, 50, 1)",position:"BOTTOM",markerSize:5},$__no_data:{color:"rgba(150, 150, 150, 1)",position:"BOTTOM",markerSize:5}};if(this.event)a=[{min:this.event.time.valueOf(),title:this.event.title,text:this.event.text,eventType:"$__alerting"}];else for(var e=0;e<a.length;e++){var f=a[e];f.newState?f.eventType="$__"+f.newState:d[f.source.name]||(d[f.source.name]={color:f.source.iconColor,position:"BOTTOM",markerSize:5})}b.events={levels:c.default.keys(d).length+1,data:a,types:d}}},a}(),a("EventManager",f)}}});