"use strict";angular.module("com.2fdevs.videogular",["ngSanitize"]).constant("VG_STATES",{PLAY:"play",PAUSE:"pause",STOP:"stop"}).service("VG_UTILS",function(){this.fixEventOffset=function(a){if(navigator.userAgent.match(/Firefox/i)){var b=a.currentTarget.currentStyle||window.getComputedStyle(a.target,null),c=parseInt(b.borderLeftWidth,10),d=parseInt(b.borderTopWidth,10),e=a.currentTarget.getBoundingClientRect(),f=a.clientX-c-e.left,g=a.clientY-d-e.top;a.offsetX=f,a.offsetY=g}return a},this.getZIndex=function(){var a=1;return angular.element("*").filter(function(){return"auto"!==angular.element(this).css("zIndex")}).each(function(){var b=parseInt(angular.element(this).css("zIndex"));b>a&&(a=b+1)}),a},this.toUTCDate=function(a){return new Date(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate(),a.getUTCHours(),a.getUTCMinutes(),a.getUTCSeconds())},this.secondsToDate=function(a){var b=new Date;return b.setTime(1e3*a),b=this.toUTCDate(b)},this.isMobileDevice=function(){return"undefined"!=typeof window.orientation||-1!==navigator.userAgent.indexOf("IEMobile")},this.isiOSDevice=function(){return navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPod/i)||navigator.userAgent.match(/iPad/i)}}).run(["$window","VG_UTILS",function(a,b){var c,d={w3:{enabled:"fullscreenEnabled",element:"fullscreenElement",request:"requestFullscreen",exit:"exitFullscreen",onchange:"fullscreenchange",onerror:"fullscreenerror"},newWebkit:{enabled:"webkitFullscreenEnabled",element:"webkitFullscreenElement",request:"webkitRequestFullscreen",exit:"webkitExitFullscreen",onchange:"webkitfullscreenchange",onerror:"webkitfullscreenerror"},oldWebkit:{enabled:"webkitIsFullScreen",element:"webkitCurrentFullScreenElement",request:"webkitRequestFullScreen",exit:"webkitCancelFullScreen",onchange:"webkitfullscreenchange",onerror:"webkitfullscreenerror"},moz:{enabled:"mozFullScreen",element:"mozFullScreenElement",request:"mozRequestFullScreen",exit:"mozCancelFullScreen",onchange:"mozfullscreenchange",onerror:"mozfullscreenerror"},ios:{enabled:"webkitFullscreenEnabled",element:"webkitFullscreenElement",request:"webkitEnterFullscreen",exit:"webkitExitFullscreen",onchange:"webkitfullscreenchange",onerror:"webkitfullscreenerror"},ms:{enabled:"msFullscreenEnabled",element:"msFullscreenElement",request:"msRequestFullscreen",exit:"msExitFullscreen",onchange:"msfullscreenchange",onerror:"msfullscreenerror"}};for(var e in d)if(d[e].enabled in document){c=d[e],c.isFullScreen=function(){return null!=document[this.element]};break}b.isiOSDevice()&&(c=d.ios,c.isFullScreen=function(){return null!=document[this.element]}),angular.element(a)[0].fullScreenAPI=c}]).directive("videogular",["$window","VG_STATES","VG_UTILS",function(a,b,c){return{restrict:"E",scope:{theme:"=vgTheme",autoPlay:"=vgAutoplay",vgComplete:"&",vgUpdateVolume:"&",vgUpdateTime:"&",vgUpdateState:"&",vgPlayerReady:"&",vgChangeSource:"&"},controller:["$scope","$timeout",function(d,e){var f=null,g=!1,h=!1,i=d.vgComplete(),j=d.vgUpdateVolume(),k=d.vgUpdateTime(),l=d.vgUpdateState(),m=d.vgPlayerReady(),n=d.vgChangeSource();this.videogularElement=null,this.clearMedia=function(){d.API.mediaElement[0].src=""},this.onMobileVideoReady=function(a,b){this.onVideoReady(a,b,!0)},this.onVideoReady=function(a,f,g){d.API.isReady=!0,d.API.autoPlay=d.autoPlay,d.API.currentState=b.STOP,d.API.onUpdateTime(a),g||d.$apply(),h=!0,d.vgPlayerReady()&&(m=d.vgPlayerReady())(d.API),(d.autoPlay&&!c.isMobileDevice()||d.API.currentState===b.PLAY)&&e(function(){d.API.play()})},this.onUpdateTime=function(a){d.API.currentTime=c.secondsToDate(a.target.currentTime),1/0!=a.target.duration?(d.API.totalTime=c.secondsToDate(a.target.duration),d.API.timeLeft=c.secondsToDate(a.target.duration-a.target.currentTime),d.API.isLive=!1):d.API.isLive=!0,d.vgUpdateTime()&&(k=d.vgUpdateTime())(a.target.currentTime,a.target.duration),d.$apply()},this.onPlay=function(){d.API.setState(b.PLAY),d.$apply()},this.onPause=function(){d.API.setState(b.PAUSE),d.$apply()},this.onVolumeChange=function(){d.API.volume=d.API.mediaElement[0].volume,d.$apply()},this.seekTime=function(a,b){var e;b?(e=a*d.API.mediaElement[0].duration/100,d.API.mediaElement[0].currentTime=e):(e=a,d.API.mediaElement[0].currentTime=e),d.API.currentTime=c.secondsToDate(e)},this.playPause=function(){d.API.mediaElement[0].paused?this.play():this.pause()},this.setState=function(a){return a&&a!=d.API.currentState&&(d.vgUpdateState()&&(l=d.vgUpdateState())(a),d.API.currentState=a),d.API.currentState},this.play=function(){d.API.mediaElement[0].play(),this.setState(b.PLAY)},this.pause=function(){d.API.mediaElement[0].pause(),this.setState(b.PAUSE)},this.stop=function(){d.API.mediaElement[0].pause(),d.API.mediaElement[0].currentTime=0,this.setState(b.STOP)},this.toggleFullScreen=function(){angular.element(a)[0].fullScreenAPI?angular.element(a)[0].fullScreenAPI.isFullScreen()?c.isMobileDevice()||document[angular.element(a)[0].fullScreenAPI.exit]():c.isMobileDevice()?c.isiOSDevice()?h?this.enterElementInFullScreen(d.API.mediaElement[0]):(g=!0,this.play()):this.enterElementInFullScreen(d.API.mediaElement[0]):this.enterElementInFullScreen(d.API.videogularElement[0]):(d.API.isFullScreen?(d.API.videogularElement.removeClass("fullscreen"),d.API.videogularElement.css("z-index",0)):(d.API.videogularElement.addClass("fullscreen"),d.API.videogularElement.css("z-index",c.getZIndex())),d.API.isFullScreen=!d.API.isFullScreen)},this.enterElementInFullScreen=function(b){b[angular.element(a)[0].fullScreenAPI.request]()},this.changeSource=function(a){d.vgChangeSource()&&(n=d.vgChangeSource())(a)},this.setVolume=function(a){d.vgUpdateVolume()&&(j=d.vgUpdateVolume())(a),d.API.mediaElement[0].volume=a,d.API.volume=a},this.updateTheme=function(a){if(f)for(var b=document.getElementsByTagName("link"),c=0,d=b.length;d>c;c++)b[c].outerHTML.indexOf(f)>=0&&b[c].parentNode.removeChild(b[c]);if(a){var e=angular.element(document).find("head");e.append(""),f=a}},this.onStartBuffering=function(){d.API.isBuffering=!0},this.onStartPlaying=function(){d.API.isBuffering=!1},this.onComplete=function(){d.vgComplete()&&(i=d.vgComplete())(),d.API.setState(b.STOP),d.API.isCompleted=!0,d.$apply()},d.API=this,d.init=function(){d.API.isReady=!1,d.API.isCompleted=!1,d.API.currentTime=c.secondsToDate(0),d.API.totalTime=c.secondsToDate(0),d.API.timeLeft=c.secondsToDate(0),d.API.isLive=!1,d.API.updateTheme(d.theme),d.addBindings(),angular.element(a)[0].fullScreenAPI&&document.addEventListener(angular.element(a)[0].fullScreenAPI.onchange,d.onFullScreenChange)},d.addBindings=function(){d.$watch("theme",function(a,b){a!=b&&d.API.updateTheme(a)}),d.$watch("autoPlay",function(a,b){a!=b&&a&&d.API.play()})},d.onFullScreenChange=function(){d.API.isFullScreen=angular.element(a)[0].fullScreenAPI.isFullScreen(),d.$apply()},d.$on("$destroy",this.clearMedia),d.$on("$routeChangeStart",this.clearMedia),d.init()}],link:{pre:function(a,b,c,d){d.videogularElement=angular.element(b)}}}}]).directive("vgVideo",["$compile","VG_UTILS",function(a,b){return{restrict:"E",require:"^videogular",scope:{vgSrc:"=",vgLoop:"=",vgPreload:"=",vgNativeControls:"=",vgTracks:"="},link:function(c,d,e,f){var g='