!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("video.js")):"function"==typeof define&&define.amd?define(["exports","video.js"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).videojsIma={},t.videojs)}(this,function(t,e){"use strict";function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=Array(e);i<e;i++)n[i]=t[i];return n}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e,i){return Object.defineProperty(t,"prototype",{writable:!1}),t}function o(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return i(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(t,e):void 0}}(t))||e){n&&(t=n);var s=0,o=function(){};return{s:o,n:function(){return s>=t.length?{done:!0}:{done:!1,value:t[s++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,a=!0,d=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){d=!0,r=t},f:function(){try{a||null==n.return||n.return()}finally{if(d)throw r}}}}function r(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function a(t){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},a(t)}var d=function(t,e,i){this.vjsPlayer=t,this.controller=i,this.contentTrackingTimer=null,this.contentComplete=!1,this.updateTimeIntervalHandle=null,this.updateTimeInterval=1e3,this.seekCheckIntervalHandle=null,this.seekCheckInterval=1e3,this.resizeCheckIntervalHandle=null,this.resizeCheckInterval=250,this.seekThreshold=100,this.contentEndedListeners=[],this.contentSource="",this.contentSourceType="",this.contentPlayheadTracker={currentTime:0,previousTime:0,seeking:!1,duration:0},this.vjsPlayerDimensions={width:this.getPlayerWidth(),height:this.getPlayerHeight()},this.vjsControls=this.vjsPlayer.getChild("controlBar"),this.h5Player=null,this.vjsPlayer.one("play",this.setUpPlayerIntervals.bind(this)),this.boundContentEndedListener=this.localContentEndedListener.bind(this),this.vjsPlayer.on("readyforpostroll",this.boundContentEndedListener),this.vjsPlayer.on("dispose",this.playerDisposedListener.bind(this)),this.vjsPlayer.on("readyforpreroll",this.onReadyForPreroll.bind(this)),this.vjsPlayer.on("adtimeout",this.onAdTimeout.bind(this)),this.vjsPlayer.ready(this.onPlayerReady.bind(this)),"onPlay"===this.controller.getSettings().requestMode&&this.vjsPlayer.one("play",this.controller.requestAds.bind(this.controller)),this.vjsPlayer.ads||window.console.warn("You may be using a version of videojs-contrib-ads that is not compatible with your version of video.js."),this.vjsPlayer.ads(e)};d.prototype.setUpPlayerIntervals=function(){this.updateTimeIntervalHandle&&clearInterval(this.updateTimeIntervalHandle),this.seekCheckIntervalHandle&&clearInterval(this.seekCheckIntervalHandle),this.resizeCheckIntervalHandle&&clearInterval(this.resizeCheckIntervalHandle),this.updateTimeIntervalHandle=setInterval(this.updateCurrentTime.bind(this),this.updateTimeInterval),this.seekCheckIntervalHandle=setInterval(this.checkForSeeking.bind(this),this.seekCheckInterval),this.resizeCheckIntervalHandle=setInterval(this.checkForResize.bind(this),this.resizeCheckInterval)},d.prototype.updateCurrentTime=function(){this.contentPlayheadTracker.seeking||(this.contentPlayheadTracker.currentTime=this.vjsPlayer.currentTime())},d.prototype.checkForSeeking=function(){var t=1e3*(this.vjsPlayer.currentTime()-this.contentPlayheadTracker.previousTime);Math.abs(t)>this.seekCheckInterval+this.seekThreshold?this.contentPlayheadTracker.seeking=!0:this.contentPlayheadTracker.seeking=!1,this.contentPlayheadTracker.previousTime=this.vjsPlayer.currentTime()},d.prototype.checkForResize=function(){var t=this.getPlayerWidth(),e=this.getPlayerHeight();t==this.vjsPlayerDimensions.width&&e==this.vjsPlayerDimensions.height||(this.vjsPlayerDimensions.width=t,this.vjsPlayerDimensions.height=e,this.controller.onPlayerResize(t,e))},d.prototype.localContentEndedListener=function(){for(var t in this.contentComplete||(this.contentComplete=!0,this.controller.onContentComplete()),this.contentEndedListeners)"function"==typeof this.contentEndedListeners[t]&&this.contentEndedListeners[t]();this.vjsPlayer.el()&&this.vjsPlayer.one("play",this.setUpPlayerIntervals.bind(this))},d.prototype.onNoPostroll=function(){this.vjsPlayer.trigger("nopostroll")},d.prototype.playerDisposedListener=function(){this.contentEndedListeners=[],this.controller.onPlayerDisposed(),this.contentComplete=!0,this.vjsPlayer.off("readyforpostroll",this.boundContentEndedListener),this.vjsPlayer.ads.adTimeoutTimeout&&clearTimeout(this.vjsPlayer.ads.adTimeoutTimeout);var t=[this.updateTimeIntervalHandle,this.seekCheckIntervalHandle,this.resizeCheckIntervalHandle];for(var e in t)t[e]&&clearInterval(t[e])},d.prototype.onReadyForPreroll=function(){this.controller.onPlayerReadyForPreroll()},d.prototype.onAdTimeout=function(){this.controller.onAdTimeout()},d.prototype.onPlayerReady=function(){this.h5Player=document.getElementById(this.getPlayerId()).getElementsByClassName("vjs-tech")[0],this.h5Player.hasAttribute("autoplay")&&this.controller.setSetting("adWillAutoPlay",!0),this.onVolumeChange(),this.vjsPlayer.on("fullscreenchange",this.onFullscreenChange.bind(this)),this.vjsPlayer.on("volumechange",this.onVolumeChange.bind(this)),this.controller.onPlayerReady()},d.prototype.onFullscreenChange=function(){this.vjsPlayer.isFullscreen()?this.controller.onPlayerEnterFullscreen():this.controller.onPlayerExitFullscreen()},d.prototype.onVolumeChange=function(){var t=this.vjsPlayer.muted()?0:this.vjsPlayer.volume();this.controller.onPlayerVolumeChanged(t)},d.prototype.injectAdContainerDiv=function(t){this.vjsControls.el().parentNode.appendChild(t)},d.prototype.getContentPlayer=function(){return this.h5Player},d.prototype.getVolume=function(){return this.vjsPlayer.muted()?0:this.vjsPlayer.volume()},d.prototype.setVolume=function(t){this.vjsPlayer.volume(t),0==t?this.vjsPlayer.muted(!0):this.vjsPlayer.muted(!1)},d.prototype.unmute=function(){this.vjsPlayer.muted(!1)},d.prototype.mute=function(){this.vjsPlayer.muted(!0)},d.prototype.play=function(){this.vjsPlayer.play()},d.prototype.togglePlayback=function(){this.vjsPlayer.paused()?this.vjsPlayer.play():this.vjsPlayer.pause()},d.prototype.getPlayerWidth=function(){var t=(getComputedStyle(this.vjsPlayer.el())||{}).width;return t&&0!==parseFloat(t)||(t=(this.vjsPlayer.el().getBoundingClientRect()||{}).width),parseFloat(t)||this.vjsPlayer.width()},d.prototype.getPlayerHeight=function(){var t=(getComputedStyle(this.vjsPlayer.el())||{}).height;return t&&0!==parseFloat(t)||(t=(this.vjsPlayer.el().getBoundingClientRect()||{}).height),parseFloat(t)||this.vjsPlayer.height()},d.prototype.getPlayerOptions=function(){return this.vjsPlayer.options_},d.prototype.getPlayerId=function(){return this.vjsPlayer.id()},d.prototype.toggleFullscreen=function(){this.vjsPlayer.isFullscreen()?this.vjsPlayer.exitFullscreen():this.vjsPlayer.requestFullscreen()},d.prototype.getContentPlayheadTracker=function(){return this.contentPlayheadTracker},d.prototype.onAdError=function(t){this.vjsControls.show();var e=void 0!==t.getError?t.getError():t.stack;this.vjsPlayer.trigger({type:"adserror",data:{AdError:e,AdErrorEvent:t}})},d.prototype.onAdLog=function(t){var e=t.getAdData(),i=void 0!==e.adError?e.adError.getMessage():void 0;this.vjsPlayer.trigger({type:"adslog",data:{AdError:i,AdEvent:t}})},d.prototype.onAdBreakStart=function(){this.contentSource=this.vjsPlayer.currentSrc(),this.contentSourceType=this.vjsPlayer.currentType(),this.vjsPlayer.off("readyforpostroll",this.boundContentEndedListener),this.vjsPlayer.ads.startLinearAdMode(),this.vjsControls.hide(),this.vjsPlayer.pause()},d.prototype.onAdBreakEnd=function(){this.vjsPlayer.on("readyforpostroll",this.boundContentEndedListener),this.vjsPlayer.ads.inAdBreak()&&this.vjsPlayer.ads.endLinearAdMode(),this.vjsControls.show()},d.prototype.onAdStart=function(){this.vjsPlayer.trigger("ads-ad-started")},d.prototype.onAllAdsCompleted=function(){1==this.contentComplete&&(this.contentSource&&this.vjsPlayer.currentSrc()!=this.contentSource&&this.vjsPlayer.src({src:this.contentSource,type:this.contentSourceType}),this.controller.onContentAndAdsCompleted())},d.prototype.onAdsReady=function(){this.vjsPlayer.trigger("adsready")},d.prototype.changeSource=function(t){this.vjsPlayer.currentSrc()&&(this.vjsPlayer.currentTime(0),this.vjsPlayer.pause()),t&&this.vjsPlayer.src(t),this.vjsPlayer.one("loadedmetadata",this.seekContentToZero.bind(this))},d.prototype.seekContentToZero=function(){this.vjsPlayer.currentTime(0)},d.prototype.triggerPlayerEvent=function(t,e){this.vjsPlayer.trigger(t,e)},d.prototype.addContentEndedListener=function(t){this.contentEndedListeners.push(t)},d.prototype.reset=function(){this.vjsPlayer.off("readyforpostroll",this.boundContentEndedListener),this.vjsPlayer.on("readyforpostroll",this.boundContentEndedListener),this.vjsControls.show(),this.vjsPlayer.ads.inAdBreak()&&this.vjsPlayer.ads.endLinearAdMode(),this.contentPlayheadTracker.currentTime=0,this.contentComplete=!1};var l=function(t){this.controller=t,this.adContainerDiv=document.createElement("div"),this.controlsDiv=document.createElement("div"),this.countdownDiv=document.createElement("div"),this.seekBarDiv=document.createElement("div"),this.progressDiv=document.createElement("div"),this.playPauseDiv=document.createElement("div"),this.muteDiv=document.createElement("div"),this.sliderDiv=document.createElement("div"),this.sliderLevelDiv=document.createElement("div"),this.fullscreenDiv=document.createElement("div"),this.boundOnMouseUp=this.onMouseUp.bind(this),this.boundOnMouseMove=this.onMouseMove.bind(this),this.adPlayheadTracker={currentTime:0,duration:0,isPod:!1,adPosition:0,totalAds:0},this.controlPrefix=this.controller.getPlayerId()+"_",this.showCountdown=!0,!1===this.controller.getSettings().showCountdown&&(this.showCountdown=!1),this.isAdNonlinear=!1,this.createAdContainer()};l.prototype.createAdContainer=function(){this.assignControlAttributes(this.adContainerDiv,"ima-ad-container"),this.adContainerDiv.classList.add("hide-ad-container"),this.adContainerDiv.addEventListener("mouseenter",this.showAdControls.bind(this),!1),this.adContainerDiv.addEventListener("mouseleave",this.hideAdControls.bind(this),!1),this.adContainerDiv.addEventListener("click",this.onAdContainerClick.bind(this),!1),this.createControls(),this.controller.injectAdContainerDiv(this.adContainerDiv)},l.prototype.createControls=function(){this.assignControlAttributes(this.controlsDiv,"ima-controls-div"),this.controlsDiv.style.width="100%",this.controller.getIsMobile()?this.countdownDiv.style.display="none":(this.assignControlAttributes(this.countdownDiv,"ima-countdown-div"),this.countdownDiv.innerHTML=this.controller.getSettings().adLabel,this.countdownDiv.style.display=this.showCountdown?"block":"none"),this.assignControlAttributes(this.seekBarDiv,"ima-seek-bar-div"),this.seekBarDiv.style.width="100%",this.assignControlAttributes(this.progressDiv,"ima-progress-div"),this.assignControlAttributes(this.playPauseDiv,"ima-play-pause-div"),this.addClass(this.playPauseDiv,"ima-playing"),this.playPauseDiv.addEventListener("click",this.onAdPlayPauseClick.bind(this),!1),this.assignControlAttributes(this.muteDiv,"ima-mute-div"),this.addClass(this.muteDiv,"ima-non-muted"),this.muteDiv.addEventListener("click",this.onAdMuteClick.bind(this),!1),this.assignControlAttributes(this.sliderDiv,"ima-slider-div"),this.sliderDiv.addEventListener("mousedown",this.onAdVolumeSliderMouseDown.bind(this),!1),this.controller.getIsIos()&&(this.sliderDiv.style.display="none"),this.assignControlAttributes(this.sliderLevelDiv,"ima-slider-level-div"),this.assignControlAttributes(this.fullscreenDiv,"ima-fullscreen-div"),this.addClass(this.fullscreenDiv,"ima-non-fullscreen"),this.fullscreenDiv.addEventListener("click",this.onAdFullscreenClick.bind(this),!1),this.adContainerDiv.appendChild(this.controlsDiv),this.controlsDiv.appendChild(this.countdownDiv),this.controlsDiv.appendChild(this.seekBarDiv),this.controlsDiv.appendChild(this.playPauseDiv),this.controlsDiv.appendChild(this.muteDiv),this.controlsDiv.appendChild(this.sliderDiv),this.controlsDiv.appendChild(this.fullscreenDiv),this.seekBarDiv.appendChild(this.progressDiv),this.sliderDiv.appendChild(this.sliderLevelDiv)},l.prototype.onAdPlayPauseClick=function(){this.controller.onAdPlayPauseClick()},l.prototype.onAdMuteClick=function(){this.controller.onAdMuteClick()},l.prototype.onAdFullscreenClick=function(){this.controller.toggleFullscreen()},l.prototype.onAdsPaused=function(){this.controller.sdkImpl.adPlaying=!1,this.addClass(this.playPauseDiv,"ima-paused"),this.removeClass(this.playPauseDiv,"ima-playing"),this.showAdControls()},l.prototype.onAdsResumed=function(){this.onAdsPlaying(),this.showAdControls()},l.prototype.onAdsPlaying=function(){this.controller.sdkImpl.adPlaying=!0,this.addClass(this.playPauseDiv,"ima-playing"),this.removeClass(this.playPauseDiv,"ima-paused")},l.prototype.updateAdUi=function(t,e,i,n,s){var o=Math.floor(e/60),r=Math.floor(e%60);r.toString().length<2&&(r="0"+r);var a=": ";s>1&&(a=" ("+n+" "+this.controller.getSettings().adLabelNofN+" "+s+"): "),this.countdownDiv.innerHTML=this.controller.getSettings().adLabel+a+o+":"+r;var d=100*(t/i);this.progressDiv.style.width=d+"%"},l.prototype.unmute=function(){this.addClass(this.muteDiv,"ima-non-muted"),this.removeClass(this.muteDiv,"ima-muted"),this.sliderLevelDiv.style.width=100*this.controller.getPlayerVolume()+"%"},l.prototype.mute=function(){this.addClass(this.muteDiv,"ima-muted"),this.removeClass(this.muteDiv,"ima-non-muted"),this.sliderLevelDiv.style.width="0%"},l.prototype.onAdVolumeSliderMouseDown=function(){document.addEventListener("mouseup",this.boundOnMouseUp,!1),document.addEventListener("mousemove",this.boundOnMouseMove,!1)},l.prototype.onMouseMove=function(t){this.changeVolume(t)},l.prototype.onMouseUp=function(t){this.changeVolume(t),document.removeEventListener("mouseup",this.boundOnMouseUp),document.removeEventListener("mousemove",this.boundOnMouseMove)},l.prototype.changeVolume=function(t){var e=(t.clientX-this.sliderDiv.getBoundingClientRect().left)/this.sliderDiv.offsetWidth;e*=100,e=Math.min(Math.max(e,0),100),this.sliderLevelDiv.style.width=e+"%",0==this.percent?(this.addClass(this.muteDiv,"ima-muted"),this.removeClass(this.muteDiv,"ima-non-muted")):(this.addClass(this.muteDiv,"ima-non-muted"),this.removeClass(this.muteDiv,"ima-muted")),this.controller.setVolume(e/100)},l.prototype.showAdContainer=function(){this.adContainerDiv.classList.remove("hide-ad-container")},l.prototype.hideAdContainer=function(){this.adContainerDiv.classList.add("hide-ad-container")},l.prototype.onAdContainerClick=function(){this.isAdNonlinear&&this.controller.togglePlayback()},l.prototype.reset=function(){this.hideAdContainer()},l.prototype.onAdError=function(){this.hideAdContainer()},l.prototype.onAdBreakStart=function(t){this.showAdContainer(),"application/javascript"!==t.getAd().getContentType()||this.controller.getSettings().showControlsForJSAds?this.controlsDiv.style.display="block":this.controlsDiv.style.display="none",this.onAdsPlaying(),this.hideAdControls()},l.prototype.onAdBreakEnd=function(){var t=this.controller.getCurrentAd();(null==t||t.isLinear())&&this.hideAdContainer(),this.controlsDiv.style.display="none",this.countdownDiv.innerHTML=""},l.prototype.onAllAdsCompleted=function(){this.hideAdContainer()},l.prototype.onLinearAdStart=function(){this.removeClass(this.adContainerDiv,"bumpable-ima-ad-container"),this.isAdNonlinear=!1},l.prototype.onNonLinearAdLoad=function(){this.addClass(this.adContainerDiv,"bumpable-ima-ad-container"),this.isAdNonlinear=!0},l.prototype.onPlayerEnterFullscreen=function(){this.addClass(this.fullscreenDiv,"ima-fullscreen"),this.removeClass(this.fullscreenDiv,"ima-non-fullscreen")},l.prototype.onPlayerExitFullscreen=function(){this.addClass(this.fullscreenDiv,"ima-non-fullscreen"),this.removeClass(this.fullscreenDiv,"ima-fullscreen")},l.prototype.onPlayerVolumeChanged=function(t){0==t?(this.addClass(this.muteDiv,"ima-muted"),this.removeClass(this.muteDiv,"ima-non-muted"),this.sliderLevelDiv.style.width="0%"):(this.addClass(this.muteDiv,"ima-non-muted"),this.removeClass(this.muteDiv,"ima-muted"),this.sliderLevelDiv.style.width=100*t+"%")},l.prototype.showAdControls=function(){this.controller.getSettings().disableAdControls||this.addClass(this.controlsDiv,"ima-controls-div-showing")},l.prototype.hideAdControls=function(){this.removeClass(this.controlsDiv,"ima-controls-div-showing")},l.prototype.assignControlAttributes=function(t,e){t.id=this.controlPrefix+e,t.className=this.controlPrefix+e+" "+e},l.prototype.getClassRegexp=function(t){return new RegExp("(^|[^A-Za-z-])"+t+"((?![A-Za-z-])|$)","gi")},l.prototype.elementHasClass=function(t,e){return this.getClassRegexp(e).test(t.className)},l.prototype.addClass=function(t,e){t.className=t.className.trim()+" "+e},l.prototype.removeClass=function(t,e){var i=this.getClassRegexp(e);t.className=t.className.trim().replace(i,"")},l.prototype.getAdContainerDiv=function(){return this.adContainerDiv},l.prototype.setShowCountdown=function(t){this.showCountdown=t,this.countdownDiv.style.display=this.showCountdown?"block":"none"};var h="2.6.0",p=function(t){this.controller=t,this.adDisplayContainer=null,this.adDisplayContainerInitialized=!1,this.adsLoader=null,this.adsManager=null,this.adsRenderingSettings=null,this.adsResponse=null,this.currentAd=null,this.adTrackingTimer=null,this.allAdsCompleted=!1,this.adsActive=!1,this.adPlaying=!1,this.adMuted=!1,this.adBreakReadyListener=void 0,this.contentCompleteCalled=!1,this.isAdTimedOut=!1,this.adsManagerDimensions={width:0,height:0},this.autoPlayAdBreaks=!0,!1===this.controller.getSettings().autoPlayAdBreaks&&(this.autoPlayAdBreaks=!1),this.controller.getSettings().locale&&google.ima.settings.setLocale(this.controller.getSettings().locale),this.controller.getSettings().disableFlashAds&&google.ima.settings.setDisableFlashAds(this.controller.getSettings().disableFlashAds),this.controller.getSettings().disableCustomPlaybackForIOS10Plus&&google.ima.settings.setDisableCustomPlaybackForIOS10Plus(this.controller.getSettings().disableCustomPlaybackForIOS10Plus),this.controller.getSettings().ppid&&google.ima.settings.setPpid(this.controller.getSettings().ppid),this.controller.getSettings().featureFlags&&google.ima.settings.setFeatureFlags(this.controller.getSettings().featureFlags)};p.prototype.initAdObjects=function(){this.adDisplayContainer=new google.ima.AdDisplayContainer(this.controller.getAdContainerDiv(),this.controller.getContentPlayer()),this.adsLoader=new google.ima.AdsLoader(this.adDisplayContainer),this.adsLoader.getSettings().setVpaidMode(google.ima.ImaSdkSettings.VpaidMode.ENABLED),0==this.controller.getSettings().vpaidAllowed&&this.adsLoader.getSettings().setVpaidMode(google.ima.ImaSdkSettings.VpaidMode.DISABLED),void 0!==this.controller.getSettings().vpaidMode&&this.adsLoader.getSettings().setVpaidMode(this.controller.getSettings().vpaidMode),this.controller.getSettings().locale&&this.adsLoader.getSettings().setLocale(this.controller.getSettings().locale),this.controller.getSettings().numRedirects&&this.adsLoader.getSettings().setNumRedirects(this.controller.getSettings().numRedirects),this.controller.getSettings().sessionId&&this.adsLoader.getSettings().setSessionId(this.controller.getSettings().sessionId),this.adsLoader.getSettings().setPlayerType("videojs-ima"),this.adsLoader.getSettings().setPlayerVersion(h),this.adsLoader.getSettings().setAutoPlayAdBreaks(this.autoPlayAdBreaks),this.adsLoader.addEventListener(google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,this.onAdsManagerLoaded.bind(this),!1),this.adsLoader.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR,this.onAdsLoaderError.bind(this),!1),this.controller.playerWrapper.vjsPlayer.trigger({type:"ads-loader",adsLoader:this.adsLoader})},p.prototype.requestAds=function(){var t=new google.ima.AdsRequest;if(this.controller.getSettings().adTagUrl?t.adTagUrl=this.controller.getSettings().adTagUrl:t.adsResponse=this.controller.getSettings().adsResponse,this.controller.getSettings().forceNonLinearFullSlot&&(t.forceNonLinearFullSlot=!0),this.controller.getSettings().vastLoadTimeout&&(t.vastLoadTimeout=this.controller.getSettings().vastLoadTimeout),this.controller.getSettings().omidMode&&window.console.warn("The additional setting `omidMode` has been removed. Use `omidVendorAccess` instead."),this.controller.getSettings().omidVendorAccess){t.omidAccessModeRules={};var e=this.controller.getSettings().omidVendorAccess;Object.keys(e).forEach(function(i){t.omidAccessModeRules[i]=e[i]})}t.linearAdSlotWidth=this.controller.getPlayerWidth(),t.linearAdSlotHeight=this.controller.getPlayerHeight(),t.nonLinearAdSlotWidth=this.controller.getSettings().nonLinearWidth||this.controller.getPlayerWidth(),t.nonLinearAdSlotHeight=this.controller.getSettings().nonLinearHeight||this.controller.getPlayerHeight(),t.setAdWillAutoPlay(this.controller.adsWillAutoplay()),t.setAdWillPlayMuted(this.controller.adsWillPlayMuted());var i=this.controller.getSettings().adsRequest;i&&"object"===a(i)&&Object.keys(i).forEach(function(e){t[e]=i[e]}),this.adsLoader.requestAds(t),this.controller.playerWrapper.vjsPlayer.trigger({type:"ads-request",AdsRequest:t})},p.prototype.onAdsManagerLoaded=function(t){this.createAdsRenderingSettings(),this.adsManager=t.getAdsManager(this.controller.getContentPlayheadTracker(),this.adsRenderingSettings),this.adsManager.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR,this.onAdError.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.AD_BREAK_READY,this.onAdBreakReady.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED,this.onContentPauseRequested.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED,this.onContentResumeRequested.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.ALL_ADS_COMPLETED,this.onAllAdsCompleted.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.LOADED,this.onAdLoaded.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.STARTED,this.onAdStarted.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.COMPLETE,this.onAdComplete.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.SKIPPED,this.onAdComplete.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.LOG,this.onAdLog.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.PAUSED,this.onAdPaused.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.RESUMED,this.onAdResumed.bind(this)),this.controller.playerWrapper.vjsPlayer.trigger({type:"ads-manager",adsManager:this.adsManager}),this.autoPlayAdBreaks||this.initAdsManager();var e=this.controller.getSettings().preventLateAdStart;e?e&&!this.isAdTimedOut&&this.controller.onAdsReady():this.controller.onAdsReady(),this.controller.getSettings().adsManagerLoadedCallback&&this.controller.getSettings().adsManagerLoadedCallback()},p.prototype.onAdsLoaderError=function(t){window.console.warn("AdsLoader error: "+t.getError()),this.controller.onErrorLoadingAds(t),this.adsManager&&this.adsManager.destroy()},p.prototype.initAdsManager=function(){try{var t=this.controller.getPlayerWidth(),e=this.controller.getPlayerHeight();this.adsManagerDimensions.width=t,this.adsManagerDimensions.height=e,this.adsManager.init(t,e),this.adsManager.setVolume(this.controller.getPlayerVolume()),this.initializeAdDisplayContainer()}catch(t){this.onAdError(t)}},p.prototype.createAdsRenderingSettings=function(){if(this.adsRenderingSettings=new google.ima.AdsRenderingSettings,this.adsRenderingSettings.restoreCustomPlaybackStateOnAdBreakComplete=!0,this.controller.getSettings().adsRenderingSettings)for(var t in this.controller.getSettings().adsRenderingSettings)""!==t&&(this.adsRenderingSettings[t]=this.controller.getSettings().adsRenderingSettings[t])},p.prototype.onAdError=function(t){var e=void 0!==t.getError?t.getError():t.stack;window.console.warn("Ad error: "+e),this.adsManager.destroy(),this.controller.onAdError(t),this.adsActive=!1,this.adPlaying=!1},p.prototype.onAdBreakReady=function(t){this.adBreakReadyListener(t)},p.prototype.onContentPauseRequested=function(t){this.adsActive=!0,this.adPlaying=!0,this.controller.onAdBreakStart(t)},p.prototype.onContentResumeRequested=function(t){this.adsActive=!1,this.adPlaying=!1,this.controller.onAdBreakEnd()},p.prototype.onAllAdsCompleted=function(t){this.allAdsCompleted=!0,this.controller.onAllAdsCompleted()},p.prototype.onAdLoaded=function(t){t.getAd().isLinear()||(this.controller.onNonLinearAdLoad(),this.controller.playContent())},p.prototype.onAdStarted=function(t){this.currentAd=t.getAd(),this.currentAd.isLinear()?(this.adTrackingTimer=setInterval(this.onAdPlayheadTrackerInterval.bind(this),250),this.controller.onLinearAdStart()):this.controller.onNonLinearAdStart()},p.prototype.onAdPaused=function(){this.controller.onAdsPaused()},p.prototype.onAdResumed=function(t){this.controller.onAdsResumed()},p.prototype.onAdComplete=function(){this.currentAd.isLinear()&&clearInterval(this.adTrackingTimer)},p.prototype.onAdLog=function(t){this.controller.onAdLog(t)},p.prototype.onAdPlayheadTrackerInterval=function(){if(null!==this.adsManager){var t=this.adsManager.getRemainingTime(),e=this.currentAd.getDuration(),i=e-t;i=i>0?i:0;var n,s=0;this.currentAd.getAdPodInfo()&&(n=this.currentAd.getAdPodInfo().getAdPosition(),s=this.currentAd.getAdPodInfo().getTotalAds()),this.controller.onAdPlayheadUpdated(i,t,e,n,s)}},p.prototype.onContentComplete=function(){this.adsLoader&&(this.adsLoader.contentComplete(),this.contentCompleteCalled=!0),(this.adsManager&&this.adsManager.getCuePoints()&&!this.adsManager.getCuePoints().includes(-1)||!this.adsManager)&&this.controller.onNoPostroll(),this.allAdsCompleted&&this.controller.onContentAndAdsCompleted()},p.prototype.onPlayerDisposed=function(){this.adTrackingTimer&&clearInterval(this.adTrackingTimer),this.adsManager&&(this.adsManager.destroy(),this.adsManager=null)},p.prototype.onPlayerReadyForPreroll=function(){if(this.autoPlayAdBreaks){this.initAdsManager();try{this.controller.showAdContainer(),this.adsManager.setVolume(this.controller.getPlayerVolume()),this.adsManager.start()}catch(t){this.onAdError(t)}}},p.prototype.onAdTimeout=function(){this.isAdTimedOut=!0},p.prototype.onPlayerReady=function(){this.initAdObjects(),(this.controller.getSettings().adTagUrl||this.controller.getSettings().adsResponse)&&"onLoad"===this.controller.getSettings().requestMode&&this.requestAds()},p.prototype.onPlayerEnterFullscreen=function(){this.adsManager&&this.adsManager.resize(window.screen.width,window.screen.height)},p.prototype.onPlayerExitFullscreen=function(){this.adsManager&&this.adsManager.resize(this.controller.getPlayerWidth(),this.controller.getPlayerHeight())},p.prototype.onPlayerVolumeChanged=function(t){this.adsManager&&this.adsManager.setVolume(t),this.adMuted=0==t},p.prototype.onPlayerResize=function(t,e){this.adsManager&&(this.adsManagerDimensions.width=t,this.adsManagerDimensions.height=e,this.adsManager.resize(t,e))},p.prototype.getCurrentAd=function(){return this.currentAd},p.prototype.setAdBreakReadyListener=function(t){this.adBreakReadyListener=t},p.prototype.isAdPlaying=function(){return this.adPlaying},p.prototype.isAdMuted=function(){return this.adMuted},p.prototype.pauseAds=function(){this.adsManager.pause(),this.adPlaying=!1},p.prototype.resumeAds=function(){this.adsManager.resume(),this.adPlaying=!0},p.prototype.unmute=function(){this.adsManager.setVolume(1),this.adMuted=!1},p.prototype.mute=function(){this.adsManager.setVolume(0),this.adMuted=!0},p.prototype.setVolume=function(t){this.adsManager.setVolume(t),this.adMuted=0==t},p.prototype.initializeAdDisplayContainer=function(){this.adDisplayContainer&&(this.adDisplayContainerInitialized||(this.adDisplayContainer.initialize(),this.adDisplayContainerInitialized=!0))},p.prototype.playAdBreak=function(){this.autoPlayAdBreaks||(this.controller.showAdContainer(),this.adsManager.setVolume(this.controller.getPlayerVolume()),this.adsManager.start())},p.prototype.addEventListener=function(t,e){this.adsManager&&this.adsManager.addEventListener(t,e)},p.prototype.getAdsManager=function(){return this.adsManager},p.prototype.reset=function(){this.adsActive=!1,this.adPlaying=!1,this.adTrackingTimer&&clearInterval(this.adTrackingTimer),this.adsManager&&(this.adsManager.destroy(),this.adsManager=null),this.adsLoader&&!this.contentCompleteCalled&&this.adsLoader.contentComplete(),this.contentCompleteCalled=!1,this.allAdsCompleted=!1};var u=function(t,e){this.settings={},this.contentAndAdsEndedListeners=[],this.isMobile=navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPad/i)||navigator.userAgent.match(/Android/i),this.isIos=navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPad/i),this.initWithSettings(e);var i={debug:this.settings.debug,timeout:this.settings.timeout,prerollTimeout:this.settings.prerollTimeout},n=Object.assign({},i,e.contribAdsSettings||{});this.playerWrapper=new d(t,n,this),this.adUi=new l(this),this.sdkImpl=new p(this)};u.IMA_DEFAULTS={adLabel:"Advertisement",adLabelNofN:"of",debug:!1,disableAdControls:!1,prerollTimeout:1e3,preventLateAdStart:!1,requestMode:"onLoad",showControlsForJSAds:!0,timeout:5e3},u.prototype.initWithSettings=function(t){this.settings=Object.assign({},u.IMA_DEFAULTS,t||{}),this.warnAboutDeprecatedSettings(),this.showCountdown=!0,!1===this.settings.showCountdown&&(this.showCountdown=!1)},u.prototype.warnAboutDeprecatedSettings=function(){var t=this;["adWillAutoplay","adsWillAutoplay","adWillPlayMuted","adsWillPlayMuted"].forEach(function(e){void 0!==t.settings[e]&&console.warn("WARNING: videojs.ima setting "+e+" is deprecated")})},u.prototype.getSettings=function(){return this.settings},u.prototype.getIsMobile=function(){return this.isMobile},u.prototype.getIsIos=function(){return this.isIos},u.prototype.injectAdContainerDiv=function(t){this.playerWrapper.injectAdContainerDiv(t)},u.prototype.getAdContainerDiv=function(){return this.adUi.getAdContainerDiv()},u.prototype.getContentPlayer=function(){return this.playerWrapper.getContentPlayer()},u.prototype.getContentPlayheadTracker=function(){return this.playerWrapper.getContentPlayheadTracker()},u.prototype.requestAds=function(){this.sdkImpl.requestAds()},u.prototype.setSetting=function(t,e){this.settings[t]=e},u.prototype.onErrorLoadingAds=function(t){this.adUi.onAdError(),this.playerWrapper.onAdError(t)},u.prototype.onAdPlayPauseClick=function(){this.sdkImpl.isAdPlaying()?(this.adUi.onAdsPaused(),this.sdkImpl.pauseAds()):(this.adUi.onAdsPlaying(),this.sdkImpl.resumeAds())},u.prototype.onAdMuteClick=function(){this.sdkImpl.isAdMuted()?(this.playerWrapper.unmute(),this.adUi.unmute(),this.sdkImpl.unmute()):(this.playerWrapper.mute(),this.adUi.mute(),this.sdkImpl.mute())},u.prototype.setVolume=function(t){this.playerWrapper.setVolume(t),this.sdkImpl.setVolume(t)},u.prototype.getPlayerVolume=function(){return this.playerWrapper.getVolume()},u.prototype.toggleFullscreen=function(){this.playerWrapper.toggleFullscreen()},u.prototype.onAdError=function(t){this.adUi.onAdError(),this.playerWrapper.onAdError(t)},u.prototype.onAdBreakStart=function(t){this.playerWrapper.onAdBreakStart(),this.adUi.onAdBreakStart(t)},u.prototype.showAdContainer=function(){this.adUi.showAdContainer()},u.prototype.onAdBreakEnd=function(){this.playerWrapper.onAdBreakEnd(),this.adUi.onAdBreakEnd()},u.prototype.onAllAdsCompleted=function(){this.adUi.onAllAdsCompleted(),this.playerWrapper.onAllAdsCompleted()},u.prototype.onAdsPaused=function(){this.adUi.onAdsPaused()},u.prototype.onAdsResumed=function(){this.adUi.onAdsResumed()},u.prototype.onAdPlayheadUpdated=function(t,e,i,n,s){this.adUi.updateAdUi(t,e,i,n,s)},u.prototype.onAdLog=function(t){this.playerWrapper.onAdLog(t)},u.prototype.getCurrentAd=function(){return this.sdkImpl.getCurrentAd()},u.prototype.playContent=function(){this.playerWrapper.play()},u.prototype.onLinearAdStart=function(){this.adUi.onLinearAdStart(),this.playerWrapper.onAdStart()},u.prototype.onNonLinearAdLoad=function(){this.adUi.onNonLinearAdLoad()},u.prototype.onNonLinearAdStart=function(){this.adUi.onNonLinearAdLoad(),this.playerWrapper.onAdStart()},u.prototype.getPlayerWidth=function(){return this.playerWrapper.getPlayerWidth()},u.prototype.getPlayerHeight=function(){return this.playerWrapper.getPlayerHeight()},u.prototype.onAdsReady=function(){this.playerWrapper.onAdsReady()},u.prototype.onPlayerResize=function(t,e){this.sdkImpl.onPlayerResize(t,e)},u.prototype.onContentComplete=function(){this.sdkImpl.onContentComplete()},u.prototype.onNoPostroll=function(){this.playerWrapper.onNoPostroll()},u.prototype.onContentAndAdsCompleted=function(){for(var t in this.contentAndAdsEndedListeners)"function"==typeof this.contentAndAdsEndedListeners[t]&&this.contentAndAdsEndedListeners[t]()},u.prototype.onPlayerDisposed=function(){this.contentAndAdsEndedListeners=[],this.sdkImpl.onPlayerDisposed()},u.prototype.onPlayerReadyForPreroll=function(){this.sdkImpl.onPlayerReadyForPreroll()},u.prototype.onAdTimeout=function(){this.sdkImpl.onAdTimeout()},u.prototype.onPlayerReady=function(){this.sdkImpl.onPlayerReady()},u.prototype.onPlayerEnterFullscreen=function(){this.adUi.onPlayerEnterFullscreen(),this.sdkImpl.onPlayerEnterFullscreen()},u.prototype.onPlayerExitFullscreen=function(){this.adUi.onPlayerExitFullscreen(),this.sdkImpl.onPlayerExitFullscreen()},u.prototype.onPlayerVolumeChanged=function(t){this.adUi.onPlayerVolumeChanged(t),this.sdkImpl.onPlayerVolumeChanged(t)},u.prototype.setContentWithAdTag=function(t,e){this.reset(),this.settings.adTagUrl=e||this.settings.adTagUrl,this.playerWrapper.changeSource(t)},u.prototype.setContentWithAdsResponse=function(t,e){this.reset(),this.settings.adsResponse=e||this.settings.adsResponse,this.playerWrapper.changeSource(t)},u.prototype.setContentWithAdsRequest=function(t,e){this.reset(),this.settings.adsRequest=e||this.settings.adsRequest,this.playerWrapper.changeSource(t)},u.prototype.reset=function(){this.sdkImpl.reset(),this.playerWrapper.reset(),this.adUi.reset()},u.prototype.addContentEndedListener=function(t){this.playerWrapper.addContentEndedListener(t)},u.prototype.addContentAndAdsEndedListener=function(t){this.contentAndAdsEndedListeners.push(t)},u.prototype.setAdBreakReadyListener=function(t){this.sdkImpl.setAdBreakReadyListener(t)},u.prototype.setShowCountdown=function(t){this.adUi.setShowCountdown(t),this.showCountdown=t,this.adUi.countdownDiv.style.display=this.showCountdown?"block":"none"},u.prototype.initializeAdDisplayContainer=function(){this.sdkImpl.initializeAdDisplayContainer()},u.prototype.playAdBreak=function(){this.sdkImpl.playAdBreak()},u.prototype.addEventListener=function(t,e){this.sdkImpl.addEventListener(t,e)},u.prototype.getAdsManager=function(){return this.sdkImpl.getAdsManager()},u.prototype.getPlayerId=function(){return this.playerWrapper.getPlayerId()},u.prototype.changeAdTag=function(t){this.reset(),this.settings.adTagUrl=t},u.prototype.pauseAd=function(){this.adUi.onAdsPaused(),this.sdkImpl.pauseAds()},u.prototype.resumeAd=function(){this.adUi.onAdsPlaying(),this.sdkImpl.resumeAds()},u.prototype.togglePlayback=function(){this.playerWrapper.togglePlayback()},u.prototype.adsWillAutoplay=function(){return void 0!==this.settings.adsWillAutoplay?this.settings.adsWillAutoplay:void 0!==this.settings.adWillAutoplay?this.settings.adWillAutoplay:!!this.playerWrapper.getPlayerOptions().autoplay},u.prototype.adsWillPlayMuted=function(){return void 0!==this.settings.adsWillPlayMuted?this.settings.adsWillPlayMuted:void 0!==this.settings.adWillPlayMuted?this.settings.adWillPlayMuted:void 0!==this.playerWrapper.getPlayerOptions().muted?this.playerWrapper.getPlayerOptions().muted:0==this.playerWrapper.getVolume()},u.prototype.triggerPlayerEvent=function(t,e){this.playerWrapper.triggerPlayerEvent(t,e)};var c=function(t,e,i){this.vjsPlayer=t,this.daiController=i,this.vjsControls=this.vjsPlayer.getChild("controlBar"),this.h5Player=null,this.vjsPlayer.on("dispose",this.playerDisposedListener.bind(this)),this.vjsPlayer.on("pause",this.onPause.bind(this)),this.vjsPlayer.on("play",this.onPlay.bind(this)),this.vjsPlayer.on("seeked",this.onSeekEnd.bind(this)),this.vjsPlayer.ready(this.onPlayerReady.bind(this)),this.vjsPlayer.ads||window.console.warn("You may be using a version of videojs-contrib-ads that is not compatible with your version of video.js."),this.vjsPlayer.ads(e)};c.prototype.playerDisposedListener=function(){this.contentEndedListeners=[],this.daiController.onPlayerDisposed()},c.prototype.onPause=function(){this.daiController.isInAdBreak()&&this.vjsControls.show()},c.prototype.onPlay=function(){this.daiController.isInAdBreak()&&this.vjsControls.hide()},c.prototype.onSeekEnd=function(){this.daiController.onSeekEnd(this.vjsPlayer.currentTime())},c.prototype.onPlayerReady=function(){this.h5Player=document.getElementById(this.getPlayerId()).getElementsByClassName("vjs-tech")[0],this.daiController.onPlayerReady()},c.prototype.getStreamPlayer=function(){return this.h5Player},c.prototype.getVjsPlayer=function(){return this.vjsPlayer},c.prototype.getPlayerOptions=function(){return this.vjsPlayer.options_},c.prototype.getPlayerId=function(){return this.vjsPlayer.id()},c.prototype.onAdError=function(t){this.vjsControls.show();var e=void 0!==t.getError?t.getError():t.stack;this.vjsPlayer.trigger({type:"adserror",data:{AdError:e,AdErrorEvent:t}})},c.prototype.onAdBreakStart=function(){this.vjsControls.hide()},c.prototype.onAdBreakEnd=function(){this.vjsControls.show()},c.prototype.reset=function(){this.vjsControls.show()};var y="TXXX",g=function(t){this.daiController=t,this.streamPlayer=null,this.vjsPlayer=null,this.streamManager=null,this.uiSettings=new google.ima.dai.api.UiSettings,this.isAdBreak=!1,this.isSnapback=!1,this.snapForwardTime=0,this.timedMetadata,this.metadataLoaded={},this.SOURCE_TYPES={hls:"application/x-mpegURL",dash:"application/dash+xml"}};g.prototype.initImaDai=function(){var t=this;this.streamPlayer=this.daiController.getStreamPlayer(),this.vjsPlayer=this.daiController.getVjsPlayer(),this.createAdUiDiv(),this.daiController.getSettings().locale&&this.uiSettings.setLocale(this.daiController.getSettings().locale),this.streamManager=new google.ima.dai.api.StreamManager(this.streamPlayer,this.adUiDiv,this.uiSettings),this.streamPlayer.addEventListener("pause",this.onStreamPause),this.streamPlayer.addEventListener("play",this.onStreamPlay),[google.ima.dai.api.StreamEvent.Type.LOADED,google.ima.dai.api.StreamEvent.Type.ERROR,google.ima.dai.api.StreamEvent.Type.AD_BREAK_STARTED,google.ima.dai.api.StreamEvent.Type.AD_BREAK_ENDED].forEach(function(e){t.streamManager.addEventListener(e,t.onStreamEvent.bind(t))}),this.vjsPlayer.textTracks().onaddtrack=this.onAddTrack.bind(this),this.vjsPlayer.trigger({type:"stream-manager",StreamManager:this.streamManager}),this.requestStream()},g.prototype.onAddTrack=function(t){var e=this,i=t.track;"metadata"===i.kind&&(i.mode="hidden",i.addEventListener("cuechange",function(t){var n=i.activeCues_||i.activeCues;if(n){var s,a=o(n);try{for(a.s();!(s=a.n()).done;){var d=s.value;d.value&&d.value.key===y&&e.streamManager.onTimedMetadata(r({},y,d.value.data))}}catch(t){a.e(t)}finally{a.f()}}}))},g.prototype.createAdUiDiv=function(){var t=document.createElement("div");t.id="ad-ui",t.style.height="calc(100% - 3em)",this.streamPlayer.parentNode.appendChild(t),this.adUiDiv=t},g.prototype.onStreamPause=function(){this.isAdBreak&&(this.adUiDiv.style.display="none")},g.prototype.onStreamPlay=function(){this.isAdBreak&&(this.adUiDiv.style.display="block")},g.prototype.onSeekEnd=function(t){if("live"!==this.daiController.getSettings().streamType)if(this.isSnapback)this.isSnapback=!1;else{var e=this.streamManager.previousCuePointForStreamTime(t);e&&!e.played&&(this.isSnapback=!0,this.snapForwardTime=t,this.vjsPlayer.currentTime(e.start))}},g.prototype.onStreamEvent=function(t){switch(t.type){case google.ima.dai.api.StreamEvent.Type.LOADED:this.loadUrl(t.getStreamData().url);break;case google.ima.dai.api.StreamEvent.Type.ERROR:window.console.warn("Error loading stream, attempting to play backup stream. "+t.getStreamData().errorMessage),this.daiController.onErrorLoadingAds(t),this.daiController.getSettings().fallbackStreamUrl&&this.loadUrl(this.daiController.getSettings().fallbackStreamUrl);break;case google.ima.dai.api.StreamEvent.Type.AD_BREAK_STARTED:this.isAdBreak=!0,this.adUiDiv.style.display="block",this.daiController.onAdBreakStart();break;case google.ima.dai.api.StreamEvent.Type.AD_BREAK_ENDED:this.isAdBreak=!1,this.adUiDiv.style.display="none",this.daiController.onAdBreakEnd(),this.snapForwardTime&&this.snapForwardTime>this.vjsPlayer.currentTime()&&(this.vjsPlayer.currentTime(this.snapForwardTime),this.snapForwardTime=0)}},g.prototype.loadUrl=function(t){this.vjsPlayer.ready(function(){var e=this.daiController.getSettings().streamFormat;this.vjsPlayer.src({src:t,type:this.SOURCE_TYPES[e]});var i=this.daiController.getSettings().bookmarkTime;if(i){var n=this.streamManager.streamTimeForContentTime(i);this.isSnapback=!0,this.vjsPlayer.currentTime(n)}}.bind(this))},g.prototype.requestStream=function(){var t,e=this.daiController.getSettings().streamType;if("vod"===e?((t=new google.ima.dai.api.VODStreamRequest).contentSourceId=this.daiController.getSettings().cmsId,t.videoId=this.daiController.getSettings().videoId):"live"===e?(t=new google.ima.dai.api.LiveStreamRequest).assetKey=this.daiController.getSettings().assetKey:window.console.warn("No valid stream type selected"),t.format=this.daiController.getSettings().streamFormat,this.daiController.getSettings().apiKey&&(t.apiKey=this.daiController.getSettings().apiKey),this.daiController.getSettings().authToken&&(t.authToken=this.daiController.getSettings().authToken),this.daiController.getSettings().adTagParameters&&(t.adTagParameters=this.daiController.getSettings().adTagParameters),this.daiController.getSettings().streamActivityMonitorId&&(t.streamActivityMonitorId=this.daiController.getSettings().streamActivityMonitorId),this.daiController.getSettings().omidMode){t.omidAccessModeRules={};var i=this.daiController.getSettings().omidMode;i.FULL&&(t.omidAccessModeRules[google.ima.OmidAccessMode.FULL]=i.FULL),i.DOMAIN&&(t.omidAccessModeRules[google.ima.OmidAccessMode.DOMAIN]=i.DOMAIN),i.LIMITED&&(t.omidAccessModeRules[google.ima.OmidAccessMode.LIMITED]=i.LIMITED)}this.streamManager.requestStream(t),this.vjsPlayer.trigger({type:"stream-request",StreamRequest:t})},g.prototype.onPlayerReady=function(){this.initImaDai()},g.prototype.onPlayerDisposed=function(){this.streamManager&&this.streamManager.reset()},g.prototype.addEventListener=function(t,e){this.streamManager&&this.streamManager.addEventListener(t,e)},g.prototype.getStreamManager=function(){return this.streamManager},g.prototype.reset=function(){this.streamManager&&this.streamManager.reset()};var m=function(t,e){this.inAdBreak=!1,this.settings={},this.isMobile=navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPad/i)||navigator.userAgent.match(/Android/i),this.isIos=navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPad/i),this.initWithSettings(e);var i={debug:this.settings.debug,timeout:this.settings.timeout,prerollTimeout:this.settings.prerollTimeout},n=Object.assign({},i,e.contribAdsSettings||{});this.playerWrapper=new c(t,n,this),this.sdkImpl=new g(this)};m.IMA_DEFAULTS={adLabel:"Advertisement",adLabelNofN:"of",debug:!1,disableAdControls:!1,showControlsForJSAds:!0},m.prototype.initWithSettings=function(t){this.settings=Object.assign({},m.IMA_DEFAULTS,t||{}),this.warnAboutDeprecatedSettings(),this.showCountdown=!0,!1===this.settings.showCountdown&&(this.showCountdown=!1)},m.prototype.warnAboutDeprecatedSettings=function(){var t=this;[].forEach(function(e){void 0!==t.settings[e]&&console.warn("WARNING: videojs.imaDai setting "+e+" is deprecated")})},m.prototype.getSettings=function(){return this.settings},m.prototype.getIsMobile=function(){return this.isMobile},m.prototype.getIsIos=function(){return this.isIos},m.prototype.getStreamPlayer=function(){return this.playerWrapper.getStreamPlayer()},m.prototype.getVjsPlayer=function(){return this.playerWrapper.getVjsPlayer()},m.prototype.requestStream=function(){this.sdkImpl.requestStream()},m.prototype.setSetting=function(t,e){this.settings[t]=e},m.prototype.onErrorLoadingAds=function(t){this.playerWrapper.onAdError(t)},m.prototype.onAdError=function(t){this.playerWrapper.onAdError(t)},m.prototype.onAdBreakStart=function(){this.inAdBreak=!0,this.playerWrapper.onAdBreakStart()},m.prototype.onAdBreakEnd=function(){this.inAdBreak=!1,this.playerWrapper.onAdBreakEnd()},m.prototype.onPlayerDisposed=function(){this.contentAndAdsEndedListeners=[],this.sdkImpl.onPlayerDisposed()},m.prototype.isInAdBreak=function(){return this.inAdBreak},m.prototype.onSeekEnd=function(t){this.sdkImpl.onSeekEnd(t)},m.prototype.onPlayerReady=function(){this.sdkImpl.onPlayerReady()},m.prototype.reset=function(){this.sdkImpl.reset(),this.playerWrapper.reset()},m.prototype.addEventListener=function(t,e){this.sdkImpl.addEventListener(t,e)},m.prototype.getStreamManager=function(){return this.sdkImpl.getStreamManager()},m.prototype.getPlayerId=function(){return this.playerWrapper.getPlayerId()},m.prototype.streamWillAutoplay=function(){return void 0!==this.settings.streamWillAutoplay?this.settings.streamWillAutoplay:!!this.playerWrapper.getPlayerOptions().autoplay},m.prototype.triggerPlayerEvent=function(t,e){this.playerWrapper.triggerPlayerEvent(t,e)};var v=function(t,e){this.controller=new u(t,e),this.addContentAndAdsEndedListener=function(t){this.controller.addContentAndAdsEndedListener(t)}.bind(this),this.addContentEndedListener=function(t){this.controller.addContentEndedListener(t)}.bind(this),this.addEventListener=function(t,e){this.controller.addEventListener(t,e)}.bind(this),this.changeAdTag=function(t){this.controller.changeAdTag(t)}.bind(this),this.getAdsManager=function(){return this.controller.getAdsManager()}.bind(this),this.initializeAdDisplayContainer=function(){this.controller.initializeAdDisplayContainer()}.bind(this),this.pauseAd=function(){this.controller.pauseAd()}.bind(this),this.playAdBreak=function(){this.controller.playAdBreak()}.bind(this),this.requestAds=function(){this.controller.requestAds()}.bind(this),this.resumeAd=function(){this.controller.resumeAd()}.bind(this),this.setAdBreakReadyListener=function(t){this.controller.setAdBreakReadyListener(t)}.bind(this),this.setContentWithAdTag=function(t,e){this.controller.setContentWithAdTag(t,e)}.bind(this),this.setContentWithAdsResponse=function(t,e){this.controller.setContentWithAdsResponse(t,e)}.bind(this),this.setContentWithAdsRequest=function(t,e){this.controller.setContentWithAdsRequest(t,e)}.bind(this),this.setShowCountdown=function(t){this.controller.setShowCountdown(t)}.bind(this)},A=function(t,e){this.controller=new m(t,e),this.streamEndedListener=function(t){this.controller.addStreamEndedListener(t)}.bind(this),this.addEventListener=function(t,e){this.controller.addEventListener(t,e)}.bind(this),this.getStreamManager=function(){return this.controller.getStreamManager()}.bind(this)},f=s(function t(e,i){n(this,t),"hls"===(e=e.toLowerCase())||"dash"===e?"dash"!==e?"string"==typeof i?(this.streamFormat=e,this.assetKey=i):window.console.error("assetKey error: value must be string."):window.console.error("streamFormat error: DASH streams are notcurrently supported by this plugin."):window.console.error("VodStream error: incorrect streamFormat.")}),P=s(function t(e,i,s){n(this,t),"hls"===(e=e.toLowerCase())||"dash"===e?"dash"!==e?"string"==typeof i?"string"==typeof s?(this.streamFormat=e,this.cmsId=i,this.videoId=s):window.console.error("videoId error: value must be string."):window.console.error("cmsId error: value must be string."):window.console.error("streamFormat error: DASH streams are notcurrently supported by this plugin."):window.console.error("VodStream error: incorrect streamFormat.")}),C=e.registerPlugin||e.plugin;C("ima",function(t){this.ima=new v(this,t)}),C("imaDai",function(t,e){if(t instanceof f)e.streamType="live",e.assetKey=t.assetKey;else{if(!(t instanceof P))return void window.console.error("initDai() first parameter must be an instance of LiveStream or VodStream.");e.streamType="vod",e.cmsId=t.cmsId,e.videoId=t.videoId}e.streamFormat=t.streamFormat,this.imaDai=new A(this,e)}),t.LiveStream=f,t.VodStream=P,t.default=v,Object.defineProperty(t,"__esModule",{value:!0})});
