@mux/mux-video 0.16.3 → 0.16.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- var ti=Object.defineProperty;var ei=(i,e,t)=>e in i?ti(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var f=(i,e,t)=>(ei(i,typeof e!="symbol"?e+"":e,t),t),se=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)};var r=(i,e,t)=>(se(i,e,"read from private field"),t?t.call(i):e.get(i)),c=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},d=(i,e,t,n)=>(se(i,e,"write to private field"),n?n.call(i,t):e.set(i,t),t);var b=(i,e,t)=>(se(i,e,"access private method"),t);var ct=class{addEventListener(){}removeEventListener(){}dispatchEvent(e){return!0}};if(typeof DocumentFragment=="undefined"){class i extends ct{}globalThis.DocumentFragment=i}var Pt=class extends ct{},ne=class extends ct{},ii={get(i){},define(i,e,t){},upgrade(i){},whenDefined(i){return Promise.resolve(Pt)}},Rt,ae=class{constructor(e,t={}){c(this,Rt,void 0);d(this,Rt,t==null?void 0:t.detail)}get detail(){return r(this,Rt)}initCustomEvent(){}};Rt=new WeakMap;function ri(i,e){return new Pt}var Le={document:{createElement:ri},DocumentFragment,customElements:ii,CustomEvent:ae,EventTarget:ct,HTMLElement:Pt,HTMLVideoElement:ne},Ce=typeof window=="undefined"||typeof globalThis.customElements=="undefined",Lt=Ce?Le:globalThis,Ii=Ce?Le.document:globalThis.document;import{initialize as ui,teardown as hi,generatePlayerInitTime as li,PlaybackTypes as ie,toMuxVideoURL as fi,MediaError as Xr,getError as mi,CmcdTypeValues as Ze,addCuePoints as pi,getCuePoints as Ei,getActiveCuePoint as gi,getStartDate as yi,getCurrentPdt as vi,getStreamType as Ti,getTargetLiveWindow as bi,getLiveEdgeStart as Ai,getSeekable as ki,getEnded as Si}from"@mux/playback-core";var si=()=>{try{return"0.16.3"}catch{}return"UNKNOWN"},ni=si(),Oe=()=>ni;var Ie=i=>{var e,t,n,a,m,we,v,Kt,L,D,M,Ht,nt,$t,Vt,Me,qt,_e,at,oe,l,A,S,E,y,R,I,Ct,Ut,xe,At,ce,Yt,De,kt,de,Wt,Ne,St,ue;return e=class extends i{constructor(){super();c(this,I);c(this,Ut);c(this,At);c(this,Yt);c(this,kt);c(this,Wt);c(this,St);f(this,"castEnabled",!1);c(this,l,{paused:!1});c(this,A,void 0);c(this,S,{});c(this,E,void 0);c(this,y,void 0);c(this,R,void 0);e.instances.add(this),b(this,kt,de).call(this)}static get castElement(){return r(e,t)}static get castEnabled(){return r(e,n)}static get castState(){var s;return(s=r(e,L,D))==null?void 0:s.getCastState()}static async exitCast(){try{await r(e,L,D).endCurrentSession(!0)}catch(u){console.error(u);return}}get castPlayer(){if(e.castElement===this)return r(this,A)}attributeChangedCallback(s){if(!!this.castPlayer)switch(s){case"cast-stream-type":case"cast-src":this.load();break}}async requestCast(s={}){var u;b(u=e,at,oe).call(u,s),d(e,t,this),Object.entries(r(this,S)).forEach(([k,C])=>{r(this,A).controller.addEventListener(k,C)});try{await r(e,L,D).requestSession()}catch{d(e,t,void 0);return}r(this,l).paused=super.paused,super.pause(),this.muted=super.muted;try{await this.load()}catch(k){console.error(k)}}async load(){var x,Q;if(!this.castPlayer)return super.load();let s=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType),u=[...this.querySelectorAll("track")].filter(({kind:_,src:w})=>w&&(_==="subtitles"||_==="captions")),k=[],C=0;u.length&&(s.tracks=u.map(_=>{let w=++C;k.length===0&&_.track.mode==="showing"&&k.push(w);let Z=new chrome.cast.media.Track(w,chrome.cast.media.TrackType.TEXT);return Z.trackContentId=_.src,Z.trackContentType="text/vtt",Z.subtype=_.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,Z.name=_.label,Z.language=_.srclang,Z})),this.castStreamType==="live"?s.streamType=chrome.cast.media.StreamType.LIVE:s.streamType=chrome.cast.media.StreamType.BUFFERED,s.metadata=new chrome.cast.media.GenericMediaMetadata,s.metadata.title=this.title,s.metadata.images=[{url:this.poster}];let O=new chrome.cast.media.LoadRequest(s);O.currentTime=(x=super.currentTime)!=null?x:0,O.autoplay=!r(this,l).paused,O.activeTrackIds=k,await((Q=r(e,M,Ht))==null?void 0:Q.loadMedia(O)),this.dispatchEvent(new Event("volumechange"))}play(){var s;if(this.castPlayer){this.castPlayer.isPaused&&((s=this.castPlayer.controller)==null||s.playOrPause());return}return super.play()}pause(){var s;if(this.castPlayer){this.castPlayer.isPaused||(s=this.castPlayer.controller)==null||s.playOrPause();return}super.pause()}get castSrc(){var s,u,k;return(k=(u=this.getAttribute("cast-src"))!=null?u:(s=this.querySelector("source"))==null?void 0:s.src)!=null?k:this.currentSrc}set castSrc(s){this.castSrc!=s&&this.setAttribute("cast-src",`${s}`)}get castContentType(){var s;return(s=this.getAttribute("cast-content-type"))!=null?s:void 0}set castContentType(s){this.setAttribute("cast-content-type",`${s}`)}get castStreamType(){var s,u;return(u=(s=this.getAttribute("cast-stream-type"))!=null?s:this.streamType)!=null?u:void 0}set castStreamType(s){this.setAttribute("cast-stream-type",`${s}`)}get readyState(){if(this.castPlayer)switch(this.castPlayer.playerState){case chrome.cast.media.PlayerState.IDLE:return 0;case chrome.cast.media.PlayerState.BUFFERING:return 2;default:return 3}return super.readyState}get paused(){return this.castPlayer?this.castPlayer.isPaused:super.paused}get muted(){var s;return this.castPlayer?(s=this.castPlayer)==null?void 0:s.isMuted:super.muted}set muted(s){var u;if(this.castPlayer){(s&&!this.castPlayer.isMuted||!s&&this.castPlayer.isMuted)&&((u=this.castPlayer.controller)==null||u.muteOrUnmute());return}super.muted=s}get volume(){var s,u;return this.castPlayer?(u=(s=this.castPlayer)==null?void 0:s.volumeLevel)!=null?u:1:super.volume}set volume(s){var u;if(this.castPlayer){this.castPlayer.volumeLevel=s,(u=this.castPlayer.controller)==null||u.setVolumeLevel();return}super.volume=s}get duration(){var s,u;return this.castPlayer&&r(this,I,Ct)?(u=(s=this.castPlayer)==null?void 0:s.duration)!=null?u:NaN:super.duration}get currentTime(){var s,u;return this.castPlayer&&r(this,I,Ct)?(u=(s=this.castPlayer)==null?void 0:s.currentTime)!=null?u:0:super.currentTime}set currentTime(s){var u;if(this.castPlayer){this.castPlayer.currentTime=s,(u=this.castPlayer.controller)==null||u.seek();return}super.currentTime=s}get onentercast(){return r(this,E)}set onentercast(s){r(this,E)&&(this.removeEventListener("entercast",r(this,E)),d(this,E,null)),typeof s=="function"&&(d(this,E,s),this.addEventListener("entercast",s))}get onleavecast(){return r(this,y)}set onleavecast(s){r(this,y)&&(this.removeEventListener("leavecast",r(this,y)),d(this,y,null)),typeof s=="function"&&(d(this,y,s),this.addEventListener("leavecast",s))}get oncastchange(){return r(this,R)}set oncastchange(s){r(this,R)&&(this.removeEventListener("castchange",r(this,R)),d(this,R,null)),typeof s=="function"&&(d(this,R,s),this.addEventListener("castchange",s))}},t=new WeakMap,n=new WeakMap,a=new WeakMap,m=new WeakSet,we=function(){return typeof chrome!="undefined"&&chrome.cast&&chrome.cast.isAvailable},v=new WeakSet,Kt=function(){return typeof cast!="undefined"&&cast.framework},L=new WeakSet,D=function(){if(r(e,v,Kt))return cast.framework.CastContext.getInstance()},M=new WeakSet,Ht=function(){var s;return(s=r(e,L,D))==null?void 0:s.getCurrentSession()},nt=new WeakSet,$t=function(){var s;return(s=r(e,M,Ht))==null?void 0:s.getSessionObj().media[0]},Vt=new WeakSet,Me=function(s){return new Promise((u,k)=>{r(e,nt,$t).editTracksInfo(s,u,k)})},qt=new WeakSet,_e=function(s){return new Promise((u,k)=>{r(e,nt,$t).getStatus(s,u,k)})},at=new WeakSet,oe=function(s){return r(e,L,D).setOptions({receiverApplicationId:chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0,...s})},l=new WeakMap,A=new WeakMap,S=new WeakMap,E=new WeakMap,y=new WeakMap,R=new WeakMap,I=new WeakSet,Ct=function(){var s;return(s=this.castPlayer)==null?void 0:s.isMediaLoaded},Ut=new WeakSet,xe=function(){r(e,t)===this&&(Object.entries(r(this,S)).forEach(([s,u])=>{r(this,A).controller.removeEventListener(s,u)}),d(e,t,void 0),this.muted=r(this,A).isMuted,this.currentTime=r(this,A).savedPlayerState.currentTime,r(this,A).savedPlayerState.isPaused===!1&&this.play())},At=new WeakSet,ce=function(){this.dispatchEvent(new CustomEvent("castchange",{detail:r(e,L,D).getCastState()}))},Yt=new WeakSet,De=async function(){var u,k;let{SESSION_RESUMED:s}=cast.framework.SessionState;if(r(e,L,D).getSessionState()===s&&this.castSrc===((u=r(e,nt,$t))==null?void 0:u.media.contentId)){d(e,t,this),Object.entries(r(this,S)).forEach(([C,O])=>{r(this,A).controller.addEventListener(C,O)});try{await b(k=e,qt,_e).call(k,new chrome.cast.media.GetStatusRequest)}catch(C){console.error(C)}r(this,S)[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED](),r(this,S)[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},kt=new WeakSet,de=function(){var s;!r(e,v,Kt)||this.castEnabled||(this.castEnabled=!0,b(s=e,at,oe).call(s),this.textTracks.addEventListener("change",b(this,St,ue).bind(this)),b(this,At,ce).call(this),d(this,A,new cast.framework.RemotePlayer),new cast.framework.RemotePlayerController(r(this,A)),d(this,S,{[cast.framework.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:u})=>{u===!1&&b(this,Ut,xe).call(this),this.dispatchEvent(new Event(u?"entercast":"leavecast"))},[cast.framework.RemotePlayerEventType.DURATION_CHANGED]:()=>{this.dispatchEvent(new Event("durationchange"))},[cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED]:()=>{!r(this,I,Ct)||this.dispatchEvent(new Event("timeupdate"))},[cast.framework.RemotePlayerEventType.VIDEO_INFO_CHANGED]:()=>{this.dispatchEvent(new Event("resize"))},[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED]:()=>{this.dispatchEvent(new Event(this.paused?"pause":"play"))},[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]:()=>{var u,k;((u=this.castPlayer)==null?void 0:u.playerState)!==chrome.cast.media.PlayerState.PAUSED&&this.dispatchEvent(new Event({[chrome.cast.media.PlayerState.PLAYING]:"playing",[chrome.cast.media.PlayerState.BUFFERING]:"waiting",[chrome.cast.media.PlayerState.IDLE]:"emptied"}[(k=this.castPlayer)==null?void 0:k.playerState]))},[cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{!r(this,I,Ct)||(await Promise.resolve(),b(this,Wt,Ne).call(this))}}))},Wt=new WeakSet,Ne=function(){b(this,St,ue).call(this)},St=new WeakSet,ue=async function(){var ye,ve,Te,be,Ae,ke;if(!this.castPlayer)return;let u=((ve=(ye=r(this,A).mediaInfo)==null?void 0:ye.tracks)!=null?ve:[]).filter(({type:P})=>P===chrome.cast.media.TrackType.TEXT),k=[...this.textTracks].filter(({kind:P})=>P==="subtitles"||P==="captions"),C=u.map(({language:P,name:jt,trackId:re})=>{var Pe;let{mode:Se}=(Pe=k.find(Re=>Re.language===P&&Re.label===jt))!=null?Pe:{};return Se?{mode:Se,trackId:re}:!1}).filter(Boolean),x=C.filter(({mode:P})=>P!=="showing").map(({trackId:P})=>P),Q=C.find(({mode:P})=>P==="showing"),_=(Ae=(be=(Te=r(e,M,Ht))==null?void 0:Te.getSessionObj().media[0])==null?void 0:be.activeTrackIds)!=null?Ae:[],w=_;if(_.length&&(w=w.filter(P=>!x.includes(P))),Q!=null&&Q.trackId&&(w=[...w,Q.trackId]),w=[...new Set(w)],!((P,jt)=>P.length===jt.length&&P.every(re=>jt.includes(re)))(_,w))try{let P=new chrome.cast.media.EditTracksInfoRequest(w);await b(ke=e,Vt,Me).call(ke,P)}catch(P){console.error(P)}},c(e,m),c(e,v),c(e,L),c(e,M),c(e,nt),c(e,Vt),c(e,qt),c(e,at),f(e,"observedAttributes",["cast-src","cast-content-type","cast-stream-type"]),f(e,"instances",new Set),c(e,t,void 0),c(e,n,!1),f(e,"initCast",()=>{var s;r(e,m,we)?r(e,v,Kt)?r(s=e,a).call(s,chrome.cast.isAvailable):customElements.whenDefined("google-cast-button").then(()=>{var u;return r(u=e,a).call(u,chrome.cast.isAvailable)}):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(()=>{var u;return r(u=e,a).call(u,chrome.cast.isAvailable)})}}),c(e,a,s=>{if(s){d(e,n,!0);let{CAST_STATE_CHANGED:u}=cast.framework.CastContextEventType;r(e,L,D).addEventListener(u,C=>{e.instances.forEach(O=>{var x;return b(x=O,At,ce).call(x,C)})});let{SESSION_STATE_CHANGED:k}=cast.framework.CastContextEventType;r(e,L,D).addEventListener(k,C=>{e.instances.forEach(O=>{var x;return b(x=O,Yt,De).call(x,C)})}),e.instances.forEach(C=>{var O;return b(O=C,kt,de).call(O)})}}),e},he=globalThis.HTMLVideoElement?Ie(HTMLVideoElement):Ie(Object);globalThis.customElements&&!globalThis.customElements.get("castable-video")&&(customElements.define("castable-video",he,{extends:"video"}),globalThis.CastableVideoElement=he);he.initCast();var me=["abort","canplay","canplaythrough","durationchange","emptied","encrypted","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting","waitingforkey","resize","enterpictureinpicture","leavepictureinpicture","webkitbeginfullscreen","webkitendfullscreen","webkitpresentationmodechanged"],Fe,le=(Fe=globalThis.document)==null?void 0:Fe.createElement("template");le&&(le.innerHTML=`
1
+ var ti=Object.defineProperty;var ei=(i,e,t)=>e in i?ti(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var f=(i,e,t)=>(ei(i,typeof e!="symbol"?e+"":e,t),t),ne=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)};var r=(i,e,t)=>(ne(i,e,"read from private field"),t?t.call(i):e.get(i)),c=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},d=(i,e,t,n)=>(ne(i,e,"write to private field"),n?n.call(i,t):e.set(i,t),t);var T=(i,e,t)=>(ne(i,e,"access private method"),t);var ct=class{addEventListener(){}removeEventListener(){}dispatchEvent(e){return!0}};if(typeof DocumentFragment=="undefined"){class i extends ct{}globalThis.DocumentFragment=i}var Rt=class extends ct{},ae=class extends ct{},ii={get(i){},define(i,e,t){},upgrade(i){},whenDefined(i){return Promise.resolve(Rt)}},Lt,oe=class{constructor(e,t={}){c(this,Lt,void 0);d(this,Lt,t==null?void 0:t.detail)}get detail(){return r(this,Lt)}initCustomEvent(){}};Lt=new WeakMap;function ri(i,e){return new Rt}var Le={document:{createElement:ri},DocumentFragment,customElements:ii,CustomEvent:oe,EventTarget:ct,HTMLElement:Rt,HTMLVideoElement:ae},Ce=typeof window=="undefined"||typeof globalThis.customElements=="undefined",Ct=Ce?Le:globalThis,Ii=Ce?Le.document:globalThis.document;import{initialize as ui,teardown as hi,generatePlayerInitTime as li,PlaybackTypes as ie,toMuxVideoURL as fi,MediaError as Xr,getError as mi,CmcdTypeValues as Ze,addCuePoints as pi,getCuePoints as Ei,getActiveCuePoint as gi,getStartDate as vi,getCurrentPdt as yi,getStreamType as Ti,getTargetLiveWindow as bi,getLiveEdgeStart as Ai,getSeekable as ki,getEnded as Si}from"@mux/playback-core";var si=()=>{try{return"0.16.4"}catch{}return"UNKNOWN"},ni=si(),Oe=()=>ni;var Ie=i=>{var e,t,n,a,m,we,y,Kt,L,N,M,Ht,nt,$t,Vt,Me,qt,_e,at,ce,l,A,S,E,v,R,I,Ot,Ut,xe,kt,de,Yt,De,St,ue,Wt,Ne,Pt,he;return e=class extends i{constructor(){super();c(this,I);c(this,Ut);c(this,kt);c(this,Yt);c(this,St);c(this,Wt);c(this,Pt);f(this,"castEnabled",!1);c(this,l,{paused:!1});c(this,A,void 0);c(this,S,{});c(this,E,void 0);c(this,v,void 0);c(this,R,void 0);e.instances.add(this),T(this,St,ue).call(this)}static get castElement(){return r(e,t)}static get castEnabled(){return r(e,n)}static get castState(){var s;return(s=r(e,L,N))==null?void 0:s.getCastState()}static async exitCast(){try{await r(e,L,N).endCurrentSession(!0)}catch(u){console.error(u);return}}get castPlayer(){if(e.castElement===this)return r(this,A)}attributeChangedCallback(s){if(!!this.castPlayer)switch(s){case"cast-stream-type":case"cast-src":this.load();break}}async requestCast(s={}){var u;T(u=e,at,ce).call(u,s),d(e,t,this),Object.entries(r(this,S)).forEach(([k,C])=>{r(this,A).controller.addEventListener(k,C)});try{await r(e,L,N).requestSession()}catch{d(e,t,void 0);return}r(this,l).paused=super.paused,super.pause(),this.muted=super.muted;try{await this.load()}catch(k){console.error(k)}}async load(){var D,Q;if(!this.castPlayer)return super.load();let s=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType),u=[...this.querySelectorAll("track")].filter(({kind:_,src:w})=>w&&(_==="subtitles"||_==="captions")),k=[],C=0;u.length&&(s.tracks=u.map(_=>{let w=++C;k.length===0&&_.track.mode==="showing"&&k.push(w);let Z=new chrome.cast.media.Track(w,chrome.cast.media.TrackType.TEXT);return Z.trackContentId=_.src,Z.trackContentType="text/vtt",Z.subtype=_.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,Z.name=_.label,Z.language=_.srclang,Z})),this.castStreamType==="live"?s.streamType=chrome.cast.media.StreamType.LIVE:s.streamType=chrome.cast.media.StreamType.BUFFERED,s.metadata=new chrome.cast.media.GenericMediaMetadata,s.metadata.title=this.title,s.metadata.images=[{url:this.poster}];let O=new chrome.cast.media.LoadRequest(s);O.currentTime=(D=super.currentTime)!=null?D:0,O.autoplay=!r(this,l).paused,O.activeTrackIds=k,await((Q=r(e,M,Ht))==null?void 0:Q.loadMedia(O)),this.dispatchEvent(new Event("volumechange"))}play(){var s;if(this.castPlayer){this.castPlayer.isPaused&&((s=this.castPlayer.controller)==null||s.playOrPause());return}return super.play()}pause(){var s;if(this.castPlayer){this.castPlayer.isPaused||(s=this.castPlayer.controller)==null||s.playOrPause();return}super.pause()}get castSrc(){var s,u,k;return(k=(u=this.getAttribute("cast-src"))!=null?u:(s=this.querySelector("source"))==null?void 0:s.src)!=null?k:this.currentSrc}set castSrc(s){this.castSrc!=s&&this.setAttribute("cast-src",`${s}`)}get castContentType(){var s;return(s=this.getAttribute("cast-content-type"))!=null?s:void 0}set castContentType(s){this.setAttribute("cast-content-type",`${s}`)}get castStreamType(){var s,u;return(u=(s=this.getAttribute("cast-stream-type"))!=null?s:this.streamType)!=null?u:void 0}set castStreamType(s){this.setAttribute("cast-stream-type",`${s}`)}get readyState(){if(this.castPlayer)switch(this.castPlayer.playerState){case chrome.cast.media.PlayerState.IDLE:return 0;case chrome.cast.media.PlayerState.BUFFERING:return 2;default:return 3}return super.readyState}get paused(){return this.castPlayer?this.castPlayer.isPaused:super.paused}get muted(){var s;return this.castPlayer?(s=this.castPlayer)==null?void 0:s.isMuted:super.muted}set muted(s){var u;if(this.castPlayer){(s&&!this.castPlayer.isMuted||!s&&this.castPlayer.isMuted)&&((u=this.castPlayer.controller)==null||u.muteOrUnmute());return}super.muted=s}get volume(){var s,u;return this.castPlayer?(u=(s=this.castPlayer)==null?void 0:s.volumeLevel)!=null?u:1:super.volume}set volume(s){var u;if(this.castPlayer){this.castPlayer.volumeLevel=s,(u=this.castPlayer.controller)==null||u.setVolumeLevel();return}super.volume=s}get duration(){var s,u;return this.castPlayer&&r(this,I,Ot)?(u=(s=this.castPlayer)==null?void 0:s.duration)!=null?u:NaN:super.duration}get currentTime(){var s,u;return this.castPlayer&&r(this,I,Ot)?(u=(s=this.castPlayer)==null?void 0:s.currentTime)!=null?u:0:super.currentTime}set currentTime(s){var u;if(this.castPlayer){this.castPlayer.currentTime=s,(u=this.castPlayer.controller)==null||u.seek();return}super.currentTime=s}get onentercast(){return r(this,E)}set onentercast(s){r(this,E)&&(this.removeEventListener("entercast",r(this,E)),d(this,E,null)),typeof s=="function"&&(d(this,E,s),this.addEventListener("entercast",s))}get onleavecast(){return r(this,v)}set onleavecast(s){r(this,v)&&(this.removeEventListener("leavecast",r(this,v)),d(this,v,null)),typeof s=="function"&&(d(this,v,s),this.addEventListener("leavecast",s))}get oncastchange(){return r(this,R)}set oncastchange(s){r(this,R)&&(this.removeEventListener("castchange",r(this,R)),d(this,R,null)),typeof s=="function"&&(d(this,R,s),this.addEventListener("castchange",s))}},t=new WeakMap,n=new WeakMap,a=new WeakMap,m=new WeakSet,we=function(){return typeof chrome!="undefined"&&chrome.cast&&chrome.cast.isAvailable},y=new WeakSet,Kt=function(){return typeof cast!="undefined"&&cast.framework},L=new WeakSet,N=function(){if(r(e,y,Kt))return cast.framework.CastContext.getInstance()},M=new WeakSet,Ht=function(){var s;return(s=r(e,L,N))==null?void 0:s.getCurrentSession()},nt=new WeakSet,$t=function(){var s;return(s=r(e,M,Ht))==null?void 0:s.getSessionObj().media[0]},Vt=new WeakSet,Me=function(s){return new Promise((u,k)=>{r(e,nt,$t).editTracksInfo(s,u,k)})},qt=new WeakSet,_e=function(s){return new Promise((u,k)=>{r(e,nt,$t).getStatus(s,u,k)})},at=new WeakSet,ce=function(s){return r(e,L,N).setOptions({receiverApplicationId:chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0,...s})},l=new WeakMap,A=new WeakMap,S=new WeakMap,E=new WeakMap,v=new WeakMap,R=new WeakMap,I=new WeakSet,Ot=function(){var s;return(s=this.castPlayer)==null?void 0:s.isMediaLoaded},Ut=new WeakSet,xe=function(){r(e,t)===this&&(Object.entries(r(this,S)).forEach(([s,u])=>{r(this,A).controller.removeEventListener(s,u)}),d(e,t,void 0),this.muted=r(this,A).isMuted,this.currentTime=r(this,A).savedPlayerState.currentTime,r(this,A).savedPlayerState.isPaused===!1&&this.play())},kt=new WeakSet,de=function(){this.dispatchEvent(new CustomEvent("castchange",{detail:r(e,L,N).getCastState()}))},Yt=new WeakSet,De=async function(){var u,k;let{SESSION_RESUMED:s}=cast.framework.SessionState;if(r(e,L,N).getSessionState()===s&&this.castSrc===((u=r(e,nt,$t))==null?void 0:u.media.contentId)){d(e,t,this),Object.entries(r(this,S)).forEach(([C,O])=>{r(this,A).controller.addEventListener(C,O)});try{await T(k=e,qt,_e).call(k,new chrome.cast.media.GetStatusRequest)}catch(C){console.error(C)}r(this,S)[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED](),r(this,S)[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},St=new WeakSet,ue=function(){var s;!r(e,y,Kt)||this.castEnabled||(this.castEnabled=!0,T(s=e,at,ce).call(s),this.textTracks.addEventListener("change",T(this,Pt,he).bind(this)),T(this,kt,de).call(this),d(this,A,new cast.framework.RemotePlayer),new cast.framework.RemotePlayerController(r(this,A)),d(this,S,{[cast.framework.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:u})=>{u===!1&&T(this,Ut,xe).call(this),this.dispatchEvent(new Event(u?"entercast":"leavecast"))},[cast.framework.RemotePlayerEventType.DURATION_CHANGED]:()=>{this.dispatchEvent(new Event("durationchange"))},[cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED]:()=>{!r(this,I,Ot)||this.dispatchEvent(new Event("timeupdate"))},[cast.framework.RemotePlayerEventType.VIDEO_INFO_CHANGED]:()=>{this.dispatchEvent(new Event("resize"))},[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED]:()=>{this.dispatchEvent(new Event(this.paused?"pause":"play"))},[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]:()=>{var u,k;((u=this.castPlayer)==null?void 0:u.playerState)!==chrome.cast.media.PlayerState.PAUSED&&this.dispatchEvent(new Event({[chrome.cast.media.PlayerState.PLAYING]:"playing",[chrome.cast.media.PlayerState.BUFFERING]:"waiting",[chrome.cast.media.PlayerState.IDLE]:"emptied"}[(k=this.castPlayer)==null?void 0:k.playerState]))},[cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{!r(this,I,Ot)||(await Promise.resolve(),T(this,Wt,Ne).call(this))}}))},Wt=new WeakSet,Ne=function(){T(this,Pt,he).call(this)},Pt=new WeakSet,he=async function(){var ve,ye,Te,be,Ae,ke;if(!this.castPlayer)return;let u=((ye=(ve=r(this,A).mediaInfo)==null?void 0:ve.tracks)!=null?ye:[]).filter(({type:P})=>P===chrome.cast.media.TrackType.TEXT),k=[...this.textTracks].filter(({kind:P})=>P==="subtitles"||P==="captions"),C=u.map(({language:P,name:jt,trackId:se})=>{var Pe;let{mode:Se}=(Pe=k.find(Re=>Re.language===P&&Re.label===jt))!=null?Pe:{};return Se?{mode:Se,trackId:se}:!1}).filter(Boolean),D=C.filter(({mode:P})=>P!=="showing").map(({trackId:P})=>P),Q=C.find(({mode:P})=>P==="showing"),_=(Ae=(be=(Te=r(e,M,Ht))==null?void 0:Te.getSessionObj().media[0])==null?void 0:be.activeTrackIds)!=null?Ae:[],w=_;if(_.length&&(w=w.filter(P=>!D.includes(P))),Q!=null&&Q.trackId&&(w=[...w,Q.trackId]),w=[...new Set(w)],!((P,jt)=>P.length===jt.length&&P.every(se=>jt.includes(se)))(_,w))try{let P=new chrome.cast.media.EditTracksInfoRequest(w);await T(ke=e,Vt,Me).call(ke,P)}catch(P){console.error(P)}},c(e,m),c(e,y),c(e,L),c(e,M),c(e,nt),c(e,Vt),c(e,qt),c(e,at),f(e,"observedAttributes",["cast-src","cast-content-type","cast-stream-type"]),f(e,"instances",new Set),c(e,t,void 0),c(e,n,!1),f(e,"initCast",()=>{var s;r(e,m,we)?r(e,y,Kt)?r(s=e,a).call(s,chrome.cast.isAvailable):customElements.whenDefined("google-cast-button").then(()=>{var u;return r(u=e,a).call(u,chrome.cast.isAvailable)}):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(()=>{var u;return r(u=e,a).call(u,chrome.cast.isAvailable)})}}),c(e,a,s=>{if(s){d(e,n,!0);let{CAST_STATE_CHANGED:u}=cast.framework.CastContextEventType;r(e,L,N).addEventListener(u,C=>{e.instances.forEach(O=>{var D;return T(D=O,kt,de).call(D,C)})});let{SESSION_STATE_CHANGED:k}=cast.framework.CastContextEventType;r(e,L,N).addEventListener(k,C=>{e.instances.forEach(O=>{var D;return T(D=O,Yt,De).call(D,C)})}),e.instances.forEach(C=>{var O;return T(O=C,St,ue).call(O)})}}),e},le=globalThis.HTMLVideoElement?Ie(HTMLVideoElement):Ie(Object);globalThis.customElements&&!globalThis.customElements.get("castable-video")&&(customElements.define("castable-video",le,{extends:"video"}),globalThis.CastableVideoElement=le);le.initCast();var pe=["abort","canplay","canplaythrough","durationchange","emptied","encrypted","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting","waitingforkey","resize","enterpictureinpicture","leavepictureinpicture","webkitbeginfullscreen","webkitendfullscreen","webkitpresentationmodechanged"],Fe,fe=(Fe=globalThis.document)==null?void 0:Fe.createElement("template");fe&&(fe.innerHTML=`
2
2
  <style>
3
3
  :host {
4
4
  display: inline-block;
@@ -13,7 +13,7 @@ var ti=Object.defineProperty;var ei=(i,e,t)=>e in i?ti(i,e,{enumerable:!0,config
13
13
  }
14
14
  </style>
15
15
  <slot></slot>
16
- `);var Ge,fe=(Ge=globalThis.document)==null?void 0:Ge.createElement("template");fe&&(fe.innerHTML=`
16
+ `);var Ge,me=(Ge=globalThis.document)==null?void 0:Ge.createElement("template");me&&(me.innerHTML=`
17
17
  <style>
18
18
  :host {
19
19
  display: inline-block;
@@ -35,5 +35,5 @@ var ti=Object.defineProperty;var ei=(i,e,t)=>e in i?ti(i,e,{enumerable:!0,config
35
35
  }
36
36
  </style>
37
37
  <slot></slot>
38
- `);var zt=(i,{tag:e,is:t})=>{var m,g,v,T,Ve,bt,M,V,dt,Gt,Be,Bt,qe;let n=(m=globalThis.document)==null?void 0:m.createElement(e,{is:t}),a=n?ai(n):[];return g=class extends i{constructor(){super();c(this,V);c(this,Gt);c(this,Bt);c(this,bt,void 0);c(this,M,void 0);this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.append(this.constructor.template.content.cloneNode(!0)))}static get observedAttributes(){var l,A,S;return b(l=g,T,Ve).call(l),[...(S=(A=n==null?void 0:n.constructor)==null?void 0:A.observedAttributes)!=null?S:[],"autopictureinpicture","disablepictureinpicture","disableremoteplayback","autoplay","controls","controlslist","crossorigin","loop","muted","playsinline","poster","preload","src"]}get nativeEl(){var p,l;return(l=(p=r(this,M))!=null?p:this.shadowRoot.querySelector(e))!=null?l:this.querySelector(e)}set nativeEl(p){d(this,M,p)}get defaultMuted(){return this.hasAttribute("muted")}set defaultMuted(p){this.toggleAttribute("muted",Boolean(p))}get src(){return this.getAttribute("src")}set src(p){this.setAttribute("src",`${p}`)}get preload(){var p,l;return(l=this.getAttribute("preload"))!=null?l:(p=this.nativeEl)==null?void 0:p.preload}set preload(p){this.setAttribute("preload",`${p}`)}attributeChangedCallback(p,l,A){b(this,V,dt).call(this),b(this,Bt,qe).call(this,p,l,A)}connectedCallback(){b(this,V,dt).call(this)}},v=new WeakMap,T=new WeakSet,Ve=function(){if(r(this,v))return;d(this,v,!0);let p=new Set(this.observedAttributes);p.delete("muted");for(let l of a){if(l in this.prototype)continue;if(typeof n[l]=="function")this.prototype[l]=function(...S){return b(this,V,dt).call(this),(()=>this.call?this.call(l,...S):this.nativeEl[l].apply(this.nativeEl,S))()};else{let S={get(){var y,R,I;b(this,V,dt).call(this);let E=l.toLowerCase();if(p.has(E)){let ot=this.getAttribute(E);return ot===null?!1:ot===""?!0:ot}return(I=(y=this.get)==null?void 0:y.call(this,l))!=null?I:(R=this.nativeEl)==null?void 0:R[l]}};l!==l.toUpperCase()&&(S.set=function(E){b(this,V,dt).call(this);let y=l.toLowerCase();if(p.has(y)){E===!0||E===!1||E==null?this.toggleAttribute(y,Boolean(E)):this.setAttribute(y,E);return}if(this.set){this.set(l,E);return}this.nativeEl[l]=E}),Object.defineProperty(this.prototype,l,S)}}},bt=new WeakMap,M=new WeakMap,V=new WeakSet,dt=function(){var A,S;if(r(this,bt))return;if(d(this,bt,!0),!this.nativeEl){let E=document.createElement(e,{is:t});E.part=e,this.shadowRoot.append(E)}this.nativeEl.muted=this.hasAttribute("muted");for(let E of a)b(this,Gt,Be).call(this,E);let p=new Map,l=this.shadowRoot.querySelector("slot:not([name])");l==null||l.addEventListener("slotchange",()=>{let E=new Map(p);l.assignedElements().filter(y=>["track","source"].includes(y.localName)).forEach(y=>{var I,ot;E.delete(y);let R=p.get(y);R||(R=y.cloneNode(),p.set(y,R)),(ot=(I=this.nativeEl).append)==null||ot.call(I,R)}),E.forEach(y=>y.remove())});for(let E of this.constructor.Events)(S=(A=this.shadowRoot).addEventListener)==null||S.call(A,E,y=>{y.target===this.nativeEl&&this.dispatchEvent(new CustomEvent(y.type,{detail:y.detail}))},!0)},Gt=new WeakSet,Be=function(p){if(Object.prototype.hasOwnProperty.call(this,p)){let l=this[p];delete this[p],this[p]=l}},Bt=new WeakSet,qe=function(p,l,A){var S,E,y,R;["id","class"].includes(p)||(A===null?(E=(S=this.nativeEl).removeAttribute)==null||E.call(S,p):(R=(y=this.nativeEl).setAttribute)==null||R.call(y,p,A))},c(g,T),f(g,"Events",me),f(g,"template",e.endsWith("audio")?le:fe),c(g,v,void 0),g};function ai(i){let e=[];for(let t=Object.getPrototypeOf(i);t&&t!==HTMLElement.prototype;t=Object.getPrototypeOf(t))e.push(...Object.getOwnPropertyNames(t));return e}var Ni=globalThis.document?zt(HTMLElement,{tag:"video"}):class{},Fi=globalThis.document?zt(HTMLElement,{tag:"audio"}):class{};var F=class extends Event{constructor(t,n){super(t);f(this,"track");this.track=n.track}};var pe=new WeakMap;function o(i){var e;return(e=pe.get(i))!=null?e:oi(i,{})}function oi(i,e){let t=pe.get(i);return t||pe.set(i,t={}),Object.assign(t,e)}function Xt(i,e){let t=i.videoTracks;o(e).media=i,o(e).renditionSet||(o(e).renditionSet=new Set);let n=o(t).trackSet;n.add(e);let a=n.size-1;a in et.prototype||Object.defineProperty(et.prototype,a,{get(){return[...o(this).trackSet][a]}}),queueMicrotask(()=>{t.dispatchEvent(new F("addtrack",{track:e}))})}function Jt(i){var n;let e=(n=o(i).media)==null?void 0:n.videoTracks;if(!e)return;o(e).trackSet.delete(i),queueMicrotask(()=>{e.dispatchEvent(new F("removetrack",{track:i}))})}function Ue(i){var n;let e=(n=o(i).media.videoTracks)!=null?n:[],t=!1;for(let a of e)a!==i&&(a.selected=!1,t=!0);if(t){if(o(e).changeRequested)return;o(e).changeRequested=!0,queueMicrotask(()=>{delete o(e).changeRequested,e.dispatchEvent(new Event("change"))})}}var B,q,U,tt,Ot,et=class extends EventTarget{constructor(){super();c(this,tt);c(this,B,void 0);c(this,q,void 0);c(this,U,void 0);o(this).trackSet=new Set}[Symbol.iterator](){return r(this,tt,Ot).values()}get length(){return r(this,tt,Ot).size}getTrackById(t){var n;return(n=[...r(this,tt,Ot)].find(a=>a.id===t))!=null?n:null}get selectedIndex(){return[...r(this,tt,Ot)].findIndex(t=>t.selected)}get onaddtrack(){return r(this,B)}set onaddtrack(t){r(this,B)&&(this.removeEventListener("addtrack",r(this,B)),d(this,B,void 0)),typeof t=="function"&&(d(this,B,t),this.addEventListener("addtrack",t))}get onremovetrack(){return r(this,q)}set onremovetrack(t){r(this,q)&&(this.removeEventListener("removetrack",r(this,q)),d(this,q,void 0)),typeof t=="function"&&(d(this,q,t),this.addEventListener("removetrack",t))}get onchange(){return r(this,U)}set onchange(t){r(this,U)&&(this.removeEventListener("change",r(this,U)),d(this,U,void 0)),typeof t=="function"&&(d(this,U,t),this.addEventListener("change",t))}};B=new WeakMap,q=new WeakMap,U=new WeakMap,tt=new WeakSet,Ot=function(){return o(this).trackSet};var G=class extends Event{constructor(t,n){super(t);f(this,"rendition");this.rendition=n.rendition}};function Ye(i,e){let t=o(i).media.videoRenditions;o(e).media=o(i).media,o(e).track=i;let n=o(i).renditionSet;n.add(e);let a=n.size-1;a in it.prototype||Object.defineProperty(it.prototype,a,{get(){return ut(this)[a]}}),queueMicrotask(()=>{!i.selected||t.dispatchEvent(new G("addrendition",{rendition:e}))})}function We(i){let e=o(i).media.videoRenditions,t=o(i).track;o(t).renditionSet.delete(i),queueMicrotask(()=>{!o(i).track.selected||e.dispatchEvent(new G("removerendition",{rendition:i}))})}function je(i){let e=o(i).media.videoRenditions;!e||o(e).changeRequested||(o(e).changeRequested=!0,queueMicrotask(()=>{delete o(e).changeRequested,o(i).track.selected&&e.dispatchEvent(new Event("change"))}))}function ut(i){return[...o(i).media.videoTracks].filter(t=>t.selected).flatMap(t=>[...o(t).renditionSet])}var Y,W,j,it=class extends EventTarget{constructor(){super(...arguments);c(this,Y,void 0);c(this,W,void 0);c(this,j,void 0)}[Symbol.iterator](){return ut(this).values()}get length(){return ut(this).length}getRenditionById(t){var n;return(n=ut(this).find(a=>`${a.id}`==`${t}`))!=null?n:null}get selectedIndex(){return ut(this).findIndex(t=>t.selected)}set selectedIndex(t){for(let[n,a]of ut(this).entries())a.selected=n===t}get onaddrendition(){return r(this,Y)}set onaddrendition(t){r(this,Y)&&(this.removeEventListener("addrendition",r(this,Y)),d(this,Y,void 0)),typeof t=="function"&&(d(this,Y,t),this.addEventListener("addrendition",t))}get onremoverendition(){return r(this,W)}set onremoverendition(t){r(this,W)&&(this.removeEventListener("removerendition",r(this,W)),d(this,W,void 0)),typeof t=="function"&&(d(this,W,t),this.addEventListener("removerendition",t))}get onchange(){return r(this,j)}set onchange(t){r(this,j)&&(this.removeEventListener("change",r(this,j)),d(this,j,void 0)),typeof t=="function"&&(d(this,j,t),this.addEventListener("change",t))}};Y=new WeakMap,W=new WeakMap,j=new WeakMap;var ht,It=class{constructor(){f(this,"src");f(this,"id");f(this,"width");f(this,"height");f(this,"bitrate");f(this,"frameRate");f(this,"codec");c(this,ht,!1)}get selected(){return r(this,ht)}set selected(e){r(this,ht)!==e&&(d(this,ht,e),je(this))}};ht=new WeakMap;var lt,ft=class{constructor(){f(this,"id");f(this,"kind");f(this,"label","");f(this,"language","");f(this,"sourceBuffer");c(this,lt,!1)}addRendition(e,t,n,a,m,g){let v=new It;return v.src=e,v.width=t,v.height=n,v.frameRate=g,v.bitrate=m,v.codec=a,Ye(this,v),v}removeRendition(e){We(e)}get selected(){return r(this,lt)}set selected(e){r(this,lt)!==e&&(d(this,lt,e),e===!0&&Ue(this))}};lt=new WeakMap;function Ke(i,e){let t=o(i).media.audioRenditions;o(e).media=o(i).media,o(e).track=i;let n=o(i).renditionSet;n.add(e);let a=n.size-1;a in rt.prototype||Object.defineProperty(rt.prototype,a,{get(){return mt(this)[a]}}),queueMicrotask(()=>{!i.enabled||t.dispatchEvent(new G("addrendition",{rendition:e}))})}function He(i){let e=o(i).media.audioRenditions,t=o(i).track;o(t).renditionSet.delete(i),queueMicrotask(()=>{!o(i).track.enabled||e.dispatchEvent(new G("removerendition",{rendition:i}))})}function $e(i){let e=o(i).media.audioRenditions;!e||o(e).changeRequested||(o(e).changeRequested=!0,queueMicrotask(()=>{delete o(e).changeRequested,o(i).track.enabled&&e.dispatchEvent(new Event("change"))}))}function mt(i){return[...o(i).media.audioTracks].filter(t=>t.enabled).flatMap(t=>[...o(t).renditionSet])}var K,H,$,rt=class extends EventTarget{constructor(){super(...arguments);c(this,K,void 0);c(this,H,void 0);c(this,$,void 0)}[Symbol.iterator](){return mt(this).values()}get length(){return mt(this).length}getRenditionById(t){var n;return(n=mt(this).find(a=>`${a.id}`==`${t}`))!=null?n:null}get selectedIndex(){return mt(this).findIndex(t=>t.selected)}set selectedIndex(t){for(let[n,a]of mt(this).entries())a.selected=n===t}get onaddrendition(){return r(this,K)}set onaddrendition(t){r(this,K)&&(this.removeEventListener("addrendition",r(this,K)),d(this,K,void 0)),typeof t=="function"&&(d(this,K,t),this.addEventListener("addrendition",t))}get onremoverendition(){return r(this,H)}set onremoverendition(t){r(this,H)&&(this.removeEventListener("removerendition",r(this,H)),d(this,H,void 0)),typeof t=="function"&&(d(this,H,t),this.addEventListener("removerendition",t))}get onchange(){return r(this,$)}set onchange(t){r(this,$)&&(this.removeEventListener("change",r(this,$)),d(this,$,void 0)),typeof t=="function"&&(d(this,$,t),this.addEventListener("change",t))}};K=new WeakMap,H=new WeakMap,$=new WeakMap;var pt,wt=class{constructor(){f(this,"src");f(this,"id");f(this,"bitrate");f(this,"codec");c(this,pt,!1)}get selected(){return r(this,pt)}set selected(e){r(this,pt)!==e&&(d(this,pt,e),$e(this))}};pt=new WeakMap;function Zt(i,e){let t=i.audioTracks;o(e).media=i,o(e).renditionSet||(o(e).renditionSet=new Set);let n=o(t).trackSet;n.add(e);let a=n.size-1;a in st.prototype||Object.defineProperty(st.prototype,a,{get(){return[...o(this).trackSet][a]}}),queueMicrotask(()=>{t.dispatchEvent(new F("addtrack",{track:e}))})}function te(i){var n;let e=(n=o(i).media)==null?void 0:n.audioTracks;if(!e)return;o(e).trackSet.delete(i),queueMicrotask(()=>{e.dispatchEvent(new F("removetrack",{track:i}))})}function ze(i){let e=o(i).media.audioTracks;!e||o(e).changeRequested||(o(e).changeRequested=!0,queueMicrotask(()=>{delete o(e).changeRequested,e.dispatchEvent(new Event("change"))}))}var z,X,J,Et,Qt,st=class extends EventTarget{constructor(){super();c(this,Et);c(this,z,void 0);c(this,X,void 0);c(this,J,void 0);o(this).trackSet=new Set}[Symbol.iterator](){return r(this,Et,Qt).values()}get length(){return r(this,Et,Qt).size}getTrackById(t){var n;return(n=[...r(this,Et,Qt)].find(a=>a.id===t))!=null?n:null}get onaddtrack(){return r(this,z)}set onaddtrack(t){r(this,z)&&(this.removeEventListener("addtrack",r(this,z)),d(this,z,void 0)),typeof t=="function"&&(d(this,z,t),this.addEventListener("addtrack",t))}get onremovetrack(){return r(this,X)}set onremovetrack(t){r(this,X)&&(this.removeEventListener("removetrack",r(this,X)),d(this,X,void 0)),typeof t=="function"&&(d(this,X,t),this.addEventListener("removetrack",t))}get onchange(){return r(this,J)}set onchange(t){r(this,J)&&(this.removeEventListener("change",r(this,J)),d(this,J,void 0)),typeof t=="function"&&(d(this,J,t),this.addEventListener("change",t))}};z=new WeakMap,X=new WeakMap,J=new WeakMap,Et=new WeakSet,Qt=function(){return o(this).trackSet};var gt,yt=class{constructor(){f(this,"id");f(this,"kind");f(this,"label","");f(this,"language","");f(this,"sourceBuffer");c(this,gt,!1)}addRendition(e,t,n){let a=new wt;return a.src=e,a.codec=t,a.bitrate=n,Ke(this,a),a}removeRendition(e){He(e)}get enabled(){return r(this,gt)}set enabled(e){r(this,gt)!==e&&(d(this,gt,e),ze(this))}};gt=new WeakMap;var Xe=ee(globalThis.HTMLMediaElement,"video"),Je=ee(globalThis.HTMLMediaElement,"audio");function Qe(i){if(!(i!=null&&i.prototype))return i;let e=ee(i,"video");(!e||`${e}`.includes("[native code]"))&&Object.defineProperty(i.prototype,"videoTracks",{get(){return ci(this)}});let t=ee(i,"audio");(!t||`${t}`.includes("[native code]"))&&Object.defineProperty(i.prototype,"audioTracks",{get(){return di(this)}}),"addVideoTrack"in i.prototype||(i.prototype.addVideoTrack=function(m,g="",v=""){let T=new ft;return T.kind=m,T.label=g,T.language=v,Xt(this,T),T}),"removeVideoTrack"in i.prototype||(i.prototype.removeVideoTrack=Jt),"addAudioTrack"in i.prototype||(i.prototype.addAudioTrack=function(m,g="",v=""){let T=new yt;return T.kind=m,T.label=g,T.language=v,Zt(this,T),T}),"removeAudioTrack"in i.prototype||(i.prototype.removeAudioTrack=te),"videoRenditions"in i.prototype||Object.defineProperty(i.prototype,"videoRenditions",{get(){return n(this)}});let n=m=>{let g=o(m).videoRenditions;return g||(g=new it,o(g).media=m,o(m).videoRenditions=g),g};"audioRenditions"in i.prototype||Object.defineProperty(i.prototype,"audioRenditions",{get(){return a(this)}});let a=m=>{let g=o(m).audioRenditions;return g||(g=new rt,o(g).media=m,o(m).audioRenditions=g),g};return i}function ee(i,e){var t;if(i!=null&&i.prototype)return(t=Object.getOwnPropertyDescriptor(i.prototype,`${e}Tracks`))==null?void 0:t.get}function ci(i){var t;let e=o(i).videoTracks;if(!e&&(e=new et,o(i).videoTracks=e,Xe)){let n=Xe.call((t=i.nativeEl)!=null?t:i);for(let a of n)Xt(i,a);n.addEventListener("change",()=>{e.dispatchEvent(new Event("change"))}),n.addEventListener("addtrack",a=>{if([...e].some(m=>m instanceof ft)){for(let m of n)Jt(m);return}Xt(i,a.track)}),n.addEventListener("removetrack",a=>{Jt(a.track)})}return e}function di(i){var t;let e=o(i).audioTracks;if(!e&&(e=new st,o(i).audioTracks=e,Je)){let n=Je.call((t=i.nativeEl)!=null?t:i);for(let a of n)Zt(i,a);n.addEventListener("change",()=>{e.dispatchEvent(new Event("change"))}),n.addEventListener("addtrack",a=>{if([...e].some(m=>m instanceof yt)){for(let m of n)te(m);return}Zt(i,a.track)}),n.addEventListener("removetrack",a=>{te(a.track)})}return e}me.push("castchange","entercast","leavecast");var Ee=Qe(zt(Lt.HTMLElement,{tag:"video",is:"castable-video"})),h={BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",CUSTOM_DOMAIN:"custom-domain",DEBUG:"debug",DISABLE_COOKIES:"disable-cookies",ENV_KEY:"env-key",MAX_RESOLUTION:"max-resolution",METADATA_URL:"metadata-url",PLAYBACK_ID:"playback-id",PLAYER_SOFTWARE_NAME:"player-software-name",PLAYER_SOFTWARE_VERSION:"player-software-version",PREFER_CMCD:"prefer-cmcd",PREFER_PLAYBACK:"prefer-playback",START_TIME:"start-time",STREAM_TYPE:"stream-type",TARGET_LIVE_WINDOW:"target-live-window",LIVE_EDGE_OFFSET:"live-edge-offset",TYPE:"type"},Pi=Object.values(h),Ri=Oe(),Li="mux-video",N,vt,_t,Tt,xt,Dt,Nt,Ft,ge,Mt=class extends Ee{constructor(){super();c(this,Ft);c(this,N,void 0);c(this,vt,void 0);c(this,_t,void 0);c(this,Tt,{});c(this,xt,void 0);c(this,Dt,void 0);c(this,Nt,void 0);d(this,_t,li())}static get observedAttributes(){var t;return[...Pi,...(t=Ee.observedAttributes)!=null?t:[]]}get preferCmcd(){var t;return(t=this.getAttribute(h.PREFER_CMCD))!=null?t:void 0}set preferCmcd(t){t!==this.preferCmcd&&(t?Ze.includes(t)?this.setAttribute(h.PREFER_CMCD,t):console.warn(`Invalid value for preferCmcd. Must be one of ${Ze.join()}`):this.removeAttribute(h.PREFER_CMCD))}get playerInitTime(){return r(this,_t)}get playerSoftwareName(){var t;return(t=r(this,Dt))!=null?t:Li}set playerSoftwareName(t){d(this,Dt,t)}get playerSoftwareVersion(){var t;return(t=r(this,xt))!=null?t:Ri}set playerSoftwareVersion(t){d(this,xt,t)}get _hls(){var t;return(t=r(this,N))==null?void 0:t.engine}get mux(){var t;return(t=this.nativeEl)==null?void 0:t.mux}get error(){var t;return(t=mi(this.nativeEl))!=null?t:null}get errorTranslator(){return r(this,Nt)}set errorTranslator(t){d(this,Nt,t)}get src(){return this.getAttribute("src")}set src(t){t!==this.src&&(t==null?this.removeAttribute("src"):this.setAttribute("src",t))}get type(){var t;return(t=this.getAttribute(h.TYPE))!=null?t:void 0}set type(t){t!==this.type&&(t?this.setAttribute(h.TYPE,t):this.removeAttribute(h.TYPE))}get autoplay(){let t=this.getAttribute("autoplay");return t===null?!1:t===""?!0:t}set autoplay(t){let n=this.autoplay;t!==n&&(t?this.setAttribute("autoplay",typeof t=="string"?t:""):this.removeAttribute("autoplay"))}get preload(){let t=this.getAttribute("preload");return t===""?"auto":["none","metadata","auto"].includes(t)?t:super.preload}set preload(t){t!=this.getAttribute("preload")&&(["","none","metadata","auto"].includes(t)?this.setAttribute("preload",t):this.removeAttribute("preload"))}get debug(){return this.getAttribute(h.DEBUG)!=null}set debug(t){t!==this.debug&&(t?this.setAttribute(h.DEBUG,""):this.removeAttribute(h.DEBUG))}get disableCookies(){return this.hasAttribute(h.DISABLE_COOKIES)}set disableCookies(t){t!==this.disableCookies&&(t?this.setAttribute(h.DISABLE_COOKIES,""):this.removeAttribute(h.DISABLE_COOKIES))}get startTime(){let t=this.getAttribute(h.START_TIME);if(t==null)return;let n=+t;return Number.isNaN(n)?void 0:n}set startTime(t){t!==this.startTime&&(t==null?this.removeAttribute(h.START_TIME):this.setAttribute(h.START_TIME,`${t}`))}get playbackId(){var t;return(t=this.getAttribute(h.PLAYBACK_ID))!=null?t:void 0}set playbackId(t){t!==this.playbackId&&(t?this.setAttribute(h.PLAYBACK_ID,t):this.removeAttribute(h.PLAYBACK_ID))}get maxResolution(){var t;return(t=this.getAttribute(h.MAX_RESOLUTION))!=null?t:void 0}set maxResolution(t){t!==this.maxResolution&&(t?this.setAttribute(h.MAX_RESOLUTION,t):this.removeAttribute(h.MAX_RESOLUTION))}get customDomain(){var t;return(t=this.getAttribute(h.CUSTOM_DOMAIN))!=null?t:void 0}set customDomain(t){t!==this.customDomain&&(t?this.setAttribute(h.CUSTOM_DOMAIN,t):this.removeAttribute(h.CUSTOM_DOMAIN))}get ended(){return Si(this.nativeEl,this._hls)}get envKey(){var t;return(t=this.getAttribute(h.ENV_KEY))!=null?t:void 0}set envKey(t){t!==this.envKey&&(t?this.setAttribute(h.ENV_KEY,t):this.removeAttribute(h.ENV_KEY))}get beaconCollectionDomain(){var t;return(t=this.getAttribute(h.BEACON_COLLECTION_DOMAIN))!=null?t:void 0}set beaconCollectionDomain(t){t!==this.beaconCollectionDomain&&(t?this.setAttribute(h.BEACON_COLLECTION_DOMAIN,t):this.removeAttribute(h.BEACON_COLLECTION_DOMAIN))}get streamType(){var t;return(t=this.getAttribute(h.STREAM_TYPE))!=null?t:Ti(this.nativeEl)}set streamType(t){t!==this.streamType&&(t?this.setAttribute(h.STREAM_TYPE,t):this.removeAttribute(h.STREAM_TYPE))}get targetLiveWindow(){return this.hasAttribute(h.TARGET_LIVE_WINDOW)?+this.getAttribute(h.TARGET_LIVE_WINDOW):bi(this.nativeEl)}set targetLiveWindow(t){t!=this.targetLiveWindow&&(t==null?this.removeAttribute(h.TARGET_LIVE_WINDOW):this.setAttribute(h.TARGET_LIVE_WINDOW,`${+t}`))}get liveEdgeStart(){var t,n;if(this.hasAttribute(h.LIVE_EDGE_OFFSET)){let{liveEdgeOffset:a}=this,m=(t=this.nativeEl.seekable.end(0))!=null?t:0,g=(n=this.nativeEl.seekable.start(0))!=null?n:0;return Math.max(g,m-a)}return Ai(this.nativeEl)}get liveEdgeOffset(){if(!!this.hasAttribute(h.LIVE_EDGE_OFFSET))return+this.getAttribute(h.LIVE_EDGE_OFFSET)}set liveEdgeOffset(t){t!=this.targetLiveWindow&&(t==null?this.removeAttribute(h.LIVE_EDGE_OFFSET):this.setAttribute(h.LIVE_EDGE_OFFSET,`${+t}`))}get seekable(){return ki(this.nativeEl)}async addCuePoints(t){return pi(this.nativeEl,t)}get activeCuePoint(){return gi(this.nativeEl)}get cuePoints(){return Ei(this.nativeEl)}getStartDate(){return yi(this.nativeEl,this._hls)}get currentPdt(){return vi(this.nativeEl,this._hls)}get preferPlayback(){let t=this.getAttribute(h.PREFER_PLAYBACK);if(t===ie.MSE||t===ie.NATIVE)return t}set preferPlayback(t){t!==this.preferPlayback&&(t===ie.MSE||t===ie.NATIVE?this.setAttribute(h.PREFER_PLAYBACK,t):this.removeAttribute(h.PREFER_PLAYBACK))}get metadata(){return{...this.getAttributeNames().filter(n=>n.startsWith("metadata-")&&![h.METADATA_URL].includes(n)).reduce((n,a)=>{let m=this.getAttribute(a);return m!=null&&(n[a.replace(/^metadata-/,"").replace(/-/g,"_")]=m),n},{}),...r(this,Tt)}}set metadata(t){d(this,Tt,t!=null?t:{}),this.mux&&this.mux.emit("hb",r(this,Tt))}load(){d(this,N,ui(this,this.nativeEl,r(this,N)))}unload(){hi(this.nativeEl,r(this,N)),d(this,N,void 0)}attributeChangedCallback(t,n,a){var g,v;switch(Ee.observedAttributes.includes(t)&&!["src","autoplay","preload"].includes(t)&&super.attributeChangedCallback(t,n,a),t){case h.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=a!=null?a:void 0;break;case h.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=a!=null?a:void 0;break;case"src":{let T=!!n,L=!!a;!T&&L?b(this,Ft,ge).call(this):T&&!L?this.unload():T&&L&&(this.unload(),b(this,Ft,ge).call(this));break}case"autoplay":if(a===n)break;(g=r(this,N))==null||g.setAutoplay(this.autoplay);break;case"preload":if(a===n)break;(v=r(this,N))==null||v.setPreload(a);break;case h.PLAYBACK_ID:this.src=fi(a!=null?a:void 0,{maxResolution:this.maxResolution,domain:this.customDomain});break;case h.DEBUG:{let T=this.debug;this.mux&&console.info("Cannot toggle debug mode of mux data after initialization. Make sure you set all metadata to override before setting the src."),this._hls&&(this._hls.config.debug=T);break}case h.METADATA_URL:a&&fetch(a).then(T=>T.json()).then(T=>this.metadata=T).catch(()=>console.error(`Unable to load or parse metadata JSON from metadata-url ${a}!`));break;case h.STREAM_TYPE:(a==null||a!==n)&&this.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}));break;case h.TARGET_LIVE_WINDOW:(a==null||a!==n)&&this.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0,detail:this.targetLiveWindow}));break;default:break}}disconnectedCallback(){this.unload()}};N=new WeakMap,vt=new WeakMap,_t=new WeakMap,Tt=new WeakMap,xt=new WeakMap,Dt=new WeakMap,Nt=new WeakMap,Ft=new WeakSet,ge=async function(){r(this,vt)||(await d(this,vt,Promise.resolve()),d(this,vt,null),this.load())};Lt.customElements.get("mux-video")||(Lt.customElements.define("mux-video",Mt),Lt.MuxVideoElement=Mt);var is=Mt;export{h as Attributes,Xr as MediaError,me as VideoEvents,is as default};
38
+ `);var zt=(i,{tag:e,is:t})=>{var m,g,y,b,Ve,At,M,V,dt,Gt,Be,Bt,qe;let n=(m=globalThis.document)==null?void 0:m.createElement(e,{is:t}),a=n?ai(n):[];return g=class extends i{constructor(){super();c(this,V);c(this,Gt);c(this,Bt);c(this,At,void 0);c(this,M,void 0);this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.append(this.constructor.template.content.cloneNode(!0)))}static get observedAttributes(){var l,A,S;return T(l=g,b,Ve).call(l),[...(S=(A=n==null?void 0:n.constructor)==null?void 0:A.observedAttributes)!=null?S:[],"autopictureinpicture","disablepictureinpicture","disableremoteplayback","autoplay","controls","controlslist","crossorigin","loop","muted","playsinline","poster","preload","src"]}get nativeEl(){var p,l;return(l=(p=r(this,M))!=null?p:this.shadowRoot.querySelector(e))!=null?l:this.querySelector(e)}set nativeEl(p){d(this,M,p)}get defaultMuted(){return this.hasAttribute("muted")}set defaultMuted(p){this.toggleAttribute("muted",Boolean(p))}get src(){return this.getAttribute("src")}set src(p){this.setAttribute("src",`${p}`)}get preload(){var p,l;return(l=this.getAttribute("preload"))!=null?l:(p=this.nativeEl)==null?void 0:p.preload}set preload(p){this.setAttribute("preload",`${p}`)}attributeChangedCallback(p,l,A){T(this,V,dt).call(this),T(this,Bt,qe).call(this,p,l,A)}connectedCallback(){T(this,V,dt).call(this)}},y=new WeakMap,b=new WeakSet,Ve=function(){if(r(this,y))return;d(this,y,!0);let p=new Set(this.observedAttributes);p.delete("muted");for(let l of a){if(l in this.prototype)continue;if(typeof n[l]=="function")this.prototype[l]=function(...S){return T(this,V,dt).call(this),(()=>this.call?this.call(l,...S):this.nativeEl[l].apply(this.nativeEl,S))()};else{let S={get(){var v,R,I;T(this,V,dt).call(this);let E=l.toLowerCase();if(p.has(E)){let ot=this.getAttribute(E);return ot===null?!1:ot===""?!0:ot}return(I=(v=this.get)==null?void 0:v.call(this,l))!=null?I:(R=this.nativeEl)==null?void 0:R[l]}};l!==l.toUpperCase()&&(S.set=function(E){T(this,V,dt).call(this);let v=l.toLowerCase();if(p.has(v)){E===!0||E===!1||E==null?this.toggleAttribute(v,Boolean(E)):this.setAttribute(v,E);return}if(this.set){this.set(l,E);return}this.nativeEl[l]=E}),Object.defineProperty(this.prototype,l,S)}}},At=new WeakMap,M=new WeakMap,V=new WeakSet,dt=function(){var A,S;if(r(this,At))return;if(d(this,At,!0),!this.nativeEl){let E=document.createElement(e,{is:t});E.part=e,this.shadowRoot.append(E)}this.nativeEl.muted=this.hasAttribute("muted");for(let E of a)T(this,Gt,Be).call(this,E);let p=new Map,l=this.shadowRoot.querySelector("slot:not([name])");l==null||l.addEventListener("slotchange",()=>{let E=new Map(p);l.assignedElements().filter(v=>["track","source"].includes(v.localName)).forEach(v=>{var I,ot;E.delete(v);let R=p.get(v);R||(R=v.cloneNode(),p.set(v,R)),(ot=(I=this.nativeEl).append)==null||ot.call(I,R)}),E.forEach(v=>v.remove())});for(let E of this.constructor.Events)(S=(A=this.shadowRoot).addEventListener)==null||S.call(A,E,v=>{v.target===this.nativeEl&&this.dispatchEvent(new CustomEvent(v.type,{detail:v.detail}))},!0)},Gt=new WeakSet,Be=function(p){if(Object.prototype.hasOwnProperty.call(this,p)){let l=this[p];delete this[p],this[p]=l}},Bt=new WeakSet,qe=function(p,l,A){var S,E,v,R;["id","class"].includes(p)||(A===null?(E=(S=this.nativeEl).removeAttribute)==null||E.call(S,p):(R=(v=this.nativeEl).setAttribute)==null||R.call(v,p,A))},c(g,b),f(g,"Events",pe),f(g,"template",e.endsWith("audio")?fe:me),c(g,y,void 0),g};function ai(i){let e=[];for(let t=Object.getPrototypeOf(i);t&&t!==HTMLElement.prototype;t=Object.getPrototypeOf(t))e.push(...Object.getOwnPropertyNames(t));return e}var Ni=globalThis.document?zt(HTMLElement,{tag:"video"}):class{},Fi=globalThis.document?zt(HTMLElement,{tag:"audio"}):class{};var F=class extends Event{constructor(t,n){super(t);f(this,"track");this.track=n.track}};var Ee=new WeakMap;function o(i){var e;return(e=Ee.get(i))!=null?e:oi(i,{})}function oi(i,e){let t=Ee.get(i);return t||Ee.set(i,t={}),Object.assign(t,e)}function Xt(i,e){let t=i.videoTracks;o(e).media=i,o(e).renditionSet||(o(e).renditionSet=new Set);let n=o(t).trackSet;n.add(e);let a=n.size-1;a in et.prototype||Object.defineProperty(et.prototype,a,{get(){return[...o(this).trackSet][a]}}),queueMicrotask(()=>{t.dispatchEvent(new F("addtrack",{track:e}))})}function Jt(i){var n;let e=(n=o(i).media)==null?void 0:n.videoTracks;if(!e)return;o(e).trackSet.delete(i),queueMicrotask(()=>{e.dispatchEvent(new F("removetrack",{track:i}))})}function Ue(i){var n;let e=(n=o(i).media.videoTracks)!=null?n:[],t=!1;for(let a of e)a!==i&&(a.selected=!1,t=!0);if(t){if(o(e).changeRequested)return;o(e).changeRequested=!0,queueMicrotask(()=>{delete o(e).changeRequested,e.dispatchEvent(new Event("change"))})}}var B,q,U,tt,It,et=class extends EventTarget{constructor(){super();c(this,tt);c(this,B,void 0);c(this,q,void 0);c(this,U,void 0);o(this).trackSet=new Set}[Symbol.iterator](){return r(this,tt,It).values()}get length(){return r(this,tt,It).size}getTrackById(t){var n;return(n=[...r(this,tt,It)].find(a=>a.id===t))!=null?n:null}get selectedIndex(){return[...r(this,tt,It)].findIndex(t=>t.selected)}get onaddtrack(){return r(this,B)}set onaddtrack(t){r(this,B)&&(this.removeEventListener("addtrack",r(this,B)),d(this,B,void 0)),typeof t=="function"&&(d(this,B,t),this.addEventListener("addtrack",t))}get onremovetrack(){return r(this,q)}set onremovetrack(t){r(this,q)&&(this.removeEventListener("removetrack",r(this,q)),d(this,q,void 0)),typeof t=="function"&&(d(this,q,t),this.addEventListener("removetrack",t))}get onchange(){return r(this,U)}set onchange(t){r(this,U)&&(this.removeEventListener("change",r(this,U)),d(this,U,void 0)),typeof t=="function"&&(d(this,U,t),this.addEventListener("change",t))}};B=new WeakMap,q=new WeakMap,U=new WeakMap,tt=new WeakSet,It=function(){return o(this).trackSet};var G=class extends Event{constructor(t,n){super(t);f(this,"rendition");this.rendition=n.rendition}};function Ye(i,e){let t=o(i).media.videoRenditions;o(e).media=o(i).media,o(e).track=i;let n=o(i).renditionSet;n.add(e);let a=n.size-1;a in it.prototype||Object.defineProperty(it.prototype,a,{get(){return ut(this)[a]}}),queueMicrotask(()=>{!i.selected||t.dispatchEvent(new G("addrendition",{rendition:e}))})}function We(i){let e=o(i).media.videoRenditions,t=o(i).track;o(t).renditionSet.delete(i),queueMicrotask(()=>{!o(i).track.selected||e.dispatchEvent(new G("removerendition",{rendition:i}))})}function je(i){let e=o(i).media.videoRenditions;!e||o(e).changeRequested||(o(e).changeRequested=!0,queueMicrotask(()=>{delete o(e).changeRequested,o(i).track.selected&&e.dispatchEvent(new Event("change"))}))}function ut(i){return[...o(i).media.videoTracks].filter(t=>t.selected).flatMap(t=>[...o(t).renditionSet])}var Y,W,j,it=class extends EventTarget{constructor(){super(...arguments);c(this,Y,void 0);c(this,W,void 0);c(this,j,void 0)}[Symbol.iterator](){return ut(this).values()}get length(){return ut(this).length}getRenditionById(t){var n;return(n=ut(this).find(a=>`${a.id}`==`${t}`))!=null?n:null}get selectedIndex(){return ut(this).findIndex(t=>t.selected)}set selectedIndex(t){for(let[n,a]of ut(this).entries())a.selected=n===t}get onaddrendition(){return r(this,Y)}set onaddrendition(t){r(this,Y)&&(this.removeEventListener("addrendition",r(this,Y)),d(this,Y,void 0)),typeof t=="function"&&(d(this,Y,t),this.addEventListener("addrendition",t))}get onremoverendition(){return r(this,W)}set onremoverendition(t){r(this,W)&&(this.removeEventListener("removerendition",r(this,W)),d(this,W,void 0)),typeof t=="function"&&(d(this,W,t),this.addEventListener("removerendition",t))}get onchange(){return r(this,j)}set onchange(t){r(this,j)&&(this.removeEventListener("change",r(this,j)),d(this,j,void 0)),typeof t=="function"&&(d(this,j,t),this.addEventListener("change",t))}};Y=new WeakMap,W=new WeakMap,j=new WeakMap;var ht,wt=class{constructor(){f(this,"src");f(this,"id");f(this,"width");f(this,"height");f(this,"bitrate");f(this,"frameRate");f(this,"codec");c(this,ht,!1)}get selected(){return r(this,ht)}set selected(e){r(this,ht)!==e&&(d(this,ht,e),je(this))}};ht=new WeakMap;var lt,ft=class{constructor(){f(this,"id");f(this,"kind");f(this,"label","");f(this,"language","");f(this,"sourceBuffer");c(this,lt,!1)}addRendition(e,t,n,a,m,g){let y=new wt;return y.src=e,y.width=t,y.height=n,y.frameRate=g,y.bitrate=m,y.codec=a,Ye(this,y),y}removeRendition(e){We(e)}get selected(){return r(this,lt)}set selected(e){r(this,lt)!==e&&(d(this,lt,e),e===!0&&Ue(this))}};lt=new WeakMap;function Ke(i,e){let t=o(i).media.audioRenditions;o(e).media=o(i).media,o(e).track=i;let n=o(i).renditionSet;n.add(e);let a=n.size-1;a in rt.prototype||Object.defineProperty(rt.prototype,a,{get(){return mt(this)[a]}}),queueMicrotask(()=>{!i.enabled||t.dispatchEvent(new G("addrendition",{rendition:e}))})}function He(i){let e=o(i).media.audioRenditions,t=o(i).track;o(t).renditionSet.delete(i),queueMicrotask(()=>{!o(i).track.enabled||e.dispatchEvent(new G("removerendition",{rendition:i}))})}function $e(i){let e=o(i).media.audioRenditions;!e||o(e).changeRequested||(o(e).changeRequested=!0,queueMicrotask(()=>{delete o(e).changeRequested,o(i).track.enabled&&e.dispatchEvent(new Event("change"))}))}function mt(i){return[...o(i).media.audioTracks].filter(t=>t.enabled).flatMap(t=>[...o(t).renditionSet])}var K,H,$,rt=class extends EventTarget{constructor(){super(...arguments);c(this,K,void 0);c(this,H,void 0);c(this,$,void 0)}[Symbol.iterator](){return mt(this).values()}get length(){return mt(this).length}getRenditionById(t){var n;return(n=mt(this).find(a=>`${a.id}`==`${t}`))!=null?n:null}get selectedIndex(){return mt(this).findIndex(t=>t.selected)}set selectedIndex(t){for(let[n,a]of mt(this).entries())a.selected=n===t}get onaddrendition(){return r(this,K)}set onaddrendition(t){r(this,K)&&(this.removeEventListener("addrendition",r(this,K)),d(this,K,void 0)),typeof t=="function"&&(d(this,K,t),this.addEventListener("addrendition",t))}get onremoverendition(){return r(this,H)}set onremoverendition(t){r(this,H)&&(this.removeEventListener("removerendition",r(this,H)),d(this,H,void 0)),typeof t=="function"&&(d(this,H,t),this.addEventListener("removerendition",t))}get onchange(){return r(this,$)}set onchange(t){r(this,$)&&(this.removeEventListener("change",r(this,$)),d(this,$,void 0)),typeof t=="function"&&(d(this,$,t),this.addEventListener("change",t))}};K=new WeakMap,H=new WeakMap,$=new WeakMap;var pt,Mt=class{constructor(){f(this,"src");f(this,"id");f(this,"bitrate");f(this,"codec");c(this,pt,!1)}get selected(){return r(this,pt)}set selected(e){r(this,pt)!==e&&(d(this,pt,e),$e(this))}};pt=new WeakMap;function Zt(i,e){let t=i.audioTracks;o(e).media=i,o(e).renditionSet||(o(e).renditionSet=new Set);let n=o(t).trackSet;n.add(e);let a=n.size-1;a in st.prototype||Object.defineProperty(st.prototype,a,{get(){return[...o(this).trackSet][a]}}),queueMicrotask(()=>{t.dispatchEvent(new F("addtrack",{track:e}))})}function te(i){var n;let e=(n=o(i).media)==null?void 0:n.audioTracks;if(!e)return;o(e).trackSet.delete(i),queueMicrotask(()=>{e.dispatchEvent(new F("removetrack",{track:i}))})}function ze(i){let e=o(i).media.audioTracks;!e||o(e).changeRequested||(o(e).changeRequested=!0,queueMicrotask(()=>{delete o(e).changeRequested,e.dispatchEvent(new Event("change"))}))}var z,X,J,Et,Qt,st=class extends EventTarget{constructor(){super();c(this,Et);c(this,z,void 0);c(this,X,void 0);c(this,J,void 0);o(this).trackSet=new Set}[Symbol.iterator](){return r(this,Et,Qt).values()}get length(){return r(this,Et,Qt).size}getTrackById(t){var n;return(n=[...r(this,Et,Qt)].find(a=>a.id===t))!=null?n:null}get onaddtrack(){return r(this,z)}set onaddtrack(t){r(this,z)&&(this.removeEventListener("addtrack",r(this,z)),d(this,z,void 0)),typeof t=="function"&&(d(this,z,t),this.addEventListener("addtrack",t))}get onremovetrack(){return r(this,X)}set onremovetrack(t){r(this,X)&&(this.removeEventListener("removetrack",r(this,X)),d(this,X,void 0)),typeof t=="function"&&(d(this,X,t),this.addEventListener("removetrack",t))}get onchange(){return r(this,J)}set onchange(t){r(this,J)&&(this.removeEventListener("change",r(this,J)),d(this,J,void 0)),typeof t=="function"&&(d(this,J,t),this.addEventListener("change",t))}};z=new WeakMap,X=new WeakMap,J=new WeakMap,Et=new WeakSet,Qt=function(){return o(this).trackSet};var gt,vt=class{constructor(){f(this,"id");f(this,"kind");f(this,"label","");f(this,"language","");f(this,"sourceBuffer");c(this,gt,!1)}addRendition(e,t,n){let a=new Mt;return a.src=e,a.codec=t,a.bitrate=n,Ke(this,a),a}removeRendition(e){He(e)}get enabled(){return r(this,gt)}set enabled(e){r(this,gt)!==e&&(d(this,gt,e),ze(this))}};gt=new WeakMap;var Xe=ee(globalThis.HTMLMediaElement,"video"),Je=ee(globalThis.HTMLMediaElement,"audio");function Qe(i){if(!(i!=null&&i.prototype))return i;let e=ee(i,"video");(!e||`${e}`.includes("[native code]"))&&Object.defineProperty(i.prototype,"videoTracks",{get(){return ci(this)}});let t=ee(i,"audio");(!t||`${t}`.includes("[native code]"))&&Object.defineProperty(i.prototype,"audioTracks",{get(){return di(this)}}),"addVideoTrack"in i.prototype||(i.prototype.addVideoTrack=function(m,g="",y=""){let b=new ft;return b.kind=m,b.label=g,b.language=y,Xt(this,b),b}),"removeVideoTrack"in i.prototype||(i.prototype.removeVideoTrack=Jt),"addAudioTrack"in i.prototype||(i.prototype.addAudioTrack=function(m,g="",y=""){let b=new vt;return b.kind=m,b.label=g,b.language=y,Zt(this,b),b}),"removeAudioTrack"in i.prototype||(i.prototype.removeAudioTrack=te),"videoRenditions"in i.prototype||Object.defineProperty(i.prototype,"videoRenditions",{get(){return n(this)}});let n=m=>{let g=o(m).videoRenditions;return g||(g=new it,o(g).media=m,o(m).videoRenditions=g),g};"audioRenditions"in i.prototype||Object.defineProperty(i.prototype,"audioRenditions",{get(){return a(this)}});let a=m=>{let g=o(m).audioRenditions;return g||(g=new rt,o(g).media=m,o(m).audioRenditions=g),g};return i}function ee(i,e){var t;if(i!=null&&i.prototype)return(t=Object.getOwnPropertyDescriptor(i.prototype,`${e}Tracks`))==null?void 0:t.get}function ci(i){var t;let e=o(i).videoTracks;if(!e&&(e=new et,o(i).videoTracks=e,Xe)){let n=Xe.call((t=i.nativeEl)!=null?t:i);for(let a of n)Xt(i,a);n.addEventListener("change",()=>{e.dispatchEvent(new Event("change"))}),n.addEventListener("addtrack",a=>{if([...e].some(m=>m instanceof ft)){for(let m of n)Jt(m);return}Xt(i,a.track)}),n.addEventListener("removetrack",a=>{Jt(a.track)})}return e}function di(i){var t;let e=o(i).audioTracks;if(!e&&(e=new st,o(i).audioTracks=e,Je)){let n=Je.call((t=i.nativeEl)!=null?t:i);for(let a of n)Zt(i,a);n.addEventListener("change",()=>{e.dispatchEvent(new Event("change"))}),n.addEventListener("addtrack",a=>{if([...e].some(m=>m instanceof vt)){for(let m of n)te(m);return}Zt(i,a.track)}),n.addEventListener("removetrack",a=>{te(a.track)})}return e}pe.push("castchange","entercast","leavecast");var ge=Qe(zt(Ct.HTMLElement,{tag:"video",is:"castable-video"})),h={BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",CUSTOM_DOMAIN:"custom-domain",DEBUG:"debug",DISABLE_COOKIES:"disable-cookies",ENV_KEY:"env-key",MAX_RESOLUTION:"max-resolution",METADATA_URL:"metadata-url",PLAYBACK_ID:"playback-id",PLAYER_SOFTWARE_NAME:"player-software-name",PLAYER_SOFTWARE_VERSION:"player-software-version",PREFER_CMCD:"prefer-cmcd",PREFER_PLAYBACK:"prefer-playback",START_TIME:"start-time",STREAM_TYPE:"stream-type",TARGET_LIVE_WINDOW:"target-live-window",LIVE_EDGE_OFFSET:"live-edge-offset",TYPE:"type"},Pi=Object.values(h),Ri=Oe(),Li="mux-video",x,yt,xt,Tt,Dt,Nt,Ft,bt,re,_t=class extends ge{constructor(){super();c(this,bt);c(this,x,void 0);c(this,yt,void 0);c(this,xt,void 0);c(this,Tt,{});c(this,Dt,void 0);c(this,Nt,void 0);c(this,Ft,void 0);d(this,xt,li())}static get observedAttributes(){var t;return[...Pi,...(t=ge.observedAttributes)!=null?t:[]]}get preferCmcd(){var t;return(t=this.getAttribute(h.PREFER_CMCD))!=null?t:void 0}set preferCmcd(t){t!==this.preferCmcd&&(t?Ze.includes(t)?this.setAttribute(h.PREFER_CMCD,t):console.warn(`Invalid value for preferCmcd. Must be one of ${Ze.join()}`):this.removeAttribute(h.PREFER_CMCD))}get playerInitTime(){return r(this,xt)}get playerSoftwareName(){var t;return(t=r(this,Nt))!=null?t:Li}set playerSoftwareName(t){d(this,Nt,t)}get playerSoftwareVersion(){var t;return(t=r(this,Dt))!=null?t:Ri}set playerSoftwareVersion(t){d(this,Dt,t)}get _hls(){var t;return(t=r(this,x))==null?void 0:t.engine}get mux(){var t;return(t=this.nativeEl)==null?void 0:t.mux}get error(){var t;return(t=mi(this.nativeEl))!=null?t:null}get errorTranslator(){return r(this,Ft)}set errorTranslator(t){d(this,Ft,t)}get src(){return this.getAttribute("src")}set src(t){t!==this.src&&(t==null?this.removeAttribute("src"):this.setAttribute("src",t))}get type(){var t;return(t=this.getAttribute(h.TYPE))!=null?t:void 0}set type(t){t!==this.type&&(t?this.setAttribute(h.TYPE,t):this.removeAttribute(h.TYPE))}get autoplay(){let t=this.getAttribute("autoplay");return t===null?!1:t===""?!0:t}set autoplay(t){let n=this.autoplay;t!==n&&(t?this.setAttribute("autoplay",typeof t=="string"?t:""):this.removeAttribute("autoplay"))}get preload(){let t=this.getAttribute("preload");return t===""?"auto":["none","metadata","auto"].includes(t)?t:super.preload}set preload(t){t!=this.getAttribute("preload")&&(["","none","metadata","auto"].includes(t)?this.setAttribute("preload",t):this.removeAttribute("preload"))}get debug(){return this.getAttribute(h.DEBUG)!=null}set debug(t){t!==this.debug&&(t?this.setAttribute(h.DEBUG,""):this.removeAttribute(h.DEBUG))}get disableCookies(){return this.hasAttribute(h.DISABLE_COOKIES)}set disableCookies(t){t!==this.disableCookies&&(t?this.setAttribute(h.DISABLE_COOKIES,""):this.removeAttribute(h.DISABLE_COOKIES))}get startTime(){let t=this.getAttribute(h.START_TIME);if(t==null)return;let n=+t;return Number.isNaN(n)?void 0:n}set startTime(t){t!==this.startTime&&(t==null?this.removeAttribute(h.START_TIME):this.setAttribute(h.START_TIME,`${t}`))}get playbackId(){var t;return(t=this.getAttribute(h.PLAYBACK_ID))!=null?t:void 0}set playbackId(t){t!==this.playbackId&&(t?this.setAttribute(h.PLAYBACK_ID,t):this.removeAttribute(h.PLAYBACK_ID))}get maxResolution(){var t;return(t=this.getAttribute(h.MAX_RESOLUTION))!=null?t:void 0}set maxResolution(t){t!==this.maxResolution&&(t?this.setAttribute(h.MAX_RESOLUTION,t):this.removeAttribute(h.MAX_RESOLUTION))}get customDomain(){var t;return(t=this.getAttribute(h.CUSTOM_DOMAIN))!=null?t:void 0}set customDomain(t){t!==this.customDomain&&(t?this.setAttribute(h.CUSTOM_DOMAIN,t):this.removeAttribute(h.CUSTOM_DOMAIN))}get ended(){return Si(this.nativeEl,this._hls)}get envKey(){var t;return(t=this.getAttribute(h.ENV_KEY))!=null?t:void 0}set envKey(t){t!==this.envKey&&(t?this.setAttribute(h.ENV_KEY,t):this.removeAttribute(h.ENV_KEY))}get beaconCollectionDomain(){var t;return(t=this.getAttribute(h.BEACON_COLLECTION_DOMAIN))!=null?t:void 0}set beaconCollectionDomain(t){t!==this.beaconCollectionDomain&&(t?this.setAttribute(h.BEACON_COLLECTION_DOMAIN,t):this.removeAttribute(h.BEACON_COLLECTION_DOMAIN))}get streamType(){var t;return(t=this.getAttribute(h.STREAM_TYPE))!=null?t:Ti(this.nativeEl)}set streamType(t){t!==this.streamType&&(t?this.setAttribute(h.STREAM_TYPE,t):this.removeAttribute(h.STREAM_TYPE))}get targetLiveWindow(){return this.hasAttribute(h.TARGET_LIVE_WINDOW)?+this.getAttribute(h.TARGET_LIVE_WINDOW):bi(this.nativeEl)}set targetLiveWindow(t){t!=this.targetLiveWindow&&(t==null?this.removeAttribute(h.TARGET_LIVE_WINDOW):this.setAttribute(h.TARGET_LIVE_WINDOW,`${+t}`))}get liveEdgeStart(){var t,n;if(this.hasAttribute(h.LIVE_EDGE_OFFSET)){let{liveEdgeOffset:a}=this,m=(t=this.nativeEl.seekable.end(0))!=null?t:0,g=(n=this.nativeEl.seekable.start(0))!=null?n:0;return Math.max(g,m-a)}return Ai(this.nativeEl)}get liveEdgeOffset(){if(!!this.hasAttribute(h.LIVE_EDGE_OFFSET))return+this.getAttribute(h.LIVE_EDGE_OFFSET)}set liveEdgeOffset(t){t!=this.targetLiveWindow&&(t==null?this.removeAttribute(h.LIVE_EDGE_OFFSET):this.setAttribute(h.LIVE_EDGE_OFFSET,`${+t}`))}get seekable(){return ki(this.nativeEl)}async addCuePoints(t){return pi(this.nativeEl,t)}get activeCuePoint(){return gi(this.nativeEl)}get cuePoints(){return Ei(this.nativeEl)}getStartDate(){return vi(this.nativeEl,this._hls)}get currentPdt(){return yi(this.nativeEl,this._hls)}get preferPlayback(){let t=this.getAttribute(h.PREFER_PLAYBACK);if(t===ie.MSE||t===ie.NATIVE)return t}set preferPlayback(t){t!==this.preferPlayback&&(t===ie.MSE||t===ie.NATIVE?this.setAttribute(h.PREFER_PLAYBACK,t):this.removeAttribute(h.PREFER_PLAYBACK))}get metadata(){return{...this.getAttributeNames().filter(n=>n.startsWith("metadata-")&&![h.METADATA_URL].includes(n)).reduce((n,a)=>{let m=this.getAttribute(a);return m!=null&&(n[a.replace(/^metadata-/,"").replace(/-/g,"_")]=m),n},{}),...r(this,Tt)}}set metadata(t){d(this,Tt,t!=null?t:{}),this.mux&&this.mux.emit("hb",r(this,Tt))}load(){d(this,x,ui(this,this.nativeEl,r(this,x)))}unload(){hi(this.nativeEl,r(this,x)),d(this,x,void 0)}attributeChangedCallback(t,n,a){var g,y;switch(ge.observedAttributes.includes(t)&&!["src","autoplay","preload"].includes(t)&&super.attributeChangedCallback(t,n,a),t){case h.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=a!=null?a:void 0;break;case h.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=a!=null?a:void 0;break;case"src":{let b=!!n,L=!!a;!b&&L?T(this,bt,re).call(this):b&&!L?this.unload():b&&L&&(this.unload(),T(this,bt,re).call(this));break}case"autoplay":if(a===n)break;(g=r(this,x))==null||g.setAutoplay(this.autoplay);break;case"preload":if(a===n)break;(y=r(this,x))==null||y.setPreload(a);break;case h.PLAYBACK_ID:this.src=fi(a!=null?a:void 0,{maxResolution:this.maxResolution,domain:this.customDomain});break;case h.DEBUG:{let b=this.debug;this.mux&&console.info("Cannot toggle debug mode of mux data after initialization. Make sure you set all metadata to override before setting the src."),this._hls&&(this._hls.config.debug=b);break}case h.METADATA_URL:a&&fetch(a).then(b=>b.json()).then(b=>this.metadata=b).catch(()=>console.error(`Unable to load or parse metadata JSON from metadata-url ${a}!`));break;case h.STREAM_TYPE:(a==null||a!==n)&&this.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}));break;case h.TARGET_LIVE_WINDOW:(a==null||a!==n)&&this.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0,detail:this.targetLiveWindow}));break;default:break}}connectedCallback(){var t;(t=super.connectedCallback)==null||t.call(this),this.nativeEl&&this.src&&!r(this,x)&&T(this,bt,re).call(this)}disconnectedCallback(){this.unload()}};x=new WeakMap,yt=new WeakMap,xt=new WeakMap,Tt=new WeakMap,Dt=new WeakMap,Nt=new WeakMap,Ft=new WeakMap,bt=new WeakSet,re=async function(){r(this,yt)||(await d(this,yt,Promise.resolve()),d(this,yt,null),this.load())};Ct.customElements.get("mux-video")||(Ct.customElements.define("mux-video",_t),Ct.MuxVideoElement=_t);var is=_t;export{h as Attributes,Xr as MediaError,pe as VideoEvents,is as default};
39
39
  //# sourceMappingURL=index.mjs.map