@flowplayer/player 3.2.2 → 3.2.4

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/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Level, MediaKeyFunc } from "hls.js"
2
- import {AnyPlugin, Loader, Plugin, PluginCtor} from "./plugin"
2
+ import {Loader, Plugin, PluginCtor} from "./plugin"
3
3
 
4
4
 
5
5
 
@@ -30,9 +30,8 @@ export declare namespace Flowplayer {
30
30
  & T
31
31
  export type UnsafeSource =
32
32
  | SourceStr
33
- | SourceStr[]
34
33
  | SourceObj
35
- | SourceList
34
+ | Array<SourceStr|SourceObj>
36
35
  export type SourceList =
37
36
  | Array<SourceObj>
38
37
  export type DRMConfiguration = {
@@ -162,7 +161,7 @@ export declare namespace Flowplayer {
162
161
  <T>(selector : string, config? : CustomConfig<T>): Player;
163
162
  (element : HTMLElement, config? : Config): Player;
164
163
  <T>(element : HTMLElement, config? : CustomConfig<T>): Player;
165
- (...plugins : AnyPlugin[]): void;
164
+ (...plugins : PluginCtor[]): void;
166
165
  instances: Player[];
167
166
  extensions: PluginCtor[];
168
167
  events: Record<string, string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowplayer/player",
3
- "version": "3.2.2",
3
+ "version": "3.2.4",
4
4
  "description": "video player for the future",
5
5
  "license": "https://flowplayer.com/commercial-license",
6
6
  "main": "default.js",
@@ -52,6 +52,7 @@
52
52
  "flowplayer.css",
53
53
  "core/events.d.ts",
54
54
  "index.d.ts",
55
+ "plugin.d.ts",
55
56
  "util/loader.d.ts"
56
57
  ]
57
58
  }
package/plugin.d.ts ADDED
@@ -0,0 +1,31 @@
1
+ import { Config
2
+ , Player
3
+ , PlayerRoot
4
+ , SourceObj
5
+ , SourceStr
6
+ , FlowplayerUMD
7
+ , PluginConfig,
8
+ SourceWith
9
+ } from "."
10
+
11
+ export interface Plugin {
12
+ /**
13
+ * a plugin must always implement the init method so a player instance knows how to initialize it
14
+ */
15
+ init<T> (config : PluginConfig<T>, container : PlayerRoot, player : Player): void;
16
+ init (config : Config, container : PlayerRoot, player : Player): void;
17
+ }
18
+
19
+ export interface Loader extends Plugin {
20
+ onload<T = Record<string, any>> (config : PluginConfig<T>, root : PlayerRoot, video : Player, src? : SourceObj): void;
21
+ wants<S = SourceObj, T = Record<string, any>> (srcString : SourceStr, srcObj : S, config : PluginConfig<T>): boolean;
22
+ wants<S = Record<string, any>, T = Record<string, any>> (srcString : SourceStr, srcObj : SourceWith<S>, config : PluginConfig<T>): boolean;
23
+ }
24
+
25
+ export interface PluginCtor {
26
+ new (umd : FlowplayerUMD, player : Player): AnyPlugin
27
+ }
28
+
29
+ export type AnyPlugin =
30
+ | Plugin
31
+ | Loader
package/plugins/ads.js CHANGED
@@ -1,22 +1,7 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.ads=t())}(this,(function(){"use strict";var e;!function(e){e[e.ADS=2]="ADS",e[e.ANALYTICS=4]="ANALYTICS",e[e.NO_METERING=8]="NO_METERING",e[e.DEVELOPER_PLAN=16]="DEVELOPER_PLAN"}(e||(e={}));const t=["localhost","127.0.0.1","0.0.0.0","s.codepen.io","cdpn.io","try.flowplayer.com"];function s(e,s){return!!~t.indexOf(e)||e.indexOf(s)===e.length-s.length}s.check_whitelist=function(e){return!!~t.indexOf(e)};function i(e){this.message=e}i.prototype=new Error,i.prototype.name="InvalidCharacterError";var r="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.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=t.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(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(r(e).replace(/(.)/g,(function(e,t){var s=t.charCodeAt(0).toString(16).toUpperCase();return s.length<2&&(s="0"+s),"%"+s})))}(t)}catch(e){return r(t)}};function n(e){this.message=e}n.prototype=new Error,n.prototype.name="InvalidTokenError";var o=function(e,t){if("string"!=typeof e)throw new n("Invalid token specified");var s=!0===(t=t||{}).header?0:1;try{return JSON.parse(a(e.split(".")[s]))}catch(e){throw new n("Invalid token specified: "+e.message)}};o.InvalidTokenError=n;const d="production";function l(e,t){const s={valid_jwt:!1,raw:"",data:{acl:0},exp:0};let i={c:"{}",exp:0};t=t||{};try{i=o(e),s.valid_jwt=!0}catch(e){}return s.raw=e,s.data=JSON.parse(i.c),s.exp=i.exp,t.require_valid_token&&l.validate(s),s}function c(e){return{grant:e,is_granted:t=>(e&t)===t}}function u(e){return{width:e.clientWidth,height:e.clientHeight}}function h(e,t,s){return"number"==typeof s&&(s+="px"),e.style.setProperty(t,s),e}l.validate=function(e){if("string"==typeof e&&(e=l(e)),!e||!e.raw){if(s.check_whitelist(window.location.hostname)||"dev"===d.toString())return!0;throw new Error("No token provided in configuration")}if(!e.valid_jwt)throw new Error("Invalid token provided");const t=window.location.hostname,i=s.bind(null,t);if("dev"!==d.toString()&&e.data.domain&&e.data.domain.length&&!e.data.domain.some(i))throw new Error("Domain not allowed");if("dev"!==d.toString()&&1e3*e.exp-Date.now()<0)throw new Error("Expired token");return!0},l.id=function(e){if(e)return"string"==typeof e&&(e=l(e)),e.data.id},c.of=c,c.from_token=function(e){const t=l(e,{require_valid_token:!0});return c.of(t.data.acl)},c.permissions=e;const p="ad-initialized";var g=Object.freeze({__proto__:null,AD_INIT:p,AD_PLAYBACK_ERROR:"ad-playback-error",AD_TEARDOWN:"ad-teardown",AD_VIDEOTAG_ATTACHED:"ad-videotag-attached",AD_BLOCKED:"ad-blocked",AD_REQUEST_ERROR:"ad-request-error",AD_REQUESTED:"ad-requested",AD_REQUEST_COMPLETED:"ad-request-completed",AD_PAUSE_CONTENT:"ad-pause-content",AD_STARTED:"ad-started",AD_COMPLETED:"ad-completed",AD_PAUSED:"ad-paused",AD_RESUMED:"ad-resumed",AD_WAITING:"ad-waiting",AD_PROGRESS:"ad-progress",AD_SKIPPED:"ad-skipped",AD_MUTED:"ad-muted",AD_VOLUME_CHANGED:"ad-volume-changed",AD_FULLSCREEN:"ad-fullscreen",AD_TIMEOUT:"ad-timeout",AD_BREAK_COMPLETED:"ad-break-completed",AD_POSTROLL_FINISHED:"ad-postroll-finished",AD_PREROLL_FINSIHED:"ad-preroll-finished",AD_MIDROLL_FINISHED:"ad-midroll-finished",VPAID_INIT:"vpaid-init",IMA_ADAPTER_INIT:"ad-ima-adapter-init",IMA_BEFORE_ADS_REQUEST:"ad-ima-before-ads-request",IMA_ADS_RENDERING_SETTINGS:"ad-ima-rendering-settings",ADAPTER_INIT_FAILED:"ad-adapter-init-failed",AD_PLAY_REQUESTED:"ad-play-requested",RELOAD_AD_REQUESTED:"reload-ad-requested",AD_ERROR:"ad-error",REQUEST_AD_PAUSE:"request/ad/pause",REQUEST_AD_PLAY:"request/ad/play",REQUEST_AD_MUTE_UNMUTE:"request/ad/muteunmute"});const m="undefined"!=typeof document&&"undefined"!=typeof window&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream;var _;function f(e,t){const s=function(){try{return localStorage.getItem("flowplayer/debug")}catch(e){return""}}(),i=(i,...r)=>{const a=(null==t?void 0:t.debug)||s;a&&e.match(a)&&console.log(`${e} -- ${i}`,...r)};return i.log=i,i}!function(e){e[e.OFF=0]="OFF",e[e.ON=1]="ON",e[e.AUDIO_REQUIRED=2]="AUDIO_REQUIRED"}(_||(_={}));const y=(e,t)=>new(((e,t)=>{const s=e.get(t);if(!s)throw new Error(`no flowplayer component with the name ${t} exists`);const i=window.customElements.get(t);if(!i)throw new Error(`no default flowplayer component with the name ${t} exists`);const r=window.customElements.get(s);return"function"!=typeof r?i:r})(e._customElements,t))(e),v=(e,t,s)=>{window.customElements.get(t)||window.customElements.define(t,s),e.customElements.get(t)||e.customElements.set(t,t)},A=f("ads/lifecycle"),w=["ad-playback-error","ad-teardown","ad-break-completed"];async function E({config:e,root:t,content:s,ads:i,ima:r}){A("LifeCycle::initLifeCycle",e,t,s,i,r),s.autoplay=!1;const a=e.autoplay===_.AUDIO_REQUIRED,n=function(e,t){return{muted:!(t||!e.muted),volume:e.volume}}(s,a);s.on("volumechange",()=>{n.volume=s.volume,n.muted=s.muted});const o=y(s,"flowplayer-ad-ui"),d=o.adContainer;t.append(o);const l={listening:!1,preload:null==r?void 0:r.preload_ads};if(A("initial",n),i.setVideoTag(s),e.autoplay){A("Trying to autoplay"),o.hideFirstFrame(t);await async function e(t,s){const[i,r]=[t.muted,t.volume];A("Lifecycle::peek_content(:muted => %s, :volume => %s)",i,r);const a=()=>new Promise(e=>setTimeout(e,0,!1));s&&(t.muted=!1,t.volume=t.volume?t.volume:1);try{return await async function(e){return A("Lifecycle::wait_for_source"),new Promise((t,s)=>{let i=0;const r=setInterval(()=>{if(++i>40)return clearInterval(r),s(new Error("No source in 2000ms, giving up"));e.currentSrc&&(t(null),clearInterval(r))},50)})}(t),t.volume&&(t.volume=.01),A("Lifecycle::peek_content::play"),await new Promise(e=>setTimeout(()=>e(t.togglePlay(!0)))),A("Lifecycle::peek_content::pause"),await new Promise(e=>setTimeout(()=>e(t.togglePlay(!1)))),t.volume=r,A("Lifecycle::peek_content::true"),!0}catch(n){return t.volume=r,s?(t.muted=!1,0==t.volume&&(t.volume=1),await a()):i||!r?(A("Lifecycle::peek_content::false"),await a()):(A("Lifecycle::peek_content::recover"),t.muted=!0,!!await e(t)||(t.muted=i,A("Lifecycle::peek_content::false"),await a()))}}(s,a)?(A("Can autoplay, start ad"),s.opts.autoplay=1,b({ads:i,content:s,state:l,adContainer:d,ima:r,config:e})):(A("cannot autoplay(audioRequired: %s), fallback to poster state",a),e.autoplay=0,o.showFirstFrame(t),s.setState("is-starting",!0))}e.autoplay||i.hasPreroll()&&function({content:e,ads:t,config:s,state:i,initial:r,adContainer:a,ima:n}){e.once("beforeplay",(async function(o){(e.hasState("is-in-viewport")||"touchend"!=o.type)&&t.shallPlayAd(0)&&(!m&&o.preventDefault(),O({ads:t,content:e,state:i}),A("user_gesture(:intercept) -> shallPlayAd(0: %s)",t.shallPlayAd(0)),s.muted=r.muted,await b({ads:t,content:e,state:i,adContainer:a,ima:n,config:s}),M({ads:t,content:e}))}))}({content:s,ads:i,config:e,state:l,initial:n,adContainer:d,ima:r}),!e.autoplay&&i.hasPreroll()&&l.preload&&b({ads:i,content:s,state:l,adContainer:d,ima:r,config:e}),L({config:e,root:t,content:s,ads:i,state:l,adContainer:d,ui:o,ima:r,initial:n}),s.on("src",()=>{s.once("beforeplay",()=>i.resetScheduleCounter())})}async function b(e){e.state.started||(e.content.hasState("is-in-viewport")?await T(e):e.content.once("viewenter",async()=>{await T(e)}))}async function T({ads:e,content:t,adContainer:s,ima:i,state:r,config:a}){var n;r.started=!0;const o=
2
- /*! *****************************************************************************
3
- Copyright (c) Microsoft Corporation.
4
-
5
- Permission to use, copy, modify, and/or distribute this software for any
6
- purpose with or without fee is hereby granted.
7
-
8
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
11
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
- PERFORMANCE OF THIS SOFTWARE.
15
- ***************************************************************************** */
16
- function(e,t){var s={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(s[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(s[i[r]]=e[i[r]])}return s}(i,["ads"]),d=u(t.root),l=(null==a?void 0:a.muted)||t.muted,c=Object.assign(Object.assign(Object.assign({container:s,volume:l?0:t.volume,muted:l,autoplay:(null==a?void 0:a.autoplay)||!1,video_source:t.original_src,DisableCustomPlaybackForIOS10Plus:m,preload_ads:null===(n=null==a?void 0:a.ima)||void 0===n?void 0:n.preload_ads},o),d));A("start():",c,r),await e.initialize(!1,c,r.preload)}function S(e,t){var s,i;return{content_width:e.clientWidth||(null===(s=e.parentNode)||void 0===s?void 0:s.clientWidth)||t.clientWidth,content_height:e.clientHeight||(null===(i=e.parentNode)||void 0===i?void 0:i.clientHeight)||t.clientHeight}}function L({config:e,root:t,content:s,ads:i,initial:r,adContainer:a,state:n,ui:o,ima:d}){A("addUIListeners()"),s.once("playing",async r=>{if(i){if(A("addUIListeners() -> content started playing"),O({ads:i,content:s,state:n}),!i.shallPlayAd(0)||!i.adapter.isLinearAd())return A("addUIListeners() -> no more preroll ads -> resume content"),await b({ads:i,content:s,state:n,adContainer:a,ima:d,config:e});s.togglePlay(!1),await b({ads:i,content:s,state:n,adContainer:a,ima:d,config:e}),i.shallPlayAd(0)&&i.adapter.isLinearAd()&&(o.classList.add("on","linear"),t.classList.add("is-waiting"),M({ads:i,content:s}))}}),s.on(["portrait","landscape"],(function(){if(!i)return;const{content_width:e,content_height:r}=S(s,t);i.resize({height:r,width:e})})),s.on("resize",e=>{if(!i||!e.detail)return;const{width:t,height:s}=e.detail.contentRect;i.resize({width:t,height:s})}),s.on("ended",e=>{var t;i&&(A("ui_listeners(:%s, event: %o)",e.type,e.detail),(null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.from)!==i&&(e.preventDefault(),Object.assign(e,{prevented_from_ads:!0}),i.finished((function(){s.emit("ended",{from:i})}))))}),i.on("ad-requested",()=>{t.classList.toggle("is-waiting",!0)}),i.once("ad-started",()=>{s.on(["beforeplay","beforepause"],e=>{var t;if(!i.adBreak||!i.adapter.isLinearAd())return;e.preventDefault();const s=(null===(t=e.detail)||void 0===t?void 0:t.forced)?"beforeplay"===e.type:!i.adPlaying;s&&i.paused&&i.resume(),s||i.paused||i.pause()})}),i.on("ad-started",e=>{const a=e.detail,{linear:n,ad:d,ad_type:l}=a;let c;if(A(`Ad[linear: ${n}, currentTime: ${s.currentTime}] starting`,d),"preroll"==l&&!n&&s.paused&&s.togglePlay(!0),"preroll"==l&&n&&s.currentTime>0&&!s.opt("start_time")&&!s.opt("live")&&(A("Preroll[rewind: true]",s.currentTime),s.currentTime=0),n&&(c=S(s,t)),i.resize({width:c?c.content_width:d.width,height:c?c.content_height:d.height,linear:n,resize_non_linear:!0}),o.resize({linear:n,resizeContainerAlso:!0,width:n?void 0:d.width,height:n?void 0:d.height}),t.classList.remove("is-waiting"),o.classList.add("on"),o.classList.toggle("linear",n),o.classList.toggle("non-linear",!n),!n){A("non-linear ad / restarting content");try{s.togglePlay(!0),s.volume=r.volume,s.muted=r.muted}catch(e){A(e)}}}),i.on("ad-pause-content",()=>{o.resize({linear:!0,width:0,height:0})}),s.on(w,e=>async function({root:e,content:t,ads:s,ui:i,eventName:r,err:a={reason:""}}){A("teardown(event: %s)",r),e.classList.add("is-seamless"),i.classList.remove("is-vpaid"),e.classList.remove("is-waiting"),a.reason&&A("teardown(:err, reason: %s) %o",a.reason);i.classList.remove("on");const n=s.getLastAd();if(i.showFirstFrame(e),!s.shouldRestartContent())return A("Lifecycle.teardown(:skip_restart, reason: %s)","Ad prevented restarting content"),R(e);if(t.currentTime>0&&t.currentTime>=t.duration||"postroll"==s.ad_type||!1===(null==n?void 0:n.restart))return A("Lifecycle.teardown(:skip_restart, reason: %s)","was a postroll ad"),R(e);""===t.currentSrc&&t.setSrc(t.original_src);t.paused&&s.shouldRestartContent()&&(A("Lifecycle.teardown(:toggle_play, %s)","attempting to restart content"),await t.togglePlay(!0));if(!t.paused)return A("Lifecycle.teardown(:ok)","restarted video content"),R(e)}({root:t,content:s,ads:i,ui:o,err:e.detail,eventName:e.type}));let l=!!e.autoplay;s.on("viewenter",()=>{l&&i.resume()}),s.on("viewleave",()=>{l=!i.paused,i.pause()})}function O({ads:e,content:t,state:s}){s.listening||(t.on(["timeupdate","seeked","playing","seeking"],s=>{e.adPlaying&&e.adapter.isLinearAd()&&!e.adapter.isSharedVideoTag()&&!t.paused&&t.pause(),M({ads:e,content:t,seek:"seeking"===s.type})}),s.listening=!0)}function M({ads:e,content:t,seek:s=!1}){e&&e.setCurrentTime(t.currentTime,void 0,s)}function R(e){e.classList.remove("is-seamless")}const P=f("ads/timers");class TimerRegistry{constructor(e={},t={}){this.intervals=e,this.timers=t}}let k=-1;function D(e,t,s){const i=setInterval(s,t);if(P("TimerRegistry.createInterval() -> "+i,e.intervals),"object"==typeof i){const t=++k;return e.intervals[t]=t,t}return e.intervals[i]=i,i}function C(e){if(e)return P("TimerRegistry.empty()",Object.keys(e.timers),Object.keys(e.intervals)),Object.keys(e.intervals).forEach(t=>function(e,t){return P("TimerRegistry.removeInterval() -> "+t,e.intervals),clearInterval(e.intervals[t]),delete e.intervals[t],e}(e,t)),Object.keys(e.timers).forEach(t=>function(e,t){return P("TimerRegistry.removeTimeout() -> "+t,e.timers),clearTimeout(e.timers[t]),delete e.timers[t],e}(e,t)),e}class Schedule{constructor(e,t={}){this._ads=e,this._opts=t,this._nextIndex=0,this._postroll=void 0,this._loadPending=!1,this._postrollActive=!1,this.reset(this._ads)}toJSON(){const e=(this._ads||[]).slice(this._nextIndex);return this._postroll&&e.push(this._postroll),e}reset(e){this.setAds(e),this._nextIndex=0,this._postrollActive=!1}resetCounter(){this._nextIndex=0,this._postrollActive=!1}setAds(e){this._ads=e||[],this.sort()}getAds(){return this._ads}getNextAd(e){return this._ads[this._nextIndex]||e}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(e){this._opts.content_duration=e}increment(){++this._nextIndex}decrement(){this._nextIndex>0&&--this._nextIndex}getNextIndex(){return this._nextIndex}getCurrentType(){const e=this.getCurrentAd();if(e)return Schedule.kindOf(e.time)}sort(){this._postroll=this._ads.find(e=>-1===e.time),this._ads=this._ads.filter(e=>e!==this._postroll).sort((e,t)=>e.time===t.time?this._ads.indexOf(e)-this._ads.indexOf(t):e.time-t.time)}shallPlayAd(e){if(this._loadPending)return!1;const t=this.getCurrentAd()||this.getNextAd();return!!(t&&t.time<=e&&-1!==t.time)}shallPlayNext(){const e=this.getNextAd(),t=this.getCurrentAd();return!(!e||!t||e.time!==t.time)}waitForLoad(e,t,s){if(this._loadPending=!1,!t)return!1;const i=s?this._opts.preload_advance:0;return t.time>=0?this._loadPending=e<t.time-i:-1===t.time&&(this._loadPending=this._opts.content_duration>0&&-1!==e?e<this._opts.content_duration-i:-1!==e),this._loadPending}static hasPreroll(e){return!!e.find(e=>0===e.time)}static isOutstream(e){return Schedule.hasPreroll(e)&&!!e[0].outstream}static kindOf(e){switch(e){case 0:return"preroll";case-1:return"postroll";default:return"midroll"}}}function I(e){try{return e.getAdPodInfo().getPodIndex()}catch(e){return}}class IMA{constructor(e){this.eventHandler=e,this.log=f("ads/adapter/ima"),this.google=window.google,this._adHandlers=[],this._timers=new TimerRegistry,this._started=!1,this._volumeLevel=0,this._adLoaded=!1,this._paused=!1,this._all_ads_completed=!1,this._currentDuration=0,this._currentRemaining=0,this._currentDisplayTs=0,this._iosPlaysInline=!1,this.sharedVideoTag=!1,this._isInitialized=!1,this._prepared=!1,this.opts={}}async init(e){this.log("init",this.videoTag,e),this.opts=e,this._dimensions={width:e.width,height:e.height,linear:e.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(e){this.log("initAdapter failed:",e),this._prepared=!1,this.eventHandler.trigger("ad-adapter-init-failed")}}isReady(){return!!this._isInitialized}setIOSPlaysInline(e){this.log("setIOSPlaysInline",e),this.sharedVideoTag=!e,this.initialize(Object.assign(Object.assign({},this.opts),{DisableCustomPlaybackForIOS10Plus:e}))}getIOSPlaysInline(){return this._iosPlaysInline}setVideoTag(e){this.videoTag=e}isLinearAd(){return!!this._adLinear}isSharedVideoTag(){return!!this.sharedVideoTag}getVideoTag(){return this.videoTag}getDimensions(){return this._dimensions||{}}getOpts(){return this.opts}isPaused(){return this._paused}destroy(){C(this._timers),this._adHandlers&&this._adHandlers.forEach(e=>e()),this._adHandlers=void 0,this._adDisplayContainer&&this._adDisplayContainer.destroy(),this._adDisplayContainer=void 0,this._adsLoader&&this._adsLoader.destroy(),this._adsLoader=void 0,this._adsManager&&this._adsManager.destroy(),this._adsManager=void 0}stop(){this._adsManager&&this._adsManager.stop()}initialize(e){const t=this.isAdPod(),s=this._adLoaded||t;if(this.cleanup(),!this.videoTag)return console.warn("videoTag not set during initialization");this.opts=e,this._volumeLevel=e.volume;const i=this.google.ima.settings;e.NumRedirects=e.NumRedirects||e.redirects;const r={VpaidMode:this.google.ima.ImaSdkSettings.VpaidMode.INSECURE,DisableCustomPlaybackForIOS10Plus:!0};if(i.setVpaidMode(e.VpaidMode||r.VpaidMode),i.setDisableCustomPlaybackForIOS10Plus(e.DisableCustomPlaybackForIOS10Plus||r.DisableCustomPlaybackForIOS10Plus),"NumRedirects"in e&&i.setNumRedirects(e.NumRedirects),"AutoPlayAdBreaks"in e&&i.setAutoPlayAdBreaks(e.AutoPlayAdBreaks),"Locale"in e&&i.setLocale(e.Locale),"Ppid"in e&&i.setPpid(e.Ppid),!document.body.contains(e.container))throw new Error("AdDisplayContainer was not found in the document.body");this._adDisplayContainer=new this.google.ima.AdDisplayContainer(e.container,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({},e),{volume:this.videoTag.volume,muted:this.videoTag.muted})),this._adsLoader.addEventListener(this.google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,t=>{if(!this.videoTag)return;this.log("ima.initialise(:done -> ADS_MANAGER_LOADED)\n%o",Object.assign(Object.assign({},e),{volume:this.videoTag.volume,muted:this.videoTag.muted}));const s=new this.google.ima.AdsRenderingSettings;this.log("ima.rendering(preload: %s)",!!e.preload_ads),s.useStyledNonLinearAds=!0,s.enablePreloading=!!e.preload_ads,"number"==typeof e.media_timeout&&(s.loadVideoTimeout=e.media_timeout),s.restoreCustomPlaybackStateOnAdBreakComplete=!e.DisableCustomPlaybackForIOS10Plus,this.sharedVideoTag&&(s.playAdsAfterTime=this.videoTag.currentTime),this.eventHandler.trigger("ad-ima-rendering-settings",s);const i=this._adsManager=t.getAdsManager(this.videoTag,s);this.eventHandler.trigger("ad-ima-adapter-init",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.STARTED,e=>{this.debugEvent(e);const t=e.getAd();t&&(this._currentDuration=t.getDuration(),this._currentDisplayTs=Date.now(),this.emitWithAd("ad-started",t),t.isLinear()&&IMA.pollRemaining({ima:this,adsManager:i}))}),i.addEventListener(this.google.ima.AdEvent.Type.COMPLETE,e=>{this.debugEvent(e);const t=e.getAd();t&&this.emitWithAd("ad-completed",t),C(this._timers)}),i.addEventListener(this.google.ima.AdEvent.Type.SKIPPED,e=>{this.debugEvent(e);const t=e.getAd();t&&this.emitWithAd("ad-skipped",t)}),i.addEventListener(this.google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED,e=>{this.debugEvent(e);const t=e.getAd();t&&this.emitWithAd("ad-pause-content",t)});const r=()=>{this._started=!1,this._currentDisplayTs=0,this.eventHandler.trigger("ad-break-completed")};i.addEventListener(this.google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED,e=>{this.debugEvent(e),r()}),i.addEventListener(this.google.ima.AdEvent.Type.VOLUME_CHANGED,e=>{this.log("IMA::volume(type: %s, event: %o)",e);const t=i.getVolume();this._volumeLevel=t,this.eventHandler.trigger("ad-volume-changed",t)});const a=e=>{this._paused=e,this.eventHandler.trigger(e?"ad-paused":"ad-resumed")};i.addEventListener(this.google.ima.AdEvent.Type.PAUSED,()=>a(!0)),i.addEventListener(this.google.ima.AdEvent.Type.RESUMED,()=>a(!1)),i.addEventListener(this.google.ima.AdEvent.Type.STARTED,()=>a(!1)),i.addEventListener(this.google.ima.AdEvent.Type.VOLUME_MUTED,e=>{this.log("IMA::volume(type: %s, event: %o)","mute",e),this.eventHandler.trigger("ad-muted")});const{width:n,height:o}=e;n&&o&&(i.init(n,o,this.google.ima.ViewMode.NORMAL),this.log("ima.initialise: done initializing"))}),s&&(this.log("Event(reload: %s)","reload-ad-requested"),this.eventHandler.trigger("reload-ad-requested",t)),this.eventHandler.trigger(p,this)}destroyManager(e="unknown"){if(!this._adsManager)return this.log("ima::destroyManager(:skip, label: %s)",e);this.log("ima::destroyManager(:ok, label: %s)",e),this._adsManager.destroy()}reset(){this.destroyManager("reset"),C(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(e=>{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),e(this._adsManager)})})}async initAd(e,t=5e3){this.log(`ima.initAd(adTag: ${e}, timeout: ${t})`);try{await this.requestAd(e,t),this._adLoaded=!0}catch(e){throw this.log("ima.initAd:",e),this._adLoaded=!1,e}finally{C(this._timers)}}async requestAd(e,t){if(this.destroyManager("requestAd"),!this.videoTag)return;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:t,adTag:e,_volumeLevel:this._volumeLevel,manager:this._adsManager})),this.clearAdHandlers();const n=new this.google.ima.AdsRequest;n.adTagUrl=e;const{height:o,width:d}=this.opts;if(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=t,this.eventHandler.trigger("ad-ima-before-ads-request",{request:n}),!this._adsLoader)return;this._adsLoader.requestAds(n);return new Promise(async(e,s)=>{const r=t=>{clearTimeout(o),e(t)},n=e=>{clearTimeout(o),s(e)};this.once(this._adsLoader,this.google.ima.AdErrorEvent.Type.AD_ERROR,e=>{this.emitError("ad-request-error",e),n(new Error("Ad load failed"))});const o=setTimeout(()=>{const e=new Error("Ad internal timeout reached");this.eventHandler.trigger("ad-timeout",e),s(e)},1.5*(t+(this.opts.media_timeout||5e3))),d=await this.waitForAdsManager();this.volume(a?0:this._volumeLevel),this.eventHandler.trigger("ad-volume-changed",this._volumeLevel);const l=this.cuepoints();if(l&&l.length&&0!==l[0])return r({ad:!1,adsManager:d});this.once(d,this.google.ima.AdErrorEvent.Type.AD_ERROR,e=>{this.emitError("ad-playback-error",e),n(e)}),this.once(d,this.google.ima.AdEvent.Type.ALL_ADS_COMPLETED,()=>{this._all_ads_completed=!0,r(null)}),this.once(d,this.google.ima.AdEvent.Type.LOADED,e=>{this.eventHandler.trigger("ad-request-completed",{request_load_time:Date.now()-i});const t=e.getAd();t&&(this.log("ima.requestAd: AD_REQUEST_COMPLETED",t.getContentType()),"application/javascript"==t.getContentType()&&this.eventHandler.trigger("vpaid-init",t),r(null))}),this.once(d,this.google.ima.AdEvent.Type.CLICK,()=>{this.log("ima.requestAd: click event"),this.pause()})})}async playAd(){if(this.log("ima.playAd()",this),!this._adsManager||!this._adLoaded)return;const e=this.currentAd();if(e&&(!this.sharedVideoTag||e.isLinear()))try{await this.startAndWaitForAdCompletion(this._adsManager,e.isLinear())}catch(e){throw this.log("ima.playAd",e),e}finally{this._adLoaded=!1,C(this._timers)}}startAndWaitForAdCompletion(e,t){if(!this._started)return this.log("ima.startAndWaitForAdCompletion(manager: %o)",{volume:e.getVolume()}),new Promise((s,i)=>{let r=!1;this.once(e,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(e,this.google.ima.AdErrorEvent.Type.AD_ERROR,async e=>{this.log("ima.startAndWaitForAdCompletion: beginning error recovery ->",e),r=!0;try{const{ok:t}=await IMA.pollForFatalError({err:e,ima:this});t&&(r=!1)}catch(t){this._started=!1,i(e)}}),t&&(this._started=!0),e.start(),this.eventHandler.trigger("ad-play-requested")})}pause(){this.log("ima.pause()"),this._adsManager&&this._adsManager.pause()}resume(){this.log("ima.resume()"),this._adsManager&&this._adsManager.resume()}volume(e){if(this._adsManager)try{return arguments.length>0&&"number"==typeof e&&this._adsManager.setVolume(e),this._volumeLevel=this._adsManager.getVolume()}catch(e){this.log("ima.volume() failed (%o)",e)}}onResize({width:e,height:t,linear:s,silent:i,resize_non_linear:r}){this._adsManager&&(this._adLinear=void 0===s?this._adLinear:s,this.opts&&(e||t)&&(!1===s&&(e+=10,t+=10),this._dimensions={width:e,height:t,linear:s},s&&(this.opts.width=e,this.opts.height=t),(this._adLinear||r)&&(i||this.log("ima.onResize %s x %s",e,t),this._adsManager.resize(e,t,this.google.ima.ViewMode.NORMAL))))}getAdInfo(){const e=this.currentAd();if(e)return{duration:e.getDuration(),currentTime:this._currentRemaining}}currentAd(){const e=this._adsManager;if(e)return e.getCurrentAd()}isAdPod(){const e=this.cuepoints();return!!(e&&e.length>1)}cuepoints(){return this._adsManager&&this._adsManager.getCuePoints()}async contentComplete(){this.log("ima.contentComplete() -> ",this),this._adsLoader&&this._adsLoader.contentComplete();const e=this.cuepoints();e&&-1!==e.indexOf(-1)&&await new Promise(e=>{IMA.race(this.eventHandler,["ad-break-completed","ad-error"],e)})}isUiDisabled(){try{const e=this.currentAd();return e&&e.isUiDisabled()}catch(e){return null}}getAdPodInfo(){try{const e=this.currentAd();return e&&e.getAdPodInfo()}catch(e){return null}}canDismissNonLinear(){const e=this.currentAd();if(!e||e.isLinear()||!this._adsManager||!this._currentDisplayTs)return!0;const t=Date.now(),s=e.getMinSuggestedDuration();return t-this._currentDisplayTs>1e3*s}static unwrapError(e,t){if(!e)return"";if("function"==typeof e.getMessage){return e.getMessage()}return e.message?e.message:t||""}static pollForFatalError({err:e,ima:t}){let s;try{const t=e.getError(),i=t.getInnerError(),r=i?IMA.unwrapError(i,t.message):"";s={reason:r,type:t.getType(),code:t.getErrorCode()}}catch(e){}const i=t._currentRemaining;return new Promise((e,r)=>{const a=setTimeout(()=>{t.eventHandler&&t.eventHandler.trigger("ad-playback-error",s),r(new Error("Ad not progressing"))},2500);t.eventHandler.once("ad-progress",t=>{const s=t.detail.remaining;-1!==s&&s<i&&(clearTimeout(a),e({ok:1}))})})}static pollRemaining({ima:e,adsManager:t}){let s=-1;return D(e._timers,250,(function(){e._currentRemaining=t.getRemainingTime(),s!=e._currentRemaining&&(s=e._currentRemaining,e.eventHandler.trigger("ad-progress",{remaining:e._currentRemaining,duration:e._currentDuration}))}))}once(e,t,s){this._adHandlers.push(function(e,t,s){const i=r=>{s(r),e.removeEventListener(t,i)};return e.addEventListener(t,i),()=>e.removeEventListener(t,i)}(e,t,s))}static race(e,t,s){t.forEach(i=>{const r=(...i)=>{t.forEach(t=>e.removeListener(t,r)),s(i)};e.on(i,r)})}clearAdHandlers(){this.log("ima.clearAdHandlers"),this._adHandlers.forEach(e=>e()),this._adHandlers=[]}emitWithAd(e,t){if(this.log("ima.emitWithAd",e,t),!this._adsManager)return;const s=I(t),i=s?Schedule.kindOf(s):"unknown",r=function(e){try{return e.getAdPodInfo().getAdPosition()}catch(e){return}}(t),a=function(e){try{return e.getAdPodInfo().getTotalAds()}catch(e){return}}(t),n={ad_type:i,ad:{duration:t.getDuration(),width:t.getWidth(),height:t.getHeight(),position:r,totals:a},volume:this._adsManager.getVolume(),vast_ad_id:t.getAdId(),linear:t.isLinear(),mime_type:t.getContentType(),ima_event:!0};this.log(`emitWithAd::event(name: ${e}, data: %o, ad: %o)`,n,t),this.eventHandler.trigger(e,n)}emitError(e,t){const s={vast_error_type:t.getError().getType(),reason:t.getError().getMessage(),vast_error:t.getError().getErrorCode()};this.log(`ima.error(${e})`,s),this.eventHandler.trigger(e,s)}debugEvent(e){try{const t=e.getAd();if(!t)return;this.log(`ima.event.${e.type} ->`,{event:e,data:e.getAdData(),position:I(t),ad:t})}catch(e){}}}var U=function(e){var t={exports:{}};return e(t,t.exports),t.exports}((function(e,t){var s=function(){for(var e=new Array(256),t=0;t<256;++t)e[t]="%"+((t<16?"0":"")+t.toString(16)).toUpperCase();return e}(),i=Object.prototype.hasOwnProperty;t.arrayToObject=function(e,t){for(var s=t.plainObjects?Object.create(null):{},i=0;i<e.length;++i)void 0!==e[i]&&(s[i]=e[i]);return s},t.merge=function(e,s,r){if(!s)return e;if("object"!=typeof s){if(Array.isArray(e))e.push(s);else{if("object"!=typeof e)return[e,s];(r.plainObjects||r.allowPrototypes||!i.call(Object.prototype,s))&&(e[s]=!0)}return e}if("object"!=typeof e)return[e].concat(s);var a=e;return Array.isArray(e)&&!Array.isArray(s)&&(a=t.arrayToObject(e,r)),Object.keys(s).reduce((function(e,a){var n=s[a];return i.call(e,a)?e[a]=t.merge(e[a],n,r):e[a]=n,e}),a)},t.decode=function(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(t){return e}},t.encode=function(e){if(0===e.length)return e;for(var t="string"==typeof e?e:String(e),i="",r=0;r<t.length;++r){var a=t.charCodeAt(r);45===a||46===a||95===a||126===a||a>=48&&a<=57||a>=65&&a<=90||a>=97&&a<=122?i+=t.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&t.charCodeAt(r)),i+=s[240|a>>18]+s[128|a>>12&63]+s[128|a>>6&63]+s[128|63&a])}return i},t.compact=function(e,s){if("object"!=typeof e||null===e)return e;var i=s||[],r=i.indexOf(e);if(-1!==r)return i[r];if(i.push(e),Array.isArray(e)){for(var a=[],n=0;n<e.length;++n)e[n]&&"object"==typeof e[n]?a.push(t.compact(e[n],i)):void 0!==e[n]&&a.push(e[n]);return a}for(var o=Object.keys(e),d=0;d<o.length;++d){var l=o[d];e[l]=t.compact(e[l],i)}return e},t.isRegExp=function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},t.isBuffer=function(e){return null!=e&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))}})),N={brackets:function(e){return e+"[]"},indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},F={delimiter:"&",strictNullHandling:!1,skipNulls:!1,encode:!0,encoder:U.encode},x=function e(t,s,i,r,a,n,o,d,l){var c=t;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||U.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(e(c[m],i(s,m),i,r,a,n,o,d,l)):h.concat(e(c[m],s+(l?"."+m:"["+m+"]"),i,r,a,n,o,d,l)))}return h},B=Object.prototype.hasOwnProperty,q={delimiter:"&",depth:5,arrayLimit:20,parameterLimit:1e3,strictNullHandling:!1,plainObjects:!1,allowPrototypes:!1,allowDots:!1,decoder:U.decode},j=function(e,t,s){if(e){var i=s.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,r=/(\[[^[\]]*])/g,a=/(\[[^[\]]*])/.exec(i),n=a?i.slice(0,a.index):i,o=[];if(n){if(!s.plainObjects&&B.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&&B.call(Object.prototype,a[1].slice(1,-1))&&!s.allowPrototypes)return;o.push(a[1])}return a&&o.push("["+i.slice(a.index)+"]"),function e(t,s,i){if(!t.length)return s;var r,a=t.shift();if("[]"===a)r=(r=[]).concat(e(t,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]=e(t,s,i):r[n]=e(t,s,i)}return r}(o,t,s)}},V=function(e,t){var s,i,r=e,a=t||{},n=void 0===a.delimiter?F.delimiter:a.delimiter,o="boolean"==typeof a.strictNullHandling?a.strictNullHandling:F.strictNullHandling,d="boolean"==typeof a.skipNulls?a.skipNulls:F.skipNulls,l=("boolean"==typeof a.encode?a.encode:F.encode)?"function"==typeof a.encoder?a.encoder:F.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 N?a.arrayFormat:"indices"in a?a.indices?"indices":"repeat":"indices";var g=N[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(x(r[_],_,g,o,d,l,i,c,u)))}return p.join(n)},H=function(e,t){var s=t||{};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||U.isRegExp(s.delimiter)?s.delimiter:q.delimiter,s.depth="number"==typeof s.depth?s.depth:q.depth,s.arrayLimit="number"==typeof s.arrayLimit?s.arrayLimit:q.arrayLimit,s.parseArrays=!1!==s.parseArrays,s.decoder="function"==typeof s.decoder?s.decoder:q.decoder,s.allowDots="boolean"==typeof s.allowDots?s.allowDots:q.allowDots,s.plainObjects="boolean"==typeof s.plainObjects?s.plainObjects:q.plainObjects,s.allowPrototypes="boolean"==typeof s.allowPrototypes?s.allowPrototypes:q.allowPrototypes,s.parameterLimit="number"==typeof s.parameterLimit?s.parameterLimit:q.parameterLimit,s.strictNullHandling="boolean"==typeof s.strictNullHandling?s.strictNullHandling:q.strictNullHandling,""===e||null==e)return s.plainObjects?Object.create(null):{};for(var i="string"==typeof e?function(e,t){for(var s={},i=e.split(t.delimiter,t.parameterLimit===1/0?void 0:t.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=t.decoder(o),n=t.strictNullHandling?null:""):(a=t.decoder(o.slice(0,d)),n=t.decoder(o.slice(d+1))),B.call(s,a)?s[a]=[].concat(s[a]).concat(n):s[a]=n}return s}(e,s):e,r=s.plainObjects?Object.create(null):{},a=Object.keys(i),n=0;n<a.length;++n){var o=a[n],d=j(o,i[o],s);r=U.merge(r,d,s)}return U.compact(r)};const z=f("fpads:macros"),Q=/\[([\s\S]+?)\]/g;class Macros{constructor(e={},t=Q){this.vars=e,this.pattern=t}static run(e){try{return e()}catch(e){return void console.error(e)}}static merge(...e){return e.reduce((e,t)=>Object.assign(e,t),{})}static cast(e){return void 0===e?"":"function"==typeof e?encodeURIComponent(Macros.run(e)||""):"string"==typeof e?encodeURIComponent(e):""}static normalize(e){return e.trim()}static process_obj(e,t,s){return Object.keys(e).reduce((i,r)=>{const a=Macros.process_str(r,t,s,!0),n=e[r];return null===n?(i[a]=n,i):"object"==typeof n?(i[a]=Macros.process_obj(n,t,s),i):"string"==typeof n?(i[a]=Macros.process_str(n,t,s),i):(console.error(new Error(`${n} at ${r} not a handled Macro type`)),i)},{})}static process_str(e,t,s,i=!1){return e.replace(t.pattern,(e,t)=>{const r=Macros.normalize(t);if(!(r in s)||void 0===s[r])return e;const a=s[r],n=i?a:Macros.cast(a);return z("Macro.replace(raw: %s, macro: %s, value: %s)",i,t,n),n})}fork(e={},t=this.pattern){const s=Macros.merge(this.vars,e);return new Macros(s,t)}compile(e,t={}){const s=Macros.merge(this.vars,t),[i,r]=e.split("?"),a=H(r||"",{strictNullHandling:!0,decoder:e=>e}),n=V(Macros.process_obj(a,this,s),{encode:!1,strictNullHandling:!0});return Macros.process_str(i,this,s,!0)+"?"+n}}function W(e,t={width:0,height:0}){let s,i;try{const e=document.createElement("a");e.href=s=window.location!=window.parent.location?document.referrer:document.location.href,i=e.hostname}catch(e){console.error(e)}const{width:r,height:a}=t,{video_source:n}=e||{},o=function(){const e=window;return"object"==typeof e.__flowplayerAdParameters?e.__flowplayerAdParameters:{}}();return Object.assign({random:Date.now(),page_url:s,domain:i,player_width:r,player_height:a,video_url:n,videourl:n},o)}async function G(e){if("function"!=typeof e)return e;try{return await e()}catch(e){return""}}Macros.patterns={BRACKETS:Q,CURLY:/\{([\s\S]+?)\}/g,UNDERSCORE:/__([\s\S]+?)__/g};const $=Object.prototype,K=Object.getPrototypeOf;const Y=f("fpads:ads:state");var J;!function(e){e[e.IDLE=0]="IDLE",e[e.INITIALIZING=1]="INITIALIZING",e[e.FETCHING_AD=2]="FETCHING_AD",e[e.AD_AVAILABLE=4]="AD_AVAILABLE",e[e.BREAK_ACTIVE=8]="BREAK_ACTIVE",e[e.PLAYING=16]="PLAYING",e[e.FATAL_ERROR=32]="FATAL_ERROR"}(J||(J={}));class AdsState{constructor(e=0){this._state=e}static of(){return new AdsState}reset(){this._state=0}toggleState(e,t){return void 0===e&&Y(new Error("AdState cannot toggleState for `undefined`")),null==typeof t?this._state^=e:t?void(this._state|=e):this._state&=~e}hasAll(e){return this._state==(this._state|e)}hasAny(e){return!!(this._state&e)}get state(){return this._state}}function Z(e,t,s){const i=function(e,t){const s=new CustomEvent(e,{detail:t,cancelable:!0});return t&&Object.defineProperty(s,"data",{get:()=>t}),s}(t,s);return e.dispatchEvent(i),e}!function(){let e=!1;try{const t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(e){}}();const X={ok:f("fpads:analytics:request-queue"),err:f("fpads:analytics:request-queue:err"),warn:f("fpads:analytics:request-queue:warn")};class RequestQueue{constructor(e=[],t=[],s={failures:0,ttl:0}){this.pending=e,this.open=t,this.stats=s}static of(){return new RequestQueue}static is_empty(e){return 0==e.pending.length}static is_high_water(e){return e.open.length==RequestQueue.MAX_OPEN_REQUESTS}static maybe_spawn_req(e){if(RequestQueue.is_empty(e))return X.ok("maybe_spawn_req called Queue that is EMPTY"),e;if(RequestQueue.is_high_water(e))return X.warn("maybe_spawn_req called on Queue that is HIGH_WATER"),e;try{const t=RequestQueue.lpop(e);t&&RequestQueue.request(e,t)}catch(e){X.err(e)}}static increment_failures(e){return e.stats.failures++,e.stats.failures>RequestQueue.MAX_FAILURE_COUNT&&(e.stats.ttl=Date.now()+RequestQueue.REQUEST_TTL_MS),e}static handle_error(e,t){RequestQueue.rm(e,t),RequestQueue.increment_failures(e)}static request(e,[t,s,i]){if(X.ok(`Request[${i.event_type}] request`,i,e.stats),Date.now()<e.stats.ttl)return X.warn(`Request[${i.event_type}] skipping because too many errors too quickly`,e.stats);const r=new XMLHttpRequest;e.open.push(r),r.timeout=RequestQueue.REQUEST_TIMEOUT_MS,r.ontimeout=function(){RequestQueue.handle_error(e,r),X.warn(`Request[${i.event_type}] timed out in ${r.timeout}ms`,e.stats)},r.onerror=function(t){RequestQueue.handle_error(e,r),t&&X.err(t),X.warn(`Request[${i.event_type}] encountered an Error`,r.responseText,e.stats)},r.onreadystatechange=function(){r.readyState==XMLHttpRequest.DONE&&RequestQueue.rm(e,r),Math.floor(r.status/100)},r.onload=function(){RequestQueue.rm(e,r),e.stats.failures&&e.stats.failures--,X.ok(`Request[${i.event_type}] :ok`,r.status)},r.open(s,t),r.setRequestHeader("Content-Type","text/plain;charset=UTF-8");try{r.send(JSON.stringify(i))}catch(e){X.err(e)}}static rpush(e,...t){return t.forEach(t=>{if(RequestQueue.is_high_water(e))return X.warn("Too many open requests, skipping",e.stats);e.pending.push(t),RequestQueue.maybe_spawn_req(e)}),e}static lpop(e){return e.pending.shift()}static rm(e,t){const s=e.open.lastIndexOf(t);return~s&&e.open.splice(s,1),e}}RequestQueue.MAX_OPEN_REQUESTS=3,RequestQueue.REQUEST_TIMEOUT_MS=4e3,RequestQueue.REQUEST_TTL_MS=5e3,RequestQueue.MAX_FAILURE_COUNT=3;const ee={"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"},te={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"},se={tablet:"tablet",mobile:"mobile",desktop:"desktop",tv:"tv"},ie={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"},re={EdgeHTML:"EdgeHTML",Blink:"Blink",Trident:"Trident",Presto:"Presto",Gecko:"Gecko",WebKit:"WebKit"};class Utils{static getFirstMatch(e,t){const s=t.match(e);return s&&s.length>0&&s[1]||""}static getSecondMatch(e,t){const s=t.match(e);return s&&s.length>1&&s[2]||""}static matchAndReturnConst(e,t,s){if(e.test(t))return s}static getWindowsVersionName(e){switch(e){case"NT":return"NT";case"XP":return"XP";case"NT 5.0":return"2000";case"NT 5.1":return"XP";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(e){const t=e.split(".").splice(0,2).map(e=>parseInt(e,10)||0);if(t.push(0),10===t[0])switch(t[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(e){const t=e.split(".").splice(0,2).map(e=>parseInt(e,10)||0);if(t.push(0),!(1===t[0]&&t[1]<5))return 1===t[0]&&t[1]<6?"Cupcake":1===t[0]&&t[1]>=6?"Donut":2===t[0]&&t[1]<2?"Eclair":2===t[0]&&2===t[1]?"Froyo":2===t[0]&&t[1]>2?"Gingerbread":3===t[0]?"Honeycomb":4===t[0]&&t[1]<1?"Ice Cream Sandwich":4===t[0]&&t[1]<4?"Jelly Bean":4===t[0]&&t[1]>=4?"KitKat":5===t[0]?"Lollipop":6===t[0]?"Marshmallow":7===t[0]?"Nougat":8===t[0]?"Oreo":9===t[0]?"Pie":void 0}static getVersionPrecision(e){return e.split(".").length}static compareVersions(e,t,s=!1){const i=Utils.getVersionPrecision(e),r=Utils.getVersionPrecision(t);let a=Math.max(i,r),n=0;const o=Utils.map([e,t],e=>{const t=a-Utils.getVersionPrecision(e),s=e+new Array(t+1).join(".0");return Utils.map(s.split("."),e=>new Array(20-e.length).join("0")+e).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(e,t){const s=[];let i;if(Array.prototype.map)return Array.prototype.map.call(e,t);for(i=0;i<e.length;i+=1)s.push(t(e[i]));return s}static find(e,t){let s,i;if(Array.prototype.find)return Array.prototype.find.call(e,t);for(s=0,i=e.length;s<i;s+=1){const i=e[s];if(t(i,s))return i}}static assign(e,...t){const s=e;let i,r;if(Object.assign)return Object.assign(e,...t);for(i=0,r=t.length;i<r;i+=1){const e=t[i];if("object"==typeof e&&null!==e){Object.keys(e).forEach(t=>{s[t]=e[t]})}}return e}static getBrowserAlias(e){return ee[e]}static getBrowserTypeByAlias(e){return te[e]||""}}const ae=/version\/(\d+(\.?_?\d+)+)/i,ne=[{test:[/googlebot/i],describe(e){const t={name:"Googlebot"},s=Utils.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,e)||Utils.getFirstMatch(ae,e);return s&&(t.version=s),t}},{test:[/opera/i],describe(e){const t={name:"Opera"},s=Utils.getFirstMatch(ae,e)||Utils.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/opr\/|opios/i],describe(e){const t={name:"Opera"},s=Utils.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i,e)||Utils.getFirstMatch(ae,e);return s&&(t.version=s),t}},{test:[/SamsungBrowser/i],describe(e){const t={name:"Samsung Internet for Android"},s=Utils.getFirstMatch(ae,e)||Utils.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/Whale/i],describe(e){const t={name:"NAVER Whale Browser"},s=Utils.getFirstMatch(ae,e)||Utils.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/MZBrowser/i],describe(e){const t={name:"MZ Browser"},s=Utils.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,e)||Utils.getFirstMatch(ae,e);return s&&(t.version=s),t}},{test:[/focus/i],describe(e){const t={name:"Focus"},s=Utils.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,e)||Utils.getFirstMatch(ae,e);return s&&(t.version=s),t}},{test:[/swing/i],describe(e){const t={name:"Swing"},s=Utils.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,e)||Utils.getFirstMatch(ae,e);return s&&(t.version=s),t}},{test:[/coast/i],describe(e){const t={name:"Opera Coast"},s=Utils.getFirstMatch(ae,e)||Utils.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/opt\/\d+(?:.?_?\d+)+/i],describe(e){const t={name:"Opera Touch"},s=Utils.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i,e)||Utils.getFirstMatch(ae,e);return s&&(t.version=s),t}},{test:[/yabrowser/i],describe(e){const t={name:"Yandex Browser"},s=Utils.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,e)||Utils.getFirstMatch(ae,e);return s&&(t.version=s),t}},{test:[/ucbrowser/i],describe(e){const t={name:"UC Browser"},s=Utils.getFirstMatch(ae,e)||Utils.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/Maxthon|mxios/i],describe(e){const t={name:"Maxthon"},s=Utils.getFirstMatch(ae,e)||Utils.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/epiphany/i],describe(e){const t={name:"Epiphany"},s=Utils.getFirstMatch(ae,e)||Utils.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/puffin/i],describe(e){const t={name:"Puffin"},s=Utils.getFirstMatch(ae,e)||Utils.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/sleipnir/i],describe(e){const t={name:"Sleipnir"},s=Utils.getFirstMatch(ae,e)||Utils.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/k-meleon/i],describe(e){const t={name:"K-Meleon"},s=Utils.getFirstMatch(ae,e)||Utils.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/micromessenger/i],describe(e){const t={name:"WeChat"},s=Utils.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,e)||Utils.getFirstMatch(ae,e);return s&&(t.version=s),t}},{test:[/qqbrowser/i],describe(e){const t={name:/qqbrowserlite/i.test(e)?"QQ Browser Lite":"QQ Browser"},s=Utils.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i,e)||Utils.getFirstMatch(ae,e);return s&&(t.version=s),t}},{test:[/msie|trident/i],describe(e){const t={name:"Internet Explorer"},s=Utils.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/\sedg\//i],describe(e){const t={name:"Microsoft Edge"},s=Utils.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/edg([ea]|ios)/i],describe(e){const t={name:"Microsoft Edge"},s=Utils.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/vivaldi/i],describe(e){const t={name:"Vivaldi"},s=Utils.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/seamonkey/i],describe(e){const t={name:"SeaMonkey"},s=Utils.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/sailfish/i],describe(e){const t={name:"Sailfish"},s=Utils.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,e);return s&&(t.version=s),t}},{test:[/silk/i],describe(e){const t={name:"Amazon Silk"},s=Utils.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/phantom/i],describe(e){const t={name:"PhantomJS"},s=Utils.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/slimerjs/i],describe(e){const t={name:"SlimerJS"},s=Utils.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe(e){const t={name:"BlackBerry"},s=Utils.getFirstMatch(ae,e)||Utils.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/(web|hpw)[o0]s/i],describe(e){const t={name:"WebOS Browser"},s=Utils.getFirstMatch(ae,e)||Utils.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/bada/i],describe(e){const t={name:"Bada"},s=Utils.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/tizen/i],describe(e){const t={name:"Tizen"},s=Utils.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,e)||Utils.getFirstMatch(ae,e);return s&&(t.version=s),t}},{test:[/qupzilla/i],describe(e){const t={name:"QupZilla"},s=Utils.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,e)||Utils.getFirstMatch(ae,e);return s&&(t.version=s),t}},{test:[/firefox|iceweasel|fxios/i],describe(e){const t={name:"Firefox"},s=Utils.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/electron/i],describe(e){const t={name:"Electron"},s=Utils.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/MiuiBrowser/i],describe(e){const t={name:"Miui"},s=Utils.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/chromium/i],describe(e){const t={name:"Chromium"},s=Utils.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,e)||Utils.getFirstMatch(ae,e);return s&&(t.version=s),t}},{test:[/chrome|crios|crmo/i],describe(e){const t={name:"Chrome"},s=Utils.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/GSA/i],describe(e){const t={name:"Google Search"},s=Utils.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test(e){const t=!e.test(/like android/i),s=e.test(/android/i);return t&&s},describe(e){const t={name:"Android Browser"},s=Utils.getFirstMatch(ae,e);return s&&(t.version=s),t}},{test:[/playstation 4/i],describe(e){const t={name:"PlayStation 4"},s=Utils.getFirstMatch(ae,e);return s&&(t.version=s),t}},{test:[/safari|applewebkit/i],describe(e){const t={name:"Safari"},s=Utils.getFirstMatch(ae,e);return s&&(t.version=s),t}},{test:[/.*/i],describe(e){const t=-1!==e.search("\\(")?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return{name:Utils.getFirstMatch(t,e),version:Utils.getSecondMatch(t,e)}}}];var oe=[{test:[/Roku\/DVP/],describe(e){const t=Utils.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,e);return{name:ie.Roku,version:t}}},{test:[/windows phone/i],describe(e){const t=Utils.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,e);return{name:ie.WindowsPhone,version:t}}},{test:[/windows /i],describe(e){const t=Utils.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,e),s=Utils.getWindowsVersionName(t);return{name:ie.Windows,version:t,versionName:s}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe(e){const t={name:ie.iOS},s=Utils.getSecondMatch(/(Version\/)(\d[\d.]+)/,e);return s&&(t.version=s),t}},{test:[/macintosh/i],describe(e){const t=Utils.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,e).replace(/[_\s]/g,"."),s=Utils.getMacOSVersionName(t),i={name:ie.MacOS,version:t};return s&&(i.versionName=s),i}},{test:[/(ipod|iphone|ipad)/i],describe(e){const t=Utils.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,e).replace(/[_\s]/g,".");return{name:ie.iOS,version:t}}},{test(e){const t=!e.test(/like android/i),s=e.test(/android/i);return t&&s},describe(e){const t=Utils.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i,e),s=Utils.getAndroidVersionName(t),i={name:ie.Android,version:t};return s&&(i.versionName=s),i}},{test:[/(web|hpw)[o0]s/i],describe(e){const t=Utils.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,e),s={name:ie.WebOS};return t&&t.length&&(s.version=t),s}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe(e){const t=Utils.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,e)||Utils.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,e)||Utils.getFirstMatch(/\bbb(\d+)/i,e);return{name:ie.BlackBerry,version:t}}},{test:[/bada/i],describe(e){const t=Utils.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,e);return{name:ie.Bada,version:t}}},{test:[/tizen/i],describe(e){const t=Utils.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,e);return{name:ie.Tizen,version:t}}},{test:[/linux/i],describe:()=>({name:ie.Linux})},{test:[/CrOS/],describe:()=>({name:ie.ChromeOS})},{test:[/PlayStation 4/],describe(e){const t=Utils.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,e);return{name:ie.PlayStation4,version:t}}}],de=[{test:[/googlebot/i],describe:()=>({type:"bot",vendor:"Google"})},{test:[/huawei/i],describe(e){const t=Utils.getFirstMatch(/(can-l01)/i,e)&&"Nova",s={type:se.mobile,vendor:"Huawei"};return t&&(s.model=t),s}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:()=>({type:se.tablet,vendor:"Nexus"})},{test:[/ipad/i],describe:()=>({type:se.tablet,vendor:"Apple",model:"iPad"})},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:()=>({type:se.tablet,vendor:"Apple",model:"iPad"})},{test:[/kftt build/i],describe:()=>({type:se.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"})},{test:[/silk/i],describe:()=>({type:se.tablet,vendor:"Amazon"})},{test:[/tablet(?! pc)/i],describe:()=>({type:se.tablet})},{test(e){const t=e.test(/ipod|iphone/i),s=e.test(/like (ipod|iphone)/i);return t&&!s},describe(e){const t=Utils.getFirstMatch(/(ipod|iphone)/i,e);return{type:se.mobile,vendor:"Apple",model:t}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:()=>({type:se.mobile,vendor:"Nexus"})},{test:[/[^-]mobi/i],describe:()=>({type:se.mobile})},{test:e=>"blackberry"===e.getBrowserName(!0),describe:()=>({type:se.mobile,vendor:"BlackBerry"})},{test:e=>"bada"===e.getBrowserName(!0),describe:()=>({type:se.mobile})},{test:e=>"windows phone"===e.getBrowserName(),describe:()=>({type:se.mobile,vendor:"Microsoft"})},{test(e){const t=Number(String(e.getOSVersion()).split(".")[0]);return"android"===e.getOSName(!0)&&t>=3},describe:()=>({type:se.tablet})},{test:e=>"android"===e.getOSName(!0),describe:()=>({type:se.mobile})},{test:e=>"macos"===e.getOSName(!0),describe:()=>({type:se.desktop,vendor:"Apple"})},{test:e=>"windows"===e.getOSName(!0),describe:()=>({type:se.desktop})},{test:e=>"linux"===e.getOSName(!0),describe:()=>({type:se.desktop})},{test:e=>"playstation 4"===e.getOSName(!0),describe:()=>({type:se.tv})},{test:e=>"roku"===e.getOSName(!0),describe:()=>({type:se.tv})}],le=[{test:e=>"microsoft edge"===e.getBrowserName(!0),describe(e){if(/\sedg\//i.test(e))return{name:re.Blink};const t=Utils.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,e);return{name:re.EdgeHTML,version:t}}},{test:[/trident/i],describe(e){const t={name:re.Trident},s=Utils.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:e=>e.test(/presto/i),describe(e){const t={name:re.Presto},s=Utils.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test(e){const t=e.test(/gecko/i),s=e.test(/like gecko/i);return t&&!s},describe(e){const t={name:re.Gecko},s=Utils.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/(apple)?webkit\/537\.36/i],describe:()=>({name:re.Blink})},{test:[/(apple)?webkit/i],describe(e){const t={name:re.WebKit},s=Utils.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}}];class Parser{constructor(e,t=!1){if(null==e||""===e)throw new Error("UserAgent parameter can't be empty");this._ua=e,this.parsedResult={},!0!==t&&this.parse()}getUA(){return this._ua}test(e){return e.test(this._ua)}parseBrowser(){this.parsedResult.browser={};const e=Utils.find(ne,e=>{if("function"==typeof e.test)return e.test(this);if(e.test instanceof Array)return e.test.some(e=>this.test(e));throw new Error("Browser's test function is not valid")});return e&&(this.parsedResult.browser=e.describe(this.getUA())),this.parsedResult.browser}getBrowser(){return this.parsedResult.browser?this.parsedResult.browser:this.parseBrowser()}getBrowserName(e){return e?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 e=Utils.find(oe,e=>{if("function"==typeof e.test)return e.test(this);if(e.test instanceof Array)return e.test.some(e=>this.test(e));throw new Error("Browser's test function is not valid")});return e&&(this.parsedResult.os=e.describe(this.getUA())),this.parsedResult.os}getOSName(e){const{name:t}=this.getOS();return e?String(t).toLowerCase()||"":t||""}getOSVersion(){return this.getOS().version}getPlatform(){return this.parsedResult.platform?this.parsedResult.platform:this.parsePlatform()}getPlatformType(e=!1){const{type:t}=this.getPlatform();return e?String(t).toLowerCase()||"":t||""}parsePlatform(){this.parsedResult.platform={};const e=Utils.find(de,e=>{if("function"==typeof e.test)return e.test(this);if(e.test instanceof Array)return e.test.some(e=>this.test(e));throw new Error("Browser's test function is not valid")});return e&&(this.parsedResult.platform=e.describe(this.getUA())),this.parsedResult.platform}getEngine(){return this.parsedResult.engine?this.parsedResult.engine:this.parseEngine()}getEngineName(e){return e?String(this.getEngine().name).toLowerCase()||"":this.getEngine().name||""}parseEngine(){this.parsedResult.engine={};const e=Utils.find(le,e=>{if("function"==typeof e.test)return e.test(this);if(e.test instanceof Array)return e.test.some(e=>this.test(e));throw new Error("Browser's test function is not valid")});return e&&(this.parsedResult.engine=e.describe(this.getUA())),this.parsedResult.engine}parse(){return this.parseBrowser(),this.parseOS(),this.parsePlatform(),this.parseEngine(),this}getResult(){return Utils.assign({},this.parsedResult)}satisfies(e){const t={};let s=0;const i={};let r=0;if(Object.keys(e).forEach(a=>{const n=e[a];"string"==typeof n?(i[a]=n,r+=1):"object"==typeof n&&(t[a]=n,s+=1)}),s>0){const e=Object.keys(t),s=Utils.find(e,e=>this.isOS(e));if(s){const e=this.satisfies(t[s]);if(void 0!==e)return e}const i=Utils.find(e,e=>this.isPlatform(e));if(i){const e=this.satisfies(t[i]);if(void 0!==e)return e}}if(r>0){const e=Object.keys(i),t=Utils.find(e,e=>this.isBrowser(e,!0));if(void 0!==t)return this.compareVersion(i[t])}}isBrowser(e,t=!1){const s=this.getBrowserName().toLowerCase();let i=e.toLowerCase();const r=Utils.getBrowserTypeByAlias(i);return t&&r&&(i=r.toLowerCase()),i===s}compareVersion(e){let t=[0],s=e,i=!1;const r=this.getBrowserVersion();if("string"==typeof r)return">"===e[0]||"<"===e[0]?(s=e.substr(1),"="===e[1]?(i=!0,s=e.substr(2)):t=[],">"===e[0]?t.push(1):t.push(-1)):"="===e[0]?s=e.substr(1):"~"===e[0]&&(i=!0,s=e.substr(1)),t.indexOf(Utils.compareVersions(r,s,i))>-1}isOS(e){return this.getOSName(!0)===String(e).toLowerCase()}isPlatform(e){return this.getPlatformType(!0)===String(e).toLowerCase()}isEngine(e){return this.getEngineName(!0)===String(e).toLowerCase()}is(e,t=!1){return this.isBrowser(e,t)||this.isOS(e)||this.isPlatform(e)}some(e=[]){return e.some(e=>this.is(e))}}
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.ads=t())}(this,(function(){"use strict";var e;!function(e){e[e.ADS=2]="ADS",e[e.ANALYTICS=4]="ANALYTICS",e[e.NO_METERING=8]="NO_METERING",e[e.DEVELOPER_PLAN=16]="DEVELOPER_PLAN"}(e||(e={}));const t=["localhost","127.0.0.1","0.0.0.0","s.codepen.io","cdpn.io","try.flowplayer.com"];function s(e,s){return!!~t.indexOf(e)||e.indexOf(s)===e.length-s.length}s.check_whitelist=function(e){return!!~t.indexOf(e)};function i(e){this.message=e}i.prototype=new Error,i.prototype.name="InvalidCharacterError";var r="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.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=t.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(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(r(e).replace(/(.)/g,(function(e,t){var s=t.charCodeAt(0).toString(16).toUpperCase();return s.length<2&&(s="0"+s),"%"+s})))}(t)}catch(e){return r(t)}};function n(e){this.message=e}n.prototype=new Error,n.prototype.name="InvalidTokenError";var o=function(e,t){if("string"!=typeof e)throw new n("Invalid token specified");var s=!0===(t=t||{}).header?0:1;try{return JSON.parse(a(e.split(".")[s]))}catch(e){throw new n("Invalid token specified: "+e.message)}};o.InvalidTokenError=n;const d="production";function l(e,t){const s={valid_jwt:!1,raw:"",data:{acl:0},exp:0};let i={c:"{}",exp:0};t=t||{};try{i=o(e),s.valid_jwt=!0}catch(e){}return s.raw=e,s.data=JSON.parse(i.c),s.exp=i.exp,t.require_valid_token&&l.validate(s),s}function c(e){return{grant:e,is_granted:t=>(e&t)===t}}function u(e){return{width:e.clientWidth,height:e.clientHeight}}function h(e,t,s){return"number"==typeof s&&(s+="px"),e.style.setProperty(t,s),e}l.validate=function(e){if("string"==typeof e&&(e=l(e)),!e||!e.raw){if(s.check_whitelist(window.location.hostname)||"dev"===d.toString())return!0;throw new Error("No token provided in configuration")}if(!e.valid_jwt)throw new Error("Invalid token provided");const t=window.location.hostname,i=s.bind(null,t);if("dev"!==d.toString()&&e.data.domain&&e.data.domain.length&&!e.data.domain.some(i))throw new Error("Domain not allowed");if("dev"!==d.toString()&&1e3*e.exp-Date.now()<0)throw new Error("Expired token");return!0},l.id=function(e){if(e)return"string"==typeof e&&(e=l(e)),e.data.id},c.of=c,c.from_token=function(e){const t=l(e,{require_valid_token:!0});return c.of(t.data.acl)},c.permissions=e;const p="ad-initialized";var g=Object.freeze({__proto__:null,AD_INIT:p,AD_PLAYBACK_ERROR:"ad-playback-error",AD_TEARDOWN:"ad-teardown",AD_VIDEOTAG_ATTACHED:"ad-videotag-attached",AD_BLOCKED:"ad-blocked",AD_REQUEST_ERROR:"ad-request-error",AD_REQUESTED:"ad-requested",AD_REQUEST_COMPLETED:"ad-request-completed",AD_PAUSE_CONTENT:"ad-pause-content",AD_STARTED:"ad-started",AD_COMPLETED:"ad-completed",AD_PAUSED:"ad-paused",AD_RESUMED:"ad-resumed",AD_WAITING:"ad-waiting",AD_PROGRESS:"ad-progress",AD_SKIPPED:"ad-skipped",AD_MUTED:"ad-muted",AD_VOLUME_CHANGED:"ad-volume-changed",AD_FULLSCREEN:"ad-fullscreen",AD_TIMEOUT:"ad-timeout",AD_BREAK_COMPLETED:"ad-break-completed",AD_POSTROLL_FINISHED:"ad-postroll-finished",AD_PREROLL_FINSIHED:"ad-preroll-finished",AD_MIDROLL_FINISHED:"ad-midroll-finished",VPAID_INIT:"vpaid-init",IMA_ADAPTER_INIT:"ad-ima-adapter-init",IMA_BEFORE_ADS_REQUEST:"ad-ima-before-ads-request",IMA_ADS_RENDERING_SETTINGS:"ad-ima-rendering-settings",ADAPTER_INIT_FAILED:"ad-adapter-init-failed",AD_PLAY_REQUESTED:"ad-play-requested",RELOAD_AD_REQUESTED:"reload-ad-requested",AD_ERROR:"ad-error",REQUEST_AD_PAUSE:"request/ad/pause",REQUEST_AD_PLAY:"request/ad/play",REQUEST_AD_MUTE_UNMUTE:"request/ad/muteunmute"});const m="undefined"!=typeof document&&"undefined"!=typeof window&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream;var _;function f(e,t){const s=function(){try{return localStorage.getItem("flowplayer/debug")}catch(e){return""}}(),i=(i,...r)=>{const a=(null==t?void 0:t.debug)||s;a&&e.match(a)&&console.log(`${e} -- ${i}`,...r)};return i.log=i,i}!function(e){e[e.OFF=0]="OFF",e[e.ON=1]="ON",e[e.AUDIO_REQUIRED=2]="AUDIO_REQUIRED"}(_||(_={}));const y=(e,t)=>new(((e,t)=>{const s=e.get(t);if(!s)throw new Error(`no flowplayer component with the name ${t} exists`);const i=window.customElements.get(t);if(!i)throw new Error(`no default flowplayer component with the name ${t} exists`);const r=window.customElements.get(s);return"function"!=typeof r?i:r})(e._customElements,t))(e),v=(e,t,s)=>{window.customElements.get(t)||window.customElements.define(t,s),e.customElements.get(t)||e.customElements.set(t,t)},A=f("ads/lifecycle"),w=["ad-playback-error","ad-teardown","ad-break-completed"];async function E({config:e,root:t,content:s,ads:i,ima:r}){A("LifeCycle::initLifeCycle",e,t,s,i,r),s.autoplay=!1;const a=e.autoplay===_.AUDIO_REQUIRED,n=function(e,t){return{muted:!(t||!e.muted),volume:e.volume}}(s,a);s.on("volumechange",()=>{n.volume=s.volume,n.muted=s.muted});const o=y(s,"flowplayer-ad-ui"),d=o.adContainer;t.append(o);const l={listening:!1,preload:null==r?void 0:r.preload_ads};if(A("initial",n),i.setVideoTag(s),e.autoplay){A("Trying to autoplay"),o.hideFirstFrame(t);await async function e(t,s){const[i,r]=[t.muted,t.volume];A("Lifecycle::peek_content(:muted => %s, :volume => %s)",i,r);const a=()=>new Promise(e=>setTimeout(e,0,!1));s&&(t.muted=!1,t.volume=t.volume?t.volume:1);try{return await async function(e){return A("Lifecycle::wait_for_source"),new Promise((t,s)=>{let i=0;const r=setInterval(()=>{if(++i>40)return clearInterval(r),s(new Error("No source in 2000ms, giving up"));e.currentSrc&&(t(null),clearInterval(r))},50)})}(t),t.volume&&(t.volume=.01),A("Lifecycle::peek_content::play"),await new Promise(e=>setTimeout(()=>e(t.togglePlay(!0)))),A("Lifecycle::peek_content::pause"),await new Promise(e=>setTimeout(()=>e(t.togglePlay(!1)))),t.volume=r,A("Lifecycle::peek_content::true"),!0}catch(n){return t.volume=r,s?(t.muted=!1,0==t.volume&&(t.volume=1),await a()):i||!r?(A("Lifecycle::peek_content::false"),await a()):(A("Lifecycle::peek_content::recover"),t.muted=!0,!!await e(t)||(t.muted=i,A("Lifecycle::peek_content::false"),await a()))}}(s,a)?(A("Can autoplay, start ad"),s.opts.autoplay=1,b({ads:i,content:s,state:l,adContainer:d,ima:r,config:e})):(A("cannot autoplay(audioRequired: %s), fallback to poster state",a),e.autoplay=0,o.showFirstFrame(t),s.setState("is-starting",!0))}e.autoplay||i.hasPreroll()&&function({content:e,ads:t,config:s,state:i,initial:r,adContainer:a,ima:n}){e.once("beforeplay",(async function(o){(e.hasState("is-in-viewport")||"touchend"!=o.type)&&t.shallPlayAd(0)&&(!m&&o.preventDefault(),O({ads:t,content:e,state:i}),A("user_gesture(:intercept) -> shallPlayAd(0: %s)",t.shallPlayAd(0)),s.muted=r.muted,await b({ads:t,content:e,state:i,adContainer:a,ima:n,config:s}),M({ads:t,content:e}))}))}({content:s,ads:i,config:e,state:l,initial:n,adContainer:d,ima:r}),!e.autoplay&&i.hasPreroll()&&l.preload&&b({ads:i,content:s,state:l,adContainer:d,ima:r,config:e}),L({config:e,root:t,content:s,ads:i,state:l,adContainer:d,ui:o,ima:r,initial:n}),s.on("src",()=>{s.once("beforeplay",()=>i.resetScheduleCounter())})}async function b(e){e.state.started||(e.content.hasState("is-in-viewport")?await T(e):e.content.once("viewenter",async()=>{await T(e)}))}async function T({ads:e,content:t,adContainer:s,ima:i,state:r,config:a}){var n;r.started=!0;const o=function(e,t){var s={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(s[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(s[i[r]]=e[i[r]])}return s}(i,["ads"]),d=u(t.root),l=(null==a?void 0:a.muted)||t.muted,c=Object.assign(Object.assign(Object.assign({container:s,volume:l?0:t.volume,muted:l,autoplay:(null==a?void 0:a.autoplay)||!1,video_source:t.original_src,DisableCustomPlaybackForIOS10Plus:m,preload_ads:null===(n=null==a?void 0:a.ima)||void 0===n?void 0:n.preload_ads},o),d));A("start():",c,r),await e.initialize(!1,c,r.preload)}function S(e,t){var s,i;return{content_width:e.clientWidth||(null===(s=e.parentNode)||void 0===s?void 0:s.clientWidth)||t.clientWidth,content_height:e.clientHeight||(null===(i=e.parentNode)||void 0===i?void 0:i.clientHeight)||t.clientHeight}}function L({config:e,root:t,content:s,ads:i,initial:r,adContainer:a,state:n,ui:o,ima:d}){A("addUIListeners()"),s.once("playing",async r=>{if(i){if(A("addUIListeners() -> content started playing"),O({ads:i,content:s,state:n}),!i.shallPlayAd(0)||!i.adapter.isLinearAd())return A("addUIListeners() -> no more preroll ads -> resume content"),await b({ads:i,content:s,state:n,adContainer:a,ima:d,config:e});s.togglePlay(!1),await b({ads:i,content:s,state:n,adContainer:a,ima:d,config:e}),i.shallPlayAd(0)&&i.adapter.isLinearAd()&&(o.classList.add("on","linear"),t.classList.add("is-waiting"),M({ads:i,content:s}))}}),s.on(["portrait","landscape"],(function(){if(!i)return;const{content_width:e,content_height:r}=S(s,t);i.resize({height:r,width:e})})),s.on("resize",e=>{if(!i||!e.detail)return;const{width:t,height:s}=e.detail.contentRect;i.resize({width:t,height:s})}),s.on("ended",e=>{var t;i&&(A("ui_listeners(:%s, event: %o)",e.type,e.detail),(null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.from)!==i&&(e.preventDefault(),Object.assign(e,{prevented_from_ads:!0}),i.finished((function(){s.emit("ended",{from:i})}))))}),i.on("ad-requested",()=>{t.classList.toggle("is-waiting",!0)}),i.once("ad-started",()=>{s.on(["beforeplay","beforepause"],e=>{var t;if(!i.adBreak||!i.adapter.isLinearAd())return;e.preventDefault();const s=(null===(t=e.detail)||void 0===t?void 0:t.forced)?"beforeplay"===e.type:!i.adPlaying;s&&i.paused&&i.resume(),s||i.paused||i.pause()})}),i.on("ad-started",e=>{const a=e.detail,{linear:n,ad:d,ad_type:l}=a;let c;if(A(`Ad[linear: ${n}, currentTime: ${s.currentTime}] starting`,d),"preroll"==l&&!n&&s.paused&&s.togglePlay(!0),"preroll"==l&&n&&s.currentTime>0&&!s.opt("start_time")&&!s.opt("live")&&(A("Preroll[rewind: true]",s.currentTime),s.currentTime=0),n&&(c=S(s,t)),i.resize({width:c?c.content_width:d.width,height:c?c.content_height:d.height,linear:n,resize_non_linear:!0}),o.resize({linear:n,resizeContainerAlso:!0,width:n?void 0:d.width,height:n?void 0:d.height}),t.classList.remove("is-waiting"),o.classList.add("on"),o.classList.toggle("linear",n),o.classList.toggle("non-linear",!n),!n){A("non-linear ad / restarting content");try{s.togglePlay(!0),s.volume=r.volume,s.muted=r.muted}catch(e){A(e)}}}),i.on("ad-pause-content",()=>{o.resize({linear:!0,width:0,height:0})}),s.on(w,e=>async function({root:e,content:t,ads:s,ui:i,eventName:r,err:a={reason:""}}){A("teardown(event: %s)",r),e.classList.add("is-seamless"),i.classList.remove("is-vpaid"),e.classList.remove("is-waiting"),a.reason&&A("teardown(:err, reason: %s) %o",a.reason);i.classList.remove("on");const n=s.getLastAd();if(i.showFirstFrame(e),!s.shouldRestartContent())return A("Lifecycle.teardown(:skip_restart, reason: %s)","Ad prevented restarting content"),R(e);if(t.currentTime>0&&t.currentTime>=t.duration||"postroll"==s.ad_type||!1===(null==n?void 0:n.restart))return A("Lifecycle.teardown(:skip_restart, reason: %s)","was a postroll ad"),R(e);""===t.currentSrc&&t.setSrc(t.original_src);t.paused&&s.shouldRestartContent()&&(A("Lifecycle.teardown(:toggle_play, %s)","attempting to restart content"),await t.togglePlay(!0));if(!t.paused)return A("Lifecycle.teardown(:ok)","restarted video content"),R(e)}({root:t,content:s,ads:i,ui:o,err:e.detail,eventName:e.type}));let l=!!e.autoplay;s.on("viewenter",()=>{l&&i.resume()}),s.on("viewleave",()=>{l=!i.paused,i.pause()})}function O({ads:e,content:t,state:s}){s.listening||(t.on(["timeupdate","seeked","playing","seeking"],s=>{e.adPlaying&&e.adapter.isLinearAd()&&!e.adapter.isSharedVideoTag()&&!t.paused&&t.pause(),M({ads:e,content:t,seek:"seeking"===s.type})}),s.listening=!0)}function M({ads:e,content:t,seek:s=!1}){e&&e.setCurrentTime(t.currentTime,void 0,s)}function R(e){e.classList.remove("is-seamless")}const P=f("ads/timers");class TimerRegistry{constructor(e={},t={}){this.intervals=e,this.timers=t}}let k=-1;function D(e,t,s){const i=setInterval(s,t);if(P("TimerRegistry.createInterval() -> "+i,e.intervals),"object"==typeof i){const t=++k;return e.intervals[t]=t,t}return e.intervals[i]=i,i}function C(e){if(e)return P("TimerRegistry.empty()",Object.keys(e.timers),Object.keys(e.intervals)),Object.keys(e.intervals).forEach(t=>function(e,t){return P("TimerRegistry.removeInterval() -> "+t,e.intervals),clearInterval(e.intervals[t]),delete e.intervals[t],e}(e,t)),Object.keys(e.timers).forEach(t=>function(e,t){return P("TimerRegistry.removeTimeout() -> "+t,e.timers),clearTimeout(e.timers[t]),delete e.timers[t],e}(e,t)),e}class Schedule{constructor(e,t={}){this._ads=e,this._opts=t,this._nextIndex=0,this._postroll=void 0,this._loadPending=!1,this._postrollActive=!1,this.reset(this._ads)}toJSON(){const e=(this._ads||[]).slice(this._nextIndex);return this._postroll&&e.push(this._postroll),e}reset(e){this.setAds(e),this._nextIndex=0,this._postrollActive=!1}resetCounter(){this._nextIndex=0,this._postrollActive=!1}setAds(e){this._ads=e||[],this.sort()}getAds(){return this._ads}getNextAd(e){return this._ads[this._nextIndex]||e}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(e){this._opts.content_duration=e}increment(){++this._nextIndex}decrement(){this._nextIndex>0&&--this._nextIndex}getNextIndex(){return this._nextIndex}getCurrentType(){const e=this.getCurrentAd();if(e)return Schedule.kindOf(e.time)}sort(){this._postroll=this._ads.find(e=>-1===e.time),this._ads=this._ads.filter(e=>e!==this._postroll).sort((e,t)=>e.time===t.time?this._ads.indexOf(e)-this._ads.indexOf(t):e.time-t.time)}shallPlayAd(e){if(this._loadPending)return!1;const t=this.getCurrentAd()||this.getNextAd();return!!(t&&t.time<=e&&-1!==t.time)}shallPlayNext(){const e=this.getNextAd(),t=this.getCurrentAd();return!(!e||!t||e.time!==t.time)}waitForLoad(e,t,s){if(this._loadPending=!1,!t)return!1;const i=s?this._opts.preload_advance:0;return t.time>=0?this._loadPending=e<t.time-i:-1===t.time&&(this._loadPending=this._opts.content_duration>0&&-1!==e?e<this._opts.content_duration-i:-1!==e),this._loadPending}static hasPreroll(e){return!!e.find(e=>0===e.time)}static isOutstream(e){return Schedule.hasPreroll(e)&&!!e[0].outstream}static kindOf(e){switch(e){case 0:return"preroll";case-1:return"postroll";default:return"midroll"}}}function I(e){try{return e.getAdPodInfo().getPodIndex()}catch(e){return}}class IMA{constructor(e){this.eventHandler=e,this.log=f("ads/adapter/ima"),this.google=window.google,this._adHandlers=[],this._timers=new TimerRegistry,this._started=!1,this._volumeLevel=0,this._adLoaded=!1,this._paused=!1,this._all_ads_completed=!1,this._currentDuration=0,this._currentRemaining=0,this._currentDisplayTs=0,this._iosPlaysInline=!1,this.sharedVideoTag=!1,this._isInitialized=!1,this._prepared=!1,this.opts={}}async init(e){this.log("init",this.videoTag,e),this.opts=e,this._dimensions={width:e.width,height:e.height,linear:e.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(e){this.log("initAdapter failed:",e),this._prepared=!1,this.eventHandler.trigger("ad-adapter-init-failed")}}isReady(){return!!this._isInitialized}setIOSPlaysInline(e){this.log("setIOSPlaysInline",e),this.sharedVideoTag=!e,this.initialize(Object.assign(Object.assign({},this.opts),{DisableCustomPlaybackForIOS10Plus:e}))}getIOSPlaysInline(){return this._iosPlaysInline}setVideoTag(e){this.videoTag=e}isLinearAd(){return!!this._adLinear}isSharedVideoTag(){return!!this.sharedVideoTag}getVideoTag(){return this.videoTag}getDimensions(){return this._dimensions||{}}getOpts(){return this.opts}isPaused(){return this._paused}destroy(){C(this._timers),this._adHandlers&&this._adHandlers.forEach(e=>e()),this._adHandlers=void 0,this._adDisplayContainer&&this._adDisplayContainer.destroy(),this._adDisplayContainer=void 0,this._adsLoader&&this._adsLoader.destroy(),this._adsLoader=void 0,this._adsManager&&this._adsManager.destroy(),this._adsManager=void 0}stop(){this._adsManager&&this._adsManager.stop()}initialize(e){const t=this.isAdPod(),s=this._adLoaded||t;if(this.cleanup(),!this.videoTag)return console.warn("videoTag not set during initialization");this.opts=e,this._volumeLevel=e.volume;const i=this.google.ima.settings;e.NumRedirects=e.NumRedirects||e.redirects;const r={VpaidMode:this.google.ima.ImaSdkSettings.VpaidMode.INSECURE,DisableCustomPlaybackForIOS10Plus:!0};if(i.setVpaidMode(e.VpaidMode||r.VpaidMode),i.setDisableCustomPlaybackForIOS10Plus(e.DisableCustomPlaybackForIOS10Plus||r.DisableCustomPlaybackForIOS10Plus),"NumRedirects"in e&&i.setNumRedirects(e.NumRedirects),"AutoPlayAdBreaks"in e&&i.setAutoPlayAdBreaks(e.AutoPlayAdBreaks),"Locale"in e&&i.setLocale(e.Locale),"Ppid"in e&&i.setPpid(e.Ppid),!document.body.contains(e.container))throw new Error("AdDisplayContainer was not found in the document.body");this._adDisplayContainer=new this.google.ima.AdDisplayContainer(e.container,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({},e),{volume:this.videoTag.volume,muted:this.videoTag.muted})),this._adsLoader.addEventListener(this.google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,t=>{if(!this.videoTag)return;this.log("ima.initialise(:done -> ADS_MANAGER_LOADED)\n%o",Object.assign(Object.assign({},e),{volume:this.videoTag.volume,muted:this.videoTag.muted}));const s=new this.google.ima.AdsRenderingSettings;this.log("ima.rendering(preload: %s)",!!e.preload_ads),s.useStyledNonLinearAds=!0,s.enablePreloading=!!e.preload_ads,"number"==typeof e.media_timeout&&(s.loadVideoTimeout=e.media_timeout),s.restoreCustomPlaybackStateOnAdBreakComplete=!e.DisableCustomPlaybackForIOS10Plus,this.sharedVideoTag&&(s.playAdsAfterTime=this.videoTag.currentTime),this.eventHandler.trigger("ad-ima-rendering-settings",s);const i=this._adsManager=t.getAdsManager(this.videoTag,s);this.eventHandler.trigger("ad-ima-adapter-init",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.STARTED,e=>{this.debugEvent(e);const t=e.getAd();t&&(this._currentDuration=t.getDuration(),this._currentDisplayTs=Date.now(),this.emitWithAd("ad-started",t),t.isLinear()&&IMA.pollRemaining({ima:this,adsManager:i}))}),i.addEventListener(this.google.ima.AdEvent.Type.COMPLETE,e=>{this.debugEvent(e);const t=e.getAd();t&&this.emitWithAd("ad-completed",t),C(this._timers)}),i.addEventListener(this.google.ima.AdEvent.Type.SKIPPED,e=>{this.debugEvent(e);const t=e.getAd();t&&this.emitWithAd("ad-skipped",t)}),i.addEventListener(this.google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED,e=>{this.debugEvent(e);const t=e.getAd();t&&this.emitWithAd("ad-pause-content",t)});const r=()=>{this._started=!1,this._currentDisplayTs=0,this.eventHandler.trigger("ad-break-completed")};i.addEventListener(this.google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED,e=>{this.debugEvent(e),r()}),i.addEventListener(this.google.ima.AdEvent.Type.VOLUME_CHANGED,e=>{this.log("IMA::volume(type: %s, event: %o)",e);const t=i.getVolume();this._volumeLevel=t,this.eventHandler.trigger("ad-volume-changed",t)});const a=e=>{this._paused=e,this.eventHandler.trigger(e?"ad-paused":"ad-resumed")};i.addEventListener(this.google.ima.AdEvent.Type.PAUSED,()=>a(!0)),i.addEventListener(this.google.ima.AdEvent.Type.RESUMED,()=>a(!1)),i.addEventListener(this.google.ima.AdEvent.Type.STARTED,()=>a(!1)),i.addEventListener(this.google.ima.AdEvent.Type.VOLUME_MUTED,e=>{this.log("IMA::volume(type: %s, event: %o)","mute",e),this.eventHandler.trigger("ad-muted")});const{width:n,height:o}=e;n&&o&&(i.init(n,o,this.google.ima.ViewMode.NORMAL),this.log("ima.initialise: done initializing"))}),s&&(this.log("Event(reload: %s)","reload-ad-requested"),this.eventHandler.trigger("reload-ad-requested",t)),this.eventHandler.trigger(p,this)}destroyManager(e="unknown"){if(!this._adsManager)return this.log("ima::destroyManager(:skip, label: %s)",e);this.log("ima::destroyManager(:ok, label: %s)",e),this._adsManager.destroy()}reset(){this.destroyManager("reset"),C(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(e=>{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),e(this._adsManager)})})}async initAd(e,t=5e3){this.log(`ima.initAd(adTag: ${e}, timeout: ${t})`);try{await this.requestAd(e,t),this._adLoaded=!0}catch(e){throw this.log("ima.initAd:",e),this._adLoaded=!1,e}finally{C(this._timers)}}async requestAd(e,t){if(this.destroyManager("requestAd"),!this.videoTag)return;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:t,adTag:e,_volumeLevel:this._volumeLevel,manager:this._adsManager})),this.clearAdHandlers();const n=new this.google.ima.AdsRequest;n.adTagUrl=e;const{height:o,width:d}=this.opts;if(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=t,this.eventHandler.trigger("ad-ima-before-ads-request",{request:n}),!this._adsLoader)return;this._adsLoader.requestAds(n);return new Promise(async(e,s)=>{const r=t=>{clearTimeout(o),e(t)},n=e=>{clearTimeout(o),s(e)};this.once(this._adsLoader,this.google.ima.AdErrorEvent.Type.AD_ERROR,e=>{this.emitError("ad-request-error",e),n(new Error("Ad load failed"))});const o=setTimeout(()=>{const e=new Error("Ad internal timeout reached");this.eventHandler.trigger("ad-timeout",e),s(e)},1.5*(t+(this.opts.media_timeout||5e3))),d=await this.waitForAdsManager();this.volume(a?0:this._volumeLevel),this.eventHandler.trigger("ad-volume-changed",this._volumeLevel);const l=this.cuepoints();if(l&&l.length&&0!==l[0])return r({ad:!1,adsManager:d});this.once(d,this.google.ima.AdErrorEvent.Type.AD_ERROR,e=>{this.emitError("ad-playback-error",e),n(e)}),this.once(d,this.google.ima.AdEvent.Type.ALL_ADS_COMPLETED,()=>{this._all_ads_completed=!0,r(null)}),this.once(d,this.google.ima.AdEvent.Type.LOADED,e=>{this.eventHandler.trigger("ad-request-completed",{request_load_time:Date.now()-i});const t=e.getAd();t&&(this.log("ima.requestAd: AD_REQUEST_COMPLETED",t.getContentType()),"application/javascript"==t.getContentType()&&this.eventHandler.trigger("vpaid-init",t),r(null))}),this.once(d,this.google.ima.AdEvent.Type.CLICK,()=>{this.log("ima.requestAd: click event"),this.pause()})})}async playAd(){if(this.log("ima.playAd()",this),!this._adsManager||!this._adLoaded)return;const e=this.currentAd();if(e&&(!this.sharedVideoTag||e.isLinear()))try{await this.startAndWaitForAdCompletion(this._adsManager,e.isLinear())}catch(e){throw this.log("ima.playAd",e),e}finally{this._adLoaded=!1,C(this._timers)}}startAndWaitForAdCompletion(e,t){if(!this._started)return this.log("ima.startAndWaitForAdCompletion(manager: %o)",{volume:e.getVolume()}),new Promise((s,i)=>{let r=!1;this.once(e,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(e,this.google.ima.AdErrorEvent.Type.AD_ERROR,async e=>{this.log("ima.startAndWaitForAdCompletion: beginning error recovery ->",e),r=!0;try{const{ok:t}=await IMA.pollForFatalError({err:e,ima:this});t&&(r=!1)}catch(t){this._started=!1,i(e)}}),t&&(this._started=!0),e.start(),this.eventHandler.trigger("ad-play-requested")})}pause(){this.log("ima.pause()"),this._adsManager&&this._adsManager.pause()}resume(){this.log("ima.resume()"),this._adsManager&&this._adsManager.resume()}volume(e){if(this._adsManager)try{return arguments.length>0&&"number"==typeof e&&this._adsManager.setVolume(e),this._volumeLevel=this._adsManager.getVolume()}catch(e){this.log("ima.volume() failed (%o)",e)}}onResize({width:e,height:t,linear:s,silent:i,resize_non_linear:r}){this._adsManager&&(this._adLinear=void 0===s?this._adLinear:s,this.opts&&(e||t)&&(!1===s&&(e+=10,t+=10),this._dimensions={width:e,height:t,linear:s},s&&(this.opts.width=e,this.opts.height=t),(this._adLinear||r)&&(i||this.log("ima.onResize %s x %s",e,t),this._adsManager.resize(e,t,this.google.ima.ViewMode.NORMAL))))}getAdInfo(){const e=this.currentAd();if(e)return{duration:e.getDuration(),currentTime:this._currentRemaining}}currentAd(){const e=this._adsManager;if(e)return e.getCurrentAd()}isAdPod(){const e=this.cuepoints();return!!(e&&e.length>1)}cuepoints(){return this._adsManager&&this._adsManager.getCuePoints()}async contentComplete(){this.log("ima.contentComplete() -> ",this),this._adsLoader&&this._adsLoader.contentComplete();const e=this.cuepoints();e&&-1!==e.indexOf(-1)&&await new Promise(e=>{IMA.race(this.eventHandler,["ad-break-completed","ad-error"],e)})}isUiDisabled(){try{const e=this.currentAd();return e&&e.isUiDisabled()}catch(e){return null}}getAdPodInfo(){try{const e=this.currentAd();return e&&e.getAdPodInfo()}catch(e){return null}}canDismissNonLinear(){const e=this.currentAd();if(!e||e.isLinear()||!this._adsManager||!this._currentDisplayTs)return!0;const t=Date.now(),s=e.getMinSuggestedDuration();return t-this._currentDisplayTs>1e3*s}static unwrapError(e,t){if(!e)return"";if("function"==typeof e.getMessage){return e.getMessage()}return e.message?e.message:t||""}static pollForFatalError({err:e,ima:t}){let s;try{const t=e.getError(),i=t.getInnerError(),r=i?IMA.unwrapError(i,t.message):"";s={reason:r,type:t.getType(),code:t.getErrorCode()}}catch(e){}const i=t._currentRemaining;return new Promise((e,r)=>{const a=setTimeout(()=>{t.eventHandler&&t.eventHandler.trigger("ad-playback-error",s),r(new Error("Ad not progressing"))},2500);t.eventHandler.once("ad-progress",t=>{const s=t.detail.remaining;-1!==s&&s<i&&(clearTimeout(a),e({ok:1}))})})}static pollRemaining({ima:e,adsManager:t}){let s=-1;return D(e._timers,250,(function(){e._currentRemaining=t.getRemainingTime(),s!=e._currentRemaining&&(s=e._currentRemaining,e.eventHandler.trigger("ad-progress",{remaining:e._currentRemaining,duration:e._currentDuration}))}))}once(e,t,s){this._adHandlers.push(function(e,t,s){const i=r=>{s(r),e.removeEventListener(t,i)};return e.addEventListener(t,i),()=>e.removeEventListener(t,i)}(e,t,s))}static race(e,t,s){t.forEach(i=>{const r=(...i)=>{t.forEach(t=>e.removeListener(t,r)),s(i)};e.on(i,r)})}clearAdHandlers(){this.log("ima.clearAdHandlers"),this._adHandlers.forEach(e=>e()),this._adHandlers=[]}emitWithAd(e,t){if(this.log("ima.emitWithAd",e,t),!this._adsManager)return;const s=I(t),i=s?Schedule.kindOf(s):"unknown",r=function(e){try{return e.getAdPodInfo().getAdPosition()}catch(e){return}}(t),a=function(e){try{return e.getAdPodInfo().getTotalAds()}catch(e){return}}(t),n={ad_type:i,ad:{duration:t.getDuration(),width:t.getWidth(),height:t.getHeight(),position:r,totals:a},volume:this._adsManager.getVolume(),vast_ad_id:t.getAdId(),linear:t.isLinear(),mime_type:t.getContentType(),ima_event:!0};this.log(`emitWithAd::event(name: ${e}, data: %o, ad: %o)`,n,t),this.eventHandler.trigger(e,n)}emitError(e,t){const s={vast_error_type:t.getError().getType(),reason:t.getError().getMessage(),vast_error:t.getError().getErrorCode()};this.log(`ima.error(${e})`,s),this.eventHandler.trigger(e,s)}debugEvent(e){try{const t=e.getAd();if(!t)return;this.log(`ima.event.${e.type} ->`,{event:e,data:e.getAdData(),position:I(t),ad:t})}catch(e){}}}var U=function(e){var t={exports:{}};return e(t,t.exports),t.exports}((function(e,t){var s=function(){for(var e=new Array(256),t=0;t<256;++t)e[t]="%"+((t<16?"0":"")+t.toString(16)).toUpperCase();return e}(),i=Object.prototype.hasOwnProperty;t.arrayToObject=function(e,t){for(var s=t.plainObjects?Object.create(null):{},i=0;i<e.length;++i)void 0!==e[i]&&(s[i]=e[i]);return s},t.merge=function(e,s,r){if(!s)return e;if("object"!=typeof s){if(Array.isArray(e))e.push(s);else{if("object"!=typeof e)return[e,s];(r.plainObjects||r.allowPrototypes||!i.call(Object.prototype,s))&&(e[s]=!0)}return e}if("object"!=typeof e)return[e].concat(s);var a=e;return Array.isArray(e)&&!Array.isArray(s)&&(a=t.arrayToObject(e,r)),Object.keys(s).reduce((function(e,a){var n=s[a];return i.call(e,a)?e[a]=t.merge(e[a],n,r):e[a]=n,e}),a)},t.decode=function(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(t){return e}},t.encode=function(e){if(0===e.length)return e;for(var t="string"==typeof e?e:String(e),i="",r=0;r<t.length;++r){var a=t.charCodeAt(r);45===a||46===a||95===a||126===a||a>=48&&a<=57||a>=65&&a<=90||a>=97&&a<=122?i+=t.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&t.charCodeAt(r)),i+=s[240|a>>18]+s[128|a>>12&63]+s[128|a>>6&63]+s[128|63&a])}return i},t.compact=function(e,s){if("object"!=typeof e||null===e)return e;var i=s||[],r=i.indexOf(e);if(-1!==r)return i[r];if(i.push(e),Array.isArray(e)){for(var a=[],n=0;n<e.length;++n)e[n]&&"object"==typeof e[n]?a.push(t.compact(e[n],i)):void 0!==e[n]&&a.push(e[n]);return a}for(var o=Object.keys(e),d=0;d<o.length;++d){var l=o[d];e[l]=t.compact(e[l],i)}return e},t.isRegExp=function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},t.isBuffer=function(e){return null!=e&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))}})),N={brackets:function(e){return e+"[]"},indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},F={delimiter:"&",strictNullHandling:!1,skipNulls:!1,encode:!0,encoder:U.encode},x=function e(t,s,i,r,a,n,o,d,l){var c=t;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||U.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(e(c[m],i(s,m),i,r,a,n,o,d,l)):h.concat(e(c[m],s+(l?"."+m:"["+m+"]"),i,r,a,n,o,d,l)))}return h},B=Object.prototype.hasOwnProperty,q={delimiter:"&",depth:5,arrayLimit:20,parameterLimit:1e3,strictNullHandling:!1,plainObjects:!1,allowPrototypes:!1,allowDots:!1,decoder:U.decode},j=function(e,t,s){if(e){var i=s.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,r=/(\[[^[\]]*])/g,a=/(\[[^[\]]*])/.exec(i),n=a?i.slice(0,a.index):i,o=[];if(n){if(!s.plainObjects&&B.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&&B.call(Object.prototype,a[1].slice(1,-1))&&!s.allowPrototypes)return;o.push(a[1])}return a&&o.push("["+i.slice(a.index)+"]"),function e(t,s,i){if(!t.length)return s;var r,a=t.shift();if("[]"===a)r=(r=[]).concat(e(t,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]=e(t,s,i):r[n]=e(t,s,i)}return r}(o,t,s)}},V=function(e,t){var s,i,r=e,a=t||{},n=void 0===a.delimiter?F.delimiter:a.delimiter,o="boolean"==typeof a.strictNullHandling?a.strictNullHandling:F.strictNullHandling,d="boolean"==typeof a.skipNulls?a.skipNulls:F.skipNulls,l=("boolean"==typeof a.encode?a.encode:F.encode)?"function"==typeof a.encoder?a.encoder:F.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 N?a.arrayFormat:"indices"in a?a.indices?"indices":"repeat":"indices";var g=N[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(x(r[_],_,g,o,d,l,i,c,u)))}return p.join(n)},H=function(e,t){var s=t||{};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||U.isRegExp(s.delimiter)?s.delimiter:q.delimiter,s.depth="number"==typeof s.depth?s.depth:q.depth,s.arrayLimit="number"==typeof s.arrayLimit?s.arrayLimit:q.arrayLimit,s.parseArrays=!1!==s.parseArrays,s.decoder="function"==typeof s.decoder?s.decoder:q.decoder,s.allowDots="boolean"==typeof s.allowDots?s.allowDots:q.allowDots,s.plainObjects="boolean"==typeof s.plainObjects?s.plainObjects:q.plainObjects,s.allowPrototypes="boolean"==typeof s.allowPrototypes?s.allowPrototypes:q.allowPrototypes,s.parameterLimit="number"==typeof s.parameterLimit?s.parameterLimit:q.parameterLimit,s.strictNullHandling="boolean"==typeof s.strictNullHandling?s.strictNullHandling:q.strictNullHandling,""===e||null==e)return s.plainObjects?Object.create(null):{};for(var i="string"==typeof e?function(e,t){for(var s={},i=e.split(t.delimiter,t.parameterLimit===1/0?void 0:t.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=t.decoder(o),n=t.strictNullHandling?null:""):(a=t.decoder(o.slice(0,d)),n=t.decoder(o.slice(d+1))),B.call(s,a)?s[a]=[].concat(s[a]).concat(n):s[a]=n}return s}(e,s):e,r=s.plainObjects?Object.create(null):{},a=Object.keys(i),n=0;n<a.length;++n){var o=a[n],d=j(o,i[o],s);r=U.merge(r,d,s)}return U.compact(r)};const z=f("fpads:macros"),Q=/\[([\s\S]+?)\]/g;class Macros{constructor(e={},t=Q){this.vars=e,this.pattern=t}static run(e){try{return e()}catch(e){return void console.error(e)}}static merge(...e){return e.reduce((e,t)=>Object.assign(e,t),{})}static cast(e){return void 0===e?"":"function"==typeof e?encodeURIComponent(Macros.run(e)||""):"string"==typeof e?encodeURIComponent(e):""}static normalize(e){return e.trim()}static process_obj(e,t,s){return Object.keys(e).reduce((i,r)=>{const a=Macros.process_str(r,t,s,!0),n=e[r];return null===n?(i[a]=n,i):"object"==typeof n?(i[a]=Macros.process_obj(n,t,s),i):"string"==typeof n?(i[a]=Macros.process_str(n,t,s),i):(console.error(new Error(`${n} at ${r} not a handled Macro type`)),i)},{})}static process_str(e,t,s,i=!1){return e.replace(t.pattern,(e,t)=>{const r=Macros.normalize(t);if(!(r in s)||void 0===s[r])return e;const a=s[r],n=i?a:Macros.cast(a);return z("Macro.replace(raw: %s, macro: %s, value: %s)",i,t,n),n})}fork(e={},t=this.pattern){const s=Macros.merge(this.vars,e);return new Macros(s,t)}compile(e,t={}){const s=Macros.merge(this.vars,t),[i,r]=e.split("?"),a=H(r||"",{strictNullHandling:!0,decoder:e=>e}),n=V(Macros.process_obj(a,this,s),{encode:!1,strictNullHandling:!0});return Macros.process_str(i,this,s,!0)+"?"+n}}function W(e,t={width:0,height:0}){let s,i;try{const e=document.createElement("a");e.href=s=window.location!=window.parent.location?document.referrer:document.location.href,i=e.hostname}catch(e){console.error(e)}const{width:r,height:a}=t,{video_source:n}=e||{},o=function(){const e=window;return"object"==typeof e.__flowplayerAdParameters?e.__flowplayerAdParameters:{}}();return Object.assign({random:Date.now(),page_url:s,domain:i,player_width:r,player_height:a,video_url:n,videourl:n},o)}async function G(e){if("function"!=typeof e)return e;try{return await e()}catch(e){return""}}Macros.patterns={BRACKETS:Q,CURLY:/\{([\s\S]+?)\}/g,UNDERSCORE:/__([\s\S]+?)__/g};const $=Object.prototype,K=Object.getPrototypeOf;const Y=f("fpads:ads:state");var J;!function(e){e[e.IDLE=0]="IDLE",e[e.INITIALIZING=1]="INITIALIZING",e[e.FETCHING_AD=2]="FETCHING_AD",e[e.AD_AVAILABLE=4]="AD_AVAILABLE",e[e.BREAK_ACTIVE=8]="BREAK_ACTIVE",e[e.PLAYING=16]="PLAYING",e[e.FATAL_ERROR=32]="FATAL_ERROR"}(J||(J={}));class AdsState{constructor(e=0){this._state=e}static of(){return new AdsState}reset(){this._state=0}toggleState(e,t){return void 0===e&&Y(new Error("AdState cannot toggleState for `undefined`")),null==typeof t?this._state^=e:t?void(this._state|=e):this._state&=~e}hasAll(e){return this._state==(this._state|e)}hasAny(e){return!!(this._state&e)}get state(){return this._state}}function Z(e,t,s){const i=function(e,t){const s=new CustomEvent(e,{detail:t,cancelable:!0});return t&&Object.defineProperty(s,"data",{get:()=>t}),s}(t,s);return e.dispatchEvent(i),e}!function(){let e=!1;try{const t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(e){}}();const X={ok:f("fpads:analytics:request-queue"),err:f("fpads:analytics:request-queue:err"),warn:f("fpads:analytics:request-queue:warn")};class RequestQueue{constructor(e=[],t=[],s={failures:0,ttl:0}){this.pending=e,this.open=t,this.stats=s}static of(){return new RequestQueue}static is_empty(e){return 0==e.pending.length}static is_high_water(e){return e.open.length==RequestQueue.MAX_OPEN_REQUESTS}static maybe_spawn_req(e){if(RequestQueue.is_empty(e))return X.ok("maybe_spawn_req called Queue that is EMPTY"),e;if(RequestQueue.is_high_water(e))return X.warn("maybe_spawn_req called on Queue that is HIGH_WATER"),e;try{const t=RequestQueue.lpop(e);t&&RequestQueue.request(e,t)}catch(e){X.err(e)}}static increment_failures(e){return e.stats.failures++,e.stats.failures>RequestQueue.MAX_FAILURE_COUNT&&(e.stats.ttl=Date.now()+RequestQueue.REQUEST_TTL_MS),e}static handle_error(e,t){RequestQueue.rm(e,t),RequestQueue.increment_failures(e)}static request(e,[t,s,i]){if(X.ok(`Request[${i.event_type}] request`,i,e.stats),Date.now()<e.stats.ttl)return X.warn(`Request[${i.event_type}] skipping because too many errors too quickly`,e.stats);const r=new XMLHttpRequest;e.open.push(r),r.timeout=RequestQueue.REQUEST_TIMEOUT_MS,r.ontimeout=function(){RequestQueue.handle_error(e,r),X.warn(`Request[${i.event_type}] timed out in ${r.timeout}ms`,e.stats)},r.onerror=function(t){RequestQueue.handle_error(e,r),t&&X.err(t),X.warn(`Request[${i.event_type}] encountered an Error`,r.responseText,e.stats)},r.onreadystatechange=function(){r.readyState==XMLHttpRequest.DONE&&RequestQueue.rm(e,r),Math.floor(r.status/100)},r.onload=function(){RequestQueue.rm(e,r),e.stats.failures&&e.stats.failures--,X.ok(`Request[${i.event_type}] :ok`,r.status)},r.open(s,t),r.setRequestHeader("Content-Type","text/plain;charset=UTF-8");try{r.send(JSON.stringify(i))}catch(e){X.err(e)}}static rpush(e,...t){return t.forEach(t=>{if(RequestQueue.is_high_water(e))return X.warn("Too many open requests, skipping",e.stats);e.pending.push(t),RequestQueue.maybe_spawn_req(e)}),e}static lpop(e){return e.pending.shift()}static rm(e,t){const s=e.open.lastIndexOf(t);return~s&&e.open.splice(s,1),e}}RequestQueue.MAX_OPEN_REQUESTS=3,RequestQueue.REQUEST_TIMEOUT_MS=4e3,RequestQueue.REQUEST_TTL_MS=5e3,RequestQueue.MAX_FAILURE_COUNT=3;const ee={"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"},te={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"},se={tablet:"tablet",mobile:"mobile",desktop:"desktop",tv:"tv"},ie={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"},re={EdgeHTML:"EdgeHTML",Blink:"Blink",Trident:"Trident",Presto:"Presto",Gecko:"Gecko",WebKit:"WebKit"};class Utils{static getFirstMatch(e,t){const s=t.match(e);return s&&s.length>0&&s[1]||""}static getSecondMatch(e,t){const s=t.match(e);return s&&s.length>1&&s[2]||""}static matchAndReturnConst(e,t,s){if(e.test(t))return s}static getWindowsVersionName(e){switch(e){case"NT":return"NT";case"XP":return"XP";case"NT 5.0":return"2000";case"NT 5.1":return"XP";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(e){const t=e.split(".").splice(0,2).map(e=>parseInt(e,10)||0);if(t.push(0),10===t[0])switch(t[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(e){const t=e.split(".").splice(0,2).map(e=>parseInt(e,10)||0);if(t.push(0),!(1===t[0]&&t[1]<5))return 1===t[0]&&t[1]<6?"Cupcake":1===t[0]&&t[1]>=6?"Donut":2===t[0]&&t[1]<2?"Eclair":2===t[0]&&2===t[1]?"Froyo":2===t[0]&&t[1]>2?"Gingerbread":3===t[0]?"Honeycomb":4===t[0]&&t[1]<1?"Ice Cream Sandwich":4===t[0]&&t[1]<4?"Jelly Bean":4===t[0]&&t[1]>=4?"KitKat":5===t[0]?"Lollipop":6===t[0]?"Marshmallow":7===t[0]?"Nougat":8===t[0]?"Oreo":9===t[0]?"Pie":void 0}static getVersionPrecision(e){return e.split(".").length}static compareVersions(e,t,s=!1){const i=Utils.getVersionPrecision(e),r=Utils.getVersionPrecision(t);let a=Math.max(i,r),n=0;const o=Utils.map([e,t],e=>{const t=a-Utils.getVersionPrecision(e),s=e+new Array(t+1).join(".0");return Utils.map(s.split("."),e=>new Array(20-e.length).join("0")+e).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(e,t){const s=[];let i;if(Array.prototype.map)return Array.prototype.map.call(e,t);for(i=0;i<e.length;i+=1)s.push(t(e[i]));return s}static find(e,t){let s,i;if(Array.prototype.find)return Array.prototype.find.call(e,t);for(s=0,i=e.length;s<i;s+=1){const i=e[s];if(t(i,s))return i}}static assign(e,...t){const s=e;let i,r;if(Object.assign)return Object.assign(e,...t);for(i=0,r=t.length;i<r;i+=1){const e=t[i];if("object"==typeof e&&null!==e){Object.keys(e).forEach(t=>{s[t]=e[t]})}}return e}static getBrowserAlias(e){return ee[e]}static getBrowserTypeByAlias(e){return te[e]||""}}const ae=/version\/(\d+(\.?_?\d+)+)/i,ne=[{test:[/googlebot/i],describe(e){const t={name:"Googlebot"},s=Utils.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,e)||Utils.getFirstMatch(ae,e);return s&&(t.version=s),t}},{test:[/opera/i],describe(e){const t={name:"Opera"},s=Utils.getFirstMatch(ae,e)||Utils.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/opr\/|opios/i],describe(e){const t={name:"Opera"},s=Utils.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i,e)||Utils.getFirstMatch(ae,e);return s&&(t.version=s),t}},{test:[/SamsungBrowser/i],describe(e){const t={name:"Samsung Internet for Android"},s=Utils.getFirstMatch(ae,e)||Utils.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/Whale/i],describe(e){const t={name:"NAVER Whale Browser"},s=Utils.getFirstMatch(ae,e)||Utils.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/MZBrowser/i],describe(e){const t={name:"MZ Browser"},s=Utils.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,e)||Utils.getFirstMatch(ae,e);return s&&(t.version=s),t}},{test:[/focus/i],describe(e){const t={name:"Focus"},s=Utils.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,e)||Utils.getFirstMatch(ae,e);return s&&(t.version=s),t}},{test:[/swing/i],describe(e){const t={name:"Swing"},s=Utils.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,e)||Utils.getFirstMatch(ae,e);return s&&(t.version=s),t}},{test:[/coast/i],describe(e){const t={name:"Opera Coast"},s=Utils.getFirstMatch(ae,e)||Utils.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/opt\/\d+(?:.?_?\d+)+/i],describe(e){const t={name:"Opera Touch"},s=Utils.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i,e)||Utils.getFirstMatch(ae,e);return s&&(t.version=s),t}},{test:[/yabrowser/i],describe(e){const t={name:"Yandex Browser"},s=Utils.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,e)||Utils.getFirstMatch(ae,e);return s&&(t.version=s),t}},{test:[/ucbrowser/i],describe(e){const t={name:"UC Browser"},s=Utils.getFirstMatch(ae,e)||Utils.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/Maxthon|mxios/i],describe(e){const t={name:"Maxthon"},s=Utils.getFirstMatch(ae,e)||Utils.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/epiphany/i],describe(e){const t={name:"Epiphany"},s=Utils.getFirstMatch(ae,e)||Utils.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/puffin/i],describe(e){const t={name:"Puffin"},s=Utils.getFirstMatch(ae,e)||Utils.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/sleipnir/i],describe(e){const t={name:"Sleipnir"},s=Utils.getFirstMatch(ae,e)||Utils.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/k-meleon/i],describe(e){const t={name:"K-Meleon"},s=Utils.getFirstMatch(ae,e)||Utils.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/micromessenger/i],describe(e){const t={name:"WeChat"},s=Utils.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,e)||Utils.getFirstMatch(ae,e);return s&&(t.version=s),t}},{test:[/qqbrowser/i],describe(e){const t={name:/qqbrowserlite/i.test(e)?"QQ Browser Lite":"QQ Browser"},s=Utils.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i,e)||Utils.getFirstMatch(ae,e);return s&&(t.version=s),t}},{test:[/msie|trident/i],describe(e){const t={name:"Internet Explorer"},s=Utils.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/\sedg\//i],describe(e){const t={name:"Microsoft Edge"},s=Utils.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/edg([ea]|ios)/i],describe(e){const t={name:"Microsoft Edge"},s=Utils.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/vivaldi/i],describe(e){const t={name:"Vivaldi"},s=Utils.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/seamonkey/i],describe(e){const t={name:"SeaMonkey"},s=Utils.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/sailfish/i],describe(e){const t={name:"Sailfish"},s=Utils.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,e);return s&&(t.version=s),t}},{test:[/silk/i],describe(e){const t={name:"Amazon Silk"},s=Utils.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/phantom/i],describe(e){const t={name:"PhantomJS"},s=Utils.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/slimerjs/i],describe(e){const t={name:"SlimerJS"},s=Utils.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe(e){const t={name:"BlackBerry"},s=Utils.getFirstMatch(ae,e)||Utils.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/(web|hpw)[o0]s/i],describe(e){const t={name:"WebOS Browser"},s=Utils.getFirstMatch(ae,e)||Utils.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/bada/i],describe(e){const t={name:"Bada"},s=Utils.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/tizen/i],describe(e){const t={name:"Tizen"},s=Utils.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,e)||Utils.getFirstMatch(ae,e);return s&&(t.version=s),t}},{test:[/qupzilla/i],describe(e){const t={name:"QupZilla"},s=Utils.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,e)||Utils.getFirstMatch(ae,e);return s&&(t.version=s),t}},{test:[/firefox|iceweasel|fxios/i],describe(e){const t={name:"Firefox"},s=Utils.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/electron/i],describe(e){const t={name:"Electron"},s=Utils.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/MiuiBrowser/i],describe(e){const t={name:"Miui"},s=Utils.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/chromium/i],describe(e){const t={name:"Chromium"},s=Utils.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,e)||Utils.getFirstMatch(ae,e);return s&&(t.version=s),t}},{test:[/chrome|crios|crmo/i],describe(e){const t={name:"Chrome"},s=Utils.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/GSA/i],describe(e){const t={name:"Google Search"},s=Utils.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test(e){const t=!e.test(/like android/i),s=e.test(/android/i);return t&&s},describe(e){const t={name:"Android Browser"},s=Utils.getFirstMatch(ae,e);return s&&(t.version=s),t}},{test:[/playstation 4/i],describe(e){const t={name:"PlayStation 4"},s=Utils.getFirstMatch(ae,e);return s&&(t.version=s),t}},{test:[/safari|applewebkit/i],describe(e){const t={name:"Safari"},s=Utils.getFirstMatch(ae,e);return s&&(t.version=s),t}},{test:[/.*/i],describe(e){const t=-1!==e.search("\\(")?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return{name:Utils.getFirstMatch(t,e),version:Utils.getSecondMatch(t,e)}}}];var oe=[{test:[/Roku\/DVP/],describe(e){const t=Utils.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,e);return{name:ie.Roku,version:t}}},{test:[/windows phone/i],describe(e){const t=Utils.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,e);return{name:ie.WindowsPhone,version:t}}},{test:[/windows /i],describe(e){const t=Utils.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,e),s=Utils.getWindowsVersionName(t);return{name:ie.Windows,version:t,versionName:s}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe(e){const t={name:ie.iOS},s=Utils.getSecondMatch(/(Version\/)(\d[\d.]+)/,e);return s&&(t.version=s),t}},{test:[/macintosh/i],describe(e){const t=Utils.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,e).replace(/[_\s]/g,"."),s=Utils.getMacOSVersionName(t),i={name:ie.MacOS,version:t};return s&&(i.versionName=s),i}},{test:[/(ipod|iphone|ipad)/i],describe(e){const t=Utils.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,e).replace(/[_\s]/g,".");return{name:ie.iOS,version:t}}},{test(e){const t=!e.test(/like android/i),s=e.test(/android/i);return t&&s},describe(e){const t=Utils.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i,e),s=Utils.getAndroidVersionName(t),i={name:ie.Android,version:t};return s&&(i.versionName=s),i}},{test:[/(web|hpw)[o0]s/i],describe(e){const t=Utils.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,e),s={name:ie.WebOS};return t&&t.length&&(s.version=t),s}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe(e){const t=Utils.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,e)||Utils.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,e)||Utils.getFirstMatch(/\bbb(\d+)/i,e);return{name:ie.BlackBerry,version:t}}},{test:[/bada/i],describe(e){const t=Utils.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,e);return{name:ie.Bada,version:t}}},{test:[/tizen/i],describe(e){const t=Utils.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,e);return{name:ie.Tizen,version:t}}},{test:[/linux/i],describe:()=>({name:ie.Linux})},{test:[/CrOS/],describe:()=>({name:ie.ChromeOS})},{test:[/PlayStation 4/],describe(e){const t=Utils.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,e);return{name:ie.PlayStation4,version:t}}}],de=[{test:[/googlebot/i],describe:()=>({type:"bot",vendor:"Google"})},{test:[/huawei/i],describe(e){const t=Utils.getFirstMatch(/(can-l01)/i,e)&&"Nova",s={type:se.mobile,vendor:"Huawei"};return t&&(s.model=t),s}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:()=>({type:se.tablet,vendor:"Nexus"})},{test:[/ipad/i],describe:()=>({type:se.tablet,vendor:"Apple",model:"iPad"})},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:()=>({type:se.tablet,vendor:"Apple",model:"iPad"})},{test:[/kftt build/i],describe:()=>({type:se.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"})},{test:[/silk/i],describe:()=>({type:se.tablet,vendor:"Amazon"})},{test:[/tablet(?! pc)/i],describe:()=>({type:se.tablet})},{test(e){const t=e.test(/ipod|iphone/i),s=e.test(/like (ipod|iphone)/i);return t&&!s},describe(e){const t=Utils.getFirstMatch(/(ipod|iphone)/i,e);return{type:se.mobile,vendor:"Apple",model:t}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:()=>({type:se.mobile,vendor:"Nexus"})},{test:[/[^-]mobi/i],describe:()=>({type:se.mobile})},{test:e=>"blackberry"===e.getBrowserName(!0),describe:()=>({type:se.mobile,vendor:"BlackBerry"})},{test:e=>"bada"===e.getBrowserName(!0),describe:()=>({type:se.mobile})},{test:e=>"windows phone"===e.getBrowserName(),describe:()=>({type:se.mobile,vendor:"Microsoft"})},{test(e){const t=Number(String(e.getOSVersion()).split(".")[0]);return"android"===e.getOSName(!0)&&t>=3},describe:()=>({type:se.tablet})},{test:e=>"android"===e.getOSName(!0),describe:()=>({type:se.mobile})},{test:e=>"macos"===e.getOSName(!0),describe:()=>({type:se.desktop,vendor:"Apple"})},{test:e=>"windows"===e.getOSName(!0),describe:()=>({type:se.desktop})},{test:e=>"linux"===e.getOSName(!0),describe:()=>({type:se.desktop})},{test:e=>"playstation 4"===e.getOSName(!0),describe:()=>({type:se.tv})},{test:e=>"roku"===e.getOSName(!0),describe:()=>({type:se.tv})}],le=[{test:e=>"microsoft edge"===e.getBrowserName(!0),describe(e){if(/\sedg\//i.test(e))return{name:re.Blink};const t=Utils.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,e);return{name:re.EdgeHTML,version:t}}},{test:[/trident/i],describe(e){const t={name:re.Trident},s=Utils.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:e=>e.test(/presto/i),describe(e){const t={name:re.Presto},s=Utils.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test(e){const t=e.test(/gecko/i),s=e.test(/like gecko/i);return t&&!s},describe(e){const t={name:re.Gecko},s=Utils.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}},{test:[/(apple)?webkit\/537\.36/i],describe:()=>({name:re.Blink})},{test:[/(apple)?webkit/i],describe(e){const t={name:re.WebKit},s=Utils.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,e);return s&&(t.version=s),t}}];class Parser{constructor(e,t=!1){if(null==e||""===e)throw new Error("UserAgent parameter can't be empty");this._ua=e,this.parsedResult={},!0!==t&&this.parse()}getUA(){return this._ua}test(e){return e.test(this._ua)}parseBrowser(){this.parsedResult.browser={};const e=Utils.find(ne,e=>{if("function"==typeof e.test)return e.test(this);if(e.test instanceof Array)return e.test.some(e=>this.test(e));throw new Error("Browser's test function is not valid")});return e&&(this.parsedResult.browser=e.describe(this.getUA())),this.parsedResult.browser}getBrowser(){return this.parsedResult.browser?this.parsedResult.browser:this.parseBrowser()}getBrowserName(e){return e?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 e=Utils.find(oe,e=>{if("function"==typeof e.test)return e.test(this);if(e.test instanceof Array)return e.test.some(e=>this.test(e));throw new Error("Browser's test function is not valid")});return e&&(this.parsedResult.os=e.describe(this.getUA())),this.parsedResult.os}getOSName(e){const{name:t}=this.getOS();return e?String(t).toLowerCase()||"":t||""}getOSVersion(){return this.getOS().version}getPlatform(){return this.parsedResult.platform?this.parsedResult.platform:this.parsePlatform()}getPlatformType(e=!1){const{type:t}=this.getPlatform();return e?String(t).toLowerCase()||"":t||""}parsePlatform(){this.parsedResult.platform={};const e=Utils.find(de,e=>{if("function"==typeof e.test)return e.test(this);if(e.test instanceof Array)return e.test.some(e=>this.test(e));throw new Error("Browser's test function is not valid")});return e&&(this.parsedResult.platform=e.describe(this.getUA())),this.parsedResult.platform}getEngine(){return this.parsedResult.engine?this.parsedResult.engine:this.parseEngine()}getEngineName(e){return e?String(this.getEngine().name).toLowerCase()||"":this.getEngine().name||""}parseEngine(){this.parsedResult.engine={};const e=Utils.find(le,e=>{if("function"==typeof e.test)return e.test(this);if(e.test instanceof Array)return e.test.some(e=>this.test(e));throw new Error("Browser's test function is not valid")});return e&&(this.parsedResult.engine=e.describe(this.getUA())),this.parsedResult.engine}parse(){return this.parseBrowser(),this.parseOS(),this.parsePlatform(),this.parseEngine(),this}getResult(){return Utils.assign({},this.parsedResult)}satisfies(e){const t={};let s=0;const i={};let r=0;if(Object.keys(e).forEach(a=>{const n=e[a];"string"==typeof n?(i[a]=n,r+=1):"object"==typeof n&&(t[a]=n,s+=1)}),s>0){const e=Object.keys(t),s=Utils.find(e,e=>this.isOS(e));if(s){const e=this.satisfies(t[s]);if(void 0!==e)return e}const i=Utils.find(e,e=>this.isPlatform(e));if(i){const e=this.satisfies(t[i]);if(void 0!==e)return e}}if(r>0){const e=Object.keys(i),t=Utils.find(e,e=>this.isBrowser(e,!0));if(void 0!==t)return this.compareVersion(i[t])}}isBrowser(e,t=!1){const s=this.getBrowserName().toLowerCase();let i=e.toLowerCase();const r=Utils.getBrowserTypeByAlias(i);return t&&r&&(i=r.toLowerCase()),i===s}compareVersion(e){let t=[0],s=e,i=!1;const r=this.getBrowserVersion();if("string"==typeof r)return">"===e[0]||"<"===e[0]?(s=e.substr(1),"="===e[1]?(i=!0,s=e.substr(2)):t=[],">"===e[0]?t.push(1):t.push(-1)):"="===e[0]?s=e.substr(1):"~"===e[0]&&(i=!0,s=e.substr(1)),t.indexOf(Utils.compareVersions(r,s,i))>-1}isOS(e){return this.getOSName(!0)===String(e).toLowerCase()}isPlatform(e){return this.getPlatformType(!0)===String(e).toLowerCase()}isEngine(e){return this.getEngineName(!0)===String(e).toLowerCase()}is(e,t=!1){return this.isBrowser(e,t)||this.isOS(e)||this.isPlatform(e)}some(e=[]){return e.some(e=>this.is(e))}}
17
2
  /*!
18
3
  * Bowser - a browser detector
19
4
  * https://github.com/lancedikson/bowser
20
5
  * MIT License | (c) Dustin Diaz 2012-2015
21
6
  * MIT License | (c) Denis Demchenko 2015-2019
22
- */const ce=class Bowser{static getParser(e,t=!1){if("string"!=typeof e)throw new Error("UserAgent should be a string");return new Parser(e,t)}static parse(e){return new Parser(e).getResult()}static get BROWSER_MAP(){return te}static get ENGINE_MAP(){return re}static get OS_MAP(){return ie}static get PLATFORMS_MAP(){return se}}.parse(window.navigator.userAgent),{platform:ue,os:he,browser:pe}=ce,ge=e=>e&&e.toLowerCase();var me={rnd:Math.random().toString(36).substr(2,32),os:ge(he.name+(he.versionName?" "+he.versionName:"")),device:ge(ue.type),browser:ge(pe.name),browser_version:(pe&&pe.version?pe.version:"unknown").split(".").shift(),plugin_version:"3.2.2"};const _e="https://fp-eu-w1-aai.flowplayer.com/in",fe="POST",ye=["ad-requested","ad-request-error","ad-request-completed","ad-completed","ad-started","ad-error","ad-skipped"],ve=["event_type","ad_tag_id","media_id","player_id","site_id","sitegroup_id","rnd","os","device","browser","browser_version","plugin_version","player_version"],Ae=["vast_error","reason","request_load_time","ad_type","vast_ad_id"],we=f("ads/analytics"),Ee=RequestQueue.of(),be=(...e)=>Object.assign({},...e);class Analytics{constructor(e,t={}){this.emitter=e,this.metadata=be(me,t.metadata||{}),this.emitter=e,this.events=t.events||[],this.required_keys=t.required_keys||[],this.optional_keys=t.optional_keys||[],this.valid_keys=this.required_keys.slice(0).concat(this.optional_keys),we(this),this.wireup()}static of(e,t){return new Analytics(e,t)}static ensure_required_keys(e,t){return e.required_keys.filter(e=>!(e in t))}static pluck_valid_keys(e,t){return((e,...t)=>Object.keys(e).filter(e=>~t.indexOf(e)).reduce((t,s)=>Object.assign(t,{[s]:e[s]}),{}))(t,...e.valid_keys)}static mergeMetadata(e,t={}){return e.metadata=Analytics.pluck_valid_keys(e,be(e.metadata,t,{player_version:"3.2.2"})),e}wireup(){this.events.forEach(e=>{this.emitter.on(e,t=>{const s=t.detail,i=be(this.metadata,{event_type:e},s),r=Analytics.pluck_valid_keys(this,i),a=Analytics.ensure_required_keys(this,r);if(we(`Event[${e}]`,{payload:r,observation:s}),a.length)return we(`Analytics.validate_metadata() failed for\n Event[${e}]\n missing keys: ${a}`,r);RequestQueue.rpush(Ee,[_e,fe,r])})})}destroy(){this.emitter=this.metadata=this.events=this.required_keys=this.optional_keys=this.valid_keys=void 0}}const Te=f("ads/controller"),Se={show_all_ads_on_seek:!1,timeout:5e3,preload_advance:10};class AdsController extends class EventBus{constructor(e=document.createElement("div"),t=[]){this._bus=e,this._listeners=t}removeAllListeners(){this._listeners.length=0,this._bus=document.createElement("div")}emit(e,t){const s=new CustomEvent(e,{detail:t||{}});this._bus.dispatchEvent(s)}on(e,t){this._listeners.push([e,t]),this._bus.addEventListener(e,t,{passive:!0})}once(e,t){this._bus.addEventListener(e,t,{once:!0})}removeListener(e,t){this._bus.removeEventListener(e,t)}}{constructor(e={}){var t;super(),this.adapter=function(e,t){return e.adapter?new e.adapter(t):new IMA(t)}(e,this),this.opts=Object.assign(Object.assign({},Se),e),this.analytics=(t=this,Analytics.of(t,{required_keys:ve,optional_keys:Ae,events:ye})),this._state=AdsState.of(),this._schedule=void 0,this._lastAd=void 0,this._macros=new Macros(e.parameters||{}),this.wireup()}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();this.analytics=void 0,this.opts=void 0,this.adapter=void 0,this._state=void 0,this._schedule=void 0,this._lastAd=void 0,this._macros=void 0}stop(){this.adapter&&this.adapter.stop()}wireup(){const e=()=>{var e;const t=new CustomEvent("ad/playing");null===(e=this.videoTag)||void 0===e||e.dispatchEvent(t),this._state.toggleState(J.PLAYING,!0)};this.on("ad-play-requested",e),this.on("ad-started",e),this.on("ad-resumed",e);const t=()=>{var e;const t=new CustomEvent("ad/paused");null===(e=this.videoTag)||void 0===e||e.dispatchEvent(t),this._state.toggleState(J.PLAYING,!1)};this.on("ad-break-completed",t),this.on("ad-teardown",t),this.on("ad-playback-error",t),this.on("ad-request-error",t),this.on("ad-paused",t),this.on("ad-skipped",t),this.on("ad-completed",t),this.on("ad-break-completed",()=>{var e;const t=new CustomEvent("ad/complete");null===(e=this.videoTag)||void 0===e||e.dispatchEvent(t),this._state.toggleState(J.BREAK_ACTIVE,!1)}),this.on("ad-adapter-init-failed",()=>{console.error("Adapter init failed"),t(),this._state.toggleState(J.FATAL_ERROR,!0)}),this.on("reload-ad-requested",async e=>{if(Te("Ads.on(RELOAD_AD_REQUESTED)",e),this._schedule){if(t(),e)return this._schedule.reset(this._schedule.getAds());this._state.hasAny(J.AD_AVAILABLE)&&(this._schedule.decrement(),this._state.toggleState(J.AD_AVAILABLE,!1))}})}async initialize(e,t={},s){return Te("Ads.initialize():",e,t,s),this._state.toggleState(J.INITIALIZING,!0),Object.assign(this.opts,t),Array.isArray(e)&&this.setSchedule(e),await this.adapter.init(this.opts),this._macros=this._macros.fork(Object.assign({},t.parameters||{},{autoplay:t.autoplay,muted:t.muted})),this.adapter.isReady()&&await this.adapterInitialized(s),this}get videoTag(){return this.adapter.getVideoTag()}get adInfo(){return this.adapter.getAdInfo()}async setVideoTag(e){Te("Ads.setVideoTag():",e),await this.adapter.setVideoTag(e),this.trigger("ad-videotag-attached",e),this.adapter.isReady()&&await this.adapterInitialized(),e.on("request/ad/pause",()=>this.adapter.pause()),e.on("request/ad/play",()=>this.adapter.resume()),e.on("request/ad/muteunmute",()=>{var t;e.muted=(null!==(t=this.adapter.volume())&&void 0!==t?t:0)>0,this.adapter.volume(e.muted?0:0==e.volume?.1:e.volume)})}waitForVideoTag(){return new Promise(e=>{const t=this.adapter.getVideoTag();if(t)return e(t);this.on("ad-videotag-attached",t=>{this.once(p,()=>e(t))})})}async adapterInitialized(e){Te("Ads.adapterInitialized()"),this._state.toggleState(J.INITIALIZING,!1),this._state.toggleState(J.BREAK_ACTIVE,!!this.hasPreroll()),await this.setCurrentTime(0,e),this.checkIfBreakComplete(),e&&!this.opts.autoplay||this.trigger("ad-teardown")}async fetchNextAd(e,t=0){var s,i;if(!this._schedule)return;if(!this.adapter.isReady())return;if(t>50)throw this._state.toggleState(J.FATAL_ERROR,!0),this._state.toggleState(J.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===e)if(this._schedule.waitForLoad(e,r,this.opts.preload_ads))this._state.toggleState(J.FETCHING_AD,!1);else if(r===this._schedule.getPostroll()&&this._schedule.setPostrollActive(),this._schedule.isDrained()||this._schedule.increment(),r){Te("Ads.fetchNextAd",r),this._state.toggleState(J.FETCHING_AD,!0);try{return await this.requestAd(r),this._state.toggleState(J.AD_AVAILABLE,!0),void this._state.toggleState(J.FETCHING_AD,!1)}catch(s){if(Te("Ads.fetchNextAd(err: %o, ad: %o)",s,r),this.setLastAd(r),r!==this._schedule.getPostroll())return await this.fetchNextAd(e,++t)}}else this._state.toggleState(J.FETCHING_AD,!1)}skipAdsOnSeek(e){if(!this._schedule)return;let t=this._schedule.getNextAd();for(;t&&t.time<e;)this._schedule.increment(),t=this._schedule.getNextAd()}async setCurrentTime(e,t=!1,s=!1){if(!this._schedule)return;if(!this.adapter.isReady())return;if(this._state.hasAny(J.FETCHING_AD))return;if(this._state.hasAny(J.PLAYING)&&this.adapter.isLinearAd())return;const i=0===e&&0===this._schedule.getNextIndex();try{if(s&&!this.opts.show_all_ads_on_seek&&this.skipAdsOnSeek(e),this._state.hasAny(J.AD_AVAILABLE)||await this.fetchNextAd(e),!this._state.hasAny(J.AD_AVAILABLE)||!this.shallPlayAd(e)||t)return;await this.playAd(),await this.setCurrentTime(e),this.checkIfBreakComplete()}catch(e){Te("setCurrentTime: Error(from: setCurrentTime, message: %s)",e.message)}finally{i&&this.trigger("ad-preroll-finished")}}async playAd(){var e;if(this._state.hasAny(J.AD_AVAILABLE)){this._state.toggleState(J.AD_AVAILABLE,!1),this._state.toggleState(J.BREAK_ACTIVE,!0);try{const t=null===(e=this._schedule)||void 0===e?void 0:e.getCurrentAd();await this.adapter.playAd(),t&&this.setLastAd(t)}catch(e){console.error("Ads.playAd: error",e)}}}checkIfBreakComplete(){if(!this._state.hasAny(J.BREAK_ACTIVE))return Te("Ads.checkIfBreakComplete(:bail, ad: %o)",this.getLastAd());Te("Ads.checkIfBreakComplete(:run, ad: %o)",this.getLastAd()),this._state.toggleState(J.BREAK_ACTIVE,!1),this.adapter.isAdPod()||this.trigger("ad-break-completed")}resetScheduleCounter(){this._schedule&&this._schedule.resetCounter()}setSchedule(e,t){if(t&&!isNaN(t)&&this._schedule&&this._schedule.updateContentDuration(t),this._schedule&&this._schedule.getNextIndex()>0)return this._schedule.setAds(e);this._schedule=new Schedule(e,{preload_advance:this.opts.preload_advance,content_duration:t?0:t})}toJSON(){return this._schedule?this._schedule.toJSON():[]}trigger(e,t={}){var s;if(!this.adapter.getVideoTag())return;if(!this._state)return;if("ad-break-completed"===e&&this._state.hasAny(J.BREAK_ACTIVE)&&!this.adapter.isAdPod())return Te("skipping AD_BREAK_COMPLETE reason: %s pod=%s",this._state.toString(),this.adapter.isAdPod());if(null===(i=t)||"object"!=typeof i||K(i)!==$)return this.dispatch(e,t);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},t);return t.ima_event&&"preroll"===t.ad_type&&(r.ad_type=this.ad_type),this.dispatch(e,r)}dispatch(e,t){const s=this.adapter.getVideoTag();if(s){Te(":dispatch",e,t);try{const i={event:"ads/"+e,detail:{outstream:t.outstream,ad_type:t.ad_type,ad_break_time:t.time,ad_remaining_seconds:t.remaining,ad_muted:t.muted,ad_duration_seconds:t.duration,ad_error_reason:t.reason,ad_vast_error:t.vast_error,ad_vast_error_type:t.vast_error_type,ad_request_load_type:t.request_load_time}};s.dispatchEvent(new CustomEvent("health:record",{detail:i}))}catch(e){Te(":error",e)}Z(s,e,t),this.emit(e,t)}}get ad_type(){return this._schedule&&this._schedule.getCurrentType()}shouldRestartContent(){if(this.adapter.isAdPod())return!0;const e=this.getLastAd();return!!e&&(!e.outstream&&!1!==e.restart)}async finished(e){if(this._schedule&&(Te("Ads.finished"),!(this.adapter.isSharedVideoTag()&&this._state.hasAny(J.PLAYING)&&this.adapter.isLinearAd()))){Te("Ads.finished: trying to play postroll");try{if(!this._schedule.getPostroll())return Te("Ads.finished: no postroll found"),await this.adapter.contentComplete();this._state.hasAny(J.AD_AVAILABLE)||await this.fetchNextAd(-1),await this.playAd(),this.adapter.contentComplete()}catch(e){Te("Ads.finished: postroll failed:",e)}finally{this.trigger("ad-postroll-finished"),this.checkIfBreakComplete(),"function"==typeof e&&e()}}}hasPreroll(){return this._schedule&&Schedule.hasPreroll(this._schedule.getAds())}shallPlayAd(e){var t;return(!this.adapter||!this.adapter.isAdPod())&&(!(!this._state||this._state.hasAny(J.FATAL_ERROR))&&!!(null===(t=this._schedule)||void 0===t?void 0:t.shallPlayAd(e)))}setLastAd(e){return this._lastAd=e,this}getLastAd(){return this._lastAd}mergeMacros(e={}){return this._macros=this._macros.fork(Object.assign({},e)),this}get paused(){return this.adapter&&this.adapter.isPaused()}pause(){this.adapter&&this.adapter.pause()}resume(){this.adapter&&this.adapter.resume()}resize(e){this.adapter&&this.adapter.onResize(e)}async requestAd(e,t=0,s=this.opts.timeout){if(!this._state)return;Te("Ads.requestAd(ad: %o)",{ad:e,timeout:s,idx:t});const i=await async function e(t){if("function"==typeof t)return[await G(t)];if("string"==typeof t)return[await G(t)];if(Array.isArray(t)){const e=t;return await Promise.all(e.map(G))}if("object"==typeof t&&t&&t.adTag)return await e(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 `)}(e);if(void 0===i[t])return Promise.reject(new Error("Ad failed, no fallbacks left"));if(!i[t])return await this.requestAd(i,t+1,s);this.trigger("ad-requested",e);const r=this._macros.compile(i[t],W(this.opts,this.adapter.getDimensions()));try{return void await this.adapter.initAd(r,s)}catch(e){return Te(`Ads.requestAd(:fallback, idx: ${t}, length: ${i.length}, adTag: ${i[t]})\nError `,{adTag:i,err:e}),this.requestAd(i,t+1,s)}}resetSchedule(e){this._schedule&&this._schedule.reset(e)}get adPlaying(){return this._state&&this._state.hasAny(J.PLAYING)}get adBreak(){return this._state&&this._state.hasAny(J.BREAK_ACTIVE)}}var Le=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"}),Oe=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 Me(e){return Object.assign({muted:!1,timeout:250,inline:!1},e)}function Re(e,t){var s=e.muted,i=e.timeout,r=e.inline,a=t(),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(e){d=n.play(),l=setTimeout((function(){c(!1,new Error("Timeout "+i+" ms has been reached"))}),i),c=function(t){var s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;n.remove(),n.srcObject=null,clearTimeout(l),e({result:t,error:s})},void 0!==d?d.then((function(){return c(!0)})).catch((function(e){return c(!1,e)})):c(!0)}))}var Pe={audio:function(e){return Re(e=Me(e),(function(){return{element:document.createElement("audio"),source:URL.createObjectURL(Le)}}))},video:function(e){return Re(e=Me(e),(function(){return{element:document.createElement("video"),source:URL.createObjectURL(Oe)}}))}};let ke=void 0;async function De(e=!0){return ke||(ke=await Pe.video({timeout:500,muted:e}),ke)}const Ce=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"}),Ie=["progress","duration"];class AdUI extends HTMLElement{constructor(e,t=document.createElement("div")){super(),this.player=e,this.adContainer=t,this.render(),e.addEventListener("ad/playing",e=>this.updateState(e.type)),e.addEventListener("ad/paused",e=>this.updateState(e.type)),e.addEventListener("ad/complete",e=>this.updateState(e.type))}static get observedAttributes(){return Ie}updateState(e){this.classList.toggle("ad-paused","ad/paused"==e),this.classList.toggle("ad-playing","ad/playing"==e)}hideFirstFrame(e){e.classList.toggle("ad-hide-first-frame",!0)}showFirstFrame(e){e.classList.toggle("ad-hide-first-frame",!1)}resize(e){const t=this.style;e.linear?e.width&&(t.width=e.width+"px"):e.width?this.adContainer.style.width=e.width+"px":t.removeProperty("width"),e.height?t.height=e.height+"px":t.removeProperty("height")}attributeChangedCallback(e,t,s){switch(e){case"duration":return this.onDurationChange(parseFloat(s));case"progress":return this.onProgress(parseFloat(t),parseFloat(s))}}onDurationChange(e){}onProgress(e,t){}render(){this.adContainer.classList.add("fp-ad-container"),this.append(this.adContainer);const e=y(this.player,"flowplayer-ad-controls"),t=y(this.player,"flowplayer-ad-countdown");this.append(e,t)}}const Ue=f("fpads:native:outstream"),Ne={OUTSTREAM:"is-outstream",HIDDEN:"is-outstream-hidden",SHOWING:"is-outstream-visible",DONE:"is-outstream-done"};var Fe,xe;!function(e){e.OUTSTREAM_VISIBLE="ads-outstream-visible",e.OUTSTREAM_VIEWPORT_UPDATE="ads-outstream-viewport-update",e.OUTSTREAM_TEARDOWN="ads-outstream-teardown",e.OUTSTREAM_ENDSCREEN_READY="ads-outstream-endscreen-ready"}(Fe||(Fe={})),function(e){e[e.None=0]="None",e[e.Booting=1]="Booting",e[e.Ready=2]="Ready",e[e.Disposed=3]="Disposed"}(xe||(xe={}));class Outstream{constructor({ads:e,root:t,content:s,ima:i}){this.state=xe.None,Ue("creating Outstream instance"),this.content=s,this.ads=e,this.root=t,this.ima=i,this.aspectRatio=s.videoHeight/s.videoWidth,this.dimensions=function(e){if(e.clientWidth>0||e.clientHeight)return u(e);const t={height:e.style.height};h(e,"opacity",0),h(e,"display","absolute"),h(e,"display","inline-block"),h(e,"height","auto");const s=u(e);return h(e,"height",t.height),h(e,"opacity",1),s}(this.root),this.adUi=new AdUI(s),this.adContainer=this.adUi.adContainer,this.initialVolumeState={},t.classList.add(Ne.OUTSTREAM),t.append(this.adUi),this.hide(),this.ads.on("ad-pause-content",e=>{var t;if(this.state==xe.Disposed)return;const s=!!(null===(t=e.detail)||void 0===t?void 0:t.linear);this.ads.resize(Object.assign(Object.assign({},this.dimensions),{linear:s}))}),s.on("resize",e=>{if(this.state==xe.Disposed)return;const t=e.detail;t&&(this.dimensions={width:t.contentRect.width,height:t.contentRect.height},this.ads.resize(this.dimensions))}),s.on("intersectionchange",e=>{if(this.state==xe.Disposed)return;const t=e.detail;if(t)switch(this.state){case xe.Booting:return Ue(":boot skipping intersectionchange");case xe.None:return this.state=xe.Booting,this.begin_life_cycle();case xe.Ready:if(t.ratio>=.5&&this.ads.adPlaying)return;t.ratio>=.5&&this.ads.resume(),t.ratio<.5&&this.ads.pause()}}),this.setup()}hide(){return this}restore_aspect_ratio(){return Ue(`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.adUi.classList.add("linear","on")}async begin_life_cycle(){this.state=xe.Ready;const{error:e,result:t}=await De(!1),{result:s}=await De(!0);this.attach_ad_listeners(),this.initialVolumeState={can_autoplay:!(!t&&!s),muted:!t},Ue("Outstream.show() :autoplay >> sound="+t),e&&this.content&&!t&&(this.content.muted=!0,this.content.volume=0),await this.ads.setVideoTag(this.content),await b({ads:this.ads,content:this.content,adContainer:this.adContainer,ima:this.ima,state:{listening:!1},config:this.content.opts}),M({content:this.content,ads:this.ads}),this.state=xe.Ready}attach_ad_listeners(){const e=this.ads;e.once("ad-pause-content",()=>{this.show(),this.ads.adPlaying&&this.ads.pause()}),this.ima.always_show_controls||e.on("vpaid-init",()=>this.adUi.classList.add("is-vpaid"));const t=()=>{w.forEach(e=>this.ads.removeListener(e,t));const e=new CustomEvent(Fe.OUTSTREAM_TEARDOWN);Ue("Outstream(:teardown)",e),this.content.dispatchEvent(e)};w.forEach(e=>this.ads.once(e,t)),this.content.once(Fe.OUTSTREAM_TEARDOWN,e=>{setTimeout(()=>{if(e.defaultPrevented)return this.handle_endscreen();this.dispose()},0)})}handle_endscreen(){this.reset_ui(),this.ads.reset(),L({config:this.content.opts,ui:this.adUi,ads:this.ads,adContainer:this.adContainer,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(Ce)})}setup(){this.root.classList.add(Outstream.CLASS.OUTSTREAM),this.root.classList.add(Outstream.CLASS.HIDDEN),this.empty_src()}reset_ui(){const e=this.root;e.classList.remove(Outstream.CLASS.SHOWING),e.classList.remove(Outstream.CLASS.OUTSTREAM),this.adUi.classList.remove("on")}dispose(){if(this.state==xe.Disposed)return;const e=this.root,t=this.content;this.reset_ui(),e.classList.add(Outstream.CLASS.OUTSTREAM),e.classList.add(Outstream.CLASS.DONE);this.video=this.container=this.ads=0,this.state=xe.Disposed,t.destroy(),e.innerHTML=""}}function Be(e){return e&&"number"==typeof e.time}function qe(e){return e&&"number"==typeof e.percent&&"number"!=typeof e.time}Outstream.CLASS=Ne;const je=f("ads/index");function Ve(e,t,s){if(!("google"in window))return console.warn("google.ima unavailable");let i=e.autoplay;e.autoplay&&(je("handling initial autoplay, original_autoplay: ",i),s.autoplay=!1,e.autoplay=0);const r=s.ads=new AdsController,a=r.analytics;let n=!1;r.resize(u(t)),m&&(s.on(["fullscreenenter","fullscreenexit","webkitendfullscreen"],e=>{var t;const i="fullscreenenter"===e.type;null===(t=null==s?void 0:s.ads)||void 0===t||t.adapter.setIOSPlaysInline(!i)}),r.on("ad-postroll-finished",()=>{r.adapter.isSharedVideoTag()&&r.once("ad-break-completed",()=>{s.src=s.original_src,s.once("canplay",()=>{s.togglePlay(!1)}),s.webkitExitFullscreen()})})),s.on("reap",(function(){r&&r.destroy()})),s.on("src",()=>{r&&r.stop()}),s.on("config",(function({detail:o}){const d=o.ima;if(void 0===i&&o.autoplay&&(i=o.autoplay),!d)return;if(!Array.isArray(d.ads))return je("handling non-array ima.ads"),void(void 0!==i?e.autoplay=i:delete e.autoplay);const l=o.duration||s.duration;if(d.ads=function(e,t){return Array.isArray(e)?e.filter(e=>Be(e)||qe(e)).reduce((e,s)=>{if(Be(s))return e.push(s),e;if(s.lazy)return e.push(s),e;if(qe(s)){const i=Object.assign({},s);return i.time=Math.floor(s.percentage*t),e.push(i),e}return e},[]):(console.warn("AdSchedule was not an Array"),[])}(d.ads,l),r.setSchedule(d.ads,l),o.metadata&&Analytics.mergeMetadata(a,o.metadata),o.metadata&&r.mergeMacros(o.metadata),o.metadata&&d.parameters&&(d.parameters=Object.assign(Object.assign({},d.parameters),o.metadata)),Analytics.mergeMetadata(a,{muted:o.muted||!1,autoplay:o.autoplay||!1}),!n){if(n=!0,e.lang&&!d.Locale&&(d.Locale=e.lang),Schedule.isOutstream(d.ads))return je("is outstream, returning"),new Outstream({root:t,content:s,ads:r,ima:d});E({config:Object.assign(Object.assign({},e),{autoplay:i}),root:t,content:s,ads:r,ima:d})}}))}class AdControls extends HTMLElement{constructor(e){super(),this.player=e,this.render(),e.on("ad-started",e=>{if(!this.indicatorControl)return;const{position:t,totals:s}=e.detail.ad;this.indicatorControl.textContent=`ADS ${t} / ${s}`})}render(){this.classList.add("fp-ad-controls"),this.indicatorControl=document.createElement("div"),this.indicatorControl.classList.add("ad-indicator","fp-color-text"),this.indicatorControl.textContent="ADS";const e=document.createElement("div");e.classList.add("ad-playback-controls");const t=y(this.player,"flowplayer-small-play-icon");t.addEventListener("click",()=>this.player.emit("request/ad/play"));const s=y(this.player,"flowplayer-small-pause-icon");s.addEventListener("click",()=>this.player.emit("request/ad/pause")),e.append(t,s);const i=y(this.player,"flowplayer-volume-icon");i.addEventListener("click",()=>this.player.emit("request/ad/muteunmute"));const r=y(this.player,"flowplayer-header-right-zone");this.append(this.indicatorControl,e,i,r)}}class AdCountdown extends HTMLElement{constructor(e){super(),this.player=e,e.on("ad-progress",e=>{const{duration:t,remaining:s}=e.detail;this.setAttribute("duration",t+""),this.setAttribute("remaining",s+"")}),this.addEventListener("animationend",()=>{const e=this.style.getPropertyValue("--ad-percent-complete")||"0";this.style.setProperty("--ad-percent-previous",e)})}static get observedAttributes(){return["remaining"]}attributeChangedCallback(e,t){switch(e){case"remaining":return this.onRemaining(t)}}onRemaining(e){const t=parseFloat(this.getAttribute("duration")||"0");e||(e=t+"");const s=parseFloat(e),i=this.style.getPropertyValue("--ad-percent-complete")||"0";this.style.setProperty("--ad-percent-previous",i),this.classList.remove("go");const r=((t-s)/t*100).toFixed(3);requestAnimationFrame(()=>{this.style.setProperty("--ad-percent-complete",r),this.classList.add("go")})}}var He=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{samsung_tv:ze}=function(){const e="undefined"!=typeof document&&"undefined"!=typeof window,t=e?navigator.userAgent:"",s=/iP(hone|od)/i.test(t)&&!/iPad/.test(t)&&!/IEMobile/i.test(t),i=/Android/.test(t)&&!/Firefox/.test(t),r=/^((?!chrome|android).)*safari/i.test(t),a=/SamsungBrowser/.test(t),n=a&&/SMART-TV/.test(t);return{controls:!s,video:function(t){return e&&document.createElement("video").canPlayType(t)},lang:e&&window.navigator.language,android:i,iphone:s,safari:r,ios:e&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,samsung:a,samsung_tv:a&&n,touch:!!("ontouchstart"in window)}}();class Ads{constructor(e){this.umd=e,v(e,"flowplayer-ad-ui",AdUI),v(e,"flowplayer-ad-controls",AdControls),v(e,"flowplayer-ad-countdown",AdCountdown)}init(e,t,s){if(c.from_token(e.token||"").is_granted(c.permissions.ADS)&&!ze)return Ve(e,t,s)}}return Ads.events=g,Ads.ui=He,function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const s=e.flowplayer;"function"==typeof s?s(t):(Array.isArray(s.extensions)||(s.extensions=[]),~s.extensions.indexOf(t)||s.extensions.push(t))}(window,Ads),Ads}));
7
+ */const ce=class Bowser{static getParser(e,t=!1){if("string"!=typeof e)throw new Error("UserAgent should be a string");return new Parser(e,t)}static parse(e){return new Parser(e).getResult()}static get BROWSER_MAP(){return te}static get ENGINE_MAP(){return re}static get OS_MAP(){return ie}static get PLATFORMS_MAP(){return se}}.parse(window.navigator.userAgent),{platform:ue,os:he,browser:pe}=ce,ge=e=>e&&e.toLowerCase();var me={rnd:Math.random().toString(36).substr(2,32),os:ge(he.name+(he.versionName?" "+he.versionName:"")),device:ge(ue.type),browser:ge(pe.name),browser_version:(pe&&pe.version?pe.version:"unknown").split(".").shift(),plugin_version:"3.2.4"};const _e="https://fp-eu-w1-aai.flowplayer.com/in",fe="POST",ye=["ad-requested","ad-request-error","ad-request-completed","ad-completed","ad-started","ad-error","ad-skipped"],ve=["event_type","ad_tag_id","media_id","player_id","site_id","sitegroup_id","rnd","os","device","browser","browser_version","plugin_version","player_version"],Ae=["vast_error","reason","request_load_time","ad_type","vast_ad_id"],we=f("ads/analytics"),Ee=RequestQueue.of(),be=(...e)=>Object.assign({},...e);class Analytics{constructor(e,t={}){this.emitter=e,this.metadata=be(me,t.metadata||{}),this.emitter=e,this.events=t.events||[],this.required_keys=t.required_keys||[],this.optional_keys=t.optional_keys||[],this.valid_keys=this.required_keys.slice(0).concat(this.optional_keys),we(this),this.wireup()}static of(e,t){return new Analytics(e,t)}static ensure_required_keys(e,t){return e.required_keys.filter(e=>!(e in t))}static pluck_valid_keys(e,t){return((e,...t)=>Object.keys(e).filter(e=>~t.indexOf(e)).reduce((t,s)=>Object.assign(t,{[s]:e[s]}),{}))(t,...e.valid_keys)}static mergeMetadata(e,t={}){return e.metadata=Analytics.pluck_valid_keys(e,be(e.metadata,t,{player_version:"3.2.4"})),e}wireup(){this.events.forEach(e=>{this.emitter.on(e,t=>{const s=t.detail,i=be(this.metadata,{event_type:e},s),r=Analytics.pluck_valid_keys(this,i),a=Analytics.ensure_required_keys(this,r);if(we(`Event[${e}]`,{payload:r,observation:s}),a.length)return we(`Analytics.validate_metadata() failed for\n Event[${e}]\n missing keys: ${a}`,r);RequestQueue.rpush(Ee,[_e,fe,r])})})}destroy(){this.emitter=this.metadata=this.events=this.required_keys=this.optional_keys=this.valid_keys=void 0}}const Te=f("ads/controller"),Se={show_all_ads_on_seek:!1,timeout:5e3,preload_advance:10};class AdsController extends class EventBus{constructor(e=document.createElement("div"),t=[]){this._bus=e,this._listeners=t}removeAllListeners(){this._listeners.length=0,this._bus=document.createElement("div")}emit(e,t){const s=new CustomEvent(e,{detail:t||{}});this._bus.dispatchEvent(s)}on(e,t){this._listeners.push([e,t]),this._bus.addEventListener(e,t,{passive:!0})}once(e,t){this._bus.addEventListener(e,t,{once:!0})}removeListener(e,t){this._bus.removeEventListener(e,t)}}{constructor(e={}){var t;super(),this.adapter=function(e,t){return e.adapter?new e.adapter(t):new IMA(t)}(e,this),this.opts=Object.assign(Object.assign({},Se),e),this.analytics=(t=this,Analytics.of(t,{required_keys:ve,optional_keys:Ae,events:ye})),this._state=AdsState.of(),this._schedule=void 0,this._lastAd=void 0,this._macros=new Macros(e.parameters||{}),this.wireup()}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();this.analytics=void 0,this.opts=void 0,this.adapter=void 0,this._state=void 0,this._schedule=void 0,this._lastAd=void 0,this._macros=void 0}stop(){this.adapter&&this.adapter.stop()}wireup(){const e=()=>{var e;const t=new CustomEvent("ad/playing");null===(e=this.videoTag)||void 0===e||e.dispatchEvent(t),this._state.toggleState(J.PLAYING,!0)};this.on("ad-play-requested",e),this.on("ad-started",e),this.on("ad-resumed",e);const t=()=>{var e;const t=new CustomEvent("ad/paused");null===(e=this.videoTag)||void 0===e||e.dispatchEvent(t),this._state.toggleState(J.PLAYING,!1)};this.on("ad-break-completed",t),this.on("ad-teardown",t),this.on("ad-playback-error",t),this.on("ad-request-error",t),this.on("ad-paused",t),this.on("ad-skipped",t),this.on("ad-completed",t),this.on("ad-break-completed",()=>{var e;const t=new CustomEvent("ad/complete");null===(e=this.videoTag)||void 0===e||e.dispatchEvent(t),this._state.toggleState(J.BREAK_ACTIVE,!1)}),this.on("ad-adapter-init-failed",()=>{console.error("Adapter init failed"),t(),this._state.toggleState(J.FATAL_ERROR,!0)}),this.on("reload-ad-requested",async e=>{if(Te("Ads.on(RELOAD_AD_REQUESTED)",e),this._schedule){if(t(),e)return this._schedule.reset(this._schedule.getAds());this._state.hasAny(J.AD_AVAILABLE)&&(this._schedule.decrement(),this._state.toggleState(J.AD_AVAILABLE,!1))}})}async initialize(e,t={},s){return Te("Ads.initialize():",e,t,s),this._state.toggleState(J.INITIALIZING,!0),Object.assign(this.opts,t),Array.isArray(e)&&this.setSchedule(e),await this.adapter.init(this.opts),this._macros=this._macros.fork(Object.assign({},t.parameters||{},{autoplay:t.autoplay,muted:t.muted})),this.adapter.isReady()&&await this.adapterInitialized(s),this}get videoTag(){return this.adapter.getVideoTag()}get adInfo(){return this.adapter.getAdInfo()}async setVideoTag(e){Te("Ads.setVideoTag():",e),await this.adapter.setVideoTag(e),this.trigger("ad-videotag-attached",e),this.adapter.isReady()&&await this.adapterInitialized(),e.on("request/ad/pause",()=>this.adapter.pause()),e.on("request/ad/play",()=>this.adapter.resume()),e.on("request/ad/muteunmute",()=>{var t;e.muted=(null!==(t=this.adapter.volume())&&void 0!==t?t:0)>0,this.adapter.volume(e.muted?0:0==e.volume?.1:e.volume)})}waitForVideoTag(){return new Promise(e=>{const t=this.adapter.getVideoTag();if(t)return e(t);this.on("ad-videotag-attached",t=>{this.once(p,()=>e(t))})})}async adapterInitialized(e){Te("Ads.adapterInitialized()"),this._state.toggleState(J.INITIALIZING,!1),this._state.toggleState(J.BREAK_ACTIVE,!!this.hasPreroll()),await this.setCurrentTime(0,e),this.checkIfBreakComplete(),e&&!this.opts.autoplay||this.trigger("ad-teardown")}async fetchNextAd(e,t=0){var s,i;if(!this._schedule)return;if(!this.adapter.isReady())return;if(t>50)throw this._state.toggleState(J.FATAL_ERROR,!0),this._state.toggleState(J.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===e)if(this._schedule.waitForLoad(e,r,this.opts.preload_ads))this._state.toggleState(J.FETCHING_AD,!1);else if(r===this._schedule.getPostroll()&&this._schedule.setPostrollActive(),this._schedule.isDrained()||this._schedule.increment(),r){Te("Ads.fetchNextAd",r),this._state.toggleState(J.FETCHING_AD,!0);try{return await this.requestAd(r),this._state.toggleState(J.AD_AVAILABLE,!0),void this._state.toggleState(J.FETCHING_AD,!1)}catch(s){if(Te("Ads.fetchNextAd(err: %o, ad: %o)",s,r),this.setLastAd(r),r!==this._schedule.getPostroll())return await this.fetchNextAd(e,++t)}}else this._state.toggleState(J.FETCHING_AD,!1)}skipAdsOnSeek(e){if(!this._schedule)return;let t=this._schedule.getNextAd();for(;t&&t.time<e;)this._schedule.increment(),t=this._schedule.getNextAd()}async setCurrentTime(e,t=!1,s=!1){if(!this._schedule)return;if(!this.adapter.isReady())return;if(this._state.hasAny(J.FETCHING_AD))return;if(this._state.hasAny(J.PLAYING)&&this.adapter.isLinearAd())return;const i=0===e&&0===this._schedule.getNextIndex();try{if(s&&!this.opts.show_all_ads_on_seek&&this.skipAdsOnSeek(e),this._state.hasAny(J.AD_AVAILABLE)||await this.fetchNextAd(e),!this._state.hasAny(J.AD_AVAILABLE)||!this.shallPlayAd(e)||t)return;await this.playAd(),await this.setCurrentTime(e),this.checkIfBreakComplete()}catch(e){Te("setCurrentTime: Error(from: setCurrentTime, message: %s)",e.message)}finally{i&&this.trigger("ad-preroll-finished")}}async playAd(){var e;if(this._state.hasAny(J.AD_AVAILABLE)){this._state.toggleState(J.AD_AVAILABLE,!1),this._state.toggleState(J.BREAK_ACTIVE,!0);try{const t=null===(e=this._schedule)||void 0===e?void 0:e.getCurrentAd();await this.adapter.playAd(),t&&this.setLastAd(t)}catch(e){console.error("Ads.playAd: error",e)}}}checkIfBreakComplete(){if(!this._state.hasAny(J.BREAK_ACTIVE))return Te("Ads.checkIfBreakComplete(:bail, ad: %o)",this.getLastAd());Te("Ads.checkIfBreakComplete(:run, ad: %o)",this.getLastAd()),this._state.toggleState(J.BREAK_ACTIVE,!1),this.adapter.isAdPod()||this.trigger("ad-break-completed")}resetScheduleCounter(){this._schedule&&this._schedule.resetCounter()}setSchedule(e,t){if(t&&!isNaN(t)&&this._schedule&&this._schedule.updateContentDuration(t),this._schedule&&this._schedule.getNextIndex()>0)return this._schedule.setAds(e);this._schedule=new Schedule(e,{preload_advance:this.opts.preload_advance,content_duration:t?0:t})}toJSON(){return this._schedule?this._schedule.toJSON():[]}trigger(e,t={}){var s;if(!this.adapter.getVideoTag())return;if(!this._state)return;if("ad-break-completed"===e&&this._state.hasAny(J.BREAK_ACTIVE)&&!this.adapter.isAdPod())return Te("skipping AD_BREAK_COMPLETE reason: %s pod=%s",this._state.toString(),this.adapter.isAdPod());if(null===(i=t)||"object"!=typeof i||K(i)!==$)return this.dispatch(e,t);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},t);return t.ima_event&&"preroll"===t.ad_type&&(r.ad_type=this.ad_type),this.dispatch(e,r)}dispatch(e,t){const s=this.adapter.getVideoTag();if(s){Te(":dispatch",e,t);try{const i={event:"ads/"+e,detail:{outstream:t.outstream,ad_type:t.ad_type,ad_break_time:t.time,ad_remaining_seconds:t.remaining,ad_muted:t.muted,ad_duration_seconds:t.duration,ad_error_reason:t.reason,ad_vast_error:t.vast_error,ad_vast_error_type:t.vast_error_type,ad_request_load_type:t.request_load_time}};s.dispatchEvent(new CustomEvent("health:record",{detail:i}))}catch(e){Te(":error",e)}Z(s,e,t),this.emit(e,t)}}get ad_type(){return this._schedule&&this._schedule.getCurrentType()}shouldRestartContent(){if(this.adapter.isAdPod())return!0;const e=this.getLastAd();return!!e&&(!e.outstream&&!1!==e.restart)}async finished(e){if(this._schedule&&(Te("Ads.finished"),!(this.adapter.isSharedVideoTag()&&this._state.hasAny(J.PLAYING)&&this.adapter.isLinearAd()))){Te("Ads.finished: trying to play postroll");try{if(!this._schedule.getPostroll())return Te("Ads.finished: no postroll found"),await this.adapter.contentComplete();this._state.hasAny(J.AD_AVAILABLE)||await this.fetchNextAd(-1),await this.playAd(),this.adapter.contentComplete()}catch(e){Te("Ads.finished: postroll failed:",e)}finally{this.trigger("ad-postroll-finished"),this.checkIfBreakComplete(),"function"==typeof e&&e()}}}hasPreroll(){return this._schedule&&Schedule.hasPreroll(this._schedule.getAds())}shallPlayAd(e){var t;return(!this.adapter||!this.adapter.isAdPod())&&(!(!this._state||this._state.hasAny(J.FATAL_ERROR))&&!!(null===(t=this._schedule)||void 0===t?void 0:t.shallPlayAd(e)))}setLastAd(e){return this._lastAd=e,this}getLastAd(){return this._lastAd}mergeMacros(e={}){return this._macros=this._macros.fork(Object.assign({},e)),this}get paused(){return this.adapter&&this.adapter.isPaused()}pause(){this.adapter&&this.adapter.pause()}resume(){this.adapter&&this.adapter.resume()}resize(e){this.adapter&&this.adapter.onResize(e)}async requestAd(e,t=0,s=this.opts.timeout){if(!this._state)return;Te("Ads.requestAd(ad: %o)",{ad:e,timeout:s,idx:t});const i=await async function e(t){if("function"==typeof t)return[await G(t)];if("string"==typeof t)return[await G(t)];if(Array.isArray(t)){const e=t;return await Promise.all(e.map(G))}if("object"==typeof t&&t&&t.adTag)return await e(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 `)}(e);if(void 0===i[t])return Promise.reject(new Error("Ad failed, no fallbacks left"));if(!i[t])return await this.requestAd(i,t+1,s);this.trigger("ad-requested",e);const r=this._macros.compile(i[t],W(this.opts,this.adapter.getDimensions()));try{return void await this.adapter.initAd(r,s)}catch(e){return Te(`Ads.requestAd(:fallback, idx: ${t}, length: ${i.length}, adTag: ${i[t]})\nError `,{adTag:i,err:e}),this.requestAd(i,t+1,s)}}resetSchedule(e){this._schedule&&this._schedule.reset(e)}get adPlaying(){return this._state&&this._state.hasAny(J.PLAYING)}get adBreak(){return this._state&&this._state.hasAny(J.BREAK_ACTIVE)}}var Le=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"}),Oe=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 Me(e){return Object.assign({muted:!1,timeout:250,inline:!1},e)}function Re(e,t){var s=e.muted,i=e.timeout,r=e.inline,a=t(),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(e){d=n.play(),l=setTimeout((function(){c(!1,new Error("Timeout "+i+" ms has been reached"))}),i),c=function(t){var s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;n.remove(),n.srcObject=null,clearTimeout(l),e({result:t,error:s})},void 0!==d?d.then((function(){return c(!0)})).catch((function(e){return c(!1,e)})):c(!0)}))}var Pe={audio:function(e){return Re(e=Me(e),(function(){return{element:document.createElement("audio"),source:URL.createObjectURL(Le)}}))},video:function(e){return Re(e=Me(e),(function(){return{element:document.createElement("video"),source:URL.createObjectURL(Oe)}}))}};let ke=void 0;async function De(e=!0){return ke||(ke=await Pe.video({timeout:500,muted:e}),ke)}const Ce=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"}),Ie=["progress","duration"];class AdUI extends HTMLElement{constructor(e,t=document.createElement("div")){super(),this.player=e,this.adContainer=t,this.render(),e.addEventListener("ad/playing",e=>this.updateState(e.type)),e.addEventListener("ad/paused",e=>this.updateState(e.type)),e.addEventListener("ad/complete",e=>this.updateState(e.type))}static get observedAttributes(){return Ie}updateState(e){this.classList.toggle("ad-paused","ad/paused"==e),this.classList.toggle("ad-playing","ad/playing"==e)}hideFirstFrame(e){e.classList.toggle("ad-hide-first-frame",!0)}showFirstFrame(e){e.classList.toggle("ad-hide-first-frame",!1)}resize(e){const t=this.style;e.linear?e.width&&(t.width=e.width+"px"):e.width?this.adContainer.style.width=e.width+"px":t.removeProperty("width"),e.height?t.height=e.height+"px":t.removeProperty("height")}attributeChangedCallback(e,t,s){switch(e){case"duration":return this.onDurationChange(parseFloat(s));case"progress":return this.onProgress(parseFloat(t),parseFloat(s))}}onDurationChange(e){}onProgress(e,t){}render(){this.adContainer.classList.add("fp-ad-container"),this.append(this.adContainer);const e=y(this.player,"flowplayer-ad-controls"),t=y(this.player,"flowplayer-ad-countdown");this.append(e,t)}}const Ue=f("fpads:native:outstream"),Ne={OUTSTREAM:"is-outstream",HIDDEN:"is-outstream-hidden",SHOWING:"is-outstream-visible",DONE:"is-outstream-done"};var Fe,xe;!function(e){e.OUTSTREAM_VISIBLE="ads-outstream-visible",e.OUTSTREAM_VIEWPORT_UPDATE="ads-outstream-viewport-update",e.OUTSTREAM_TEARDOWN="ads-outstream-teardown",e.OUTSTREAM_ENDSCREEN_READY="ads-outstream-endscreen-ready"}(Fe||(Fe={})),function(e){e[e.None=0]="None",e[e.Booting=1]="Booting",e[e.Ready=2]="Ready",e[e.Disposed=3]="Disposed"}(xe||(xe={}));class Outstream{constructor({ads:e,root:t,content:s,ima:i}){this.state=xe.None,Ue("creating Outstream instance"),this.content=s,this.ads=e,this.root=t,this.ima=i,this.aspectRatio=s.videoHeight/s.videoWidth,this.dimensions=function(e){if(e.clientWidth>0||e.clientHeight)return u(e);const t={height:e.style.height};h(e,"opacity",0),h(e,"display","absolute"),h(e,"display","inline-block"),h(e,"height","auto");const s=u(e);return h(e,"height",t.height),h(e,"opacity",1),s}(this.root),this.adUi=new AdUI(s),this.adContainer=this.adUi.adContainer,this.initialVolumeState={},t.classList.add(Ne.OUTSTREAM),t.append(this.adUi),this.hide(),this.ads.on("ad-pause-content",e=>{var t;if(this.state==xe.Disposed)return;const s=!!(null===(t=e.detail)||void 0===t?void 0:t.linear);this.ads.resize(Object.assign(Object.assign({},this.dimensions),{linear:s}))}),s.on("resize",e=>{if(this.state==xe.Disposed)return;const t=e.detail;t&&(this.dimensions={width:t.contentRect.width,height:t.contentRect.height},this.ads.resize(this.dimensions))}),s.on("intersectionchange",e=>{if(this.state==xe.Disposed)return;const t=e.detail;if(t)switch(this.state){case xe.Booting:return Ue(":boot skipping intersectionchange");case xe.None:return this.state=xe.Booting,this.begin_life_cycle();case xe.Ready:if(t.ratio>=.5&&this.ads.adPlaying)return;t.ratio>=.5&&this.ads.resume(),t.ratio<.5&&this.ads.pause()}}),this.setup()}hide(){return this}restore_aspect_ratio(){return Ue(`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.adUi.classList.add("linear","on")}async begin_life_cycle(){this.state=xe.Ready;const{error:e,result:t}=await De(!1),{result:s}=await De(!0);this.attach_ad_listeners(),this.initialVolumeState={can_autoplay:!(!t&&!s),muted:!t},Ue("Outstream.show() :autoplay >> sound="+t),e&&this.content&&!t&&(this.content.muted=!0,this.content.volume=0),await this.ads.setVideoTag(this.content),await b({ads:this.ads,content:this.content,adContainer:this.adContainer,ima:this.ima,state:{listening:!1},config:this.content.opts}),M({content:this.content,ads:this.ads}),this.state=xe.Ready}attach_ad_listeners(){const e=this.ads;e.once("ad-pause-content",()=>{this.show(),this.ads.adPlaying&&this.ads.pause()}),this.ima.always_show_controls||e.on("vpaid-init",()=>this.adUi.classList.add("is-vpaid"));const t=()=>{w.forEach(e=>this.ads.removeListener(e,t));const e=new CustomEvent(Fe.OUTSTREAM_TEARDOWN);Ue("Outstream(:teardown)",e),this.content.dispatchEvent(e)};w.forEach(e=>this.ads.once(e,t)),this.content.once(Fe.OUTSTREAM_TEARDOWN,e=>{setTimeout(()=>{if(e.defaultPrevented)return this.handle_endscreen();this.dispose()},0)})}handle_endscreen(){this.reset_ui(),this.ads.reset(),L({config:this.content.opts,ui:this.adUi,ads:this.ads,adContainer:this.adContainer,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(Ce)})}setup(){this.root.classList.add(Outstream.CLASS.OUTSTREAM),this.root.classList.add(Outstream.CLASS.HIDDEN),this.empty_src()}reset_ui(){const e=this.root;e.classList.remove(Outstream.CLASS.SHOWING),e.classList.remove(Outstream.CLASS.OUTSTREAM),this.adUi.classList.remove("on")}dispose(){if(this.state==xe.Disposed)return;const e=this.root,t=this.content;this.reset_ui(),e.classList.add(Outstream.CLASS.OUTSTREAM),e.classList.add(Outstream.CLASS.DONE);this.video=this.container=this.ads=0,this.state=xe.Disposed,t.destroy(),e.innerHTML=""}}function Be(e){return e&&"number"==typeof e.time}function qe(e){return e&&"number"==typeof e.percent&&"number"!=typeof e.time}Outstream.CLASS=Ne;const je=f("ads/index");function Ve(e,t,s){if(!("google"in window))return console.warn("google.ima unavailable");let i=e.autoplay;e.autoplay&&(je("handling initial autoplay, original_autoplay: ",i),s.autoplay=!1,e.autoplay=0);const r=s.ads=new AdsController,a=r.analytics;let n=!1;r.resize(u(t)),m&&(s.on(["fullscreenenter","fullscreenexit","webkitendfullscreen"],e=>{var t;const i="fullscreenenter"===e.type;null===(t=null==s?void 0:s.ads)||void 0===t||t.adapter.setIOSPlaysInline(!i)}),r.on("ad-postroll-finished",()=>{r.adapter.isSharedVideoTag()&&r.once("ad-break-completed",()=>{s.src=s.original_src,s.once("canplay",()=>{s.togglePlay(!1)}),s.webkitExitFullscreen()})})),s.on("reap",(function(){r&&r.destroy()})),s.on("src",()=>{r&&r.stop()}),s.on("config",(function({detail:o}){const d=o.ima;if(void 0===i&&o.autoplay&&(i=o.autoplay),!d)return;if(!Array.isArray(d.ads))return je("handling non-array ima.ads"),void(void 0!==i?e.autoplay=i:delete e.autoplay);const l=o.duration||s.duration;if(d.ads=function(e,t){return Array.isArray(e)?e.filter(e=>Be(e)||qe(e)).reduce((e,s)=>{if(Be(s))return e.push(s),e;if(s.lazy)return e.push(s),e;if(qe(s)){const i=Object.assign({},s);return i.time=Math.floor(s.percentage*t),e.push(i),e}return e},[]):(console.warn("AdSchedule was not an Array"),[])}(d.ads,l),r.setSchedule(d.ads,l),o.metadata&&Analytics.mergeMetadata(a,o.metadata),o.metadata&&r.mergeMacros(o.metadata),o.metadata&&d.parameters&&(d.parameters=Object.assign(Object.assign({},d.parameters),o.metadata)),Analytics.mergeMetadata(a,{muted:o.muted||!1,autoplay:o.autoplay||!1}),!n){if(n=!0,e.lang&&!d.Locale&&(d.Locale=e.lang),Schedule.isOutstream(d.ads))return je("is outstream, returning"),new Outstream({root:t,content:s,ads:r,ima:d});E({config:Object.assign(Object.assign({},e),{autoplay:i}),root:t,content:s,ads:r,ima:d})}}))}class AdControls extends HTMLElement{constructor(e){super(),this.player=e,this.render(),e.on("ad-started",e=>{if(!this.indicatorControl)return;const{position:t,totals:s}=e.detail.ad;this.indicatorControl.textContent=`ADS ${t} / ${s}`})}render(){this.classList.add("fp-ad-controls"),this.indicatorControl=document.createElement("div"),this.indicatorControl.classList.add("ad-indicator","fp-color-text"),this.indicatorControl.textContent="ADS";const e=document.createElement("div");e.classList.add("ad-playback-controls");const t=y(this.player,"flowplayer-small-play-icon");t.addEventListener("click",()=>this.player.emit("request/ad/play"));const s=y(this.player,"flowplayer-small-pause-icon");s.addEventListener("click",()=>this.player.emit("request/ad/pause")),e.append(t,s);const i=y(this.player,"flowplayer-volume-icon");i.addEventListener("click",()=>this.player.emit("request/ad/muteunmute"));const r=y(this.player,"flowplayer-header-right-zone");this.append(this.indicatorControl,e,i,r)}}class AdCountdown extends HTMLElement{constructor(e){super(),this.player=e,e.on("ad-progress",e=>{const{duration:t,remaining:s}=e.detail;this.setAttribute("duration",t+""),this.setAttribute("remaining",s+"")}),this.addEventListener("animationend",()=>{const e=this.style.getPropertyValue("--ad-percent-complete")||"0";this.style.setProperty("--ad-percent-previous",e)})}static get observedAttributes(){return["remaining"]}attributeChangedCallback(e,t){switch(e){case"remaining":return this.onRemaining(t)}}onRemaining(e){const t=parseFloat(this.getAttribute("duration")||"0");e||(e=t+"");const s=parseFloat(e),i=this.style.getPropertyValue("--ad-percent-complete")||"0";this.style.setProperty("--ad-percent-previous",i),this.classList.remove("go");const r=((t-s)/t*100).toFixed(3);requestAnimationFrame(()=>{this.style.setProperty("--ad-percent-complete",r),this.classList.add("go")})}}var He=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{samsung_tv:ze}=function(){const e="undefined"!=typeof document&&"undefined"!=typeof window,t=e?navigator.userAgent:"",s=/iP(hone|od)/i.test(t)&&!/iPad/.test(t)&&!/IEMobile/i.test(t),i=/Android/.test(t)&&!/Firefox/.test(t),r=/^((?!chrome|android).)*safari/i.test(t),a=/SamsungBrowser/.test(t),n=a&&/SMART-TV/.test(t);return{controls:!s,video:function(t){return e&&document.createElement("video").canPlayType(t)},lang:e&&window.navigator.language,android:i,iphone:s,safari:r,ios:e&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,samsung:a,samsung_tv:a&&n,touch:!!("ontouchstart"in window)}}();class Ads{constructor(e){this.umd=e,v(e,"flowplayer-ad-ui",AdUI),v(e,"flowplayer-ad-controls",AdControls),v(e,"flowplayer-ad-countdown",AdCountdown)}init(e,t,s){if(c.from_token(e.token||"").is_granted(c.permissions.ADS)&&!ze)return Ve(e,t,s)}}return Ads.events=g,Ads.ui=He,function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const s=e.flowplayer;"function"==typeof s?s(t):(Array.isArray(s.extensions)||(s.extensions=[]),~s.extensions.indexOf(t)||s.extensions.push(t))}(window,Ads),Ads}));