var mc=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)};var me=(i,e,t)=>(mc(i,e,"read from private field"),t?t.call(i):e.get(i)),Xe=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Ht=(i,e,t,r)=>(mc(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t);var Ze=(i,e,t)=>(mc(i,e,"access private method"),t);var $s=class{addEventListener(){}removeEventListener(){}dispatchEvent(e){return!0}};if(typeof DocumentFragment=="undefined"){class i extends $s{}globalThis.DocumentFragment=i}var Wn=class extends $s{},pc=class extends $s{},G_={get(i){},define(i,e,t){},getName(i){return null},upgrade(i){},whenDefined(i){return Promise.resolve(Wn)}},Vn,gc=class{constructor(e,t={}){Xe(this,Vn,void 0);Ht(this,Vn,t==null?void 0:t.detail)}get detail(){return me(this,Vn)}initCustomEvent(){}};Vn=new WeakMap;function K_(i,e){return new Wn}var Wg={document:{createElement:K_},DocumentFragment,customElements:G_,CustomEvent:gc,EventTarget:$s,HTMLElement:Wn,HTMLVideoElement:pc},Vg=typeof window=="undefined"||typeof globalThis.customElements=="undefined",Ve=Vg?Wg:globalThis,Ut=Vg?Wg.document:globalThis.document;var $={MEDIA_PLAY_REQUEST:"mediaplayrequest",MEDIA_PAUSE_REQUEST:"mediapauserequest",MEDIA_MUTE_REQUEST:"mediamuterequest",MEDIA_UNMUTE_REQUEST:"mediaunmuterequest",MEDIA_VOLUME_REQUEST:"mediavolumerequest",MEDIA_SEEK_REQUEST:"mediaseekrequest",MEDIA_AIRPLAY_REQUEST:"mediaairplayrequest",MEDIA_ENTER_FULLSCREEN_REQUEST:"mediaenterfullscreenrequest",MEDIA_EXIT_FULLSCREEN_REQUEST:"mediaexitfullscreenrequest",MEDIA_PREVIEW_REQUEST:"mediapreviewrequest",MEDIA_ENTER_PIP_REQUEST:"mediaenterpiprequest",MEDIA_EXIT_PIP_REQUEST:"mediaexitpiprequest",MEDIA_ENTER_CAST_REQUEST:"mediaentercastrequest",MEDIA_EXIT_CAST_REQUEST:"mediaexitcastrequest",MEDIA_SHOW_TEXT_TRACKS_REQUEST:"mediashowtexttracksrequest",MEDIA_HIDE_TEXT_TRACKS_REQUEST:"mediahidetexttracksrequest",MEDIA_SHOW_SUBTITLES_REQUEST:"mediashowsubtitlesrequest",MEDIA_DISABLE_SUBTITLES_REQUEST:"mediadisablesubtitlesrequest",MEDIA_TOGGLE_SUBTITLES_REQUEST:"mediatogglesubtitlesrequest",MEDIA_PLAYBACK_RATE_REQUEST:"mediaplaybackraterequest",MEDIA_RENDITION_REQUEST:"mediarenditionrequest",MEDIA_AUDIO_TRACK_REQUEST:"mediaaudiotrackrequest",MEDIA_SEEK_TO_LIVE_REQUEST:"mediaseektoliverequest",REGISTER_MEDIA_STATE_RECEIVER:"registermediastatereceiver",UNREGISTER_MEDIA_STATE_RECEIVER:"unregistermediastatereceiver"},ue={MEDIA_CHROME_ATTRIBUTES:"mediachromeattributes",MEDIA_CONTROLLER:"mediacontroller"},vc={MEDIA_AIRPLAY_UNAVAILABLE:"mediaAirplayUnavailable",MEDIA_FULLSCREEN_UNAVAILABLE:"mediaFullscreenUnavailable",MEDIA_PIP_UNAVAILABLE:"mediaPipUnavailable",MEDIA_CAST_UNAVAILABLE:"mediaCastUnavailable",MEDIA_RENDITION_UNAVAILABLE:"mediaRenditionUnavailable",MEDIA_AUDIO_TRACK_UNAVAILABLE:"mediaAudioTrackUnavailable",MEDIA_WIDTH:"mediaWidth",MEDIA_HEIGHT:"mediaHeight",MEDIA_PAUSED:"mediaPaused",MEDIA_HAS_PLAYED:"mediaHasPlayed",MEDIA_ENDED:"mediaEnded",MEDIA_MUTED:"mediaMuted",MEDIA_VOLUME_LEVEL:"mediaVolumeLevel",MEDIA_VOLUME:"mediaVolume",MEDIA_VOLUME_UNAVAILABLE:"mediaVolumeUnavailable",MEDIA_IS_PIP:"mediaIsPip",MEDIA_IS_CASTING:"mediaIsCasting",MEDIA_IS_AIRPLAYING:"mediaIsAirplaying",MEDIA_SUBTITLES_LIST:"mediaSubtitlesList",MEDIA_SUBTITLES_SHOWING:"mediaSubtitlesShowing",MEDIA_IS_FULLSCREEN:"mediaIsFullscreen",MEDIA_PLAYBACK_RATE:"mediaPlaybackRate",MEDIA_CURRENT_TIME:"mediaCurrentTime",MEDIA_DURATION:"mediaDuration",MEDIA_SEEKABLE:"mediaSeekable",MEDIA_PREVIEW_TIME:"mediaPreviewTime",MEDIA_PREVIEW_IMAGE:"mediaPreviewImage",MEDIA_PREVIEW_COORDS:"mediaPreviewCoords",MEDIA_PREVIEW_CHAPTER:"mediaPreviewChapter",MEDIA_LOADING:"mediaLoading",MEDIA_BUFFERED:"mediaBuffered",MEDIA_STREAM_TYPE:"mediaStreamType",MEDIA_TARGET_LIVE_WINDOW:"mediaTargetLiveWindow",MEDIA_TIME_IS_LIVE:"mediaTimeIsLive",MEDIA_RENDITION_LIST:"mediaRenditionList",MEDIA_RENDITION_SELECTED:"mediaRenditionSelected",MEDIA_AUDIO_TRACK_LIST:"mediaAudioTrackList",MEDIA_AUDIO_TRACK_ENABLED:"mediaAudioTrackEnabled",MEDIA_CHAPTERS_CUES:"mediaChaptersCues"},Yg=Object.entries(vc),y=Yg.reduce((i,[e,t])=>(i[e]=t.toLowerCase(),i),{}),W_={USER_INACTIVE:"userinactivechange",BREAKPOINTS_CHANGE:"breakpointchange",BREAKPOINTS_COMPUTED:"breakpointscomputed"},Hi=Yg.reduce((i,[e,t])=>(i[e]=t.toLowerCase(),i),{...W_}),tD=Object.entries(Hi).reduce((i,[e,t])=>{let r=y[e];return r&&(i[t]=r),i},{userinactivechange:"userinactive"}),qg=Object.entries(y).reduce((i,[e,t])=>{let r=Hi[e];return r&&(i[t]=r),i},{userinactive:"userinactivechange"}),It={SUBTITLES:"subtitles",CAPTIONS:"captions",DESCRIPTIONS:"descriptions",CHAPTERS:"chapters",METADATA:"metadata"},ar={DISABLED:"disabled",HIDDEN:"hidden",SHOWING:"showing"};var Ec={MOUSE:"mouse",PEN:"pen",TOUCH:"touch"},Ft={UNAVAILABLE:"unavailable",UNSUPPORTED:"unsupported"},zt={LIVE:"live",ON_DEMAND:"on-demand",UNKNOWN:"unknown"};var jg={INLINE:"inline",FULLSCREEN:"fullscreen",PICTURE_IN_PICTURE:"picture-in-picture"};var ce={ENTER_AIRPLAY:"Start airplay",EXIT_AIRPLAY:"Stop airplay",AUDIO_TRACK_MENU:"Audio",CAPTIONS:"Captions",ENABLE_CAPTIONS:"Enable captions",DISABLE_CAPTIONS:"Disable captions",START_CAST:"Start casting",STOP_CAST:"Stop casting",ENTER_FULLSCREEN:"Enter fullscreen mode",EXIT_FULLSCREEN:"Exit fullscreen mode",MUTE:"Mute",UNMUTE:"Unmute",ENTER_PIP:"Enter picture in picture mode",EXIT_PIP:"Enter picture in picture mode",PLAY:"Play",PAUSE:"Pause",PLAYBACK_RATE:"Playback rate",RENDITIONS:"Quality",SEEK_BACKWARD:"Seek backward",SEEK_FORWARD:"Seek forward",SETTINGS:"Settings"},Pe={AUDIO_PLAYER:()=>"audio player",VIDEO_PLAYER:()=>"video player",VOLUME:()=>"volume",SEEK:()=>"seek",CLOSED_CAPTIONS:()=>"closed captions",PLAYBACK_RATE:({playbackRate:i=1}={})=>`current playback rate ${i}`,PLAYBACK_TIME:()=>"playback time",MEDIA_LOADING:()=>"media loading",SETTINGS:()=>"settings",AUDIO_TRACKS:()=>"audio tracks",QUALITY:()=>"quality"},Oe={PLAY:()=>"play",PAUSE:()=>"pause",MUTE:()=>"mute",UNMUTE:()=>"unmute",ENTER_AIRPLAY:()=>"start airplay",EXIT_AIRPLAY:()=>"stop airplay",ENTER_CAST:()=>"start casting",EXIT_CAST:()=>"stop casting",ENTER_FULLSCREEN:()=>"enter fullscreen mode",EXIT_FULLSCREEN:()=>"exit fullscreen mode",ENTER_PIP:()=>"enter picture in picture mode",EXIT_PIP:()=>"exit picture in picture mode",SEEK_FORWARD_N_SECS:({seekOffset:i=30}={})=>`seek forward ${i} seconds`,SEEK_BACK_N_SECS:({seekOffset:i=30}={})=>`seek back ${i} seconds`,SEEK_LIVE:()=>"seek to live",PLAYING_LIVE:()=>"playing live"},Y_={...Pe,...Oe};function zg(i){return i==null?void 0:i.map(q_).join(" ")}function Xg(i){return i==null?void 0:i.split(/\s+/).map(j_)}function q_(i){if(i){let{id:e,width:t,height:r}=i;return[e,t,r].filter(s=>s!=null).join(":")}}function j_(i){if(i){let[e,t,r]=i.split(":");return{id:e,width:+t,height:+r}}}function Qg(i){return i==null?void 0:i.map(z_).join(" ")}function Zg(i){return i==null?void 0:i.split(/\s+/).map(X_)}function z_(i){if(i){let{id:e,kind:t,language:r,label:s}=i;return[e,t,r,s].filter(n=>n!=null).join(":")}}function X_(i){if(i){let[e,t,r,s]=i.split(":");return{id:e,kind:t,language:r,label:s}}}function Jg(i){return i.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase())}function Hs(i){return typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i)}function wo(i){return typeof i!="string"?!1:!isNaN(i)&&!isNaN(parseFloat(i))}var Do=i=>new Promise(e=>setTimeout(e,i));var e0=[{singular:"hour",plural:"hours"},{singular:"minute",plural:"minutes"},{singular:"second",plural:"seconds"}],Q_=(i,e)=>{let t=i===1?e0[e].singular:e0[e].plural;return`${i} ${t}`},Or=i=>{if(!Hs(i))return"";let e=Math.abs(i),t=e!==i,r=new Date(0,0,0,0,0,e,0);return`${[r.getHours(),r.getMinutes(),r.getSeconds()].map((o,l)=>o&&Q_(o,l)).filter(o=>o).join(", ")}${t?" remaining":""}`};function di(i,e){let t=!1;i<0&&(t=!0,i=0-i),i=i<0?0:i;let r=Math.floor(i%60),s=Math.floor(i/60%60),n=Math.floor(i/3600),a=Math.floor(e/60%60),o=Math.floor(e/3600);return(isNaN(i)||i===1/0)&&(n=s=r="0"),n=n>0||o>0?n+":":"",s=((n||a>=10)&&s<10?"0"+s:s)+":",r=r<10?"0"+r:r,(t?"-":"")+n+s+r}var nD=Object.freeze({length:0,start(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'start' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0},end(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'end' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0}});var Mo=class{addEventListener(){}removeEventListener(){}dispatchEvent(){return!0}},Po=class extends Mo{},Oo=class extends Po{constructor(){super(...arguments),this.role=null}},bc=class{observe(){}unobserve(){}disconnect(){}},t0={createElement:function(){return new Yn.HTMLElement},createElementNS:function(){return new Yn.HTMLElement},addEventListener(){},removeEventListener(){},dispatchEvent(i){return!1}},Yn={ResizeObserver:bc,document:t0,Node:Po,Element:Oo,HTMLElement:class extends Oo{constructor(){super(...arguments),this.innerHTML=""}get content(){return new Yn.DocumentFragment}},DocumentFragment:class extends Mo{},customElements:{get:function(){},define:function(){},whenDefined:function(){}},localStorage:{getItem(i){return null},setItem(i,e){},removeItem(i){}},CustomEvent:function(){},getComputedStyle:function(){},navigator:{languages:[],get userAgent(){return""}},matchMedia(i){return{matches:!1,media:i}}},i0=typeof window=="undefined"||typeof window.customElements=="undefined",r0=Object.keys(Yn).every(i=>i in globalThis),x=i0&&!r0?Yn:globalThis,N=i0&&!r0?t0:globalThis.document;var s0=new WeakMap,yc=i=>{let e=s0.get(i);return e||s0.set(i,e=new Set),e},n0=new x.ResizeObserver(i=>{for(let e of i)for(let t of yc(e.target))t(e)});function Gi(i,e){yc(i).add(e),n0.observe(i)}function Nr(i,e){let t=yc(i);t.delete(e),t.size||n0.unobserve(i)}function He(i){var e;return(e=No(i))!=null?e:ui(i,"media-controller")}function No(i){var e;let{MEDIA_CONTROLLER:t}=ue,r=i.getAttribute(t);if(r)return(e=Ur(i))==null?void 0:e.getElementById(r)}var Uo=(i,e,t=".value")=>{let r=i.querySelector(t);r&&(r.textContent=e)},J_=(i,e)=>{let t=`slot[name="${e}"]`,r=i.shadowRoot.querySelector(t);return r?r.children:[]},Fo=(i,e)=>J_(i,e)[0],St=(i,e)=>!i||!e?!1:i!=null&&i.contains(e)?!0:St(i,e.getRootNode().host),ui=(i,e)=>{if(!i)return null;let t=i.closest(e);return t||ui(i.getRootNode().host,e)};function qn(i=document){var e;let t=i==null?void 0:i.activeElement;return t?(e=qn(t.shadowRoot))!=null?e:t:null}function Ur(i){var e;let t=(e=i==null?void 0:i.getRootNode)==null?void 0:e.call(i);return t instanceof ShadowRoot||t instanceof Document?t:null}function a0(i,e=3){if(i.checkVisibility)return i.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0});let t=i;for(;t&&e>0;){let r=getComputedStyle(t);if(r.opacity==="0"||r.visibility==="hidden"||r.display==="none")return!1;t=t.parentElement,e--}return!0}function o0(i,e,t,r){let s=Tc(t,r),n=Tc(t,{x:i,y:e}),a=Tc(r,{x:i,y:e});return n>s||a>s?n>a?1:0:n/s}function Tc(i,e){return Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2))}function Le(i,e){let t=eA(i,r=>r===e);return t||_c(i,e)}function eA(i,e){var t,r;let s;for(s of(t=i.querySelectorAll("style:not([media])"))!=null?t:[]){let n;try{n=(r=s.sheet)==null?void 0:r.cssRules}catch{continue}for(let a of n!=null?n:[])if(e(a.selectorText))return a}}function _c(i,e){var t,r;let s=(t=i.querySelectorAll("style:not([media])"))!=null?t:[],n=s==null?void 0:s[s.length-1];return n!=null&&n.sheet?(n==null||n.sheet.insertRule(`${e}{}`,n.sheet.cssRules.length),(r=n.sheet.cssRules)==null?void 0:r[n.sheet.cssRules.length-1]):(console.warn("Media Chrome: No style sheet found on style tag of",i),{style:{setProperty:()=>{},removeProperty:()=>"",getPropertyValue:()=>""}})}function pe(i,e,t=Number.NaN){let r=i.getAttribute(e);return r!=null?+r:t}function Te(i,e,t){let r=+t;if(t==null||Number.isNaN(r)){i.hasAttribute(e)&&i.removeAttribute(e);return}pe(i,e,void 0)!==r&&i.setAttribute(e,`${r}`)}function Re(i,e){return i.hasAttribute(e)}function Se(i,e,t){if(t==null){i.hasAttribute(e)&&i.removeAttribute(e);return}Re(i,e)!=t&&i.toggleAttribute(e,t)}function ge(i,e,t=null){var r;return(r=i.getAttribute(e))!=null?r:t}function fe(i,e,t){if(t==null){i.hasAttribute(e)&&i.removeAttribute(e);return}let r=`${t}`;ge(i,e,void 0)!==r&&i.setAttribute(e,r)}var l0=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},or=(i,e,t)=>(l0(i,e,"read from private field"),t?t.call(i):e.get(i)),tA=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Bo=(i,e,t,r)=>(l0(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Lt,d0=N.createElement("template");d0.innerHTML=`
`;var Ac=class extends x.HTMLElement{constructor(e={}){if(super(),tA(this,Lt,void 0),!this.shadowRoot){let t=this.attachShadow({mode:"open"}),r=d0.content.cloneNode(!0);this.nativeEl=r;let s=e.slotTemplate;s||(s=N.createElement("template"),s.innerHTML=`
=C||k>d*10)return;s.nextLoadLevel=s.nextAutoLevel=M,E?this.bwEstimator.sample(u-Math.min(f,g),l.loaded):this.bwEstimator.sampleTTFB(u);let B=T[M].maxBitrate;this.getBwEstimate()*this.hls.config.abrBandWidthUpFactor>B&&this.resetEstimator(B),this.clearTimer(),L.warn(`[abr] Fragment ${t.sn}${r?" part "+r.index:""} of level ${t.level} is loading too slowly;
Time to underbuffer: ${p.toFixed(3)} s
Estimated load time for current fragment: ${C.toFixed(3)} s
Estimated load time for down switch fragment: ${k.toFixed(3)} s
TTFB estimate: ${g|0} ms
Current BW estimate: ${q(b)?b|0:"Unknown"} bps
New BW estimate: ${this.getBwEstimate()|0} bps
Switching to level ${M} @ ${B|0} bps`),s.trigger(v.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:r,stats:l})},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(e){e&&(L.log(`setting initial bwe to ${e}`),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}initEstimator(){let e=this.hls.config;return new Cf(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){let{hls:e}=this;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.FRAG_LOADING,this.onFragLoading,this),e.on(v.FRAG_LOADED,this.onFragLoaded,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this),e.on(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(v.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(v.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e&&(e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.FRAG_LOADING,this.onFragLoading,this),e.off(v.FRAG_LOADED,this.onFragLoaded,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this),e.off(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(v.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(v.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null}onManifestLoading(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}onLevelsUpdated(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}onMaxAutoLevelUpdated(){this.firstSelection=-1,this.nextAutoLevelKey=""}onFragLoading(e,t){let r=t.frag;if(!this.ignoreFragment(r)){if(!r.bitrateTest){var s;this.fragCurrent=r,this.partCurrent=(s=t.part)!=null?s:null}this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}}onLevelSwitching(e,t){this.clearTimer()}onError(e,t){if(!t.fatal)switch(t.details){case w.BUFFER_ADD_CODEC_ERROR:case w.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case w.FRAG_LOAD_TIMEOUT:{let r=t.frag,{fragCurrent:s,partCurrent:n}=this;if(r&&s&&r.sn===s.sn&&r.level===s.level){let a=performance.now(),o=n?n.stats:r.stats,l=a-o.loading.start,d=o.loading.first?o.loading.first-o.loading.start:-1;if(o.loaded&&d>-1){let c=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(l-Math.min(c,d),o.loaded)}else this.bwEstimator.sampleTTFB(l)}break}}}getTimeToLoadFrag(e,t,r,s){let n=e+r/t,a=s?this.lastLevelLoadSec:0;return n+a}onLevelLoaded(e,t){let r=this.hls.config,{loading:s}=t.stats,n=s.end-s.start;q(n)&&(this.lastLevelLoadSec=n/1e3),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)}onFragLoaded(e,{frag:t,part:r}){let s=r?r.stats:t.stats;if(t.type===re.MAIN&&this.bwEstimator.sampleTTFB(s.loading.first-s.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),t.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){let n=r?r.duration:t.duration,a=this.hls.levels[t.level],o=(a.loaded?a.loaded.bytes:0)+s.loaded,l=(a.loaded?a.loaded.duration:0)+n;a.loaded={bytes:o,duration:l},a.realBitrate=Math.round(8*o/l)}if(t.bitrateTest){let n={stats:s,frag:t,part:r,id:t.type};this.onFragBuffered(v.FRAG_BUFFERED,n),t.bitrateTest=!1}else this.lastLoadedFragLevel=t.level}}onFragBuffered(e,t){let{frag:r,part:s}=t,n=s!=null&&s.stats.loaded?s.stats:r.stats;if(n.aborted||this.ignoreFragment(r))return;let a=n.parsing.end-n.loading.start-Math.min(n.loading.first-n.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(a,n.loaded),n.bwEstimate=this.getBwEstimate(),r.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==re.MAIN||e.sn==="initSegment"}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}get firstAutoLevel(){let{maxAutoLevel:e,minAutoLevel:t}=this.hls,r=this.getBwEstimate(),s=this.hls.config.maxStarvationDelay,n=this.findBestLevel(r,t,e,0,s,1,1);if(n>-1)return n;let a=this.hls.firstLevel,o=Math.min(Math.max(a,t),e);return L.warn(`[abr] Could not find best starting auto level. Defaulting to first in playlist ${a} clamped to ${o}`),o}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){let e=this.forcedAutoLevel,r=this.bwEstimator.canEstimate(),s=this.lastLoadedFragLevel>-1;if(e!==-1&&(!r||!s||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;let n=r&&s?this.getNextABRAutoLevel():this.firstAutoLevel;if(e!==-1){let a=this.hls.levels;if(a.length>Math.max(e,n)&&a[e].loadError<=a[n].loadError)return e}return this._nextAutoLevel=n,this.nextAutoLevelKey=this.getAutoLevelKey(),n}getAutoLevelKey(){return`${this.getBwEstimate()}_${this.getStarvationDelay().toFixed(2)}`}getNextABRAutoLevel(){let{fragCurrent:e,partCurrent:t,hls:r}=this,{maxAutoLevel:s,config:n,minAutoLevel:a}=r,o=t?t.duration:e?e.duration:0,l=this.getBwEstimate(),d=this.getStarvationDelay(),u=n.abrBandWidthFactor,c=n.abrBandWidthUpFactor;if(d){let g=this.findBestLevel(l,a,s,d,0,u,c);if(g>=0)return g}let h=o?Math.min(o,n.maxStarvationDelay):n.maxStarvationDelay;if(!d){let g=this.bitrateTestDelay;g&&(h=(o?Math.min(o,n.maxLoadingDelay):n.maxLoadingDelay)-g,L.info(`[abr] bitrate test took ${Math.round(1e3*g)}ms, set first fragment max fetchDuration to ${Math.round(1e3*h)} ms`),u=c=1)}let f=this.findBestLevel(l,a,s,d,h,u,c);if(L.info(`[abr] ${d?"rebuffering expected":"buffer is empty"}, optimal quality level ${f}`),f>-1)return f;let m=r.levels[a],p=r.levels[r.loadLevel];return(m==null?void 0:m.bitrate)<(p==null?void 0:p.bitrate)?a:r.loadLevel}getStarvationDelay(){let e=this.hls,t=e.media;if(!t)return 1/0;let r=t&&t.playbackRate!==0?Math.abs(t.playbackRate):1,s=e.mainForwardBufferInfo;return(s?s.len:0)/r}getBwEstimate(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}findBestLevel(e,t,r,s,n,a,o){var l;let d=s+n,u=this.lastLoadedFragLevel,c=u===-1?this.hls.firstLevel:u,{fragCurrent:h,partCurrent:f}=this,{levels:m,allAudioTracks:p,loadLevel:g,config:E}=this.hls;if(m.length===1)return 0;let b=m[c],T=!!(b!=null&&(l=b.details)!=null&&l.live),_=g===-1||u===-1,A,R="SDR",S=(b==null?void 0:b.frameRate)||0,{audioPreference:C,videoPreference:P}=E,k=this.audioTracksByGroup||(this.audioTracksByGroup=rI(p));if(_){if(this.firstSelection!==-1)return this.firstSelection;let Q=this.codecTiers||(this.codecTiers=sI(m,k,t,r)),V=iI(Q,R,e,C,P),{codecSet:ne,videoRanges:le,minFramerate:W,minBitrate:G,preferHDR:ae}=V;A=ne,R=ae?le[le.length-1]:le[0],S=W,e=Math.max(e,G),L.log(`[abr] picked start tier ${JSON.stringify(V)}`)}else A=b==null?void 0:b.codecSet,R=b==null?void 0:b.videoRange;let M=f?f.duration:h?h.duration:0,B=this.bwEstimator.getEstimateTTFB()/1e3,F=[];for(let Q=r;Q>=t;Q--){var X;let V=m[Q],ne=Q>c;if(!V)continue;if(E.useMediaCapabilities&&!V.supportedResult&&!V.supportedPromise){let Fe=navigator.mediaCapabilities;typeof(Fe==null?void 0:Fe.decodingInfo)=="function"&&QR(V,k,R,S,e,C)?(V.supportedPromise=ZR(V,k,Fe),V.supportedPromise.then(We=>{if(!this.hls)return;V.supportedResult=We;let ze=this.hls.levels,At=ze.indexOf(V);We.error?L.warn(`[abr] MediaCapabilities decodingInfo error: "${We.error}" for level ${At} ${JSON.stringify(We)}`):We.supported||(L.warn(`[abr] Unsupported MediaCapabilities decodingInfo result for level ${At} ${JSON.stringify(We)}`),At>-1&&ze.length>1&&(L.log(`[abr] Removing unsupported level ${At}`),this.hls.removeLevel(At)))})):V.supportedResult=Ub}if(A&&V.codecSet!==A||R&&V.videoRange!==R||ne&&S>V.frameRate||!ne&&S>0&&S h.end+o.targetduration;if(_||!(h!=null&&h.len)&&d.len){let A=this.getAppendedFrag(b.start,re.MAIN);if(A===null||(T||(T=!!A.gap||!!_&&h.len===0),_&&!T||T&&d.nextStart&&d.nextStart
${(W=i.dialog)==null?void 0:W.message}
${(G=i.dialog)!=null&&G.linkUrl?tr`${(Z=i.dialog.linkText)!=null?Z:i.dialog.linkUrl}`:tr``}
${e.startSN} prev-sn: ${l?l.sn:"na"} fragments: ${s}`),d}return n}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*3)}setStartPosition(e,t){let r=this.startPosition;if(r>24&255,a[1]=r>>16&255,a[2]=r>>8&255,a[3]=r&255,a.set(e,4),s=0,r=8;s>>24&255,d>>>16&255,d>>>8&255,d&255,u>>>24&255,u>>>16&255,u>>>8&255,u&255,c.isLeading<<2|c.dependsOn,c.isDependedOn<<6|c.hasRedundancy<<4|c.paddingValue<<1|c.isNonSync,c.degradPrio&61440,c.degradPrio&15,h>>>24&255,h>>>16&255,h>>>8&255,h&255],12+16*o);return i.box(i.types.trun,a)}static initSegment(e){i.types||i.init();let t=i.moov(e);return Wt(i.FTYP,t)}};at.types=void 0;at.HDLR_TYPES=void 0;at.STTS=void 0;at.STSC=void 0;at.STCO=void 0;at.STSZ=void 0;at.VMHD=void 0;at.SMHD=void 0;at.STSD=void 0;at.FTYP=void 0;at.DINF=void 0;var Xb=9e4;function Dm(i,e,t=1,r=!1){let s=i*e*t;return r?Math.round(s):s}function MI(i,e,t=1,r=!1){return Dm(i,e,1/t,r)}function Sa(i,e=!1){return Dm(i,1e3,1/Xb,e)}function PI(i,e=1){return Dm(i,Xb,1/e)}var OI=10*1e3,eb=1024,NI=1152,UI=1536,gn=null,of=null,yn=class{constructor(e,t,r,s=""){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=r,this.ISGenerated=!1,gn===null){let a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);gn=a?parseInt(a[1]):0}if(of===null){let n=navigator.userAgent.match(/Safari\/(\d+)/i);of=n?parseInt(n[1]):0}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(e){L.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}resetNextTimestamp(){L.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){L.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}getVideoStartPts(e){let t=!1,r=e.reduce((s,n)=>{let a=n.pts-s;return a<-4294967296?(t=!0,Kt(s,n.pts)):a>0?s:n.pts},e[0].pts);return t&&L.debug("PTS rollover detected"),r}remux(e,t,r,s,n,a,o,l){let d,u,c,h,f,m,p=n,g=n,E=e.pid>-1,b=t.pid>-1,T=t.samples.length,_=e.samples.length>0,A=o&&T>0||T>1;if((!E||_)&&(!b||A)||this.ISGenerated||o){if(this.ISGenerated){var S,C,P,k;let X=this.videoTrackConfig;X&&(t.width!==X.width||t.height!==X.height||((S=t.pixelRatio)==null?void 0:S[0])!==((C=X.pixelRatio)==null?void 0:C[0])||((P=t.pixelRatio)==null?void 0:P[1])!==((k=X.pixelRatio)==null?void 0:k[1]))&&this.resetInitSegment()}else c=this.generateIS(e,t,n,a);let M=this.isVideoContiguous,B=-1,F;if(A&&(B=FI(t.samples),!M&&this.config.forceKeyFrameOnDiscontinuity))if(m=!0,B>0){L.warn(`[mp4-remuxer]: Dropped ${B} out of ${T} video samples due to a missing keyframe`);let X=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(B),t.dropped+=B,g+=(t.samples[0].pts-X)/t.inputTimeScale,F=g}else B===-1&&(L.warn(`[mp4-remuxer]: No keyframe found out of ${T} video samples`),m=!1);if(this.ISGenerated){if(_&&A){let X=this.getVideoStartPts(t.samples),V=(Kt(e.samples[0].pts,X)-X)/t.inputTimeScale;p+=Math.max(0,V),g+=Math.max(0,-V)}if(_){if(e.samplerate||(L.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),c=this.generateIS(e,t,n,a)),u=this.remuxAudio(e,p,this.isAudioContiguous,a,b||A||l===re.AUDIO?g:void 0),A){let X=u?u.endPTS-u.startPTS:0;t.inputTimeScale||(L.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),c=this.generateIS(e,t,n,a)),d=this.remuxVideo(t,g,M,X)}}else A&&(d=this.remuxVideo(t,g,M,0));d&&(d.firstKeyFrame=B,d.independent=B!==-1,d.firstKeyFramePTS=F)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(f=Qb(r,n,this._initPTS,this._initDTS)),s.samples.length&&(h=Zb(s,n,this._initPTS))),{audio:u,video:d,initSegment:c,independent:m,text:h,id3:f}}generateIS(e,t,r,s){let n=e.samples,a=t.samples,o=this.typeSupported,l={},d=this._initPTS,u=!d||s,c="audio/mp4",h,f,m;if(u&&(h=f=1/0),e.config&&n.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":o.mpeg?(c="audio/mpeg",e.codec=""):o.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3";break}l.audio={id:"audio",container:c,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&o.mpeg?new Uint8Array(0):at.initSegment([e]),metadata:{channelCount:e.channelCount}},u&&(m=e.inputTimeScale,!d||m!==d.timescale?h=f=n[0].pts-Math.round(m*r):u=!1)}if(t.sps&&t.pps&&a.length){if(t.timescale=t.inputTimeScale,l.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:at.initSegment([t]),metadata:{width:t.width,height:t.height}},u)if(m=t.inputTimeScale,!d||m!==d.timescale){let p=this.getVideoStartPts(a),g=Math.round(m*r);f=Math.min(f,Kt(a[0].dts,p)-g),h=Math.min(h,p-g)}else u=!1;this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(l).length)return this.ISGenerated=!0,u?(this._initPTS={baseTime:h,timescale:m},this._initDTS={baseTime:f,timescale:m}):h=m=void 0,{tracks:l,initPTS:h,timescale:m}}remuxVideo(e,t,r,s){let n=e.inputTimeScale,a=e.samples,o=[],l=a.length,d=this._initPTS,u=this.nextAvcDts,c=8,h=this.videoSampleDuration,f,m,p=Number.POSITIVE_INFINITY,g=Number.NEGATIVE_INFINITY,E=!1;if(!r||u===null){let W=t*n,G=a[0].pts-Kt(a[0].dts,a[0].pts);gn&&u!==null&&Math.abs(W-G-u)<15e3?r=!0:u=W-G}let b=d.baseTime*n/d.timescale;for(let W=0;W
/gi,`
`)}var um=class{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new om,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){let t=this;e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));function r(){let n=t.buffer,a=0;for(n=sy(n);a=s&&n(t,r,a.flush(),e)):n(t,r,u,e),l()}).catch(()=>Promise.reject());return l()}};function qL(i,e){let t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(tt({},i.headers))};return i.rangeEnd&&t.headers.set("Range","bytes="+i.rangeStart+"-"+String(i.rangeEnd-1)),t}function jL(i){let e=YL.exec(i);if(e)return parseInt(e[2])-parseInt(e[1])+1}function zL(i){let e=i.get("Content-Range");if(e){let r=jL(e);if(q(r))return r}let t=i.get("Content-Length");if(t)return parseInt(t)}function XL(i,e){return new self.Request(i.url,e)}var bm=class extends Error{constructor(e,t,r){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=r}},QL=/\s/,ZL={newCue(i,e,t,r){let s=[],n,a,o,l,d,u=self.VTTCue||self.TextTrackCue;for(let h=0;h${i.dialog.title}
`:tr``}