!function(){"use strict";function e(e){if("true"===e)return!0;if("false"===e)return!1;var t=parseFloat(e);return isNaN(t)?e:t}function t(e){var t=Object.keys(e).filter(function(t){return"pre"===e[t].offset||!e[t].offset});return t.length?t[0]:null}function i(){return D}function n(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);return e}function r(e,t){var i=void 0,n=new Promise(function(e){i=e}),r=document.getElementsByTagName("head")[0]||document.documentElement,a=document.createElement("script");return a.src=e,a.onload=a.onreadystatechange=function(e){this.readyState&&"loaded"!==this.readyState&&"complete"!==this.readyState||(i(e),a.onload=a.onreadystatechange=null,r&&a.parentNode&&r.removeChild(a))},a.onerror=function(){i("Error loading script")},r.insertBefore(a,r.firstChild),setTimeout(function(){i()},t),n}function a(e,t,i){return e?["https://an.facebook.com/v2/placementbid.json?&placementids[]="+e,"&playerwidth="+t,"&playerheight="+i,"&adformats[]="+B,"&sdk="+U,"&pageurl="+G].join(""):null}function o(e,t,i,n){return["https://an.facebook.com/v1/instream/vast.xml?placementid="+e,"&playerwidth="+i,"&playerheight="+n,"&sdk="+U,"&bidid="+t,"&pageurl="+G].join("")}function s(e,t,i,n){return!!n&&(!!e||!(!t||"usd"!==i))}function d(e,t){var i=e.xhttpFAN,n=e.settings,r=e.bidders,d=r.FAN.placementId,l=e.tag,u=n.floorPriceCents,h=n.playerWidth,c=n.playerHeight,p=a(d,h,c),g=e.bidders.APS,f=e.mediationLayer||g.pubID&&g.slotID;if(!s(f,u,n.floorPriceCurrency,p))return t({error:!0,message:"Invalid config"});i.onreadystatechange=function(){if(4===this.readyState){if(clearTimeout(e.currentTimeout),200!==this.status)return t({error:!0,message:"Invalid response (status "+this.status+")"});var i=JSON.parse(this.responseText),n=i.errors;if(n&&n.length)return t({error:!0,message:n[0]});var r=i.bids;if(!r||!r[d]||!r[d][0])return t({error:!0,message:"No bids for placement id"});var a=r[d][0],s=a.bid_price_cents,p=a.bid_id;if(f){var g=Math.round(s/100);return t({tag:l,custParams:{jwFANBidPrice:g,jwFANBidID:p}})}var m=a.bid_price_currency,v=s>u,y={bidWon:v,priceCents:s,priceCurrency:m};return v?(y.tag=o(d,p,h,c),t(y)):t(y)}},i.open("GET",p),i.withCredentials=!0,i.send(null)}function l(e,t){var i=e.bidders.APS;if(!i.pubID||!i.slotID)return t({error:!0,message:"Invalid config"});F().then(function(){return apstag.init({pubID:i.pubId,adServer:i.adServer}),apstag.fetchBids({slots:[{slotID:i.slotID}],timeout:e.settings.bidTimeout},function(n){return t(n&&n[0]&&n[0].slotID===i.slotID?{tag:e.tag,custParams:{amznbid:n[0].amznbid,amzniid:n[0].amzniid}}:{error:!0,message:"No bids for pubID and slotID"})})}).catch(function(){t({error:!0,message:"Amazon header bidding failed"})})}function u(e,t){var i=n({videoCommonArgs:{protocols:[2,3,5,6],mimes:["video/mp4","video/webm","application/javascript"],apiList:[1,2]}},e.bidders.index);if(!i.script&&!i.siteID&&!window.indexapi)return t({error:!0,message:"Invalid config"});setTimeout(function(){t({error:!0,message:"Index Exchange header bidding request failed"})},e.settings.bidTimeout),H().then(function(){var n=function(i,n){if(void 0!==n)return t({tag:e.tag,custParams:n});t({error:!0,message:"Index Exchange header bidding request failed"})};window.indexapi=window.indexapi||{},window.indexapi.deferQueue=window.indexapi.deferQueue||[],window.indexapi.deferQueue.push(function(){window.indexapi.solicitIndexVideoAds(e.tag,n,i)})}).catch(function(){t({error:!0,message:"Index Exchange header bidding failed"})})}function h(e){for(var t=[d,l,u],i=[],r=0;r1?e[1]:""}function f(e,t){var i=Math.pow(10,t);return Math.round(e*i)/i}function m(e){return-1!==e.indexOf("?")?"&":"?"}function v(e,t,i){if(!e)return e;var n=t.getPlaylistItem(),r=t.getConfig(),a=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()||r.height).replace("__player-width__",t.getWidth()||r.width).replace("__item-duration__",f(t.getDuration(),3)).replace("__domain__",encodeURIComponent(g()));a=i.companiondiv&&i.companiondiv.id?a.replace("__companion-div__",i.companiondiv.id):a.replace("__companion-div__","");for(var o=a.match(new RegExp(/__item-[a-z 0-9 A-Z]*__/g)),s=0;o&&s1e3&&(u=u.substring(0,1e3)),a=a.replace(d,encodeURIComponent(u))}else a=a.replace(d,"")}if(n.title&&-1===a.indexOf("vid_t=")){var h=n.title.substring(0,100).replace(/[^\x00-\x7F]/g,"");a+=m(a)+"vid_t="+encodeURIComponent(h)}return a}function y(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 b(e){var t=parseInt(e,10),i=Math.floor(t)%1e3,n=Math.floor(t/1e3)%60,r=Math.floor(t/6e4)%60,a=Math.floor(t/36e5)%24;return a=a<10?"0"+a:a,r=r<10?"0"+r:r,n=n<10?"0"+n:n,i=("000"+i).slice(-3),a+":"+r+":"+n+"."+i}function A(e,t,i){var n=y(e,t,i);return n||(n="pre"),i.isNumber(n)&&(n=b(1e3*n)),n}function P(e,t,i){if(!i)return e;var n=e.indexOf("?")>=0?"&":"?",r=e.indexOf("cust_params="),a="cust_params=".length,o="",s="";if(t.foreach(i,function(e,t){o=""+o+s+e+"="+t,s="&"}),o=encodeURIComponent(o),r>=0){var d=e.substr(0,r+a),l=e.substr(r+a);return""+d+o+"%26"+l}return""+e+n+"cust_params="+o}function w(e,t,i){var n={};return t.foreach(e,function(e,r){var a={},o=r.ad||r;a.offset=A(o.offset||o.position||r.offset||"",t,i),a.tag=P(o.tag,t,o.custParams),a.type=o.type||r.type||"linear,nonlinear",n[e]=a}),n}function E(e){return new Array(e+1).join((Math.random().toString(36)+"00000000000000000").slice(2,18)).slice(0,e)}function M(e){try{return e.getAdPodInfo()}catch(e){return null}}var _="adCompanions",C="adStarted",I=2e3,T=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},L={adcountercountkey:"__AD_POD_CURRENT__",adcounterdynamic:"Ad __AD_POD_CURRENT__ of __AD_POD_LENGTH__. ",adcountertotalkey:"__AD_POD_LENGTH__",admessage:"This ad will end in xx seconds.",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:"",overlayslotheight:0,overlayslotwidth:0,premiumAds:!1,scaled_ads:!0,usestaticmessage:!1,vpaidcontrols:!1,vpaidmode:"insecure"},S=function(){function i(t,n){T(this,i),this.config=t,this.utils=n;for(var r in L)if(L.hasOwnProperty(r)){var a=t[r],o=L[r],s=typeof o;if(void 0!==a){if("boolean"!==s&&"number"!==s||(a=e(a)),typeof a!==s)throw new Error("invalid parameter: "+r+" should be a "+s);this[r]=a}else this[r]=o}this.admessagedynamic=this.admessage}return i.prototype.getPrerollBlock=function(){var e=this.getConfigSchedule(),i=this.bidsResponse;if("string"==typeof e){if(!i)return e;var n=i.custParams;if(n){var r="jwFANBidPrice="+n.jwFANBidPrice+"&jwFANBidID="+n.jwFANBidID,a=i.tag.indexOf("?")>=0?"&":"?";return""+i.tag+a+r}return i.tag}var o=t(e);if(!o)return null;var s=this.utils.extend({},e[o]);return i&&(s.tag=i.tag,s.custParams=this.utils.extend({},s.custParams,i.custParams)),s},i.prototype.addBidsResponse=function(e){e&&!e.error&&(e.bidWon||e.tag)?this.bidsResponse=e:this.bidsResponse=null},i.prototype.getSchedule=function(){var e=this.utils.extend({},this.getConfigSchedule());if(!this.bidsResponse)return this.getConfigSchedule();var i=this.getPrerollBlock();return"string"==typeof i?i:(e[t(e)]=i,e)},i.prototype.getConfigSchedule=function(){var e=this.config;return e.tag||this.adschedule||e.schedule||e.ad},i}(),k=function(){function e(t,i,n){T(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;t0&&void 0!==arguments[0]?arguments[0]:{settings:{},bidders:{}},i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;T(this,e),this.tag=i,this.mediationLayer=t.mediationLayerAdServer,this.settings=c(t.settings,r,a),this.bidders=p(t.bidders),this.xhttpFAN=new XMLHttpRequest,this.request=new Promise(function(e){n.resolve=e}),t.bidders.APS&&t.bidders.APS.pubID&&t.bidders.APS.slotID&&F(),t.bidders.index&&(t.bidders.index.script||t.bidders.index.siteID)&&H(t.bidders.index.script),this.currentTimeout=null}return e.prototype.start=function(){return this.start=function(){return this.request},h(this),this.request},e.prototype.stop=function(){clearTimeout(this.currentTimeout),this.xhttpFAN&&(this.xhttpFAN.abort(),this.xhttpFAN=null),this.resolve({error:!0,message:"Request aborted"})},e.prototype.then=function(e){return this.request.then(e,e)},e.prototype.timeout=function(){var e=this;clearTimeout(this.currentTimeout),this.currentTimeout=setTimeout(function(){e.currentTimeout=null,e.resolve&&e.resolve({error:!0,message:"Response timeout"})},this.settings.bidTimeout)},e}(),Q=function(){function e(t,i,n,r,a,o){T(this,e),n.utils.extend(this,n.Events),this.item=t,this.options=i,this.player=n,this.utils=n.utils,this.instreamProvider=r,this.view=a,this.initAdsManagerPromise=null,this.bidsPromise=null,this.blockingInstreamPlayer=null,this.mobilePlayCallback=null,this.currentAd=null,this.bids=null,this.timeoutAdStart=-1,this.progressIntervalId=-1,this.video=n.getContainer().querySelector("video"),this.fullscreenIcon=n.getContainer().querySelector(".jw-icon-fullscreen"),this.adsLoaderManager=o,this.playbackProxy={currentTime:0,duration:0},this.isItemSchedule=!0,this.paused=!1,this._qoe=new n.utils.Timer}return e.prototype.init=function(e,t){var i=this,n=t.getPrerollBlock();if(!this.player.getConfig().autostart&&n){var r="string"!=typeof n,a=r?n.bids:t.config.bids,o=r?n.tag:n;this.bids=new W(a,o,this.player.getWidth(),this.player.getHeight()),this.bids.start()}else this.bids=Promise.resolve();this.bidsPromise=this.bids.then(function(e){if(i.destroyed())return null;t.addBidsResponse(e)}),this.initAdsManagerPromise=this.bidsPromise.then(R).then(function(){return i.destroyed()?null:i.adsLoaderManager.open(e,t,i.player,i.options)}).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 a=i.player.getSafeRegion(!1);if(r.init(a.width,a.height,i.getViewMode()),n.initializeDisplay(),n.bindEvents({LOADED:i.adLoaded.bind(i),AD_ERROR:i.adError.bind(i),CONTENT_PAUSE_REQUESTED:i.prepareToPlayAd.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 o=r.getCuePoints();if("string"==typeof n.schedule||o.length&&0===o[0]||i.stopBlocking(),o.length){var s=o.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){return i.asyncError(e),Promise.reject(e)})},e.prototype.getViewMode=function(){var e=google.ima.ViewMode;return this.player.getFullscreen()?e.FULLSCREEN:e.NORMAL},e.prototype.waitForPlaybackOnMobile=function(){return this.video&&this.player.utils.isMobile()&&!this.video.__jwMobileCanPlay&&(this.player.isBeforePlay()||0===this.video.currentTime)},e.prototype.prepareToPlayAd=function(){this.destroyed()||this.blockingInstreamPlayer||(clearTimeout(this.timeoutAdStart),this.video&&this.player.utils.isIOS()&&(this.video.controls=!1),this.waitForPlaybackOnMobile()?(this.mobilePlayCallback=this.getMobilePlayCallback(),this.video.addEventListener("play",this.mobilePlayCallback)):this.startBlocking())},e.prototype.muteInstreamProvider=function(){var e=this.video&&this.video.muted||this.player.getMute()||0===this.adsLoaderManager.adsManager.getVolume();this.instreamProvider.mute(e)},e.prototype.getMobilePlayCallback=function(){var e=this,t=function(i){i.currentTarget.removeEventListener("play",t),i.currentTarget.__jwMobileCanPlay=!0,e.mobilePlayCallback=null,e.startBlocking(),e.bidsPromise.then(R).then(function(){e.destroyed()||e.adsLoaderManager.requestAds()})};return t},e.prototype.exitFullscreenOnInlineIOS=function(){this.utils.isIOS()&&(this.utils.isIOS(6)||this.utils.isIOS(7)||this.utils.isIOS(8)||this.utils.isIOS(9)||(this.player.setFullscreen(!1),this.utils.style(this.fullscreenIcon,{display:"none"})))},e.prototype.startBlocking=function(){var e=this;this.blockingInstreamPlayer||this.destroyed()||(this.exitFullscreenOnInlineIOS(),this.options.premiumAds&&this.player.on("viewable",function(t){t.viewable?e.player.play():e.player.pause()},this),this._qoe.tick("adLoading"),this.player.utils.addClass(this.player.getContainer(),"jw-flag-ads-googleima"),this.blockingInstreamPlayer=this.player.createInstream().init(),this.blockingInstreamPlayer.setText("Loading"),this.blockingInstreamPlayer.applyProviderListeners(this.instreamProvider),this.initAdsManagerPromise.then(function(e){e.start()}).catch(function(){}),clearTimeout(this.timeoutAdStart),this.timeoutAdStart=setTimeout(function(){e.destroyed()||(e.stopBlocking(),e.asyncDiscardAdBreak())},1e4))},e.prototype.stopBlocking=function(){this.destroyed()||(this.player.off("viewable",null,this),clearTimeout(this.timeoutAdStart),this.utils.style(this.fullscreenIcon,{display:""}),this.player.utils.removeClass(this.player.getContainer(),["jw-flag-ads-vpaid","jw-flag-ads-googleima"]),this.mobilePlayCallback&&(this.video&&this.video.removeEventListener("play",this.mobilePlayCallback),this.mobilePlayCallback=null),this.blockingInstreamPlayer&&(this.video&&(this.video.setAttribute("jw-loaded","none"),this.video.pause()),this.instreamProvider.off(),this.blockingInstreamPlayer.destroy(),this.blockingInstreamPlayer=null,this.view.adTakeDown()))},e.prototype.resumeRequested=function(){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(){var e=this.adsLoaderManager.adsManager;e&&e.pause()},e.prototype.resume=function(){var e=this.adsLoaderManager.adsManager;e&&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.adsLoaderManager.initializeDisplay(),this.waitForPlaybackOnMobile()||this.bidsPromise.then(R).then(function(){t.destroyed()||t.adsLoaderManager.requestAds()})},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.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),t.resize(n.width,r,this.getViewMode()),this.view.resizeNonLinear(n,r)}else 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(),a=-1,o=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)return void clearInterval(i.progressIntervalId);var h=t.getRemainingTime();if(!(isNaN(h)||h<=0)&&a!==h){a=h;var c=e.getDuration(),p=c-h;if(i.blockingInstreamPlayer){var g=o.replace(s,Math.round(c-p)),f=void 0,m=r.getTotalAds();if(m>1){var v=r.getAdPosition();f=d.replace(l,v),g=f.replace(u,m)+" "+g}i.blockingInstreamPlayer.setText(g)}if(c>0){var y=i.adsLoaderManager.adEventObject(e);y.position=p,y.duration=c,i.trigger("adTime",y)}}},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(C,i)},e.prototype.adImpression=function(e){var t=this,i=e.getAd(),n=i.isLinear(),r=n&&-1===i.getDuration(),a=i.getContentType(),o="application/javascript"===a||"application/x-shockwave-flash"===a,s=n&&o&&this.options.vpaidcontrols;this.currentAd=i,this.adsLoaderManager.bindEvents({COMPLETE:this.adComplete.bind(this)}),o&&this.utils.isMobile()&&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(),"jw-flag-ads-vpaid",n&&(r||o)),this.player.utils.toggleClass(this.player.getContainer(),"jw-flag-ads-vpaid-controls",s),this.view.adSetup(),this.resize(),this.muteInstreamProvider(),clearTimeout(this.timeoutAdStart);var d=this.adsLoaderManager.adsManager;this.progressInterval(i,d);var l=this.adsLoaderManager.adEventObject(i);if("pre"===l.adposition&&(void 0===l.podcount||1===l.sequence)){this._qoe.tick("adImpression");var u=this._qoe.between("adLoading","adImpression");l.timeLoading=u}this.trigger("adImpression",l),this.triggerAdPlay(i,"adPlay","playing","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||t.pause();var r=this.adsLoaderManager.adEventObject(i);this.trigger("adClick",r)},e.prototype.adPaused=function(e){this.paused||(this.paused=!0,this.triggerAdPlay(e.getAd(),"adPause","paused","playing"))},e.prototype.adResumed=function(e){this.paused&&(this.paused=!1,this.triggerAdPlay(e.getAd(),"adPlay","playing","paused"))},e.prototype.adSkipped=function(e){this.adsLoaderManager.unbindEvents(["COMPLETE","VOLUME_CHANGED"]),this.finishAd();var t=this.adsLoaderManager.adEventObject(e.getAd());this.trigger("adSkipped",t)},e.prototype.adUserClose=function(e){if(this.currentAd&&this.currentAd.isLinear()&&-1===this.currentAd.getDuration())return void 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()||(t.stop(),t.destroy(),e.initAdsManagerPromise=null,e.bidsPromise=null)}).catch(function(){})},e.prototype.adLog=function(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("adError",i)}},e.prototype.adError=function(e){var t=e.getError();this.handleAdError(t,e)},e.prototype.asyncError=function(e){var t=this;this.destroyed()||(e&&e.getError?this.adError(e):e.target&&e.target.src?console.error("Failed to load "+e.target.src):console.error(e),this.timeoutAdStart=setTimeout(function(){return t.destroy()},0))},e.prototype.handleAdError=function(e,t){var i=this;this.options.debug&&console.error(e),900===e.getErrorCode()?this.timeoutAdStart=setTimeout(function(){return i.destroy()},0):(this.stopBlocking(),this.view.adTakeDown());var n=this.adsLoaderManager.adErrorEventObject(e,t);this.trigger("adError",n)},e.prototype.destroy=function(){if(this.off(),!this.destroyed()){this.blockingInstreamPlayer&&this.stopBlocking(),this.initAdsManagerPromise&&(this.stopAdsManager(),this.initAdsManagerPromise=null,this.bidsPromise=null),this.item=null,this.bids&&this.bids.stop&&(this.bids.stop(),this.bids=null),this.view.adTakeDown(),clearTimeout(this.timeoutAdStart),clearInterval(this.progressIntervalId),this.currentAd=null,this.options=null,this.player.off(null,null,this),this.player=null,this.view=null,this.instreamProvider.off(),this.instreamProvider.setProxy(null),this.instreamProvider=null,this.video=null;var e=this.adsLoaderManager;e&&(e.reset(),this.adsLoaderManager=null)}},e.prototype.destroyed=function(){return!this.item},e}(),K=function(){function e(t,i){T(this,e),this.player=t,this.options=i}return e.prototype.getAdsResponse=function(e){var t=this,i=this.player,n=i.utils,r=[],a=[],o=[];return n.foreach(w(e,n,i._),function(e,n){var s=n.offset.replace("pre","start").replace("post","end"),d=''.replace(/_type_/g,n.type).replace(/_adbreakname_/g,e).replace(/_offset_/g,s).replace(/_url_/g,v(n.tag,i,t.options,n.custParams));"start"===s?r.push(d):"end"===s?o.push(d):a.push(d)}),''+r.join("")+a.join("")+o.join("")+""},e.prototype.getTagMap=function(e){var t=this,i=this.player,n=i.utils,r={};return n.foreach(w(e,n,i._),function(e,a){var o=y(a.offset,n,i._);i._.isString(o)&&(o=parseFloat(o.replace("pre","0").replace("post","-1"))),i._.isNumber(o)&&(r[o]=v(a.tag,i,t.options))}),r},e.prototype.getTagList=function(e){var t=this,i=this.player,n=i.utils,r=[];return n.foreach(w(e,n,i._),function(e,a){var o=y(a.offset,n,i._);i._.isString(o)&&(o=parseFloat(o.replace("pre","0").replace("post","-1"))),r.push({offset:o,tag:v(a.tag,i,t.options)})}),r},e}(),J=function(){function e(t){T(this,e),this.adsLoader=null,this.adDisplayContainer=null,this.displayInitialized=!1,this.adsRequest=null,this.userRequestContext=null,this.adsManager=null,this.adsManagerEvents={},this.container=t,this.adIds={},this.schedule=null,this.tagMap={},this.playerApi=null}return e.prototype.getVpaidMode=function(e){var t=google.ima.ImaSdkSettings.VpaidMode;return"disabled"===e||"none"===e?t.DISABLED:"enabled"===e?t.ENABLED:t.INSECURE},e.prototype.initializeDisplay=function(){!this.displayInitialized&&this.adDisplayContainer&&(this.adDisplayContainer.initialize(),this.displayInitialized=!0)},e.prototype.contentComplete=function(){if(null!==this.adsRequest){var e=this.adsLoader;e&&e.contentComplete(),this.adsRequest=null}},e.prototype.reset=function(){this.userRequestContext=null,this.contentComplete(),this.schedule=null;var e=this.adsManager;e&&(e.stop(),e.destroy(),this.adsManager=null),this.adsManagerEvents={},this.adIds={},this.tagMap={}},e.prototype.prepare=function(e){var t=this.adsLoader;if(!t){var i=e.getContainer().querySelector("video");this.adDisplayContainer=new google.ima.AdDisplayContainer(this.container,i),t=this.adsLoader=new google.ima.AdsLoader(this.adDisplayContainer)}return t},e.prototype.open=function(e,t,i,n){t.locale&&google.ima.settings.setLocale(t.locale),google.ima.settings.setDisableCustomPlaybackForIOS10Plus(!0);var r=this.prepare(i);this.playerApi=i;var a={requestType:e,vpaidMode:t.vpaidmode,playerVersion:i.version.split("+")[0]};this.userRequestContext=a;var o=t.getSchedule();if(!o)return Promise.reject();var s=new google.ima.AdsRequest,d=i.getSafeRegion(!1);s.linearAdSlotWidth=d.width,s.linearAdSlotHeight=d.height;var l=i.getSafeRegion(!0);s.nonLinearAdSlotWidth=l.width,s.nonLinearAdSlotHeight=l.height,s.setAdWillAutoPlay(i.getConfig().autostart&&!i.utils.isMobile()),s.forceNonLinearFullSlot=n.forceNonLinearFullSlot,this.adsRequest=s;var u=new K(i,n);if("object"==typeof o){var h=u.getTagList(o);1===h.length&&0===h[0].offset&&(o=h[0].tag)}return"string"==typeof o?o=s.adTagUrl=a.adTagUrl=v(o,i,n):(s.adsResponse=a.adsResponse=u.getAdsResponse(o),this.tagMap=u.getTagMap(o)),this.schedule=o,new Promise(function(e,t){r.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR,t,!1),r.addEventListener(google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,e,!1)})},e.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)},e.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},e.prototype.bindEvents=function(e){var t=this,i=google.ima.AdEvent.Type,n=google.ima.AdErrorEvent.Type;Object.keys(e).forEach(function(r){var a=i[r]||n[r],o=t.adsManagerEvents[a];o&&t.adsManager.removeEventListener(a,o),t.adsManager.addEventListener(a,e[r],!1),t.adsManagerEvents[a]=e[r]})},e.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],a=t.adsManagerEvents[r];a&&(t.adsManager.removeEventListener(r,a),delete t.adsManagerEvents[r])})},e.prototype.getAdId=function(e){if(e){var t=e.getAdId(),i=M(e);if(i&&(t=""+i.getTimeOffset()),t)return void 0===this.adIds[t]&&(this.adIds[t]=E(12)),this.adIds[t]}return"-1"},e.prototype.getTag=function(e,t){if("string"==typeof this.schedule)return this.schedule;var i=M(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),"")},e.prototype.adEventObject=function(e){var t={client:"googima",tag:this.getTag(e),ima:{ad:e,userRequestContext:this.userRequestContext}};if(!e)return t;t.id=this.getAdId(e),t.adtitle=e.getTitle(),t.adsystem=e.getAdSystem(),t.creativetype=e.getContentType(),t.linear=e.isLinear()?"linear":"nonlinear",t.viewable=this.playerApi.getViewable();var i=M(e);if(i){var n=i.getTotalAds();n>1&&(t.sequence=i.getAdPosition(),t.podcount=n);var r=i.getTimeOffset(),a="mid";0===r?a="pre":-1===r&&(a="post"),t.adposition=a}return t},e.prototype.adErrorEventObject=function(e,t){return{id:"-1",client:"googima",message:"Ad Error: "+(e.getMessage&&e.getMessage()||e.message),code:e.getVastErrorCode&&e.getVastErrorCode()||900,tag:this.getTag(t.getAd&&t.getAd(),t)}},e}(),Y=function(e,t,n){function r(e,t,i,n){try{return e.getCompanionAds(t,i,n)}catch(e){return[]}}function a(e){if(e&&e.length){var t=document.getElementById(g.companiondiv.id);if(t){var i=e[0];i&&(m.isFunction(i.getContent)?t.innerHTML=i.getContent():t.innerHTML=i.resource||i.content)}}}function o(e){ for(var t=[],i=0;i0}function d(){P&&!P.destroyed()&&(e.off(null,null,P),P.destroy(),P=null)}function l(t){P&&P.discardAdBreak(),A.contentComplete(),d(),t&&t.adschedule?g.adschedule=t.adschedule:g.adschedule=null,e.setCues([])}function u(t,n,r){var a=this;if(l(t),!r.getSchedule())return void R(c).then(function(){A.prepare(e)}).catch(c.noop);A.reset(),P=new Q(t,g,e,b,y,A),P.init(n,r),P.on("all",function(t,i){return e.trigger(t,i)}),P.on(C,function(e){s(e.ima.ad)}),e.once("beforePlay",function(t){if(g.premiumAds){var n=e.getHeight(),r=e.getWidth();if(n<270||r<480)return console.log("Premium Ads: Player size is smaller than 480x270 to play an ad"),void a.destroy();i()<0&&(f=Date.now())}P.beforePlay(t)},P).on("beforeComplete",function(){return P.beforeComplete()},P).on("time",function(e){return P.time(e)},P).on("resize",function(){return P.resize()},P).on("fullscreen",function(){return P.resize()},P)}var h=this,c=e.utils,p=e.getConfig(),g=new S(t||{},c),f=void 0;if(g.premiumAds){if(e.getMute()||p.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 I}()>=I)return console.log("Premium Ads: Page load took too long to start an ad"),void(this.destroy&&this.destroy())}R(c).then(function(){if(f){var e=i();e>=0&&e-f>=I&&(console.log("Premium Ads: IMA SDK load took too long to start an ad"),h.destroy&&h.destroy())}}).catch(c.noop);var m=e._,v=p.key,y=new k(n,e.id,c.style),b=new N(c,e.Events,y),A=new J(y.getAdDiv()),P=null;this.version="7.10.5",e.utils.extend(this,e.Events),e.on("destroyPlugin",function(){h.destroy()}),e.pauseAd=function(e){P&&(e?P.pause():P.resume())},e.playAd=function(i){var n=c.extend({},t);delete n.ad,delete n.tag,delete n.schedule,e._.isArray(i)?n.tag=i[0]:n.tag=i,u({},"TYPE_API",new S(n,c)),P&&P.beforePlay(null)},e.on("playlistItem",function(e){u(e.item,"TYPE_SCHEDULE",g)},this).on("playlistComplete",function(){return l()},this).on("cast",function(e){e.active&&l()},this),j.call(this,c,v).catch(function(t){d(),e.off(null,null,h),e.playAd=c.noop,e.trigger("adError",{id:"-1",client:"googima",message:"Ad Error: "+t.message,code:900,tag:""})}),this.destroy=d};(window.jwplayerPluginJsonp||window.jwplayer().registerPlugin)("googima","7.9",Y)}();