!function(){function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var i=0;i',S.className="jw-vast-nonlinear-open-button",x.className="jw-vast-nonlinear-close-button";var j=function(){function e(i,r,a,s,o){t(this,e),this.player=i,this.environment=i.getEnvironment(),this.div=s,this.staticURL=r,this.clickURL=a,this.loadTimer=-1,this.animationTimer=-1,this.banner=null,n(this,i.Events),this.banner=document.createElement("img"),this.banner.className="jw-banner",this.banner.id=this.player.id+"_vast_static",this.div.appendChild(S),this.div.appendChild(this.banner),this.div.appendChild(x),this.loadTimer=setTimeout(this.imageLoadError.bind(this),o),this.banner.onerror=this.imageLoadError.bind(this),this.banner.onload=this.onLoaded.bind(this),this.banner.src=this.staticURL}return r(e,[{key:"onLoaded",value:function(){if(clearTimeout(this.loadTimer),0!==this.banner.naturalWidth){this.removeBannerEventListeners();var e=this.player.utils;e.addClass(this.div,"jw-vast-nonlinear-active"),e.style(x,{bottom:this.banner.height-8,left:this.banner.width},!0),new e.UI(this.banner).on("click tap",this.sendClick.bind(this)),x.onclick=x.ontouchstart=this.collapse.bind(this),S.onclick=S.ontouchstart=this.expand.bind(this),this.trigger(P)}else this.imageLoadError()}},{key:"imageLoadError",value:function(){clearTimeout(this.loadTimer),this.trigger(A),this.removeBanner()}},{key:"sendClick",value:function(){this.trigger(k)}},{key:"collapse",value:function(e){var t=this;e.preventDefault(),this.player.utils.addClass(this.div,"jw-vast-nonlinear-collapsed"),this.animationTimer=setTimeout((function(){t.remove(t.banner),t.remove(x),t.animationTimer=-1}),250)}},{key:"expand",value:function(e){-1===this.animationTimer&&(e.preventDefault(),this.player.utils.removeClass(this.div,"jw-vast-nonlinear-collapsed"),this.div.appendChild(this.banner),this.div.appendChild(x))}},{key:"remove",value:function(e){this.div.contains(e)&&this.div.removeChild(e)}},{key:"removeBannerEventListeners",value:function(){this.banner.onload=this.banner.onerror=null}},{key:"removeBanner",value:function(){this.removeBannerEventListeners(),this.remove(this.banner)}},{key:"removeListeners",value:function(){clearTimeout(this.loadTimer),clearTimeout(this.animationTimer),x.onclick=x.ontouchstart=S.onclick=S.ontouchstart=null,this.off(),this.removeBannerEventListeners()}},{key:"stop",value:function(){this.player.utils.removeClass(this.div,"jw-vast-nonlinear-active jw-vast-nonlinear-collapsed"),this.removeBanner(),this.remove(x),this.remove(S)}}]),e}(),M=function(){function e(i,r){t(this,e),this.player=i,this.div=r,this.startTime=0,this.minDur=0,this.environment=i.getEnvironment(),n(this,i.Events),this.type="static",i.on("time",this.dispatchTime,this)}return r(e,[{key:"playAd",value:function(e,t,i,r,a){this.minDur=this.player.utils.seconds(i),this.adTag=r,this.static&&(this.static.removeListeners(),this.static.stop()),this.player.utils.addClass(this.div,"jw-vast-nonlinear"),this.static=new j(this.player,e,t,this.div,a),this.static.on(P,this.startAd,this),this.static.on(k,this.clickHandler,this),this.static.on(A,this.errorHandler,this)}},{key:"dispatchTime",value:function(e){this.trigger("time",e)}},{key:"startAd",value:function(){this.startTime=this.player.getPosition(),this.minDur>0&&(0===this.startTime?this.on("time",this.startTimingAd,this):this.on("time",this.timeAd,this)),this.sendEvent(P)}},{key:"startTimingAd",value:function(e){this.startTime=e.position,this.off("time",this.startTimingAd,this),this.on("time",this.timeAd,this)}},{key:"timeAd",value:function(e){e.position-this.startTime>this.minDur&&(this.off("time",this.timeAd,this),this.stop())}},{key:"clickHandler",value:function(){this.sendEvent(k)}},{key:"errorHandler",value:function(){this.sendEvent(A)}},{key:"sendEvent",value:function(e,t){(t=t||{}).tag=t.tag||this.adTag,this.trigger(e,t)}},{key:"removeEvents",value:function(){this.off()}},{key:"getState",value:function(){return y}},{key:"stop",value:function(){this.startTime&&this.static&&(this.startTime=0,this.minDur=0,this.off("time",this.startTimingAd,this),this.off("time",this.timeAd,this),this.static.removeListeners(),this.static.stop(),this.sendEvent(w))}},{key:"pause",value:function(){}}]),e}(),B=/^(https?:\/\/).*.(?:ampproject.org|bing-amp.com)\/(?:.\/)*(.*)\/amp.*$/;var O=new RegExp(/^[^/]*:\/\/\/?([^\/]*)/);function V(e){var t=e.match(O);return t&&t.length>1?t[1]:""}var L,H=new RegExp(/^[^:\/?#]+:?\/\/[^\/?#]+/);function D(){var e,t,i=null!==document.referrer.match(H)?(e=document.referrer,(t=e.match(B))&&t.length>1?"".concat(t[1]).concat(t[2]):e):"";if(window.top!==window.self){try{return{url:window.top.location.href,domain:window.top.document.domain,referrer:i}}catch(e){}return{url:i,domain:V(i),referrer:""}}return{url:document.location.href,domain:document.domain,referrer:i}}function q(e){var t=e.advertising;if(t&&t.placement){var i=t.placement.toLowerCase();if(I[i])return I[i]}return I[t&&t.outstream?_:E]}function N(e,t,i,r){var a=F(e,i,r),s=t.adErrorCode||60900;return n(a,{message:t.message,code:t.code>=100&&t.code<=1008?t.code:900,adErrorCode:s}),10402===s||50004===s||50400===s?a.timeout=i?i.creativeTimeout:r.creativeTimeout:11007!==s&&10301!==s&&60006!==s||(a.timeout=i?i.requestTimeout:r.requestTimeout),void 0!==t.id&&(a.id=t.id),void 0!==t.sourceError&&(a.sourceError=t.sourceError),void 0!==t.tag&&(a.tag=t.tag),void 0!==t.vmap&&(a.vmap=t.vmap),a}function F(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r={client:c};if(null===e)return r;var a=e.bidding,s=e.config,o=e.item,l=e.player;e.isDestroyed()||(r.placement=q(l.getConfig()));var d=i.schedule;if(d)return n(r,{item:o,tag:d.getVMAP(),adbreaks:d.getAllAds().map((function(e){var t={type:e._type,offset:e._offSet};if(e._vmap?t.vmap=e._vmap:t.adbreak=n({},e._adbreak),a){var i=a.getBid(e.adPlayId);i&&n(t,i.getEventObject())}return t}))});if(s.preloadAds&&(r.preloadAds=i.preload||t&&t._preload||!1),i.jwpseg&&(r.jwpseg=i.jwpseg),t){var u=e.getAdIds(t,i),h=u.adBreakId,p=u.adPlayId;if(n(r,{adBreakId:h,adPlayId:p,offset:t._offSet}),a){var v=a.getBid(p);v&&n(r,v.getEventObject())}}var f=t&&(i.tag||t._currentTag);if(f&&(n(r,{id:t._id,tag:f,adposition:t._position,sequence:t._adPodIndex+1,witem:t._waterfallIndex+1,wcount:t._adQueue?t._adQueue.length:1,adsystem:t.adsystem||""}),t.adServingId&&(r.adServingId=t.adServingId),void 0!==t.skipoffset&&(r.skipoffset=t.skipoffset),t.wrappedTags&&n(r,{wrapperAdSystem:t.wrapper||"",wrappedTags:t.wrappedTags.slice(1)}),t._adbreak&&(r.adschedule=t._adbreak,r.adschedule.offset=t._offSet)),t&&t.companions&&i.companions)return r.companions=i.companions,r;if(t&&t.response){var m=e.params;n(r,{adtitle:t.adTitle||"",description:t.description||"",adId:t.adId||"",advertiser:t.advertiser||"",advertiserId:t.advertiserId||"",creativeId:t.creativeId||"",creativeAdId:t.creativeAdId||"",dealId:t.dealId||"",request:t.request,response:t.response,conditionalAd:t.conditionalAd,conditionalAdOptOut:m.conditionaladoptout,vastversion:t.vastversion,clickThroughUrl:t.clickthrough,duration:i.duration,linear:i.linear}),"boolean"==typeof t.mediaFileCompliance&&(r.mediaFileCompliance=t.mediaFileCompliance,t.nonComplianceReasons&&(r.nonComplianceReasons=t.nonComplianceReasons)),t.selectedMedia&&(r.mediafile={file:t.selectedMedia.file}),i.metadata&&(r.adMessage=m.dynamicMessage||"",t.companions&&(r.companions=t.companions),t.sequence&&(r.podMessage=m.podMessage||""),void 0!==t.skipoffset&&n(r,{skipMessage:m.skipMessage,skipText:m.skipText}))}else r.item=o;return r}function U(e){return e.isBeforePlay()||0===e.getPosition()&&"idle"===e.getState()?"pre":e.isBeforeComplete()||e.getPosition()===e.getDuration()?"post":"mid"}var Q="vast",X="googima",W="shared",z=1e3,G=4096,$="[ERRORCODE]",J="vmap",Y="-1",K="cust_params=",Z=5e3,ee=5e3,te="adBreakIgnored",ie="__jwpseg__",re="instream",ae="article",ne=(a(L={},[re],1),a(L,["banner"],2),a(L,[ae],3),a(L,["feed"],4),a(L,["floating"],5),a(L,["interstitial"],5),a(L,["slider"],5),L),se="inference",oe=new RegExp(/^[^/]*:\/\/\/?([^\/]*)/);function le(e){var t=e.match(oe);return t&&t.length>1?t[1]:""}var de=new RegExp(/^[^:\/?#]+:?\/\/[^\/?#]+/);var ue=/^(https?:\/\/).*.(?:ampproject.org|bing-amp.com)\/(?:.\/)*(.*)\/amp.*$/;var he=null,ce={gdprApplies:!0,consentData:""},pe=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e3;return null===he&&(he=new Promise((function(e){var t=window.__tcfapi||ve("__tcfapi");if(t)return t("getTCData",2,(function(t,i){e(!1!==i?{gdprApplies:t.gdprApplies,consentData:t.tcString}:null)}));var i=window.__cmp||ve("__cmp");return i?i("getConsentData",null,(function(t,i){e(!1!==i?{gdprApplies:t.gdprApplies||t.isUserInEu,consentData:t.consentData}:null)})):e({gdprApplies:!1,consentData:""})})).then((function(e){return e&&(ce=e),ce}))),Promise.race([he,new Promise((function(t){setTimeout(t,e,ce)}))])},ve=function(e){var t=function(e){for(var t=window;t;){try{if(t.frames[e])break}catch(e){}t=t===window.top?null:t.parent}return t}("".concat(e,"Locator"));return null!==t&&function(i,r,n,s){var o=fe();window.addEventListener("message",(function t(i){var r=i?i.data:{};if("string"==typeof r)try{r=JSON.parse(r)}catch(e){r={}}var a="".concat(e,"Return");r[a]&&r[a].callId===o&&(removeEventListener("message",t),n(r[a].returnValue,r[a].success))}),!1);var l=void 0!==s?"version":"parameter",d=a({},["".concat(e,"Call")],a({command:i,callId:o,parameter:s},[l],r));t.postMessage(JSON.stringify(d),"*")}},fe=Date.now||function(){return(new Date).getTime()};function me(e){var t=e.advertising;if(t&&t.placement){var i=t.placement.toLowerCase();if(ne[i])return ne[i]}return ne[t&&t.outstream?ae:re]}function ye(){var e,t,i=null!==document.referrer.match(de)?(e=document.referrer,(t=e.match(ue))&&t.length>1?"".concat(t[1]).concat(t[2]):e):"";if(window.top!==window.self){try{return{url:window.top.location.href,domain:window.top.document.domain,referrer:i}}catch(e){}return{url:i,domain:le(i),referrer:""}}return{url:document.location.href,domain:document.domain,referrer:i}}function ge(e,t){var i,r=e.getPlugin(se),a=t.jwpseg_client_side,n=t.jwpseg||[];if(!a||!a.length||!r)return n;try{i=r.predict(a,t)}catch(e){return t.jwpseg||[]}var s=Object.keys(i).filter((function(e){return i[e]})),o=n.filter((function(e){return-1===a.indexOf(e)}));return[].concat(u(s),u(o))}function ke(e,t,i){var r=Pe(e,t,i);return n(r,{message:"Ad Error: bidding plugin failed to load",code:900,adErrorCode:60008}),r}function Pe(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r={client:e.client},a=e.bidding,s=e.item,o=e.player;if(e.isDestroyed()||n(r,{placement:me(o.getConfig()),viewable:o.getViewable()}),i.jwpseg&&(r.jwpseg=i.jwpseg),t){var l=e.getAdIds(t,i),d=l.adBreakId,u=l.adPlayId;if(n(r,{adBreakId:d,adPlayId:u,offset:t._offSet}),a){var h=a.getBid(u);h&&n(r,h.getEventObject())}}return r.item=s,r}var Ae=/^((https?:)?\/\/)?(secure)?pubads\.g\.doubleclick\.net\/gampad\/ads\?[\S]*$/;function we(e,t,i,r,a){var n=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};if(!e)return Promise.resolve(e);var s=function(e,t){var i=e.getConfig(),r=e.getPlaylistItem()===t;return{playerHeight:e.getHeight()||i.height||"",playerWidth:e.getWidth()||i.width||"",itemDuration:r?(a=e.getDuration(),n=3,s=Math.pow(10,n),Math.round(a*s)/s||""):"",item:t,jwpseg:ge(e,t),placement:me(i),userAgent:navigator.userAgent};var a,n,s}(t,i),o=ye();-1!==e.indexOf(ie)&&(n.jwpseg=s.jwpseg),e=be(e,"__random-number__",Math.random()*Math.pow(10,18)),e=be(e,"__timestamp__",(new Date).getTime()),e=be(e,"__page-url__",encodeURIComponent(o.url)),e=be(e,"__referrer__",encodeURIComponent(o.referrer)),e=be(e,"__player-height__",s.playerHeight),e=be(e,"__player-width__",s.playerWidth),e=be(e,"__item-duration__",s.itemDuration),e=be(e,ie,s.jwpseg),e=be(e,"__domain__",encodeURIComponent(o.domain)),e=be(e,"__placement__",s.placement),e=be(e,"__device-ua__",encodeURIComponent(s.userAgent));for(var l=null,d=/__item-([\w-]+?)(-list)?__/g,u=e=a.companion?be(e,"__companion-div__",a.companion.id):be(e,"__companion-div__","");null!==(l=d.exec(u));){var h=l[0],c=l[1],p="";if(i.hasOwnProperty(c)&&"string"==typeof i[c]){p=i[c];var v=!1===a.truncateMacros?G:z;p.length>v&&(p=p.substring(0,v));var f=l[2]?",":null;p=p.split(f).map(encodeURIComponent)}e=be(e,h,p)}if(r===Q){var m=t.getConfig().autostart?1:0,y=t.getMute()?1:0;e=function(e,t,i){Ae.test(e)&&(e="".concat(e,"&vpa=").concat(t,"&vpmute=").concat(i));return e}(e,m,y)}if(r===X&&i.title&&-1===e.indexOf("vid_t=")){var g=i.title.substring(0,100).replace(/[^\x00-\x7F]/g,"");e+=function(e){return-1!==e.indexOf("?")?"&":"?"}(e)+"vid_t="+encodeURIComponent(g)}return-1!==e.indexOf("__gdpr__")||-1!==e.indexOf("__gdpr_consent__")?pe().then((function(t){var i=t.gdprApplies,r=t.consentData;return e=be(e,"__gdpr__",i?1:0),be(e,"__gdpr_consent__",r)})).catch((function(){return e})):Promise.resolve(e)}function be(e,t,i){return e.replace(t,i)}var Te=Array.prototype,Ee=Te.forEach,_e=Te.map,Ie=function(){};function Ce(e,t,i){if(Be(e,"VMAP",J).length)return function(e,t,i){var r=[];Le(Be(e,"VMAP",J)[0],"version")||xe(r,"VMAP Schema Error: version missing from VMAP tag",Y);var a=Be(e,"AdBreak",J);a.length||je();for(var n=e.lookupNamespaceURI(J),s=0;s4.2||t<2)&&this.throwError(102,"Vast version not supported"),t>=4&&(r.conditionalAd=!!Le(i,"conditionalAd")),u?(Ne(u,"Impression",(a=function(e,t,i){var r=Be(Oe(e,"Creatives"),"Creative"),a={},n={trackers:a};n.adServingId=De(Oe(e,"AdServingId")),n.adsystem=De(Oe(e,"AdSystem"));var s=Be(e,"Category");return n.categories=_e.call(s,(function(e){return De(e)})),Ee.call(r,(function(e){var r=Oe(e,"Linear"),s=Oe(e,"NonLinear"),o=Be(Oe(e,"TrackingEvents"),"Tracking");if(t>=4){var l=Be(e,"UniversalAdId");n.universalAdId=_e.call(l,(function(e){return{universalAdIdRegistry:Le(e,"idRegistry")||"unknown",universalAdIdValue:De(e)||Le(e,"idValue")||"unknown"}}))}n.creativeId=Le(e,"id"),n.creativeAdId=Le(e,"adId"),(r||s)&&Ee.call(o,(function(e){He(a,e)}));var d=De(Oe(e,"AdParameters"));if(d&&(n.adParams=d),r){var u=Oe(r,"VideoClicks"),h=De(Oe(u,"ClickThrough")),c=Be(u,"ClickTracking"),p=Le(r,"skipoffset"),v=De(Oe(r,"Duration"));Ee.call(c,(function(e){qe(a,"click",De(e))})),v&&(n.duration=i.seconds(v)),h&&(n.clickthrough=h),void 0!==p&&(n.skipoffset=p),function(e,t){var i=Be(Oe(e,"MediaFiles"),"MediaFile"),r=t.media?t.media:[];t.media=r.concat(_e.call(i,(function(e){return{type:Le(e,"type"),file:De(e),adType:Le(e,"apiFramework")||"",width:parseInt(Le(e,"width"),10)||0,height:parseInt(Le(e,"height"),10)||0,bitrate:parseInt(Le(e,"bitrate"),10)||null,maxBitrate:parseInt(Le(e,"maxBitrate"),10)||null}})).filter((function(e){return e.file})))}(r,n),function(e,t){var i=Be(e,"Icon");t.icons=Array.prototype.reduce.call(i,(function(e,t){var i,r;if(i=Oe(t,"StaticResource"))r=Le(i,"creativeType");else if(i=Oe(t,"IFrameResource"))r="iframe";else{if(!(i=Oe(t,"HTMLResource")))return e;r="html"}var a=De(i),n={};n.iconClick=De(Oe(t,"IconClickTracking"))||null,n.iconView=De(Oe(t,"IconViewTracking"))||null;var s=Le(t,"xPosition").toLowerCase(),o=Le(t,"yPosition").toLowerCase(),l={};return"left"===s||"right"===s?l[s]=0:l.left=parseInt(s,10)||0,"top"===o||"bottom"===o?l[o]=0:l.top=parseInt(o,10)||0,l.width=parseInt(Le(t,"width"),10)||0,l.height=parseInt(Le(t,"height"),10)||0,e.push({program:Le(t,"program"),style:l,apiFramework:Le(t,"apiFramework"),offset:Le(t,"offset")||"00:00:00",duration:Le(t,"duration")||null,clickThrough:De(Oe(t,"IconClickThrough")),trackers:n,resource:{resourceType:r,resourceSource:a}}),e}),t.icons||[])}(r,n)}else if(s){var f=De(Oe(s,"NonLinearClickThrough"));f&&(n.clickthrough=f),function(e,t){var i=[],r=Oe(e,"StaticResource");r&&(i.push({type:Le(r,"creativeType"),file:De(r),adType:Le(Oe(e,"NonLinear"),"apiFramework")||"static",minDuration:Le(Oe(e,"NonLinear"),"minSuggestedDuration")||"00:00:00"}),t.media=i)}(e,n)}else!function(e,t){var i=Be(Oe(e,"CompanionAds"),"Companion"),r=t.companions?t.companions:[];Ee.call(i,(function(e){var t,i,a=Oe(e,"StaticResource"),n=Oe(e,"IFrameResource"),s=Oe(e,"HTMLResource"),o={};if(a)t=Le(a,"creativeType"),i=De(a);else if(n)t="iframe",i=De(n);else{if(!s)return;t="html",i=De(s)}var l=Be(Oe(e,"TrackingEvents"),"Tracking");Ee.call(l,(function(e){var t=Le(e,"event");qe(o,t,De(e))}));var d=De(Oe(e,"CompanionClickThrough"));r.push({width:parseInt(Le(e,"width"),10),height:parseInt(Le(e,"height"),10),type:t,source:i,trackers:o,clickthrough:d})})),t.companions=r}(e,n)})),n}(u,t,this.utils)).trackers),Ne(u,"Error",a.trackers),Ne(u,"NotViewable",a.trackers),Ne(u,"Viewable",a.trackers),function(e){var t={};e.media&&e.media.forEach((function(e){var i=e.type,r="application/x-mpegURL"===i||"vnd.apple.mpegURL"===i;"vpaid"===e.adType.toLowerCase()||r||(t[i]=t[i]||0,t[i]++)}));e.mediaFileCompliance=!0,Object.keys(t).forEach((function(i){var r=t[i];r<3&&(e.mediaFileCompliance=!1,e.nonComplianceReasons=e.nonComplianceReasons||[],e.nonComplianceReasons.push("".concat(i," has only ").concat(r," qualities")))}))}(a),d&&(a.wrappedURI=De(Oe(d,"VASTAdTagURI"))||De(Oe(d,"VASTAdTagURL")),a.followAdditionalWrappers=JSON.parse(Le(d,"followAdditionalWrappers")),a.allowMultipleAds=JSON.parse(Le(d,"allowMultipleAds")),a.fallbackOnNoAd=JSON.parse(Le(d,"fallbackOnNoAd"))),s=a,o=n({},r),Object.keys(s).forEach((function(t){var i=s[t];Array.isArray(o[t])?o[t]=o[t].concat(i):"object"===e(o[t])&&null!==o[t]?o[t]=n(o[t],i):o[t]=i})),a=o):this.throwError(303,"No ads",10303),a}},{key:"throwError",value:function(e,t,i){throw this._error=new Error(t),this._error.code=e,this._error.adErrorCode=i||1e4+e,this._error}}]),i}();function Be(e,t,i){var r=[];return e&&(r=e.getElementsByTagName(t),i&&r&&0===r.length&&(r=e.getElementsByTagName("".concat(i,":").concat(t)))),r}function Oe(e,t){if(e){var i=e.getElementsByTagName(t);if(i)return i[0]}return null}function Ve(e,t,i,r){var a=[];return e||t?a=t.getElementsByTagNameNS?t.getElementsByTagNameNS(e,i):t.getElementsByTagName("".concat(r,":").concat(i)):a}function Le(e,t){return e?e.getAttribute(t):null}function He(e,t){var i=Le(t,"event");if("progress"===i){var r=Le(t,"offset");i="".concat(i,"_").concat(r)}qe(e,i,De(t))}function De(e){if(e){var t=e.textContent||e.text;if(t)return t.trim()}return""}function qe(e,t,i){e[t]||(e[t]=[]),i&&(e[t].push(i),Fe(i))}function Ne(e,t,i){var r=Be(e,t);_e.call(r,(function(e){qe(i,t.toLowerCase(),De(e))}))}var Fe=function(e){(e.indexOf("[REGULATIONS]")>=0||e.indexOf("[GDPRCONSENT]")>=0)&&(pe().catch(Ie),Fe=Ie)};function Ue(e){e.onload=e.onreadystatechange=e.onerror=null,"abort"in e&&e.abort()}var Qe=function(){function e(i,r){t(this,e),this.adRules=i,this.utils=r,this.preRoll=null,this.vmap=null,this.postRoll=null,this.midRolls=[],this.playedMidRolls=[],this.duration=0,this._vmapPromise=null,this._vmapXHR=null}return r(e,[{key:"load",value:function(e,t,i,r){var a=this;if(this._vmapPromise)return this._vmapPromise;null!==this._vmapXHR&&(Ue(this._vmapXHR),this._vmapXHR=null);var s=we(this.getVMAP(),e,t,i,r);return this._vmapPromise=s.then((function(t){return new Promise((function(i,n){a._vmapXHR=e.utils.ajax({url:t,withCredentials:r.withCredentials,retryWithoutCredentials:!0,requireValidXML:!0,timeout:a.requestTimeout},i,(function(e,t,i,r){return n(r)}))})).then((function(i){return a._vmapXHR=null,Ce(i.responseXML,a,e.utils).map((function(e){return n(e,{vmap:t})}))})).catch((function(i){a._vmapXHR=null;var r={id:Y,vmap:t};if(i.message)n(r,{message:"VMAP Schema Error: ".concat(i.message),code:1002,adErrorCode:i.adErrorCode||11002});else{var s={1:{code:1007,message:"Timeout"},602:{code:1e3,message:"Invalid XML"},default:{code:1008,message:e.getConfig().localization.errors[i.key]}},o=s[i.code]||s.default;e.utils.log(o.message),n(r,{message:"Error Loading VMAP Schedule",code:o.code,adErrorCode:o.code+1e4})}throw r}))})),this._vmapPromise}},{key:"canWaterfall",value:function(e){return e._adQueue&&e._waterfallIndex+1t)return null;this.sort(i);for(var r=this.midRolls.length;r--;){var a=this.midRolls[r],n=We(this.midRolls[r]._offSet,i);if(e>=n)return null;if(t>=n){var s=Xe(a,this.requestTimeout,this.creativeTimeout);if(!this.adRules.timeBetweenAdsAllowsAdPlayback(s))return null;if(!this.adRules.timeBetweenAds){if(this.playedMidRolls.indexOf(r)>=0)return null;this.playedMidRolls.push(r)}return r}}return null}},{key:"peek",value:function(e,t,i){if(this.midRolls.length>this.playedMidRolls.length){this.sort(i);for(var r=0;this.midRolls[r];){var a=We(this.midRolls[r]._offSet,i);if(a>=e&&-1===this.playedMidRolls.indexOf(r)){var n=fe()+1e3*(a-e);return a<=t&&this.adRules.timeBetweenAdsAllowsAdPlayback(null,n)?r:null}r+=1}}var s=fe()+1e3*(i-e);return this.postRoll&&t>=i&&this.adRules.timeBetweenAdsAllowsAdPlayback(null,s)?-1:null}},{key:"getNextMidrollIndex",value:function(e,t,i){if(this.adRules.timeBetweenAds||this.adRules.startOnSeek)return this.getLastMidRollIndexBetweenTime(e,t,i);if(this.midRolls.length>this.playedMidRolls.length){var r=this.getClosestIndex(t,i);if(r>=0&&this.playedMidRolls.indexOf(r)<0)return this.playedMidRolls.push(r),r}return null}},{key:"getMidRolls",value:function(){var e=this;return this.midRolls.map((function(t){return Xe(t,e.requestTimeout,e.creativeTimeout)}))}},{key:"reset",value:function(){null!==this._vmapXHR&&(Ue(this._vmapXHR),this._vmapXHR=null),this.playedMidRolls=[],this.duration=0}},{key:"setPreRoll",value:function(e){this.resetBreakId(e),this.preRoll=e}},{key:"addMidRoll",value:function(e){this.resetBreakId(e),this.midRolls.push(e),this.duration=0}},{key:"setPostRoll",value:function(e){this.resetBreakId(e),this.postRoll=e}},{key:"sort",value:function(e,t){(!e||e<1)&&(e=1),(this.duration!==e||t)&&(this.duration=e,this.midRolls.sort((function(t,i){return We(t._offSet,e)-We(i._offSet,e)})),function(e,t){for(var i=0;i=We(this.midRolls[i]._offSet,t))return i;return-1}},{key:"resetBreakId",value:function(e){e.adBreakId=this.utils.genId(12)}},{key:"resetAllBreakIds",value:function(){var e=this;this.getAllAds().forEach((function(t){e.resetBreakId(t)}))}}]),e}();function Xe(e,t,i){var r;if(null!==e)return Object.keys(e).forEach((function(t){var i=e[t];(r=r||{})[t]="_adQueue"===t||"_pod"===t?i.slice():i})),r?(r.requestTimeout=t,r.creativeTimeout=i,r._errors=[],r._waterfallIndex=0,r._adPodIndex=0,r):void 0}function We(e,t){return"%"===e.toString().slice(-1)?t*parseFloat(e.slice(0,-1))/100:parseFloat(e)}var ze=function(){function e(i){t(this,e),this.utils=i}return r(e,[{key:"getSchedule",value:function(e,t){var i=new Qe(t,this.utils);if(i.requestTimeout=$e(e.requestTimeout,Z),i.creativeTimeout=$e(e.creativeTimeout,ee),e.tag)i.setPreRoll({_offSet:"pre",_adQueue:Ge(e.tag),_waterfallIndex:0});else if("string"==typeof e.vastxml)i.setPreRoll({_offSet:"pre",_adXML:e.vastxml});else{if("string"==typeof e.schedule)return i.setVMAP(e.schedule),i;if("string"==typeof e.adschedule)return i.setVMAP(e.adschedule),i;!function(e,t,i){var r=t.schedule||t.adschedule;if(!r)return;var a={};Object.keys(r).forEach((function(e){var t=r[e];t.ad&&(n(t,t.ad),delete t.ad);var s=function(e,t){if("start"===e||"0%"===e||!e&&0!==e)return"pre";if("end"===e||"100%"===e)return"post";if("pre"===e||"post"===e||(e+"").indexOf("%")>=0)return e;var i=t.seconds(e);if("number"==typeof i)return i;return!1}(t.offset,i),o=$e(t.requestTimeout,Z),l=$e(t.creativeTimeout,ee),d=a[s];if(d){if("nonlinear"===t.type)return;"nonlinear"===d._type&&(d=null)}var u=a[s]=d||{_offSet:s,_type:t.type,_breakId:e,adBreakId:i.genId(12),requestTimeout:o,creativeTimeout:l};!1===s&&i.log("Error: ad offset format not supported",s);var h=t.skipoffset;if(void 0!==h&&void 0===u.skipoffset&&(u.skipoffset=h),"string"==typeof t.adm)u.adm=t.adm;else if(t.pod){var c=u._pod||[];u._pod=c.concat(t.pod)}else if(t.tag){var p=function(e,t){if(!t)return e;var i=e.indexOf("?")>=0?"&":"?",r=e.indexOf(K),a=K.length,n="",s="";if(Object.keys(t).forEach((function(e){var i=t[e];n="".concat(n).concat(s).concat(e,"=").concat(i),s="&"})),n=encodeURIComponent(n),r>=0){var o=e.substr(0,r+a),l=e.substr(r+a);return"".concat(o).concat(n,"%26").concat(l)}return"".concat(e).concat(i).concat(K).concat(n)}(t.tag,t.custParams);u._adQueue&&(u._pod=[u._adQueue[0]],delete u._adQueue),u._pod?u._pod.push(Ge(p)[0]):u._adQueue=Ge(p)}else{if("string"!=typeof t.vastxml)return void i.log("Error: no ad tag provided");u._adXML=t.vastxml}})),Object.keys(a).forEach((function(i){var r=a[i];switch(r.skipoffset=void 0!==r.skipoffset?r.skipoffset:t.skipoffset,i){case"pre":e.setPreRoll(r);break;case"post":e.setPostRoll(r);break;default:e.addMidRoll(r)}}))}(i,e,this.utils)}return i.sort(),i}},{key:"getOptParams",value:function(e,t){var i={cuetext:t.cuetext,dynamicMessage:t.admessage,loadingAd:t.loadingAd,podMessage:t.podmessage,skipoffset:e.skipoffset,skipMessage:t.skipmessage,skipText:t.skiptext,vpaidcontrols:e.vpaidcontrols||!1,conditionaladoptout:e.conditionaladoptout||!1,requestFilter:e.requestFilter,trackingFilter:e.trackingFilter,withCredentials:void 0===e.withCredentials||e.withCredentials},r=e.companiondiv;return r&&(i.companion={id:r.id,height:r.height,width:r.width}),i}},{key:"getAdRules",value:function(e){var t=e.rules||{},i=parseInt(t.frequency,10);return{startOn:t.startOn||1,frequency:isNaN(i)?1:i,timeBetweenAds:t.timeBetweenAds||0,startOnSeek:t.startOnSeek||null,deferAds:t.deferAds||null}}}]),e}();function Ge(e){return Array.isArray(e)?e.slice(0):[e]}function $e(e,t){return 0===e?1/0:e||t}var Je=function(){function e(i,r){t(this,e),this.player=i,this.options=r,this.client=r.client,this.ignoreStartOnSeek=!1,this.reset(),r.timeBetweenAds&&i.on({adBreakStart:this.handleAdBreakStart,adSkipped:this.handleAdSkipped,adComplete:this.handleAdComplete,adBreakEnd:this.handleAdBreakEnd,destroyPlugin:this.destroy},this)}return r(e,[{key:"shouldDeferAds",value:function(){return this.options.deferAds&&!this.player.getConfig().activeTab}},{key:"clearStartOnSeek",value:function(){this.ignoreStartOnSeek=!0}},{key:"sendAdBreakIgnored",value:function(e,t){e&&this.player.trigger(te,function(e,t){var i={};return e&&(i={id:e._breakId,tag:e._adQueue&&e._adQueue.length>0?e._adQueue[0]:e._adXML,offset:e._offSet}),n(i,{timeSinceLastAd:t,type:te})}(e,t,this.client))}},{key:"rulesAllowAdPlayback",value:function(e){var t=this.options,i=0===t.frequency&&1===e,r=e>=t.startOn&&(e-t.startOn)%t.frequency==0;return i||r}},{key:"handleAdBreakStart",value:function(){this.adSkipped=!1,this.adComplete=!1}},{key:"handleAdComplete",value:function(){this.adComplete=!0}},{key:"handleAdSkipped",value:function(){this.adSkipped=!0}},{key:"handleAdBreakEnd",value:function(){!this.adSkipped&&this.adComplete&&(this.recentCompletedAdTime=fe())}},{key:"timeBetweenAdsAllowsAdPlayback",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:fe();if(this.options.timeBetweenAds){var i=(t-this.recentCompletedAdTime)/1e3;if(i0&&void 0!==arguments[0]?arguments[0]:null,i=arguments.length>1?arguments[1]:void 0;if(this.schedule.isVMAP()&&(i.requestTimeout=this.schedule.requestTimeout,i.creativeTimeout=this.schedule.creativeTimeout,this.vmapPromise=this.schedule.load(this.player,this.item,this.client,i)),this.bidsPromise=this.vmapPromise||Promise.resolve(),this.bidsPromise=null!==t?this.bidsPromise.then((function(){if(!e.isDestroyed()){if(e.bidding)return e.createBidsPromise(t,i);var r=ke(e,null,i);e.player.trigger("adError",r)}})).catch(Ye):this.bidsPromise.catch(Ye),this.config.preloadAds)if(1===i.playlistItemEventCount){var r=this.player.getConfig().autostart;!1===r||"viewable"===r&&0===this.player.getViewable()?this.loadPreroll(i).catch((function(t){return e.isDestroyed()?null:e.enqueueAdEvent("adError",t,{preload:!0})})):this.player.once("autostartNotAllowed",(function(){e.loadPreroll(i).catch((function(t){return e.isDestroyed()?null:e.enqueueAdEvent("adError",t,{preload:!0})}))}))}else i.preloadPreroll&&this.loadPreroll(i).catch((function(t){return e.isDestroyed()?null:e.enqueueAdEvent("adError",t,{preload:!0})}));return this.bidsPromise}},{key:"createBidsPromise",value:function(e,t){var i=this,r=this.player,a=parseInt(e.bidOnBreaks,10);return a=a>0?a:1/0,this.bids=this.schedule.getAllAds().slice(0,a).map((function(a){var s=i.getAdIds(a).adPlayId,o=r.getConfig(),l=i.config.skipoffset,d=null!=l&&l>=0,u=ge(r,i.item),h={id:s,offset:e.offset,jwpseg:u,placement:me(o),tag:a._adQueue?a._adQueue[0]:a._currentTag};i.client===Q&&(h.skipoffset=d?l:-1);var c=i.bidding.createNewBid(h,{getURLParts:ye});i.player.trigger("adBidRequest",Pe(i,a,n({jwpseg:u},t))),c.init();var p=c.start().then((function(e){var r=e.result;if(!i.isDestroyed()){var n=Promise.resolve();return r&&!r.error&&(a.jwpseg=u,r.adm?(a._adXML=r.adm,a._adQueue&&a._adQueue.length&&a._adQueue.unshift(r.adm)):r.tag&&(n=we(r.tag,i.player,i.item,i.client,{},a).then((function(e){a._adQueue=a._adQueue||[],a._adQueue.unshift(e)})))),i.player.trigger("adBidResponse",Pe(i,a,t)),n}}));return i.bidsPromises.push(p),c})),Promise.all(this.bidsPromises)}},{key:"checkPreroll",value:function(e){var t=this;if(this.bidTimeoutStarted||(this.bidTimeoutStarted=!0,this.bids.forEach((function(e){return e.timeout()}))),!(this.casting||this.preRollPlayed||this.adRules.shouldDeferAds())){this.preRollPlayed=!0;var i=(e||{}).startTime||this.player.getPosition();this.lastTimeEvent=i||this.lastTimeEvent;var r=this.schedule.getPreRoll(i);if(r||this.vmapPromise){(null!==this.vmapPromise||r&&"nonlinear"!==r._type)&&this.startBlocking(),this.bidsPromise.then((function(){if(!t.isDestroyed()){var e=t.schedule.getPreRoll(i);e&&"nonlinear"!==e._type&&t.triggerAdBreakEvents(e,"pre")}})),i?"none"===this.adRules.startOnSeek&&(this.prerollPromise=null):this.adRules.clearStartOnSeek();var a=e&&e.playReason?e.playReason:"external";this.playPreroll({adBlock:this.adBlockErrorDetected,startTime:i,reason:a})}}}},{key:"checkMidrolls",value:function(e){var t=this;if(!this.casting&&0!==e.duration&&!this.adRules.shouldDeferAds()){var i=this.schedule.getNextMidrollIndex(this.lastTimeEvent,e.position,e.duration);if(this.lastTimeEvent=e.position,null!==i){var r=this.schedule.getMidRollAtIndex(i);"nonlinear"!==r._type&&(this.startBlocking(),this.triggerAdBreakEvents(r,"mid")),this.playMidrollAtIndex(i,{adBlock:this.adBlockErrorDetected})}else if(!this.preRollPlayed&&this.schedule.getClosestIndex(e.position,e.duration)<0)this.checkPreroll(e);else if(this.config.preloadAds){var a=e.position+5,n=this.schedule.peek(e.position,a,e.duration);if(null!==n&&n>=0)this.loadMidrollAtIndex(n,{adBlock:this.adBlockErrorDetected,preload:!0}).catch(Ye);else if(-1===n){var s=fe()+1e3*(e.duration-e.position);this.loadPostroll({adBlock:this.adBlockErrorDetected,preload:!0,startTime:s}).catch(Ye)}else if(null===this.next&&null===this.nextPlaylistItemPromise&&a>e.duration){var o=this.player.getPlaylistIndex()+1,l=this.player.getPlaylistItem(o);if(this.nextPlaylistRelated=!!this.relatedNextUp,l||this.relatedNextUp){var d=this.relatedNextUp?-1:o;this.nextPlaylistItemPromise=Promise.resolve(this.player.getPlaylistItemPromise(d)).then((function(){t.isDestroyed()||(t.trigger("preloadNext",{item:t.player.getPlaylistItem(o)||t.relatedNextUp,index:d}),t.relatedNextUp=null,t.nextPlaylistItemPromise=null)})).catch(Ye)}}}}}},{key:"checkPostrolls",value:function(e){if(!(this.casting||this.adRules.shouldDeferAds()||this.isDestroyed())){var t=this.schedule.getPostRoll();t&&("nonlinear"!==t._type&&(this.startBlocking(),this.triggerAdBreakEvents(t,"post")),this.playPostroll(e))}}},{key:"getAdIds",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t.tagIndex,r=t.podIndex,a=e.adRequestIds&&void 0!==i?e.adRequestIds[i]:null;if(!a){var n=r||e._adPodIndex||0,s="p".concat(n,"w").concat(e._waterfallIndex||0);"p0w0"===s?a=e.adBreakId:(e.adPlayIds=e.adPlayIds||{},a=e.adPlayIds[s]=e.adPlayIds[s]||this.player.utils.genId(12))}return{adBreakId:e.adBreakId,adPlayId:a}}},{key:"loadPreroll",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.prerollPromise||(this.prerollPromise=this.bidsPromise.then((function(){if(!e.isDestroyed()){var i=e.schedule.getPreRoll(t.startTime);return i?(i._position="pre",i._preload=!0,e.loadAd(i,t)):void 0}}))),this.prerollPromise}},{key:"loadMidrollAtIndex",value:function(e,t){var i=this;return this.midrollPromise[e]||(this.midrollPromise[e]=this.bidsPromise.then((function(){if(!i.isDestroyed()){var r=i.schedule.getMidRollAtIndex(e);return r?(r._position="mid",r._preload=!0,i.loadAd(r,t)):void 0}}))),this.midrollPromise[e]}},{key:"loadPostroll",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.postrollPromise||(this.postrollPromise=this.bidsPromise.then((function(){if(!e.isDestroyed()){var i=e.schedule.getPostRoll(t.startTime);return i?(i._position="post",i._preload=!0,e.loadAd(i,t)):void 0}}))),this.postrollPromise}},{key:"playPreroll",value:function(e){var t=this;this.prerollPromise?this.playPreloadedPromise(this.prerollPromise,e):this.bidsPromise.then((function(){var i=t.schedule.getPreRoll();i?(i._position="pre",t.startAdBreak(i,e)):t.stopBlocking()}))}},{key:"playMidrollAtIndex",value:function(e){var t=this;this.midrollPromise[e]?this.playPreloadedPromise(this.midrollPromise[e]):this.bidsPromise.then((function(){var i=t.schedule.getMidRollAtIndex(e);i&&(i._position="mid",t.startAdBreak(i))}))}},{key:"playPostroll",value:function(e){var t=this;this.postrollPromise?this.playPreloadedPromise(this.postrollPromise):this.bidsPromise.then((function(){var i=t.schedule.getPostRoll();i&&(i._position="post",t.startAdBreak(i,e))}))}},{key:"isDestroyed",value:function(){return null===this.player}},{key:"destroy",value:function(){this.bids.forEach((function(e){return e.stop()})),this.bidsPromises=[],this.bids=[],this.player.off(null,null,this),this.player=null}},{key:"enqueueAdEvent",value:function(e,t,i){this._events.push({type:e,event:t}),i.preload||this.dequeueAdEvents()}},{key:"dequeueAdEvents",value:function(){}},{key:"triggerAdBreakEvents",value:function(){}},{key:"startBlocking",value:function(){}},{key:"stopBlocking",value:function(){}},{key:"loadAd",value:function(){}},{key:"playPreloadedPromise",value:function(){}},{key:"startAdBreak",value:function(){}}]),e}(),Ze=[];var et=function(){function e(i,r,a,n,s){var o=this;t(this,e);var l=r||{};this.ad=i,this.map=l,this.debugTrackFn=a,this.trackerPlayerUtils=function(e){return{getPosition:function(){return e.getPosition()},getFile:function(){return e.getPlaylistItem().file},getPlacement:function(){return q(e.getConfig())},getUserAgent:function(){return navigator.userAgent}}}(n),this.trackingFilter=s,this.lastQuartile=0,this.progressEvents=[],this.breakStarted=!1,this.started=!1,this.firedError=!1,this.hasComp=!1,Object.keys(l).forEach((function(e){if(l.hasOwnProperty(e)&&0===e.indexOf("progress")){var t="".concat(e.split("_")[1]),i={key:e,offset:t,tracked:!1,percentage:!1};/^\d+%$/.test(t)?(i.percentage=!0,i.offset=parseFloat(t)):i.offset=n.utils.seconds(t),o.progressEvents.push(i)}})),this.setFactories()}return r(e,[{key:"getUrls",value:function(e){return this.map.hasOwnProperty(e)?this.map[e]:[]}},{key:"addUrl",value:function(e,t){this.map.hasOwnProperty(e)?this.map[e].push(t):(this.map[e]=[],this.map[e].push(t))}},{key:"trackPings",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=this.getUrls(e),r=this.trackingFilter,a=[],n=[],s=[];if(i.length){t=this.replaceMacros(t),i.forEach((function(e){if(e){if(Object.keys(t).forEach((function(i){e=e.replace(i,t[i])})),r&&!1===r(e))return void n.push(e);var i=new Image;i.src=e,a.push(e),s.push(i)}})),Array.prototype.push.apply(Ze,s);for(var o=Ze.length;o--&&(Ze[o].width||Ze[o].complete);)Ze.length=o}"function"==typeof this.debugTrackFn&&this.debugTrackFn({type:"ping",data:{pingType:e,urls:a,filteredUrls:n,images:s}})}},{key:"replaceMacros",value:function(e){var t,i,r,a,n,s,o,l=ce,d=l.gdprApplies,u=l.consentData;return e["[ADSERVINGID]"]=encodeURIComponent(this.ad.adServingId||""),e["[ASSETURI]"]=encodeURIComponent(this.trackerPlayerUtils.getFile()),e["[CACHEBUSTING]"]=Math.random().toString().slice(2,10),e["[CONTENTPLAYHEAD]"]=encodeURIComponent((t=this.trackerPlayerUtils.getPosition(),i=("0"+Math.floor(t/3600)).slice(-2),r=("0"+Math.floor((t-3600*i)/60)).slice(-2),i+":"+r+":"+("0"+Math.floor(t-3600*i-60*r)).slice(-2)+"."+(t%1).toFixed(3).toString().slice(2,5))),e["[DEVICEUA]"]=encodeURIComponent(this.trackerPlayerUtils.getUserAgent()),e["[GDPRCONSENT]"]=u,e["[PAGEURL]"]=encodeURIComponent(D().url),e["[PLACEMENTTYPE]"]=this.trackerPlayerUtils.getPlacement(),e["[REGULATIONS]"]=d?"gdpr":"",e["[TIMESTAMP]"]=encodeURIComponent((a=new Date,n=a.getTime(),s=a.getTimezoneOffset()/60,o=6e4*a.getTimezoneOffset(),new Date(n-o).toISOString().slice(0,-1)+(s>0?"-":"+")+("0"+s).slice(-2))),e}},{key:"start",value:function(){this.started=!0,this.trackPings("start")}},{key:"breakStart",value:function(){this.breakStarted=!0,this.trackPings("breakStart")}},{key:"time",value:function(e,t){if(!(t<=1)){for(var i=(4*e+.05)/t|0;i>this.lastQuartile&&this.lastQuartile<3;)this.lastQuartile++,1===this.lastQuartile?this.trackPings("firstQuartile"):2===this.lastQuartile?this.trackPings("midpoint"):3===this.lastQuartile&&this.trackPings("thirdQuartile");this.trackProgress(e,t)}}},{key:"trackProgress",value:function(e,t){for(var i=this.progressEvents.length;i--;){var r=this.progressEvents[i];if(!r.tracked){var a=r.offset;r.percentage&&(a=t*a/100),e>=a&&(r.tracked=!0,this.trackPings(r.key))}}}},{key:"error",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:900;this.firedError=!0;var t={};t["[ERRORCODE]"]=e,this.trackPings("error",t)}},{key:"factory",value:function(e){var t=this;return function(){t.trackPings(e)}}},{key:"setFactories",value:function(){this.creativeView=this.factory("creativeView"),this.click=this.factory("click"),this.skip=this.factory("skip"),this.complete=this.factory("complete"),this.pause=this.factory("pause"),this.resume=this.factory("resume"),this.mute=this.factory("mute"),this.unmute=this.factory("unmute"),this.fullscreen=this.factory("fullscreen"),this.expand=this.factory("expand"),this.collapse=this.factory("collapse"),this.acceptInvitation=this.factory("acceptInvitation"),this.close=this.factory("close"),this.rewind=this.factory("rewind"),this.impression=this.factory("impression"),this.viewable=this.factory("viewable"),this.notViewable=this.factory("notviewable"),this.breakEnd=this.factory("breakEnd")}}]),e}(),tt=function(){function i(e,r,a,s,o){t(this,i),this._scheduledAd=e,this.player=r,this.options=a,this.item=a.item,this.params=a.params||{},this.wrapperOptions=s||{followAdditionalAds:!0,allowMultipleAds:!0},this.debugTrackFn=o,n(this,r.Events),this._history=[],this.loadedAds=[],this.parser=null,this.promise=null,this.xmlhttp=null,this.wrappedTags=null,this.options.isPodItemLoader||(e.adPlayIds={})}return r(i,[{key:"load",value:function(e){var t=this;if(null===this.promise){this._history.push(e);var i=this.options.requestFilter;this.promise=new Promise((function(r,a){t.xmlhttp=t.player.utils.ajax({url:e,withCredentials:t.params.withCredentials,retryWithoutCredentials:!0,requireValidXML:!0,timeout:t._scheduledAd.requestTimeout,requestFilter:i},r,(function(e,t,i,r){return a(r)}))})).catch((function(i){if(null!==t.player)throw t.ajaxError(i,e)})).then((function(i){if(null!==t.player)return t.parseXMLString(i.responseXML||i.responseText,e)}))}return this.promise}},{key:"destroy",value:function(){var e;(e=this.xmlhttp)&&(e.onload=null,e.onreadystatechange=null,e.onerror=null,e.abort&&e.abort()),this.player=null,this.xmlhttp=null}},{key:"scheduledAd",value:function(){return this._scheduledAd}},{key:"allAds",value:function(){return this.loadedAds}},{key:"podMultipleVastLoaders",value:function(e){var t=this,i=e.map((function(e){return e.then((function(e){var i=e.adPod();if(i.length)return i;var r=e.adBuffet();return r.length?[r[0]]:Promise.reject({vloader:t,message:"No compatible ad"})})).catch((function(e){return{error:e}}))}));return Promise.all(i).then((function(e){var i=0,r=e.reduce((function(e,r,a){if(r.error)return r.error.tagIndex=a,t.trigger("adPodError",r.error),e;if(r.length&&0!==a){var n="p".concat(i,"w").concat(t._scheduledAd._waterfallIndex);t._scheduledAd.adPlayIds[n]=t._scheduledAd.adRequestIds[a]}return r.forEach((function(t){t.sequence=++i,e.push(t)})),e}),[]);return r.length?(t.loadedAds=r,t):null}))}},{key:"adPod",value:function(){var e=[];return this.loadedAds.forEach((function(t){t.sequence&&e.push(t)})),e.sort((function(e,t){return e.sequence-t.sequence})),e}},{key:"adBuffet",value:function(){var e=[];return this.loadedAds.forEach((function(t){t.sequence||e.push(t)})),e}},{key:"parseXMLString",value:function(t,r){var a=this;return null===this.parser&&(this.parser=new Me(null,this.player.utils)),new Promise((function(i){var r,n=(r=t,("object"===("undefined"==typeof Node?"undefined":e(Node))?r instanceof Node:r&&"object"===e(r)&&"number"==typeof r.nodeType&&"string"==typeof r.nodeName)?t:a.player.utils.parseXML(t));if(null===n){throw{message:"Invalid XML",code:100}}return i(a.parser.parse(n,a.xmlhttp))})).catch((function(e){if(null!==a.player){var t=e.code||900,i=e.adErrorCode||1e4+t;throw a.sendErrorEvent(e.message,t,i,r)}})).then((function(e){if(null===a.player)return null;if(0===e.length)throw a.sendErrorEvent("No ads",303,10303,r);var t=e.filter((function(e){return!e.sequence})).map((function(e){return e._currentTag=r,e}));a.wrapperOptions.allowMultipleAds?a.loadedAds=e:a.loadedAds=t,a.options.wrapper=a.options.wrapper||[],a.options.adsystem&&a.options.wrapper.push(a.options.adsystem),a.options.adsystem=a.loadedAds[0].adsystem;var n=[];return e.forEach((function(e,r){if(e.wrappedURI){if(!1===a.wrapperOptions.followAdditionalWrappers)return;a.options.wrappedTags=a.options.wrappedTags||[a._scheduledAd._currentTag],a.options.wrappedTags.push(e.wrappedURI);var s=new i(a._scheduledAd,a.player,a.options,{fallbackOnNoAd:e.fallbackOnNoAd,allowMultipleAds:e.allowMultipleAds,followAdditionalWrappers:e.followAdditionalWrappers},a.debugTrackFn),o=we(e.wrappedURI,a.player,a.item,c,a.params,e).then((function(e){return s.load(e)})).then((function(t){var i,r,n,s=(i=e,r=t.allAds(),n=[],r.forEach((function(e){var t,r;i.companions&&(e.companions=(e.companions?e.companions:[]).concat(i.companions)),i.trackers&&(e.trackers=(t=e.trackers,r=i.trackers,t=t||{},Object.keys(r).forEach((function(e){var i=r[e];t[e]?t[e]=t[e].concat(i):t[e]=i})),t)),i.sequence&&(e.sequence=i.sequence),i._currentTag&&(e._currentTag=i._currentTag),n.push(e)})),n),o=a.loadedAds.indexOf(e);Array.prototype.splice.apply(a.loadedAds,[o,1].concat(s))})).catch((function(i){var n=a.sendAdpodErrorEvent(i,e,r),s=e.fallbackOnNoAd&&e.sequence&&t.length,o=a.loadedAds.indexOf(e);if(s)return e.loadError=n,void i.vloader.destroy();if(a.loadedAds.splice(o,1),i.vloader.destroy(),"adPodError"!==n.type)throw n;a.trigger("adPodError",n)}));n.push(o)}else a.options.wrapper.length&&(e.wrapper=a.options.wrapper,e.wrappedTags=a.options.wrappedTags)})),Promise.all(n)})).then((function(){if(null===a.player)return null;var e=a.loadedAds.filter((function(e){return!e.sequence}));a.loadedAds.forEach((function(t,i){if(t.loadError)if(e.length){var r=a.loadedAds[i+1],s=r&&!r.sequence?r:e[0];a.loadedAds[i]=n({},s,{sequence:t.sequence})}else a.trigger("adPodError",t.loadError)}));var t=a.loadedAds.slice(0),i=t.length;t.forEach((function(e){e.media&&e.media.length||t.length--}));var r=0===i,s=t.length!==i;if(r||s)throw a.sendErrorEvent("Ad Tag Empty",101,10101,a._history[a._history.length-1]);return a}))}},{key:"ajaxError",value:function(e,t){if(this.player.getAdBlock())return this.sendErrorEvent("Ad playback blocked by an ad blocker",900,60003,t);var i=e.code;if(601===i||602===i)return this.sendErrorEvent("Invalid XML",100,10100,t);var r=this.options.wrappedTags&&this.options.wrappedTags.length,a=r?301:900,n=r?10301:60006;return this.sendErrorEvent(e.message||"Error loading file",a,n,t)}},{key:"firstUrl",value:function(){return this._history&&this._history.length?this._history[0]:""}},{key:"sendAdpodErrorEvent",value:function(e,t,i){var r=e.message,a=e.code,n=e.adErrorCode,s=e.url;if(1===this.loadedAds.length)return this.sendErrorEvent(r,a,n,s,i);var o={message:r,code:a,adErrorCode:n,podIndex:i,vloader:this,tag:this.firstUrl()||s,type:"adPodError"};return this.trackError(o,t),this.wrappedTags=s,o}},{key:"sendErrorEvent",value:function(e,t,i,r,a){var n={message:e,code:t,adErrorCode:i,podIndex:a,vloader:this,tag:this.firstUrl()||r,adsystem:this.options.adsystem||""};return this.options.wrappedTags&&(n.wrapperAdSystem=this.options.wrapper||"",n.wrappedTags=this.options.wrappedTags),this.trackError(n),n}},{key:"trackError",value:function(e,t){var i=e.vloader.allAds();if(i&&i.length){var r=t||i[0];if(r){var a=r.trackers;if(a&&a.error)new et(r,a,this.debugTrackFn,this.player,this.options.trackingFilter).error(e.code)}}}}]),i}();var it=function(){function e(i,r,a,s,o){var l=this;t(this,e),this.player=i,this.state=i.state,this.vpaidURL=a,this.adTag=s,this.adParams=o.adParams,this.vpaidControls=o.vpaidControls,this.remainingTimeInterval=null,this.type="vpaid",this.instream=r||i.createInstream(),this.vpaidState={linear:!1,expanded:!1,remainingTime:-1},this.paused=!1,n(this,i.Events),this.setMuteCallback=function(){l.handleMute?l.setMute():l.handleMute=!0},this.playerContainer=this.player.getContainer(),o.adOptOut?setTimeout((function(){l.sendEvent("error",{message:"Conditional ad rejected",code:408})}),0):this.iframe=function(e,t,i,r){var a=document.createElement("iframe");a.setAttribute("allow","autoplay"),a.src="javascript:false",a.classList.add("jw-vpaid-iframe"),a.scrolling="no",i.querySelector(".jw-media").appendChild(a);var n=a.contentWindow.document;return n.open().write("\n ")),a.contentWindow.myCallback=r,n.close(),a}(i.utils,this.vpaidURL,this.playerContainer,this.callback.bind(this))}return r(e,[{key:"sendEvent",value:function(e,t){(t=t||{}).tag||(t.tag=this.adTag),this.trigger(e,t)}},{key:"sendTimeEvent",value:function(e,t,i){var r=t.getAdDuration(),a=t.getAdRemainingTime(),s=n({duration:r},i);this.sendEvent(e,s),a>0&&(s.position=r-a,this.trigger("time",s))}},{key:"handleQuartile",value:function(e,t){this.sendTimeEvent("quartile",e,{quartile:t})}},{key:"genEvent",value:function(e){var t=this;return function(i){t.on(e,i)}}},{key:"setMute",value:function(){var e=0===this.vpaidAd.getAdVolume();this.player.getMute()!==e&&this.player.setMute(e)}},{key:"prepareNonlinearAd",value:function(){if(this.player.utils.style(this.iframe,{height:150}),this.iframe.classList.add("jw-vpaid-non-linear"),this.resize(null,150),this.instream){this.instream.noResume=!0,this.instream.applyProviderListeners(null),this.instream.destroy(),this.instream=null;var e=this.playerContainer.querySelector(".jw-media"),t=e.querySelector("video,audio");e.insertBefore(t,this.iframe),t.play()}}},{key:"progressInterval",value:function(e){var t=this;if(clearInterval(this.remainingTimeInterval),e&&e.getAdRemainingTime){var i=-1;this.remainingTimeInterval=setInterval((function(){if(!t.paused){var r=e.getAdRemainingTime();isNaN(r)||r<=0||i===r||(i=r,t.sendTimeEvent("remainingTimeChange",e,{remainingTime:r}))}}),250)}}},{key:"genListeners",value:function(e){var t=this;return{AdLoaded:function(){e.setAdVolume(t.getPlayerVolume()),e.startAd()},AdStarted:function(){var i=e.getAdDuration?e.getAdDuration():0,r=!e.getAdLinear||e.getAdLinear(),a=r?"linear":"nonlinear";r?(t.vpaidControls||(t.instream=t.instream||t.player.createInstream(),t.instream.hide()),t.progressInterval(e)):t.prepareNonlinearAd(),t.sendEvent("impression",{linear:a,duration:i}),t.sendEvent("play",{oldstate:"buffering",newstate:y,linear:a}),t.handleMute=!0,e.subscribe(t.setMuteCallback,"AdVolumeChange",e)},AdVideoStart:function(){t.sendEvent("started")},AdStopped:function(){t.sendEvent("stopped")},AdPaused:function(){t.paused||(t.paused=!0,t.sendEvent("pause",{newstate:"paused",oldstate:y}))},AdPlaying:function(){if(t.paused){var i=!e.getAdLinear||e.getAdLinear()?"linear":"nonlinear";t.paused=!1,t.sendEvent("play",{newstate:y,oldstate:"paused",linear:i})}},AdLinearChange:function(){!e.getAdLinear||e.getAdLinear()?(t.player.utils.style(t.iframe,{height:"100%"}),t.player.off(null,null,t),t.instream=t.instream||t.player.createInstream(),t.instream.init(),t.vpaidControls||t.instream.hide()):t.prepareNonlinearAd()},AdDurationChange:function(){t.sendTimeEvent("remainingTimeChange",e,{isDurationChange:!0,remainingTime:e.getAdRemainingTime()})},AdRemainingTimeChange:function(){t.paused||t.sendTimeEvent("remainingTimeChange",e,{remainingTime:e.getAdRemainingTime()})},AdExpandedChange:function(){t.sendEvent("expandedChange",{expanded:e.getAdExpanded()})},AdSkippableStateChange:function(){t.sendEvent("skippableStateChange",{skippable:e.getAdSkippableState()})},AdSkipped:function(){t.sendEvent("skipped")},AdVideoFirstQuartile:function(){t.handleQuartile(e,1)},AdVideoMidpoint:function(){t.handleQuartile(e,2)},AdVideoThirdQuartile:function(){t.handleQuartile(e,3)},AdVideoComplete:function(){t.sendEvent("complete")},AdUserClose:function(){t.sendEvent("close")},AdClickThru:function(e,i,r){t.sendEvent("click",{id:i,url:e,playerHandles:r})},AdError:function(e){var i=function(e){if(e){var t=e.match(/\b(?:[34])[0-9]{2}\b/);if(t)return parseInt(t[0],10);if(e.match(/timeout/i))return e.match(/vpaid|vast/i)?301:402;if(e.match(/found/i))return 401;if(e.match(/supported/i))return 403;if(e.match(/(?:displaying|media file)/i))return 405}return 901}(e);t.sendEvent("error",{message:e,code:i,adErrorCode:5e4+i})}}}},{key:"callback",value:function(){try{this.vpaidAd=this.iframe.contentWindow.getVPAIDAd();var e=this.vpaidAd.handshakeVersion("2.0");if(parseFloat(e)<1)throw new Error("Invalid vpaid version in handshake")}catch(e){return void this.sendEvent("error",{message:e.message||"VPAID general error",code:901,adErrorCode:51901})}var t=this.vpaidAd,i=this.genListeners(t);Object.keys(i).forEach((function(e){t.subscribe(i[e],e,t)})),this.listeners=i;var r={AdParameters:this.adParams},a=this.iframe.contentWindow.document.createElement("div");a.className="jw-vpaid-wrapper",a.style.height="100%",this.iframe.contentWindow.document.body.appendChild(a),this.vpaidURL.indexOf("//imasdk.googleapis.com/js/sdkloader/vpaid_adapter.js")>=0&&(this.iframe.contentWindow.HTMLVideoElement=HTMLVideoElement);var n={videoSlot:this.instream.getMediaElement(),slot:a};t.initAd(this.player.getWidth(),this.player.getHeight(),"normal",1e3,r,n),t.setAdVolume(this.getPlayerVolume())}},{key:"play",value:function(){this.vpaidAd.resumeAd()}},{key:"pause",value:function(){this.vpaidAd.pauseAd()}},{key:"skip",value:function(){return!(!this.vpaidAd.skipAd||!this.vpaidAd.getAdSkippableState())&&(this.vpaidAd.skipAd(),!0)}},{key:"stop",value:function(){if(this.vpaidAd)try{this.vpaidAd.stopAd()}catch(e){}}},{key:"getPlayerVolume",value:function(){return this.player.getMute()?0:this.player.getVolume()/100}},{key:"setVolume",value:function(e){this.handleMute=!1,this.vpaidAd.setAdVolume(e/100)}},{key:"resize",value:function(e,t){if(this.vpaidAd&&this.vpaidAd.resizeAd){var i=this.player.getFullscreen()||document.fullScreen||document.mozFullScreen||document.webkitIsFullScreen?"fullscreen":"normal";this.vpaidAd.resizeAd(e||this.player.getWidth(),t||this.player.getHeight(),i)}}},{key:"destroy",value:function(){if(this.removeEvents(),clearInterval(this.remainingTimeInterval),this.vpaidAd)try{var e=this.listeners,t=this.vpaidAd;Object.keys(e).forEach((function(i){t.unsubscribe(e[i],i,t)})),t.unsubscribe(this.setMuteCallback,"AdVolumeChange",t)}catch(e){}this.iframe&&this.iframe.parentNode&&this.iframe.parentNode.removeChild(this.iframe),this.vpaidAd=null,this.player=null,this.instream=null}},{key:"removeEvents",value:function(){this.player&&this.player.off(null,null,this),this.off()}},{key:"attachMedia",value:function(){}},{key:"detachMedia",value:function(){}},{key:"volume",value:function(){}},{key:"mute",value:function(){}},{key:"getState",value:function(){return this.vpaidState.linear?this.paused?"paused":y:"idle"}}]),e}();var rt=function(){function e(i,r,a){t(this,e),this.player=i,this.icon=r,this.div=a;var n=this.utils=i.utils;this.images=[],this.iconContainer=function(e,t){var i=document.createElement("div");return i.className="jw-ad-icon-container",t.style(i,e),i}(r.style,n);var s=function(e,t){var i,r=e.resourceSource,a=e.resourceType;switch(a){case"iframe":(i=document.createElement("iframe")).src=r,i.scrolling="no";break;case"html":i=document.createElement("div"),t.replaceInnerHtml(i,r);break;default:(i=document.createElement("img")).src=r,i.setAttribute("type",a)}return t.addClass(i,"jw-ad-icon"),i}(r.resource,n);this.iconContainer.appendChild(s),a.appendChild(this.iconContainer);var o=1e3*n.seconds(r.offset);o>0?this.showTimeout=setTimeout(this.show.bind(this),o):this.show(),this.ui=new n.UI(this.iconContainer).on("click tap",this.clickHandler,this)}return r(e,[{key:"clickHandler",value:function(){this.player.pause({reason:"clickthrough"}),this.sendPing(this.icon.trackers.iconClick),this.utils.openLink(this.icon.clickThrough,"_blank",{rel:"noreferrer"})}},{key:"show",value:function(){clearTimeout(this.showTimeout),this.utils.addClass(this.iconContainer,"jw-ad-icon-active"),this.sendPing(this.icon.trackers.iconView),this.icon.duration&&(this.duration=this.utils.seconds(this.icon.duration),this.beginningPosition=this.utils.seconds(this.icon.offset))}},{key:"updateTime",value:function(e){e-this.beginningPosition>=this.duration&&this.remove()}},{key:"sendPing",value:function(e){if(e){var t=this.images,i=new Image;i.src=e;for(var r=t.length;r--&&(t[r].width||t[r].complete);)t.length=r;t.push(i)}}},{key:"remove",value:function(){clearTimeout(this.showTimeout),this.div.contains(this.iconContainer)&&this.div.removeChild(this.iconContainer),this.ui&&(this.ui.destroy(),this.ui=null)}}]),e}();var at=function(){function e(i,r,a){t(this,e),this.player=r,this.playlistItemManager=a;var s=a.adPlayerProperties,o=s.staticPlayer,l=s.companion,d=s.div,u=s.optionalParams;this.staticPlayer=o,this.companion=l,this.div=d,this.optionalParams=u,this.debugTrackFn=this.optionalParams.debugTrackFn,this.scheduledAd=i.scheduledAd(),this.vastBuffet=i.adBuffet(),this.vastAdPod=i.adPod(),this.vastAd=this.vastBuffet.length?this.vastBuffet[0]:null,this.adType=null,this.vpaidPlayer=null,this.instreamPlayer=null,this.blockingInstreamPlayer=null,this.mediaType=null,this.adPodItems=null,this.creativeTimeout=null,this.vastOptions=null,this.duration=0,this.position=0,this.initialIndex=0,this.viewablePlayedTime=0,this.adViewableImpressionHandler=r.utils.noop,this.lastPosition=null,this.reason=null,n(this,r.Events)}return r(e,[{key:"init",value:function(e,t){return this.init=function(){throw new Error("Adplayer can only be initialized once")},this.blockingInstreamPlayer=e,this.reason=t,this.prepareAdPod()?(this.player.on("fullscreen",this.playerFullscreenHandler,this),this.player.on("volume",this.playerVolumeHandler,this),this.player.on("mute",this.muteHandler,this),this.player.on("resize",this.playerResizeHandler,this),this.playAd()):Promise.reject()}},{key:"prepareAdPod",value:function(){var e,t=this,i=null,r=0,a=[];if(this.vastAd&&(ot(this.vastAd,this.debugTrackFn,this.player,this.optionalParams.trackingFilter),(i=this.prepareAdPodItem(this.vastAd))&&"vpaid"===i.adType&&!st(this.vastAd)&&(i=null)),this.vastAdPod)for(var n=null,s=0;s=n})).sort((function(e,t){return e.width-t.width}));r.length||(r=t.sort((function(e,t){return t.width-e.width})));var o=r.filter((function(e){return e.width===r[0].width}));if(o.length>1){var l=o.reduce((function(t,i){return i.bitratet.bitrate?i:t})),d=o.reduce((function(t,i){return i.bitrate>=e&&i.bitrate0&&this.positionthis.scheduledAd._adPodIndex){if(this.vpaidPlayer&&(this.vpaidPlayer.destroy(),this.vpaidPlayer=null),"instream"===this.adType&&this.instreamPlayer)return void this.instreamPlayer.loadNextItemOnError();this.scheduledAd._adPodIndex++,this.playAd()}}},{key:"playVpaid",value:function(e){var t=this;clearTimeout(this.creativeTimeout),this.creativeTimeout=setTimeout((function(){t.creativeAdError("VPAID tag communication timeout",900,50004)}),this.scheduledAd.creativeTimeout),this.vastAd=e;var i=st(e),r=this.optionalParams.conditionaladoptout&&e.conditionalAd;if(this.vastAd.selectedMedia=i,this.mediaType=i.type,"flash"===nt(i))return this.creativeAdError("Flash creatives are not supported",403,10403),Promise.reject();var a={adParams:this.vastAd.adParams,vpaidControls:this.optionalParams.vpaidcontrols,adOptOut:r};return this.vpaidPlayer=new it(this.player,this.blockingInstreamPlayer,i.file,this.scheduledAd._currentTag,a),this.blockingInstreamPlayer&&this.blockingInstreamPlayer.applyProviderListeners(this.vpaidPlayer),this.vpaidPlayer.on("play",this.playHandler,this),this.vpaidPlayer.on("pause",this.pauseHandler,this),this.vpaidPlayer.on("quartile",this.quartileHandler,this),this.vpaidPlayer.on("remainingTimeChange",this.remainingTimeHandler,this),this.vpaidPlayer.on("click",this.clickVpaidHandler,this),this.vpaidPlayer.on("error",this.playbackErrorHandler,this),this.vpaidPlayer.on("impression",this.impressionHandler,this),this.vpaidPlayer.on("expandedChange",this.vpaidExpandedHandler,this),this.vpaidPlayer.on("close",this.adCloseHandler,this),this.vpaidPlayer.on("skipped",this.vpaidAdSkipped,this),this.vpaidPlayer.on("stopped",this.endOfVpaidAdHandler,this),this.vpaidPlayer.on("complete",this.adCompleteHandler,this),this.vpaidPlayer.on("started",this.adStartedHandler,this),this.vpaidPlayer.on("skippableStateChange",this.skippableStateChangeHandler,this),Promise.resolve()}},{key:"skippableStateChangeHandler",value:function(e){e.skippable&&this.blockingInstreamPlayer&&(this.blockingInstreamPlayer.off("adSkipped",this.skipVpaidAd,this),this.blockingInstreamPlayer.setupSkipButton(0,this.optionalParams,this.player.utils.noop),this.blockingInstreamPlayer.on("adSkipped",this.skipVpaidAd,this))}},{key:"playInstream",value:function(e,t){var i=this,r=this.player.getEnvironment().OS;if(r.android&&2===r.version.major&&3===r.version.minor)return this.adError("Android 2.3 not supported",900,60007),Promise.reject();clearTimeout(this.creativeTimeout),this.blockingInstreamPlayer?this.instreamPlayer=this.blockingInstreamPlayer:this.instreamPlayer=this.player.createInstream().init(),this.instreamPlayer.on("play",this.playHandler,this),this.instreamPlayer.on("pause",this.pauseHandler,this),this.instreamPlayer.on("time",this.timeHandler,this),this.instreamPlayer.on("playlistItem",this.playlistItemHandler,this),this.instreamPlayer.on("complete",this.adCompleteHandler,this),this.instreamPlayer.on("playlistComplete",this.endOfAdBreakHandler,this),this.instreamPlayer.on("mute",this.muteHandler,this),this.instreamPlayer.on("instreamClick",this.clickInstreamHandler,this),this.instreamPlayer.on("adSkipped",this.adSkipped,this),this.instreamPlayer.on("error",this.playbackErrorHandler,this),this.instreamPlayer.on("mediaError",this.playbackErrorHandler,this),this.instreamPlayer.on("destroyed",(function(){i.instreamPlayer=null}),this);var a=this.instreamPlayer.loadItem(e,t);return this.clearBlocking(),a}},{key:"playerFullscreenHandler",value:function(e){var t=this.getVastAd().tracker;e.fullscreen&&t.started&&t.fullscreen()}},{key:"playerResizeHandler",value:function(e){this.vpaidPlayer&&this.vpaidPlayer.resize(e.width,e.height)}},{key:"playerVolumeHandler",value:function(e){this.vpaidPlayer&&this.vpaidPlayer.setVolume(e.volume)}},{key:"playlistItemHandler",value:function(e){var t=this;this.instreamPlayer&&(clearTimeout(this.creativeTimeout),this.creativeTimeout=setTimeout((function(){t.creativeAdError("Video creative timeout",402,10402)}),this.scheduledAd.creativeTimeout),this.scheduledAd._adPodIndex=e.index+this.initialIndex,this.scheduledAd._adPodIndex>0&&this.triggerEvent("adItem"))}},{key:"impressionHandler",value:function(e){var t=this.getVastAd(),i=t.tracker;i.impression(),this.player.getViewable()?i.viewable():i.notViewable();var r=n({},this.scheduledAd,t);this.triggerEvent("adImpression",F(this.playlistItemManager,r,{duration:e.duration||t.duration||this.getDurationFromVideoTag(),linear:e.linear||i.linear})),this.setupViewableListener()}},{key:"viewableHandler",value:function(e){e.viewable?(this.viewablePlayedTime=0,this.lastPosition=null,this.adViewableImpressionHandler=this.adViewableHandler):this.adViewableImpressionHandler=this.player.utils.noop}},{key:"playHandler",value:function(e){var t=this;clearTimeout(this.creativeTimeout),this.creativeTimeout=null;var i,r=this.getVastAd(),a=r.tracker;if(a.started)"paused"===e.oldstate&&(a.resume(),this.dispatchPlay(e));else{this.vpaidPlayer&&(a.linear=e.linear),this.instreamPlayer&&this.impressionHandler({linear:a.linear});var s=n({},this.scheduledAd,r),o=F(this.playlistItemManager,s,{linear:a.linear,metadata:!0});if(this.triggerEvent("adMeta",o),r.companions){var l=F(this.playlistItemManager,s,{companions:(i=r.companions,i.map((function(e){var t,i="iframe"===e.type||"html"===e.type?e.type:"static";return e.trackers&&e.trackers.creativeView&&e.trackers.creativeView.length&&(t=e.trackers.creativeView),{width:e.width,height:e.height,type:i,resource:e.source,creativeview:t,click:e.clickthrough}})))});this.triggerEvent("adCompanions",l)}r.icons&&(r.iconInstances=r.icons.map((function(e){return new rt(t.player,e,t.div)})));var d,u=this.companion;d=this.player.utils.flashVersion()>9?r.companions:function(e){if(e)return e.filter((function(e){return e.type.indexOf("flash")<0}));return[]}(r.companions),this.optionalParams.companion&&d&&d.length&&(a.hasComp=u.addCompanion(this.optionalParams.companion,d)),a.start(),a.creativeView(),this.dispatchPlay(e)}}},{key:"pauseHandler",value:function(e){clearTimeout(this.creativeTimeout),this.creativeTimeout=null,this.getVastAd().tracker.pause(),null===this.reason&&"vpaid"===this.adType&&(this.reason="external"),this.setState(e)}},{key:"remainingTimeHandler",value:function(e){var t=this;e.duration?this.duration=e.duration:this.duration=Math.max(1,this.duration,e.remainingTime);var i=e.remainingTime>=0?this.duration-e.remainingTime:0;this.position===i?this.creativeTimeout=this.creativeTimeout||setTimeout((function(){t.creativeAdError("Video stall",400)}),this.scheduledAd.creativeTimeout):this.creativeTimeout&&(clearTimeout(this.creativeTimeout),this.creativeTimeout=null),this.timeHandler({position:i,duration:this.duration,isDurationChange:e.isDurationChange})}},{key:"quartileHandler",value:function(e){if(e.duration)this.duration=e.duration;else{var t=4*e.remainingTime/(4-e.quartile);this.duration=Math.max(this.duration,1,t)}this.timeHandler({position:this.duration*e.quartile*.25,duration:this.duration})}},{key:"adViewableHandler",value:function(e){var t=e.position;null===this.lastPosition&&(this.lastPosition=t);var i=t-this.lastPosition;this.lastPosition=t,i=Math.min(Math.max(0,i),4),this.viewablePlayedTime+=i,this.viewablePlayedTime>=2&&(this.player.off("viewable",this.viewableHandler,this),this.adViewableImpressionHandler=this.player.utils.noop,this.triggerEvent("adViewableImpression",{}))}},{key:"timeHandler",value:function(e){var t=this.getVastAd(),i=e.position,r=e.duration;this.adViewableImpressionHandler(e);var a=r-i,n=t.tracker,s=this.optionalParams.dynamicMessage||"",o=this.optionalParams.podMessage||"";if(s&&a>0){if(s=s.replace(/(\b)xx(s?\b)/gi,"$1".concat(Math.ceil(a),"$2")),this.adPodItems&&this.adPodItems.length>1&&o){var l=this.scheduledAd._adPodIndex+1;s=(o=(o=o.replace(/__AD_POD_CURRENT__/g,"".concat(l))).replace(/__AD_POD_LENGTH__/g,"".concat(this.adPodItems.length)))+" "+s}this.instreamPlayer?this.instreamPlayer.setText(s):this.vpaidPlayer&&this.vpaidPlayer.instream&&this.vpaidPlayer.instream.setText(s)}if(!e.isDurationChange){n&&n.time(i,r),t.iconInstances&&t.iconInstances.forEach((function(e){e.updateTime(i)}));var d={};d.position=this.position=i,d.duration=r,this.triggerEvent("adTime",d)}}},{key:"combinedCompleteHandler",value:function(){this.adCompleteHandler(),this.endOfAdBreakHandler()}},{key:"adCompleteHandler",value:function(){clearTimeout(this.viewableTimeout);var e=this.getVastAd();lt(e);var t=e.tracker;t.firedError||(t.complete(),this.triggerEvent("adComplete"))}},{key:"adCloseHandler",value:function(){clearTimeout(this.viewableTimeout);var e=this.getVastAd().tracker;e.firedError||e.close()}},{key:"adStartedHandler",value:function(){this.triggerEvent("adStarted")}},{key:"endOfVpaidAdHandler",value:function(){if(clearTimeout(this.viewableTimeout),this.adPodItems&&this.adPodItems.length-1>this.scheduledAd._adPodIndex)return this.vpaidPlayer&&(this.vpaidPlayer.destroy(),this.vpaidPlayer=null),this.scheduledAd._adPodIndex++,void this.playAd();this.endOfAdBreakHandler()}},{key:"endOfAdBreakHandler",value:function(){this.removePlayerListeners(),this.trigger("adPlayComplete")}},{key:"muteHandler",value:function(e){var t=this.getVastAd().tracker;t&&(e.mute?t.mute():t.unmute(),this.vpaidPlayer&&this.vpaidPlayer.setVolume(e.mute?0:this.player.getVolume()))}},{key:"clickStaticHandler",value:function(){var e=this.getVastAd();this.player.pause({reason:"clickthrough"}),this.clickThrough(e)}},{key:"clickVpaidHandler",value:function(e){var t=this.getVastAd(),i=!0;e&&void 0!==e.url&&(!1===e.playerHandles&&(i=!1),t.clickthrough=e.url),this.clickThrough(t,i)}},{key:"clickInstreamHandler",value:function(){"paused"!==this.instreamPlayer.getState()&&this.clickThrough(this.getVastAd())}},{key:"playbackErrorHandler",value:function(e){var t=e.message||"Error Playing Ad Tag",i=e.code;i&&232404===i?i=403:(!i||i<=4||i>901)&&(i=405),this.vpaidPlayer&&"function"==typeof this.vpaidPlayer.off?(this.vpaidPlayer.off(),this.creativeAdError(t,i,e.adErrorCode)):this.adError(t,i,e.adErrorCode)}},{key:"staticErrorHandler",value:function(){this.adError("Unable to fetch NonLinear resource",502)}},{key:"vpaidExpandedHandler",value:function(e){var t=this.getVastAd().tracker;e.expanded?t.expand():t.collapse()}},{key:"getDurationFromVideoTag",value:function(){var e=this.blockingInstreamPlayer?this.blockingInstreamPlayer.getMediaElement():null;return e?e.duration:0}},{key:"setupViewableListener",value:function(){this.player.off("viewable",this.viewableHandler,this),this.player.on("viewable",this.viewableHandler,this),this.viewableHandler({viewable:this.player.getViewable()})}},{key:"dispatchPlay",value:function(e){"static"===this.adType||"vpaid"===this.adType&&"linear"!==e.linear||(null===this.reason&&"vpaid"===this.adType&&(this.reason="external"),this.setState(e))}},{key:"setState",value:function(e){var t=e.newstate,i=e.oldstate,r=t===y,a=this.adEventObject(r?"adPlay":"adPause");(a.newstate=t,null!==this.reason)&&(a[r?"playReason":"pauseReason"]=this.reason,this.reason=null);this.vpaidPlayer?(a.oldstate=i,this.vpaidPlayer.trigger("state",a)):this.instreamPlayer.setEventData(a)}},{key:"clickThrough",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];e.tracker.click();var i={};e.clickthrough&&(i.clickThroughUrl=e.clickthrough),this.reason="clickthrough",this.triggerEvent("adClick",i),window.jwcast&&window.jwcast.player.id||e.clickthrough&&t&&window.open(e.clickthrough)}},{key:"skipVpaidAd",value:function(){this.vpaidPlayer&&this.vpaidPlayer.skip()&&this.vpaidAdSkipped()}},{key:"vpaidAdSkipped",value:function(){this.adSkipped(),this.endOfVpaidAdHandler()}},{key:"adSkipped",value:function(){clearTimeout(this.viewableTimeout);var e=this.getVastAd();e.tracker.skip(),lt(e);var t="vpaid"===this.adType?void 0:this.getSkipOffset(e);this.triggerEvent("adSkipped",{duration:e.duration,skipoffset:t,position:this.position,watchedPastSkipPoint:this.position-t})}},{key:"triggerEvent",value:function(e,t){var i=this.adEventObject(e);t&&n(i,t),this.trigger(e,i),-1===b.indexOf(e)&&this.player.trigger(e,i)}}]),e}();function nt(e){return function(e){return"application/javascript"===e.type||"application/x-javascript"===e.type}(e)?"html5":"flash"}function st(e){for(var t,i=0;i1&&void 0!==arguments[1]?arguments[1]:{},r=this.config,a=new tt(e,this.player,n({requestFilter:r.requestFilter,trackingFilter:r.trackingFilter,item:this.item,params:this.params},i));this._vloaderQueue.push(a);var s=0;return a.on("adPodError",(function(r){s+=1;var n=t._getVloaderErrorObject(r,null,i);if(t.enqueueAdEvent("adError",n,i),!(a._scheduledAd._pod&&a._scheduledAd._pod.length===s)){var o=F(t,e,{podIndex:a._scheduledAd._adPodIndex,tagIndex:s},i);t.enqueueAdEvent("adItem",o,i)}})),a}},{key:"_getVloaderErrorObject",value:function(e,t,i){e.wrapperAdSystem&&e.wrapperAdSystem.length!==e.wrappedTags.length&&(e.wrapperAdSystem.push(e.adsystem),e.adsystem="");var r=n({adsystem:e.adsystem,wrapper:e.wrapperAdSystem,wrappedTags:e.wrappedTags},e.vloader.scheduledAd());return N(this,e,r,n({tag:e.tag,tagIndex:e.tagIndex||t,podIndex:e.podIndex},n({jwpseg:r.jwpseg},i)))}},{key:"dequeueAdEvents",value:function(){var e=this;this._events.forEach((function(t){var i=t.type,r=t.event;"adError"===i?e.dispatchAdError(r):e.player.trigger(i,r)})),this._events.splice(0)}},{key:"triggerAdBreakEvents",value:function(e){var t=this,i=this.getVMAPTracker(e);this.blockingInstreamPlayer.once("destroyed",(function(){t.qoe.clear("adBreakStart"),i.breakEnd(),t.player.trigger("adBreakEnd",F(t,e))})),this.qoe.tick("adBreakStart"),i.breakStart();var r=F(this,e);this.player.trigger("adBreakStart",r),this.player.trigger("adItem",r)}},{key:"startBlocking",value:function(){this.blockingInstreamPlayer||(this.blockingInstreamPlayer=this.player.createInstream().init(),this.blockingInstreamPlayer.setText(null))}},{key:"stopBlocking",value:function(){if(this.blockingInstreamPlayer||this.adInstreamPlayer){var e=this.blockingInstreamPlayer||this.adInstreamPlayer;this.blockingInstreamPlayer=null,e.destroy()}this.adInstreamPlayer=null}},{key:"loadAd",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=this.player.utils;if(e._id=e._id||r.genId(12),e._vmapTracker=this.getVMAPTracker(e),e._adQueue||e._adXML||e._pod){if(i.adBlock)throw N(this,{message:"Ad playback blocked by an ad blocker",adErrorCode:600003},e,i);var a;if(e._pod)return this._loadPods(e,i);var n=function(){return t.isDestroyed()?null:t._dispatchAdLoaded(e,i)};return(a=e._adXML?this._loadXML(e,i):this._loadTag(e,i)).then(n).catch(dt),a.catch(n).catch(dt),a.catch((function(e){return t.isDestroyed()?null:t._vloaderWaterfall(e,i)}))}r.log("scheduled ad has no url or xml",e)}},{key:"playPreloadedPromise",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e.then((function(e){return t.tryPlayAd(e,i.reason)})).catch((function(e){t.isDestroyed()||(t.dispatchAdError(e),t.stopBlocking())}))}},{key:"startAdBreak",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=this.bidsPromise.then((function(){return t.loadAd(e,i)}));return r.then((function(e){return t.tryPlayAd(e,i.reason)})).catch((function(e){t.dispatchAdError(e),t.stopBlocking()}))}},{key:"removeVastLoader",value:function(e){var t=this._vloaderQueue.indexOf(e);-1!==t&&(e.destroy(),this._vloaderQueue.splice(t,1))}},{key:"isDestroyed",value:function(){return null===this.player}},{key:"destroy",value:function(){this._vloaderQueue.forEach((function(e){return e.destroy()})),this.clearNonlinearAd(),this.stopBlocking(),d(s(i.prototype),"destroy",this).call(this)}}]),i}(Ke);function ht(e){return e.tag&&(void 0===e.podcount||1===e.sequence)}var ct={};var pt=function(){},vt=function(){function e(i,r,a){t(this,e),this.player=i,this.pluginConfig=r,this.adClient=a;var n=i.getConfig(),s=n.key,o=this.configParser=new ze(i.utils),l=this.adRules=new Je(i,o.getAdRules(r),a);this.resetDefaultSchedule(),this.emptySchedule=new Qe(l,i.utils);var d=function(e,t,i){var r=ct[t];return r||(ct[t]=new Promise((function(r,a){!function(i){var r=new e.key(t);if("unlimited"===r.edition())return i();var a=["//","entitlements.jwplayer.com","/",r.token(),".json"];"file:"===window.location.protocol&&a.unshift("https:"),e.ajax(a.join(""),(function(e){i(e&&e.response)}),(function(){i()}),{timeout:1e4,responseType:"json"})}((function(e){var t,n,s=e||{};!0===i.outstream?(t=!1!==s.canPlayOutstreamAds,n="Outstream Ad Limit Reached"):(t=!1!==s.canPlayAds,n="Ad Limit Reached"),!1!==t?r({message:"Can Play Ads"}):a({message:n})}))})))}(i.utils,s,r);d.catch(pt),i.on("ready",(function(){d.catch((function(e){i.trigger("destroyPlugin",e),i.trigger("adError",function(e,t,i){return{client:i,message:e,adErrorCode:60002,id:Y,placement:me(t),tag:""}}(e.message,n,a))}))}))}return r(e,[{key:"getAdRules",value:function(){return this.adRules}},{key:"resetDefaultSchedule",value:function(){var e=void 0===this.pluginConfig.withCredentials||this.pluginConfig.withCredentials,t=this.defaultSchedule=this.configParser.getSchedule(this.pluginConfig,this.adRules);t.isVMAP()&&t.load(this.player,{},this.adClient,{withCredentials:e}).catch(pt)}},{key:"getSchedule",value:function(e,t){return t>0&&!this.adRules.rulesAllowAdPlayback(t)?this.emptySchedule:e&&e.adschedule?this.configParser.getSchedule(e,this.adRules):(t>1&&this.resetDefaultSchedule(),this.defaultSchedule)}},{key:"getOptParams",value:function(e,t){return this.configParser.getOptParams(e,t)}},{key:"reset",value:function(){this.adRules.reset()}}]),e}(),ft=function(){};!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-time-slider-above .jw-vpaid-non-linear{bottom:66px}.jwplayer.jw-breakpoint-7 .jw-vpaid-non-linear{bottom:132px}.jwplayer.jw-flag-user-inactive:not(.jw-state-paused) .jw-vpaid-non-linear{bottom:.5em}.jwplayer .jw-vpaid-non-linear{bottom:60px}.jwplayer .jw-vpaid-iframe{border:0;width:100%;height:100%;position:absolute;overflow:hidden}.jwplayer .jw-plugin-vast.jw-plugin{top:0;width:100%;pointer-events:none}.jwplayer .jw-plugin-vast.jw-plugin *{pointer-events:all}.jwplayer .jw-plugin-vast .jw-ad-icon-container{position:absolute;display:none;pointer-events:all;cursor:pointer}.jwplayer .jw-plugin-vast .jw-ad-icon-container.jw-ad-icon-active{display:block}.jwplayer .jw-plugin-vast .jw-ad-icon-container iframe{pointer-events:none;border:none;height:100%;width:100%;margin:0}.jw-plugin-vast.jw-vast-nonlinear-active .jw-banner{opacity:1}.jw-plugin-vast.jw-vast-nonlinear-active .jw-vast-nonlinear-close-button{margin:0 auto;opacity:.75}.jw-plugin-vast.jw-vast-nonlinear-active:hover .jw-vast-nonlinear-close-button{opacity:1}.jw-plugin-vast.jw-vast-nonlinear-collapsed .jw-vast-nonlinear-open-button{margin:0 auto;opacity:.5}.jw-plugin-vast.jw-vast-nonlinear-collapsed .jw-banner,.jw-plugin-vast.jw-vast-nonlinear-collapsed .jw-vast-nonlinear-close-button{opacity:0}.jw-plugin-vast.jw-vast-nonlinear-collapsed:hover .jw-vast-nonlinear-open-button{opacity:1}.jw-plugin-vast.jw-vast-nonlinear-collapsed:hover .jw-vast-nonlinear-close-button{opacity:0}.jw-plugin-vast .jw-vast-nonlinear-close-button,.jw-plugin-vast .jw-vast-nonlinear-open-button{position:absolute;right:0;bottom:0;left:0;display:block;margin:auto;width:18px;height:18px;cursor:pointer;opacity:0;transition:opacity .2s ease}.jw-plugin-vast .jw-vast-nonlinear-close-button{transform:rotate(45deg)}"),(window.jwplayerPluginJsonp||window.jwplayer().registerPlugin)(c,"8.1",(function(e,t,i){var r=new vt(e,t,c),a=e.getConfig(),s=e.getEnvironment(),o=t.debug&&t.trackFn?t.trackFn:null,l=this,d=void 0===t.withCredentials||t.withCredentials,u=null,h=t.bids&&t.bids.settings?t.bids.settings.mediationLayerAdServer||f:null;if((h===f||h===m)&&t.bids.bidders){var k=t.bids.bidders;k.length&&(u=n({},t.bids,{bidders:k}))}var P,A,w,b={withCredentials:d},T=!1,E=0,_=!1;function I(i,a,s){var o=r.getSchedule(i,a),d=new ut(e,o,i,t,s,w,_);return d.init(u,s).then((function(){d.isDestroyed()||e.trigger(g,F(d,null,{schedule:o}))})).catch(ft),d.on("preloadNext",(function(e){var t=n({},s,{preloadPreroll:!0,playlistItemEventCount:E+1});d.next=I(e.item,t.playlistItemEventCount,t)}),l),d}function R(t){P&&(t&&(A=P.next,T=P.nextPlaylistRelated),P.schedule.reset(),P.off(null,null,l),P.destroy(),P=null),r.reset(),e.setCues([])}function S(t){var i=t.getMidRolls(),r=[];i.length&&i.forEach((function(e){"nonlinear"!==e._type&&r.push({begin:e._offSet,text:b.cuetext,cueType:"ads"})})),e.addCues(r)}this.version="8.8.2",n(this,e.Events),e.utils.addClass(i,"jw-plugin-vast"),e.on({ready:function(){a.localization=e.getConfig().localization,(b=r.getOptParams(t,a.localization.advertising)).debugTrackFn=o,w={staticPlayer:new M(e,i),companion:new C(o,s,{openLink:e.utils.openLink}),div:i,optionalParams:b}},cast:function(e){_=!!e.active},play:function(e){l.trigger(y,e)},playlistItem:function(t){E+=1,R(!0);var i=e.getPlaylistItem(t.index);A&&i!==A.item&&!T&&(A.off(null,null,l),A.destroy(),A=null,T=!1);b.playlistItemEventCount=E,(P=A||I(i,E,b)).attachListeners(),A=null,T=!1,P.schedule.isVMAP()?P.vmapPromise.then((function(){P.isDestroyed()||S(P.schedule)})).catch(ft):S(P.schedule)},playlistComplete:R,complete:function(){P&&P.clearNonlinearAd()},destroyPlugin:R},this),e.pauseAd=function(e,t){e="boolean"!=typeof e||e,P&&P.pauseAd(e,t)},e.playAd=function(t){var i,r=0===b.requestTimeout?1/0:b.requestTimeout,a=0===b.creativeTimeout?1/0:b.creativeTimeout;i=Array.isArray(t)?t.slice(0):[t];var n=e.utils.genId,s={_id:n(12),_adQueue:i,_waterfallIndex:0,_adPodIndex:0,adBreakId:n(12),_offset:0,_position:U(e),requestTimeout:r||p,creativeTimeout:a||v};P?(P.clearNonlinearAd(),P.playAdAPI(s)):e.once("playlistItem",(function(){return P.playAdAPI(s)}))},e.skipAd=function(){P&&P.skipAd()},this.destroy=R}))}();