@mux/mux-video 0.15.6 → 0.16.0

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