"use strict";function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}window.HELP_IMPROVE_VIDEOJS=!1,window.PUBSTACK_VIDEO_APIS={valid:!1,players:[],youtube:{status:{sources:!1,api:!1}},videojs:{adblocker:!1,status:{main:{sources:!1,api:!1},ad:{sources:!1,api:!1},sources:!1,api:!1}},comscore:{publisher_id:"6683813",status:{sources:!1,api:!1}},debug:"1"===localStorage.getItem("NW18_PUBSTACK_PLAYER_DEBUG")},window.onYouTubeIframeAPIReady=function(){window.PUBSTACK_VIDEO_APIS.youtube.status.api=!0},window.pubstackPlayerLog=function(t){window.PUBSTACK_VIDEO_APIS.debug&&console.log(t)},window.generatePubstackPlayerID=function(t){for(var e="",a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",i=a.length,o=0;o<32;o++)e+=a.charAt(Math.floor(Math.random()*i));return"".concat(t,"-").concat(e)},window.getPubstackPlayerGATracker=function(){if(!Object.prototype.hasOwnProperty.apply(window,["ga"]))return null;if(!ga.getAll||"function"!=typeof ga.getAll)return null;var t=ga.getAll();if(!t||0===t.length)return null;var e=t[0];return t.forEach(function(t){"UA-156703-1"===t.get("trackingId")&&(e=t)}),e},window.PubstackYTPlayer=function(){var s={videoPlay:function(){return{category:"VOD",action:"Play",label:"".concat(this.video.title," | ").concat(this.video.category," | ").concat(window.location.href),log:"GOOGLE ANALYTICS EVENT: Video Play! Player ID: ".concat(this.playerID," Video ID: ").concat(this.player.getVideoData().video_id)}},videoPause:function(){return{category:"VOD",action:"Pause",label:"".concat(this.video.title," | ").concat(this.video.category," | ").concat(window.location.href),log:"GOOGLE ANALYTICS EVENT: Video Pause! Player ID: ".concat(this.playerID," Video ID: ").concat(this.player.getVideoData().video_id)}},videoResume:function(){return{category:"VOD",action:"Resume",label:"".concat(this.video.title," | ").concat(this.video.category," | ").concat(window.location.href),log:"GOOGLE ANALYTICS EVENT: Video Resume! Player ID: ".concat(this.playerID," Video ID: ").concat(this.player.getVideoData().video_id)}},videoEnd:function(){return{category:"VOD",action:"Complete",label:"".concat(this.video.title," | ").concat(this.video.category," | ").concat(window.location.href),log:"GOOGLE ANALYTICS EVENT: Video End! Player ID: ".concat(this.playerID," Video ID: ").concat(this.player.getVideoData().video_id)}},videoProgress:function(){var t=Math.round(this.player.getCurrentTime());return{category:"VOD",action:"Played Time - ".concat(t," sec"),label:"".concat(this.video.title," | ").concat(this.video.category," | ").concat(window.location.href),log:"GOOGLE ANALYTICS ! Player ID: ".concat(this.playerID," Video ID: ").concat(this.player.getVideoData().video_id," Duration: ").concat(t)}}},t={on_ready:function(){var t,e;this.player.setPlaybackQuality(n.get_mapped_quality(this.config.quality)),a.load_video.call(this),a.update_internal_state.apply(this,[this.READY_STATE]),a.start_progress_observer.call(this),this.target.firstElementChild&&"IFRAME"===this.target.firstElementChild.nodeName&&(t="".concat(parseInt(getComputedStyle(this.target).width),"px"),e="".concat(parseInt(getComputedStyle(this.target).width)/this.config.aspect_ratio,"px"),this.target.firstElementChild.width=t,this.target.firstElementChild.height=e,this.target.firstElementChild.style.minWidth=t,this.target.firstElementChild.style.minHeight=e)},on_state_change:function(t){switch(t.data){case window.YT.PlayerState.ENDED:this.previousProgressTime=0,a.update_internal_state.apply(this,[this.END_STATE]);break;case window.YT.PlayerState.PLAYING:this.player.setPlaybackQuality(n.get_mapped_quality(this.config.quality)),a.update_internal_state.apply(this,[this.PLAY_STATE]);break;case window.YT.PlayerState.PAUSED:this.isPaused=!0,a.update_internal_state.apply(this,[this.PAUSE_STATE]);break;case window.YT.PlayerState.BUFFERING:a.update_internal_state.apply(this,[this.BUFFERING_STATE]);break;case window.YT.PlayerState.CUED:a.update_internal_state.apply(this,[this.CUE_STATE]),this.config.autoplay&&this.player.playVideo()}},on_quality_change:function(t){var e=n.get_unmapped_quality(t.data);n.log.apply(this,["EVENT: Video quality changed - ".concat(e)]),this.config.events.onQualityChange.apply(null,[{target:this},e])},on_rate_change:function(){n.log.apply(this,["EVENT: Video playback rate changed - ".concat(event.data)]),this.config.events.onRateChange.apply(null,[{target:this},event.data])},on_error:function(t){n.log.apply(this,[t]),this.config.events.onError.apply(null,[{target:this}])},on_api_change:function(){}},n={get_default_config:function(){return{origin:n.get_origin(),referrer:n.get_origin(),controls:{onScreen:!0,keyboard:!0},autoplay:!1,loop:!1,disable_cc:!0,disable_annotions:!0,disable_fullscreen:!1,hide_logo:!0,start:0,end:0,lang:{cc:"en",interface:"en"},quality:"auto",color:"red",aspect_ratio:1.77778,events:{onReady:function(){},onVideoReady:function(){},onPlay:function(){},onPause:function(){},onStop:function(){},onEnd:function(){},onProgress:function(){},onBuffering:function(){},onCued:function(){},onError:function(){},onQualityChange:function(){},onRateChange:function(){},onStateChange:function(){},onDestroy:function(){}}}},log:function(t){window.pubstackPlayerLog(t)},get_origin:function(){return window.location.protocol+"//"+window.location.hostname+(window.location.port?":"+window.location.port:"")},get_mapped_quality:function(t){switch(t){case"highres":return"highres";case"1080p":return"hd1080";case"720p":return"hd720";case"480p":return"large";case"360p":return"medium";case"240p":return"small";case"144p":return"tiny";default:return"default"}},get_unmapped_quality:function(t){switch(t){case"highres":return"highres";case"hd1080":return"1080p";case"hd720":return"720p";case"large":return"480p";case"medium":return"360p";case"small":return"240p";case"tiny":return"144p";default:return"auto"}},send_event:function(t){if(this.tracker&&-1!==Object.keys(s).indexOf(t))if("videoProgress"===t){var e,a,i=Math.round(this.player.getCurrentTime());if(this.previousProgressTime===i)return;this.previousProgressTime=i,-1!==[5,10,15,30,50,60].indexOf(i)?(e=s[t].call(this),this.tracker.send("event",e.category,e.action,e.label),n.log.apply(this,[e.log])):i%30==0&&(a=s[t].call(this),this.tracker.send("event",a.category,a.action,a.label),n.log.apply(this,[a.log]))}else{var o=s[t].call(this);this.tracker.send("event",o.category,o.action,o.label),n.log.apply(this,[o.log])}}},a={validate_target:function(){if(!(this.target&&this.target instanceof HTMLDivElement))return{status:!1,message:"Target is null or target is not a valid Div element."};var t=null!==this.target.getAttribute("data-pubstack-player")&&"true"===this.target.getAttribute("data-pubstack-player"),e=null!==this.target.getAttribute("data-youtube")&&"true"===this.target.getAttribute("data-youtube");return t||e?{status:!0,message:null}:{status:!1,message:"Target is not supported by library. Please verify data attributes are correct."}},update_player_target:function(){this.target.innerHTML="",this.target.style.height="fit-content",this.innerTarget=document.createElement("div"),this.innerTarget.id=this.playerID,this.target.appendChild(this.innerTarget)},update_player_config:function(){this.playerConfig={playerVars:{enablejsapi:1,autoplay:0,loop:0,rel:0,showinfo:0},events:{onReady:t.on_ready.bind(this),onStateChange:t.on_state_change.bind(this),onPlaybackQualityChange:t.on_quality_change.bind(this),onPlaybackRateChange:t.on_rate_change.bind(this),onError:t.on_error.bind(this),onApiChange:t.on_api_change.bind(this)}};Object.keys(this.config).forEach(function(t){if(-1===["enablejsapi","loop","rel","showinfo","quality","send_usage","events","google_analytics"].indexOf(t))if("autoplay"!==t)if("referrer"!==t)if("disable_cc"!==t)if("disable_annotions"!==t)if("disable_fullscreen"!==t){if("hide_logo"!==t)return"lang"===t?(this.playerConfig.playerVars.cc_lang_pref=this.config.lang.cc,void(this.playerConfig.playerVars.hl=this.config.lang.interface)):"controls"===t?(this.playerConfig.playerVars.disablekb=this.config.controls.keyboard?0:1,void(this.playerConfig.playerVars.controls=this.config.controls.onScreen?1:0)):void("color"!==t?"start"!==t?"end"!==t?"width"!==t?"height"!==t||(this.playerConfig.height=this.config.height):this.playerConfig.width=this.config.width:this.playerConfig.playerVars.end=Math.round(this.config.end):this.playerConfig.playerVars.start=Math.round(this.config.start):this.playerConfig.playerVars.color=this.config.color);this.playerConfig.playerVars.modestbranding=this.config.hide_logo?1:0}else this.playerConfig.playerVars.fs=this.config.disable_fullscreen?0:1;else this.playerConfig.playerVars.iv_load_policy=this.config.disable_annotions?3:1;else this.playerConfig.playerVars.cc_load_policy=this.config.disable_cc?0:1;else this.playerConfig.widget_referrer=this.config.referrer;else this.playerConfig.playerVars.mute=this.config.autoplay?1:0}.bind(this))},update_player:function(){this.player=new window.YT.Player(this.innerTarget,this.playerConfig)},load_video:function(){this.player.cueVideoById({videoId:this.video.youtube.id,startSeconds:this.config.start,endSeconds:this.config.end,suggestedQuality:n.get_mapped_quality(this.config.quality)})},update_internal_state:function(t){switch(this.state=t,this.config.events.onStateChange.apply(null,[{target:this},this.state]),t){case this.READY_STATE:n.log.apply(this,["EVENT: Player is ready to play video!"]),this.config.events.onReady.apply(null,[{target:this}]);break;case this.VIDEO_READY_STATE:n.log.apply(this,["EVENT: Video Ready!"]),this.config.events.onVideoReady.apply(null,[{target:this}]);break;case this.END_STATE:n.send_event.apply(this,["videoEnd"]),n.log.apply(this,["EVENT: Video playback has ended!"]),this.config.events.onEnd.apply(null,[{target:this}]);break;case this.PLAY_STATE:this.isPaused?n.send_event.apply(this,["videoResume"]):n.send_event.apply(this,["videoPlay"]),this.isPaused=!1,n.log.apply(this,["EVENT: Video playback is resumed!"]),this.config.events.onPlay.apply(null,[{target:this}]);break;case this.PAUSE_STATE:n.send_event.apply(this,["videoPause"]),n.log.apply(this,["EVENT: Video playback is paused!"]),this.config.events.onPause.apply(null,[{target:this}]);break;case this.BUFFERING_STATE:n.log.apply(this,["EVENT: Video Buffering!"]),this.config.events.onBuffering.apply(null,[{target:this}]);break;case this.CUE_STATE:n.log.apply(this,["EVENT: Video Cued!"]),this.config.events.onCued.apply(null,[{target:this}])}},start_progress_observer:function(){var i=this,o=this,s=0;this.progressInterval=setInterval(function(){var t,e,a;o.player.getPlayerState()===window.YT.PlayerState.PLAYING&&(t=o.player.getCurrentTime(),s!==t&&(e=Math.round(100*t)/100,a=t/o.player.getDuration()*100,a=Math.round(100*a)/100,n.send_event.apply(i,["videoProgress"]),n.log.apply(o,["EVENT: Video progress - ".concat(e,"s ").concat(a,"%")]),o.config.events.onProgress.apply(null,[{target:o},t,a]),s=t))},100)},init:function(){var t=a.validate_target.call(this);if(!t.status)throw new Error("InvalidTarget: ".concat(t.message));a.update_player_target.call(this),a.update_player_config.call(this),a.update_player.call(this)}};return function t(e){_classCallCheck(this,t),this.video=e,this.target=this.video.target,this.innerTarget=null,this.config=n.get_default_config(),this.playerID=window.generatePubstackPlayerID("YOUTUBE"),this.tracker=window.getPubstackPlayerGATracker(),this.playerConfig={},this.INITIALIZE_STATE=-1,this.READY_STATE=0,this.VIDEO_READY_STATE=1,this.PLAY_STATE=2,this.PAUSE_STATE=3,this.BUFFERING_STATE=4,this.CUE_STATE=5,this.END_STATE=6,this.state=this.INITIALIZE_STATE,this.isPaused=!1,this.previousProgressTime=0,a.init.call(this)}}(),window.PubstackVideoJSPlayer=function(){var s={videoPlay:function(){return{category:"VOD",action:"Play",label:"".concat(this.video.title," | ").concat(this.video.category," | ").concat(window.location.href),log:"GOOGLE ANALYTICS EVENT: Video Play! Player ID: ".concat(this.playerID," Video ID: ").concat(this.config.id)}},videoPause:function(){return{category:"VOD",action:"Pause",label:"".concat(this.video.title," | ").concat(this.video.category," | ").concat(window.location.href),log:"GOOGLE ANALYTICS EVENT: Video Pause! Player ID: ".concat(this.playerID," Video ID: ").concat(this.config.id)}},videoResume:function(){return{category:"VOD",action:"Resume",label:"".concat(this.video.title," | ").concat(this.video.category," | ").concat(window.location.href),log:"GOOGLE ANALYTICS EVENT: Video Resume! Player ID: ".concat(this.playerID," Video ID: ").concat(this.config.id)}},videoEnd:function(){return{category:"VOD",action:"Complete",label:"".concat(this.video.title," | ").concat(this.video.category," | ").concat(window.location.href),log:"GOOGLE ANALYTICS EVENT: Video End! Player ID: ".concat(this.playerID," Video ID: ").concat(this.config.id)}},videoProgress:function(){var t=Math.round(this.player.currentTime());return{category:"VOD",action:"Played Time - ".concat(t," sec"),label:"".concat(this.video.title," | ").concat(this.video.category," | ").concat(window.location.href),log:"GOOGLE ANALYTICS ! Player ID: ".concat(this.playerID," Video ID: ").concat(this.config.id," Duration: ").concat(t)}}},i={on_ready:function(){o.start_progress_observer.call(this),o.update_internal_state.apply(this,[this.READY_STATE]),o.update_player_events.call(this)},on_play:function(){o.update_internal_state.apply(this,[this.PLAY_STATE])},on_pause:function(){o.update_internal_state.apply(this,[this.PAUSE_STATE])},on_ended:function(){o.update_internal_state.apply(this,[this.END_STATE])},on_error:function(){n.log.apply(this,["VIDEOJS ERROR"]),this.config.events.onError.apply(null,[{target:this}])},on_ad_play:function(){n.log.apply(this,["[PUBSTACK-PLAYER][VIDEOJS][LOG] Video AD started playing!"]),this.adState=this.PLAY_STATE},on_ad_pause:function(){n.log.apply(this,["[PUBSTACK-PLAYER][VIDEOJS][LOG] Video AD paused!"]),this.adState=this.PAUSE_STATE},on_ad_resume:function(){n.log.apply(this,["[PUBSTACK-PLAYER][VIDEOJS][LOG] Video AD started playing!"]),this.adState=this.PLAY_STATE},on_ad_complete:function(){n.log.apply(this,["[PUBSTACK-PLAYER][VIDEOJS][LOG] Video AD completed!"]),this.adState=this.END_STATE},on_ad_skipped:function(){n.log.apply(this,["[PUBSTACK-PLAYER][VIDEOJS][LOG] Video AD skipped!"]),this.adState=this.END_STATE},on_page_scroll:function(){var t=this.videoTarget.getBoundingClientRect(),e=0<=t.top&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight);this.isAdSupported?e?this.adState===this.INITIALIZE_STATE?(o.load_video_ad.call(this),this.player.play()):this.adState===this.PAUSE_STATE?this.player.ima.resumeAd():this.adState===this.END_STATE&&this.player.play():this.adState===this.PLAY_STATE?this.player.ima.pauseAd():this.adState===this.END_STATE&&this.player.pause():e?this.player.play():this.player.pause()}},n={get_default_config:function(){return{autoplay:!1,controls:!0,loop:!1,muted:!0,poster:null,preload:"metadata",aspectRatio:"16:9",autoSetup:!1,fluid:!0,language:"en",nativeControlsForTouch:!0,fullscreen:{options:{navigationUI:"show"}},html5:{vhs:{overrideNative:!window.pubstackvideojs.browser.IS_SAFARI},nativeAudioTracks:!1,nativeVideoTracks:!1},playbackRates:[.5,1,1.5,2],responsive:!0,sources:[],suppressNotSupportedError:!0,analytics:!0,events:{onReady:function(){},onPlay:function(){},onPause:function(){},onEnd:function(){},onProgress:function(){},onError:function(){},onStateChange:function(){},onDestroy:function(){}}}},log:function(t){window.pubstackPlayerLog(t)},send_event:function(t){if(this.config.analytics&&this.tracker&&-1!==Object.keys(s).indexOf(t))if("videoProgress"===t){var e,a,i=Math.round(this.player.currentTime());if(this.previousProgressTime===i)return;this.previousProgressTime=i,-1!==[5,10,15,30,50,60].indexOf(i)?(e=s[t].call(this),this.tracker.send("event",e.category,e.action,e.label),n.log.apply(this,[e.log])):i%30==0&&(a=s[t].call(this),this.tracker.send("event",a.category,a.action,a.label),n.log.apply(this,[a.log]))}else{var o=s[t].call(this);this.tracker.send("event",o.category,o.action,o.label),n.log.apply(this,[o.log])}}},o={validate_target:function(){if(!(this.target&&this.target instanceof HTMLDivElement))return{status:!1,message:"Target is null or target is not a valid Div element."};var t=null!==this.target.getAttribute("data-pubstack-player")&&"true"===this.target.getAttribute("data-pubstack-player"),e=null!==this.target.getAttribute("data-youtube")&&"true"===this.target.getAttribute("data-youtube");return t||e?{status:!0,message:null}:{status:!1,message:"Target is not supported by library. Please verify data attributes are correct."}},update_player_target:function(){this.target.innerHTML="",this.videoTarget=document.createElement("video"),this.videoTarget.classList.add("pubstack-video-js"),this.videoTarget.classList.add("pubstack-video-theme"),this.videoTarget.playsInline=!0,this.videoTarget.controls=!0,this.videoTarget.id=this.playerID;var t=document.createElement("source");t.src=this.videoSource.src,t.type=this.videoSource.type,this.videoTarget.appendChild(t),this.target.appendChild(this.videoTarget)},update_player_config:function(){this.playerConfig={};Object.keys(this.config).forEach(function(t){-1!==["autoplay","controls","loop","muted","aspectRatio","autoSetup","fluid","language","fullscreen","playbackRates","responsive","suppressNotSupportedError","html5"].indexOf(t)&&(this.playerConfig[t]=this.config[t])}.bind(this))},load_video_ad:function(){this.player.ima.initializeAdDisplayContainer(),this.player.ima.setContentWithAdTag(null,this.adTag,!1),this.player.ima.requestAds(),this.adState=this.READY_STATE},update_player:function(){var t,e,a=this;this.player=window.pubstackvideojs(this.videoTarget,this.playerConfig,i.on_ready.bind(this)),this.isAdSupported&&(t={disableCustomPlaybackForIOS10Plus:!0,adWillPlayMuted:!0,adsManagerLoadedCallback:o.update_ad_events.bind(this)},(window.pubstackvideojs.browser.IS_ANDROID||window.pubstackvideojs.browser.IS_IOS)&&window.pubstackvideojs.browser.IS_CHROME&&(t.adsRenderingSettings={mimeTypes:["video/mp4"]}),this.player.ima(t),(e=document.querySelector("#".concat(this.playerID," .pubstack-vjs-big-play-button"))).addEventListener(this.startEvent,function t(){0<=a.adState||o.load_video_ad.call(a),e.removeEventListener(a.startEvent,t)}),this.videoTarget.addEventListener(this.startEvent,function t(){0<=a.adState||o.load_video_ad.call(a),a.videoTarget.removeEventListener(a.startEvent,t)}),(navigator.userAgent.match(/iPad/i)||navigator.userAgent.match(/Android/i))&&this.videoTarget.hasAttribute("controls")&&this.videoTarget.removeAttribute("controls"))},update_ad_events:function(){this.player.ima.addEventListener(window.google.ima.AdEvent.Type.STARTED,i.on_ad_play.bind(this)),this.player.ima.addEventListener(window.google.ima.AdEvent.Type.PAUSED,i.on_ad_pause.bind(this)),this.player.ima.addEventListener(window.google.ima.AdEvent.Type.RESUMED,i.on_ad_resume.bind(this)),this.player.ima.addEventListener(window.google.ima.AdEvent.Type.COMPLETE,i.on_ad_complete.bind(this)),this.player.ima.addEventListener(window.google.ima.AdEvent.Type.SKIPPED,i.on_ad_skipped.bind(this))},update_player_events:function(){this.player.on("play",i.on_play.bind(this)),this.player.on("pause",i.on_pause.bind(this)),this.player.on("ended",i.on_ended.bind(this)),this.player.on("error",i.on_error.bind(this)),window.addEventListener("scroll",i.on_page_scroll.bind(this))},load_video:function(){this.player.load()},update_internal_state:function(t){switch(this.state=t,this.config.events.onStateChange.apply(null,[{target:this},this.state]),t){case this.READY_STATE:n.log.apply(this,["EVENT: Player is ready to play video!"]),this.config.events.onReady.apply(null,[{target:this}]);break;case this.END_STATE:n.send_event.apply(this,["videoEnd"]),n.log.apply(this,["EVENT: Video playback has ended!"]),this.config.events.onEnd.apply(null,[{target:this}]);break;case this.PLAY_STATE:this.isPaused?(n.send_event.apply(this,["videoResume"]),n.log.apply(this,["EVENT: Video playback is resumed!"])):(n.send_event.apply(this,["videoPlay"]),n.log.apply(this,["EVENT: Video playback is started!"])),this.isPaused=!1,this.config.events.onPlay.apply(null,[{target:this}]);break;case this.PAUSE_STATE:this.isPaused=!0,n.send_event.apply(this,["videoPause"]),n.log.apply(this,["EVENT: Video playback is paused!"]),this.config.events.onPause.apply(null,[{target:this}])}},start_progress_observer:function(){var i=this,o=this,s=0;this.progressInterval=setInterval(function(){var t,e,a;o.player.paused()||(t=o.player.currentTime(),s!==t&&(e=Math.round(100*t)/100,a=t/o.player.duration()*100,a=Math.round(100*a)/100,n.send_event.apply(i,["videoProgress"]),n.log.apply(o,["EVENT: Video progress - ".concat(e,"s ").concat(a,"%")]),o.config.events.onProgress.apply(null,[{target:o},t,a]),s=t))},100)},init:function(){var t=o.validate_target.call(this);if(!t.status)throw new Error("InvalidTarget: ".concat(t.message));o.update_player_target.call(this),o.update_player_config.call(this),o.update_player.call(this)}};return function t(e){var a=1