!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<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function r(e,t,r){return t&&i(e.prototype,t),r&&i(e,r),e}function a(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function n(){return(n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e}).apply(this,arguments)}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function d(e,t,i){return(d="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,i){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=s(e)););return e}(e,t);if(r){var a=Object.getOwnPropertyDescriptor(r,t);return a.get?a.get.call(i):a.value}})(e,t,i||e)}function u(e){return function(e){if(Array.isArray(e)){for(var t=0,i=new Array(e.length);t<e.length;t++)i[t]=e[t];return i}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var c,h="vast",p="ssl.p.jwpcdn.com/player/lib/omid/v/1.3.15/omid-session-client-v1.js",v="ssl.p.jwpcdn.com/player/lib/omid/v/1.3.15/omweb-v1.js",f=5e3,m=15e3,y="jwp",g="jwpspotx",k="playing",P="mediaLoaded",A="adSchedule",w="click",b="play",E="error",T="complete",_=["adImpression","adError","adPodError"],I=["adStarted","adComplete","adImpression","adClick","adSkipped","adError","adPlay","adPause","adMeta"],C="instream",S="article",R=(a(c={},[C],1),a(c,["banner"],2),a(c,[S],3),a(c,["feed"],4),a(c,["floating"],5),a(c,["interstitial"],5),a(c,["slider"],5),c),x=function(){function e(i,r,a){t(this,e),this.debugTrackFn=i,this.div=null,this.elem=null,this.environment=r,this.utils=a}return r(e,[{key:"addCompanion",value:function(e,t){if(this.div=e,this.elem=document.getElementById(this.div.id),!this.elem)return!1;for(var i=0;i<t.length;i++)if(this.fitsDiv(t[i]))return this.placeCompanion(t[i]),!0;return!1}},{key:"removeCompanion",value:function(){this.elem.innerHTML=""}},{key:"sendPings",value:function(e){(e=e.creativeView)&&(e.forEach((function(e){(new Image).src=e})),"function"==typeof this.debugTrackFn&&this.debugTrackFn({type:"companion",data:{trackers:e}}))}},{key:"placeCompanion",value:function(e){var t=this;if(this.removeCompanion(),"html"===e.type){var i=document.createElement("div");i.innerHTML=e.source;var r=i.getElementsByTagName("script");return r.length&&r.forEach((function(e){new t.utils.scriptloader(e.src).load(),e.parentElement.removeChild(e)})),this.elem.appendChild(i),void this.sendPings(e.trackers)}if("iframe"===e.type){var a=document.createElement("iframe");return a.height=this.div.height,a.width=this.div.width,a.src=e.source,a.scrolling="no",a.style.border="none",a.marginWidth=0,a.marginHeight=0,this.sendPings(e.trackers),this.elem.innerHTML="",void this.elem.appendChild(a)}if("application/x-shockwave-flash"===e.type){var n=document.createElement("object");return n.setAttribute("type","application/x-shockwave-flash"),n.setAttribute("data",e.source),n.setAttribute("width","100%"),n.setAttribute("height","100%"),n.setAttribute("tabindex",0),j(n,"allowfullscreen","true"),j(n,"allowscriptaccess","always"),j(n,"seamlesstabbing","true"),j(n,"wmode","opaque"),this.elem.appendChild(n),void this.sendPings(e.trackers)}var s=new Image;s.src=e.source,e.clickthrough&&(s.onclick=function(){t.utils.openLink(e.clickthrough,"_blank",{rel:"noreferrer"})}),this.elem.innerHTML="",this.elem.appendChild(s),this.sendPings(e.trackers)}},{key:"fitsDiv",value:function(e){return e.width===this.div.width&&e.height===this.div.height}}]),e}();function j(e,t,i){var r=document.createElement("param");r.setAttribute("name",t),r.setAttribute("value",i),e.appendChild(r)}var O=document.createElement("img"),V=document.createElement("img");O.src=V.src='data:image/svg+xml;charset=UTF-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><circle cx="32" cy="32" r="32" fill="%23191919"/><line stroke="%23CCC" stroke-width="6" x1="32" y1="20" x2="32" y2="44"/><line stroke="%23CCC" stroke-width="6" x1="20" y1="32" x2="44" y2="32"/></svg>',O.className="jw-vast-nonlinear-open-button",V.className="jw-vast-nonlinear-close-button";var M=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(O),this.div.appendChild(this.banner),this.div.appendChild(V),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(V,{bottom:this.banner.height-8,left:this.banner.width},!0),new e.UI(this.banner).on("click tap",this.sendClick.bind(this)),V.onclick=V.ontouchstart=this.collapse.bind(this),O.onclick=O.ontouchstart=this.expand.bind(this),this.trigger(b)}else this.imageLoadError()}},{key:"imageLoadError",value:function(){clearTimeout(this.loadTimer),this.trigger(E),this.removeBanner()}},{key:"sendClick",value:function(){this.trigger(w)}},{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(V),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(V))}},{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),V.onclick=V.ontouchstart=O.onclick=O.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(V),this.remove(O)}}]),e}(),B=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 M(this.player,e,t,this.div,a),this.static.on(b,this.startAd,this),this.static.on(w,this.clickHandler,this),this.static.on(E,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(b)}},{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(w)}},{key:"errorHandler",value:function(){this.sendEvent(E)}},{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 k}},{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(T))}},{key:"pause",value:function(){}}]),e}(),L=/^(https?:\/\/).*.(?:ampproject.org|bing-amp.com)\/(?:.\/)*(.*)\/amp.*$/;var H=new RegExp(/^[^/]*:\/\/\/?([^\/]*)/);function D(e){var t=e.match(H);return t&&t.length>1?t[1]:""}var N,q=new RegExp(/^[^:\/?#]+:?\/\/[^\/?#]+/);function F(){var e,t,i=null!==document.referrer.match(q)?(e=document.referrer,(t=e.match(L))&&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:D(i),referrer:""}}return{url:document.location.href,domain:document.domain,referrer:i}}function U(e){var t=e.advertising;if(t&&t.placement){var i=t.placement.toLowerCase();if(R[i])return R[i]}return R[t&&t.outstream?S:C]}function Q(e,t,i,r){var a=W(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 W(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:h};if(null===e)return r;var a=e.bidding,s=e.config,o=e.item,l=e.player;e.isDestroyed()||(r.placement=U(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),c=u.adBreakId,p=u.adPlayId;if(n(r,{adBreakId:c,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||"",adVerifications:t.adVerifications||null,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 X(e){return e.isBeforePlay()||0===e.getPosition()&&"idle"===e.getState()?"pre":e.isBeforeComplete()||e.getPosition()===e.getDuration()?"post":"mid"}var z="vast",G="googima",J="shared",$=1e3,Y=4096,K="[ERRORCODE]",Z="vmap",ee="-1",te="cust_params=",ie=5e3,re=5e3,ae="adBreakIgnored",ne="adError",se="__jwpseg__",oe="instream",le="article",de=(a(N={},[oe],1),a(N,["banner"],2),a(N,[le],3),a(N,["feed"],4),a(N,["floating"],5),a(N,["interstitial"],5),a(N,["slider"],5),N),ue="inference",ce=new RegExp(/^[^/]*:\/\/\/?([^\/]*)/);function he(e){var t=e.match(ce);return t&&t.length>1?t[1]:""}var pe=new RegExp(/^[^:\/?#]+:?\/\/[^\/?#]+/);var ve=/^(https?:\/\/).*.(?:ampproject.org|bing-amp.com)\/(?:.\/)*(.*)\/amp.*$/;var fe=null,me={gdprApplies:!0,consentData:""},ye=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e3;return null===fe&&(fe=new Promise((function(e){var t=window.__tcfapi||ge("__tcfapi");if(t)return t("getTCData",2,(function(t,i){e(!1!==i?{gdprApplies:t.gdprApplies,consentData:t.tcString}:null)}));var i=window.__cmp||ge("__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&&(me=e),me}))),Promise.race([fe,new Promise((function(t){setTimeout(t,e,me)}))])},ge=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=ke();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),"*")}},ke=Date.now||function(){return(new Date).getTime()};function Pe(e){var t=e.advertising;if(t&&t.placement){var i=t.placement.toLowerCase();if(de[i])return de[i]}return de[t&&t.outstream?le:oe]}function Ae(){var e,t,i=null!==document.referrer.match(pe)?(e=document.referrer,(t=e.match(ve))&&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:he(i),referrer:""}}return{url:document.location.href,domain:document.domain,referrer:i}}function we(e,t){var i,r=e.getPlugin(ue),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 be(e,t,i){var r=Ee(e,t,i);return n(r,{message:"Ad Error: bidding plugin unavailable",code:900,adErrorCode:60008}),r}function Ee(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:Pe(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 c=a.getBid(u);c&&n(r,c.getEventObject())}}return r.item=s,r}function Te(e,t,i,r){return{client:r,message:e,adErrorCode:t,id:ee,placement:Pe(i),tag:""}}var _e=/^((https?:)?\/\/)?(secure)?pubads\.g\.doubleclick\.net\/gampad\/ads\?[\S]*$/;function Ie(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:we(e,t),placement:Pe(i),userAgent:navigator.userAgent};var a,n,s}(t,i),o=Ae();-1!==e.indexOf(se)&&(n.jwpseg=s.jwpseg),e=Ce(e,"__random-number__",Math.random()*Math.pow(10,18)),e=Ce(e,"__timestamp__",(new Date).getTime()),e=Ce(e,"__page-url__",encodeURIComponent(o.url)),e=Ce(e,"__referrer__",encodeURIComponent(o.referrer)),e=Ce(e,"__player-height__",s.playerHeight),e=Ce(e,"__player-width__",s.playerWidth),e=Ce(e,"__item-duration__",s.itemDuration),e=Ce(e,se,s.jwpseg),e=Ce(e,"__domain__",encodeURIComponent(o.domain)),e=Ce(e,"__placement__",s.placement),e=Ce(e,"__device-ua__",encodeURIComponent(s.userAgent));for(var l=null,d=/__item-([\w-]+?)(-list)?__/g,u=e=a.companion?Ce(e,"__companion-div__",a.companion.id):Ce(e,"__companion-div__","");null!==(l=d.exec(u));){var c=l[0],h=l[1],p="";if(i.hasOwnProperty(h)&&"string"==typeof i[h]){p=i[h];var v=!1===a.truncateMacros?Y:$;p.length>v&&(p=p.substring(0,v));var f=l[2]?",":null;p=p.split(f).map(encodeURIComponent)}e=Ce(e,c,p)}if(r===z){var m=t.getConfig().autostart?1:0,y=t.getMute()?1:0;e=function(e,t,i){_e.test(e)&&(e="".concat(e,"&vpa=").concat(t,"&vpmute=").concat(i));return e}(e,m,y)}if(r===G&&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__")?ye().then((function(t){var i=t.gdprApplies,r=t.consentData;return e=Ce(e,"__gdpr__",i?1:0),Ce(e,"__gdpr_consent__",r)})).catch((function(){return e})):Promise.resolve(e)}function Ce(e,t,i){return e.replace(t,i)}var Se=Array.prototype,Re=Se.forEach,xe=Se.map,je=function(){};function Oe(e,t,i){if(De(e,"VMAP",Z).length)return function(e,t,i){var r=[];Fe(De(e,"VMAP",Z)[0],"version")||Be(r,"VMAP Schema Error: version missing from VMAP tag",ee);var a=De(e,"AdBreak",Z);a.length||Le();for(var n=e.lookupNamespaceURI(Z),s=0;s<a.length;s++){var o={},l={},d=a[s],u=Fe(d,"timeOffset"),c=Fe(d,"breakId"),h=Fe(d,"breakType"),p=Fe(De(d,"AdSource",Z)[0],"id"),v=De(d,"AdTagURI",Z)[0],f=De(d,"VASTData",Z)[0]||De(d,"VASTAdData",Z)[0],m=Fe(v,"templateType"),y=Qe(v),g=qe(n,d,"Tracking",Z);if(h||Be(r,"VMAP Schema Error: missing breakType on AdBreak",c),f||m||Be(r,"VMAP Schema Error: missing templateType on AdBreak",c),u||Be(r,"VMAP Schema Error: missing timeOffset on AdBreak",c),o._type=h,o._vmap={id:p,breakid:c,timeoffset:u},f)o._adXML=Ve(Ne(f,"VAST"));else{if("vast2"!==m&&"vast3"!==m&&"vast4"!==m)continue;o._adQueue=[y],o._waterfallIndex=0}var k=[];if(g)for(var P=0;P<g.length;P++){Ue(l,g[P]);var A=Fe(g[P],"event");k.push(A)}switch((k.indexOf("breakStart")<0||k.indexOf("breakEnd")<0||k.indexOf("error")<0)&&Be(r,"Tracking events are missing breakStart, breakEnd, or error for AdBreak",c),o._trackers=l,o._type=h,u){case"start":o._offSet="pre",t.setPreRoll(o);break;case"100%":case"end":o._offSet="post",t.setPostRoll(o);break;default:if(/^#/.test(u))break;/^\d\d?(?:\.\d+)?%$/.test(u)?o._offSet=u:o._offSet=i.seconds(u),t.addMidRoll(o)}}t.preRoll||t.midRolls.length||t.postRoll||Le();return t.sort(null,!0),r}(e,t,i);if(De(e,"Playlist",Z).length)return function(e,t,i){var r=De(e,"Playlist",Z)[0],a=r.getElementsByTagName("Preroll")[0],n=r.getElementsByTagName("Postroll")[0],s=Me(a,"pre"),o=Me(n,"post");s&&t.setPreRoll(s);o&&t.setPostRoll(o);for(var l=r.getElementsByTagName("Midroll"),d=0;d<l.length;d++){var u=l[d],c=i.seconds(u.getAttribute("timeOffset")),h=Me(u,c);t.addMidRoll(h)}return[]}(e,t,i);throw new Error("No VMAP tag in response")}function Ve(e){return e.ownerDocument instanceof Document?e.outerHTML||(new XMLSerializer).serializeToString(e):null}function Me(e,t){if(!e)return null;var i=e.getElementsByTagName("Ad");if(!i.length)return null;var r={_offSet:t};if(1===i.length)r._adQueue=[i[0].textContent.trim()];else{r._pod=[];for(var a=0;a<i.length;a++)r._pod.push(i[a].textContent.trim())}return r}function Be(e,t,i){e.push({message:t,code:1002,adErrorCode:70001,id:i})}function Le(){var e=new Error("No AdBreaks in VMAP");throw e.adErrorCode=60005,e}var He=function(){function i(e,r){t(this,i),this.utils=r,this._error=null,this._version=null,e&&this.parse(e)}return r(i,[{key:"error",value:function(){return this._error}},{key:"version",value:function(){return this._version}},{key:"parse",value:function(e,t){var i,r=this;"VAST"===e.nodeName?i=e:(i=Ne(e,"VAST"))||(i=Ne(e,"VideoAdServingTemplate")),i||this.throwError(101,"Invalid VAST response");var a="VideoAdServingTemplate"===i.tagName?1:parseFloat(Fe(i,"version")||0);this._version=a;var n,s=De(i,"Ad"),o=xe.call(s,(function(i){var n=r.parseAd(a,i);return n.vastversion=a,n.response=e,n.request=t||null,n}));return o.length||(n=De(i,"Error"),Re.call(n,(function(e){var t=Qe(e).replace(K,303);(new Image).src=t}))),o}},{key:"parseAd",value:function(t,i,r){r=r||{};var a,s,o,l,d,u=Ne(i,"InLine"),c=Ne(i,"Wrapper"),h=u||c,p=Ne(h,"Advertiser"),v=Ne(h,"AdVerifications");return v&&(r.adVerifications=(s=De(v,"Verification"),o=[],Re.call(s,(function(e){var t=Fe(e,"vendor"),i=Ne(e,"JavaScriptResource"),r=Ne(e,"ExecutableResource"),a=Qe(Ne(e,"VerificationParameters")),n=De(Ne(e,"TrackingEvents"),"Tracking"),s={},l={vendor:t,verificationParameters:a,trackers:s};i&&(l.javaScriptResource={url:Qe(i),apiFramework:Fe(i,"apiFramework"),browserOptional:Fe(i,"browserOptional")}),r&&(l.executableResource={url:Qe(r),apiFramework:Fe(r,"apiFramework"),type:Fe(r,"type")}),Re.call(n,(function(e){Ue(s,e)})),o.push(l)})),o)),r.sequence=Fe(i,"sequence"),r.adId=Fe(i,"id"),r.adTitle=Qe(Ne(h,"AdTitle")),r.advertiser=Qe(p),r.advertiserId=Fe(p,"id"),r.description=Qe(Ne(h,"Description")),r.dealId=Qe(Ne(h,"DealId")),(!t||t>4.2||t<2)&&this.throwError(102,"Vast version not supported"),t>=4&&(r.conditionalAd=!!Fe(i,"conditionalAd")),h?(Xe(h,"Impression",(a=function(e,t,i){var r=De(Ne(e,"Creatives"),"Creative"),a={},n={trackers:a};n.adServingId=Qe(Ne(e,"AdServingId")),n.adsystem=Qe(Ne(e,"AdSystem"));var s=De(e,"Category");return n.categories=xe.call(s,(function(e){return Qe(e)})),Re.call(r,(function(e){var r=Ne(e,"Linear"),s=Ne(e,"NonLinear"),o=De(Ne(e,"TrackingEvents"),"Tracking");if(t>=4){var l=De(e,"UniversalAdId");n.universalAdId=xe.call(l,(function(e){return{universalAdIdRegistry:Fe(e,"idRegistry")||"unknown",universalAdIdValue:Qe(e)||Fe(e,"idValue")||"unknown"}}))}n.creativeId=Fe(e,"id"),n.creativeAdId=Fe(e,"adId"),(r||s)&&Re.call(o,(function(e){Ue(a,e)}));var d=Qe(Ne(e,"AdParameters"));if(d&&(n.adParams=d),r){var u=Ne(r,"VideoClicks"),c=Qe(Ne(u,"ClickThrough")),h=De(u,"ClickTracking"),p=Fe(r,"skipoffset"),v=Qe(Ne(r,"Duration"));Re.call(h,(function(e){We(a,"click",Qe(e))})),v&&(n.duration=i.seconds(v)),c&&(n.clickthrough=c),void 0!==p&&(n.skipoffset=p),function(e,t){var i=De(Ne(e,"MediaFiles"),"MediaFile"),r=t.media?t.media:[];t.media=r.concat(xe.call(i,(function(e){return{type:Fe(e,"type"),file:Qe(e),adType:Fe(e,"apiFramework")||"",width:parseInt(Fe(e,"width"),10)||0,height:parseInt(Fe(e,"height"),10)||0,bitrate:parseInt(Fe(e,"bitrate"),10)||null,maxBitrate:parseInt(Fe(e,"maxBitrate"),10)||null}})).filter((function(e){return e.file})))}(r,n),function(e,t){var i=De(e,"Icon");t.icons=Array.prototype.reduce.call(i,(function(e,t){var i,r;if(i=Ne(t,"StaticResource"))r=Fe(i,"creativeType");else if(i=Ne(t,"IFrameResource"))r="iframe";else{if(!(i=Ne(t,"HTMLResource")))return e;r="html"}var a=Qe(i),n={};n.iconClick=Qe(Ne(t,"IconClickTracking"))||null,n.iconView=Qe(Ne(t,"IconViewTracking"))||null;var s=Fe(t,"xPosition").toLowerCase(),o=Fe(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(Fe(t,"width"),10)||0,l.height=parseInt(Fe(t,"height"),10)||0,e.push({program:Fe(t,"program"),style:l,apiFramework:Fe(t,"apiFramework"),offset:Fe(t,"offset")||"00:00:00",duration:Fe(t,"duration")||null,clickThrough:Qe(Ne(t,"IconClickThrough")),trackers:n,resource:{resourceType:r,resourceSource:a}}),e}),t.icons||[])}(r,n)}else if(s){var f=Qe(Ne(s,"NonLinearClickThrough"));f&&(n.clickthrough=f),function(e,t){var i=[],r=Ne(e,"StaticResource");r&&(i.push({type:Fe(r,"creativeType"),file:Qe(r),adType:Fe(Ne(e,"NonLinear"),"apiFramework")||"static",minDuration:Fe(Ne(e,"NonLinear"),"minSuggestedDuration")||"00:00:00"}),t.media=i)}(e,n)}else!function(e,t){var i=De(Ne(e,"CompanionAds"),"Companion"),r=t.companions?t.companions:[];Re.call(i,(function(e){var t,i,a=Ne(e,"StaticResource"),n=Ne(e,"IFrameResource"),s=Ne(e,"HTMLResource"),o={};if(a)t=Fe(a,"creativeType"),i=Qe(a);else if(n)t="iframe",i=Qe(n);else{if(!s)return;t="html",i=Qe(s)}var l=De(Ne(e,"TrackingEvents"),"Tracking");Re.call(l,(function(e){var t=Fe(e,"event");We(o,t,Qe(e))}));var d=Qe(Ne(e,"CompanionClickThrough"));r.push({width:parseInt(Fe(e,"width"),10),height:parseInt(Fe(e,"height"),10),type:t,source:i,trackers:o,clickthrough:d})})),t.companions=r}(e,n)})),n}(h,t,this.utils)).trackers),Xe(h,"Error",a.trackers),Xe(h,"NotViewable",a.trackers),Xe(h,"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),c&&(a.wrappedURI=Qe(Ne(c,"VASTAdTagURI"))||Qe(Ne(c,"VASTAdTagURL")),a.followAdditionalWrappers=JSON.parse(Fe(c,"followAdditionalWrappers")),a.allowMultipleAds=JSON.parse(Fe(c,"allowMultipleAds")),a.fallbackOnNoAd=JSON.parse(Fe(c,"fallbackOnNoAd"))),l=a,d=n({},r),Object.keys(l).forEach((function(t){var i=l[t];Array.isArray(d[t])?d[t]=d[t].concat(i):"object"===e(d[t])&&null!==d[t]?d[t]=n(d[t],i):d[t]=i})),a=d):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 De(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 Ne(e,t){if(e){var i=e.getElementsByTagName(t);if(i)return i[0]}return null}function qe(e,t,i,r){var a=[];return e||t?a=t.getElementsByTagNameNS?t.getElementsByTagNameNS(e,i):t.getElementsByTagName("".concat(r,":").concat(i)):a}function Fe(e,t){return e?e.getAttribute(t):null}function Ue(e,t){var i=Fe(t,"event");if("progress"===i){var r=Fe(t,"offset");i="".concat(i,"_").concat(r)}We(e,i,Qe(t))}function Qe(e){if(e){var t=e.textContent||e.text;if(t)return t.trim()}return""}function We(e,t,i){e[t]||(e[t]=[]),i&&(e[t].push(i),ze(i))}function Xe(e,t,i){var r=De(e,t);xe.call(r,(function(e){We(i,t.toLowerCase(),Qe(e))}))}var ze=function(e){(e.indexOf("[REGULATIONS]")>=0||e.indexOf("[GDPRCONSENT]")>=0)&&(ye().catch(je),ze=je)};function Ge(e){e.onload=e.onreadystatechange=e.onerror=null,"abort"in e&&e.abort()}var Je=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&&(Ge(this._vmapXHR),this._vmapXHR=null);var s=Ie(this.getVMAP(),e,t,i,r);return i===G?(this._vmapPromise=s.then((function(e){a.setPreRoll({_adQueue:[e]})})),this._vmapPromise):(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,Oe(i.responseXML,a,e.utils).map((function(e){return n(e,{vmap:t})}))})).catch((function(i){a._vmapXHR=null;var r={id:ee,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+1<e._adQueue.length}},{key:"getPreRoll",value:function(e){return e&&"none"===this.adRules.startOnSeek?null:$e(this.preRoll,this.requestTimeout,this.creativeTimeout)}},{key:"getPostRoll",value:function(e){var t=$e(this.postRoll,this.requestTimeout,this.creativeTimeout);return this.adRules.timeBetweenAdsAllowsAdPlayback(t,e)?t:null}},{key:"getMidRollAtIndex",value:function(e){return $e(this.midRolls[e],this.requestTimeout,this.creativeTimeout)}},{key:"getLastMidRollIndexBetweenTime",value:function(e,t,i){if(e>t)return null;this.sort(i);for(var r=this.midRolls.length;r--;){var a=this.midRolls[r],n=Ye(this.midRolls[r]._offSet,i);if(e>=n)return null;if(t>=n){var s=$e(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=Ye(this.midRolls[r]._offSet,i);if(a>=e&&-1===this.playedMidRolls.indexOf(r)){var n=ke()+1e3*(a-e);return a<=t&&this.adRules.timeBetweenAdsAllowsAdPlayback(null,n)?r:null}r+=1}}var s=ke()+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 $e(t,e.requestTimeout,e.creativeTimeout)}))}},{key:"reset",value:function(){null!==this._vmapXHR&&(Ge(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 Ye(t._offSet,e)-Ye(i._offSet,e)})),function(e,t){for(var i=0;i<e.length;i++){var r=e[i];t?r._vmap.item=i+1:(r._adbreak={item:i+1,breakid:r._breakId},r._pod?r._adbreak.pod=r._pod:r._adbreak.tags=r._adQueue)}}(this.getAllAds(),t))}},{key:"getAllAds",value:function(){var e=this.preRoll?[this.preRoll]:[],t=this.postRoll?[this.postRoll]:[];return e.concat(this.midRolls,t)}},{key:"setVMAP",value:function(e){this.vmap=e}},{key:"isVMAP",value:function(){return!!this.vmap}},{key:"getVMAP",value:function(){return this.vmap}},{key:"getClosestIndex",value:function(e,t){this.sort(t);for(var i=this.midRolls.length;i--;)if(e>=Ye(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 $e(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 Ye(e,t){return"%"===e.toString().slice(-1)?t*parseFloat(e.slice(0,-1))/100:parseFloat(e)}var Ke=function(){function e(i){t(this,e),this.utils=i}return r(e,[{key:"getSchedule",value:function(e,t){var i=new Je(t,this.utils);if(i.requestTimeout=et(e.requestTimeout,ie),i.creativeTimeout=et(e.creativeTimeout,re),e.tag)i.setPreRoll({_offSet:"pre",_adQueue:Ze(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=et(t.requestTimeout,ie),l=et(t.creativeTimeout,re),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 c=t.skipoffset;if(void 0!==c&&void 0===u.skipoffset&&(u.skipoffset=c),"string"==typeof t.adm)u.adm=t.adm;else if(t.pod){var h=u._pod||[];u._pod=h.concat(t.pod)}else if(t.tag){var p=function(e,t){if(!t)return e;var i=e.indexOf("?")>=0?"&":"?",r=e.indexOf(te),a=te.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(te).concat(n)}(t.tag,t.custParams);u._adQueue&&(u._pod=[u._adQueue[0]],delete u._adQueue),u._pod?u._pod.push(Ze(p)[0]):u._adQueue=Ze(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,omidAccessMode:e.omidAccessMode||"full",omidSupport:e.omidSupport||"auto",allowedOmidVendors:e.allowedOmidVendors||[],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 Ze(e){return Array.isArray(e)?e.slice(0):[e]}function et(e,t){return 0===e?1/0:e||t}var tt=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(ae,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:ae})}(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=ke())}},{key:"timeBetweenAdsAllowsAdPlayback",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ke();if(this.options.timeBetweenAds){var i=(t-this.recentCompletedAdTime)/1e3;if(i<this.options.timeBetweenAds)return this.sendAdBreakIgnored(e,i),!1}return!0}},{key:"reset",value:function(){this.ignoreStartOnSeek=!1,this.recentCompletedAdTime=0}},{key:"destroy",value:function(){this.player.off(null,null,this)}},{key:"timeBetweenAds",get:function(){return this.options.timeBetweenAds}},{key:"startOnSeek",get:function(){return this.ignoreStartOnSeek?null:this.options.startOnSeek}}]),e}(),it=function(){},rt=function(){function e(i,r,a,s,o){t(this,e),n(this,i.Events),this.client=J,this.player=i,this.item=a,this.config=s,this.casting=o;var l=i.utils,d=new Ke(l);this.adRules=new tt(i,d.getAdRules(s)),"string"==typeof r?(this.schedule=new Je(this.adRules,l),this.schedule.setPreRoll({tag:r})):(this.schedule=r,r.resetAllBreakIds()),this.vmapPromise=null,this.lastTimeEvent=null,this.prerollPromise=null,this.midrollPromise={},this.postrollPromise=null,this.next=null,this.nextPlaylistItemPromise=null,this.relatedNextUp=null,this.bidding=i.getPlugin("bidding"),this.bids=[],this.bidsPromises=[],this.bidsPromise=null,this._events=[]}return r(e,[{key:"attachListeners",value:function(){this.player.on({all:this.onAll,beforePlay:this.checkPreroll,relatedReady:this.relatedReady,cast:this.onCast,destroyBidding:this.destroyBids},this)}},{key:"onAll",value:function(e,t){"time"===e?this.checkMidrolls(t):"beforeComplete"===e&&this.checkPostrolls(t)}},{key:"relatedReady",value:function(){var e=this;if(this.config.preloadAds){var t=this.player.getPlugin("related");t&&t.on("nextUp",(function(t){t&&"discovery"===t.mode&&(e.relatedNextUp=t)}))}}},{key:"onCast",value:function(e){this.casting=!!e.active}},{key:"init",value:function(){var e=this,t=arguments.length>0&&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=be(e,null,i);e.player.trigger(ne,r)}})).catch(it):this.bidsPromise.catch(it),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(ne,t,{preload:!0})})):this.player.once("autostartNotAllowed",(function(){e.loadPreroll(i).catch((function(t){return e.isDestroyed()?null:e.enqueueAdEvent(ne,t,{preload:!0})}))}))}else i.preloadPreroll&&this.loadPreroll(i).catch((function(t){return e.isDestroyed()?null:e.enqueueAdEvent(ne,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=we(r,i.item),c={id:s,offset:e.offset,jwpseg:u,placement:Pe(o),tag:a._adQueue?a._adQueue[0]:a._currentTag,adClient:i.client};i.client===z&&(c.skipoffset=d?l:-1);var h=i.bidding.createNewBid(c,{getURLParts:Ae});i.player.trigger("adBidRequest",Ee(i,a,n({jwpseg:u},t))),h.init();var p=h.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=Ie(r.tag,i.player,i.item,i.client,{},a).then((function(e){i.client===z?(a._adQueue=a._adQueue||[],a._adQueue.unshift(e)):a._adQueue=[e]})))),i.player.trigger("adBidResponse",Ee(i,a,t)),n}}));return i.bidsPromises.push(p),h})),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(it);else if(-1===n){var s=ke()+1e3*(e.duration-e.position);this.loadPostroll({adBlock:this.adBlockErrorDetected,preload:!0,startTime:s}).catch(it)}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(it)}}}}}},{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(){if(!t.isDestroyed()){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.destroyBids(),this.player.off(null,null,this),this.player=null}},{key:"destroyBids",value:function(){this.bids.forEach((function(e){return e.stop()})),this.bidsPromises=[],this.bids=[]}},{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}(),at=function(){function e(i,r,a,s,o,l){t(this,e),n(this,i.Events),this.player=i,this.startingSize=i.getWidth()*i.getHeight();var d=o.allowedOmidVendors;try{var u=[];s.forEach((function(e){var t=e.javaScriptResource,i=e.vendor,a=e.verificationParameters,n=e.trackers;d.length&&d.indexOf(i)<0?l("verificationNotExecuted",n.verificationNotExecuted,{"[REASON]":1}):t?t.url?u.push(new r.VerificationScriptResource(t.url,i,a,o.omidAccessMode)):l("verificationNotExecuted",n.verificationNotExecuted,{"[REASON]":3}):l("verificationNotExecuted",n.verificationNotExecuted,{"[REASON]":2})}));var c=new r.Partner("JWPlayer",i.version),h=new r.Context(c,u,location.href);h.setVideoElement(a),h.underEvaluation=!0,h.setServiceWindow(window);var p=this.adSession=new r.AdSession(h);if(!p.isSupported())return;this.adEvents=new r.AdEvents(p),this.mediaEvents=new r.MediaEvents(p),p.start()}catch(e){return console.log(e),null}}return r(e,[{key:"resetResizeTimeout",value:function(){var e=this;clearTimeout(this.resizeTimer),this.isFullscreen||(this.resizeTimer=setTimeout((function(){if(e.mediaEvents){var t=e.player.getWidth(),i=e.player.getHeight();t*i>e.startingSize?e.mediaEvents.playerStateChange("expanded"):t*i<e.startingSize?e.mediaEvents.playerStateChange("collapsed"):e.mediaEvents.playerStateChange("normal")}}),250))}},{key:"trackEvent",value:function(e){var t,i;if(this.adEvents&&this.mediaEvents){for(var r=arguments.length,a=new Array(r>1?r-1:0),n=1;n<r;n++)a[n-1]=arguments[n];switch(e){case P:this.adEvents.loaded();break;case"click":this.mediaEvents.adUserInteraction("click");break;case"close":this.finishSession();break;case"complete":this.mediaEvents.complete(),this.finishSession();break;case"firstQuartile":this.mediaEvents.firstQuartile();break;case"fullscreen":this.isFullscreen=a[0],this.resetResizeTimeout(),this.isFullscreen&&this.mediaEvents.playerStateChange("fullscreen");break;case"impression":(t=this.mediaEvents).start.apply(t,a),this.adEvents.impressionOccurred(),this.startingSize=this.player.getWidth()*this.player.getHeight(),this.isFullscreen=this.player.getFullscreen();break;case"midpoint":this.mediaEvents.midpoint();break;case"mute":this.mediaEvents.volumeChange(0);break;case"pause":this.mediaEvents.pause();break;case"resize":this.resetResizeTimeout();break;case"resume":this.mediaEvents.resume();break;case"skip":this.mediaEvents.skipped(),this.finishSession();break;case"thirdQuartile":this.mediaEvents.thirdQuartile();break;case"unmute":this.mediaEvents.volumeChange(this.player.getVolume()/100);break;case"volume":(i=this.mediaEvents).volumeChange.apply(i,a);break;case"bufferStart":this.mediaEvents.bufferStart();break;case"bufferFinish":this.mediaEvents.bufferFinish()}}}},{key:"finishSession",value:function(){this.adSession&&(this.adSession.finish(),this.adSession=null,this.adEvents=null,this.mediaEvents=null)}}]),e}(),nt=null,st=null;function ot(e){return function(e){if(st)return st;var t=["//",v];"file:"===document.location.protocol&&t.unshift("https:");var i=new(0,e.scriptloader)(t.join(""));return st=i.load()}(e).then((function(){return function(e){if(nt)return nt;if(window.OmidSessionClient&&OmidSessionClient.default)return nt=Promise.resolve();var t=["//",p];"file:"===document.location.protocol&&t.unshift("https:");var i=new(0,e.scriptloader)(t.join(""));return nt=i.load()}(e)}))}var lt=[];var dt=function(){function e(i,r,a,n,s,o){var l=this;t(this,e);var d=r||{};this.ad=i,this.map=d,this.omidDeferredEvents=[],o&&i.adVerifications&&"disabled"!==s.omidSupport&&(o.on(P,(function(){o.off(null,null,l),l.trackOmidEvent(P)}),this),ot(n.utils).then((function(){var e=window.OmidSessionClient.default,t=o.getMediaElement();l.omidTracker=new at(n,e,t,i.adVerifications,s,l.trackPingsByUrl.bind(l)),l.omidDeferredEvents.forEach((function(e){var t=e.type,i=e.args;l.trackOmidEvent.apply(l,[t].concat(u(i)))})),l.omidDeferredEvents=[]}))),this.debugTrackFn=a,this.trackerPlayerUtils=function(e){return{getPosition:function(){return e.getPosition()},getFile:function(){return e.getPlaylistItem().file},getPlacement:function(){return U(e.getConfig())},getUserAgent:function(){return navigator.userAgent}}}(n),this.trackingFilter=s.trackingFilter,this.lastQuartile=0,this.progressEvents=[],this.breakStarted=!1,this.started=!1,this.firedError=!1,this.hasComp=!1,this.buffering=!1,Object.keys(d).forEach((function(e){if(d.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),l.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:"trackPingsByUrl",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=this.trackingFilter,a=[],n=[],s=[];if(t.length){i=this.replaceMacros(i),t.forEach((function(e){if(e){if(Object.keys(i).forEach((function(t){e=e.replace(t,i[t])})),r&&!1===r(e))return void n.push(e);var t=new Image;t.src=e,a.push(e),s.push(t)}})),Array.prototype.push.apply(lt,s);for(var o=lt.length;o--&&(lt[o].width||lt[o].complete);)lt.length=o}"function"==typeof this.debugTrackFn&&this.debugTrackFn({type:"ping",data:{pingType:e,urls:a,filteredUrls:n,images:s}})}},{key:"trackPings",value:function(e,t){var i=this.getUrls(e);this.trackPingsByUrl(e,i,t)}},{key:"trackOmidEvent",value:function(e){for(var t,i=arguments.length,r=new Array(i>1?i-1:0),a=1;a<i;a++)r[a-1]=arguments[a];this.omidTracker?(t=this.omidTracker).trackEvent.apply(t,[e].concat(r)):this.omidDeferredEvents.push({type:e,args:r})}},{key:"replaceMacros",value:function(e){var t,i,r,a,n,s,o,l=me,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(F().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"),this.trackOmidEvent("firstQuartile")):2===this.lastQuartile?(this.trackPings("midpoint"),this.trackOmidEvent("midpoint")):3===this.lastQuartile&&(this.trackPings("thirdQuartile"),this.trackOmidEvent("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(){if(t.trackPings(e),"fullscreen"!==e){for(var i=arguments.length,r=new Array(i),a=0;a<i;a++)r[a]=arguments[a];t.trackOmidEvent.apply(t,[e].concat(r))}}}},{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}(),ut=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||{},"boolean"!=typeof this.wrapperOptions.followAdditionalAds&&(this.wrapperOptions.followAdditionalAds=!0),"boolean"!=typeof this.wrapperOptions.allowMultipleAds&&(this.wrapperOptions.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 He(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||[];var n=a.options,s=n.adsystem,o=n.dealId;s&&a.options.wrapper.push(s),o&&(a.options.wrapperDealId=o),a.options.adsystem=a.loadedAds[0].adsystem,a.options.dealId=a.loadedAds[0].dealId;var l=[];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 n=new i(a._scheduledAd,a.player,a.options,{fallbackOnNoAd:e.fallbackOnNoAd,allowMultipleAds:e.allowMultipleAds,followAdditionalWrappers:e.followAdditionalWrappers},a.debugTrackFn),s=Ie(e.wrappedURI,a.player,a.item,h,a.params,e).then((function(e){return n.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),i.adVerifications&&(e.adVerifications=(e.adVerifications?e.adVerifications:[]).concat(i.adVerifications)),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)}));l.push(s)}else a.options.wrapper.length&&(e.wrapper=a.options.wrapper,e.wrappedTags=a.options.wrappedTags,e.dealId=a.options.wrapperDealId)})),Promise.all(l)})).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 dt(r,a,this.debugTrackFn,this.player,this.options).error(e.code)}}}}]),i}();var ct=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    <body onload=\"\n        var js = document.createElement('script');\n        js.src = '".concat(t,"';\n        js.addEventListener('load', function() { window.myCallback(); });\n        document.body.appendChild(js);\"\n    style=\"margin: 0\">")),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:k,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:k}))},AdPlaying:function(){if(t.paused){var i=!e.getAdLinear||e.getAdLinear()?"linear":"nonlinear";t.paused=!1,t.sendEvent("play",{newstate:k,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(){var e=this;if(this.removeEvents(),clearInterval(this.remainingTimeInterval),this.vpaidAd)try{var t=this.listeners,i=this.vpaidAd;Object.keys(t).forEach((function(e){i.unsubscribe(t[e],e,i)})),i.unsubscribe(this.setMuteCallback,"AdVolumeChange",i)}catch(e){}setTimeout((function(){e.iframe&&e.iframe.parentNode&&e.iframe.parentNode.removeChild(e.iframe)}),0),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":k:"idle"}}]),e}();var ht=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 pt=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.omidSupport=u.omidSupport,this.debugTrackFn=u.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&&(mt(this.vastAd,this.debugTrackFn,this.player,this.optionalParams,this.blockingInstreamPlayer),(i=this.prepareAdPodItem(this.vastAd))&&"vpaid"===i.adType&&!ft(this.vastAd)&&(i=null)),this.vastAdPod)for(var n=null,s=0;s<this.vastAdPod.length;s++){var o=this.vastAdPod[s];mt(o,this.debugTrackFn,this.player,this.optionalParams,this.blockingInstreamPlayer);var l=this.prepareAdPodItem(o);if(l){if(n!==l.adType&&"instream"===n)break;if(n=l.adType,"vpaid"!==l.adType||ft(o)){var d=a.length+r===s;l&&d&&a.push(l)}else r++}else r++}return a.length||i?(a.length?(e=a,this.vastOptions=[],e.forEach((function(e){t.vastOptions.push(t.getInstreamOptions(e.vastAd))}))):(e=i,this.vastOptions=this.getInstreamOptions(this.vastAd)),this.adPodItems=e,!0):(this.scheduledAd._pod&&this.scheduledAd._pod.length||this.adError("No Compatible Creatives",403),!1)}},{key:"prepareAdPodItem",value:function(e){e.tracker.linear="linear";var t="".concat(e.media[0].adType).toLowerCase()||"instream";"vpaid"!==t||ft(e)||(t="instream");var i={vastAd:e,sources:[],adType:t};void 0!==this.scheduledAd.skipoffset&&(i.skipoffset=this.scheduledAd.skipoffset);var r=e.media,a={};if(r.forEach((function(e,t){i.sources.push({file:e.file,mimeType:e.type,type:(""+e.type).replace(/^(?:video|audio)\/(?:x-)?/,""),id:t}),a[e.file]={width:e.width||0,height:e.height||0,bitrate:e.bitrate||e.maxBitrate,id:t}})),"instream"===t&&(i.sources=function(e){var t;t=jwplayer.api.availableProviders.filter((function(e){return"flash"!==e.name}));var i=e.filter((function(e){return t.some((function(t){return t.supports(e)}))})),r=i.filter((function(e){return"3gpp"!==e.type}));return r.length?r:i}(i.sources)),0===i.sources.length)return null;var n=this.player.getSafeRegion(!1).width,s=this.player.getConfig().bandwidthEstimate||5e5,o=function(){var e=s/1e3*.95,t=i.sources.map((function(e){return a[e.file]})),r=t.filter((function(e){return e.width>=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.bitrate<e&&i.bitrate>t.bitrate?i:t})),d=o.reduce((function(t,i){return i.bitrate>=e&&i.bitrate<t.bitrate?i:t}));return l||d}return o[0]}().id;return i.vastAd.selectedMedia=i.sources.filter((function(e){return e.id===o}))[0],this.mediaType=i.vastAd.selectedMedia.mimeType.toLowerCase(),i.sources=[i.vastAd.selectedMedia],i}},{key:"getInstreamOptions",value:function(e){return{skipoffset:this.getSkipOffset(e),skipMessage:this.optionalParams.skipMessage,skipText:this.optionalParams.skipText}}},{key:"getSkipOffset",value:function(e){var t=[this.scheduledAd.skipoffset,this.optionalParams.skipoffset,e.skipoffset].filter((function(e){return null!=e}));return e.skipoffset=t.length?this.player.utils.seconds(t[0]):void 0,e.skipoffset}},{key:"getVastAd",value:function(){var e,t=this.scheduledAd._adPodIndex;if(this.adPodItems){if((e=this.adPodItems.length?this.adPodItems[t]:this.adPodItems).vastAd)return e.vastAd}else if(this.vastAdPod&&this.vastAdPod.length)return this.vastAdPod[t];return this.vastAd}},{key:"adError",value:function(e,t,i){clearTimeout(this.creativeTimeout),this.creativeTimeout=null;var r=this.getVastAd();yt(r),t=t||900;var a="vpaid"===this.adType?5e4:1e4;i=i||a+t;var s=n({},this.scheduledAd,r),o={jwpseg:s.jwpseg},l=Q(this.playlistItemManager,{message:e,code:t,adErrorCode:i},s,o);this.vastAdPod&&this.scheduledAd._adPodIndex<this.vastAdPod.length-1?this.triggerEvent("adPodError",l):(r.tracker.error(l.code),this.triggerEvent("adError",l),this.removePlayerListeners())}},{key:"playAd",value:function(){var e=this.scheduledAd._adPodIndex,t=this.adPodItems[e]||this.adPodItems;if(this.adType=t.adType,this.blockingInstreamPlayer){var i=this.optionalParams.loadingAd;this.blockingInstreamPlayer.setText(i)}if("vpaid"===this.adType)return this.playVpaid(t.vastAd);if("static"===this.adType)return this.playStatic(),Promise.resolve();var r=Array.isArray(this.adPodItems)?this.adPodItems.slice(e):this.adPodItems,a=Array.isArray(this.vastOptions)?this.vastOptions.slice(e):this.vastOptions;return this.initialIndex=e,this.playInstream(r,a).catch(this.player.utils.noop)}},{key:"clearVpaidBlocking",value:function(){var e=this.vpaidPlayer.instream;e&&e!==this.blockingInstreamPlayer&&(this.vpaidPlayer.instream=null,this.clearBlocking(e))}},{key:"clearBlocking",value:function(e){(e=e||this.blockingInstreamPlayer)&&e!==this.instreamPlayer&&e.destroy()}},{key:"getState",value:function(){return this.instreamPlayer?this.instreamPlayer.getState():this.vpaidPlayer?this.vpaidPlayer.getState():""}},{key:"clearNonlinear",value:function(){this.staticPlayer.stop(),this.vpaidPlayer&&(this.clearVpaidBlocking(),this.vpaidPlayer&&(this.vpaidPlayer.stop(),this.vpaidPlayer.destroy(),this.vpaidPlayer=null))}},{key:"destroy",value:function(){if(this.off(),this.removePlayerListeners(),clearTimeout(this.creativeTimeout),this.creativeTimeout=null,this.instreamPlayer){var e=this.instreamPlayer;this.instreamPlayer=null,this.clearBlocking(e)}this.vpaidPlayer&&(this.clearVpaidBlocking(),this.vpaidPlayer&&(this.vpaidPlayer.destroy(),this.vpaidPlayer=null)),this.clearNonlinear(),yt(this.vastAd),this.player=null,this.instreamPlayer=null,this.scheduledAd=null,this.vastBuffet=null,this.vastAd=null,this.vastAdPod=null}},{key:"pause",value:function(e){var t=e.reason;this.reason=t||"external",this.instreamPlayer?this.instreamPlayer.pause():this.vpaidPlayer&&this.vpaidPlayer.pause()}},{key:"play",value:function(e){var t=e.reason;this.reason=t||"external",this.instreamPlayer?this.instreamPlayer.play():this.vpaidPlayer&&this.vpaidPlayer.play()}},{key:"skip",value:function(){if(this.instreamPlayer){var e=this.getSkipOffset(this.getVastAd());if(e>0&&this.position<e)return;this.instreamPlayer.skipAd()}else this.vpaidPlayer&&this.vpaidPlayer.skip()}},{key:"removePlayerListeners",value:function(){this.player&&(this.player.off("fullscreen",this.playerFullscreenHandler,this),this.player.off("volume",this.playerVolumeHandler,this),this.player.off("mute",this.muteHandler,this),this.player.off("viewable",this.viewableHandler,this),this.player.off("resize",this.playerResizeHandler,this)),this.instreamPlayer&&this.instreamPlayer.off(null,null,this),this.vpaidPlayer&&(this.vpaidPlayer.removeEvents(),this.clearVpaidBlocking(),this.vpaidPlayer&&(this.vpaidPlayer.destroy(),this.vpaidPlayer=null)),this.staticPlayer.stop(),this.staticPlayer.removeEvents()}},{key:"adEventObject",value:function(e){var t=this.getVastAd(),i=n({},this.scheduledAd,t),r=W(this.playlistItemManager,i);return r.viewable=this.player.getViewable(),this.adPodItems&&this.adPodItems.length&&(r.sequence=this.scheduledAd._adPodIndex+1,r.podcount=this.adPodItems.length),this.mediaType&&(r.creativetype=this.mediaType),this.scheduledAd._vmap&&(r.vmap=this.scheduledAd._vmap),-1!==I.indexOf(e)&&(r.universalAdId=t.universalAdId,r.categories=t.categories),r}},{key:"playStatic",value:function(){this.vastAd.tracker.linear="nonlinear";var e=this.vastAd.media[0];this.vastAd.selectedMedia=e;var t=this.vastAd.clickthrough||"",i=this.staticPlayer;i.removeEvents(),i.on("play",this.impressionHandler,this),i.on("play",this.playHandler,this),i.on("complete",this.combinedCompleteHandler,this),i.on("click",this.clickStaticHandler,this),i.on("error",this.staticErrorHandler,this),i.playAd(e.file,t,e.minDuration,this.scheduledAd._currentTag,this.scheduledAd.requestTimeout),this.clearBlocking()}},{key:"creativeAdError",value:function(e,t,i){if(this.adError(e,t,i),this.adPodItems&&this.adPodItems.length-1>this.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=ft(e),r=this.optionalParams.conditionaladoptout&&e.conditionalAd;if(this.vastAd.selectedMedia=i,this.mediaType=i.type,"flash"===vt(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 ct(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("state",this.stateHandler,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;t.trackOmidEvent("fullscreen",e.fullscreen),e.fullscreen&&t.started&&t.fullscreen()}},{key:"playerResizeHandler",value:function(e){this.getVastAd().tracker.trackOmidEvent("resize",e.width,e.height),this.vpaidPlayer&&this.vpaidPlayer.resize(e.width,e.height)}},{key:"playerVolumeHandler",value:function(e){this.getVastAd().tracker.trackOmidEvent("volume",e.volume/100),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,r=n({},this.scheduledAd,t),a=e.duration||t.duration||this.getDurationFromVideoTag(),s=this.player.getVolume()/100;i.impression(a,s),this.player.getViewable()?i.viewable():i.notViewable(),this.triggerEvent("adImpression",W(this.playlistItemManager,r,{duration:a,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:"bufferStartHandler",value:function(e){e.buffering=!0,e.trackOmidEvent("bufferStart")}},{key:"bufferFinishHandler",value:function(e){e.buffering=!1,e.trackOmidEvent("bufferFinish")}},{key:"stateHandler",value:function(e){var t=e.oldstate,i=e.newstate;if(i!==t||"playing"===i){var r="loading"===i||"stalled"===i,a=this.getVastAd().tracker;!r&&a.buffering?this.bufferFinishHandler(a):r&&a.started&&this.bufferStartHandler(a)}}},{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=W(this.playlistItemManager,s,{linear:a.linear,metadata:!0});if(this.triggerEvent("adMeta",o),r.companions){var l=W(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 ht(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();yt(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===k,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(),yt(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===_.indexOf(e)&&this.player.trigger(e,i)}}]),e}();function vt(e){return function(e){return"application/javascript"===e.type||"application/x-javascript"===e.type}(e)?"html5":"flash"}function ft(e){for(var t,i=0;i<e.media.length;i++){var r=e.media[i];if("html5"===vt(r)){t=r;break}}return t}function mt(e,t,i,r,a){e.tracker=new dt(e,e.trackers,t,i,r,a)}function yt(e){e&&e.iconInstances&&(e.iconInstances.forEach((function(e){e.remove()})),e.iconInstances=null)}var gt=function(){},kt=function(e){function i(e,r,a,o,d,u,c){var p,v,f;return t(this,i),v=this,(p=!(f=s(i).call(this,e,r,a,o,c))||"object"!=typeof f&&"function"!=typeof f?l(v):f).client=h,p.config=o,p.item=a,p.params=d,p.player=e,p.adPlayerProperties=u,p._vloaderQueue=[],p._events=[],p.adPlayerQueue=[],p.qoe=new e.utils.Timer,p.reason=null,p._debugTrackFn=o.debug&&o.trackFn?o.trackFn:null,n(l(p),e.Events),p}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&o(e,t)}(i,e),r(i,[{key:"init",value:function(e,t){var r=this,a=d(s(i.prototype),"init",this).call(this,e,t);return this.vmapPromise&&this.vmapPromise.then((function(e){!r.isDestroyed()&&e&&e.length&&e.forEach((function(e){var i=Q(r,e,null,t);r.dispatchAdError(i)}))})).catch((function(e){if(!r.isDestroyed()){var i=Q(r,e,null,t);r.enqueueAdEvent("adError",i,t)}})),a}},{key:"adPlayerImpressionHandler",value:function(e){Pt(e)&&(this.qoe.tick("adImpression".concat(e.id)),e.timeLoading=this.qoe.between("adBreakStart","adImpression".concat(e.id))),this.player.trigger("adImpression",e)}},{key:"playAdAPI",value:function(e){var t=this;this.startBlocking(),Promise.resolve(e).then((function(){if(!t.isDestroyed())return t.triggerAdBreakEvents(e),t.startAdBreak(e,{adBlock:t.adBlockErrorDetected,reason:"external"})})).catch((function(e){return t.isDestroyed()?null:t.dispatchFatalAdError(e)}))}},{key:"tryPlayAd",value:function(e,t){var i=this;return this.reason=t.reason||this.reason,this.dequeueAdEvents(),e?("nonlinear"===e.scheduledAd()._type&&this.stopBlocking(),this.playAd(e).catch((function(r){return i.isDestroyed()?null:i.adWaterfall(e,r,t)}))):(this.stopBlocking(),null)}},{key:"playAd",value:function(e){var t=this,i=e.scheduledAd();return 0===i._waterfallIndex&&this.clearNonlinearAd(),this.removeVastLoader(e),new Promise((function(i,r){var a=new pt(e,t.player,t);a.on("adPlayComplete",i),a.on("adError",r),a.on("adImpression",t.adPlayerImpressionHandler.bind(t)),a.on("adMeta",t.player.trigger),a.on("adPodError",t.dispatchAdError.bind(t)),a.init(t.blockingInstreamPlayer,t.reason).catch(gt),t.reason=null,t.adInstreamPlayer=t.blockingInstreamPlayer,t.blockingInstreamPlayer=null,t.adPlayerQueue.push(a)})).then((function(){t.isDestroyed()||"nonlinear"===i._type||t.stopBlocking()}))}},{key:"pauseAd",value:function(e,t){if(this.adPlayerQueue.length){var i=this.adPlayerQueue[this.adPlayerQueue.length-1];e?i.pause(t||{}):i.play(t||{})}}},{key:"skipAd",value:function(){this.adPlayerQueue.length&&this.adPlayerQueue[this.adPlayerQueue.length-1].skip()}},{key:"dispatchFatalAdError",value:function(e){e&&e.adErrorCode||(e=Q(this,{message:"An unexpected ad error has occurred",sourceError:e})),this.dequeueAdEvents(),this.dispatchAdError(e),this.destroyPlayers(),this.stopBlocking()}},{key:"destroyPlayers",value:function(){this.adPlayerQueue.forEach((function(e){return e.destroy()})),this.adPlayerQueue.splice(0)}},{key:"dispatchAdError",value:function(e){Pt(e)&&(this.qoe.tick("adError".concat(e.id)),e.timeLoading=this.qoe.between("adBreakStart","adError".concat(e.id))),this.vmapTracker&&this.vmapTracker.error(e.code),50004!==e.adErrorCode&&50901!==e.adErrorCode||!this.player.getAdBlock()||(this.adBlockErrorDetected=!0);var t=70001===e.adErrorCode?"adWarning":"adError";this.player.trigger(t,e)}},{key:"clearNonlinearAd",value:function(){this.adPlayerQueue.length&&this.adPlayerQueue[this.adPlayerQueue.length-1].clearNonlinear()}},{key:"getVMAPTracker",value:function(e){if(!e._vmapTracker){var t=new dt(e,e._trackers,this._debugTrackFn,this.player,this.config);e._vmapTracker=this.vmapTracker=t}return e._vmapTracker}},{key:"_loadTag",value:function(e,t){var i=e._adQueue[e._waterfallIndex];return this._loadTagUrl(e,i,t)}},{key:"_loadTagUrl",value:function(e,t,i){var r=this;return Ie(t,this.player,this.item,this.client,this.params,e).then((function(a){"function"==typeof r._debugTrackFn&&r._debugTrackFn({type:"tagReplacement",data:{actualTag:a,originalTag:t}});var s=r._createVastLoader(e,i),o=s.load(a);return i.isPodItemLoader?i.tagIndex&&(s.scheduledAd().adRequestIds[i.tagIndex]=r.player.utils.genId(12)):e._currentTag=a,r._dispatchAdRequest(e,n({tag:a},i)),o}))}},{key:"_loadPods",value:function(e,t){var i=this;e.adRequestIds=[];var r=this._createVastLoader(e,t),a=e._pod.map((function(r,a){var s=n({tag:r,isPodItemLoader:!0,tagIndex:a},t),o=i._loadTagUrl(e,r,s).catch((function(e){return e.tagIndex=a,Promise.reject(e)})),l=function(){return i.isDestroyed()?null:i._dispatchAdLoaded(e,s)};return o.then(l).catch(gt),o.catch(l).catch(gt),o}));return r.podMultipleVastLoaders(a)}},{key:"_loadXML",value:function(e,t){var i=this;return e._currentTag=e._currentTag||e._adXML.toString(),this.bidsPromise.then((function(){return i._dispatchAdRequest(e,t),i._createVastLoader(e,t).parseXMLString(e._adXML,e._currentTag)}))}},{key:"_dispatchAdRequest",value:function(e,t){var i=W(this,e,n({jwpseg:e.jwpseg},t));this.player.trigger("adRequest",i),this.qoe.tick("adLoading".concat(i.id))}},{key:"_dispatchAdLoaded",value:function(e,t){var i=W(this,e,t),r=i.id;this.qoe.tick("adLoaded".concat(r)),i.timeLoading=this.qoe.between("adLoading".concat(r),"adLoaded".concat(r)),this.player.trigger("adLoaded",i)}},{key:"_handleVastLoadError",value:function(e,t,i){var r=e.vloader;return this.removeVastLoader(r),this._getVloaderErrorObject(e,t,i)}},{key:"_vloaderWaterfall",value:function(e,t){var i=this._handleVastLoadError(e,null,t),r=e.vloader;return this.adWaterfall(r,i,t)}},{key:"adWaterfall",value:function(e,t,i){var r=e.scheduledAd();if(this.schedule.canWaterfall(r))return r.jwpseg=null,r._adXML=null,r._waterfallIndex+=1,this.enqueueAdEvent("adError",t,i),this.startAdBreak(r,i);throw t}},{key:"_createVastLoader",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=this.config,a=new ut(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=W(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 Q(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",W(t,e))})),this.qoe.tick("adBreakStart"),i.breakStart();var r=W(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 Q(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(gt),a.catch(n).catch(gt),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)})).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)})).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}(rt);function Pt(e){return e.tag&&(void 0===e.podcount||1===e.sequence)}var At=function(){},wt=function(){function e(i,r,a){t(this,e),this.player=i,this.pluginConfig=r,this.adClient=a;var n=this.configParser=new Ke(i.utils),s=this.adRules=new tt(i,n.getAdRules(r),a);this.emptySchedule=new Je(s,i.utils)}return r(e,[{key:"getAdRules",value:function(){return this.adRules}},{key:"resetDefaultSchedule",value:function(e){var t=void 0===this.pluginConfig.withCredentials||this.pluginConfig.withCredentials,i=this.defaultSchedule=this.configParser.getSchedule(this.pluginConfig,this.adRules);i.isVMAP()&&i.load(this.player,e,this.adClient,{withCredentials:t}).catch(At)}},{key:"getSchedule",value:function(e,t){return t>0&&!this.adRules.rulesAllowAdPlayback(t)?this.emptySchedule:e&&e.adschedule?this.configParser.getSchedule(e,this.adRules):(this.resetDefaultSchedule(e),this.defaultSchedule)}},{key:"getOptParams",value:function(e,t){return this.configParser.getOptParams(e,t)}},{key:"reset",value:function(){this.adRules.reset()}}]),e}(),bt={},Et={},Tt={};function _t(e,t){var i=bt[t];return i||(bt[t]=new Promise((function(i,r){var a=new e.key(t);if("unlimited"===a.edition())return r();var n=["//","entitlements.jwplayer.com","/",a.token(),".json"];"file:"===window.location.protocol&&n.unshift("https:"),e.ajax(n.join(""),(function(e){var t=e&&e.response;t?i(t):r()}),(function(){r()}),{timeout:1e4,responseType:"json"})})))}function It(e,t){var i=Et[t];return i||(Et[t]=_t(e,t).catch((function(){return{}})).then((function(e){if(!1===e.canUseVPB)throw new Error("Not entitled for Player Bidding")})))}var Ct=function(e,t,i){var r=Tt[t];return r||(Tt[t]=_t(e,t).catch((function(){return{}})).then((function(e){var t,r;if(!0===i.outstream?(t=!1!==e.canPlayOutstreamAds,r="Outstream Ad Limit Reached"):(t=!1!==e.canPlayAds,r="Ad Limit Reached"),!1===t)throw new Error(r);return{message:"Can Play Ads"}})))},St=function(){};var Rt=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)(h,"8.1",(function(e,t,i){var r,a,s,o,l=new wt(e,t,h),d=e.getConfig(),u=e.getEnvironment(),c=t.debug&&t.trackFn?t.trackFn:null,p=e.utils,v=this,P={withCredentials:void 0===t.withCredentials||t.withCredentials},w=!1,b=0,E=!1;function T(i,r,a){var d=l.getSchedule(i,r),u=new kt(e,d,i,t,a,s,E);return u.init(o,a).then((function(){u.isDestroyed()||e.trigger(A,W(u,null,{schedule:d}))})).catch(Rt),u.on("preloadNext",(function(e){var t=n({},a,{preloadPreroll:!0,playlistItemEventCount:b+1});u.next=T(e.item,t.playlistItemEventCount,t)}),v),u}function _(t){r&&(t&&(a=r.next,w=r.nextPlaylistRelated),r.schedule.reset(),r.off(null,null,v),r.destroy(),r=null),l.reset(),e.setCues([])}function I(t){var i=t.getMidRolls(),r=[];i.length&&i.forEach((function(e){"nonlinear"!==e._type&&r.push({begin:e._offSet,text:P.cuetext,cueType:"ads"})})),e.addCues(r)}(function(e){try{var t=e.settings.mediationLayerAdServer||y,i=!!e.bidders.length;return(t===y||t===g)&&i}catch(e){return!1}})(t.bids)&&(o=n({},t.bids)),function(e,t,i,r){var a,n=t.key,s=e.utils,o=Ct(s,n,i);o.catch(St),i.bids&&(a=It(s,n)).catch(St),e.on("ready",(function(){a&&a.catch((function(i){e.trigger("destroyBidding"),e.trigger(ne,Te(i.message,60009,t,r))})),o.catch((function(i){e.trigger("destroyPlugin",i),e.trigger(ne,Te(i.message,60002,t,r))}))}))}(e,d,t,h),"enabled"===t.omidSupport&&ot(p).catch(p.noop),this.version="8.9.2",n(this,e.Events),p.addClass(i,"jw-plugin-vast"),e.on({ready:function(){d.localization=e.getConfig().localization,(P=l.getOptParams(t,d.localization.advertising)).debugTrackFn=c,s={staticPlayer:new B(e,i),companion:new x(c,u,{openLink:p.openLink}),div:i,optionalParams:P}},cast:function(e){E=!!e.active},play:function(e){v.trigger(k,e)},playlistItem:function(t){b+=1,_(!0);var i=e.getPlaylistItem(t.index);a&&i!==a.item&&!w&&(a.off(null,null,v),a.destroy(),a=null,w=!1);P.playlistItemEventCount=b,(r=a||T(i,b,P)).attachListeners(),a=null,w=!1,r.schedule.isVMAP()?r.vmapPromise.then((function(){r.isDestroyed()||I(r.schedule)})).catch(Rt):I(r.schedule)},playlistComplete:_,complete:function(){r&&r.clearNonlinearAd()},destroyPlugin:_,destroyBidding:function(){o=null}},this),e.pauseAd=function(e,t){e="boolean"!=typeof e||e,r&&r.pauseAd(e,t)},e.playAd=function(t){var i,a=0===P.requestTimeout?1/0:P.requestTimeout,n=0===P.creativeTimeout?1/0:P.creativeTimeout;i=Array.isArray(t)?t.slice(0):[t];var s=p.genId,o={_id:s(12),_adQueue:i,_waterfallIndex:0,_adPodIndex:0,adBreakId:s(12),_offset:0,_position:X(e),requestTimeout:a||f,creativeTimeout:n||m};r?(r.clearNonlinearAd(),r.playAdAPI(o)):e.once("playlistItem",(function(){return r.playAdAPI(o)}))},e.skipAd=function(){r&&r.skipAd()},this.destroy=_}))}();
