(()=>{"use strict";class e{static enabled(){var e;return"on"===(null===(e=i.extractCookieValue(null===document||void 0===document?void 0:document.cookie,"APP_DEBUG"))||void 0===e?void 0:e.toLowerCase())}static log(...t){e.enabled()&&console.log(`${CBS.Registry.chromecast.receiver_id}:`,...t)}static debug(...t){e.enabled()&&console.debug(`${CBS.Registry.chromecast.receiver_id}:`,...t)}static error(...e){console.error(`${CBS.Registry.chromecast.receiver_id}:`,...e)}static warn(...e){console.warn(`${CBS.Registry.chromecast.receiver_id}:`,...e)}static info(...e){console.info(`${CBS.Registry.chromecast.receiver_id}:`,...e)}}const t="LIVE";var a=function(e,t,a,o){return new(a||(a=Promise))((function(i,s){function n(e){try{l(o.next(e))}catch(e){s(e)}}function r(e){try{l(o.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof a?t:new a((function(e){e(t)}))).then(n,r)}l((o=o.apply(e,t||[])).next())}))};const o=["/watch/","/trailer/"];class i{static setTagVO(e){i.$tagVO=e}static gettagVO(){return i.$tagVO}static updateTagVOProp(e,t){i.$tagVO[e]=Object.assign(Object.assign({},i.$tagVO[e]),t)}static setRegistry(e){i.$registry=e}static getRegistry(){return i.$registry}static getContentID(){var e,t;const a=i.getMediaInformationFromPage();return null!==(t=null===(e=null==a?void 0:a.CONTENT)||void 0===e?void 0:e.refIdForCast)&&void 0!==t?t:""}static getContentType(){var e,t;const a=i.getMediaInformationFromPage();return(null==a?void 0:a.CONTENT)&&((null===(e=a.CONTENT.drm)||void 0===e?void 0:e.enabled)||["Trailer","Clip"].includes(null===(t=(a.CONTENT.metadata||[])[0])||void 0===t?void 0:t.mediaType))?"application/dash+xml":"application/x-mpegurl"}static isLive(){var e,t;const a=i.getMediaInformationFromPage();return null!==(t=null===(e=null==a?void 0:a.CONTENT)||void 0===e?void 0:e.isLive)&&void 0!==t&&t}static isLiveStreamType(e){return(e+"").toLowerCase()===t.toLowerCase()}static getDAIStreamKey(){var e,t,a;const o=i.getMediaInformationFromPage();return null!==(a=null===(t=null===(e=null==o?void 0:o.CONTENT)||void 0===e?void 0:e.metadata[0])||void 0===t?void 0:t.daistreamKey)&&void 0!==a?a:""}static getVideoProperties(){var e,t,a;const o=i.getMediaInformationFromPage();return null!==(a=null===(t=null===(e=null==o?void 0:o.CONTENT)||void 0===e?void 0:e.metadata[0])||void 0===t?void 0:t.videoProperties)&&void 0!==a?a:[]}static getContinuousPlay(){const e=`continuous_play_${CBS.Registry.user.profile_id}`,t=localStorage.getItem(e);return"true"===t||!t}static getCBSCookie(){return i.getCookie("CBS_COM")}static getSession(){var e,t,a,o;let s={};try{s=JSON.parse(null===(o=null===(a=null===(t=null===(e=i.gettagVO())||void 0===e?void 0:e.params)||void 0===t?void 0:t.CONTEXT)||void 0===a?void 0:a.metadata)||void 0===o?void 0:o["ss.episode"])}catch(e){s={error:e}}return s}static getMediaInformationFromPage(){return i.gettagVO()&&i.gettagVO().params?i.gettagVO().params:{}}static getCookie(e){const t=document.cookie.split(";");for(const a of t){const t=a.split("="),o=decodeURIComponent(t[0].trim()),i=t.length>1?t[1]:"";if(o===e)return decodeURIComponent(i)}return""}static getCustomDataObject(){var e,t,a;const o={};if(i.isLive()){if(i.getStationName())o.stationName=i.getStationName();else{switch(i.getStreamType()){case"cbsn":o.liveContent="CBSN";break;case"etl":o.liveContent="ETL";break;case"sports_hq":o.liveContent="SPORTS_HQ";break;case"live_stream":o.liveContent="LIVE_STREAM"}}i.getLatitude()&&(o.latitude=parseFloat(i.getLatitude())),i.getLongitude()&&(o.longitude=parseFloat(i.getLongitude()))}const s=i.getAdSessionValues();s&&(o.video_ad_session_values=s);const n=i.getMVPDAuthZObj();return n&&n.mvpd_name&&""!==n.mvpd_name&&(o.mvpd=n.mvpd_name,o.mvpd_name=n.mvpd_display_name),o.vguid=null!==(e=window.__page_uuid)&&void 0!==e?e:"",o.ptype=null!==(a=null===(t=window.utag_data)||void 0===t?void 0:t.pageType)&&void 0!==a?a:"",o}static getCoords(){var e,t,a;return i.getRegistry()&&i.getRegistry().location?i.getRegistry().location.coords:i.getLocation()&&(null===(e=i.getLocation())||void 0===e?void 0:e.coords)&&null!==(a=null===(t=i.getLocation())||void 0===t?void 0:t.coords)&&void 0!==a?a:null}static getLatitude(){var e;const t=i.getCoords();return null!==(e=null==t?void 0:t.latitude)&&void 0!==e?e:""}static getLongitude(){var e;const t=i.getCoords();return null!==(e=null==t?void 0:t.longitude)&&void 0!==e?e:""}static getStationName(){var e,t;const a=i.getMediaInformationFromPage();return null!==(t=null===(e=null==a?void 0:a.CONTENT)||void 0===e?void 0:e.stationName)&&void 0!==t?t:""}static setLocation(e){i.$geolocation=e}static getLocation(){return i.$geolocation}static getAdSessionValues(){const e={},t=i.getCookie("CBS_ADV_VAL"),a=i.getCookie("CBS_ADV_SUBSES_VAL");if(null!=t&&""!==t&&(e.session=t),null!=a&&""!==a&&(e.subses=a),Object.keys(e).length)return e}static getUserId(){var e,t;return null===(t=null===(e=i.getRegistry())||void 0===e?void 0:e.user)||void 0===t?void 0:t.id}static getMarketingCloudUserId(){var e;return null===(e=window.s)||void 0===e?void 0:e.marketingCloudVisitorID}static getStreamType(){var e,t,a,o;return null!==(o=null===(a=null===(t=null===(e=i.getRegistry())||void 0===e?void 0:e.paramsVO)||void 0===t?void 0:t.setByPage)||void 0===a?void 0:a.streamType)&&void 0!==o?o:""}static getGDPRConsent(){var e;return a(this,void 0,void 0,(function*(){return yield null===(e=i.getRegistry())||void 0===e?void 0:e.fwGPDRPromise}))}static isEmptyObject(e){return!e||0===Object.keys(e).length}static getMVPDAuthZObj(){const t=i.getCookie("mvpd_authz");try{const e=JSON.parse(t);if(e&&"object"==typeof e)return e}catch(a){e.warn(`Error parsing mvpd_authz cookie: ${t}`)}return null}static getChannelInfo(){var e,t,a;return null===(a=null===(t=null===(e=i.gettagVO().params.CONTENT)||void 0===e?void 0:e.channelInfo)||void 0===t?void 0:t.currentListing)||void 0===a?void 0:a.find((e=>e.videoContentId===i.gettagVO().params.CONTENT.refIdForCast))}static getChannelSlug(){var e,t;return(null===(t=null===(e=i.gettagVO().params.CONTENT)||void 0===e?void 0:e.channelInfo)||void 0===t?void 0:t.slug)||null}static isSFBStream(){var e;return!!(null===(e=i.getChannelInfo())||void 0===e?void 0:e.gameStartTimestamp)}static getShowPage(){var e,t;return null===(t=null===(e=this.getChannelInfo())||void 0===e?void 0:e.contentCANVideo)||void 0===t?void 0:t.showPageUrl}static extractCookieValue(e,t){const a=new RegExp(`\\b${t}\\b`,"gi");return-1===e.search(a)?null:decodeURIComponent(e.substr(e.search(a)+t.length+1).substr(0,e.substr(e.search(a)+t.length+1).search(/(&|;|$)/)))}static indexOfSkipURI(e){return o.find((t=>e.indexOf(t)>=0))}static isMovie(e){return 1===e}static getFormattedAdBreaks(e,t){const a=[];if(Array.isArray(e)){let o;for(let i=0;i<e.length;i++)o=Object.assign({},e[i]),o.startMediaTime=o.startTime=parseInt(`${o.position}`,10),o.position="post",0===Math.floor(o.startTime)?o.position="pre":o.startTime>0&&o.startTime<t&&(o.position="mid"),o.isUnwatched=o.isWatched,o.durationMediaTime=o.duration,o.index=i+1,a.push(o)}return a}static clamp(e,t,a){return Math.min(Math.max(e,t),a)}}var s=function(e,t,a,o){return new(a||(a=Promise))((function(i,s){function n(e){try{l(o.next(e))}catch(e){s(e)}}function r(e){try{l(o.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof a?t:new a((function(e){e(t)}))).then(n,r)}l((o=o.apply(e,t||[])).next())}))};class n{constructor(){this.defaultAppID=CBS.Registry.chromecast.receiver_id,this.$disconnectTime=0,this.$soundSettings=null,this.currentContentId="",this.liveEdgeDelta=10,this.liveEdgeSeekDelta=1,this.liveSeekableRange=null,this.isLts=!1,this.sessionStartTime=Date.now()/1e3}init(e,t=this.defaultAppID,a=chrome.cast.AutoJoinPolicy.TAB_AND_ORIGIN_SCOPED){this.$castToLocal=e,this.$castContext=cast.framework.CastContext.getInstance(),this.$remotePlayer=new cast.framework.RemotePlayer,this.$remotePlayerController=new cast.framework.RemotePlayerController(this.$remotePlayer),this.$castContext.setOptions({receiverApplicationId:t,autoJoinPolicy:a}),this.addEventListeners(),this.$castToLocal.enable()}get volumeLevel(){return this.$remotePlayer.volumeLevel}get currentCastSession(){var e;return null===(e=this.$castContext)||void 0===e?void 0:e.getCurrentSession()}get castSessionID(){var e;return null===(e=this.currentCastSession)||void 0===e?void 0:e.getSessionId()}get mediaSession(){var e,t;return null!==(t=null===(e=this.currentCastSession)||void 0===e?void 0:e.getMediaSession())&&void 0!==t?t:null}get pageURI(){var e,t;return null===(t=null===(e=this.mediaInfo)||void 0===e?void 0:e.customData)||void 0===t?void 0:t.page_uri}get mediaInfo(){var e;return null===(e=this.mediaSession)||void 0===e?void 0:e.media}get castDeviceName(){var e,t;return null===(t=null===(e=this.currentCastSession)||void 0===e?void 0:e.getCastDevice())||void 0===t?void 0:t.friendlyName}get mediaTitle(){return this.$remotePlayer.title}get mediaDuration(){var e;return null===(e=this.mediaInfo)||void 0===e?void 0:e.duration}get breaks(){var e;return null===(e=this.mediaInfo)||void 0===e?void 0:e.breaks}get currentTime(){var e;return null===(e=this.mediaSession)||void 0===e?void 0:e.getEstimatedTime()}get playerState(){return this.$remotePlayer.playerState}requestSession(){this.$castContext&&this.$castContext.requestSession()}loadRequest(t=!1){var a,o,n,r,l;return s(this,void 0,void 0,(function*(){const s=i.getContentID(),d=i.getContentType(),c=i.isLive();s&&this.currentCastSession||e.error("Valid params needed to make a loadRequest");const u=new chrome.cast.media.MediaInfo(s,d);u.streamType=c?chrome.cast.media.StreamType.LIVE:chrome.cast.media.StreamType.BUFFERED;const v=i.getCustomDataObject();v.slug=i.getChannelSlug(),v.cbs_com_cookie=i.getCBSCookie(),v.userId=i.getUserId(),v.marketingCloudUserId=i.getMarketingCloudUserId(),v.daistreamKey=i.getDAIStreamKey()||"",v.videoProperties=i.getVideoProperties()||[],v.region=CBS.Registry.region,v.continuousPlay=i.getContinuousPlay(),v.userPlaybackConfig={startFromBeginning:t};let m={};try{m=this.getCurrentStartTimeObject(c),c&&(v.streamStartUTC=Date.now()/1e3-m.playbackTime)}catch(e){m=this.resolveStartTimeLegacy()}if(this.$castToLocal.getCaptionsStyle()&&this.$castToLocal.getCaptionsStyle().language){const e=this.$castToLocal.getCaptionsStyle();v.captionsLanguage=e.language,u.textTrackStyle=this.processTextTrackStyles(e)}this.$castToLocal.getAudioTrackInfo()&&this.$castToLocal.getAudioTrackInfo().language?v.audioLanguage=this.$castToLocal.getAudioTrackInfo().language:v.audioLanguage="en",this.$castToLocal.getAudioTrackInfo()&&this.$castToLocal.getAudioTrackInfo().type&&(v.audioTrackRole=this.$castToLocal.getAudioTrackInfo().type);const g=yield i.getGDPRConsent();v.adParams={_fw_content_language:null===(o=null===(a=v.region)||void 0===a?void 0:a.locale)||void 0===o?void 0:o.split("-")[0],region:(null===(r=null===(n=v.region)||void 0===n?void 0:n.property)||void 0===r?void 0:r.toLowerCase())||"",_fw_gdpr:(null==g?void 0:g.gdpr)||0,_fw_gdpr_consent:(null==g?void 0:g.gdpr_consent)||"",language_selection:v.audioLanguage.split("-")[0],ptype:v.ptype,vguid:v.vguid},u.metadata=new chrome.cast.media.GenericMediaMetadata,u.customData=v;const h=new chrome.cast.media.LoadRequest(u);return h.currentTime=c?m.streamTime-m.playbackTime:m.contentTime,null===(l=this.currentCastSession)||void 0===l?void 0:l.loadMedia(h)}))}seek(e){var t,a;if(!isNaN(e)){if(this.isLts){const o=(null===(t=this.liveSeekableRange)||void 0===t?void 0:t.start)||0,s=(null===(a=this.liveSeekableRange)||void 0===a?void 0:a.end)||2e6;e=i.clamp(o+e,o,s)}this.$remotePlayer.currentTime=e,this.$remotePlayerController.seek()}}play(){this.$remotePlayer.isPaused&&this.$remotePlayerController.playOrPause()}pause(){this.$remotePlayer.isPaused||this.$remotePlayerController.playOrPause()}mute(e){this.$remotePlayer.isMuted!==e&&this.$remotePlayerController.muteOrUnmute()}isConnected(){return!!this.$castContext&&(this.$castContext.getCastState()===cast.framework.CastState.CONNECTING||this.$castContext.getCastState()===cast.framework.CastState.CONNECTED)}reconnectLocalToCast(){this.$castToLocal.connecting()}setVolume(e){!isNaN(e)&&e>=0&&(this.$remotePlayer.volumeLevel=Math.min(e,1),this.$remotePlayerController.setVolumeLevel())}castMedia(t){var a,o,s,n,r,l,d,c,u,v;if(this.$castToLocal.connect(),this.syncVolumeToSender(),this.isConnected()&&!this.mediaInfo)return e.debug("Starting new session"),void this.processLoadRequest(t);const m=null!==(a=i.getChannelSlug())&&void 0!==a?a:null,g=null!==(l=null===(r=null===(n=null===(s=null===(o=this.mediaInfo)||void 0===o?void 0:o.customData)||void 0===s?void 0:s.video)||void 0===n?void 0:n.channel)||void 0===r?void 0:r.slug)&&void 0!==l?l:null;if(this.isConnected()&&(i.getContentID()!==(null===(d=this.mediaInfo)||void 0===d?void 0:d.contentId)||m!==g))return e.debug("Joining existing session with new content",{old:this.mediaInfo,new:null===(u=null===(c=i.getMediaInformationFromPage())||void 0===c?void 0:c.CONTENT)||void 0===u?void 0:u.metadata}),void(i.isSFBStream()&&void 0===t?this.$castToLocal.preCastHandler():this.processLoadRequest(t));i.getContentID()===(null===(v=this.mediaInfo)||void 0===v?void 0:v.contentId)&&(e.debug("Joining existing session with same content",this.mediaInfo),this.onLoadSuccess(),this.setMetaInfo())}updateCaptions(e,t=null,a=null){this.updateTracks(chrome.cast.media.TrackType.TEXT,e,t,a)}updateAudioTracks(e,t,a){this.updateTracks(chrome.cast.media.TrackType.AUDIO,e,t,null,a)}syncVolumeToSender(){var e,t,a;this.$soundSettings?(this.setVolume(this.$soundSettings.volume),this.mute(this.$soundSettings.mute)):this.$castToLocal.volumeChange((null===(e=this.currentCastSession)||void 0===e?void 0:e.getVolume())||0,null!==(a=null===(t=this.currentCastSession)||void 0===t?void 0:t.isMute())&&void 0!==a&&a)}setMetaInfo(){var e,t,a,o,i,s,n,r;let l="",d={};const c=this.mediaTitle;this.mediaInfo&&(l=(null===(o=null===(a=null===(t=null===(e=this.mediaInfo)||void 0===e?void 0:e.customData)||void 0===t?void 0:t.video)||void 0===a?void 0:a.channel)||void 0===o?void 0:o.isLTSEnabled)?"DVR":this.mediaInfo.streamType,this.isLts=!!(null===(r=null===(n=null===(s=null===(i=this.mediaInfo)||void 0===i?void 0:i.customData)||void 0===s?void 0:s.video)||void 0===n?void 0:n.channel)||void 0===r?void 0:r.isLTSEnabled),this.mediaInfo.metadata&&(d=this.mediaInfo.metadata)),this.$castToLocal.setMetaInfo(c,l,d)}onLoadSuccess(){var a,o;this.sessionStartTime=Date.now()/1e3,this.$disconnectTime=0,this.$castToLocal.loadSuccess(this.playerState,this.castDeviceName,this.castSessionID,this.mediaDuration,this.breaks),this.liveSeekableRange=null;const{CONTENT:s}=i.getMediaInformationFromPage();let n="VOD";(null==s?void 0:s.isLive)&&(n=(null===(o=null===(a=null==s?void 0:s.metadata)||void 0===a?void 0:a[0].videoProperties)||void 0===o?void 0:o.includes("DVR"))||this.isLts?"DVR":t),this.$castToLocal.setStreamType(n),this.addSessionMessageListeners(),e.debug("Finished content load")}onLoadFailure(t){e.error("Content load failed",t),this.$castToLocal.loadFailure()}addSessionMessageListeners(){const e=this.$castContext.getCurrentSession();if(!e)throw new Error("Cannot set up listeners when session is undefined");e.addMessageListener("urn:x-cast:livetimeshifting",((e,t)=>this.liveSeekableRange=JSON.parse(t)))}addEventListeners(){if(!this.$castContext)throw new Error("castContext not defined");if(this.$castContext.addEventListener(cast.framework.CastContextEventType.SESSION_STATE_CHANGED,(e=>{e&&(e.sessionState,cast.framework.SessionState.SESSION_ENDING)})),this.$castContext.addEventListener(cast.framework.CastContextEventType.CAST_STATE_CHANGED,(e=>{!e||e.castState!==cast.framework.CastState.CONNECTED&&e.castState!==cast.framework.CastState.CONNECTING||this.$soundSettings||(this.$soundSettings=Object.assign({},this.$castToLocal.getSoundSettings()))})),!this.$remotePlayerController)throw new Error("remotePlayerController not defined");this.$remotePlayerController.addEventListener(cast.framework.RemotePlayerEventType.MEDIA_INFO_CHANGED,(e=>{var t,a,o,s,n,r,l,d,c,u,v,m,g,h,p,C;if(!(null==e?void 0:e.value))return;if(""!==this.currentContentId){const g=null===(o=null===(a=null===(t=e.value.customData)||void 0===t?void 0:t.video)||void 0===a?void 0:a.videoProperties)||void 0===o?void 0:o.some((e=>"BBLF"===e.toUpperCase()));let h=!1;if(h=i.isLive()?null!==(d=null===(l=null===(r=null===(n=null===(s=e.value)||void 0===s?void 0:s.customData)||void 0===n?void 0:n.senderData)||void 0===r?void 0:r.customData)||void 0===l?void 0:l.slug)&&void 0!==d?d:""!==(null!==(c=i.getChannelSlug())&&void 0!==c?c:""):this.currentContentId!==e.value.contentId,(null===(u=e.value)||void 0===u?void 0:u.contentId)&&h&&e.value.streamType&&(null===(m=null===(v=e.value.customData)||void 0===v?void 0:v.video)||void 0===m?void 0:m.url)&&!g)return this.currentContentId=e.value.contentId,void this.$castToLocal.newMediaSession(e.value.customData.video.url,e.value.contentId)}else this.currentContentId=e.value.contentId;if(!this.mediaInfo)return;const T=this.mediaInfo.tracks||[],S={ids:(null===(g=this.mediaSession)||void 0===g?void 0:g.activeTrackIds)||[],text:[],audio:[]};if(T.length){if(T.forEach((e=>{-1!==S.ids.indexOf(e.trackId)&&[chrome.cast.media.TrackType.TEXT,chrome.cast.media.TrackType.AUDIO].includes(e.type)&&S[e.type.toLowerCase()].push(e)})),null===(h=this.$castToLocal.getCaptionsStyle())||void 0===h?void 0:h.language){const e=Object.assign(Object.assign({},this.$castToLocal.getCaptionsStyle()),S.text.length&&{language:null===(p=S.text[0])||void 0===p?void 0:p.language});this.$castToLocal.setCaptionsStyle(e)}S.audio.length&&this.$castToLocal.setAudioTrack(S.audio[0])}this.$castToLocal.setMediaTracksData(T,null===(C=this.mediaSession)||void 0===C?void 0:C.activeTrackIds)})),this.$remotePlayerController.addEventListener(cast.framework.RemotePlayerEventType.TITLE_CHANGED,(()=>{this.setMetaInfo()})),this.$remotePlayerController.addEventListener(cast.framework.RemotePlayerEventType.IS_CONNECTED_CHANGED,(e=>{let t=this.$disconnectTime;e&&!1!==e.value?e&&!0===e.value&&this.$castToLocal.connecting():(this.liveSeekableRange&&(t=i.clamp(t,this.liveSeekableRange.start,this.liveSeekableRange.end)),this.$castToLocal.disconnectConnect(t),this.$soundSettings=null)})),this.$remotePlayerController.addEventListener(cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED,(e=>{var t,a;e&&this.$castToLocal.volumeChange(e.value,null!==(a=null===(t=this.currentCastSession)||void 0===t?void 0:t.isMute())&&void 0!==a&&a)})),this.$remotePlayerController.addEventListener(cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED,(e=>{e&&this.$castToLocal.muteOrUnmute(e.value)})),this.$remotePlayerController.addEventListener(cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED,(e=>{if(!(null==e?void 0:e.value)||e.value<=0)return;let t=e.value,a=this.liveSeekableRange?e.value+this.liveEdgeDelta>=this.liveSeekableRange.end?e.value:this.liveSeekableRange.end:this.mediaDuration;this.isLts&&this.liveSeekableRange&&(a=this.liveSeekableRange.end-this.liveSeekableRange.start,t=i.clamp(a-(this.liveSeekableRange.end-e.value),0,a)),this.$castToLocal.currentTimeChange(t,a),this.$disconnectTime=e.value})),this.$remotePlayerController.addEventListener(cast.framework.RemotePlayerEventType.ANY_CHANGE,(t=>e.debug(t))),this.$remotePlayerController.addEventListener(cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED,(e=>{e&&this.$castToLocal.playerStateChange(e.value)})),this.$remotePlayerController.addEventListener(cast.framework.RemotePlayerEventType.IS_PLAYING_BREAK_CHANGED,(e=>{e&&e.value?this.$castToLocal.adBreakStart():this.$castToLocal.adBreakEnd()}))}processLoadRequest(t=!1){var a;e.debug("Starting content load",i.getMediaInformationFromPage()),null===(a=this.loadRequest(t))||void 0===a||a.then((()=>this.onLoadSuccess()),(e=>this.onLoadFailure(e)))}resolveStartTimeLegacy(){const e=this.$castToLocal.getLoadStartTime();return{contentTime:e,streamTime:e,playbackTime:0,liveStreamUtcDuration:0,liveStreamUtcStart:0,liveStreamUtcTime:0}}getCurrentStartTimeObject(t){if(!this.mediaInfo||!i.isLive()){const a=Object.entries(this.$castToLocal.getLoadStartTimeObject(t)).reduce(((e,[t,a])=>Object.assign(Object.assign({},e),{[t]:isNaN(+a)?0:+a})),{});return e.debug("Using load start time",a),a}return e.debug("Starting content from the start"),{}}processTextTrackStyles(e){const t=new chrome.cast.media.TextTrackStyle;return t.backgroundColor=e.windowColor,t.edgeType=e.edgeType,t.fontFamily=e.fontFamily,t.fontGenericFamily=chrome.cast.media.TextTrackFontGenericFamily.SANS_SERIF,t.fontScale=e.fontScale,t.fontStyle=e.customData.fontStyle?e.customData.fontStyle.toUpperCase():chrome.cast.media.TextTrackFontStyle.NORMAL,t.fontSize=e.customData.fontSize?e.customData.fontSize:20,t.foregroundColor=e.foregroundColor,t.windowColor=e.windowColor,t.windowType=chrome.cast.media.TextTrackWindowType.ROUNDED_CORNERS,t}updateTracks(e,t,a,o=null,i=null,s=(()=>{}),n=(()=>{})){var r,l,d;const c="string"==typeof a?[a]:null!=a?a:[];if(this.mediaInfo){const u=this.mediaInfo.tracks;let v,m=(null===(r=this.mediaSession)||void 0===r?void 0:r.activeTrackIds)||[];const g=m.filter((t=>{const a=u.find((e=>e.trackId===t));if(a&&!a.type&&-1!==a.trackContentType.indexOf("mp4a")&&(a.type=chrome.cast.media.TrackType.AUDIO),a&&a.type!==e)return!0}));if(m=g||[],t){if(c)for(let e=0;e<c.length;e++)c[e]=(c[e]+"").toLowerCase();if(o&&(v=this.processTextTrackStyles(o)),u){const t=u.filter((t=>(!t.type&&t.trackContentType&&-1!==t.trackContentType.indexOf("mp4a")&&(t.type=chrome.cast.media.TrackType.AUDIO),t.type===e&&(!a||!!c.find((e=>(e+"").toLowerCase()===(t.language+"").toLowerCase()))))));if(t.length){const e=null===(l=i?t.find((e=>{var t;return(null===(t=null==e?void 0:e.roles)||void 0===t?void 0:t[0])===i})):t[0])||void 0===l?void 0:l.trackId;e&&m.push(e)}}}const h=new chrome.cast.media.EditTracksInfoRequest(m,v);null===(d=this.mediaSession)||void 0===d||d.editTracksInfo(h,s,n)}}}class r{constructor(e){this.$interfaceCastToLocal=e}get interfaceCastToLocal_(){return this.$interfaceCastToLocal}connect(){}disconnectConnect(e=0){}connecting(){}newMediaSession(e,t){}loadSuccess(e,t,a,o,i){}loadFailure(){}setMetaInfo(e,t,{metadataType:a,seriesTitle:o,season:i,episode:s,releaseDate:n}){}setMediaTracksData(e,t){}getLoadStartTimeObject(e){return{}}getLoadStartTime(){return 0}getCurrentTime(){return 0}getSoundSettings(){return null}volumeChange(e,t){}muteOrUnmute(e=!1){}currentTimeChange(e,t){}playerStateChange(e){}adBreakStart(){}adBreakEnd(){}contentStart(){}getCaptionsStyle(){return{}}setCaptionsStyle(e){}getAudioTrackInfo(){return{}}setAudioTrack(e){}enable(){}disable(){}setStreamType(e){}preCastHandler(){}}class l extends r{constructor(e){super(e)}connect(){this.interfaceCastToLocal_.connect()}disconnectConnect(e=0){this.interfaceCastToLocal_.end(e)}connecting(){this.interfaceCastToLocal_.start()}newMediaSession(e,t){e=e.replace(/([^\/]$)/,"$1/");const a=(window.location.href+"").indexOf(e)>=0,o=window.location.pathname!==e,s=CBS.Registry.region.prefix+e;e&&e.length>0&&window&&window.location&&!i.indexOfSkipURI(window.location.href+"")&&(window.location.href+"").indexOf(t)<0&&(a&&o?window.location.pathname=s.replace(/(\/){2,}/g,"/"):a||(window.location.href=s.replace(/(\/){2,}/g,"/")))}loadSuccess(e,t,a,o,s){this.interfaceCastToLocal_.initialize(a,t,o,i.getFormattedAdBreaks(s,o)),this.interfaceCastToLocal_.playerState(e),this.interfaceCastToLocal_.contentStart(),this.interfaceCastToLocal_.adBreaks(i.getFormattedAdBreaks(s,o),o)}setMetaInfo(e,t,{metadataType:a,seriesTitle:o,season:s,episode:n,releaseDate:r}){const l={line1:"",line2:""};if(i.isLiveStreamType(t))l.line1=o,l.line2=e;else if(i.isMovie(a)){if(l.line1=null!=e?e:"",l.line2="",r){const e=new Date(r).getFullYear();l.line2=`${l.line2} ${e}`}}else l.line1=o,l.line2=e,n&&(l.line2=`E${n} ${l.line2}`),s&&(l.line2=`S${s} ${l.line2}`);this.interfaceCastToLocal_.metadata(l)}setMediaTracksData(e,t){this.interfaceCastToLocal_.mediaTracks(e,t)}getLoadStartTimeObject(){let e={streamTime:0,contentTime:0,playbackTime:0,liveStreamUtcTime:0,liveStreamUtcDuration:0,liveStreamUtcStart:0};const t=this.getCurrentTimeObject(),a=this.getGlobalResumeTime();return t?e=t:a&&(e.contentTime=a),e}getCurrentTime(){return this.interfaceCastToLocal_.getCurrentTime()}getCurrentTimeObject(){return this.interfaceCastToLocal_.getCurrentTimeObject()}getGlobalResumeTime(){return this.interfaceCastToLocal_.getGlobalResumeTime()}getSoundSettings(){return this.interfaceCastToLocal_&&this.interfaceCastToLocal_.getSoundSettings?this.interfaceCastToLocal_.getSoundSettings():null}volumeChange(e,t=!1){e>=0&&!isNaN(e)&&(this.interfaceCastToLocal_.volumeUpdate(parseFloat(`${e}`)),this.muteOrUnmute(t))}muteOrUnmute(e=!1){e?this.interfaceCastToLocal_.mute():this.interfaceCastToLocal_.unmute()}currentTimeChange(e,t){e>=0&&!isNaN(e)&&this.interfaceCastToLocal_.playbackProgress(Math.floor(e),t||0)}playerStateChange(e){this.interfaceCastToLocal_.playerState(e)}adBreakStart(){this.interfaceCastToLocal_.adBreakStart()}adBreakEnd(){this.interfaceCastToLocal_.adBreakEnd(),this.contentStart()}contentStart(){this.interfaceCastToLocal_.contentStart()}getCaptionsStyle(){return this.interfaceCastToLocal_.getCaptionsInfo()}setCaptionsStyle(e){e&&this.interfaceCastToLocal_.setCaptions(e)}getAudioTrackInfo(){return this.interfaceCastToLocal_.getAudioTrackInfo()}setAudioTrack(e){this.interfaceCastToLocal_.setAudioTrack(e)}enable(){this.interfaceCastToLocal_.enable()}disable(){this.interfaceCastToLocal_.disable()}setStreamType(e){this.interfaceCastToLocal_.setStreamType(e)}preCastHandler(){this.interfaceCastToLocal_.preCastHandler()}}class d{constructor(e){this.$CastSenderMerica=e}get castSender_(){return this.$CastSenderMerica}readyToCast(){}stopCast(){}castMedia(e=!1){}seek(e){}playVideo(){}pauseVideo(){}mute(e){}unmute(e){}setVolume(e){}showCaptions(e){}hideCaptions(e){}updateVolume(e,t=-1){}requestCastSession(){}setCastAudioTrack(e){}setCaptionsStyle(e){}isConnected(){return!1}}class c extends d{constructor(e){super(e),this.hideCaptions=this.showCaptions,this.stopCast=this.requestCastSession}readyToCast(){super.castSender_.isConnected()&&super.castSender_.reconnectLocalToCast()}castMedia(e){super.castSender_.castMedia(e)}seek(e){e&&e.payload&&super.castSender_.seek(e.payload.seekTo)}pauseVideo(){super.castSender_.pause()}playVideo(){super.castSender_.play()}mute(e){e&&this.updateVolume(!0)}unmute(e){e&&this.updateVolume(!1)}setVolume(e){e&&e.payload&&super.castSender_.setVolume(e.payload.volume)}showCaptions(e){let t={};e&&e.payload&&e.payload.ccSettings&&(t=e.payload.ccSettings);const a=void 0!==t.language;super.castSender_.updateCaptions(a,null==t?void 0:t.language,t||null)}updateVolume(e,t=-1){super.castSender_.mute(e),super.castSender_.setVolume(t)}requestCastSession(){super.castSender_.requestSession()}setCastAudioTrack(e){var t,a,o,i;let s,n={};(null===(a=null===(t=null==e?void 0:e.payload)||void 0===t?void 0:t.audioTrack)||void 0===a?void 0:a.language)&&(n=e.payload.audioTrack,n.type=chrome.cast.media.TrackType.AUDIO,s=null!==(i=null===(o=null==n?void 0:n.roles)||void 0===o?void 0:o[0])&&void 0!==i?i:""),super.castSender_.updateAudioTracks(!(!n||!n.language),null==n?void 0:n.language,`${s}`)}setCaptionsStyle(e){let t={};e&&e.payload&&e.payload.ccSettings&&(t=e.payload.ccSettings);const a=void 0!==t.language;super.castSender_.updateCaptions(a,t?t.language:null,t||null)}isConnected(){return super.castSender_.isConnected()}}window.Chromecast=class{static getHelper(){return i}setSmartTagNameSpace(e,t){e.seek=e=>t.seek.apply(t,[e]),e.play=()=>t.playVideo.apply(t),e.pause=()=>t.pauseVideo.apply(t),e.mute=e=>t.mute.apply(t,[e]),e.unmute=e=>t.unmute.apply(t,[e]),e.setVolume=e=>t.setVolume.apply(t,[e]),e.updateVolume=(e,a=-1)=>t.updateVolume.apply(t,[e,a]),e.showCaptions=e=>t.showCaptions.apply(t,[e]),e.hideCaptions=e=>t.hideCaptions.apply(t,[e]),e.requestSession=()=>t.requestCastSession.apply(t),e.uiReady=()=>t.castMedia.apply(t),e.stopSession=()=>t.stopCast.apply(t),e.setAudioTrack=e=>t.setCastAudioTrack.apply(t,[e]),e.setCaptions=e=>t.setCaptionsStyle.apply(t,[e]),e.isConnected=()=>t.isConnected.apply(t),e.sendLoadRequest=(e=!1)=>t.castMedia.apply(t,[e])}start(e,t=null){const a=e.CastToLocalAdapter,o=e.CastNS,s=SmartTag.list[0];i.setRegistry(null===CBS||void 0===CBS?void 0:CBS.Registry),i.setTagVO(s),i.setLocation(t);const r=new n,d=new c(r),u=new l(a);this.setSmartTagNameSpace(o,d),chrome.cast&&r.init(u,CBS.Registry.chromecast.receiver_id,chrome.cast.AutoJoinPolicy.TAB_AND_ORIGIN_SCOPED)}}})();
//# sourceMappingURL=sender-e26f4899637f94d540bb.min.js.map