@flowplayer/player 3.34.1 → 3.34.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowplayer/player",
3
- "version": "3.34.1",
3
+ "version": "3.34.2",
4
4
  "description": "video player for the future",
5
5
  "keywords": [
6
6
  "flowplayer",
package/plugins/ads.js CHANGED
@@ -1,7 +1,7 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((t="undefined"!=typeof globalThis?globalThis:t||self).flowplayer=t.flowplayer||{},t.flowplayer.ads=e())}(this,function(){"use strict";var t;!function(t){t[t.ADS=2]="ADS",t[t.ANALYTICS=4]="ANALYTICS",t[t.NO_METERING=8]="NO_METERING",t[t.DEVELOPER_PLAN=16]="DEVELOPER_PLAN",t[t.WOWZA_VIDEO=32]="WOWZA_VIDEO"}(t||(t={}));const e=["localhost","127.0.0.1","0.0.0.0","s.codepen.io","cdpn.io","try.flowplayer.com"];function s(t,s){return!!~e.indexOf(t)||t.indexOf(s)===t.length-s.length}s.check_whitelist=function(t){return!!~e.indexOf(t)};function i(t){this.message=t}i.prototype=new Error,i.prototype.name="InvalidCharacterError";var r="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new i("'atob' failed: The string to be decoded is not correctly encoded.");for(var s,r,a=0,n=0,o="";r=e.charAt(n++);~r&&(s=a%4?64*s+r:r,a++%4)?o+=String.fromCharCode(255&s>>(-2*a&6)):0)r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(r);return o};var a=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(r(t).replace(/(.)/g,function(t,e){var s=e.charCodeAt(0).toString(16).toUpperCase();return s.length<2&&(s="0"+s),"%"+s}))}(e)}catch(t){return r(e)}};function n(t){this.message=t}n.prototype=new Error,n.prototype.name="InvalidTokenError";var o=function(t,e){if("string"!=typeof t)throw new n("Invalid token specified");var s=!0===(e=e||{}).header?0:1;try{return JSON.parse(a(t.split(".")[s]))}catch(t){throw new n("Invalid token specified: "+t.message)}};o.InvalidTokenError=n;const d="production";function l(t,e){const s={valid_jwt:!1,raw:"",data:{acl:0},exp:0};let i={c:"{}",exp:0};e=e||{};try{i=o(t),s.valid_jwt=!0}catch(t){}return s.raw=t,s.data=JSON.parse(i.c),s.exp=i.exp,e.require_valid_token&&l.validate(s),s}function c(t){return{grant:t,is_granted:e=>(t&e)===e}}function u(){const t="undefined"!=typeof document&&"undefined"!=typeof window,e=t?navigator.userAgent:"",s=/iP(hone|od)/i.test(e)&&!/iPad/.test(e)&&!/IEMobile/i.test(e),i=/Android/.test(e)&&!/Firefox/.test(e),r=/^((?!chrome|android).)*safari/i.test(e),a=/chrome|crios/i.test(e)&&!/opr|opera|chromium|edg|ucbrowser|googlebot/i.test(e),n=/firefox|fxios/i.test(e)&&!/seamonkey/i.test(e),o=/edg/i.test(e),d=/opr|opera/i.test(e),l=/SamsungBrowser/.test(e),c=l&&/SMART-TV/.test(e);return{controls:!s,video:function(e){return t&&document.createElement("video").canPlayType(e)},lang:t&&window.navigator.language,android:i,iphone:s,safari:r,edge:o,opera:d,chrome:a,firefox:n,ios:t&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,samsung:l,samsung_tv:l&&c,touch:"ontouchstart"in window,tizen:"tizen"in window,webOS:"webos"in window}}function h(t){return{width:t.clientWidth,height:t.clientHeight}}function p(t,e,s){return"number"==typeof s&&(s+="px"),t.style.setProperty(e,s),t}l.validate=function(t){if("string"==typeof t&&(t=l(t)),!t||!t.raw){if(s.check_whitelist(window.location.hostname)||"dev"===d.toString())return!0;throw new Error("No token provided in configuration")}if(!t.valid_jwt)throw new Error("Invalid token provided");const e=window.location.hostname,i=s.bind(null,e);if("dev"!==d.toString()&&t.data.domain&&t.data.domain.length&&!t.data.domain.some(i))throw new Error("Domain not allowed");if("dev"!==d.toString()&&1e3*t.exp-Date.now()<0)throw new Error("Expired token");return!0},l.id=function(t){if(t)return"string"==typeof t&&(t=l(t)),t.data.id},c.of=c,c.from_token=function(t){const e=l(t,{require_valid_token:!0});return c.of(e.data.acl)},c.permissions=t;const g="ad-initialized",m="ad-playback-error",_="ad-teardown",f="ad-videotag-attached",v="ad-request-error",y="ad-requested",A="ad-request-completed",b="ad-pause-content",w="ad-started",E="ad-completed",S="ad-paused",T="ad-resumed",L="ad-progress",O="ad-skipped",R="ad-muted",M="ad-volume-changed",P="ad-timeout",k="ad-break-completed",D="ad-postroll-finished",I="ad-preroll-finished",C="vpaid-init",N="ad-ima-adapter-init",U="ad-ima-before-ads-request",x="ad-ima-rendering-settings",F="ad-adapter-init-failed",B="ad-play-requested",j="reload-ad-requested",q="ad-error",H="request/ad/pause",V="request/ad/play",z="request/ad/muteunmute",G="ad/show-first-frame",W="ad/resize",Q="ad/set-ui-flags",$="ad/pbjs";var K=Object.freeze({__proto__:null,AD_INIT:g,AD_PLAYBACK_ERROR:m,AD_TEARDOWN:_,AD_VIDEOTAG_ATTACHED:f,AD_BLOCKED:"ad-blocked",AD_REQUEST_ERROR:v,AD_REQUESTED:y,AD_REQUEST_COMPLETED:A,AD_PAUSE_CONTENT:b,AD_STARTED:w,AD_COMPLETED:E,AD_PAUSED:S,AD_RESUMED:T,AD_WAITING:"ad-waiting",AD_PROGRESS:L,AD_SKIPPED:O,AD_MUTED:R,AD_VOLUME_CHANGED:M,AD_FULLSCREEN:"ad-fullscreen",AD_TIMEOUT:P,AD_BREAK_COMPLETED:k,AD_POSTROLL_FINISHED:D,AD_PREROLL_FINSIHED:I,AD_MIDROLL_FINISHED:"ad-midroll-finished",VPAID_INIT:C,IMA_ADAPTER_INIT:N,IMA_BEFORE_ADS_REQUEST:U,IMA_ADS_RENDERING_SETTINGS:x,ADAPTER_INIT_FAILED:F,AD_PLAY_REQUESTED:B,RELOAD_AD_REQUESTED:j,AD_ERROR:q,REQUEST_AD_PAUSE:H,REQUEST_AD_PLAY:V,REQUEST_AD_MUTE_UNMUTE:z,AD_SHOW_FIRST_FRAME:G,AD_RESIZE:W,AD_SET_UI_FLAGS:Q,PBJS_AVAILABLE:$});const Y="resize",Z="volumechange",J="playing",X="ended",tt="seeked",et="seeking",st="viewenter",it="beforeplay";const rt="is-playing",at="is-starting",nt="is-live",ot="is-waiting",dt="is-autoplay",lt="is-in-viewport";function ct(t,e,s){const i=function(t,e){const s=new CustomEvent(t,{detail:e,cancelable:!0});return e&&Object.defineProperty(s,"data",{get:()=>e}),s}(e,s);return t.dispatchEvent(i),t}var ut;!function(){let t=!1;try{const e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("testPassive",null,e),window.removeEventListener("testPassive",null,e)}catch(t){}}(),function(t){t[t.OFF=0]="OFF",t[t.ON=1]="ON",t[t.AUDIO_REQUIRED=2]="AUDIO_REQUIRED"}(ut||(ut={}));function ht(t){const e="number"==typeof t?t:parseInt(t,10);return(e>9?"":"0")+e}function pt(t){return function(t,e){const s=t.seekable;if("object"!=typeof t.opts||0==s.length)return{head:0,tail:0};const i=gt(t),r=e||t.live_state.dvr_window;return{head:i,tail:"number"!=typeof r||i-r<0?s.start(0):i-r}}(t).tail}function gt(t){var e;const s=t.seekable;return s.length?t.hasState("is-chromecast-playing")||!(null===(e=t.hls)||void 0===e?void 0:e.liveSyncPosition)?s.end(s.length-1):t.hls.liveSyncPosition:0}function mt(t){try{t.dvr_offset=0,t.currentTime=gt(t)}catch(t){console.warn("failed to seek to now: %j",t)}}const _t=1;function ft(t,e){if(!t.hasState(nt)||![void 0,0,-1].includes(e)||!t.seekable.length||t.hasState("has-casted"))return t.setState(at,!1);t.once(tt,()=>t.setState(at,!1)),0===e?function(t){t.currentTime=pt(t)}(t):mt(t)}const vt="is-popped-out";function yt(t,e){const s=function(){try{return localStorage.getItem("flowplayer/debug")}catch(t){return""}}(),i=(i,...r)=>{try{const a=(null==e?void 0:e.debug)||s;a&&t.match(a)&&console.log(`flowplayer/${t} -- ${i}`,...r)}catch(t){console.warn(t)}};return i.log=i,i}const At=(t,e)=>new(((t,e)=>{const s=t.get(e);if(!s)throw new Error(`no flowplayer component with the name ${e} exists`);const i=window.customElements.get(e);if(!i)throw new Error(`no default flowplayer component with the name ${e} exists`);const r=window.customElements.get(s);return"function"!=typeof r?i:r})(t._customElements,e))(t),bt=(t,e,s)=>{window.customElements.get(e)||window.customElements.define(e,s),t.customElements.get(e)||t.customElements.set(e,e)},wt="flowplayer-ad-ui",Et="flowplayer-ad-controls",St="flowplayer-ad-countdown",Tt="flowplayer-ad-indicator",Lt=new Blob([new Uint8Array([0,0,0,28,102,116,121,112,105,115,111,109,0,0,2,0,105,115,111,109,105,115,111,50,109,112,52,49,0,0,0,8,102,114,101,101,0,0,2,239,109,100,97,116,33,16,5,32,164,27,255,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,55,167,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,112,33,16,5,32,164,27,255,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,55,167,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,112,0,0,2,194,109,111,111,118,0,0,0,108,109,118,104,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,232,0,0,0,47,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,1,236,116,114,97,107,0,0,0,92,116,107,104,100,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,47,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,36,101,100,116,115,0,0,0,28,101,108,115,116,0,0,0,0,0,0,0,1,0,0,0,47,0,0,0,0,0,1,0,0,0,0,1,100,109,100,105,97,0,0,0,32,109,100,104,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,172,68,0,0,8,0,85,196,0,0,0,0,0,45,104,100,108,114,0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0,0,0,1,15,109,105,110,102,0,0,0,16,115,109,104,100,0,0,0,0,0,0,0,0,0,0,0,36,100,105,110,102,0,0,0,28,100,114,101,102,0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1,0,0,0,211,115,116,98,108,0,0,0,103,115,116,115,100,0,0,0,0,0,0,0,1,0,0,0,87,109,112,52,97,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,2,0,16,0,0,0,0,172,68,0,0,0,0,0,51,101,115,100,115,0,0,0,0,3,128,128,128,34,0,2,0,4,128,128,128,20,64,21,0,0,0,0,1,244,0,0,1,243,249,5,128,128,128,2,18,16,6,128,128,128,1,2,0,0,0,24,115,116,116,115,0,0,0,0,0,0,0,1,0,0,0,2,0,0,4,0,0,0,0,28,115,116,115,99,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,2,0,0,0,1,0,0,0,28,115,116,115,122,0,0,0,0,0,0,0,0,0,0,0,2,0,0,1,115,0,0,1,116,0,0,0,20,115,116,99,111,0,0,0,0,0,0,0,1,0,0,0,44,0,0,0,98,117,100,116,97,0,0,0,90,109,101,116,97,0,0,0,0,0,0,0,33,104,100,108,114,0,0,0,0,0,0,0,0,109,100,105,114,97,112,112,108,0,0,0,0,0,0,0,0,0,0,0,0,45,105,108,115,116,0,0,0,37,169,116,111,111,0,0,0,29,100,97,116,97,0,0,0,1,0,0,0,0,76,97,118,102,53,54,46,52,48,46,49,48,49])],{type:"video/mp4"});let Ot=null;function Rt(t,e=500){return new Promise(s=>{const i=document.createElement("video"),r={autoplay_sound:!1,autoplay_muted:!1},a=()=>{i.pause(),i.currentTime=0,i.src="",i.remove(),s(r)},n=setTimeout(a,e);i.setAttribute("playsinline",""),i.setAttribute("webkit-playsinline",""),i.setAttribute("disablepictureinpicture",""),i.preload="auto",i.playsInline=!0,i.muted=!1,Object.assign(i.style,{position:"fixed",left:"-9999px",top:"0",width:"1px",height:"1px",opacity:"0",pointerEvents:"none"}),document.body.appendChild(i),i.src=(Ot||(Ot=URL.createObjectURL(Lt)),Ot);(async()=>{try{return await i.play(),clearTimeout(n),r.autoplay_sound=!0,r.autoplay_muted=!0,a()}catch(e){if(t)return clearTimeout(n),a()}try{i.muted=!0,i.setAttribute("muted",""),await i.play(),r.autoplay_muted=!0}catch(t){}clearTimeout(n),a()})()})}const Mt=yt("ads/lifecycle"),Pt=[m,_,k];async function kt({config:t,root:e,content:s,ads:i,ima:r}){var a;Mt("LifeCycle::initLifeCycle",t,e,s,i,r),s.autoplay=!1;const n=t.autoplay===ut.AUDIO_REQUIRED,o=function(t,e){return{muted:!(e||!t.muted),volume:t.volume}}(s,n);s.on(Z,()=>{o.volume=s.volume,o.muted=s.muted}),s.on(G,()=>{Mt("showFirstFrame"),e.classList.toggle("ad-hide-first-frame",!1)});const d=At(s,wt),l=d;s.emit(Q,{ui_flags:null===(a=t.ads)||void 0===a?void 0:a.ui}),s.renderPlugin(d);const c={listening:!1,preload:null==r?void 0:r.preload_ads};if(Mt("initial",o),i.setVideoTag(s),t.autoplay){Mt("Trying to autoplay"),e.classList.add("ad-hide-first-frame"),Mt("hideFirstFrame");const a=await async function(t,e){const[s,i]=[t.muted,t.volume];Mt("Lifecycle::peek_content(:muted => %s, :volume => %s)",s,i),await async function(t){return Mt("Lifecycle::wait_for_source"),new Promise((e,s)=>{const i=50,r=2e3;let a=0;const n=setInterval(()=>{if(++a>r/i)return clearInterval(n),s(new Error(`No source in ${r}ms, giving up`));(t.currentSrc||"dash"in t)&&(e(null),clearInterval(n))},i)})}(t),await function(t){return new Promise(e=>{if(t.hasState(lt))return e(null);t.once(st,()=>e(null))})}(t);const r=Date.now();t.muted=!1,t.volume=t.volume?t.volume:1;const{autoplay_sound:a,autoplay_muted:n}=await Rt(e);return Mt("Lifecycle::peek_content:: ","audioRequired: "+e," autoplay_sound: "+a," autoplay_muted: "+n," peek_content_check_ms: "+(Date.now()-r)),!!a||!e&&(t.muted=!!n||s,n)}(s,n);a?(Mt("Can autoplay, start ad"),s.opts.autoplay=1,s.setState(dt,!0),Dt({ads:i,content:s,state:c,adContainer:l,ima:r,config:t})):(Mt("cannot autoplay(audioRequired: %s), fallback to poster state",n),t.autoplay=0,s.emit(G,{root:e}),s.setState("is-starting",!0))}!t.autoplay&&i.hasPreroll()&&function({content:t,ads:e,config:s,state:i,initial:r,adContainer:a,ima:n}){t.once(it,async function(o){(t.hasState(lt)||"touchend"!=o.type)&&e.shallPlayAd(0)&&(e.adapter.setAttemptingPrerollOnIOS(e.adapter.isCustomPlaybackEnabled()),e.adapter.isCustomPlaybackEnabled()||o.preventDefault(),Ut({ads:e,content:t,state:i}),Mt("user_gesture(:intercept) -> shallPlayAd(0: %s)",e.shallPlayAd(0)),s.muted=r.muted,await Dt({ads:e,content:t,state:i,adContainer:a,ima:n,config:s}),xt({ads:e,content:t}))})}({content:s,ads:i,config:t,state:c,initial:o,adContainer:l,ima:r}),!t.autoplay&&i.hasPreroll()&&c.preload&&Dt({ads:i,content:s,state:c,adContainer:l,ima:r,config:t}),Nt({config:t,root:e,content:s,ads:i,state:c,adContainer:l,ui:d,ima:r,initial:o});const u=async t=>{s.removeEventListener(it,u),i.resetScheduleCounter(),i.hasPreroll()&&(i.adapter.setAttemptingPrerollOnIOS(i.adapter.isCustomPlaybackEnabled()),t.preventDefault(),await i.setCurrentTime(0))};s.on("src",()=>{c.started&&(s.removeEventListener(it,u),s.addEventListener(it,u))}),s.on(it,t=>{(i.adBreak||i.adPlaying||i.adRequesting)&&(i.adBreak&&!i.adLinear||(Mt("prevented content from starting because ad break is active"),t.preventDefault()))})}async function Dt(t){t.state.started||(t.content.hasState(lt)?await It(t):t.content.once(st,async()=>{await It(t)}))}async function It({ads:t,content:e,adContainer:s,ima:i,state:r,config:a}){var n;r.started=!0;const o=function(t,e){var s={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(s[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(t);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(t,i[r])&&(s[i[r]]=t[i[r]])}return s}(i,["ads"]),d=h(e.root),l=(null==a?void 0:a.muted)||e.muted,c=Object.assign(Object.assign(Object.assign({container:s,volume:l?0:e.volume,muted:l,autoplay:(null==a?void 0:a.autoplay)||!1,video_source:e.original_src,preload_ads:null===(n=null==a?void 0:a.ima)||void 0===n?void 0:n.preload_ads},o),d));Mt("start():",c,r),await t.initialize(!1,c,r.preload)}function Ct(t,e){var s,i;return{content_width:t.clientWidth||(null===(s=t.parentNode)||void 0===s?void 0:s.clientWidth)||e.clientWidth,content_height:t.clientHeight||(null===(i=t.parentNode)||void 0===i?void 0:i.clientHeight)||e.clientHeight}}function Nt({config:t,root:e,content:s,ads:i,initial:r,adContainer:a,state:n,ui:o,ima:d}){Mt("addUIListeners()");const l=async()=>{if(i){if(!(i.adapter.isAttemptingPrerollOnIOS()||i.adapter.isCustomPlaybackEnabled()&&s.currentSrc!==s.original_src)){if(s.off(J,l),Mt("addUIListeners() -> content started playing"),Ut({ads:i,content:s,state:n}),!i.shallPlayAd(0)||!i.adapter.isLinearAd())return Mt("addUIListeners() -> no more preroll ads -> resume content"),s.emit(G,{root:e}),await Dt({ads:i,content:s,state:n,adContainer:a,ima:d,config:t});s.togglePlay(!1),await Dt({ads:i,content:s,state:n,adContainer:a,ima:d,config:t}),i.shallPlayAd(0)&&i.adapter.isLinearAd()&&(o.classList.add("on","linear"),e.classList.add(ot),xt({ads:i,content:s}))}}else s.off(J,l)};s.on(J,l),s.on(["portrait","landscape"],function(){if(!i)return;const{content_width:t,content_height:r}=Ct(s,e);i.resize({height:r,width:t})}),s.on(Y,t=>{if(!i||!t.detail)return;const{width:e,height:s}=t.detail.contentRect;i.resize({width:e,height:s})}),s.on(X,t=>{var r;const a=()=>{t.preventDefault(),Object.assign(t,{prevented:!0})};if(e.classList.contains("ad-linear")&&e.classList.contains("ads-custom-playback-enabled"))return a();i&&(Mt("ui_listeners(:%s, event: %o)",t.type,t.detail),(null===(r=null==t?void 0:t.detail)||void 0===r?void 0:r.from)!==i&&(a(),i.finished(function(){s.emit(X,{from:i})})))}),i.on(y,()=>{e.classList.toggle(ot,!0)}),i.once(w,()=>{s.on([it,"beforepause"],t=>{var e;if(!i.adBreak||!i.adapter.isLinearAd())return;t.preventDefault();const s=(null===(e=t.detail)||void 0===e?void 0:e.forced)?t.type===it:!i.adPlaying;s&&i.paused&&i.resume(),s||i.paused||i.pause()})}),i.on(w,t=>{const a=t.detail,{linear:n,ad:o,ad_type:d}=a;let l;if(Mt(`Ad[linear: ${n}, currentTime: ${s.currentTime}] starting`,o),"preroll"==d&&!n&&s.paused&&s.togglePlay(!0),n&&(l=Ct(s,e)),i.resize({width:l?l.content_width:o.width,height:l?l.content_height:o.height,linear:n,resize_non_linear:!0}),s.emit(W,{opts:{linear:n,resizeContainerAlso:!0,width:n?void 0:o.width,height:n?void 0:o.height}}),e.classList.remove(ot),s.setState("ad-linear",n),s.setState("ad-non-linear",!n),!n){Mt("non-linear ad / restarting content");try{s.togglePlay(!0),s.volume=r.volume,s.muted=r.muted}catch(t){Mt(t)}}s.hasState(lt)||s.hasState(vt)||!n||i.pause()}),i.on(b,()=>{s.emit(W,{opts:{linear:!0,width:0,height:0}})}),s.on(Pt,t=>async function({root:t,content:e,ads:s,eventName:i,err:r={reason:""}}){Mt("teardown(event: %s)",i),s.adapter.isAttemptingPrerollOnIOS()&&(s.adapter.setAttemptingPrerollOnIOS(!1),!e.paused&&e.hasState(at)&&e.hasState(rt)&&ft(e,e.opts.start_time));t.classList.add("is-seamless"),t.classList.remove(ot),["ad-non-linear","ad-linear"].forEach(t=>e.setState(t,!1)),r.reason&&Mt("teardown(:err, reason: %s) %o",r.reason);const a=s.getLastAd();if(e.emit(G,{root:t}),!s.shouldRestartContent())return Mt("Lifecycle.teardown(:skip_restart, reason: %s)","Ad prevented restarting content"),Ft(t);if(e.currentTime>0&&e.currentTime>=e.duration||"postroll"==s.ad_type||!1===(null==a?void 0:a.restart))return Mt("Lifecycle.teardown(:skip_restart, reason: %s)","was a postroll ad"),Ft(t);""===e.currentSrc&&e.setSrc(e.original_src);e.paused&&s.shouldRestartContent()&&(Mt("Lifecycle.teardown(:toggle_play, %s)","attempting to restart content"),await e.togglePlay(!0));if(!e.paused)return Mt("Lifecycle.teardown(:ok)","restarted video content"),Ft(t)}({root:e,content:s,ads:i,ui:o,err:t.detail,eventName:t.type}));let c=!!t.autoplay;var u;s.on(st,()=>{c&&!1!==d.autopause&&i.resume()}),s.on("viewleave",(u=()=>{!1!==d.autopause&&(c=!i.paused,i.pause())},t=>{setTimeout(function(){if(!t.defaultPrevented&&!t.prevented)return u(t)},0)}))}function Ut({ads:t,content:e,state:s}){s.listening||(e.on(["timeupdate",tt,J,et],s=>{t.adapter.isCustomPlaybackEnabled()&&(t.adPlaying||t.paused)||(t.adPlaying&&t.adapter.isLinearAd()&&!e.paused&&e.pause(),xt({ads:t,content:e,seek:s.type===et}))}),s.listening=!0)}function xt({ads:t,content:e,seek:s=!1}){t&&t.setCurrentTime(e.currentTime,void 0,s)}function Ft(t){t.classList.remove("is-seamless")}const Bt=yt("ads/timers");class TimerRegistry{constructor(t={},e={}){this.intervals=t,this.timers=e}}let jt=-1;function qt(t,e,s){const i=setInterval(s,e);if(Bt(`TimerRegistry.createInterval() -> ${i}`,t.intervals),"object"==typeof i){const e=++jt;return t.intervals[e]=e,e}return t.intervals[i]=i,i}function Ht(t){if(t)return Bt("TimerRegistry.empty()",Object.keys(t.timers),Object.keys(t.intervals)),Object.keys(t.intervals).forEach(e=>function(t,e){return Bt(`TimerRegistry.removeInterval() -> ${e}`,t.intervals),clearInterval(t.intervals[e]),delete t.intervals[e],t}(t,e)),Object.keys(t.timers).forEach(e=>function(t,e){return Bt(`TimerRegistry.removeTimeout() -> ${e}`,t.timers),clearTimeout(t.timers[e]),delete t.timers[e],t}(t,e)),t}function Vt(t){try{return t.getAdPodInfo().getPodIndex()}catch(t){return}}class AdLoadingController{adRequestStart(t){"number"==typeof t&&"number"!=typeof this.requestStart&&(this.requestStart=performance.now())}adRequestEnd(){this.requestStart=void 0}getRemainingAdLoadTime(t,e){return"number"!=typeof e||"number"!=typeof this.requestStart?t:Math.max(0,e-(performance.now()-this.requestStart))}}function zt(t){return function(t){return!document.fullscreenEnabled&&"function"==typeof t.webkitEnterFullScreen&&"function"==typeof t.webkitExitFullScreen}(t)&&!t.root.classList.contains("no-fullscreen")}function Gt(t){const e=null==t?void 0:t.ads;return!!(e&&Array.isArray(e)&&e.length>0)}class IMA{constructor(t){this.eventHandler=t,this.log=yt("ads/adapter/ima"),this.google=window.google,this._adHandlers=[],this._timers=new TimerRegistry,this._started=!1,this._volumeLevel=0,this._adLoaded=!1,this.customPlaybackEnabled=!1,this._paused=!1,this._all_ads_completed=!1,this._currentDuration=0,this._currentRemaining=0,this._currentDisplayTs=0,this._isInitialized=!1,this._adBreakTime=0,this._prepared=!1,this.opts={},this.loadingController=new AdLoadingController}async init(t){this.log("init",this.videoTag,t),this.opts=t,this._dimensions={width:t.width,height:t.height,linear:t.linear},this._prepared=!0,!this._isInitialized&&this.videoTag&&await this.initAdapter()}async initAdapter(){this.log("initAdapter",this.opts);try{await this.initialize(this.opts),this._isInitialized=!0}catch(t){this.log("initAdapter failed:",t),this._prepared=!1,this.eventHandler.trigger(F)}}isReady(){return!!this._isInitialized}setVideoTag(t){this.videoTag=t,this.customPlaybackEnabled=zt(t),t.root.classList.toggle("ads-custom-playback-enabled",this.customPlaybackEnabled)}setAdBreakTime(t){this._adBreakTime=t}getAdBreakTime(){return this._adBreakTime}isCustomPlaybackEnabled(){return this.customPlaybackEnabled}isAttemptingPrerollOnIOS(){var t;return!!(null===(t=null==this?void 0:this.videoTag)||void 0===t?void 0:t.root.classList.contains("preroll-ios"))}setAttemptingPrerollOnIOS(t){var e;null===(e=null==this?void 0:this.videoTag)||void 0===e||e.root.classList.toggle("preroll-ios",t)}isLinearAd(){return!!this._adLinear}getVideoTag(){return this.videoTag}getDimensions(){return this._dimensions||{}}getOpts(){return this.opts}isPaused(){return this._paused}destroy(){const t=this;Ht(this._timers),this._adHandlers&&this._adHandlers.forEach(t=>t()),t._adHandlers=void 0,this._adDisplayContainer&&this._adDisplayContainer.destroy(),t._adDisplayContainer=void 0,this._adsLoader&&this._adsLoader.destroy(),t._adsLoader=void 0,this._adsManager&&this._adsManager.destroy(),t._adsManager=void 0}stop(){this._adsManager&&this._adsManager.stop()}initialize(t){const e=this.isAdPod(),s=this._adLoaded||e;if(this.cleanup(),!this.videoTag)return console.warn("videoTag not set during initialization");this.opts=t,this._volumeLevel=t.volume;const i=this.google.ima.settings;if(t.NumRedirects=t.NumRedirects||t.redirects,i.setVpaidMode(t.VpaidMode||this.google.ima.ImaSdkSettings.VpaidMode.INSECURE),i.setDisableCustomPlaybackForIOS10Plus(!this.customPlaybackEnabled),"NumRedirects"in t&&i.setNumRedirects(t.NumRedirects),"AutoPlayAdBreaks"in t&&i.setAutoPlayAdBreaks(t.AutoPlayAdBreaks),"Locale"in t&&i.setLocale(t.Locale),"Ppid"in t&&i.setPpid(t.Ppid),!document.body.contains(t.container))throw new Error("AdDisplayContainer was not found in the document.body");this._adDisplayContainer=new this.google.ima.AdDisplayContainer(t.container,u().tizen||u().webOS?void 0:this.videoTag),this._adDisplayContainer.initialize(),this._adsLoader=new this.google.ima.AdsLoader(this._adDisplayContainer),this.log("ima.initialise(:wait -> ADS_MANAGER_LOADED)",Object.assign(Object.assign({},t),{volume:this.videoTag.volume,muted:this.videoTag.muted})),this._adsLoader.addEventListener(this.google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,e=>{if(!this.videoTag)return;this.log("ima.initialise(:done -> ADS_MANAGER_LOADED)\n%o",Object.assign(Object.assign({},t),{volume:this.videoTag.volume,muted:this.videoTag.muted}));const s=new this.google.ima.AdsRenderingSettings;this.log("ima.rendering(preload: %s)",!!t.preload_ads),s.useStyledNonLinearAds=!0,s.enablePreloading=!!t.preload_ads,s.loadVideoTimeout=t.media_timeout||-1,s.restoreCustomPlaybackStateOnAdBreakComplete=this.customPlaybackEnabled,this.customPlaybackEnabled&&(s.playAdsAfterTime=this.videoTag.currentTime),this.eventHandler.trigger(x,s);const i=this._adsManager=e.getAdsManager(this.videoTag,s);this.eventHandler.trigger(N,i),i.addEventListener(this.google.ima.AdEvent.Type.LOADED,()=>{this.log("debug(ima.adsManager): google.ima.AdEvent.Type.LOADED")}),i.addEventListener(this.google.ima.AdErrorEvent.Type.AD_ERROR,()=>{this.log("debug(ima.adsManager): google.ima.AdErrorEvent.Type.AD_ERROR")}),i.addEventListener(this.google.ima.AdEvent.Type.STARTED,()=>{this.log("debug(ima.adsManager): google.ima.AdEvent.Type.STARTED")}),i.addEventListener(this.google.ima.AdEvent.Type.AD_PROGRESS,t=>{var e,s;const i=null===(e=t.getAdData())||void 0===e?void 0:e.duration,r=null===(s=t.getAdData())||void 0===s?void 0:s.currentTime;isNaN(i)||isNaN(r)||(this._currentRemaining=i-r,this.eventHandler.trigger(L,{remaining:this._currentRemaining,duration:i}))}),i.addEventListener(this.google.ima.AdEvent.Type.STARTED,t=>{this._currentRemaining=-1,this.debugEvent(t);const e=t.getAd();e&&(this._currentDuration=e.getDuration(),this._currentDisplayTs=Date.now(),this.emitWithAd(w,e),e.isLinear()&&IMA.pollRemaining({ima:this,adsManager:i}))}),i.addEventListener(this.google.ima.AdEvent.Type.COMPLETE,t=>{this.debugEvent(t);const e=t.getAd();e&&this.emitWithAd(E,e),Ht(this._timers)}),i.addEventListener(this.google.ima.AdEvent.Type.SKIPPED,t=>{this.debugEvent(t);const e=t.getAd();e&&this.emitWithAd(O,e)}),i.addEventListener(this.google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED,t=>{if(this.isAdPod()&&this.videoTag){const t=Math.abs(this.videoTag.currentTime-this.videoTag.duration)<1?-1:this.videoTag.currentTime;this.setAdBreakTime(t)}this.debugEvent(t);const e=t.getAd();e&&this.emitWithAd(b,e)}),i.addEventListener(this.google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED,t=>{this.debugEvent(t),this._started=!1,this._currentDisplayTs=0,this.eventHandler.trigger(k,{force:!0})}),i.addEventListener(this.google.ima.AdEvent.Type.VOLUME_CHANGED,t=>{this.log("IMA::volume(type: %s, event: %o)",t);const e=i.getVolume();this._volumeLevel=e,this.eventHandler.trigger(M,e)});const r=t=>{this._paused=t,this.eventHandler.trigger(t?S:T)};i.addEventListener(this.google.ima.AdEvent.Type.PAUSED,()=>r(!0)),i.addEventListener(this.google.ima.AdEvent.Type.RESUMED,()=>r(!1)),i.addEventListener(this.google.ima.AdEvent.Type.STARTED,()=>r(!1)),i.addEventListener(this.google.ima.AdEvent.Type.VOLUME_MUTED,t=>{this.log("IMA::volume(type: %s, event: %o)","mute",t),this.eventHandler.trigger(R)});const{width:a,height:n}=t;a&&n&&(i.init(a,n,this.google.ima.ViewMode.NORMAL),this.log("ima.initialise: done initializing"))}),s&&(this.log("Event(reload: %s)",j),this.eventHandler.trigger(j,e)),this.eventHandler.trigger(g,this)}destroyManager(t="unknown"){if(!this._adsManager)return this.log("ima::destroyManager(:skip, label: %s)",t);this.log("ima::destroyManager(:ok, label: %s)",t),this._adsManager.destroy()}reset(){this.destroyManager("reset"),Ht(this._timers),this.clearAdHandlers(),this._started=!1,this._adLoaded=!1}cleanup(){this.destroyManager("cleanup"),this._adsLoader&&this._adsLoader.destroy(),this._adDisplayContainer&&this._adDisplayContainer.destroy(),this._adLoaded=!1}waitForAdsManager(){return new Promise(t=>{this.log("ima.waitForAdsManager:",this._adsManager),this.once(this._adsLoader,this.google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,()=>{this.log("ima.waitForAdsManager(:ok)",this._adsManager),t(this._adsManager)})})}async initAd(t,e=5e3){var s;this.log(`ima.initAd(adTag: ${t}, timeout: ${e})`),this.customPlaybackEnabled||this.loadingController.adRequestStart(this.opts.total_loading_timeout);try{if(await this.requestAd(t,this.loadingController.getRemainingAdLoadTime(e,this.opts.total_loading_timeout)),this._adLoaded=!0,this.customPlaybackEnabled)return;null===(s=this._adsManager)||void 0===s||s.updateAdsRenderingSettings({loadVideoTimeout:this.loadingController.getRemainingAdLoadTime(this.opts.media_timeout||-1,this.opts.total_loading_timeout)})}catch(t){throw this.log("ima.initAd:",t),this._adLoaded=!1,t}finally{Ht(this._timers)}}async requestAd(t,e){if(this.destroyManager("requestAd"),!this.videoTag)return;this.setAdBreakTime(this.videoTag.currentTime);const{autoplay:s=!1}=this.opts,i=Date.now(),r=this.videoTag.muted;this._volumeLevel=this.videoTag.volume;const a=r||0==this._volumeLevel;this._all_ads_completed=!1,this.log("ima.requestAd(%o)",Object.assign(Object.assign({},this.opts),{autoplay:s,muted:r,timeout:e,adTag:t,_volumeLevel:this._volumeLevel,manager:this._adsManager})),this.clearAdHandlers();const n=new this.google.ima.AdsRequest;n.adTagUrl=t;const{height:o,width:d}=this.opts;return d&&(n.linearAdSlotWidth=d),o&&(n.linearAdSlotHeight=o),!this.opts.disable_non_linear_ads&&d&&(n.nonLinearAdSlotWidth=d),!this.opts.disable_non_linear_ads&&o&&(n.nonLinearAdSlotHeight=o-50),n.setAdWillAutoPlay(s),n.setAdWillPlayMuted(a),n.vastLoadTimeout=e,this.eventHandler.trigger(U,{request:n}),this._adsLoader?new Promise(async(t,s)=>{var i;const r=this.waitForAdsManager();null===(i=this._adsLoader)||void 0===i||i.requestAds(n),this.once(this._adsLoader,this.google.ima.AdErrorEvent.Type.AD_ERROR,t=>{s(()=>(this.emitError(v,t),Promise.reject(new Error("Ad load failed"))))}),setTimeout(()=>{s(()=>{r.then(t=>{t.destroy(),this._adsManager===t&&(this._adsManager=void 0)});const t=new Error("Ad internal timeout reached");return this.eventHandler.trigger(P,t),Promise.reject(t)})},e),t(await r)}).then(t=>new Promise((e,s)=>{this.volume(a?0:this._volumeLevel),this.eventHandler.trigger(M,this._volumeLevel);const r=this.cuepoints();if(r&&r.length&&0!==r[0])return e({ad:!1,adsManager:t});this.once(t,this.google.ima.AdErrorEvent.Type.AD_ERROR,t=>{s(()=>(this.emitError(v,t),Promise.reject(t)))}),this.once(t,this.google.ima.AdEvent.Type.ALL_ADS_COMPLETED,()=>{this._all_ads_completed=!0,e(null)}),this.once(t,this.google.ima.AdEvent.Type.LOADED,t=>{this.eventHandler.trigger(A,{request_load_time:Date.now()-i});const s=t.getAd();s&&(this.log("ima.requestAd: AD_REQUEST_COMPLETED",s.getContentType()),"application/javascript"==s.getContentType()&&this.eventHandler.trigger(C,s),e(null))}),this.once(t,this.google.ima.AdEvent.Type.CLICK,()=>{this.log("ima.requestAd: click event"),this.pause()})}),t=>t()):void 0}async playAd(){if(this.log("ima.playAd()",this),!this._adsManager||!this._adLoaded)return;const t=this.currentAd();if(t&&(!this.customPlaybackEnabled||t.isLinear()))try{await this.startAndWaitForAdCompletion(this._adsManager,t.isLinear())}catch(t){throw this.log("ima.playAd",t),t}finally{this._adLoaded=!1,Ht(this._timers)}}startAndWaitForAdCompletion(t,e){if(!this._started)return this.log("ima.startAndWaitForAdCompletion(manager: %o)",{volume:t.getVolume()}),new Promise((s,i)=>{let r=!1;this.once(t,this.google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED,()=>{if(this.log("ima.startAndWaitForAdCompletion: CONTENT_RESUME_REQUESTED <<< happened"),this._started=!1,r)return this.log("ima.startAndWaitForAdCompletion: Content resume requested, but trying to recover from ad error");s()}),this.once(t,this.google.ima.AdErrorEvent.Type.AD_ERROR,async t=>{this.log("ima.startAndWaitForAdCompletion: beginning error recovery ->",t),r=!0;try{const{ok:e}=await IMA.pollForFatalError({err:t,ima:this});e&&(r=!1)}catch(e){this._started=!1,i(t)}});const a=this.getVideoTag();if(!a)return;const n=()=>{e&&(this._started=!0),t.start(),this.eventHandler.trigger(B)};if(!e||a.hasState(lt)||a.hasState(vt))return n();a.paused||a.pause(),a.once(st,()=>n())})}pause(){this.log("ima.pause()"),this._adsManager&&this._adsManager.pause()}resume(){this.log("ima.resume()"),this._adsManager&&this._adsManager.resume()}volume(t){if(this._adsManager)try{return arguments.length>0&&"number"==typeof t&&this._adsManager.setVolume(t),this._volumeLevel=this._adsManager.getVolume()}catch(t){this.log("ima.volume() failed (%o)",t)}}onResize({width:t,height:e,linear:s,silent:i,resize_non_linear:r}){this._adsManager&&(this._adLinear=void 0===s?this._adLinear:s,this.opts&&(t||e)&&(!1===s&&(t+=10,e+=10),this._dimensions={width:t,height:e,linear:s},s&&(this.opts.width=t,this.opts.height=e),(this._adLinear||r)&&(i||this.log("ima.onResize %s x %s",t,e),this._adsManager.resize(t,e,this.google.ima.ViewMode.NORMAL))))}onAdRequestEnd(){var t;this.customPlaybackEnabled||(this.loadingController.adRequestEnd(),null===(t=this._adsManager)||void 0===t||t.updateAdsRenderingSettings({loadVideoTimeout:this.opts.media_timeout||-1}))}getAdInfo(){const t=this.currentAd();if(t)return{duration:t.getDuration(),currentTime:this._currentRemaining}}currentAd(){const t=this._adsManager;if(t)return t.getCurrentAd()}isAdPod(){const t=this.cuepoints();return!!(t&&t.length>1)}cuepoints(){return this._adsManager&&this._adsManager.getCuePoints()}async contentComplete(){this.log("ima.contentComplete() -> ",this),this._adsLoader&&this._adsLoader.contentComplete();const t=this.cuepoints();t&&-1!==t.indexOf(-1)&&await new Promise(t=>{IMA.race(this.eventHandler,[k,q],t)})}isUiDisabled(){try{const t=this.currentAd();return t&&t.isUiDisabled()}catch(t){return null}}getAdPodInfo(){try{const t=this.currentAd();return t&&t.getAdPodInfo()}catch(t){return null}}canDismissNonLinear(){const t=this.currentAd();if(!t||t.isLinear()||!this._adsManager||!this._currentDisplayTs)return!0;const e=Date.now(),s=t.getMinSuggestedDuration();return e-this._currentDisplayTs>1e3*s}static unwrapError(t,e){if(!t)return"";if("function"==typeof t.getMessage){return t.getMessage()}return t.message?t.message:e||""}static pollForFatalError({err:t,ima:e}){let s;try{const e=t.getError(),i=e.getInnerError(),r=i?IMA.unwrapError(i,e.message):"";s={reason:r,type:e.getType(),code:e.getErrorCode()}}catch(t){}const i=e._currentRemaining;return new Promise((t,r)=>{const a=setTimeout(()=>{e.eventHandler&&e.eventHandler.trigger(m,s),r(new Error("Ad not progressing"))},2500);e.eventHandler.once(L,e=>{const s=e.detail.remaining;-1!==s&&s<i&&(clearTimeout(a),t({ok:1}))})})}static pollRemaining({ima:t,adsManager:e}){let s=-1;return qt(t._timers,250,function(){const i=e.getRemainingTime();-1!=t._currentRemaining&&t._currentRemaining<=i||(t._currentRemaining=e.getRemainingTime(),s!=t._currentRemaining&&(s=t._currentRemaining,t.eventHandler.trigger(L,{remaining:t._currentRemaining,duration:t._currentDuration})))})}once(t,e,s){this._adHandlers.push(function(t,e,s){const i=r=>{s(r),t.removeEventListener(e,i)};return t.addEventListener(e,i),()=>t.removeEventListener(e,i)}(t,e,s))}static race(t,e,s){e.forEach(i=>{const r=(...i)=>{e.forEach(e=>t.removeListener(e,r)),s(i)};t.on(i,r)})}clearAdHandlers(){this.log("ima.clearAdHandlers"),this._adHandlers.forEach(t=>t()),this._adHandlers=[]}emitWithAd(t,e){if(this.log("ima.emitWithAd",t,e),!this._adsManager)return;const s=function(t){try{return t.getAdPodInfo().getAdPosition()}catch(t){return}}(e),i=function(t){try{return t.getAdPodInfo().getTotalAds()}catch(t){return}}(e),r={ad:{duration:e.getDuration(),width:e.getWidth(),height:e.getHeight(),position:s,totals:i},volume:this._adsManager.getVolume(),vast_ad_id:e.getAdId(),linear:e.isLinear(),mime_type:e.getContentType(),ima_event:!0};this.log(`emitWithAd::event(name: ${t}, data: %o, ad: %o)`,r,e),this.eventHandler.trigger(t,r)}emitError(t,e){const s={vast_error_type:e.getError().getType(),reason:e.getError().getMessage(),vast_error:e.getError().getErrorCode()};this.log(`ima.error(${t})`,s),this.eventHandler.trigger(t,s)}debugEvent(t){try{const e=t.getAd();if(!e)return;this.log(`ima.event.${t.type} ->`,{event:t,data:t.getAdData(),position:Vt(e),ad:e})}catch(t){}}}var Wt=function(t){var e={exports:{}};return t(e,e.exports),e.exports}(function(t,e){var s=function(){for(var t=new Array(256),e=0;e<256;++e)t[e]="%"+((e<16?"0":"")+e.toString(16)).toUpperCase();return t}(),i=Object.prototype.hasOwnProperty;e.arrayToObject=function(t,e){for(var s=e.plainObjects?Object.create(null):{},i=0;i<t.length;++i)void 0!==t[i]&&(s[i]=t[i]);return s},e.merge=function(t,s,r){if(!s)return t;if("object"!=typeof s){if(Array.isArray(t))t.push(s);else{if("object"!=typeof t)return[t,s];(r.plainObjects||r.allowPrototypes||!i.call(Object.prototype,s))&&(t[s]=!0)}return t}if("object"!=typeof t)return[t].concat(s);var a=t;return Array.isArray(t)&&!Array.isArray(s)&&(a=e.arrayToObject(t,r)),Object.keys(s).reduce(function(t,a){var n=s[a];return i.call(t,a)?t[a]=e.merge(t[a],n,r):t[a]=n,t},a)},e.decode=function(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch(e){return t}},e.encode=function(t){if(0===t.length)return t;for(var e="string"==typeof t?t:String(t),i="",r=0;r<e.length;++r){var a=e.charCodeAt(r);45===a||46===a||95===a||126===a||a>=48&&a<=57||a>=65&&a<=90||a>=97&&a<=122?i+=e.charAt(r):a<128?i+=s[a]:a<2048?i+=s[192|a>>6]+s[128|63&a]:a<55296||a>=57344?i+=s[224|a>>12]+s[128|a>>6&63]+s[128|63&a]:(r+=1,a=65536+((1023&a)<<10|1023&e.charCodeAt(r)),i+=s[240|a>>18]+s[128|a>>12&63]+s[128|a>>6&63]+s[128|63&a])}return i},e.compact=function(t,s){if("object"!=typeof t||null===t)return t;var i=s||[],r=i.indexOf(t);if(-1!==r)return i[r];if(i.push(t),Array.isArray(t)){for(var a=[],n=0;n<t.length;++n)t[n]&&"object"==typeof t[n]?a.push(e.compact(t[n],i)):void 0!==t[n]&&a.push(t[n]);return a}for(var o=Object.keys(t),d=0;d<o.length;++d){var l=o[d];t[l]=e.compact(t[l],i)}return t},e.isRegExp=function(t){return"[object RegExp]"===Object.prototype.toString.call(t)},e.isBuffer=function(t){return null!=t&&!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))}}),Qt={brackets:function(t){return t+"[]"},indices:function(t,e){return t+"["+e+"]"},repeat:function(t){return t}},$t={delimiter:"&",strictNullHandling:!1,skipNulls:!1,encode:!0,encoder:Wt.encode},Kt=function t(e,s,i,r,a,n,o,d,l){var c=e;if("function"==typeof o)c=o(s,c);else if(c instanceof Date)c=c.toISOString();else if(null===c){if(r)return n?n(s):s;c=""}if("string"==typeof c||"number"==typeof c||"boolean"==typeof c||Wt.isBuffer(c))return n?[n(s)+"="+n(c)]:[s+"="+String(c)];var u,h=[];if(void 0===c)return h;if(Array.isArray(o))u=o;else{var p=Object.keys(c);u=d?p.sort(d):p}for(var g=0;g<u.length;++g){var m=u[g];a&&null===c[m]||(h=Array.isArray(c)?h.concat(t(c[m],i(s,m),i,r,a,n,o,d,l)):h.concat(t(c[m],s+(l?"."+m:"["+m+"]"),i,r,a,n,o,d,l)))}return h},Yt=Object.prototype.hasOwnProperty,Zt={delimiter:"&",depth:5,arrayLimit:20,parameterLimit:1e3,strictNullHandling:!1,plainObjects:!1,allowPrototypes:!1,allowDots:!1,decoder:Wt.decode},Jt=function t(e,s,i){if(!e.length)return s;var r,a=e.shift();if("[]"===a)r=(r=[]).concat(t(e,s,i));else{r=i.plainObjects?Object.create(null):{};var n="["===a.charAt(0)&&"]"===a.charAt(a.length-1)?a.slice(1,-1):a,o=parseInt(n,10);!isNaN(o)&&a!==n&&String(o)===n&&o>=0&&i.parseArrays&&o<=i.arrayLimit?(r=[])[o]=t(e,s,i):r[n]=t(e,s,i)}return r},Xt=function(t,e,s){if(t){var i=s.allowDots?t.replace(/\.([^.[]+)/g,"[$1]"):t,r=/(\[[^[\]]*])/g,a=/(\[[^[\]]*])/.exec(i),n=a?i.slice(0,a.index):i,o=[];if(n){if(!s.plainObjects&&Yt.call(Object.prototype,n)&&!s.allowPrototypes)return;o.push(n)}for(var d=0;null!==(a=r.exec(i))&&d<s.depth;){if(d+=1,!s.plainObjects&&Yt.call(Object.prototype,a[1].slice(1,-1))&&!s.allowPrototypes)return;o.push(a[1])}return a&&o.push("["+i.slice(a.index)+"]"),Jt(o,e,s)}},te=function(t,e){var s,i,r=t,a=e||{},n=void 0===a.delimiter?$t.delimiter:a.delimiter,o="boolean"==typeof a.strictNullHandling?a.strictNullHandling:$t.strictNullHandling,d="boolean"==typeof a.skipNulls?a.skipNulls:$t.skipNulls,l=("boolean"==typeof a.encode?a.encode:$t.encode)?"function"==typeof a.encoder?a.encoder:$t.encoder:null,c="function"==typeof a.sort?a.sort:null,u=void 0!==a.allowDots&&a.allowDots;if(null!==a.encoder&&void 0!==a.encoder&&"function"!=typeof a.encoder)throw new TypeError("Encoder has to be a function.");"function"==typeof a.filter?r=(i=a.filter)("",r):Array.isArray(a.filter)&&(s=i=a.filter);var h,p=[];if("object"!=typeof r||null===r)return"";h=a.arrayFormat in Qt?a.arrayFormat:"indices"in a?a.indices?"indices":"repeat":"indices";var g=Qt[h];s||(s=Object.keys(r)),c&&s.sort(c);for(var m=0;m<s.length;++m){var _=s[m];d&&null===r[_]||(p=p.concat(Kt(r[_],_,g,o,d,l,i,c,u)))}return p.join(n)},ee=function(t,e){var s=e||{};if(null!==s.decoder&&void 0!==s.decoder&&"function"!=typeof s.decoder)throw new TypeError("Decoder has to be a function.");if(s.delimiter="string"==typeof s.delimiter||Wt.isRegExp(s.delimiter)?s.delimiter:Zt.delimiter,s.depth="number"==typeof s.depth?s.depth:Zt.depth,s.arrayLimit="number"==typeof s.arrayLimit?s.arrayLimit:Zt.arrayLimit,s.parseArrays=!1!==s.parseArrays,s.decoder="function"==typeof s.decoder?s.decoder:Zt.decoder,s.allowDots="boolean"==typeof s.allowDots?s.allowDots:Zt.allowDots,s.plainObjects="boolean"==typeof s.plainObjects?s.plainObjects:Zt.plainObjects,s.allowPrototypes="boolean"==typeof s.allowPrototypes?s.allowPrototypes:Zt.allowPrototypes,s.parameterLimit="number"==typeof s.parameterLimit?s.parameterLimit:Zt.parameterLimit,s.strictNullHandling="boolean"==typeof s.strictNullHandling?s.strictNullHandling:Zt.strictNullHandling,""===t||null==t)return s.plainObjects?Object.create(null):{};for(var i="string"==typeof t?function(t,e){for(var s={},i=t.split(e.delimiter,e.parameterLimit===1/0?void 0:e.parameterLimit),r=0;r<i.length;++r){var a,n,o=i[r],d=-1===o.indexOf("]=")?o.indexOf("="):o.indexOf("]=")+1;-1===d?(a=e.decoder(o),n=e.strictNullHandling?null:""):(a=e.decoder(o.slice(0,d)),n=e.decoder(o.slice(d+1))),Yt.call(s,a)?s[a]=[].concat(s[a]).concat(n):s[a]=n}return s}(t,s):t,r=s.plainObjects?Object.create(null):{},a=Object.keys(i),n=0;n<a.length;++n){var o=a[n],d=Xt(o,i[o],s);r=Wt.merge(r,d,s)}return Wt.compact(r)};const se=yt("fpads:macros"),ie=/\[([\s\S]+?)\]/g;class Macros{static run(t){try{return t()}catch(t){return void console.error(t)}}static merge(...t){return t.reduce((t,e)=>Object.assign(t,e),{})}static cast(t){return void 0===t?"":"function"==typeof t?encodeURIComponent(Macros.run(t)||""):"string"==typeof t?encodeURIComponent(t):"number"==typeof t||"boolean"==typeof t?t.toString():""}static normalize(t){return t.trim()}static process_obj(t,e,s){return Object.keys(t).reduce((i,r)=>{const a=Macros.process_str(r,e,s,!0),n=t[r];return null===n?(i[a]=n,i):"object"==typeof n?(i[a]=Macros.process_obj(n,e,s),i):"string"==typeof n?(i[a]=Macros.process_str(n,e,s),i):(console.error(new Error(`${n} at ${r} not a handled Macro type`)),i)},{})}static process_str(t,e,s,i=!1){return t.replace(e.pattern,(t,e)=>{const r=Macros.normalize(e);if(!(r in s)||void 0===s[r])return t;const a=s[r],n=i?a:Macros.cast(a);return se("Macro.replace(raw: %s, macro: %s, value: %s)",i,e,n),n})}constructor(t={},e=ie){this.vars=t,this.pattern=e}fork(t={},e=this.pattern){const s=Macros.merge(this.vars,t);return new Macros(s,e)}compile(t,e={}){const s=Macros.merge(this.vars,e),[i,r]=t.split("?"),a=ee(r||"",{strictNullHandling:!0,decoder:t=>t}),n=te(Macros.process_obj(a,this,s),{encode:!1,strictNullHandling:!0});return Macros.process_str(i,this,s,!0)+"?"+n}}function re(t,e={width:0,height:0}){let s,i;try{const t=document.createElement("a");t.href=s=window.location!=window.parent.location?document.referrer:document.location.href,i=t.hostname}catch(t){console.error(t)}const{width:r,height:a}=e,{video_source:n}=t||{},o=function(){const t=window;return"object"==typeof t.__flowplayerAdParameters?t.__flowplayerAdParameters:{}}();return Object.assign({random:Date.now(),page_url:s,domain:i,player_width:r,player_height:a,video_url:n,videourl:n},o)}Macros.patterns={BRACKETS:ie,CURLY:/\{([\s\S]+?)\}/g,UNDERSCORE:/__([\s\S]+?)__/g};const ae=/^flowplayer:\/\/(.+)/;async function ne(t){if("string"==typeof t&&ae.test(t)){const e=ae.exec(t),s=e&&window[e[1]];if(s)return ne(s)}if("function"!=typeof t)return t;try{return await t()}catch(t){return""}}async function oe(t){if("function"==typeof t)return[await ne(t)];if("string"==typeof t)return[await ne(t)];if(Array.isArray(t)){const e=t;return await Promise.all(e.map(ne))}if("object"==typeof t&&t&&t.adTag)return await oe(t.adTag);throw new Error(`\n unhandled ads type ${typeof t}:\n ${JSON.stringify(t)}\n can be:\n | Array<string>\n | string\n | function\n | {adTag: Array<string>|string|function}\n `)}class Schedule{constructor(t,e={}){this._ads=t,this._opts=e,this._nextIndex=0,this._postroll=void 0,this._loadPending=!1,this._postrollActive=!1,this.reset(this._ads)}toJSON(){const t=(this._ads||[]).slice(this._nextIndex);return this._postroll&&t.push(this._postroll),t}reset(t){this.setAds(t),this._nextIndex=0,this._postrollActive=!1}resetCounter(){this._nextIndex=0,this._postrollActive=!1}setAds(t){this._ads=t||[],this.sort()}getAds(){return this._ads}getNextAd(t){return this._ads[this._nextIndex]||t}getCurrentAd(){return this._postrollActive?this._postroll:this._loadPending?0:this._ads[this._nextIndex-1]}getPostroll(){return this._postroll}isDrained(){return this._nextIndex+1>this._ads.length}setPostrollActive(){this._postrollActive=!0}updateContentDuration(t){this._opts.content_duration=t}increment(){++this._nextIndex}decrement(){this._nextIndex>0&&--this._nextIndex}getNextIndex(){return this._nextIndex}getCurrentType(){const t=this.getCurrentAd();if(t)return Schedule.kindOf(t.time)}sort(){this._postroll=this._ads.find(t=>-1===t.time),this._ads=this._ads.filter(t=>t!==this._postroll).sort((t,e)=>t.time===e.time?this._ads.indexOf(t)-this._ads.indexOf(e):t.time-e.time)}shallPlayAd(t){if(this._loadPending)return!1;const e=this.getCurrentAd()||this.getNextAd();return!!(e&&e.time<=t&&-1!==e.time)}shallPlayNext(){const t=this.getNextAd(),e=this.getCurrentAd();return!(!t||!e||t.time!==e.time)}waitForLoad(t,e,s){if(this._loadPending=!1,!e)return!1;const i=s?this._opts.preload_advance:0;return e.time>=0?this._loadPending=t<e.time-i:-1===e.time&&(this._loadPending=this._opts.content_duration>0&&-1!==t?t<this._opts.content_duration-i:-1!==t),this._loadPending}static hasPreroll(t){return!!t.find(t=>0===t.time)}static isOutstream(t){return Schedule.hasPreroll(t)&&!!t[0].outstream}static kindOf(t){switch(t){case 0:return"preroll";case-1:return"postroll";default:return"midroll"}}}const de=Object.prototype,le=Object.getPrototypeOf;const ce=yt("fpads:ads:state");var ue;!function(t){t[t.IDLE=0]="IDLE",t[t.INITIALIZING=1]="INITIALIZING",t[t.FETCHING_AD=2]="FETCHING_AD",t[t.AD_AVAILABLE=4]="AD_AVAILABLE",t[t.BREAK_ACTIVE=8]="BREAK_ACTIVE",t[t.PLAYING=16]="PLAYING",t[t.FATAL_ERROR=32]="FATAL_ERROR"}(ue||(ue={}));class AdsState{static of(){return new AdsState}constructor(t=0){this._state=t}reset(){this._state=0}toggleState(t,e){return void 0===t&&ce(new Error("AdState cannot toggleState for `undefined`")),void 0===e?this._state^=t:e?void(this._state|=t):this._state&=~t}hasAll(t){return this._state==(this._state|t)}hasAny(t){return!!(this._state&t)}get state(){return this._state}}const he={ok:yt("fpads:analytics:request-queue"),err:yt("fpads:analytics:request-queue:err"),warn:yt("fpads:analytics:request-queue:warn")};class RequestQueue{static of(){return new RequestQueue}static is_empty(t){return 0==t.pending.length}static is_high_water(t){return t.open.length==RequestQueue.MAX_OPEN_REQUESTS}static maybe_spawn_req(t){if(RequestQueue.is_empty(t))return he.ok("maybe_spawn_req called Queue that is EMPTY"),t;if(RequestQueue.is_high_water(t))return he.warn("maybe_spawn_req called on Queue that is HIGH_WATER"),t;try{const e=RequestQueue.lpop(t);e&&RequestQueue.request(t,e)}catch(t){he.err(t)}}static increment_failures(t){return t.stats.failures++,t.stats.failures>RequestQueue.MAX_FAILURE_COUNT&&(t.stats.ttl=Date.now()+RequestQueue.REQUEST_TTL_MS),t}static handle_error(t,e){RequestQueue.rm(t,e),RequestQueue.increment_failures(t)}static request(t,[e,s,i]){if(he.ok(`Request[${i.event_type}] request`,i,t.stats),Date.now()<t.stats.ttl)return he.warn(`Request[${i.event_type}] skipping because too many errors too quickly`,t.stats);const r=new XMLHttpRequest;t.open.push(r),r.timeout=RequestQueue.REQUEST_TIMEOUT_MS,r.ontimeout=function(){RequestQueue.handle_error(t,r),he.warn(`Request[${i.event_type}] timed out in ${r.timeout}ms`,t.stats)},r.onerror=function(e){RequestQueue.handle_error(t,r),e&&he.err(e),he.warn(`Request[${i.event_type}] encountered an Error`,r.responseText,t.stats)},r.onreadystatechange=function(){r.readyState==XMLHttpRequest.DONE&&RequestQueue.rm(t,r),Math.floor(r.status/100)},r.onload=function(){RequestQueue.rm(t,r),t.stats.failures&&t.stats.failures--,he.ok(`Request[${i.event_type}] :ok`,r.status)},r.open(s,e),r.setRequestHeader("Content-Type","text/plain;charset=UTF-8");try{r.send(JSON.stringify(i))}catch(t){he.err(t)}}static rpush(t,...e){return e.forEach(e=>{if(RequestQueue.is_high_water(t))return he.warn("Too many open requests, skipping",t.stats);t.pending.push(e),RequestQueue.maybe_spawn_req(t)}),t}static lpop(t){return t.pending.shift()}static rm(t,e){const s=t.open.lastIndexOf(e);return~s&&t.open.splice(s,1),t}constructor(t=[],e=[],s={failures:0,ttl:0}){this.pending=t,this.open=e,this.stats=s}}RequestQueue.MAX_OPEN_REQUESTS=3,RequestQueue.REQUEST_TIMEOUT_MS=4e3,RequestQueue.REQUEST_TTL_MS=5e3,RequestQueue.MAX_FAILURE_COUNT=3;const pe={"Amazon Silk":"amazon_silk","Android Browser":"android",Bada:"bada",BlackBerry:"blackberry",Chrome:"chrome",Chromium:"chromium",Electron:"electron",Epiphany:"epiphany",Firefox:"firefox",Focus:"focus",Generic:"generic","Google Search":"google_search",Googlebot:"googlebot","Internet Explorer":"ie","K-Meleon":"k_meleon",Maxthon:"maxthon","Microsoft Edge":"edge","MZ Browser":"mz","NAVER Whale Browser":"naver",Opera:"opera","Opera Coast":"opera_coast",PhantomJS:"phantomjs",Puffin:"puffin",QupZilla:"qupzilla",QQ:"qq",QQLite:"qqlite",Safari:"safari",Sailfish:"sailfish","Samsung Internet for Android":"samsung_internet",SeaMonkey:"seamonkey",Sleipnir:"sleipnir",Swing:"swing",Tizen:"tizen","UC Browser":"uc",Vivaldi:"vivaldi","WebOS Browser":"webos",WeChat:"wechat","Yandex Browser":"yandex",Roku:"roku"},ge={amazon_silk:"Amazon Silk",android:"Android Browser",bada:"Bada",blackberry:"BlackBerry",chrome:"Chrome",chromium:"Chromium",electron:"Electron",epiphany:"Epiphany",firefox:"Firefox",focus:"Focus",generic:"Generic",googlebot:"Googlebot",google_search:"Google Search",ie:"Internet Explorer",k_meleon:"K-Meleon",maxthon:"Maxthon",edge:"Microsoft Edge",mz:"MZ Browser",naver:"NAVER Whale Browser",opera:"Opera",opera_coast:"Opera Coast",phantomjs:"PhantomJS",puffin:"Puffin",qupzilla:"QupZilla",qq:"QQ Browser",qqlite:"QQ Browser Lite",safari:"Safari",sailfish:"Sailfish",samsung_internet:"Samsung Internet for Android",seamonkey:"SeaMonkey",sleipnir:"Sleipnir",swing:"Swing",tizen:"Tizen",uc:"UC Browser",vivaldi:"Vivaldi",webos:"WebOS Browser",wechat:"WeChat",yandex:"Yandex Browser"},me={tablet:"tablet",mobile:"mobile",desktop:"desktop",tv:"tv"},_e={WindowsPhone:"Windows Phone",Windows:"Windows",MacOS:"macOS",iOS:"iOS",Android:"Android",WebOS:"WebOS",BlackBerry:"BlackBerry",Bada:"Bada",Tizen:"Tizen",Linux:"Linux",ChromeOS:"Chrome OS",PlayStation4:"PlayStation 4",Roku:"Roku"},fe={EdgeHTML:"EdgeHTML",Blink:"Blink",Trident:"Trident",Presto:"Presto",Gecko:"Gecko",WebKit:"WebKit"};class Utils{static getFirstMatch(t,e){const s=e.match(t);return s&&s.length>0&&s[1]||""}static getSecondMatch(t,e){const s=e.match(t);return s&&s.length>1&&s[2]||""}static matchAndReturnConst(t,e,s){if(t.test(e))return s}static getWindowsVersionName(t){switch(t){case"NT":return"NT";case"XP":case"NT 5.1":return"XP";case"NT 5.0":return"2000";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}}static getMacOSVersionName(t){const e=t.split(".").splice(0,2).map(t=>parseInt(t,10)||0);if(e.push(0),10===e[0])switch(e[1]){case 5:return"Leopard";case 6:return"Snow Leopard";case 7:return"Lion";case 8:return"Mountain Lion";case 9:return"Mavericks";case 10:return"Yosemite";case 11:return"El Capitan";case 12:return"Sierra";case 13:return"High Sierra";case 14:return"Mojave";case 15:return"Catalina";default:return}}static getAndroidVersionName(t){const e=t.split(".").splice(0,2).map(t=>parseInt(t,10)||0);if(e.push(0),!(1===e[0]&&e[1]<5))return 1===e[0]&&e[1]<6?"Cupcake":1===e[0]&&e[1]>=6?"Donut":2===e[0]&&e[1]<2?"Eclair":2===e[0]&&2===e[1]?"Froyo":2===e[0]&&e[1]>2?"Gingerbread":3===e[0]?"Honeycomb":4===e[0]&&e[1]<1?"Ice Cream Sandwich":4===e[0]&&e[1]<4?"Jelly Bean":4===e[0]&&e[1]>=4?"KitKat":5===e[0]?"Lollipop":6===e[0]?"Marshmallow":7===e[0]?"Nougat":8===e[0]?"Oreo":9===e[0]?"Pie":void 0}static getVersionPrecision(t){return t.split(".").length}static compareVersions(t,e,s=!1){const i=Utils.getVersionPrecision(t),r=Utils.getVersionPrecision(e);let a=Math.max(i,r),n=0;const o=Utils.map([t,e],t=>{const e=a-Utils.getVersionPrecision(t),s=t+new Array(e+1).join(".0");return Utils.map(s.split("."),t=>new Array(20-t.length).join("0")+t).reverse()});for(s&&(n=a-Math.min(i,r)),a-=1;a>=n;){if(o[0][a]>o[1][a])return 1;if(o[0][a]===o[1][a]){if(a===n)return 0;a-=1}else if(o[0][a]<o[1][a])return-1}}static map(t,e){const s=[];let i;if(Array.prototype.map)return Array.prototype.map.call(t,e);for(i=0;i<t.length;i+=1)s.push(e(t[i]));return s}static find(t,e){let s,i;if(Array.prototype.find)return Array.prototype.find.call(t,e);for(s=0,i=t.length;s<i;s+=1){const i=t[s];if(e(i,s))return i}}static assign(t,...e){const s=t;let i,r;if(Object.assign)return Object.assign(t,...e);for(i=0,r=e.length;i<r;i+=1){const t=e[i];if("object"==typeof t&&null!==t){Object.keys(t).forEach(e=>{s[e]=t[e]})}}return t}static getBrowserAlias(t){return pe[t]}static getBrowserTypeByAlias(t){return ge[t]||""}}const ve=/version\/(\d+(\.?_?\d+)+)/i,ye=[{test:[/googlebot/i],describe(t){const e={name:"Googlebot"},s=Utils.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,t)||Utils.getFirstMatch(ve,t);return s&&(e.version=s),e}},{test:[/opera/i],describe(t){const e={name:"Opera"},s=Utils.getFirstMatch(ve,t)||Utils.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/opr\/|opios/i],describe(t){const e={name:"Opera"},s=Utils.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i,t)||Utils.getFirstMatch(ve,t);return s&&(e.version=s),e}},{test:[/SamsungBrowser/i],describe(t){const e={name:"Samsung Internet for Android"},s=Utils.getFirstMatch(ve,t)||Utils.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/Whale/i],describe(t){const e={name:"NAVER Whale Browser"},s=Utils.getFirstMatch(ve,t)||Utils.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/MZBrowser/i],describe(t){const e={name:"MZ Browser"},s=Utils.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,t)||Utils.getFirstMatch(ve,t);return s&&(e.version=s),e}},{test:[/focus/i],describe(t){const e={name:"Focus"},s=Utils.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,t)||Utils.getFirstMatch(ve,t);return s&&(e.version=s),e}},{test:[/swing/i],describe(t){const e={name:"Swing"},s=Utils.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,t)||Utils.getFirstMatch(ve,t);return s&&(e.version=s),e}},{test:[/coast/i],describe(t){const e={name:"Opera Coast"},s=Utils.getFirstMatch(ve,t)||Utils.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/opt\/\d+(?:.?_?\d+)+/i],describe(t){const e={name:"Opera Touch"},s=Utils.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i,t)||Utils.getFirstMatch(ve,t);return s&&(e.version=s),e}},{test:[/yabrowser/i],describe(t){const e={name:"Yandex Browser"},s=Utils.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,t)||Utils.getFirstMatch(ve,t);return s&&(e.version=s),e}},{test:[/ucbrowser/i],describe(t){const e={name:"UC Browser"},s=Utils.getFirstMatch(ve,t)||Utils.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/Maxthon|mxios/i],describe(t){const e={name:"Maxthon"},s=Utils.getFirstMatch(ve,t)||Utils.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/epiphany/i],describe(t){const e={name:"Epiphany"},s=Utils.getFirstMatch(ve,t)||Utils.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/puffin/i],describe(t){const e={name:"Puffin"},s=Utils.getFirstMatch(ve,t)||Utils.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/sleipnir/i],describe(t){const e={name:"Sleipnir"},s=Utils.getFirstMatch(ve,t)||Utils.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/k-meleon/i],describe(t){const e={name:"K-Meleon"},s=Utils.getFirstMatch(ve,t)||Utils.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/micromessenger/i],describe(t){const e={name:"WeChat"},s=Utils.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,t)||Utils.getFirstMatch(ve,t);return s&&(e.version=s),e}},{test:[/qqbrowser/i],describe(t){const e={name:/qqbrowserlite/i.test(t)?"QQ Browser Lite":"QQ Browser"},s=Utils.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i,t)||Utils.getFirstMatch(ve,t);return s&&(e.version=s),e}},{test:[/msie|trident/i],describe(t){const e={name:"Internet Explorer"},s=Utils.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/\sedg\//i],describe(t){const e={name:"Microsoft Edge"},s=Utils.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/edg([ea]|ios)/i],describe(t){const e={name:"Microsoft Edge"},s=Utils.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/vivaldi/i],describe(t){const e={name:"Vivaldi"},s=Utils.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/seamonkey/i],describe(t){const e={name:"SeaMonkey"},s=Utils.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/sailfish/i],describe(t){const e={name:"Sailfish"},s=Utils.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,t);return s&&(e.version=s),e}},{test:[/silk/i],describe(t){const e={name:"Amazon Silk"},s=Utils.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/phantom/i],describe(t){const e={name:"PhantomJS"},s=Utils.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/slimerjs/i],describe(t){const e={name:"SlimerJS"},s=Utils.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe(t){const e={name:"BlackBerry"},s=Utils.getFirstMatch(ve,t)||Utils.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/(web|hpw)[o0]s/i],describe(t){const e={name:"WebOS Browser"},s=Utils.getFirstMatch(ve,t)||Utils.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/bada/i],describe(t){const e={name:"Bada"},s=Utils.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/tizen/i],describe(t){const e={name:"Tizen"},s=Utils.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,t)||Utils.getFirstMatch(ve,t);return s&&(e.version=s),e}},{test:[/qupzilla/i],describe(t){const e={name:"QupZilla"},s=Utils.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,t)||Utils.getFirstMatch(ve,t);return s&&(e.version=s),e}},{test:[/firefox|iceweasel|fxios/i],describe(t){const e={name:"Firefox"},s=Utils.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/electron/i],describe(t){const e={name:"Electron"},s=Utils.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/MiuiBrowser/i],describe(t){const e={name:"Miui"},s=Utils.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/chromium/i],describe(t){const e={name:"Chromium"},s=Utils.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,t)||Utils.getFirstMatch(ve,t);return s&&(e.version=s),e}},{test:[/chrome|crios|crmo/i],describe(t){const e={name:"Chrome"},s=Utils.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/GSA/i],describe(t){const e={name:"Google Search"},s=Utils.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test(t){const e=!t.test(/like android/i),s=t.test(/android/i);return e&&s},describe(t){const e={name:"Android Browser"},s=Utils.getFirstMatch(ve,t);return s&&(e.version=s),e}},{test:[/playstation 4/i],describe(t){const e={name:"PlayStation 4"},s=Utils.getFirstMatch(ve,t);return s&&(e.version=s),e}},{test:[/safari|applewebkit/i],describe(t){const e={name:"Safari"},s=Utils.getFirstMatch(ve,t);return s&&(e.version=s),e}},{test:[/.*/i],describe(t){const e=-1!==t.search("\\(")?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return{name:Utils.getFirstMatch(e,t),version:Utils.getSecondMatch(e,t)}}}];var Ae=[{test:[/Roku\/DVP/],describe(t){const e=Utils.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,t);return{name:_e.Roku,version:e}}},{test:[/windows phone/i],describe(t){const e=Utils.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,t);return{name:_e.WindowsPhone,version:e}}},{test:[/windows /i],describe(t){const e=Utils.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,t),s=Utils.getWindowsVersionName(e);return{name:_e.Windows,version:e,versionName:s}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe(t){const e={name:_e.iOS},s=Utils.getSecondMatch(/(Version\/)(\d[\d.]+)/,t);return s&&(e.version=s),e}},{test:[/macintosh/i],describe(t){const e=Utils.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,t).replace(/[_\s]/g,"."),s=Utils.getMacOSVersionName(e),i={name:_e.MacOS,version:e};return s&&(i.versionName=s),i}},{test:[/(ipod|iphone|ipad)/i],describe(t){const e=Utils.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,t).replace(/[_\s]/g,".");return{name:_e.iOS,version:e}}},{test(t){const e=!t.test(/like android/i),s=t.test(/android/i);return e&&s},describe(t){const e=Utils.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i,t),s=Utils.getAndroidVersionName(e),i={name:_e.Android,version:e};return s&&(i.versionName=s),i}},{test:[/(web|hpw)[o0]s/i],describe(t){const e=Utils.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,t),s={name:_e.WebOS};return e&&e.length&&(s.version=e),s}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe(t){const e=Utils.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,t)||Utils.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,t)||Utils.getFirstMatch(/\bbb(\d+)/i,t);return{name:_e.BlackBerry,version:e}}},{test:[/bada/i],describe(t){const e=Utils.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,t);return{name:_e.Bada,version:e}}},{test:[/tizen/i],describe(t){const e=Utils.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,t);return{name:_e.Tizen,version:e}}},{test:[/linux/i],describe:()=>({name:_e.Linux})},{test:[/CrOS/],describe:()=>({name:_e.ChromeOS})},{test:[/PlayStation 4/],describe(t){const e=Utils.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,t);return{name:_e.PlayStation4,version:e}}}],be=[{test:[/googlebot/i],describe:()=>({type:"bot",vendor:"Google"})},{test:[/huawei/i],describe(t){const e=Utils.getFirstMatch(/(can-l01)/i,t)&&"Nova",s={type:me.mobile,vendor:"Huawei"};return e&&(s.model=e),s}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:()=>({type:me.tablet,vendor:"Nexus"})},{test:[/ipad/i],describe:()=>({type:me.tablet,vendor:"Apple",model:"iPad"})},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:()=>({type:me.tablet,vendor:"Apple",model:"iPad"})},{test:[/kftt build/i],describe:()=>({type:me.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"})},{test:[/silk/i],describe:()=>({type:me.tablet,vendor:"Amazon"})},{test:[/tablet(?! pc)/i],describe:()=>({type:me.tablet})},{test(t){const e=t.test(/ipod|iphone/i),s=t.test(/like (ipod|iphone)/i);return e&&!s},describe(t){const e=Utils.getFirstMatch(/(ipod|iphone)/i,t);return{type:me.mobile,vendor:"Apple",model:e}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:()=>({type:me.mobile,vendor:"Nexus"})},{test:[/[^-]mobi/i],describe:()=>({type:me.mobile})},{test:t=>"blackberry"===t.getBrowserName(!0),describe:()=>({type:me.mobile,vendor:"BlackBerry"})},{test:t=>"bada"===t.getBrowserName(!0),describe:()=>({type:me.mobile})},{test:t=>"windows phone"===t.getBrowserName(),describe:()=>({type:me.mobile,vendor:"Microsoft"})},{test(t){const e=Number(String(t.getOSVersion()).split(".")[0]);return"android"===t.getOSName(!0)&&e>=3},describe:()=>({type:me.tablet})},{test:t=>"android"===t.getOSName(!0),describe:()=>({type:me.mobile})},{test:t=>"macos"===t.getOSName(!0),describe:()=>({type:me.desktop,vendor:"Apple"})},{test:t=>"windows"===t.getOSName(!0),describe:()=>({type:me.desktop})},{test:t=>"linux"===t.getOSName(!0),describe:()=>({type:me.desktop})},{test:t=>"playstation 4"===t.getOSName(!0),describe:()=>({type:me.tv})},{test:t=>"roku"===t.getOSName(!0),describe:()=>({type:me.tv})}],we=[{test:t=>"microsoft edge"===t.getBrowserName(!0),describe(t){if(/\sedg\//i.test(t))return{name:fe.Blink};const e=Utils.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,t);return{name:fe.EdgeHTML,version:e}}},{test:[/trident/i],describe(t){const e={name:fe.Trident},s=Utils.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:t=>t.test(/presto/i),describe(t){const e={name:fe.Presto},s=Utils.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test(t){const e=t.test(/gecko/i),s=t.test(/like gecko/i);return e&&!s},describe(t){const e={name:fe.Gecko},s=Utils.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/(apple)?webkit\/537\.36/i],describe:()=>({name:fe.Blink})},{test:[/(apple)?webkit/i],describe(t){const e={name:fe.WebKit},s=Utils.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}}];class Parser{constructor(t,e=!1){if(null==t||""===t)throw new Error("UserAgent parameter can't be empty");this._ua=t,this.parsedResult={},!0!==e&&this.parse()}getUA(){return this._ua}test(t){return t.test(this._ua)}parseBrowser(){this.parsedResult.browser={};const t=Utils.find(ye,t=>{if("function"==typeof t.test)return t.test(this);if(t.test instanceof Array)return t.test.some(t=>this.test(t));throw new Error("Browser's test function is not valid")});return t&&(this.parsedResult.browser=t.describe(this.getUA())),this.parsedResult.browser}getBrowser(){return this.parsedResult.browser?this.parsedResult.browser:this.parseBrowser()}getBrowserName(t){return t?String(this.getBrowser().name).toLowerCase()||"":this.getBrowser().name||""}getBrowserVersion(){return this.getBrowser().version}getOS(){return this.parsedResult.os?this.parsedResult.os:this.parseOS()}parseOS(){this.parsedResult.os={};const t=Utils.find(Ae,t=>{if("function"==typeof t.test)return t.test(this);if(t.test instanceof Array)return t.test.some(t=>this.test(t));throw new Error("Browser's test function is not valid")});return t&&(this.parsedResult.os=t.describe(this.getUA())),this.parsedResult.os}getOSName(t){const{name:e}=this.getOS();return t?String(e).toLowerCase()||"":e||""}getOSVersion(){return this.getOS().version}getPlatform(){return this.parsedResult.platform?this.parsedResult.platform:this.parsePlatform()}getPlatformType(t=!1){const{type:e}=this.getPlatform();return t?String(e).toLowerCase()||"":e||""}parsePlatform(){this.parsedResult.platform={};const t=Utils.find(be,t=>{if("function"==typeof t.test)return t.test(this);if(t.test instanceof Array)return t.test.some(t=>this.test(t));throw new Error("Browser's test function is not valid")});return t&&(this.parsedResult.platform=t.describe(this.getUA())),this.parsedResult.platform}getEngine(){return this.parsedResult.engine?this.parsedResult.engine:this.parseEngine()}getEngineName(t){return t?String(this.getEngine().name).toLowerCase()||"":this.getEngine().name||""}parseEngine(){this.parsedResult.engine={};const t=Utils.find(we,t=>{if("function"==typeof t.test)return t.test(this);if(t.test instanceof Array)return t.test.some(t=>this.test(t));throw new Error("Browser's test function is not valid")});return t&&(this.parsedResult.engine=t.describe(this.getUA())),this.parsedResult.engine}parse(){return this.parseBrowser(),this.parseOS(),this.parsePlatform(),this.parseEngine(),this}getResult(){return Utils.assign({},this.parsedResult)}satisfies(t){const e={};let s=0;const i={};let r=0;if(Object.keys(t).forEach(a=>{const n=t[a];"string"==typeof n?(i[a]=n,r+=1):"object"==typeof n&&(e[a]=n,s+=1)}),s>0){const t=Object.keys(e),s=Utils.find(t,t=>this.isOS(t));if(s){const t=this.satisfies(e[s]);if(void 0!==t)return t}const i=Utils.find(t,t=>this.isPlatform(t));if(i){const t=this.satisfies(e[i]);if(void 0!==t)return t}}if(r>0){const t=Object.keys(i),e=Utils.find(t,t=>this.isBrowser(t,!0));if(void 0!==e)return this.compareVersion(i[e])}}isBrowser(t,e=!1){const s=this.getBrowserName().toLowerCase();let i=t.toLowerCase();const r=Utils.getBrowserTypeByAlias(i);return e&&r&&(i=r.toLowerCase()),i===s}compareVersion(t){let e=[0],s=t,i=!1;const r=this.getBrowserVersion();if("string"==typeof r)return">"===t[0]||"<"===t[0]?(s=t.substr(1),"="===t[1]?(i=!0,s=t.substr(2)):e=[],">"===t[0]?e.push(1):e.push(-1)):"="===t[0]?s=t.substr(1):"~"===t[0]&&(i=!0,s=t.substr(1)),e.indexOf(Utils.compareVersions(r,s,i))>-1}isOS(t){return this.getOSName(!0)===String(t).toLowerCase()}isPlatform(t){return this.getPlatformType(!0)===String(t).toLowerCase()}isEngine(t){return this.getEngineName(!0)===String(t).toLowerCase()}is(t,e=!1){return this.isBrowser(t,e)||this.isOS(t)||this.isPlatform(t)}some(t=[]){return t.some(t=>this.is(t))}}
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((t="undefined"!=typeof globalThis?globalThis:t||self).flowplayer=t.flowplayer||{},t.flowplayer.ads=e())}(this,function(){"use strict";var t;!function(t){t[t.ADS=2]="ADS",t[t.ANALYTICS=4]="ANALYTICS",t[t.NO_METERING=8]="NO_METERING",t[t.DEVELOPER_PLAN=16]="DEVELOPER_PLAN",t[t.WOWZA_VIDEO=32]="WOWZA_VIDEO"}(t||(t={}));const e=["localhost","127.0.0.1","0.0.0.0","s.codepen.io","cdpn.io","try.flowplayer.com"];function s(t,s){return!!~e.indexOf(t)||t.indexOf(s)===t.length-s.length}s.check_whitelist=function(t){return!!~e.indexOf(t)};function i(t){this.message=t}i.prototype=new Error,i.prototype.name="InvalidCharacterError";var r="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new i("'atob' failed: The string to be decoded is not correctly encoded.");for(var s,r,a=0,n=0,o="";r=e.charAt(n++);~r&&(s=a%4?64*s+r:r,a++%4)?o+=String.fromCharCode(255&s>>(-2*a&6)):0)r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(r);return o};var a=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(r(t).replace(/(.)/g,function(t,e){var s=e.charCodeAt(0).toString(16).toUpperCase();return s.length<2&&(s="0"+s),"%"+s}))}(e)}catch(t){return r(e)}};function n(t){this.message=t}n.prototype=new Error,n.prototype.name="InvalidTokenError";var o=function(t,e){if("string"!=typeof t)throw new n("Invalid token specified");var s=!0===(e=e||{}).header?0:1;try{return JSON.parse(a(t.split(".")[s]))}catch(t){throw new n("Invalid token specified: "+t.message)}};o.InvalidTokenError=n;const d="production";function l(t,e){const s={valid_jwt:!1,raw:"",data:{acl:0},exp:0};let i={c:"{}",exp:0};e=e||{};try{i=o(t),s.valid_jwt=!0}catch(t){}return s.raw=t,s.data=JSON.parse(i.c),s.exp=i.exp,e.require_valid_token&&l.validate(s),s}function c(t){return{grant:t,is_granted:e=>(t&e)===e}}function u(){const t="undefined"!=typeof document&&"undefined"!=typeof window,e=t?navigator.userAgent:"",s=/iP(hone|od)/i.test(e)&&!/iPad/.test(e)&&!/IEMobile/i.test(e),i=/Android/.test(e)&&!/Firefox/.test(e),r=/^((?!chrome|android).)*safari/i.test(e),a=/chrome|crios/i.test(e)&&!/opr|opera|chromium|edg|ucbrowser|googlebot/i.test(e),n=/firefox|fxios/i.test(e)&&!/seamonkey/i.test(e),o=/edg/i.test(e),d=/opr|opera/i.test(e),l=/SamsungBrowser/.test(e),c=l&&/SMART-TV/.test(e);return{controls:!s,video:function(e){return t&&document.createElement("video").canPlayType(e)},lang:t&&window.navigator.language,android:i,iphone:s,safari:r,edge:o,opera:d,chrome:a,firefox:n,ios:t&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,samsung:l,samsung_tv:l&&c,touch:"ontouchstart"in window,tizen:"tizen"in window,webOS:"webos"in window}}function h(t){return{width:t.clientWidth,height:t.clientHeight}}function p(t,e,s){return"number"==typeof s&&(s+="px"),t.style.setProperty(e,s),t}l.validate=function(t){if("string"==typeof t&&(t=l(t)),!t||!t.raw){if(s.check_whitelist(window.location.hostname)||"dev"===d.toString())return!0;throw new Error("No token provided in configuration")}if(!t.valid_jwt)throw new Error("Invalid token provided");const e=window.location.hostname,i=s.bind(null,e);if("dev"!==d.toString()&&t.data.domain&&t.data.domain.length&&!t.data.domain.some(i))throw new Error("Domain not allowed");if("dev"!==d.toString()&&1e3*t.exp-Date.now()<0)throw new Error("Expired token");return!0},l.id=function(t){if(t)return"string"==typeof t&&(t=l(t)),t.data.id},c.of=c,c.from_token=function(t){const e=l(t,{require_valid_token:!0});return c.of(e.data.acl)},c.permissions=t;const g="ad-initialized",m="ad-playback-error",_="ad-teardown",f="ad-videotag-attached",v="ad-request-error",y="ad-requested",A="ad-request-completed",b="ad-pause-content",w="ad-started",E="ad-completed",S="ad-paused",T="ad-resumed",L="ad-progress",O="ad-skipped",R="ad-muted",M="ad-volume-changed",P="ad-timeout",k="ad-break-completed",D="ad-postroll-finished",I="ad-preroll-finished",C="vpaid-init",N="ad-ima-adapter-init",U="ad-ima-before-ads-request",x="ad-ima-rendering-settings",F="ad-adapter-init-failed",B="ad-play-requested",j="reload-ad-requested",q="ad-error",H="request/ad/pause",V="request/ad/play",z="request/ad/muteunmute",G="ad/show-first-frame",W="ad/resize",Q="ad/set-ui-flags",$="ad/pbjs";var K=Object.freeze({__proto__:null,AD_INIT:g,AD_PLAYBACK_ERROR:m,AD_TEARDOWN:_,AD_VIDEOTAG_ATTACHED:f,AD_BLOCKED:"ad-blocked",AD_REQUEST_ERROR:v,AD_REQUESTED:y,AD_REQUEST_COMPLETED:A,AD_PAUSE_CONTENT:b,AD_STARTED:w,AD_COMPLETED:E,AD_PAUSED:S,AD_RESUMED:T,AD_WAITING:"ad-waiting",AD_PROGRESS:L,AD_SKIPPED:O,AD_MUTED:R,AD_VOLUME_CHANGED:M,AD_FULLSCREEN:"ad-fullscreen",AD_TIMEOUT:P,AD_BREAK_COMPLETED:k,AD_POSTROLL_FINISHED:D,AD_PREROLL_FINSIHED:I,AD_MIDROLL_FINISHED:"ad-midroll-finished",VPAID_INIT:C,IMA_ADAPTER_INIT:N,IMA_BEFORE_ADS_REQUEST:U,IMA_ADS_RENDERING_SETTINGS:x,ADAPTER_INIT_FAILED:F,AD_PLAY_REQUESTED:B,RELOAD_AD_REQUESTED:j,AD_ERROR:q,REQUEST_AD_PAUSE:H,REQUEST_AD_PLAY:V,REQUEST_AD_MUTE_UNMUTE:z,AD_SHOW_FIRST_FRAME:G,AD_RESIZE:W,AD_SET_UI_FLAGS:Q,PBJS_AVAILABLE:$});const Y="resize",Z="volumechange",J="playing",X="ended",tt="seeked",et="seeking",st="viewenter",it="beforeplay";const rt="is-playing",at="is-starting",nt="is-live",ot="is-waiting",dt="is-autoplay",lt="is-in-viewport";function ct(t,e,s){const i=function(t,e){const s=new CustomEvent(t,{detail:e,cancelable:!0});return e&&Object.defineProperty(s,"data",{get:()=>e}),s}(e,s);return t.dispatchEvent(i),t}var ut;!function(){let t=!1;try{const e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("testPassive",null,e),window.removeEventListener("testPassive",null,e)}catch(t){}}(),function(t){t[t.OFF=0]="OFF",t[t.ON=1]="ON",t[t.AUDIO_REQUIRED=2]="AUDIO_REQUIRED"}(ut||(ut={}));function ht(t){const e="number"==typeof t?t:parseInt(t,10);return(e>9?"":"0")+e}function pt(t){return function(t,e){const s=t.seekable;if("object"!=typeof t.opts||0==s.length)return{head:0,tail:0};const i=gt(t),r=e||t.live_state.dvr_window;return{head:i,tail:"number"!=typeof r||i-r<0?s.start(0):i-r}}(t).tail}function gt(t){var e;const s=t.seekable;return s.length?t.hasState("is-chromecast-playing")||!(null===(e=t.hls)||void 0===e?void 0:e.liveSyncPosition)?s.end(s.length-1):t.hls.liveSyncPosition:0}function mt(t){try{t.dvr_offset=0,t.currentTime=gt(t)}catch(t){console.warn("failed to seek to now: %j",t)}}const _t=1;function ft(t,e){if(!t.hasState(nt)||![void 0,0,-1].includes(e)||!t.seekable.length||t.hasState("has-casted"))return t.setState(at,!1);t.once(tt,()=>t.setState(at,!1)),0===e?function(t){t.currentTime=pt(t)}(t):mt(t)}const vt="is-popped-out";function yt(t,e){const s=function(){try{return localStorage.getItem("flowplayer/debug")}catch(t){return""}}(),i=(i,...r)=>{try{const a=(null==e?void 0:e.debug)||s;a&&t.match(a)&&console.log(`flowplayer/${t} -- ${i}`,...r)}catch(t){console.warn(t)}};return i.log=i,i}const At=(t,e)=>new(((t,e)=>{const s=t.get(e);if(!s)throw new Error(`no flowplayer component with the name ${e} exists`);const i=window.customElements.get(e);if(!i)throw new Error(`no default flowplayer component with the name ${e} exists`);const r=window.customElements.get(s);return"function"!=typeof r?i:r})(t._customElements,e))(t),bt=(t,e,s)=>{window.customElements.get(e)||window.customElements.define(e,s),t.customElements.get(e)||t.customElements.set(e,e)},wt="flowplayer-ad-ui",Et="flowplayer-ad-controls",St="flowplayer-ad-countdown",Tt="flowplayer-ad-indicator",Lt=new Blob([new Uint8Array([0,0,0,28,102,116,121,112,105,115,111,109,0,0,2,0,105,115,111,109,105,115,111,50,109,112,52,49,0,0,0,8,102,114,101,101,0,0,2,239,109,100,97,116,33,16,5,32,164,27,255,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,55,167,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,112,33,16,5,32,164,27,255,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,55,167,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,112,0,0,2,194,109,111,111,118,0,0,0,108,109,118,104,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,232,0,0,0,47,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,1,236,116,114,97,107,0,0,0,92,116,107,104,100,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,47,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,36,101,100,116,115,0,0,0,28,101,108,115,116,0,0,0,0,0,0,0,1,0,0,0,47,0,0,0,0,0,1,0,0,0,0,1,100,109,100,105,97,0,0,0,32,109,100,104,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,172,68,0,0,8,0,85,196,0,0,0,0,0,45,104,100,108,114,0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0,0,0,1,15,109,105,110,102,0,0,0,16,115,109,104,100,0,0,0,0,0,0,0,0,0,0,0,36,100,105,110,102,0,0,0,28,100,114,101,102,0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1,0,0,0,211,115,116,98,108,0,0,0,103,115,116,115,100,0,0,0,0,0,0,0,1,0,0,0,87,109,112,52,97,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,2,0,16,0,0,0,0,172,68,0,0,0,0,0,51,101,115,100,115,0,0,0,0,3,128,128,128,34,0,2,0,4,128,128,128,20,64,21,0,0,0,0,1,244,0,0,1,243,249,5,128,128,128,2,18,16,6,128,128,128,1,2,0,0,0,24,115,116,116,115,0,0,0,0,0,0,0,1,0,0,0,2,0,0,4,0,0,0,0,28,115,116,115,99,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,2,0,0,0,1,0,0,0,28,115,116,115,122,0,0,0,0,0,0,0,0,0,0,0,2,0,0,1,115,0,0,1,116,0,0,0,20,115,116,99,111,0,0,0,0,0,0,0,1,0,0,0,44,0,0,0,98,117,100,116,97,0,0,0,90,109,101,116,97,0,0,0,0,0,0,0,33,104,100,108,114,0,0,0,0,0,0,0,0,109,100,105,114,97,112,112,108,0,0,0,0,0,0,0,0,0,0,0,0,45,105,108,115,116,0,0,0,37,169,116,111,111,0,0,0,29,100,97,116,97,0,0,0,1,0,0,0,0,76,97,118,102,53,54,46,52,48,46,49,48,49])],{type:"video/mp4"});let Ot=null;function Rt(t,e=2e3){return new Promise(s=>{const i=document.createElement("video"),r={autoplay_sound:!1,autoplay_muted:!1},a=()=>{i.pause(),i.currentTime=0,i.src="",i.remove(),s(r)},n=setTimeout(a,e);i.setAttribute("playsinline",""),i.setAttribute("webkit-playsinline",""),i.setAttribute("disablepictureinpicture",""),i.preload="auto",i.playsInline=!0,i.muted=!1,Object.assign(i.style,{position:"fixed",left:"-9999px",top:"0",width:"1px",height:"1px",opacity:"0",pointerEvents:"none"}),document.body.appendChild(i),i.src=(Ot||(Ot=URL.createObjectURL(Lt)),Ot);(async()=>{try{return await i.play(),clearTimeout(n),r.autoplay_sound=!0,r.autoplay_muted=!0,a()}catch(e){if(t)return clearTimeout(n),a()}try{i.muted=!0,i.setAttribute("muted",""),await i.play(),r.autoplay_muted=!0}catch(t){}clearTimeout(n),a()})()})}const Mt=yt("ads/lifecycle"),Pt=[m,_,k];async function kt({config:t,root:e,content:s,ads:i,ima:r}){var a;Mt("LifeCycle::initLifeCycle",t,e,s,i,r),s.autoplay=!1;const n=t.autoplay===ut.AUDIO_REQUIRED,o=function(t,e){return{muted:!(e||!t.muted),volume:t.volume}}(s,n);s.on(Z,()=>{o.volume=s.volume,o.muted=s.muted}),s.on(G,()=>{Mt("showFirstFrame"),e.classList.toggle("ad-hide-first-frame",!1)});const d=At(s,wt),l=d;s.emit(Q,{ui_flags:null===(a=t.ads)||void 0===a?void 0:a.ui}),s.renderPlugin(d);const c={listening:!1,preload:null==r?void 0:r.preload_ads};if(Mt("initial",o),i.setVideoTag(s),t.autoplay){Mt("Trying to autoplay"),e.classList.add("ad-hide-first-frame"),Mt("hideFirstFrame");const a=await async function(t,e){const[s,i]=[t.muted,t.volume];Mt("Lifecycle::peek_content(:muted => %s, :volume => %s)",s,i),await async function(t){return Mt("Lifecycle::wait_for_source"),new Promise((e,s)=>{const i=50,r=2e3;let a=0;const n=setInterval(()=>{if(++a>r/i)return clearInterval(n),s(new Error(`No source in ${r}ms, giving up`));(t.currentSrc||"dash"in t)&&(e(null),clearInterval(n))},i)})}(t),await function(t){return new Promise(e=>{if(t.hasState(lt))return e(null);t.once(st,()=>e(null))})}(t);const r=Date.now();!e&&t.opts.muted||(t.muted=!1);t.volume=t.volume?t.volume:1;const{autoplay_sound:a,autoplay_muted:n}=await Rt(e);return Mt("Lifecycle::peek_content:: ","audioRequired: "+e," autoplay_sound: "+a," autoplay_muted: "+n," peek_content_check_ms: "+(Date.now()-r)),t.opts.muted&&!e?n:!!a||!e&&(t.muted=!!n||s,n)}(s,n);a?(Mt("Can autoplay, start ad"),s.opts.autoplay=1,s.setState(dt,!0),Dt({ads:i,content:s,state:c,adContainer:l,ima:r,config:t})):(Mt("cannot autoplay(audioRequired: %s), fallback to poster state",n),t.autoplay=0,s.emit(G,{root:e}),s.setState("is-starting",!0))}!t.autoplay&&i.hasPreroll()&&function({content:t,ads:e,config:s,state:i,initial:r,adContainer:a,ima:n}){t.once(it,async function(o){(t.hasState(lt)||"touchend"!=o.type)&&e.shallPlayAd(0)&&(e.adapter.setAttemptingPrerollOnIOS(e.adapter.isCustomPlaybackEnabled()),e.adapter.isCustomPlaybackEnabled()||o.preventDefault(),Ut({ads:e,content:t,state:i}),Mt("user_gesture(:intercept) -> shallPlayAd(0: %s)",e.shallPlayAd(0)),s.muted=r.muted,await Dt({ads:e,content:t,state:i,adContainer:a,ima:n,config:s}),xt({ads:e,content:t}))})}({content:s,ads:i,config:t,state:c,initial:o,adContainer:l,ima:r}),!t.autoplay&&i.hasPreroll()&&c.preload&&Dt({ads:i,content:s,state:c,adContainer:l,ima:r,config:t}),Nt({config:t,root:e,content:s,ads:i,state:c,adContainer:l,ui:d,ima:r,initial:o});const u=async t=>{s.removeEventListener(it,u),i.resetScheduleCounter(),i.hasPreroll()&&(i.adapter.setAttemptingPrerollOnIOS(i.adapter.isCustomPlaybackEnabled()),t.preventDefault(),await i.setCurrentTime(0))};s.on("src",()=>{c.started&&(s.removeEventListener(it,u),s.addEventListener(it,u))}),s.on(it,t=>{(i.adBreak||i.adPlaying||i.adRequesting)&&(i.adBreak&&!i.adLinear||(Mt("prevented content from starting because ad break is active"),t.preventDefault()))})}async function Dt(t){t.state.started||(t.content.hasState(lt)?await It(t):t.content.once(st,async()=>{await It(t)}))}async function It({ads:t,content:e,adContainer:s,ima:i,state:r,config:a}){var n;r.started=!0;const o=function(t,e){var s={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(s[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(t);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(t,i[r])&&(s[i[r]]=t[i[r]])}return s}(i,["ads"]),d=h(e.root),l=(null==a?void 0:a.muted)||e.muted,c=Object.assign(Object.assign(Object.assign({container:s,volume:l?0:e.volume,muted:l,autoplay:(null==a?void 0:a.autoplay)||!1,video_source:e.original_src,preload_ads:null===(n=null==a?void 0:a.ima)||void 0===n?void 0:n.preload_ads},o),d));Mt("start():",c,r),await t.initialize(!1,c,r.preload)}function Ct(t,e){var s,i;return{content_width:t.clientWidth||(null===(s=t.parentNode)||void 0===s?void 0:s.clientWidth)||e.clientWidth,content_height:t.clientHeight||(null===(i=t.parentNode)||void 0===i?void 0:i.clientHeight)||e.clientHeight}}function Nt({config:t,root:e,content:s,ads:i,initial:r,adContainer:a,state:n,ui:o,ima:d}){Mt("addUIListeners()");const l=async()=>{if(i){if(!(i.adapter.isAttemptingPrerollOnIOS()||i.adapter.isCustomPlaybackEnabled()&&s.currentSrc!==s.original_src)){if(s.off(J,l),Mt("addUIListeners() -> content started playing"),Ut({ads:i,content:s,state:n}),!i.shallPlayAd(0)||!i.adapter.isLinearAd())return Mt("addUIListeners() -> no more preroll ads -> resume content"),s.emit(G,{root:e}),await Dt({ads:i,content:s,state:n,adContainer:a,ima:d,config:t});s.togglePlay(!1),await Dt({ads:i,content:s,state:n,adContainer:a,ima:d,config:t}),i.shallPlayAd(0)&&i.adapter.isLinearAd()&&(o.classList.add("on","linear"),e.classList.add(ot),xt({ads:i,content:s}))}}else s.off(J,l)};s.on(J,l),s.on(["portrait","landscape"],function(){if(!i)return;const{content_width:t,content_height:r}=Ct(s,e);i.resize({height:r,width:t})}),s.on(Y,t=>{if(!i||!t.detail)return;const{width:e,height:s}=t.detail.contentRect;i.resize({width:e,height:s})}),s.on(X,t=>{var r;const a=()=>{t.preventDefault(),Object.assign(t,{prevented:!0})};if(e.classList.contains("ad-linear")&&e.classList.contains("ads-custom-playback-enabled"))return a();i&&(Mt("ui_listeners(:%s, event: %o)",t.type,t.detail),(null===(r=null==t?void 0:t.detail)||void 0===r?void 0:r.from)!==i&&(a(),i.finished(function(){s.emit(X,{from:i})})))}),i.on(y,()=>{e.classList.toggle(ot,!0)}),i.once(w,()=>{s.on([it,"beforepause"],t=>{var e;if(!i.adBreak||!i.adapter.isLinearAd())return;t.preventDefault();const s=(null===(e=t.detail)||void 0===e?void 0:e.forced)?t.type===it:!i.adPlaying;s&&i.paused&&i.resume(),s||i.paused||i.pause()})}),i.on(w,t=>{const a=t.detail,{linear:n,ad:o,ad_type:d}=a;let l;if(Mt(`Ad[linear: ${n}, currentTime: ${s.currentTime}] starting`,o),"preroll"==d&&!n&&s.paused&&s.togglePlay(!0),n&&(l=Ct(s,e)),i.resize({width:l?l.content_width:o.width,height:l?l.content_height:o.height,linear:n,resize_non_linear:!0}),s.emit(W,{opts:{linear:n,resizeContainerAlso:!0,width:n?void 0:o.width,height:n?void 0:o.height}}),e.classList.remove(ot),s.setState("ad-linear",n),s.setState("ad-non-linear",!n),!n){Mt("non-linear ad / restarting content");try{s.togglePlay(!0),s.volume=r.volume,s.muted=r.muted}catch(t){Mt(t)}}s.hasState(lt)||s.hasState(vt)||!n||i.pause()}),i.on(b,()=>{s.emit(W,{opts:{linear:!0,width:0,height:0}})}),s.on(Pt,t=>async function({root:t,content:e,ads:s,eventName:i,err:r={reason:""}}){Mt("teardown(event: %s)",i),s.adapter.isAttemptingPrerollOnIOS()&&(s.adapter.setAttemptingPrerollOnIOS(!1),!e.paused&&e.hasState(at)&&e.hasState(rt)&&ft(e,e.opts.start_time));t.classList.add("is-seamless"),t.classList.remove(ot),["ad-non-linear","ad-linear"].forEach(t=>e.setState(t,!1)),r.reason&&Mt("teardown(:err, reason: %s) %o",r.reason);const a=s.getLastAd();if(e.emit(G,{root:t}),!s.shouldRestartContent())return Mt("Lifecycle.teardown(:skip_restart, reason: %s)","Ad prevented restarting content"),Ft(t);if(e.currentTime>0&&e.currentTime>=e.duration||"postroll"==s.ad_type||!1===(null==a?void 0:a.restart))return Mt("Lifecycle.teardown(:skip_restart, reason: %s)","was a postroll ad"),Ft(t);""===e.currentSrc&&e.setSrc(e.original_src);e.paused&&s.shouldRestartContent()&&(Mt("Lifecycle.teardown(:toggle_play, %s)","attempting to restart content"),await e.togglePlay(!0));if(!e.paused)return Mt("Lifecycle.teardown(:ok)","restarted video content"),Ft(t)}({root:e,content:s,ads:i,ui:o,err:t.detail,eventName:t.type}));let c=!!t.autoplay;var u;s.on(st,()=>{c&&!1!==d.autopause&&i.resume()}),s.on("viewleave",(u=()=>{!1!==d.autopause&&(c=!i.paused,i.pause())},t=>{setTimeout(function(){if(!t.defaultPrevented&&!t.prevented)return u(t)},0)}))}function Ut({ads:t,content:e,state:s}){s.listening||(e.on(["timeupdate",tt,J,et],s=>{t.adapter.isCustomPlaybackEnabled()&&(t.adPlaying||t.paused)||(t.adPlaying&&t.adapter.isLinearAd()&&!e.paused&&e.pause(),xt({ads:t,content:e,seek:s.type===et}))}),s.listening=!0)}function xt({ads:t,content:e,seek:s=!1}){t&&t.setCurrentTime(e.currentTime,void 0,s)}function Ft(t){t.classList.remove("is-seamless")}const Bt=yt("ads/timers");class TimerRegistry{constructor(t={},e={}){this.intervals=t,this.timers=e}}let jt=-1;function qt(t,e,s){const i=setInterval(s,e);if(Bt(`TimerRegistry.createInterval() -> ${i}`,t.intervals),"object"==typeof i){const e=++jt;return t.intervals[e]=e,e}return t.intervals[i]=i,i}function Ht(t){if(t)return Bt("TimerRegistry.empty()",Object.keys(t.timers),Object.keys(t.intervals)),Object.keys(t.intervals).forEach(e=>function(t,e){return Bt(`TimerRegistry.removeInterval() -> ${e}`,t.intervals),clearInterval(t.intervals[e]),delete t.intervals[e],t}(t,e)),Object.keys(t.timers).forEach(e=>function(t,e){return Bt(`TimerRegistry.removeTimeout() -> ${e}`,t.timers),clearTimeout(t.timers[e]),delete t.timers[e],t}(t,e)),t}function Vt(t){try{return t.getAdPodInfo().getPodIndex()}catch(t){return}}class AdLoadingController{adRequestStart(t){"number"==typeof t&&"number"!=typeof this.requestStart&&(this.requestStart=performance.now())}adRequestEnd(){this.requestStart=void 0}getRemainingAdLoadTime(t,e){return"number"!=typeof e||"number"!=typeof this.requestStart?t:Math.max(0,e-(performance.now()-this.requestStart))}}function zt(t){return function(t){return!document.fullscreenEnabled&&"function"==typeof t.webkitEnterFullScreen&&"function"==typeof t.webkitExitFullScreen}(t)&&!t.root.classList.contains("no-fullscreen")}function Gt(t){const e=null==t?void 0:t.ads;return!!(e&&Array.isArray(e)&&e.length>0)}class IMA{constructor(t){this.eventHandler=t,this.log=yt("ads/adapter/ima"),this.google=window.google,this._adHandlers=[],this._timers=new TimerRegistry,this._started=!1,this._volumeLevel=0,this._adLoaded=!1,this.customPlaybackEnabled=!1,this._paused=!1,this._all_ads_completed=!1,this._currentDuration=0,this._currentRemaining=0,this._currentDisplayTs=0,this._isInitialized=!1,this._adBreakTime=0,this._prepared=!1,this.opts={},this.loadingController=new AdLoadingController}async init(t){this.log("init",this.videoTag,t),this.opts=t,this._dimensions={width:t.width,height:t.height,linear:t.linear},this._prepared=!0,!this._isInitialized&&this.videoTag&&await this.initAdapter()}async initAdapter(){this.log("initAdapter",this.opts);try{await this.initialize(this.opts),this._isInitialized=!0}catch(t){this.log("initAdapter failed:",t),this._prepared=!1,this.eventHandler.trigger(F)}}isReady(){return!!this._isInitialized}setVideoTag(t){this.videoTag=t,this.customPlaybackEnabled=zt(t),t.root.classList.toggle("ads-custom-playback-enabled",this.customPlaybackEnabled)}setAdBreakTime(t){this._adBreakTime=t}getAdBreakTime(){return this._adBreakTime}isCustomPlaybackEnabled(){return this.customPlaybackEnabled}isAttemptingPrerollOnIOS(){var t;return!!(null===(t=null==this?void 0:this.videoTag)||void 0===t?void 0:t.root.classList.contains("preroll-ios"))}setAttemptingPrerollOnIOS(t){var e;null===(e=null==this?void 0:this.videoTag)||void 0===e||e.root.classList.toggle("preroll-ios",t)}isLinearAd(){return!!this._adLinear}getVideoTag(){return this.videoTag}getDimensions(){return this._dimensions||{}}getOpts(){return this.opts}isPaused(){return this._paused}destroy(){const t=this;Ht(this._timers),this._adHandlers&&this._adHandlers.forEach(t=>t()),t._adHandlers=void 0,this._adDisplayContainer&&this._adDisplayContainer.destroy(),t._adDisplayContainer=void 0,this._adsLoader&&this._adsLoader.destroy(),t._adsLoader=void 0,this._adsManager&&this._adsManager.destroy(),t._adsManager=void 0}stop(){this._adsManager&&this._adsManager.stop()}initialize(t){const e=this.isAdPod(),s=this._adLoaded||e;if(this.cleanup(),!this.videoTag)return console.warn("videoTag not set during initialization");this.opts=t,this._volumeLevel=t.volume;const i=this.google.ima.settings;if(t.NumRedirects=t.NumRedirects||t.redirects,i.setVpaidMode(t.VpaidMode||this.google.ima.ImaSdkSettings.VpaidMode.INSECURE),i.setDisableCustomPlaybackForIOS10Plus(!this.customPlaybackEnabled),"NumRedirects"in t&&i.setNumRedirects(t.NumRedirects),"AutoPlayAdBreaks"in t&&i.setAutoPlayAdBreaks(t.AutoPlayAdBreaks),"Locale"in t&&i.setLocale(t.Locale),"Ppid"in t&&i.setPpid(t.Ppid),!document.body.contains(t.container))throw new Error("AdDisplayContainer was not found in the document.body");this._adDisplayContainer=new this.google.ima.AdDisplayContainer(t.container,u().tizen||u().webOS?void 0:this.videoTag),this._adDisplayContainer.initialize(),this._adsLoader=new this.google.ima.AdsLoader(this._adDisplayContainer),this.log("ima.initialise(:wait -> ADS_MANAGER_LOADED)",Object.assign(Object.assign({},t),{volume:this.videoTag.volume,muted:this.videoTag.muted})),this._adsLoader.addEventListener(this.google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,e=>{if(!this.videoTag)return;this.log("ima.initialise(:done -> ADS_MANAGER_LOADED)\n%o",Object.assign(Object.assign({},t),{volume:this.videoTag.volume,muted:this.videoTag.muted}));const s=new this.google.ima.AdsRenderingSettings;this.log("ima.rendering(preload: %s)",!!t.preload_ads),s.useStyledNonLinearAds=!0,s.enablePreloading=!!t.preload_ads,s.loadVideoTimeout=t.media_timeout||-1,s.restoreCustomPlaybackStateOnAdBreakComplete=this.customPlaybackEnabled,this.customPlaybackEnabled&&(s.playAdsAfterTime=this.videoTag.currentTime),this.eventHandler.trigger(x,s);const i=this._adsManager=e.getAdsManager(this.videoTag,s);this.eventHandler.trigger(N,i),i.addEventListener(this.google.ima.AdEvent.Type.LOADED,()=>{this.log("debug(ima.adsManager): google.ima.AdEvent.Type.LOADED")}),i.addEventListener(this.google.ima.AdErrorEvent.Type.AD_ERROR,()=>{this.log("debug(ima.adsManager): google.ima.AdErrorEvent.Type.AD_ERROR")}),i.addEventListener(this.google.ima.AdEvent.Type.STARTED,()=>{this.log("debug(ima.adsManager): google.ima.AdEvent.Type.STARTED")}),i.addEventListener(this.google.ima.AdEvent.Type.AD_PROGRESS,t=>{var e,s;const i=null===(e=t.getAdData())||void 0===e?void 0:e.duration,r=null===(s=t.getAdData())||void 0===s?void 0:s.currentTime;isNaN(i)||isNaN(r)||(this._currentRemaining=i-r,this.eventHandler.trigger(L,{remaining:this._currentRemaining,duration:i}))}),i.addEventListener(this.google.ima.AdEvent.Type.STARTED,t=>{this._currentRemaining=-1,this.debugEvent(t);const e=t.getAd();e&&(this._currentDuration=e.getDuration(),this._currentDisplayTs=Date.now(),this.emitWithAd(w,e),e.isLinear()&&IMA.pollRemaining({ima:this,adsManager:i}))}),i.addEventListener(this.google.ima.AdEvent.Type.COMPLETE,t=>{this.debugEvent(t);const e=t.getAd();e&&this.emitWithAd(E,e),Ht(this._timers)}),i.addEventListener(this.google.ima.AdEvent.Type.SKIPPED,t=>{this.debugEvent(t);const e=t.getAd();e&&this.emitWithAd(O,e)}),i.addEventListener(this.google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED,t=>{if(this.isAdPod()&&this.videoTag){const t=Math.abs(this.videoTag.currentTime-this.videoTag.duration)<1?-1:this.videoTag.currentTime;this.setAdBreakTime(t)}this.debugEvent(t);const e=t.getAd();e&&this.emitWithAd(b,e)}),i.addEventListener(this.google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED,t=>{this.debugEvent(t),this._started=!1,this._currentDisplayTs=0,this.eventHandler.trigger(k,{force:!0})}),i.addEventListener(this.google.ima.AdEvent.Type.VOLUME_CHANGED,t=>{this.log("IMA::volume(type: %s, event: %o)",t);const e=i.getVolume();this._volumeLevel=e,this.eventHandler.trigger(M,e)});const r=t=>{this._paused=t,this.eventHandler.trigger(t?S:T)};i.addEventListener(this.google.ima.AdEvent.Type.PAUSED,()=>r(!0)),i.addEventListener(this.google.ima.AdEvent.Type.RESUMED,()=>r(!1)),i.addEventListener(this.google.ima.AdEvent.Type.STARTED,()=>r(!1)),i.addEventListener(this.google.ima.AdEvent.Type.VOLUME_MUTED,t=>{this.log("IMA::volume(type: %s, event: %o)","mute",t),this.eventHandler.trigger(R)});const{width:a,height:n}=t;a&&n&&(i.init(a,n,this.google.ima.ViewMode.NORMAL),this.log("ima.initialise: done initializing"))}),s&&(this.log("Event(reload: %s)",j),this.eventHandler.trigger(j,e)),this.eventHandler.trigger(g,this)}destroyManager(t="unknown"){if(!this._adsManager)return this.log("ima::destroyManager(:skip, label: %s)",t);this.log("ima::destroyManager(:ok, label: %s)",t),this._adsManager.destroy()}reset(){this.destroyManager("reset"),Ht(this._timers),this.clearAdHandlers(),this._started=!1,this._adLoaded=!1}cleanup(){this.destroyManager("cleanup"),this._adsLoader&&this._adsLoader.destroy(),this._adDisplayContainer&&this._adDisplayContainer.destroy(),this._adLoaded=!1}waitForAdsManager(){return new Promise(t=>{this.log("ima.waitForAdsManager:",this._adsManager),this.once(this._adsLoader,this.google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,()=>{this.log("ima.waitForAdsManager(:ok)",this._adsManager),t(this._adsManager)})})}async initAd(t,e=5e3){var s;this.log(`ima.initAd(adTag: ${t}, timeout: ${e})`),this.customPlaybackEnabled||this.loadingController.adRequestStart(this.opts.total_loading_timeout);try{if(await this.requestAd(t,this.loadingController.getRemainingAdLoadTime(e,this.opts.total_loading_timeout)),this._adLoaded=!0,this.customPlaybackEnabled)return;null===(s=this._adsManager)||void 0===s||s.updateAdsRenderingSettings({loadVideoTimeout:this.loadingController.getRemainingAdLoadTime(this.opts.media_timeout||-1,this.opts.total_loading_timeout)})}catch(t){throw this.log("ima.initAd:",t),this._adLoaded=!1,t}finally{Ht(this._timers)}}async requestAd(t,e){if(this.destroyManager("requestAd"),!this.videoTag)return;this.setAdBreakTime(this.videoTag.currentTime);const{autoplay:s=!1}=this.opts,i=Date.now(),r=this.videoTag.muted;this._volumeLevel=this.videoTag.volume;const a=r||0==this._volumeLevel;this._all_ads_completed=!1,this.log("ima.requestAd(%o)",Object.assign(Object.assign({},this.opts),{autoplay:s,muted:r,timeout:e,adTag:t,_volumeLevel:this._volumeLevel,manager:this._adsManager})),this.clearAdHandlers();const n=new this.google.ima.AdsRequest;n.adTagUrl=t;const{height:o,width:d}=this.opts;return d&&(n.linearAdSlotWidth=d),o&&(n.linearAdSlotHeight=o),!this.opts.disable_non_linear_ads&&d&&(n.nonLinearAdSlotWidth=d),!this.opts.disable_non_linear_ads&&o&&(n.nonLinearAdSlotHeight=o-50),n.setAdWillAutoPlay(s),n.setAdWillPlayMuted(a),n.vastLoadTimeout=e,this.eventHandler.trigger(U,{request:n}),this._adsLoader?new Promise(async(t,s)=>{var i;const r=this.waitForAdsManager();null===(i=this._adsLoader)||void 0===i||i.requestAds(n),this.once(this._adsLoader,this.google.ima.AdErrorEvent.Type.AD_ERROR,t=>{s(()=>(this.emitError(v,t),Promise.reject(new Error("Ad load failed"))))}),setTimeout(()=>{s(()=>{r.then(t=>{t.destroy(),this._adsManager===t&&(this._adsManager=void 0)});const t=new Error("Ad internal timeout reached");return this.eventHandler.trigger(P,t),Promise.reject(t)})},e),t(await r)}).then(t=>new Promise((e,s)=>{this.volume(a?0:this._volumeLevel),this.eventHandler.trigger(M,this._volumeLevel);const r=this.cuepoints();if(r&&r.length&&0!==r[0])return e({ad:!1,adsManager:t});this.once(t,this.google.ima.AdErrorEvent.Type.AD_ERROR,t=>{s(()=>(this.emitError(v,t),Promise.reject(t)))}),this.once(t,this.google.ima.AdEvent.Type.ALL_ADS_COMPLETED,()=>{this._all_ads_completed=!0,e(null)}),this.once(t,this.google.ima.AdEvent.Type.LOADED,t=>{this.eventHandler.trigger(A,{request_load_time:Date.now()-i});const s=t.getAd();s&&(this.log("ima.requestAd: AD_REQUEST_COMPLETED",s.getContentType()),"application/javascript"==s.getContentType()&&this.eventHandler.trigger(C,s),e(null))}),this.once(t,this.google.ima.AdEvent.Type.CLICK,()=>{this.log("ima.requestAd: click event"),this.pause()})}),t=>t()):void 0}async playAd(){if(this.log("ima.playAd()",this),!this._adsManager||!this._adLoaded)return;const t=this.currentAd();if(t&&(!this.customPlaybackEnabled||t.isLinear()))try{await this.startAndWaitForAdCompletion(this._adsManager,t.isLinear())}catch(t){throw this.log("ima.playAd",t),t}finally{this._adLoaded=!1,Ht(this._timers)}}startAndWaitForAdCompletion(t,e){if(!this._started)return this.log("ima.startAndWaitForAdCompletion(manager: %o)",{volume:t.getVolume()}),new Promise((s,i)=>{let r=!1;this.once(t,this.google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED,()=>{if(this.log("ima.startAndWaitForAdCompletion: CONTENT_RESUME_REQUESTED <<< happened"),this._started=!1,r)return this.log("ima.startAndWaitForAdCompletion: Content resume requested, but trying to recover from ad error");s()}),this.once(t,this.google.ima.AdErrorEvent.Type.AD_ERROR,async t=>{this.log("ima.startAndWaitForAdCompletion: beginning error recovery ->",t),r=!0;try{const{ok:e}=await IMA.pollForFatalError({err:t,ima:this});e&&(r=!1)}catch(e){this._started=!1,i(t)}});const a=this.getVideoTag();if(!a)return;const n=()=>{e&&(this._started=!0),t.start(),this.eventHandler.trigger(B)};if(!e||a.hasState(lt)||a.hasState(vt))return n();a.paused||a.pause(),a.once(st,()=>n())})}pause(){this.log("ima.pause()"),this._adsManager&&this._adsManager.pause()}resume(){this.log("ima.resume()"),this._adsManager&&this._adsManager.resume()}volume(t){if(this._adsManager)try{return arguments.length>0&&"number"==typeof t&&this._adsManager.setVolume(t),this._volumeLevel=this._adsManager.getVolume()}catch(t){this.log("ima.volume() failed (%o)",t)}}onResize({width:t,height:e,linear:s,silent:i,resize_non_linear:r}){this._adsManager&&(this._adLinear=void 0===s?this._adLinear:s,this.opts&&(t||e)&&(!1===s&&(t+=10,e+=10),this._dimensions={width:t,height:e,linear:s},s&&(this.opts.width=t,this.opts.height=e),(this._adLinear||r)&&(i||this.log("ima.onResize %s x %s",t,e),this._adsManager.resize(t,e,this.google.ima.ViewMode.NORMAL))))}onAdRequestEnd(){var t;this.customPlaybackEnabled||(this.loadingController.adRequestEnd(),null===(t=this._adsManager)||void 0===t||t.updateAdsRenderingSettings({loadVideoTimeout:this.opts.media_timeout||-1}))}getAdInfo(){const t=this.currentAd();if(t)return{duration:t.getDuration(),currentTime:this._currentRemaining}}currentAd(){const t=this._adsManager;if(t)return t.getCurrentAd()}isAdPod(){const t=this.cuepoints();return!!(t&&t.length>1)}cuepoints(){return this._adsManager&&this._adsManager.getCuePoints()}async contentComplete(){this.log("ima.contentComplete() -> ",this),this._adsLoader&&this._adsLoader.contentComplete();const t=this.cuepoints();t&&-1!==t.indexOf(-1)&&await new Promise(t=>{IMA.race(this.eventHandler,[k,q],t)})}isUiDisabled(){try{const t=this.currentAd();return t&&t.isUiDisabled()}catch(t){return null}}getAdPodInfo(){try{const t=this.currentAd();return t&&t.getAdPodInfo()}catch(t){return null}}canDismissNonLinear(){const t=this.currentAd();if(!t||t.isLinear()||!this._adsManager||!this._currentDisplayTs)return!0;const e=Date.now(),s=t.getMinSuggestedDuration();return e-this._currentDisplayTs>1e3*s}static unwrapError(t,e){if(!t)return"";if("function"==typeof t.getMessage){return t.getMessage()}return t.message?t.message:e||""}static pollForFatalError({err:t,ima:e}){let s;try{const e=t.getError(),i=e.getInnerError(),r=i?IMA.unwrapError(i,e.message):"";s={reason:r,type:e.getType(),code:e.getErrorCode()}}catch(t){}const i=e._currentRemaining;return new Promise((t,r)=>{const a=setTimeout(()=>{e.eventHandler&&e.eventHandler.trigger(m,s),r(new Error("Ad not progressing"))},2500);e.eventHandler.once(L,e=>{const s=e.detail.remaining;-1!==s&&s<i&&(clearTimeout(a),t({ok:1}))})})}static pollRemaining({ima:t,adsManager:e}){let s=-1;return qt(t._timers,250,function(){const i=e.getRemainingTime();-1!=t._currentRemaining&&t._currentRemaining<=i||(t._currentRemaining=e.getRemainingTime(),s!=t._currentRemaining&&(s=t._currentRemaining,t.eventHandler.trigger(L,{remaining:t._currentRemaining,duration:t._currentDuration})))})}once(t,e,s){this._adHandlers.push(function(t,e,s){const i=r=>{s(r),t.removeEventListener(e,i)};return t.addEventListener(e,i),()=>t.removeEventListener(e,i)}(t,e,s))}static race(t,e,s){e.forEach(i=>{const r=(...i)=>{e.forEach(e=>t.removeListener(e,r)),s(i)};t.on(i,r)})}clearAdHandlers(){this.log("ima.clearAdHandlers"),this._adHandlers.forEach(t=>t()),this._adHandlers=[]}emitWithAd(t,e){if(this.log("ima.emitWithAd",t,e),!this._adsManager)return;const s=function(t){try{return t.getAdPodInfo().getAdPosition()}catch(t){return}}(e),i=function(t){try{return t.getAdPodInfo().getTotalAds()}catch(t){return}}(e),r={ad:{duration:e.getDuration(),width:e.getWidth(),height:e.getHeight(),position:s,totals:i},volume:this._adsManager.getVolume(),vast_ad_id:e.getAdId(),linear:e.isLinear(),mime_type:e.getContentType(),ima_event:!0};this.log(`emitWithAd::event(name: ${t}, data: %o, ad: %o)`,r,e),this.eventHandler.trigger(t,r)}emitError(t,e){const s={vast_error_type:e.getError().getType(),reason:e.getError().getMessage(),vast_error:e.getError().getErrorCode()};this.log(`ima.error(${t})`,s),this.eventHandler.trigger(t,s)}debugEvent(t){try{const e=t.getAd();if(!e)return;this.log(`ima.event.${t.type} ->`,{event:t,data:t.getAdData(),position:Vt(e),ad:e})}catch(t){}}}var Wt=function(t){var e={exports:{}};return t(e,e.exports),e.exports}(function(t,e){var s=function(){for(var t=new Array(256),e=0;e<256;++e)t[e]="%"+((e<16?"0":"")+e.toString(16)).toUpperCase();return t}(),i=Object.prototype.hasOwnProperty;e.arrayToObject=function(t,e){for(var s=e.plainObjects?Object.create(null):{},i=0;i<t.length;++i)void 0!==t[i]&&(s[i]=t[i]);return s},e.merge=function(t,s,r){if(!s)return t;if("object"!=typeof s){if(Array.isArray(t))t.push(s);else{if("object"!=typeof t)return[t,s];(r.plainObjects||r.allowPrototypes||!i.call(Object.prototype,s))&&(t[s]=!0)}return t}if("object"!=typeof t)return[t].concat(s);var a=t;return Array.isArray(t)&&!Array.isArray(s)&&(a=e.arrayToObject(t,r)),Object.keys(s).reduce(function(t,a){var n=s[a];return i.call(t,a)?t[a]=e.merge(t[a],n,r):t[a]=n,t},a)},e.decode=function(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch(e){return t}},e.encode=function(t){if(0===t.length)return t;for(var e="string"==typeof t?t:String(t),i="",r=0;r<e.length;++r){var a=e.charCodeAt(r);45===a||46===a||95===a||126===a||a>=48&&a<=57||a>=65&&a<=90||a>=97&&a<=122?i+=e.charAt(r):a<128?i+=s[a]:a<2048?i+=s[192|a>>6]+s[128|63&a]:a<55296||a>=57344?i+=s[224|a>>12]+s[128|a>>6&63]+s[128|63&a]:(r+=1,a=65536+((1023&a)<<10|1023&e.charCodeAt(r)),i+=s[240|a>>18]+s[128|a>>12&63]+s[128|a>>6&63]+s[128|63&a])}return i},e.compact=function(t,s){if("object"!=typeof t||null===t)return t;var i=s||[],r=i.indexOf(t);if(-1!==r)return i[r];if(i.push(t),Array.isArray(t)){for(var a=[],n=0;n<t.length;++n)t[n]&&"object"==typeof t[n]?a.push(e.compact(t[n],i)):void 0!==t[n]&&a.push(t[n]);return a}for(var o=Object.keys(t),d=0;d<o.length;++d){var l=o[d];t[l]=e.compact(t[l],i)}return t},e.isRegExp=function(t){return"[object RegExp]"===Object.prototype.toString.call(t)},e.isBuffer=function(t){return null!=t&&!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))}}),Qt={brackets:function(t){return t+"[]"},indices:function(t,e){return t+"["+e+"]"},repeat:function(t){return t}},$t={delimiter:"&",strictNullHandling:!1,skipNulls:!1,encode:!0,encoder:Wt.encode},Kt=function t(e,s,i,r,a,n,o,d,l){var c=e;if("function"==typeof o)c=o(s,c);else if(c instanceof Date)c=c.toISOString();else if(null===c){if(r)return n?n(s):s;c=""}if("string"==typeof c||"number"==typeof c||"boolean"==typeof c||Wt.isBuffer(c))return n?[n(s)+"="+n(c)]:[s+"="+String(c)];var u,h=[];if(void 0===c)return h;if(Array.isArray(o))u=o;else{var p=Object.keys(c);u=d?p.sort(d):p}for(var g=0;g<u.length;++g){var m=u[g];a&&null===c[m]||(h=Array.isArray(c)?h.concat(t(c[m],i(s,m),i,r,a,n,o,d,l)):h.concat(t(c[m],s+(l?"."+m:"["+m+"]"),i,r,a,n,o,d,l)))}return h},Yt=Object.prototype.hasOwnProperty,Zt={delimiter:"&",depth:5,arrayLimit:20,parameterLimit:1e3,strictNullHandling:!1,plainObjects:!1,allowPrototypes:!1,allowDots:!1,decoder:Wt.decode},Jt=function t(e,s,i){if(!e.length)return s;var r,a=e.shift();if("[]"===a)r=(r=[]).concat(t(e,s,i));else{r=i.plainObjects?Object.create(null):{};var n="["===a.charAt(0)&&"]"===a.charAt(a.length-1)?a.slice(1,-1):a,o=parseInt(n,10);!isNaN(o)&&a!==n&&String(o)===n&&o>=0&&i.parseArrays&&o<=i.arrayLimit?(r=[])[o]=t(e,s,i):r[n]=t(e,s,i)}return r},Xt=function(t,e,s){if(t){var i=s.allowDots?t.replace(/\.([^.[]+)/g,"[$1]"):t,r=/(\[[^[\]]*])/g,a=/(\[[^[\]]*])/.exec(i),n=a?i.slice(0,a.index):i,o=[];if(n){if(!s.plainObjects&&Yt.call(Object.prototype,n)&&!s.allowPrototypes)return;o.push(n)}for(var d=0;null!==(a=r.exec(i))&&d<s.depth;){if(d+=1,!s.plainObjects&&Yt.call(Object.prototype,a[1].slice(1,-1))&&!s.allowPrototypes)return;o.push(a[1])}return a&&o.push("["+i.slice(a.index)+"]"),Jt(o,e,s)}},te=function(t,e){var s,i,r=t,a=e||{},n=void 0===a.delimiter?$t.delimiter:a.delimiter,o="boolean"==typeof a.strictNullHandling?a.strictNullHandling:$t.strictNullHandling,d="boolean"==typeof a.skipNulls?a.skipNulls:$t.skipNulls,l=("boolean"==typeof a.encode?a.encode:$t.encode)?"function"==typeof a.encoder?a.encoder:$t.encoder:null,c="function"==typeof a.sort?a.sort:null,u=void 0!==a.allowDots&&a.allowDots;if(null!==a.encoder&&void 0!==a.encoder&&"function"!=typeof a.encoder)throw new TypeError("Encoder has to be a function.");"function"==typeof a.filter?r=(i=a.filter)("",r):Array.isArray(a.filter)&&(s=i=a.filter);var h,p=[];if("object"!=typeof r||null===r)return"";h=a.arrayFormat in Qt?a.arrayFormat:"indices"in a?a.indices?"indices":"repeat":"indices";var g=Qt[h];s||(s=Object.keys(r)),c&&s.sort(c);for(var m=0;m<s.length;++m){var _=s[m];d&&null===r[_]||(p=p.concat(Kt(r[_],_,g,o,d,l,i,c,u)))}return p.join(n)},ee=function(t,e){var s=e||{};if(null!==s.decoder&&void 0!==s.decoder&&"function"!=typeof s.decoder)throw new TypeError("Decoder has to be a function.");if(s.delimiter="string"==typeof s.delimiter||Wt.isRegExp(s.delimiter)?s.delimiter:Zt.delimiter,s.depth="number"==typeof s.depth?s.depth:Zt.depth,s.arrayLimit="number"==typeof s.arrayLimit?s.arrayLimit:Zt.arrayLimit,s.parseArrays=!1!==s.parseArrays,s.decoder="function"==typeof s.decoder?s.decoder:Zt.decoder,s.allowDots="boolean"==typeof s.allowDots?s.allowDots:Zt.allowDots,s.plainObjects="boolean"==typeof s.plainObjects?s.plainObjects:Zt.plainObjects,s.allowPrototypes="boolean"==typeof s.allowPrototypes?s.allowPrototypes:Zt.allowPrototypes,s.parameterLimit="number"==typeof s.parameterLimit?s.parameterLimit:Zt.parameterLimit,s.strictNullHandling="boolean"==typeof s.strictNullHandling?s.strictNullHandling:Zt.strictNullHandling,""===t||null==t)return s.plainObjects?Object.create(null):{};for(var i="string"==typeof t?function(t,e){for(var s={},i=t.split(e.delimiter,e.parameterLimit===1/0?void 0:e.parameterLimit),r=0;r<i.length;++r){var a,n,o=i[r],d=-1===o.indexOf("]=")?o.indexOf("="):o.indexOf("]=")+1;-1===d?(a=e.decoder(o),n=e.strictNullHandling?null:""):(a=e.decoder(o.slice(0,d)),n=e.decoder(o.slice(d+1))),Yt.call(s,a)?s[a]=[].concat(s[a]).concat(n):s[a]=n}return s}(t,s):t,r=s.plainObjects?Object.create(null):{},a=Object.keys(i),n=0;n<a.length;++n){var o=a[n],d=Xt(o,i[o],s);r=Wt.merge(r,d,s)}return Wt.compact(r)};const se=yt("fpads:macros"),ie=/\[([\s\S]+?)\]/g;class Macros{static run(t){try{return t()}catch(t){return void console.error(t)}}static merge(...t){return t.reduce((t,e)=>Object.assign(t,e),{})}static cast(t){return void 0===t?"":"function"==typeof t?encodeURIComponent(Macros.run(t)||""):"string"==typeof t?encodeURIComponent(t):"number"==typeof t||"boolean"==typeof t?t.toString():""}static normalize(t){return t.trim()}static process_obj(t,e,s){return Object.keys(t).reduce((i,r)=>{const a=Macros.process_str(r,e,s,!0),n=t[r];return null===n?(i[a]=n,i):"object"==typeof n?(i[a]=Macros.process_obj(n,e,s),i):"string"==typeof n?(i[a]=Macros.process_str(n,e,s),i):(console.error(new Error(`${n} at ${r} not a handled Macro type`)),i)},{})}static process_str(t,e,s,i=!1){return t.replace(e.pattern,(t,e)=>{const r=Macros.normalize(e);if(!(r in s)||void 0===s[r])return t;const a=s[r],n=i?a:Macros.cast(a);return se("Macro.replace(raw: %s, macro: %s, value: %s)",i,e,n),n})}constructor(t={},e=ie){this.vars=t,this.pattern=e}fork(t={},e=this.pattern){const s=Macros.merge(this.vars,t);return new Macros(s,e)}compile(t,e={}){const s=Macros.merge(this.vars,e),[i,r]=t.split("?"),a=ee(r||"",{strictNullHandling:!0,decoder:t=>t}),n=te(Macros.process_obj(a,this,s),{encode:!1,strictNullHandling:!0});return Macros.process_str(i,this,s,!0)+"?"+n}}function re(t,e={width:0,height:0}){let s,i;try{const t=document.createElement("a");t.href=s=window.location!=window.parent.location?document.referrer:document.location.href,i=t.hostname}catch(t){console.error(t)}const{width:r,height:a}=e,{video_source:n}=t||{},o=function(){const t=window;return"object"==typeof t.__flowplayerAdParameters?t.__flowplayerAdParameters:{}}();return Object.assign({random:Date.now(),page_url:s,domain:i,player_width:r,player_height:a,video_url:n,videourl:n},o)}Macros.patterns={BRACKETS:ie,CURLY:/\{([\s\S]+?)\}/g,UNDERSCORE:/__([\s\S]+?)__/g};const ae=/^flowplayer:\/\/(.+)/;async function ne(t){if("string"==typeof t&&ae.test(t)){const e=ae.exec(t),s=e&&window[e[1]];if(s)return ne(s)}if("function"!=typeof t)return t;try{return await t()}catch(t){return""}}async function oe(t){if("function"==typeof t)return[await ne(t)];if("string"==typeof t)return[await ne(t)];if(Array.isArray(t)){const e=t;return await Promise.all(e.map(ne))}if("object"==typeof t&&t&&t.adTag)return await oe(t.adTag);throw new Error(`\n unhandled ads type ${typeof t}:\n ${JSON.stringify(t)}\n can be:\n | Array<string>\n | string\n | function\n | {adTag: Array<string>|string|function}\n `)}class Schedule{constructor(t,e={}){this._ads=t,this._opts=e,this._nextIndex=0,this._postroll=void 0,this._loadPending=!1,this._postrollActive=!1,this.reset(this._ads)}toJSON(){const t=(this._ads||[]).slice(this._nextIndex);return this._postroll&&t.push(this._postroll),t}reset(t){this.setAds(t),this._nextIndex=0,this._postrollActive=!1}resetCounter(){this._nextIndex=0,this._postrollActive=!1}setAds(t){this._ads=t||[],this.sort()}getAds(){return this._ads}getNextAd(t){return this._ads[this._nextIndex]||t}getCurrentAd(){return this._postrollActive?this._postroll:this._loadPending?0:this._ads[this._nextIndex-1]}getPostroll(){return this._postroll}isDrained(){return this._nextIndex+1>this._ads.length}setPostrollActive(){this._postrollActive=!0}updateContentDuration(t){this._opts.content_duration=t}increment(){++this._nextIndex}decrement(){this._nextIndex>0&&--this._nextIndex}getNextIndex(){return this._nextIndex}getCurrentType(){const t=this.getCurrentAd();if(t)return Schedule.kindOf(t.time)}sort(){this._postroll=this._ads.find(t=>-1===t.time),this._ads=this._ads.filter(t=>t!==this._postroll).sort((t,e)=>t.time===e.time?this._ads.indexOf(t)-this._ads.indexOf(e):t.time-e.time)}shallPlayAd(t){if(this._loadPending)return!1;const e=this.getCurrentAd()||this.getNextAd();return!!(e&&e.time<=t&&-1!==e.time)}shallPlayNext(){const t=this.getNextAd(),e=this.getCurrentAd();return!(!t||!e||t.time!==e.time)}waitForLoad(t,e,s){if(this._loadPending=!1,!e)return!1;const i=s?this._opts.preload_advance:0;return e.time>=0?this._loadPending=t<e.time-i:-1===e.time&&(this._loadPending=this._opts.content_duration>0&&-1!==t?t<this._opts.content_duration-i:-1!==t),this._loadPending}static hasPreroll(t){return!!t.find(t=>0===t.time)}static isOutstream(t){return Schedule.hasPreroll(t)&&!!t[0].outstream}static kindOf(t){switch(t){case 0:return"preroll";case-1:return"postroll";default:return"midroll"}}}const de=Object.prototype,le=Object.getPrototypeOf;const ce=yt("fpads:ads:state");var ue;!function(t){t[t.IDLE=0]="IDLE",t[t.INITIALIZING=1]="INITIALIZING",t[t.FETCHING_AD=2]="FETCHING_AD",t[t.AD_AVAILABLE=4]="AD_AVAILABLE",t[t.BREAK_ACTIVE=8]="BREAK_ACTIVE",t[t.PLAYING=16]="PLAYING",t[t.FATAL_ERROR=32]="FATAL_ERROR"}(ue||(ue={}));class AdsState{static of(){return new AdsState}constructor(t=0){this._state=t}reset(){this._state=0}toggleState(t,e){return void 0===t&&ce(new Error("AdState cannot toggleState for `undefined`")),void 0===e?this._state^=t:e?void(this._state|=t):this._state&=~t}hasAll(t){return this._state==(this._state|t)}hasAny(t){return!!(this._state&t)}get state(){return this._state}}const he={ok:yt("fpads:analytics:request-queue"),err:yt("fpads:analytics:request-queue:err"),warn:yt("fpads:analytics:request-queue:warn")};class RequestQueue{static of(){return new RequestQueue}static is_empty(t){return 0==t.pending.length}static is_high_water(t){return t.open.length==RequestQueue.MAX_OPEN_REQUESTS}static maybe_spawn_req(t){if(RequestQueue.is_empty(t))return he.ok("maybe_spawn_req called Queue that is EMPTY"),t;if(RequestQueue.is_high_water(t))return he.warn("maybe_spawn_req called on Queue that is HIGH_WATER"),t;try{const e=RequestQueue.lpop(t);e&&RequestQueue.request(t,e)}catch(t){he.err(t)}}static increment_failures(t){return t.stats.failures++,t.stats.failures>RequestQueue.MAX_FAILURE_COUNT&&(t.stats.ttl=Date.now()+RequestQueue.REQUEST_TTL_MS),t}static handle_error(t,e){RequestQueue.rm(t,e),RequestQueue.increment_failures(t)}static request(t,[e,s,i]){if(he.ok(`Request[${i.event_type}] request`,i,t.stats),Date.now()<t.stats.ttl)return he.warn(`Request[${i.event_type}] skipping because too many errors too quickly`,t.stats);const r=new XMLHttpRequest;t.open.push(r),r.timeout=RequestQueue.REQUEST_TIMEOUT_MS,r.ontimeout=function(){RequestQueue.handle_error(t,r),he.warn(`Request[${i.event_type}] timed out in ${r.timeout}ms`,t.stats)},r.onerror=function(e){RequestQueue.handle_error(t,r),e&&he.err(e),he.warn(`Request[${i.event_type}] encountered an Error`,r.responseText,t.stats)},r.onreadystatechange=function(){r.readyState==XMLHttpRequest.DONE&&RequestQueue.rm(t,r),Math.floor(r.status/100)},r.onload=function(){RequestQueue.rm(t,r),t.stats.failures&&t.stats.failures--,he.ok(`Request[${i.event_type}] :ok`,r.status)},r.open(s,e),r.setRequestHeader("Content-Type","text/plain;charset=UTF-8");try{r.send(JSON.stringify(i))}catch(t){he.err(t)}}static rpush(t,...e){return e.forEach(e=>{if(RequestQueue.is_high_water(t))return he.warn("Too many open requests, skipping",t.stats);t.pending.push(e),RequestQueue.maybe_spawn_req(t)}),t}static lpop(t){return t.pending.shift()}static rm(t,e){const s=t.open.lastIndexOf(e);return~s&&t.open.splice(s,1),t}constructor(t=[],e=[],s={failures:0,ttl:0}){this.pending=t,this.open=e,this.stats=s}}RequestQueue.MAX_OPEN_REQUESTS=3,RequestQueue.REQUEST_TIMEOUT_MS=4e3,RequestQueue.REQUEST_TTL_MS=5e3,RequestQueue.MAX_FAILURE_COUNT=3;const pe={"Amazon Silk":"amazon_silk","Android Browser":"android",Bada:"bada",BlackBerry:"blackberry",Chrome:"chrome",Chromium:"chromium",Electron:"electron",Epiphany:"epiphany",Firefox:"firefox",Focus:"focus",Generic:"generic","Google Search":"google_search",Googlebot:"googlebot","Internet Explorer":"ie","K-Meleon":"k_meleon",Maxthon:"maxthon","Microsoft Edge":"edge","MZ Browser":"mz","NAVER Whale Browser":"naver",Opera:"opera","Opera Coast":"opera_coast",PhantomJS:"phantomjs",Puffin:"puffin",QupZilla:"qupzilla",QQ:"qq",QQLite:"qqlite",Safari:"safari",Sailfish:"sailfish","Samsung Internet for Android":"samsung_internet",SeaMonkey:"seamonkey",Sleipnir:"sleipnir",Swing:"swing",Tizen:"tizen","UC Browser":"uc",Vivaldi:"vivaldi","WebOS Browser":"webos",WeChat:"wechat","Yandex Browser":"yandex",Roku:"roku"},ge={amazon_silk:"Amazon Silk",android:"Android Browser",bada:"Bada",blackberry:"BlackBerry",chrome:"Chrome",chromium:"Chromium",electron:"Electron",epiphany:"Epiphany",firefox:"Firefox",focus:"Focus",generic:"Generic",googlebot:"Googlebot",google_search:"Google Search",ie:"Internet Explorer",k_meleon:"K-Meleon",maxthon:"Maxthon",edge:"Microsoft Edge",mz:"MZ Browser",naver:"NAVER Whale Browser",opera:"Opera",opera_coast:"Opera Coast",phantomjs:"PhantomJS",puffin:"Puffin",qupzilla:"QupZilla",qq:"QQ Browser",qqlite:"QQ Browser Lite",safari:"Safari",sailfish:"Sailfish",samsung_internet:"Samsung Internet for Android",seamonkey:"SeaMonkey",sleipnir:"Sleipnir",swing:"Swing",tizen:"Tizen",uc:"UC Browser",vivaldi:"Vivaldi",webos:"WebOS Browser",wechat:"WeChat",yandex:"Yandex Browser"},me={tablet:"tablet",mobile:"mobile",desktop:"desktop",tv:"tv"},_e={WindowsPhone:"Windows Phone",Windows:"Windows",MacOS:"macOS",iOS:"iOS",Android:"Android",WebOS:"WebOS",BlackBerry:"BlackBerry",Bada:"Bada",Tizen:"Tizen",Linux:"Linux",ChromeOS:"Chrome OS",PlayStation4:"PlayStation 4",Roku:"Roku"},fe={EdgeHTML:"EdgeHTML",Blink:"Blink",Trident:"Trident",Presto:"Presto",Gecko:"Gecko",WebKit:"WebKit"};class Utils{static getFirstMatch(t,e){const s=e.match(t);return s&&s.length>0&&s[1]||""}static getSecondMatch(t,e){const s=e.match(t);return s&&s.length>1&&s[2]||""}static matchAndReturnConst(t,e,s){if(t.test(e))return s}static getWindowsVersionName(t){switch(t){case"NT":return"NT";case"XP":case"NT 5.1":return"XP";case"NT 5.0":return"2000";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}}static getMacOSVersionName(t){const e=t.split(".").splice(0,2).map(t=>parseInt(t,10)||0);if(e.push(0),10===e[0])switch(e[1]){case 5:return"Leopard";case 6:return"Snow Leopard";case 7:return"Lion";case 8:return"Mountain Lion";case 9:return"Mavericks";case 10:return"Yosemite";case 11:return"El Capitan";case 12:return"Sierra";case 13:return"High Sierra";case 14:return"Mojave";case 15:return"Catalina";default:return}}static getAndroidVersionName(t){const e=t.split(".").splice(0,2).map(t=>parseInt(t,10)||0);if(e.push(0),!(1===e[0]&&e[1]<5))return 1===e[0]&&e[1]<6?"Cupcake":1===e[0]&&e[1]>=6?"Donut":2===e[0]&&e[1]<2?"Eclair":2===e[0]&&2===e[1]?"Froyo":2===e[0]&&e[1]>2?"Gingerbread":3===e[0]?"Honeycomb":4===e[0]&&e[1]<1?"Ice Cream Sandwich":4===e[0]&&e[1]<4?"Jelly Bean":4===e[0]&&e[1]>=4?"KitKat":5===e[0]?"Lollipop":6===e[0]?"Marshmallow":7===e[0]?"Nougat":8===e[0]?"Oreo":9===e[0]?"Pie":void 0}static getVersionPrecision(t){return t.split(".").length}static compareVersions(t,e,s=!1){const i=Utils.getVersionPrecision(t),r=Utils.getVersionPrecision(e);let a=Math.max(i,r),n=0;const o=Utils.map([t,e],t=>{const e=a-Utils.getVersionPrecision(t),s=t+new Array(e+1).join(".0");return Utils.map(s.split("."),t=>new Array(20-t.length).join("0")+t).reverse()});for(s&&(n=a-Math.min(i,r)),a-=1;a>=n;){if(o[0][a]>o[1][a])return 1;if(o[0][a]===o[1][a]){if(a===n)return 0;a-=1}else if(o[0][a]<o[1][a])return-1}}static map(t,e){const s=[];let i;if(Array.prototype.map)return Array.prototype.map.call(t,e);for(i=0;i<t.length;i+=1)s.push(e(t[i]));return s}static find(t,e){let s,i;if(Array.prototype.find)return Array.prototype.find.call(t,e);for(s=0,i=t.length;s<i;s+=1){const i=t[s];if(e(i,s))return i}}static assign(t,...e){const s=t;let i,r;if(Object.assign)return Object.assign(t,...e);for(i=0,r=e.length;i<r;i+=1){const t=e[i];if("object"==typeof t&&null!==t){Object.keys(t).forEach(e=>{s[e]=t[e]})}}return t}static getBrowserAlias(t){return pe[t]}static getBrowserTypeByAlias(t){return ge[t]||""}}const ve=/version\/(\d+(\.?_?\d+)+)/i,ye=[{test:[/googlebot/i],describe(t){const e={name:"Googlebot"},s=Utils.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,t)||Utils.getFirstMatch(ve,t);return s&&(e.version=s),e}},{test:[/opera/i],describe(t){const e={name:"Opera"},s=Utils.getFirstMatch(ve,t)||Utils.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/opr\/|opios/i],describe(t){const e={name:"Opera"},s=Utils.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i,t)||Utils.getFirstMatch(ve,t);return s&&(e.version=s),e}},{test:[/SamsungBrowser/i],describe(t){const e={name:"Samsung Internet for Android"},s=Utils.getFirstMatch(ve,t)||Utils.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/Whale/i],describe(t){const e={name:"NAVER Whale Browser"},s=Utils.getFirstMatch(ve,t)||Utils.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/MZBrowser/i],describe(t){const e={name:"MZ Browser"},s=Utils.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,t)||Utils.getFirstMatch(ve,t);return s&&(e.version=s),e}},{test:[/focus/i],describe(t){const e={name:"Focus"},s=Utils.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,t)||Utils.getFirstMatch(ve,t);return s&&(e.version=s),e}},{test:[/swing/i],describe(t){const e={name:"Swing"},s=Utils.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,t)||Utils.getFirstMatch(ve,t);return s&&(e.version=s),e}},{test:[/coast/i],describe(t){const e={name:"Opera Coast"},s=Utils.getFirstMatch(ve,t)||Utils.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/opt\/\d+(?:.?_?\d+)+/i],describe(t){const e={name:"Opera Touch"},s=Utils.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i,t)||Utils.getFirstMatch(ve,t);return s&&(e.version=s),e}},{test:[/yabrowser/i],describe(t){const e={name:"Yandex Browser"},s=Utils.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,t)||Utils.getFirstMatch(ve,t);return s&&(e.version=s),e}},{test:[/ucbrowser/i],describe(t){const e={name:"UC Browser"},s=Utils.getFirstMatch(ve,t)||Utils.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/Maxthon|mxios/i],describe(t){const e={name:"Maxthon"},s=Utils.getFirstMatch(ve,t)||Utils.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/epiphany/i],describe(t){const e={name:"Epiphany"},s=Utils.getFirstMatch(ve,t)||Utils.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/puffin/i],describe(t){const e={name:"Puffin"},s=Utils.getFirstMatch(ve,t)||Utils.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/sleipnir/i],describe(t){const e={name:"Sleipnir"},s=Utils.getFirstMatch(ve,t)||Utils.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/k-meleon/i],describe(t){const e={name:"K-Meleon"},s=Utils.getFirstMatch(ve,t)||Utils.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/micromessenger/i],describe(t){const e={name:"WeChat"},s=Utils.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,t)||Utils.getFirstMatch(ve,t);return s&&(e.version=s),e}},{test:[/qqbrowser/i],describe(t){const e={name:/qqbrowserlite/i.test(t)?"QQ Browser Lite":"QQ Browser"},s=Utils.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i,t)||Utils.getFirstMatch(ve,t);return s&&(e.version=s),e}},{test:[/msie|trident/i],describe(t){const e={name:"Internet Explorer"},s=Utils.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/\sedg\//i],describe(t){const e={name:"Microsoft Edge"},s=Utils.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/edg([ea]|ios)/i],describe(t){const e={name:"Microsoft Edge"},s=Utils.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/vivaldi/i],describe(t){const e={name:"Vivaldi"},s=Utils.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/seamonkey/i],describe(t){const e={name:"SeaMonkey"},s=Utils.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/sailfish/i],describe(t){const e={name:"Sailfish"},s=Utils.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,t);return s&&(e.version=s),e}},{test:[/silk/i],describe(t){const e={name:"Amazon Silk"},s=Utils.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/phantom/i],describe(t){const e={name:"PhantomJS"},s=Utils.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/slimerjs/i],describe(t){const e={name:"SlimerJS"},s=Utils.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe(t){const e={name:"BlackBerry"},s=Utils.getFirstMatch(ve,t)||Utils.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/(web|hpw)[o0]s/i],describe(t){const e={name:"WebOS Browser"},s=Utils.getFirstMatch(ve,t)||Utils.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/bada/i],describe(t){const e={name:"Bada"},s=Utils.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/tizen/i],describe(t){const e={name:"Tizen"},s=Utils.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,t)||Utils.getFirstMatch(ve,t);return s&&(e.version=s),e}},{test:[/qupzilla/i],describe(t){const e={name:"QupZilla"},s=Utils.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,t)||Utils.getFirstMatch(ve,t);return s&&(e.version=s),e}},{test:[/firefox|iceweasel|fxios/i],describe(t){const e={name:"Firefox"},s=Utils.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/electron/i],describe(t){const e={name:"Electron"},s=Utils.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/MiuiBrowser/i],describe(t){const e={name:"Miui"},s=Utils.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/chromium/i],describe(t){const e={name:"Chromium"},s=Utils.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,t)||Utils.getFirstMatch(ve,t);return s&&(e.version=s),e}},{test:[/chrome|crios|crmo/i],describe(t){const e={name:"Chrome"},s=Utils.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/GSA/i],describe(t){const e={name:"Google Search"},s=Utils.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test(t){const e=!t.test(/like android/i),s=t.test(/android/i);return e&&s},describe(t){const e={name:"Android Browser"},s=Utils.getFirstMatch(ve,t);return s&&(e.version=s),e}},{test:[/playstation 4/i],describe(t){const e={name:"PlayStation 4"},s=Utils.getFirstMatch(ve,t);return s&&(e.version=s),e}},{test:[/safari|applewebkit/i],describe(t){const e={name:"Safari"},s=Utils.getFirstMatch(ve,t);return s&&(e.version=s),e}},{test:[/.*/i],describe(t){const e=-1!==t.search("\\(")?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return{name:Utils.getFirstMatch(e,t),version:Utils.getSecondMatch(e,t)}}}];var Ae=[{test:[/Roku\/DVP/],describe(t){const e=Utils.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,t);return{name:_e.Roku,version:e}}},{test:[/windows phone/i],describe(t){const e=Utils.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,t);return{name:_e.WindowsPhone,version:e}}},{test:[/windows /i],describe(t){const e=Utils.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,t),s=Utils.getWindowsVersionName(e);return{name:_e.Windows,version:e,versionName:s}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe(t){const e={name:_e.iOS},s=Utils.getSecondMatch(/(Version\/)(\d[\d.]+)/,t);return s&&(e.version=s),e}},{test:[/macintosh/i],describe(t){const e=Utils.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,t).replace(/[_\s]/g,"."),s=Utils.getMacOSVersionName(e),i={name:_e.MacOS,version:e};return s&&(i.versionName=s),i}},{test:[/(ipod|iphone|ipad)/i],describe(t){const e=Utils.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,t).replace(/[_\s]/g,".");return{name:_e.iOS,version:e}}},{test(t){const e=!t.test(/like android/i),s=t.test(/android/i);return e&&s},describe(t){const e=Utils.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i,t),s=Utils.getAndroidVersionName(e),i={name:_e.Android,version:e};return s&&(i.versionName=s),i}},{test:[/(web|hpw)[o0]s/i],describe(t){const e=Utils.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,t),s={name:_e.WebOS};return e&&e.length&&(s.version=e),s}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe(t){const e=Utils.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,t)||Utils.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,t)||Utils.getFirstMatch(/\bbb(\d+)/i,t);return{name:_e.BlackBerry,version:e}}},{test:[/bada/i],describe(t){const e=Utils.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,t);return{name:_e.Bada,version:e}}},{test:[/tizen/i],describe(t){const e=Utils.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,t);return{name:_e.Tizen,version:e}}},{test:[/linux/i],describe:()=>({name:_e.Linux})},{test:[/CrOS/],describe:()=>({name:_e.ChromeOS})},{test:[/PlayStation 4/],describe(t){const e=Utils.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,t);return{name:_e.PlayStation4,version:e}}}],be=[{test:[/googlebot/i],describe:()=>({type:"bot",vendor:"Google"})},{test:[/huawei/i],describe(t){const e=Utils.getFirstMatch(/(can-l01)/i,t)&&"Nova",s={type:me.mobile,vendor:"Huawei"};return e&&(s.model=e),s}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:()=>({type:me.tablet,vendor:"Nexus"})},{test:[/ipad/i],describe:()=>({type:me.tablet,vendor:"Apple",model:"iPad"})},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:()=>({type:me.tablet,vendor:"Apple",model:"iPad"})},{test:[/kftt build/i],describe:()=>({type:me.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"})},{test:[/silk/i],describe:()=>({type:me.tablet,vendor:"Amazon"})},{test:[/tablet(?! pc)/i],describe:()=>({type:me.tablet})},{test(t){const e=t.test(/ipod|iphone/i),s=t.test(/like (ipod|iphone)/i);return e&&!s},describe(t){const e=Utils.getFirstMatch(/(ipod|iphone)/i,t);return{type:me.mobile,vendor:"Apple",model:e}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:()=>({type:me.mobile,vendor:"Nexus"})},{test:[/[^-]mobi/i],describe:()=>({type:me.mobile})},{test:t=>"blackberry"===t.getBrowserName(!0),describe:()=>({type:me.mobile,vendor:"BlackBerry"})},{test:t=>"bada"===t.getBrowserName(!0),describe:()=>({type:me.mobile})},{test:t=>"windows phone"===t.getBrowserName(),describe:()=>({type:me.mobile,vendor:"Microsoft"})},{test(t){const e=Number(String(t.getOSVersion()).split(".")[0]);return"android"===t.getOSName(!0)&&e>=3},describe:()=>({type:me.tablet})},{test:t=>"android"===t.getOSName(!0),describe:()=>({type:me.mobile})},{test:t=>"macos"===t.getOSName(!0),describe:()=>({type:me.desktop,vendor:"Apple"})},{test:t=>"windows"===t.getOSName(!0),describe:()=>({type:me.desktop})},{test:t=>"linux"===t.getOSName(!0),describe:()=>({type:me.desktop})},{test:t=>"playstation 4"===t.getOSName(!0),describe:()=>({type:me.tv})},{test:t=>"roku"===t.getOSName(!0),describe:()=>({type:me.tv})}],we=[{test:t=>"microsoft edge"===t.getBrowserName(!0),describe(t){if(/\sedg\//i.test(t))return{name:fe.Blink};const e=Utils.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,t);return{name:fe.EdgeHTML,version:e}}},{test:[/trident/i],describe(t){const e={name:fe.Trident},s=Utils.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:t=>t.test(/presto/i),describe(t){const e={name:fe.Presto},s=Utils.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test(t){const e=t.test(/gecko/i),s=t.test(/like gecko/i);return e&&!s},describe(t){const e={name:fe.Gecko},s=Utils.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}},{test:[/(apple)?webkit\/537\.36/i],describe:()=>({name:fe.Blink})},{test:[/(apple)?webkit/i],describe(t){const e={name:fe.WebKit},s=Utils.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,t);return s&&(e.version=s),e}}];class Parser{constructor(t,e=!1){if(null==t||""===t)throw new Error("UserAgent parameter can't be empty");this._ua=t,this.parsedResult={},!0!==e&&this.parse()}getUA(){return this._ua}test(t){return t.test(this._ua)}parseBrowser(){this.parsedResult.browser={};const t=Utils.find(ye,t=>{if("function"==typeof t.test)return t.test(this);if(t.test instanceof Array)return t.test.some(t=>this.test(t));throw new Error("Browser's test function is not valid")});return t&&(this.parsedResult.browser=t.describe(this.getUA())),this.parsedResult.browser}getBrowser(){return this.parsedResult.browser?this.parsedResult.browser:this.parseBrowser()}getBrowserName(t){return t?String(this.getBrowser().name).toLowerCase()||"":this.getBrowser().name||""}getBrowserVersion(){return this.getBrowser().version}getOS(){return this.parsedResult.os?this.parsedResult.os:this.parseOS()}parseOS(){this.parsedResult.os={};const t=Utils.find(Ae,t=>{if("function"==typeof t.test)return t.test(this);if(t.test instanceof Array)return t.test.some(t=>this.test(t));throw new Error("Browser's test function is not valid")});return t&&(this.parsedResult.os=t.describe(this.getUA())),this.parsedResult.os}getOSName(t){const{name:e}=this.getOS();return t?String(e).toLowerCase()||"":e||""}getOSVersion(){return this.getOS().version}getPlatform(){return this.parsedResult.platform?this.parsedResult.platform:this.parsePlatform()}getPlatformType(t=!1){const{type:e}=this.getPlatform();return t?String(e).toLowerCase()||"":e||""}parsePlatform(){this.parsedResult.platform={};const t=Utils.find(be,t=>{if("function"==typeof t.test)return t.test(this);if(t.test instanceof Array)return t.test.some(t=>this.test(t));throw new Error("Browser's test function is not valid")});return t&&(this.parsedResult.platform=t.describe(this.getUA())),this.parsedResult.platform}getEngine(){return this.parsedResult.engine?this.parsedResult.engine:this.parseEngine()}getEngineName(t){return t?String(this.getEngine().name).toLowerCase()||"":this.getEngine().name||""}parseEngine(){this.parsedResult.engine={};const t=Utils.find(we,t=>{if("function"==typeof t.test)return t.test(this);if(t.test instanceof Array)return t.test.some(t=>this.test(t));throw new Error("Browser's test function is not valid")});return t&&(this.parsedResult.engine=t.describe(this.getUA())),this.parsedResult.engine}parse(){return this.parseBrowser(),this.parseOS(),this.parsePlatform(),this.parseEngine(),this}getResult(){return Utils.assign({},this.parsedResult)}satisfies(t){const e={};let s=0;const i={};let r=0;if(Object.keys(t).forEach(a=>{const n=t[a];"string"==typeof n?(i[a]=n,r+=1):"object"==typeof n&&(e[a]=n,s+=1)}),s>0){const t=Object.keys(e),s=Utils.find(t,t=>this.isOS(t));if(s){const t=this.satisfies(e[s]);if(void 0!==t)return t}const i=Utils.find(t,t=>this.isPlatform(t));if(i){const t=this.satisfies(e[i]);if(void 0!==t)return t}}if(r>0){const t=Object.keys(i),e=Utils.find(t,t=>this.isBrowser(t,!0));if(void 0!==e)return this.compareVersion(i[e])}}isBrowser(t,e=!1){const s=this.getBrowserName().toLowerCase();let i=t.toLowerCase();const r=Utils.getBrowserTypeByAlias(i);return e&&r&&(i=r.toLowerCase()),i===s}compareVersion(t){let e=[0],s=t,i=!1;const r=this.getBrowserVersion();if("string"==typeof r)return">"===t[0]||"<"===t[0]?(s=t.substr(1),"="===t[1]?(i=!0,s=t.substr(2)):e=[],">"===t[0]?e.push(1):e.push(-1)):"="===t[0]?s=t.substr(1):"~"===t[0]&&(i=!0,s=t.substr(1)),e.indexOf(Utils.compareVersions(r,s,i))>-1}isOS(t){return this.getOSName(!0)===String(t).toLowerCase()}isPlatform(t){return this.getPlatformType(!0)===String(t).toLowerCase()}isEngine(t){return this.getEngineName(!0)===String(t).toLowerCase()}is(t,e=!1){return this.isBrowser(t,e)||this.isOS(t)||this.isPlatform(t)}some(t=[]){return t.some(t=>this.is(t))}}
2
2
  /*!
3
3
  * Bowser - a browser detector
4
4
  * https://github.com/lancedikson/bowser
5
5
  * MIT License | (c) Dustin Diaz 2012-2015
6
6
  * MIT License | (c) Denis Demchenko 2015-2019
7
- */const Ee=class Bowser{static getParser(t,e=!1){if("string"!=typeof t)throw new Error("UserAgent should be a string");return new Parser(t,e)}static parse(t){return new Parser(t).getResult()}static get BROWSER_MAP(){return ge}static get ENGINE_MAP(){return fe}static get OS_MAP(){return _e}static get PLATFORMS_MAP(){return me}}.parse(window.navigator.userAgent),{platform:Se,os:Te,browser:Le}=Ee,Oe=t=>t&&t.toLowerCase();var Re={rnd:Math.random().toString(36).substr(2,32),os:Oe(Te.name+(Te.versionName?` ${Te.versionName}`:"")),device:Oe(Se.type),browser:Oe(Le.name),browser_version:(Le&&Le.version?Le.version:"unknown").split(".").shift(),plugin_version:"3.34.1"};const Me="https://fp-eu-w1-aai.flowplayer.com/in",Pe="POST",ke=[y,v,A,E,w,q,O],De=["event_type","ad_tag_id","media_id","player_id","site_id","sitegroup_id","rnd","os","device","browser","browser_version","plugin_version","player_version"],Ie=["vast_error","reason","request_load_time","ad_type","vast_ad_id"],Ce=yt("ads/analytics"),Ne=RequestQueue.of(),Ue=(...t)=>Object.assign({},...t);class Analytics{static of(t,e){return new Analytics(t,e)}static ensure_required_keys(t,e){return t.required_keys.filter(t=>!(t in e))}static pluck_valid_keys(t,e){return((t,...e)=>Object.keys(t).filter(t=>~e.indexOf(t)).reduce((e,s)=>Object.assign(e,{[s]:t[s]}),{}))(e,...t.valid_keys)}static mergeMetadata(t,e={}){return t.metadata=Analytics.pluck_valid_keys(t,Ue(t.metadata,e,{player_version:"3.34.1"})),t}constructor(t,e={}){this.emitter=t,this.metadata=Ue(Re,e.metadata||{}),this.emitter=t,this.events=e.events||[],this.required_keys=e.required_keys||[],this.optional_keys=e.optional_keys||[],this.valid_keys=this.required_keys.slice(0).concat(this.optional_keys),Ce(this),this.wireup()}wireup(){this.events.forEach(t=>{this.emitter.on(t,e=>{const s=e.detail,i=Ue(this.metadata,{event_type:t},s),r=Analytics.pluck_valid_keys(this,i),a=Analytics.ensure_required_keys(this,r);if(Ce(`Event[${t}]`,{payload:r,observation:s}),a.length)return Ce(`Analytics.validate_metadata() failed for\n Event[${t}]\n missing keys: ${a}`,r);RequestQueue.rpush(Ne,[Me,Pe,r])})})}destroy(){const t=this;t.emitter=t.metadata=t.events=t.required_keys=t.optional_keys=t.valid_keys=void 0}}class EventBus{constructor(t=document.createElement("div"),e=[]){this._bus=t,this._listeners=e}removeAllListeners(){this._listeners.length=0,this._bus=document.createElement("div")}emit(t,e){const s=new CustomEvent(t,{detail:e||{}});this._bus.dispatchEvent(s)}on(t,e){this._listeners.push([t,e]),this._bus.addEventListener(t,e,{passive:!0})}once(t,e){this._bus.addEventListener(t,e,{once:!0})}removeListener(t,e){this._bus.removeEventListener(t,e)}}const xe=yt("ads/controller"),Fe={show_all_ads_on_seek:!1,timeout:5e3,preload_advance:10};class AdsController extends EventBus{constructor(t={}){var e;super(),this.adapter=function(t,e){return t.adapter?new t.adapter(e):new IMA(e)}(t,this),this.opts=Object.assign(Object.assign({},Fe),t),this.analytics=(e=this,Analytics.of(e,{required_keys:De,optional_keys:Ie,events:ke})),this._state=AdsState.of(),this._schedule=void 0,this._lastAd=void 0,this._macros=new Macros(t.parameters||{}),this.wireup(),this.content_processing_src=!1}reset(){return this.removeAllListeners(),this.wireup(),this.analytics&&this.analytics.wireup(),this._state.reset(),this.adapter.reset(),this}destroy(){this.removeAllListeners(),this.analytics&&this.analytics.destroy(),this.adapter&&this.adapter.destroy();const t=this;t.analytics=void 0,t.opts=void 0,t.adapter=void 0,t._state=void 0,t._schedule=void 0,t._lastAd=void 0,t._macros=void 0}stop(){this.adapter&&this.adapter.stop()}onContentNewSrc(){this._state.reset(),this.adapter.destroyManager(),this.adapter.contentComplete()}wireup(){const t=()=>{var t,e;this.adapter.onAdRequestEnd(),null===(t=this.videoTag)||void 0===t||t.setState("ad-paused",!1),null===(e=this.videoTag)||void 0===e||e.setState("ad-playing",!0),this._state.toggleState(ue.PLAYING,!0)};this.on(B,t),this.on(w,t),this.on(T,t);const e=t=>{var e,s;(null==t?void 0:t.type)!==v&&this.adapter.onAdRequestEnd(),null===(e=this.videoTag)||void 0===e||e.setState("ad-paused",(null==t?void 0:t.type)===S),null===(s=this.videoTag)||void 0===s||s.setState("ad-playing",!1),this.adPlaying&&this._state.toggleState(ue.PLAYING,!1)};this.on(k,e),this.on(_,e),this.on(m,e),this.on(v,e),this.on(S,e),this.on(O,e),this.on(E,e),this.on(k,()=>{requestAnimationFrame(()=>{this._state.toggleState(ue.BREAK_ACTIVE,!1)})}),this.on(F,()=>{console.error("Adapter init failed"),e(),this._state.toggleState(ue.FATAL_ERROR,!0)}),this.on(j,async t=>{if(xe("Ads.on(RELOAD_AD_REQUESTED)",t),this._schedule){if(e(),t)return this._schedule.reset(this._schedule.getAds());this._state.hasAny(ue.AD_AVAILABLE)&&(this._schedule.decrement(),this._state.toggleState(ue.AD_AVAILABLE,!1))}})}async initialize(t,e={},s){return xe("Ads.initialize():",t,e,s),this._state.toggleState(ue.INITIALIZING,!0),Object.assign(this.opts,e),Array.isArray(t)&&this.setSchedule(t),await this.adapter.init(this.opts),this._macros=this._macros.fork(Object.assign({},e.parameters||{},{autoplay:e.autoplay,muted:e.muted})),this.adapter.isReady()&&await this.adapterInitialized(s),this}get videoTag(){return this.adapter.getVideoTag()}get adInfo(){return this.adapter.getAdInfo()}async setVideoTag(t){xe("Ads.setVideoTag():",t),await this.adapter.setVideoTag(t),this.trigger(f,t),this.adapter.isReady()&&await this.adapterInitialized(),t.on(H,()=>this.adapter.pause()),t.on(V,()=>this.adapter.resume()),t.on(z,()=>t.toggleMute()),t.on(Z,()=>{this.adapter.volume(t.muted?0:0==t.volume?.1:t.volume)}),t.on("src",()=>t.hasState("ad-playing")||t.hasState("ad-paused")?(this.stop(),this.adapter.isLinearAd()?(this.setIsContentProcessingNewSrc(!0),void this.once(k,()=>{setTimeout(()=>{this.setIsContentProcessingNewSrc(!1),this.onContentNewSrc()},0)})):this.onContentNewSrc()):this.onContentNewSrc())}waitForVideoTag(){return new Promise(t=>{const e=this.adapter.getVideoTag();if(e)return t(e);this.on(f,e=>{this.once(g,()=>t(e))})})}async adapterInitialized(t){xe("Ads.adapterInitialized()"),this._state.toggleState(ue.INITIALIZING,!1),this._state.toggleState(ue.BREAK_ACTIVE,!!this.hasPreroll()),await this.setCurrentTime(0,t),this.checkIfBreakComplete(),this.adapter.isAdPod()||t&&!this.opts.autoplay||this.trigger(_)}async fetchNextAd(t,e=0){var s,i;if(!this._schedule)return;if(!this.adapter.isReady())return;if(e>50)throw this._state.toggleState(ue.FATAL_ERROR,!0),this._state.toggleState(ue.FETCHING_AD,!1),new Error("Ads.fetchNextAd() :max_recursion_depth");const r=(null===(s=this._schedule)||void 0===s?void 0:s.getNextAd())||(null===(i=this._schedule)||void 0===i?void 0:i.getPostroll());if(!r||this.adapter.canDismissNonLinear()||-1===t)if(this._schedule.waitForLoad(t,r,this.opts.preload_ads))this._state.toggleState(ue.FETCHING_AD,!1);else if(r!==this._schedule.getPostroll()||(this._schedule.setPostrollActive(),-1===t))if(this._schedule.isDrained()||this._schedule.increment(),r){xe("Ads.fetchNextAd",r),this._state.toggleState(ue.FETCHING_AD,!0);try{return await this.requestAd(r),this._state.toggleState(ue.AD_AVAILABLE,!0),void this._state.toggleState(ue.FETCHING_AD,!1)}catch(s){return xe("Ads.fetchNextAd(err: %o, ad: %o)",s,r),this.setLastAd(r),r!==this._schedule.getPostroll()?await this.fetchNextAd(t,++e):void this._state.toggleState(ue.FETCHING_AD,!1)}}else this._state.toggleState(ue.FETCHING_AD,!1);else this._state.toggleState(ue.FETCHING_AD,!1)}skipAdsOnSeek(t){if(!this._schedule)return;let e=this._schedule.getNextAd();for(;e&&e.time<t;)this._schedule.increment(),e=this._schedule.getNextAd()}async setCurrentTime(t,e=!1,s=!1){if(!this._schedule)return;if(!this.adapter.isReady())return;if(this._state.hasAny(ue.FETCHING_AD))return;if(this._state.hasAny(ue.PLAYING)&&this.adapter.isLinearAd())return;const i=0===t&&0===this._schedule.getNextIndex();try{if(s&&!this.opts.show_all_ads_on_seek&&this.skipAdsOnSeek(t),this._state.hasAny(ue.AD_AVAILABLE)||await this.fetchNextAd(t),!this._state.hasAny(ue.AD_AVAILABLE)||!this.shallPlayAd(t)||e)return;await this.playAd(),await this.setCurrentTime(t),this.checkIfBreakComplete()}catch(t){xe("setCurrentTime: Error(from: setCurrentTime, message: %s)",t.message)}finally{i&&this.trigger(I)}}async playAd(){var t;if(!this._state.hasAny(ue.AD_AVAILABLE))return;this._state.toggleState(ue.AD_AVAILABLE,!1),this._state.toggleState(ue.BREAK_ACTIVE,!0);const e=null===(t=this._schedule)||void 0===t?void 0:t.getCurrentAd();try{await this.adapter.playAd()}catch(t){console.error("Ads.playAd: error",t)}finally{e&&this.setLastAd(e)}}checkIfBreakComplete(){if(!this._state.hasAny(ue.BREAK_ACTIVE))return xe("Ads.checkIfBreakComplete(:bail, ad: %o)",this.getLastAd());xe("Ads.checkIfBreakComplete(:run, ad: %o)",this.getLastAd()),this._state.toggleState(ue.BREAK_ACTIVE,!1),this.adapter.isAdPod()||this.trigger(k)}resetScheduleCounter(){this._schedule&&this._schedule.resetCounter()}setSchedule(t,e){if(e&&!isNaN(e)&&this._schedule&&this._schedule.updateContentDuration(e),this._schedule&&this._schedule.getNextIndex()>0)return this._schedule.setAds(t);this._schedule=new Schedule(t,{preload_advance:this.opts.preload_advance,content_duration:e?0:e})}toJSON(){return this._schedule?this._schedule.toJSON():[]}trigger(t,e={}){var s;if(!this.adapter.getVideoTag())return;if(!this._state)return;if(t===k&&this._state.hasAny(ue.BREAK_ACTIVE)&&!this.adapter.isAdPod()&&!e.force)return xe("skipping AD_BREAK_COMPLETE reason: %s pod=%s",this._state.toString(),this.adapter.isAdPod());if(null===(i=e)||"object"!=typeof i||le(i)!==de)return this.dispatch(t,e);var i;const r=Object.assign({},this.adapter.getOpts()||{},(null===(s=this._schedule)||void 0===s?void 0:s.getCurrentAd())||{},{ad_type:this.ad_type},e);return this.dispatch(t,r)}dispatch(t,e){const s=this.adapter.getVideoTag();if(s){xe(":dispatch",t,e),this.adapter.isAdPod()&&"object"==typeof e&&"time"in e&&"preroll"!==e.ad_type&&(e.time=this.adapter.getAdBreakTime());try{const i={event:"ads/"+t,detail:{outstream:e.outstream,ad_type:e.ad_type,ad_break_time:e.time,ad_remaining_seconds:e.remaining,ad_muted:e.muted,ad_duration_seconds:e.duration,ad_error_reason:e.reason,ad_vast_error:e.vast_error,ad_vast_error_type:e.vast_error_type,ad_request_load_type:e.request_load_time}};s.dispatchEvent(new CustomEvent("health:record",{detail:i}))}catch(t){xe(":error",t)}ct(s,t,e),this.emit(t,e)}}get ad_type(){if(!this.videoTag)return;if(!this.adapter.isAdPod())return this._schedule&&this._schedule.getCurrentType();const t=this.adapter.getAdBreakTime();return-1===t?"postroll":this.videoTag.hasState(nt)||t<1?"preroll":"midroll"}shouldRestartContent(){if(this.getIsContentProcessingNewSrc())return!1;if(this.adapter.isAdPod())return!0;const t=this.getLastAd();return!t||!t.outstream&&!1!==t.restart}async finished(t){if(this._schedule&&(xe("Ads.finished"),!(this.adapter.isCustomPlaybackEnabled()&&this._state.hasAny(ue.PLAYING)&&this.adapter.isLinearAd()))){xe("Ads.finished: trying to play postroll");try{if(!this._schedule.getPostroll())return xe("Ads.finished: no postroll found"),await this.adapter.contentComplete();this._state.hasAny(ue.AD_AVAILABLE)||await this.fetchNextAd(-1),await this.playAd(),this.adapter.contentComplete()}catch(t){xe("Ads.finished: postroll failed:",t)}finally{this.trigger(D),this.checkIfBreakComplete(),"function"==typeof t&&t()}}}hasPreroll(){return this._schedule&&Schedule.hasPreroll(this._schedule.getAds())}shallPlayAd(t){var e;return(!this.adapter||!this.adapter.isAdPod())&&(!(!this._state||this._state.hasAny(ue.FATAL_ERROR))&&!!(null===(e=this._schedule)||void 0===e?void 0:e.shallPlayAd(t)))}setLastAd(t){return this._lastAd=t,this}setIsContentProcessingNewSrc(t){this.content_processing_src=t}getLastAd(){return this._lastAd}getIsContentProcessingNewSrc(){return this.content_processing_src}mergeMacros(t={}){return this._macros=this._macros.fork(Object.assign({},t)),this}get paused(){return this.adapter&&this.adapter.isPaused()}pause(){this.adapter&&this.adapter.pause()}resume(){this.adapter&&this.adapter.resume()}resize(t){this.adapter&&this.adapter.onResize(t)}async requestAd(t,e=0,s=this.opts.timeout){if(!this._state)return;xe("Ads.requestAd(ad: %o)",{ad:t,timeout:s,idx:e});const i=await oe(t);if(void 0===i[e])return setTimeout(()=>this.trigger(_),0),Promise.reject(new Error("Ad failed, no fallbacks left"));if(!i[e])return await this.requestAd(i,e+1,s);this.trigger(y,t);const r=this._macros.compile(i[e],re(this.opts,this.adapter.getDimensions()));try{return void await this.adapter.initAd(r,s)}catch(t){return xe(`Ads.requestAd(:fallback, idx: ${e}, length: ${i.length}, adTag: ${i[e]})\nError `,{adTag:i,err:t}),this.requestAd(i,e+1,s)}}resetSchedule(t){this._schedule&&this._schedule.reset(t)}get adPlaying(){return this._state&&this._state.hasAny(ue.PLAYING)}get adBreak(){return this._state&&this._state.hasAny(ue.BREAK_ACTIVE)}get adRequesting(){return this._state.hasAny(ue.FETCHING_AD)}get adLinear(){return this.adBreak&&this.adapter.isLinearAd()}}var Be=new Blob([new Uint8Array([255,227,24,196,0,0,0,3,72,1,64,0,0,4,132,16,31,227,192,225,76,255,67,12,255,221,27,255,228,97,73,63,255,195,131,69,192,232,223,255,255,207,102,239,255,255,255,101,158,206,70,20,59,255,254,95,70,149,66,4,16,128,0,2,2,32,240,138,255,36,106,183,255,227,24,196,59,11,34,62,80,49,135,40,0,253,29,191,209,200,141,71,7,255,252,152,74,15,130,33,185,6,63,255,252,195,70,203,86,53,15,255,255,247,103,76,121,64,32,47,255,34,227,194,209,138,76,65,77,69,51,46,57,55,170,170,170,170,170,170,170,170,170,170,255,227,24,196,73,13,153,210,100,81,135,56,0,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170])],{type:"audio/mpeg"}),je=new Blob([new Uint8Array([0,0,0,28,102,116,121,112,105,115,111,109,0,0,2,0,105,115,111,109,105,115,111,50,109,112,52,49,0,0,0,8,102,114,101,101,0,0,2,239,109,100,97,116,33,16,5,32,164,27,255,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,55,167,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,112,33,16,5,32,164,27,255,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,55,167,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,112,0,0,2,194,109,111,111,118,0,0,0,108,109,118,104,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,232,0,0,0,47,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,1,236,116,114,97,107,0,0,0,92,116,107,104,100,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,47,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,36,101,100,116,115,0,0,0,28,101,108,115,116,0,0,0,0,0,0,0,1,0,0,0,47,0,0,0,0,0,1,0,0,0,0,1,100,109,100,105,97,0,0,0,32,109,100,104,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,172,68,0,0,8,0,85,196,0,0,0,0,0,45,104,100,108,114,0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0,0,0,1,15,109,105,110,102,0,0,0,16,115,109,104,100,0,0,0,0,0,0,0,0,0,0,0,36,100,105,110,102,0,0,0,28,100,114,101,102,0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1,0,0,0,211,115,116,98,108,0,0,0,103,115,116,115,100,0,0,0,0,0,0,0,1,0,0,0,87,109,112,52,97,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,2,0,16,0,0,0,0,172,68,0,0,0,0,0,51,101,115,100,115,0,0,0,0,3,128,128,128,34,0,2,0,4,128,128,128,20,64,21,0,0,0,0,1,244,0,0,1,243,249,5,128,128,128,2,18,16,6,128,128,128,1,2,0,0,0,24,115,116,116,115,0,0,0,0,0,0,0,1,0,0,0,2,0,0,4,0,0,0,0,28,115,116,115,99,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,2,0,0,0,1,0,0,0,28,115,116,115,122,0,0,0,0,0,0,0,0,0,0,0,2,0,0,1,115,0,0,1,116,0,0,0,20,115,116,99,111,0,0,0,0,0,0,0,1,0,0,0,44,0,0,0,98,117,100,116,97,0,0,0,90,109,101,116,97,0,0,0,0,0,0,0,33,104,100,108,114,0,0,0,0,0,0,0,0,109,100,105,114,97,112,112,108,0,0,0,0,0,0,0,0,0,0,0,0,45,105,108,115,116,0,0,0,37,169,116,111,111,0,0,0,29,100,97,116,97,0,0,0,1,0,0,0,0,76,97,118,102,53,54,46,52,48,46,49,48,49])],{type:"video/mp4"});function qe(t){return Object.assign({muted:!1,timeout:250,inline:!1},t)}function He(t,e){var s=t.muted,i=t.timeout,r=t.inline,a=e(),n=a.element,o=a.source,d=void 0,l=void 0,c=void 0;return n.muted=s,!0===s&&n.setAttribute("muted","muted"),!0===r&&n.setAttribute("playsinline","playsinline"),n.src=o,new Promise(function(t){d=n.play(),l=setTimeout(function(){c(!1,new Error("Timeout "+i+" ms has been reached"))},i),c=function(e){var s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;n.remove(),n.srcObject=null,clearTimeout(l),t({result:e,error:s})},void 0!==d?d.then(function(){return c(!0)}).catch(function(t){return c(!1,t)}):c(!0)})}var Ve={audio:function(t){return He(t=qe(t),function(){return{element:document.createElement("audio"),source:URL.createObjectURL(Be)}})},video:function(t){return He(t=qe(t),function(){return{element:document.createElement("video"),source:URL.createObjectURL(je)}})}};let ze;async function Ge(t=!0){return ze||(ze=await Ve.video({timeout:500,muted:t}),ze)}var We=Object.freeze({__proto__:null,STICKY_CONTROLS:1,NO_FULLSCREEN:2,NO_AD_INDICATOR:4,AD_ATTRIBUTION:8,AD_CHOICES:16,REMAINING_TIME:32,VOLUME_BAR:64});const Qe=["progress","duration","remaining"];class AdUI extends HTMLElement{static get observedAttributes(){return Qe}constructor(t){super(),this.player=t,this.className="fp-ad-ui",this.append(...t.createComponents(Et,St)),t.on(Q,t=>{let{ui_flags:e}=t.detail;if(e=e||0,(8&e)>0){const t=document.createElement("div");t.classList.add("ad-attribution"),t.textContent=this.player.i18n("ads.advertisement","Advertisement"),this.append(t)}})}}const $e=yt("fpads:native:outstream"),Ke={OUTSTREAM:"is-outstream",HIDDEN:"is-outstream-hidden",SHOWING:"is-outstream-visible",DONE:"is-outstream-done"};var Ye,Ze;!function(t){t.OUTSTREAM_VISIBLE="ads-outstream-visible",t.OUTSTREAM_VIEWPORT_UPDATE="ads-outstream-viewport-update",t.OUTSTREAM_TEARDOWN="ads-outstream-teardown",t.OUTSTREAM_ENDSCREEN_READY="ads-outstream-endscreen-ready"}(Ye||(Ye={})),function(t){t[t.None=0]="None",t[t.Booting=1]="Booting",t[t.Ready=2]="Ready",t[t.Disposed=3]="Disposed"}(Ze||(Ze={}));class Outstream{constructor({ads:t,root:e,content:s,ima:i}){this.state=Ze.None,$e("creating Outstream instance"),this.content=s,this.ads=t,this.root=e,this.ima=i,this.aspectRatio=s.videoHeight/s.videoWidth,this.dimensions=function(t){if(t.clientWidth>0||t.clientHeight)return h(t);const e={height:t.style.height};p(t,"opacity",0),p(t,"display","absolute"),p(t,"display","inline-block"),p(t,"height","auto");const s=h(t);return p(t,"height",e.height),p(t,"opacity",1),s}(this.root),this.adUi=new AdUI(s),this.initialVolumeState={},e.classList.add(Ke.OUTSTREAM),e.append(this.adUi),this.hide(),this.ads.on(b,t=>{var e;if(this.state==Ze.Disposed)return;const s=!!(null===(e=t.detail)||void 0===e?void 0:e.linear);this.ads.resize(Object.assign(Object.assign({},this.dimensions),{linear:s}))}),s.on(Y,t=>{if(this.state==Ze.Disposed)return;const e=t.detail;e&&(this.dimensions={width:e.contentRect.width,height:e.contentRect.height},this.ads.resize(this.dimensions))});let r=1,a=!0;s.on("intersectionchange",t=>{if(this.state==Ze.Disposed)return;const e=t.detail;if(e)switch(this.state){case Ze.Booting:return $e(":boot skipping intersectionchange");case Ze.None:return this.state=Ze.Booting,this.begin_life_cycle();case Ze.Ready:if(r=e.ratio,e.ratio>=.5&&this.ads.adPlaying)return;e.ratio>=.5&&a&&this.ads.resume(),e.ratio<.5&&this.ads.pause()}}),this.content.on(S,()=>a=r<.5),this.setup(),setTimeout(()=>(this.state=Ze.Booting,this.begin_life_cycle()),0)}hide(){return this}restore_aspect_ratio(){return $e(`Outstream.restore_aspect_ratio(${this.aspectRatio})`),this.content.setOpts({ratio:this.aspectRatio}),this}show(){this.root.classList.remove(Outstream.CLASS.HIDDEN),this.root.classList.add(Outstream.CLASS.SHOWING),this.content.setState("ad-linear",!0)}async begin_life_cycle(){var t;this.state=Ze.Ready;const{error:e,result:s}=await Ge(!1),{result:i}=await Ge(!0);this.content.emit(Q,{ui_flags:null===(t=this.content.opts.ads)||void 0===t?void 0:t.ui}),this.attach_ad_listeners(),this.initialVolumeState={can_autoplay:!(!s&&!i),muted:!s},$e(`Outstream.show() :autoplay >> sound=${s}`),e&&this.content&&!s&&(this.content.muted=!0,this.content.volume=0),await this.ads.setVideoTag(this.content),await Dt({ads:this.ads,content:this.content,adContainer:this.adUi,ima:this.ima,state:{listening:!1},config:this.content.opts}),xt({content:this.content,ads:this.ads}),this.state=Ze.Ready}attach_ad_listeners(){this.ads.once(b,()=>{this.show(),this.ads.adPlaying&&this.ads.pause()});const t=()=>{Pt.forEach(e=>this.ads.removeListener(e,t));const e=new CustomEvent(Ye.OUTSTREAM_TEARDOWN);$e("Outstream(:teardown)",e),this.content.dispatchEvent(e)};Pt.forEach(e=>this.ads.once(e,t)),this.content.once(Ye.OUTSTREAM_TEARDOWN,t=>{setTimeout(()=>{if(t.defaultPrevented)return this.handle_endscreen();this.dispose()},0)})}handle_endscreen(){this.reset_ui(),this.ads.reset(),Nt({config:this.content.opts,ui:this.adUi,ads:this.ads,adContainer:this.adUi,ima:this.ima,content:this.content,root:this.content.root,state:{started:!0,listening:!1},initial:{muted:!0,volume:1}})}empty_src(){this.content.setSrc({type:"video/mp4",src:URL.createObjectURL(Lt)})}setup(){this.root.classList.add(Outstream.CLASS.OUTSTREAM),this.root.classList.add(Outstream.CLASS.HIDDEN),this.content.setState("ad-linear",!1),this.empty_src()}reset_ui(){const t=this.root;t.classList.remove(Outstream.CLASS.SHOWING),t.classList.remove(Outstream.CLASS.OUTSTREAM)}dispose(){if(this.state==Ze.Disposed)return;const t=this.root,e=this.content;this.reset_ui(),t.classList.add(Outstream.CLASS.OUTSTREAM),t.classList.add(Outstream.CLASS.DONE);const s=this;s.video=s.container=s.ads=0,this.state=Ze.Disposed,e.destroy(),t.innerHTML=""}}function Je(t){return t&&"number"==typeof t.time}function Xe(t){return t&&"number"==typeof t.percentage&&"number"!=typeof t.time}Outstream.CLASS=Ke;const ts=yt("ads/ima/sdk");var es,ss;async function is(t,e){var s;const i=null===(s=null===window||void 0===window?void 0:window.google)||void 0===s?void 0:s.ima;if(e?null==i?void 0:i.dai:i)return void ts(":noop");const r=e?"https://imasdk.googleapis.com/js/sdkloader/ima3_dai.js":t._storage.getItem("ima/debug")?"https://imasdk.googleapis.com/js/sdkloader/ima3_debug.js":"https://imasdk.googleapis.com/js/sdkloader/ima3.js";try{return await async function(t){return new Promise((e,s)=>{let i=document.querySelector(`script[src='${t}']`);if(i)return rs(i,e,s);i=document.createElement("script"),i.setAttribute("state",es.LOADING),rs(i,e,s),i.src=t,document.head.appendChild(i)})}(r),void ts(":loaded")}catch(t){ts(`:error ${t.message}`,t)}}function rs(t,e,s){const i=t.getAttribute("state");if(i&&[es.ERROR,es.LOADED].includes(i))return e(void 0);t.addEventListener("load",()=>{t.setAttribute("state",es.LOADED),e(void 0)},{once:!0}),["error","abort"].forEach(e=>{t.addEventListener(e,()=>{t.setAttribute("state",es.ERROR),s("script failed to load")},{once:!0})})}!function(t){t.LOADING="loading",t.LOADED="loaded",t.ERROR="error"}(es||(es={})),function(t){t.LOADING="loading",t.LOADED="loaded",t.ERROR="error"}(ss||(ss={}));const as=yt("ads/ima/sdk"),ns="https://cdn.jsdelivr.net/npm/prebid.js@latest/dist/not-for-prod/prebid.js",os=ns;async function ds(t){var e;const s=t._storage.getItem("prebid/debug")?ns:os;if(null===(e=null===window||void 0===window?void 0:window.pbjs)||void 0===e?void 0:e.version)as(":noop");else if(!document.querySelector(`script[src='${s}']`))try{return await async function(t){return new Promise((e,s)=>{let i=document.querySelector(`script[src='${t}']`);i||(i=document.createElement("script")),i.setAttribute("state",ss.LOADING);const r=i.getAttribute("state");if(r&&[ss.ERROR,ss.LOADED].includes(r))return e(void 0);i.addEventListener("load",()=>{i.setAttribute("state",ss.LOADED),e(void 0)},{once:!0}),["error","abort"].forEach(t=>{i.addEventListener(t,()=>{i.setAttribute("state",ss.ERROR),s("script failed to load")},{once:!0})}),i.src=t,document.head.appendChild(i)})}(s),void as(":loaded")}catch(t){console.warn(`:error / failed to load prebid.js / ${t.message}`,t)}}const ls=window.pbjs=window.pbjs||{};ls.que=ls.que||[];class PrebidAdController{constructor(t,e){this.player=t,this.config=e,this.player=t,this.bestOffer="",ls.que.push(()=>{var s,i;const r=this.createAdUnit();ls.addAdUnits(r);const a=(null===(i=null===(s=e.ads)||void 0===s?void 0:s.prebid)||void 0===i?void 0:i.pbjs)||{};ls.setConfig(Object.assign({enableSendAllBids:!0},a)),t.emit($,{pbjs:ls}),ls.requestBids({bidsBackHandler:t=>{var s,i,a,n,o;const d=null===(s=t[this.prebidCode()])||void 0===s?void 0:s.bids;if(!d)return;if(0==d.length)return;const l=d[0];if(l&&l.vastUrl)return this.bestOffer=l.vastUrl;const c=ls.adServers.dfp.buildVideoUrl({adUnit:r,params:{iu:null===(a=null===(i=e.ads)||void 0===i?void 0:i.prebid)||void 0===a?void 0:a.iu,cust_params:null===(o=null===(n=e.ads)||void 0===n?void 0:n.prebid)||void 0===o?void 0:o.custom_params,output:"vast"}});this.bestOffer=c}})})}prebidCode(){var t,e;return(null===(e=null===(t=this.config.ads)||void 0===t?void 0:t.prebid)||void 0===e?void 0:e.code)||this.player.root.id}videoInfo(){var t,e;return(null===(e=null===(t=this.config.ads)||void 0===t?void 0:t.prebid)||void 0===e?void 0:e.video)||{context:"instream",playerSize:[[this.player.videoWidth||640,this.player.videoHeight||480]]}}createAdUnit(){var t,e;return{code:this.prebidCode(),mediaTypes:{video:this.videoInfo()},bids:null===(e=null===(t=this.config.ads)||void 0===t?void 0:t.prebid)||void 0===e?void 0:e.bidders}}vastGenerator(){return async()=>this.bestOffer}}function cs(t,e){var s,i;const r=null===(s=e.ads)||void 0===s?void 0:s.prebid;if(!r)return;if((null===(i=t.prebidController)||void 0===i?void 0:i.config)===e)return;!function(t,{feature_name:e,behavior:s,sample_rate:i}){e&&(i||(i=_t),t.emit("flowplayer:feature",{feature_name:e,behavior:s,sample_rate:i}))}(t,{feature_name:"prebid",behavior:"used"}),t.prebidController||(t.prebidController=new PrebidAdController(t,e),ds(t));const a=t.prebidController;if(a){const e=r.breaks.map(t=>({adTag:a.vastGenerator(),time:t}));t.setOpts({ima:{ads:e}})}}const us=yt("ads/index");async function hs(t,e,s){var i;let r;if(s.on("config",()=>{var e,i,a;void 0===r&&t.autoplay&&(Gt(a=t.ima)&&(null==a?void 0:a.ads.find(t=>!t.time||"percentage"in t&&0===t.percentage)))&&!s.currentSrc&&(i=t.autoplay,r=!0===i?ut.ON:!1===i?ut.OFF:i,t.autoplay=0),(null===(e=t.ads)||void 0===e?void 0:e.prebid)&&cs(s,t),Gt(t.ima)&&zt(s)&&Object.assign(t,{hls:{native:!0}}),s.ads&&d()}),s.once("loadstart",()=>{setTimeout(async()=>{if(void 0!==r&&(await is(s),!("google"in window))){if(t.autoplay=r,s.setState(dt,!0),!s.hasState(lt))return s.once(st,()=>s.togglePlay(!0));s.togglePlay(!0)}},0)}),await is(s),!("google"in window))return console.warn("google.ima unavailable");let a=!1;const n=s.ads=new AdsController,o=n.analytics;function d(){if(!Gt(t.ima))return;const i=t.ima,d=t.duration||s.duration;if(i.ads=function(t,e){return Array.isArray(t)?t.filter(t=>Je(t)||Xe(t)).reduce((t,s)=>{if(Je(s))return t.push(s),t;if(s.lazy)return t.push(s),t;if(Xe(s)){const i=Object.assign({},s),r=s.percentage?s.percentage*e:0;return isNaN(r)||(i.time=r<0||r===e?-1:r),t.push(i),t}return t},[]):(console.warn("AdSchedule was not an Array"),[])}(i.ads,d),n.setSchedule(i.ads,d),t.metadata&&Analytics.mergeMetadata(o,t.metadata),t.metadata&&n.mergeMacros(t.metadata),t.metadata&&i.parameters&&(i.parameters=Object.assign(Object.assign({},i.parameters),t.metadata)),Analytics.mergeMetadata(o,{muted:t.muted||!1,autoplay:t.autoplay||!1}),!a){if(a=!0,t.lang&&!i.Locale&&(i.Locale=t.lang),Schedule.isOutstream(i.ads))return us("is outstream, returning"),new Outstream({root:e,content:s,ads:n,ima:i});kt({config:Object.assign(Object.assign({},t),{autoplay:r}),root:e,content:s,ads:n,ima:i})}}n.resize(h(e)),n.on(D,()=>{n.adapter.isCustomPlaybackEnabled()&&n.once(k,()=>{s.src=s.original_src,s.once("canplay",()=>{s.togglePlay(!1)}),s.webkitExitFullscreen()})}),s.on("reap",function(){n&&n.destroy()}),(null===(i=t.ads)||void 0===i?void 0:i.prebid)&&cs(s,t),d()}class AdControls extends HTMLElement{constructor(t){super(),this.player=t,this.classList.add("fp-ad-controls"),this.append(this.adRemainingTime(),At(this.player,Tt),this.playbackButtons(),this.volumeBtn(),At(this.player,"flowplayer-volume-bar"),...this.fullscreenIcons(),this.adChoices()),t.on(Q,this.applyStyleFlags.bind(this))}fullscreenIcons(){return this.player.createComponents("flowplayer-fullscreen-enter-icon","flowplayer-fullscreen-exit-icon").map(t=>(t.onclick=()=>this.player.toggleFullScreen(),t))}volumeBtn(){const t=At(this.player,"flowplayer-volume-icon");return t.onclick=()=>this.player.emit(z),t}playbackButtons(){const t=document.createElement("div");t.classList.add("ad-playback-controls");const e=At(this.player,"flowplayer-small-play-icon"),s=At(this.player,"flowplayer-small-pause-icon");return e.addEventListener("click",()=>{this.player.emit(V),setTimeout(function(){s.focus&&s.focus()},100)}),s.addEventListener("click",()=>{this.player.emit(H),setTimeout(function(){e.focus&&e.focus()},100)}),t.append(e,s),t}adChoices(){const t=document.createElement("div");return t.classList.add("fp-ad-choices"),t.textContent=this.player.i18n("ads.adchoices","AdChoices"),t.addEventListener("click",t=>{t.preventDefault(),this.player.togglePlay(!1),window.open("https://adssettings.google.com","_blank")}),t}adRemainingTime(){const t=document.createElement("div");return t.classList.add("fp-ad-remaining","fp-color-text"),this.prepend(t),this.player.on(L,e=>{const s=e.detail.remaining;t.textContent=function(t){if(isNaN(t)||t>=Number.MAX_SAFE_INTEGER)return"";const e=t<0?"-":"";t=Math.round(Math.abs(t));const s=Math.floor(t/3600);let i=Math.floor(t/60);return t-=60*i,s>=1?(i-=60*s,e+s+":"+ht(i)+":"+ht(t)):e+ht(i)+":"+ht(t)}(parseFloat(s+""))}),t}applyStyleFlags(t){var e;const s=null!==(e=t.detail.ui_flags)&&void 0!==e?e:0;this.classList.toggle("is-ad-controls-sticky",(1&s)>0),this.classList.toggle("no-indicator",(4&s)>0),this.classList.toggle("is-ad-choices",(16&s)>0),this.classList.toggle("no-volume-bar",!(64&s)),this.classList.toggle("is-ad-remaining",(32&s)>0),this.classList.toggle("no-fullscreen",(2&s)>0)}}class AdCountdown extends HTMLElement{static get observedAttributes(){return["remaining"]}constructor(t){super(),this.player=t,this.className="fp-ad-countdown",t.on(L,t=>{const{duration:e,remaining:s}=t.detail;this.setAttribute("duration",e+""),this.setAttribute("remaining",s+"")}),t.on(w,t=>{t.detail.linear&&(this.style.setProperty("--ad-percent-previous","0"),this.style.setProperty("--ad-percent-complete","0"))}),this.addEventListener("animationend",()=>{const t=this.style.getPropertyValue("--ad-percent-complete")||"0";this.style.setProperty("--ad-percent-previous",t)})}attributeChangedCallback(t,e,s){if("remaining"===t)return this.onRemaining(s)}onRemaining(t){const e=parseFloat(this.getAttribute("duration")||"0");t||(t=e+"");const s=parseFloat(t),i=this.style.getPropertyValue("--ad-percent-complete")||"0";this.style.setProperty("--ad-percent-previous",i),this.classList.remove("go");const r=((e-s)/e*100).toFixed(3);requestAnimationFrame(()=>{this.style.setProperty("--ad-percent-complete",r),this.classList.add("go")})}}class AdIndicator extends HTMLElement{static get observedAttributes(){return["position","totals"]}constructor(t){super(),this.player=t,this.render(),t.on(w,t=>{const{position:e,totals:s}=t.detail.ad;this.setAttribute("position",e+""),this.setAttribute("totals",s+"")})}attributeChangedCallback(t,e){switch(t){case"position":case"totals":return this.updateText()}}updateText(){if(!this.element)return;const t=parseFloat(this.getAttribute("position")||"0"),e=parseFloat(this.getAttribute("totals")||"0");this.element.textContent=`${this.player.i18n("ads.indicator","ADS")} ${t} / ${e}`}render(){this.element=document.createElement("div"),this.element.classList.add("ad-indicator","fp-color-text"),this.element.textContent=this.player.i18n("ads.indicator","ADS"),this.append(this.element)}}var ps,gs=Object.freeze({__proto__:null,SINGlE_INLINE_LINEAR:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_ad_samples&sz=640x480&cust_params=sample_ct%3Dlinear&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator=",SINGLE_SKIPPABLE_INLINE:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_preroll_skippable&sz=640x480&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator=",SINGLE_REDIRECT_LINEAR:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_ad_samples&sz=640x480&cust_params=sample_ct%3Dredirectlinear&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator=",SINGLE_REDIRECT_ERROR:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_ad_samples&sz=640x480&cust_params=sample_ct%3Dredirecterror&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator=",SINGLE_REDIRECT_BROKEN:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_ad_samples&sz=640x480&cust_params=sample_ct%3Dredirecterror&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&nofb=1&correlator=",SINGLE_VPAID_20_LINEAR:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_ad_samples&sz=640x480&cust_params=sample_ct%3Dlinearvpaid2js&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator=",SINGLE_VPAID_20_NON_LINEAR:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_ad_samples&sz=640x480&cust_params=sample_ct%3Dnonlinearvpaid2js&ciu_szs=728x90%2C300x250&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator=",SINGLE_NON_LINEAR_INLINE:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/nonlinear_ad_samples&sz=480x70&cust_params=sample_ct%3Dnonlinear&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator=",VMAP_SESSION_AD_RULE_PREROLL:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/vmap_ad_samples&sz=640x480&cust_params=sar%3Da0f2&ciu_szs=300x250&ad_rule=1&gdfp_req=1&output=vmap&unviewed_position_start=1&env=vp&impl=s&correlator=",VMAP_PREROLL:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/vmap_ad_samples&sz=640x480&cust_params=sample_ar%3Dpreonly&ciu_szs=300x250%2C728x90&gdfp_req=1&ad_rule=1&output=vmap&unviewed_position_start=1&env=vp&impl=s&correlator=",VMAP_PREROLL_BUMPER:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/vmap_ad_samples&sz=640x480&cust_params=sample_ar%3Dpreonlybumper&ciu_szs=300x250&gdfp_req=1&ad_rule=1&output=vmap&unviewed_position_start=1&env=vp&impl=s&correlator=",VMAP_POSTROLL:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/vmap_ad_samples&sz=640x480&cust_params=sample_ar%3Dpostonly&ciu_szs=300x250&gdfp_req=1&ad_rule=1&output=vmap&unviewed_position_start=1&env=vp&impl=s&correlator=",VMAP_POSTROLL_BUMPER:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/vmap_ad_samples&sz=640x480&cust_params=sample_ar%3Dpostonlybumper&ciu_szs=300x250&gdfp_req=1&ad_rule=1&output=vmap&unviewed_position_start=1&env=vp&impl=s&correlator="});const{samsung_tv:ms}=u(),_s=(ps=class Ads{constructor(t){this.umd=t,bt(t,wt,AdUI),bt(t,Et,AdControls),bt(t,St,AdCountdown),bt(t,Tt,AdIndicator)}init(t,e,s){if(c.from_token(t.token||"").is_granted(c.permissions.ADS)&&!ms)return hs(t,e,s)}},ps.pluginName="ads",ps.events=K,ps.ui=We,ps.tags=gs,ps);return function(t,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;if(null===document.currentScript)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});const s=t.flowplayer;return"function"==typeof s?(s(e),e):(Array.isArray(s.extensions)||(s.extensions=[]),~s.extensions.indexOf(e)||s.extensions.push(e),e)}(window,_s)});
7
+ */const Ee=class Bowser{static getParser(t,e=!1){if("string"!=typeof t)throw new Error("UserAgent should be a string");return new Parser(t,e)}static parse(t){return new Parser(t).getResult()}static get BROWSER_MAP(){return ge}static get ENGINE_MAP(){return fe}static get OS_MAP(){return _e}static get PLATFORMS_MAP(){return me}}.parse(window.navigator.userAgent),{platform:Se,os:Te,browser:Le}=Ee,Oe=t=>t&&t.toLowerCase();var Re={rnd:Math.random().toString(36).substr(2,32),os:Oe(Te.name+(Te.versionName?` ${Te.versionName}`:"")),device:Oe(Se.type),browser:Oe(Le.name),browser_version:(Le&&Le.version?Le.version:"unknown").split(".").shift(),plugin_version:"3.34.2"};const Me="https://fp-eu-w1-aai.flowplayer.com/in",Pe="POST",ke=[y,v,A,E,w,q,O],De=["event_type","ad_tag_id","media_id","player_id","site_id","sitegroup_id","rnd","os","device","browser","browser_version","plugin_version","player_version"],Ie=["vast_error","reason","request_load_time","ad_type","vast_ad_id"],Ce=yt("ads/analytics"),Ne=RequestQueue.of(),Ue=(...t)=>Object.assign({},...t);class Analytics{static of(t,e){return new Analytics(t,e)}static ensure_required_keys(t,e){return t.required_keys.filter(t=>!(t in e))}static pluck_valid_keys(t,e){return((t,...e)=>Object.keys(t).filter(t=>~e.indexOf(t)).reduce((e,s)=>Object.assign(e,{[s]:t[s]}),{}))(e,...t.valid_keys)}static mergeMetadata(t,e={}){return t.metadata=Analytics.pluck_valid_keys(t,Ue(t.metadata,e,{player_version:"3.34.2"})),t}constructor(t,e={}){this.emitter=t,this.metadata=Ue(Re,e.metadata||{}),this.emitter=t,this.events=e.events||[],this.required_keys=e.required_keys||[],this.optional_keys=e.optional_keys||[],this.valid_keys=this.required_keys.slice(0).concat(this.optional_keys),Ce(this),this.wireup()}wireup(){this.events.forEach(t=>{this.emitter.on(t,e=>{const s=e.detail,i=Ue(this.metadata,{event_type:t},s),r=Analytics.pluck_valid_keys(this,i),a=Analytics.ensure_required_keys(this,r);if(Ce(`Event[${t}]`,{payload:r,observation:s}),a.length)return Ce(`Analytics.validate_metadata() failed for\n Event[${t}]\n missing keys: ${a}`,r);RequestQueue.rpush(Ne,[Me,Pe,r])})})}destroy(){const t=this;t.emitter=t.metadata=t.events=t.required_keys=t.optional_keys=t.valid_keys=void 0}}class EventBus{constructor(t=document.createElement("div"),e=[]){this._bus=t,this._listeners=e}removeAllListeners(){this._listeners.length=0,this._bus=document.createElement("div")}emit(t,e){const s=new CustomEvent(t,{detail:e||{}});this._bus.dispatchEvent(s)}on(t,e){this._listeners.push([t,e]),this._bus.addEventListener(t,e,{passive:!0})}once(t,e){this._bus.addEventListener(t,e,{once:!0})}removeListener(t,e){this._bus.removeEventListener(t,e)}}const xe=yt("ads/controller"),Fe={show_all_ads_on_seek:!1,timeout:5e3,preload_advance:10};class AdsController extends EventBus{constructor(t={}){var e;super(),this.adapter=function(t,e){return t.adapter?new t.adapter(e):new IMA(e)}(t,this),this.opts=Object.assign(Object.assign({},Fe),t),this.analytics=(e=this,Analytics.of(e,{required_keys:De,optional_keys:Ie,events:ke})),this._state=AdsState.of(),this._schedule=void 0,this._lastAd=void 0,this._macros=new Macros(t.parameters||{}),this.wireup(),this.content_processing_src=!1}reset(){return this.removeAllListeners(),this.wireup(),this.analytics&&this.analytics.wireup(),this._state.reset(),this.adapter.reset(),this}destroy(){this.removeAllListeners(),this.analytics&&this.analytics.destroy(),this.adapter&&this.adapter.destroy();const t=this;t.analytics=void 0,t.opts=void 0,t.adapter=void 0,t._state=void 0,t._schedule=void 0,t._lastAd=void 0,t._macros=void 0}stop(){this.adapter&&this.adapter.stop()}onContentNewSrc(){this._state.reset(),this.adapter.destroyManager(),this.adapter.contentComplete()}wireup(){const t=()=>{var t,e;this.adapter.onAdRequestEnd(),null===(t=this.videoTag)||void 0===t||t.setState("ad-paused",!1),null===(e=this.videoTag)||void 0===e||e.setState("ad-playing",!0),this._state.toggleState(ue.PLAYING,!0)};this.on(B,t),this.on(w,t),this.on(T,t);const e=t=>{var e,s;(null==t?void 0:t.type)!==v&&this.adapter.onAdRequestEnd(),null===(e=this.videoTag)||void 0===e||e.setState("ad-paused",(null==t?void 0:t.type)===S),null===(s=this.videoTag)||void 0===s||s.setState("ad-playing",!1),this.adPlaying&&this._state.toggleState(ue.PLAYING,!1)};this.on(k,e),this.on(_,e),this.on(m,e),this.on(v,e),this.on(S,e),this.on(O,e),this.on(E,e),this.on(k,()=>{requestAnimationFrame(()=>{this._state.toggleState(ue.BREAK_ACTIVE,!1)})}),this.on(F,()=>{console.error("Adapter init failed"),e(),this._state.toggleState(ue.FATAL_ERROR,!0)}),this.on(j,async t=>{if(xe("Ads.on(RELOAD_AD_REQUESTED)",t),this._schedule){if(e(),t)return this._schedule.reset(this._schedule.getAds());this._state.hasAny(ue.AD_AVAILABLE)&&(this._schedule.decrement(),this._state.toggleState(ue.AD_AVAILABLE,!1))}})}async initialize(t,e={},s){return xe("Ads.initialize():",t,e,s),this._state.toggleState(ue.INITIALIZING,!0),Object.assign(this.opts,e),Array.isArray(t)&&this.setSchedule(t),await this.adapter.init(this.opts),this._macros=this._macros.fork(Object.assign({},e.parameters||{},{autoplay:e.autoplay,muted:e.muted})),this.adapter.isReady()&&await this.adapterInitialized(s),this}get videoTag(){return this.adapter.getVideoTag()}get adInfo(){return this.adapter.getAdInfo()}async setVideoTag(t){xe("Ads.setVideoTag():",t),await this.adapter.setVideoTag(t),this.trigger(f,t),this.adapter.isReady()&&await this.adapterInitialized(),t.on(H,()=>this.adapter.pause()),t.on(V,()=>this.adapter.resume()),t.on(z,()=>t.toggleMute()),t.on(Z,()=>{this.adapter.volume(t.muted?0:0==t.volume?.1:t.volume)}),t.on("src",()=>t.hasState("ad-playing")||t.hasState("ad-paused")?(this.stop(),this.adapter.isLinearAd()?(this.setIsContentProcessingNewSrc(!0),void this.once(k,()=>{setTimeout(()=>{this.setIsContentProcessingNewSrc(!1),this.onContentNewSrc()},0)})):this.onContentNewSrc()):this.onContentNewSrc())}waitForVideoTag(){return new Promise(t=>{const e=this.adapter.getVideoTag();if(e)return t(e);this.on(f,e=>{this.once(g,()=>t(e))})})}async adapterInitialized(t){xe("Ads.adapterInitialized()"),this._state.toggleState(ue.INITIALIZING,!1),this._state.toggleState(ue.BREAK_ACTIVE,!!this.hasPreroll()),await this.setCurrentTime(0,t),this.checkIfBreakComplete(),this.adapter.isAdPod()||t&&!this.opts.autoplay||this.trigger(_)}async fetchNextAd(t,e=0){var s,i;if(!this._schedule)return;if(!this.adapter.isReady())return;if(e>50)throw this._state.toggleState(ue.FATAL_ERROR,!0),this._state.toggleState(ue.FETCHING_AD,!1),new Error("Ads.fetchNextAd() :max_recursion_depth");const r=(null===(s=this._schedule)||void 0===s?void 0:s.getNextAd())||(null===(i=this._schedule)||void 0===i?void 0:i.getPostroll());if(!r||this.adapter.canDismissNonLinear()||-1===t)if(this._schedule.waitForLoad(t,r,this.opts.preload_ads))this._state.toggleState(ue.FETCHING_AD,!1);else if(r!==this._schedule.getPostroll()||(this._schedule.setPostrollActive(),-1===t))if(this._schedule.isDrained()||this._schedule.increment(),r){xe("Ads.fetchNextAd",r),this._state.toggleState(ue.FETCHING_AD,!0);try{return await this.requestAd(r),this._state.toggleState(ue.AD_AVAILABLE,!0),void this._state.toggleState(ue.FETCHING_AD,!1)}catch(s){return xe("Ads.fetchNextAd(err: %o, ad: %o)",s,r),this.setLastAd(r),r!==this._schedule.getPostroll()?await this.fetchNextAd(t,++e):void this._state.toggleState(ue.FETCHING_AD,!1)}}else this._state.toggleState(ue.FETCHING_AD,!1);else this._state.toggleState(ue.FETCHING_AD,!1)}skipAdsOnSeek(t){if(!this._schedule)return;let e=this._schedule.getNextAd();for(;e&&e.time<t;)this._schedule.increment(),e=this._schedule.getNextAd()}async setCurrentTime(t,e=!1,s=!1){if(!this._schedule)return;if(!this.adapter.isReady())return;if(this._state.hasAny(ue.FETCHING_AD))return;if(this._state.hasAny(ue.PLAYING)&&this.adapter.isLinearAd())return;const i=0===t&&0===this._schedule.getNextIndex();try{if(s&&!this.opts.show_all_ads_on_seek&&this.skipAdsOnSeek(t),this._state.hasAny(ue.AD_AVAILABLE)||await this.fetchNextAd(t),!this._state.hasAny(ue.AD_AVAILABLE)||!this.shallPlayAd(t)||e)return;await this.playAd(),await this.setCurrentTime(t),this.checkIfBreakComplete()}catch(t){xe("setCurrentTime: Error(from: setCurrentTime, message: %s)",t.message)}finally{i&&this.trigger(I)}}async playAd(){var t;if(!this._state.hasAny(ue.AD_AVAILABLE))return;this._state.toggleState(ue.AD_AVAILABLE,!1),this._state.toggleState(ue.BREAK_ACTIVE,!0);const e=null===(t=this._schedule)||void 0===t?void 0:t.getCurrentAd();try{await this.adapter.playAd()}catch(t){console.error("Ads.playAd: error",t)}finally{e&&this.setLastAd(e)}}checkIfBreakComplete(){if(!this._state.hasAny(ue.BREAK_ACTIVE))return xe("Ads.checkIfBreakComplete(:bail, ad: %o)",this.getLastAd());xe("Ads.checkIfBreakComplete(:run, ad: %o)",this.getLastAd()),this._state.toggleState(ue.BREAK_ACTIVE,!1),this.adapter.isAdPod()||this.trigger(k)}resetScheduleCounter(){this._schedule&&this._schedule.resetCounter()}setSchedule(t,e){if(e&&!isNaN(e)&&this._schedule&&this._schedule.updateContentDuration(e),this._schedule&&this._schedule.getNextIndex()>0)return this._schedule.setAds(t);this._schedule=new Schedule(t,{preload_advance:this.opts.preload_advance,content_duration:e?0:e})}toJSON(){return this._schedule?this._schedule.toJSON():[]}trigger(t,e={}){var s;if(!this.adapter.getVideoTag())return;if(!this._state)return;if(t===k&&this._state.hasAny(ue.BREAK_ACTIVE)&&!this.adapter.isAdPod()&&!e.force)return xe("skipping AD_BREAK_COMPLETE reason: %s pod=%s",this._state.toString(),this.adapter.isAdPod());if(null===(i=e)||"object"!=typeof i||le(i)!==de)return this.dispatch(t,e);var i;const r=Object.assign({},this.adapter.getOpts()||{},(null===(s=this._schedule)||void 0===s?void 0:s.getCurrentAd())||{},{ad_type:this.ad_type},e);return this.dispatch(t,r)}dispatch(t,e){const s=this.adapter.getVideoTag();if(s){xe(":dispatch",t,e),this.adapter.isAdPod()&&"object"==typeof e&&"time"in e&&"preroll"!==e.ad_type&&(e.time=this.adapter.getAdBreakTime());try{const i={event:"ads/"+t,detail:{outstream:e.outstream,ad_type:e.ad_type,ad_break_time:e.time,ad_remaining_seconds:e.remaining,ad_muted:e.muted,ad_duration_seconds:e.duration,ad_error_reason:e.reason,ad_vast_error:e.vast_error,ad_vast_error_type:e.vast_error_type,ad_request_load_type:e.request_load_time}};s.dispatchEvent(new CustomEvent("health:record",{detail:i}))}catch(t){xe(":error",t)}ct(s,t,e),this.emit(t,e)}}get ad_type(){if(!this.videoTag)return;if(!this.adapter.isAdPod())return this._schedule&&this._schedule.getCurrentType();const t=this.adapter.getAdBreakTime();return-1===t?"postroll":this.videoTag.hasState(nt)||t<1?"preroll":"midroll"}shouldRestartContent(){if(this.getIsContentProcessingNewSrc())return!1;if(this.adapter.isAdPod())return!0;const t=this.getLastAd();return!t||!t.outstream&&!1!==t.restart}async finished(t){if(this._schedule&&(xe("Ads.finished"),!(this.adapter.isCustomPlaybackEnabled()&&this._state.hasAny(ue.PLAYING)&&this.adapter.isLinearAd()))){xe("Ads.finished: trying to play postroll");try{if(!this._schedule.getPostroll())return xe("Ads.finished: no postroll found"),await this.adapter.contentComplete();this._state.hasAny(ue.AD_AVAILABLE)||await this.fetchNextAd(-1),await this.playAd(),this.adapter.contentComplete()}catch(t){xe("Ads.finished: postroll failed:",t)}finally{this.trigger(D),this.checkIfBreakComplete(),"function"==typeof t&&t()}}}hasPreroll(){return this._schedule&&Schedule.hasPreroll(this._schedule.getAds())}shallPlayAd(t){var e;return(!this.adapter||!this.adapter.isAdPod())&&(!(!this._state||this._state.hasAny(ue.FATAL_ERROR))&&!!(null===(e=this._schedule)||void 0===e?void 0:e.shallPlayAd(t)))}setLastAd(t){return this._lastAd=t,this}setIsContentProcessingNewSrc(t){this.content_processing_src=t}getLastAd(){return this._lastAd}getIsContentProcessingNewSrc(){return this.content_processing_src}mergeMacros(t={}){return this._macros=this._macros.fork(Object.assign({},t)),this}get paused(){return this.adapter&&this.adapter.isPaused()}pause(){this.adapter&&this.adapter.pause()}resume(){this.adapter&&this.adapter.resume()}resize(t){this.adapter&&this.adapter.onResize(t)}async requestAd(t,e=0,s=this.opts.timeout){if(!this._state)return;xe("Ads.requestAd(ad: %o)",{ad:t,timeout:s,idx:e});const i=await oe(t);if(void 0===i[e])return setTimeout(()=>this.trigger(_),0),Promise.reject(new Error("Ad failed, no fallbacks left"));if(!i[e])return await this.requestAd(i,e+1,s);this.trigger(y,t);const r=this._macros.compile(i[e],re(this.opts,this.adapter.getDimensions()));try{return void await this.adapter.initAd(r,s)}catch(t){return xe(`Ads.requestAd(:fallback, idx: ${e}, length: ${i.length}, adTag: ${i[e]})\nError `,{adTag:i,err:t}),this.requestAd(i,e+1,s)}}resetSchedule(t){this._schedule&&this._schedule.reset(t)}get adPlaying(){return this._state&&this._state.hasAny(ue.PLAYING)}get adBreak(){return this._state&&this._state.hasAny(ue.BREAK_ACTIVE)}get adRequesting(){return this._state.hasAny(ue.FETCHING_AD)}get adLinear(){return this.adBreak&&this.adapter.isLinearAd()}}var Be=new Blob([new Uint8Array([255,227,24,196,0,0,0,3,72,1,64,0,0,4,132,16,31,227,192,225,76,255,67,12,255,221,27,255,228,97,73,63,255,195,131,69,192,232,223,255,255,207,102,239,255,255,255,101,158,206,70,20,59,255,254,95,70,149,66,4,16,128,0,2,2,32,240,138,255,36,106,183,255,227,24,196,59,11,34,62,80,49,135,40,0,253,29,191,209,200,141,71,7,255,252,152,74,15,130,33,185,6,63,255,252,195,70,203,86,53,15,255,255,247,103,76,121,64,32,47,255,34,227,194,209,138,76,65,77,69,51,46,57,55,170,170,170,170,170,170,170,170,170,170,255,227,24,196,73,13,153,210,100,81,135,56,0,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170])],{type:"audio/mpeg"}),je=new Blob([new Uint8Array([0,0,0,28,102,116,121,112,105,115,111,109,0,0,2,0,105,115,111,109,105,115,111,50,109,112,52,49,0,0,0,8,102,114,101,101,0,0,2,239,109,100,97,116,33,16,5,32,164,27,255,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,55,167,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,112,33,16,5,32,164,27,255,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,55,167,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,112,0,0,2,194,109,111,111,118,0,0,0,108,109,118,104,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,232,0,0,0,47,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,1,236,116,114,97,107,0,0,0,92,116,107,104,100,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,47,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,36,101,100,116,115,0,0,0,28,101,108,115,116,0,0,0,0,0,0,0,1,0,0,0,47,0,0,0,0,0,1,0,0,0,0,1,100,109,100,105,97,0,0,0,32,109,100,104,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,172,68,0,0,8,0,85,196,0,0,0,0,0,45,104,100,108,114,0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0,0,0,1,15,109,105,110,102,0,0,0,16,115,109,104,100,0,0,0,0,0,0,0,0,0,0,0,36,100,105,110,102,0,0,0,28,100,114,101,102,0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1,0,0,0,211,115,116,98,108,0,0,0,103,115,116,115,100,0,0,0,0,0,0,0,1,0,0,0,87,109,112,52,97,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,2,0,16,0,0,0,0,172,68,0,0,0,0,0,51,101,115,100,115,0,0,0,0,3,128,128,128,34,0,2,0,4,128,128,128,20,64,21,0,0,0,0,1,244,0,0,1,243,249,5,128,128,128,2,18,16,6,128,128,128,1,2,0,0,0,24,115,116,116,115,0,0,0,0,0,0,0,1,0,0,0,2,0,0,4,0,0,0,0,28,115,116,115,99,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,2,0,0,0,1,0,0,0,28,115,116,115,122,0,0,0,0,0,0,0,0,0,0,0,2,0,0,1,115,0,0,1,116,0,0,0,20,115,116,99,111,0,0,0,0,0,0,0,1,0,0,0,44,0,0,0,98,117,100,116,97,0,0,0,90,109,101,116,97,0,0,0,0,0,0,0,33,104,100,108,114,0,0,0,0,0,0,0,0,109,100,105,114,97,112,112,108,0,0,0,0,0,0,0,0,0,0,0,0,45,105,108,115,116,0,0,0,37,169,116,111,111,0,0,0,29,100,97,116,97,0,0,0,1,0,0,0,0,76,97,118,102,53,54,46,52,48,46,49,48,49])],{type:"video/mp4"});function qe(t){return Object.assign({muted:!1,timeout:250,inline:!1},t)}function He(t,e){var s=t.muted,i=t.timeout,r=t.inline,a=e(),n=a.element,o=a.source,d=void 0,l=void 0,c=void 0;return n.muted=s,!0===s&&n.setAttribute("muted","muted"),!0===r&&n.setAttribute("playsinline","playsinline"),n.src=o,new Promise(function(t){d=n.play(),l=setTimeout(function(){c(!1,new Error("Timeout "+i+" ms has been reached"))},i),c=function(e){var s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;n.remove(),n.srcObject=null,clearTimeout(l),t({result:e,error:s})},void 0!==d?d.then(function(){return c(!0)}).catch(function(t){return c(!1,t)}):c(!0)})}var Ve={audio:function(t){return He(t=qe(t),function(){return{element:document.createElement("audio"),source:URL.createObjectURL(Be)}})},video:function(t){return He(t=qe(t),function(){return{element:document.createElement("video"),source:URL.createObjectURL(je)}})}};let ze;async function Ge(t=!0){return ze||(ze=await Ve.video({timeout:500,muted:t}),ze)}var We=Object.freeze({__proto__:null,STICKY_CONTROLS:1,NO_FULLSCREEN:2,NO_AD_INDICATOR:4,AD_ATTRIBUTION:8,AD_CHOICES:16,REMAINING_TIME:32,VOLUME_BAR:64});const Qe=["progress","duration","remaining"];class AdUI extends HTMLElement{static get observedAttributes(){return Qe}constructor(t){super(),this.player=t,this.className="fp-ad-ui",this.append(...t.createComponents(Et,St)),t.on(Q,t=>{let{ui_flags:e}=t.detail;if(e=e||0,(8&e)>0){const t=document.createElement("div");t.classList.add("ad-attribution"),t.textContent=this.player.i18n("ads.advertisement","Advertisement"),this.append(t)}})}}const $e=yt("fpads:native:outstream"),Ke={OUTSTREAM:"is-outstream",HIDDEN:"is-outstream-hidden",SHOWING:"is-outstream-visible",DONE:"is-outstream-done"};var Ye,Ze;!function(t){t.OUTSTREAM_VISIBLE="ads-outstream-visible",t.OUTSTREAM_VIEWPORT_UPDATE="ads-outstream-viewport-update",t.OUTSTREAM_TEARDOWN="ads-outstream-teardown",t.OUTSTREAM_ENDSCREEN_READY="ads-outstream-endscreen-ready"}(Ye||(Ye={})),function(t){t[t.None=0]="None",t[t.Booting=1]="Booting",t[t.Ready=2]="Ready",t[t.Disposed=3]="Disposed"}(Ze||(Ze={}));class Outstream{constructor({ads:t,root:e,content:s,ima:i}){this.state=Ze.None,$e("creating Outstream instance"),this.content=s,this.ads=t,this.root=e,this.ima=i,this.aspectRatio=s.videoHeight/s.videoWidth,this.dimensions=function(t){if(t.clientWidth>0||t.clientHeight)return h(t);const e={height:t.style.height};p(t,"opacity",0),p(t,"display","absolute"),p(t,"display","inline-block"),p(t,"height","auto");const s=h(t);return p(t,"height",e.height),p(t,"opacity",1),s}(this.root),this.adUi=new AdUI(s),this.initialVolumeState={},e.classList.add(Ke.OUTSTREAM),e.append(this.adUi),this.hide(),this.ads.on(b,t=>{var e;if(this.state==Ze.Disposed)return;const s=!!(null===(e=t.detail)||void 0===e?void 0:e.linear);this.ads.resize(Object.assign(Object.assign({},this.dimensions),{linear:s}))}),s.on(Y,t=>{if(this.state==Ze.Disposed)return;const e=t.detail;e&&(this.dimensions={width:e.contentRect.width,height:e.contentRect.height},this.ads.resize(this.dimensions))});let r=1,a=!0;s.on("intersectionchange",t=>{if(this.state==Ze.Disposed)return;const e=t.detail;if(e)switch(this.state){case Ze.Booting:return $e(":boot skipping intersectionchange");case Ze.None:return this.state=Ze.Booting,this.begin_life_cycle();case Ze.Ready:if(r=e.ratio,e.ratio>=.5&&this.ads.adPlaying)return;e.ratio>=.5&&a&&this.ads.resume(),e.ratio<.5&&this.ads.pause()}}),this.content.on(S,()=>a=r<.5),this.setup(),setTimeout(()=>(this.state=Ze.Booting,this.begin_life_cycle()),0)}hide(){return this}restore_aspect_ratio(){return $e(`Outstream.restore_aspect_ratio(${this.aspectRatio})`),this.content.setOpts({ratio:this.aspectRatio}),this}show(){this.root.classList.remove(Outstream.CLASS.HIDDEN),this.root.classList.add(Outstream.CLASS.SHOWING),this.content.setState("ad-linear",!0)}async begin_life_cycle(){var t;this.state=Ze.Ready;const{error:e,result:s}=await Ge(!1),{result:i}=await Ge(!0);this.content.emit(Q,{ui_flags:null===(t=this.content.opts.ads)||void 0===t?void 0:t.ui}),this.attach_ad_listeners(),this.initialVolumeState={can_autoplay:!(!s&&!i),muted:!s},$e(`Outstream.show() :autoplay >> sound=${s}`),e&&this.content&&!s&&(this.content.muted=!0,this.content.volume=0),await this.ads.setVideoTag(this.content),await Dt({ads:this.ads,content:this.content,adContainer:this.adUi,ima:this.ima,state:{listening:!1},config:this.content.opts}),xt({content:this.content,ads:this.ads}),this.state=Ze.Ready}attach_ad_listeners(){this.ads.once(b,()=>{this.show(),this.ads.adPlaying&&this.ads.pause()});const t=()=>{Pt.forEach(e=>this.ads.removeListener(e,t));const e=new CustomEvent(Ye.OUTSTREAM_TEARDOWN);$e("Outstream(:teardown)",e),this.content.dispatchEvent(e)};Pt.forEach(e=>this.ads.once(e,t)),this.content.once(Ye.OUTSTREAM_TEARDOWN,t=>{setTimeout(()=>{if(t.defaultPrevented)return this.handle_endscreen();this.dispose()},0)})}handle_endscreen(){this.reset_ui(),this.ads.reset(),Nt({config:this.content.opts,ui:this.adUi,ads:this.ads,adContainer:this.adUi,ima:this.ima,content:this.content,root:this.content.root,state:{started:!0,listening:!1},initial:{muted:!0,volume:1}})}empty_src(){this.content.setSrc({type:"video/mp4",src:URL.createObjectURL(Lt)})}setup(){this.root.classList.add(Outstream.CLASS.OUTSTREAM),this.root.classList.add(Outstream.CLASS.HIDDEN),this.content.setState("ad-linear",!1),this.empty_src()}reset_ui(){const t=this.root;t.classList.remove(Outstream.CLASS.SHOWING),t.classList.remove(Outstream.CLASS.OUTSTREAM)}dispose(){if(this.state==Ze.Disposed)return;const t=this.root,e=this.content;this.reset_ui(),t.classList.add(Outstream.CLASS.OUTSTREAM),t.classList.add(Outstream.CLASS.DONE);const s=this;s.video=s.container=s.ads=0,this.state=Ze.Disposed,e.destroy(),t.innerHTML=""}}function Je(t){return t&&"number"==typeof t.time}function Xe(t){return t&&"number"==typeof t.percentage&&"number"!=typeof t.time}Outstream.CLASS=Ke;const ts=yt("ads/ima/sdk");var es,ss;async function is(t,e){var s;const i=null===(s=null===window||void 0===window?void 0:window.google)||void 0===s?void 0:s.ima;if(e?null==i?void 0:i.dai:i)return void ts(":noop");const r=e?"https://imasdk.googleapis.com/js/sdkloader/ima3_dai.js":t._storage.getItem("ima/debug")?"https://imasdk.googleapis.com/js/sdkloader/ima3_debug.js":"https://imasdk.googleapis.com/js/sdkloader/ima3.js";try{return await async function(t){return new Promise((e,s)=>{let i=document.querySelector(`script[src='${t}']`);if(i)return rs(i,e,s);i=document.createElement("script"),i.setAttribute("state",es.LOADING),rs(i,e,s),i.src=t,document.head.appendChild(i)})}(r),void ts(":loaded")}catch(t){ts(`:error ${t.message}`,t)}}function rs(t,e,s){const i=t.getAttribute("state");if(i&&[es.ERROR,es.LOADED].includes(i))return e(void 0);t.addEventListener("load",()=>{t.setAttribute("state",es.LOADED),e(void 0)},{once:!0}),["error","abort"].forEach(e=>{t.addEventListener(e,()=>{t.setAttribute("state",es.ERROR),s("script failed to load")},{once:!0})})}!function(t){t.LOADING="loading",t.LOADED="loaded",t.ERROR="error"}(es||(es={})),function(t){t.LOADING="loading",t.LOADED="loaded",t.ERROR="error"}(ss||(ss={}));const as=yt("ads/ima/sdk"),ns="https://cdn.jsdelivr.net/npm/prebid.js@latest/dist/not-for-prod/prebid.js",os=ns;async function ds(t){var e;const s=t._storage.getItem("prebid/debug")?ns:os;if(null===(e=null===window||void 0===window?void 0:window.pbjs)||void 0===e?void 0:e.version)as(":noop");else if(!document.querySelector(`script[src='${s}']`))try{return await async function(t){return new Promise((e,s)=>{let i=document.querySelector(`script[src='${t}']`);i||(i=document.createElement("script")),i.setAttribute("state",ss.LOADING);const r=i.getAttribute("state");if(r&&[ss.ERROR,ss.LOADED].includes(r))return e(void 0);i.addEventListener("load",()=>{i.setAttribute("state",ss.LOADED),e(void 0)},{once:!0}),["error","abort"].forEach(t=>{i.addEventListener(t,()=>{i.setAttribute("state",ss.ERROR),s("script failed to load")},{once:!0})}),i.src=t,document.head.appendChild(i)})}(s),void as(":loaded")}catch(t){console.warn(`:error / failed to load prebid.js / ${t.message}`,t)}}const ls=window.pbjs=window.pbjs||{};ls.que=ls.que||[];class PrebidAdController{constructor(t,e){this.player=t,this.config=e,this.player=t,this.bestOffer="",ls.que.push(()=>{var s,i;const r=this.createAdUnit();ls.addAdUnits(r);const a=(null===(i=null===(s=e.ads)||void 0===s?void 0:s.prebid)||void 0===i?void 0:i.pbjs)||{};ls.setConfig(Object.assign({enableSendAllBids:!0},a)),t.emit($,{pbjs:ls}),ls.requestBids({bidsBackHandler:t=>{var s,i,a,n,o;const d=null===(s=t[this.prebidCode()])||void 0===s?void 0:s.bids;if(!d)return;if(0==d.length)return;const l=d[0];if(l&&l.vastUrl)return this.bestOffer=l.vastUrl;const c=ls.adServers.dfp.buildVideoUrl({adUnit:r,params:{iu:null===(a=null===(i=e.ads)||void 0===i?void 0:i.prebid)||void 0===a?void 0:a.iu,cust_params:null===(o=null===(n=e.ads)||void 0===n?void 0:n.prebid)||void 0===o?void 0:o.custom_params,output:"vast"}});this.bestOffer=c}})})}prebidCode(){var t,e;return(null===(e=null===(t=this.config.ads)||void 0===t?void 0:t.prebid)||void 0===e?void 0:e.code)||this.player.root.id}videoInfo(){var t,e;return(null===(e=null===(t=this.config.ads)||void 0===t?void 0:t.prebid)||void 0===e?void 0:e.video)||{context:"instream",playerSize:[[this.player.videoWidth||640,this.player.videoHeight||480]]}}createAdUnit(){var t,e;return{code:this.prebidCode(),mediaTypes:{video:this.videoInfo()},bids:null===(e=null===(t=this.config.ads)||void 0===t?void 0:t.prebid)||void 0===e?void 0:e.bidders}}vastGenerator(){return async()=>this.bestOffer}}function cs(t,e){var s,i;const r=null===(s=e.ads)||void 0===s?void 0:s.prebid;if(!r)return;if((null===(i=t.prebidController)||void 0===i?void 0:i.config)===e)return;!function(t,{feature_name:e,behavior:s,sample_rate:i}){e&&(i||(i=_t),t.emit("flowplayer:feature",{feature_name:e,behavior:s,sample_rate:i}))}(t,{feature_name:"prebid",behavior:"used"}),t.prebidController||(t.prebidController=new PrebidAdController(t,e),ds(t));const a=t.prebidController;if(a){const e=r.breaks.map(t=>({adTag:a.vastGenerator(),time:t}));t.setOpts({ima:{ads:e}})}}const us=yt("ads/index");async function hs(t,e,s){var i;let r;if(s.on("config",()=>{var e,i,a;void 0===r&&t.autoplay&&(Gt(a=t.ima)&&(null==a?void 0:a.ads.find(t=>!t.time||"percentage"in t&&0===t.percentage)))&&!s.currentSrc&&(i=t.autoplay,r=!0===i?ut.ON:!1===i?ut.OFF:i,t.autoplay=0),(null===(e=t.ads)||void 0===e?void 0:e.prebid)&&cs(s,t),Gt(t.ima)&&zt(s)&&Object.assign(t,{hls:{native:!0}}),s.ads&&d()}),s.once("loadstart",()=>{setTimeout(async()=>{if(void 0!==r&&(await is(s),!("google"in window))){if(t.autoplay=r,s.setState(dt,!0),!s.hasState(lt))return s.once(st,()=>s.togglePlay(!0));s.togglePlay(!0)}},0)}),await is(s),!("google"in window))return console.warn("google.ima unavailable");let a=!1;const n=s.ads=new AdsController,o=n.analytics;function d(){if(!Gt(t.ima))return;const i=t.ima,d=t.duration||s.duration;if(i.ads=function(t,e){return Array.isArray(t)?t.filter(t=>Je(t)||Xe(t)).reduce((t,s)=>{if(Je(s))return t.push(s),t;if(s.lazy)return t.push(s),t;if(Xe(s)){const i=Object.assign({},s),r=s.percentage?s.percentage*e:0;return isNaN(r)||(i.time=r<0||r===e?-1:r),t.push(i),t}return t},[]):(console.warn("AdSchedule was not an Array"),[])}(i.ads,d),n.setSchedule(i.ads,d),t.metadata&&Analytics.mergeMetadata(o,t.metadata),t.metadata&&n.mergeMacros(t.metadata),t.metadata&&i.parameters&&(i.parameters=Object.assign(Object.assign({},i.parameters),t.metadata)),Analytics.mergeMetadata(o,{muted:t.muted||!1,autoplay:t.autoplay||!1}),!a){if(a=!0,t.lang&&!i.Locale&&(i.Locale=t.lang),Schedule.isOutstream(i.ads))return us("is outstream, returning"),new Outstream({root:e,content:s,ads:n,ima:i});kt({config:Object.assign(Object.assign({},t),{autoplay:r}),root:e,content:s,ads:n,ima:i})}}n.resize(h(e)),n.on(D,()=>{n.adapter.isCustomPlaybackEnabled()&&n.once(k,()=>{s.src=s.original_src,s.once("canplay",()=>{s.togglePlay(!1)}),s.webkitExitFullscreen()})}),s.on("reap",function(){n&&n.destroy()}),(null===(i=t.ads)||void 0===i?void 0:i.prebid)&&cs(s,t),d()}class AdControls extends HTMLElement{constructor(t){super(),this.player=t,this.classList.add("fp-ad-controls"),this.append(this.adRemainingTime(),At(this.player,Tt),this.playbackButtons(),this.volumeBtn(),At(this.player,"flowplayer-volume-bar"),...this.fullscreenIcons(),this.adChoices()),t.on(Q,this.applyStyleFlags.bind(this))}fullscreenIcons(){return this.player.createComponents("flowplayer-fullscreen-enter-icon","flowplayer-fullscreen-exit-icon").map(t=>(t.onclick=()=>this.player.toggleFullScreen(),t))}volumeBtn(){const t=At(this.player,"flowplayer-volume-icon");return t.onclick=()=>this.player.emit(z),t}playbackButtons(){const t=document.createElement("div");t.classList.add("ad-playback-controls");const e=At(this.player,"flowplayer-small-play-icon"),s=At(this.player,"flowplayer-small-pause-icon");return e.addEventListener("click",()=>{this.player.emit(V),setTimeout(function(){s.focus&&s.focus()},100)}),s.addEventListener("click",()=>{this.player.emit(H),setTimeout(function(){e.focus&&e.focus()},100)}),t.append(e,s),t}adChoices(){const t=document.createElement("div");return t.classList.add("fp-ad-choices"),t.textContent=this.player.i18n("ads.adchoices","AdChoices"),t.addEventListener("click",t=>{t.preventDefault(),this.player.togglePlay(!1),window.open("https://adssettings.google.com","_blank")}),t}adRemainingTime(){const t=document.createElement("div");return t.classList.add("fp-ad-remaining","fp-color-text"),this.prepend(t),this.player.on(L,e=>{const s=e.detail.remaining;t.textContent=function(t){if(isNaN(t)||t>=Number.MAX_SAFE_INTEGER)return"";const e=t<0?"-":"";t=Math.round(Math.abs(t));const s=Math.floor(t/3600);let i=Math.floor(t/60);return t-=60*i,s>=1?(i-=60*s,e+s+":"+ht(i)+":"+ht(t)):e+ht(i)+":"+ht(t)}(parseFloat(s+""))}),t}applyStyleFlags(t){var e;const s=null!==(e=t.detail.ui_flags)&&void 0!==e?e:0;this.classList.toggle("is-ad-controls-sticky",(1&s)>0),this.classList.toggle("no-indicator",(4&s)>0),this.classList.toggle("is-ad-choices",(16&s)>0),this.classList.toggle("no-volume-bar",!(64&s)),this.classList.toggle("is-ad-remaining",(32&s)>0),this.classList.toggle("no-fullscreen",(2&s)>0)}}class AdCountdown extends HTMLElement{static get observedAttributes(){return["remaining"]}constructor(t){super(),this.player=t,this.className="fp-ad-countdown",t.on(L,t=>{const{duration:e,remaining:s}=t.detail;this.setAttribute("duration",e+""),this.setAttribute("remaining",s+"")}),t.on(w,t=>{t.detail.linear&&(this.style.setProperty("--ad-percent-previous","0"),this.style.setProperty("--ad-percent-complete","0"))}),this.addEventListener("animationend",()=>{const t=this.style.getPropertyValue("--ad-percent-complete")||"0";this.style.setProperty("--ad-percent-previous",t)})}attributeChangedCallback(t,e,s){if("remaining"===t)return this.onRemaining(s)}onRemaining(t){const e=parseFloat(this.getAttribute("duration")||"0");t||(t=e+"");const s=parseFloat(t),i=this.style.getPropertyValue("--ad-percent-complete")||"0";this.style.setProperty("--ad-percent-previous",i),this.classList.remove("go");const r=((e-s)/e*100).toFixed(3);requestAnimationFrame(()=>{this.style.setProperty("--ad-percent-complete",r),this.classList.add("go")})}}class AdIndicator extends HTMLElement{static get observedAttributes(){return["position","totals"]}constructor(t){super(),this.player=t,this.render(),t.on(w,t=>{const{position:e,totals:s}=t.detail.ad;this.setAttribute("position",e+""),this.setAttribute("totals",s+"")})}attributeChangedCallback(t,e){switch(t){case"position":case"totals":return this.updateText()}}updateText(){if(!this.element)return;const t=parseFloat(this.getAttribute("position")||"0"),e=parseFloat(this.getAttribute("totals")||"0");this.element.textContent=`${this.player.i18n("ads.indicator","ADS")} ${t} / ${e}`}render(){this.element=document.createElement("div"),this.element.classList.add("ad-indicator","fp-color-text"),this.element.textContent=this.player.i18n("ads.indicator","ADS"),this.append(this.element)}}var ps,gs=Object.freeze({__proto__:null,SINGlE_INLINE_LINEAR:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_ad_samples&sz=640x480&cust_params=sample_ct%3Dlinear&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator=",SINGLE_SKIPPABLE_INLINE:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_preroll_skippable&sz=640x480&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator=",SINGLE_REDIRECT_LINEAR:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_ad_samples&sz=640x480&cust_params=sample_ct%3Dredirectlinear&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator=",SINGLE_REDIRECT_ERROR:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_ad_samples&sz=640x480&cust_params=sample_ct%3Dredirecterror&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator=",SINGLE_REDIRECT_BROKEN:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_ad_samples&sz=640x480&cust_params=sample_ct%3Dredirecterror&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&nofb=1&correlator=",SINGLE_VPAID_20_LINEAR:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_ad_samples&sz=640x480&cust_params=sample_ct%3Dlinearvpaid2js&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator=",SINGLE_VPAID_20_NON_LINEAR:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_ad_samples&sz=640x480&cust_params=sample_ct%3Dnonlinearvpaid2js&ciu_szs=728x90%2C300x250&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator=",SINGLE_NON_LINEAR_INLINE:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/nonlinear_ad_samples&sz=480x70&cust_params=sample_ct%3Dnonlinear&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator=",VMAP_SESSION_AD_RULE_PREROLL:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/vmap_ad_samples&sz=640x480&cust_params=sar%3Da0f2&ciu_szs=300x250&ad_rule=1&gdfp_req=1&output=vmap&unviewed_position_start=1&env=vp&impl=s&correlator=",VMAP_PREROLL:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/vmap_ad_samples&sz=640x480&cust_params=sample_ar%3Dpreonly&ciu_szs=300x250%2C728x90&gdfp_req=1&ad_rule=1&output=vmap&unviewed_position_start=1&env=vp&impl=s&correlator=",VMAP_PREROLL_BUMPER:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/vmap_ad_samples&sz=640x480&cust_params=sample_ar%3Dpreonlybumper&ciu_szs=300x250&gdfp_req=1&ad_rule=1&output=vmap&unviewed_position_start=1&env=vp&impl=s&correlator=",VMAP_POSTROLL:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/vmap_ad_samples&sz=640x480&cust_params=sample_ar%3Dpostonly&ciu_szs=300x250&gdfp_req=1&ad_rule=1&output=vmap&unviewed_position_start=1&env=vp&impl=s&correlator=",VMAP_POSTROLL_BUMPER:"https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/vmap_ad_samples&sz=640x480&cust_params=sample_ar%3Dpostonlybumper&ciu_szs=300x250&gdfp_req=1&ad_rule=1&output=vmap&unviewed_position_start=1&env=vp&impl=s&correlator="});const{samsung_tv:ms}=u(),_s=(ps=class Ads{constructor(t){this.umd=t,bt(t,wt,AdUI),bt(t,Et,AdControls),bt(t,St,AdCountdown),bt(t,Tt,AdIndicator)}init(t,e,s){if(c.from_token(t.token||"").is_granted(c.permissions.ADS)&&!ms)return hs(t,e,s)}},ps.pluginName="ads",ps.events=K,ps.ui=We,ps.tags=gs,ps);return function(t,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;if(null===document.currentScript)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});const s=t.flowplayer;return"function"==typeof s?(s(e),e):(Array.isArray(s.extensions)||(s.extensions=[]),~s.extensions.indexOf(e)||s.extensions.push(e),e)}(window,_s)});