(function(){var g={}; var _ = _ || {}
var f=function(window){var $V="Ad Error",aW="onAdBreakStarted()",bW="onAdBreakStopped()",cW=function(a){function b(l,m){l in h||!m||(h[l]=m)}var c=_.sk(),d=Conviva.Constants.DeviceType.DESKTOP,e=Conviva.Constants.DeviceCategory.WEB,f=c.os;c=c.osVersion.name;var g="";_.xl()&&(g="Apple");_.wl()?(g="Google",d=Conviva.Constants.DeviceType.SETTOP,e=Conviva.Constants.DeviceCategory.CHROMECAST):_.yl()?(d=Conviva.Constants.DeviceType.MOBILE,/(android)/i.test(navigator.userAgent)?e=Conviva.Constants.DeviceCategory.ANDROID_DEVICE:
_.xl()&&(e=Conviva.Constants.DeviceCategory.APPLE_DEVICE)):_.rk()||_.qk()||_.tl("Hisense")?(d=Conviva.Constants.DeviceType.SMARTTV,e=Conviva.Constants.DeviceCategory.SMART_TV,_.rk()?(c="",g="LG",e=Conviva.Constants.DeviceCategory.LG_TV):_.qk()?(g="Samsung",e=Conviva.Constants.DeviceCategory.SAMSUNG_TV):_.tl("Hisense")&&(c="",g="Hisense")):_.tl("Xbox One")&&(g="Microsoft",d=Conviva.Constants.DeviceType.CONSOLE,e=Conviva.Constants.DeviceCategory.XBOX);var h=a.deviceMetadata||{};b(Conviva.Constants.DeviceMetadata.TYPE,
a.deviceType||d);b(Conviva.Constants.DeviceMetadata.OS_NAME,f);b(Conviva.Constants.DeviceMetadata.OS_VERSION,c);b(Conviva.Constants.DeviceMetadata.CATEGORY,a.deviceCategory||e);b(Conviva.Constants.DeviceMetadata.BRAND,a.deviceBrand||g);return h},dW=function(a){return a?Conviva.Constants.StreamType.LIVE:Conviva.Constants.StreamType.VOD},eW=function(a){return 0===a?"Pre-roll":-1===a?"Post-roll":"Mid-roll"},gW=function(a,b,c,d){var e={};e[Conviva.Constants.PLAYER_NAME]=c;e[Conviva.Constants.VIEWER_ID]=
b;e[Conviva.Constants.IS_LIVE]=dW(!!d);e[Conviva.Constants.ASSET_NAME]=$V;a&&(e[Conviva.Constants.ASSET_NAME]=a.getTitle(),e[Conviva.Constants.STREAM_URL]=a.getMediaUrl(),e[Conviva.Constants.DURATION]=a.getDuration(),e["c3.ad.id"]=fW(a.getId()),e["c3.ad.creativeId"]=fW(a.getCreativeId()),e["c3.ad.system"]=fW(a.getAdSystem()),e["c3.ad.mediaFileApiFramework"]=fW(a.getApiFramework()),e["c3.ad.advertiser"]=fW(a.getAdvertiserName()),e["c3.ad.position"]=eW(a.getPodIndex()),e["c3.ad.technology"]=0===a.Cb()?
Conviva.Constants.AdType.CLIENT_SIDE:Conviva.Constants.AdType.SERVER_SIDE,e["c3.ad.adManagerName"]=fW(a.xb()),e["c3.ad.adManagerVersion"]=fW(a.yb()),e["c3.ad.advertiserCategory"]=fW(null),e["c3.ad.advertiserId"]=fW(null),e["c3.ad.breakId"]=fW(null),e["c3.ad.campaignName"]=fW(null),e["c3.ad.category"]=fW(null),e["c3.ad.classification"]=fW(null),e["c3.ad.creativeName"]=fW(null),e["c3.ad.sequence"]=fW(a.Bb()),e["c3.ad.sessionStartEvent"]=fW(null),e["c3.ad.unitName"]=fW(null),e["c3.ad.dayPart"]=fW(null),
b=a.getWrapperAdIds().slice(-1)[0]||a.getId(),c=a.getWrapperAdSystems().slice(-1)[0]||a.getAdSystem(),a=a.getWrapperCreativeIds().slice(-1)[0]||a.getCreativeId(),e["c3.ad.firstAdId"]=fW(b),e["c3.ad.firstAdSystem"]=fW(c),e["c3.ad.firstCreativeId"]=fW(a));return e},fW=function(a){return a?""+a:"NA"},hW=function(a,b){this.m=a;this.B=b;this.A="";this.w=_.xa;this.g=new _.J("clpp.conviva.ad");this.f=new _.gi;this.a=null;this.j=this.l=this.o=this.h=!1},iW=function(a,b){if(!a.l){a.j=!1;try{if(a.a=Conviva.Analytics.buildAdAnalytics(a.B()),
b){var c=gW(b,a.A,a.w,a.m.isLive()),d=String(b.yb()),e={};e[Conviva.Constants.FRAMEWORK_NAME]=b.xb();e[Conviva.Constants.FRAMEWORK_VERSION]=d;a.a.setAdPlayerInfo(e);a.a.reportAdStarted(c)}}catch(f){a.g.error("Could not create ad analytics session",f)}}},lW=function(a,b,c){c=void 0===c?$V:c;if(a.a){a.a.reportAdMetric(Conviva.Constants.Playback.PLAYER_STATE,Conviva.Constants.PlayerState.STOPPED);switch(b){case jW:a.a.reportAdFailed(c,gW(null,a.A,a.w));break;case kW:a.a.reportAdSkipped();break;default:a.a.reportAdEnded()}a.a.release();
a.a=null;a.h=!1}},mW=function(a){a.f.on(a.m,_.hc,a.ik.bind(a));a.f.on(a.m,_.ic,a.jk.bind(a));a.f.on(a.m,_.xc,a.qk.bind(a));a.f.on(a.m,_.uc,a.qf.bind(a));a.f.on(a.m,_.tc,a.qf.bind(a));a.f.on(a.m,_.vc,a.qf.bind(a));a.f.on(a.m,_.jc,a.qf.bind(a));a.f.on(a.m,_.zc,a.rk.bind(a));a.f.on(a.m,_.wc,a.pk.bind(a));a.f.on(a.m,_.kc,a.kk.bind(a));a.f.on(a.m,_.qc,a.mk.bind(a));a.f.on(a.m,_.rc,a.nk.bind(a));a.f.on(a.m,_.mc,a.lk.bind(a));a.f.on(a.m,_.sc,a.Tm.bind(a));a.f.on(a.m,_.Ac,a.sk.bind(a));a.f.on(a.m,_.ie,function(b){var c=
b.detail;if(10003===c.code&&(a.g.debug("onAdError()"),!a.j)){b=Conviva.Constants.ErrorSeverity;switch(c.data.errorType){case 0:c="Ad Load Error";break;case 1:c="Ad Play Error";break;default:c=$V}null===a.a&&iW(a,null);a.a.reportAdError(c,b.FATAL);a.j=!0;a.g.debug("Ad Playback Failure");lW(a,jW,c)}})},nW=function(a,b){this.m=a;this.f=new _.gi;this.a=null;this.o=!1;this.H=!0;this.B=this.h=this.A=this.C=this.l=!1;this.N=0;this.K=!1;this.w=null;this.J=!1;this.g=b;this.L=this.G=null;this.j=[];this.I=0},
oW=function(a){if(!a.l&&a.a){var b=dW(a.m.isLive()),c={};c[Conviva.Constants.IS_LIVE]=b;c[Conviva.Constants.DURATION]=a.m.getDuration();a.a.setContentInfo(c)}},pW=function(a){return null!==a.a&&a.C},qW=function(a){return a.m.getConfiguration().autoplay||!1},rW=function(a,b){var c={};c[Conviva.Constants.LOG_LEVEL]=Conviva.Constants.LogLevel.DEBUG;b.serviceUrl&&(a.g.warn("Touchstone URL is set. Do not set this in production!"),c[Conviva.Constants.GATEWAY_URL]=b.serviceUrl.replace(/\/$/,""));Conviva.Analytics.init(b.customerKey,
null,c);Conviva.Analytics.setDeviceMetadata(cW(b));b.connectionType&&Conviva.Analytics.reportDeviceMetric(Conviva.Constants.Network.CONNECTION_TYPE,b.connectionType);a.a=Conviva.Analytics.buildVideoAnalytics();a.o=!1;c={};c[Conviva.Constants.FRAMEWORK_NAME]=_.xa;c[Conviva.Constants.FRAMEWORK_VERSION]=_.ia;a.a.setPlayerInfo(c)},sW=function(a){if(!a.l)if(a.C)a.g.warn("Current session still active. No-op.");else{var b=a.m.getLoadedSource()||a.L,c=a.m.getConfiguration().conviva||null,d=c&&c.viewerId||
"N/A",e=c&&c.defaultResource||"N/A";a.g.debug(a.m.getConfiguration().source);var f={},g=new _.Mk(b.url);b&&(f[Conviva.Constants.ASSET_NAME]=b.name||"N/A",f[Conviva.Constants.STREAM_URL]=_.Nk(g));f[Conviva.Constants.PLAYER_NAME]=c.playerName||_.xa;f[Conviva.Constants.VIEWER_ID]=d;f[Conviva.Constants.DEFAULT_RESOURCE]=e;if(c&&!_.L.R(c.customTags))for(var h in c.customTags)f[h]=c.customTags[h];a.a.reportPlaybackRequested(f);a.a.setCallback(function(){a.g.debug("reportMiscellaneousMetrics()");if(pW(a)){var l=
1E3*a.m.getPosition();a.a.reportPlaybackMetric(Conviva.Constants.Playback.PLAY_HEAD_TIME,l);if(l=a.m.getStats()){l=l.decodedFrames;var m=l-a.I;a.I=l;isFinite(m)&&(a.g.debug("Current FPS",m),a.a.reportPlaybackMetric(Conviva.Constants.Playback.RENDERED_FRAMERATE,m))}}});a.C=!0;a.h=!0;a.J=!1;0<a.j.length&&(a.g.debug("Report deferred events"),a.j.forEach(function(l){l.Xh(l.args)}));a.j=[]}},tW=function(a){a.g.debug("terminateSession()");a.a&&(a.a.reportPlaybackMetric(Conviva.Constants.Playback.PLAYER_STATE,
Conviva.Constants.PlayerState.STOPPED),a.a.reportPlaybackEnded(),a.a.release(),Conviva.Analytics.release(),a.o=!0,a.C=!1,a.A=!1,a.h=!1,a.w=null,a.B=!1,a.N=0,a.K=!1,a.j=[],a.I=0)},uW=function(){this.h=this.f=null;this.a=!1;this.g=new _.J("clpp.conviva")},vW=function(a){var b=[];typeof a===_.Re&&(a.customerKey||b.push("customerKey"),a.viewerId||b.push("viewerId"));if(0<b.length)throw new _.N(1,9,9001,{missingKeys:b});},xW=function(a,b){var c=b.getConfiguration();a.a=!_.L.R(c.conviva)&&typeof c.conviva===
_.Re;a.a?"undefined"===typeof window.Conviva?(a.g.warn("Conviva SDK is not loaded. Will do nothing."),a.a=!1,c=new _.N(1,9,9E3),wW(b,c)):b.namespace()===_.sd&&(a.a=!1,a.g.debug("Conviva does not report when casting.")):a.g.debug("Conviva plugin is loaded but not configured. Will do nothing.")},wW=function(a,b){a.trigger(new _.K(_.ie,{detail:b}))},yW=function(){};_.r=hW.prototype;_.r.initialize=function(a){this.g.debug("Initialize Ad Insights");this.j=this.o=!1;this.A=a.viewerId;this.w=a.playerName||_.xa;mW(this)};_.r.release=function(){this.g.debug("Release Ad Insights");this.o?this.g.debug(_.na):(_.ki(this.f),this.a&&lW(this,zW),this.f.release(),this.o=!0,this.h=this.j=!1)};_.r.destroy=function(){this.g.debug(_.Nd);this.l?this.g.debug(_.ma):this.l=!0};_.r.ik=function(){this.g.debug(aW)};_.r.jk=function(){this.g.debug(bW)};
_.r.qk=function(a){this.g.debug("onAdStarted()");a=a.ad;this.h||(this.g.warn("Ad load event was not triggered. This will have incidence on VSF"),iW(this,a));this.h=!1;this.a.reportAdMetric(Conviva.Constants.Playback.PLAYER_STATE,Conviva.Constants.PlayerState.PLAYING);this.a.reportAdMetric(Conviva.Constants.Playback.RESOLUTION,a.ob(),a.nb());this.a.reportAdMetric(Conviva.Constants.Playback.BITRATE,a.Ua())};
_.r.qf=function(a){var b=this;this.g.debug("onAdStateChanged()");if(this.a){var c=function(d){b.a.reportAdMetric(Conviva.Constants.Playback.PLAYER_STATE,d)};switch(a.type){case _.uc:case _.vc:c(Conviva.Constants.PlayerState.PLAYING);break;case _.tc:c(Conviva.Constants.PlayerState.PAUSED);break;case _.jc:c(Conviva.Constants.PlayerState.BUFFERING)}}};_.r.rk=function(){this.g.debug("onAdStopped()");this.a&&!this.j&&lW(this,zW)};_.r.pk=function(){this.g.debug("onAdSkipped()");this.a&&lW(this,kW)};
_.r.kk=function(){this.g.debug("onAdClicked()");this.a&&this.a.reportAdPlayerEvent("AdClicked")};_.r.mk=function(){this.g.debug("onAdImpression()");if(this.a){var a=Conviva.Constants.Events;this.a.reportAdPlayerEvent(a.AD_IMPRESSION_START);this.a.reportAdPlayerEvent(a.AD_IMPRESSION_END)}};
_.r.nk=function(a){var b=this;this.g.debug("onAdLoaded()");var c=a.ad;if(-1!==c.getPodIndex()||this.m.getPosition()>=this.m.getDuration()-5)b.h=!0,iW(b,c);else this.f.on(this.m,_.rg,function(){b.m.getPosition()>=b.m.getDuration()-5&&(b.f.off(b.m,_.rg),b.h=!0,iW(b,c))})};_.r.lk=function(){this.g.debug("onAdFirstQuartile()");this.a&&this.a.reportAdPlayerEvent(Conviva.Constants.Events.AD_FIRST_QUARTILE)};_.r.Tm=function(){this.g.debug("onAdMidPoint()");this.a&&this.a.reportAdPlayerEvent(Conviva.Constants.Events.AD_MID_QUARTILE)};
_.r.sk=function(){this.g.debug("onAdThirdQuartile()");this.a&&this.a.reportAdPlayerEvent(Conviva.Constants.Events.AD_THIRD_QUARTILE)};var kW=0,zW=1,jW=2;_.r=nW.prototype;
_.r.initialize=function(a,b,c){this.l||(this.g.debug("Initialize conviva"),this.H=!1,this.G=_.L.kb(b),this.L=c,this.m=a,rW(this,this.G),this.f.on(this.m,_.ff,this.vn.bind(this)),this.f.on(this.m,_.bg,this.xk.bind(this)),this.f.on(this.m,_.Yc,this.wh.bind(this)),this.f.on(this.m,_.Cg,this.wk.bind(this)),this.f.on(this.m,_.Bg,this.vk.bind(this)),this.f.on(this.m,_.hc,this.tk.bind(this)),this.f.on(this.m,_.ic,this.uk.bind(this)),this.f.on(this.m,_.Cc,this.Ym.bind(this)),this.f.on(this.m,_.Xc,this.Zm.bind(this)),
this.f.on(this.m,_.ie,this.xh.bind(this)),qW(this)&&(this.g.debug("Start a new session: A new video starts in autoplay."),sW(this)))};_.r.release=function(){this.g.debug("Release conviva");this.H?this.g.debug(_.na):(_.ki(this.f),pW(this)||this.o||!qW(this)||this.a&&this.a.reportPlaybackFailed("Exit Before Video Start"),pW(this)&&tW(this),this.a=null,this.H=!0)};_.r.destroy=function(){this.g.debug(_.Nd);this.l?this.g.debug(_.ma):this.l=!0};
_.r.reportAppEvent=function(a,b){var c=!1;try{Conviva.Analytics.reportAppEvent(a,b),c=!0}catch(d){this.g.debug("Report app event error",d),c=!1}return c};_.r.vn=function(){this.g.debug("onPlayRequest()");pW(this)||qW(this)?pW(this)&&this.A&&!this.h&&(this.g.debug("Resuming VST monitoring ..."),pW(this)&&!this.h&&(this.a.reportPlaybackEvent(Conviva.Constants.Events.USER_WAIT_ENDED),this.h=!0),this.A=!1):(this.g.debug("Creating conviva session. On Play Requested / No autoplay"),sW(this))};
_.r.xk=function(a){function b(d){if(c.o&&(c.g.debug("Creating conviva session (On Seek / Replay)"),rW(c,c.G),sW(c),oW(c),pW(c))){var e=c.m.getTrackManager();e=e.ma()||e.Ab();e.width&&e.height&&c.a.reportPlaybackMetric(Conviva.Constants.Playback.RESOLUTION,e.width,e.height);e.bandwidth&&c.a.reportPlaybackMetric(Conviva.Constants.Playback.BITRATE,e.bandwidth/1E3)}pW(c)&&c.a.reportPlaybackMetric(Conviva.Constants.Playback.PLAYER_STATE,d)}var c=this;this.g.debug(_.Xe);switch(a.detail.currentState){case _.Hq:b(Conviva.Constants.PlayerState.PLAYING);
break;case _.Gq:b(Conviva.Constants.PlayerState.PAUSED);break;case _.yq:b(Conviva.Constants.PlayerState.BUFFERING);break;case _.Aq:this.g.debug("onVideoEnded()"),pW(this)&&(this.w&&this.w.Qb()?(this.g.debug("Waiting for postroll Ad before terminating session"),this.K=!0):tW(this))}};
_.r.wh=function(a){this.g.debug(_.Se);if(pW(this)){if(a=a.detail,typeof a.width===_.k&&typeof a.height===_.k&&this.a.reportPlaybackMetric(Conviva.Constants.Playback.RESOLUTION,a.width,a.height),a.bandwidth&&this.a.reportPlaybackMetric(Conviva.Constants.Playback.BITRATE,a.bandwidth/1E3),(a=a.rendition)&&a.track&&(a=a.track)&&a.frameRate){var b={};b[Conviva.Constants.ENCODED_FRAMERATE]=a.frameRate;this.a.setContentInfo(b)}}else this.j.push({Xh:this.wh.bind(this),args:a})};
_.r.wk=function(){this.g.debug("onSeeking()");pW(this)&&this.a.reportPlaybackMetric(Conviva.Constants.Playback.SEEK_STARTED)};_.r.vk=function(){this.g.debug("onSeeked()");pW(this)&&this.a.reportPlaybackMetric(Conviva.Constants.Playback.SEEK_ENDED)};_.r.Ym=function(a){this.g.debug("onAdsTimelineChanged()");if(a=a.adsTimeline)this.w=a};
_.r.tk=function(a){this.g.debug(aW);var b=a.ad;a=0===b.Va();var c=eW(b.getPodIndex());pW(this)||qW(this)||!a||sW(this);if(pW(this)){a=0===b.Cb()?Conviva.Constants.AdType.CLIENT_SIDE:Conviva.Constants.AdType.SERVER_SIDE;var d=0,e={};1===b.pb()&&(d=b.getDuration());e[Conviva.Constants.POD_DURATION]=d;e[Conviva.Constants.POD_INDEX]=++this.N;e[Conviva.Constants.POD_POSITION]=c;b=Conviva.Constants.AdPlayer;b=a!==Conviva.Constants.AdType.CLIENT_SIDE||_.wl()?b.CONTENT:b.SEPARATE;this.a.reportAdBreakStarted(a,
b,e);this.B=!0}else this.g.debug("Bug: should already have a valid session")};_.r.uk=function(){this.g.debug(bW);pW(this)&&this.B&&(this.a.reportAdBreakEnded(),this.B=!1,this.K&&tW(this))};
_.r.xh=function(a){this.g.debug(_.Ue);if(this.o&&this.J)this.g.debug("Session ended in VPF; ignoring subsequent errors");else{var b=a.detail||null,c=b&&b.message||"Player error",d=Conviva.Constants.ErrorSeverity.WARNING;b&&b.severity&&b.severity===_.O&&(d=Conviva.Constants.ErrorSeverity.FATAL,pW(this)||sW(this));pW(this)?(this.g.debug("Report error",c,d),this.a.reportPlaybackError(c,d),d===Conviva.Constants.ErrorSeverity.FATAL&&(this.g.debug("Video Playback Failure"),this.J=!0,tW(this))):this.j.push({Xh:this.xh.bind(this),
args:a})}};_.r.Zm=function(){this.g.debug("onAutoPlayBlocked()");pW(this)&&(this.g.debug("Auto-play blocked. Pausing VST monitoring."),this.A=!0,pW(this)&&this.h&&(this.a.reportPlaybackEvent(Conviva.Constants.Events.USER_WAIT_STARTED),this.h=!1))};_.r=uW.prototype;_.r.onPlayerCreated=function(a){this.f=new nW(a,this.g)};_.r.onContentWillLoad=function(a,b){var c=this;xW(this,a);if(this.a){var d=a.getConfiguration();d=_.L.kb(d.conviva||{});try{vW(d);var e=d.enableAdInsights||!1;this.f.initialize(a,d,b);e&&(this.h=new hW(a,function(){return c.f.a}),this.h.initialize(d))}catch(f){f instanceof _.N?wW(a,f):wW(a,new _.N(1,9,9002,f,f))}}};_.r.onContentLoaded=function(a,b){for(var c=1;c<arguments.length;++c);this.a&&oW(this.f)};
_.r.onPlayerWillDestroy=function(){this.a&&(this.a=!1,this.f.destroy(),this.f=null,this.h&&(this.h.destroy(),this.h=null))};_.r.onPlayerWillRelease=function(){this.a&&(this.f.release(),this.h&&this.h.release())};_.r.id=function(){return"conviva"};_.r.reportAppEvent=function(a,b){return this.f?this.f.reportAppEvent(a,b):!1};_.I("clpp.conviva.ConvivaPlugin",uW);uW.prototype.reportAppEvent=uW.prototype.reportAppEvent;uW.Id="conviva";yW.prototype.create=function(){return new uW};_.Yt(new yW);};
if(typeof(module)!="undefined"&&module.exports){var x=require("./cl.core.js");_ = x._;(f.call(g,this));module.exports=g;}
else if (typeof(define)!="undefined"&&define.amd) {define(["./cl.core"], function(c){_=c._;(f.call(g,this));return g;});}
else{_=this.clpp._;(f.call(g,this));}
})();