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

System.register(["../../core/core_module","app/core/utils/kbn","app/core/app_events"],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,d,e){this.$rootScope=a,this.$location=b,this.$timeout=c,this.backendSrv=d,this.$routeParams=e}return a.$inject=["$rootScope","$location","$timeout","backendSrv","$routeParams"],a.prototype.next=function(){var a=this;this.$timeout.cancel(this.cancelPromise);var b=this.index>this.dashboards.length-1;if(b)return void(window.location.href=this.getUrlWithKioskMode());var c=this.dashboards[this.index];this.$location.url("dashboard/"+c.uri),this.index++,this.cancelPromise=this.$timeout(function(){return a.next()},this.interval)},a.prototype.getUrlWithKioskMode=function(){var a=document.body.classList.contains("page-kiosk-mode");return a&&this.startUrl.indexOf("kiosk")===-1?this.startUrl+"?kiosk=true":a?this.startUrl:this.startUrl.split("?")[0]},a.prototype.prev=function(){this.index=Math.max(this.index-2,0),this.next()},a.prototype.start=function(a){var b=this;this.stop(),this.startUrl=window.location.href,this.index=0,this.playlistId=a,this.isPlaying=!0,this.$routeParams.kiosk&&e.default.emit("toggle-kiosk-mode"),this.backendSrv.get("/api/playlists/"+a).then(function(c){b.backendSrv.get("/api/playlists/"+a+"/dashboards").then(function(a){b.dashboards=a,b.interval=d.default.interval_to_ms(c.interval),b.next()})})},a.prototype.stop=function(){this.index=0,this.isPlaying=!1,this.playlistId=0,this.cancelPromise&&this.$timeout.cancel(this.cancelPromise)},a}(),c.default.service("playlistSrv",f)}}});