@newrelic/video-videojs 4.2.0 → 4.2.1
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/CHANGELOG.md +61 -0
- package/README.md +88 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.LICENSE.txt +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.LICENSE.txt +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/umd/newrelic-video-videojs.min.js +1 -1
- package/dist/umd/newrelic-video-videojs.min.js.LICENSE.txt +1 -1
- package/dist/umd/newrelic-video-videojs.min.js.map +1 -1
- package/package.json +1 -1
- package/src/tracker.js +43 -11
package/dist/cjs/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! For license information please see index.js.LICENSE.txt */
|
|
2
|
-
(()=>{"use strict";var e={38:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s,a=(s=i(472))&&s.__esModule?s:{default:s};class r extends a.default{static isUsing(e){return!!e.FreeWheelPlugin&&"undefined"!=typeof tv&&tv.freewheel}getTrackerName(){return"freewheel-ads"}getPlayerName(){return"freewheel-ads"}getPlayerVersion(){return this.player.FreeWheelPlugin.VERSION}getPlayhead(){if(this.player.ads.ad.currentTime)return 1e3*this.player.ads.ad.currentTime()}getDuration(){if(this.player.ads.ad.duration)return 1e3*this.player.ads.ad.duration}getVideoId(){return this.player.ads.ad.id}getAdPartner(){return"freewheel"}getAdCreativeId(){try{return this.player.ads.provider.event.adInstance.getActiveCreativeRendition().getId()}catch(e){}}getSrc(){try{return this.player.ads.provider.event.adInstance.getActiveCreativeRendition().getPrimaryCreativeRenditionAsset().getUrl()}catch(e){}}getTitle(){try{return this.player.ads.provider.event.adInstance.getActiveCreativeRendition().getPrimaryCreativeRenditionAsset().getName()}catch(e){}}getAdPosition(){switch(this.player.ads.ad.type){case"PREROLL":return nrvideo.Constants.AdPositions.PRE;case"MIDROLL":return nrvideo.Constants.AdPositions.MID;case"POSTROLL":return nrvideo.Constants.AdPositions.POST}}}t.default=r},64:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=r(i(555)),a=r(i(472));function r(e){return e&&e.__esModule?e:{default:e}}class n extends a.default{static isUsing(e){return!!e.ima3}getTrackerName(){return"brightcove-ima-ads"}getPlayerName(){return"brightcove-ima-ads"}getPlayhead(){return this.player?.ima3?.adPlayer?.currentTime()}registerListeners(){s.default.Log.debugCommonVideoEvents(this.player,[null,"ima3-ready","ima3error","ima3-ad-error","ima3-started","ima3-complete","ima3-paused","ima3-resumed","ads-request","ads-load","ads-ad-started","ads-ad-ended","ads-pause","ads-play","ads-click","ads-pod-started","ads-pod-ended","ads-allpods-completed"]),this.player.on("ima3-started",this.onStarted.bind(this)),this.player.on("ima3-paused",this.onPaused.bind(this)),this.player.on("ima3-resumed",this.onResume.bind(this)),this.player.on("ima3-complete",this.onComplete.bind(this)),this.player.on("ima3-skipped",this.onSkipped.bind(this)),this.player.on("adserror",this.onError.bind(this)),this.player.on("ads-click",this.onClick.bind(this))}unregisterListeners(){this.player.off("ima3-started",this.onStarted),this.player.off("ima3-paused",this.onPaused),this.player.off("ima3-resumed",this.onResume),this.player.off("ima3-complete",this.onComplete),this.player.off("ima3-skipped",this.onSkipped),this.player.off("adserror",this.onError),this.player.off("ads-click",this.onClick)}onStarted(e){this.sendRequest(),this.sendStart()}onPaused(e){this.sendPause()}onResume(e){this.sendResume()}onComplete(e){this.sendEnd()}onSkipped(e){this.sendEnd({skipped:!0})}onError(e){this.sendError()}onClick(e){this.sendClick()}}t.default=n},257:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;class i{constructor(e){this.tech=e.vhs_,this.player=e.el().player}getResource(e){return this.tech.url}getRenditionName(e){try{var t=this.tech.levels[this.tech.currentLevel];if(t&&t.name)return t.name}catch(e){}return null}getRenditionBitrate(e){try{var t=this.tech.levels[this.tech.currentLevel];if(t&&t.bitrate)return Math.round(t.bitrate)}catch(e){}return null}getRenditionWidth(e){try{var t=this.tech.levels[this.tech.currentLevel];if(t&&t.width)return t.width}catch(e){}return null}getRenditionHeight(e){try{var t=this.tech.levels[this.tech.currentLevel];if(t&&t.height)return t.height}catch(e){}return null}getBitrate(){return this.getContentBitratePlayback()}getContentBitratePlayback(){try{const e=this.tech.levels[this.tech.currentLevel];if(e&&e.bitrate)return Math.round(e.bitrate)}catch(e){}return null}getManifestBitrate(){try{if(this.tech.levels&&this.tech.levels.length>0)return Math.round(Math.max(...this.tech.levels.map((e=>e.bitrate))))}catch(e){}return null}getSegmentDownloadBitrate(){try{if(this.tech.stats&&this.tech.stats.bandwidth>0)return Math.round(this.tech.stats.bandwidth)}catch(e){}return null}getNetworkDownloadBitrate(){return this.tech.throughput&&this.tech.throughput>0?Math.round(this.tech.throughput):null}}t.default=i,i.isUsing=function(e){return!!e.vhs_}},298:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=r(i(555)),a=r(i(472));function r(e){return e&&e.__esModule?e:{default:e}}class n extends a.default{static isUsing(e){return e.ima&&"undefined"!=typeof google}getTrackerName(){return"ima-ads"}getPlayerName(){return"ima"}getPlayerVersion(){return"ima: "+google.ima.VERSION+"; contrib-ads: "+this.player.ads.VERSION}getCuePoints(){return this.player.ima.getAdsManager().getCuePoints()}getAdPosition(){if(this.lastAdData&&this.lastAdData.podInfo&&void 0!==this.lastAdData.podInfo.podIndex){const e=this.lastAdData.podInfo.podIndex;return 0===e?"pre":-1===e?"post":"mid"}return null}getDuration(){return this.lastAdData&&void 0!==this.lastAdData.duration?1e3*this.lastAdData.duration:null}getVideoId(){return this.lastAdData&&this.lastAdData.adId?this.lastAdData.adId:null}getAdCreativeId(){return this.lastAdData&&this.lastAdData.creativeId?this.lastAdData.creativeId:null}getSrc(){return this.lastAdData&&this.lastAdData.mediaUrl?this.lastAdData.mediaUrl:null}getTitle(){return this.lastAdData&&this.lastAdData.title?this.lastAdData.title:null}getPlayhead(){let e=this.player.ima.getAdsManager();if(e)return 1e3*(this.getDuration()-e.getRemainingTime())}getPlayrate(){return this.player.playbackRate()}getAdPartner(){return"ima"}getWebkitBitrate(){const e=this.getAdVideoElement();if(e&&e.webkitVideoDecodedByteCount){let t;if(this._lastAdWebkitBitrate>0){const i=e.webkitVideoDecodedByteCount-this._lastAdWebkitBitrate,s=this.getHeartbeat()/1e3;t=Math.round(i/s*8)}return this._lastAdWebkitBitrate=e.webkitVideoDecodedByteCount,t??null}return null}getRenditionBitrate(){return this.lastAdData&&this.lastAdData.renditionBitrate?Math.round(this.lastAdData.renditionBitrate):null}registerListeners(){let e=google.ima.AdEvent.Type,t=google.ima.AdErrorEvent.Type.AD_ERROR;this.lastAdData=null,s.default.Log.debugCommonVideoEvents(this.player.ima.addEventListener,[null,e.ALL_ADS_COMPLETED,e.LINEAR_CHANGED,e.COMPLETE,e.USER_CLOSE,e.IMPRESSION,e.CONTENT_PAUSE_REQUESTED,e.CONTENT_RESUME_REQUESTED,e.SKIPPED,e.SKIPPABLE_STATE_CHANGED,e.LOADED,e.PAUSED,e.RESUMED,e.STARTED,e.AD_CAN_PLAY,e.AD_METADATA,e.EXPANDED_CHANGED,e.AD_BREAK_READY,e.LOG,e.CLICK,e.FIRST_QUARTILE,e.MIDPOINT,e.THIRD_QUARTILE,t]),this.player.ima.addEventListener(e.LOADED,this.onLoaded.bind(this)),this.player.ima.addEventListener(e.STARTED,this.onStart.bind(this)),this.player.ima.addEventListener(e.PAUSED,this.onPaused.bind(this)),this.player.ima.addEventListener(e.RESUMED,this.onResumed.bind(this)),this.player.ima.addEventListener(e.COMPLETE,this.onComplete.bind(this)),this.player.ima.addEventListener(e.SKIPPED,this.onSkipped.bind(this)),this.player.ima.addEventListener(e.CLICK,this.onClick.bind(this)),this.player.ima.addEventListener(e.FIRST_QUARTILE,this.onFirstQuartile.bind(this)),this.player.ima.addEventListener(e.MIDPOINT,this.onMidpoint.bind(this)),this.player.ima.addEventListener(e.THIRD_QUARTILE,this.onThirdQuartile.bind(this)),this.player.ima.addEventListener(t,this.onError.bind(this))}unregisterListeners(){let e=google.ima.AdEvent.Type,t=google.ima.AdErrorEvent.Type.AD_ERROR;this.player.ima.removeEventListener(e.LOADED,this.onLoaded),this.player.ima.removeEventListener(e.STARTED,this.onLoaded.bind(this)),this.player.ima.removeEventListener(e.IMPRESSION,this.onImpression),this.player.ima.removeEventListener(e.PAUSED,this.onPaused),this.player.ima.removeEventListener(e.RESUMED,this.onResumed),this.player.ima.removeEventListener(e.COMPLETE,this.onComplete),this.player.ima.removeEventListener(e.SKIPPED,this.onSkipped),this.player.ima.removeEventListener(e.CLICK,this.onClick),this.player.ima.removeEventListener(e.FIRST_QUARTILE,this.onFirstQuartile),this.player.ima.removeEventListener(e.MIDPOINT,this.onMidpoint),this.player.ima.removeEventListener(e.THIRD_QUARTILE,this.onThirdQuartile),this.player.ima.removeEventListener(t,this.onError),this.lastAdData=null}onLoaded(e){this.lastAdData=this.getAdData(),this.sendRequest()}onStart(e){this.lastAdData=this.getAdData(),this._lastAdWebkitBitrate=0,this.sendStart()}onComplete(e){this.sendEnd(),this.lastAdData=null}onSkipped(e){this.sendEnd({skipped:!0}),this.lastAdData=null}onError(e){const t=e.getError(),i=t.getErrorCode(),s=t.getMessage();this.sendError({adError:t,errorCode:i,errorMessage:s})}onClick(e){this.sendAdClick()}onFirstQuartile(){this.sendAdQuartile({adQuartile:1})}onMidpoint(){this.sendAdQuartile({adQuartile:2})}onThirdQuartile(){this.sendAdQuartile({adQuartile:3})}onPaused(){this.sendPause()}onResumed(){this.sendResume()}getAdData(){try{const e=this.player.ima.getAdsManager();if(e){const t=e.getCurrentAd();if(t)return{adId:t.getAdId(),creativeId:t.getCreativeId(),duration:t.getDuration(),mediaUrl:t.getMediaUrl(),title:t.getTitle(),podInfo:t.getAdPodInfo()?.data,renditionBitrate:t.getVastMediaBitrate()}}return null}catch(e){return null}}getAdVideoElement(){if(this.player.ima&&this.player.ima.controller&&this.player.ima.controller.adUi){const e=this.player.ima.controller.adUi.adContainerDiv;if(e){const t=e.querySelector("video");if(t)return t}}}}t.default=n},302:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AD_TRACKING=void 0,Object.defineProperty(t,"BrightcoveImaAdsTracker",{enumerable:!0,get:function(){return h.default}}),Object.defineProperty(t,"ContribHlsTech",{enumerable:!0,get:function(){return r.default}}),Object.defineProperty(t,"DaiAdsTracker",{enumerable:!0,get:function(){return c.default}}),Object.defineProperty(t,"FreewheelAdsTracker",{enumerable:!0,get:function(){return u.default}}),Object.defineProperty(t,"HlsJsTech",{enumerable:!0,get:function(){return n.default}}),Object.defineProperty(t,"ImaAdsTracker",{enumerable:!0,get:function(){return l.default}}),Object.defineProperty(t,"MediaTailorAdsTracker",{enumerable:!0,get:function(){return g.default}}),Object.defineProperty(t,"ShakaTech",{enumerable:!0,get:function(){return d.default}}),Object.defineProperty(t,"VideojsAdsTracker",{enumerable:!0,get:function(){return o.default}}),t.default=void 0;var s=m(i(555)),a=m(i(330)),r=m(i(409)),n=m(i(257)),d=m(i(338)),o=m(i(472)),l=m(i(298)),h=m(i(64)),u=m(i(38)),c=m(i(717)),g=m(i(687));function m(e){return e&&e.__esModule?e:{default:e}}const A=t.AD_TRACKING={CSAI:"csai",SSAI:Object.freeze({DAI:"ssai:dai",MT:"ssai:mt"})};class T extends s.default.VideoTracker{constructor(e,t){if(super(e,t),this.options=t,this.isContentEnd=!1,this.imaAdCuePoints="",this.daiInitialized=!1,this.adTracking=t?.config?.ad?.type||null,t&&!this.adTracking&&s.default.Log.warn("VideojsTracker: config.ad not set — no ad tracking will run. Set config.ad.type to enable it (e.g. AD_TRACKING.CSAI, AD_TRACKING.SSAI.MT)."),this.adTracking===A.SSAI.MT){const e=t?.config?.ad||{};this.options=Object.assign({},this.options,{mediatailor:{segmentPrefix:e.segmentPrefix,trackingUrl:e.trackingUrl,...this.options?.mediatailor}})}s.default.Core.addTracker(this,t)}setAdTracking(e){const t=[A.CSAI,...Object.values(A.SSAI)];t.includes(e)?(this.adTracking=e,s.default.Log.debug(`VideojsTracker: adTracking set to "${e}"`)):s.default.Log.warn(`VideojsTracker.setAdTracking: unknown value "${e}". Valid values: ${t.join(", ")}`)}getTech(){let e=this.player.tech({IWillNotUseThisInPlugins:!0});if(e){if(r.default.isUsing(e))return new r.default(e);if(n.default.isUsing(e))return new n.default(e);if(d.default.isUsing(e))return new d.default(e)}}getTrackerName(){return"videojs"}getInstrumentationProvider(){return"New Relic"}getInstrumentationName(){return this.getPlayerName()}getInstrumentationVersion(){return this.getPlayerVersion()}getTrackerVersion(){return a.default.version}getPlayhead(){return this.player.ads&&"ads-playback"===this.player.ads.state&&this.player.ads.snapshot&&this.player.ads.snapshot.currentTime?1e3*this.player.ads.snapshot.currentTime:this.player.absoluteTime?1e3*this.player.absoluteTime():1e3*this.player.currentTime()}getDuration(){return this.player.mediainfo&&void 0!==this.player.mediainfo.duration?1e3*this.player.mediainfo.duration:1e3*this.player.duration()}getTitle(){return this.player?.mediainfo?.name}getId(){return this.player?.mediainfo?.id}getLanguage(){return this.player?.language()}getSrc(){let e=this.getTech();return e&&e.getSrc?e.getSrc():this.player.currentSrc()}getPlayerName(){return this.player?.name()||"videojs"}getPlayerVersion(){return this.player?.version||videojs.VERSION}isMuted(){return this.player.muted()}getBitrate(){return this.getContentBitratePlayback()}getContentBitratePlayback(){try{const e=this.player.tech({IWillNotUseThisInPlugins:!0});if(e?.vhs?.playlists?.media()){const t=e.vhs.playlists.media(),i=t.attributes["AVERAGE-BANDWIDTH"]||t.attributes.BANDWIDTH||null;return null!==i?Math.round(i):null}const t=this.getTech();if(t?.getBitrate){const e=t.getBitrate();return null!==e?Math.round(e):null}}catch(e){}return null}getRenditionName(){let e=this.getTech();if(e&&e.getRenditionName)return e.getRenditionName()}getManifestBitrate(){try{const e=this.player.tech({IWillNotUseThisInPlugins:!0}),t=e?.vhs?.playlists?.master?.playlists;if(t&&t.length>0){const e=Math.max(...t.map((e=>e.attributes.BANDWIDTH||0)));return e>0?Math.round(e):null}const i=this.getTech();if(i?.getManifestBitrate){const e=i.getManifestBitrate();return null!==e?Math.round(e):null}}catch(e){}return null}getSegmentDownloadBitrate(){try{const e=this.player.tech({IWillNotUseThisInPlugins:!0});if(e?.vhs?.stats?.bandwidth&&e.vhs.stats.bandwidth>0)return Math.round(e.vhs.stats.bandwidth);const t=this.getTech();if(t?.getSegmentDownloadBitrate){const e=t.getSegmentDownloadBitrate();return null!==e?Math.round(e):null}}catch(e){}return null}getNetworkDownloadBitrate(){const e=this.player.tech({IWillNotUseThisInPlugins:!0});if(e?.vhs?.throughput&&e.vhs.throughput>0)return Math.round(e.vhs.throughput);const t=this.getTech();if(t?.getNetworkDownloadBitrate){const e=t.getNetworkDownloadBitrate();return null!==e?Math.round(e):null}return null}getRenditionHeight(){let e=this.getTech();return e&&e.getRenditionHeight?e.getRenditionHeight():this.player.videoHeight()}getRenditionWidth(){let e=this.getTech();return e&&e.getRenditionWidth?e.getRenditionWidth():this.player.videoWidth()}getPlayrate(){return this.player.playbackRate()}isAutoplayed(){return this.player.autoplay()}isFullscreen(){return this.player.isFullscreen()}getPreload(){return this.player.preload()}registerListeners(){s.default.Log.debugCommonVideoEvents(this.player,["adstart","adend","adskip","adsready","adserror","dispose"]),this.onDownload=this.onDownload.bind(this),this.onAdsready=this.onAdsready.bind(this),this.onAdStart=this.onAdStart.bind(this),this.onAdEnd=this.onAdEnd.bind(this),this.onPlay=this.onPlay.bind(this),this.onPause=this.onPause.bind(this),this.onPlaying=this.onPlaying.bind(this),this.onAbort=this.onAbort.bind(this),this.onEnded=this.onEnded.bind(this),this.onDispose=this.onDispose.bind(this),this.onSeeking=this.onSeeking.bind(this),this.onSeeked=this.onSeeked.bind(this),this.onError=this.onError.bind(this),this.onWaiting=this.onWaiting.bind(this),this.onTimeupdate=this.onTimeupdate.bind(this),this.OnAdsAllpodsCompleted=this.OnAdsAllpodsCompleted.bind(this),this.onStreamManager=this.onStreamManager.bind(this),this.onCanPlayThrough=this.onCanPlayThrough.bind(this),this.player.on("loadstart",this.onDownload),this.player.on("loadeddata",this.onDownload),this.player.on("loadedmetadata",this.onDownload),this.player.on("adsready",this.onAdsready),this.player.on("adstart",this.onAdStart),this.player.on("adend",this.onAdEnd),this.player.on("play",this.onPlay),this.player.on("pause",this.onPause),this.player.on("playing",this.onPlaying),this.player.on("abort",this.onAbort),this.player.on("ended",this.onEnded),this.player.on("dispose",this.onDispose),this.player.on("seeking",this.onSeeking),this.player.on("seeked",this.onSeeked),this.player.on("error",this.onError),this.player.on("waiting",this.onWaiting),this.player.on("timeupdate",this.onTimeupdate),this.player.on("ads-allpods-completed",this.OnAdsAllpodsCompleted),this.player.on("stream-manager",this.onStreamManager),this.player.on("canplaythrough",this.onCanPlayThrough)}unregisterListeners(){this.player.off("loadstart",this.onDownload),this.player.off("loadeddata",this.onDownload),this.player.off("loadedmetadata",this.onDownload),this.player.off("adsready",this.onAdsready),this.player.off("adstart",this.onAdStart),this.player.off("adend",this.onAdEnd),this.player.off("play",this.onPlay),this.player.off("pause",this.onPause),this.player.off("playing",this.onPlaying),this.player.off("abort",this.onAbort),this.player.off("ended",this.onEnded),this.player.off("dispose",this.onDispose),this.player.off("seeking",this.onSeeking),this.player.off("seeked",this.onSeeked),this.player.off("error",this.onError),this.player.off("waiting",this.onWaiting),this.player.off("timeupdate",this.onTimeupdate),this.player.off("ads-allpods-completed",this.OnAdsAllpodsCompleted),this.player.off("stream-manager",this.onStreamManager),this.player.off("canplaythrough",this.onCanPlayThrough)}onDownload(e){this.sendDownload({state:e.type}),this.adTracking!==A.SSAI.MT||this.adsTracker||"loadstart"!==e.type||(s.default.Log.debug("VideojsTracker: Creating MediaTailorAdsTracker"),this.setAdsTracker(new g.default(this.player,this.options)),this.adsTracker.setIsAd(!1))}onStreamManager(e){if(this.adTracking===A.SSAI.DAI&&!this.adsTracker&&e.StreamManager){const t=new c.default(this.player);t.setStreamManager(e.StreamManager),this.setAdsTracker(t)}}onAdsready(){Object.values(A.SSAI).includes(this.adTracking)||(this.adTracking||s.default.Log.warn("VideojsTracker: adsready fired but config.ad.type is not set — attempting CSAI auto-detection for backward compatibility."),this.adsTracker||(h.default.isUsing(this.player)?(s.default.Log.debug("VideojsTracker: auto-detected BrightcoveImaAdsTracker"),this.setAdsTracker(new h.default(this.player))):l.default.isUsing(this.player)?(s.default.Log.debug("VideojsTracker: auto-detected ImaAdsTracker"),this.setAdsTracker(new l.default(this.player))):u.default.isUsing(this.player)?(s.default.Log.debug("VideojsTracker: auto-detected FreewheelAdsTracker"),this.setAdsTracker(new u.default(this.player))):(s.default.Log.debug("VideojsTracker: no specific CSAI framework detected, using generic VideojsAdsTracker"),this.setAdsTracker(new o.default(this.player)))))}onAdStart(){this.currentAdPlaying=!0,this.imaAdCuePoints||(this.imaAdCuePoints=this.player?.ima?.getAdsManager().getCuePoints())}onAdEnd(){this.isContentEnd&&this.sendEnd()}OnAdsAllpodsCompleted(){this.onEnded.bind(this),this.FreewheelAdsCompleted=!0}isAdsTrackerActive(){return this.player.ads?"ads-playback"===this.player.ads.state:this.adsTracker&&this.adsTracker.isAd&&this.adsTracker.isAd()}onPlay(){this.sendRequest()}onPause(){this.isAdsTrackerActive()||this.player.ended()||this.sendPause()}onCanPlayThrough(){this.isAdsTrackerActive()||this.sendBufferEnd()}onPlaying(){this.isAdsTrackerActive()||(this.sendResume(),this.sendBufferEnd())}onAbort(){this.sendEnd()}onEnded(){this.adsTracker?(this.isContentEnd=!0,this.imaAdCuePoints&&!this.imaAdCuePoints.includes(-1)&&this.sendEnd()):this.sendEnd()}onDispose(){this.sendEnd()}onSeeking(){this.isAdsTrackerActive()||this.sendSeekStart()}onSeeked(){this.isAdsTrackerActive()||this.sendSeekEnd()}onError(){const e=this.player.error(),t=e.code,i=e.message;this.player.error&&this.player.error()&&this.sendError({errorCode:t,errorMessage:i})}onWaiting(e){this.isAdsTrackerActive()||this.sendBufferStart()}onTimeupdate(e){this.getPlayhead()>.1&&this.sendStart()}}t.default=T,T.AD_TRACKING=A,T.Log=s.default.Log},324:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TRACKING_API_TIMEOUT_MS=t.STREAM_TYPE=t.SCTE35_SCHEME_MARKER=t.REGEX_TRACKING_PATH_SEGMENT=t.REGEX_SESSION_ID=t.REGEX_MAP=t.REGEX_MANIFEST_FILE_SUFFIX=t.REGEX_ISO_8601_DURATION=t.REGEX_HLS_TARGET_DURATION=t.REGEX_DISCONTINUITY=t.REGEX_DASH_MINIMUM_UPDATE_PERIOD=t.REGEX_CUE_OUT=t.QUARTILES=t.POST_AD_PAUSE_THRESHOLD=t.MT_SEGMENT_PATTERN=t.MT_HLS_CUE_OUT_TAG=t.MT_HLS_CUE_IN_TAG=t.MT_DEFAULT_AD_SEGMENT_PATH=t.MIN_AD_DURATION=t.MEDIATAILOR_HOST_MARKER=t.MANIFEST_TYPE=t.HLS_TAG_PREFIX=t.HLS_SEGMENT_DURATION_TAG=t.HLS_MIME_TYPE=t.HLS_MANIFEST_EXTENSION=t.DEFAULT_LIVE_POLL_INTERVAL_MS=t.DASH_SCTE35_EVENT_STREAM_SELECTOR=t.DASH_MANIFEST_EXTENSION=t.AD_TIMING_TOLERANCE=t.AD_SOURCE=t.AD_POSITION=void 0;t.REGEX_CUE_OUT=/#EXT-X-CUE-OUT:DURATION=([\d.]+)/,t.REGEX_DISCONTINUITY=/#EXT-X-DISCONTINUITY/,t.REGEX_MAP=/#EXT-X-MAP:URI="([^"]+)"/,t.REGEX_SESSION_ID=/sessionId=([^&]+)/,t.REGEX_TRACKING_PATH_SEGMENT=/\/v1\/(master|session|dash)\//,t.REGEX_MANIFEST_FILE_SUFFIX=/\/[^/]*\.(m3u8|mpd).*$/,t.REGEX_HLS_TARGET_DURATION=/#EXT-X-TARGETDURATION:(\d+)/,t.REGEX_DASH_MINIMUM_UPDATE_PERIOD=/minimumUpdatePeriod="([^"]+)"/,t.REGEX_ISO_8601_DURATION=/PT(?:(\d+)H)?(?:(\d+)M)?(?:([\d.]+)S)?/,t.HLS_MANIFEST_EXTENSION=".m3u8",t.DASH_MANIFEST_EXTENSION=".mpd",t.MEDIATAILOR_HOST_MARKER=".mediatailor.",t.MT_HLS_CUE_OUT_TAG="#EXT-X-CUE-OUT",t.MT_HLS_CUE_IN_TAG="#EXT-X-CUE-IN",t.HLS_SEGMENT_DURATION_TAG="#EXTINF:",t.HLS_TAG_PREFIX="#",t.SCTE35_SCHEME_MARKER="scte35",t.DASH_SCTE35_EVENT_STREAM_SELECTOR='EventStream[schemeIdUri*="scte35"], EventStream[schemeIdUri*="SCTE35"]',t.HLS_MIME_TYPE="application/vnd.apple.mpegurl",t.MT_SEGMENT_PATTERN="segments.mediatailor",t.MT_DEFAULT_AD_SEGMENT_PATH="/tm/",t.TRACKING_API_TIMEOUT_MS=5e3,t.DEFAULT_LIVE_POLL_INTERVAL_MS=5e3,t.MIN_AD_DURATION=.5,t.AD_TIMING_TOLERANCE=.5,t.POST_AD_PAUSE_THRESHOLD=500,t.STREAM_TYPE={VOD:"vod",LIVE:"live"},t.MANIFEST_TYPE={HLS:"hls",DASH:"dash"},t.AD_POSITION={PRE_ROLL:"pre",MID_ROLL:"mid",POST_ROLL:"post"},t.AD_SOURCE={MANIFEST_CUE:"manifest-cue",VHS_DISCONTINUITY:"vhs-discontinuity",TRACKING_API:"tracking-api",MANIFEST_AND_TRACKING:"manifest+tracking",DASH_EMSG:"dash-emsg",DASH_EVENT_STREAM:"dash-event-stream"},t.QUARTILES={Q1:.25,Q2:.5,Q3:.75}},330:e=>{e.exports=JSON.parse('{"name":"@newrelic/video-videojs","version":"4.2.0","description":"New relic tracker for Videojs","main":"dist/cjs/index.js","module":"dist/esm/index.js","scripts":{"build":"webpack --mode production","build:dev":"webpack --mode development","watch":"webpack --mode production --progress --color --watch","watch:dev":"webpack --progress --color --watch --mode development","prezip":"npm run build","zip":"zip -P newrelic -x \'*.DS_Store\' -x \'samples/agent.js\' -r videojs.zip dist samples README.md CHANGELOG.md EULA.md","clean":"rm -rf dist *.zip","deploy":"node scripts/deploy.js","third-party-updates":"oss third-party manifest --includeOptDeps && oss third-party notices --includeOptDeps && git add THIRD_PARTY_NOTICES.md third_party_manifest.json"},"repository":{"type":"git","url":"https://github.com/newrelic/video-videojs-js.git"},"author":"Jordi Aguilar","contributors":["Andreu Santarén Llop","Bharat Saraswat","Malay Chandan"],"license":"Apache-2.0","devDependencies":{"@babel/core":"^7.24.5","@babel/plugin-transform-modules-commonjs":"^7.24.1","@babel/preset-env":"^7.24.5","@newrelic/newrelic-oss-cli":"^0.1.2","@semantic-release/changelog":"^6.0.3","@semantic-release/commit-analyzer":"^12.0.0","@semantic-release/git":"^10.0.1","@semantic-release/github":"^10.0.3","@semantic-release/npm":"^12.0.0","@semantic-release/release-notes-generator":"^13.0.0","aws-sdk":"^2.920.0","babel-loader":"^9.1.3","semantic-release":"^23.0.8","videojs-ima":"2.1.0","webpack":"^5.91.0","webpack-cli":"^4.9.2"},"files":["THIRD_PARTY_NOTICES.md","dist","CHANGELOG.md","README.md","src","!test"],"publishConfig":{"access":"public"},"dependencies":{"@newrelic/video-core":"^4.1.5"}}')},338:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;class i{constructor(e){this.tech=e.shakaPlayer,this.player=e.el().player}getSrc(e){try{return this.tech.getManifestUri()}catch(e){}return null}getRenditionBitrate(e){try{const e=this.tech.getStats().streamBandwidth;return e?Math.round(e):null}catch(e){}return null}getManifestBitrate(){try{const e=this.tech.getVariantTracks();if(e&&e.length>0)return Math.round(Math.max(...e.map((e=>e.videoBandwidth+(e.audioBandwidth||0)))))}catch(e){}return null}getRenditionWidth(e){try{var t=this.tech.getVariantTracks();for(var i in t){var s=t[i];if(s.active&&"video"===s.type)return s.width}}catch(e){}return null}getRenditionHeight(e){try{var t=this.tech.getVariantTracks();for(var i in t){var s=t[i];if(s.active&&"video"===s.type)return s.height}}catch(e){}return null}getBitrate(){return this.getContentBitratePlayback()}getContentBitratePlayback(){try{var e=this.tech.getStats();if(e&&e.streamBandwidth&&e.streamBandwidth>0)return Math.round(e.streamBandwidth)}catch(e){}return null}getSegmentDownloadBitrate(){try{var e=this.tech.getStats();if(e&&e.estimatedBandwidth>0)return Math.round(e.estimatedBandwidth)}catch(e){}return null}getNetworkDownloadBitrate(){try{var e=this.tech.getStats();if(e&&e.estimatedBandwidth>0)return Math.round(e.estimatedBandwidth)}catch(e){}return null}}t.default=i,i.isUsing=function(e){return!!e.shakaPlayer}},409:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;class i{constructor(e){this.tech=e.vhs,this.player=e.el().player}getRenditionName(){try{var e=this.tech.playlists.media();if(e&&e.attributes)return e.attributes.NAME}catch(e){}return null}getRenditionBitrate(){try{var e=this.tech.playlists.media();if(e&&e.attributes)return Math.round(e.attributes.BANDWIDTH)}catch(e){}return null}getRenditionWidth(){try{var e=this.tech.playlists.media();if(e&&e.attributes&&e.attributes.RESOLUTION)return e.attributes.RESOLUTION.width}catch(e){}return null}getRenditionHeight(){try{var e=this.tech.playlists.media();if(e&&e.attributes&&e.attributes.RESOLUTION)return e.attributes.RESOLUTION.height}catch(e){}return null}getBitrate(){return this.getContentBitratePlayback()}getManifestBitrate(){try{const e=this.tech.playlists.master.playlists;if(e&&e.length>0)return Math.round(Math.max(...e.map((e=>e.attributes.BANDWIDTH))))}catch(e){}return null}getSegmentDownloadBitrate(){return void 0!==this.tech.stats?.bandwidth&&this.tech.stats.bandwidth>0?Math.round(this.tech.stats.bandwidth):null}getNetworkDownloadBitrate(){return void 0!==this.tech.throughput&&this.tech.throughput>0?Math.round(this.tech.throughput):null}getContentBitratePlayback(){try{const e=this.tech.playlists.media();if(e&&e.attributes){const t=e.attributes["AVERAGE-BANDWIDTH"]||e.attributes.BANDWIDTH||null;return null!==t?Math.round(t):null}}catch(e){}return null}}t.default=i,i.isUsing=function(e){return!!e.vhs}},472:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=o(i(555)),a=o(i(330)),r=o(i(409)),n=o(i(257)),d=o(i(338));function o(e){return e&&e.__esModule?e:{default:e}}class l extends s.default.VideoTracker{getTech(){const e=this.player.tech({IWillNotUseThisInPlugins:!0});if(e){if(r.default.isUsing(e))return new r.default(e);if(n.default.isUsing(e))return new n.default(e);if(d.default.isUsing(e))return new d.default(e)}}getTrackerName(){return"videojs-ads"}getTrackerVersion(){return a.default.version}isMuted(){return this.player.muted()}getRenditionHeight(){return null}getRenditionWidth(){return null}getPlayerName(){return"videojs-ads"}getPlayerVersion(){return this.player.ads.VERSION}registerListeners(){s.default.Log.debugCommonVideoEvents(this.player,[null,"ads-request","ads-load","adstart","adend","adskip","adserror","ads-click","ads-pod-started","ads-pod-ended","ads-first-quartile","ads-midpoint","ads-third-quartile","ads-pause","ads-play","adtimeout"]),this.player.on("ads-request",this.onAdrequest.bind(this)),this.player.on("ads-load",this.onAdload.bind(this)),this.player.on("adstart",this.onAdstart.bind(this)),this.player.on("adend",this.onAdend.bind(this)),this.player.on("adskip",this.onAdskip.bind(this)),this.player.on("adserror",this.onAdserror.bind(this)),this.player.on("ads-click",this.onAdsClick.bind(this)),this.player.on("ads-pod-started",this.onPodStart.bind(this)),this.player.on("ads-pod-ended",this.onPodEnd.bind(this)),this.player.on("ads-first-quartile",this.onFirstQuartile.bind(this)),this.player.on("ads-midpoint",this.onMidpoint.bind(this)),this.player.on("ads-third-quartile",this.onThirdQuartile.bind(this)),this.player.on("ads-pause",this.onAdspause.bind(this)),this.player.on("ads-play",this.onAdsplay.bind(this))}unregisterListeners(){this.player.off("ads-request",this.onAdrequest),this.player.off("ads-load",this.onAdload),this.player.off("adstart",this.onAdstart),this.player.off("adend",this.onAdend),this.player.off("adskip",this.onAdskip),this.player.off("adserror",this.onAdserror),this.player.off("ads-click",this.onAdsClick),this.player.off("ads-pod-started",this.onPodStart),this.player.off("ads-pod-ended",this.onPodEnd),this.player.off("ads-first-quartile",this.onFirstQuartile),this.player.off("ads-midpoint",this.onMidpoint),this.player.off("ads-third-quartile",this.onThirdQuartile),this.player.off("ads-pause",this.onAdspause),this.player.off("ads-play",this.onAdsplay)}onAdrequest(e){this.sendRequest(),this.sendDownload({state:"ads-request"})}onAdload(e){this.sendDownload({state:"ads-load"})}onAdstart(e){this.sendRequest(),this.sendStart()}onAdend(e){this.sendEnd()}onAdskip(e){this.sendEnd({skipped:!0})}onAdserror(e){this.sendError()}onAdsClick(e){this.sendAdClick({url:"unknown"})}onPodStart(e){this.sendAdBreakStart()}onPodEnd(e){this.sendAdBreakEnd()}onFirstQuartile(){this.sendAdQuartile({quartile:1})}onMidpoint(){this.sendAdQuartile({quartile:2})}onThirdQuartile(){this.sendAdQuartile({quartile:3})}onAdspause(){this.sendPause()}onAdsplay(){this.sendResume()}}t.default=l},555:(e,t,i)=>{i.r(t),i.d(t,{default:()=>P});var s={487(e,t,i){i.r(t),i.d(t,{videoAnalyticsHarvester:()=>o});var s=i(374),a=i(431),r=i(51),n=i(144),d=i(302);const o=new class{constructor(){this.isInitialized=!1,this.harvestScheduler=null,this.eventBuffer=null}initialize(){if(this.isInitialized)n.A.warn("Video analytics agent already initialized");else try{this.eventBuffer=new a.t,this.harvestScheduler=new s.n(this.eventBuffer),this.harvestScheduler.startScheduler(),this.isInitialized=!0,n.A.notice("Video analytics agent initialized successfully")}catch(e){n.A.error("Failed to initialize video analytics agent:",e.message)}}addEvent(e){this.isInitialized||(n.A.warn("Video analytics agent not initialized, initializing now"),this.initialize());try{return e.actionName&&e.actionName===d.A.Events.QOE_AGGREGATE?e.viewId?this.eventBuffer.addOrReplaceByActionNameAndViewId(d.A.Events.QOE_AGGREGATE,e.viewId,e):this.eventBuffer.addOrReplaceByActionName(d.A.Events.QOE_AGGREGATE,e):this.eventBuffer.add(e)}catch(e){return n.A.error("Failed to add event to harvesting system:",e.message),!1}}setHarvestInterval(e){this.isInitialized||this.initialize(),this.harvestScheduler.updateHarvestInterval(e)}forceNextQoeCycle(){this.harvestScheduler&&(this.harvestScheduler.forceNextQoeCycle=!0)}setBeforeDrainCallback(e){this.harvestScheduler&&(this.harvestScheduler.beforeDrainCallback=e)}refreshQoeKpis(e,t){if(!this.eventBuffer||!e)return;const i=t?this.eventBuffer.findByActionNameAndViewId(d.A.Events.QOE_AGGREGATE,t):this.eventBuffer.findByActionName(d.A.Events.QOE_AGGREGATE);if(i){const s={...i};for(const t of r.A.QOE_KPI_KEYS)t in e&&(s[t]=e[t]);t?this.eventBuffer.addOrReplaceByActionNameAndViewId(d.A.Events.QOE_AGGREGATE,t,s):this.eventBuffer.addOrReplaceByActionName(d.A.Events.QOE_AGGREGATE,s)}}}},455(e,t,i){i.d(t,{A:()=>a});class s{constructor(){this.reset()}reset(){this.startTime=0,this.stopTime=0,this.accumulator=0,this.offset=0}getDeltaTime(){return this.startTime?this.offset+((new Date).getTime()-this.startTime):null}start(){this.startTime=(new Date).getTime(),this.stopTime=0}stop(){return this.stopTime=(new Date).getTime(),this.startTime<this.stopTime&&(this.accumulator+=this.stopTime-this.startTime),this.getDeltaTime()}getDuration(){return this.stopTime?this.accumulator+this.offset:this.accumulator+(this.getDeltaTime()??0)}clone(){var e=new s;return e.startTime=this.startTime,e.stopTime=this.stopTime,e.offset=this.offset,e.accumulator=this.accumulator,e}}const a=s},51(e,t,i){i.d(t,{A:()=>a});class s{}s.AdPositions={PRE:"pre",MID:"mid",POST:"post"},s.COLLECTOR={US:["bam.nr-data.net","bam-cell.nr-data.net"],EU:"bam.eu01.nr-data.net",Staging:"staging-bam-cell.nr-data.net",GOV:"gov-bam.nr-data.net"},s.VALID_EVENT_TYPES=["VideoAction","VideoAdAction","VideoErrorAction","VideoCustomAction"],s.MAX_PAYLOAD_SIZE=1048576,s.MAX_BEACON_SIZE=61440,s.MAX_EVENTS_PER_BATCH=1e3,s.INTERVAL=1e4,s.QOE_KPI_KEYS=["startupTime","peakBitrate","averageBitrate","totalPlaytime","totalRebufferingTime","rebufferingRatio","hadStartupError","hadPlaybackError","numberOfErrors"],s.QOE_AGGREGATE_KEYS=["coreVersion","instrumentation.name","instrumentation.provider","instrumentation.version","isBackgroundEvent","playerName","playerVersion","src","viewId","viewSession","contentIsAutoplayed","contentIsMuted","contentRenditionHeight","contentRenditionWidth","contentSrc","numberOfVideos","pageUrl","trackerName","trackerVersion","contentDuration","contentPlayrate","contentPlayhead","contentPreload","elapsedTime","contentTitle","contentId","contentIsLive","deviceType","deviceGroup","deviceManufacturer","deviceModel","deviceName","deviceSize","deviceUuid","contentRenditionName","contentIsFullscreen","contentCdn","contentFps","asnOrganization","asnLongitude","asnLatitude","asn","timeSinceRequested","timeSinceStarted"];const a=s},568(e,t,i){i.d(t,{A:()=>s});const s=class{on(e,t){if(this._listeners=this._listeners||{},"function"==typeof t)return this._listeners[e]=this._listeners[e]||[],this._listeners[e].push(t),this}off(e,t){if(this._listeners=this._listeners||{},this._listeners[e]){var i=this._listeners[e].indexOf(t);-1!==i&&this._listeners[e].splice(i,1)}return this}emit(e,t,i){return this._listeners=this._listeners||{},i=i||{},Array.isArray(this._listeners[t])&&this._listeners[t].forEach((s=>{s.call(this,{eventType:e,type:t,data:i,target:this})})),Array.isArray(this._listeners["*"])&&this._listeners["*"].forEach((s=>{s.call(this,{eventType:e,type:t,data:i,target:this})})),this}}},431(e,t,i){i.d(t,{t:()=>o});var s=i(144),a=i(51),r=i(347);const{MAX_PAYLOAD_SIZE:n,MAX_EVENTS_PER_BATCH:d}=a.A;class o{constructor(){this.buffer=[],this.maxPayloadSize=n,this.maxEventsPerBatch=d,this.currentPayloadSize=0,this.totalEvents=0,this.smartHarvestPayloadThreshold=Math.floor(.6*this.maxPayloadSize),this.overflowPayloadThreshold=Math.floor(.9*this.maxPayloadSize),this.smartHarvestEventThreshold=Math.floor(.6*this.maxEventsPerBatch),this.overflowEventThreshold=Math.floor(.9*this.maxEventsPerBatch),this.onSmartHarvestTrigger=null}addOrReplaceByActionName(e,t){const i=this.buffer.findIndex((t=>t.actionName===e));try{return-1===i?this.add(t):this.add(t,i),!0}catch(e){return s.A.error("Failed to set or replace the event to buffer:",e.message),!1}}addOrReplaceByActionNameAndViewId(e,t,i){const a=this.buffer.findIndex((i=>i.actionName===e&&i.viewId===t));try{return-1===a?this.add(i):this.add(i,a),!0}catch(e){return s.A.error("Failed to set or replace the event to buffer:",e.message),!1}}findByActionNameAndViewId(e,t){return this.buffer.find((i=>i.actionName===e&&i.viewId===t))||null}findByActionName(e){return this.buffer.find((t=>t.actionName===e))||null}add(e,t){try{const i=(0,r.Q3)(e),s=this.currentPayloadSize+i>=this.maxPayloadSize,a=this.totalEvents+1>=this.maxEventsPerBatch;if((s||a)&&this.makeRoom(i),null!=t&&t>-1){const s=(0,r.Q3)(this.buffer[t]);this.buffer[t]=e,this.currentPayloadSize+=i-s}else this.buffer.push(e),this.totalEvents++,this.currentPayloadSize+=i;return this.checkSmartHarvestTrigger(),!0}catch(e){return s.A.error("Failed to add event to buffer:",e.message),!1}}checkSmartHarvestTrigger(){const e=this.currentPayloadSize/this.maxPayloadSize,t=this.totalEvents/this.maxEventsPerBatch,i=this.currentPayloadSize>=this.overflowPayloadThreshold,a=this.totalEvents>=this.overflowEventThreshold;if(i||a){const a=i?`payload ${this.currentPayloadSize}/${this.maxPayloadSize} bytes (${Math.round(100*e)}%)`:`events ${this.totalEvents}/${this.maxEventsPerBatch} (${Math.round(100*t)}%)`;s.A.warn(`OVERFLOW PREVENTION: ${a} - Emergency harvest triggered`),this.onSmartHarvestTrigger&&"function"==typeof this.onSmartHarvestTrigger&&this.onSmartHarvestTrigger("overflow",90)}else{const e=this.currentPayloadSize>=this.smartHarvestPayloadThreshold,t=this.totalEvents>=this.smartHarvestEventThreshold;(e||t)&&this.onSmartHarvestTrigger&&"function"==typeof this.onSmartHarvestTrigger&&this.onSmartHarvestTrigger("smart",60)}}setSmartHarvestCallback(e){this.onSmartHarvestTrigger=e}drain(){try{const e=this.buffer.splice(0);return this.totalEvents=0,this.currentPayloadSize=0,e}catch(e){return s.A.error("Failed to drain events from buffer:",e.message),[]}}isEmpty(){return 0===this.totalEvents}size(){return this.totalEvents}clear(){this.buffer=[],this.totalEvents=0}makeRoom(e){if(e>this.maxPayloadSize)s.A.error("Event dropped: Event size exceeds maximum payload size.");else for(;(this.totalEvents>=this.maxEventsPerBatch||this.currentPayloadSize+e>=this.maxPayloadSize)&&this.buffer.length>0;){const e=this.buffer.shift(),t=(0,r.Q3)(e);this.totalEvents--,this.currentPayloadSize-=t,s.A.warn("Event buffer full, oldest event removed.")}}}},374(e,t,i){i.d(t,{n:()=>h});var s=i(431),a=i(413),r=i(481),n=i(347),d=i(51),o=i(302),l=i(144);class h{constructor(e){this.eventBuffer=e,this.retryQueueHandler=new a.u,this.httpClient=new r.X,this.fallBackUrl="",this.retryCount=0,this.eventBuffer instanceof s.t&&this.eventBuffer.setSmartHarvestCallback(((e,t)=>this.triggerSmartHarvest(e,t))),this.isStarted=!1,this.currentTimerId=null,this.harvestCycle=d.A.INTERVAL,this.isHarvesting=!1,this.qoeCycleCount=1,this.forceNextQoeCycle=!1,this.beforeDrainCallback=null,this._lastSentQoeKpis={},this.setupPageLifecycleHandlers()}startScheduler(){this.isStarted?l.A.warn("Harvest scheduler is already started"):(this.isStarted=!0,l.A.notice("Starting harvest scheduler",{harvestCycle:this.harvestCycle,eventBufferSize:this.eventBuffer?this.eventBuffer.size():0}),this.scheduleNextHarvest())}stopScheduler(){this.isStarted&&(this.isStarted=!1,this.currentTimerId&&(clearTimeout(this.currentTimerId),this.currentTimerId=null),l.A.notice("Harvest scheduler stopped"))}async triggerSmartHarvest(e,t){if(l.A.notice(`${e} harvest triggered at ${t}% threshold`,{type:e,threshold:t}),this.eventBuffer&&!this.eventBuffer.isEmpty()){this.currentTimerId&&(clearTimeout(this.currentTimerId),this.currentTimerId=null);try{await this.triggerHarvest({})}catch(t){l.A.error(`${e} harvest failed:`,t.message)}finally{this.isStarted&&this.scheduleNextHarvest()}}}scheduleNextHarvest(){if(!this.isStarted)return;const e=this.harvestCycle;this.currentTimerId=setTimeout((()=>this.onHarvestInterval()),e)}async onHarvestInterval(){try{const e=this.eventBuffer&&!this.eventBuffer.isEmpty(),t=this.retryQueueHandler&&this.retryQueueHandler.getQueueSize()>0;if(!e&&!t)return;await this.triggerHarvest({})}catch(e){l.A.error("Error during scheduled harvest:",e.message)}finally{this.scheduleNextHarvest()}}async triggerHarvest(e={}){if(this.isHarvesting)return{success:!1,reason:"harvest_in_progress"};this.isHarvesting=!0;try{let t=this.drainEvents(e);if(e.isFinalHarvest){const e=d.A.MAX_BEACON_SIZE;(0,n.Q3)(t)>e&&(t=this.trimEventsToFit(t,e))}const i=await this.sendChunk(t,e,!0);return{success:i.success,totalChunks:1,results:[i]}}catch(e){return l.A.error("Harvest cycle failed:",e.message),this.handleHarvestFailure(e),{success:!1,error:e.message,consecutiveFailures:this.consecutiveFailures}}finally{this.isHarvesting=!1}}trimEventsToFit(e,t){if(0===e.length)return e;const i=[];let s=0;for(let a=e.length-1;a>=0;a--){const r=e[a],d=(0,n.Q3)({ins:[r,...i]});d>t||(i.unshift(r),s=d)}const a=e.length-i.length;if(a>0){const r=e.slice(0,a);l.A.warn(`Discarded ${a} events to fit beacon size limit`,{originalCount:e.length,trimmedCount:i.length,finalSize:s,maxSize:t}),this.retryQueueHandler&&this.retryQueueHandler.addFailedEvents(r)}return i}drainEvents(e={}){const t=window.NRVIDEO?.config?.qoeIntervalFactor??1,i=!!e.isFinalHarvest||this.forceNextQoeCycle,s=(this.qoeCycleCount-1)%t==0||i;if(this.forceNextQoeCycle&&(this.forceNextQoeCycle=!1),this.beforeDrainCallback&&"function"==typeof this.beforeDrainCallback)try{this.beforeDrainCallback()}catch(e){l.A.error("Before drain callback failed:",e.message)}const a=this.eventBuffer.drain();let r;if(s)r=a;else{r=[];for(const e of a)e.actionName===o.A.Events.QOE_AGGREGATE?this.eventBuffer.add(e):r.push(e)}this.qoeCycleCount++;for(let e=r.length-1;e>=0;e--){const t=r[e];t.actionName===o.A.Events.QOE_AGGREGATE&&(!i&&this._qoeKpisUnchanged(t)?r.splice(e,1):this._saveQoeKpis(t))}let h=[...r],u=(0,n.Q3)(r);if(this.retryQueueHandler&&this.retryQueueHandler.getQueueSize()>0){const e=d.A.MAX_PAYLOAD_SIZE-u,t=d.A.MAX_EVENTS_PER_BATCH-h.length;if(e>0&&t>0){const i=this.retryQueueHandler.getRetryEventsToFit(e,t);i.length>0&&(h=[...i,...h])}}return h}async sendChunk(e,t,i){const s={url:(0,n.c$)(this.fallBackUrl),payload:{body:{ins:e}},options:{...t,isLastChunk:i}};return new Promise((t=>{this.httpClient.send(s,(i=>{i.retry?this.handleRequestFailure(e):(this.retryCount=0,this.fallBackUrl=""),t({success:!i.retry,status:i.status,error:i.error,chunk:e,eventCount:e.length})}))}))}handleRequestFailure(e){this.retryQueueHandler.addFailedEvents(e),"US"===window.NRVIDEO?.info?.region&&(this.retryCount++,this.retryCount>5?(this.retryCount=0,this.fallBackUrl=""):this.retryCount>=2&&(this.fallBackUrl=d.A.COLLECTOR.US[1]))}handleHarvestFailure(e){this.consecutiveFailures++,l.A.warn("Harvest failure handled",{error:e.message,consecutiveFailures:this.consecutiveFailures})}updateHarvestInterval(e){"number"!=typeof e&&isNaN(e)?l.A.warn("Invalid newInterval provided to updateHarvestInterval"):e<1e3||e>3e5?l.A.warn("newInterval out of bounds (1000-300000), ignoring"):this.harvestCycle!==e&&(this.harvestCycle=e,l.A.notice("Updated harvestCycle:",this.harvestCycle),this.currentTimerId&&(clearTimeout(this.currentTimerId),this.currentTimerId=null),this.isStarted&&this.scheduleNextHarvest())}setupPageLifecycleHandlers(){let e=!1;const t=()=>{e||(e=!0,this.triggerHarvest({isFinalHarvest:!0,force:!0}))};document.addEventListener("visibilitychange",(()=>{document.hidden&&t()})),window.addEventListener("pagehide",(()=>{t()})),window.addEventListener("beforeunload",(()=>{t()}))}_qoeKpisUnchanged(e){const t=this._lastSentQoeKpis[e.viewId];if(!t)return!1;for(const i of d.A.QOE_KPI_KEYS)if(e[i]!==t[i])return!1;return!0}_saveQoeKpis(e){const t={};for(const i of d.A.QOE_KPI_KEYS)t[i]=e[i];this._lastSentQoeKpis[e.viewId]=t}}},144(e,t,i){i.d(t,{A:()=>d});class s{static error(...e){a(e,s.Levels.ERROR,"darkred")}static warn(...e){a(e,s.Levels.WARNING,"darkorange")}static notice(...e){a([].slice.call(arguments),s.Levels.NOTICE,"darkcyan")}static debug(...e){a(e,s.Levels.DEBUG,"indigo")}static debugCommonVideoEvents(e,t,i){try{if(s.level<=s.Levels.DEBUG){i=i||function(e){s.debug("Event: "+e.type)};var a=["canplay","buffering","waiting","ended","play","playing","pause","resume","error","abort","seek","seeking","seeked","stalled","dispose","loadeddata","loadstart","loadedmetadata"];t&&(null===t[0]?(t.shift(),a=t):a=a.concat(t));for(var r=0;r<a.length;r++)"function"==typeof e?e.call(window,a[r],i):e.on?e.on(a[r],i):e.addEventListener?e.addEventListener(a[r],i):e.addEventHandler?e.addEventHandler(a[r],i):s.warn("debugCommonVideoEvents: No common listener function found for ",e)}}catch(e){s.warn(e)}}}function a(e,t,i){t=t||s.Levels.NOTICE,i=i||"darkcyan";var a,d,o=s.prefix;s.includeTime&&(o+="["+("0"+(a=new Date).getDate()).slice(-2)+":"+("0"+a.getMinutes()).slice(-2)+":"+("0"+a.getSeconds()).slice(-2)+"."+("00"+a.getMilliseconds()).slice(-3)+"] "),o+=function(e){return n[e]}(t)+":",s.level<=t&&t!==s.Levels.SILENT&&(!s.colorful||"undefined"!=typeof document&&document.documentMode?r(e,o):(d=t===s.Levels.ERROR&&console.error?console.error:t===s.Levels.WARNING&&console.warn?console.warn:t===s.Levels.DEBUG&&console.debug&&null==window.cast?console.debug:console.log,o="%c"+o,e.splice(0,0,o,"color: "+i),d.apply(console,e)))}function r(e,t){if(e instanceof Array)for(var i in e)r(e[i],t);else"string"==typeof e?console.log(t+" "+e):(console.log(t+"↵"),console.log(e))}s.Levels={SILENT:5,ERROR:4,WARNING:3,NOTICE:2,DEBUG:1,ALL:0},s.level=s.Levels.ERROR,s.colorful=!0,s.includeTime=!0,s.prefix="[nrvideo]";const n={4:"e",3:"w",2:"n",1:"d"};!function(){if("undefined"!=typeof window&&window.location&&window.location.search){var e=/\?.*&*nrvideo-debug=(.+)/i.exec(window.location.search);null!==e&&("true"===e[1]?s.level=s.Levels.ALL:s.level=e[1]),null!==/\?.*&*nrvideo-colors=false/i.exec(window.location.search)&&(s.colorful=!1)}}();const d=s},481(e,t,i){i.d(t,{X:()=>r});var s=i(347),a=i(144);class r{async send(e,t){const{url:i,payload:s,options:r={}}=e;try{if(!i||!s)throw new Error("URL and payload are required");const e={url:i,payload:s,options:r,callback:t};await this.executeRequest(e)}catch(e){a.A.error("Failed to send request:",e.message),t({retry:!1,status:0,error:e.message})}}async executeRequest(e){const{url:t,payload:i,options:s,callback:r}=e,n=Date.now();try{const r=(d=JSON.stringify(i.body),o=window.NRVIDEO?.config?.obfuscate,o&&0!==o.length?o.reduce(((e,t)=>{let i;try{if(t.regex instanceof RegExp){const e=t.regex.flags.includes("g")?t.regex.flags:t.regex.flags+"g";i=new RegExp(t.regex.source,e)}else i=new RegExp(t.regex,"g")}catch(i){return a.A.warn("applyObfuscationRules: invalid regex, skipping rule:",t.regex,i.message),e}return e.replace(i,t.replacement)}),d):d);if(s.isFinalHarvest&&navigator.sendBeacon){const i=await this.sendWithBeacon(t,r),s={success:i,status:i?204:0};return void this.handleRequestComplete(e,s,n)}const l=await this.fetchWithTimeout(t,{method:"POST",body:r,headers:{"Content-Type":"application/json"},keepalive:s.isFinalHarvest},1e4),h={success:l.ok,status:l.status,statusText:l.statusText};this.handleRequestComplete(e,h,n)}catch(t){const i={success:!1,status:0,error:t.message};this.handleRequestComplete(e,i,n)}var d,o}handleRequestComplete(e,t){const{callback:i}=e;i({retry:!t.success&&(0===t.status||(0,s.Sc)(t.status)),status:t.status,error:t.error})}async sendWithBeacon(e,t){try{return navigator.sendBeacon(e,t)}catch(e){return a.A.warn("sendBeacon failed, falling back to fetch:",e.message),!1}}async fetchWithTimeout(e,t,i){const s=new AbortController,a=setTimeout((()=>s.abort()),i);try{const i=await fetch(e,{...t,signal:s.signal});return clearTimeout(a),i}catch(e){if(clearTimeout(a),"AbortError"===e.name)throw new Error(`Request timeout after ${i}ms`);throw e}}}},413(e,t,i){i.d(t,{u:()=>o});var s=i(144),a=i(347),r=i(51);const{MAX_PAYLOAD_SIZE:n,MAX_EVENTS_PER_BATCH:d}=r.A;class o{constructor(){this.retryQueue=[],this.maxQueueSize=d,this.maxQueueSizeBytes=n}addFailedEvents(e){try{const t=Array.isArray(e)?e:[e];s.A.notice(`Adding ${t.length} failed events to retry queue`,{queueSizeBefore:this.retryQueue.length});for(const e of t){this.retryQueue.length>=this.maxQueueSize&&this.evictOldestEvent();const t=(0,a.Q3)(e);for(;(0,a.Q3)(this.retryQueue)+t>this.maxQueueSizeBytes;)this.evictOldestEvent();this.retryQueue.push({...e})}}catch(e){s.A.error("Failed to add events to retry queue:",e.message)}}discardEvent(e,t){s.A.warn("Discarded event",{reason:t,eventType:e.eventType})}evictOldestEvent(){if(this.retryQueue.length>0){const e=this.retryQueue.shift();this.discardEvent(e,"Queue full - evicted oldest")}}getRetryEventsToFit(e,t){const i=[];let s=0,r=0;for(let n=this.retryQueue.length-1;n>=0;n--){const d=this.retryQueue[n];if(r>=t)break;const o=(0,a.Q3)(d);if(s+o>e)break;i.unshift(d),s+=o,r++,this.retryQueue.splice(n,1)}return i}getQueueSize(){return this.retryQueue.length}clear(){this.retryQueue=[]}}},302(e,t,i){i.d(t,{A:()=>h});var s=i(330),a=i(568),r=i(455),n=i(51),d=i(487),o=i(144);class l extends a.A{constructor(e){super(),this.customData={},this.heartbeat=null,this.parentTracker=null,this._trackerReadyChrono=new r.A,this._trackerReadyChrono.start(),this._actionTable=n.A.ACTION_TABLE,this._actionAdTable=n.A.ACTION_AD_TABLE,e=e||{},this.setOptions(e)}setOptions(e){e&&(e.parentTracker&&(this.parentTracker=e.parentTracker),e.customData&&(this.customData=e.customData),e.heartbeat&&(this.heartbeat=e.heartbeat))}dispose(){this.unregisterListeners()}registerListeners(){}unregisterListeners(){}getHeartbeat(){return this.state._isAd?2e3:this.heartbeat?this.heartbeat:this.parentTracker&&this.parentTracker.heartbeat?this.parentTracker.heartbeat:3e4}startHeartbeat(){this._heartbeatInterval=setInterval(this.sendHeartbeat.bind(this),Math.max(this.getHeartbeat(),2e3))}stopHeartbeat(){this._heartbeatInterval&&clearInterval(this._heartbeatInterval)}sendHeartbeat(e){this.sendVideoAction(l.Events.HEARTBEAT,e)}getAttributes(e,t){(e=e||{}).trackerName=this.getTrackerName(),e.trackerVersion=this.getTrackerVersion(),e.coreVersion=s.rE,e.timeSinceTrackerReady=this._trackerReadyChrono.getDeltaTime();for(let t in this.customData)e[t]=this.customData[t];return null!=document.hidden&&(e.isBackgroundEvent=document.hidden),e}getTrackerVersion(){return s.rE}getTrackerName(){return"base-tracker"}sendVideoAction(e,t){this.emit("VideoAction",e,this.getAttributes(t))}sendVideoAdAction(e,t){this.emit("VideoAdAction",e,this.getAttributes(t))}sendVideoErrorAction(e,t){let i=this.isAd()?"adError":"videoError";this.emit("VideoErrorAction",e,this.getAttributes(t,i))}sendVideoCustomAction(e,t){this.emit("VideoCustomAction",e,this.getAttributes(t,"customAction"))}setHarvestInterval(e){if(d.videoAnalyticsHarvester)try{d.videoAnalyticsHarvester.setHarvestInterval(e)}catch(e){return void o.A.error("Failed to set harvest interval:",e.message)}else o.A.error("VideoAnalyticsHarvester is not available")}}l.Events={HEARTBEAT:"HEARTBEAT",QOE_AGGREGATE:"QOE_AGGREGATE"};const h=l},347(e,t,i){i.d(t,{Q3:()=>n,Sc:()=>d,c$:()=>r,z8:()=>o});var s=i(330),a=i(144);function r(e){try{if(!window.NRVIDEO||!window.NRVIDEO.info)throw new Error("NRVIDEO info is not available.");let{beacon:t,licenseKey:i,applicationID:a}=window.NRVIDEO.info;if(!t||!i)throw new Error("Options object provided by New Relic is not correctly initialized");return a?`https://${e||t}/ins/1/${i}?a=${a}&v=${s.rE}&ref=${window.location.href}&ca=VA`:`https://${e||t}/ins/1/${i}?&v=${s.rE}&ref=${window.location.href}&ca=VA`}catch(e){return console.error(e.message),null}}function n(e){if("string"==typeof e&&e.length)return e.length;if("object"==typeof e){if("undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer&&e.byteLength)return e.byteLength;if("undefined"!=typeof Blob&&e instanceof Blob&&e.size)return e.size;if(!("undefined"!=typeof FormData&&e instanceof FormData))try{return function(e){try{return JSON.stringify(e,(()=>{const e=new WeakSet;return(t,i)=>{if("object"==typeof i&&null!==i){if(e.has(i))return;e.add(i)}return i}})())??""}catch(e){return a.A.error("Error stringifying value:",e.message),""}}(e).length}catch(e){return}}}function d(e){switch(e){case 408:case 429:case 500:return!0;case 401:case 403:case 404:return!1}return e>=502&&e<=504||e>=512&&e<=530}function o(e,t){return e&&Array.isArray(e)&&0!==e.length?t&&"object"==typeof t?e.reduce(((e,i)=>(i in t&&(e[i]=t[i]),e)),{}):{}:t}},330(e){e.exports={rE:"4.1.5"}}},a={};function r(e){var t=a[e];if(void 0!==t)return t.exports;var i=a[e]={exports:{}};return s[e](i,i.exports,r),i.exports}r.d=(e,t)=>{for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n=r(144),d=r(487),o=r(51),l=r(302),h=r(347);function u(e,t={}){try{if(!o.A.VALID_EVENT_TYPES.includes(e))return n.A.warn("Invalid event type provided to recordEvent",{eventType:e}),!1;if(!window?.NRVIDEO?.info)return;const{appName:i,applicationID:s}=window.NRVIDEO.info,{qoe:a,...r}=t,u=a?{...a}:{},c={...s?{}:{appName:i},timestamp:Date.now(),timeSinceLoad:window.performance?window.performance.now()/1e3:null},g={...r,eventType:e,...c},m=(0,h.z8)(o.A.QOE_AGGREGATE_KEYS,t);let A=null;"VideoAction"===e&&(A={eventType:"VideoAction",actionName:l.A.Events.QOE_AGGREGATE,qoeAggregateVersion:"1.0.0",...u,...m,...c});const T=d.videoAnalyticsHarvester.addEvent(g);if(A&&window?.NRVIDEO?.config?.qoeAggregate){const e=d.videoAnalyticsHarvester.addEvent(A);return T&&e}return T}catch(e){return n.A.error("Failed to record event:",e.message),!1}}const{COLLECTOR:c}=o.A,g=new class{setConfiguration(e,t){return!!this.validateRequiredFields(e)&&!!this.validateConfigFields(t)&&(this.initializeGlobalConfig(e,t),n.A.notice("Video analytics configuration initialized successfully"),!0)}validateRequiredFields(e){if(!e||"object"!=typeof e)return n.A.error("Configuration must be an object"),!1;const{licenseKey:t,appName:i,region:s,applicationID:a,beacon:r}=e;if(!t)return n.A.error("licenseKey is required"),!1;if(a){if(!r)return n.A.error("beacon is required when applicationID is provided"),!1;if(!Object.values(c).flatMap((e=>e)).includes(r))return n.A.error(`Invalid beacon: ${r}`),!1}else{if(!i||!s)return n.A.error("appName and region are required when applicationID is not provided"),!1;if(!c[s])return n.A.error(`Invalid region: ${s}. Valid regions are: ${Object.keys(c).join(", ")}`),!1}return!0}validateConfigFields(e){if(null==e)return!0;if("object"!=typeof e||Array.isArray(e))return n.A.error("config must be an object"),!1;const{qoeAggregate:t,obfuscate:i}=e;return void 0!==t&&"boolean"!=typeof t?(n.A.error("qoeAggregate must be a boolean"),!1):!(void 0!==i&&!Array.isArray(i)&&(n.A.error("obfuscate must be an array"),1))}filterObfuscateRules(e){return e?e.filter((e=>{const t=void 0!==e.regex&&("string"==typeof e.regex||e.regex instanceof RegExp),i=void 0!==e.replacement&&"string"==typeof e.replacement;return!(!t||!i)||(n.A.warn("obfuscate rule missing required 'regex' (string|RegExp) and/or 'replacement' (string), skipping:",e),!1)})):[]}sanitizeQoeIntervalFactor(e){return null==e?1:"number"==typeof e&&Number.isInteger(e)&&e>=1?e:(console.warn(`[nrvideo] Invalid qoeIntervalFactor "${e}" — must be a positive integer. Defaulting to 1.`),1)}initializeGlobalConfig(e,t){let{licenseKey:i,appName:s,region:a,beacon:r,applicationID:n}=e;r="US"===a?o.A.COLLECTOR.US[0]:r||c[a],window.NRVIDEO={info:{...a?{region:a}:{},beacon:r,licenseKey:i,applicationID:n,...n?{}:{appName:s}},config:{qoeAggregate:t?.qoeAggregate??!1,qoeIntervalFactor:this.sanitizeQoeIntervalFactor(t?.qoeIntervalFactor),obfuscate:this.filterObfuscateRules(t?.obfuscate)}}}};class m{static addTracker(e,t){var i,s;t?.info&&(i=t.info,s=t?.config,g.setConfiguration(i,s)),e.on&&e.emit?(A.push(e),e.on("*",T),"function"==typeof e.trackerInit&&e.trackerInit()):n.A.error("Tried to load a non-tracker.",e)}static removeTracker(e){e.off("*",T),e.dispose();let t=A.indexOf(e);-1!==t&&A.splice(t,1)}static getTrackers(){return A}static send(e,t,i){return u(e,{actionName:t,...i})}static sendError(e){return u("VideoErrorAction",{actionName:"ERROR",...e})}static async forceHarvest(){try{const{videoAnalyticsHarvester:e}=r(487);return await e.forceHarvest()}catch(e){return n.A.error("Failed to force harvest:",e.message),{success:!1,error:e.message}}}}let A=[];function T(e){try{let t=function(e){let t={};for(let i in e)null!==e[i]&&void 0!==e[i]&&(t[i]=e[i]);return t}(e.data);n.A.level<=n.A.Levels.DEBUG?n.A.notice("Sent",e.type,t):n.A.notice("Sent",e.type),m.send(e.eventType,e.type,t)}catch(e){n.A.error("Error in event handler:",e.message)}}const p=m;var f=r(455),E=r(568);const S=class{constructor(){this.reset(),this._createdAt=Date.now(),this._hb=!0,this._acc=0,this._bufferAcc=0}reset(){this._viewSession=null,this._viewCount=0,this._isAd=!1,this.numberOfErrors=0,this.numberOfAds=0,this.numberOfVideos=0,this.totalPlaytime=0,this.weightedAverageBitrate=0,this.totalAdPlaytime=0,this.isAdBreak=!1,this.initialBufferingHappened=!1,this.startupTime=null,this.peakBitrate=0,this._lastBitrate=null,this._lastBitrateChangeTimestamp=null,this.partialAverageBitrate=0,this._totalBitrateDuration=0,this.hadStartupError=!1,this.hadPlaybackError=!1,this.totalRebufferingTime=0,this.resetFlags(),this.resetChronos()}resetFlags(){this.isPlayerReady=!1,this.isRequested=!1,this.isStarted=!1,this.isPaused=!1,this.isSeeking=!1,this.isBuffering=!1,this.isPlaying=!1}resetChronos(){this.timeSinceRequested=new f.A,this.timeSinceStarted=new f.A,this.timeSincePaused=new f.A,this.timeSinceSeekBegin=new f.A,this.timeSinceBufferBegin=new f.A,this.timeSinceAdBreakStart=new f.A,this.timeSinceLastDownload=new f.A,this.timeSinceLastHeartbeat=new f.A,this.timeSinceLastRenditionChange=new f.A,this.timeSinceLastAdQuartile=new f.A,this.timeSinceLastAd=new f.A,this.timeSinceLastError=new f.A,this.timeSinceLastAdError=new f.A,this.timeSinceResumed=new f.A,this.timeSinceSeekEnd=new f.A,this.playtimeSinceLastEvent=new f.A,this.customTimeSinceAttributes={},this.elapsedTime=new f.A,this.bufferElapsedTime=new f.A,this._totalAdPlaytime=new f.A}isAd(){return this._isAd}setIsAd(e){this._isAd=e}setTimeSinceAttribute(e){this.customTimeSinceAttributes[e]=new f.A,this.customTimeSinceAttributes[e].start()}removeTimeSinceAttribute(e){delete this.customTimeSinceAttributes[e]}getViewSession(){if(!this._viewSession){let e=(new Date).getTime(),t=Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2);this._viewSession=e+"-"+t}return this._viewSession}getViewId(){return this.getViewSession()+"-"+this._viewCount}getStateAttributes(e){e=e||{},this.isAd()?(this.isRequested&&(e.timeSinceAdRequested=this.timeSinceRequested.getDeltaTime(),e.timeSinceLastAdHeartbeat=this.timeSinceLastHeartbeat.getDeltaTime()),this.isStarted&&(e.timeSinceAdStarted=this.timeSinceStarted.getDeltaTime()),this.isPaused&&(e.timeSinceAdPaused=this.timeSincePaused.getDeltaTime()),this.isBuffering&&(e.timeSinceAdBufferBegin=this.timeSinceBufferBegin.getDeltaTime()),this.isSeeking&&(e.timeSinceAdSeekBegin=this.timeSinceSeekBegin.getDeltaTime()),this.isAdBreak&&(e.timeSinceAdBreakBegin=this.timeSinceAdBreakStart.getDeltaTime()),this.numberOfErrors>0&&this.timeSinceLastAdError.startTime>0&&(e.timeSinceLastAdError=this.timeSinceLastAdError.getDeltaTime()),e.numberOfAds=this.numberOfAds):(this.isRequested&&(e.timeSinceRequested=this.timeSinceRequested.getDeltaTime(),e.timeSinceLastHeartbeat=this.timeSinceLastHeartbeat.getDeltaTime()),this.isStarted&&(e.timeSinceStarted=this.timeSinceStarted.getDeltaTime()),this.isPaused&&(e.timeSincePaused=this.timeSincePaused.getDeltaTime()),this.isBuffering&&(e.timeSinceBufferBegin=this.timeSinceBufferBegin.getDeltaTime()),this.isSeeking&&(e.timeSinceSeekBegin=this.timeSinceSeekBegin.getDeltaTime()),e.timeSinceLastAd=this.timeSinceLastAd.getDeltaTime(),this.numberOfErrors>0&&this.timeSinceLastError.startTime>0&&(e.timeSinceLastError=this.timeSinceLastError.getDeltaTime()),e.numberOfVideos=this.numberOfVideos),e.numberOfErrors=this.numberOfErrors,this.isAd()||(this.playtimeSinceLastEvent.startTime>0?e.playtimeSinceLastEvent=this.playtimeSinceLastEvent.getDeltaTime():e.playtimeSinceLastEvent=0,this.isPlaying?this.playtimeSinceLastEvent.start():this.playtimeSinceLastEvent.reset(),this.totalPlaytime+=e.playtimeSinceLastEvent,e.totalPlaytime=this.totalPlaytime);for(const[t,i]of Object.entries(this.customTimeSinceAttributes))e[t]=i.getDeltaTime();return e}getQoeAttributes(e){e=e||{};const t={};try{null!==this.startupTime&&(t.startupTime=this.startupTime),this.peakBitrate>0&&(t.peakBitrate=this.peakBitrate),t.hadStartupError=this.hadStartupError,t.hadPlaybackError=this.hadPlaybackError,t.totalRebufferingTime=this.totalRebufferingTime,t.rebufferingRatio=this.totalPlaytime>0?this.totalRebufferingTime/this.totalPlaytime*100:0,t.totalPlaytime=this.totalPlaytime,t.averageBitrate=this.weightedBitrate,t.numberOfErrors=this.numberOfErrors}catch(e){n.A.error("Failed to add attributes for QOE KPIs",e.message)}return e.qoe=t,e}calculateBufferType(e){let t="";return t=e?"initial":this.isSeeking?"seek":this.isPaused?"pause":"connection",n.A.debug("Buffer Type = "+t),t}goViewCountUp(){this._viewCount++}goPlayerReady(){return!this.isPlayerReady&&(this.isPlayerReady=!0,!0)}goRequest(){return!this.isRequested&&(this.isRequested=!0,this.timeSinceLastAd.reset(),this.timeSinceRequested.start(),!0)}goStart(){return!(!this.isRequested||this.isStarted||(this.isAd()?this.numberOfAds++:this.numberOfVideos++,this.isStarted=!0,this.isPlaying=!0,this.timeSinceStarted.start(),this.playtimeSinceLastEvent.start(),0))}goEnd(){return!!this.isRequested&&(this.numberOfErrors=0,this.resetFlags(),this.timeSinceRequested.stop(),this.timeSinceStarted.stop(),this.playtimeSinceLastEvent.stop(),this.isPlaying=!1,!0)}goPause(){return!(!this.isStarted||this.isPaused||(this.isPaused=!0,this.isPlaying=!1,this.timeSincePaused.start(),this.playtimeSinceLastEvent.stop(),this.timeSinceResumed.reset(),this.isBuffering&&(this._bufferAcc+=this.bufferElapsedTime.getDeltaTime()),this.elapsedTime.start(),0))}goResume(){return!(!this.isStarted||!this.isPaused||(this.isPaused=!1,this.isPlaying=!0,this.timeSincePaused.stop(),this.timeSinceResumed.start(),this._hb?(this._acc=this.elapsedTime.getDeltaTime(),this._hb=!1):(this.isBuffering&&this.bufferElapsedTime.start(),this._acc+=this.elapsedTime.getDeltaTime()),0))}goBufferStart(){return!(!this.isRequested||this.isBuffering||(this.isBuffering=!0,this.isPlaying=!1,this.timeSinceBufferBegin.start(),this.bufferElapsedTime.start(),0))}goBufferEnd(){return!(!this.isRequested||!this.isBuffering||(this.isBuffering=!1,this.isPlaying=!0,this.timeSinceBufferBegin.stop(),this._hb?(this._bufferAcc=this.bufferElapsedTime.getDeltaTime(),this._hb=!1):this._bufferAcc+=this.bufferElapsedTime.getDeltaTime(),!this.isAd()&&this.initialBufferingHappened&&(this.totalRebufferingTime+=this.timeSinceBufferBegin.stopTime-this.timeSinceBufferBegin.startTime),0))}goSeekStart(){return!(!this.isStarted||this.isSeeking||(this.isSeeking=!0,this.isPlaying=!1,this.timeSinceSeekBegin.start(),this.timeSinceSeekEnd.reset(),0))}goSeekEnd(){return!(!this.isStarted||!this.isSeeking||(this.isSeeking=!1,this.isPlaying=!0,this.timeSinceSeekBegin.stop(),this.timeSinceSeekEnd.start(),0))}goAdBreakStart(){return!this.isAdBreak&&(this.isAdBreak=!0,this.timeSinceAdBreakStart.start(),!0)}goAdBreakEnd(){return!!this.isAdBreak&&(this.isRequested=!1,this.isAdBreak=!1,this.totalAdPlaytime=this.timeSinceAdBreakStart.getDeltaTime(),this.timeSinceAdBreakStart.stop(),!0)}goDownload(){this.timeSinceLastDownload.start()}goHeartbeat(){this.timeSinceLastHeartbeat.start()}goRenditionChange(){this.timeSinceLastRenditionChange.start()}goAdQuartile(){this.timeSinceLastAdQuartile.start()}goError(){this.isError=!0,this.numberOfErrors++,this.isAd()?this.timeSinceLastAdError.start():(this.timeSinceLastError.start(),this.isStarted?this.hadPlaybackError=!0:this.hadStartupError=!0)}goLastAd(){this.timeSinceLastAd.start()}trackContentBitrateState(e){if(e&&"number"==typeof e){this.peakBitrate=Math.max(this.peakBitrate,e);const t=Date.now();if(!this.isPlaying){if(null!==this._lastBitrate&&null!==this._lastBitrateChangeTimestamp){const e=t-this._lastBitrateChangeTimestamp;e>0&&(this.partialAverageBitrate+=this._lastBitrate*e,this._totalBitrateDuration+=e),this._lastBitrateChangeTimestamp=null}return void(this._lastBitrate=e)}if(null===this._lastBitrateChangeTimestamp&&null!==this._lastBitrate&&(this._lastBitrateChangeTimestamp=t),null!==this._lastBitrate&&this._lastBitrate!==e&&null!==this._lastBitrateChangeTimestamp){const e=t-this._lastBitrateChangeTimestamp;e>0&&(this.partialAverageBitrate+=this._lastBitrate*e,this._totalBitrateDuration+=e),this._lastBitrateChangeTimestamp=t}null===this._lastBitrateChangeTimestamp&&(this._lastBitrateChangeTimestamp=t),this._lastBitrate=e;let i=this.partialAverageBitrate,s=this._totalBitrateDuration;const a=t-this._lastBitrateChangeTimestamp;a>0&&(i+=e*a,s+=a),this.weightedBitrate=s>0?Math.round(i/s):e}}resetViewIdTrackedState(){this.peakBitrate=0,this.partialAverageBitrate=0,this._totalBitrateDuration=0,this.startupTime=null,this._lastBitrate=null,this._lastBitrateChangeTimestamp=null}clearTotalAdsTime(){n.A.debug("clear total ads time",this.totalAdTime),this._totalAdPlaytime.reset()}totalAdTime(){return this._totalAdPlaytime.getDuration()}startAdsTime(){return n.A.debug("startAdsTime"),this._totalAdPlaytime.start()}stopAdsTime(){return n.A.debug("stopAdsTime"),this._totalAdPlaytime.stop()}setStartupTime(e){null===this.startupTime&&(this.startupTime=Math.max(this.timeSinceRequested.getDeltaTime()-e,0))}};var y=r(330);class v extends l.A{constructor(e,t){super(),this.state=new S,this.adsTracker=null,this._lastBufferType=null,this._userId=null,t=t||{},this.setOptions(t),e&&this.setPlayer(e,t.tag),n.A.notice("Tracker "+this.getTrackerName()+" v"+this.getTrackerVersion()+" is ready.")}setUserId(e){this._userId=e}setOptions(e){e&&(e.adsTracker&&this.setAdsTracker(e.adsTracker),"boolean"==typeof e.isAd&&this.setIsAd(e.isAd),l.A.prototype.setOptions.apply(this,arguments))}setPlayer(e,t){(this.player||this.tag)&&this.dispose(),"undefined"!=typeof document&&document.getElementById&&("string"==typeof e&&(e=document.getElementById(e)),"string"==typeof t&&(t=document.getElementById(t))),t=t||e,this.player=e,this.tag=t,this.registerListeners()}isAd(){return this.state.isAd()}setIsAd(e){this.state.setIsAd(e)}setAdsTracker(e){this.disposeAdsTracker(),e&&(this.adsTracker=e,this.adsTracker.setIsAd(!0),this.adsTracker.parentTracker=this,this.adsTracker.on("*",_.bind(this)))}disposeAdsTracker(){this.adsTracker&&(this.adsTracker.off("*",_),this.adsTracker.dispose())}dispose(){this.stopHeartbeat(),this.disposeAdsTracker(),this.unregisterListeners(),this.player=null,this.tag=null}registerListeners(){}unregisterListeners(){}getViewId(){return this.parentTracker?this.parentTracker.getViewId():this.state.getViewId()}getViewSession(){return this.parentTracker?this.parentTracker.getViewSession():this.state.getViewSession()}getVideoId(){return null}getTitle(){return null}isLive(){return null}getBitrate(){return null}getManifestBitrate(){return null}getSegmentDownloadBitrate(){return null}getNetworkDownloadBitrate(){return null}getWebkitBitrate(){if(this.tag&&this.tag.webkitVideoDecodedByteCount){let e;if(this._lastWebkitBitrate){e=this.tag.webkitVideoDecodedByteCount;let t=e-this._lastWebkitBitrate,i=this.getHeartbeat()/1e3;e=Math.round(t/i*8)}return this._lastWebkitBitrate=this.tag.webkitVideoDecodedByteCount,e||null}}getRenditionName(){return null}getRenditionBitrate(){return null}getRenditionShift(e){let t,i=this.getRenditionBitrate();return this.isAd()?(t=this._lastAdRendition,e&&(this._lastAdRendition=i)):(t=this._lastRendition,e&&(this._lastRendition=i)),i&&t?i>t?"up":i<t?"down":null:null}getRenditionHeight(){return this.tag?this.tag.videoHeight:null}getRenditionWidth(){return this.tag?this.tag.videoWidth:null}getDuration(){return this.tag?this.tag.duration:null}getPlayhead(){return this.tag?this.tag.currentTime:null}getLanguage(){return null}getSrc(){return this.tag?this.tag.currentSrc:null}getPlayrate(){return this.tag?this.tag.playbackRate:null}isMuted(){return this.tag?this.tag.muted:null}isFullscreen(){return null}getCdn(){return null}getPlayerName(){return this.getTrackerName()}getPlayerVersion(){return y.rE}getFps(){return null}isAutoplayed(){return this.tag?this.tag.autoplay:null}getPreload(){return this.tag?this.tag.preload:null}getAdQuartile(){return null}getAdPosition(){return this.parentTracker?this.parentTracker.state.isStarted?"mid":"pre":null}getAdPartner(){return null}getAdCreativeId(){return null}getInstrumentationProvider(){return null}getInstrumentationName(){return null}getInstrumentationVersion(){return null}getAttributes(e,t){if(void 0===(e=l.A.prototype.getAttributes.apply(this,arguments)).isAd&&(e.isAd=this.isAd()),e.viewSession=this.getViewSession(),e.viewId=this.getViewId(),e.playerName=this.getPlayerName(),e.playerVersion=this.getPlayerVersion(),e["instrumentation.provider"]=this.getInstrumentationProvider(),e["instrumentation.name"]=this.getInstrumentationName(),e["instrumentation.version"]=this.getInstrumentationVersion(),e["enduser.id"]=this._userId,e.src="Browser","customAction"===t)return e;try{e.pageUrl=window.location.href}catch(e){}this.isAd()?(e.adId=this.getVideoId(),e.adTitle=this.getTitle(),e.adSrc=this.getSrc(),e.adCdn=this.getCdn(),this.state.isStarted&&(e.adBitrate=this.getBitrate()||0),e.adRenditionName=this.getRenditionName(),e.adRenditionHeight=this.getRenditionHeight(),e.adRenditionWidth=this.getRenditionWidth(),e.adDuration=this.getDuration(),e.adPlayhead=this.getPlayhead(),e.adLanguage=this.getLanguage(),e.adIsMuted=this.isMuted(),e.adFps=this.getFps(),e.adPosition=this.getAdPosition(),e.adCreativeId=this.getAdCreativeId(),e.adPartner=this.getAdPartner()):(e.contentId=this.getVideoId(),e.contentTitle=this.getTitle(),e.contentSrc=this.getSrc(),e.contentCdn=this.getCdn(),e.contentPlayhead=this.getPlayhead(),e.contentIsLive=this.isLive(),this.state.isStarted&&(e.contentBitrate=this.getBitrate()||0,e.contentManifestBitrate=this.getManifestBitrate()||0,e.contentSegmentDownloadBitrate=this.getSegmentDownloadBitrate()||0,e.contentNetworkDownloadBitrate=this.getNetworkDownloadBitrate()||0),e.contentRenditionName=this.getRenditionName(),e.contentRenditionHeight=this.getRenditionHeight(),e.contentRenditionWidth=this.getRenditionWidth(),e.contentDuration=this.getDuration(),e.contentLanguage=this.getLanguage(),e.contentPlayrate=this.getPlayrate(),e.contentIsFullscreen=this.isFullscreen(),e.contentIsMuted=this.isMuted(),e.contentIsAutoplayed=this.isAutoplayed(),e.contentPreload=this.getPreload(),e.contentFps=this.getFps(),null!=this.adsTracker&&this.adsTracker.state.totalAdPlaytime>0&&(e.totalAdPlaytime=this.adsTracker.state.totalAdPlaytime)),this.state.getStateAttributes(e),this.state.isStarted&&!this.isAd()&&this.state.trackContentBitrateState(e.contentBitrate);for(let t in this.customData)e[t]=this.customData[t];return this.addQoeAttributes(e),e}addQoeAttributes(e){const t=(e=this.state.getQoeAttributes(e)).qoe;for(let e in this.customData)t[e]=this.customData[e]}sendCustom(e,t,i){i=i||{},this.sendVideoCustomAction(e,i),this.state.setTimeSinceAttribute(t)}sendPlayerReady(e){this.state.goPlayerReady()&&(e=e||{},this.sendVideoAction(v.Events.PLAYER_READY,e))}sendRequest(e){if(this.state.goRequest()){let t;this.isAd()?(t=v.Events.AD_REQUEST,this.sendVideoAdAction(t,e)):(t=v.Events.CONTENT_REQUEST,this.sendVideoAction(t,e))}}sendStart(e){if(this.state.goStart()){let t;if(this.isAd())t=v.Events.AD_START,this.parentTracker&&(this.parentTracker.state.isPlaying=!1),this.sendVideoAdAction(t,e),this.state.startAdsTime();else{t=v.Events.CONTENT_START;let i=0;this.adsTracker&&((this.adsTracker.state.isPlaying||this.adsTracker.state.isBuffering)&&(this.adsTracker.state.stopAdsTime(),this.adsTracker.state.isPlaying=!1,this.adsTracker.state.isBuffering=!1),i=this.adsTracker.state.totalAdTime()??0),this.state.setStartupTime(i),this.sendVideoAction(t,e),d.videoAnalyticsHarvester.setBeforeDrainCallback((()=>{if(this.state){const e=this.state.getQoeAttributes({}).qoe;d.videoAnalyticsHarvester.refreshQoeKpis(e,this.getViewId())}}))}this.startHeartbeat(),this.state.goHeartbeat()}}sendEnd(e){if(this.state.goEnd()){let t;e=e||{},this.isAd()?(t=v.Events.AD_END,e.timeSinceAdRequested=this.state.timeSinceRequested.getDeltaTime(),e.timeSinceAdStarted=this.state.timeSinceStarted.getDeltaTime(),this.parentTracker&&(this.parentTracker.state.isPlaying=!0),this.state.stopAdsTime()):(t=v.Events.CONTENT_END,e.timeSinceRequested=this.state.timeSinceRequested.getDeltaTime(),e.timeSinceStarted=this.state.timeSinceStarted.getDeltaTime()),this.stopHeartbeat(),this.isAd()?this.sendVideoAdAction(t,e):this.sendVideoAction(t,e),this.parentTracker&&this.isAd()&&this.parentTracker.state.goLastAd(),this.state.goViewCountUp(),this.state.totalPlaytime=0,this.isAd()||(d.videoAnalyticsHarvester.forceNextQoeCycle(),d.videoAnalyticsHarvester.setBeforeDrainCallback(null),this.adsTracker&&this.adsTracker.state.clearTotalAdsTime(),this.state.resetViewIdTrackedState())}}sendPause(e){if(this.state.goPause()){let t=this.isAd()?v.Events.AD_PAUSE:v.Events.CONTENT_PAUSE;this.isAd()?this.sendVideoAdAction(t,e):this.sendVideoAction(t,e)}}sendResume(e){if(this.state.goResume()){let t;e=e||{},this.isAd()?(t=v.Events.AD_RESUME,e.timeSinceAdPaused=this.state.timeSincePaused.getDeltaTime()):(t=v.Events.CONTENT_RESUME,e.timeSincePaused=this.state.timeSincePaused.getDeltaTime()),this.isAd()?this.sendVideoAdAction(t,e):this.sendVideoAction(t,e)}}sendBufferStart(e){if(this.state.goBufferStart()){let t;e=e||{},t=this.isAd()?v.Events.AD_BUFFER_START:v.Events.CONTENT_BUFFER_START,e=this.buildBufferAttributes(e),this._lastBufferType=e.bufferType,this.isAd()?this.sendVideoAdAction(t,e):this.sendVideoAction(t,e)}}sendBufferEnd(e){if(this.state.goBufferEnd()){let t;e=e||{},this.isAd()?(t=v.Events.AD_BUFFER_END,e.timeSinceAdBufferBegin=this.state.timeSinceBufferBegin.getDeltaTime()):(t=v.Events.CONTENT_BUFFER_END,e.timeSinceBufferBegin=this.state.timeSinceBufferBegin.getDeltaTime()),e=this.buildBufferAttributes(e),null!=this._lastBufferType&&(e.bufferType=this._lastBufferType),this.isAd()?this.sendVideoAdAction(t,e):this.sendVideoAction(t,e),this.state.initialBufferingHappened=!0}}buildBufferAttributes(e){return null==e.timeSinceStarted||e.timeSinceStarted<100?e.isInitialBuffering=!this.state.initialBufferingHappened:e.isInitialBuffering=!1,e.bufferType=this.state.calculateBufferType(e.isInitialBuffering),e.timeSinceResumed=this.state.timeSinceResumed.getDeltaTime(),e.timeSinceSeekEnd=this.state.timeSinceSeekEnd.getDeltaTime(),e}sendSeekStart(e){if(this.state.goSeekStart()){let t;t=this.isAd()?v.Events.AD_SEEK_START:v.Events.CONTENT_SEEK_START,this.isAd()?this.sendVideoAdAction(t,e):this.sendVideoAction(t,e)}}sendSeekEnd(e){if(this.state.goSeekEnd()){let t;e=e||{},this.isAd()?(t=v.Events.AD_SEEK_END,e.timeSinceAdSeekBegin=this.state.timeSinceSeekBegin.getDeltaTime()):(t=v.Events.CONTENT_SEEK_END,e.timeSinceSeekBegin=this.state.timeSinceSeekBegin.getDeltaTime()),this.isAd()?this.sendVideoAdAction(t,e):this.sendVideoAction(t,e)}}sendDownload(e){(e=e||{}).state||n.A.warn("Called sendDownload without { state: xxxxx }."),this.sendVideoAction(v.Events.DOWNLOAD,e),this.state.goDownload()}sendError(e){(e=e||{}).isAd=this.isAd(),this.state.goError();let t=this.isAd()?v.Events.AD_ERROR:v.Events.CONTENT_ERROR;this.sendVideoErrorAction(t,e)}sendRenditionChanged(e){let t;(e=e||{}).timeSinceLastRenditionChange=this.state.timeSinceLastRenditionChange.getDeltaTime(),e.shift=this.getRenditionShift(!0),t=this.isAd()?v.Events.AD_RENDITION_CHANGE:v.Events.CONTENT_RENDITION_CHANGE,this.isAd()?this.sendVideoAdAction(t,e):this.sendVideoAction(t,e),this.state.goRenditionChange()}sendHeartbeat(e){if(this.state.isRequested){let t,i=this.getHeartbeat();this.state._hb=!0,i=this.adjustElapsedTimeForPause(i),this.isAd()?(t=v.Events.AD_HEARTBEAT,"bitmovin-ads"===this.getPlayerName()?this.sendVideoAdAction(t,e):this.sendVideoAdAction(t,{elapsedTime:i,...e})):(t=v.Events.CONTENT_HEARTBEAT,this.sendVideoAction(t,{elapsedTime:i,...e})),this.state.goHeartbeat()}}adjustElapsedTimeForPause(e){return this.state._acc&&(e-=this.state._acc,this.state._acc=0),this.state.isPaused&&((e-=this.state.elapsedTime.getDeltaTime())<10&&(e=0),this.state.elapsedTime.start()),this.state._bufferAcc?(e-=this.state._bufferAcc,this.state._bufferAcc=0):this.state.isBuffering&&((e-=this.state.bufferElapsedTime.getDeltaTime())<5&&(e=0),this.state.bufferElapsedTime.start()),Math.max(0,e)}sendAdBreakStart(e){this.isAd()&&this.state.goAdBreakStart()&&(this.state.totalAdPlaytime=0,this.parentTracker&&(this.parentTracker.state.isPlaying=!1),this.sendVideoAdAction(v.Events.AD_BREAK_START,e))}sendAdBreakEnd(e){this.isAd()&&this.state.goAdBreakEnd()&&((e=e||{}).timeSinceAdBreakBegin=this.state.timeSinceAdBreakStart.getDeltaTime(),this.sendVideoAdAction(v.Events.AD_BREAK_END,e),this.parentTracker&&(this.parentTracker.state.isPlaying=!0),this.stopHeartbeat(),this.parentTracker&&this.isAd()&&this.parentTracker.state.goLastAd())}sendAdQuartile(e){this.isAd()&&((e=e||{}).quartile||n.A.warn("Called sendAdQuartile without { quartile: xxxxx }."),e.timeSinceLastAdQuartile=this.state.timeSinceLastAdQuartile.getDeltaTime(),this.sendVideoAdAction(v.Events.AD_QUARTILE,e),this.state.goAdQuartile())}sendAdClick(e){this.isAd()&&((e=e||{}).url||n.A.warn("Called sendAdClick without { url: xxxxx }."),this.sendVideoAdAction(v.Events.AD_CLICK,e))}}function _(e){e.type!==v.Events.AD_ERROR?this.sendVideoAdAction(e.type,e.data):this.sendVideoErrorAction(e.type,e.data)}v.Events={PLAYER_READY:"PLAYER_READY",DOWNLOAD:"DOWNLOAD",ERROR:"ERROR",CONTENT_REQUEST:"CONTENT_REQUEST",CONTENT_START:"CONTENT_START",CONTENT_END:"CONTENT_END",CONTENT_PAUSE:"CONTENT_PAUSE",CONTENT_RESUME:"CONTENT_RESUME",CONTENT_SEEK_START:"CONTENT_SEEK_START",CONTENT_SEEK_END:"CONTENT_SEEK_END",CONTENT_BUFFER_START:"CONTENT_BUFFER_START",CONTENT_BUFFER_END:"CONTENT_BUFFER_END",CONTENT_HEARTBEAT:"CONTENT_HEARTBEAT",CONTENT_RENDITION_CHANGE:"CONTENT_RENDITION_CHANGE",CONTENT_ERROR:"CONTENT_ERROR",AD_REQUEST:"AD_REQUEST",AD_START:"AD_START",AD_END:"AD_END",AD_PAUSE:"AD_PAUSE",AD_RESUME:"AD_RESUME",AD_SEEK_START:"AD_SEEK_START",AD_SEEK_END:"AD_SEEK_END",AD_BUFFER_START:"AD_BUFFER_START",AD_BUFFER_END:"AD_BUFFER_END",AD_HEARTBEAT:"AD_HEARTBEAT",AD_RENDITION_CHANGE:"AD_RENDITION_CHANGE",AD_ERROR:"AD_ERROR",AD_BREAK_START:"AD_BREAK_START",AD_BREAK_END:"AD_BREAK_END",AD_QUARTILE:"AD_QUARTILE",AD_CLICK:"AD_CLICK"};const D=v;var k=r(431),b=r(413),I=r(481),R=r(374);const P={Constants:o.A,Chrono:f.A,Log:n.A,Emitter:E.A,Tracker:l.A,VideoTracker:D,VideoTrackerState:S,Core:p,version:y.rE,NrVideoEventAggregator:k.t,RetryQueueHandler:b.u,OptimizedHttpClient:I.X,HarvestScheduler:R.n,recordEvent:u}},612:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.buildTrackingEndpointUrl=function(e){const t=e.match(r.REGEX_SESSION_ID);if(!t)return null;const i=t[1];return e.replace(r.REGEX_TRACKING_PATH_SEGMENT,"/v1/tracking/").replace(r.REGEX_MANIFEST_FILE_SUFFIX,`/${i}`)},t.calculateQuartiles=o,t.detectAdBreaksFromVhsPlaylist=function(e,{adSegmentPrefix:t}={}){const i=e.segments,s=e.discontinuityStarts||[],a=[];let n=null,o=null,l=0;i.forEach(((e,i)=>{const h=d(e,{adSegmentPrefix:t}),u=s.includes(i);if(h){u&&o&&(o.endTime=l,o.duration>r.MIN_AD_DURATION&&n.pods.push(o),o=null),n||(n={id:`avail-${l}`,startTime:l,duration:0,endTime:null,source:"vhs-discontinuity",confirmedByTracking:!1,hasFiredStart:!1,hasFiredEnd:!1,hasFiredAdStart:!1,hasFiredQ1:!1,hasFiredQ2:!1,hasFiredQ3:!1,pods:[]}),o||(o={startTime:l,duration:0,endTime:null,hasFiredStart:!1,hasFiredQ1:!1,hasFiredQ2:!1,hasFiredQ3:!1});const t=e.duration||0;n.duration+=t,o.duration+=t}else n&&(o&&(o.endTime=l,o.duration>r.MIN_AD_DURATION&&n.pods.push(o),o=null),n.endTime=l,n.duration>r.MIN_AD_DURATION&&a.push(n),n=null);l+=e.duration||0})),n&&(o&&(o.endTime=l,o.duration>r.MIN_AD_DURATION&&n.pods.push(o)),n.endTime=l,n.duration>r.MIN_AD_DURATION&&a.push(n));return a},t.detectManifestFormatFromUrl=function(e){if(e.includes(r.HLS_MANIFEST_EXTENSION))return r.MANIFEST_TYPE.HLS;if(e.includes(r.DASH_MANIFEST_EXTENSION))return r.MANIFEST_TYPE.DASH;return r.MANIFEST_TYPE.HLS},t.detectPlaybackStreamType=function(e){return e===1/0?r.STREAM_TYPE.LIVE:r.STREAM_TYPE.VOD},t.determineAdPosition=function(e,t,i){if(i===r.STREAM_TYPE.LIVE)return null;return 0===e?r.AD_POSITION.PRE_ROLL:e===t-1?r.AD_POSITION.POST_ROLL:r.AD_POSITION.MID_ROLL},t.enrichAdScheduleWithTrackingMetadata=function(e,t){const i=new Map;e.forEach((e=>{const t=Math.round(e.startTime);i.set(t,e)}));const s=[];return t.forEach((e=>{const t=e.ads&&e.ads.length>0?e.ads[0]:null;if(!t)return;const a=Math.round(t.startTimeInSeconds),r=i.get(a);r?(r.id=e.availId,r.creativeId=t.adId,r.title=t.adTitle,r.confirmedByTracking=!0,e.ads&&e.ads.length>0&&r.pods&&e.ads.forEach(((e,t)=>{r.pods[t]?(r.pods[t].title=e.adTitle,r.pods[t].creativeId=e.adId,r.pods[t].trackingStartTime=e.startTimeInSeconds,r.pods[t].trackingDuration=e.durationInSeconds):r.pods.push({startTime:e.startTimeInSeconds,duration:e.durationInSeconds,endTime:e.startTimeInSeconds+e.durationInSeconds,title:e.adTitle,creativeId:e.adId,hasFiredStart:!1,hasFiredQ1:!1,hasFiredQ2:!1,hasFiredQ3:!1})}))):s.push({id:e.availId,startTime:t.startTimeInSeconds,duration:e.durationInSeconds,endTime:t.startTimeInSeconds+e.durationInSeconds,title:t.adTitle,creativeId:t.adId,source:"tracking-api",confirmedByTracking:!0,hasFiredStart:!1,hasFiredEnd:!1,hasFiredAdStart:!1,hasFiredQ1:!1,hasFiredQ2:!1,hasFiredQ3:!1,pods:e.ads.map((e=>({startTime:e.startTimeInSeconds,duration:e.durationInSeconds,endTime:e.startTimeInSeconds+e.durationInSeconds,title:e.adTitle,creativeId:e.adId,hasFiredStart:!1,hasFiredQ1:!1,hasFiredQ2:!1,hasFiredQ3:!1})))})})),s},t.extractDashMinimumUpdatePeriodSeconds=function(e){const t=e.match(r.REGEX_DASH_MINIMUM_UPDATE_PERIOD);return t?h(t[1]):null},t.extractHlsTargetDurationSeconds=function(e){const t=e.match(r.REGEX_HLS_TARGET_DURATION);return t?parseInt(t[1],10):null},t.extractMediaPlaylistUrl=function(e,t){const i=e.split("\n");for(const e of i)if(!e.startsWith(r.HLS_TAG_PREFIX)&&e.includes(r.HLS_MANIFEST_EXTENSION))return new URL(e.trim(),t).href;return null},t.fetchDashManifest=async function(e){return await l(e)},t.fetchHlsMasterManifest=async function(e){const t=await l(e),i=t.split("\n");let s=null;for(const t of i)if(!t.startsWith(r.HLS_TAG_PREFIX)&&t.includes(r.HLS_MANIFEST_EXTENSION)){s=new URL(t.trim(),e).href;break}return{masterText:t,mediaPlaylistUrl:s}},t.fetchHlsMediaPlaylist=async function(e){return await l(e)},t.findActiveAdBreak=function(e,t){return e.find((e=>t>=e.startTime&&t<e.endTime))},t.findActivePod=function(e,t){if(!e||!e.pods||0===e.pods.length)return null;return e.pods.find((e=>t>=e.startTime&&t<e.endTime))},t.findAdBreakIndex=function(e,t){return e.findIndex((e=>Math.abs(e.startTime-t)<r.AD_TIMING_TOLERANCE))},t.getQuartilesToFire=function(e,t,i){const s=o(t),a=[];e>=s.q1&&!i.q1&&a.push({quartile:1,key:"q1"});e>=s.q2&&!i.q2&&a.push({quartile:2,key:"q2"});e>=s.q3&&!i.q3&&a.push({quartile:3,key:"q3"});return a},t.getTimestamp=function(){return(new Date).toISOString().substring(11,23)},t.getTrackingMetadata=async function(e,t=8e3,i=null){const s=new AbortController,a=setTimeout((()=>s.abort()),t),r=()=>s.abort();i&&i.addEventListener("abort",r);try{const t=await fetch(`${e}?t=${Date.now()}`,{signal:s.signal,credentials:"include"});if(clearTimeout(a),i&&i.removeEventListener("abort",r),!t.ok)throw new Error(`Tracking API error: ${t.status}`);return await t.json()}catch(e){throw clearTimeout(a),i&&i.removeEventListener("abort",r),e}},t.isMediaTailorSegment=d,t.isValidAdBreak=function(e){return e.duration>r.MIN_AD_DURATION},t.mergeAdSchedules=function(e,t){const i=new Map;e.forEach((e=>{const t=Math.round(e.startTime);i.set(t,e)}));const s=[];t.forEach((e=>{const t=Math.round(e.startTime),a=i.get(t);a?!a.confirmedByTracking&&e.confirmedByTracking&&Object.assign(a,e):(s.push(e),i.set(t,e))}));const a=[...e,...s];return a.sort(((e,t)=>e.startTime-t.startTime)),a},t.parseDashManifestForAdBreaks=function(e,{adSegmentPrefix:t}={}){const i=(new DOMParser).parseFromString(e,"text/xml"),s=[],a=i.querySelector("parsererror");if(a)return n.error("[MT] DASH XML parse error:",a.textContent),s;const d=i.querySelectorAll("Period");if(n.debug(`[MT] Found ${d.length} Period(s) in DASH manifest`),d.length>1)d.forEach((e=>{const i=e.querySelector("BaseURL"),a=i?i.textContent.trim():"",d=[r.MT_SEGMENT_PATTERN,r.MT_DEFAULT_AD_SEGMENT_PATH];if(t&&d.push(t),!d.some((e=>a.includes(e))))return;const o=e.getAttribute("id")||"",l=h(e.getAttribute("start")||"PT0S"),u=h(e.getAttribute("duration")||"");u<r.MIN_AD_DURATION?n.debug(`[MT] Skipping period ${o} - duration too short (${u}s)`):(n.debug(`[MT] Ad period detected: ${o}`,{startTime:l,duration:u}),s.push({id:o,startTime:l,duration:u,endTime:l+u,source:r.AD_SOURCE.MANIFEST_CUE,confirmedByTracking:!1,hasFiredStart:!1,hasFiredEnd:!1,hasFiredAdStart:!1,hasFiredQ1:!1,hasFiredQ2:!1,hasFiredQ3:!1,pods:[]}))}));else{const e=i.querySelectorAll(r.DASH_SCTE35_EVENT_STREAM_SELECTOR);n.debug(`[MT] Found ${e.length} SCTE-35 EventStream(s) in single-period manifest`),e.forEach((e=>{const t=parseFloat(e.getAttribute("timescale")||"1");e.querySelectorAll("Event").forEach((e=>{const i=parseFloat(e.getAttribute("presentationTime")||0),a=parseFloat(e.getAttribute("duration")||0),d=e.getAttribute("id")||`${r.SCTE35_SCHEME_MARKER}-${i}`,o=1!==t?i/t:i,l=1!==t?a/t:a;l<r.MIN_AD_DURATION?n.debug(`[MT] Skipping event ${d} - duration too short (${l}s)`):(n.debug(`[MT] SCTE-35 event detected: ${d}`,{startTime:o,durationSeconds:l}),s.push({id:d,startTime:o,duration:l,endTime:o+l,source:r.AD_SOURCE.MANIFEST_CUE,confirmedByTracking:!1,hasFiredStart:!1,hasFiredEnd:!1,hasFiredAdStart:!1,hasFiredQ1:!1,hasFiredQ2:!1,hasFiredQ3:!1,pods:[]}))}))}))}return n.debug(`[MT] Parsed ${s.length} valid ad break(s) from DASH manifest`),s},t.parseHlsManifestForAdBreaks=function(e){const t=e.split("\n"),i=[];let s=0,a=null,n=null,d=null,o=[],l=!1;for(const e of t){if(r.REGEX_DISCONTINUITY.test(e)&&l&&d){const t=e.match(r.REGEX_MAP),i=t?t[1]:null;if(i&&i!==d){if(null!==n){const e=s-n;o.push({startTime:n,duration:e,endTime:s,mapUrl:d})}n=s,d=i}}const t=e.match(r.REGEX_MAP);if(t&&l){const e=t[1];if(e&&e!==d){if(null!==n){const e=s-n;o.push({startTime:n,duration:e,endTime:s,mapUrl:d})}n=s,d=e}}if(e.startsWith(r.MT_HLS_CUE_OUT_TAG)){const t=e.match(r.REGEX_CUE_OUT);l=!0,o=[],a={id:`avail-${s}`,startTime:s,duration:t?parseFloat(t[1]):null,endTime:null,pods:[],hasFiredStart:!1,hasFiredEnd:!1,hasFiredAdStart:!1,confirmedByTracking:!1}}if(e.startsWith(r.MT_HLS_CUE_IN_TAG)&&a){if(null!==n){const e=s-n;o.push({startTime:n,duration:e,endTime:s,mapUrl:d})}const e=s-a.startTime;e>=r.MIN_AD_DURATION&&(a.duration=e,a.endTime=s,a.pods=o,i.push(a)),a=null,l=!1,n=null,d=null,o=[]}if(e.startsWith(r.HLS_SEGMENT_DURATION_TAG)){const t=parseFloat(e.split(":")[1]);isNaN(t)||(s+=t)}}a&&a.duration&&(a.endTime=a.startTime+a.duration,a.pods=o,i.push(a));return i},t.parseIsoDuration=h,t.whichAdSegmentMarker=function(e,{adSegmentPrefix:t}={}){const i=[{marker:r.MT_SEGMENT_PATTERN,label:"aws-hostname (segments.mediatailor)"},{marker:r.MT_DEFAULT_AD_SEGMENT_PATH,label:"default-cdn-path (/tm/)"}];t&&i.push({marker:t,label:`custom-prefix (${t})`});const s=e.map&&e.map.uri||"",a=e.uri||"",n=i.find((({marker:e})=>s.includes(e)||a.includes(e)));return n?n.label:null};var s,a=(s=i(555))&&s.__esModule?s:{default:s},r=i(324);const n=(a.default.default||a.default).Log;function d(e,{adSegmentPrefix:t}={}){const i=[r.MT_SEGMENT_PATTERN,r.MT_DEFAULT_AD_SEGMENT_PATH];t&&i.push(t);const s=e.map&&e.map.uri||"",a=e.uri||"";return i.some((e=>s.includes(e)||a.includes(e)))}function o(e){return{q1:e*r.QUARTILES.Q1,q2:e*r.QUARTILES.Q2,q3:e*r.QUARTILES.Q3}}async function l(e){const t=await fetch(e,{credentials:"include"});if(!1===t.ok)throw new Error(`Manifest request failed: ${t.status||"unknown"} ${t.statusText||"Request failed"}`);return await t.text()}function h(e){if(!e)return 0;const t=e.match(r.REGEX_ISO_8601_DURATION);if(!t)return 0;return 3600*parseFloat(t[1]||0)+60*parseFloat(t[2]||0)+parseFloat(t[3]||0)}},687:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=d(i(555)),a=d(i(472)),r=i(324),n=i(612);function d(e){return e&&e.__esModule?e:{default:e}}const o=(s.default.default||s.default).Log;class l extends a.default{static isUsing(e,t={}){return Boolean(t&&t.mediatailor)}getTrackerName(){return"aws-media-tailor"}getPlayerVersion(){return"MediaTailor"}getAdPosition(){return this.currentAdBreak&&this.currentAdBreak.adPosition?this.currentAdBreak.adPosition:super.getAdPosition()}constructor(e,t={}){super(e);const i=!0===t.mediatailor?{}:t.mediatailor||{};this.streamType=null,this.manifestFormat=null,this.playbackManifestUrl=e.currentSrc(),this.explicitTrackingUrl=i.trackingUrl||null,this.adSegmentPrefix=i.adSegmentPrefix||null,this.adSegmentPrefix?o.debug(`[MT] ad segment detection: custom prefix "${this.adSegmentPrefix}"`):o.debug("[MT] ad segment detection: default (segments.mediatailor hostname or /tm/ path)"),this.adSchedule=[],this.currentAdBreak=null,this.currentAdPod=null,this.hasEndedContent=!1,this.isDisposed=!1,this.trackingAbortController=null,this.manifestAbortController=null,this.isFetchingTracking=!1,this.isFetchingManifest=!1,this.trackingEndpointUrl=null,this.hasAttemptedTrackingFetch=!1,this.trackingFetchRetries=0,this.maxTrackingRetries=1,this.manifestPollTimer=null,this.trackingPollTimer=null,this.liveRefreshIntervalSeconds=null,this.mediaPlaylistUrl=null,this.lastMediaPlaylistText=null,o.debug(`[MT - ${(0,n.getTimestamp)()}] MediaTailorAdsTracker initialized`,{endpoint:this.playbackManifestUrl,trackingAPITimeout:r.TRACKING_API_TIMEOUT_MS}),this.manifestFormat=(0,n.detectManifestFormatFromUrl)(this.playbackManifestUrl),o.debug(`[MT - ${(0,n.getTimestamp)()}] Manifest type: ${this.manifestFormat.toUpperCase()}`),this.player.one("loadedmetadata",(()=>{this.streamType=(0,n.detectPlaybackStreamType)(this.player.duration()),o.debug(`[MT - ${(0,n.getTimestamp)()}] Stream type: ${this.streamType.toUpperCase()}`),this.initializeTracking()}))}initializeTracking(){o.debug(`[MT - ${(0,n.getTimestamp)()}] Initializing ${this.manifestFormat.toUpperCase()} ${this.streamType.toUpperCase()} tracking`),this.trackingEndpointUrl=this.explicitTrackingUrl||(0,n.buildTrackingEndpointUrl)(this.playbackManifestUrl),this.trackingEndpointUrl?o.debug(`[MT - ${(0,n.getTimestamp)()}] Tracking URL extracted:`,this.trackingEndpointUrl):o.warn(`[MT - ${(0,n.getTimestamp)()}] Could not derive tracking URL from playback URL — pass trackingUrl in mediatailor options if needed`),this.streamType===r.STREAM_TYPE.VOD?this.setupVODTracking():this.setupLiveTracking()}registerListeners(){super.registerListeners(),this.onPause=this.onPause.bind(this),this.onPlaying=this.onPlaying.bind(this),this.onSeeking=this.onSeeking.bind(this),this.onSeeked=this.onSeeked.bind(this),this.onWaiting=this.onWaiting.bind(this),this.onEnded=this.onEnded.bind(this),this.onTimeUpdate=this.onTimeUpdate.bind(this),this.player.on("pause",this.onPause),this.player.on("playing",this.onPlaying),this.player.on("seeking",this.onSeeking),this.player.on("seeked",this.onSeeked),this.player.on("waiting",this.onWaiting),this.player.on("ended",this.onEnded),this.player.on("timeupdate",this.onTimeUpdate),o.debug(`[MT - ${(0,n.getTimestamp)()}] Event listeners registered`)}unregisterListeners(){super.unregisterListeners(),this.player.off("pause",this.onPause),this.player.off("playing",this.onPlaying),this.player.off("seeking",this.onSeeking),this.player.off("seeked",this.onSeeked),this.player.off("waiting",this.onWaiting),this.player.off("ended",this.onEnded),this.player.off("timeupdate",this.onTimeUpdate),this.stopLivePolling()}stopLivePolling(){this.manifestPollTimer&&(clearTimeout(this.manifestPollTimer),this.manifestPollTimer=null),this.trackingPollTimer&&(clearInterval(this.trackingPollTimer),this.trackingPollTimer=null)}setupVODTracking(){o.debug(`[MT - ${(0,n.getTimestamp)()}] VOD mode: Single manifest parse`),this.hookPlayerManifest()}setupLiveTracking(){o.debug(`[MT - ${(0,n.getTimestamp)()}] Live mode: Continuous polling`),this.hookPlayerManifest();const e=this.getLiveRefreshIntervalMs();this.manifestPollTimer=setInterval((()=>{this.pollManifestForNewAds()}),e),this.trackingPollTimer=setInterval((()=>{this.getAndProcessTrackingMetadata()}),e),o.debug(`[MT - ${(0,n.getTimestamp)()}] Live polling started`,{pollingInterval:e})}getLiveRefreshIntervalMs(){return this.liveRefreshIntervalSeconds?1e3*this.liveRefreshIntervalSeconds:r.DEFAULT_LIVE_POLL_INTERVAL_MS}restartLivePollingTimers(){if(!this.liveRefreshIntervalSeconds)return;const e=this.getLiveRefreshIntervalMs();o.debug(`[MT - ${(0,n.getTimestamp)()}] Updating live polling interval: ${this.liveRefreshIntervalSeconds}s`),this.manifestPollTimer&&clearInterval(this.manifestPollTimer),this.trackingPollTimer&&clearInterval(this.trackingPollTimer),this.manifestPollTimer=setInterval((()=>{this.pollManifestForNewAds()}),e),this.trackingPollTimer=setInterval((()=>{this.getAndProcessTrackingMetadata()}),e)}hookPlayerManifest(){const e=this.player.tech({IWillNotUseThisInPlugins:!0});if(!e)return o.debug(`[MT - ${(0,n.getTimestamp)()}] No tech - using fallback fetch`),void this.getManifestDirectly();if(this.manifestFormat===r.MANIFEST_TYPE.HLS){if(this.hookHLSViaVHS(e)||this.hookHLSViaNative(e)||this.hookHLSViaContribHls(e))return}else if(this.manifestFormat===r.MANIFEST_TYPE.DASH&&(this.hookDASHViaShaka(e)||this.hookDASHViaDashJs(e)))return;o.debug(`[MT - ${(0,n.getTimestamp)()}] Using fallback: direct manifest fetch`),this.getManifestDirectly()}hookHLSViaVHS(e){if(!e.vhs||!e.vhs.playlists)return!1;o.debug(`[MT - ${(0,n.getTimestamp)()}] Hooked: VHS`);const t=e.vhs.playlists.media();return t&&t.segments&&t.segments.length>0&&(o.debug(`[MT - ${(0,n.getTimestamp)()}] Parsing existing playlist`),this.parseVhsPlaylistForAdBreaks(t)),e.vhs.on("loadedplaylist",(()=>{const t=e.vhs.playlists.media();t&&this.parseVhsPlaylistForAdBreaks(t)})),!0}hookHLSViaNative(e){return!!(e.el_&&e.el_.canPlayType&&e.el_.canPlayType(r.HLS_MIME_TYPE))&&(o.debug(`[MT - ${(0,n.getTimestamp)()}] Native HLS detected - using fallback`),this.getManifestDirectly(),!0)}hookHLSViaContribHls(e){if(!e.hls||!e.hls.playlists)return!1;o.debug(`[MT - ${(0,n.getTimestamp)()}] Hooked: contrib-hls (legacy)`);const t=e.hls.playlists.media();return t&&t.segments&&t.segments.length>0&&this.parseVhsPlaylistForAdBreaks(t),e.hls.on("loadedplaylist",(()=>{const t=e.hls.playlists.media();t&&this.parseVhsPlaylistForAdBreaks(t)})),!0}hookDASHViaShaka(e){return!!e.shakaPlayer&&(o.debug(`[MT - ${(0,n.getTimestamp)()}] Hooked: Shaka Player`),e.shakaPlayer.addEventListener("emsg",(e=>{this.handleDASHEmsgEvent(e)})),!0)}hookDASHViaDashJs(e){return!(!e.dash||!e.dash.on)&&(o.debug(`[MT - ${(0,n.getTimestamp)()}] Hooked: dash.js`),e.dash.on("EVENT_MODE_ON_RECEIVE",(e=>{this.handleDASHEventStream(e)})),!0)}async getManifestDirectly(){o.debug(`[MT - ${(0,n.getTimestamp)()}] Fallback: fetching manifest directly`);try{const e=this.playbackManifestUrl;this.manifestFormat===r.MANIFEST_TYPE.HLS?await this.fetchAndParseHlsManifest(e):this.manifestFormat===r.MANIFEST_TYPE.DASH&&await this.fetchAndParseDashManifest(e)}catch(e){o.debug(`[MT - ${(0,n.getTimestamp)()}] Fallback fetch error:`,e)}}async fetchAndParseHlsManifest(e){try{o.debug(`[MT - ${(0,n.getTimestamp)()}] Fetching HLS master manifest`);const{mediaPlaylistUrl:t}=await(0,n.fetchHlsMasterManifest)(e);if(!t)return void o.debug(`[MT - ${(0,n.getTimestamp)()}] No media playlist found`);o.debug(`[MT - ${(0,n.getTimestamp)()}] Fetching media playlist`);const i=await(0,n.fetchHlsMediaPlaylist)(t),s=(0,n.extractHlsTargetDurationSeconds)(i);this.updateLiveRefreshIntervalFromManifest(s,"hls target duration");const a=(0,n.parseHlsManifestForAdBreaks)(i);a.length>0&&(o.debug(`[MT - ${(0,n.getTimestamp)()}] Detected ${a.length} ad break(s)`),this.mergeNewAds(a))}catch(e){o.debug(`[MT - ${(0,n.getTimestamp)()}] HLS fetch error:`,e)}}async fetchAndParseDashManifest(e){try{o.debug(`[MT - ${(0,n.getTimestamp)()}] Fetching DASH manifest`);const t=await(0,n.fetchDashManifest)(e),i=(0,n.extractDashMinimumUpdatePeriodSeconds)(t);this.updateLiveRefreshIntervalFromManifest(i,"dash minimumUpdatePeriod");const s=(0,n.parseDashManifestForAdBreaks)(t);o.debug(`[MT - ${(0,n.getTimestamp)()}] DASH: ${s.length} ad break(s) found`),s.length>0?this.mergeNewAds(s):this.streamType===r.STREAM_TYPE.VOD&&this.trackingEndpointUrl&&!this.hasAttemptedTrackingFetch&&(o.debug(`[MT - ${(0,n.getTimestamp)()}] DASH: no manifest cues, fetching tracking API`),this.hasAttemptedTrackingFetch=!0,this.getAndProcessTrackingMetadata())}catch(e){o.debug(`[MT - ${(0,n.getTimestamp)()}] DASH fetch error:`,e)}}handleDASHEmsgEvent(e){o.debug(`[MT - ${(0,n.getTimestamp)()}] DASH emsg event:`,e);try{const t=e.detail;if(!t)return void o.debug(`[MT - ${(0,n.getTimestamp)()}] No emsg data in event`);const i=t.schemeIdUri||"";if(!i.includes(r.SCTE35_SCHEME_MARKER))return void o.debug(`[MT - ${(0,n.getTimestamp)()}] Non-SCTE-35 emsg, skipping:`,i);o.debug(`[MT - ${(0,n.getTimestamp)()}] SCTE-35 emsg detected:`,{schemeIdUri:t.schemeIdUri,value:t.value,timescale:t.timescale,presentationTime:t.presentationTime,presentationTimeDelta:t.presentationTimeDelta,eventDuration:t.eventDuration});const s=t.timescale||1,a=t.presentationTime||0,d=t.eventDuration||0,l=a/s,h=d/s;if(t.messageData&&h>0){const e={id:`dash-emsg-${l}`,startTime:l,duration:h,endTime:l+h,source:"dash-emsg",confirmedByTracking:!1,hasFiredStart:!1,hasFiredEnd:!1,hasFiredAdStart:!1,pods:[]};o.debug(`[MT - ${(0,n.getTimestamp)()}] Adding ad break from DASH emsg:`,e),this.mergeNewAds([e])}}catch(e){o.debug(`[MT - ${(0,n.getTimestamp)()}] Error parsing DASH emsg event:`,e)}}handleDASHEventStream(e){o.debug(`[MT - ${(0,n.getTimestamp)()}] DASH event stream:`,e);try{const t=e.event||e;if(!t)return void o.debug(`[MT - ${(0,n.getTimestamp)()}] No event data`);const i=t.schemeIdUri||"";if(!i.includes(r.SCTE35_SCHEME_MARKER))return void o.debug(`[MT - ${(0,n.getTimestamp)()}] Non-SCTE-35 event, skipping:`,i);o.debug(`[MT - ${(0,n.getTimestamp)()}] SCTE-35 event stream detected:`,{id:t.id,schemeIdUri:t.schemeIdUri,presentationTime:t.presentationTime,duration:t.duration,messageData:t.messageData});const s=parseFloat(t.presentationTime||0),a=parseFloat(t.duration||0);if(a>0){const e={id:t.id||`dash-event-${s}`,startTime:s,duration:a,endTime:s+a,source:"dash-event-stream",confirmedByTracking:!1,hasFiredStart:!1,hasFiredEnd:!1,hasFiredAdStart:!1,pods:[]};o.debug(`[MT - ${(0,n.getTimestamp)()}] Adding ad break from DASH event stream:`,e),this.mergeNewAds([e])}}catch(e){o.debug(`[MT - ${(0,n.getTimestamp)()}] Error parsing DASH event stream:`,e)}}parseVhsPlaylistForAdBreaks(e){if(o.debug(`[MT - ${(0,n.getTimestamp)()}] Parsing VHS playlist (${e.segments?.length||0} segments)`),!e.segments||0===e.segments.length)return void o.debug(`[MT - ${(0,n.getTimestamp)()}] No segments in playlist`);this.updateLiveRefreshIntervalFromManifest(e.targetDuration,"vhs target duration");const t=(0,n.detectAdBreaksFromVhsPlaylist)(e,{adSegmentPrefix:this.adSegmentPrefix});if(t.length>0){if(!this._detectionPathLogged){const t=e.segments&&e.segments.find((e=>(0,n.whichAdSegmentMarker)(e,{adSegmentPrefix:this.adSegmentPrefix})));if(t){const e=(0,n.whichAdSegmentMarker)(t,{adSegmentPrefix:this.adSegmentPrefix});o.debug(`[MT] ad segment detection matched via: ${e}`),this._detectionPathLogged=!0}}o.debug(`[MT - ${(0,n.getTimestamp)()}] VHS detected ${t.length} ad break(s), ${t.reduce(((e,t)=>e+t.pods.length),0)} pod(s)`),this.mergeNewAds(t)}else o.debug(`[MT - ${(0,n.getTimestamp)()}] No ads detected in VHS playlist`)}async pollManifestForNewAds(){if(!this.isDisposed&&this.streamType===r.STREAM_TYPE.LIVE)if(this.isFetchingManifest)o.debug(`[MT - ${(0,n.getTimestamp)()}] Manifest fetch already in progress, skipping`);else{this.isFetchingManifest=!0;try{const e=this.player.tech({IWillNotUseThisInPlugins:!0});if(e&&e.vhs){const t=e.vhs.playlists.media();t&&this.parseVhsPlaylistForAdBreaks(t)}else this.manifestFormat===r.MANIFEST_TYPE.DASH&&await this.fetchAndParseDashManifest(this.playbackManifestUrl)}catch(e){o.debug(`[MT - ${(0,n.getTimestamp)()}] Manifest poll error:`,e)}finally{this.isFetchingManifest=!1}}}mergeNewAds(e){this.adSchedule=(0,n.mergeAdSchedules)(this.adSchedule,e),o.debug(`[MT - ${(0,n.getTimestamp)()}] Ad schedule: ${this.adSchedule.length} ad break(s)`),this.streamType===r.STREAM_TYPE.VOD&&this.trackingEndpointUrl&&!this.hasAttemptedTrackingFetch&&(this.hasAttemptedTrackingFetch=!0,o.debug(`[MT - ${(0,n.getTimestamp)()}] Fetching tracking metadata (first manifest parse)`),this.getAndProcessTrackingMetadata())}updateLiveRefreshIntervalFromManifest(e,t){this.streamType!==r.STREAM_TYPE.LIVE||!e||e<=0||this.liveRefreshIntervalSeconds!==e&&(this.liveRefreshIntervalSeconds=e,o.debug(`[MT - ${(0,n.getTimestamp)()}] Derived live polling interval from ${t}: ${e}s`),(this.manifestPollTimer||this.trackingPollTimer)&&this.restartLivePollingTimers())}async getAndProcessTrackingMetadata(){if(!this.isDisposed&&this.trackingEndpointUrl)if(this.isFetchingTracking)o.debug(`[MT - ${(0,n.getTimestamp)()}] Tracking fetch already in progress, skipping`);else{this.isFetchingTracking=!0;try{o.debug(`[MT - ${(0,n.getTimestamp)()}] Fetching tracking metadata`),this.trackingAbortController=new AbortController;const e=await(0,n.getTrackingMetadata)(this.trackingEndpointUrl,r.TRACKING_API_TIMEOUT_MS,this.trackingAbortController.signal);if(this.isDisposed)return void o.debug(`[MT - ${(0,n.getTimestamp)()}] Disposed during tracking fetch, ignoring result`);e.avails&&e.avails.length>0?(o.debug(`[MT - ${(0,n.getTimestamp)()}] Enriching with ${e.avails.length} avail(s)`),this.enrichWithTrackingMetadata(e.avails),this.trackingFetchRetries=0):o.debug(`[MT - ${(0,n.getTimestamp)()}] Tracking API returned 0 avails`)}catch(e){if("AbortError"===e.name||this.isDisposed)return void o.debug(`[MT - ${(0,n.getTimestamp)()}] Tracking fetch aborted`);if(o.debug(`[MT - ${(0,n.getTimestamp)()}] Tracking API error: ${e.message}`,e),this.trackingFetchRetries<this.maxTrackingRetries)return this.trackingFetchRetries++,o.debug(`[MT - ${(0,n.getTimestamp)()}] Retrying tracking fetch (${this.trackingFetchRetries}/${this.maxTrackingRetries})`),this.isFetchingTracking=!1,void await this.getAndProcessTrackingMetadata();o.debug(`[MT - ${(0,n.getTimestamp)()}] Max retries reached, continuing with manifest data only`)}finally{this.isFetchingTracking=!1,this.trackingAbortController=null}}}enrichWithTrackingMetadata(e){const t=(0,n.enrichAdScheduleWithTrackingMetadata)(this.adSchedule,e);t.length>0&&(this.adSchedule.push(...t),this.adSchedule.sort(((e,t)=>e.startTime-t.startTime))),o.debug(`[MT - ${(0,n.getTimestamp)()}] Enrichment complete: ${this.adSchedule.length} ad break(s)`),o.debug(`[MT - ${(0,n.getTimestamp)()}] Enriched schedule:`,this.adSchedule.map((e=>({id:e.id,startTime:e.startTime,endTime:e.endTime,duration:e.duration,title:e.title,podCount:e.pods.length,pods:e.pods.map((e=>({title:e.title,startTime:e.startTime,endTime:e.endTime,duration:e.duration})))})))),o.debug(`[MT - ${(0,n.getTimestamp)()}] Current player time: ${this.player.currentTime()}s`)}trackQuartiles(e,t){if(!e.duration||e.duration<=0)return;(0,n.getQuartilesToFire)(t,e.duration,{q1:e.hasFiredQ1,q2:e.hasFiredQ2,q3:e.hasFiredQ3}).forEach((({quartile:t,key:i})=>{o.debug(`[MT - ${(0,n.getTimestamp)()}] → AD_QUARTILE ${25*t}%`),this.sendAdQuartile({quartile:t}),e[`hasFired${i.toUpperCase()}`]=!0}))}onTimeUpdate(){const e=this.player.currentTime(),t=(0,n.findActiveAdBreak)(this.adSchedule,e);if(this.adSchedule.length>0&&Math.floor(e)%5==0&&Math.floor(10*e)%10==0&&o.debug(`[MT - ${(0,n.getTimestamp)()}] TimeUpdate: ${e.toFixed(2)}s, Active break: ${t?t.id:"none"}, Schedule count: ${this.adSchedule.length}`),t){if(!t.hasFiredStart){this.currentAdBreak=t,this.setIsAd(!0),o.debug(`[MT - ${(0,n.getTimestamp)()}] setIsAd(true) - Entering ad break`);const e=this.adSchedule.findIndex((e=>Math.abs(e.startTime-t.startTime)<.5)),i=(0,n.determineAdPosition)(e,this.adSchedule.length,this.streamType);t.adPosition=i,o.debug(`[MT - ${(0,n.getTimestamp)()}] → AD_BREAK_START`,{startTime:t.startTime,duration:t.duration,podCount:t.pods?.length||0,position:i,breakIndex:e,totalBreaks:this.adSchedule.length}),this.sendAdBreakStart(),t.hasFiredStart=!0}if(t.pods&&t.pods.length>0){const i=(0,n.findActivePod)(t,e);if(i){this.currentAdPod&&this.currentAdPod===i||(this.currentAdPod&&(o.debug(`[MT - ${(0,n.getTimestamp)()}] → AD_END (pod transition)`),this.sendEnd()),this.currentAdPod=i,o.debug(`[MT - ${(0,n.getTimestamp)()}] → AD_START (new pod)`,{startTime:i.startTime,duration:i.duration,position:t.adPosition}),this.sendRequest({adPartner:"aws-mediatailor",adPosition:t.adPosition}),this.sendStart({adPartner:"aws-mediatailor",adPosition:t.adPosition}),i.hasFiredStart=!0);const s=e-i.startTime;this.trackQuartiles(i,s)}}else{t.hasFiredAdStart||(o.debug(`[MT - ${(0,n.getTimestamp)()}] → AD_START (no pods)`,{startTime:t.startTime,duration:t.duration,position:t.adPosition}),this.sendRequest({adPartner:"aws-mediatailor",adPosition:t.adPosition}),this.sendStart({adPartner:"aws-mediatailor",adPosition:t.adPosition}),t.hasFiredAdStart=!0);const i=e-t.startTime;this.trackQuartiles(t,i)}}else this.currentAdBreak&&(this.currentAdPod&&(o.debug(`[MT - ${(0,n.getTimestamp)()}] → AD_END (final pod)`),this.sendEnd(),this.currentAdPod=null),this.currentAdBreak.hasFiredEnd||(o.debug(`[MT - ${(0,n.getTimestamp)()}] → AD_BREAK_END`),this.sendAdBreakEnd(),this.currentAdBreak.hasFiredEnd=!0),this.currentAdBreak=null,this.setIsAd(!1),o.debug(`[MT - ${(0,n.getTimestamp)()}] setIsAd(false) - Exiting ad break`),this.player.ended()&&!this.hasEndedContent&&(o.debug(`[MT - ${(0,n.getTimestamp)()}] Video ended after last ad → CONTENT_END`),this.sendContentEnd(),this.hasEndedContent=!0))}sendContentEnd(){this.parentTracker?this.parentTracker.sendEnd():super.sendEnd()}handleAdEvent(e,t){this.isAd()&&(o.debug(`[MT - ${(0,n.getTimestamp)()}] → ${e}`),t.call(this))}onPause(){this.handleAdEvent("AD_PAUSE",this.sendPause)}onPlaying(){this.isAd()&&(o.debug(`[MT - ${(0,n.getTimestamp)()}] → AD_RESUME`),this.sendResume(),this.sendBufferEnd())}onSeeking(){this.handleAdEvent("AD_SEEK_START",this.sendSeekStart)}onSeeked(){this.handleAdEvent("AD_SEEK_END",this.sendSeekEnd)}onWaiting(){this.handleAdEvent("AD_BUFFER_START",this.sendBufferStart)}onEnded(){this.hasEndedContent||(o.debug(`[MT - ${(0,n.getTimestamp)()}] Video ended → CONTENT_END`),this.sendContentEnd(),this.hasEndedContent=!0)}getTitle(){return this.currentAdPod?this.currentAdPod.title||this.currentAdBreak?.id||null:this.currentAdBreak?.title||this.currentAdBreak?.id||null}getVideoId(){return this.currentAdPod?this.currentAdPod.creativeId||this.currentAdPod.title||this.currentAdBreak?.id||null:this.currentAdBreak?.creativeId||this.currentAdBreak?.id||null}getSrc(){return this.trackingEndpointUrl||this.playbackManifestUrl||null}getDuration(){return this.currentAdPod?1e3*this.currentAdPod.duration:this.currentAdBreak?1e3*this.currentAdBreak.duration:null}stopPolling(){this.manifestPollTimer&&(clearInterval(this.manifestPollTimer),this.manifestPollTimer=null),this.trackingPollTimer&&(clearInterval(this.trackingPollTimer),this.trackingPollTimer=null),o.debug(`[MT - ${(0,n.getTimestamp)()}] Polling stopped`)}dispose(){o.debug(`[MT - ${(0,n.getTimestamp)()}] Disposing MediaTailorAdsTracker`),this.isDisposed=!0,this.trackingAbortController&&(o.debug(`[MT - ${(0,n.getTimestamp)()}] Aborting in-flight tracking fetch`),this.trackingAbortController.abort(),this.trackingAbortController=null),this.manifestAbortController&&(o.debug(`[MT - ${(0,n.getTimestamp)()}] Aborting in-flight manifest fetch`),this.manifestAbortController.abort(),this.manifestAbortController=null),this.stopLivePolling(),this.unregisterListeners(),super.dispose&&super.dispose()}}t.default=l},717:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=r(i(555)),a=r(i(472));function r(e){return e&&e.__esModule?e:{default:e}}const n={DAI_STREAM_INITIALIZED:"dai-stream-initialized",DAI_STREAM_LOADED:"dai-stream-loaded",DAI_STREAM_ERROR:"dai-stream-error",DAI_AD_BREAK_STARTED:"dai-ad-break-started",DAI_AD_BREAK_ENDED:"dai-ad-break-ended",DAI_AD_PERIOD_STARTED:"dai-ad-period-started",DAI_AD_PERIOD_ENDED:"dai-ad-period-ended",DAI_AD_STARTED:"dai-ad-started",DAI_AD_FIRST_QUARTILE:"dai-ad-first-quartile",DAI_AD_MIDPOINT:"dai-ad-midpoint",DAI_AD_THIRD_QUARTILE:"dai-ad-third-quartile",DAI_AD_COMPLETE:"dai-ad-complete",DAI_AD_SKIPPED:"dai-ad-skipped",DAI_AD_PAUSED:"dai-ad-paused",DAI_AD_RESUMED:"dai-ad-resumed",DAI_AD_CLICKED:"dai-ad-clicked",DAI_AD_ERROR:"dai-ad-error",DAI_CUEPOINTS_CHANGED:"dai-cuepoints-changed",DAI_TIMED_METADATA:"dai-timed-metadata"};class d extends a.default{static isUsing(e){return e.imaDai&&"function"==typeof e.imaDai||e.dai&&void 0!==e.dai.VERSION||e.ima&&e.ima.dai||e.streamManager}constructor(e){super(e),this.streamManager=null,this.currentAdData=null,this.adBreakData=null,this.streamData=null,this.cuePoints=[],this.initialized=!1,this.eventHandlers=null}setStreamManager(e){this.streamManager=e,this.setupStreamManagerListeners(),this.initialized=!0,s.default.Log.debug("DaiAdsTracker: StreamManager set and listeners registered")}setupStreamManagerListeners(){if(!this.streamManager||!google?.ima?.dai?.api?.StreamEvent)return void s.default.Log.warn("DaiAdsTracker: StreamManager or DAI API not available");const e=google.ima.dai.api.StreamEvent.Type;this.eventHandlers={[e.LOADED]:this.onStreamLoaded.bind(this),[e.STREAM_INITIALIZED]:this.onStreamInitialized.bind(this),[e.ERROR]:this.onStreamError.bind(this),[e.AD_BREAK_STARTED]:this.onAdBreakStarted.bind(this),[e.AD_BREAK_ENDED]:this.onAdBreakEnded.bind(this),[e.AD_PERIOD_STARTED]:this.onAdPeriodStarted.bind(this),[e.AD_PERIOD_ENDED]:this.onAdPeriodEnded.bind(this),[e.STARTED]:this.onAdStarted.bind(this),[e.FIRST_QUARTILE]:this.onAdFirstQuartile.bind(this),[e.MIDPOINT]:this.onAdMidpoint.bind(this),[e.THIRD_QUARTILE]:this.onAdThirdQuartile.bind(this),[e.COMPLETE]:this.onAdComplete.bind(this),[e.SKIPPED]:this.onAdSkipped.bind(this),[e.PAUSED]:this.onAdPaused.bind(this),[e.RESUMED]:this.onAdResumed.bind(this),[e.CLICK]:this.onAdClicked.bind(this),[e.VIDEO_CLICKED]:this.onAdClicked.bind(this),[e.CUEPOINTS_CHANGED]:this.onCuePointsChanged.bind(this),[e.TIMED_METADATA]:this.onTimedMetadata.bind(this)},Object.entries(this.eventHandlers).forEach((([e,t])=>{this.streamManager.addEventListener(e,t)})),s.default.Log.debug("DaiAdsTracker: StreamManager listeners registered")}registerListeners(){super.registerListeners(),s.default.Log.debugCommonVideoEvents(this.player,[null,Object.values(n)])}unregisterListeners(){super.unregisterListeners(),this.streamManager&&this.eventHandlers&&Object.entries(this.eventHandlers).forEach((([e,t])=>{this.streamManager.removeEventListener(e,t)})),this.streamManager=null,this.currentAdData=null,this.adBreakData=null,this.streamData=null,this.cuePoints=[],this.initialized=!1,this.eventHandlers=null}onStreamLoaded(e){this.streamData=this.extractStreamData(e),s.default.Log.debug("DaiAdsTracker: Stream loaded",this.streamData),this.sendRequest()}onStreamInitialized(e){s.default.Log.debug("DaiAdsTracker: Stream initialized"),this.sendDownload({state:"stream-initialized"})}onStreamError(e){const t=this.extractErrorData(e);s.default.Log.error("DaiAdsTracker: Stream error",t),this.sendError(t)}onAdBreakStarted(e){this.adBreakData=this.extractAdBreakData(e),s.default.Log.debug("DaiAdsTracker: Ad break started",this.adBreakData),this.sendAdBreakStart(this.adBreakData)}onAdBreakEnded(e){s.default.Log.debug("DaiAdsTracker: Ad break ended"),this.sendAdBreakEnd(),this.adBreakData=null}onAdPeriodStarted(e){s.default.Log.debug("DaiAdsTracker: Ad period started"),this.adBreakData||this.onAdBreakStarted(e)}onAdPeriodEnded(e){s.default.Log.debug("DaiAdsTracker: Ad period ended")}onAdStarted(e){this.currentAdData=this.extractAdData(e),s.default.Log.debug("DaiAdsTracker: Ad started",this.currentAdData),this.sendStart()}onAdFirstQuartile(e){s.default.Log.debug("DaiAdsTracker: Ad first quartile"),this.sendAdQuartile({quartile:1})}onAdMidpoint(e){s.default.Log.debug("DaiAdsTracker: Ad midpoint"),this.sendAdQuartile({quartile:2})}onAdThirdQuartile(e){s.default.Log.debug("DaiAdsTracker: Ad third quartile"),this.sendAdQuartile({quartile:3})}onAdComplete(e){s.default.Log.debug("DaiAdsTracker: Ad complete"),this.sendEnd(),this.currentAdData=null}onAdSkipped(e){s.default.Log.debug("DaiAdsTracker: Ad skipped"),this.sendEnd({skipped:!0}),this.currentAdData=null}onAdPaused(e){s.default.Log.debug("DaiAdsTracker: Ad paused"),this.sendPause()}onAdResumed(e){s.default.Log.debug("DaiAdsTracker: Ad resumed"),this.sendResume()}onAdClicked(e){s.default.Log.debug("DaiAdsTracker: Ad clicked"),this.sendAdClick({url:this.getClickThroughUrl()})}onCuePointsChanged(e){this.cuePoints=this.extractCuePoints(e),s.default.Log.debug("DaiAdsTracker: Cue points changed",this.cuePoints)}onTimedMetadata(e){const t=this.extractTimedMetadata(e);s.default.Log.debug("DaiAdsTracker: Timed metadata",t)}extractStreamData(e){try{const t=e.getStreamData();return{streamId:t?.streamId,url:t?.url,adTagParameters:t?.adTagParameters,streamType:this.getStreamType()}}catch(e){return s.default.Log.warn("DaiAdsTracker: Failed to extract stream data",e),{}}}extractAdBreakData(e){try{const t=e.getAdBreak();return{adBreakId:t?.id,adBreakTitle:t?.title,adCount:t?.ads?.length||0,position:this.getAdPosition()}}catch(e){return s.default.Log.warn("DaiAdsTracker: Failed to extract ad break data",e),{}}}extractAdData(e){try{const t=e.getAd();return{adId:t?.getAdId(),creativeId:t?.getCreativeId(),duration:t?.getDuration(),title:t?.getTitle(),description:t?.getDescription(),advertiserName:t?.getAdvertiserName(),clickThroughUrl:t?.getClickThroughUrl(),dealId:t?.getDealId(),wrapperAdIds:t?.getWrapperAdIds(),position:this.getAdPosition()}}catch(e){return s.default.Log.warn("DaiAdsTracker: Failed to extract ad data",e),{}}}extractErrorData(e){try{const t=e.getError();return{errorCode:t?.getErrorCode(),errorMessage:t?.getMessage(),innerError:t?.getInnerError()}}catch(e){return s.default.Log.warn("DaiAdsTracker: Failed to extract error data",e),{errorMessage:"Unknown DAI error"}}}extractCuePoints(e){try{return e.getCuepoints()||[]}catch(e){return s.default.Log.warn("DaiAdsTracker: Failed to extract cue points",e),[]}}extractTimedMetadata(e){try{return{type:e.getType(),data:e.getData()}}catch(e){return s.default.Log.warn("DaiAdsTracker: Failed to extract timed metadata",e),{}}}getTrackerName(){return"dai-ads"}getPlayerName(){return"videojs-dai"}getPlayerVersion(){return this.player.dai?.VERSION?this.player.dai.VERSION:this.player.ima?.VERSION?`ima-dai: ${this.player.ima.VERSION}`:"unknown"}getAdCuePoints(){return this.cuePoints}getAdPosition(){if(!this.currentAdData&&!this.adBreakData)return null;const e=this.player.currentTime(),t=this.player.duration();return e<5?"pre":t&&e>t-10?"post":"mid"}getDuration(){return void 0!==this.currentAdData?.duration?1e3*this.currentAdData.duration:null}getVideoId(){return this.currentAdData?.adId||null}getAdCreativeId(){return this.currentAdData?.creativeId||null}getTitle(){return this.currentAdData?.title||null}getSrc(){return this.streamData?.url||null}getPlayhead(){if(this.streamManager)try{return 1e3*this.streamManager.getStreamTime()}catch(e){return 1e3*this.player.currentTime()}return 1e3*this.player.currentTime()}getAdPartner(){return"google-dai"}getClickThroughUrl(){return this.currentAdData?.clickThroughUrl||null}getStreamType(){if(this.streamData?.streamType)return this.streamData.streamType;return this.player.duration()===1/0?"live":"vod"}isLiveStream(){return"live"===this.getStreamType()}getCurrentAdBreak(){return this.adBreakData}getCurrentAd(){return this.currentAdData}getStreamData(){return this.streamData}getBitrate(){const e=this.getTech();return e&&e.tech&&e.tech.stats&&e.tech.stats.bandwidth?Math.round(e.tech.stats.bandwidth):null}getRenditionBitrate(){const e=this.getTech();if(e&&e.getRenditionBitrate){const t=e.getRenditionBitrate();return null!==t?Math.round(t):null}return null}}t.default=d}},t={};function i(s){var a=t[s];if(void 0!==a)return a.exports;var r=t[s]={exports:{}};return e[s](r,r.exports,i),r.exports}i.d=(e,t)=>{for(var s in t)i.o(t,s)&&!i.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};(()=>{var e=s;Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t,a=(t=i(302))&&t.__esModule?t:{default:t};e.default=a.default})(),module.exports.VideojsTracker=s})();
|
|
2
|
+
(()=>{"use strict";var e={555(e,t,i){i.r(t),i.d(t,{default:()=>P});var s={487(e,t,i){i.d(t,{videoAnalyticsHarvester:()=>o});var s=i(374),a=i(431),r=i(51),n=i(144),d=i(302);const o=new class{constructor(){this.isInitialized=!1,this.harvestScheduler=null,this.eventBuffer=null}initialize(){if(this.isInitialized)n.A.warn("Video analytics agent already initialized");else try{this.eventBuffer=new a.t,this.harvestScheduler=new s.n(this.eventBuffer),this.harvestScheduler.startScheduler(),this.isInitialized=!0,n.A.notice("Video analytics agent initialized successfully")}catch(e){n.A.error("Failed to initialize video analytics agent:",e.message)}}addEvent(e){this.isInitialized||(n.A.warn("Video analytics agent not initialized, initializing now"),this.initialize());try{return e.actionName&&e.actionName===d.A.Events.QOE_AGGREGATE?e.viewId?this.eventBuffer.addOrReplaceByActionNameAndViewId(d.A.Events.QOE_AGGREGATE,e.viewId,e):this.eventBuffer.addOrReplaceByActionName(d.A.Events.QOE_AGGREGATE,e):this.eventBuffer.add(e)}catch(e){return n.A.error("Failed to add event to harvesting system:",e.message),!1}}setHarvestInterval(e){this.isInitialized||this.initialize(),this.harvestScheduler.updateHarvestInterval(e)}forceNextQoeCycle(){this.harvestScheduler&&(this.harvestScheduler.forceNextQoeCycle=!0)}setBeforeDrainCallback(e){this.harvestScheduler&&(this.harvestScheduler.beforeDrainCallback=e)}refreshQoeKpis(e,t){if(!this.eventBuffer||!e)return;const i=t?this.eventBuffer.findByActionNameAndViewId(d.A.Events.QOE_AGGREGATE,t):this.eventBuffer.findByActionName(d.A.Events.QOE_AGGREGATE);if(i){const s={...i};for(const t of r.A.QOE_KPI_KEYS)t in e&&(s[t]=e[t]);t?this.eventBuffer.addOrReplaceByActionNameAndViewId(d.A.Events.QOE_AGGREGATE,t,s):this.eventBuffer.addOrReplaceByActionName(d.A.Events.QOE_AGGREGATE,s)}}}},455(e,t,i){i.d(t,{A:()=>a});class s{constructor(){this.reset()}reset(){this.startTime=0,this.stopTime=0,this.accumulator=0,this.offset=0}getDeltaTime(){return this.startTime?this.offset+((new Date).getTime()-this.startTime):null}start(){this.startTime=(new Date).getTime(),this.stopTime=0}stop(){return this.stopTime=(new Date).getTime(),this.startTime<this.stopTime&&(this.accumulator+=this.stopTime-this.startTime),this.getDeltaTime()}getDuration(){return this.stopTime?this.accumulator+this.offset:this.accumulator+(this.getDeltaTime()??0)}clone(){var e=new s;return e.startTime=this.startTime,e.stopTime=this.stopTime,e.offset=this.offset,e.accumulator=this.accumulator,e}}const a=s},51(e,t,i){i.d(t,{A:()=>a});class s{}s.AdPositions={PRE:"pre",MID:"mid",POST:"post"},s.COLLECTOR={US:["bam.nr-data.net","bam-cell.nr-data.net"],EU:"bam.eu01.nr-data.net",Staging:"staging-bam-cell.nr-data.net",GOV:"gov-bam.nr-data.net"},s.VALID_EVENT_TYPES=["VideoAction","VideoAdAction","VideoErrorAction","VideoCustomAction"],s.MAX_PAYLOAD_SIZE=1048576,s.MAX_BEACON_SIZE=61440,s.MAX_EVENTS_PER_BATCH=1e3,s.INTERVAL=1e4,s.QOE_KPI_KEYS=["startupTime","peakBitrate","averageBitrate","totalPlaytime","totalRebufferingTime","rebufferingRatio","hadStartupError","hadPlaybackError","numberOfErrors"],s.QOE_AGGREGATE_KEYS=["coreVersion","instrumentation.name","instrumentation.provider","instrumentation.version","isBackgroundEvent","playerName","playerVersion","src","viewId","viewSession","contentIsAutoplayed","contentIsMuted","contentRenditionHeight","contentRenditionWidth","contentSrc","numberOfVideos","pageUrl","trackerName","trackerVersion","contentDuration","contentPlayrate","contentPlayhead","contentPreload","elapsedTime","contentTitle","contentId","contentIsLive","deviceType","deviceGroup","deviceManufacturer","deviceModel","deviceName","deviceSize","deviceUuid","contentRenditionName","contentIsFullscreen","contentCdn","contentFps","asnOrganization","asnLongitude","asnLatitude","asn","timeSinceRequested","timeSinceStarted"];const a=s},568(e,t,i){i.d(t,{A:()=>s});const s=class{on(e,t){if(this._listeners=this._listeners||{},"function"==typeof t)return this._listeners[e]=this._listeners[e]||[],this._listeners[e].push(t),this}off(e,t){if(this._listeners=this._listeners||{},this._listeners[e]){var i=this._listeners[e].indexOf(t);-1!==i&&this._listeners[e].splice(i,1)}return this}emit(e,t,i){return this._listeners=this._listeners||{},i=i||{},Array.isArray(this._listeners[t])&&this._listeners[t].forEach(s=>{s.call(this,{eventType:e,type:t,data:i,target:this})}),Array.isArray(this._listeners["*"])&&this._listeners["*"].forEach(s=>{s.call(this,{eventType:e,type:t,data:i,target:this})}),this}}},431(e,t,i){i.d(t,{t:()=>o});var s=i(144),a=i(51),r=i(347);const{MAX_PAYLOAD_SIZE:n,MAX_EVENTS_PER_BATCH:d}=a.A;class o{constructor(){this.buffer=[],this.maxPayloadSize=n,this.maxEventsPerBatch=d,this.currentPayloadSize=0,this.totalEvents=0,this.smartHarvestPayloadThreshold=Math.floor(.6*this.maxPayloadSize),this.overflowPayloadThreshold=Math.floor(.9*this.maxPayloadSize),this.smartHarvestEventThreshold=Math.floor(.6*this.maxEventsPerBatch),this.overflowEventThreshold=Math.floor(.9*this.maxEventsPerBatch),this.onSmartHarvestTrigger=null}addOrReplaceByActionName(e,t){const i=this.buffer.findIndex(t=>t.actionName===e);try{return-1===i?this.add(t):this.add(t,i),!0}catch(e){return s.A.error("Failed to set or replace the event to buffer:",e.message),!1}}addOrReplaceByActionNameAndViewId(e,t,i){const a=this.buffer.findIndex(i=>i.actionName===e&&i.viewId===t);try{return-1===a?this.add(i):this.add(i,a),!0}catch(e){return s.A.error("Failed to set or replace the event to buffer:",e.message),!1}}findByActionNameAndViewId(e,t){return this.buffer.find(i=>i.actionName===e&&i.viewId===t)||null}findByActionName(e){return this.buffer.find(t=>t.actionName===e)||null}add(e,t){try{const i=(0,r.Q3)(e),s=this.currentPayloadSize+i>=this.maxPayloadSize,a=this.totalEvents+1>=this.maxEventsPerBatch;if((s||a)&&this.makeRoom(i),null!=t&&t>-1){const s=(0,r.Q3)(this.buffer[t]);this.buffer[t]=e,this.currentPayloadSize+=i-s}else this.buffer.push(e),this.totalEvents++,this.currentPayloadSize+=i;return this.checkSmartHarvestTrigger(),!0}catch(e){return s.A.error("Failed to add event to buffer:",e.message),!1}}checkSmartHarvestTrigger(){const e=this.currentPayloadSize/this.maxPayloadSize,t=this.totalEvents/this.maxEventsPerBatch,i=this.currentPayloadSize>=this.overflowPayloadThreshold,a=this.totalEvents>=this.overflowEventThreshold;if(i||a){const a=i?`payload ${this.currentPayloadSize}/${this.maxPayloadSize} bytes (${Math.round(100*e)}%)`:`events ${this.totalEvents}/${this.maxEventsPerBatch} (${Math.round(100*t)}%)`;s.A.warn(`OVERFLOW PREVENTION: ${a} - Emergency harvest triggered`),this.onSmartHarvestTrigger&&"function"==typeof this.onSmartHarvestTrigger&&this.onSmartHarvestTrigger("overflow",90)}else{const e=this.currentPayloadSize>=this.smartHarvestPayloadThreshold,t=this.totalEvents>=this.smartHarvestEventThreshold;(e||t)&&this.onSmartHarvestTrigger&&"function"==typeof this.onSmartHarvestTrigger&&this.onSmartHarvestTrigger("smart",60)}}setSmartHarvestCallback(e){this.onSmartHarvestTrigger=e}drain(){try{const e=this.buffer.splice(0);return this.totalEvents=0,this.currentPayloadSize=0,e}catch(e){return s.A.error("Failed to drain events from buffer:",e.message),[]}}isEmpty(){return 0===this.totalEvents}size(){return this.totalEvents}clear(){this.buffer=[],this.totalEvents=0}makeRoom(e){if(e>this.maxPayloadSize)s.A.error("Event dropped: Event size exceeds maximum payload size.");else for(;(this.totalEvents>=this.maxEventsPerBatch||this.currentPayloadSize+e>=this.maxPayloadSize)&&this.buffer.length>0;){const e=this.buffer.shift(),t=(0,r.Q3)(e);this.totalEvents--,this.currentPayloadSize-=t,s.A.warn("Event buffer full, oldest event removed.")}}}},374(e,t,i){i.d(t,{n:()=>h});var s=i(431),a=i(413),r=i(481),n=i(347),d=i(51),o=i(302),l=i(144);class h{constructor(e){this.eventBuffer=e,this.retryQueueHandler=new a.u,this.httpClient=new r.X,this.fallBackUrl="",this.retryCount=0,this.eventBuffer instanceof s.t&&this.eventBuffer.setSmartHarvestCallback((e,t)=>this.triggerSmartHarvest(e,t)),this.isStarted=!1,this.currentTimerId=null,this.harvestCycle=d.A.INTERVAL,this.isHarvesting=!1,this.qoeCycleCount=1,this.forceNextQoeCycle=!1,this.beforeDrainCallback=null,this._lastSentQoeKpis={},this.setupPageLifecycleHandlers()}startScheduler(){this.isStarted?l.A.warn("Harvest scheduler is already started"):(this.isStarted=!0,l.A.notice("Starting harvest scheduler",{harvestCycle:this.harvestCycle,eventBufferSize:this.eventBuffer?this.eventBuffer.size():0}),this.scheduleNextHarvest())}stopScheduler(){this.isStarted&&(this.isStarted=!1,this.currentTimerId&&(clearTimeout(this.currentTimerId),this.currentTimerId=null),l.A.notice("Harvest scheduler stopped"))}async triggerSmartHarvest(e,t){if(l.A.notice(`${e} harvest triggered at ${t}% threshold`,{type:e,threshold:t}),this.eventBuffer&&!this.eventBuffer.isEmpty()){this.currentTimerId&&(clearTimeout(this.currentTimerId),this.currentTimerId=null);try{await this.triggerHarvest({})}catch(t){l.A.error(`${e} harvest failed:`,t.message)}finally{this.isStarted&&this.scheduleNextHarvest()}}}scheduleNextHarvest(){if(!this.isStarted)return;const e=this.harvestCycle;this.currentTimerId=setTimeout(()=>this.onHarvestInterval(),e)}async onHarvestInterval(){try{const e=this.eventBuffer&&!this.eventBuffer.isEmpty(),t=this.retryQueueHandler&&this.retryQueueHandler.getQueueSize()>0;if(!e&&!t)return;await this.triggerHarvest({})}catch(e){l.A.error("Error during scheduled harvest:",e.message)}finally{this.scheduleNextHarvest()}}async triggerHarvest(e={}){if(this.isHarvesting)return{success:!1,reason:"harvest_in_progress"};this.isHarvesting=!0;try{let t=this.drainEvents(e);if(e.isFinalHarvest){const e=d.A.MAX_BEACON_SIZE;(0,n.Q3)(t)>e&&(t=this.trimEventsToFit(t,e))}const i=await this.sendChunk(t,e,!0);return{success:i.success,totalChunks:1,results:[i]}}catch(e){return l.A.error("Harvest cycle failed:",e.message),this.handleHarvestFailure(e),{success:!1,error:e.message,consecutiveFailures:this.consecutiveFailures}}finally{this.isHarvesting=!1}}trimEventsToFit(e,t){if(0===e.length)return e;const i=[];let s=0;for(let a=e.length-1;a>=0;a--){const r=e[a],d=(0,n.Q3)({ins:[r,...i]});d>t||(i.unshift(r),s=d)}const a=e.length-i.length;if(a>0){const r=e.slice(0,a);l.A.warn(`Discarded ${a} events to fit beacon size limit`,{originalCount:e.length,trimmedCount:i.length,finalSize:s,maxSize:t}),this.retryQueueHandler&&this.retryQueueHandler.addFailedEvents(r)}return i}drainEvents(e={}){const t=window.NRVIDEO?.config?.qoeIntervalFactor??1,i=!!e.isFinalHarvest||this.forceNextQoeCycle,s=(this.qoeCycleCount-1)%t==0||i;if(this.forceNextQoeCycle&&(this.forceNextQoeCycle=!1),this.beforeDrainCallback&&"function"==typeof this.beforeDrainCallback)try{this.beforeDrainCallback()}catch(e){l.A.error("Before drain callback failed:",e.message)}const a=this.eventBuffer.drain();let r;if(s)r=a;else{r=[];for(const e of a)e.actionName===o.A.Events.QOE_AGGREGATE?this.eventBuffer.add(e):r.push(e)}this.qoeCycleCount++;for(let e=r.length-1;e>=0;e--){const t=r[e];t.actionName===o.A.Events.QOE_AGGREGATE&&(!i&&this._qoeKpisUnchanged(t)?r.splice(e,1):this._saveQoeKpis(t))}let h=[...r],u=(0,n.Q3)(r);if(this.retryQueueHandler&&this.retryQueueHandler.getQueueSize()>0){const e=d.A.MAX_PAYLOAD_SIZE-u,t=d.A.MAX_EVENTS_PER_BATCH-h.length;if(e>0&&t>0){const i=this.retryQueueHandler.getRetryEventsToFit(e,t);i.length>0&&(h=[...i,...h])}}return h}async sendChunk(e,t,i){const s={url:(0,n.c$)(this.fallBackUrl),payload:{body:{ins:e}},options:{...t,isLastChunk:i}};return new Promise(t=>{this.httpClient.send(s,i=>{i.retry?this.handleRequestFailure(e):(this.retryCount=0,this.fallBackUrl=""),t({success:!i.retry,status:i.status,error:i.error,chunk:e,eventCount:e.length})})})}handleRequestFailure(e){this.retryQueueHandler.addFailedEvents(e),"US"===window.NRVIDEO?.info?.region&&(this.retryCount++,this.retryCount>5?(this.retryCount=0,this.fallBackUrl=""):this.retryCount>=2&&(this.fallBackUrl=d.A.COLLECTOR.US[1]))}handleHarvestFailure(e){this.consecutiveFailures++,l.A.warn("Harvest failure handled",{error:e.message,consecutiveFailures:this.consecutiveFailures})}updateHarvestInterval(e){"number"!=typeof e&&isNaN(e)?l.A.warn("Invalid newInterval provided to updateHarvestInterval"):e<1e3||e>3e5?l.A.warn("newInterval out of bounds (1000-300000), ignoring"):this.harvestCycle!==e&&(this.harvestCycle=e,l.A.notice("Updated harvestCycle:",this.harvestCycle),this.currentTimerId&&(clearTimeout(this.currentTimerId),this.currentTimerId=null),this.isStarted&&this.scheduleNextHarvest())}setupPageLifecycleHandlers(){let e=!1;const t=()=>{e||(e=!0,this.triggerHarvest({isFinalHarvest:!0,force:!0}))};document.addEventListener("visibilitychange",()=>{document.hidden&&t()}),window.addEventListener("pagehide",()=>{t()}),window.addEventListener("beforeunload",()=>{t()})}_qoeKpisUnchanged(e){const t=this._lastSentQoeKpis[e.viewId];if(!t)return!1;for(const i of d.A.QOE_KPI_KEYS)if(e[i]!==t[i])return!1;return!0}_saveQoeKpis(e){const t={};for(const i of d.A.QOE_KPI_KEYS)t[i]=e[i];this._lastSentQoeKpis[e.viewId]=t}}},144(e,t,i){i.d(t,{A:()=>d});class s{static error(...e){a(e,s.Levels.ERROR,"darkred")}static warn(...e){a(e,s.Levels.WARNING,"darkorange")}static notice(...e){a([].slice.call(arguments),s.Levels.NOTICE,"darkcyan")}static debug(...e){a(e,s.Levels.DEBUG,"indigo")}static debugCommonVideoEvents(e,t,i){try{if(s.level<=s.Levels.DEBUG){i=i||function(e){s.debug("Event: "+e.type)};var a=["canplay","buffering","waiting","ended","play","playing","pause","resume","error","abort","seek","seeking","seeked","stalled","dispose","loadeddata","loadstart","loadedmetadata"];t&&(null===t[0]?(t.shift(),a=t):a=a.concat(t));for(var r=0;r<a.length;r++)"function"==typeof e?e.call(window,a[r],i):e.on?e.on(a[r],i):e.addEventListener?e.addEventListener(a[r],i):e.addEventHandler?e.addEventHandler(a[r],i):s.warn("debugCommonVideoEvents: No common listener function found for ",e)}}catch(e){s.warn(e)}}}function a(e,t,i){t=t||s.Levels.NOTICE,i=i||"darkcyan";var a,d,o=s.prefix;s.includeTime&&(o+="["+("0"+(a=new Date).getDate()).slice(-2)+":"+("0"+a.getMinutes()).slice(-2)+":"+("0"+a.getSeconds()).slice(-2)+"."+("00"+a.getMilliseconds()).slice(-3)+"] "),o+=function(e){return n[e]}(t)+":",s.level<=t&&t!==s.Levels.SILENT&&(!s.colorful||"undefined"!=typeof document&&document.documentMode?r(e,o):(d=t===s.Levels.ERROR&&console.error?console.error:t===s.Levels.WARNING&&console.warn?console.warn:t===s.Levels.DEBUG&&console.debug&&null==window.cast?console.debug:console.log,o="%c"+o,e.splice(0,0,o,"color: "+i),d.apply(console,e)))}function r(e,t){if(e instanceof Array)for(var i in e)r(e[i],t);else"string"==typeof e?console.log(t+" "+e):(console.log(t+"↵"),console.log(e))}s.Levels={SILENT:5,ERROR:4,WARNING:3,NOTICE:2,DEBUG:1,ALL:0},s.level=s.Levels.ERROR,s.colorful=!0,s.includeTime=!0,s.prefix="[nrvideo]";const n={4:"e",3:"w",2:"n",1:"d"};!function(){if("undefined"!=typeof window&&window.location&&window.location.search){var e=/\?.*&*nrvideo-debug=(.+)/i.exec(window.location.search);null!==e&&("true"===e[1]?s.level=s.Levels.ALL:s.level=e[1]),null!==/\?.*&*nrvideo-colors=false/i.exec(window.location.search)&&(s.colorful=!1)}}();const d=s},481(e,t,i){i.d(t,{X:()=>r});var s=i(347),a=i(144);class r{async send(e,t){const{url:i,payload:s,options:r={}}=e;try{if(!i||!s)throw new Error("URL and payload are required");const e={url:i,payload:s,options:r,callback:t};await this.executeRequest(e)}catch(e){a.A.error("Failed to send request:",e.message),t({retry:!1,status:0,error:e.message})}}async executeRequest(e){const{url:t,payload:i,options:s,callback:r}=e,n=Date.now();try{const r=(d=JSON.stringify(i.body),o=window.NRVIDEO?.config?.obfuscate,o&&0!==o.length?o.reduce((e,t)=>{let i;try{if(t.regex instanceof RegExp){const e=t.regex.flags.includes("g")?t.regex.flags:t.regex.flags+"g";i=new RegExp(t.regex.source,e)}else i=new RegExp(t.regex,"g")}catch(i){return a.A.warn("applyObfuscationRules: invalid regex, skipping rule:",t.regex,i.message),e}return e.replace(i,t.replacement)},d):d);if(s.isFinalHarvest&&navigator.sendBeacon){const i=await this.sendWithBeacon(t,r),s={success:i,status:i?204:0};return void this.handleRequestComplete(e,s,n)}const l=await this.fetchWithTimeout(t,{method:"POST",body:r,headers:{"Content-Type":"application/json"},keepalive:s.isFinalHarvest},1e4),h={success:l.ok,status:l.status,statusText:l.statusText};this.handleRequestComplete(e,h,n)}catch(t){const i={success:!1,status:0,error:t.message};this.handleRequestComplete(e,i,n)}var d,o}handleRequestComplete(e,t){const{callback:i}=e;i({retry:!t.success&&(0===t.status||(0,s.Sc)(t.status)),status:t.status,error:t.error})}async sendWithBeacon(e,t){try{return navigator.sendBeacon(e,t)}catch(e){return a.A.warn("sendBeacon failed, falling back to fetch:",e.message),!1}}async fetchWithTimeout(e,t,i){const s=new AbortController,a=setTimeout(()=>s.abort(),i);try{const i=await fetch(e,{...t,signal:s.signal});return clearTimeout(a),i}catch(e){if(clearTimeout(a),"AbortError"===e.name)throw new Error(`Request timeout after ${i}ms`);throw e}}}},413(e,t,i){i.d(t,{u:()=>o});var s=i(144),a=i(347),r=i(51);const{MAX_PAYLOAD_SIZE:n,MAX_EVENTS_PER_BATCH:d}=r.A;class o{constructor(){this.retryQueue=[],this.maxQueueSize=d,this.maxQueueSizeBytes=n}addFailedEvents(e){try{const t=Array.isArray(e)?e:[e];s.A.notice(`Adding ${t.length} failed events to retry queue`,{queueSizeBefore:this.retryQueue.length});for(const e of t){this.retryQueue.length>=this.maxQueueSize&&this.evictOldestEvent();const t=(0,a.Q3)(e);for(;(0,a.Q3)(this.retryQueue)+t>this.maxQueueSizeBytes;)this.evictOldestEvent();this.retryQueue.push({...e})}}catch(e){s.A.error("Failed to add events to retry queue:",e.message)}}discardEvent(e,t){s.A.warn("Discarded event",{reason:t,eventType:e.eventType})}evictOldestEvent(){if(this.retryQueue.length>0){const e=this.retryQueue.shift();this.discardEvent(e,"Queue full - evicted oldest")}}getRetryEventsToFit(e,t){const i=[];let s=0,r=0;for(let n=this.retryQueue.length-1;n>=0;n--){const d=this.retryQueue[n];if(r>=t)break;const o=(0,a.Q3)(d);if(s+o>e)break;i.unshift(d),s+=o,r++,this.retryQueue.splice(n,1)}return i}getQueueSize(){return this.retryQueue.length}clear(){this.retryQueue=[]}}},302(e,t,i){i.d(t,{A:()=>h});var s=i(330),a=i(568),r=i(455),n=i(51),d=i(487),o=i(144);class l extends a.A{constructor(e){super(),this.customData={},this.heartbeat=null,this.parentTracker=null,this._trackerReadyChrono=new r.A,this._trackerReadyChrono.start(),this._actionTable=n.A.ACTION_TABLE,this._actionAdTable=n.A.ACTION_AD_TABLE,e=e||{},this.setOptions(e)}setOptions(e){e&&(e.parentTracker&&(this.parentTracker=e.parentTracker),e.customData&&(this.customData=e.customData),e.heartbeat&&(this.heartbeat=e.heartbeat))}dispose(){this.unregisterListeners()}registerListeners(){}unregisterListeners(){}getHeartbeat(){return this.state._isAd?2e3:this.heartbeat?this.heartbeat:this.parentTracker&&this.parentTracker.heartbeat?this.parentTracker.heartbeat:3e4}startHeartbeat(){this._heartbeatInterval=setInterval(this.sendHeartbeat.bind(this),Math.max(this.getHeartbeat(),2e3))}stopHeartbeat(){this._heartbeatInterval&&clearInterval(this._heartbeatInterval)}sendHeartbeat(e){this.sendVideoAction(l.Events.HEARTBEAT,e)}getAttributes(e,t){(e=e||{}).trackerName=this.getTrackerName(),e.trackerVersion=this.getTrackerVersion(),e.coreVersion=s.rE,e.timeSinceTrackerReady=this._trackerReadyChrono.getDeltaTime();for(let t in this.customData)e[t]=this.customData[t];return null!=document.hidden&&(e.isBackgroundEvent=document.hidden),e}getTrackerVersion(){return s.rE}getTrackerName(){return"base-tracker"}sendVideoAction(e,t){this.emit("VideoAction",e,this.getAttributes(t))}sendVideoAdAction(e,t){this.emit("VideoAdAction",e,this.getAttributes(t))}sendVideoErrorAction(e,t){let i=this.isAd()?"adError":"videoError";this.emit("VideoErrorAction",e,this.getAttributes(t,i))}sendVideoCustomAction(e,t){this.emit("VideoCustomAction",e,this.getAttributes(t,"customAction"))}setHarvestInterval(e){if(d.videoAnalyticsHarvester)try{d.videoAnalyticsHarvester.setHarvestInterval(e)}catch(e){return void o.A.error("Failed to set harvest interval:",e.message)}else o.A.error("VideoAnalyticsHarvester is not available")}}l.Events={HEARTBEAT:"HEARTBEAT",QOE_AGGREGATE:"QOE_AGGREGATE"};const h=l},347(e,t,i){i.d(t,{Q3:()=>n,Sc:()=>d,c$:()=>r,z8:()=>o});var s=i(330),a=i(144);function r(e){try{if(!window.NRVIDEO||!window.NRVIDEO.info)throw new Error("NRVIDEO info is not available.");let{beacon:t,licenseKey:i,applicationID:a}=window.NRVIDEO.info;if(!t||!i)throw new Error("Options object provided by New Relic is not correctly initialized");return a?`https://${e||t}/ins/1/${i}?a=${a}&v=${s.rE}&ref=${window.location.href}&ca=VA`:`https://${e||t}/ins/1/${i}?&v=${s.rE}&ref=${window.location.href}&ca=VA`}catch(e){return console.error(e.message),null}}function n(e){if("string"==typeof e&&e.length)return e.length;if("object"==typeof e){if("undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer&&e.byteLength)return e.byteLength;if("undefined"!=typeof Blob&&e instanceof Blob&&e.size)return e.size;if(!("undefined"!=typeof FormData&&e instanceof FormData))try{return function(e){try{return JSON.stringify(e,(()=>{const e=new WeakSet;return(t,i)=>{if("object"==typeof i&&null!==i){if(e.has(i))return;e.add(i)}return i}})())??""}catch(e){return a.A.error("Error stringifying value:",e.message),""}}(e).length}catch(e){return}}}function d(e){switch(e){case 408:case 429:case 500:return!0;case 401:case 403:case 404:return!1}return e>=502&&e<=504||e>=512&&e<=530}function o(e,t){return e&&Array.isArray(e)&&0!==e.length?t&&"object"==typeof t?e.reduce((e,i)=>(i in t&&(e[i]=t[i]),e),{}):{}:t}},330(e){e.exports={rE:"4.1.7"}}},a={};function r(e){var t=a[e];if(void 0!==t)return t.exports;var i=a[e]={exports:{}};return s[e](i,i.exports,r),i.exports}r.d=(e,t)=>{for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var n=r(144),d=r(487),o=r(51),l=r(302),h=r(347);function u(e,t={}){try{if(!o.A.VALID_EVENT_TYPES.includes(e))return n.A.warn("Invalid event type provided to recordEvent",{eventType:e}),!1;if(!window?.NRVIDEO?.info)return;const{appName:i,applicationID:s}=window.NRVIDEO.info,{qoe:a,...r}=t,u=a?{...a}:{},c={...s?{}:{appName:i},timestamp:Date.now(),timeSinceLoad:window.performance?window.performance.now()/1e3:null},g={...r,eventType:e,...c},m=(0,h.z8)(o.A.QOE_AGGREGATE_KEYS,t);let A=null;"VideoAction"===e&&(A={eventType:"VideoAction",actionName:l.A.Events.QOE_AGGREGATE,qoeAggregateVersion:"1.0.0",...u,...m,...c});const T=d.videoAnalyticsHarvester.addEvent(g);if(A&&window?.NRVIDEO?.config?.qoeAggregate){const e=d.videoAnalyticsHarvester.addEvent(A);return T&&e}return T}catch(e){return n.A.error("Failed to record event:",e.message),!1}}const{COLLECTOR:c}=o.A,g=new class{setConfiguration(e,t){return!!this.validateRequiredFields(e)&&!!this.validateConfigFields(t)&&(this.initializeGlobalConfig(e,t),n.A.notice("Video analytics configuration initialized successfully"),!0)}validateRequiredFields(e){if(!e||"object"!=typeof e)return n.A.error("Configuration must be an object"),!1;const{licenseKey:t,appName:i,region:s,applicationID:a,beacon:r}=e;if(!t)return n.A.error("licenseKey is required"),!1;if(a){if(!r)return n.A.error("beacon is required when applicationID is provided"),!1;if(!Object.values(c).flatMap(e=>e).includes(r))return n.A.error(`Invalid beacon: ${r}`),!1}else{if(!i||!s)return n.A.error("appName and region are required when applicationID is not provided"),!1;if(!c[s])return n.A.error(`Invalid region: ${s}. Valid regions are: ${Object.keys(c).join(", ")}`),!1}return!0}validateConfigFields(e){if(null==e)return!0;if("object"!=typeof e||Array.isArray(e))return n.A.error("config must be an object"),!1;const{qoeAggregate:t,obfuscate:i}=e;return void 0!==t&&"boolean"!=typeof t?(n.A.error("qoeAggregate must be a boolean"),!1):!(void 0!==i&&!Array.isArray(i)&&(n.A.error("obfuscate must be an array"),1))}filterObfuscateRules(e){return e?e.filter(e=>{const t=void 0!==e.regex&&("string"==typeof e.regex||e.regex instanceof RegExp),i=void 0!==e.replacement&&"string"==typeof e.replacement;return!(!t||!i)||(n.A.warn("obfuscate rule missing required 'regex' (string|RegExp) and/or 'replacement' (string), skipping:",e),!1)}):[]}sanitizeQoeIntervalFactor(e){return null==e?2:"number"==typeof e&&Number.isInteger(e)&&e>=1?e:(n.A.warn(`Invalid qoeIntervalFactor "${e}" — must be a positive integer. Defaulting to 2.`),2)}initializeGlobalConfig(e,t){let{licenseKey:i,appName:s,region:a,beacon:r,applicationID:n}=e;r="US"===a?o.A.COLLECTOR.US[0]:r||c[a],window.NRVIDEO={info:{...a?{region:a}:{},beacon:r,licenseKey:i,applicationID:n,...n?{}:{appName:s}},config:{qoeAggregate:t?.qoeAggregate??!0,qoeIntervalFactor:this.sanitizeQoeIntervalFactor(t?.qoeIntervalFactor),obfuscate:this.filterObfuscateRules(t?.obfuscate)}}}};class m{static addTracker(e,t){var i,s;t?.info&&(i=t.info,s=t?.config,g.setConfiguration(i,s)),e.on&&e.emit?(A.push(e),e.on("*",T),"function"==typeof e.trackerInit&&e.trackerInit()):n.A.error("Tried to load a non-tracker.",e)}static removeTracker(e){e.off("*",T),e.dispose();let t=A.indexOf(e);-1!==t&&A.splice(t,1)}static getTrackers(){return A}static send(e,t,i){return u(e,{actionName:t,...i})}static sendError(e){return u("VideoErrorAction",{actionName:"ERROR",...e})}static async forceHarvest(){try{const{videoAnalyticsHarvester:e}=r(487);return await e.forceHarvest()}catch(e){return n.A.error("Failed to force harvest:",e.message),{success:!1,error:e.message}}}}let A=[];function T(e){try{let t=function(e){let t={};for(let i in e)null!==e[i]&&void 0!==e[i]&&(t[i]=e[i]);return t}(e.data);n.A.level<=n.A.Levels.DEBUG?n.A.notice("Sent",e.type,t):n.A.notice("Sent",e.type),m.send(e.eventType,e.type,t)}catch(e){n.A.error("Error in event handler:",e.message)}}const p=m;var f=r(455),E=r(568);const S=class{constructor(){this.reset(),this._createdAt=Date.now(),this._hb=!0,this._acc=0,this._bufferAcc=0}reset(){this._viewSession=null,this._viewCount=0,this._isAd=!1,this.numberOfErrors=0,this.numberOfAds=0,this.numberOfVideos=0,this.totalPlaytime=0,this.weightedAverageBitrate=0,this.totalAdPlaytime=0,this.isAdBreak=!1,this.initialBufferingHappened=!1,this.startupTime=null,this.peakBitrate=0,this._lastBitrate=null,this._lastBitrateChangeTimestamp=null,this.partialAverageBitrate=0,this._totalBitrateDuration=0,this.hadStartupError=!1,this.hadPlaybackError=!1,this.totalRebufferingTime=0,this.resetFlags(),this.resetChronos()}resetFlags(){this.isPlayerReady=!1,this.isRequested=!1,this.isStarted=!1,this.isPaused=!1,this.isSeeking=!1,this.isBuffering=!1,this.isPlaying=!1}resetChronos(){this.timeSinceRequested=new f.A,this.timeSinceStarted=new f.A,this.timeSincePaused=new f.A,this.timeSinceSeekBegin=new f.A,this.timeSinceBufferBegin=new f.A,this.timeSinceAdBreakStart=new f.A,this.timeSinceLastDownload=new f.A,this.timeSinceLastHeartbeat=new f.A,this.timeSinceLastRenditionChange=new f.A,this.timeSinceLastAdQuartile=new f.A,this.timeSinceLastAd=new f.A,this.timeSinceLastError=new f.A,this.timeSinceLastAdError=new f.A,this.timeSinceResumed=new f.A,this.timeSinceSeekEnd=new f.A,this.playtimeSinceLastEvent=new f.A,this.customTimeSinceAttributes={},this.elapsedTime=new f.A,this.bufferElapsedTime=new f.A,this._totalAdPlaytime=new f.A}isAd(){return this._isAd}setIsAd(e){this._isAd=e}setTimeSinceAttribute(e){this.customTimeSinceAttributes[e]=new f.A,this.customTimeSinceAttributes[e].start()}removeTimeSinceAttribute(e){delete this.customTimeSinceAttributes[e]}getViewSession(){if(!this._viewSession){let e=(new Date).getTime(),t=Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2);this._viewSession=e+"-"+t}return this._viewSession}getViewId(){return this.getViewSession()+"-"+this._viewCount}getStateAttributes(e){e=e||{},this.isAd()?(this.isRequested&&(e.timeSinceAdRequested=this.timeSinceRequested.getDeltaTime(),e.timeSinceLastAdHeartbeat=this.timeSinceLastHeartbeat.getDeltaTime()),this.isStarted&&(e.timeSinceAdStarted=this.timeSinceStarted.getDeltaTime()),this.isPaused&&(e.timeSinceAdPaused=this.timeSincePaused.getDeltaTime()),this.isBuffering&&(e.timeSinceAdBufferBegin=this.timeSinceBufferBegin.getDeltaTime()),this.isSeeking&&(e.timeSinceAdSeekBegin=this.timeSinceSeekBegin.getDeltaTime()),this.isAdBreak&&(e.timeSinceAdBreakBegin=this.timeSinceAdBreakStart.getDeltaTime()),this.numberOfErrors>0&&this.timeSinceLastAdError.startTime>0&&(e.timeSinceLastAdError=this.timeSinceLastAdError.getDeltaTime()),e.numberOfAds=this.numberOfAds):(this.isRequested&&(e.timeSinceRequested=this.timeSinceRequested.getDeltaTime(),e.timeSinceLastHeartbeat=this.timeSinceLastHeartbeat.getDeltaTime()),this.isStarted&&(e.timeSinceStarted=this.timeSinceStarted.getDeltaTime()),this.isPaused&&(e.timeSincePaused=this.timeSincePaused.getDeltaTime()),this.isBuffering&&(e.timeSinceBufferBegin=this.timeSinceBufferBegin.getDeltaTime()),this.isSeeking&&(e.timeSinceSeekBegin=this.timeSinceSeekBegin.getDeltaTime()),e.timeSinceLastAd=this.timeSinceLastAd.getDeltaTime(),this.numberOfErrors>0&&this.timeSinceLastError.startTime>0&&(e.timeSinceLastError=this.timeSinceLastError.getDeltaTime()),e.numberOfVideos=this.numberOfVideos),e.numberOfErrors=this.numberOfErrors,this.isAd()||(this.playtimeSinceLastEvent.startTime>0?e.playtimeSinceLastEvent=this.playtimeSinceLastEvent.getDeltaTime():e.playtimeSinceLastEvent=0,this.isPlaying?this.playtimeSinceLastEvent.start():this.playtimeSinceLastEvent.reset(),this.totalPlaytime+=e.playtimeSinceLastEvent,e.totalPlaytime=this.totalPlaytime);for(const[t,i]of Object.entries(this.customTimeSinceAttributes))e[t]=i.getDeltaTime();return e}getQoeAttributes(e){e=e||{};const t={};try{null!==this.startupTime&&(t.startupTime=this.startupTime),this.peakBitrate>0&&(t.peakBitrate=this.peakBitrate),t.hadStartupError=this.hadStartupError,t.hadPlaybackError=this.hadPlaybackError,t.totalRebufferingTime=this.totalRebufferingTime,t.rebufferingRatio=this.totalPlaytime>0?this.totalRebufferingTime/this.totalPlaytime*100:0,t.totalPlaytime=this.totalPlaytime,t.averageBitrate=this.weightedBitrate,t.numberOfErrors=this.numberOfErrors}catch(e){n.A.error("Failed to add attributes for QOE KPIs",e.message)}return e.qoe=t,e}calculateBufferType(e){let t="";return t=e?"initial":this.isSeeking?"seek":this.isPaused?"pause":"connection",n.A.debug("Buffer Type = "+t),t}goViewCountUp(){this._viewCount++}goPlayerReady(){return!this.isPlayerReady&&(this.isPlayerReady=!0,!0)}goRequest(){return!this.isRequested&&(this.isRequested=!0,this.timeSinceLastAd.reset(),this.timeSinceRequested.start(),!0)}goStart(){return!(!this.isRequested||this.isStarted||(this.isAd()?this.numberOfAds++:this.numberOfVideos++,this.isStarted=!0,this.isPlaying=!0,this.timeSinceStarted.start(),this.playtimeSinceLastEvent.start(),0))}goEnd(){return!!this.isRequested&&(this.numberOfErrors=0,this.resetFlags(),this.timeSinceRequested.stop(),this.timeSinceStarted.stop(),this.playtimeSinceLastEvent.stop(),this.isPlaying=!1,!0)}goPause(){return!(!this.isStarted||this.isPaused||(this.isPaused=!0,this.isPlaying=!1,this.timeSincePaused.start(),this.playtimeSinceLastEvent.stop(),this.timeSinceResumed.reset(),this.isBuffering&&(this._bufferAcc+=this.bufferElapsedTime.getDeltaTime()),this.elapsedTime.start(),0))}goResume(){return!(!this.isStarted||!this.isPaused||(this.isPaused=!1,this.isPlaying=!0,this.timeSincePaused.stop(),this.timeSinceResumed.start(),this._hb?(this._acc=this.elapsedTime.getDeltaTime(),this._hb=!1):(this.isBuffering&&this.bufferElapsedTime.start(),this._acc+=this.elapsedTime.getDeltaTime()),0))}goBufferStart(){return!(!this.isRequested||this.isBuffering||(this.isBuffering=!0,this.isPlaying=!1,this.timeSinceBufferBegin.start(),this.bufferElapsedTime.start(),0))}goBufferEnd(){return!(!this.isRequested||!this.isBuffering||(this.isBuffering=!1,this.isPlaying=!0,this.timeSinceBufferBegin.stop(),this._hb?(this._bufferAcc=this.bufferElapsedTime.getDeltaTime(),this._hb=!1):this._bufferAcc+=this.bufferElapsedTime.getDeltaTime(),!this.isAd()&&this.initialBufferingHappened&&(this.totalRebufferingTime+=this.timeSinceBufferBegin.stopTime-this.timeSinceBufferBegin.startTime),0))}goSeekStart(){return!(!this.isStarted||this.isSeeking||(this.isSeeking=!0,this.isPlaying=!1,this.timeSinceSeekBegin.start(),this.timeSinceSeekEnd.reset(),0))}goSeekEnd(){return!(!this.isStarted||!this.isSeeking||(this.isSeeking=!1,this.isPlaying=!0,this.timeSinceSeekBegin.stop(),this.timeSinceSeekEnd.start(),0))}goAdBreakStart(){return!this.isAdBreak&&(this.isAdBreak=!0,this.timeSinceAdBreakStart.start(),!0)}goAdBreakEnd(){return!!this.isAdBreak&&(this.isRequested=!1,this.isAdBreak=!1,this.totalAdPlaytime=this.timeSinceAdBreakStart.getDeltaTime(),this.timeSinceAdBreakStart.stop(),!0)}goDownload(){this.timeSinceLastDownload.start()}goHeartbeat(){this.timeSinceLastHeartbeat.start()}goRenditionChange(){this.timeSinceLastRenditionChange.start()}goAdQuartile(){this.timeSinceLastAdQuartile.start()}goError(){this.isError=!0,this.numberOfErrors++,this.isAd()?this.timeSinceLastAdError.start():(this.timeSinceLastError.start(),this.isStarted?this.hadPlaybackError=!0:this.hadStartupError=!0)}goLastAd(){this.timeSinceLastAd.start()}trackContentBitrateState(e){if(e&&"number"==typeof e){this.peakBitrate=Math.max(this.peakBitrate,e);const t=Date.now();if(!this.isPlaying){if(null!==this._lastBitrate&&null!==this._lastBitrateChangeTimestamp){const e=t-this._lastBitrateChangeTimestamp;e>0&&(this.partialAverageBitrate+=this._lastBitrate*e,this._totalBitrateDuration+=e),this._lastBitrateChangeTimestamp=null}return void(this._lastBitrate=e)}if(null===this._lastBitrateChangeTimestamp&&null!==this._lastBitrate&&(this._lastBitrateChangeTimestamp=t),null!==this._lastBitrate&&this._lastBitrate!==e&&null!==this._lastBitrateChangeTimestamp){const e=t-this._lastBitrateChangeTimestamp;e>0&&(this.partialAverageBitrate+=this._lastBitrate*e,this._totalBitrateDuration+=e),this._lastBitrateChangeTimestamp=t}null===this._lastBitrateChangeTimestamp&&(this._lastBitrateChangeTimestamp=t),this._lastBitrate=e;let i=this.partialAverageBitrate,s=this._totalBitrateDuration;const a=t-this._lastBitrateChangeTimestamp;a>0&&(i+=e*a,s+=a),this.weightedBitrate=s>0?Math.round(i/s):e}}resetViewIdTrackedState(){this.peakBitrate=0,this.partialAverageBitrate=0,this._totalBitrateDuration=0,this.startupTime=null,this._lastBitrate=null,this._lastBitrateChangeTimestamp=null}clearTotalAdsTime(){n.A.debug("clear total ads time",this.totalAdTime),this._totalAdPlaytime.reset()}totalAdTime(){return this._totalAdPlaytime.getDuration()}startAdsTime(){return n.A.debug("startAdsTime"),this._totalAdPlaytime.start()}stopAdsTime(){return n.A.debug("stopAdsTime"),this._totalAdPlaytime.stop()}setStartupTime(e){null===this.startupTime&&(this.startupTime=Math.max(this.timeSinceRequested.getDeltaTime()-e,0))}};var y=r(330);class v extends l.A{constructor(e,t){super(),this.state=new S,this.adsTracker=null,this._lastBufferType=null,this._userId=null,t=t||{},this.setOptions(t),e&&this.setPlayer(e,t.tag),n.A.notice("Tracker "+this.getTrackerName()+" v"+this.getTrackerVersion()+" is ready.")}setUserId(e){this._userId=e}setOptions(e){e&&(e.adsTracker&&this.setAdsTracker(e.adsTracker),"boolean"==typeof e.isAd&&this.setIsAd(e.isAd),l.A.prototype.setOptions.apply(this,arguments))}setPlayer(e,t){(this.player||this.tag)&&this.dispose(),"undefined"!=typeof document&&document.getElementById&&("string"==typeof e&&(e=document.getElementById(e)),"string"==typeof t&&(t=document.getElementById(t))),t=t||e,this.player=e,this.tag=t,this.registerListeners()}isAd(){return this.state.isAd()}setIsAd(e){this.state.setIsAd(e)}setAdsTracker(e){this.disposeAdsTracker(),e&&(this.adsTracker=e,this.adsTracker.setIsAd(!0),this.adsTracker.parentTracker=this,this.adsTracker.on("*",_.bind(this)))}disposeAdsTracker(){this.adsTracker&&(this.adsTracker.off("*",_),this.adsTracker.dispose())}dispose(){this.stopHeartbeat(),this.disposeAdsTracker(),this.unregisterListeners(),this.player=null,this.tag=null}registerListeners(){}unregisterListeners(){}getViewId(){return this.parentTracker?this.parentTracker.getViewId():this.state.getViewId()}getViewSession(){return this.parentTracker?this.parentTracker.getViewSession():this.state.getViewSession()}getVideoId(){return null}getTitle(){return null}isLive(){return null}getBitrate(){return null}getManifestBitrate(){return null}getSegmentDownloadBitrate(){return null}getNetworkDownloadBitrate(){return null}getWebkitBitrate(){if(this.tag&&this.tag.webkitVideoDecodedByteCount){let e;if(this._lastWebkitBitrate){e=this.tag.webkitVideoDecodedByteCount;let t=e-this._lastWebkitBitrate,i=this.getHeartbeat()/1e3;e=Math.round(t/i*8)}return this._lastWebkitBitrate=this.tag.webkitVideoDecodedByteCount,e||null}}getRenditionName(){return null}getRenditionBitrate(){return null}getRenditionShift(e){let t,i=this.getRenditionBitrate();return this.isAd()?(t=this._lastAdRendition,e&&(this._lastAdRendition=i)):(t=this._lastRendition,e&&(this._lastRendition=i)),i&&t?i>t?"up":i<t?"down":null:null}getRenditionHeight(){return this.tag?this.tag.videoHeight:null}getRenditionWidth(){return this.tag?this.tag.videoWidth:null}getDuration(){return this.tag?this.tag.duration:null}getPlayhead(){return this.tag?this.tag.currentTime:null}getLanguage(){return null}getSrc(){return this.tag?this.tag.currentSrc:null}getPlayrate(){return this.tag?this.tag.playbackRate:null}isMuted(){return this.tag?this.tag.muted:null}isFullscreen(){return null}getCdn(){return null}getPlayerName(){return this.getTrackerName()}getPlayerVersion(){return y.rE}getFps(){return null}isAutoplayed(){return this.tag?this.tag.autoplay:null}getPreload(){return this.tag?this.tag.preload:null}getAdQuartile(){return null}getAdPosition(){return this.parentTracker?this.parentTracker.state.isStarted?"mid":"pre":null}getAdPartner(){return null}getAdCreativeId(){return null}getInstrumentationProvider(){return null}getInstrumentationName(){return null}getInstrumentationVersion(){return null}getAttributes(e,t){if(void 0===(e=l.A.prototype.getAttributes.apply(this,arguments)).isAd&&(e.isAd=this.isAd()),e.viewSession=this.getViewSession(),e.viewId=this.getViewId(),e.playerName=this.getPlayerName(),e.playerVersion=this.getPlayerVersion(),e["instrumentation.provider"]=this.getInstrumentationProvider(),e["instrumentation.name"]=this.getInstrumentationName(),e["instrumentation.version"]=this.getInstrumentationVersion(),e["enduser.id"]=this._userId,e.src="Browser","customAction"===t)return e;try{e.pageUrl=window.location.href}catch(e){}this.isAd()?(e.adId=this.getVideoId(),e.adTitle=this.getTitle(),e.adSrc=this.getSrc(),e.adCdn=this.getCdn(),this.state.isStarted&&(e.adBitrate=this.getBitrate()||0),e.adRenditionName=this.getRenditionName(),e.adRenditionHeight=this.getRenditionHeight(),e.adRenditionWidth=this.getRenditionWidth(),e.adDuration=this.getDuration(),e.adPlayhead=this.getPlayhead(),e.adLanguage=this.getLanguage(),e.adIsMuted=this.isMuted(),e.adFps=this.getFps(),e.adPosition=this.getAdPosition(),e.adCreativeId=this.getAdCreativeId(),e.adPartner=this.getAdPartner()):(e.contentId=this.getVideoId(),e.contentTitle=this.getTitle(),e.contentSrc=this.getSrc(),e.contentCdn=this.getCdn(),e.contentPlayhead=this.getPlayhead(),e.contentIsLive=this.isLive(),this.state.isStarted&&(e.contentBitrate=this.getBitrate()||0,e.contentManifestBitrate=this.getManifestBitrate()||0,e.contentSegmentDownloadBitrate=this.getSegmentDownloadBitrate()||0,e.contentNetworkDownloadBitrate=this.getNetworkDownloadBitrate()||0),e.contentRenditionName=this.getRenditionName(),e.contentRenditionHeight=this.getRenditionHeight(),e.contentRenditionWidth=this.getRenditionWidth(),e.contentDuration=this.getDuration(),e.contentLanguage=this.getLanguage(),e.contentPlayrate=this.getPlayrate(),e.contentIsFullscreen=this.isFullscreen(),e.contentIsMuted=this.isMuted(),e.contentIsAutoplayed=this.isAutoplayed(),e.contentPreload=this.getPreload(),e.contentFps=this.getFps(),null!=this.adsTracker&&this.adsTracker.state.totalAdPlaytime>0&&(e.totalAdPlaytime=this.adsTracker.state.totalAdPlaytime)),this.state.getStateAttributes(e),this.state.isStarted&&!this.isAd()&&this.state.trackContentBitrateState(e.contentBitrate);for(let t in this.customData)e[t]=this.customData[t];return this.addQoeAttributes(e),e}addQoeAttributes(e){const t=(e=this.state.getQoeAttributes(e)).qoe;for(let e in this.customData)t[e]=this.customData[e]}sendCustom(e,t,i){i=i||{},this.sendVideoCustomAction(e,i),this.state.setTimeSinceAttribute(t)}sendPlayerReady(e){this.state.goPlayerReady()&&(e=e||{},this.sendVideoAction(v.Events.PLAYER_READY,e))}sendRequest(e){if(this.state.goRequest()){let t;this.isAd()?(t=v.Events.AD_REQUEST,this.sendVideoAdAction(t,e)):(t=v.Events.CONTENT_REQUEST,this.sendVideoAction(t,e))}}sendStart(e){if(this.state.goStart()){let t;if(this.isAd())t=v.Events.AD_START,this.parentTracker&&(this.parentTracker.state.isPlaying=!1),this.sendVideoAdAction(t,e),this.state.startAdsTime();else{t=v.Events.CONTENT_START;let i=0;this.adsTracker&&((this.adsTracker.state.isPlaying||this.adsTracker.state.isBuffering)&&(this.adsTracker.state.stopAdsTime(),this.adsTracker.state.isPlaying=!1,this.adsTracker.state.isBuffering=!1),i=this.adsTracker.state.totalAdTime()??0),this.state.setStartupTime(i),this.sendVideoAction(t,e),d.videoAnalyticsHarvester.setBeforeDrainCallback(()=>{if(this.state){const e=this.state.getQoeAttributes({}).qoe;d.videoAnalyticsHarvester.refreshQoeKpis(e,this.getViewId())}})}this.startHeartbeat(),this.state.goHeartbeat()}}sendEnd(e){if(this.state.goEnd()){let t;e=e||{},this.isAd()?(t=v.Events.AD_END,e.timeSinceAdRequested=this.state.timeSinceRequested.getDeltaTime(),e.timeSinceAdStarted=this.state.timeSinceStarted.getDeltaTime(),this.parentTracker&&(this.parentTracker.state.isPlaying=!0),this.state.stopAdsTime()):(t=v.Events.CONTENT_END,e.timeSinceRequested=this.state.timeSinceRequested.getDeltaTime(),e.timeSinceStarted=this.state.timeSinceStarted.getDeltaTime()),this.stopHeartbeat(),this.isAd()?this.sendVideoAdAction(t,e):this.sendVideoAction(t,e),this.parentTracker&&this.isAd()&&this.parentTracker.state.goLastAd(),this.state.goViewCountUp(),this.state.totalPlaytime=0,this.isAd()||(d.videoAnalyticsHarvester.forceNextQoeCycle(),d.videoAnalyticsHarvester.setBeforeDrainCallback(null),this.adsTracker&&this.adsTracker.state.clearTotalAdsTime(),this.state.resetViewIdTrackedState())}}sendPause(e){if(this.state.goPause()){let t=this.isAd()?v.Events.AD_PAUSE:v.Events.CONTENT_PAUSE;this.isAd()?this.sendVideoAdAction(t,e):this.sendVideoAction(t,e)}}sendResume(e){if(this.state.goResume()){let t;e=e||{},this.isAd()?(t=v.Events.AD_RESUME,e.timeSinceAdPaused=this.state.timeSincePaused.getDeltaTime()):(t=v.Events.CONTENT_RESUME,e.timeSincePaused=this.state.timeSincePaused.getDeltaTime()),this.isAd()?this.sendVideoAdAction(t,e):this.sendVideoAction(t,e)}}sendBufferStart(e){if(this.state.goBufferStart()){let t;e=e||{},t=this.isAd()?v.Events.AD_BUFFER_START:v.Events.CONTENT_BUFFER_START,e=this.buildBufferAttributes(e),this._lastBufferType=e.bufferType,this.isAd()?this.sendVideoAdAction(t,e):this.sendVideoAction(t,e)}}sendBufferEnd(e){if(this.state.goBufferEnd()){let t;e=e||{},this.isAd()?(t=v.Events.AD_BUFFER_END,e.timeSinceAdBufferBegin=this.state.timeSinceBufferBegin.getDeltaTime()):(t=v.Events.CONTENT_BUFFER_END,e.timeSinceBufferBegin=this.state.timeSinceBufferBegin.getDeltaTime()),e=this.buildBufferAttributes(e),null!=this._lastBufferType&&(e.bufferType=this._lastBufferType),this.isAd()?this.sendVideoAdAction(t,e):this.sendVideoAction(t,e),this.state.initialBufferingHappened=!0}}buildBufferAttributes(e){return null==e.timeSinceStarted||e.timeSinceStarted<100?e.isInitialBuffering=!this.state.initialBufferingHappened:e.isInitialBuffering=!1,e.bufferType=this.state.calculateBufferType(e.isInitialBuffering),e.timeSinceResumed=this.state.timeSinceResumed.getDeltaTime(),e.timeSinceSeekEnd=this.state.timeSinceSeekEnd.getDeltaTime(),e}sendSeekStart(e){if(this.state.goSeekStart()){let t;t=this.isAd()?v.Events.AD_SEEK_START:v.Events.CONTENT_SEEK_START,this.isAd()?this.sendVideoAdAction(t,e):this.sendVideoAction(t,e)}}sendSeekEnd(e){if(this.state.goSeekEnd()){let t;e=e||{},this.isAd()?(t=v.Events.AD_SEEK_END,e.timeSinceAdSeekBegin=this.state.timeSinceSeekBegin.getDeltaTime()):(t=v.Events.CONTENT_SEEK_END,e.timeSinceSeekBegin=this.state.timeSinceSeekBegin.getDeltaTime()),this.isAd()?this.sendVideoAdAction(t,e):this.sendVideoAction(t,e)}}sendDownload(e){(e=e||{}).state||n.A.warn("Called sendDownload without { state: xxxxx }."),this.sendVideoAction(v.Events.DOWNLOAD,e),this.state.goDownload()}sendError(e){(e=e||{}).isAd=this.isAd(),this.state.goError();let t=this.isAd()?v.Events.AD_ERROR:v.Events.CONTENT_ERROR;this.sendVideoErrorAction(t,e)}sendRenditionChanged(e){let t;(e=e||{}).timeSinceLastRenditionChange=this.state.timeSinceLastRenditionChange.getDeltaTime(),e.shift=this.getRenditionShift(!0),t=this.isAd()?v.Events.AD_RENDITION_CHANGE:v.Events.CONTENT_RENDITION_CHANGE,this.isAd()?this.sendVideoAdAction(t,e):this.sendVideoAction(t,e),this.state.goRenditionChange()}sendHeartbeat(e){if(this.state.isRequested){let t,i=this.getHeartbeat();this.state._hb=!0,i=this.adjustElapsedTimeForPause(i),this.isAd()?(t=v.Events.AD_HEARTBEAT,"bitmovin-ads"===this.getPlayerName()?this.sendVideoAdAction(t,e):this.sendVideoAdAction(t,{elapsedTime:i,...e})):(t=v.Events.CONTENT_HEARTBEAT,this.sendVideoAction(t,{elapsedTime:i,...e})),this.state.goHeartbeat()}}adjustElapsedTimeForPause(e){return this.state._acc&&(e-=this.state._acc,this.state._acc=0),this.state.isPaused&&((e-=this.state.elapsedTime.getDeltaTime())<10&&(e=0),this.state.elapsedTime.start()),this.state._bufferAcc?(e-=this.state._bufferAcc,this.state._bufferAcc=0):this.state.isBuffering&&((e-=this.state.bufferElapsedTime.getDeltaTime())<5&&(e=0),this.state.bufferElapsedTime.start()),Math.max(0,e)}sendAdBreakStart(e){this.isAd()&&this.state.goAdBreakStart()&&(this.state.totalAdPlaytime=0,this.parentTracker&&(this.parentTracker.state.isPlaying=!1),this.sendVideoAdAction(v.Events.AD_BREAK_START,e))}sendAdBreakEnd(e){this.isAd()&&this.state.goAdBreakEnd()&&((e=e||{}).timeSinceAdBreakBegin=this.state.timeSinceAdBreakStart.getDeltaTime(),this.sendVideoAdAction(v.Events.AD_BREAK_END,e),this.parentTracker&&(this.parentTracker.state.isPlaying=!0),this.stopHeartbeat(),this.parentTracker&&this.isAd()&&this.parentTracker.state.goLastAd())}sendAdQuartile(e){this.isAd()&&((e=e||{}).quartile||n.A.warn("Called sendAdQuartile without { quartile: xxxxx }."),e.timeSinceLastAdQuartile=this.state.timeSinceLastAdQuartile.getDeltaTime(),this.sendVideoAdAction(v.Events.AD_QUARTILE,e),this.state.goAdQuartile())}sendAdClick(e){this.isAd()&&((e=e||{}).url||n.A.warn("Called sendAdClick without { url: xxxxx }."),this.sendVideoAdAction(v.Events.AD_CLICK,e))}}function _(e){e.type!==v.Events.AD_ERROR?this.sendVideoAdAction(e.type,e.data):this.sendVideoErrorAction(e.type,e.data)}v.Events={PLAYER_READY:"PLAYER_READY",DOWNLOAD:"DOWNLOAD",ERROR:"ERROR",CONTENT_REQUEST:"CONTENT_REQUEST",CONTENT_START:"CONTENT_START",CONTENT_END:"CONTENT_END",CONTENT_PAUSE:"CONTENT_PAUSE",CONTENT_RESUME:"CONTENT_RESUME",CONTENT_SEEK_START:"CONTENT_SEEK_START",CONTENT_SEEK_END:"CONTENT_SEEK_END",CONTENT_BUFFER_START:"CONTENT_BUFFER_START",CONTENT_BUFFER_END:"CONTENT_BUFFER_END",CONTENT_HEARTBEAT:"CONTENT_HEARTBEAT",CONTENT_RENDITION_CHANGE:"CONTENT_RENDITION_CHANGE",CONTENT_ERROR:"CONTENT_ERROR",AD_REQUEST:"AD_REQUEST",AD_START:"AD_START",AD_END:"AD_END",AD_PAUSE:"AD_PAUSE",AD_RESUME:"AD_RESUME",AD_SEEK_START:"AD_SEEK_START",AD_SEEK_END:"AD_SEEK_END",AD_BUFFER_START:"AD_BUFFER_START",AD_BUFFER_END:"AD_BUFFER_END",AD_HEARTBEAT:"AD_HEARTBEAT",AD_RENDITION_CHANGE:"AD_RENDITION_CHANGE",AD_ERROR:"AD_ERROR",AD_BREAK_START:"AD_BREAK_START",AD_BREAK_END:"AD_BREAK_END",AD_QUARTILE:"AD_QUARTILE",AD_CLICK:"AD_CLICK"};const D=v;var k=r(431),b=r(413),I=r(481),R=r(374);const P={Constants:o.A,Chrono:f.A,Log:n.A,Emitter:E.A,Tracker:l.A,VideoTracker:D,VideoTrackerState:S,Core:p,version:y.rE,NrVideoEventAggregator:k.t,RetryQueueHandler:b.u,OptimizedHttpClient:I.X,HarvestScheduler:R.n,recordEvent:u}},64(e,t,i){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=r(i(555)),a=r(i(472));function r(e){return e&&e.__esModule?e:{default:e}}class n extends a.default{static isUsing(e){return!!e.ima3}getTrackerName(){return"brightcove-ima-ads"}getPlayerName(){return"brightcove-ima-ads"}getPlayhead(){return this.player?.ima3?.adPlayer?.currentTime()}registerListeners(){s.default.Log.debugCommonVideoEvents(this.player,[null,"ima3-ready","ima3error","ima3-ad-error","ima3-started","ima3-complete","ima3-paused","ima3-resumed","ads-request","ads-load","ads-ad-started","ads-ad-ended","ads-pause","ads-play","ads-click","ads-pod-started","ads-pod-ended","ads-allpods-completed"]),this.player.on("ima3-started",this.onStarted.bind(this)),this.player.on("ima3-paused",this.onPaused.bind(this)),this.player.on("ima3-resumed",this.onResume.bind(this)),this.player.on("ima3-complete",this.onComplete.bind(this)),this.player.on("ima3-skipped",this.onSkipped.bind(this)),this.player.on("adserror",this.onError.bind(this)),this.player.on("ads-click",this.onClick.bind(this))}unregisterListeners(){this.player.off("ima3-started",this.onStarted),this.player.off("ima3-paused",this.onPaused),this.player.off("ima3-resumed",this.onResume),this.player.off("ima3-complete",this.onComplete),this.player.off("ima3-skipped",this.onSkipped),this.player.off("adserror",this.onError),this.player.off("ads-click",this.onClick)}onStarted(e){this.sendRequest(),this.sendStart()}onPaused(e){this.sendPause()}onResume(e){this.sendResume()}onComplete(e){this.sendEnd()}onSkipped(e){this.sendEnd({skipped:!0})}onError(e){this.sendError()}onClick(e){this.sendClick()}}t.default=n},717(e,t,i){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=r(i(555)),a=r(i(472));function r(e){return e&&e.__esModule?e:{default:e}}const n={DAI_STREAM_INITIALIZED:"dai-stream-initialized",DAI_STREAM_LOADED:"dai-stream-loaded",DAI_STREAM_ERROR:"dai-stream-error",DAI_AD_BREAK_STARTED:"dai-ad-break-started",DAI_AD_BREAK_ENDED:"dai-ad-break-ended",DAI_AD_PERIOD_STARTED:"dai-ad-period-started",DAI_AD_PERIOD_ENDED:"dai-ad-period-ended",DAI_AD_STARTED:"dai-ad-started",DAI_AD_FIRST_QUARTILE:"dai-ad-first-quartile",DAI_AD_MIDPOINT:"dai-ad-midpoint",DAI_AD_THIRD_QUARTILE:"dai-ad-third-quartile",DAI_AD_COMPLETE:"dai-ad-complete",DAI_AD_SKIPPED:"dai-ad-skipped",DAI_AD_PAUSED:"dai-ad-paused",DAI_AD_RESUMED:"dai-ad-resumed",DAI_AD_CLICKED:"dai-ad-clicked",DAI_AD_ERROR:"dai-ad-error",DAI_CUEPOINTS_CHANGED:"dai-cuepoints-changed",DAI_TIMED_METADATA:"dai-timed-metadata"};class d extends a.default{static isUsing(e){return e.imaDai&&"function"==typeof e.imaDai||e.dai&&void 0!==e.dai.VERSION||e.ima&&e.ima.dai||e.streamManager}constructor(e){super(e),this.streamManager=null,this.currentAdData=null,this.adBreakData=null,this.streamData=null,this.cuePoints=[],this.initialized=!1,this.eventHandlers=null}setStreamManager(e){this.streamManager=e,this.setupStreamManagerListeners(),this.initialized=!0,s.default.Log.debug("DaiAdsTracker: StreamManager set and listeners registered")}setupStreamManagerListeners(){if(!this.streamManager||!google?.ima?.dai?.api?.StreamEvent)return void s.default.Log.warn("DaiAdsTracker: StreamManager or DAI API not available");const e=google.ima.dai.api.StreamEvent.Type;this.eventHandlers={[e.LOADED]:this.onStreamLoaded.bind(this),[e.STREAM_INITIALIZED]:this.onStreamInitialized.bind(this),[e.ERROR]:this.onStreamError.bind(this),[e.AD_BREAK_STARTED]:this.onAdBreakStarted.bind(this),[e.AD_BREAK_ENDED]:this.onAdBreakEnded.bind(this),[e.AD_PERIOD_STARTED]:this.onAdPeriodStarted.bind(this),[e.AD_PERIOD_ENDED]:this.onAdPeriodEnded.bind(this),[e.STARTED]:this.onAdStarted.bind(this),[e.FIRST_QUARTILE]:this.onAdFirstQuartile.bind(this),[e.MIDPOINT]:this.onAdMidpoint.bind(this),[e.THIRD_QUARTILE]:this.onAdThirdQuartile.bind(this),[e.COMPLETE]:this.onAdComplete.bind(this),[e.SKIPPED]:this.onAdSkipped.bind(this),[e.PAUSED]:this.onAdPaused.bind(this),[e.RESUMED]:this.onAdResumed.bind(this),[e.CLICK]:this.onAdClicked.bind(this),[e.VIDEO_CLICKED]:this.onAdClicked.bind(this),[e.CUEPOINTS_CHANGED]:this.onCuePointsChanged.bind(this),[e.TIMED_METADATA]:this.onTimedMetadata.bind(this)},Object.entries(this.eventHandlers).forEach(([e,t])=>{this.streamManager.addEventListener(e,t)}),s.default.Log.debug("DaiAdsTracker: StreamManager listeners registered")}registerListeners(){super.registerListeners(),s.default.Log.debugCommonVideoEvents(this.player,[null,Object.values(n)])}unregisterListeners(){super.unregisterListeners(),this.streamManager&&this.eventHandlers&&Object.entries(this.eventHandlers).forEach(([e,t])=>{this.streamManager.removeEventListener(e,t)}),this.streamManager=null,this.currentAdData=null,this.adBreakData=null,this.streamData=null,this.cuePoints=[],this.initialized=!1,this.eventHandlers=null}onStreamLoaded(e){this.streamData=this.extractStreamData(e),s.default.Log.debug("DaiAdsTracker: Stream loaded",this.streamData),this.sendRequest()}onStreamInitialized(e){s.default.Log.debug("DaiAdsTracker: Stream initialized"),this.sendDownload({state:"stream-initialized"})}onStreamError(e){const t=this.extractErrorData(e);s.default.Log.error("DaiAdsTracker: Stream error",t),this.sendError(t)}onAdBreakStarted(e){this.adBreakData=this.extractAdBreakData(e),s.default.Log.debug("DaiAdsTracker: Ad break started",this.adBreakData),this.sendAdBreakStart(this.adBreakData)}onAdBreakEnded(e){s.default.Log.debug("DaiAdsTracker: Ad break ended"),this.sendAdBreakEnd(),this.adBreakData=null}onAdPeriodStarted(e){s.default.Log.debug("DaiAdsTracker: Ad period started"),this.adBreakData||this.onAdBreakStarted(e)}onAdPeriodEnded(e){s.default.Log.debug("DaiAdsTracker: Ad period ended")}onAdStarted(e){this.currentAdData=this.extractAdData(e),s.default.Log.debug("DaiAdsTracker: Ad started",this.currentAdData),this.sendStart()}onAdFirstQuartile(e){s.default.Log.debug("DaiAdsTracker: Ad first quartile"),this.sendAdQuartile({quartile:1})}onAdMidpoint(e){s.default.Log.debug("DaiAdsTracker: Ad midpoint"),this.sendAdQuartile({quartile:2})}onAdThirdQuartile(e){s.default.Log.debug("DaiAdsTracker: Ad third quartile"),this.sendAdQuartile({quartile:3})}onAdComplete(e){s.default.Log.debug("DaiAdsTracker: Ad complete"),this.sendEnd(),this.currentAdData=null}onAdSkipped(e){s.default.Log.debug("DaiAdsTracker: Ad skipped"),this.sendEnd({skipped:!0}),this.currentAdData=null}onAdPaused(e){s.default.Log.debug("DaiAdsTracker: Ad paused"),this.sendPause()}onAdResumed(e){s.default.Log.debug("DaiAdsTracker: Ad resumed"),this.sendResume()}onAdClicked(e){s.default.Log.debug("DaiAdsTracker: Ad clicked"),this.sendAdClick({url:this.getClickThroughUrl()})}onCuePointsChanged(e){this.cuePoints=this.extractCuePoints(e),s.default.Log.debug("DaiAdsTracker: Cue points changed",this.cuePoints)}onTimedMetadata(e){const t=this.extractTimedMetadata(e);s.default.Log.debug("DaiAdsTracker: Timed metadata",t)}extractStreamData(e){try{const t=e.getStreamData();return{streamId:t?.streamId,url:t?.url,adTagParameters:t?.adTagParameters,streamType:this.getStreamType()}}catch(e){return s.default.Log.warn("DaiAdsTracker: Failed to extract stream data",e),{}}}extractAdBreakData(e){try{const t=e.getAdBreak();return{adBreakId:t?.id,adBreakTitle:t?.title,adCount:t?.ads?.length||0,position:this.getAdPosition()}}catch(e){return s.default.Log.warn("DaiAdsTracker: Failed to extract ad break data",e),{}}}extractAdData(e){try{const t=e.getAd();return{adId:t?.getAdId(),creativeId:t?.getCreativeId(),duration:t?.getDuration(),title:t?.getTitle(),description:t?.getDescription(),advertiserName:t?.getAdvertiserName(),clickThroughUrl:t?.getClickThroughUrl(),dealId:t?.getDealId(),wrapperAdIds:t?.getWrapperAdIds(),position:this.getAdPosition()}}catch(e){return s.default.Log.warn("DaiAdsTracker: Failed to extract ad data",e),{}}}extractErrorData(e){try{const t=e.getError();return{errorCode:t?.getErrorCode(),errorMessage:t?.getMessage(),innerError:t?.getInnerError()}}catch(e){return s.default.Log.warn("DaiAdsTracker: Failed to extract error data",e),{errorMessage:"Unknown DAI error"}}}extractCuePoints(e){try{return e.getCuepoints()||[]}catch(e){return s.default.Log.warn("DaiAdsTracker: Failed to extract cue points",e),[]}}extractTimedMetadata(e){try{return{type:e.getType(),data:e.getData()}}catch(e){return s.default.Log.warn("DaiAdsTracker: Failed to extract timed metadata",e),{}}}getTrackerName(){return"dai-ads"}getPlayerName(){return"videojs-dai"}getPlayerVersion(){return this.player.dai?.VERSION?this.player.dai.VERSION:this.player.ima?.VERSION?`ima-dai: ${this.player.ima.VERSION}`:"unknown"}getAdCuePoints(){return this.cuePoints}getAdPosition(){if(!this.currentAdData&&!this.adBreakData)return null;const e=this.player.currentTime(),t=this.player.duration();return e<5?"pre":t&&e>t-10?"post":"mid"}getDuration(){return void 0!==this.currentAdData?.duration?1e3*this.currentAdData.duration:null}getVideoId(){return this.currentAdData?.adId||null}getAdCreativeId(){return this.currentAdData?.creativeId||null}getTitle(){return this.currentAdData?.title||null}getSrc(){return this.streamData?.url||null}getPlayhead(){if(this.streamManager)try{return 1e3*this.streamManager.getStreamTime()}catch(e){return 1e3*this.player.currentTime()}return 1e3*this.player.currentTime()}getAdPartner(){return"google-dai"}getClickThroughUrl(){return this.currentAdData?.clickThroughUrl||null}getStreamType(){if(this.streamData?.streamType)return this.streamData.streamType;return this.player.duration()===1/0?"live":"vod"}isLiveStream(){return"live"===this.getStreamType()}getCurrentAdBreak(){return this.adBreakData}getCurrentAd(){return this.currentAdData}getStreamData(){return this.streamData}getBitrate(){const e=this.getTech();return e&&e.tech&&e.tech.stats&&e.tech.stats.bandwidth?Math.round(e.tech.stats.bandwidth):null}getRenditionBitrate(){const e=this.getTech();if(e&&e.getRenditionBitrate){const t=e.getRenditionBitrate();return null!==t?Math.round(t):null}return null}}t.default=d},38(e,t,i){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s,a=(s=i(472))&&s.__esModule?s:{default:s};class r extends a.default{static isUsing(e){return!!e.FreeWheelPlugin&&"undefined"!=typeof tv&&tv.freewheel}getTrackerName(){return"freewheel-ads"}getPlayerName(){return"freewheel-ads"}getPlayerVersion(){return this.player.FreeWheelPlugin.VERSION}getPlayhead(){if(this.player.ads.ad.currentTime)return 1e3*this.player.ads.ad.currentTime()}getDuration(){if(this.player.ads.ad.duration)return 1e3*this.player.ads.ad.duration}getVideoId(){return this.player.ads.ad.id}getAdPartner(){return"freewheel"}getAdCreativeId(){try{return this.player.ads.provider.event.adInstance.getActiveCreativeRendition().getId()}catch(e){}}getSrc(){try{return this.player.ads.provider.event.adInstance.getActiveCreativeRendition().getPrimaryCreativeRenditionAsset().getUrl()}catch(e){}}getTitle(){try{return this.player.ads.provider.event.adInstance.getActiveCreativeRendition().getPrimaryCreativeRenditionAsset().getName()}catch(e){}}getAdPosition(){switch(this.player.ads.ad.type){case"PREROLL":return nrvideo.Constants.AdPositions.PRE;case"MIDROLL":return nrvideo.Constants.AdPositions.MID;case"POSTROLL":return nrvideo.Constants.AdPositions.POST}}}t.default=r},298(e,t,i){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=r(i(555)),a=r(i(472));function r(e){return e&&e.__esModule?e:{default:e}}class n extends a.default{static isUsing(e){return e.ima&&"undefined"!=typeof google}getTrackerName(){return"ima-ads"}getPlayerName(){return"ima"}getPlayerVersion(){return"ima: "+google.ima.VERSION+"; contrib-ads: "+this.player.ads.VERSION}getCuePoints(){return this.player.ima.getAdsManager().getCuePoints()}getAdPosition(){if(this.lastAdData&&this.lastAdData.podInfo&&void 0!==this.lastAdData.podInfo.podIndex){const e=this.lastAdData.podInfo.podIndex;return 0===e?"pre":-1===e?"post":"mid"}return null}getDuration(){return this.lastAdData&&void 0!==this.lastAdData.duration?1e3*this.lastAdData.duration:null}getVideoId(){return this.lastAdData&&this.lastAdData.adId?this.lastAdData.adId:null}getAdCreativeId(){return this.lastAdData&&this.lastAdData.creativeId?this.lastAdData.creativeId:null}getSrc(){return this.lastAdData&&this.lastAdData.mediaUrl?this.lastAdData.mediaUrl:null}getTitle(){return this.lastAdData&&this.lastAdData.title?this.lastAdData.title:null}getPlayhead(){let e=this.player.ima.getAdsManager();if(e)return 1e3*(this.getDuration()-e.getRemainingTime())}getPlayrate(){return this.player.playbackRate()}getAdPartner(){return"ima"}getWebkitBitrate(){const e=this.getAdVideoElement();if(e&&e.webkitVideoDecodedByteCount){let t;if(this._lastAdWebkitBitrate>0){const i=e.webkitVideoDecodedByteCount-this._lastAdWebkitBitrate,s=this.getHeartbeat()/1e3;t=Math.round(i/s*8)}return this._lastAdWebkitBitrate=e.webkitVideoDecodedByteCount,t??null}return null}getRenditionBitrate(){return this.lastAdData&&this.lastAdData.renditionBitrate?Math.round(this.lastAdData.renditionBitrate):null}registerListeners(){let e=google.ima.AdEvent.Type,t=google.ima.AdErrorEvent.Type.AD_ERROR;this.lastAdData=null,s.default.Log.debugCommonVideoEvents(this.player.ima.addEventListener,[null,e.ALL_ADS_COMPLETED,e.LINEAR_CHANGED,e.COMPLETE,e.USER_CLOSE,e.IMPRESSION,e.CONTENT_PAUSE_REQUESTED,e.CONTENT_RESUME_REQUESTED,e.SKIPPED,e.SKIPPABLE_STATE_CHANGED,e.LOADED,e.PAUSED,e.RESUMED,e.STARTED,e.AD_CAN_PLAY,e.AD_METADATA,e.EXPANDED_CHANGED,e.AD_BREAK_READY,e.LOG,e.CLICK,e.FIRST_QUARTILE,e.MIDPOINT,e.THIRD_QUARTILE,t]),this.player.ima.addEventListener(e.LOADED,this.onLoaded.bind(this)),this.player.ima.addEventListener(e.STARTED,this.onStart.bind(this)),this.player.ima.addEventListener(e.PAUSED,this.onPaused.bind(this)),this.player.ima.addEventListener(e.RESUMED,this.onResumed.bind(this)),this.player.ima.addEventListener(e.COMPLETE,this.onComplete.bind(this)),this.player.ima.addEventListener(e.SKIPPED,this.onSkipped.bind(this)),this.player.ima.addEventListener(e.CLICK,this.onClick.bind(this)),this.player.ima.addEventListener(e.FIRST_QUARTILE,this.onFirstQuartile.bind(this)),this.player.ima.addEventListener(e.MIDPOINT,this.onMidpoint.bind(this)),this.player.ima.addEventListener(e.THIRD_QUARTILE,this.onThirdQuartile.bind(this)),this.player.ima.addEventListener(t,this.onError.bind(this))}unregisterListeners(){let e=google.ima.AdEvent.Type,t=google.ima.AdErrorEvent.Type.AD_ERROR;this.player.ima.removeEventListener(e.LOADED,this.onLoaded),this.player.ima.removeEventListener(e.STARTED,this.onLoaded.bind(this)),this.player.ima.removeEventListener(e.IMPRESSION,this.onImpression),this.player.ima.removeEventListener(e.PAUSED,this.onPaused),this.player.ima.removeEventListener(e.RESUMED,this.onResumed),this.player.ima.removeEventListener(e.COMPLETE,this.onComplete),this.player.ima.removeEventListener(e.SKIPPED,this.onSkipped),this.player.ima.removeEventListener(e.CLICK,this.onClick),this.player.ima.removeEventListener(e.FIRST_QUARTILE,this.onFirstQuartile),this.player.ima.removeEventListener(e.MIDPOINT,this.onMidpoint),this.player.ima.removeEventListener(e.THIRD_QUARTILE,this.onThirdQuartile),this.player.ima.removeEventListener(t,this.onError),this.lastAdData=null}onLoaded(e){this.lastAdData=this.getAdData(),this.sendRequest()}onStart(e){this.lastAdData=this.getAdData(),this._lastAdWebkitBitrate=0,this.sendStart()}onComplete(e){this.sendEnd(),this.lastAdData=null}onSkipped(e){this.sendEnd({skipped:!0}),this.lastAdData=null}onError(e){const t=e.getError(),i=t.getErrorCode(),s=t.getMessage();this.sendError({adError:t,errorCode:i,errorMessage:s})}onClick(e){this.sendAdClick()}onFirstQuartile(){this.sendAdQuartile({adQuartile:1})}onMidpoint(){this.sendAdQuartile({adQuartile:2})}onThirdQuartile(){this.sendAdQuartile({adQuartile:3})}onPaused(){this.sendPause()}onResumed(){this.sendResume()}getAdData(){try{const e=this.player.ima.getAdsManager();if(e){const t=e.getCurrentAd();if(t)return{adId:t.getAdId(),creativeId:t.getCreativeId(),duration:t.getDuration(),mediaUrl:t.getMediaUrl(),title:t.getTitle(),podInfo:t.getAdPodInfo()?.data,renditionBitrate:t.getVastMediaBitrate()}}return null}catch(e){return null}}getAdVideoElement(){if(this.player.ima&&this.player.ima.controller&&this.player.ima.controller.adUi){const e=this.player.ima.controller.adUi.adContainerDiv;if(e){const t=e.querySelector("video");if(t)return t}}}}t.default=n},687(e,t,i){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=d(i(555)),a=d(i(472)),r=i(324),n=i(612);function d(e){return e&&e.__esModule?e:{default:e}}const o=(s.default.default||s.default).Log;class l extends a.default{static isUsing(e,t={}){return Boolean(t&&t.mediatailor)}getTrackerName(){return"aws-media-tailor"}getPlayerVersion(){return"MediaTailor"}getAdPosition(){return this.currentAdBreak&&this.currentAdBreak.adPosition?this.currentAdBreak.adPosition:super.getAdPosition()}constructor(e,t={}){super(e);const i=!0===t.mediatailor?{}:t.mediatailor||{};this.streamType=null,this.manifestFormat=null,this.playbackManifestUrl=e.currentSrc(),this.explicitTrackingUrl=i.trackingUrl||null,this.adSegmentPrefix=i.adSegmentPrefix||null,this.adSegmentPrefix?o.debug(`[MT] ad segment detection: custom prefix "${this.adSegmentPrefix}"`):o.debug("[MT] ad segment detection: default (segments.mediatailor hostname or /tm/ path)"),this.adSchedule=[],this.currentAdBreak=null,this.currentAdPod=null,this.hasEndedContent=!1,this.isDisposed=!1,this.trackingAbortController=null,this.manifestAbortController=null,this.isFetchingTracking=!1,this.isFetchingManifest=!1,this.trackingEndpointUrl=null,this.hasAttemptedTrackingFetch=!1,this.trackingFetchRetries=0,this.maxTrackingRetries=1,this.manifestPollTimer=null,this.trackingPollTimer=null,this.liveRefreshIntervalSeconds=null,this.mediaPlaylistUrl=null,this.lastMediaPlaylistText=null,o.debug(`[MT - ${(0,n.getTimestamp)()}] MediaTailorAdsTracker initialized`,{endpoint:this.playbackManifestUrl,trackingAPITimeout:r.TRACKING_API_TIMEOUT_MS}),this.manifestFormat=(0,n.detectManifestFormatFromUrl)(this.playbackManifestUrl),o.debug(`[MT - ${(0,n.getTimestamp)()}] Manifest type: ${this.manifestFormat.toUpperCase()}`),this.player.one("loadedmetadata",()=>{this.streamType=(0,n.detectPlaybackStreamType)(this.player.duration()),o.debug(`[MT - ${(0,n.getTimestamp)()}] Stream type: ${this.streamType.toUpperCase()}`),this.initializeTracking()})}initializeTracking(){o.debug(`[MT - ${(0,n.getTimestamp)()}] Initializing ${this.manifestFormat.toUpperCase()} ${this.streamType.toUpperCase()} tracking`),this.trackingEndpointUrl=this.explicitTrackingUrl||(0,n.buildTrackingEndpointUrl)(this.playbackManifestUrl),this.trackingEndpointUrl?o.debug(`[MT - ${(0,n.getTimestamp)()}] Tracking URL extracted:`,this.trackingEndpointUrl):o.warn(`[MT - ${(0,n.getTimestamp)()}] Could not derive tracking URL from playback URL — pass trackingUrl in mediatailor options if needed`),this.streamType===r.STREAM_TYPE.VOD?this.setupVODTracking():this.setupLiveTracking()}registerListeners(){super.registerListeners(),this.onPause=this.onPause.bind(this),this.onPlaying=this.onPlaying.bind(this),this.onSeeking=this.onSeeking.bind(this),this.onSeeked=this.onSeeked.bind(this),this.onWaiting=this.onWaiting.bind(this),this.onEnded=this.onEnded.bind(this),this.onTimeUpdate=this.onTimeUpdate.bind(this),this.player.on("pause",this.onPause),this.player.on("playing",this.onPlaying),this.player.on("seeking",this.onSeeking),this.player.on("seeked",this.onSeeked),this.player.on("waiting",this.onWaiting),this.player.on("ended",this.onEnded),this.player.on("timeupdate",this.onTimeUpdate),o.debug(`[MT - ${(0,n.getTimestamp)()}] Event listeners registered`)}unregisterListeners(){super.unregisterListeners(),this.player.off("pause",this.onPause),this.player.off("playing",this.onPlaying),this.player.off("seeking",this.onSeeking),this.player.off("seeked",this.onSeeked),this.player.off("waiting",this.onWaiting),this.player.off("ended",this.onEnded),this.player.off("timeupdate",this.onTimeUpdate),this.stopLivePolling()}stopLivePolling(){this.manifestPollTimer&&(clearTimeout(this.manifestPollTimer),this.manifestPollTimer=null),this.trackingPollTimer&&(clearInterval(this.trackingPollTimer),this.trackingPollTimer=null)}setupVODTracking(){o.debug(`[MT - ${(0,n.getTimestamp)()}] VOD mode: Single manifest parse`),this.hookPlayerManifest()}setupLiveTracking(){o.debug(`[MT - ${(0,n.getTimestamp)()}] Live mode: Continuous polling`),this.hookPlayerManifest();const e=this.getLiveRefreshIntervalMs();this.manifestPollTimer=setInterval(()=>{this.pollManifestForNewAds()},e),this.trackingPollTimer=setInterval(()=>{this.getAndProcessTrackingMetadata()},e),o.debug(`[MT - ${(0,n.getTimestamp)()}] Live polling started`,{pollingInterval:e})}getLiveRefreshIntervalMs(){return this.liveRefreshIntervalSeconds?1e3*this.liveRefreshIntervalSeconds:r.DEFAULT_LIVE_POLL_INTERVAL_MS}restartLivePollingTimers(){if(!this.liveRefreshIntervalSeconds)return;const e=this.getLiveRefreshIntervalMs();o.debug(`[MT - ${(0,n.getTimestamp)()}] Updating live polling interval: ${this.liveRefreshIntervalSeconds}s`),this.manifestPollTimer&&clearInterval(this.manifestPollTimer),this.trackingPollTimer&&clearInterval(this.trackingPollTimer),this.manifestPollTimer=setInterval(()=>{this.pollManifestForNewAds()},e),this.trackingPollTimer=setInterval(()=>{this.getAndProcessTrackingMetadata()},e)}hookPlayerManifest(){const e=this.player.tech({IWillNotUseThisInPlugins:!0});if(!e)return o.debug(`[MT - ${(0,n.getTimestamp)()}] No tech - using fallback fetch`),void this.getManifestDirectly();if(this.manifestFormat===r.MANIFEST_TYPE.HLS){if(this.hookHLSViaVHS(e)||this.hookHLSViaNative(e)||this.hookHLSViaContribHls(e))return}else if(this.manifestFormat===r.MANIFEST_TYPE.DASH&&(this.hookDASHViaShaka(e)||this.hookDASHViaDashJs(e)))return;o.debug(`[MT - ${(0,n.getTimestamp)()}] Using fallback: direct manifest fetch`),this.getManifestDirectly()}hookHLSViaVHS(e){if(!e.vhs||!e.vhs.playlists)return!1;o.debug(`[MT - ${(0,n.getTimestamp)()}] Hooked: VHS`);const t=e.vhs.playlists.media();return t&&t.segments&&t.segments.length>0&&(o.debug(`[MT - ${(0,n.getTimestamp)()}] Parsing existing playlist`),this.parseVhsPlaylistForAdBreaks(t)),e.vhs.on("loadedplaylist",()=>{const t=e.vhs.playlists.media();t&&this.parseVhsPlaylistForAdBreaks(t)}),!0}hookHLSViaNative(e){return!!(e.el_&&e.el_.canPlayType&&e.el_.canPlayType(r.HLS_MIME_TYPE))&&(o.debug(`[MT - ${(0,n.getTimestamp)()}] Native HLS detected - using fallback`),this.getManifestDirectly(),!0)}hookHLSViaContribHls(e){if(!e.hls||!e.hls.playlists)return!1;o.debug(`[MT - ${(0,n.getTimestamp)()}] Hooked: contrib-hls (legacy)`);const t=e.hls.playlists.media();return t&&t.segments&&t.segments.length>0&&this.parseVhsPlaylistForAdBreaks(t),e.hls.on("loadedplaylist",()=>{const t=e.hls.playlists.media();t&&this.parseVhsPlaylistForAdBreaks(t)}),!0}hookDASHViaShaka(e){return!!e.shakaPlayer&&(o.debug(`[MT - ${(0,n.getTimestamp)()}] Hooked: Shaka Player`),e.shakaPlayer.addEventListener("emsg",e=>{this.handleDASHEmsgEvent(e)}),!0)}hookDASHViaDashJs(e){return!(!e.dash||!e.dash.on)&&(o.debug(`[MT - ${(0,n.getTimestamp)()}] Hooked: dash.js`),e.dash.on("EVENT_MODE_ON_RECEIVE",e=>{this.handleDASHEventStream(e)}),!0)}async getManifestDirectly(){o.debug(`[MT - ${(0,n.getTimestamp)()}] Fallback: fetching manifest directly`);try{const e=this.playbackManifestUrl;this.manifestFormat===r.MANIFEST_TYPE.HLS?await this.fetchAndParseHlsManifest(e):this.manifestFormat===r.MANIFEST_TYPE.DASH&&await this.fetchAndParseDashManifest(e)}catch(e){o.debug(`[MT - ${(0,n.getTimestamp)()}] Fallback fetch error:`,e)}}async fetchAndParseHlsManifest(e){try{o.debug(`[MT - ${(0,n.getTimestamp)()}] Fetching HLS master manifest`);const{mediaPlaylistUrl:t}=await(0,n.fetchHlsMasterManifest)(e);if(!t)return void o.debug(`[MT - ${(0,n.getTimestamp)()}] No media playlist found`);o.debug(`[MT - ${(0,n.getTimestamp)()}] Fetching media playlist`);const i=await(0,n.fetchHlsMediaPlaylist)(t),s=(0,n.extractHlsTargetDurationSeconds)(i);this.updateLiveRefreshIntervalFromManifest(s,"hls target duration");const a=(0,n.parseHlsManifestForAdBreaks)(i);a.length>0&&(o.debug(`[MT - ${(0,n.getTimestamp)()}] Detected ${a.length} ad break(s)`),this.mergeNewAds(a))}catch(e){o.debug(`[MT - ${(0,n.getTimestamp)()}] HLS fetch error:`,e)}}async fetchAndParseDashManifest(e){try{o.debug(`[MT - ${(0,n.getTimestamp)()}] Fetching DASH manifest`);const t=await(0,n.fetchDashManifest)(e),i=(0,n.extractDashMinimumUpdatePeriodSeconds)(t);this.updateLiveRefreshIntervalFromManifest(i,"dash minimumUpdatePeriod");const s=(0,n.parseDashManifestForAdBreaks)(t);o.debug(`[MT - ${(0,n.getTimestamp)()}] DASH: ${s.length} ad break(s) found`),s.length>0?this.mergeNewAds(s):this.streamType===r.STREAM_TYPE.VOD&&this.trackingEndpointUrl&&!this.hasAttemptedTrackingFetch&&(o.debug(`[MT - ${(0,n.getTimestamp)()}] DASH: no manifest cues, fetching tracking API`),this.hasAttemptedTrackingFetch=!0,this.getAndProcessTrackingMetadata())}catch(e){o.debug(`[MT - ${(0,n.getTimestamp)()}] DASH fetch error:`,e)}}handleDASHEmsgEvent(e){o.debug(`[MT - ${(0,n.getTimestamp)()}] DASH emsg event:`,e);try{const t=e.detail;if(!t)return void o.debug(`[MT - ${(0,n.getTimestamp)()}] No emsg data in event`);const i=t.schemeIdUri||"";if(!i.includes(r.SCTE35_SCHEME_MARKER))return void o.debug(`[MT - ${(0,n.getTimestamp)()}] Non-SCTE-35 emsg, skipping:`,i);o.debug(`[MT - ${(0,n.getTimestamp)()}] SCTE-35 emsg detected:`,{schemeIdUri:t.schemeIdUri,value:t.value,timescale:t.timescale,presentationTime:t.presentationTime,presentationTimeDelta:t.presentationTimeDelta,eventDuration:t.eventDuration});const s=t.timescale||1,a=t.presentationTime||0,d=t.eventDuration||0,l=a/s,h=d/s;if(t.messageData&&h>0){const e={id:`dash-emsg-${l}`,startTime:l,duration:h,endTime:l+h,source:"dash-emsg",confirmedByTracking:!1,hasFiredStart:!1,hasFiredEnd:!1,hasFiredAdStart:!1,pods:[]};o.debug(`[MT - ${(0,n.getTimestamp)()}] Adding ad break from DASH emsg:`,e),this.mergeNewAds([e])}}catch(e){o.debug(`[MT - ${(0,n.getTimestamp)()}] Error parsing DASH emsg event:`,e)}}handleDASHEventStream(e){o.debug(`[MT - ${(0,n.getTimestamp)()}] DASH event stream:`,e);try{const t=e.event||e;if(!t)return void o.debug(`[MT - ${(0,n.getTimestamp)()}] No event data`);const i=t.schemeIdUri||"";if(!i.includes(r.SCTE35_SCHEME_MARKER))return void o.debug(`[MT - ${(0,n.getTimestamp)()}] Non-SCTE-35 event, skipping:`,i);o.debug(`[MT - ${(0,n.getTimestamp)()}] SCTE-35 event stream detected:`,{id:t.id,schemeIdUri:t.schemeIdUri,presentationTime:t.presentationTime,duration:t.duration,messageData:t.messageData});const s=parseFloat(t.presentationTime||0),a=parseFloat(t.duration||0);if(a>0){const e={id:t.id||`dash-event-${s}`,startTime:s,duration:a,endTime:s+a,source:"dash-event-stream",confirmedByTracking:!1,hasFiredStart:!1,hasFiredEnd:!1,hasFiredAdStart:!1,pods:[]};o.debug(`[MT - ${(0,n.getTimestamp)()}] Adding ad break from DASH event stream:`,e),this.mergeNewAds([e])}}catch(e){o.debug(`[MT - ${(0,n.getTimestamp)()}] Error parsing DASH event stream:`,e)}}parseVhsPlaylistForAdBreaks(e){if(o.debug(`[MT - ${(0,n.getTimestamp)()}] Parsing VHS playlist (${e.segments?.length||0} segments)`),!e.segments||0===e.segments.length)return void o.debug(`[MT - ${(0,n.getTimestamp)()}] No segments in playlist`);this.updateLiveRefreshIntervalFromManifest(e.targetDuration,"vhs target duration");const t=(0,n.detectAdBreaksFromVhsPlaylist)(e,{adSegmentPrefix:this.adSegmentPrefix});if(t.length>0){if(!this._detectionPathLogged){const t=e.segments&&e.segments.find(e=>(0,n.whichAdSegmentMarker)(e,{adSegmentPrefix:this.adSegmentPrefix}));if(t){const e=(0,n.whichAdSegmentMarker)(t,{adSegmentPrefix:this.adSegmentPrefix});o.debug(`[MT] ad segment detection matched via: ${e}`),this._detectionPathLogged=!0}}o.debug(`[MT - ${(0,n.getTimestamp)()}] VHS detected ${t.length} ad break(s), ${t.reduce((e,t)=>e+t.pods.length,0)} pod(s)`),this.mergeNewAds(t)}else o.debug(`[MT - ${(0,n.getTimestamp)()}] No ads detected in VHS playlist`)}async pollManifestForNewAds(){if(!this.isDisposed&&this.streamType===r.STREAM_TYPE.LIVE)if(this.isFetchingManifest)o.debug(`[MT - ${(0,n.getTimestamp)()}] Manifest fetch already in progress, skipping`);else{this.isFetchingManifest=!0;try{const e=this.player.tech({IWillNotUseThisInPlugins:!0});if(e&&e.vhs){const t=e.vhs.playlists.media();t&&this.parseVhsPlaylistForAdBreaks(t)}else this.manifestFormat===r.MANIFEST_TYPE.DASH&&await this.fetchAndParseDashManifest(this.playbackManifestUrl)}catch(e){o.debug(`[MT - ${(0,n.getTimestamp)()}] Manifest poll error:`,e)}finally{this.isFetchingManifest=!1}}}mergeNewAds(e){this.adSchedule=(0,n.mergeAdSchedules)(this.adSchedule,e),o.debug(`[MT - ${(0,n.getTimestamp)()}] Ad schedule: ${this.adSchedule.length} ad break(s)`),this.streamType===r.STREAM_TYPE.VOD&&this.trackingEndpointUrl&&!this.hasAttemptedTrackingFetch&&(this.hasAttemptedTrackingFetch=!0,o.debug(`[MT - ${(0,n.getTimestamp)()}] Fetching tracking metadata (first manifest parse)`),this.getAndProcessTrackingMetadata())}updateLiveRefreshIntervalFromManifest(e,t){this.streamType!==r.STREAM_TYPE.LIVE||!e||e<=0||this.liveRefreshIntervalSeconds!==e&&(this.liveRefreshIntervalSeconds=e,o.debug(`[MT - ${(0,n.getTimestamp)()}] Derived live polling interval from ${t}: ${e}s`),(this.manifestPollTimer||this.trackingPollTimer)&&this.restartLivePollingTimers())}async getAndProcessTrackingMetadata(){if(!this.isDisposed&&this.trackingEndpointUrl)if(this.isFetchingTracking)o.debug(`[MT - ${(0,n.getTimestamp)()}] Tracking fetch already in progress, skipping`);else{this.isFetchingTracking=!0;try{o.debug(`[MT - ${(0,n.getTimestamp)()}] Fetching tracking metadata`),this.trackingAbortController=new AbortController;const e=await(0,n.getTrackingMetadata)(this.trackingEndpointUrl,r.TRACKING_API_TIMEOUT_MS,this.trackingAbortController.signal);if(this.isDisposed)return void o.debug(`[MT - ${(0,n.getTimestamp)()}] Disposed during tracking fetch, ignoring result`);e.avails&&e.avails.length>0?(o.debug(`[MT - ${(0,n.getTimestamp)()}] Enriching with ${e.avails.length} avail(s)`),this.enrichWithTrackingMetadata(e.avails),this.trackingFetchRetries=0):o.debug(`[MT - ${(0,n.getTimestamp)()}] Tracking API returned 0 avails`)}catch(e){if("AbortError"===e.name||this.isDisposed)return void o.debug(`[MT - ${(0,n.getTimestamp)()}] Tracking fetch aborted`);if(o.debug(`[MT - ${(0,n.getTimestamp)()}] Tracking API error: ${e.message}`,e),this.trackingFetchRetries<this.maxTrackingRetries)return this.trackingFetchRetries++,o.debug(`[MT - ${(0,n.getTimestamp)()}] Retrying tracking fetch (${this.trackingFetchRetries}/${this.maxTrackingRetries})`),this.isFetchingTracking=!1,void await this.getAndProcessTrackingMetadata();o.debug(`[MT - ${(0,n.getTimestamp)()}] Max retries reached, continuing with manifest data only`)}finally{this.isFetchingTracking=!1,this.trackingAbortController=null}}}enrichWithTrackingMetadata(e){const t=(0,n.enrichAdScheduleWithTrackingMetadata)(this.adSchedule,e);t.length>0&&(this.adSchedule.push(...t),this.adSchedule.sort((e,t)=>e.startTime-t.startTime)),o.debug(`[MT - ${(0,n.getTimestamp)()}] Enrichment complete: ${this.adSchedule.length} ad break(s)`),o.debug(`[MT - ${(0,n.getTimestamp)()}] Enriched schedule:`,this.adSchedule.map(e=>({id:e.id,startTime:e.startTime,endTime:e.endTime,duration:e.duration,title:e.title,podCount:e.pods.length,pods:e.pods.map(e=>({title:e.title,startTime:e.startTime,endTime:e.endTime,duration:e.duration}))}))),o.debug(`[MT - ${(0,n.getTimestamp)()}] Current player time: ${this.player.currentTime()}s`)}trackQuartiles(e,t){if(!e.duration||e.duration<=0)return;(0,n.getQuartilesToFire)(t,e.duration,{q1:e.hasFiredQ1,q2:e.hasFiredQ2,q3:e.hasFiredQ3}).forEach(({quartile:t,key:i})=>{o.debug(`[MT - ${(0,n.getTimestamp)()}] → AD_QUARTILE ${25*t}%`),this.sendAdQuartile({quartile:t}),e[`hasFired${i.toUpperCase()}`]=!0})}onTimeUpdate(){const e=this.player.currentTime(),t=(0,n.findActiveAdBreak)(this.adSchedule,e);if(this.adSchedule.length>0&&Math.floor(e)%5==0&&Math.floor(10*e)%10==0&&o.debug(`[MT - ${(0,n.getTimestamp)()}] TimeUpdate: ${e.toFixed(2)}s, Active break: ${t?t.id:"none"}, Schedule count: ${this.adSchedule.length}`),t){if(!t.hasFiredStart){this.currentAdBreak=t,this.setIsAd(!0),o.debug(`[MT - ${(0,n.getTimestamp)()}] setIsAd(true) - Entering ad break`);const e=this.adSchedule.findIndex(e=>Math.abs(e.startTime-t.startTime)<.5),i=(0,n.determineAdPosition)(e,this.adSchedule.length,this.streamType);t.adPosition=i,o.debug(`[MT - ${(0,n.getTimestamp)()}] → AD_BREAK_START`,{startTime:t.startTime,duration:t.duration,podCount:t.pods?.length||0,position:i,breakIndex:e,totalBreaks:this.adSchedule.length}),this.sendAdBreakStart(),t.hasFiredStart=!0}if(t.pods&&t.pods.length>0){const i=(0,n.findActivePod)(t,e);if(i){this.currentAdPod&&this.currentAdPod===i||(this.currentAdPod&&(o.debug(`[MT - ${(0,n.getTimestamp)()}] → AD_END (pod transition)`),this.sendEnd()),this.currentAdPod=i,o.debug(`[MT - ${(0,n.getTimestamp)()}] → AD_START (new pod)`,{startTime:i.startTime,duration:i.duration,position:t.adPosition}),this.sendRequest({adPartner:"aws-mediatailor",adPosition:t.adPosition}),this.sendStart({adPartner:"aws-mediatailor",adPosition:t.adPosition}),i.hasFiredStart=!0);const s=e-i.startTime;this.trackQuartiles(i,s)}}else{t.hasFiredAdStart||(o.debug(`[MT - ${(0,n.getTimestamp)()}] → AD_START (no pods)`,{startTime:t.startTime,duration:t.duration,position:t.adPosition}),this.sendRequest({adPartner:"aws-mediatailor",adPosition:t.adPosition}),this.sendStart({adPartner:"aws-mediatailor",adPosition:t.adPosition}),t.hasFiredAdStart=!0);const i=e-t.startTime;this.trackQuartiles(t,i)}}else this.currentAdBreak&&(this.currentAdPod&&(o.debug(`[MT - ${(0,n.getTimestamp)()}] → AD_END (final pod)`),this.sendEnd(),this.currentAdPod=null),this.currentAdBreak.hasFiredEnd||(o.debug(`[MT - ${(0,n.getTimestamp)()}] → AD_BREAK_END`),this.sendAdBreakEnd(),this.currentAdBreak.hasFiredEnd=!0),this.currentAdBreak=null,this.setIsAd(!1),o.debug(`[MT - ${(0,n.getTimestamp)()}] setIsAd(false) - Exiting ad break`),this.player.ended()&&!this.hasEndedContent&&(o.debug(`[MT - ${(0,n.getTimestamp)()}] Video ended after last ad → CONTENT_END`),this.sendContentEnd(),this.hasEndedContent=!0))}sendContentEnd(){this.parentTracker?this.parentTracker.sendEnd():super.sendEnd()}handleAdEvent(e,t){this.isAd()&&(o.debug(`[MT - ${(0,n.getTimestamp)()}] → ${e}`),t.call(this))}onPause(){this.handleAdEvent("AD_PAUSE",this.sendPause)}onPlaying(){this.isAd()&&(o.debug(`[MT - ${(0,n.getTimestamp)()}] → AD_RESUME`),this.sendResume(),this.sendBufferEnd())}onSeeking(){this.handleAdEvent("AD_SEEK_START",this.sendSeekStart)}onSeeked(){this.handleAdEvent("AD_SEEK_END",this.sendSeekEnd)}onWaiting(){this.handleAdEvent("AD_BUFFER_START",this.sendBufferStart)}onEnded(){this.hasEndedContent||(o.debug(`[MT - ${(0,n.getTimestamp)()}] Video ended → CONTENT_END`),this.sendContentEnd(),this.hasEndedContent=!0)}getTitle(){return this.currentAdPod?this.currentAdPod.title||this.currentAdBreak?.id||null:this.currentAdBreak?.title||this.currentAdBreak?.id||null}getVideoId(){return this.currentAdPod?this.currentAdPod.creativeId||this.currentAdPod.title||this.currentAdBreak?.id||null:this.currentAdBreak?.creativeId||this.currentAdBreak?.id||null}getSrc(){return this.trackingEndpointUrl||this.playbackManifestUrl||null}getDuration(){return this.currentAdPod?1e3*this.currentAdPod.duration:this.currentAdBreak?1e3*this.currentAdBreak.duration:null}stopPolling(){this.manifestPollTimer&&(clearInterval(this.manifestPollTimer),this.manifestPollTimer=null),this.trackingPollTimer&&(clearInterval(this.trackingPollTimer),this.trackingPollTimer=null),o.debug(`[MT - ${(0,n.getTimestamp)()}] Polling stopped`)}dispose(){o.debug(`[MT - ${(0,n.getTimestamp)()}] Disposing MediaTailorAdsTracker`),this.isDisposed=!0,this.trackingAbortController&&(o.debug(`[MT - ${(0,n.getTimestamp)()}] Aborting in-flight tracking fetch`),this.trackingAbortController.abort(),this.trackingAbortController=null),this.manifestAbortController&&(o.debug(`[MT - ${(0,n.getTimestamp)()}] Aborting in-flight manifest fetch`),this.manifestAbortController.abort(),this.manifestAbortController=null),this.stopLivePolling(),this.unregisterListeners(),super.dispose&&super.dispose()}}t.default=l},324(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.TRACKING_API_TIMEOUT_MS=t.STREAM_TYPE=t.SCTE35_SCHEME_MARKER=t.REGEX_TRACKING_PATH_SEGMENT=t.REGEX_SESSION_ID=t.REGEX_MAP=t.REGEX_MANIFEST_FILE_SUFFIX=t.REGEX_ISO_8601_DURATION=t.REGEX_HLS_TARGET_DURATION=t.REGEX_DISCONTINUITY=t.REGEX_DASH_MINIMUM_UPDATE_PERIOD=t.REGEX_CUE_OUT=t.QUARTILES=t.POST_AD_PAUSE_THRESHOLD=t.MT_SEGMENT_PATTERN=t.MT_HLS_CUE_OUT_TAG=t.MT_HLS_CUE_IN_TAG=t.MT_DEFAULT_AD_SEGMENT_PATH=t.MIN_AD_DURATION=t.MEDIATAILOR_HOST_MARKER=t.MANIFEST_TYPE=t.HLS_TAG_PREFIX=t.HLS_SEGMENT_DURATION_TAG=t.HLS_MIME_TYPE=t.HLS_MANIFEST_EXTENSION=t.DEFAULT_LIVE_POLL_INTERVAL_MS=t.DASH_SCTE35_EVENT_STREAM_SELECTOR=t.DASH_MANIFEST_EXTENSION=t.AD_TIMING_TOLERANCE=t.AD_SOURCE=t.AD_POSITION=void 0;t.REGEX_CUE_OUT=/#EXT-X-CUE-OUT:DURATION=([\d.]+)/,t.REGEX_DISCONTINUITY=/#EXT-X-DISCONTINUITY/,t.REGEX_MAP=/#EXT-X-MAP:URI="([^"]+)"/,t.REGEX_SESSION_ID=/sessionId=([^&]+)/,t.REGEX_TRACKING_PATH_SEGMENT=/\/v1\/(master|session|dash)\//,t.REGEX_MANIFEST_FILE_SUFFIX=/\/[^/]*\.(m3u8|mpd).*$/,t.REGEX_HLS_TARGET_DURATION=/#EXT-X-TARGETDURATION:(\d+)/,t.REGEX_DASH_MINIMUM_UPDATE_PERIOD=/minimumUpdatePeriod="([^"]+)"/,t.REGEX_ISO_8601_DURATION=/PT(?:(\d+)H)?(?:(\d+)M)?(?:([\d.]+)S)?/,t.HLS_MANIFEST_EXTENSION=".m3u8",t.DASH_MANIFEST_EXTENSION=".mpd",t.MEDIATAILOR_HOST_MARKER=".mediatailor.",t.MT_HLS_CUE_OUT_TAG="#EXT-X-CUE-OUT",t.MT_HLS_CUE_IN_TAG="#EXT-X-CUE-IN",t.HLS_SEGMENT_DURATION_TAG="#EXTINF:",t.HLS_TAG_PREFIX="#",t.SCTE35_SCHEME_MARKER="scte35",t.DASH_SCTE35_EVENT_STREAM_SELECTOR='EventStream[schemeIdUri*="scte35"], EventStream[schemeIdUri*="SCTE35"]',t.HLS_MIME_TYPE="application/vnd.apple.mpegurl",t.MT_SEGMENT_PATTERN="segments.mediatailor",t.MT_DEFAULT_AD_SEGMENT_PATH="/tm/",t.TRACKING_API_TIMEOUT_MS=5e3,t.DEFAULT_LIVE_POLL_INTERVAL_MS=5e3,t.MIN_AD_DURATION=.5,t.AD_TIMING_TOLERANCE=.5,t.POST_AD_PAUSE_THRESHOLD=500,t.STREAM_TYPE={VOD:"vod",LIVE:"live"},t.MANIFEST_TYPE={HLS:"hls",DASH:"dash"},t.AD_POSITION={PRE_ROLL:"pre",MID_ROLL:"mid",POST_ROLL:"post"},t.AD_SOURCE={MANIFEST_CUE:"manifest-cue",VHS_DISCONTINUITY:"vhs-discontinuity",TRACKING_API:"tracking-api",MANIFEST_AND_TRACKING:"manifest+tracking",DASH_EMSG:"dash-emsg",DASH_EVENT_STREAM:"dash-event-stream"},t.QUARTILES={Q1:.25,Q2:.5,Q3:.75}},612(e,t,i){Object.defineProperty(t,"__esModule",{value:!0}),t.buildTrackingEndpointUrl=function(e){const t=e.match(r.REGEX_SESSION_ID);if(!t)return null;const i=t[1];return e.replace(r.REGEX_TRACKING_PATH_SEGMENT,"/v1/tracking/").replace(r.REGEX_MANIFEST_FILE_SUFFIX,`/${i}`)},t.calculateQuartiles=o,t.detectAdBreaksFromVhsPlaylist=function(e,{adSegmentPrefix:t}={}){const i=e.segments,s=e.discontinuityStarts||[],a=[];let n=null,o=null,l=0;i.forEach((e,i)=>{const h=d(e,{adSegmentPrefix:t}),u=s.includes(i);if(h){u&&o&&(o.endTime=l,o.duration>r.MIN_AD_DURATION&&n.pods.push(o),o=null),n||(n={id:`avail-${l}`,startTime:l,duration:0,endTime:null,source:"vhs-discontinuity",confirmedByTracking:!1,hasFiredStart:!1,hasFiredEnd:!1,hasFiredAdStart:!1,hasFiredQ1:!1,hasFiredQ2:!1,hasFiredQ3:!1,pods:[]}),o||(o={startTime:l,duration:0,endTime:null,hasFiredStart:!1,hasFiredQ1:!1,hasFiredQ2:!1,hasFiredQ3:!1});const t=e.duration||0;n.duration+=t,o.duration+=t}else n&&(o&&(o.endTime=l,o.duration>r.MIN_AD_DURATION&&n.pods.push(o),o=null),n.endTime=l,n.duration>r.MIN_AD_DURATION&&a.push(n),n=null);l+=e.duration||0}),n&&(o&&(o.endTime=l,o.duration>r.MIN_AD_DURATION&&n.pods.push(o)),n.endTime=l,n.duration>r.MIN_AD_DURATION&&a.push(n));return a},t.detectManifestFormatFromUrl=function(e){if(e.includes(r.HLS_MANIFEST_EXTENSION))return r.MANIFEST_TYPE.HLS;if(e.includes(r.DASH_MANIFEST_EXTENSION))return r.MANIFEST_TYPE.DASH;return r.MANIFEST_TYPE.HLS},t.detectPlaybackStreamType=function(e){return e===1/0?r.STREAM_TYPE.LIVE:r.STREAM_TYPE.VOD},t.determineAdPosition=function(e,t,i){if(i===r.STREAM_TYPE.LIVE)return null;return 0===e?r.AD_POSITION.PRE_ROLL:e===t-1?r.AD_POSITION.POST_ROLL:r.AD_POSITION.MID_ROLL},t.enrichAdScheduleWithTrackingMetadata=function(e,t){const i=new Map;e.forEach(e=>{const t=Math.round(e.startTime);i.set(t,e)});const s=[];return t.forEach(e=>{const t=e.ads&&e.ads.length>0?e.ads[0]:null;if(!t)return;const a=Math.round(t.startTimeInSeconds),r=i.get(a);r?(r.id=e.availId,r.creativeId=t.adId,r.title=t.adTitle,r.confirmedByTracking=!0,e.ads&&e.ads.length>0&&r.pods&&e.ads.forEach((e,t)=>{r.pods[t]?(r.pods[t].title=e.adTitle,r.pods[t].creativeId=e.adId,r.pods[t].trackingStartTime=e.startTimeInSeconds,r.pods[t].trackingDuration=e.durationInSeconds):r.pods.push({startTime:e.startTimeInSeconds,duration:e.durationInSeconds,endTime:e.startTimeInSeconds+e.durationInSeconds,title:e.adTitle,creativeId:e.adId,hasFiredStart:!1,hasFiredQ1:!1,hasFiredQ2:!1,hasFiredQ3:!1})})):s.push({id:e.availId,startTime:t.startTimeInSeconds,duration:e.durationInSeconds,endTime:t.startTimeInSeconds+e.durationInSeconds,title:t.adTitle,creativeId:t.adId,source:"tracking-api",confirmedByTracking:!0,hasFiredStart:!1,hasFiredEnd:!1,hasFiredAdStart:!1,hasFiredQ1:!1,hasFiredQ2:!1,hasFiredQ3:!1,pods:e.ads.map(e=>({startTime:e.startTimeInSeconds,duration:e.durationInSeconds,endTime:e.startTimeInSeconds+e.durationInSeconds,title:e.adTitle,creativeId:e.adId,hasFiredStart:!1,hasFiredQ1:!1,hasFiredQ2:!1,hasFiredQ3:!1}))})}),s},t.extractDashMinimumUpdatePeriodSeconds=function(e){const t=e.match(r.REGEX_DASH_MINIMUM_UPDATE_PERIOD);return t?h(t[1]):null},t.extractHlsTargetDurationSeconds=function(e){const t=e.match(r.REGEX_HLS_TARGET_DURATION);return t?parseInt(t[1],10):null},t.extractMediaPlaylistUrl=function(e,t){const i=e.split("\n");for(const e of i)if(!e.startsWith(r.HLS_TAG_PREFIX)&&e.includes(r.HLS_MANIFEST_EXTENSION))return new URL(e.trim(),t).href;return null},t.fetchDashManifest=async function(e){return await l(e)},t.fetchHlsMasterManifest=async function(e){const t=await l(e),i=t.split("\n");let s=null;for(const t of i)if(!t.startsWith(r.HLS_TAG_PREFIX)&&t.includes(r.HLS_MANIFEST_EXTENSION)){s=new URL(t.trim(),e).href;break}return{masterText:t,mediaPlaylistUrl:s}},t.fetchHlsMediaPlaylist=async function(e){return await l(e)},t.findActiveAdBreak=function(e,t){return e.find(e=>t>=e.startTime&&t<e.endTime)},t.findActivePod=function(e,t){if(!e||!e.pods||0===e.pods.length)return null;return e.pods.find(e=>t>=e.startTime&&t<e.endTime)},t.findAdBreakIndex=function(e,t){return e.findIndex(e=>Math.abs(e.startTime-t)<r.AD_TIMING_TOLERANCE)},t.getQuartilesToFire=function(e,t,i){const s=o(t),a=[];e>=s.q1&&!i.q1&&a.push({quartile:1,key:"q1"});e>=s.q2&&!i.q2&&a.push({quartile:2,key:"q2"});e>=s.q3&&!i.q3&&a.push({quartile:3,key:"q3"});return a},t.getTimestamp=function(){return(new Date).toISOString().substring(11,23)},t.getTrackingMetadata=async function(e,t=8e3,i=null){const s=new AbortController,a=setTimeout(()=>s.abort(),t),r=()=>s.abort();i&&i.addEventListener("abort",r);try{const t=await fetch(`${e}?t=${Date.now()}`,{signal:s.signal,credentials:"include"});if(clearTimeout(a),i&&i.removeEventListener("abort",r),!t.ok)throw new Error(`Tracking API error: ${t.status}`);return await t.json()}catch(e){throw clearTimeout(a),i&&i.removeEventListener("abort",r),e}},t.isMediaTailorSegment=d,t.isValidAdBreak=function(e){return e.duration>r.MIN_AD_DURATION},t.mergeAdSchedules=function(e,t){const i=new Map;e.forEach(e=>{const t=Math.round(e.startTime);i.set(t,e)});const s=[];t.forEach(e=>{const t=Math.round(e.startTime),a=i.get(t);a?!a.confirmedByTracking&&e.confirmedByTracking&&Object.assign(a,e):(s.push(e),i.set(t,e))});const a=[...e,...s];return a.sort((e,t)=>e.startTime-t.startTime),a},t.parseDashManifestForAdBreaks=function(e,{adSegmentPrefix:t}={}){const i=(new DOMParser).parseFromString(e,"text/xml"),s=[],a=i.querySelector("parsererror");if(a)return n.error("[MT] DASH XML parse error:",a.textContent),s;const d=i.querySelectorAll("Period");if(n.debug(`[MT] Found ${d.length} Period(s) in DASH manifest`),d.length>1)d.forEach(e=>{const i=e.querySelector("BaseURL"),a=i?i.textContent.trim():"",d=[r.MT_SEGMENT_PATTERN,r.MT_DEFAULT_AD_SEGMENT_PATH];if(t&&d.push(t),!d.some(e=>a.includes(e)))return;const o=e.getAttribute("id")||"",l=h(e.getAttribute("start")||"PT0S"),u=h(e.getAttribute("duration")||"");u<r.MIN_AD_DURATION?n.debug(`[MT] Skipping period ${o} - duration too short (${u}s)`):(n.debug(`[MT] Ad period detected: ${o}`,{startTime:l,duration:u}),s.push({id:o,startTime:l,duration:u,endTime:l+u,source:r.AD_SOURCE.MANIFEST_CUE,confirmedByTracking:!1,hasFiredStart:!1,hasFiredEnd:!1,hasFiredAdStart:!1,hasFiredQ1:!1,hasFiredQ2:!1,hasFiredQ3:!1,pods:[]}))});else{const e=i.querySelectorAll(r.DASH_SCTE35_EVENT_STREAM_SELECTOR);n.debug(`[MT] Found ${e.length} SCTE-35 EventStream(s) in single-period manifest`),e.forEach(e=>{const t=parseFloat(e.getAttribute("timescale")||"1");e.querySelectorAll("Event").forEach(e=>{const i=parseFloat(e.getAttribute("presentationTime")||0),a=parseFloat(e.getAttribute("duration")||0),d=e.getAttribute("id")||`${r.SCTE35_SCHEME_MARKER}-${i}`,o=1!==t?i/t:i,l=1!==t?a/t:a;l<r.MIN_AD_DURATION?n.debug(`[MT] Skipping event ${d} - duration too short (${l}s)`):(n.debug(`[MT] SCTE-35 event detected: ${d}`,{startTime:o,durationSeconds:l}),s.push({id:d,startTime:o,duration:l,endTime:o+l,source:r.AD_SOURCE.MANIFEST_CUE,confirmedByTracking:!1,hasFiredStart:!1,hasFiredEnd:!1,hasFiredAdStart:!1,hasFiredQ1:!1,hasFiredQ2:!1,hasFiredQ3:!1,pods:[]}))})})}return n.debug(`[MT] Parsed ${s.length} valid ad break(s) from DASH manifest`),s},t.parseHlsManifestForAdBreaks=function(e){const t=e.split("\n"),i=[];let s=0,a=null,n=null,d=null,o=[],l=!1;for(const e of t){if(r.REGEX_DISCONTINUITY.test(e)&&l&&d){const t=e.match(r.REGEX_MAP),i=t?t[1]:null;if(i&&i!==d){if(null!==n){const e=s-n;o.push({startTime:n,duration:e,endTime:s,mapUrl:d})}n=s,d=i}}const t=e.match(r.REGEX_MAP);if(t&&l){const e=t[1];if(e&&e!==d){if(null!==n){const e=s-n;o.push({startTime:n,duration:e,endTime:s,mapUrl:d})}n=s,d=e}}if(e.startsWith(r.MT_HLS_CUE_OUT_TAG)){const t=e.match(r.REGEX_CUE_OUT);l=!0,o=[],a={id:`avail-${s}`,startTime:s,duration:t?parseFloat(t[1]):null,endTime:null,pods:[],hasFiredStart:!1,hasFiredEnd:!1,hasFiredAdStart:!1,confirmedByTracking:!1}}if(e.startsWith(r.MT_HLS_CUE_IN_TAG)&&a){if(null!==n){const e=s-n;o.push({startTime:n,duration:e,endTime:s,mapUrl:d})}const e=s-a.startTime;e>=r.MIN_AD_DURATION&&(a.duration=e,a.endTime=s,a.pods=o,i.push(a)),a=null,l=!1,n=null,d=null,o=[]}if(e.startsWith(r.HLS_SEGMENT_DURATION_TAG)){const t=parseFloat(e.split(":")[1]);isNaN(t)||(s+=t)}}a&&a.duration&&(a.endTime=a.startTime+a.duration,a.pods=o,i.push(a));return i},t.parseIsoDuration=h,t.whichAdSegmentMarker=function(e,{adSegmentPrefix:t}={}){const i=[{marker:r.MT_SEGMENT_PATTERN,label:"aws-hostname (segments.mediatailor)"},{marker:r.MT_DEFAULT_AD_SEGMENT_PATH,label:"default-cdn-path (/tm/)"}];t&&i.push({marker:t,label:`custom-prefix (${t})`});const s=e.map&&e.map.uri||"",a=e.uri||"",n=i.find(({marker:e})=>s.includes(e)||a.includes(e));return n?n.label:null};var s,a=(s=i(555))&&s.__esModule?s:{default:s},r=i(324);const n=(a.default.default||a.default).Log;function d(e,{adSegmentPrefix:t}={}){const i=[r.MT_SEGMENT_PATTERN,r.MT_DEFAULT_AD_SEGMENT_PATH];t&&i.push(t);const s=e.map&&e.map.uri||"",a=e.uri||"";return i.some(e=>s.includes(e)||a.includes(e))}function o(e){return{q1:e*r.QUARTILES.Q1,q2:e*r.QUARTILES.Q2,q3:e*r.QUARTILES.Q3}}async function l(e){const t=await fetch(e,{credentials:"include"});if(!1===t.ok)throw new Error(`Manifest request failed: ${t.status||"unknown"} ${t.statusText||"Request failed"}`);return await t.text()}function h(e){if(!e)return 0;const t=e.match(r.REGEX_ISO_8601_DURATION);if(!t)return 0;return 3600*parseFloat(t[1]||0)+60*parseFloat(t[2]||0)+parseFloat(t[3]||0)}},472(e,t,i){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=o(i(555)),a=o(i(330)),r=o(i(409)),n=o(i(257)),d=o(i(338));function o(e){return e&&e.__esModule?e:{default:e}}class l extends s.default.VideoTracker{getTech(){const e=this.player.tech({IWillNotUseThisInPlugins:!0});if(e){if(r.default.isUsing(e))return new r.default(e);if(n.default.isUsing(e))return new n.default(e);if(d.default.isUsing(e))return new d.default(e)}}getTrackerName(){return"videojs-ads"}getTrackerVersion(){return a.default.version}isMuted(){return this.player.muted()}getRenditionHeight(){return null}getRenditionWidth(){return null}getPlayerName(){return"videojs-ads"}getPlayerVersion(){return this.player.ads.VERSION}registerListeners(){s.default.Log.debugCommonVideoEvents(this.player,[null,"ads-request","ads-load","adstart","adend","adskip","adserror","ads-click","ads-pod-started","ads-pod-ended","ads-first-quartile","ads-midpoint","ads-third-quartile","ads-pause","ads-play","adtimeout"]),this.player.on("ads-request",this.onAdrequest.bind(this)),this.player.on("ads-load",this.onAdload.bind(this)),this.player.on("adstart",this.onAdstart.bind(this)),this.player.on("adend",this.onAdend.bind(this)),this.player.on("adskip",this.onAdskip.bind(this)),this.player.on("adserror",this.onAdserror.bind(this)),this.player.on("ads-click",this.onAdsClick.bind(this)),this.player.on("ads-pod-started",this.onPodStart.bind(this)),this.player.on("ads-pod-ended",this.onPodEnd.bind(this)),this.player.on("ads-first-quartile",this.onFirstQuartile.bind(this)),this.player.on("ads-midpoint",this.onMidpoint.bind(this)),this.player.on("ads-third-quartile",this.onThirdQuartile.bind(this)),this.player.on("ads-pause",this.onAdspause.bind(this)),this.player.on("ads-play",this.onAdsplay.bind(this))}unregisterListeners(){this.player.off("ads-request",this.onAdrequest),this.player.off("ads-load",this.onAdload),this.player.off("adstart",this.onAdstart),this.player.off("adend",this.onAdend),this.player.off("adskip",this.onAdskip),this.player.off("adserror",this.onAdserror),this.player.off("ads-click",this.onAdsClick),this.player.off("ads-pod-started",this.onPodStart),this.player.off("ads-pod-ended",this.onPodEnd),this.player.off("ads-first-quartile",this.onFirstQuartile),this.player.off("ads-midpoint",this.onMidpoint),this.player.off("ads-third-quartile",this.onThirdQuartile),this.player.off("ads-pause",this.onAdspause),this.player.off("ads-play",this.onAdsplay)}onAdrequest(e){this.sendRequest(),this.sendDownload({state:"ads-request"})}onAdload(e){this.sendDownload({state:"ads-load"})}onAdstart(e){this.sendRequest(),this.sendStart()}onAdend(e){this.sendEnd()}onAdskip(e){this.sendEnd({skipped:!0})}onAdserror(e){this.sendError()}onAdsClick(e){this.sendAdClick({url:"unknown"})}onPodStart(e){this.sendAdBreakStart()}onPodEnd(e){this.sendAdBreakEnd()}onFirstQuartile(){this.sendAdQuartile({quartile:1})}onMidpoint(){this.sendAdQuartile({quartile:2})}onThirdQuartile(){this.sendAdQuartile({quartile:3})}onAdspause(){this.sendPause()}onAdsplay(){this.sendResume()}}t.default=l},409(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;class i{constructor(e){this.tech=e.vhs,this.player=e.el().player}getRenditionName(){try{var e=this.tech.playlists.media();if(e&&e.attributes)return e.attributes.NAME}catch(e){}return null}getRenditionBitrate(){try{var e=this.tech.playlists.media();if(e&&e.attributes)return Math.round(e.attributes.BANDWIDTH)}catch(e){}return null}getRenditionWidth(){try{var e=this.tech.playlists.media();if(e&&e.attributes&&e.attributes.RESOLUTION)return e.attributes.RESOLUTION.width}catch(e){}return null}getRenditionHeight(){try{var e=this.tech.playlists.media();if(e&&e.attributes&&e.attributes.RESOLUTION)return e.attributes.RESOLUTION.height}catch(e){}return null}getBitrate(){return this.getContentBitratePlayback()}getManifestBitrate(){try{const e=this.tech.playlists.master.playlists;if(e&&e.length>0)return Math.round(Math.max(...e.map(e=>e.attributes.BANDWIDTH)))}catch(e){}return null}getSegmentDownloadBitrate(){return void 0!==this.tech.stats?.bandwidth&&this.tech.stats.bandwidth>0?Math.round(this.tech.stats.bandwidth):null}getNetworkDownloadBitrate(){return void 0!==this.tech.throughput&&this.tech.throughput>0?Math.round(this.tech.throughput):null}getContentBitratePlayback(){try{const e=this.tech.playlists.media();if(e&&e.attributes){const t=e.attributes["AVERAGE-BANDWIDTH"]||e.attributes.BANDWIDTH||null;return null!==t?Math.round(t):null}}catch(e){}return null}}t.default=i,i.isUsing=function(e){return!!e.vhs}},257(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;class i{constructor(e){this.tech=e.vhs_,this.player=e.el().player}getResource(e){return this.tech.url}getRenditionName(e){try{var t=this.tech.levels[this.tech.currentLevel];if(t&&t.name)return t.name}catch(e){}return null}getRenditionBitrate(e){try{var t=this.tech.levels[this.tech.currentLevel];if(t&&t.bitrate)return Math.round(t.bitrate)}catch(e){}return null}getRenditionWidth(e){try{var t=this.tech.levels[this.tech.currentLevel];if(t&&t.width)return t.width}catch(e){}return null}getRenditionHeight(e){try{var t=this.tech.levels[this.tech.currentLevel];if(t&&t.height)return t.height}catch(e){}return null}getBitrate(){return this.getContentBitratePlayback()}getContentBitratePlayback(){try{const e=this.tech.levels[this.tech.currentLevel];if(e&&e.bitrate)return Math.round(e.bitrate)}catch(e){}return null}getManifestBitrate(){try{if(this.tech.levels&&this.tech.levels.length>0)return Math.round(Math.max(...this.tech.levels.map(e=>e.bitrate)))}catch(e){}return null}getSegmentDownloadBitrate(){try{if(this.tech.stats&&this.tech.stats.bandwidth>0)return Math.round(this.tech.stats.bandwidth)}catch(e){}return null}getNetworkDownloadBitrate(){return this.tech.throughput&&this.tech.throughput>0?Math.round(this.tech.throughput):null}}t.default=i,i.isUsing=function(e){return!!e.vhs_}},338(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;class i{constructor(e){this.tech=e.shakaPlayer,this.player=e.el().player}getSrc(e){try{return this.tech.getManifestUri()}catch(e){}return null}getRenditionBitrate(e){try{const e=this.tech.getStats().streamBandwidth;return e?Math.round(e):null}catch(e){}return null}getManifestBitrate(){try{const e=this.tech.getVariantTracks();if(e&&e.length>0)return Math.round(Math.max(...e.map(e=>e.videoBandwidth+(e.audioBandwidth||0))))}catch(e){}return null}getRenditionWidth(e){try{var t=this.tech.getVariantTracks();for(var i in t){var s=t[i];if(s.active&&"video"===s.type)return s.width}}catch(e){}return null}getRenditionHeight(e){try{var t=this.tech.getVariantTracks();for(var i in t){var s=t[i];if(s.active&&"video"===s.type)return s.height}}catch(e){}return null}getBitrate(){return this.getContentBitratePlayback()}getContentBitratePlayback(){try{var e=this.tech.getStats();if(e&&e.streamBandwidth&&e.streamBandwidth>0)return Math.round(e.streamBandwidth)}catch(e){}return null}getSegmentDownloadBitrate(){try{var e=this.tech.getStats();if(e&&e.estimatedBandwidth>0)return Math.round(e.estimatedBandwidth)}catch(e){}return null}getNetworkDownloadBitrate(){try{var e=this.tech.getStats();if(e&&e.estimatedBandwidth>0)return Math.round(e.estimatedBandwidth)}catch(e){}return null}}t.default=i,i.isUsing=function(e){return!!e.shakaPlayer}},302(e,t,i){Object.defineProperty(t,"__esModule",{value:!0}),t.AD_TRACKING=void 0,Object.defineProperty(t,"BrightcoveImaAdsTracker",{enumerable:!0,get:function(){return h.default}}),Object.defineProperty(t,"ContribHlsTech",{enumerable:!0,get:function(){return r.default}}),Object.defineProperty(t,"DaiAdsTracker",{enumerable:!0,get:function(){return c.default}}),Object.defineProperty(t,"FreewheelAdsTracker",{enumerable:!0,get:function(){return u.default}}),Object.defineProperty(t,"HlsJsTech",{enumerable:!0,get:function(){return n.default}}),Object.defineProperty(t,"ImaAdsTracker",{enumerable:!0,get:function(){return l.default}}),Object.defineProperty(t,"MediaTailorAdsTracker",{enumerable:!0,get:function(){return g.default}}),Object.defineProperty(t,"ShakaTech",{enumerable:!0,get:function(){return d.default}}),Object.defineProperty(t,"VideojsAdsTracker",{enumerable:!0,get:function(){return o.default}}),t.default=void 0;var s=m(i(555)),a=m(i(330)),r=m(i(409)),n=m(i(257)),d=m(i(338)),o=m(i(472)),l=m(i(298)),h=m(i(64)),u=m(i(38)),c=m(i(717)),g=m(i(687));function m(e){return e&&e.__esModule?e:{default:e}}const A=t.AD_TRACKING={CSAI:"csai",SSAI:Object.freeze({DAI:"ssai:dai",MT:"ssai:mt"})};class T extends s.default.VideoTracker{constructor(e,t){if(super(e,t),this.options=t,this.isContentEnd=!1,this.imaAdCuePoints="",this.daiInitialized=!1,this.adTracking=t?.config?.ad?.type||null,this.previousBitrate=null,t&&!this.adTracking&&s.default.Log.warn("VideojsTracker: config.ad not set — no ad tracking will run. Set config.ad.type to enable it (e.g. AD_TRACKING.CSAI, AD_TRACKING.SSAI.MT)."),this.adTracking===A.SSAI.MT){const e=t?.config?.ad||{};this.options=Object.assign({},this.options,{mediatailor:{segmentPrefix:e.segmentPrefix,trackingUrl:e.trackingUrl,...this.options?.mediatailor}})}s.default.Core.addTracker(this,t)}setAdTracking(e){const t=[A.CSAI,...Object.values(A.SSAI)];t.includes(e)?(this.adTracking=e,s.default.Log.debug(`VideojsTracker: adTracking set to "${e}"`)):s.default.Log.warn(`VideojsTracker.setAdTracking: unknown value "${e}". Valid values: ${t.join(", ")}`)}getTech(){let e=this.player.tech({IWillNotUseThisInPlugins:!0});if(e){if(r.default.isUsing(e))return new r.default(e);if(n.default.isUsing(e))return new n.default(e);if(d.default.isUsing(e))return new d.default(e)}}getTrackerName(){return"videojs"}getInstrumentationProvider(){return"New Relic"}getInstrumentationName(){return this.getPlayerName()}getInstrumentationVersion(){return this.getPlayerVersion()}getTrackerVersion(){return a.default.version}getPlayhead(){return this.player.ads&&"ads-playback"===this.player.ads.state&&this.player.ads.snapshot&&this.player.ads.snapshot.currentTime?1e3*this.player.ads.snapshot.currentTime:this.player.absoluteTime?1e3*this.player.absoluteTime():1e3*this.player.currentTime()}getDuration(){return this.player.mediainfo&&void 0!==this.player.mediainfo.duration?1e3*this.player.mediainfo.duration:1e3*this.player.duration()}getTitle(){return this.player?.mediainfo?.name}getId(){return this.player?.mediainfo?.id}getLanguage(){return this.player?.language()}getSrc(){let e=this.getTech();return e&&e.getSrc?e.getSrc():this.player.currentSrc()}getPlayerName(){return this.player?.name()||"videojs"}getPlayerVersion(){return this.player?.version||videojs.VERSION}isMuted(){return this.player.muted()}getBitrate(){return this.getContentBitratePlayback()}getContentBitratePlayback(){try{const e=this.player.tech({IWillNotUseThisInPlugins:!0});if(e?.vhs?.playlists?.media()){const t=e.vhs.playlists.media(),i=t.attributes["AVERAGE-BANDWIDTH"]||t.attributes.BANDWIDTH||null;return null!==i?Math.round(i):null}const t=this.getTech();if(t?.getBitrate){const e=t.getBitrate();return null!==e?Math.round(e):null}}catch(e){}return null}getRenditionName(){let e=this.getTech();if(e&&e.getRenditionName)return e.getRenditionName()}getManifestBitrate(){try{const e=this.player.tech({IWillNotUseThisInPlugins:!0}),t=e?.vhs?.playlists?.master?.playlists;if(t&&t.length>0){const e=Math.max(...t.map(e=>e.attributes.BANDWIDTH||0));return e>0?Math.round(e):null}const i=this.getTech();if(i?.getManifestBitrate){const e=i.getManifestBitrate();return null!==e?Math.round(e):null}}catch(e){}return null}getSegmentDownloadBitrate(){try{const e=this.player.tech({IWillNotUseThisInPlugins:!0});if(e?.vhs?.stats?.bandwidth&&e.vhs.stats.bandwidth>0)return Math.round(e.vhs.stats.bandwidth);const t=this.getTech();if(t?.getSegmentDownloadBitrate){const e=t.getSegmentDownloadBitrate();return null!==e?Math.round(e):null}}catch(e){}return null}getNetworkDownloadBitrate(){const e=this.player.tech({IWillNotUseThisInPlugins:!0});if(e?.vhs?.throughput&&e.vhs.throughput>0)return Math.round(e.vhs.throughput);const t=this.getTech();if(t?.getNetworkDownloadBitrate){const e=t.getNetworkDownloadBitrate();return null!==e?Math.round(e):null}return null}getRenditionHeight(){let e=this.getTech();return e&&e.getRenditionHeight?e.getRenditionHeight():this.player.videoHeight()}getRenditionWidth(){let e=this.getTech();return e&&e.getRenditionWidth?e.getRenditionWidth():this.player.videoWidth()}getPlayrate(){return this.player.playbackRate()}isAutoplayed(){return this.player.autoplay()}isFullscreen(){return this.player.isFullscreen()}getPreload(){return this.player.preload()}registerListeners(){s.default.Log.debugCommonVideoEvents(this.player,["adstart","adend","adskip","adsready","adserror","dispose"]),this.onDownload=this.onDownload.bind(this),this.onAdsready=this.onAdsready.bind(this),this.onAdStart=this.onAdStart.bind(this),this.onAdEnd=this.onAdEnd.bind(this),this.onPlay=this.onPlay.bind(this),this.onPause=this.onPause.bind(this),this.onPlaying=this.onPlaying.bind(this),this.onAbort=this.onAbort.bind(this),this.onEnded=this.onEnded.bind(this),this.onDispose=this.onDispose.bind(this),this.onSeeking=this.onSeeking.bind(this),this.onSeeked=this.onSeeked.bind(this),this.onError=this.onError.bind(this),this.onWaiting=this.onWaiting.bind(this),this.onTimeupdate=this.onTimeupdate.bind(this),this.OnAdsAllpodsCompleted=this.OnAdsAllpodsCompleted.bind(this),this.onStreamManager=this.onStreamManager.bind(this),this.onCanPlayThrough=this.onCanPlayThrough.bind(this),this.player.on("loadstart",this.onDownload),this.player.on("loadeddata",this.onDownload),this.player.on("loadedmetadata",this.onDownload),this.player.on("adsready",this.onAdsready),this.player.on("adstart",this.onAdStart),this.player.on("adend",this.onAdEnd),this.player.on("play",this.onPlay),this.player.on("pause",this.onPause),this.player.on("playing",this.onPlaying),this.player.on("abort",this.onAbort),this.player.on("ended",this.onEnded),this.player.on("dispose",this.onDispose),this.player.on("seeking",this.onSeeking),this.player.on("seeked",this.onSeeked),this.player.on("error",this.onError),this.player.on("waiting",this.onWaiting),this.player.on("timeupdate",this.onTimeupdate),this.player.on("ads-allpods-completed",this.OnAdsAllpodsCompleted),this.player.on("stream-manager",this.onStreamManager),this.player.on("canplaythrough",this.onCanPlayThrough),this.onQualityLevelChange=this.onQualityLevelChange.bind(this),"function"==typeof this.player.qualityLevels&&(this.qualityLevels=this.player.qualityLevels(),this.qualityLevels&&this.qualityLevels.on("change",this.onQualityLevelChange))}unregisterListeners(){this.player.off("loadstart",this.onDownload),this.player.off("loadeddata",this.onDownload),this.player.off("loadedmetadata",this.onDownload),this.player.off("adsready",this.onAdsready),this.player.off("adstart",this.onAdStart),this.player.off("adend",this.onAdEnd),this.player.off("play",this.onPlay),this.player.off("pause",this.onPause),this.player.off("playing",this.onPlaying),this.player.off("abort",this.onAbort),this.player.off("ended",this.onEnded),this.player.off("dispose",this.onDispose),this.player.off("seeking",this.onSeeking),this.player.off("seeked",this.onSeeked),this.player.off("error",this.onError),this.player.off("waiting",this.onWaiting),this.player.off("timeupdate",this.onTimeupdate),this.player.off("ads-allpods-completed",this.OnAdsAllpodsCompleted),this.player.off("stream-manager",this.onStreamManager),this.player.off("canplaythrough",this.onCanPlayThrough),this.qualityLevels&&this.qualityLevels.off("change",this.onQualityLevelChange)}onDownload(e){this.sendDownload({state:e.type}),this.adTracking!==A.SSAI.MT||this.adsTracker||"loadstart"!==e.type||(s.default.Log.debug("VideojsTracker: Creating MediaTailorAdsTracker"),this.setAdsTracker(new g.default(this.player,this.options)),this.adsTracker.setIsAd(!1))}onStreamManager(e){if(this.adTracking===A.SSAI.DAI&&!this.adsTracker&&e.StreamManager){const t=new c.default(this.player);t.setStreamManager(e.StreamManager),this.setAdsTracker(t)}}onAdsready(){Object.values(A.SSAI).includes(this.adTracking)||(this.adTracking||s.default.Log.warn("VideojsTracker: adsready fired but config.ad.type is not set — attempting CSAI auto-detection for backward compatibility."),this.adsTracker||(h.default.isUsing(this.player)?(s.default.Log.debug("VideojsTracker: auto-detected BrightcoveImaAdsTracker"),this.setAdsTracker(new h.default(this.player))):l.default.isUsing(this.player)?(s.default.Log.debug("VideojsTracker: auto-detected ImaAdsTracker"),this.setAdsTracker(new l.default(this.player))):u.default.isUsing(this.player)?(s.default.Log.debug("VideojsTracker: auto-detected FreewheelAdsTracker"),this.setAdsTracker(new u.default(this.player))):(s.default.Log.debug("VideojsTracker: no specific CSAI framework detected, using generic VideojsAdsTracker"),this.setAdsTracker(new o.default(this.player)))))}onAdStart(){this.currentAdPlaying=!0,this.imaAdCuePoints||(this.imaAdCuePoints=this.player?.ima?.getAdsManager().getCuePoints())}onAdEnd(){this.isContentEnd&&this.sendEnd()}OnAdsAllpodsCompleted(){this.onEnded.bind(this),this.FreewheelAdsCompleted=!0}isAdsTrackerActive(){return this.player.ads?"ads-playback"===this.player.ads.state:this.adsTracker&&this.adsTracker.isAd&&this.adsTracker.isAd()}onPlay(){this.sendRequest()}onPause(){this.isAdsTrackerActive()||this.player.ended()||this.sendPause()}onCanPlayThrough(){this.isAdsTrackerActive()||this.sendBufferEnd()}onPlaying(){this.isAdsTrackerActive()||(this.sendResume(),this.sendBufferEnd())}onAbort(){this.sendEnd()}onEnded(){this.adsTracker?(this.isContentEnd=!0,this.imaAdCuePoints&&!this.imaAdCuePoints.includes(-1)&&this.sendEnd()):this.sendEnd()}onDispose(){this.sendEnd()}onSeeking(){this.isAdsTrackerActive()||this.sendSeekStart()}onSeeked(){this.isAdsTrackerActive()||this.sendSeekEnd()}onError(){const e=this.player.error(),t=e.code,i=e.message;this.player.error&&this.player.error()&&this.sendError({errorCode:t,errorMessage:i})}onWaiting(e){this.isAdsTrackerActive()||this.sendBufferStart()}onTimeupdate(e){this.getPlayhead()>.1&&this.sendStart()}onQualityLevelChange(e){if(this.qualityLevels&&this.qualityLevels.selectedIndex>=0){const e=this.qualityLevels[this.qualityLevels.selectedIndex];if(e){const t=e.bitrate,i=this.previousBitrate;this.sendRenditionChanged({oldBitrate:i,newBitrate:t}),this.previousBitrate=t}}}}t.default=T,T.AD_TRACKING=A,T.Log=s.default.Log},330(e){e.exports=JSON.parse('{"name":"@newrelic/video-videojs","version":"4.2.1","description":"New relic tracker for Videojs","main":"dist/cjs/index.js","module":"dist/esm/index.js","scripts":{"build":"webpack --mode production","build:dev":"webpack --mode development","watch":"webpack --mode production --progress --color --watch","watch:dev":"webpack --progress --color --watch --mode development","prezip":"npm run build","zip":"zip -P newrelic -x \'*.DS_Store\' -x \'samples/agent.js\' -r videojs.zip dist samples README.md CHANGELOG.md EULA.md","clean":"rm -rf dist *.zip","deploy":"node scripts/deploy.js","third-party-updates":"oss third-party manifest --includeOptDeps && oss third-party notices --includeOptDeps && git add THIRD_PARTY_NOTICES.md third_party_manifest.json"},"repository":{"type":"git","url":"https://github.com/newrelic/video-videojs-js.git"},"author":"Jordi Aguilar","contributors":["Andreu Santarén Llop","Bharat Saraswat","Malay Chandan"],"license":"Apache-2.0","devDependencies":{"@babel/core":"^7.24.5","@babel/plugin-transform-modules-commonjs":"^7.24.1","@babel/preset-env":"^7.24.5","@newrelic/newrelic-oss-cli":"^0.1.2","@semantic-release/changelog":"^6.0.3","@semantic-release/commit-analyzer":"^12.0.0","@semantic-release/git":"^10.0.1","@semantic-release/github":"^10.0.3","@semantic-release/npm":"^12.0.0","@semantic-release/release-notes-generator":"^13.0.0","aws-sdk":"^2.920.0","babel-loader":"^9.1.3","semantic-release":"^23.0.8","videojs-ima":"2.1.0","webpack":"^5.91.0","webpack-cli":"^4.9.2"},"files":["THIRD_PARTY_NOTICES.md","dist","CHANGELOG.md","README.md","src","!test"],"publishConfig":{"access":"public"},"dependencies":{"@newrelic/video-core":"^4.1.5"}}')}},t={};function i(s){var a=t[s];if(void 0!==a)return a.exports;var r=t[s]={exports:{}};return e[s](r,r.exports,i),r.exports}i.d=(e,t)=>{for(var s in t)i.o(t,s)&&!i.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};(()=>{var e=s;Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t,a=(t=i(302))&&t.__esModule?t:{default:t};e.default=a.default})(),module.exports.VideojsTracker=s})();
|
|
3
3
|
//# sourceMappingURL=index.js.map
|