Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mux/playback-core

Package Overview
Dependencies
Maintainers
1
Versions
585
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mux/playback-core - npm Package Compare versions

Comparing version 0.28.1-canary.2 to 0.28.1-canary.3

4

dist/index.cjs.js

@@ -1,4 +0,4 @@

"use strict";var kt=Object.create;var B=Object.defineProperty;var ht=Object.getOwnPropertyDescriptor;var Lt=Object.getOwnPropertyNames;var Nt=Object.getPrototypeOf,It=Object.prototype.hasOwnProperty;var At=(e,t)=>{for(var r in t)B(e,r,{get:t[r],enumerable:!0})},De=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Lt(t))!It.call(e,o)&&o!==r&&B(e,o,{get:()=>t[o],enumerable:!(n=ht(t,o))||n.enumerable});return e};var Pe=(e,t,r)=>(r=e!=null?kt(Nt(e)):{},De(t||!e||!e.__esModule?B(r,"default",{value:e,enumerable:!0}):r,e)),St=e=>De(B({},"__esModule",{value:!0}),e);var ar={};At(ar,{AutoplayTypes:()=>H,CmcdTypeValues:()=>Ot,CmcdTypes:()=>O,ExtensionMimeTypeMap:()=>N,Hls:()=>R,MaxResolution:()=>Vt,MediaError:()=>f,MimeTypeShorthandMap:()=>V,MinResolution:()=>Ft,MuxErrorCategory:()=>x,MuxErrorCode:()=>g,MuxJWTAud:()=>Q,PlaybackTypes:()=>J,RenditionOrder:()=>Kt,StreamTypes:()=>D,addChapters:()=>pe,addCuePoints:()=>ce,addTextTrack:()=>X,allMediaTypes:()=>Ht,errorCategoryToTokenNameOrPrefix:()=>U,generatePlayerInitTime:()=>Xt,generateUUID:()=>dt,getActiveChapter:()=>fe,getActiveCuePoint:()=>ue,getAppCertificate:()=>xt,getChapters:()=>Be,getCuePoints:()=>We,getCurrentPdt:()=>Ge,getDRMConfig:()=>Rt,getEnded:()=>yt,getError:()=>pt,getLicenseKey:()=>bt,getLiveEdgeStart:()=>tr,getMediaPlaylistLinesFromMultivariantPlaylistSrc:()=>nt,getSeekable:()=>Me,getStartDate:()=>Je,getStreamInfoFromHlsjsLevelDetails:()=>it,getStreamInfoFromPlaylistLines:()=>ot,getStreamInfoFromSrcAndType:()=>at,getStreamType:()=>Ee,getStreamTypeConfig:()=>Mt,getTargetLiveWindow:()=>er,getTextTrack:()=>S,i18n:()=>E,initialize:()=>nr,isKeyOf:()=>w,isMuxVideoSrc:()=>Ce,isPseudoEnded:()=>Tt,isStuckOnLastFragment:()=>xe,loadMedia:()=>vt,mux:()=>$.default,muxMediaState:()=>v,parseJwt:()=>q,removeTextTrack:()=>Fe,setupChapters:()=>Te,setupCuePoints:()=>de,setupHls:()=>gt,setupMux:()=>_t,setupNativeFairplayDRM:()=>Ct,shorthandKeys:()=>Ut,teardown:()=>mt,toAppCertURL:()=>be,toDRMTypeFromKeySystem:()=>rt,toLicenseKeyURL:()=>W,toMuxVideoURL:()=>Qt,toPlaybackIdFromSrc:()=>lt,toPlaybackIdParts:()=>F,updateStreamInfoFromHlsjsLevelDetails:()=>ct,updateStreamInfoFromSrc:()=>st});module.exports=St(ar);var $=Pe(require("mux-embed"));var ke=Pe(require("hls.js")),R=ke.default;var x={VIDEO:"video",THUMBNAIL:"thumbnail",STORYBOARD:"storyboard",DRM:"drm"},g={NOT_AN_ERROR:0,NETWORK_OFFLINE:2000002,NETWORK_UNKNOWN_ERROR:2e6,NETWORK_NO_STATUS:2000001,NETWORK_INVALID_URL:24e5,NETWORK_NOT_FOUND:2404e3,NETWORK_NOT_READY:2412e3,NETWORK_GENERIC_SERVER_FAIL:25e5,NETWORK_TOKEN_MISSING:2403201,NETWORK_TOKEN_MALFORMED:2412202,NETWORK_TOKEN_EXPIRED:2403210,NETWORK_TOKEN_AUD_MISSING:2403221,NETWORK_TOKEN_AUD_MISMATCH:2403222,NETWORK_TOKEN_SUB_MISMATCH:2403232,ENCRYPTED_ERROR:5e6,ENCRYPTED_UNSUPPORTED_KEY_SYSTEM:5000001,ENCRYPTED_GENERATE_REQUEST_FAILED:5000002,ENCRYPTED_UPDATE_LICENSE_FAILED:5000003,ENCRYPTED_UPDATE_SERVER_CERT_FAILED:5000004,ENCRYPTED_CDM_ERROR:5000005,ENCRYPTED_OUTPUT_RESTRICTED:5000006,ENCRYPTED_MISSING_TOKEN:5000002},U=e=>e===x.VIDEO?"playback":e,k=class k extends Error{constructor(t,r=k.MEDIA_ERR_CUSTOM,n,o){var a;super(t),this.name="MediaError",this.code=r,this.context=o,this.fatal=n!=null?n:r>=k.MEDIA_ERR_NETWORK&&r<=k.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(a=k.defaultMessages[this.code])!=null?a:"")}};k.MEDIA_ERR_ABORTED=1,k.MEDIA_ERR_NETWORK=2,k.MEDIA_ERR_DECODE=3,k.MEDIA_ERR_SRC_NOT_SUPPORTED=4,k.MEDIA_ERR_ENCRYPTED=5,k.MEDIA_ERR_CUSTOM=100,k.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail.",3:"A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.",4:"An unsupported error occurred. The server or network failed, or your browser does not support this format.",5:"The media is encrypted and there are no keys to decrypt it."};var f=k;var wt=e=>e==null,w=(e,t)=>wt(t)?!1:e in t,H={ANY:"any",MUTED:"muted"},D={ON_DEMAND:"on-demand",LIVE:"live",UNKNOWN:"unknown"},J={MSE:"mse",NATIVE:"native"},O={HEADER:"header",QUERY:"query",NONE:"none"},Ot=Object.values(O),N={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},V={HLS:N.M3U8},Ut=Object.keys(V),Ht=[...Object.values(N),"hls","HLS"],Vt={upTo720p:"720p",upTo1080p:"1080p",upTo1440p:"1440p",upTo2160p:"2160p"},Ft={noLessThan480p:"480p",noLessThan540p:"540p",noLessThan720p:"720p",noLessThan1080p:"1080p",noLessThan1440p:"1440p",noLessThan2160p:"2160p"},Kt={DESCENDING:"desc"};var Yt="en",G={code:Yt};var C=(e,t,r,n,o=e)=>{o.addEventListener(t,r,n),e.addEventListener("teardown",()=>{o.removeEventListener(t,r)},{once:!0})};function he(e,t,r){t&&r>t&&(r=t);for(let n=0;n<e.length;n++)if(e.start(n)<=r&&e.end(n)>=r)return!0;return!1}var F=e=>{let t=e.indexOf("?");if(t<0)return[e];let r=e.slice(0,t),n=e.slice(t);return[r,n]},K=e=>{let t=e.type;if(t){let n=t.toUpperCase();return w(n,V)?V[n]:t}let{src:r}=e;return r?Wt(r):""},ne=e=>e==="VOD"?D.ON_DEMAND:D.LIVE,oe=e=>e==="EVENT"?Number.POSITIVE_INFINITY:e==="VOD"?Number.NaN:0,Wt=e=>{let t="";try{t=new URL(e).pathname}catch{console.error("invalid url")}let r=t.lastIndexOf(".");if(r<0)return"";let o=t.slice(r+1).toUpperCase();return w(o,N)?N[o]:""},q=e=>{let t=(e!=null?e:"").split(".")[1];if(t)try{let r=t.replace(/-/g,"+").replace(/_/g,"/"),n=decodeURIComponent(atob(r).split("").map(function(o){return"%"+("00"+o.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(n)}catch{return}},Le=({exp:e},t=Date.now())=>!e||e*1e3<t,Ne=({sub:e},t)=>e!==t,Ie=({aud:e},t)=>!e,Ae=({aud:e},t)=>e!==t,Se="en";function E(e,t=!0){var o,a;let r=t&&(a=(o=G)==null?void 0:o[e])!=null?a:e,n=t?G.code:Se;return new re(r,n)}var re=class{constructor(t,r=(n=>(n=G)!=null?n:Se)()){this.message=t,this.locale=r}format(t){return this.message.replace(/\{(\w+)\}/g,(r,n)=>{var o;return(o=t[n])!=null?o:""})}toString(){return this.message}};var $t=Object.values(H),we=e=>typeof e=="boolean"||typeof e=="string"&&$t.includes(e),Oe=(e,t,r)=>{let{autoplay:n}=e,o=!1,a=!1,s=we(n)?n:!!n,u=()=>{o||C(t,"playing",()=>{o=!0},{once:!0})};if(u(),C(t,"loadstart",()=>{o=!1,u(),ae(t,s)},{once:!0}),C(t,"loadstart",()=>{r||(e.streamType&&e.streamType!==D.UNKNOWN?a=e.streamType===D.LIVE:a=!Number.isFinite(t.duration)),ae(t,s)},{once:!0}),r&&r.once(R.Events.LEVEL_LOADED,(c,i)=>{var d;e.streamType&&e.streamType!==D.UNKNOWN?a=e.streamType===D.LIVE:a=(d=i.details.live)!=null?d:!1}),!s){let c=()=>{!a||Number.isFinite(e.startTime)||(r!=null&&r.liveSyncPosition?t.currentTime=r.liveSyncPosition:Number.isFinite(t.seekable.end(0))&&(t.currentTime=t.seekable.end(0)))};r&&C(t,"play",()=>{t.preload==="metadata"?r.once(R.Events.LEVEL_UPDATED,c):c()},{once:!0})}return c=>{o||(s=we(c)?c:!!c,ae(t,s))}},ae=(e,t)=>{if(!t)return;let r=e.muted,n=()=>e.muted=r;switch(t){case H.ANY:e.play().catch(()=>{e.muted=!0,e.play().catch(n)});break;case H.MUTED:e.muted=!0,e.play().catch(n);break;default:e.play().catch(()=>{});break}};var Ue=({preload:e,src:t},r,n)=>{let o=d=>{d!=null&&["","none","metadata","auto"].includes(d)?r.setAttribute("preload",d):r.removeAttribute("preload")};if(!n)return o(e),o;let a=!1,s=!1,u=n.config.maxBufferLength,l=n.config.maxBufferSize,c=d=>{o(d);let p=d!=null?d:r.preload;s||p==="none"||(p==="metadata"?(n.config.maxBufferLength=1,n.config.maxBufferSize=1):(n.config.maxBufferLength=u,n.config.maxBufferSize=l),i())},i=()=>{!a&&t&&(a=!0,n.loadSource(t))};return C(r,"play",()=>{s=!0,n.config.maxBufferLength=u,n.config.maxBufferSize=l,i()},{once:!0}),c(e),c};function He(e,t){var l;if(!("videoTracks"in e))return;let r=new WeakMap;t.on(R.Events.MANIFEST_PARSED,function(c,i){u();let d=e.addVideoTrack("main");d.selected=!0;for(let[p,T]of i.levels.entries()){let y=d.addRendition(T.url[0],T.width,T.height,T.videoCodec,T.bitrate);r.set(T,`${p}`),y.id=`${p}`}}),t.on(R.Events.AUDIO_TRACKS_UPDATED,function(c,i){s();for(let d of i.audioTracks){let p=d.default?"main":"alternative",T=e.addAudioTrack(p,d.name,d.lang);T.id=`${d.id}`,d.default&&(T.enabled=!0)}}),e.audioTracks.addEventListener("change",()=>{var d;let c=+((d=[...e.audioTracks].find(p=>p.enabled))==null?void 0:d.id),i=t.audioTracks.map(p=>p.id);c!=t.audioTrack&&i.includes(c)&&(t.audioTrack=c)}),t.on(R.Events.LEVELS_UPDATED,function(c,i){var T;let d=e.videoTracks[(T=e.videoTracks.selectedIndex)!=null?T:0];if(!d)return;let p=i.levels.map(y=>r.get(y));for(let y of e.videoRenditions)y.id&&!p.includes(y.id)&&d.removeRendition(y)});let n=c=>{let i=c.target.selectedIndex;i!=t.nextLevel&&o(i)},o=c=>{let i=e.currentTime,d=!1,p=(T,y)=>{d||(d=!Number.isFinite(y.endOffset))};t.on(R.Events.BUFFER_FLUSHING,p),t.nextLevel=c,t.off(R.Events.BUFFER_FLUSHING,p),d||t.trigger(R.Events.BUFFER_FLUSHING,{startOffset:i+10,endOffset:1/0,type:"video"})};(l=e.videoRenditions)==null||l.addEventListener("change",n);let a=()=>{for(let c of e.videoTracks)e.removeVideoTrack(c)},s=()=>{for(let c of e.audioTracks)e.removeAudioTrack(c)},u=()=>{a(),s()};t.once(R.Events.DESTROYING,u)}var se=e=>"time"in e?e.time:e.startTime;function Ve(e,t){t.on(R.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(o,{tracks:a})=>{a.forEach(s=>{var i,d;let u=(i=s.subtitleTrack)!=null?i:s.closedCaptions,l=t.subtitleTracks.findIndex(({lang:p,name:T,type:y})=>p==(u==null?void 0:u.lang)&&T===s.label&&y.toLowerCase()===s.kind),c=((d=s._id)!=null?d:s.default)?"default":`${s.kind}${l}`;X(e,s.kind,s.label,u==null?void 0:u.lang,c,s.default)})});let r=()=>{if(!t.subtitleTracks.length)return;let o=Array.from(e.textTracks).find(u=>u.id&&u.mode==="showing"&&["subtitles","captions"].includes(u.kind));if(!o)return;let a=t.subtitleTracks[t.subtitleTrack],s=a?a.default?"default":`${t.subtitleTracks[t.subtitleTrack].type.toLowerCase()}${t.subtitleTrack}`:void 0;if(t.subtitleTrack<0||(o==null?void 0:o.id)!==s){let u=t.subtitleTracks.findIndex(({lang:l,name:c,type:i,default:d})=>o.id==="default"&&d||l==o.language&&c===o.label&&i.toLowerCase()===o.kind);t.subtitleTrack=u}(o==null?void 0:o.id)===s&&o.cues&&Array.from(o.cues).forEach(u=>{o.addCue(u)})};e.textTracks.addEventListener("change",r),t.on(R.Events.CUES_PARSED,(o,{track:a,cues:s})=>{let u=e.textTracks.getTrackById(a);if(!u)return;let l=u.mode==="disabled";l&&(u.mode="hidden"),s.forEach(c=>{var i;(i=u.cues)!=null&&i.getCueById(c.id)||u.addCue(c)}),l&&(u.mode="disabled")}),t.once(R.Events.DESTROYING,()=>{e.textTracks.removeEventListener("change",r),e.querySelectorAll("track[data-removeondestroy]").forEach(a=>{a.remove()})});let n=()=>{Array.from(e.textTracks).forEach(o=>{var a,s;if(!["subtitles","caption"].includes(o.kind)&&(o.label==="thumbnails"||o.kind==="chapters")){if(!((a=o.cues)!=null&&a.length)){let u="track";o.kind&&(u+=`[kind="${o.kind}"]`),o.label&&(u+=`[label="${o.label}"]`);let l=e.querySelector(u),c=(s=l==null?void 0:l.getAttribute("src"))!=null?s:"";l==null||l.removeAttribute("src"),setTimeout(()=>{l==null||l.setAttribute("src",c)},0)}o.mode!=="hidden"&&(o.mode="hidden")}})};t.once(R.Events.MANIFEST_LOADED,n),t.once(R.Events.MEDIA_ATTACHED,n)}function X(e,t,r,n,o,a){let s=document.createElement("track");return s.kind=t,s.label=r,n&&(s.srclang=n),o&&(s.id=o),a&&(s.default=!0),s.track.mode=["subtitles","captions"].includes(t)?"disabled":"hidden",s.setAttribute("data-removeondestroy",""),e.append(s),s.track}function Fe(e,t){let r=Array.prototype.find.call(e.querySelectorAll("track"),n=>n.track===t);r==null||r.remove()}function S(e,t,r){var n;return(n=Array.from(e.querySelectorAll("track")).find(o=>o.track.label===t&&o.track.kind===r))==null?void 0:n.track}async function Ke(e,t,r,n){let o=S(e,r,n);return o||(o=X(e,n,r),o.mode="hidden",await new Promise(a=>setTimeout(()=>a(void 0),0))),o.mode!=="hidden"&&(o.mode="hidden"),[...t].sort((a,s)=>se(s)-se(a)).forEach(a=>{var l,c;let s=a.value,u=se(a);if("endTime"in a&&a.endTime!=null)o==null||o.addCue(new VTTCue(u,a.endTime,n==="chapters"?s:JSON.stringify(s!=null?s:null)));else{let i=Array.prototype.findIndex.call(o==null?void 0:o.cues,y=>y.startTime>=u),d=(l=o==null?void 0:o.cues)==null?void 0:l[i],p=d?d.startTime:Number.isFinite(e.duration)?e.duration:Number.MAX_SAFE_INTEGER,T=(c=o==null?void 0:o.cues)==null?void 0:c[i-1];T&&(T.endTime=u),o==null||o.addCue(new VTTCue(u,p,n==="chapters"?s:JSON.stringify(s!=null?s:null)))}}),e.textTracks.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),o}var ie="cuepoints",Ye=Object.freeze({label:ie});async function ce(e,t,r=Ye){return Ke(e,t,r.label,"metadata")}var j=e=>({time:e.startTime,value:JSON.parse(e.text)});function We(e,t={label:ie}){let r=S(e,t.label,"metadata");return r!=null&&r.cues?Array.from(r.cues,n=>j(n)):[]}function ue(e,t={label:ie}){var a,s;let r=S(e,t.label,"metadata");if(!((a=r==null?void 0:r.activeCues)!=null&&a.length))return;if(r.activeCues.length===1)return j(r.activeCues[0]);let{currentTime:n}=e,o=Array.prototype.find.call((s=r.activeCues)!=null?s:[],({startTime:u,endTime:l})=>u<=n&&l>n);return j(o||r.activeCues[0])}async function de(e,t=Ye){return new Promise(r=>{C(e,"loadstart",async()=>{let n=await ce(e,[],t);C(e,"cuechange",()=>{let o=ue(e);if(o){let a=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:o});e.dispatchEvent(a)}},{},n),r(n)})})}var le="chapters",$e=Object.freeze({label:le}),z=e=>({startTime:e.startTime,endTime:e.endTime,value:e.text});async function pe(e,t,r=$e){return Ke(e,t,r.label,"chapters")}function Be(e,t={label:le}){var n;let r=S(e,t.label,"chapters");return(n=r==null?void 0:r.cues)!=null&&n.length?Array.from(r.cues,o=>z(o)):[]}function fe(e,t={label:le}){var a,s;let r=S(e,t.label,"chapters");if(!((a=r==null?void 0:r.activeCues)!=null&&a.length))return;if(r.activeCues.length===1)return z(r.activeCues[0]);let{currentTime:n}=e,o=Array.prototype.find.call((s=r.activeCues)!=null?s:[],({startTime:u,endTime:l})=>u<=n&&l>n);return z(o||r.activeCues[0])}async function Te(e,t=$e){return new Promise(r=>{C(e,"loadstart",async()=>{let n=await pe(e,[],t);C(e,"cuechange",()=>{let o=fe(e);if(o){let a=new CustomEvent("chapterchange",{composed:!0,bubbles:!0,detail:o});e.dispatchEvent(a)}},{},n),r(n)})})}function Je(e,t){if(t){let r=t.playingDate;if(r!=null)return new Date(r.getTime()-e.currentTime*1e3)}return typeof e.getStartDate=="function"?e.getStartDate():new Date(NaN)}function Ge(e,t){if(t&&t.playingDate)return t.playingDate;if(typeof e.getStartDate=="function"){let r=e.getStartDate();return new Date(r.getTime()+e.currentTime*1e3)}return new Date(NaN)}var h=require("hls.js");var Q={VIDEO:"v",THUMBNAIL:"t",STORYBOARD:"s",DRM:"d"},Bt=e=>{if(e===x.VIDEO)return Q.VIDEO;if(e===x.DRM)return Q.DRM},Jt=(e,t)=>{var o,a;let r=U(e),n=`${r}Token`;return(o=t.tokens)!=null&&o[r]?(a=t.tokens)==null?void 0:a[r]:w(n,t)?t[n]:void 0},Y=(e,t,r,n=!1,o=!(a=>(a=globalThis.navigator)==null?void 0:a.onLine)())=>{var _,P;if(o){let M=E("Your device appears to be offline",n),b=void 0,m=f.MEDIA_ERR_NETWORK,L=new f(M,m,!0,b);return L.errorCategory=t,L.muxCode=g.NETWORK_OFFLINE,L.data=e,L}let s="status"in e?e.status:e.code,u=Date.now(),l=f.MEDIA_ERR_NETWORK;if(s===200)return;let c=U(t),i=Jt(t,r),d=Bt(t),[p]=F((_=r.playbackId)!=null?_:"");if(!s||!p)return;let T=q(i);if(i&&!T){let M=E("The {tokenNamePrefix}-token provided is invalid or malformed.",n).format({tokenNamePrefix:c}),b=E("Compact JWT string: {token}",n).format({token:i}),m=new f(M,l,!0,b);return m.errorCategory=t,m.muxCode=g.NETWORK_TOKEN_MALFORMED,m.data=e,m}if(s>=500){let M=new f("",l,!0);return M.errorCategory=t,M.muxCode=g.NETWORK_UNKNOWN_ERROR,M}if(s===403)if(T){if(Le(T,u)){let M={timeStyle:"medium",dateStyle:"medium"},b=E("The video\u2019s secured {tokenNamePrefix}-token has expired.",n).format({tokenNamePrefix:c}),m=E("Expired at: {expiredDate}. Current time: {currentDate}.",n).format({expiredDate:new Intl.DateTimeFormat("en",M).format((P=T.exp)!=null?P:0*1e3),currentDate:new Intl.DateTimeFormat("en",M).format(u)}),L=new f(b,l,!0,m);return L.errorCategory=t,L.muxCode=g.NETWORK_TOKEN_EXPIRED,L.data=e,L}if(Ne(T,p)){let M=E("The video\u2019s playback ID does not match the one encoded in the {tokenNamePrefix}-token.",n).format({tokenNamePrefix:c}),b=E("Specified playback ID: {playbackId} and the playback ID encoded in the {tokenNamePrefix}-token: {tokenPlaybackId}",n).format({tokenNamePrefix:c,playbackId:p,tokenPlaybackId:T.sub}),m=new f(M,l,!0,b);return m.errorCategory=t,m.muxCode=g.NETWORK_TOKEN_SUB_MISMATCH,m.data=e,m}if(Ie(T,d)){let M=E("The {tokenNamePrefix}-token is formatted with incorrect information.",n).format({tokenNamePrefix:c}),b=E("The {tokenNamePrefix}-token has no aud value. aud value should be {expectedAud}.",n).format({tokenNamePrefix:c,expectedAud:d}),m=new f(M,l,!0,b);return m.errorCategory=t,m.muxCode=g.NETWORK_TOKEN_AUD_MISSING,m.data=e,m}if(Ae(T,d)){let M=E("The {tokenNamePrefix}-token is formatted with incorrect information.",n).format({tokenNamePrefix:c}),b=E("The {tokenNamePrefix}-token has an incorrect aud value: {aud}. aud value should be {expectedAud}.",n).format({tokenNamePrefix:c,expectedAud:d,aud:T.aud}),m=new f(M,l,!0,b);return m.errorCategory=t,m.muxCode=g.NETWORK_TOKEN_AUD_MISMATCH,m.data=e,m}}else{let M=E("Authorization error trying to access this {category} URL. If this is a signed URL, you might need to provide a {tokenNamePrefix}-token.",n).format({tokenNamePrefix:c,category:t}),b=E("Specified playback ID: {playbackId}",n).format({playbackId:p}),m=new f(M,l,!0,b);return m.errorCategory=t,m.muxCode=g.NETWORK_TOKEN_MISSING,m.data=e,m}if(s===412){let M=E("This playback-id may belong to a live stream that is not currently active or an asset that is not ready.",n),b=E("Specified playback ID: {playbackId}",n).format({playbackId:p}),m=new f(M,l,!0,b);return m.errorCategory=t,m.muxCode=g.NETWORK_NOT_READY,m.data=e,m}if(s===404){let M=E("This URL or playback-id does not exist. You may have used an Asset ID or an ID from a different resource.",n),b=E("Specified playback ID: {playbackId}",n).format({playbackId:p}),m=new f(M,l,!0,b);return m.errorCategory=t,m.muxCode=g.NETWORK_NOT_FOUND,m.data=e,m}if(s===400){let M=E("The URL or playback-id was invalid. You may have used an invalid value as a playback-id."),b=E("Specified playback ID: {playbackId}",n).format({playbackId:p}),m=new f(M,l,!0,b);return m.errorCategory=t,m.muxCode=g.NETWORK_INVALID_URL,m.data=e,m}let y=new f("",l,!0);return y.errorCategory=t,y.muxCode=g.NETWORK_UNKNOWN_ERROR,y.data=e,y};var ye=require("hls.js"),Z=class Z extends ye.CapLevelController{constructor(t){super(t)}get levels(){var t;return(t=this.hls.levels)!=null?t:[]}getValidLevels(t){return this.levels.filter((r,n)=>this.isLevelAllowed(r)&&n<=t)}getMaxLevel(t){let r=super.getMaxLevel(t),n=this.getValidLevels(t);if(!n[r])return r;let o=Math.min(n[r].width,n[r].height),a=Z.minMaxResolution;return o>=a?r:ye.CapLevelController.getMaxLevelByMediaSize(n,a*(16/9),a)}};Z.minMaxResolution=720;var me=Z,qe=me;var ee={FAIRPLAY:"fairplay",PLAYREADY:"playready",WIDEVINE:"widevine"},rt=e=>{if(e.includes("fps"))return ee.FAIRPLAY;if(e.includes("playready"))return ee.PLAYREADY;if(e.includes("widevine"))return ee.WIDEVINE},nt=async e=>fetch(e).then(t=>t.status!==200?Promise.reject(t):t.text()).then(t=>{let r=t.split(`
"use strict";var Pt=Object.create;var $=Object.defineProperty;var kt=Object.getOwnPropertyDescriptor;var ht=Object.getOwnPropertyNames;var Lt=Object.getPrototypeOf,Nt=Object.prototype.hasOwnProperty;var It=(e,t)=>{for(var r in t)$(e,r,{get:t[r],enumerable:!0})},De=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ht(t))!Nt.call(e,o)&&o!==r&&$(e,o,{get:()=>t[o],enumerable:!(n=kt(t,o))||n.enumerable});return e};var ve=(e,t,r)=>(r=e!=null?Pt(Lt(e)):{},De(t||!e||!e.__esModule?$(r,"default",{value:e,enumerable:!0}):r,e)),At=e=>De($({},"__esModule",{value:!0}),e);var or={};It(or,{AutoplayTypes:()=>U,CmcdTypeValues:()=>wt,CmcdTypes:()=>w,ExtensionMimeTypeMap:()=>L,Hls:()=>E,MaxResolution:()=>Ht,MediaError:()=>f,MimeTypeShorthandMap:()=>H,MinResolution:()=>Vt,MuxErrorCategory:()=>x,MuxErrorCode:()=>M,MuxJWTAud:()=>X,PlaybackTypes:()=>B,RenditionOrder:()=>Ft,StreamTypes:()=>_,addChapters:()=>le,addCuePoints:()=>ie,addTextTrack:()=>z,allMediaTypes:()=>Ut,errorCategoryToTokenNameOrPrefix:()=>O,generatePlayerInitTime:()=>zt,generateUUID:()=>ut,getActiveChapter:()=>pe,getActiveCuePoint:()=>ce,getAppCertificate:()=>Rt,getChapters:()=>We,getCuePoints:()=>Ke,getCurrentPdt:()=>Be,getDRMConfig:()=>Mt,getEnded:()=>Tt,getError:()=>lt,getLicenseKey:()=>xt,getLiveEdgeStart:()=>er,getMediaPlaylistLinesFromMultivariantPlaylistSrc:()=>rt,getSeekable:()=>Ee,getStartDate:()=>$e,getStreamInfoFromHlsjsLevelDetails:()=>st,getStreamInfoFromPlaylistLines:()=>nt,getStreamInfoFromSrcAndType:()=>ot,getStreamType:()=>ye,getStreamTypeConfig:()=>gt,getTargetLiveWindow:()=>Zt,getTextTrack:()=>A,i18n:()=>g,initialize:()=>rr,isKeyOf:()=>S,isMuxVideoSrc:()=>xe,isPseudoEnded:()=>ft,isStuckOnLastFragment:()=>Me,loadMedia:()=>Dt,mux:()=>W.default,muxMediaState:()=>v,parseJwt:()=>G,removeTextTrack:()=>He,setupChapters:()=>fe,setupCuePoints:()=>ue,setupHls:()=>Et,setupMux:()=>Ct,setupNativeFairplayDRM:()=>bt,shorthandKeys:()=>Ot,teardown:()=>yt,toAppCertURL:()=>Re,toDRMTypeFromKeySystem:()=>tt,toLicenseKeyURL:()=>Y,toMuxVideoURL:()=>Xt,toPlaybackIdFromSrc:()=>dt,toPlaybackIdParts:()=>V,updateStreamInfoFromHlsjsLevelDetails:()=>it,updateStreamInfoFromSrc:()=>at});module.exports=At(or);var W=ve(require("mux-embed"));var _e=ve(require("hls.js")),E=_e.default;var x={VIDEO:"video",THUMBNAIL:"thumbnail",STORYBOARD:"storyboard",DRM:"drm"},M={NOT_AN_ERROR:0,NETWORK_OFFLINE:2000002,NETWORK_UNKNOWN_ERROR:2e6,NETWORK_NO_STATUS:2000001,NETWORK_INVALID_URL:24e5,NETWORK_NOT_FOUND:2404e3,NETWORK_NOT_READY:2412e3,NETWORK_GENERIC_SERVER_FAIL:25e5,NETWORK_TOKEN_MISSING:2403201,NETWORK_TOKEN_MALFORMED:2412202,NETWORK_TOKEN_EXPIRED:2403210,NETWORK_TOKEN_AUD_MISSING:2403221,NETWORK_TOKEN_AUD_MISMATCH:2403222,NETWORK_TOKEN_SUB_MISMATCH:2403232,ENCRYPTED_ERROR:5e6,ENCRYPTED_UNSUPPORTED_KEY_SYSTEM:5000001,ENCRYPTED_GENERATE_REQUEST_FAILED:5000002,ENCRYPTED_UPDATE_LICENSE_FAILED:5000003,ENCRYPTED_UPDATE_SERVER_CERT_FAILED:5000004,ENCRYPTED_CDM_ERROR:5000005,ENCRYPTED_OUTPUT_RESTRICTED:5000006,ENCRYPTED_MISSING_TOKEN:5000002},O=e=>e===x.VIDEO?"playback":e,k=class k extends Error{constructor(t,r=k.MEDIA_ERR_CUSTOM,n,o){var a;super(t),this.name="MediaError",this.code=r,this.context=o,this.fatal=n!=null?n:r>=k.MEDIA_ERR_NETWORK&&r<=k.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(a=k.defaultMessages[this.code])!=null?a:"")}};k.MEDIA_ERR_ABORTED=1,k.MEDIA_ERR_NETWORK=2,k.MEDIA_ERR_DECODE=3,k.MEDIA_ERR_SRC_NOT_SUPPORTED=4,k.MEDIA_ERR_ENCRYPTED=5,k.MEDIA_ERR_CUSTOM=100,k.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail.",3:"A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.",4:"An unsupported error occurred. The server or network failed, or your browser does not support this format.",5:"The media is encrypted and there are no keys to decrypt it."};var f=k;var St=e=>e==null,S=(e,t)=>St(t)?!1:e in t,U={ANY:"any",MUTED:"muted"},_={ON_DEMAND:"on-demand",LIVE:"live",UNKNOWN:"unknown"},B={MSE:"mse",NATIVE:"native"},w={HEADER:"header",QUERY:"query",NONE:"none"},wt=Object.values(w),L={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},H={HLS:L.M3U8},Ot=Object.keys(H),Ut=[...Object.values(L),"hls","HLS"],Ht={upTo720p:"720p",upTo1080p:"1080p",upTo1440p:"1440p",upTo2160p:"2160p"},Vt={noLessThan480p:"480p",noLessThan540p:"540p",noLessThan720p:"720p",noLessThan1080p:"1080p",noLessThan1440p:"1440p",noLessThan2160p:"2160p"},Ft={DESCENDING:"desc"};var Kt="en",J={code:Kt};var C=(e,t,r,n,o=e)=>{o.addEventListener(t,r,n),e.addEventListener("teardown",()=>{o.removeEventListener(t,r)},{once:!0})};function Pe(e,t,r){t&&r>t&&(r=t);for(let n=0;n<e.length;n++)if(e.start(n)<=r&&e.end(n)>=r)return!0;return!1}var V=e=>{let t=e.indexOf("?");if(t<0)return[e];let r=e.slice(0,t),n=e.slice(t);return[r,n]},F=e=>{let t=e.type;if(t){let n=t.toUpperCase();return S(n,H)?H[n]:t}let{src:r}=e;return r?Yt(r):""},re=e=>e==="VOD"?_.ON_DEMAND:_.LIVE,ne=e=>e==="EVENT"?Number.POSITIVE_INFINITY:e==="VOD"?Number.NaN:0,Yt=e=>{let t="";try{t=new URL(e).pathname}catch{console.error("invalid url")}let r=t.lastIndexOf(".");if(r<0)return"";let o=t.slice(r+1).toUpperCase();return S(o,L)?L[o]:""},G=e=>{let t=(e!=null?e:"").split(".")[1];if(t)try{let r=t.replace(/-/g,"+").replace(/_/g,"/"),n=decodeURIComponent(atob(r).split("").map(function(o){return"%"+("00"+o.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(n)}catch{return}},ke=({exp:e},t=Date.now())=>!e||e*1e3<t,he=({sub:e},t)=>e!==t,Le=({aud:e},t)=>!e,Ne=({aud:e},t)=>e!==t,Ie="en";function g(e,t=!0){var o,a;let r=t&&(a=(o=J)==null?void 0:o[e])!=null?a:e,n=t?J.code:Ie;return new te(r,n)}var te=class{constructor(t,r=(n=>(n=J)!=null?n:Ie)()){this.message=t,this.locale=r}format(t){return this.message.replace(/\{(\w+)\}/g,(r,n)=>{var o;return(o=t[n])!=null?o:""})}toString(){return this.message}};var Wt=Object.values(U),Ae=e=>typeof e=="boolean"||typeof e=="string"&&Wt.includes(e),Se=(e,t,r)=>{let{autoplay:n}=e,o=!1,a=!1,s=Ae(n)?n:!!n,u=()=>{o||C(t,"playing",()=>{o=!0},{once:!0})};if(u(),C(t,"loadstart",()=>{o=!1,u(),oe(t,s)},{once:!0}),C(t,"loadstart",()=>{r||(e.streamType&&e.streamType!==_.UNKNOWN?a=e.streamType===_.LIVE:a=!Number.isFinite(t.duration)),oe(t,s)},{once:!0}),r&&r.once(E.Events.LEVEL_LOADED,(c,i)=>{var d;e.streamType&&e.streamType!==_.UNKNOWN?a=e.streamType===_.LIVE:a=(d=i.details.live)!=null?d:!1}),!s){let c=()=>{!a||Number.isFinite(e.startTime)||(r!=null&&r.liveSyncPosition?t.currentTime=r.liveSyncPosition:Number.isFinite(t.seekable.end(0))&&(t.currentTime=t.seekable.end(0)))};r&&C(t,"play",()=>{t.preload==="metadata"?r.once(E.Events.LEVEL_UPDATED,c):c()},{once:!0})}return c=>{o||(s=Ae(c)?c:!!c,oe(t,s))}},oe=(e,t)=>{if(!t)return;let r=e.muted,n=()=>e.muted=r;switch(t){case U.ANY:e.play().catch(()=>{e.muted=!0,e.play().catch(n)});break;case U.MUTED:e.muted=!0,e.play().catch(n);break;default:e.play().catch(()=>{});break}};var we=({preload:e,src:t},r,n)=>{let o=d=>{d!=null&&["","none","metadata","auto"].includes(d)?r.setAttribute("preload",d):r.removeAttribute("preload")};if(!n)return o(e),o;let a=!1,s=!1,u=n.config.maxBufferLength,l=n.config.maxBufferSize,c=d=>{o(d);let p=d!=null?d:r.preload;s||p==="none"||(p==="metadata"?(n.config.maxBufferLength=1,n.config.maxBufferSize=1):(n.config.maxBufferLength=u,n.config.maxBufferSize=l),i())},i=()=>{!a&&t&&(a=!0,n.loadSource(t))};return C(r,"play",()=>{s=!0,n.config.maxBufferLength=u,n.config.maxBufferSize=l,i()},{once:!0}),c(e),c};function Oe(e,t){var l;if(!("videoTracks"in e))return;let r=new WeakMap;t.on(E.Events.MANIFEST_PARSED,function(c,i){u();let d=e.addVideoTrack("main");d.selected=!0;for(let[p,T]of i.levels.entries()){let y=d.addRendition(T.url[0],T.width,T.height,T.videoCodec,T.bitrate);r.set(T,`${p}`),y.id=`${p}`}}),t.on(E.Events.AUDIO_TRACKS_UPDATED,function(c,i){s();for(let d of i.audioTracks){let p=d.default?"main":"alternative",T=e.addAudioTrack(p,d.name,d.lang);T.id=`${d.id}`,d.default&&(T.enabled=!0)}}),e.audioTracks.addEventListener("change",()=>{var d;let c=+((d=[...e.audioTracks].find(p=>p.enabled))==null?void 0:d.id),i=t.audioTracks.map(p=>p.id);c!=t.audioTrack&&i.includes(c)&&(t.audioTrack=c)}),t.on(E.Events.LEVELS_UPDATED,function(c,i){var T;let d=e.videoTracks[(T=e.videoTracks.selectedIndex)!=null?T:0];if(!d)return;let p=i.levels.map(y=>r.get(y));for(let y of e.videoRenditions)y.id&&!p.includes(y.id)&&d.removeRendition(y)});let n=c=>{let i=c.target.selectedIndex;i!=t.nextLevel&&o(i)},o=c=>{let i=e.currentTime,d=!1,p=(T,y)=>{d||(d=!Number.isFinite(y.endOffset))};t.on(E.Events.BUFFER_FLUSHING,p),t.nextLevel=c,t.off(E.Events.BUFFER_FLUSHING,p),d||t.trigger(E.Events.BUFFER_FLUSHING,{startOffset:i+10,endOffset:1/0,type:"video"})};(l=e.videoRenditions)==null||l.addEventListener("change",n);let a=()=>{for(let c of e.videoTracks)e.removeVideoTrack(c)},s=()=>{for(let c of e.audioTracks)e.removeAudioTrack(c)},u=()=>{a(),s()};t.once(E.Events.DESTROYING,u)}var ae=e=>"time"in e?e.time:e.startTime;function Ue(e,t){t.on(E.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(o,{tracks:a})=>{a.forEach(s=>{var i,d;let u=(i=s.subtitleTrack)!=null?i:s.closedCaptions,l=t.subtitleTracks.findIndex(({lang:p,name:T,type:y})=>p==(u==null?void 0:u.lang)&&T===s.label&&y.toLowerCase()===s.kind),c=((d=s._id)!=null?d:s.default)?"default":`${s.kind}${l}`;z(e,s.kind,s.label,u==null?void 0:u.lang,c,s.default)})});let r=()=>{if(!t.subtitleTracks.length)return;let o=Array.from(e.textTracks).find(u=>u.id&&u.mode==="showing"&&["subtitles","captions"].includes(u.kind));if(!o)return;let a=t.subtitleTracks[t.subtitleTrack],s=a?a.default?"default":`${t.subtitleTracks[t.subtitleTrack].type.toLowerCase()}${t.subtitleTrack}`:void 0;if(t.subtitleTrack<0||(o==null?void 0:o.id)!==s){let u=t.subtitleTracks.findIndex(({lang:l,name:c,type:i,default:d})=>o.id==="default"&&d||l==o.language&&c===o.label&&i.toLowerCase()===o.kind);t.subtitleTrack=u}(o==null?void 0:o.id)===s&&o.cues&&Array.from(o.cues).forEach(u=>{o.addCue(u)})};e.textTracks.addEventListener("change",r),t.on(E.Events.CUES_PARSED,(o,{track:a,cues:s})=>{let u=e.textTracks.getTrackById(a);if(!u)return;let l=u.mode==="disabled";l&&(u.mode="hidden"),s.forEach(c=>{var i;(i=u.cues)!=null&&i.getCueById(c.id)||u.addCue(c)}),l&&(u.mode="disabled")}),t.once(E.Events.DESTROYING,()=>{e.textTracks.removeEventListener("change",r),e.querySelectorAll("track[data-removeondestroy]").forEach(a=>{a.remove()})});let n=()=>{Array.from(e.textTracks).forEach(o=>{var a,s;if(!["subtitles","caption"].includes(o.kind)&&(o.label==="thumbnails"||o.kind==="chapters")){if(!((a=o.cues)!=null&&a.length)){let u="track";o.kind&&(u+=`[kind="${o.kind}"]`),o.label&&(u+=`[label="${o.label}"]`);let l=e.querySelector(u),c=(s=l==null?void 0:l.getAttribute("src"))!=null?s:"";l==null||l.removeAttribute("src"),setTimeout(()=>{l==null||l.setAttribute("src",c)},0)}o.mode!=="hidden"&&(o.mode="hidden")}})};t.once(E.Events.MANIFEST_LOADED,n),t.once(E.Events.MEDIA_ATTACHED,n)}function z(e,t,r,n,o,a){let s=document.createElement("track");return s.kind=t,s.label=r,n&&(s.srclang=n),o&&(s.id=o),a&&(s.default=!0),s.track.mode=["subtitles","captions"].includes(t)?"disabled":"hidden",s.setAttribute("data-removeondestroy",""),e.append(s),s.track}function He(e,t){let r=Array.prototype.find.call(e.querySelectorAll("track"),n=>n.track===t);r==null||r.remove()}function A(e,t,r){var n;return(n=Array.from(e.querySelectorAll("track")).find(o=>o.track.label===t&&o.track.kind===r))==null?void 0:n.track}async function Ve(e,t,r,n){let o=A(e,r,n);return o||(o=z(e,n,r),o.mode="hidden",await new Promise(a=>setTimeout(()=>a(void 0),0))),o.mode!=="hidden"&&(o.mode="hidden"),[...t].sort((a,s)=>ae(s)-ae(a)).forEach(a=>{var l,c;let s=a.value,u=ae(a);if("endTime"in a&&a.endTime!=null)o==null||o.addCue(new VTTCue(u,a.endTime,n==="chapters"?s:JSON.stringify(s!=null?s:null)));else{let i=Array.prototype.findIndex.call(o==null?void 0:o.cues,y=>y.startTime>=u),d=(l=o==null?void 0:o.cues)==null?void 0:l[i],p=d?d.startTime:Number.isFinite(e.duration)?e.duration:Number.MAX_SAFE_INTEGER,T=(c=o==null?void 0:o.cues)==null?void 0:c[i-1];T&&(T.endTime=u),o==null||o.addCue(new VTTCue(u,p,n==="chapters"?s:JSON.stringify(s!=null?s:null)))}}),e.textTracks.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),o}var se="cuepoints",Fe=Object.freeze({label:se});async function ie(e,t,r=Fe){return Ve(e,t,r.label,"metadata")}var q=e=>({time:e.startTime,value:JSON.parse(e.text)});function Ke(e,t={label:se}){let r=A(e,t.label,"metadata");return r!=null&&r.cues?Array.from(r.cues,n=>q(n)):[]}function ce(e,t={label:se}){var a,s;let r=A(e,t.label,"metadata");if(!((a=r==null?void 0:r.activeCues)!=null&&a.length))return;if(r.activeCues.length===1)return q(r.activeCues[0]);let{currentTime:n}=e,o=Array.prototype.find.call((s=r.activeCues)!=null?s:[],({startTime:u,endTime:l})=>u<=n&&l>n);return q(o||r.activeCues[0])}async function ue(e,t=Fe){return new Promise(r=>{C(e,"loadstart",async()=>{let n=await ie(e,[],t);C(e,"cuechange",()=>{let o=ce(e);if(o){let a=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:o});e.dispatchEvent(a)}},{},n),r(n)})})}var de="chapters",Ye=Object.freeze({label:de}),j=e=>({startTime:e.startTime,endTime:e.endTime,value:e.text});async function le(e,t,r=Ye){return Ve(e,t,r.label,"chapters")}function We(e,t={label:de}){var n;let r=A(e,t.label,"chapters");return(n=r==null?void 0:r.cues)!=null&&n.length?Array.from(r.cues,o=>j(o)):[]}function pe(e,t={label:de}){var a,s;let r=A(e,t.label,"chapters");if(!((a=r==null?void 0:r.activeCues)!=null&&a.length))return;if(r.activeCues.length===1)return j(r.activeCues[0]);let{currentTime:n}=e,o=Array.prototype.find.call((s=r.activeCues)!=null?s:[],({startTime:u,endTime:l})=>u<=n&&l>n);return j(o||r.activeCues[0])}async function fe(e,t=Ye){return new Promise(r=>{C(e,"loadstart",async()=>{let n=await le(e,[],t);C(e,"cuechange",()=>{let o=pe(e);if(o){let a=new CustomEvent("chapterchange",{composed:!0,bubbles:!0,detail:o});e.dispatchEvent(a)}},{},n),r(n)})})}function $e(e,t){if(t){let r=t.playingDate;if(r!=null)return new Date(r.getTime()-e.currentTime*1e3)}return typeof e.getStartDate=="function"?e.getStartDate():new Date(NaN)}function Be(e,t){if(t&&t.playingDate)return t.playingDate;if(typeof e.getStartDate=="function"){let r=e.getStartDate();return new Date(r.getTime()+e.currentTime*1e3)}return new Date(NaN)}var X={VIDEO:"v",THUMBNAIL:"t",STORYBOARD:"s",DRM:"d"},$t=e=>{if(e===x.VIDEO)return X.VIDEO;if(e===x.DRM)return X.DRM},Bt=(e,t)=>{var o,a;let r=O(e),n=`${r}Token`;return(o=t.tokens)!=null&&o[r]?(a=t.tokens)==null?void 0:a[r]:S(n,t)?t[n]:void 0},K=(e,t,r,n=!1,o=!(a=>(a=globalThis.navigator)==null?void 0:a.onLine)())=>{var D,P;if(o){let R=g("Your device appears to be offline",n),b=void 0,m=f.MEDIA_ERR_NETWORK,h=new f(R,m,!0,b);return h.errorCategory=t,h.muxCode=M.NETWORK_OFFLINE,h.data=e,h}let s="status"in e?e.status:e.code,u=Date.now(),l=f.MEDIA_ERR_NETWORK;if(s===200)return;let c=O(t),i=Bt(t,r),d=$t(t),[p]=V((D=r.playbackId)!=null?D:"");if(!s||!p)return;let T=G(i);if(i&&!T){let R=g("The {tokenNamePrefix}-token provided is invalid or malformed.",n).format({tokenNamePrefix:c}),b=g("Compact JWT string: {token}",n).format({token:i}),m=new f(R,l,!0,b);return m.errorCategory=t,m.muxCode=M.NETWORK_TOKEN_MALFORMED,m.data=e,m}if(s>=500){let R=new f("",l,!0);return R.errorCategory=t,R.muxCode=M.NETWORK_UNKNOWN_ERROR,R}if(s===403)if(T){if(ke(T,u)){let R={timeStyle:"medium",dateStyle:"medium"},b=g("The video\u2019s secured {tokenNamePrefix}-token has expired.",n).format({tokenNamePrefix:c}),m=g("Expired at: {expiredDate}. Current time: {currentDate}.",n).format({expiredDate:new Intl.DateTimeFormat("en",R).format((P=T.exp)!=null?P:0*1e3),currentDate:new Intl.DateTimeFormat("en",R).format(u)}),h=new f(b,l,!0,m);return h.errorCategory=t,h.muxCode=M.NETWORK_TOKEN_EXPIRED,h.data=e,h}if(he(T,p)){let R=g("The video\u2019s playback ID does not match the one encoded in the {tokenNamePrefix}-token.",n).format({tokenNamePrefix:c}),b=g("Specified playback ID: {playbackId} and the playback ID encoded in the {tokenNamePrefix}-token: {tokenPlaybackId}",n).format({tokenNamePrefix:c,playbackId:p,tokenPlaybackId:T.sub}),m=new f(R,l,!0,b);return m.errorCategory=t,m.muxCode=M.NETWORK_TOKEN_SUB_MISMATCH,m.data=e,m}if(Le(T,d)){let R=g("The {tokenNamePrefix}-token is formatted with incorrect information.",n).format({tokenNamePrefix:c}),b=g("The {tokenNamePrefix}-token has no aud value. aud value should be {expectedAud}.",n).format({tokenNamePrefix:c,expectedAud:d}),m=new f(R,l,!0,b);return m.errorCategory=t,m.muxCode=M.NETWORK_TOKEN_AUD_MISSING,m.data=e,m}if(Ne(T,d)){let R=g("The {tokenNamePrefix}-token is formatted with incorrect information.",n).format({tokenNamePrefix:c}),b=g("The {tokenNamePrefix}-token has an incorrect aud value: {aud}. aud value should be {expectedAud}.",n).format({tokenNamePrefix:c,expectedAud:d,aud:T.aud}),m=new f(R,l,!0,b);return m.errorCategory=t,m.muxCode=M.NETWORK_TOKEN_AUD_MISMATCH,m.data=e,m}}else{let R=g("Authorization error trying to access this {category} URL. If this is a signed URL, you might need to provide a {tokenNamePrefix}-token.",n).format({tokenNamePrefix:c,category:t}),b=g("Specified playback ID: {playbackId}",n).format({playbackId:p}),m=new f(R,l,!0,b);return m.errorCategory=t,m.muxCode=M.NETWORK_TOKEN_MISSING,m.data=e,m}if(s===412){let R=g("This playback-id may belong to a live stream that is not currently active or an asset that is not ready.",n),b=g("Specified playback ID: {playbackId}",n).format({playbackId:p}),m=new f(R,l,!0,b);return m.errorCategory=t,m.muxCode=M.NETWORK_NOT_READY,m.data=e,m}if(s===404){let R=g("This URL or playback-id does not exist. You may have used an Asset ID or an ID from a different resource.",n),b=g("Specified playback ID: {playbackId}",n).format({playbackId:p}),m=new f(R,l,!0,b);return m.errorCategory=t,m.muxCode=M.NETWORK_NOT_FOUND,m.data=e,m}if(s===400){let R=g("The URL or playback-id was invalid. You may have used an invalid value as a playback-id."),b=g("Specified playback ID: {playbackId}",n).format({playbackId:p}),m=new f(R,l,!0,b);return m.errorCategory=t,m.muxCode=M.NETWORK_INVALID_URL,m.data=e,m}let y=new f("",l,!0);return y.errorCategory=t,y.muxCode=M.NETWORK_UNKNOWN_ERROR,y.data=e,y};var Je=E.DefaultConfig.capLevelController,Q=class Q extends Je{constructor(t){super(t)}get levels(){var t;return(t=this.hls.levels)!=null?t:[]}getValidLevels(t){return this.levels.filter((r,n)=>this.isLevelAllowed(r)&&n<=t)}getMaxLevel(t){let r=super.getMaxLevel(t),n=this.getValidLevels(t);if(!n[r])return r;let o=Math.min(n[r].width,n[r].height),a=Q.minMaxResolution;return o>=a?r:Je.getMaxLevelByMediaSize(n,a*(16/9),a)}};Q.minMaxResolution=720;var Te=Q,Ge=Te;var Z={FAIRPLAY:"fairplay",PLAYREADY:"playready",WIDEVINE:"widevine"},tt=e=>{if(e.includes("fps"))return Z.FAIRPLAY;if(e.includes("playready"))return Z.PLAYREADY;if(e.includes("widevine"))return Z.WIDEVINE},rt=async e=>fetch(e).then(t=>t.status!==200?Promise.reject(t):t.text()).then(t=>{let r=t.split(`
`).find((n,o,a)=>o&&a[o-1].startsWith("#EXT-X-STREAM-INF"));return fetch(r).then(n=>n.status!==200?Promise.reject(n):n.text()).then(n=>n.split(`
`))}),ot=e=>{var s,u,l;let r=(u=((s=e.find(c=>c.startsWith("#EXT-X-PLAYLIST-TYPE")))!=null?s:"").split(":")[1])==null?void 0:u.trim(),n=ne(r),o=oe(r),a;if(n===D.LIVE){let c=e.find(d=>d.startsWith("#EXT-X-PART-INF"));if(!!c)a=+c.split(":")[1].split("=")[1]*2;else{let d=e.find(y=>y.startsWith("#EXT-X-TARGETDURATION")),p=(l=d==null?void 0:d.split(":"))==null?void 0:l[1];a=+(p!=null?p:6)*3}}return{streamType:n,targetLiveWindow:o,liveEdgeStartOffset:a}},at=async(e,t)=>{if(t===N.MP4)return{streamType:D.ON_DEMAND,targetLiveWindow:Number.NaN,liveEdgeStartOffset:void 0};if(t===N.M3U8){let r=await nt(e);return ot(r)}return console.error(`Media type ${t} is an unrecognized or unsupported type for src ${e}.`),{streamType:void 0,targetLiveWindow:void 0,liveEdgeStartOffset:void 0}},st=async(e,t,r=K({src:e}))=>{var s,u,l;let{streamType:n,targetLiveWindow:o,liveEdgeStartOffset:a}=await at(e,r);((s=v.get(t))!=null?s:{}).liveEdgeStartOffset=a,((u=v.get(t))!=null?u:{}).targetLiveWindow=o,t.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((l=v.get(t))!=null?l:{}).streamType=n,t.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},it=e=>{var s;let t=e.type,r=ne(t),n=oe(t),o,a=!!((s=e.partList)!=null&&s.length);return r===D.LIVE&&(o=a?e.partTarget*2:e.targetduration*3),{streamType:r,targetLiveWindow:n,liveEdgeStartOffset:o,lowLatency:a}},ct=(e,t,r)=>{var u,l,c,i,d,p,T,y;let{streamType:n,targetLiveWindow:o,liveEdgeStartOffset:a,lowLatency:s}=it(e);if(n===D.LIVE){s?(r.config.backBufferLength=(u=r.userConfig.backBufferLength)!=null?u:4,r.config.maxFragLookUpTolerance=(l=r.userConfig.maxFragLookUpTolerance)!=null?l:.001,r.config.abrBandWidthUpFactor=(c=r.userConfig.abrBandWidthUpFactor)!=null?c:r.config.abrBandWidthFactor):r.config.backBufferLength=(i=r.userConfig.backBufferLength)!=null?i:8;let _=Object.freeze({get length(){return t.seekable.length},start(P){return t.seekable.start(P)},end(P){var M;return P>this.length||P<0||Number.isFinite(t.duration)?t.seekable.end(P):(M=r.liveSyncPosition)!=null?M:t.seekable.end(P)}});((d=v.get(t))!=null?d:{}).seekable=_}((p=v.get(t))!=null?p:{}).liveEdgeStartOffset=a,((T=v.get(t))!=null?T:{}).targetLiveWindow=o,t.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((y=v.get(t))!=null?y:{}).streamType=n,t.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},je,ze,Gt=(ze=(je=globalThis==null?void 0:globalThis.navigator)==null?void 0:je.userAgent)!=null?ze:"",Xe,Qe,Ze,qt=(Ze=(Qe=(Xe=globalThis==null?void 0:globalThis.navigator)==null?void 0:Xe.userAgentData)==null?void 0:Qe.platform)!=null?Ze:"",jt=Gt.toLowerCase().includes("android")||["x11","android"].some(e=>qt.toLowerCase().includes(e)),v=new WeakMap,A="mux.com",et,tt,ut=(tt=(et=R).isSupported)==null?void 0:tt.call(et),zt=jt,Xt=()=>$.default.utils.now(),dt=$.default.utils.generateUUID,Qt=({playbackId:e,customDomain:t=A,maxResolution:r,minResolution:n,renditionOrder:o,programStartTime:a,programEndTime:s,assetStartTime:u,assetEndTime:l,playbackToken:c,tokens:{playback:i=c}={},extraSourceParams:d={}}={})=>{if(!e)return;let[p,T=""]=F(e),y=new URL(`https://stream.${t}/${p}.m3u8${T}`);return i||y.searchParams.has("token")?(y.searchParams.forEach((_,P)=>{P!="token"&&y.searchParams.delete(P)}),i&&y.searchParams.set("token",i)):(r&&y.searchParams.set("max_resolution",r),n&&(y.searchParams.set("min_resolution",n),r&&+r.slice(0,-1)<+n.slice(0,-1)&&console.error("minResolution must be <= maxResolution","minResolution",n,"maxResolution",r)),o&&y.searchParams.set("rendition_order",o),a&&y.searchParams.set("program_start_time",`${a}`),s&&y.searchParams.set("program_end_time",`${s}`),u&&y.searchParams.set("asset_start_time",`${u}`),l&&y.searchParams.set("asset_end_time",`${l}`),Object.entries(d).forEach(([_,P])=>{P!=null&&y.searchParams.set(_,P)})),y.toString()},te=e=>{if(!e)return;let[t]=e.split("?");return t||void 0},lt=e=>{if(!e||!e.startsWith("https://stream."))return;let[t]=new URL(e).pathname.slice(1).split(".m3u8");return t||void 0},Zt=e=>{var t,r,n;return(t=e==null?void 0:e.metadata)!=null&&t.video_id?e.metadata.video_id:Ce(e)&&(n=(r=te(e.playbackId))!=null?r:lt(e.src))!=null?n:e.src},pt=e=>{var t;return(t=v.get(e))==null?void 0:t.error},Ee=e=>{var t,r;return(r=(t=v.get(e))==null?void 0:t.streamType)!=null?r:D.UNKNOWN},er=e=>{var t,r;return(r=(t=v.get(e))==null?void 0:t.targetLiveWindow)!=null?r:Number.NaN},Me=e=>{var t,r;return(r=(t=v.get(e))==null?void 0:t.seekable)!=null?r:e.seekable},tr=e=>{var n;let t=(n=v.get(e))==null?void 0:n.liveEdgeStartOffset;if(typeof t!="number")return Number.NaN;let r=Me(e);return r.length?r.end(r.length-1)-t:Number.NaN},Re=.034,rr=(e,t,r=Re)=>Math.abs(e-t)<=r,ft=(e,t,r=Re)=>e>t||rr(e,t,r),Tt=(e,t=Re)=>e.paused&&ft(e.currentTime,e.duration,t),xe=(e,t)=>{var c,i,d;if(!t||!e.buffered.length)return;if(e.readyState>2)return!1;let r=t.currentLevel>=0?(i=(c=t.levels)==null?void 0:c[t.currentLevel])==null?void 0:i.details:(d=t.levels.find(p=>!!p.details))==null?void 0:d.details;if(!r||r.live)return;let{fragments:n}=r;if(!(n!=null&&n.length))return;if(e.currentTime<e.duration-(r.targetduration+.5))return!1;let o=n[n.length-1];if(e.currentTime<=o.start)return!1;let a=o.start+o.duration/2,s=e.buffered.start(e.buffered.length-1),u=e.buffered.end(e.buffered.length-1);return a>s&&a<u},yt=(e,t)=>e.ended||e.loop?e.ended:t&&xe(e,t)?!0:Tt(e),nr=(e,t,r)=>{mt(t,r);let{metadata:n={}}=e,{view_session_id:o=dt()}=n,a=Zt(e);n.view_session_id=o,n.video_id=a,e.metadata=n;let s=i=>{var d;(d=t.mux)==null||d.emit("hb",{view_drm_type:i})};e.drmTypeCb=s,v.set(t,{});let u=gt(e,t),l=Ue(e,t,u);_t(e,t,u),vt(e,t,u),de(t),Te(t);let c=Oe(e,t,u);return{engine:u,setAutoplay:c,setPreload:l}},mt=(e,t)=>{let r=t==null?void 0:t.engine;r&&(r.detachMedia(),r.destroy()),e!=null&&e.mux&&!e.mux.deleted&&(e.mux.destroy(),delete e.mux),e&&(e.removeAttribute("src"),e.load(),e.removeEventListener("error",Pt),e.removeEventListener("error",ge),e.removeEventListener("durationchange",Dt),v.delete(e),e.dispatchEvent(new Event("teardown")))};function Et(e,t){var c;let r=K(e);if(!(r===N.M3U8))return!0;let o=!r||((c=t.canPlayType(r))!=null?c:!0),{preferPlayback:a}=e,s=a===J.MSE,u=a===J.NATIVE;return o&&(u||!(ut&&(s||zt)))}var gt=(e,t)=>{let{debug:r,streamType:n,startTime:o=-1,metadata:a,preferCmcd:s,_hlsConfig:u={}}=e,c=K(e)===N.M3U8,i=Et(e,t);if(c&&!i&&ut){let d={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelToPlayerSize:!0,capLevelOnFPSDrop:!0},p=Mt(n),T=Rt(e),y=s!==O.NONE?{useHeaders:s===O.HEADER,sessionId:a==null?void 0:a.view_session_id,contentId:a==null?void 0:a.video_id}:void 0;return new R({debug:r,startPosition:o,cmcd:y,xhrSetup:(P,M)=>{var L,_e;if(s&&s!==O.QUERY)return;let b=new URL(M);if(!b.searchParams.has("CMCD"))return;let m=((_e=(L=b.searchParams.get("CMCD"))==null?void 0:L.split(","))!=null?_e:[]).filter(ve=>ve.startsWith("sid")||ve.startsWith("cid")).join(",");b.searchParams.set("CMCD",m),P.open("GET",b)},capLevelController:qe,...d,...p,...T,...u})}},Mt=e=>e===D.LIVE?{backBufferLength:8}:{},Rt=e=>{let{tokens:{drm:t}={},playbackId:r,drmTypeCb:n}=e,o=te(r);return!t||!o?{}:{emeEnabled:!0,drmSystems:{"com.apple.fps":{licenseUrl:W(e,"fairplay"),serverCertificateUrl:be(e,"fairplay")},"com.widevine.alpha":{licenseUrl:W(e,"widevine")},"com.microsoft.playready":{licenseUrl:W(e,"playready")}},requestMediaKeySystemAccessFunc:(a,s)=>(a==="com.widevine.alpha"&&(s=[...s.map(u=>{var c;let l=(c=u.videoCapabilities)==null?void 0:c.map(i=>({...i,robustness:"HW_SECURE_ALL"}));return{...u,videoCapabilities:l}}),...s]),navigator.requestMediaKeySystemAccess(a,s).then(u=>{let l=rt(a);return n==null||n(l),u}))}},xt=async e=>{let t=await fetch(e);return t.status!==200?Promise.reject(t):await t.arrayBuffer()},bt=async(e,t)=>{let r=await fetch(t,{method:"POST",headers:{"Content-type":"application/octet-stream"},body:e});if(r.status!==200)return Promise.reject(r);let n=await r.arrayBuffer();return new Uint8Array(n)},Ct=(e,t)=>{C(t,"encrypted",async n=>{try{let o=n.initDataType;if(o!=="skd"){console.error(`Received unexpected initialization data type "${o}"`);return}if(!t.mediaKeys){let c=await navigator.requestMediaKeySystemAccess("com.apple.fps",[{initDataTypes:[o],videoCapabilities:[{contentType:"application/vnd.apple.mpegurl",robustness:""}],distinctiveIdentifier:"not-allowed",persistentState:"not-allowed",sessionTypes:["temporary"]}]).then(d=>{var p;return(p=e.drmTypeCb)==null||p.call(e,ee.FAIRPLAY),d}).catch(()=>{let d=E("Cannot play DRM-protected content with current security configuration on this browser. Try playing in another browser."),p=new f(d,f.MEDIA_ERR_ENCRYPTED,!0);p.errorCategory=x.DRM,p.muxCode=g.ENCRYPTED_UNSUPPORTED_KEY_SYSTEM,I(t,p)});if(!c)return;let i=await c.createMediaKeys();try{let d=await xt(be(e,"fairplay")).catch(p=>{if(p instanceof Response){let T=Y(p,x.DRM,e);return console.error("mediaError",T==null?void 0:T.message,T==null?void 0:T.context),T?Promise.reject(T):Promise.reject(new Error("Unexpected error in app cert request"))}return Promise.reject(p)});await i.setServerCertificate(d).catch(()=>{let p=E("Your server certificate failed when attempting to set it. This may be an issue with a no longer valid certificate."),T=new f(p,f.MEDIA_ERR_ENCRYPTED,!0);return T.errorCategory=x.DRM,T.muxCode=g.ENCRYPTED_UPDATE_SERVER_CERT_FAILED,Promise.reject(T)})}catch(d){I(t,d);return}await t.setMediaKeys(i)}let a=n.initData;if(a==null){console.error(`Could not start encrypted playback due to missing initData in ${n.type} event`);return}let s=t.mediaKeys.createSession();s.addEventListener("keystatuseschange",()=>{s.keyStatuses.forEach(c=>{let i;if(c==="internal-error"){let d=E("The DRM Content Decryption Module system had an internal failure. Try reloading the page, upading your browser, or playing in another browser.");i=new f(d,f.MEDIA_ERR_ENCRYPTED,!0),i.errorCategory=x.DRM,i.muxCode=g.ENCRYPTED_CDM_ERROR}else if(c==="output-restricted"||c==="output-downscaled"){let d=E("DRM playback is being attempted in an environment that is not sufficiently secure. User may see black screen.");i=new f(d,f.MEDIA_ERR_ENCRYPTED,!1),i.errorCategory=x.DRM,i.muxCode=g.ENCRYPTED_OUTPUT_RESTRICTED}i&&I(t,i)})});let u=await Promise.all([s.generateRequest(o,a).catch(()=>{let c=E("Failed to generate a DRM license request. This may be an issue with the player or your protected content."),i=new f(c,f.MEDIA_ERR_ENCRYPTED,!0);i.errorCategory=x.DRM,i.muxCode=g.ENCRYPTED_GENERATE_REQUEST_FAILED,I(t,i)}),new Promise(c=>{s.addEventListener("message",i=>{c(i.message)},{once:!0})})]).then(([,c])=>c);s.generateRequest(o,a);let l=await bt(u,W(e,"fairplay")).catch(c=>{if(c instanceof Response){let i=Y(c,x.DRM,e);return console.error("mediaError",i==null?void 0:i.message,i==null?void 0:i.context),i?Promise.reject(i):Promise.reject(new Error("Unexpected error in license key request"))}return Promise.reject(c)});await s.update(l).catch(()=>{let c=E("Failed to update DRM license. This may be an issue with the player or your protected content."),i=new f(c,f.MEDIA_ERR_ENCRYPTED,!0);return i.errorCategory=x.DRM,i.muxCode=g.ENCRYPTED_UPDATE_LICENSE_FAILED,Promise.reject(i)})}catch(o){I(t,o);return}})},W=({playbackId:e,tokens:{drm:t}={},customDomain:r=A},n)=>{let o=te(e);return`https://license.${r.toLocaleLowerCase().endsWith(A)?r:A}/license/${n}/${o}?token=${t}`},be=({playbackId:e,tokens:{drm:t}={},customDomain:r=A},n)=>{let o=te(e);return`https://license.${r.toLocaleLowerCase().endsWith(A)?r:A}/appcert/${n}/${o}?token=${t}`},Ce=({playbackId:e,src:t,customDomain:r})=>{if(e)return!0;if(typeof t!="string")return!1;let n=window==null?void 0:window.location.href,o=new URL(t,n).hostname.toLocaleLowerCase();return o.includes(A)||!!r&&o.includes(r.toLocaleLowerCase())},_t=(e,t,r)=>{var s;let{envKey:n,disableTracking:o}=e,a=Ce(e);if(!o&&(n||a)){let{playerInitTime:u,playerSoftwareName:l,playerSoftwareVersion:c,beaconCollectionDomain:i,debug:d,disableCookies:p}=e,T={...e.metadata,video_title:((s=e==null?void 0:e.metadata)==null?void 0:s.video_title)||void 0},y=_=>typeof _.player_error_code=="string"?!1:typeof e.errorTranslator=="function"?e.errorTranslator(_):_;$.default.monitor(t,{debug:d,beaconCollectionDomain:i,hlsjs:r,Hls:r?R:void 0,automaticErrorTracking:!1,errorTranslator:y,disableCookies:p,data:{...n?{env_key:n}:{},player_software_name:l,player_software:l,player_software_version:c,player_init_time:u,...T}})}},vt=(e,t,r)=>{var c,i;let n=Et(e,t),{src:o}=e,a=()=>{t.ended||!yt(t,r)||(xe(t,r)?t.currentTime=t.buffered.end(t.buffered.length-1):t.dispatchEvent(new Event("ended")))},s,u,l=()=>{let d=Me(t),p,T;d.length>0&&(p=d.start(0),T=d.end(0)),(u!==T||s!==p)&&t.dispatchEvent(new CustomEvent("seekablechange",{composed:!0})),s=p,u=T};if(C(t,"durationchange",l),t&&n){let d=K(e);if(typeof o=="string"){let p=()=>{if(Ee(t)!==D.LIVE||Number.isFinite(t.duration))return;let y=setInterval(l,1e3);t.addEventListener("teardown",()=>{clearInterval(y)},{once:!0}),C(t,"durationchange",()=>{Number.isFinite(t.duration)&&clearInterval(y)})},T=async()=>st(o,t,d).then(p).catch(y=>{if(y instanceof Response){let _=Y(y,x.VIDEO,e);if(_){I(t,_);return}}else y instanceof Error});if(t.preload==="none"){let y=()=>{T(),t.removeEventListener("loadedmetadata",_)},_=()=>{T(),t.removeEventListener("play",y)};C(t,"play",y,{once:!0}),C(t,"loadedmetadata",_,{once:!0})}else T();(c=e.tokens)!=null&&c.drm?Ct(e,t):C(t,"encrypted",()=>{let y=E("Attempting to play DRM-protected content without providing a DRM token."),_=new f(y,f.MEDIA_ERR_ENCRYPTED,!0);_.errorCategory=x.DRM,_.muxCode=g.ENCRYPTED_MISSING_TOKEN,I(t,_)},{once:!0}),t.setAttribute("src",o),e.startTime&&(((i=v.get(t))!=null?i:{}).startTime=e.startTime,t.addEventListener("durationchange",Dt,{once:!0}))}else t.removeAttribute("src");t.addEventListener("error",Pt),t.addEventListener("error",ge),t.addEventListener("emptied",()=>{t.querySelectorAll("track[data-removeondestroy]").forEach(T=>{T.remove()})},{once:!0}),C(t,"pause",a),C(t,"seeked",a),C(t,"play",()=>{t.ended||ft(t.currentTime,t.duration)&&(t.currentTime=t.seekable.length?t.seekable.start(0):0)})}else r&&o?(r.once(R.Events.LEVEL_LOADED,(d,p)=>{ct(p.details,t,r),l(),Ee(t)===D.LIVE&&!Number.isFinite(t.duration)&&(r.on(R.Events.LEVEL_UPDATED,l),C(t,"durationchange",()=>{Number.isFinite(t.duration)&&r.off(R.Events.LEVELS_UPDATED,l)}))}),r.on(R.Events.ERROR,(d,p)=>{I(t,or(p,e))}),t.addEventListener("error",ge),C(t,"waiting",a),He(e,r),Ve(t,r),r.attachMedia(t)):console.error("It looks like the video you're trying to play will not work on this system! If possible, try upgrading to the newest versions of your browser or software.")};function Dt(e){var n;let t=e.target,r=(n=v.get(t))==null?void 0:n.startTime;if(r&&he(t.seekable,t.duration,r)){let o=t.preload==="auto";o&&(t.preload="none"),t.currentTime=r,o&&(t.preload="auto")}}async function Pt(e){if(!e.isTrusted)return;e.stopImmediatePropagation();let t=e.target;if(!(t!=null&&t.error))return;let{message:r,code:n}=t.error,o=new f(r,n);if(t.src&&n===f.MEDIA_ERR_SRC_NOT_SUPPORTED&&t.readyState===HTMLMediaElement.HAVE_NOTHING){setTimeout(()=>{var s;let a=(s=pt(t))!=null?s:t.error;(a==null?void 0:a.code)===f.MEDIA_ERR_SRC_NOT_SUPPORTED&&I(t,o)},500);return}if(t.src&&(n!==f.MEDIA_ERR_DECODE||n!==void 0))try{let{status:a}=await fetch(t.src);o.data={response:{code:a}}}catch{}I(t,o)}function I(e,t){var r;t.fatal&&(((r=v.get(e))!=null?r:{}).error=t,e.dispatchEvent(new CustomEvent("error",{detail:t})))}function ge(e){var n,o;if(!(e instanceof CustomEvent)||!(e.detail instanceof f))return;let t=e.target,r=e.detail;!r||!r.fatal||(((n=v.get(t))!=null?n:{}).error=r,(o=t.mux)==null||o.emit("error",{player_error_code:r.code,player_error_message:r.message,player_error_context:r.context}))}var or=(e,t)=>{var u,l,c;console.error("getErrorFromHlsErrorData()",e);let r={[R.ErrorTypes.NETWORK_ERROR]:f.MEDIA_ERR_NETWORK,[R.ErrorTypes.MEDIA_ERROR]:f.MEDIA_ERR_DECODE,[R.ErrorTypes.KEY_SYSTEM_ERROR]:f.MEDIA_ERR_ENCRYPTED},n=i=>[h.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,h.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED].includes(i.details)?f.MEDIA_ERR_NETWORK:r[i.type],o=i=>{if(i.type===h.ErrorTypes.KEY_SYSTEM_ERROR)return x.DRM;if(i.type===h.ErrorTypes.NETWORK_ERROR)return x.VIDEO},a,s=n(e);if(s===f.MEDIA_ERR_NETWORK&&e.response){let i=(u=o(e))!=null?u:x.VIDEO;a=(l=Y(e.response,i,t))!=null?l:new f("",s)}else if(s===f.MEDIA_ERR_ENCRYPTED)if(e.details===h.ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE){let i=E("Attempting to play DRM-protected content without providing a DRM token.");a=new f(i,f.MEDIA_ERR_ENCRYPTED,e.fatal),a.errorCategory=x.DRM,a.muxCode=g.ENCRYPTED_MISSING_TOKEN}else if(e.details===h.ErrorDetails.KEY_SYSTEM_NO_ACCESS){let i=E("Cannot play DRM-protected content with current security configuration on this browser. Try playing in another browser.");a=new f(i,f.MEDIA_ERR_ENCRYPTED,e.fatal),a.errorCategory=x.DRM,a.muxCode=g.ENCRYPTED_UNSUPPORTED_KEY_SYSTEM}else if(e.details===h.ErrorDetails.KEY_SYSTEM_NO_SESSION){let i=E("Failed to generate a DRM license request. This may be an issue with the player or your protected content.");a=new f(i,f.MEDIA_ERR_ENCRYPTED,!0),a.errorCategory=x.DRM,a.muxCode=g.ENCRYPTED_GENERATE_REQUEST_FAILED}else if(e.details===h.ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED){let i=E("Failed to update DRM license. This may be an issue with the player or your protected content.");a=new f(i,f.MEDIA_ERR_ENCRYPTED,e.fatal),a.errorCategory=x.DRM,a.muxCode=g.ENCRYPTED_UPDATE_LICENSE_FAILED}else if(e.details===h.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED){let i=E("Your server certificate failed when attempting to set it. This may be an issue with a no longer valid certificate.");a=new f(i,f.MEDIA_ERR_ENCRYPTED,e.fatal),a.errorCategory=x.DRM,a.muxCode=g.ENCRYPTED_UPDATE_SERVER_CERT_FAILED}else if(e.details===h.ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR){let i=E("The DRM Content Decryption Module system had an internal failure. Try reloading the page, upading your browser, or playing in another browser.");a=new f(i,f.MEDIA_ERR_ENCRYPTED,e.fatal),a.errorCategory=x.DRM,a.muxCode=g.ENCRYPTED_CDM_ERROR}else if(e.details===h.ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED){let i=E("DRM playback is being attempted in an environment that is not sufficiently secure. User may see black screen.");a=new f(i,f.MEDIA_ERR_ENCRYPTED,!1),a.errorCategory=x.DRM,a.muxCode=g.ENCRYPTED_OUTPUT_RESTRICTED}else a=new f(e.error.message,f.MEDIA_ERR_ENCRYPTED,e.fatal),a.errorCategory=x.DRM,a.muxCode=g.ENCRYPTED_ERROR;else a=new f("",s,e.fatal);return a.context||(a.context=`${e.url?`url: ${e.url}
`))}),nt=e=>{var s,u,l;let r=(u=((s=e.find(c=>c.startsWith("#EXT-X-PLAYLIST-TYPE")))!=null?s:"").split(":")[1])==null?void 0:u.trim(),n=re(r),o=ne(r),a;if(n===_.LIVE){let c=e.find(d=>d.startsWith("#EXT-X-PART-INF"));if(!!c)a=+c.split(":")[1].split("=")[1]*2;else{let d=e.find(y=>y.startsWith("#EXT-X-TARGETDURATION")),p=(l=d==null?void 0:d.split(":"))==null?void 0:l[1];a=+(p!=null?p:6)*3}}return{streamType:n,targetLiveWindow:o,liveEdgeStartOffset:a}},ot=async(e,t)=>{if(t===L.MP4)return{streamType:_.ON_DEMAND,targetLiveWindow:Number.NaN,liveEdgeStartOffset:void 0};if(t===L.M3U8){let r=await rt(e);return nt(r)}return console.error(`Media type ${t} is an unrecognized or unsupported type for src ${e}.`),{streamType:void 0,targetLiveWindow:void 0,liveEdgeStartOffset:void 0}},at=async(e,t,r=F({src:e}))=>{var s,u,l;let{streamType:n,targetLiveWindow:o,liveEdgeStartOffset:a}=await ot(e,r);((s=v.get(t))!=null?s:{}).liveEdgeStartOffset=a,((u=v.get(t))!=null?u:{}).targetLiveWindow=o,t.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((l=v.get(t))!=null?l:{}).streamType=n,t.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},st=e=>{var s;let t=e.type,r=re(t),n=ne(t),o,a=!!((s=e.partList)!=null&&s.length);return r===_.LIVE&&(o=a?e.partTarget*2:e.targetduration*3),{streamType:r,targetLiveWindow:n,liveEdgeStartOffset:o,lowLatency:a}},it=(e,t,r)=>{var u,l,c,i,d,p,T,y;let{streamType:n,targetLiveWindow:o,liveEdgeStartOffset:a,lowLatency:s}=st(e);if(n===_.LIVE){s?(r.config.backBufferLength=(u=r.userConfig.backBufferLength)!=null?u:4,r.config.maxFragLookUpTolerance=(l=r.userConfig.maxFragLookUpTolerance)!=null?l:.001,r.config.abrBandWidthUpFactor=(c=r.userConfig.abrBandWidthUpFactor)!=null?c:r.config.abrBandWidthFactor):r.config.backBufferLength=(i=r.userConfig.backBufferLength)!=null?i:8;let D=Object.freeze({get length(){return t.seekable.length},start(P){return t.seekable.start(P)},end(P){var R;return P>this.length||P<0||Number.isFinite(t.duration)?t.seekable.end(P):(R=r.liveSyncPosition)!=null?R:t.seekable.end(P)}});((d=v.get(t))!=null?d:{}).seekable=D}((p=v.get(t))!=null?p:{}).liveEdgeStartOffset=a,((T=v.get(t))!=null?T:{}).targetLiveWindow=o,t.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((y=v.get(t))!=null?y:{}).streamType=n,t.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},qe,je,Jt=(je=(qe=globalThis==null?void 0:globalThis.navigator)==null?void 0:qe.userAgent)!=null?je:"",ze,Xe,Qe,Gt=(Qe=(Xe=(ze=globalThis==null?void 0:globalThis.navigator)==null?void 0:ze.userAgentData)==null?void 0:Xe.platform)!=null?Qe:"",qt=Jt.toLowerCase().includes("android")||["x11","android"].some(e=>Gt.toLowerCase().includes(e)),v=new WeakMap,I="mux.com",Ze,et,ct=(et=(Ze=E).isSupported)==null?void 0:et.call(Ze),jt=qt,zt=()=>W.default.utils.now(),ut=W.default.utils.generateUUID,Xt=({playbackId:e,customDomain:t=I,maxResolution:r,minResolution:n,renditionOrder:o,programStartTime:a,programEndTime:s,assetStartTime:u,assetEndTime:l,playbackToken:c,tokens:{playback:i=c}={},extraSourceParams:d={}}={})=>{if(!e)return;let[p,T=""]=V(e),y=new URL(`https://stream.${t}/${p}.m3u8${T}`);return i||y.searchParams.has("token")?(y.searchParams.forEach((D,P)=>{P!="token"&&y.searchParams.delete(P)}),i&&y.searchParams.set("token",i)):(r&&y.searchParams.set("max_resolution",r),n&&(y.searchParams.set("min_resolution",n),r&&+r.slice(0,-1)<+n.slice(0,-1)&&console.error("minResolution must be <= maxResolution","minResolution",n,"maxResolution",r)),o&&y.searchParams.set("rendition_order",o),a&&y.searchParams.set("program_start_time",`${a}`),s&&y.searchParams.set("program_end_time",`${s}`),u&&y.searchParams.set("asset_start_time",`${u}`),l&&y.searchParams.set("asset_end_time",`${l}`),Object.entries(d).forEach(([D,P])=>{P!=null&&y.searchParams.set(D,P)})),y.toString()},ee=e=>{if(!e)return;let[t]=e.split("?");return t||void 0},dt=e=>{if(!e||!e.startsWith("https://stream."))return;let[t]=new URL(e).pathname.slice(1).split(".m3u8");return t||void 0},Qt=e=>{var t,r,n;return(t=e==null?void 0:e.metadata)!=null&&t.video_id?e.metadata.video_id:xe(e)&&(n=(r=ee(e.playbackId))!=null?r:dt(e.src))!=null?n:e.src},lt=e=>{var t;return(t=v.get(e))==null?void 0:t.error},ye=e=>{var t,r;return(r=(t=v.get(e))==null?void 0:t.streamType)!=null?r:_.UNKNOWN},Zt=e=>{var t,r;return(r=(t=v.get(e))==null?void 0:t.targetLiveWindow)!=null?r:Number.NaN},Ee=e=>{var t,r;return(r=(t=v.get(e))==null?void 0:t.seekable)!=null?r:e.seekable},er=e=>{var n;let t=(n=v.get(e))==null?void 0:n.liveEdgeStartOffset;if(typeof t!="number")return Number.NaN;let r=Ee(e);return r.length?r.end(r.length-1)-t:Number.NaN},ge=.034,tr=(e,t,r=ge)=>Math.abs(e-t)<=r,pt=(e,t,r=ge)=>e>t||tr(e,t,r),ft=(e,t=ge)=>e.paused&&pt(e.currentTime,e.duration,t),Me=(e,t)=>{var c,i,d;if(!t||!e.buffered.length)return;if(e.readyState>2)return!1;let r=t.currentLevel>=0?(i=(c=t.levels)==null?void 0:c[t.currentLevel])==null?void 0:i.details:(d=t.levels.find(p=>!!p.details))==null?void 0:d.details;if(!r||r.live)return;let{fragments:n}=r;if(!(n!=null&&n.length))return;if(e.currentTime<e.duration-(r.targetduration+.5))return!1;let o=n[n.length-1];if(e.currentTime<=o.start)return!1;let a=o.start+o.duration/2,s=e.buffered.start(e.buffered.length-1),u=e.buffered.end(e.buffered.length-1);return a>s&&a<u},Tt=(e,t)=>e.ended||e.loop?e.ended:t&&Me(e,t)?!0:ft(e),rr=(e,t,r)=>{yt(t,r);let{metadata:n={}}=e,{view_session_id:o=ut()}=n,a=Qt(e);n.view_session_id=o,n.video_id=a,e.metadata=n;let s=i=>{var d;(d=t.mux)==null||d.emit("hb",{view_drm_type:i})};e.drmTypeCb=s,v.set(t,{});let u=Et(e,t),l=we(e,t,u);Ct(e,t,u),Dt(e,t,u),ue(t),fe(t);let c=Se(e,t,u);return{engine:u,setAutoplay:c,setPreload:l}},yt=(e,t)=>{let r=t==null?void 0:t.engine;r&&(r.detachMedia(),r.destroy()),e!=null&&e.mux&&!e.mux.deleted&&(e.mux.destroy(),delete e.mux),e&&(e.removeAttribute("src"),e.load(),e.removeEventListener("error",_t),e.removeEventListener("error",me),e.removeEventListener("durationchange",vt),v.delete(e),e.dispatchEvent(new Event("teardown")))};function mt(e,t){var c;let r=F(e);if(!(r===L.M3U8))return!0;let o=!r||((c=t.canPlayType(r))!=null?c:!0),{preferPlayback:a}=e,s=a===B.MSE,u=a===B.NATIVE;return o&&(u||!(ct&&(s||jt)))}var Et=(e,t)=>{let{debug:r,streamType:n,startTime:o=-1,metadata:a,preferCmcd:s,_hlsConfig:u={}}=e,c=F(e)===L.M3U8,i=mt(e,t);if(c&&!i&&ct){let d={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelToPlayerSize:!0,capLevelOnFPSDrop:!0},p=gt(n),T=Mt(e),y=s!==w.NONE?{useHeaders:s===w.HEADER,sessionId:a==null?void 0:a.view_session_id,contentId:a==null?void 0:a.video_id}:void 0;return new E({debug:r,startPosition:o,cmcd:y,xhrSetup:(P,R)=>{var h,be;if(s&&s!==w.QUERY)return;let b=new URL(R);if(!b.searchParams.has("CMCD"))return;let m=((be=(h=b.searchParams.get("CMCD"))==null?void 0:h.split(","))!=null?be:[]).filter(Ce=>Ce.startsWith("sid")||Ce.startsWith("cid")).join(",");b.searchParams.set("CMCD",m),P.open("GET",b)},capLevelController:Ge,...d,...p,...T,...u})}},gt=e=>e===_.LIVE?{backBufferLength:8}:{},Mt=e=>{let{tokens:{drm:t}={},playbackId:r,drmTypeCb:n}=e,o=ee(r);return!t||!o?{}:{emeEnabled:!0,drmSystems:{"com.apple.fps":{licenseUrl:Y(e,"fairplay"),serverCertificateUrl:Re(e,"fairplay")},"com.widevine.alpha":{licenseUrl:Y(e,"widevine")},"com.microsoft.playready":{licenseUrl:Y(e,"playready")}},requestMediaKeySystemAccessFunc:(a,s)=>(a==="com.widevine.alpha"&&(s=[...s.map(u=>{var c;let l=(c=u.videoCapabilities)==null?void 0:c.map(i=>({...i,robustness:"HW_SECURE_ALL"}));return{...u,videoCapabilities:l}}),...s]),navigator.requestMediaKeySystemAccess(a,s).then(u=>{let l=tt(a);return n==null||n(l),u}))}},Rt=async e=>{let t=await fetch(e);return t.status!==200?Promise.reject(t):await t.arrayBuffer()},xt=async(e,t)=>{let r=await fetch(t,{method:"POST",headers:{"Content-type":"application/octet-stream"},body:e});if(r.status!==200)return Promise.reject(r);let n=await r.arrayBuffer();return new Uint8Array(n)},bt=(e,t)=>{C(t,"encrypted",async n=>{try{let o=n.initDataType;if(o!=="skd"){console.error(`Received unexpected initialization data type "${o}"`);return}if(!t.mediaKeys){let c=await navigator.requestMediaKeySystemAccess("com.apple.fps",[{initDataTypes:[o],videoCapabilities:[{contentType:"application/vnd.apple.mpegurl",robustness:""}],distinctiveIdentifier:"not-allowed",persistentState:"not-allowed",sessionTypes:["temporary"]}]).then(d=>{var p;return(p=e.drmTypeCb)==null||p.call(e,Z.FAIRPLAY),d}).catch(()=>{let d=g("Cannot play DRM-protected content with current security configuration on this browser. Try playing in another browser."),p=new f(d,f.MEDIA_ERR_ENCRYPTED,!0);p.errorCategory=x.DRM,p.muxCode=M.ENCRYPTED_UNSUPPORTED_KEY_SYSTEM,N(t,p)});if(!c)return;let i=await c.createMediaKeys();try{let d=await Rt(Re(e,"fairplay")).catch(p=>{if(p instanceof Response){let T=K(p,x.DRM,e);return console.error("mediaError",T==null?void 0:T.message,T==null?void 0:T.context),T?Promise.reject(T):Promise.reject(new Error("Unexpected error in app cert request"))}return Promise.reject(p)});await i.setServerCertificate(d).catch(()=>{let p=g("Your server certificate failed when attempting to set it. This may be an issue with a no longer valid certificate."),T=new f(p,f.MEDIA_ERR_ENCRYPTED,!0);return T.errorCategory=x.DRM,T.muxCode=M.ENCRYPTED_UPDATE_SERVER_CERT_FAILED,Promise.reject(T)})}catch(d){N(t,d);return}await t.setMediaKeys(i)}let a=n.initData;if(a==null){console.error(`Could not start encrypted playback due to missing initData in ${n.type} event`);return}let s=t.mediaKeys.createSession();s.addEventListener("keystatuseschange",()=>{s.keyStatuses.forEach(c=>{let i;if(c==="internal-error"){let d=g("The DRM Content Decryption Module system had an internal failure. Try reloading the page, upading your browser, or playing in another browser.");i=new f(d,f.MEDIA_ERR_ENCRYPTED,!0),i.errorCategory=x.DRM,i.muxCode=M.ENCRYPTED_CDM_ERROR}else if(c==="output-restricted"||c==="output-downscaled"){let d=g("DRM playback is being attempted in an environment that is not sufficiently secure. User may see black screen.");i=new f(d,f.MEDIA_ERR_ENCRYPTED,!1),i.errorCategory=x.DRM,i.muxCode=M.ENCRYPTED_OUTPUT_RESTRICTED}i&&N(t,i)})});let u=await Promise.all([s.generateRequest(o,a).catch(()=>{let c=g("Failed to generate a DRM license request. This may be an issue with the player or your protected content."),i=new f(c,f.MEDIA_ERR_ENCRYPTED,!0);i.errorCategory=x.DRM,i.muxCode=M.ENCRYPTED_GENERATE_REQUEST_FAILED,N(t,i)}),new Promise(c=>{s.addEventListener("message",i=>{c(i.message)},{once:!0})})]).then(([,c])=>c);s.generateRequest(o,a);let l=await xt(u,Y(e,"fairplay")).catch(c=>{if(c instanceof Response){let i=K(c,x.DRM,e);return console.error("mediaError",i==null?void 0:i.message,i==null?void 0:i.context),i?Promise.reject(i):Promise.reject(new Error("Unexpected error in license key request"))}return Promise.reject(c)});await s.update(l).catch(()=>{let c=g("Failed to update DRM license. This may be an issue with the player or your protected content."),i=new f(c,f.MEDIA_ERR_ENCRYPTED,!0);return i.errorCategory=x.DRM,i.muxCode=M.ENCRYPTED_UPDATE_LICENSE_FAILED,Promise.reject(i)})}catch(o){N(t,o);return}})},Y=({playbackId:e,tokens:{drm:t}={},customDomain:r=I},n)=>{let o=ee(e);return`https://license.${r.toLocaleLowerCase().endsWith(I)?r:I}/license/${n}/${o}?token=${t}`},Re=({playbackId:e,tokens:{drm:t}={},customDomain:r=I},n)=>{let o=ee(e);return`https://license.${r.toLocaleLowerCase().endsWith(I)?r:I}/appcert/${n}/${o}?token=${t}`},xe=({playbackId:e,src:t,customDomain:r})=>{if(e)return!0;if(typeof t!="string")return!1;let n=window==null?void 0:window.location.href,o=new URL(t,n).hostname.toLocaleLowerCase();return o.includes(I)||!!r&&o.includes(r.toLocaleLowerCase())},Ct=(e,t,r)=>{var s;let{envKey:n,disableTracking:o}=e,a=xe(e);if(!o&&(n||a)){let{playerInitTime:u,playerSoftwareName:l,playerSoftwareVersion:c,beaconCollectionDomain:i,debug:d,disableCookies:p}=e,T={...e.metadata,video_title:((s=e==null?void 0:e.metadata)==null?void 0:s.video_title)||void 0},y=D=>typeof D.player_error_code=="string"?!1:typeof e.errorTranslator=="function"?e.errorTranslator(D):D;W.default.monitor(t,{debug:d,beaconCollectionDomain:i,hlsjs:r,Hls:r?E:void 0,automaticErrorTracking:!1,errorTranslator:y,disableCookies:p,data:{...n?{env_key:n}:{},player_software_name:l,player_software:l,player_software_version:c,player_init_time:u,...T}})}},Dt=(e,t,r)=>{var c,i;let n=mt(e,t),{src:o}=e,a=()=>{t.ended||!Tt(t,r)||(Me(t,r)?t.currentTime=t.buffered.end(t.buffered.length-1):t.dispatchEvent(new Event("ended")))},s,u,l=()=>{let d=Ee(t),p,T;d.length>0&&(p=d.start(0),T=d.end(0)),(u!==T||s!==p)&&t.dispatchEvent(new CustomEvent("seekablechange",{composed:!0})),s=p,u=T};if(C(t,"durationchange",l),t&&n){let d=F(e);if(typeof o=="string"){let p=()=>{if(ye(t)!==_.LIVE||Number.isFinite(t.duration))return;let y=setInterval(l,1e3);t.addEventListener("teardown",()=>{clearInterval(y)},{once:!0}),C(t,"durationchange",()=>{Number.isFinite(t.duration)&&clearInterval(y)})},T=async()=>at(o,t,d).then(p).catch(y=>{if(y instanceof Response){let D=K(y,x.VIDEO,e);if(D){N(t,D);return}}else y instanceof Error});if(t.preload==="none"){let y=()=>{T(),t.removeEventListener("loadedmetadata",D)},D=()=>{T(),t.removeEventListener("play",y)};C(t,"play",y,{once:!0}),C(t,"loadedmetadata",D,{once:!0})}else T();(c=e.tokens)!=null&&c.drm?bt(e,t):C(t,"encrypted",()=>{let y=g("Attempting to play DRM-protected content without providing a DRM token."),D=new f(y,f.MEDIA_ERR_ENCRYPTED,!0);D.errorCategory=x.DRM,D.muxCode=M.ENCRYPTED_MISSING_TOKEN,N(t,D)},{once:!0}),t.setAttribute("src",o),e.startTime&&(((i=v.get(t))!=null?i:{}).startTime=e.startTime,t.addEventListener("durationchange",vt,{once:!0}))}else t.removeAttribute("src");t.addEventListener("error",_t),t.addEventListener("error",me),t.addEventListener("emptied",()=>{t.querySelectorAll("track[data-removeondestroy]").forEach(T=>{T.remove()})},{once:!0}),C(t,"pause",a),C(t,"seeked",a),C(t,"play",()=>{t.ended||pt(t.currentTime,t.duration)&&(t.currentTime=t.seekable.length?t.seekable.start(0):0)})}else r&&o?(r.once(E.Events.LEVEL_LOADED,(d,p)=>{it(p.details,t,r),l(),ye(t)===_.LIVE&&!Number.isFinite(t.duration)&&(r.on(E.Events.LEVEL_UPDATED,l),C(t,"durationchange",()=>{Number.isFinite(t.duration)&&r.off(E.Events.LEVELS_UPDATED,l)}))}),r.on(E.Events.ERROR,(d,p)=>{N(t,nr(p,e))}),t.addEventListener("error",me),C(t,"waiting",a),Oe(e,r),Ue(t,r),r.attachMedia(t)):console.error("It looks like the video you're trying to play will not work on this system! If possible, try upgrading to the newest versions of your browser or software.")};function vt(e){var n;let t=e.target,r=(n=v.get(t))==null?void 0:n.startTime;if(r&&Pe(t.seekable,t.duration,r)){let o=t.preload==="auto";o&&(t.preload="none"),t.currentTime=r,o&&(t.preload="auto")}}async function _t(e){if(!e.isTrusted)return;e.stopImmediatePropagation();let t=e.target;if(!(t!=null&&t.error))return;let{message:r,code:n}=t.error,o=new f(r,n);if(t.src&&n===f.MEDIA_ERR_SRC_NOT_SUPPORTED&&t.readyState===HTMLMediaElement.HAVE_NOTHING){setTimeout(()=>{var s;let a=(s=lt(t))!=null?s:t.error;(a==null?void 0:a.code)===f.MEDIA_ERR_SRC_NOT_SUPPORTED&&N(t,o)},500);return}if(t.src&&(n!==f.MEDIA_ERR_DECODE||n!==void 0))try{let{status:a}=await fetch(t.src);o.data={response:{code:a}}}catch{}N(t,o)}function N(e,t){var r;t.fatal&&(((r=v.get(e))!=null?r:{}).error=t,e.dispatchEvent(new CustomEvent("error",{detail:t})))}function me(e){var n,o;if(!(e instanceof CustomEvent)||!(e.detail instanceof f))return;let t=e.target,r=e.detail;!r||!r.fatal||(((n=v.get(t))!=null?n:{}).error=r,(o=t.mux)==null||o.emit("error",{player_error_code:r.code,player_error_message:r.message,player_error_context:r.context}))}var nr=(e,t)=>{var u,l,c;console.error("getErrorFromHlsErrorData()",e);let r={[E.ErrorTypes.NETWORK_ERROR]:f.MEDIA_ERR_NETWORK,[E.ErrorTypes.MEDIA_ERROR]:f.MEDIA_ERR_DECODE,[E.ErrorTypes.KEY_SYSTEM_ERROR]:f.MEDIA_ERR_ENCRYPTED},n=i=>[E.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,E.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED].includes(i.details)?f.MEDIA_ERR_NETWORK:r[i.type],o=i=>{if(i.type===E.ErrorTypes.KEY_SYSTEM_ERROR)return x.DRM;if(i.type===E.ErrorTypes.NETWORK_ERROR)return x.VIDEO},a,s=n(e);if(s===f.MEDIA_ERR_NETWORK&&e.response){let i=(u=o(e))!=null?u:x.VIDEO;a=(l=K(e.response,i,t))!=null?l:new f("",s)}else if(s===f.MEDIA_ERR_ENCRYPTED)if(e.details===E.ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE){let i=g("Attempting to play DRM-protected content without providing a DRM token.");a=new f(i,f.MEDIA_ERR_ENCRYPTED,e.fatal),a.errorCategory=x.DRM,a.muxCode=M.ENCRYPTED_MISSING_TOKEN}else if(e.details===E.ErrorDetails.KEY_SYSTEM_NO_ACCESS){let i=g("Cannot play DRM-protected content with current security configuration on this browser. Try playing in another browser.");a=new f(i,f.MEDIA_ERR_ENCRYPTED,e.fatal),a.errorCategory=x.DRM,a.muxCode=M.ENCRYPTED_UNSUPPORTED_KEY_SYSTEM}else if(e.details===E.ErrorDetails.KEY_SYSTEM_NO_SESSION){let i=g("Failed to generate a DRM license request. This may be an issue with the player or your protected content.");a=new f(i,f.MEDIA_ERR_ENCRYPTED,!0),a.errorCategory=x.DRM,a.muxCode=M.ENCRYPTED_GENERATE_REQUEST_FAILED}else if(e.details===E.ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED){let i=g("Failed to update DRM license. This may be an issue with the player or your protected content.");a=new f(i,f.MEDIA_ERR_ENCRYPTED,e.fatal),a.errorCategory=x.DRM,a.muxCode=M.ENCRYPTED_UPDATE_LICENSE_FAILED}else if(e.details===E.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED){let i=g("Your server certificate failed when attempting to set it. This may be an issue with a no longer valid certificate.");a=new f(i,f.MEDIA_ERR_ENCRYPTED,e.fatal),a.errorCategory=x.DRM,a.muxCode=M.ENCRYPTED_UPDATE_SERVER_CERT_FAILED}else if(e.details===E.ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR){let i=g("The DRM Content Decryption Module system had an internal failure. Try reloading the page, upading your browser, or playing in another browser.");a=new f(i,f.MEDIA_ERR_ENCRYPTED,e.fatal),a.errorCategory=x.DRM,a.muxCode=M.ENCRYPTED_CDM_ERROR}else if(e.details===E.ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED){let i=g("DRM playback is being attempted in an environment that is not sufficiently secure. User may see black screen.");a=new f(i,f.MEDIA_ERR_ENCRYPTED,!1),a.errorCategory=x.DRM,a.muxCode=M.ENCRYPTED_OUTPUT_RESTRICTED}else a=new f(e.error.message,f.MEDIA_ERR_ENCRYPTED,e.fatal),a.errorCategory=x.DRM,a.muxCode=M.ENCRYPTED_ERROR;else a=new f("",s,e.fatal);return a.context||(a.context=`${e.url?`url: ${e.url}
`:""}${e.response&&(e.response.code||e.response.text)?`response: ${e.response.code}, ${e.response.text}

@@ -5,0 +5,0 @@ `:""}${e.reason?`failure reason: ${e.reason}

@@ -5,2 +5,3 @@ import { ValueOf, PlaybackCore, MuxMediaProps, MuxMediaPropsInternal, MuxMediaPropTypes } from './types';

import { HlsInterface } from './hls';
import { HlsConfig } from 'hls.js';
import { MediaError, MuxErrorCategory, MuxErrorCode, errorCategoryToTokenNameOrPrefix } from './errors';

@@ -11,3 +12,2 @@ import { addTextTrack, removeTextTrack, getTextTrack, addCuePoints, getCuePoints, getActiveCuePoint, setupCuePoints, addChapters, getChapters, getActiveChapter, setupChapters } from './text-tracks';

import { StreamTypes, MediaTypes } from './types';
import { HlsConfig } from 'hls.js';
import { MuxJWTAud } from './request-errors';

@@ -14,0 +14,0 @@ export { mux, Hls, MediaError, MuxErrorCategory, MuxErrorCode, errorCategoryToTokenNameOrPrefix, MuxJWTAud, addTextTrack, removeTextTrack, getTextTrack, addCuePoints, getCuePoints, getActiveCuePoint, setupCuePoints, addChapters, getChapters, getActiveChapter, setupChapters, getStartDate, getCurrentPdt, toPlaybackIdParts, i18n, parseJwt, };

@@ -1,4 +0,4 @@

import Hls from 'hls.js';
import { HlsInterface } from './hls';
import { Level } from 'hls.js';
import { CapLevelController } from 'hls.js';
declare const CapLevelController: typeof import("hls.js").CapLevelController;
/**

@@ -10,3 +10,3 @@ * A custom HLS.js CapLevelController that behaves like the default one, except

static minMaxResolution: number;
constructor(hls: Hls);
constructor(hls: HlsInterface);
readonly levels: Level[];

@@ -13,0 +13,0 @@ getValidLevels(capLevelIndex: number): Level[];

@@ -5,2 +5,3 @@ import type { ValueOf, PlaybackCore, MuxMediaProps, MuxMediaPropsInternal, MuxMediaPropTypes } from './types';

import type { HlsInterface } from './hls';
import type { HlsConfig } from 'hls.js';
import { MediaError, MuxErrorCategory, MuxErrorCode, errorCategoryToTokenNameOrPrefix } from './errors';

@@ -11,3 +12,2 @@ import { addTextTrack, removeTextTrack, getTextTrack, addCuePoints, getCuePoints, getActiveCuePoint, setupCuePoints, addChapters, getChapters, getActiveChapter, setupChapters } from './text-tracks';

import { StreamTypes, MediaTypes } from './types';
import { type HlsConfig } from 'hls.js';
import { MuxJWTAud } from './request-errors';

@@ -14,0 +14,0 @@ export { mux, Hls, MediaError, MuxErrorCategory, MuxErrorCode, errorCategoryToTokenNameOrPrefix, MuxJWTAud, addTextTrack, removeTextTrack, getTextTrack, addCuePoints, getCuePoints, getActiveCuePoint, setupCuePoints, addChapters, getChapters, getActiveChapter, setupChapters, getStartDate, getCurrentPdt, toPlaybackIdParts, i18n, parseJwt, };

@@ -1,4 +0,4 @@

import type Hls from 'hls.js';
import type { HlsInterface } from './hls';
import type { Level } from 'hls.js';
import { CapLevelController } from 'hls.js';
declare const CapLevelController: typeof import("hls.js").CapLevelController;
/**

@@ -10,3 +10,3 @@ * A custom HLS.js CapLevelController that behaves like the default one, except

static minMaxResolution: number;
constructor(hls: Hls);
constructor(hls: HlsInterface);
get levels(): Level[];

@@ -13,0 +13,0 @@ getValidLevels(capLevelIndex: number): Level[];

{
"name": "@mux/playback-core",
"version": "0.28.1-canary.2",
"version": "0.28.1-canary.3",
"description": "Core library for media playback in the browser shared by mux elements",

@@ -5,0 +5,0 @@ "main": "./dist/index.cjs.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc