!function(){var e="googima",t="TYPE_API",i="TYPE_SCHEDULE",n="-1",r="jwp",o="jw-flag-ads-googleima",a="jw-flag-ads-vpaid",s="jw-flag-ads-vpaid-controls",d="paused",l="playing",u="adBidRequest",p="adBidResponse",h="adBreakStart",c="adBreakEnd",g="adCompanions",f="adError",m="adStarted",y="adPlay",v=2e3;function b(e,t,i){if(!e)return e;for(var n,r,o,a,s=t.getPlaylistItem(),d=t.getConfig(),l=e.replace("__random-number__",Math.random()*Math.pow(10,18)).replace("__timestamp__",(new Date).getTime()).replace("__page-url__",encodeURIComponent(window.location.href)).replace("__referrer__",encodeURIComponent(document.referrer)).replace("__player-height__",t.getHeight()||d.height).replace("__player-width__",t.getWidth()||d.width).replace("__item-duration__",(r=t.getDuration(),o=3,a=Math.pow(10,o),Math.round(r*a)/a)).replace("__domain__",encodeURIComponent((n=window.location.href.match(new RegExp(/^[^/]*:\/\/\/?([^/]*)/)))&&n.length>1?n[1]:"")),u=(l=i.companiondiv&&i.companiondiv.id?l.replace("__companion-div__",i.companiondiv.id):l.replace("__companion-div__","")).match(new RegExp(/__item-[a-z 0-9 A-Z]*__/g)),p=0;u&&p1e3&&(g=g.substring(0,1e3)),l=l.replace(h,encodeURIComponent(g))}else l=l.replace(h,"")}if(s.title&&-1===l.indexOf("vid_t=")){var f=s.title.substring(0,100).replace(/[^\x00-\x7F]/g,"");l+=(-1!==l.indexOf("?")?"&":"?")+"vid_t="+encodeURIComponent(f)}return l}var w=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")};function A(e,t,i){if("start"===e||"0%"===e)return"pre";if("end"===e||"100%"===e)return"post";if("pre"===e||"post"===e||i.indexOf(e,"%")>-1)return e;var n=t.seconds(e);return!!i.isNumber(n)&&n}function P(e,t,i){var n,r,o,a,s,d=A(e,t,i);return d||(d="pre"),i.isNumber(d)&&(n=parseInt(1e3*d,10),r=Math.floor(n)%1e3,o=Math.floor(n/1e3)%60,a=Math.floor(n/6e4)%60,d=(s=(s=Math.floor(n/36e5)%24)<10?"0"+s:s)+":"+(a=a<10?"0"+a:a)+":"+(o=o<10?"0"+o:o)+"."+(r=("000"+r).slice(-3))),d}function E(e,t,i){if(!i)return e;var n=e.indexOf("?")>=0?"&":"?",r="cust_params=",o=e.indexOf(r),a=r.length,s="",d="";if(t.foreach(i,function(e,t){s=""+s+d+e+"="+t,d="&"}),s=encodeURIComponent(s),o>=0){var l=e.substr(0,o+a),u=e.substr(o+a);return""+l+s+"%26"+u}return""+e+n+"cust_params="+s}function C(e,t,i){var n={};return t.foreach(e,function(e,r){var o={},a=r.ad||r;o.offset=P(a.offset||a.position||r.offset||"",t,i),o.tag=E(a.tag,t,a.custParams),o.type=a.type||r.type||"linear,nonlinear",n[e]=o}),n}var S=function(){function e(t,i){w(this,e),this.player=t,this.options=i}return e.prototype.getAdsResponse=function(e){var t=this,i=this.player,n=i.utils,r='',o=[],a=[],s=[];return n.foreach(C(e,n,i._),function(e,n){var d=n.offset.replace("pre","start").replace("post","end"),l=r.replace(/_type_/g,n.type).replace(/_adbreakname_/g,e).replace(/_offset_/g,d).replace(/_url_/g,b(n.tag,i,t.options,n.custParams));"start"===d?o.push(l):"end"===d?s.push(l):a.push(l)}),''+o.join("")+a.join("")+s.join("")+""},e.prototype.getTagMap=function(e){var t=this,i=this.player,n=i.utils,r={};return n.foreach(C(e,n,i._),function(e,o){var a=A(o.offset,n,i._);i._.isString(a)&&(a=parseFloat(a.replace("pre","0").replace("post","-1"))),i._.isNumber(a)&&(r[a]=b(o.tag,i,t.options))}),r},e.prototype.getTagList=function(e){var t=this,i=this.player,n=i.utils,r=[];return n.foreach(C(e,n,i._),function(e,o){var a=A(o.offset,n,i._);i._.isString(a)&&(a=parseFloat(a.replace("pre","0").replace("post","-1"))),r.push({offset:a,tag:b(o.tag,i,t.options)})}),r},e}(),M={adcountercountkey:"__AD_POD_CURRENT__",adcounterdynamic:"Ad __AD_POD_CURRENT__ of __AD_POD_LENGTH__. ",adcountertotalkey:"__AD_POD_LENGTH__",admessage:"This ad will end in xx",admessagedynamickey:"xx",admessagestatic:"This is an Advertisement",advideoheight:0,advideowidth:0,allowadskip:!1,allowadskippastseconds:0,allowplayercontrols:!1,allowvolumeslider:!1,autoplayadsmuted:!1,click_tracking:!0,companiondiv:null,companionResourceType:"",cuetext:"Advertisement",debug:!1,enablePreloading:!1,invertmutebutton:!1,loadVideoTimeout:15e3,locale:"",maxRedirects:-1,overlayslotheight:0,overlayslotwidth:0,premiumAds:!1,requestTimeout:1e4,scaled_ads:!0,usestaticmessage:!1,vpaidcontrols:!1,vpaidmode:"insecure"};function _(e){if("true"===e)return!0;if("false"===e)return!1;var t=parseFloat(e);return isNaN(t)?e:t}var L=function(){function e(t,i){for(var n in w(this,e),this.config=t,this.utils=i,this.bidsResponse={},M)if(M.hasOwnProperty(n)){var r=t[n],o=M[n],a=typeof o;if(void 0!==r){if("boolean"!==a&&"number"!==a||(r=_(r)),typeof r!==a)throw new Error("invalid parameter: "+n+" should be a "+a);this[n]=r}else this[n]=o}this.admessagedynamic=this.admessage}return e.prototype.getSingleTagPrerollBlock=function(){var e=this.getConfigSchedule(),t=this.singleTagBidsResponse;if("string"==typeof e){if(!t)return e;var i=t.custParams;return E(t.tag,this.utils,i)}return null},e.prototype.addBidsResponse=function(e,t){var i=void 0;i=e&&!e.error&&(e.bidWon||e.tag)?e:null,t?this.bidsResponse[t]=i:this.singleTagBidsResponse=i},e.prototype.getSchedule=function(){var e=this,t=this.getConfigSchedule();if(!t)return t;var i=this.utils.extend({},t),n=this.getSingleTagPrerollBlock();return n||(Object.keys(this.bidsResponse).forEach(function(t){var n=i[t],r=e.bidsResponse[t];n&&r&&(n.tag=r.tag,n.custParams=e.utils.extend({},n.custParams,r.custParams))}),i)},e.prototype.getConfigSchedule=function(){var e=this.config;return e.tag||this.adschedule||e.schedule||e.ad},e.prototype.getAdRules=function(){var e=this.config.rules||{};return{startOn:e.startOn||1,frequency:void 0!==e.frequency?e.frequency:1}},e}(),x=function(){function e(t,i,n){w(this,e);var r=document.createElement("div");this.visible=!1,this.style=n,this.div=t,this.adDiv=r,r.id=i+"_ad",n(t,{overflow:"hidden",width:"100%",height:"100%",display:"block",visibility:"hidden",pointerEvents:"none",opacity:0}),n(r,{position:"absolute",width:"100%",height:"100%"}),t.appendChild(r)}return e.prototype.resizeNonLinear=function(e,t){this.style(this.div,{height:t+"px",top:"auto",width:"100%"})},e.prototype.resizeLinear=function(){this.style(this.div,{top:"0px",left:"0px",width:"100%",height:"100%"})},e.prototype.getAdDiv=function(){return this.adDiv},e.prototype.adSetup=function(){this.visible=!0,this.style(this.div,{visibility:"visible",display:"block",pointerEvents:"all",opacity:1},!0);for(var e=this.adDiv.childNodes,t=0;th,y={id:u,name:"FAN",bidWon:f,priceCents:a,priceCurrency:l};return f?(y.tag=["https://an.facebook.com/v1/instream/vast.xml?placementid="+u,"&playerwidth="+c,"&playerheight="+g,"&sdk="+F,"&bidid="+s,"&pageurl="+Y].join(""),t(y)):t(y)}},d.open("GET",f),d.withCredentials=!0,d.send(null),{id:u,name:"FAN"})}var ee={},te=null;function ie(){if(te)return te;if(ee.apstag=ee.apstag||window.apstag,ee.apstag&&ee.apstag.init&&ee.apstag.fetchBids)return te=Promise.resolve();var e=["//",J];return"file:"===document.location.protocol&&e.unshift("https:"),te=U(e.join(""),W).then(function(){ee.apstag=window.apstag})}function ne(e,t){var i=e.bidders.APS;return i.id&&i.slotID?(ie().then(function(){return ee.apstag.init({id:i.pubId,adServer:i.adServer}),ee.apstag.fetchBids({slots:[{slotID:i.slotID}],timeout:e.settings.bidTimeout},function(n){return n&&n[0]&&n[0].slotID===i.slotID?t({id:i.id,name:"APS",tag:e.tag,custParams:{amznbid:n[0].amznbid,amzniid:n[0].amzniid}}):t({id:i.id,name:"APS",error:!0,message:"No bids for pubID and slotID"})})}).catch(function(){t({id:i.id,name:"APS",error:!0,message:"Amazon header bidding failed"})}),{id:i.id,name:"APS"}):t({id:i.id,name:"APS",error:!0,message:"invalid"})}var re=null;function oe(){if(re)return re;if(ee.SpotX=ee.SpotX||window.SpotX,ee.SpotX&&ee.SpotX.DirectAdOS)return re=Promise.resolve();var e,t,i=["//",H];return"file:"===document.location.protocol&&i.unshift("https:"),re="function"==typeof require?(e=i.join(""),t=W,new Promise(function(i,n){setTimeout(n,t),require([e],i)}).catch(function(){return Promise.reject("Error loading script")})).then(function(e){ee.SpotX=e}):U(i.join(""),W).then(function(){ee.SpotX=window.SpotX})}function ae(e,t){return{id:e,name:"SpotX",error:!0,message:t}}function se(e,t){var i=e.bidders.SpotX;if(!i||!i.id)return t(ae(i.id,"invalid"));var n=e.settings,r=N({channel_id:i.id,slot:n.playerContainer,content_width:n.playerWidth,content_height:n.playerHeight,player_vendor:"SpotXJW",player_vendor_id:n.playerId},i.optionalParams);return oe().then(function(){var t=new ee.SpotX.DirectAdOS(r);return"dfp"===n.mediationLayerAdServer?t.addSpotXParamsToMVT(e.tag):t.getAdServerKVPs()}).then(function(e){if("string"==typeof e)return t({id:i.id,name:"SpotX",tag:e});var r=100*parseFloat(e.spotx_bid),o=e.spotx_ad_key;if(!(r>n.floorPriceCents)){var a="Bid price of "+r+" from SpotX is not greater than floor price of "+n.floorPriceCents;return t(ae(i.id,a))}var s=["//",K,o];return"file:"===document.location.protocol&&s.unshift("https:"),t({id:i.id,name:"SpotX",tag:s.join(""),tagKey:o,priceCents:r})}).catch(function(e){return t(ae(i.id,"SpotX header bidding failed: "+e))}),{id:i.id,name:"SpotX"}}var de=null;function le(e){if(de)return de;if(ee.indexapi=ee.indexapi||window.indexapi,ee.indexapi)return de=Promise.resolve();var t=["//",e||X];return"file:"===document.location.protocol&&t.unshift("https:"),de=U(t.join(""),W).then(function(){ee.indexapi=window.indexapi})}function ue(e,t){return{id:e,name:"index",error:!0,message:t}}function pe(e,t){var i=e.bidders.index||{};if(!i.script&&!i.id&&!ee.indexapi)return t(ue(i.id,"invalid"));var n=N({videoCommonArgs:{protocols:[2,3,5,6],mimes:["video/mp4","video/webm","application/javascript"],apiList:[1,2]},siteID:i.id},i);return setTimeout(function(){t(ue(n.id,"Index Exchange header bidding request failed"))},e.settings.bidTimeout),le().then(function(){var i=function(i,r){if(void 0!==r)return t({id:n.id,name:"index",tag:e.tag,custParams:r});t(ue(n.id,"Index Exchange header bidding request failed"))};ee.indexapi=ee.indexapi||{},ee.indexapi.deferQueue=ee.indexapi.deferQueue||[],ee.indexapi.deferQueue.push(function(){ee.indexapi.solicitIndexVideoAds(e.tag,i,n)})}).catch(function(){t(ue(n.id,"Index Exchange header bidding failed"))}),{id:n.id,name:"index"}}var he=function(e){return!(e.error&&"invalid"===e.message)};function ce(e){var t={SpotX:{},FAN:{},APS:{}};return e.length?(Q.forEach(function(i){var n=function(e,t){if(!e||"function"!=typeof t)return null;for(var i=Object(e),n=i.length,r=0;r0&&void 0!==arguments[0]?arguments[0]:{settings:{},bidders:[]},i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,a=this,s=arguments[5],d=arguments[6];w(this,e);var l,u=t.bidders;"pre"!==n&&0!==parseInt(n)&&(u=u.filter(function(e){return"SpotX"===e.name})),this.tag=i,this.settings=(l=t.settings,N({bidTimeout:V,playerWidth:r,playerHeight:o,playerContainer:s,playerId:d},l)),this.bidders=ce(u),this.xhttpFAN=new XMLHttpRequest,this.request=new Promise(function(e){a.resolve=e}),this._bidRequests=[],this.bidders.APS&&this.bidders.APS.id&&this.bidders.APS.slotID&&ie(),this.bidders.index&&(this.bidders.index.script||this.bidders.index.id)&&le(this.bidders.index.script),this.bidders.SpotX&&this.bidders.SpotX.id&&oe(),this.currentTimeout=null}return e.prototype.start=function(){return this.start=function(){return this.request},this._bidRequests=function(e){var t=[];t="dfp"===e.settings.mediationLayerAdServer?[se,$,ne,pe]:[se,$];var i=[],n=t.map(function(t){var n=q();return new Promise(function(n){var r=t(e,n)||{};i.push(function(e){n(N(r,e))})}).then(function(e){return e.timeForBidResponse=q()-n|0,e})});return Promise.all(n).then(function(t){var i="dfp"===e.settings.mediationLayerAdServer,n={},r={},o=void 0,a=[],s={};return s.bidders=t.filter(he).map(function(e){var t=!e.error,d={id:e.id,name:e.name,result:t?"bid":"noBid",timeForBidResponse:e.timeForBidResponse};return"timeout"===e.message&&(d.result=e.message),t&&(a.push(e),e.priceCents&&(d.priceInCents=e.priceCents),e.tagKey&&(d.tagKey=e.tagKey),N(r,e.custParams),"SpotX"===e.name&&(o=e.tag),i||"priceInCents"in n&&!(n.priceInCents2&&void 0!==arguments[2]?arguments[2]:null;return{type:t,client:e,adposition:null!==n?n:function(e){if(e.isBeforePlay()||0===e.getPosition())return"pre";if(e.isBeforeComplete()||e.getPosition()===e.getDuration())return"post";return"mid"}(i),viewable:i.getViewable()}}function me(t,i){var n=i.offset,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];return{type:t,client:e,offset:n,mediationLayerAdServer:o.mediationLayerAdServer||r,floorPriceCents:o.floorPriceCents,floorPriceCurrency:o.floorPriceCurrency,bidTimeout:o.bidTimeout||V,bidders:a}}function ye(e,t){var i=t.bidders,n=t.options;return i?(n.config.bids&&n.config.bids.settings&&i.length&&(e.mediationLayerAdServer=n.config.bids.settings.mediationLayerAdServer||r,e.bidders="pre"===e.adposition?i:i.filter(function(e){return"SpotX"===e.name}),"dfp"===e.mediationLayerAdServer&&"SpotXJW"===e.adsystem&&e.bidders.map(function(e){"SpotX"===e.name&&(e.winner=!0)})),e):e}var ve=function(){function e(t,i,n,r,o,a,s){w(this,e),n.utils.extend(this,n.Events),this.item=t,this.options=i,this.player=n,this.env=n.getEnvironment(),this.utils=n.utils,this.instreamProvider=r,this.view=o,this.initAdsManagerPromise=null,this.bidsPromise=null,this.blockingInstreamPlayer=null,this.currentAd=null,this.bidders=[],this.bids=null,this.timeoutAdStart=-1,this.progressIntervalId=-1,this.fullscreenIcon=n.getContainer().querySelector(".jw-icon-fullscreen"),this.adsLoaderManager=a,this.playbackProxy={currentTime:0,duration:0},this.video=s,this.isItemSchedule=!0,this.paused=!1,this.pausedByViewable=!1,this._qoe=new n.utils.Timer,this.debugConsoleLog=n.utils.noop,i.debug&&(this.debugConsoleLog=function(){var e;(e=console).log.apply(e,arguments)})}return e.prototype.startBid=function(e,t,i){var n=this,r=this.utils.extend({},e.config.bids),o=new ge(r,t.tag,t.offset,this.player.getWidth(),this.player.getHeight(),this.player.getContainer(),this.player.id);return o.start(),this.trigger(u,me(u,t,r.settings,r.bidders)),o.then(function(o){if(n.trigger(p,me(p,t,r.settings,o.bidders)),n.bidders&&"pre"!==t.offset&&0!==parseInt(t.offset)||(n.bidders=o.bidders),n.destroyed())return null;e.addBidsResponse(o.result,i)})},e.prototype.init=function(e,t){var i=this;if(t.config.bids){var n=t.config.schedule||t.config.tag,r=[];"string"==typeof n?r.push(this.startBid(t,{tag:n,offset:"pre"})):Object.keys(n).forEach(function(e){r.push(i.startBid(t,n[e],e))}),this.bidsPromise=Promise.all(r)}else this.bidsPromise=Promise.resolve();this.initAdsManagerPromise=this.bidsPromise.then(j).then(function(){return i.destroyed()?null:(i.debugConsoleLog("[JW DEBUG] Open adsLoaderManager"),i.adsLoaderManager.open(e,t,i.player,i.options,i.video))}).then(function(e){if(i.destroyed())return null;var t=i.playbackProxy,n=i.adsLoaderManager,r=n.getAdsManager(e,t,i.options);i.instreamProvider.setProxy(r),i.muteInstreamProvider();var o=i.player.getSafeRegion(!1);if(i.debugConsoleLog("[JW DEBUG] adsManager init with",o.width,o.height,i.getViewMode()),r.init(o.width,o.height,i.getViewMode()),n.initializeDisplay(),n.bindEvents({LOADED:i.adLoaded.bind(i),AD_ERROR:i.adError.bind(i),CONTENT_PAUSE_REQUESTED:i.pauseRequested.bind(i),CONTENT_RESUME_REQUESTED:i.resumeRequested.bind(i),LOG:i.adLog.bind(i),STARTED:i.adStarted.bind(i),IMPRESSION:i.adImpression.bind(i),LINEAR_CHANGED:i.resize.bind(i),CLICK:i.adClick.bind(i),PAUSED:i.adPaused.bind(i),RESUMED:i.adResumed.bind(i),SKIPPED:i.adSkipped.bind(i),USER_CLOSE:i.adUserClose.bind(i),ALL_ADS_COMPLETED:i.allAdsCompleted.bind(i)}),i.isItemSchedule){var a=r.getCuePoints();if("string"==typeof n.schedule||a.length&&0===a[0]||(i.debugConsoleLog("[JW DEBUG] Stop blocking since there is no preroll"),i.stopBlocking()),a.length){var s=a.filter(function(e){return e>0}).map(function(e){return{begin:e,text:i.options.cuetext}});i.player.setCues(s)}}return r}).catch(function(e){throw i.asyncError(e),e})},e.prototype.getViewMode=function(){var e=google.ima.ViewMode;return this.player.getFullscreen()?e.FULLSCREEN:e.NORMAL},e.prototype.prepareToPlayAd=function(e){if(!this.destroyed())if(this.blockingInstreamPlayer){var t=e?"":this.player.getConfig().localization.loadingAd;this.blockingInstreamPlayer.setText(t)}else clearTimeout(this.timeoutAdStart),this.startBlocking(e)},e.prototype.muteInstreamProvider=function(){var e=this.video.muted||this.player.getMute()||0===this.adsLoaderManager.adsManager.getVolume();this.debugConsoleLog("[JW DEBUG] Setting mute on instreamProvider",e),this.instreamProvider.mute(e)},e.prototype.exitFullscreenOnInlineIOS=function(){this.env.OS.iOS&&(this.env.Browser.version.major<10||(this.debugConsoleLog("[JW DEBUG] Exiting fullscreen mode on iOS 10+"),this.player.setFullscreen(!1),this.utils.style(this.fullscreenIcon,{display:"none"})))},e.prototype.startBlocking=function(e){var t=this;if(!this.blockingInstreamPlayer&&!this.destroyed()){this.debugConsoleLog("[JW DEBUG] JW Player startBlocking"),this.exitFullscreenOnInlineIOS(),this.options.premiumAds&&this.player.on("viewable",function(e){e.viewable?t.pausedByViewable&&(t.debugConsoleLog("[JW DEBUG] PremiumAds mode enabled. Start playing the ad on viewable"),t.player.play()):t.paused||(t.debugConsoleLog("[JW DEBUG] PremiumAds mode enabled. Pause the ad on not viewable"),t.player.pause(),t.pausedByViewable=!0)},this),this._qoe.tick("adLoading"),this.player.utils.addClass(this.player.getContainer(),o),this.adsLoaderManager&&this.adsLoaderManager.videoProxy&&this.adsLoaderManager.videoProxy.unblock(),this.blockingInstreamPlayer=this.player.createInstream().init();var i=e?"":this.player.getConfig().localization.loadingAd;this.blockingInstreamPlayer.setText(i),this.blockingInstreamPlayer.applyProviderListeners(this.instreamProvider),this.initAdsManagerPromise.then(function(e){t.debugConsoleLog("[JW DEBUG] Start adsManager"),e.start()}).catch(function(){}),clearTimeout(this.timeoutAdStart),this.timeoutAdStart=setTimeout(function(){if(t.debugConsoleLog("[JW DEBUG] Ad request timeout"),!t.destroyed()){t.stopBlocking(),t.asyncDiscardAdBreak();var e={message:"Ad Request timeout after "+t.options.requestTimeout+" milliseconds",getErrorCode:function(){return 60004}},i=t.adsLoaderManager.adErrorEventObject(e,{});t.trigger(f,i)}},this.options.requestTimeout)}},e.prototype.stopBlocking=function(){this.destroyed()||(this.debugConsoleLog("[JW DEBUG] JW Player stopBlocking"),this.player.off("viewable",null,this),clearTimeout(this.timeoutAdStart),this.utils.style(this.fullscreenIcon,{display:""}),this.player.utils.removeClass(this.player.getContainer(),[a,s,o]),this.blockingInstreamPlayer&&(this.adsLoaderManager&&this.adsLoaderManager.videoProxy&&this.adsLoaderManager.videoProxy.block(),this.instreamProvider.off(),this.blockingInstreamPlayer.destroy(),this.blockingInstreamPlayer=null,this.view.adTakeDown()))},e.prototype.pauseRequested=function(e){var t=this;this.prepareToPlayAd();var i=this.adsLoaderManager.adEventObject(e.getAd());this.player.trigger(h,fe(h,this.player,i.adposition)),this.blockingInstreamPlayer.on("destroyed",function(){t.player.trigger(c,fe(c,t.player,i.adposition))})},e.prototype.resumeRequested=function(){this.debugConsoleLog("[JW DEBUG] ResumeRequest from IMA SDK"),this.currentAd&&this.currentAd.isLinear()&&(this.finishAd(),this.view.adTakeDown()),this.stopBlocking()},e.prototype.finishAd=function(){this.currentAd&&(clearInterval(this.progressIntervalId),this.currentAd=null)},e.prototype.discardAdBreak=function(e){!e&&this.adsLoaderManager&&(e=this.adsLoaderManager.adsManager),!this.destroyed()&&e&&(e.discardAdBreak(),e.stop())},e.prototype.asyncDiscardAdBreak=function(){var e=this;this.initAdsManagerPromise.then(function(t){return e.discardAdBreak(t)}).catch(function(){})},e.prototype.pause=function(){this.pausedByViewable=!1;var e=this.adsLoaderManager.adsManager;e&&(this.debugConsoleLog("[JW DEBUG] JW Player pause ad"),e.pause())},e.prototype.resume=function(){this.pausedByViewable=!1;var e=this.adsLoaderManager.adsManager;e&&(this.debugConsoleLog("[JW DEBUG] JW Player resume ad"),e.resume())},e.prototype.beforePlay=function(e){var t=this;this.bids&&this.bids.timeout&&this.bids.timeout(),this.player.off("beforePlay",null,this),this.isItemSchedule=!!e,this.prepareToPlayAd(this.isItemSchedule),this.adsLoaderManager.initializeDisplay(),this._qoe.tick("adBeforePlay"),this.bidsPromise.then(j).then(function(){t.destroyed()||(t.debugConsoleLog("[JW DEBUG] Request ads to IMA SDK"),t.adsLoaderManager.requestAds())}).catch(this.utils.noop)},e.prototype.beforeComplete=function(){var e=this.adsLoaderManager.adsManager;e&&e.getCuePoints().indexOf(-1)>-1&&this.prepareToPlayAd(),this.adsLoaderManager.unbindEvents(["CONTENT_RESUME_REQUESTED"]),this.playbackProxy.currentTime=this.playbackProxy.duration,this.debugConsoleLog("[JW DEBUG] Call contentComplete on IMA SDK"),this.adsLoaderManager.contentComplete()},e.prototype.time=function(e){this.playbackProxy.currentTime=e.position,e.duration>=e.position?this.playbackProxy.duration=e.duration:this.playbackProxy.duration=1/0},e.prototype.resize=function(){var e=this.currentAd,t=this.adsLoaderManager.adsManager;if(t){var i=e&&!e.isLinear(),n=this.player.getSafeRegion(i);if(i){var r=e.getHeight();r=this.player.getFullscreen()?n.height/2:Math.max(100,r+10),this.debugConsoleLog("[JW DEBUG] Resize adsManager",n.width,r,this.getViewMode()),t.resize(n.width,r,this.getViewMode()),this.view.resizeNonLinear(n,r)}else this.debugConsoleLog("[JW DEBUG] Resize adsManager",n.width,n.height,this.getViewMode()),t.resize(n.width,n.height,this.getViewMode()),this.view.resizeLinear()}},e.prototype.triggerAdPlay=function(e,t,i,n){if(e.isLinear()){this.instreamProvider.trigger("state",{newstate:i,oldstate:n});var r=this.adsLoaderManager.adEventObject(e);r.oldstate=n,r.newstate=i,this.trigger(t,r)}},e.prototype.progressInterval=function(e,t){var i=this;if(clearInterval(this.progressIntervalId),t){var n=e.getAdId(),r=e.getAdPodInfo(),o=-1,a=this.options.admessage||"",s=new RegExp(this.options.admessagedynamickey,"g"),d=this.options.adcounterdynamic||"",l=new RegExp(this.options.adcountercountkey,"g"),u=new RegExp(this.options.adcountertotalkey,"g");this.progressIntervalId=setInterval(function(){if(i.currentAd&&i.currentAd.getAdId()===n){var p=t.getRemainingTime();if(!(isNaN(p)||p<=0)&&o!==p){o=p;var h=e.getDuration(),c=h-p;if(i.blockingInstreamPlayer){var g=a.replace(s,Math.round(h-c)),f=r.getTotalAds();if(f>1){var m=r.getAdPosition();g=d.replace(l,m).replace(u,f)+" "+g}i.blockingInstreamPlayer.setText(g),i.instreamProvider.trigger("time",{duration:h,position:c})}if(h>0){var y=i.adsLoaderManager.adEventObject(e);y.position=c,y.duration=h,i.trigger("adTime",y)}}}else clearInterval(i.progressIntervalId)},250)}},e.prototype.adLoaded=function(e){this.muteInstreamProvider();var t=this.adsLoaderManager.adEventObject(e.getAd());this.trigger("adRequest",t)},e.prototype.adStarted=function(e){var t=e.getAd(),i=this.adsLoaderManager.adEventObject(t);this.trigger(m,i)},e.prototype.adImpression=function(e){var t=this,i=e.getAd(),n=i.isLinear(),r=n&&(i.getContentType().indexOf("image")>=0||-1===i.getDuration()),o=i.getContentType(),d="application/javascript"===o||"application/x-shockwave-flash"===o,u=n&&d&&this.options.vpaidcontrols;this.currentAd=i,this.blockingInstreamPlayer&&this.blockingInstreamPlayer.setSkipOffset(i.getSkipTimeOffset()),this.adsLoaderManager.bindEvents({COMPLETE:this.adComplete.bind(this)}),d&&this.env.OS.mobile&&this.options.autoplayadsmuted&&this.adsLoaderManager.bindEvents({VOLUME_CHANGED:function(){t.adsLoaderManager.unbindEvents(["VOLUME_CHANGED"]),t.player.setMute(!!t.adsLoaderManager.adsManager.getVolume())}}),r?this.startBlocking():n||this.stopBlocking(),this.player.utils.toggleClass(this.player.getContainer(),a,n&&(r||d)),this.player.utils.toggleClass(this.player.getContainer(),s,u),this.view.adSetup(),this.resize(),this.muteInstreamProvider(),clearTimeout(this.timeoutAdStart);var p=this.adsLoaderManager.adsManager;this.progressInterval(i,p);var h=this.adsLoaderManager.adEventObject(i);"pre"!==h.adposition||void 0!==h.podcount&&1!==h.sequence||(this._qoe.tick("adImpression"),h.timeLoading=this._qoe.between("adBeforePlay","adImpression")),ye(h,this),this.trigger("adImpression",h),this.triggerAdPlay(i,y,l,"buffering")},e.prototype.adComplete=function(e){this.finishAd();var t=e.getAd(),i=this.adsLoaderManager.adEventObject(t);this.trigger("adComplete",i),this.adsLoaderManager.unbindEvents(["VOLUME_CHANGED"])},e.prototype.adClick=function(e){var t=this.adsLoaderManager.adsManager,i=e.getAd(),n=i.getContentType();"application/javascript"===n||"application/x-shockwave-flash"===n||(this.debugConsoleLog("[JW DEBUG] Ad paused due to ad click"),t.pause());var r=this.adsLoaderManager.adEventObject(i);this.trigger("adClick",r),this.pausedByViewable=!1},e.prototype.adPaused=function(e){this.paused||(this.paused=!0,this.triggerAdPlay(e.getAd(),"adPause",d,l))},e.prototype.adResumed=function(e){this.paused&&(this.paused=!1,this.triggerAdPlay(e.getAd(),y,l,d))},e.prototype.adSkipped=function(e){this.debugConsoleLog("[JW DEBUG] AdSkipped"),this.adsLoaderManager.unbindEvents(["COMPLETE","VOLUME_CHANGED"]),this.finishAd();var t=this.adsLoaderManager.adEventObject(e.getAd());this.trigger("adSkipped",t)},e.prototype.adUserClose=function(e){this.debugConsoleLog("[JW DEBUG] AdUserClose"),this.currentAd&&this.currentAd.isLinear()&&-1===this.currentAd.getDuration()?this.adSkipped(e):(this.adsLoaderManager.unbindEvents(["COMPLETE","VOLUME_CHANGED"]),this.finishAd())},e.prototype.allAdsCompleted=function(){this.resumeRequested(),this.view.adTakeDown(),this.stopAdsManager()},e.prototype.stopAdsManager=function(){var e=this;this.initAdsManagerPromise.then(function(t){e.destroyed()||(e.debugConsoleLog("[JW DEBUG] Stop IMA SDK adsManager"),t.stop(),t.destroy(),e.initAdsManagerPromise=null,e.bidsPromise=null)}).catch(function(){})},e.prototype.adLog=function(e){this.debugConsoleLog("[JW DEBUG]",e.type,e);var t=e.getAdData();if(t&&t.adError){var i=this.adsLoaderManager.adErrorEventObject(t.adError,e);402===i.code?this.handleAdError(t.adError,i):this.trigger(f,i)}},e.prototype.adError=function(e){var t=e.getError();this.handleAdError(t,e)},e.prototype.asyncError=function(e){var t=this;if(!this.destroyed())if(clearTimeout(this.timeoutAdStart),this.timeoutAdStart=setTimeout(function(){return t.destroy()},0),e&&e.getError){var i=e.getError();this.handleAdError(i,e,!0)}else e.target&&e.target.src?console.error("Failed to load "+e.target.src):console.error(e)},e.prototype.handleAdError=function(e,t,i){var n=this;this.options.debug&&console.error(e),900===e.getErrorCode()||i?(clearTimeout(this.timeoutAdStart),this.timeoutAdStart=setTimeout(function(){return n.destroy()},0)):(this.stopBlocking(),this.view.adTakeDown());var r=this.adsLoaderManager.adErrorEventObject(e,t);ye(r,this),this.player&&0===this.player.getPosition()&&(this._qoe.tick("adError"),r.timeLoading=this._qoe.between("adBeforePlay","adError")),this.trigger(f,r)},e.prototype.destroy=function(){if(this.debugConsoleLog("[JW DEBUG] JW Player destroy PlaylistItemManager"),this.off(),!this.destroyed()){this.player.off(null,null,this),this.bids&&this.bids.stop&&(this.bids.stop(),this.bids=null),clearTimeout(this.timeoutAdStart),clearInterval(this.progressIntervalId),this.currentAd=null,this.options=null,this.video=null,this.initAdsManagerPromise=null,this.bidsPromise=null;var e=this.adsLoaderManager;e&&(e.reset(),this.adsLoaderManager=null),this.blockingInstreamPlayer&&this.stopBlocking(),this.instreamProvider.off(),this.instreamProvider.setProxy(null),this.instreamProvider=null,this.view.adTakeDown(),this.view=null,this.player=null,this.item=null}},e.prototype.destroyed=function(){return!this.item},e}();function be(e){var t=this;t.video=e,t.blocked=!1;var i={},n=function(n){"function"==typeof e[n]?i[n]={get:function(){return function(){var e=t.video[n];if(e){if("pause"===n&&t.blocked)return;return e.apply(t.video,arguments)}}}}:i[n]={get:function(){return t.video[n]},set:function(e){t.video[n]=e}}};for(var r in e)n(r);Object.defineProperties(this,i)}function we(e){try{return e.getAdPodInfo()}catch(e){return null}}!function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}(be.prototype,{block:function(){this.blocked=!0},unblock:function(){this.blocked=!1}});var Ae=function(){function t(e){w(this,t),this.adsLoader=null,this.adDisplayContainer=null,this.displayInitialized=!1,this.adsRequest=null,this.userRequestContext=null,this.adsManager=null,this.adsManagerEvents={},this.container=e,this.adIds={},this.schedule=null,this.tagMap={},this.playerApi=null,this.videoProxy=null}return t.prototype.getVpaidMode=function(e){var t=google.ima.ImaSdkSettings.VpaidMode;return"disabled"===e||"none"===e?t.DISABLED:"enabled"===e?t.ENABLED:t.INSECURE},t.prototype.initializeDisplay=function(){this.videoProxy&&this.videoProxy.unblock(),!this.displayInitialized&&this.adDisplayContainer&&(this.adDisplayContainer.initialize(),this.displayInitialized=!0)},t.prototype.contentComplete=function(){if(null!==this.adsRequest){var e=this.adsLoader;e&&e.contentComplete(),this.adsRequest=null}},t.prototype.reset=function(){this.userRequestContext=null;var e=this.adsManager;e&&(e.destroy(),this.adsManager=null),this.contentComplete(!0),this.schedule=null,this.videoProxy&&this.videoProxy.block(),this.adsManagerEvents={},this.adIds={},this.tagMap={}},t.prototype.prepare=function(e){google.ima.settings.setDisableCustomPlaybackForIOS10Plus(!0);var t=this.adsLoader;return t||(this.videoProxy=new be(e),this.adDisplayContainer=new google.ima.AdDisplayContainer(this.container,this.videoProxy),t=this.adsLoader=new google.ima.AdsLoader(this.adDisplayContainer)),t},t.prototype.open=function(e,t,i,n,r){t.locale&&google.ima.settings.setLocale(t.locale),t.maxRedirects>=0&&google.ima.settings.setNumRedirects(t.maxRedirects);var o=this.prepare(r);this.playerApi=i;var a={requestType:e,vpaidMode:t.vpaidmode,playerVersion:i.version.split("+")[0]};this.userRequestContext=a;var s=t.getSchedule();if(!s)return Promise.reject();var d=new google.ima.AdsRequest,l=i.getSafeRegion(!1);d.linearAdSlotWidth=l.width,d.linearAdSlotHeight=l.height;var u=i.getSafeRegion(!0);d.nonLinearAdSlotWidth=u.width,d.nonLinearAdSlotHeight=u.height,d.setAdWillAutoPlay(i.getConfig().autostart&&!i.getEnvironment().OS.mobile),d.setAdWillPlayMuted(i.getMute()),d.forceNonLinearFullSlot=n.forceNonLinearFullSlot,this.adsRequest=d;var p=new S(i,n);if("object"==typeof s){var h=p.getTagList(s);1===h.length&&0===h[0].offset&&(s=h[0].tag)}return"string"==typeof s?s=d.adTagUrl=a.adTagUrl=b(s,i,n):(d.adsResponse=a.adsResponse=p.getAdsResponse(s),this.tagMap=p.getTagMap(s)),this.schedule=s,new Promise(function(e,t){o.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR,t,!1),o.addEventListener(google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,e,!1)})},t.prototype.requestAds=function(){var e=this.adsLoader,t=this.userRequestContext,i=this.getVpaidMode(t.vpaidMode),n=e.getSettings();n.setPlayerType("jwplayer"),n.setPlayerVersion(t.playerVersion),n.setVpaidMode(i),e.requestAds(this.adsRequest,t)},t.prototype.getAdsManager=function(e,t,i){var n=new google.ima.AdsRenderingSettings;return n.loadVideoTimeout=i.loadVideoTimeout,n.enablePreloading=i.enablePreloading,n.uiElements=null,n.autoAlign=!0,n.useStyledNonLinearAds=!0,this.adsManager=e.getAdsManager(t,n),this.userRequestContext=e.getUserRequestContext(),this.adsManager},t.prototype.bindEvents=function(e){var t=this,i=google.ima.AdEvent.Type,n=google.ima.AdErrorEvent.Type;Object.keys(e).forEach(function(r){var o=i[r]||n[r],a=t.adsManagerEvents[o];a&&t.adsManager.removeEventListener(o,a),t.adsManager.addEventListener(o,e[r],!1),t.adsManagerEvents[o]=e[r]})},t.prototype.unbindEvents=function(e){var t=this,i=google.ima.AdEvent.Type,n=google.ima.AdErrorEvent.Type;e.forEach(function(e){var r=i[e]||n[e],o=t.adsManagerEvents[r];o&&(t.adsManager.removeEventListener(r,o),delete t.adsManagerEvents[r])})},t.prototype.getAdId=function(e){if(e){var t=e.getAdId(),i=we(e);if(i&&(t=""+i.getTimeOffset()),t)return void 0===this.adIds[t]&&(this.adIds[t]=(r=12,new Array(r+1).join((Math.random().toString(36)+"00000000000000000").slice(2,18)).slice(0,r))),this.adIds[t]}var r;return n},t.prototype.getTag=function(e,t){if("string"==typeof this.schedule)return this.schedule;var i=we(e);if(i){var n=this.tagMap[i.getTimeOffset()];if(n)return n}var r=this.userRequestContext;return t&&t.getUserRequestContext&&(r=t.getUserRequestContext()||r),r?r.adTagUrl||r.adsResponse||"":(console.error("invalid request context",r),"")},t.prototype.adEventObject=function(t){var i={client:e,tag:this.getTag(t),ima:{ad:t,userRequestContext:this.userRequestContext}};if(!t)return i;i.id=this.getAdId(t),i.adtitle=t.getTitle(),i.adsystem=t.getAdSystem(),i.creativetype=t.getContentType(),i.linear=t.isLinear()?"linear":"nonlinear",i.viewable=this.playerApi.getViewable();var n=we(t);if(n){var r=n.getTotalAds();r>1&&(i.sequence=n.getAdPosition(),i.podcount=r);var o=n.getTimeOffset(),a="mid";0===o?a="pre":-1===o&&(a="post"),i.adposition=a}return i},t.prototype.adErrorEventObject=function(t,i){var r=t.getMessage&&t.getMessage()||t.message,o=t.getVastErrorCode&&t.getVastErrorCode()||900,a=t.getErrorCode&&t.getErrorCode()||900;a<1e4&&(a+=2e4);var s=this.getTag(i.getAd&&i.getAd(),i);return{id:n,client:e,message:"Ad Error: "+r,code:o,adErrorCode:a,tag:s}},t}();!function(e){if(e&&"undefined"!=typeof window){var t=document.createElement("style");t.setAttribute("media","screen"),t.innerHTML=e,document.head.appendChild(t)}}(".jwplayer.jw-flag-ads-googleima.jw-flag-small-player .jw-controls-backdrop,.jwplayer.jw-flag-ads-googleima.jw-flag-small-player .jw-icon-fullscreen{display:none}.jwplayer.jw-flag-ads-googleima.jw-flag-touch .jw-controlbar{font-size:1em}.jwplayer.jw-flag-ads-googleima.jw-flag-small-player.jw-flag-ads.jw-state-playing.jw-flag-touch:not(.jw-flag-ads-vpaid) .jw-controls .jw-controlbar,.jwplayer.jw-flag-ads-googleima.jw-flag-touch .jw-display-icon-display,.jwplayer.jw-flag-ads-googleima.jw-flag-touch .jw-display-icon-display .jw-icon-display{pointer-events:none}.jwplayer.jw-flag-ads-googleima.jw-flag-small-player .jw-controlbar{background:0 0!important;flex-flow:column-reverse nowrap;height:100%;max-height:none;pointer-events:none}.jwplayer.jw-flag-ads-googleima.jw-flag-small-player .jw-button-container{align-items:flex-end;flex-wrap:wrap;margin-bottom:7px}.jwplayer.jw-flag-ads-googleima.jw-flag-small-player .jw-controlbar .jw-icon{height:30px}.jwplayer.jw-flag-ads-googleima.jw-flag-small-player .jw-svg-icon{fill:#fff;filter:drop-shadow(0 0 3px #000)}.jwplayer.jw-flag-ads-googleima.jw-flag-small-player .jw-text{align-self:flex-start;margin:16px 0 0 16px;order:-1;text-shadow:0 0 3px #000;width:100%}"),(window.jwplayerPluginJsonp||window.jwplayer().registerPlugin)(e,"8.1",function(r,o,a){var s=this,d=r.utils,l=r.getConfig(),u=new L(o||{},d),p=null,h=void 0,c=0;if(u.premiumAds){if(r.getMute()||l.autostart)return console.log("Premium Ads: Cannot play ads in autostart or muted"),void(this.destroy&&this.destroy());if(function(){var e=(window.performance||{}).timing;if(e){var t=e.loadEventEnd||(new Date).getTime(),i=t-e.navigationStart;if(i>0)return i}return v}()>=v)return console.log("Premium Ads: Page load took too long to start an ad"),void(this.destroy&&this.destroy())}j(d).then(function(){if(h){var e=k();e>=0&&e-h>=v&&(console.log("Premium Ads: IMA SDK load took too long to start an ad"),s.destroy&&s.destroy())}}).catch(d.noop);var y=r._,b=l.key;d.addClass(a,"jw-plugin-googima");var w=new x(a,r.id,d.style),A=new B(d,r.Events,w),P=new Ae(w.getAdDiv()),E=null;function C(e,t,i,n){try{return e.getCompanionAds(t,i,n)}catch(e){return[]}}function S(e){var t=new google.ima.CompanionAdSelectionSettings;t.sizeCriteria=google.ima.CompanionAdSelectionSettings.SizeCriteria.IGNORE;var i=u.companiondiv||{width:300,height:250},n=function(e){for(var t=[],i=0;i0}function M(){E&&!E.destroyed()&&(r.off(null,null,E),E.destroy(),E=null)}function _(e){E&&E.discardAdBreak(),P.contentComplete(),M(),e&&e.adschedule?u.adschedule=e.adschedule:u.adschedule=null,r.setCues([])}function T(e,t,n){var o,a,s,l=this,g=e.item||{};_(g),t!==i||(o=u.getAdRules(),a=0===o.frequency&&1===c,s=c>=o.startOn&&(c-o.startOn)%o.frequency==0,a||s)?(p||(p=r.createInstream().getMediaElement()),n.getSchedule()?(P.reset(),(E=new ve(g,u,r,A,w,P,p)).on("all",function(e,t){return r.trigger(e,t)}),E.init(t,n),E.on(m,function(e){S(e.ima.ad)}),r.once("beforePlay",function(e){if(u.premiumAds){var t=r.getHeight(),i=r.getWidth();if(t<270||i<480)return console.log("Premium Ads: Player size is smaller than 480x270 to play an ad"),void l.destroy();k()<0&&(h=Date.now())}E.beforePlay(e)},E).on("beforeComplete",function(){return E.beforeComplete()},E).on("time",function(e){return E.time(e)},E).on("resize",function(){return E.resize()},E).on("fullscreen",function(){return E.resize()},E)):j(d).then(function(){P.prepare(p)}).catch(d.noop)):u.adschedule=null}this.version="8.1.9",r.utils.extend(this,r.Events),r.pauseAd=function(e){E&&(e?E.pause():E.resume())},r.playAd=function(e){var i=d.extend({},o,{debug:u.debug});delete i.ad,delete i.tag,delete i.schedule,r._.isArray(e)?i.tag=e[0]:i.tag=e;var n=new L(i,d),a=E?E.blockingInstreamPlayer:null;a&&(a.noResume=!0),T({},t,n),E&&E.beforePlay(null)},r.on("ready",function(){j().catch(function(e){e.message.match(/Failed to load/)&&D("Ad playback blocked by an ad blocker",2e4)}),I.catch(function(e){D("Ad Error: "+e.message,60002)})},this).on("playlistItem",function(e){c++,T(e,i,u)},this).on("playlistComplete",function(){_()},this).on("cast",function(e){e.active&&_()},this).on("destroyPlugin",function(){s.destroy()},this);var I=R.call(this,d,b);I.catch(d.noop);var D=function(t,i){M(),r.off(null,null,s),r.playAd=d.noop,r.trigger(f,{id:n,client:e,message:t,code:900,adErrorCode:i,tag:""})};this.destroy=M,this.adsDebugMode=function(){u.debug=!0,E&&(E.debugConsoleLog=function(){var e;(e=console).log.apply(e,arguments)})}})}();