!function(){var t=window.jwplayer("container");window.CastPluginJS=function(t,e){var a=CastPluginJS.prototype,s=t,n=NativeCastPlugin,o=void 0,r=!0;this.castPosition=0,a.initCastSdk=function(){n.addSessionManagerListener(),this.updateCastState()},a.updateCastState=function(){var t=n.isAvailable(),e=n.isActive(),i=n.getDeviceName(),a=s.get("castAvailable"),o=s.get("castActive");(t!==a||e!==o||r)&&(s.set("castAvailable",t),s.set("castActive",e),s.set("castState",{available:t,active:e,deviceName:i}),r=!1)},a.resumeCasting=function(){var t=n.getMediaClientCurrentItemJsonString();if(t){var e=JSON.parse(t),a=e.media.contentId;this.playlistIndex=e.media.metadata.index;var r=s.getPlaylistItem(this.playlistIndex),l=[];for(l.push(r.file),i=0;i<r.sources.length;i++)l.push(r.sources[i].file);this.isResume=l.indexOf(a)>-1,o||(o=new CastProviderJS(s,s.getConfig())),s.castVideo(o,r)}this.updateCastState()},a.startCasting=function(){!1,s.pause(),s.set("state","buffering"),o||(o=new CastProviderJS(s,s.getConfig())),s.castVideo(o,s.get("playlistItem")),this.updateCastState()},a.stopCasting=function(){var t=s.get("state");const e=s.get("item"),i=s.get("playlist");var a=s.get("playlistItem");this.castPosition=o.position,o=null,!1,a&&"error"===t&&(void 0===(a=i[e+1])?t="complete":(s.set("item",e+1),s.set("playlistItem",a))),this.updateCastState(),s.stopCast(),"complete"===t||"idle"===t||this.isBackgrounded||"paused"===t||s.play()},a.destroy=function(){n.removeSessionManagerListener(),s=null,null},a.playlistItem=function(t){s.playlistItem(t)},a.triggerSeeked=function(){o.triggerSeeked()},a.triggerVolumeChanged=function(t){o.triggerVolumeChanged(t)},a.loadComplete=function(){this.updateCastState(),o.loadComplete()},a.triggerTime=function(t,e,i){o.triggerTime(t,e,i)},a.setState=function(t){o.setState(t)},a.triggerComplete=function(){s.trigger("complete")},a.triggerPlaylistComplete=function(){s.trigger("playlistComplete")},a.triggerPlaybackRateChanged=function(t){o.triggerPlaybackRateChanged(t)},a.onReady=function(){r=!0},a.onBackgrounded=function(t){this.isBackgrounded=t},this.initCastSdk(),t.on("ready",this.onReady,this)},Object.assign(CastPluginJS.prototype,t.Events),t.registerPlugin("casting","8.0",CastPluginJS)}();
