@mux/mux-player 2.7.0 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,11 @@
1
- "use strict";(()=>{var rh=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)};var Ee=(i,e,t)=>(rh(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)},Vt=(i,e,t,r)=>(rh(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t);var Qe=(i,e,t)=>(rh(i,e,"access private method"),t);var sn=class{addEventListener(){}removeEventListener(){}dispatchEvent(e){return!0}};if(typeof DocumentFragment=="undefined"){class i extends sn{}globalThis.DocumentFragment=i}var aa=class extends sn{},sh=class extends sn{},R1={get(i){},define(i,e,t){},upgrade(i){},whenDefined(i){return Promise.resolve(aa)}},oa,nh=class{constructor(e,t={}){Xe(this,oa,void 0);Vt(this,oa,t==null?void 0:t.detail)}get detail(){return Ee(this,oa)}initCustomEvent(){}};oa=new WeakMap;function w1(i,e){return new aa}var gv={document:{createElement:w1},DocumentFragment,customElements:R1,CustomEvent:nh,EventTarget:sn,HTMLElement:aa,HTMLVideoElement:sh},vv=typeof window=="undefined"||typeof globalThis.customElements=="undefined",$e=vv?gv:globalThis,Ft=vv?gv.document:globalThis.document;var F={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"},ee={MEDIA_CHROME_ATTRIBUTES:"mediachromeattributes",MEDIA_CONTROLLER:"mediacontroller"},ah={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_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"},Ev=Object.entries(ah),b=Ev.reduce((i,[e,t])=>(i[e]=`${t.toLowerCase()}`,i),{}),ir=Ev.reduce((i,[e,t])=>(i[e]=`${t.toLowerCase()}`,i),{USER_INACTIVE:"userinactivechange",BREAKPOINTS_CHANGE:"breakpointchange",BREAKPOINTS_COMPUTED:"breakpointscomputed"}),BM=Object.entries(ir).reduce((i,[e,t])=>{let r=b[e];return r&&(i[t]=r),i},{userinactivechange:"userinactive"}),bv=Object.entries(b).reduce((i,[e,t])=>{let r=ir[e];return r&&(i[t]=r),i},{userinactive:"userinactivechange"}),si={SUBTITLES:"subtitles",CAPTIONS:"captions",DESCRIPTIONS:"descriptions",CHAPTERS:"chapters",METADATA:"metadata"},Er={DISABLED:"disabled",HIDDEN:"hidden",SHOWING:"showing"};var oh={MOUSE:"mouse",PEN:"pen",TOUCH:"touch"},Bt={UNAVAILABLE:"unavailable",UNSUPPORTED:"unsupported"},ni={LIVE:"live",ON_DEMAND:"on-demand",UNKNOWN:"unknown"};var yv={INLINE:"inline",FULLSCREEN:"fullscreen",PICTURE_IN_PICTURE:"picture-in-picture"};var Ce={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"},De={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"},D1={...Ce,...De};function Tv(i){return i==null?void 0:i.map(M1).join(" ")}function qo(i){return i==null?void 0:i.split(/\s+/).map(P1)}function M1(i){if(i){let{id:e,width:t,height:r}=i;return[e,t,r].filter(s=>s!=null).join(":")}}function P1(i){if(i){let[e,t,r]=i.split(":");return{id:e,width:t,height:r}}}function _v(i){return i==null?void 0:i.map(O1).join(" ")}function Yo(i){return i==null?void 0:i.split(/\s+/).map(N1)}function O1(i){if(i){let{id:e,kind:t,language:r,label:s}=i;return[e,t,r,s].filter(n=>n!=null).join(":")}}function N1(i){if(i){let[e,t,r,s]=i.split(":");return{id:e,kind:t,language:r,label:s}}}function Av(i){return i.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase())}function Sv(i){return typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i)}function zo(i){return typeof i!="string"?!1:!isNaN(i)&&!isNaN(parseFloat(i))}var jo=i=>new Promise(e=>setTimeout(e,i));var xv=[{singular:"hour",plural:"hours"},{singular:"minute",plural:"minutes"},{singular:"second",plural:"seconds"}],U1=(i,e)=>{let t=i===1?xv[e].singular:xv[e].plural;return`${i} ${t}`},jr=i=>{if(!Sv(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&&U1(o,l)).filter(o=>o).join(", ")}${t?" remaining":""}`};function Ai(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 WM=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 Xo=class{addEventListener(){}removeEventListener(){}dispatchEvent(){return!0}},Qo=class extends Xo{},lh=class{observe(){}unobserve(){}disconnect(){}},Lv={createElement:function(){return new Zo.HTMLElement},createElementNS:function(){return new Zo.HTMLElement},addEventListener(){},removeEventListener(){},dispatchEvent(i){return!1}},Zo={ResizeObserver:lh,document:Lv,Node:Qo,HTMLElement:class extends Qo{},DocumentFragment:class extends Xo{},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}}},kv=typeof window=="undefined"||typeof window.customElements=="undefined",Iv=Object.keys(Zo).every(i=>i in globalThis),A=kv&&!Iv?Zo:globalThis,O=kv&&!Iv?Lv:globalThis.document;var Rv=new WeakMap,dh=i=>{let e=Rv.get(i);return e||Rv.set(i,e=new Set),e},wv=new A.ResizeObserver(i=>{for(let e of i)for(let t of dh(e.target))t(e)});function Kt(i,e){dh(i).add(e),wv.observe(i)}function Si(i,e){let t=dh(i);t.delete(e),t.size||wv.unobserve(i)}function qe(i){var e;return(e=Jo(i))!=null?e:ai(i,"media-controller")}function Jo(i){var e;let{MEDIA_CONTROLLER:t}=ee,r=i.getAttribute(t);if(r)return(e=Qr(i))==null?void 0:e.getElementById(r)}var el=(i,e,t=".value")=>{let r=i.querySelector(t);r&&(r.textContent=e)},B1=(i,e)=>{let t=`slot[name="${e}"]`,r=i.shadowRoot.querySelector(t);return r?r.children:[]},tl=(i,e)=>B1(i,e)[0],yt=(i,e)=>!i||!e?!1:i!=null&&i.contains(e)?!0:yt(i,e.getRootNode().host),ai=(i,e)=>{if(!i)return null;let t=i.closest(e);return t||ai(i.getRootNode().host,e)};function Xr(i=document){var e;let t=i==null?void 0:i.activeElement;return t?(e=Xr(t.shadowRoot))!=null?e:t:null}function Qr(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 Cv(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 Dv(i,e,t,r){let s=uh(t,r),n=uh(t,{x:i,y:e}),a=uh(r,{x:i,y:e});return n>s||a>s?n>a?1:0:n/s}function uh(i,e){return Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2))}function Te(i,e){let t=$1(i,r=>r===e);return t||ch(i,e)}function $1(i,e){var t;let r;for(r of i.querySelectorAll("style")){let s;try{s=(t=r.sheet)==null?void 0:t.cssRules}catch{continue}for(let n of s!=null?s:[])if(e(n.selectorText))return n}}function ch(i,e){var t,r;let s=(t=i.querySelectorAll("style"))!=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 ve(i,e,t=Number.NaN){let r=i.getAttribute(e);return r!=null?+r:t}function _e(i,e,t){let r=+t;if(t==null||Number.isNaN(r)){i.hasAttribute(e)&&i.removeAttribute(e);return}ve(i,e,void 0)!==r&&i.setAttribute(e,`${r}`)}function Le(i,e){return i.hasAttribute(e)}function Ae(i,e,t){if(t==null){i.hasAttribute(e)&&i.removeAttribute(e);return}Le(i,e)!=t&&i.toggleAttribute(e,t)}function ue(i,e,t=null){var r;return(r=i.getAttribute(e))!=null?r:t}function le(i,e,t){if(t==null){i.hasAttribute(e)&&i.removeAttribute(e);return}let r=`${t}`;ue(i,e,void 0)!==r&&i.setAttribute(e,r)}var Mv=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},br=(i,e,t)=>(Mv(i,e,"read from private field"),t?t.call(i):e.get(i)),H1=(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)},il=(i,e,t,r)=>(Mv(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),wt,Pv=O.createElement("template");Pv.innerHTML=`
1
+ "use strict";(()=>{var oh=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)};var Ee=(i,e,t)=>(oh(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)},Kt=(i,e,t,r)=>(oh(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t);var Qe=(i,e,t)=>(oh(i,e,"access private method"),t);var nn=class{addEventListener(){}removeEventListener(){}dispatchEvent(e){return!0}};if(typeof DocumentFragment=="undefined"){class i extends nn{}globalThis.DocumentFragment=i}var aa=class extends nn{},lh=class extends nn{},k1={get(i){},define(i,e,t){},upgrade(i){},whenDefined(i){return Promise.resolve(aa)}},oa,dh=class{constructor(e,t={}){Xe(this,oa,void 0);Kt(this,oa,t==null?void 0:t.detail)}get detail(){return Ee(this,oa)}initCustomEvent(){}};oa=new WeakMap;function I1(i,e){return new aa}var Ev={document:{createElement:I1},DocumentFragment,customElements:k1,CustomEvent:dh,EventTarget:nn,HTMLElement:aa,HTMLVideoElement:lh},bv=typeof window=="undefined"||typeof globalThis.customElements=="undefined",He=bv?Ev:globalThis,Ft=bv?Ev.document:globalThis.document;var B={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"},te={MEDIA_CHROME_ATTRIBUTES:"mediachromeattributes",MEDIA_CONTROLLER:"mediacontroller"},uh={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_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"},yv=Object.entries(uh),b=yv.reduce((i,[e,t])=>(i[e]=`${t.toLowerCase()}`,i),{}),ir=yv.reduce((i,[e,t])=>(i[e]=`${t.toLowerCase()}`,i),{USER_INACTIVE:"userinactivechange",BREAKPOINTS_CHANGE:"breakpointchange",BREAKPOINTS_COMPUTED:"breakpointscomputed"}),zM=Object.entries(ir).reduce((i,[e,t])=>{let r=b[e];return r&&(i[t]=r),i},{userinactivechange:"userinactive"}),Tv=Object.entries(b).reduce((i,[e,t])=>{let r=ir[e];return r&&(i[t]=r),i},{userinactive:"userinactivechange"}),si={SUBTITLES:"subtitles",CAPTIONS:"captions",DESCRIPTIONS:"descriptions",CHAPTERS:"chapters",METADATA:"metadata"},Er={DISABLED:"disabled",HIDDEN:"hidden",SHOWING:"showing"};var ch={MOUSE:"mouse",PEN:"pen",TOUCH:"touch"},Bt={UNAVAILABLE:"unavailable",UNSUPPORTED:"unsupported"},ni={LIVE:"live",ON_DEMAND:"on-demand",UNKNOWN:"unknown"};var _v={INLINE:"inline",FULLSCREEN:"fullscreen",PICTURE_IN_PICTURE:"picture-in-picture"};var De={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"},Me={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"},w1={...De,...Me};function Av(i){return i==null?void 0:i.map(C1).join(" ")}function qo(i){return i==null?void 0:i.split(/\s+/).map(D1)}function C1(i){if(i){let{id:e,width:t,height:r}=i;return[e,t,r].filter(s=>s!=null).join(":")}}function D1(i){if(i){let[e,t,r]=i.split(":");return{id:e,width:t,height:r}}}function Sv(i){return i==null?void 0:i.map(M1).join(" ")}function Yo(i){return i==null?void 0:i.split(/\s+/).map(P1)}function M1(i){if(i){let{id:e,kind:t,language:r,label:s}=i;return[e,t,r,s].filter(n=>n!=null).join(":")}}function P1(i){if(i){let[e,t,r,s]=i.split(":");return{id:e,kind:t,language:r,label:s}}}function xv(i){return i.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase())}function Lv(i){return typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i)}function zo(i){return typeof i!="string"?!1:!isNaN(i)&&!isNaN(parseFloat(i))}var jo=i=>new Promise(e=>setTimeout(e,i));var kv=[{singular:"hour",plural:"hours"},{singular:"minute",plural:"minutes"},{singular:"second",plural:"seconds"}],O1=(i,e)=>{let t=i===1?kv[e].singular:kv[e].plural;return`${i} ${t}`},Xr=i=>{if(!Lv(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&&O1(o,l)).filter(o=>o).join(", ")}${t?" remaining":""}`};function Ai(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 ZM=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 Xo=class{addEventListener(){}removeEventListener(){}dispatchEvent(){return!0}},Qo=class extends Xo{},hh=class{observe(){}unobserve(){}disconnect(){}},Iv={createElement:function(){return new Zo.HTMLElement},createElementNS:function(){return new Zo.HTMLElement},addEventListener(){},removeEventListener(){},dispatchEvent(i){return!1}},Zo={ResizeObserver:hh,document:Iv,Node:Qo,HTMLElement:class extends Qo{},DocumentFragment:class extends Xo{},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}}},Rv=typeof window=="undefined"||typeof window.customElements=="undefined",wv=Object.keys(Zo).every(i=>i in globalThis),_=Rv&&!wv?Zo:globalThis,O=Rv&&!wv?Iv:globalThis.document;var Cv=new WeakMap,fh=i=>{let e=Cv.get(i);return e||Cv.set(i,e=new Set),e},Dv=new _.ResizeObserver(i=>{for(let e of i)for(let t of fh(e.target))t(e)});function Vt(i,e){fh(i).add(e),Dv.observe(i)}function Si(i,e){let t=fh(i);t.delete(e),t.size||Dv.unobserve(i)}function Ye(i){var e;return(e=Jo(i))!=null?e:ai(i,"media-controller")}function Jo(i){var e;let{MEDIA_CONTROLLER:t}=te,r=i.getAttribute(t);if(r)return(e=Zr(i))==null?void 0:e.getElementById(r)}var el=(i,e,t=".value")=>{let r=i.querySelector(t);r&&(r.textContent=e)},U1=(i,e)=>{let t=`slot[name="${e}"]`,r=i.shadowRoot.querySelector(t);return r?r.children:[]},tl=(i,e)=>U1(i,e)[0],yt=(i,e)=>!i||!e?!1:i!=null&&i.contains(e)?!0:yt(i,e.getRootNode().host),ai=(i,e)=>{if(!i)return null;let t=i.closest(e);return t||ai(i.getRootNode().host,e)};function Qr(i=document){var e;let t=i==null?void 0:i.activeElement;return t?(e=Qr(t.shadowRoot))!=null?e:t:null}function Zr(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 Mv(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 Pv(i,e,t,r){let s=mh(t,r),n=mh(t,{x:i,y:e}),a=mh(r,{x:i,y:e});return n>s||a>s?n>a?1:0:n/s}function mh(i,e){return Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2))}function Te(i,e){let t=F1(i,r=>r===e);return t||ph(i,e)}function F1(i,e){var t;let r;for(r of i.querySelectorAll("style")){let s;try{s=(t=r.sheet)==null?void 0:t.cssRules}catch{continue}for(let n of s!=null?s:[])if(e(n.selectorText))return n}}function ph(i,e){var t,r;let s=(t=i.querySelectorAll("style"))!=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 ve(i,e,t=Number.NaN){let r=i.getAttribute(e);return r!=null?+r:t}function _e(i,e,t){let r=+t;if(t==null||Number.isNaN(r)){i.hasAttribute(e)&&i.removeAttribute(e);return}ve(i,e,void 0)!==r&&i.setAttribute(e,`${r}`)}function Le(i,e){return i.hasAttribute(e)}function Ae(i,e,t){if(t==null){i.hasAttribute(e)&&i.removeAttribute(e);return}Le(i,e)!=t&&i.toggleAttribute(e,t)}function ue(i,e,t=null){var r;return(r=i.getAttribute(e))!=null?r:t}function le(i,e,t){if(t==null){i.hasAttribute(e)&&i.removeAttribute(e);return}let r=`${t}`;ue(i,e,void 0)!==r&&i.setAttribute(e,r)}var Ov=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},br=(i,e,t)=>(Ov(i,e,"read from private field"),t?t.call(i):e.get(i)),B1=(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)},il=(i,e,t,r)=>(Ov(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),wt,Nv=O.createElement("template");Nv.innerHTML=`
2
2
  <style>
3
3
  :host {
4
4
  display: var(--media-control-display, var(--media-gesture-receiver-display, inline-block));
5
5
  box-sizing: border-box;
6
6
  }
7
7
  </style>
8
- `;var hh=class extends A.HTMLElement{constructor(e={}){if(super(),H1(this,wt,void 0),!this.shadowRoot){let t=this.attachShadow({mode:"open"}),r=Pv.content.cloneNode(!0);this.nativeEl=r;let s=e.slotTemplate;s||(s=O.createElement("template"),s.innerHTML=`<slot>${e.defaultContent||""}</slot>`),this.nativeEl.appendChild(s.content.cloneNode(!0)),t.appendChild(r)}}static get observedAttributes(){return[ee.MEDIA_CONTROLLER,b.MEDIA_PAUSED]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===ee.MEDIA_CONTROLLER&&(t&&((n=(s=br(this,wt))==null?void 0:s.unassociateElement)==null||n.call(s,this),il(this,wt,null)),r&&this.isConnected&&(il(this,wt,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=br(this,wt))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r,s;this.tabIndex=-1,this.setAttribute("aria-hidden","true"),il(this,wt,G1(this)),this.getAttribute(ee.MEDIA_CONTROLLER)&&((t=(e=br(this,wt))==null?void 0:e.associateElement)==null||t.call(e,this)),(r=br(this,wt))==null||r.addEventListener("pointerdown",this),(s=br(this,wt))==null||s.addEventListener("click",this)}disconnectedCallback(){var e,t,r,s;this.getAttribute(ee.MEDIA_CONTROLLER)&&((t=(e=br(this,wt))==null?void 0:e.unassociateElement)==null||t.call(e,this)),(r=br(this,wt))==null||r.removeEventListener("pointerdown",this),(s=br(this,wt))==null||s.removeEventListener("click",this),il(this,wt,null)}handleEvent(e){var t;let r=(t=e.composedPath())==null?void 0:t[0];if(["video","media-controller"].includes(r==null?void 0:r.localName)){if(e.type==="pointerdown")this._pointerType=e.pointerType;else if(e.type==="click"){let{clientX:n,clientY:a}=e,{left:o,top:l,width:d,height:u}=this.getBoundingClientRect(),c=n-o,h=a-l;if(c<0||h<0||c>d||h>u||d===0&&u===0)return;let{pointerType:f=this._pointerType}=e;if(this._pointerType=void 0,f===oh.TOUCH){this.handleTap(e);return}else if(f===oh.MOUSE){this.handleMouseClick(e);return}}}}get mediaPaused(){return Le(this,b.MEDIA_PAUSED)}set mediaPaused(e){Ae(this,b.MEDIA_PAUSED,e)}handleTap(e){}handleMouseClick(e){let t=this.mediaPaused?F.MEDIA_PLAY_REQUEST:F.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new A.CustomEvent(t,{composed:!0,bubbles:!0}))}};wt=new WeakMap;function G1(i){var e;let t=i.getAttribute(ee.MEDIA_CONTROLLER);return t?(e=i.getRootNode())==null?void 0:e.getElementById(t):ai(i,"media-controller")}A.customElements.get("media-gesture-receiver")||A.customElements.define("media-gesture-receiver",hh);var W1=Object.defineProperty,V1=(i,e,t)=>e in i?W1(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,K1=(i,e,t)=>(V1(i,typeof e!="symbol"?e+"":e,t),t),vh=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},mh=(i,e,t)=>(vh(i,e,"read from private field"),t?t.call(i):e.get(i)),Zr=(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)},fh=(i,e,t,r)=>(vh(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),oi=(i,e,t)=>(vh(i,e,"access private method"),t),rl,nn,ph,Ov,gh,Nv,la,sl,nl,Eh,an,da,fe={AUDIO:"audio",AUTOHIDE:"autohide",BREAKPOINTS:"breakpoints",GESTURES_DISABLED:"gesturesdisabled",KEYBOARD_CONTROL:"keyboardcontrol",NO_AUTOHIDE:"noautohide",USER_INACTIVE:"userinactive"},Uv=O.createElement("template");Uv.innerHTML=`
8
+ `;var gh=class extends _.HTMLElement{constructor(e={}){if(super(),B1(this,wt,void 0),!this.shadowRoot){let t=this.attachShadow({mode:"open"}),r=Nv.content.cloneNode(!0);this.nativeEl=r;let s=e.slotTemplate;s||(s=O.createElement("template"),s.innerHTML=`<slot>${e.defaultContent||""}</slot>`),this.nativeEl.appendChild(s.content.cloneNode(!0)),t.appendChild(r)}}static get observedAttributes(){return[te.MEDIA_CONTROLLER,b.MEDIA_PAUSED]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===te.MEDIA_CONTROLLER&&(t&&((n=(s=br(this,wt))==null?void 0:s.unassociateElement)==null||n.call(s,this),il(this,wt,null)),r&&this.isConnected&&(il(this,wt,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=br(this,wt))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r,s;this.tabIndex=-1,this.setAttribute("aria-hidden","true"),il(this,wt,$1(this)),this.getAttribute(te.MEDIA_CONTROLLER)&&((t=(e=br(this,wt))==null?void 0:e.associateElement)==null||t.call(e,this)),(r=br(this,wt))==null||r.addEventListener("pointerdown",this),(s=br(this,wt))==null||s.addEventListener("click",this)}disconnectedCallback(){var e,t,r,s;this.getAttribute(te.MEDIA_CONTROLLER)&&((t=(e=br(this,wt))==null?void 0:e.unassociateElement)==null||t.call(e,this)),(r=br(this,wt))==null||r.removeEventListener("pointerdown",this),(s=br(this,wt))==null||s.removeEventListener("click",this),il(this,wt,null)}handleEvent(e){var t;let r=(t=e.composedPath())==null?void 0:t[0];if(["video","media-controller"].includes(r==null?void 0:r.localName)){if(e.type==="pointerdown")this._pointerType=e.pointerType;else if(e.type==="click"){let{clientX:n,clientY:a}=e,{left:o,top:l,width:d,height:u}=this.getBoundingClientRect(),c=n-o,h=a-l;if(c<0||h<0||c>d||h>u||d===0&&u===0)return;let{pointerType:f=this._pointerType}=e;if(this._pointerType=void 0,f===ch.TOUCH){this.handleTap(e);return}else if(f===ch.MOUSE){this.handleMouseClick(e);return}}}}get mediaPaused(){return Le(this,b.MEDIA_PAUSED)}set mediaPaused(e){Ae(this,b.MEDIA_PAUSED,e)}handleTap(e){}handleMouseClick(e){let t=this.mediaPaused?B.MEDIA_PLAY_REQUEST:B.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new _.CustomEvent(t,{composed:!0,bubbles:!0}))}};wt=new WeakMap;function $1(i){var e;let t=i.getAttribute(te.MEDIA_CONTROLLER);return t?(e=i.getRootNode())==null?void 0:e.getElementById(t):ai(i,"media-controller")}_.customElements.get("media-gesture-receiver")||_.customElements.define("media-gesture-receiver",gh);var H1=Object.defineProperty,G1=(i,e,t)=>e in i?H1(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,W1=(i,e,t)=>(G1(i,typeof e!="symbol"?e+"":e,t),t),Th=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Eh=(i,e,t)=>(Th(i,e,"read from private field"),t?t.call(i):e.get(i)),Jr=(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)},vh=(i,e,t,r)=>(Th(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),oi=(i,e,t)=>(Th(i,e,"access private method"),t),rl,an,bh,Uv,yh,Fv,la,sl,nl,_h,on,da,fe={AUDIO:"audio",AUTOHIDE:"autohide",BREAKPOINTS:"breakpoints",GESTURES_DISABLED:"gesturesdisabled",KEYBOARD_CONTROL:"keyboardcontrol",NO_AUTOHIDE:"noautohide",USER_INACTIVE:"userinactive"},Bv=O.createElement("template");Bv.innerHTML=`
9
9
  <style>
10
10
 
11
11
  :host([${b.MEDIA_IS_FULLSCREEN}]) ::slotted([slot=media]) {
@@ -142,7 +142,7 @@
142
142
 
143
143
  <slot part="bottom chrome"></slot>
144
144
  </span>
145
- `;var q1=Object.values(b),Y1="sm:384 md:576 lg:768 xl:960";function z1(i){j1(i.target,i.contentRect.width)}function j1(i,e){var t;if(!i.isConnected)return;let r=(t=i.getAttribute(fe.BREAKPOINTS))!=null?t:Y1,s=X1(r),n=Q1(s,e),a=!1;if(Object.keys(s).forEach(o=>{if(n.includes(o)){i.hasAttribute(`breakpoint${o}`)||(i.setAttribute(`breakpoint${o}`,""),a=!0);return}i.hasAttribute(`breakpoint${o}`)&&(i.removeAttribute(`breakpoint${o}`),a=!0)}),a){let o=new CustomEvent(ir.BREAKPOINTS_CHANGE,{detail:n});i.dispatchEvent(o)}}function X1(i){let e=i.split(/\s+/);return Object.fromEntries(e.map(t=>t.split(":")))}function Q1(i,e){return Object.keys(i).filter(t=>e>=i[t])}var ua=class extends A.HTMLElement{constructor(){super(),Zr(this,ph),Zr(this,gh),Zr(this,la),Zr(this,nl),Zr(this,an),Zr(this,rl,0),Zr(this,nn,void 0),K1(this,"breakpointsComputed",!1),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Uv.content.cloneNode(!0)));let e=a=>{let o=this.media;for(let l of a)l.type==="childList"&&(l.removedNodes.forEach(d=>{if(d.slot=="media"&&l.target==this){let u=l.previousSibling&&l.previousSibling.previousElementSibling;if(!u||!o)this.mediaUnsetCallback(d);else{let c=u.slot!=="media";for(;(u=u.previousSibling)!==null;)u.slot=="media"&&(c=!1);c&&this.mediaUnsetCallback(d)}}}),o&&l.addedNodes.forEach(d=>{d===o&&this.handleMediaUpdated(o)}))};new MutationObserver(e).observe(this,{childList:!0,subtree:!0});let r=!1;Kt(this,a=>{r||(setTimeout(()=>{z1(a),r=!1,this.breakpointsComputed||(this.breakpointsComputed=!0,this.dispatchEvent(new CustomEvent(ir.BREAKPOINTS_COMPUTED,{bubbles:!0,composed:!0})))},0),r=!0)});let n=this.querySelector(":scope > slot[slot=media]");n&&n.addEventListener("slotchange",()=>{if(!n.assignedElements({flatten:!0}).length){mh(this,nn)&&this.mediaUnsetCallback(mh(this,nn));return}this.handleMediaUpdated(this.media)})}static get observedAttributes(){return[fe.AUTOHIDE,fe.GESTURES_DISABLED].concat(q1).filter(e=>![b.MEDIA_RENDITION_LIST,b.MEDIA_AUDIO_TRACK_LIST,b.MEDIA_CHAPTERS_CUES].includes(e))}attributeChangedCallback(e,t,r){e.toLowerCase()==fe.AUTOHIDE&&(this.autohide=r)}get media(){let e=this.querySelector(":scope > [slot=media]");return(e==null?void 0:e.nodeName)=="SLOT"&&(e=e.assignedElements({flatten:!0})[0]),e}async handleMediaUpdated(e){e&&(fh(this,nn,e),e.localName.includes("-")&&await A.customElements.whenDefined(e.localName),this.mediaSetCallback(e))}connectedCallback(){var e;let r=this.getAttribute(fe.AUDIO)!=null?Ce.AUDIO_PLAYER():Ce.VIDEO_PLAYER();this.setAttribute("role","region"),this.setAttribute("aria-label",r),this.handleMediaUpdated(this.media),this.setAttribute(fe.USER_INACTIVE,""),this.addEventListener("pointerdown",this),this.addEventListener("pointermove",this),this.addEventListener("pointerup",this),this.addEventListener("mouseleave",this),this.addEventListener("keyup",this),(e=A.window)==null||e.addEventListener("mouseup",this)}disconnectedCallback(){var e;this.media&&this.mediaUnsetCallback(this.media),(e=A.window)==null||e.removeEventListener("mouseup",this)}mediaSetCallback(e){}mediaUnsetCallback(e){fh(this,nn,null)}handleEvent(e){switch(e.type){case"pointerdown":fh(this,rl,e.timeStamp);break;case"pointermove":oi(this,ph,Ov).call(this,e);break;case"pointerup":oi(this,gh,Nv).call(this,e);break;case"mouseleave":oi(this,la,sl).call(this);break;case"mouseup":this.removeAttribute(fe.KEYBOARD_CONTROL);break;case"keyup":oi(this,an,da).call(this),this.setAttribute(fe.KEYBOARD_CONTROL,"");break}}set autohide(e){e=Number(e),this._autohide=isNaN(e)?0:e}get autohide(){return this._autohide===void 0?2:this._autohide}};rl=new WeakMap;nn=new WeakMap;ph=new WeakSet;Ov=function(i){i.pointerType!=="mouse"&&i.timeStamp-mh(this,rl)<250||(oi(this,nl,Eh).call(this),clearTimeout(this._inactiveTimeout),[this,this.media].includes(i.target)&&oi(this,an,da).call(this))};gh=new WeakSet;Nv=function(i){if(i.pointerType==="touch"){let e=!this.hasAttribute(fe.USER_INACTIVE);[this,this.media].includes(i.target)&&e?oi(this,la,sl).call(this):oi(this,an,da).call(this)}else i.composedPath().some(e=>["media-play-button","media-fullscreen-button"].includes(e==null?void 0:e.localName))&&oi(this,an,da).call(this)};la=new WeakSet;sl=function(){if(this.autohide<0||this.hasAttribute(fe.USER_INACTIVE))return;this.setAttribute(fe.USER_INACTIVE,"");let i=new A.CustomEvent(ir.USER_INACTIVE,{composed:!0,bubbles:!0,detail:!0});this.dispatchEvent(i)};nl=new WeakSet;Eh=function(){if(!this.hasAttribute(fe.USER_INACTIVE))return;this.removeAttribute(fe.USER_INACTIVE);let i=new A.CustomEvent(ir.USER_INACTIVE,{composed:!0,bubbles:!0,detail:!1});this.dispatchEvent(i)};an=new WeakSet;da=function(){oi(this,nl,Eh).call(this),clearTimeout(this._inactiveTimeout),!(this.autohide<0)&&(this._inactiveTimeout=setTimeout(()=>{oi(this,la,sl).call(this)},this.autohide*1e3))};A.customElements.get("media-container")||A.customElements.define("media-container",ua);var Fv=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},at=(i,e,t)=>(Fv(i,e,"read from private field"),t?t.call(i):e.get(i)),ca=(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)},al=(i,e,t,r)=>(Fv(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),on,ln,ol,Jr,rr,yr,qt=class{constructor(e,t,{defaultValue:r}={defaultValue:void 0}){ca(this,rr),ca(this,on,void 0),ca(this,ln,void 0),ca(this,ol,void 0),ca(this,Jr,new Set),al(this,on,e),al(this,ln,t),al(this,ol,new Set(r))}[Symbol.iterator](){return at(this,rr,yr).values()}get length(){return at(this,rr,yr).size}get value(){var e;return(e=[...at(this,rr,yr)].join(" "))!=null?e:""}set value(e){var t;e!==this.value&&(al(this,Jr,new Set),this.add(...(t=e==null?void 0:e.split(" "))!=null?t:[]))}toString(){return this.value}item(e){return[...at(this,rr,yr)][e]}values(){return at(this,rr,yr).values()}forEach(e){at(this,rr,yr).forEach(e)}add(...e){var t,r;e.forEach(s=>at(this,Jr).add(s)),!(this.value===""&&!((t=at(this,on))!=null&&t.hasAttribute(`${at(this,ln)}`)))&&((r=at(this,on))==null||r.setAttribute(`${at(this,ln)}`,`${this.value}`))}remove(...e){var t;e.forEach(r=>at(this,Jr).delete(r)),(t=at(this,on))==null||t.setAttribute(`${at(this,ln)}`,`${this.value}`)}contains(e){return at(this,rr,yr).has(e)}toggle(e,t){return typeof t!="undefined"?t?(this.add(e),!0):(this.remove(e),!1):this.contains(e)?(this.remove(e),!1):(this.add(e),!0)}replace(e,t){return this.remove(e),this.add(t),e===t}};on=new WeakMap;ln=new WeakMap;ol=new WeakMap;Jr=new WeakMap;rr=new WeakSet;yr=function(){return at(this,Jr).size?at(this,Jr):at(this,ol)};var Z1=(i="")=>i.split(/\s+/),Bv=(i="")=>{let[e,t,r]=i.split(":"),s=r?decodeURIComponent(r):void 0;return e=e==="cc"?"captions":"subtitles",{kind:e,language:t,label:s}},sr=(i="",e={})=>Z1(i).map(t=>{let r=Bv(t);return{...e,...r}}),bh=i=>i?Array.isArray(i)?i.map(e=>typeof e=="string"?Bv(e):e):typeof i=="string"?sr(i):[i]:[],es=({kind:i,label:e,language:t}={kind:"subtitles"})=>e?`${i==="captions"?"cc":"sb"}:${t}:${encodeURIComponent(e)}`:t,li=(i=[])=>Array.prototype.map.call(i,es).join(" "),J1=(i,e)=>t=>t[i]===e,$v=i=>{let e=Object.entries(i).map(([t,r])=>J1(t,r));return t=>e.every(r=>r(t))},ts=(i,e=[],t=[])=>{let r=bh(t).map($v),s=n=>r.some(a=>a(n));Array.from(e).filter(s).forEach(n=>{n.mode=i})},is=(i,e=()=>!0)=>{if(!(i!=null&&i.textTracks))return[];let t=typeof e=="function"?e:$v(e);return Array.from(i.textTracks).filter(t)},ll=i=>{var e;return!!((e=i.mediaSubtitlesShowing)!=null&&e.length)||i.hasAttribute(b.MEDIA_SUBTITLES_SHOWING)};var Oe={enter:"requestFullscreen",exit:"exitFullscreen",rootEvents:["fullscreenchange"],mediaEvents:[],element:"fullscreenElement",error:"fullscreenerror",enabled:"fullscreenEnabled"};O.fullscreenElement===void 0&&(Oe.enter="webkitRequestFullScreen",Oe.exit=O.webkitExitFullscreen!=null?"webkitExitFullscreen":"webkitCancelFullScreen",Oe.rootEvents=["webkitfullscreenchange"],Oe.mediaEvents=["webkitbeginfullscreen","webkitendfullscreen"],Oe.element="webkitFullscreenElement",Oe.error="webkitfullscreenerror",Oe.enabled="webkitFullscreenEnabled");var dl,yh=()=>{var i,e;return dl||(dl=(e=(i=O)==null?void 0:i.createElement)==null?void 0:e.call(i,"video"),dl)},Hv=async(i=yh())=>{if(!i)return!1;let e=i.volume;return i.volume=e/2+.1,await jo(0),i.volume!==e},eS=/.*Version\/.*Safari\/.*/.test(A.navigator.userAgent),Th=(i=yh())=>A.matchMedia("(display-mode: standalone)").matches&&eS?!1:typeof(i==null?void 0:i.requestPictureInPicture)=="function",_h=(i=yh())=>{let e=O[Oe.enabled];return!e&&i&&(e="webkitSupportsFullscreen"in i),e},Gv=_h(),Wv=Th(),Vv=!!A.WebKitPlaybackTargetAvailabilityEvent,Kv=!!A.chrome;var dn=i=>is(i.media,e=>[si.SUBTITLES,si.CAPTIONS].includes(e.kind)).sort((e,t)=>e.kind>=t.kind?1:-1),Ah=i=>is(i.media,e=>e.mode===Er.SHOWING&&[si.SUBTITLES,si.CAPTIONS].includes(e.kind)),ul=(i,e)=>{let t=dn(i),r=Ah(i),s=!!r.length;if(t.length){if(e===!1||s&&e!==!0)ts(Er.DISABLED,t,r);else if(e===!0||!s&&e!==!1){let n=t[0],{options:a}=i;if(!(a!=null&&a.noSubtitlesLangPref)){let u=globalThis.localStorage.getItem("media-chrome-pref-subtitles-lang"),c=u?[u,...globalThis.navigator.languages]:globalThis.navigator.languages,h=t.filter(f=>c.some(m=>f.language.toLowerCase().startsWith(m.split("-")[0]))).sort((f,m)=>{let p=c.findIndex(E=>f.language.toLowerCase().startsWith(E.split("-")[0])),g=c.findIndex(E=>m.language.toLowerCase().startsWith(E.split("-")[0]));return p-g});h[0]&&(n=h[0])}let{language:o,label:l,kind:d}=n;ts(Er.DISABLED,t,r),ts(Er.SHOWING,t,[{language:o,label:l,kind:d}])}}},cl=(i,e)=>i===e?!0:typeof i!=typeof e?!1:typeof i=="number"&&Number.isNaN(i)&&Number.isNaN(e)?!0:typeof i!="object"?!1:Array.isArray(i)?tS(i,e):Object.entries(i).every(([t,r])=>t in e&&cl(r,e[t])),tS=(i,e)=>{let t=Array.isArray(i),r=Array.isArray(e);return t!==r?!1:t||r?i.length!==e.length?!1:i.every((s,n)=>cl(s,e[n])):!0};var iS=Object.values(ni),hl,rS=Hv().then(i=>(hl=i,hl)),qv=async(...i)=>{await Promise.all(i.filter(e=>e).map(async e=>{if(!("localName"in e&&e instanceof A.HTMLElement))return;let t=e.localName;if(!t.includes("-"))return;let r=A.customElements.get(t);r&&e instanceof r||(await A.customElements.whenDefined(t),A.customElements.upgrade(e))}))},ha={mediaPaused:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.paused)!=null?e:!0},set(i,e){var t;let{media:r}=e;r&&(i?r.pause():(t=r.play())==null||t.catch(()=>{}))},mediaEvents:["play","playing","pause","emptied"]},mediaHasPlayed:{get(i,e){let{media:t}=i;return t?e?e.type==="playing":!t.paused:!1},mediaEvents:["playing","emptied"]},mediaEnded:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.ended)!=null?e:!1},mediaEvents:["seeked","ended","emptied"]},mediaPlaybackRate:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.playbackRate)!=null?e:1},set(i,e){let{media:t}=e;t&&Number.isFinite(+i)&&(t.playbackRate=+i)},mediaEvents:["ratechange","loadstart"]},mediaMuted:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.muted)!=null?e:!1},set(i,e){let{media:t}=e;t&&(t.muted=i)},mediaEvents:["volumechange"]},mediaVolume:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.volume)!=null?e:1},set(i,e){let{media:t}=e;if(t){try{i==null?A.localStorage.removeItem("media-chrome-pref-volume"):A.localStorage.setItem("media-chrome-pref-volume",i.toString())}catch{}Number.isFinite(+i)&&(t.volume=+i)}},mediaEvents:["volumechange"],stateOwnersUpdateHandlers:[(i,e)=>{let{options:{noVolumePref:t}}=e;if(!t)try{let r=A.localStorage.getItem("media-chrome-pref-volume");if(r==null)return;ha.mediaVolume.set(+r,e),i(r)}catch(r){console.debug("Error getting volume pref",r)}}]},mediaVolumeLevel:{get(i){let{media:e}=i;return typeof(e==null?void 0:e.volume)=="undefined"?"high":e.muted||e.volume===0?"off":e.volume<.5?"low":e.volume<.75?"medium":"high"},mediaEvents:["volumechange"]},mediaCurrentTime:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.currentTime)!=null?e:0},set(i,e){let{media:t}=e;!t||t.readyState===0||(t.currentTime=i)},mediaEvents:["timeupdate","loadedmetadata"]},mediaDuration:{get(i){let{media:e,options:{defaultDuration:t}={}}=i;return t&&(!e||!e.duration||Number.isNaN(e.duration)||!Number.isFinite(e.duration))?t:Number.isFinite(e==null?void 0:e.duration)?e.duration:Number.NaN},mediaEvents:["durationchange","loadedmetadata","emptied"]},mediaLoading:{get(i){let{media:e}=i;return(e==null?void 0:e.readyState)<3},mediaEvents:["waiting","playing","emptied"]},mediaSeekable:{get(i){var e;let{media:t}=i;if(!((e=t==null?void 0:t.seekable)!=null&&e.length))return;let r=t.seekable.start(0),s=t.seekable.end(t.seekable.length-1);if(!(!r&&!s))return[Number(r.toFixed(3)),Number(s.toFixed(3))]},mediaEvents:["loadedmetadata","emptied","progress","seekablechange"]},mediaBuffered:{get(i){var e;let{media:t}=i,r=(e=t==null?void 0:t.buffered)!=null?e:[];return Array.from(r).map((s,n)=>[Number(r.start(n).toFixed(3)),Number(r.end(n).toFixed(3))])},mediaEvents:["progress","emptied"]},mediaStreamType:{get(i){let{media:e,options:{defaultStreamType:t}={}}=i,r=[ni.LIVE,ni.ON_DEMAND].includes(t)?t:void 0;if(!e)return r;let{streamType:s}=e;if(iS.includes(s))return s===ni.UNKNOWN?r:s;let n=e.duration;return n===1/0?ni.LIVE:Number.isFinite(n)?ni.ON_DEMAND:r},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange"]},mediaTargetLiveWindow:{get(i){let{media:e}=i;if(!e)return Number.NaN;let{targetLiveWindow:t}=e,r=ha.mediaStreamType.get(i);return(t==null||Number.isNaN(t))&&r===ni.LIVE?0:t},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange","targetlivewindowchange"]},mediaTimeIsLive:{get(i){let{media:e,options:{liveEdgeOffset:t=10}={}}=i;if(!e)return!1;if(typeof e.liveEdgeStart=="number")return Number.isNaN(e.liveEdgeStart)?!1:e.currentTime>=e.liveEdgeStart;if(!(ha.mediaStreamType.get(i)===ni.LIVE))return!1;let s=e.seekable;if(!s)return!0;if(!s.length)return!1;let n=s.end(s.length-1)-t;return e.currentTime>=n},mediaEvents:["playing","timeupdate","progress","waiting","emptied"]},mediaSubtitlesList:{get(i){return dn(i).map(({kind:e,label:t,language:r})=>({kind:e,label:t,language:r}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack"]},mediaSubtitlesShowing:{get(i){return Ah(i).map(({kind:e,label:t,language:r})=>({kind:e,label:t,language:r}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack","change"],stateOwnersUpdateHandlers:[(i,e)=>{var t,r;let{media:s,options:n}=e;if(!s)return;let a=o=>{var l;!n.defaultSubtitles||o&&![si.CAPTIONS,si.SUBTITLES].includes((l=o==null?void 0:o.track)==null?void 0:l.kind)||ul(e,!0)};return(t=s.textTracks)==null||t.addEventListener("addtrack",a),(r=s.textTracks)==null||r.addEventListener("removetrack",a),a(),()=>{var o,l;(o=s.textTracks)==null||o.removeEventListener("addtrack",a),(l=s.textTracks)==null||l.removeEventListener("removetrack",a)}}]},mediaChaptersCues:{get(i){var e;let{media:t}=i;if(!t)return[];let[r]=is(t,{kind:si.CHAPTERS});return Array.from((e=r==null?void 0:r.cues)!=null?e:[]).map(({text:s,startTime:n,endTime:a})=>({text:s,startTime:n,endTime:a}))},mediaEvents:["loadstart","loadedmetadata"],textTracksEvents:["addtrack","removetrack","change"],stateOwnersUpdateHandlers:[(i,e)=>{let{media:t}=e;if(!t)return;let r=t.querySelector('track[kind="chapters"][default][src]');return r==null||r.addEventListener("load",i),()=>{r==null||r.removeEventListener("load",i)}}]},mediaIsPip:{get(i){var e,t;let{media:r,documentElement:s}=i;if(!r||!s||!s.pictureInPictureElement)return!1;if(s.pictureInPictureElement===r)return!0;if(s.pictureInPictureElement instanceof HTMLMediaElement)return(e=r.localName)!=null&&e.includes("-")?yt(r,s.pictureInPictureElement):!1;if(s.pictureInPictureElement.localName.includes("-")){let n=s.pictureInPictureElement.shadowRoot;for(;n!=null&&n.pictureInPictureElement;){if(n.pictureInPictureElement===r)return!0;n=(t=n.pictureInPictureElement)==null?void 0:t.shadowRoot}}return!1},set(i,e){let{media:t}=e;if(t)if(i){if(!O.pictureInPictureEnabled){console.warn("MediaChrome: Picture-in-picture is not enabled");return}if(!t.requestPictureInPicture){console.warn("MediaChrome: The current media does not support picture-in-picture");return}let r=()=>{console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a readyState > 0.")};t.requestPictureInPicture().catch(s=>{if(s.code===11){if(!t.src){console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a src set.");return}if(t.readyState===0&&t.preload==="none"){let n=()=>{t.removeEventListener("loadedmetadata",a),t.preload="none"},a=()=>{t.requestPictureInPicture().catch(r),n()};t.addEventListener("loadedmetadata",a),t.preload="metadata",setTimeout(()=>{t.readyState===0&&r(),n()},1e3)}else throw s}else throw s})}else O.pictureInPictureElement&&O.exitPictureInPicture()},mediaEvents:["enterpictureinpicture","leavepictureinpicture"]},mediaRenditionList:{get(i){var e;let{media:t}=i;return[...(e=t==null?void 0:t.videoRenditions)!=null?e:[]].map(r=>({...r}))},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},mediaRenditionSelected:{get(i){var e,t,r;let{media:s}=i;return(r=(t=s==null?void 0:s.videoRenditions)==null?void 0:t[(e=s.videoRenditions)==null?void 0:e.selectedIndex])==null?void 0:r.id},set(i,e){let{media:t}=e;if(!(t!=null&&t.videoRenditions)){console.warn("MediaController: Rendition selection not supported by this media.");return}let r=i,s=Array.prototype.findIndex.call(t.videoRenditions,n=>n.id==r);t.videoRenditions.selectedIndex!=s&&(t.videoRenditions.selectedIndex=s)},mediaEvents:["emptied"],videoRenditionsEvents:["addrendition","removerendition","change"]},mediaAudioTrackList:{get(i){var e;let{media:t}=i;return[...(e=t==null?void 0:t.audioTracks)!=null?e:[]]},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]},mediaAudioTrackEnabled:{get(i){var e,t;let{media:r}=i;return(t=[...(e=r==null?void 0:r.audioTracks)!=null?e:[]].find(s=>s.enabled))==null?void 0:t.id},set(i,e){let{media:t}=e;if(!(t!=null&&t.audioTracks)){console.warn("MediaChrome: Audio track selection not supported by this media.");return}let r=i;for(let s of t.audioTracks)s.enabled=r==s.id},mediaEvents:["emptied"],audioTracksEvents:["addtrack","removetrack","change"]},mediaIsFullscreen:{get(i){var e;let{media:t,documentElement:r,fullscreenElement:s=t}=i;if(!t||!r)return!1;if(!r[Oe.element])return"webkitDisplayingFullscreen"in t&&"webkitPresentationMode"in t?t.webkitDisplayingFullscreen&&t.webkitPresentationMode===yv.FULLSCREEN:!1;if(r[Oe.element]===s)return!0;if(r[Oe.element].localName.includes("-")){let n=r[Oe.element].shadowRoot;if(!(Oe.element in n))return yt(r[Oe.element],s);for(;n!=null&&n[Oe.element];){if(n[Oe.element]===s)return!0;n=(e=n[Oe.element])==null?void 0:e.shadowRoot}}return!1},set(i,e){var t,r;let{media:s,fullscreenElement:n,documentElement:a}=e;if(!i&&(a!=null&&a[Oe.exit])){let o=(t=a==null?void 0:a[Oe.exit])==null?void 0:t.call(a);o instanceof Promise&&o.catch(()=>{});return}if(n!=null&&n[Oe.enter]){let o=(r=n[Oe.enter])==null?void 0:r.call(n);o instanceof Promise&&o.catch(()=>{})}else s!=null&&s.webkitEnterFullscreen?s.webkitEnterFullscreen():s!=null&&s.requestFullscreen&&s.requestFullscreen()},rootEvents:Oe.rootEvents,mediaEvents:Oe.mediaEvents},mediaIsCasting:{get(i){var e;let{media:t}=i;return!(t!=null&&t.remote)||((e=t.remote)==null?void 0:e.state)==="disconnected"?!1:!!t.remote.state},set(i,e){var t,r;let{media:s}=e;if(s&&!(i&&((t=s.remote)==null?void 0:t.state)!=="disconnected")&&!(!i&&((r=s.remote)==null?void 0:r.state)!=="connected")){if(typeof s.remote.prompt!="function"){console.warn("MediaChrome: Casting is not supported in this environment");return}s.remote.prompt().catch(()=>{})}},remoteEvents:["connect","connecting","disconnect"]},mediaIsAirplaying:{get(){return!1},set(i,e){let{media:t}=e;if(t){if(!(t.webkitShowPlaybackTargetPicker&&A.WebKitPlaybackTargetAvailabilityEvent)){console.warn("MediaChrome: received a request to select AirPlay but AirPlay is not supported in this environment");return}t.webkitShowPlaybackTargetPicker()}},mediaEvents:["webkitcurrentplaybacktargetiswirelesschanged"]},mediaFullscreenUnavailable:{get(i){let{media:e}=i;if(!Gv||!_h(e))return Bt.UNSUPPORTED}},mediaPipUnavailable:{get(i){let{media:e}=i;if(!Wv||!Th(e))return Bt.UNSUPPORTED}},mediaVolumeUnavailable:{get(i){let{media:e}=i;if(hl===!1||(e==null?void 0:e.volume)==null)return Bt.UNSUPPORTED},stateOwnersUpdateHandlers:[i=>{hl==null&&rS.then(e=>i(e?void 0:Bt.UNSUPPORTED))}]},mediaCastUnavailable:{get(i,{availability:e="not-available"}={}){var t;let{media:r}=i;if(!Kv||!((t=r==null?void 0:r.remote)!=null&&t.state))return Bt.UNSUPPORTED;if(!(e==null||e==="available"))return Bt.UNAVAILABLE},stateOwnersUpdateHandlers:[(i,e)=>{var t;let{media:r}=e;return r?(r.disableRemotePlayback||r.hasAttribute("disableremoteplayback")||(t=r==null?void 0:r.remote)==null||t.watchAvailability(n=>{i({availability:n?"available":"not-available"})}).catch(n=>{n.name==="NotSupportedError"?i({availability:null}):i({availability:"not-available"})}),()=>{var n;(n=r==null?void 0:r.remote)==null||n.cancelWatchAvailability().catch(()=>{})}):void 0}]},mediaAirplayUnavailable:{get(i,e){if(!Vv)return Bt.UNSUPPORTED;if((e==null?void 0:e.availability)==="not-available")return Bt.UNAVAILABLE},mediaEvents:["webkitplaybacktargetavailabilitychanged"],stateOwnersUpdateHandlers:[(i,e)=>{var t;let{media:r}=e;return r?(r.disableRemotePlayback||r.hasAttribute("disableremoteplayback")||(t=r==null?void 0:r.remote)==null||t.watchAvailability(n=>{i({availability:n?"available":"not-available"})}).catch(n=>{n.name==="NotSupportedError"?i({availability:null}):i({availability:"not-available"})}),()=>{var n;(n=r==null?void 0:r.remote)==null||n.cancelWatchAvailability().catch(()=>{})}):void 0}]},mediaRenditionUnavailable:{get(i){var e;let{media:t}=i;if(!(t!=null&&t.videoRenditions))return Bt.UNSUPPORTED;if(!((e=t.videoRenditions)!=null&&e.length))return Bt.UNAVAILABLE},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},mediaAudioTrackUnavailable:{get(i){var e,t;let{media:r}=i;if(!(r!=null&&r.audioTracks))return Bt.UNSUPPORTED;if(((t=(e=r.audioTracks)==null?void 0:e.length)!=null?t:0)<=1)return Bt.UNAVAILABLE},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]}};var Yv={[F.MEDIA_PREVIEW_REQUEST](i,e,{detail:t}){var r,s,n;let{media:a}=e,o=t!=null?t:void 0,l,d;if(a&&o!=null){let[f]=is(a,{kind:si.METADATA,label:"thumbnails"}),m=Array.prototype.find.call((r=f==null?void 0:f.cues)!=null?r:[],(p,g,E)=>g===0?p.endTime>o:g===E.length-1?p.startTime<=o:p.startTime<=o&&p.endTime>o);if(m){let p=/'^(?:[a-z]+:)?\/\//i.test(m.text)||(s=a==null?void 0:a.querySelector('track[label="thumbnails"]'))==null?void 0:s.src,g=new URL(m.text,p);d=new URLSearchParams(g.hash).get("#xywh").split(",").map(T=>+T),l=g.href}}let u=i.mediaDuration.get(e),h=(n=i.mediaChaptersCues.get(e).find((f,m,p)=>m===p.length-1&&u===f.endTime?f.startTime<=o&&f.endTime>=o:f.startTime<=o&&f.endTime>o))==null?void 0:n.text;return t!=null&&h==null&&(h=""),{mediaPreviewTime:o,mediaPreviewImage:l,mediaPreviewCoords:d,mediaPreviewChapter:h}},[F.MEDIA_PAUSE_REQUEST](i,e){i["mediaPaused"].set(!0,e)},[F.MEDIA_PLAY_REQUEST](i,e){var t;let r="mediaPaused";if(i.mediaStreamType.get(e)===ni.LIVE){let a=!(i.mediaTargetLiveWindow.get(e)>0),o=(t=i.mediaSeekable.get(e))==null?void 0:t[1];a&&o&&i.mediaCurrentTime.set(o,e)}i[r].set(!1,e)},[F.MEDIA_PLAYBACK_RATE_REQUEST](i,e,{detail:t}){let r="mediaPlaybackRate",s=t;i[r].set(s,e)},[F.MEDIA_MUTE_REQUEST](i,e){i["mediaMuted"].set(!0,e)},[F.MEDIA_UNMUTE_REQUEST](i,e){let t="mediaMuted";i.mediaVolume.get(e)||i.mediaVolume.set(.25,e),i[t].set(!1,e)},[F.MEDIA_VOLUME_REQUEST](i,e,{detail:t}){let r="mediaVolume",s=t;s&&i.mediaMuted.get(e)&&i.mediaMuted.set(!1,e),i[r].set(s,e)},[F.MEDIA_SEEK_REQUEST](i,e,{detail:t}){let r="mediaCurrentTime",s=t;i[r].set(s,e)},[F.MEDIA_SEEK_TO_LIVE_REQUEST](i,e){var t;let r="mediaCurrentTime",s=(t=i.mediaSeekable.get(e))==null?void 0:t[1];Number.isNaN(Number(s))&&i[r].set(s,e)},[F.MEDIA_SHOW_SUBTITLES_REQUEST](i,e,{detail:t}){var r;let{options:s}=e,n=dn(e),a=bh(t),o=(r=a[0])==null?void 0:r.language;o&&!s.noSubtitlesLangPref&&A.localStorage.setItem("media-chrome-pref-subtitles-lang",o),ts(Er.SHOWING,n,a)},[F.MEDIA_DISABLE_SUBTITLES_REQUEST](i,e,{detail:t}){let r=dn(e),s=t!=null?t:[];ts(Er.DISABLED,r,s)},[F.MEDIA_TOGGLE_SUBTITLES_REQUEST](i,e,{detail:t}){ul(e,t)},[F.MEDIA_RENDITION_REQUEST](i,e,{detail:t}){let r="mediaRenditionSelected",s=t;i[r].set(s,e)},[F.MEDIA_AUDIO_TRACK_REQUEST](i,e,{detail:t}){let r="mediaAudioTrackEnabled",s=t;i[r].set(s,e)},[F.MEDIA_ENTER_PIP_REQUEST](i,e){let t="mediaIsPip";i.mediaIsFullscreen.get(e)&&i.mediaIsFullscreen.set(!1,e),i[t].set(!0,e)},[F.MEDIA_EXIT_PIP_REQUEST](i,e){i["mediaIsPip"].set(!1,e)},[F.MEDIA_ENTER_FULLSCREEN_REQUEST](i,e){let t="mediaIsFullscreen";i.mediaIsPip.get(e)&&i.mediaIsPip.set(!1,e),i[t].set(!0,e)},[F.MEDIA_EXIT_FULLSCREEN_REQUEST](i,e){i["mediaIsFullscreen"].set(!1,e)},[F.MEDIA_ENTER_CAST_REQUEST](i,e){let t="mediaIsCasting";i.mediaIsFullscreen.get(e)&&i.mediaIsFullscreen.set(!1,e),i[t].set(!0,e)},[F.MEDIA_EXIT_CAST_REQUEST](i,e){i["mediaIsCasting"].set(!1,e)},[F.MEDIA_AIRPLAY_REQUEST](i,e){i["mediaIsAirplaying"].set(!0,e)}};var sS=({media:i,fullscreenElement:e,documentElement:t,stateMediator:r=ha,requestMap:s=Yv,options:n={},monitorStateOwnersOnlyWithSubscriptions:a=!0})=>{let o=[],l={options:{...n}},d=Object.freeze({mediaPreviewTime:void 0,mediaPreviewImage:void 0,mediaPreviewCoords:void 0,mediaPreviewChapter:void 0}),u=p=>{p!=null&&(cl(p,d)||(d=Object.freeze({...d,...p}),o.forEach(g=>g(d))))},c=()=>{let p=Object.entries(r).reduce((g,[E,{get:T}])=>(g[E]=T(l),g),{});u(p)},h={},f,m=async(p,g)=>{var E,T,y,S,_,L,x,w,M,k,D,U,B,X,z,V;let se=!!f;if(f={...l,...f!=null?f:{},...p},se)return;await qv(...Object.values(p));let ae=o.length>0&&g===0&&a,W=l.media!==f.media,G=((E=l.media)==null?void 0:E.textTracks)!==((T=f.media)==null?void 0:T.textTracks),oe=((y=l.media)==null?void 0:y.videoRenditions)!==((S=f.media)==null?void 0:S.videoRenditions),Q=((_=l.media)==null?void 0:_.audioTracks)!==((L=f.media)==null?void 0:L.audioTracks),me=((x=l.media)==null?void 0:x.remote)!==((w=f.media)==null?void 0:w.remote),Pe=l.documentElement!==f.documentElement,Be=!!l.media&&(W||ae),Ke=!!((M=l.media)!=null&&M.textTracks)&&(G||ae),kt=!!((k=l.media)!=null&&k.videoRenditions)&&(oe||ae),vr=!!((D=l.media)!=null&&D.audioTracks)&&(Q||ae),tn=!!((U=l.media)!=null&&U.remote)&&(me||ae),av=!!l.documentElement&&(Pe||ae),ov=Be||Ke||kt||vr||tn||av,rn=o.length===0&&g===1&&a,lv=!!f.media&&(W||rn),dv=!!((B=f.media)!=null&&B.textTracks)&&(G||rn),uv=!!((X=f.media)!=null&&X.videoRenditions)&&(oe||rn),cv=!!((z=f.media)!=null&&z.audioTracks)&&(Q||rn),hv=!!((V=f.media)!=null&&V.remote)&&(me||rn),fv=!!f.documentElement&&(Pe||rn),mv=lv||dv||uv||cv||hv||fv;if(!(ov||mv)){Object.entries(f).forEach(([Re,na])=>{l[Re]=na}),c(),f=void 0;return}Object.entries(r).forEach(([Re,{get:na,mediaEvents:_1=[],textTracksEvents:A1=[],videoRenditionsEvents:S1=[],audioTracksEvents:x1=[],remoteEvents:L1=[],rootEvents:k1=[],stateOwnersUpdateHandlers:I1=[]}])=>{h[Re]||(h[Re]={});let Nt=je=>{let Ut=na(l,je);u({[Re]:Ut})},nt;nt=h[Re].mediaEvents,_1.forEach(je=>{nt&&Be&&(l.media.removeEventListener(je,nt),h[Re].mediaEvents=void 0),lv&&(f.media.addEventListener(je,Nt),h[Re].mediaEvents=Nt)}),nt=h[Re].textTracksEvents,A1.forEach(je=>{var Ut,ri;nt&&Ke&&((Ut=l.media.textTracks)==null||Ut.removeEventListener(je,nt),h[Re].textTracksEvents=void 0),dv&&((ri=f.media.textTracks)==null||ri.addEventListener(je,Nt),h[Re].textTracksEvents=Nt)}),nt=h[Re].videoRenditionsEvents,S1.forEach(je=>{var Ut,ri;nt&&kt&&((Ut=l.media.videoRenditions)==null||Ut.removeEventListener(je,nt),h[Re].videoRenditionsEvents=void 0),uv&&((ri=f.media.videoRenditions)==null||ri.addEventListener(je,Nt),h[Re].videoRenditionsEvents=Nt)}),nt=h[Re].audioTracksEvents,x1.forEach(je=>{var Ut,ri;nt&&vr&&((Ut=l.media.audioTracks)==null||Ut.removeEventListener(je,nt),h[Re].audioTracksEvents=void 0),cv&&((ri=f.media.audioTracks)==null||ri.addEventListener(je,Nt),h[Re].audioTracksEvents=Nt)}),nt=h[Re].remoteEvents,L1.forEach(je=>{var Ut,ri;nt&&tn&&((Ut=l.media.remote)==null||Ut.removeEventListener(je,nt),h[Re].remoteEvents=void 0),hv&&((ri=f.media.remote)==null||ri.addEventListener(je,Nt),h[Re].remoteEvents=Nt)}),nt=h[Re].rootEvents,k1.forEach(je=>{nt&&av&&(l.documentElement.removeEventListener(je,nt),h[Re].rootEvents=void 0),fv&&(f.documentElement.addEventListener(je,Nt),h[Re].rootEvents=Nt)});let pv=h[Re].stateOwnersUpdateHandlers;I1.forEach(je=>{pv&&ov&&pv(),mv&&(h[Re].stateOwnersUpdateHandlers=je(Nt,f))})}),Object.entries(f).forEach(([Re,na])=>{l[Re]=na}),c(),f=void 0};return m({media:i,fullscreenElement:e,documentElement:t,options:n}),{dispatch(p){let{type:g,detail:E}=p;if(s[g]){u(s[g](r,l,p));return}g==="mediaelementchangerequest"?m({media:E}):g==="fullscreenelementchangerequest"?m({fullscreenElement:E}):g==="documentelementchangerequest"?m({documentElement:E}):g==="optionschangerequest"&&Object.entries(E!=null?E:{}).forEach(([T,y])=>{l.options[T]=y})},getState(){return d},subscribe(p){return m({},o.length+1),o.push(p),p(d),()=>{let g=o.indexOf(p);g>=0&&(m({},o.length-1),o.splice(g,1))}}}},zv=sS;var kh=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},he=(i,e,t)=>(kh(i,e,"read from private field"),t?t.call(i):e.get(i)),nr=(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)},Tr=(i,e,t,r)=>(kh(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),_r=(i,e,t)=>(kh(i,e,"access private method"),t),Ar,fa,Ne,ma,xi,fl,ml,Sh,un,pa,pl,xh,Jv=["ArrowLeft","ArrowRight","Enter"," ","f","m","k","c"],jv=10,pe={DEFAULT_SUBTITLES:"defaultsubtitles",DEFAULT_STREAM_TYPE:"defaultstreamtype",DEFAULT_DURATION:"defaultduration",FULLSCREEN_ELEMENT:"fullscreenelement",HOTKEYS:"hotkeys",KEYS_USED:"keysused",LIVE_EDGE_OFFSET:"liveedgeoffset",NO_AUTO_SEEK_TO_LIVE:"noautoseektolive",NO_HOTKEYS:"nohotkeys",NO_VOLUME_PREF:"novolumepref",NO_SUBTITLES_LANG_PREF:"nosubtitleslangpref",NO_DEFAULT_STORE:"nodefaultstore",KEYBOARD_FORWARD_SEEK_OFFSET:"keyboardforwardseekoffset",KEYBOARD_BACKWARD_SEEK_OFFSET:"keyboardbackwardseekoffset"},gl=class extends ua{constructor(){super(),nr(this,ml),nr(this,un),nr(this,pl),nr(this,Ar,new qt(this,pe.HOTKEYS)),nr(this,fa,void 0),nr(this,Ne,void 0),nr(this,ma,void 0),nr(this,xi,void 0),nr(this,fl,t=>{var r;(r=he(this,Ne))==null||r.dispatch(t)}),this.mediaStateReceivers=[],this.associatedElementSubscriptions=new Map,this.associateElement(this);let e={};Tr(this,ma,t=>{Object.entries(t).forEach(([r,s])=>{if(r in e&&e[r]===s)return;this.propagateMediaState(r,s);let n=r.toLowerCase(),a=new A.CustomEvent(bv[n],{composed:!0,detail:s});this.dispatchEvent(a)}),e=t}),this.enableHotkeys()}static get observedAttributes(){return super.observedAttributes.concat(pe.NO_HOTKEYS,pe.HOTKEYS,pe.DEFAULT_STREAM_TYPE,pe.DEFAULT_SUBTITLES,pe.DEFAULT_DURATION)}get mediaStore(){return he(this,Ne)}set mediaStore(e){var t,r;if(he(this,Ne)&&((t=he(this,xi))==null||t.call(this),Tr(this,xi,void 0)),Tr(this,Ne,e),!he(this,Ne)&&!this.hasAttribute(pe.NO_DEFAULT_STORE)){_r(this,ml,Sh).call(this);return}Tr(this,xi,(r=he(this,Ne))==null?void 0:r.subscribe(he(this,ma)))}get fullscreenElement(){var e;return(e=he(this,fa))!=null?e:this}set fullscreenElement(e){var t;this.hasAttribute(pe.FULLSCREEN_ELEMENT)&&this.removeAttribute(pe.FULLSCREEN_ELEMENT),Tr(this,fa,e),(t=he(this,Ne))==null||t.dispatch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement})}attributeChangedCallback(e,t,r){var s,n,a,o,l,d;if(super.attributeChangedCallback(e,t,r),e===pe.NO_HOTKEYS)r!==t&&r===""?(this.hasAttribute(pe.HOTKEYS)&&console.warn("Media Chrome: Both `hotkeys` and `nohotkeys` have been set. All hotkeys will be disabled."),this.disableHotkeys()):r!==t&&r===null&&this.enableHotkeys();else if(e===pe.HOTKEYS)he(this,Ar).value=r;else if(e===pe.DEFAULT_SUBTITLES&&r!==t)(s=he(this,Ne))==null||s.dispatch({type:"optionschangerequest",detail:{defaultSubtitles:this.hasAttribute(pe.DEFAULT_SUBTITLES)}});else if(e===pe.DEFAULT_STREAM_TYPE)(a=he(this,Ne))==null||a.dispatch({type:"optionschangerequest",detail:{defaultStreamType:(n=this.getAttribute(pe.DEFAULT_STREAM_TYPE))!=null?n:void 0}});else if(e===pe.LIVE_EDGE_OFFSET)(o=he(this,Ne))==null||o.dispatch({type:"optionschangerequest",detail:{liveEdgeOffset:this.hasAttribute(pe.LIVE_EDGE_OFFSET)?+this.getAttribute(pe.LIVE_EDGE_OFFSET):void 0}});else if(e===pe.FULLSCREEN_ELEMENT){let u=r?(l=this.getRootNode())==null?void 0:l.getElementById(r):void 0;Tr(this,fa,u),(d=he(this,Ne))==null||d.dispatch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement})}}connectedCallback(){var e,t;!he(this,Ne)&&!this.hasAttribute(pe.NO_DEFAULT_STORE)&&_r(this,ml,Sh).call(this),(e=he(this,Ne))==null||e.dispatch({type:"documentelementchangerequest",detail:O}),super.connectedCallback(),he(this,Ne)&&!he(this,xi)&&Tr(this,xi,(t=he(this,Ne))==null?void 0:t.subscribe(he(this,ma))),this.enableHotkeys()}disconnectedCallback(){var e,t,r,s;(e=super.disconnectedCallback)==null||e.call(this),he(this,Ne)&&((t=he(this,Ne))==null||t.dispatch({type:"documentelementchangerequest",detail:void 0}),(r=he(this,Ne))==null||r.dispatch({type:F.MEDIA_TOGGLE_SUBTITLES_REQUEST,detail:!1})),he(this,xi)&&((s=he(this,xi))==null||s.call(this),Tr(this,xi,void 0))}mediaSetCallback(e){var t;super.mediaSetCallback(e),(t=he(this,Ne))==null||t.dispatch({type:"mediaelementchangerequest",detail:e}),e.hasAttribute("tabindex")||(e.tabIndex=-1)}mediaUnsetCallback(e){var t;super.mediaUnsetCallback(e),(t=he(this,Ne))==null||t.dispatch({type:"mediaelementchangerequest",detail:void 0})}propagateMediaState(e,t){Zv(this.mediaStateReceivers,e,t)}associateElement(e){if(!e)return;let{associatedElementSubscriptions:t}=this;if(t.has(e))return;let r=this.registerMediaStateReceiver.bind(this),s=this.unregisterMediaStateReceiver.bind(this),n=uS(e,r,s);Object.values(F).forEach(a=>{e.addEventListener(a,he(this,fl))}),t.set(e,n)}unassociateElement(e){if(!e)return;let{associatedElementSubscriptions:t}=this;if(!t.has(e))return;t.get(e)(),t.delete(e),Object.values(F).forEach(s=>{e.removeEventListener(s,he(this,fl))})}registerMediaStateReceiver(e){if(!e)return;let t=this.mediaStateReceivers;t.indexOf(e)>-1||(t.push(e),he(this,Ne)&&Object.entries(he(this,Ne).getState()).forEach(([s,n])=>{Zv([e],s,n)}))}unregisterMediaStateReceiver(e){let t=this.mediaStateReceivers,r=t.indexOf(e);r<0||t.splice(r,1)}enableHotkeys(){this.addEventListener("keydown",_r(this,pl,xh))}disableHotkeys(){this.removeEventListener("keydown",_r(this,pl,xh)),this.removeEventListener("keyup",_r(this,un,pa))}get hotkeys(){return he(this,Ar)}keyboardShortcutHandler(e){var t,r,s,n,a,o;if(((n=(s=(t=e.target.getAttribute(pe.KEYS_USED))==null?void 0:t.split(" "))!=null?s:(r=e.target)==null?void 0:r.keysUsed)!=null?n:[]).map(h=>h==="Space"?" ":h).filter(Boolean).includes(e.key))return;let d,u,c;if(!he(this,Ar).contains(`no${e.key.toLowerCase()}`)&&!(e.key===" "&&he(this,Ar).contains("nospace")))switch(e.key){case" ":case"k":d=he(this,Ne).getState().mediaPaused?F.MEDIA_PLAY_REQUEST:F.MEDIA_PAUSE_REQUEST,this.dispatchEvent(new A.CustomEvent(d,{composed:!0,bubbles:!0}));break;case"m":d=this.mediaStore.getState().mediaVolumeLevel==="off"?F.MEDIA_UNMUTE_REQUEST:F.MEDIA_MUTE_REQUEST,this.dispatchEvent(new A.CustomEvent(d,{composed:!0,bubbles:!0}));break;case"f":d=this.mediaStore.getState().mediaIsFullscreen?F.MEDIA_EXIT_FULLSCREEN_REQUEST:F.MEDIA_ENTER_FULLSCREEN_REQUEST,this.dispatchEvent(new A.CustomEvent(d,{composed:!0,bubbles:!0}));break;case"c":this.dispatchEvent(new A.CustomEvent(F.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0}));break;case"ArrowLeft":{let h=this.hasAttribute(pe.KEYBOARD_BACKWARD_SEEK_OFFSET)?+this.getAttribute(pe.KEYBOARD_BACKWARD_SEEK_OFFSET):jv;u=Math.max(((a=this.mediaStore.getState().mediaCurrentTime)!=null?a:0)-h,0),c=new A.CustomEvent(F.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:u}),this.dispatchEvent(c);break}case"ArrowRight":{let h=this.hasAttribute(pe.KEYBOARD_FORWARD_SEEK_OFFSET)?+this.getAttribute(pe.KEYBOARD_FORWARD_SEEK_OFFSET):jv;u=Math.max(((o=this.mediaStore.getState().mediaCurrentTime)!=null?o:0)+h,0),c=new A.CustomEvent(F.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:u}),this.dispatchEvent(c);break}default:break}}};Ar=new WeakMap;fa=new WeakMap;Ne=new WeakMap;ma=new WeakMap;xi=new WeakMap;fl=new WeakMap;ml=new WeakSet;Sh=function(){var i;this.mediaStore=zv({media:this.media,fullscreenElement:this.fullscreenElement,options:{defaultSubtitles:this.hasAttribute(pe.DEFAULT_SUBTITLES),defaultDuration:this.hasAttribute(pe.DEFAULT_DURATION)?+this.getAttribute(pe.DEFAULT_DURATION):void 0,defaultStreamType:(i=this.getAttribute(pe.DEFAULT_STREAM_TYPE))!=null?i:void 0,liveEdgeOffset:this.hasAttribute(pe.LIVE_EDGE_OFFSET)?+this.getAttribute(pe.LIVE_EDGE_OFFSET):void 0,noVolumePref:this.hasAttribute(pe.NO_VOLUME_PREF),noSubtitlesLangPref:this.hasAttribute(pe.NO_SUBTITLES_LANG_PREF)}})};un=new WeakSet;pa=function(i){let{key:e}=i;if(!Jv.includes(e)){this.removeEventListener("keyup",_r(this,un,pa));return}this.keyboardShortcutHandler(i)};pl=new WeakSet;xh=function(i){let{metaKey:e,altKey:t,key:r}=i;if(e||t||!Jv.includes(r)){this.removeEventListener("keyup",_r(this,un,pa));return}[" ","ArrowLeft","ArrowRight"].includes(r)&&!(he(this,Ar).contains(`no${r.toLowerCase()}`)||r===" "&&he(this,Ar).contains("nospace"))&&i.preventDefault(),this.addEventListener("keyup",_r(this,un,pa),{once:!0})};var nS=Object.values(b),aS=Object.values(ah),eE=i=>{var e,t,r,s;let{observedAttributes:n}=i.constructor;!n&&((e=i.nodeName)!=null&&e.includes("-"))&&(A.customElements.upgrade(i),{observedAttributes:n}=i.constructor);let a=(s=(r=(t=i==null?void 0:i.getAttribute)==null?void 0:t.call(i,ee.MEDIA_CHROME_ATTRIBUTES))==null?void 0:r.split)==null?void 0:s.call(r,/\s+/);return Array.isArray(n||a)?(n||a).filter(o=>nS.includes(o)):[]},oS=i=>{var e,t;return(e=i.nodeName)!=null&&e.includes("-")&&A.customElements.get((t=i.nodeName)==null?void 0:t.toLowerCase())&&!(i instanceof A.customElements.get(i.nodeName.toLowerCase()))&&A.customElements.upgrade(i),aS.some(r=>r in i)},Lh=i=>oS(i)||!!eE(i).length,Xv=i=>{var e;return(e=i==null?void 0:i.join)==null?void 0:e.call(i,":")},Qv={[b.MEDIA_SUBTITLES_LIST]:li,[b.MEDIA_SUBTITLES_SHOWING]:li,[b.MEDIA_SEEKABLE]:Xv,[b.MEDIA_BUFFERED]:i=>i==null?void 0:i.map(Xv).join(" "),[b.MEDIA_PREVIEW_COORDS]:i=>i==null?void 0:i.join(" "),[b.MEDIA_RENDITION_LIST]:Tv,[b.MEDIA_AUDIO_TRACK_LIST]:_v},lS=async(i,e,t)=>{var r,s;if(i.isConnected||await jo(0),typeof t=="boolean"||t==null)return Ae(i,e,t);if(typeof t=="number")return _e(i,e,t);if(typeof t=="string")return le(i,e,t);if(Array.isArray(t)&&!t.length)return i.removeAttribute(e);let n=(s=(r=Qv[e])==null?void 0:r.call(Qv,t))!=null?s:t;return i.setAttribute(e,n)},dS=i=>{var e;return!!((e=i.closest)!=null&&e.call(i,'*[slot="media"]'))},rs=(i,e)=>{if(dS(i))return;let t=(s,n)=>{var a,o;Lh(s)&&n(s);let{children:l=[]}=s!=null?s:{},d=(o=(a=s==null?void 0:s.shadowRoot)==null?void 0:a.children)!=null?o:[];[...l,...d].forEach(c=>rs(c,n))},r=i==null?void 0:i.nodeName.toLowerCase();if(r.includes("-")&&!Lh(i)){A.customElements.whenDefined(r).then(()=>{t(i,e)});return}t(i,e)},Zv=(i,e,t)=>{i.forEach(r=>{if(e in r){r[e]=t;return}let s=eE(r),n=e.toLowerCase();s.includes(n)&&lS(r,n,t)})},uS=(i,e,t)=>{rs(i,e);let r=u=>{var c;let h=(c=u==null?void 0:u.composedPath()[0])!=null?c:u.target;e(h)},s=u=>{var c;let h=(c=u==null?void 0:u.composedPath()[0])!=null?c:u.target;t(h)};i.addEventListener(F.REGISTER_MEDIA_STATE_RECEIVER,r),i.addEventListener(F.UNREGISTER_MEDIA_STATE_RECEIVER,s);let n=u=>{u.forEach(c=>{let{addedNodes:h=[],removedNodes:f=[],type:m,target:p,attributeName:g}=c;m==="childList"?(Array.prototype.forEach.call(h,E=>rs(E,e)),Array.prototype.forEach.call(f,E=>rs(E,t))):m==="attributes"&&g===ee.MEDIA_CHROME_ATTRIBUTES&&(Lh(p)?e(p):t(p))})},a=[],o=u=>{let c=u.target;c.name!=="media"&&(a.forEach(h=>rs(h,t)),a=[...c.assignedElements({flatten:!0})],a.forEach(h=>rs(h,e)))};i.addEventListener("slotchange",o);let l=new MutationObserver(n);return l.observe(i,{childList:!0,attributes:!0,subtree:!0}),()=>{rs(i,t),i.removeEventListener("slotchange",o),l.disconnect(),i.removeEventListener(F.REGISTER_MEDIA_STATE_RECEIVER,r),i.removeEventListener(F.UNREGISTER_MEDIA_STATE_RECEIVER,s)}};A.customElements.get("media-controller")||A.customElements.define("media-controller",gl);var Ih=gl;var cS=Object.defineProperty,hS=(i,e,t)=>e in i?cS(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,fS=(i,e,t)=>(hS(i,typeof e!="symbol"?e+"":e,t),t),tE=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Yt=(i,e,t)=>(tE(i,e,"read from private field"),t?t.call(i):e.get(i)),vl=(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)},El=(i,e,t,r)=>(tE(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Li,bl,cn,yl,iE=O.createElement("template");iE.innerHTML=`
145
+ `;var K1=Object.values(b),V1="sm:384 md:576 lg:768 xl:960";function q1(i){Y1(i.target,i.contentRect.width)}function Y1(i,e){var t;if(!i.isConnected)return;let r=(t=i.getAttribute(fe.BREAKPOINTS))!=null?t:V1,s=z1(r),n=j1(s,e),a=!1;if(Object.keys(s).forEach(o=>{if(n.includes(o)){i.hasAttribute(`breakpoint${o}`)||(i.setAttribute(`breakpoint${o}`,""),a=!0);return}i.hasAttribute(`breakpoint${o}`)&&(i.removeAttribute(`breakpoint${o}`),a=!0)}),a){let o=new CustomEvent(ir.BREAKPOINTS_CHANGE,{detail:n});i.dispatchEvent(o)}}function z1(i){let e=i.split(/\s+/);return Object.fromEntries(e.map(t=>t.split(":")))}function j1(i,e){return Object.keys(i).filter(t=>e>=i[t])}var ua=class extends _.HTMLElement{constructor(){super(),Jr(this,bh),Jr(this,yh),Jr(this,la),Jr(this,nl),Jr(this,on),Jr(this,rl,0),Jr(this,an,void 0),W1(this,"breakpointsComputed",!1),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Bv.content.cloneNode(!0)));let e=a=>{let o=this.media;for(let l of a)l.type==="childList"&&(l.removedNodes.forEach(d=>{if(d.slot=="media"&&l.target==this){let u=l.previousSibling&&l.previousSibling.previousElementSibling;if(!u||!o)this.mediaUnsetCallback(d);else{let c=u.slot!=="media";for(;(u=u.previousSibling)!==null;)u.slot=="media"&&(c=!1);c&&this.mediaUnsetCallback(d)}}}),o&&l.addedNodes.forEach(d=>{d===o&&this.handleMediaUpdated(o)}))};new MutationObserver(e).observe(this,{childList:!0,subtree:!0});let r=!1;Vt(this,a=>{r||(setTimeout(()=>{q1(a),r=!1,this.breakpointsComputed||(this.breakpointsComputed=!0,this.dispatchEvent(new CustomEvent(ir.BREAKPOINTS_COMPUTED,{bubbles:!0,composed:!0})))},0),r=!0)});let n=this.querySelector(":scope > slot[slot=media]");n&&n.addEventListener("slotchange",()=>{if(!n.assignedElements({flatten:!0}).length){Eh(this,an)&&this.mediaUnsetCallback(Eh(this,an));return}this.handleMediaUpdated(this.media)})}static get observedAttributes(){return[fe.AUTOHIDE,fe.GESTURES_DISABLED].concat(K1).filter(e=>![b.MEDIA_RENDITION_LIST,b.MEDIA_AUDIO_TRACK_LIST,b.MEDIA_CHAPTERS_CUES].includes(e))}attributeChangedCallback(e,t,r){e.toLowerCase()==fe.AUTOHIDE&&(this.autohide=r)}get media(){let e=this.querySelector(":scope > [slot=media]");return(e==null?void 0:e.nodeName)=="SLOT"&&(e=e.assignedElements({flatten:!0})[0]),e}async handleMediaUpdated(e){e&&(vh(this,an,e),e.localName.includes("-")&&await _.customElements.whenDefined(e.localName),this.mediaSetCallback(e))}connectedCallback(){var e;let r=this.getAttribute(fe.AUDIO)!=null?De.AUDIO_PLAYER():De.VIDEO_PLAYER();this.setAttribute("role","region"),this.setAttribute("aria-label",r),this.handleMediaUpdated(this.media),this.setAttribute(fe.USER_INACTIVE,""),this.addEventListener("pointerdown",this),this.addEventListener("pointermove",this),this.addEventListener("pointerup",this),this.addEventListener("mouseleave",this),this.addEventListener("keyup",this),(e=_.window)==null||e.addEventListener("mouseup",this)}disconnectedCallback(){var e;this.media&&this.mediaUnsetCallback(this.media),(e=_.window)==null||e.removeEventListener("mouseup",this)}mediaSetCallback(e){}mediaUnsetCallback(e){vh(this,an,null)}handleEvent(e){switch(e.type){case"pointerdown":vh(this,rl,e.timeStamp);break;case"pointermove":oi(this,bh,Uv).call(this,e);break;case"pointerup":oi(this,yh,Fv).call(this,e);break;case"mouseleave":oi(this,la,sl).call(this);break;case"mouseup":this.removeAttribute(fe.KEYBOARD_CONTROL);break;case"keyup":oi(this,on,da).call(this),this.setAttribute(fe.KEYBOARD_CONTROL,"");break}}set autohide(e){e=Number(e),this._autohide=isNaN(e)?0:e}get autohide(){return this._autohide===void 0?2:this._autohide}};rl=new WeakMap;an=new WeakMap;bh=new WeakSet;Uv=function(i){i.pointerType!=="mouse"&&i.timeStamp-Eh(this,rl)<250||(oi(this,nl,_h).call(this),clearTimeout(this._inactiveTimeout),[this,this.media].includes(i.target)&&oi(this,on,da).call(this))};yh=new WeakSet;Fv=function(i){if(i.pointerType==="touch"){let e=!this.hasAttribute(fe.USER_INACTIVE);[this,this.media].includes(i.target)&&e?oi(this,la,sl).call(this):oi(this,on,da).call(this)}else i.composedPath().some(e=>["media-play-button","media-fullscreen-button"].includes(e==null?void 0:e.localName))&&oi(this,on,da).call(this)};la=new WeakSet;sl=function(){if(this.autohide<0||this.hasAttribute(fe.USER_INACTIVE))return;this.setAttribute(fe.USER_INACTIVE,"");let i=new _.CustomEvent(ir.USER_INACTIVE,{composed:!0,bubbles:!0,detail:!0});this.dispatchEvent(i)};nl=new WeakSet;_h=function(){if(!this.hasAttribute(fe.USER_INACTIVE))return;this.removeAttribute(fe.USER_INACTIVE);let i=new _.CustomEvent(ir.USER_INACTIVE,{composed:!0,bubbles:!0,detail:!1});this.dispatchEvent(i)};on=new WeakSet;da=function(){oi(this,nl,_h).call(this),clearTimeout(this._inactiveTimeout),!(this.autohide<0)&&(this._inactiveTimeout=setTimeout(()=>{oi(this,la,sl).call(this)},this.autohide*1e3))};_.customElements.get("media-container")||_.customElements.define("media-container",ua);var $v=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ot=(i,e,t)=>($v(i,e,"read from private field"),t?t.call(i):e.get(i)),ca=(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)},al=(i,e,t,r)=>($v(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),ln,dn,ol,es,rr,yr,qt=class{constructor(e,t,{defaultValue:r}={defaultValue:void 0}){ca(this,rr),ca(this,ln,void 0),ca(this,dn,void 0),ca(this,ol,void 0),ca(this,es,new Set),al(this,ln,e),al(this,dn,t),al(this,ol,new Set(r))}[Symbol.iterator](){return ot(this,rr,yr).values()}get length(){return ot(this,rr,yr).size}get value(){var e;return(e=[...ot(this,rr,yr)].join(" "))!=null?e:""}set value(e){var t;e!==this.value&&(al(this,es,new Set),this.add(...(t=e==null?void 0:e.split(" "))!=null?t:[]))}toString(){return this.value}item(e){return[...ot(this,rr,yr)][e]}values(){return ot(this,rr,yr).values()}forEach(e){ot(this,rr,yr).forEach(e)}add(...e){var t,r;e.forEach(s=>ot(this,es).add(s)),!(this.value===""&&!((t=ot(this,ln))!=null&&t.hasAttribute(`${ot(this,dn)}`)))&&((r=ot(this,ln))==null||r.setAttribute(`${ot(this,dn)}`,`${this.value}`))}remove(...e){var t;e.forEach(r=>ot(this,es).delete(r)),(t=ot(this,ln))==null||t.setAttribute(`${ot(this,dn)}`,`${this.value}`)}contains(e){return ot(this,rr,yr).has(e)}toggle(e,t){return typeof t!="undefined"?t?(this.add(e),!0):(this.remove(e),!1):this.contains(e)?(this.remove(e),!1):(this.add(e),!0)}replace(e,t){return this.remove(e),this.add(t),e===t}};ln=new WeakMap;dn=new WeakMap;ol=new WeakMap;es=new WeakMap;rr=new WeakSet;yr=function(){return ot(this,es).size?ot(this,es):ot(this,ol)};var X1=(i="")=>i.split(/\s+/),Hv=(i="")=>{let[e,t,r]=i.split(":"),s=r?decodeURIComponent(r):void 0;return e=e==="cc"?"captions":"subtitles",{kind:e,language:t,label:s}},sr=(i="",e={})=>X1(i).map(t=>{let r=Hv(t);return{...e,...r}}),Ah=i=>i?Array.isArray(i)?i.map(e=>typeof e=="string"?Hv(e):e):typeof i=="string"?sr(i):[i]:[],ts=({kind:i,label:e,language:t}={kind:"subtitles"})=>e?`${i==="captions"?"cc":"sb"}:${t}:${encodeURIComponent(e)}`:t,li=(i=[])=>Array.prototype.map.call(i,ts).join(" "),Q1=(i,e)=>t=>t[i]===e,Gv=i=>{let e=Object.entries(i).map(([t,r])=>Q1(t,r));return t=>e.every(r=>r(t))},is=(i,e=[],t=[])=>{let r=Ah(t).map(Gv),s=n=>r.some(a=>a(n));Array.from(e).filter(s).forEach(n=>{n.mode=i})},rs=(i,e=()=>!0)=>{if(!(i!=null&&i.textTracks))return[];let t=typeof e=="function"?e:Gv(e);return Array.from(i.textTracks).filter(t)},ll=i=>{var e;return!!((e=i.mediaSubtitlesShowing)!=null&&e.length)||i.hasAttribute(b.MEDIA_SUBTITLES_SHOWING)};var Oe={enter:"requestFullscreen",exit:"exitFullscreen",rootEvents:["fullscreenchange"],mediaEvents:[],element:"fullscreenElement",error:"fullscreenerror",enabled:"fullscreenEnabled"};O.fullscreenElement===void 0&&(Oe.enter="webkitRequestFullScreen",Oe.exit=O.webkitExitFullscreen!=null?"webkitExitFullscreen":"webkitCancelFullScreen",Oe.rootEvents=["webkitfullscreenchange"],Oe.mediaEvents=["webkitbeginfullscreen","webkitendfullscreen"],Oe.element="webkitFullscreenElement",Oe.error="webkitfullscreenerror",Oe.enabled="webkitFullscreenEnabled");var dl,Sh=()=>{var i,e;return dl||(dl=(e=(i=O)==null?void 0:i.createElement)==null?void 0:e.call(i,"video"),dl)},Wv=async(i=Sh())=>{if(!i)return!1;let e=i.volume;return i.volume=e/2+.1,await jo(0),i.volume!==e},Z1=/.*Version\/.*Safari\/.*/.test(_.navigator.userAgent),xh=(i=Sh())=>_.matchMedia("(display-mode: standalone)").matches&&Z1?!1:typeof(i==null?void 0:i.requestPictureInPicture)=="function",Lh=(i=Sh())=>{let e=O[Oe.enabled];return!e&&i&&(e="webkitSupportsFullscreen"in i),e},Kv=Lh(),Vv=xh(),qv=!!_.WebKitPlaybackTargetAvailabilityEvent,Yv=!!_.chrome;var un=i=>rs(i.media,e=>[si.SUBTITLES,si.CAPTIONS].includes(e.kind)).sort((e,t)=>e.kind>=t.kind?1:-1),kh=i=>rs(i.media,e=>e.mode===Er.SHOWING&&[si.SUBTITLES,si.CAPTIONS].includes(e.kind)),ul=(i,e)=>{let t=un(i),r=kh(i),s=!!r.length;if(t.length){if(e===!1||s&&e!==!0)is(Er.DISABLED,t,r);else if(e===!0||!s&&e!==!1){let n=t[0],{options:a}=i;if(!(a!=null&&a.noSubtitlesLangPref)){let u=globalThis.localStorage.getItem("media-chrome-pref-subtitles-lang"),c=u?[u,...globalThis.navigator.languages]:globalThis.navigator.languages,h=t.filter(f=>c.some(m=>f.language.toLowerCase().startsWith(m.split("-")[0]))).sort((f,m)=>{let p=c.findIndex(E=>f.language.toLowerCase().startsWith(E.split("-")[0])),g=c.findIndex(E=>m.language.toLowerCase().startsWith(E.split("-")[0]));return p-g});h[0]&&(n=h[0])}let{language:o,label:l,kind:d}=n;is(Er.DISABLED,t,r),is(Er.SHOWING,t,[{language:o,label:l,kind:d}])}}},cl=(i,e)=>i===e?!0:typeof i!=typeof e?!1:typeof i=="number"&&Number.isNaN(i)&&Number.isNaN(e)?!0:typeof i!="object"?!1:Array.isArray(i)?J1(i,e):Object.entries(i).every(([t,r])=>t in e&&cl(r,e[t])),J1=(i,e)=>{let t=Array.isArray(i),r=Array.isArray(e);return t!==r?!1:t||r?i.length!==e.length?!1:i.every((s,n)=>cl(s,e[n])):!0};var eS=Object.values(ni),hl,tS=Wv().then(i=>(hl=i,hl)),zv=async(...i)=>{await Promise.all(i.filter(e=>e).map(async e=>{if(!("localName"in e&&e instanceof _.HTMLElement))return;let t=e.localName;if(!t.includes("-"))return;let r=_.customElements.get(t);r&&e instanceof r||(await _.customElements.whenDefined(t),_.customElements.upgrade(e))}))},ha={mediaPaused:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.paused)!=null?e:!0},set(i,e){var t;let{media:r}=e;r&&(i?r.pause():(t=r.play())==null||t.catch(()=>{}))},mediaEvents:["play","playing","pause","emptied"]},mediaHasPlayed:{get(i,e){let{media:t}=i;return t?e?e.type==="playing":!t.paused:!1},mediaEvents:["playing","emptied"]},mediaEnded:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.ended)!=null?e:!1},mediaEvents:["seeked","ended","emptied"]},mediaPlaybackRate:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.playbackRate)!=null?e:1},set(i,e){let{media:t}=e;t&&Number.isFinite(+i)&&(t.playbackRate=+i)},mediaEvents:["ratechange","loadstart"]},mediaMuted:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.muted)!=null?e:!1},set(i,e){let{media:t}=e;t&&(t.muted=i)},mediaEvents:["volumechange"]},mediaVolume:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.volume)!=null?e:1},set(i,e){let{media:t}=e;if(t){try{i==null?_.localStorage.removeItem("media-chrome-pref-volume"):_.localStorage.setItem("media-chrome-pref-volume",i.toString())}catch{}Number.isFinite(+i)&&(t.volume=+i)}},mediaEvents:["volumechange"],stateOwnersUpdateHandlers:[(i,e)=>{let{options:{noVolumePref:t}}=e;if(!t)try{let r=_.localStorage.getItem("media-chrome-pref-volume");if(r==null)return;ha.mediaVolume.set(+r,e),i(r)}catch(r){console.debug("Error getting volume pref",r)}}]},mediaVolumeLevel:{get(i){let{media:e}=i;return typeof(e==null?void 0:e.volume)=="undefined"?"high":e.muted||e.volume===0?"off":e.volume<.5?"low":e.volume<.75?"medium":"high"},mediaEvents:["volumechange"]},mediaCurrentTime:{get(i){var e;let{media:t}=i;return(e=t==null?void 0:t.currentTime)!=null?e:0},set(i,e){let{media:t}=e;!t||t.readyState===0||(t.currentTime=i)},mediaEvents:["timeupdate","loadedmetadata"]},mediaDuration:{get(i){let{media:e,options:{defaultDuration:t}={}}=i;return t&&(!e||!e.duration||Number.isNaN(e.duration)||!Number.isFinite(e.duration))?t:Number.isFinite(e==null?void 0:e.duration)?e.duration:Number.NaN},mediaEvents:["durationchange","loadedmetadata","emptied"]},mediaLoading:{get(i){let{media:e}=i;return(e==null?void 0:e.readyState)<3},mediaEvents:["waiting","playing","emptied"]},mediaSeekable:{get(i){var e;let{media:t}=i;if(!((e=t==null?void 0:t.seekable)!=null&&e.length))return;let r=t.seekable.start(0),s=t.seekable.end(t.seekable.length-1);if(!(!r&&!s))return[Number(r.toFixed(3)),Number(s.toFixed(3))]},mediaEvents:["loadedmetadata","emptied","progress","seekablechange"]},mediaBuffered:{get(i){var e;let{media:t}=i,r=(e=t==null?void 0:t.buffered)!=null?e:[];return Array.from(r).map((s,n)=>[Number(r.start(n).toFixed(3)),Number(r.end(n).toFixed(3))])},mediaEvents:["progress","emptied"]},mediaStreamType:{get(i){let{media:e,options:{defaultStreamType:t}={}}=i,r=[ni.LIVE,ni.ON_DEMAND].includes(t)?t:void 0;if(!e)return r;let{streamType:s}=e;if(eS.includes(s))return s===ni.UNKNOWN?r:s;let n=e.duration;return n===1/0?ni.LIVE:Number.isFinite(n)?ni.ON_DEMAND:r},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange"]},mediaTargetLiveWindow:{get(i){let{media:e}=i;if(!e)return Number.NaN;let{targetLiveWindow:t}=e,r=ha.mediaStreamType.get(i);return(t==null||Number.isNaN(t))&&r===ni.LIVE?0:t},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange","targetlivewindowchange"]},mediaTimeIsLive:{get(i){let{media:e,options:{liveEdgeOffset:t=10}={}}=i;if(!e)return!1;if(typeof e.liveEdgeStart=="number")return Number.isNaN(e.liveEdgeStart)?!1:e.currentTime>=e.liveEdgeStart;if(!(ha.mediaStreamType.get(i)===ni.LIVE))return!1;let s=e.seekable;if(!s)return!0;if(!s.length)return!1;let n=s.end(s.length-1)-t;return e.currentTime>=n},mediaEvents:["playing","timeupdate","progress","waiting","emptied"]},mediaSubtitlesList:{get(i){return un(i).map(({kind:e,label:t,language:r})=>({kind:e,label:t,language:r}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack"]},mediaSubtitlesShowing:{get(i){return kh(i).map(({kind:e,label:t,language:r})=>({kind:e,label:t,language:r}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack","change"],stateOwnersUpdateHandlers:[(i,e)=>{var t,r;let{media:s,options:n}=e;if(!s)return;let a=o=>{var l;!n.defaultSubtitles||o&&![si.CAPTIONS,si.SUBTITLES].includes((l=o==null?void 0:o.track)==null?void 0:l.kind)||ul(e,!0)};return(t=s.textTracks)==null||t.addEventListener("addtrack",a),(r=s.textTracks)==null||r.addEventListener("removetrack",a),a(),()=>{var o,l;(o=s.textTracks)==null||o.removeEventListener("addtrack",a),(l=s.textTracks)==null||l.removeEventListener("removetrack",a)}}]},mediaChaptersCues:{get(i){var e;let{media:t}=i;if(!t)return[];let[r]=rs(t,{kind:si.CHAPTERS});return Array.from((e=r==null?void 0:r.cues)!=null?e:[]).map(({text:s,startTime:n,endTime:a})=>({text:s,startTime:n,endTime:a}))},mediaEvents:["loadstart","loadedmetadata"],textTracksEvents:["addtrack","removetrack","change"],stateOwnersUpdateHandlers:[(i,e)=>{let{media:t}=e;if(!t)return;let r=t.querySelector('track[kind="chapters"][default][src]');return r==null||r.addEventListener("load",i),()=>{r==null||r.removeEventListener("load",i)}}]},mediaIsPip:{get(i){var e,t;let{media:r,documentElement:s}=i;if(!r||!s||!s.pictureInPictureElement)return!1;if(s.pictureInPictureElement===r)return!0;if(s.pictureInPictureElement instanceof HTMLMediaElement)return(e=r.localName)!=null&&e.includes("-")?yt(r,s.pictureInPictureElement):!1;if(s.pictureInPictureElement.localName.includes("-")){let n=s.pictureInPictureElement.shadowRoot;for(;n!=null&&n.pictureInPictureElement;){if(n.pictureInPictureElement===r)return!0;n=(t=n.pictureInPictureElement)==null?void 0:t.shadowRoot}}return!1},set(i,e){let{media:t}=e;if(t)if(i){if(!O.pictureInPictureEnabled){console.warn("MediaChrome: Picture-in-picture is not enabled");return}if(!t.requestPictureInPicture){console.warn("MediaChrome: The current media does not support picture-in-picture");return}let r=()=>{console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a readyState > 0.")};t.requestPictureInPicture().catch(s=>{if(s.code===11){if(!t.src){console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a src set.");return}if(t.readyState===0&&t.preload==="none"){let n=()=>{t.removeEventListener("loadedmetadata",a),t.preload="none"},a=()=>{t.requestPictureInPicture().catch(r),n()};t.addEventListener("loadedmetadata",a),t.preload="metadata",setTimeout(()=>{t.readyState===0&&r(),n()},1e3)}else throw s}else throw s})}else O.pictureInPictureElement&&O.exitPictureInPicture()},mediaEvents:["enterpictureinpicture","leavepictureinpicture"]},mediaRenditionList:{get(i){var e;let{media:t}=i;return[...(e=t==null?void 0:t.videoRenditions)!=null?e:[]].map(r=>({...r}))},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},mediaRenditionSelected:{get(i){var e,t,r;let{media:s}=i;return(r=(t=s==null?void 0:s.videoRenditions)==null?void 0:t[(e=s.videoRenditions)==null?void 0:e.selectedIndex])==null?void 0:r.id},set(i,e){let{media:t}=e;if(!(t!=null&&t.videoRenditions)){console.warn("MediaController: Rendition selection not supported by this media.");return}let r=i,s=Array.prototype.findIndex.call(t.videoRenditions,n=>n.id==r);t.videoRenditions.selectedIndex!=s&&(t.videoRenditions.selectedIndex=s)},mediaEvents:["emptied"],videoRenditionsEvents:["addrendition","removerendition","change"]},mediaAudioTrackList:{get(i){var e;let{media:t}=i;return[...(e=t==null?void 0:t.audioTracks)!=null?e:[]]},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]},mediaAudioTrackEnabled:{get(i){var e,t;let{media:r}=i;return(t=[...(e=r==null?void 0:r.audioTracks)!=null?e:[]].find(s=>s.enabled))==null?void 0:t.id},set(i,e){let{media:t}=e;if(!(t!=null&&t.audioTracks)){console.warn("MediaChrome: Audio track selection not supported by this media.");return}let r=i;for(let s of t.audioTracks)s.enabled=r==s.id},mediaEvents:["emptied"],audioTracksEvents:["addtrack","removetrack","change"]},mediaIsFullscreen:{get(i){var e;let{media:t,documentElement:r,fullscreenElement:s=t}=i;if(!t||!r)return!1;if(!r[Oe.element])return"webkitDisplayingFullscreen"in t&&"webkitPresentationMode"in t?t.webkitDisplayingFullscreen&&t.webkitPresentationMode===_v.FULLSCREEN:!1;if(r[Oe.element]===s)return!0;if(r[Oe.element].localName.includes("-")){let n=r[Oe.element].shadowRoot;if(!(Oe.element in n))return yt(r[Oe.element],s);for(;n!=null&&n[Oe.element];){if(n[Oe.element]===s)return!0;n=(e=n[Oe.element])==null?void 0:e.shadowRoot}}return!1},set(i,e){var t,r;let{media:s,fullscreenElement:n,documentElement:a}=e;if(!i&&(a!=null&&a[Oe.exit])){let o=(t=a==null?void 0:a[Oe.exit])==null?void 0:t.call(a);o instanceof Promise&&o.catch(()=>{});return}if(n!=null&&n[Oe.enter]){let o=(r=n[Oe.enter])==null?void 0:r.call(n);o instanceof Promise&&o.catch(()=>{})}else s!=null&&s.webkitEnterFullscreen?s.webkitEnterFullscreen():s!=null&&s.requestFullscreen&&s.requestFullscreen()},rootEvents:Oe.rootEvents,mediaEvents:Oe.mediaEvents},mediaIsCasting:{get(i){var e;let{media:t}=i;return!(t!=null&&t.remote)||((e=t.remote)==null?void 0:e.state)==="disconnected"?!1:!!t.remote.state},set(i,e){var t,r;let{media:s}=e;if(s&&!(i&&((t=s.remote)==null?void 0:t.state)!=="disconnected")&&!(!i&&((r=s.remote)==null?void 0:r.state)!=="connected")){if(typeof s.remote.prompt!="function"){console.warn("MediaChrome: Casting is not supported in this environment");return}s.remote.prompt().catch(()=>{})}},remoteEvents:["connect","connecting","disconnect"]},mediaIsAirplaying:{get(){return!1},set(i,e){let{media:t}=e;if(t){if(!(t.webkitShowPlaybackTargetPicker&&_.WebKitPlaybackTargetAvailabilityEvent)){console.warn("MediaChrome: received a request to select AirPlay but AirPlay is not supported in this environment");return}t.webkitShowPlaybackTargetPicker()}},mediaEvents:["webkitcurrentplaybacktargetiswirelesschanged"]},mediaFullscreenUnavailable:{get(i){let{media:e}=i;if(!Kv||!Lh(e))return Bt.UNSUPPORTED}},mediaPipUnavailable:{get(i){let{media:e}=i;if(!Vv||!xh(e))return Bt.UNSUPPORTED}},mediaVolumeUnavailable:{get(i){let{media:e}=i;if(hl===!1||(e==null?void 0:e.volume)==null)return Bt.UNSUPPORTED},stateOwnersUpdateHandlers:[i=>{hl==null&&tS.then(e=>i(e?void 0:Bt.UNSUPPORTED))}]},mediaCastUnavailable:{get(i,{availability:e="not-available"}={}){var t;let{media:r}=i;if(!Yv||!((t=r==null?void 0:r.remote)!=null&&t.state))return Bt.UNSUPPORTED;if(!(e==null||e==="available"))return Bt.UNAVAILABLE},stateOwnersUpdateHandlers:[(i,e)=>{var t;let{media:r}=e;return r?(r.disableRemotePlayback||r.hasAttribute("disableremoteplayback")||(t=r==null?void 0:r.remote)==null||t.watchAvailability(n=>{i({availability:n?"available":"not-available"})}).catch(n=>{n.name==="NotSupportedError"?i({availability:null}):i({availability:"not-available"})}),()=>{var n;(n=r==null?void 0:r.remote)==null||n.cancelWatchAvailability().catch(()=>{})}):void 0}]},mediaAirplayUnavailable:{get(i,e){if(!qv)return Bt.UNSUPPORTED;if((e==null?void 0:e.availability)==="not-available")return Bt.UNAVAILABLE},mediaEvents:["webkitplaybacktargetavailabilitychanged"],stateOwnersUpdateHandlers:[(i,e)=>{var t;let{media:r}=e;return r?(r.disableRemotePlayback||r.hasAttribute("disableremoteplayback")||(t=r==null?void 0:r.remote)==null||t.watchAvailability(n=>{i({availability:n?"available":"not-available"})}).catch(n=>{n.name==="NotSupportedError"?i({availability:null}):i({availability:"not-available"})}),()=>{var n;(n=r==null?void 0:r.remote)==null||n.cancelWatchAvailability().catch(()=>{})}):void 0}]},mediaRenditionUnavailable:{get(i){var e;let{media:t}=i;if(!(t!=null&&t.videoRenditions))return Bt.UNSUPPORTED;if(!((e=t.videoRenditions)!=null&&e.length))return Bt.UNAVAILABLE},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},mediaAudioTrackUnavailable:{get(i){var e,t;let{media:r}=i;if(!(r!=null&&r.audioTracks))return Bt.UNSUPPORTED;if(((t=(e=r.audioTracks)==null?void 0:e.length)!=null?t:0)<=1)return Bt.UNAVAILABLE},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]}};var jv={[B.MEDIA_PREVIEW_REQUEST](i,e,{detail:t}){var r,s,n;let{media:a}=e,o=t!=null?t:void 0,l,d;if(a&&o!=null){let[f]=rs(a,{kind:si.METADATA,label:"thumbnails"}),m=Array.prototype.find.call((r=f==null?void 0:f.cues)!=null?r:[],(p,g,E)=>g===0?p.endTime>o:g===E.length-1?p.startTime<=o:p.startTime<=o&&p.endTime>o);if(m){let p=/'^(?:[a-z]+:)?\/\//i.test(m.text)||(s=a==null?void 0:a.querySelector('track[label="thumbnails"]'))==null?void 0:s.src,g=new URL(m.text,p);d=new URLSearchParams(g.hash).get("#xywh").split(",").map(T=>+T),l=g.href}}let u=i.mediaDuration.get(e),h=(n=i.mediaChaptersCues.get(e).find((f,m,p)=>m===p.length-1&&u===f.endTime?f.startTime<=o&&f.endTime>=o:f.startTime<=o&&f.endTime>o))==null?void 0:n.text;return t!=null&&h==null&&(h=""),{mediaPreviewTime:o,mediaPreviewImage:l,mediaPreviewCoords:d,mediaPreviewChapter:h}},[B.MEDIA_PAUSE_REQUEST](i,e){i["mediaPaused"].set(!0,e)},[B.MEDIA_PLAY_REQUEST](i,e){var t;let r="mediaPaused";if(i.mediaStreamType.get(e)===ni.LIVE){let a=!(i.mediaTargetLiveWindow.get(e)>0),o=(t=i.mediaSeekable.get(e))==null?void 0:t[1];a&&o&&i.mediaCurrentTime.set(o,e)}i[r].set(!1,e)},[B.MEDIA_PLAYBACK_RATE_REQUEST](i,e,{detail:t}){let r="mediaPlaybackRate",s=t;i[r].set(s,e)},[B.MEDIA_MUTE_REQUEST](i,e){i["mediaMuted"].set(!0,e)},[B.MEDIA_UNMUTE_REQUEST](i,e){let t="mediaMuted";i.mediaVolume.get(e)||i.mediaVolume.set(.25,e),i[t].set(!1,e)},[B.MEDIA_VOLUME_REQUEST](i,e,{detail:t}){let r="mediaVolume",s=t;s&&i.mediaMuted.get(e)&&i.mediaMuted.set(!1,e),i[r].set(s,e)},[B.MEDIA_SEEK_REQUEST](i,e,{detail:t}){let r="mediaCurrentTime",s=t;i[r].set(s,e)},[B.MEDIA_SEEK_TO_LIVE_REQUEST](i,e){var t;let r="mediaCurrentTime",s=(t=i.mediaSeekable.get(e))==null?void 0:t[1];Number.isNaN(Number(s))&&i[r].set(s,e)},[B.MEDIA_SHOW_SUBTITLES_REQUEST](i,e,{detail:t}){var r;let{options:s}=e,n=un(e),a=Ah(t),o=(r=a[0])==null?void 0:r.language;o&&!s.noSubtitlesLangPref&&_.localStorage.setItem("media-chrome-pref-subtitles-lang",o),is(Er.SHOWING,n,a)},[B.MEDIA_DISABLE_SUBTITLES_REQUEST](i,e,{detail:t}){let r=un(e),s=t!=null?t:[];is(Er.DISABLED,r,s)},[B.MEDIA_TOGGLE_SUBTITLES_REQUEST](i,e,{detail:t}){ul(e,t)},[B.MEDIA_RENDITION_REQUEST](i,e,{detail:t}){let r="mediaRenditionSelected",s=t;i[r].set(s,e)},[B.MEDIA_AUDIO_TRACK_REQUEST](i,e,{detail:t}){let r="mediaAudioTrackEnabled",s=t;i[r].set(s,e)},[B.MEDIA_ENTER_PIP_REQUEST](i,e){let t="mediaIsPip";i.mediaIsFullscreen.get(e)&&i.mediaIsFullscreen.set(!1,e),i[t].set(!0,e)},[B.MEDIA_EXIT_PIP_REQUEST](i,e){i["mediaIsPip"].set(!1,e)},[B.MEDIA_ENTER_FULLSCREEN_REQUEST](i,e){let t="mediaIsFullscreen";i.mediaIsPip.get(e)&&i.mediaIsPip.set(!1,e),i[t].set(!0,e)},[B.MEDIA_EXIT_FULLSCREEN_REQUEST](i,e){i["mediaIsFullscreen"].set(!1,e)},[B.MEDIA_ENTER_CAST_REQUEST](i,e){let t="mediaIsCasting";i.mediaIsFullscreen.get(e)&&i.mediaIsFullscreen.set(!1,e),i[t].set(!0,e)},[B.MEDIA_EXIT_CAST_REQUEST](i,e){i["mediaIsCasting"].set(!1,e)},[B.MEDIA_AIRPLAY_REQUEST](i,e){i["mediaIsAirplaying"].set(!0,e)}};var iS=({media:i,fullscreenElement:e,documentElement:t,stateMediator:r=ha,requestMap:s=jv,options:n={},monitorStateOwnersOnlyWithSubscriptions:a=!0})=>{let o=[],l={options:{...n}},d=Object.freeze({mediaPreviewTime:void 0,mediaPreviewImage:void 0,mediaPreviewCoords:void 0,mediaPreviewChapter:void 0}),u=p=>{p!=null&&(cl(p,d)||(d=Object.freeze({...d,...p}),o.forEach(g=>g(d))))},c=()=>{let p=Object.entries(r).reduce((g,[E,{get:T}])=>(g[E]=T(l),g),{});u(p)},h={},f,m=async(p,g)=>{var E,T,y,S,A,L,x,w,P,k,D,U,F,z,j,K;let se=!!f;if(f={...l,...f!=null?f:{},...p},se)return;await zv(...Object.values(p));let oe=o.length>0&&g===0&&a,W=l.media!==f.media,G=((E=l.media)==null?void 0:E.textTracks)!==((T=f.media)==null?void 0:T.textTracks),ne=((y=l.media)==null?void 0:y.videoRenditions)!==((S=f.media)==null?void 0:S.videoRenditions),Q=((A=l.media)==null?void 0:A.audioTracks)!==((L=f.media)==null?void 0:L.audioTracks),me=((x=l.media)==null?void 0:x.remote)!==((w=f.media)==null?void 0:w.remote),Pe=l.documentElement!==f.documentElement,$e=!!l.media&&(W||oe),qe=!!((P=l.media)!=null&&P.textTracks)&&(G||oe),kt=!!((k=l.media)!=null&&k.videoRenditions)&&(ne||oe),vr=!!((D=l.media)!=null&&D.audioTracks)&&(Q||oe),rn=!!((U=l.media)!=null&&U.remote)&&(me||oe),lv=!!l.documentElement&&(Pe||oe),dv=$e||qe||kt||vr||rn||lv,sn=o.length===0&&g===1&&a,uv=!!f.media&&(W||sn),cv=!!((F=f.media)!=null&&F.textTracks)&&(G||sn),hv=!!((z=f.media)!=null&&z.videoRenditions)&&(ne||sn),fv=!!((j=f.media)!=null&&j.audioTracks)&&(Q||sn),mv=!!((K=f.media)!=null&&K.remote)&&(me||sn),pv=!!f.documentElement&&(Pe||sn),gv=uv||cv||hv||fv||mv||pv;if(!(dv||gv)){Object.entries(f).forEach(([Re,na])=>{l[Re]=na}),c(),f=void 0;return}Object.entries(r).forEach(([Re,{get:na,mediaEvents:y1=[],textTracksEvents:T1=[],videoRenditionsEvents:_1=[],audioTracksEvents:A1=[],remoteEvents:S1=[],rootEvents:x1=[],stateOwnersUpdateHandlers:L1=[]}])=>{h[Re]||(h[Re]={});let Nt=je=>{let Ut=na(l,je);u({[Re]:Ut})},at;at=h[Re].mediaEvents,y1.forEach(je=>{at&&$e&&(l.media.removeEventListener(je,at),h[Re].mediaEvents=void 0),uv&&(f.media.addEventListener(je,Nt),h[Re].mediaEvents=Nt)}),at=h[Re].textTracksEvents,T1.forEach(je=>{var Ut,ri;at&&qe&&((Ut=l.media.textTracks)==null||Ut.removeEventListener(je,at),h[Re].textTracksEvents=void 0),cv&&((ri=f.media.textTracks)==null||ri.addEventListener(je,Nt),h[Re].textTracksEvents=Nt)}),at=h[Re].videoRenditionsEvents,_1.forEach(je=>{var Ut,ri;at&&kt&&((Ut=l.media.videoRenditions)==null||Ut.removeEventListener(je,at),h[Re].videoRenditionsEvents=void 0),hv&&((ri=f.media.videoRenditions)==null||ri.addEventListener(je,Nt),h[Re].videoRenditionsEvents=Nt)}),at=h[Re].audioTracksEvents,A1.forEach(je=>{var Ut,ri;at&&vr&&((Ut=l.media.audioTracks)==null||Ut.removeEventListener(je,at),h[Re].audioTracksEvents=void 0),fv&&((ri=f.media.audioTracks)==null||ri.addEventListener(je,Nt),h[Re].audioTracksEvents=Nt)}),at=h[Re].remoteEvents,S1.forEach(je=>{var Ut,ri;at&&rn&&((Ut=l.media.remote)==null||Ut.removeEventListener(je,at),h[Re].remoteEvents=void 0),mv&&((ri=f.media.remote)==null||ri.addEventListener(je,Nt),h[Re].remoteEvents=Nt)}),at=h[Re].rootEvents,x1.forEach(je=>{at&&lv&&(l.documentElement.removeEventListener(je,at),h[Re].rootEvents=void 0),pv&&(f.documentElement.addEventListener(je,Nt),h[Re].rootEvents=Nt)});let vv=h[Re].stateOwnersUpdateHandlers;L1.forEach(je=>{vv&&dv&&vv(),gv&&(h[Re].stateOwnersUpdateHandlers=je(Nt,f))})}),Object.entries(f).forEach(([Re,na])=>{l[Re]=na}),c(),f=void 0};return m({media:i,fullscreenElement:e,documentElement:t,options:n}),{dispatch(p){let{type:g,detail:E}=p;if(s[g]){u(s[g](r,l,p));return}g==="mediaelementchangerequest"?m({media:E}):g==="fullscreenelementchangerequest"?m({fullscreenElement:E}):g==="documentelementchangerequest"?m({documentElement:E}):g==="optionschangerequest"&&Object.entries(E!=null?E:{}).forEach(([T,y])=>{l.options[T]=y})},getState(){return d},subscribe(p){return m({},o.length+1),o.push(p),p(d),()=>{let g=o.indexOf(p);g>=0&&(m({},o.length-1),o.splice(g,1))}}}},Xv=iS;var Ch=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},he=(i,e,t)=>(Ch(i,e,"read from private field"),t?t.call(i):e.get(i)),nr=(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)},Tr=(i,e,t,r)=>(Ch(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),_r=(i,e,t)=>(Ch(i,e,"access private method"),t),Ar,fa,Ne,ma,xi,fl,ml,Ih,cn,pa,pl,Rh,tE=["ArrowLeft","ArrowRight","Enter"," ","f","m","k","c"],Qv=10,pe={DEFAULT_SUBTITLES:"defaultsubtitles",DEFAULT_STREAM_TYPE:"defaultstreamtype",DEFAULT_DURATION:"defaultduration",FULLSCREEN_ELEMENT:"fullscreenelement",HOTKEYS:"hotkeys",KEYS_USED:"keysused",LIVE_EDGE_OFFSET:"liveedgeoffset",NO_AUTO_SEEK_TO_LIVE:"noautoseektolive",NO_HOTKEYS:"nohotkeys",NO_VOLUME_PREF:"novolumepref",NO_SUBTITLES_LANG_PREF:"nosubtitleslangpref",NO_DEFAULT_STORE:"nodefaultstore",KEYBOARD_FORWARD_SEEK_OFFSET:"keyboardforwardseekoffset",KEYBOARD_BACKWARD_SEEK_OFFSET:"keyboardbackwardseekoffset"},gl=class extends ua{constructor(){super(),nr(this,ml),nr(this,cn),nr(this,pl),nr(this,Ar,new qt(this,pe.HOTKEYS)),nr(this,fa,void 0),nr(this,Ne,void 0),nr(this,ma,void 0),nr(this,xi,void 0),nr(this,fl,t=>{var r;(r=he(this,Ne))==null||r.dispatch(t)}),this.mediaStateReceivers=[],this.associatedElementSubscriptions=new Map,this.associateElement(this);let e={};Tr(this,ma,t=>{Object.entries(t).forEach(([r,s])=>{if(r in e&&e[r]===s)return;this.propagateMediaState(r,s);let n=r.toLowerCase(),a=new _.CustomEvent(Tv[n],{composed:!0,detail:s});this.dispatchEvent(a)}),e=t}),this.enableHotkeys()}static get observedAttributes(){return super.observedAttributes.concat(pe.NO_HOTKEYS,pe.HOTKEYS,pe.DEFAULT_STREAM_TYPE,pe.DEFAULT_SUBTITLES,pe.DEFAULT_DURATION)}get mediaStore(){return he(this,Ne)}set mediaStore(e){var t,r;if(he(this,Ne)&&((t=he(this,xi))==null||t.call(this),Tr(this,xi,void 0)),Tr(this,Ne,e),!he(this,Ne)&&!this.hasAttribute(pe.NO_DEFAULT_STORE)){_r(this,ml,Ih).call(this);return}Tr(this,xi,(r=he(this,Ne))==null?void 0:r.subscribe(he(this,ma)))}get fullscreenElement(){var e;return(e=he(this,fa))!=null?e:this}set fullscreenElement(e){var t;this.hasAttribute(pe.FULLSCREEN_ELEMENT)&&this.removeAttribute(pe.FULLSCREEN_ELEMENT),Tr(this,fa,e),(t=he(this,Ne))==null||t.dispatch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement})}attributeChangedCallback(e,t,r){var s,n,a,o,l,d;if(super.attributeChangedCallback(e,t,r),e===pe.NO_HOTKEYS)r!==t&&r===""?(this.hasAttribute(pe.HOTKEYS)&&console.warn("Media Chrome: Both `hotkeys` and `nohotkeys` have been set. All hotkeys will be disabled."),this.disableHotkeys()):r!==t&&r===null&&this.enableHotkeys();else if(e===pe.HOTKEYS)he(this,Ar).value=r;else if(e===pe.DEFAULT_SUBTITLES&&r!==t)(s=he(this,Ne))==null||s.dispatch({type:"optionschangerequest",detail:{defaultSubtitles:this.hasAttribute(pe.DEFAULT_SUBTITLES)}});else if(e===pe.DEFAULT_STREAM_TYPE)(a=he(this,Ne))==null||a.dispatch({type:"optionschangerequest",detail:{defaultStreamType:(n=this.getAttribute(pe.DEFAULT_STREAM_TYPE))!=null?n:void 0}});else if(e===pe.LIVE_EDGE_OFFSET)(o=he(this,Ne))==null||o.dispatch({type:"optionschangerequest",detail:{liveEdgeOffset:this.hasAttribute(pe.LIVE_EDGE_OFFSET)?+this.getAttribute(pe.LIVE_EDGE_OFFSET):void 0}});else if(e===pe.FULLSCREEN_ELEMENT){let u=r?(l=this.getRootNode())==null?void 0:l.getElementById(r):void 0;Tr(this,fa,u),(d=he(this,Ne))==null||d.dispatch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement})}}connectedCallback(){var e,t;!he(this,Ne)&&!this.hasAttribute(pe.NO_DEFAULT_STORE)&&_r(this,ml,Ih).call(this),(e=he(this,Ne))==null||e.dispatch({type:"documentelementchangerequest",detail:O}),super.connectedCallback(),he(this,Ne)&&!he(this,xi)&&Tr(this,xi,(t=he(this,Ne))==null?void 0:t.subscribe(he(this,ma))),this.enableHotkeys()}disconnectedCallback(){var e,t,r,s;(e=super.disconnectedCallback)==null||e.call(this),he(this,Ne)&&((t=he(this,Ne))==null||t.dispatch({type:"documentelementchangerequest",detail:void 0}),(r=he(this,Ne))==null||r.dispatch({type:B.MEDIA_TOGGLE_SUBTITLES_REQUEST,detail:!1})),he(this,xi)&&((s=he(this,xi))==null||s.call(this),Tr(this,xi,void 0))}mediaSetCallback(e){var t;super.mediaSetCallback(e),(t=he(this,Ne))==null||t.dispatch({type:"mediaelementchangerequest",detail:e}),e.hasAttribute("tabindex")||(e.tabIndex=-1)}mediaUnsetCallback(e){var t;super.mediaUnsetCallback(e),(t=he(this,Ne))==null||t.dispatch({type:"mediaelementchangerequest",detail:void 0})}propagateMediaState(e,t){eE(this.mediaStateReceivers,e,t)}associateElement(e){if(!e)return;let{associatedElementSubscriptions:t}=this;if(t.has(e))return;let r=this.registerMediaStateReceiver.bind(this),s=this.unregisterMediaStateReceiver.bind(this),n=lS(e,r,s);Object.values(B).forEach(a=>{e.addEventListener(a,he(this,fl))}),t.set(e,n)}unassociateElement(e){if(!e)return;let{associatedElementSubscriptions:t}=this;if(!t.has(e))return;t.get(e)(),t.delete(e),Object.values(B).forEach(s=>{e.removeEventListener(s,he(this,fl))})}registerMediaStateReceiver(e){if(!e)return;let t=this.mediaStateReceivers;t.indexOf(e)>-1||(t.push(e),he(this,Ne)&&Object.entries(he(this,Ne).getState()).forEach(([s,n])=>{eE([e],s,n)}))}unregisterMediaStateReceiver(e){let t=this.mediaStateReceivers,r=t.indexOf(e);r<0||t.splice(r,1)}enableHotkeys(){this.addEventListener("keydown",_r(this,pl,Rh))}disableHotkeys(){this.removeEventListener("keydown",_r(this,pl,Rh)),this.removeEventListener("keyup",_r(this,cn,pa))}get hotkeys(){return he(this,Ar)}keyboardShortcutHandler(e){var t,r,s,n,a,o;if(((n=(s=(t=e.target.getAttribute(pe.KEYS_USED))==null?void 0:t.split(" "))!=null?s:(r=e.target)==null?void 0:r.keysUsed)!=null?n:[]).map(h=>h==="Space"?" ":h).filter(Boolean).includes(e.key))return;let d,u,c;if(!he(this,Ar).contains(`no${e.key.toLowerCase()}`)&&!(e.key===" "&&he(this,Ar).contains("nospace")))switch(e.key){case" ":case"k":d=he(this,Ne).getState().mediaPaused?B.MEDIA_PLAY_REQUEST:B.MEDIA_PAUSE_REQUEST,this.dispatchEvent(new _.CustomEvent(d,{composed:!0,bubbles:!0}));break;case"m":d=this.mediaStore.getState().mediaVolumeLevel==="off"?B.MEDIA_UNMUTE_REQUEST:B.MEDIA_MUTE_REQUEST,this.dispatchEvent(new _.CustomEvent(d,{composed:!0,bubbles:!0}));break;case"f":d=this.mediaStore.getState().mediaIsFullscreen?B.MEDIA_EXIT_FULLSCREEN_REQUEST:B.MEDIA_ENTER_FULLSCREEN_REQUEST,this.dispatchEvent(new _.CustomEvent(d,{composed:!0,bubbles:!0}));break;case"c":this.dispatchEvent(new _.CustomEvent(B.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0}));break;case"ArrowLeft":{let h=this.hasAttribute(pe.KEYBOARD_BACKWARD_SEEK_OFFSET)?+this.getAttribute(pe.KEYBOARD_BACKWARD_SEEK_OFFSET):Qv;u=Math.max(((a=this.mediaStore.getState().mediaCurrentTime)!=null?a:0)-h,0),c=new _.CustomEvent(B.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:u}),this.dispatchEvent(c);break}case"ArrowRight":{let h=this.hasAttribute(pe.KEYBOARD_FORWARD_SEEK_OFFSET)?+this.getAttribute(pe.KEYBOARD_FORWARD_SEEK_OFFSET):Qv;u=Math.max(((o=this.mediaStore.getState().mediaCurrentTime)!=null?o:0)+h,0),c=new _.CustomEvent(B.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:u}),this.dispatchEvent(c);break}default:break}}};Ar=new WeakMap;fa=new WeakMap;Ne=new WeakMap;ma=new WeakMap;xi=new WeakMap;fl=new WeakMap;ml=new WeakSet;Ih=function(){var i;this.mediaStore=Xv({media:this.media,fullscreenElement:this.fullscreenElement,options:{defaultSubtitles:this.hasAttribute(pe.DEFAULT_SUBTITLES),defaultDuration:this.hasAttribute(pe.DEFAULT_DURATION)?+this.getAttribute(pe.DEFAULT_DURATION):void 0,defaultStreamType:(i=this.getAttribute(pe.DEFAULT_STREAM_TYPE))!=null?i:void 0,liveEdgeOffset:this.hasAttribute(pe.LIVE_EDGE_OFFSET)?+this.getAttribute(pe.LIVE_EDGE_OFFSET):void 0,noVolumePref:this.hasAttribute(pe.NO_VOLUME_PREF),noSubtitlesLangPref:this.hasAttribute(pe.NO_SUBTITLES_LANG_PREF)}})};cn=new WeakSet;pa=function(i){let{key:e}=i;if(!tE.includes(e)){this.removeEventListener("keyup",_r(this,cn,pa));return}this.keyboardShortcutHandler(i)};pl=new WeakSet;Rh=function(i){let{metaKey:e,altKey:t,key:r}=i;if(e||t||!tE.includes(r)){this.removeEventListener("keyup",_r(this,cn,pa));return}[" ","ArrowLeft","ArrowRight"].includes(r)&&!(he(this,Ar).contains(`no${r.toLowerCase()}`)||r===" "&&he(this,Ar).contains("nospace"))&&i.preventDefault(),this.addEventListener("keyup",_r(this,cn,pa),{once:!0})};var rS=Object.values(b),sS=Object.values(uh),iE=i=>{var e,t,r,s;let{observedAttributes:n}=i.constructor;!n&&((e=i.nodeName)!=null&&e.includes("-"))&&(_.customElements.upgrade(i),{observedAttributes:n}=i.constructor);let a=(s=(r=(t=i==null?void 0:i.getAttribute)==null?void 0:t.call(i,te.MEDIA_CHROME_ATTRIBUTES))==null?void 0:r.split)==null?void 0:s.call(r,/\s+/);return Array.isArray(n||a)?(n||a).filter(o=>rS.includes(o)):[]},nS=i=>{var e,t;return(e=i.nodeName)!=null&&e.includes("-")&&_.customElements.get((t=i.nodeName)==null?void 0:t.toLowerCase())&&!(i instanceof _.customElements.get(i.nodeName.toLowerCase()))&&_.customElements.upgrade(i),sS.some(r=>r in i)},wh=i=>nS(i)||!!iE(i).length,Zv=i=>{var e;return(e=i==null?void 0:i.join)==null?void 0:e.call(i,":")},Jv={[b.MEDIA_SUBTITLES_LIST]:li,[b.MEDIA_SUBTITLES_SHOWING]:li,[b.MEDIA_SEEKABLE]:Zv,[b.MEDIA_BUFFERED]:i=>i==null?void 0:i.map(Zv).join(" "),[b.MEDIA_PREVIEW_COORDS]:i=>i==null?void 0:i.join(" "),[b.MEDIA_RENDITION_LIST]:Av,[b.MEDIA_AUDIO_TRACK_LIST]:Sv},aS=async(i,e,t)=>{var r,s;if(i.isConnected||await jo(0),typeof t=="boolean"||t==null)return Ae(i,e,t);if(typeof t=="number")return _e(i,e,t);if(typeof t=="string")return le(i,e,t);if(Array.isArray(t)&&!t.length)return i.removeAttribute(e);let n=(s=(r=Jv[e])==null?void 0:r.call(Jv,t))!=null?s:t;return i.setAttribute(e,n)},oS=i=>{var e;return!!((e=i.closest)!=null&&e.call(i,'*[slot="media"]'))},ss=(i,e)=>{if(oS(i))return;let t=(s,n)=>{var a,o;wh(s)&&n(s);let{children:l=[]}=s!=null?s:{},d=(o=(a=s==null?void 0:s.shadowRoot)==null?void 0:a.children)!=null?o:[];[...l,...d].forEach(c=>ss(c,n))},r=i==null?void 0:i.nodeName.toLowerCase();if(r.includes("-")&&!wh(i)){_.customElements.whenDefined(r).then(()=>{t(i,e)});return}t(i,e)},eE=(i,e,t)=>{i.forEach(r=>{if(e in r){r[e]=t;return}let s=iE(r),n=e.toLowerCase();s.includes(n)&&aS(r,n,t)})},lS=(i,e,t)=>{ss(i,e);let r=u=>{var c;let h=(c=u==null?void 0:u.composedPath()[0])!=null?c:u.target;e(h)},s=u=>{var c;let h=(c=u==null?void 0:u.composedPath()[0])!=null?c:u.target;t(h)};i.addEventListener(B.REGISTER_MEDIA_STATE_RECEIVER,r),i.addEventListener(B.UNREGISTER_MEDIA_STATE_RECEIVER,s);let n=u=>{u.forEach(c=>{let{addedNodes:h=[],removedNodes:f=[],type:m,target:p,attributeName:g}=c;m==="childList"?(Array.prototype.forEach.call(h,E=>ss(E,e)),Array.prototype.forEach.call(f,E=>ss(E,t))):m==="attributes"&&g===te.MEDIA_CHROME_ATTRIBUTES&&(wh(p)?e(p):t(p))})},a=[],o=u=>{let c=u.target;c.name!=="media"&&(a.forEach(h=>ss(h,t)),a=[...c.assignedElements({flatten:!0})],a.forEach(h=>ss(h,e)))};i.addEventListener("slotchange",o);let l=new MutationObserver(n);return l.observe(i,{childList:!0,attributes:!0,subtree:!0}),()=>{ss(i,t),i.removeEventListener("slotchange",o),l.disconnect(),i.removeEventListener(B.REGISTER_MEDIA_STATE_RECEIVER,r),i.removeEventListener(B.UNREGISTER_MEDIA_STATE_RECEIVER,s)}};_.customElements.get("media-controller")||_.customElements.define("media-controller",gl);var Dh=gl;var dS=Object.defineProperty,uS=(i,e,t)=>e in i?dS(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,cS=(i,e,t)=>(uS(i,typeof e!="symbol"?e+"":e,t),t),rE=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Yt=(i,e,t)=>(rE(i,e,"read from private field"),t?t.call(i):e.get(i)),vl=(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)},El=(i,e,t,r)=>(rE(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Li,bl,hn,yl,sE=O.createElement("template");sE.innerHTML=`
146
146
  <style>
147
147
  :host {
148
148
  font: var(--media-font,
@@ -191,10 +191,10 @@
191
191
  min-width: 100%;
192
192
  }
193
193
  </style>
194
- `;var be=class extends A.HTMLElement{constructor(e={}){if(super(),vl(this,Li,void 0),fS(this,"preventClick",!1),vl(this,bl,t=>{this.preventClick||this.handleClick(t)}),vl(this,cn,t=>{let{key:r}=t;if(!this.keysUsed.includes(r)){this.removeEventListener("keyup",Yt(this,cn));return}this.preventClick||this.handleClick(t)}),vl(this,yl,t=>{let{metaKey:r,altKey:s,key:n}=t;if(r||s||!this.keysUsed.includes(n)){this.removeEventListener("keyup",Yt(this,cn));return}this.addEventListener("keyup",Yt(this,cn),{once:!0})}),!this.shadowRoot){this.attachShadow({mode:"open"});let t=iE.content.cloneNode(!0);this.nativeEl=t;let r=e.slotTemplate;r||(r=O.createElement("template"),r.innerHTML=`<slot>${e.defaultContent||""}</slot>`),this.nativeEl.appendChild(r.content.cloneNode(!0)),this.shadowRoot.appendChild(t)}}static get observedAttributes(){return["disabled",ee.MEDIA_CONTROLLER]}enable(){this.addEventListener("click",Yt(this,bl)),this.addEventListener("keydown",Yt(this,yl)),this.tabIndex=0}disable(){this.removeEventListener("click",Yt(this,bl)),this.removeEventListener("keydown",Yt(this,yl)),this.removeEventListener("keyup",Yt(this,cn)),this.tabIndex=-1}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===ee.MEDIA_CONTROLLER?(t&&((n=(s=Yt(this,Li))==null?void 0:s.unassociateElement)==null||n.call(s,this),El(this,Li,null)),r&&this.isConnected&&(El(this,Li,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=Yt(this,Li))==null?void 0:o.associateElement)==null||l.call(o,this))):e==="disabled"&&r!==t&&(r==null?this.enable():this.disable())}connectedCallback(){var e,t,r;let{style:s}=Te(this.shadowRoot,":host");s.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`),this.hasAttribute("disabled")||this.enable(),this.setAttribute("role","button");let n=this.getAttribute(ee.MEDIA_CONTROLLER);n&&(El(this,Li,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(r=(t=Yt(this,Li))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;this.disable(),(t=(e=Yt(this,Li))==null?void 0:e.unassociateElement)==null||t.call(e,this),El(this,Li,null)}get keysUsed(){return["Enter"," "]}handleClick(e){}};Li=new WeakMap;bl=new WeakMap;cn=new WeakMap;yl=new WeakMap;A.customElements.get("media-chrome-button")||A.customElements.define("media-chrome-button",be);var rE=`<svg aria-hidden="true" viewBox="0 0 26 24">
194
+ `;var be=class extends _.HTMLElement{constructor(e={}){if(super(),vl(this,Li,void 0),cS(this,"preventClick",!1),vl(this,bl,t=>{this.preventClick||this.handleClick(t)}),vl(this,hn,t=>{let{key:r}=t;if(!this.keysUsed.includes(r)){this.removeEventListener("keyup",Yt(this,hn));return}this.preventClick||this.handleClick(t)}),vl(this,yl,t=>{let{metaKey:r,altKey:s,key:n}=t;if(r||s||!this.keysUsed.includes(n)){this.removeEventListener("keyup",Yt(this,hn));return}this.addEventListener("keyup",Yt(this,hn),{once:!0})}),!this.shadowRoot){this.attachShadow({mode:"open"});let t=sE.content.cloneNode(!0);this.nativeEl=t;let r=e.slotTemplate;r||(r=O.createElement("template"),r.innerHTML=`<slot>${e.defaultContent||""}</slot>`),this.nativeEl.appendChild(r.content.cloneNode(!0)),this.shadowRoot.appendChild(t)}}static get observedAttributes(){return["disabled",te.MEDIA_CONTROLLER]}enable(){this.addEventListener("click",Yt(this,bl)),this.addEventListener("keydown",Yt(this,yl)),this.tabIndex=0}disable(){this.removeEventListener("click",Yt(this,bl)),this.removeEventListener("keydown",Yt(this,yl)),this.removeEventListener("keyup",Yt(this,hn)),this.tabIndex=-1}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===te.MEDIA_CONTROLLER?(t&&((n=(s=Yt(this,Li))==null?void 0:s.unassociateElement)==null||n.call(s,this),El(this,Li,null)),r&&this.isConnected&&(El(this,Li,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=Yt(this,Li))==null?void 0:o.associateElement)==null||l.call(o,this))):e==="disabled"&&r!==t&&(r==null?this.enable():this.disable())}connectedCallback(){var e,t,r;let{style:s}=Te(this.shadowRoot,":host");s.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`),this.hasAttribute("disabled")||this.enable(),this.setAttribute("role","button");let n=this.getAttribute(te.MEDIA_CONTROLLER);n&&(El(this,Li,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(r=(t=Yt(this,Li))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;this.disable(),(t=(e=Yt(this,Li))==null?void 0:e.unassociateElement)==null||t.call(e,this),El(this,Li,null)}get keysUsed(){return["Enter"," "]}handleClick(e){}};Li=new WeakMap;bl=new WeakMap;hn=new WeakMap;yl=new WeakMap;_.customElements.get("media-chrome-button")||_.customElements.define("media-chrome-button",be);var nE=`<svg aria-hidden="true" viewBox="0 0 26 24">
195
195
  <path d="M22.13 3H3.87a.87.87 0 0 0-.87.87v13.26a.87.87 0 0 0 .87.87h3.4L9 16H5V5h16v11h-4l1.72 2h3.4a.87.87 0 0 0 .87-.87V3.87a.87.87 0 0 0-.86-.87Zm-8.75 11.44a.5.5 0 0 0-.76 0l-4.91 5.73a.5.5 0 0 0 .38.83h9.82a.501.501 0 0 0 .38-.83l-4.91-5.73Z"/>
196
196
  </svg>
197
- `,nE=O.createElement("template");nE.innerHTML=`
197
+ `,oE=O.createElement("template");oE.innerHTML=`
198
198
  <style>
199
199
  :host([${b.MEDIA_IS_AIRPLAYING}]) slot:not([name=exit]):not([name=icon]) {
200
200
  display: none !important;
@@ -207,10 +207,10 @@
207
207
  </style>
208
208
 
209
209
  <slot name="icon">
210
- <slot name="enter">${rE}</slot>
211
- <slot name="exit">${rE}</slot>
210
+ <slot name="enter">${nE}</slot>
211
+ <slot name="exit">${nE}</slot>
212
212
  </slot>
213
- `;var sE=i=>{let e=i.mediaIsAirplaying?De.EXIT_AIRPLAY():De.ENTER_AIRPLAY();i.setAttribute("aria-label",e)},Rh=class extends be{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_IS_AIRPLAYING,b.MEDIA_AIRPLAY_UNAVAILABLE]}constructor(e={}){super({slotTemplate:nE,...e})}connectedCallback(){super.connectedCallback(),sE(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_IS_AIRPLAYING&&sE(this)}get mediaIsAirplaying(){return Le(this,b.MEDIA_IS_AIRPLAYING)}set mediaIsAirplaying(e){Ae(this,b.MEDIA_IS_AIRPLAYING,e)}get mediaAirplayUnavailable(){return ue(this,b.MEDIA_AIRPLAY_UNAVAILABLE)}set mediaAirplayUnavailable(e){le(this,b.MEDIA_AIRPLAY_UNAVAILABLE,e)}handleClick(){let e=new A.CustomEvent(F.MEDIA_AIRPLAY_REQUEST,{composed:!0,bubbles:!0});this.dispatchEvent(e)}};A.customElements.get("media-airplay-button")||A.customElements.define("media-airplay-button",Rh);function aE({anchor:i,floating:e,placement:t}){let r=mS({anchor:i,floating:e}),{x:s,y:n}=gS(r,t);return{x:s,y:n}}function mS({anchor:i,floating:e}){return{anchor:pS(i,e.offsetParent),floating:{x:0,y:0,width:e.offsetWidth,height:e.offsetHeight}}}function pS(i,e){let t=i.getBoundingClientRect(),r=e.getBoundingClientRect();return{x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}function gS({anchor:i,floating:e},t){let r=vS(t)==="x"?"y":"x",s=r==="y"?"height":"width",n=oE(t),a=i.x+i.width/2-e.width/2,o=i.y+i.height/2-e.height/2,l=i[s]/2-e[s]/2,d;switch(n){case"top":d={x:a,y:i.y-e.height};break;case"bottom":d={x:a,y:i.y+i.height};break;case"right":d={x:i.x+i.width,y:o};break;case"left":d={x:i.x-e.width,y:o};break;default:d={x:i.x,y:i.y}}switch(t.split("-")[1]){case"start":d[r]-=l;break;case"end":d[r]+=l;break}return d}function oE(i){return i.split("-")[0]}function vS(i){return["top","bottom"].includes(oE(i))?"y":"x"}var ES=Object.defineProperty,bS=(i,e,t)=>e in i?ES(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Tl=(i,e,t)=>(bS(i,typeof e!="symbol"?e+"":e,t),t),Sr=class extends Event{constructor({action:e="auto",relatedTarget:t,...r}){super("invoke",r),Tl(this,"action"),Tl(this,"relatedTarget"),this.action=e,this.relatedTarget=t}},_l=class extends Event{constructor({newState:e,oldState:t,...r}){super("toggle",r),Tl(this,"newState"),Tl(this,"oldState"),this.newState=e,this.oldState=t}};var yS=Object.defineProperty,TS=(i,e,t)=>e in i?yS(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,_S=(i,e,t)=>(TS(i,typeof e!="symbol"?e+"":e,t),t),Hh=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Se=(i,e,t)=>(Hh(i,e,"read from private field"),t?t.call(i):e.get(i)),Ie=(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)},ar=(i,e,t,r)=>(Hh(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),we=(i,e,t)=>(Hh(i,e,"access private method"),t),ki,ns,xr,lE,dE,Al,Sl,as,wh,uE,kl,xl,Ch,Dh,cE,Mh,hE,Ph,fE,hn,fn,os,mn,Il,Gh,Oh,mE,Wh,pE,Nh,gE,Vh,vE,Uh,EE,Fh,bE,ga,Rl,Bh,yE,va,wl,Ll,$h;function Ii({type:i,text:e,value:t,checked:r}){let s=O.createElement("media-chrome-menu-item");s.type=i!=null?i:"",s.part.add("menu-item"),i&&s.part.add(i),s.value=t,s.checked=r;let n=O.createElement("span");return n.textContent=e,s.append(n),s}function di(i,e){let t=i.querySelector(`:scope > [slot="${e}"]`);if((t==null?void 0:t.nodeName)=="SLOT"&&(t=t.assignedElements({flatten:!0})[0]),t)return t=t.cloneNode(!0),t;let r=i.shadowRoot.querySelector(`[name="${e}"] > svg`);return r?r.cloneNode(!0):""}var TE=O.createElement("template");TE.innerHTML=`
213
+ `;var aE=i=>{let e=i.mediaIsAirplaying?Me.EXIT_AIRPLAY():Me.ENTER_AIRPLAY();i.setAttribute("aria-label",e)},Mh=class extends be{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_IS_AIRPLAYING,b.MEDIA_AIRPLAY_UNAVAILABLE]}constructor(e={}){super({slotTemplate:oE,...e})}connectedCallback(){super.connectedCallback(),aE(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_IS_AIRPLAYING&&aE(this)}get mediaIsAirplaying(){return Le(this,b.MEDIA_IS_AIRPLAYING)}set mediaIsAirplaying(e){Ae(this,b.MEDIA_IS_AIRPLAYING,e)}get mediaAirplayUnavailable(){return ue(this,b.MEDIA_AIRPLAY_UNAVAILABLE)}set mediaAirplayUnavailable(e){le(this,b.MEDIA_AIRPLAY_UNAVAILABLE,e)}handleClick(){let e=new _.CustomEvent(B.MEDIA_AIRPLAY_REQUEST,{composed:!0,bubbles:!0});this.dispatchEvent(e)}};_.customElements.get("media-airplay-button")||_.customElements.define("media-airplay-button",Mh);function lE({anchor:i,floating:e,placement:t}){let r=hS({anchor:i,floating:e}),{x:s,y:n}=mS(r,t);return{x:s,y:n}}function hS({anchor:i,floating:e}){return{anchor:fS(i,e.offsetParent),floating:{x:0,y:0,width:e.offsetWidth,height:e.offsetHeight}}}function fS(i,e){let t=i.getBoundingClientRect(),r=e.getBoundingClientRect();return{x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}function mS({anchor:i,floating:e},t){let r=pS(t)==="x"?"y":"x",s=r==="y"?"height":"width",n=dE(t),a=i.x+i.width/2-e.width/2,o=i.y+i.height/2-e.height/2,l=i[s]/2-e[s]/2,d;switch(n){case"top":d={x:a,y:i.y-e.height};break;case"bottom":d={x:a,y:i.y+i.height};break;case"right":d={x:i.x+i.width,y:o};break;case"left":d={x:i.x-e.width,y:o};break;default:d={x:i.x,y:i.y}}switch(t.split("-")[1]){case"start":d[r]-=l;break;case"end":d[r]+=l;break}return d}function dE(i){return i.split("-")[0]}function pS(i){return["top","bottom"].includes(dE(i))?"y":"x"}var gS=Object.defineProperty,vS=(i,e,t)=>e in i?gS(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Tl=(i,e,t)=>(vS(i,typeof e!="symbol"?e+"":e,t),t),Sr=class extends Event{constructor({action:e="auto",relatedTarget:t,...r}){super("invoke",r),Tl(this,"action"),Tl(this,"relatedTarget"),this.action=e,this.relatedTarget=t}},_l=class extends Event{constructor({newState:e,oldState:t,...r}){super("toggle",r),Tl(this,"newState"),Tl(this,"oldState"),this.newState=e,this.oldState=t}};var ES=Object.defineProperty,bS=(i,e,t)=>e in i?ES(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,yS=(i,e,t)=>(bS(i,typeof e!="symbol"?e+"":e,t),t),Vh=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Se=(i,e,t)=>(Vh(i,e,"read from private field"),t?t.call(i):e.get(i)),Ie=(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)},ar=(i,e,t,r)=>(Vh(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),we=(i,e,t)=>(Vh(i,e,"access private method"),t),ki,as,xr,uE,cE,Al,Sl,os,Ph,hE,kl,xl,Oh,Nh,fE,Uh,mE,Fh,pE,fn,mn,ls,pn,Il,qh,Bh,gE,Yh,vE,$h,EE,zh,bE,Hh,yE,Gh,TE,ga,Rl,Wh,_E,va,wl,Ll,Kh;function Ii({type:i,text:e,value:t,checked:r}){let s=O.createElement("media-chrome-menu-item");s.type=i!=null?i:"",s.part.add("menu-item"),i&&s.part.add(i),s.value=t,s.checked=r;let n=O.createElement("span");return n.textContent=e,s.append(n),s}function di(i,e){let t=i.querySelector(`:scope > [slot="${e}"]`);if((t==null?void 0:t.nodeName)=="SLOT"&&(t=t.assignedElements({flatten:!0})[0]),t)return t=t.cloneNode(!0),t;let r=i.shadowRoot.querySelector(`[name="${e}"] > svg`);return r?r.cloneNode(!0):""}var AE=O.createElement("template");AE.innerHTML=`
214
214
  <style>
215
215
  :host {
216
216
  font: var(--media-font,
@@ -372,16 +372,16 @@
372
372
  <slot></slot>
373
373
  </div>
374
374
  <slot name="checked-indicator" hidden></slot>
375
- `;var ss={STYLE:"style",HIDDEN:"hidden",DISABLED:"disabled",ANCHOR:"anchor"},Tt=class extends A.HTMLElement{constructor(){super(),Ie(this,wh),Ie(this,xl),Ie(this,Dh),Ie(this,Mh),Ie(this,Ph),Ie(this,os),Ie(this,Il),Ie(this,Oh),Ie(this,Wh),Ie(this,Nh),Ie(this,Vh),Ie(this,Uh),Ie(this,Fh),Ie(this,ga),Ie(this,Bh),Ie(this,va),Ie(this,Ll),Ie(this,ki,void 0),Ie(this,ns,void 0),Ie(this,xr,void 0),Ie(this,lE,""),Ie(this,dE,null),Ie(this,Al,new Set),Ie(this,Sl,void 0),Ie(this,as,!1),Ie(this,kl,()=>{let e=Se(this,Al),t=new Set(this.items);for(let r of e)t.has(r)||this.dispatchEvent(new CustomEvent("removemenuitem",{detail:r}));for(let r of t)e.has(r)||this.dispatchEvent(new CustomEvent("addmenuitem",{detail:r}));ar(this,Al,t)}),Ie(this,hn,()=>{we(this,os,mn).call(this,!1),we(this,Il,Gh).call(this,!1)}),Ie(this,fn,()=>{we(this,os,mn).call(this,!1)}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.nativeEl=this.constructor.template.content.cloneNode(!0),this.shadowRoot.append(this.nativeEl)),this.container=this.shadowRoot.querySelector("#container"),this.defaultSlot=this.shadowRoot.querySelector("slot:not([name])"),this.shadowRoot.addEventListener("slotchange",this),ar(this,Sl,new MutationObserver(Se(this,kl))),Se(this,Sl).observe(this.defaultSlot,{childList:!0})}static get observedAttributes(){return[ss.DISABLED,ss.HIDDEN,ss.STYLE,ss.ANCHOR,ee.MEDIA_CONTROLLER]}static formatMenuItemText(e){return e}enable(){this.addEventListener("click",this),this.addEventListener("focusout",this),this.addEventListener("keydown",this),this.addEventListener("invoke",this),this.addEventListener("toggle",this)}disable(){this.removeEventListener("click",this),this.removeEventListener("focusout",this),this.removeEventListener("keyup",this),this.removeEventListener("invoke",this),this.removeEventListener("toggle",this)}handleEvent(e){switch(e.type){case"slotchange":we(this,wh,uE).call(this,e);break;case"invoke":we(this,Dh,cE).call(this,e);break;case"click":we(this,Oh,mE).call(this,e);break;case"toggle":we(this,Nh,gE).call(this,e);break;case"focusout":we(this,Uh,EE).call(this,e);break;case"keydown":we(this,Fh,bE).call(this,e);break}}connectedCallback(){var e,t;we(this,xl,Ch).call(this),this.hasAttribute("disabled")||this.enable(),this.role||(this.role="menu"),ar(this,ki,Jo(this)),(t=(e=Se(this,ki))==null?void 0:e.associateElement)==null||t.call(e,this),this.hidden||(Kt(Ea(this),Se(this,hn)),Kt(this,Se(this,fn)))}disconnectedCallback(){var e,t;Si(Ea(this),Se(this,hn)),Si(this,Se(this,fn)),this.disable(),(t=(e=Se(this,ki))==null?void 0:e.unassociateElement)==null||t.call(e,this),ar(this,ki,null)}attributeChangedCallback(e,t,r){var s,n,a,o;e===ss.HIDDEN&&r!==t?(Se(this,as)||ar(this,as,!0),this.hidden?we(this,Ph,fE).call(this):we(this,Mh,hE).call(this),this.dispatchEvent(new _l({oldState:this.hidden?"open":"closed",newState:this.hidden?"closed":"open",bubbles:!0}))):e===ee.MEDIA_CONTROLLER?(t&&((n=(s=Se(this,ki))==null?void 0:s.unassociateElement)==null||n.call(s,this),ar(this,ki,null)),r&&this.isConnected&&(ar(this,ki,Jo(this)),(o=(a=Se(this,ki))==null?void 0:a.associateElement)==null||o.call(a,this))):e===ss.DISABLED&&r!==t?r==null?this.enable():this.disable():e===ss.STYLE&&r!==t&&we(this,xl,Ch).call(this)}formatMenuItemText(e,t){return this.constructor.formatMenuItemText(e,t)}get anchor(){return this.getAttribute("anchor")}set anchor(e){this.setAttribute("anchor",`${e}`)}get anchorElement(){var e;return this.anchor?(e=Qr(this))==null?void 0:e.querySelector(`#${this.anchor}`):null}get items(){return this.defaultSlot.assignedElements({flatten:!0}).filter(AS)}get radioGroupItems(){return this.items.filter(e=>e.role==="menuitemradio")}get checkedItems(){return this.items.filter(e=>e.checked)}get value(){var e,t;return(t=(e=this.checkedItems[0])==null?void 0:e.value)!=null?t:""}set value(e){let t=this.items.find(r=>r.value===e);t&&we(this,Ll,$h).call(this,t)}focus(){if(ar(this,ns,Xr()),this.items.length){we(this,va,wl).call(this,this.items[0]),this.items[0].focus();return}let e=this.querySelector('[autofocus], [tabindex]:not([tabindex="-1"]), [role="menu"]');e==null||e.focus()}handleSelect(e){var t;let r=we(this,ga,Rl).call(this,e);r&&(we(this,Ll,$h).call(this,r,r.type==="checkbox"),Se(this,xr)&&!this.hidden&&((t=Se(this,ns))==null||t.focus(),this.hidden=!0))}get keysUsed(){return["Enter","Escape","Tab"," ","ArrowDown","ArrowUp","Home","End"]}handleMove(e){var t,r;let{key:s}=e,n=this.items,a=(r=(t=we(this,ga,Rl).call(this,e))!=null?t:we(this,Bh,yE).call(this))!=null?r:n[0],o=n.indexOf(a),l=Math.max(0,o);s==="ArrowDown"?l++:s==="ArrowUp"?l--:e.key==="Home"?l=0:e.key==="End"&&(l=n.length-1),l<0&&(l=n.length-1),l>n.length-1&&(l=0),we(this,va,wl).call(this,n[l]),n[l].focus()}};ki=new WeakMap;ns=new WeakMap;xr=new WeakMap;lE=new WeakMap;dE=new WeakMap;Al=new WeakMap;Sl=new WeakMap;as=new WeakMap;wh=new WeakSet;uE=function(i){let e=i.target;for(let t of e.assignedNodes({flatten:!0}))t.nodeType===3&&t.textContent.trim()===""&&t.remove();if(["header","title"].includes(e.name)){let t=this.shadowRoot.querySelector('slot[name="header"]');t.hidden=e.assignedNodes().length===0}e.name||Se(this,kl).call(this)};kl=new WeakMap;xl=new WeakSet;Ch=function(){var i;let e=this.shadowRoot.querySelector("#layout-row"),t=(i=getComputedStyle(this).getPropertyValue("--media-menu-layout"))==null?void 0:i.trim();e.setAttribute("media",t==="row"?"":"width:0")};Dh=new WeakSet;cE=function(i){ar(this,xr,i.relatedTarget),yt(this,i.relatedTarget)||(this.hidden=!this.hidden)};Mh=new WeakSet;hE=function(){var i;(i=Se(this,xr))==null||i.setAttribute("aria-expanded","true"),requestAnimationFrame(()=>we(this,os,mn).call(this,!1)),this.addEventListener("transitionend",()=>this.focus(),{once:!0}),Kt(Ea(this),Se(this,hn)),Kt(this,Se(this,fn))};Ph=new WeakSet;fE=function(){var i;(i=Se(this,xr))==null||i.setAttribute("aria-expanded","false"),Si(Ea(this),Se(this,hn)),Si(this,Se(this,fn))};hn=new WeakMap;fn=new WeakMap;os=new WeakSet;mn=function(i,e){if(this.hasAttribute("mediacontroller")&&!this.anchor||this.hidden||!this.anchorElement)return;let{x:t,y:r}=aE({anchor:this.anchorElement,floating:this,placement:"top-start"});e!=null||(e=this.offsetWidth);let n=Ea(this).getBoundingClientRect(),a=this.anchorElement.getBoundingClientRect(),o=n.width-t-e,l=n.height-r-this.offsetHeight,d=n.height-a.height,{style:u}=Te(this.shadowRoot,":host");i||u.setProperty("--media-menu-transition-in","none"),u.setProperty("position","absolute"),u.setProperty("right",`${Math.max(0,o)}px`),u.setProperty("bottom",`${l}px`),u.setProperty("--_menu-max-height",`${d}px`),u.removeProperty("--media-menu-transition-in")};Il=new WeakSet;Gh=function(i){let e=this.querySelector('[role="menuitem"][aria-haspopup][aria-expanded="true"]'),t=e==null?void 0:e.querySelector('[role="menu"]'),{style:r}=Te(this.shadowRoot,":host");if(i||r.setProperty("--media-menu-transition-in","none"),t){let s=t.offsetHeight,n=Math.max(t.offsetWidth,e.offsetWidth);this.style.setProperty("min-width",`${n}px`),this.style.setProperty("min-height",`${s}px`),we(this,os,mn).call(this,i,n)}else this.style.removeProperty("min-width"),this.style.removeProperty("min-height"),we(this,os,mn).call(this,i);r.removeProperty("--media-menu-transition-in")};Oh=new WeakSet;mE=function(i){var e;if(i.stopPropagation(),i.composedPath().includes(Se(this,Wh,pE))){(e=Se(this,ns))==null||e.focus(),this.hidden=!0;return}let t=we(this,ga,Rl).call(this,i);!t||t.hasAttribute("disabled")||(we(this,va,wl).call(this,t),this.handleSelect(i))};Wh=new WeakSet;pE=function(){var i;return(i=this.shadowRoot.querySelector('slot[name="header"]').assignedElements({flatten:!0}))==null?void 0:i.find(t=>t.part.contains("back")&&t.part.contains("button"))};Nh=new WeakSet;gE=function(i){if(i.target===this)return;we(this,Vh,vE).call(this);let e=Array.from(this.querySelectorAll('[role="menuitem"][aria-haspopup]'));for(let t of e)t.invokeTargetElement!=i.target&&i.newState=="open"&&t.getAttribute("aria-expanded")=="true"&&!t.invokeTargetElement.hidden&&t.invokeTargetElement.dispatchEvent(new Sr({relatedTarget:t}));for(let t of e)t.setAttribute("aria-expanded",`${!t.submenuElement.hidden}`);we(this,Il,Gh).call(this,!0)};Vh=new WeakSet;vE=function(){let i='[role="menuitem"] > [role="menu"]:not([hidden])',e=this.querySelector(i);this.container.classList.toggle("has-expanded",!!e)};Uh=new WeakSet;EE=function(i){var e;yt(this,i.relatedTarget)||(Se(this,as)&&((e=Se(this,ns))==null||e.focus()),Se(this,xr)&&Se(this,xr)!==i.relatedTarget&&!this.hidden&&(this.hidden=!0))};Fh=new WeakSet;bE=function(i){var e,t,r,s,n;let{key:a,ctrlKey:o,altKey:l,metaKey:d}=i;if(!(o||l||d)&&this.keysUsed.includes(a))if(i.preventDefault(),i.stopPropagation(),a==="Tab"){if(Se(this,as)){this.hidden=!0;return}i.shiftKey?(t=(e=this.previousElementSibling)==null?void 0:e.focus)==null||t.call(e):(s=(r=this.nextElementSibling)==null?void 0:r.focus)==null||s.call(r),this.blur()}else a==="Escape"?((n=Se(this,ns))==null||n.focus(),Se(this,as)&&(this.hidden=!0)):a==="Enter"||a===" "?this.handleSelect(i):this.handleMove(i)};ga=new WeakSet;Rl=function(i){return i.composedPath().find(e=>["menuitemradio","menuitemcheckbox"].includes(e.role))};Bh=new WeakSet;yE=function(){return this.items.find(i=>i.tabIndex===0)};va=new WeakSet;wl=function(i){for(let e of this.items)e.tabIndex=e===i?0:-1};Ll=new WeakSet;$h=function(i,e){let t=[...this.checkedItems];i.type==="radio"&&this.radioGroupItems.forEach(r=>r.checked=!1),e?i.checked=!i.checked:i.checked=!0,this.checkedItems.some((r,s)=>r!=t[s])&&this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))};_S(Tt,"template",TE);function AS(i){return["menuitem","menuitemradio","menuitemcheckbox"].includes(i==null?void 0:i.role)}function Ea(i){var e;return(e=i.getAttribute("bounds")?ai(i,`#${i.getAttribute("bounds")}`):qe(i)||i.parentElement)!=null?e:i}A.customElements.get("media-chrome-menu")||A.customElements.define("media-chrome-menu",Tt);var jh=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},_E=(i,e,t)=>(jh(i,e,"read from private field"),t?t.call(i):e.get(i)),Cl=(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)},Kh=(i,e,t,r)=>(jh(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Dl=(i,e,t)=>(jh(i,e,"access private method"),t),ba,Ol,Ml,qh,Pl,Yh,zh=class extends Tt{constructor(){super(...arguments),Cl(this,Ml),Cl(this,Pl),Cl(this,ba,[]),Cl(this,Ol,void 0)}static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_AUDIO_TRACK_LIST,b.MEDIA_AUDIO_TRACK_ENABLED,b.MEDIA_AUDIO_TRACK_UNAVAILABLE]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_AUDIO_TRACK_ENABLED&&t!==r?this.value=r:e===b.MEDIA_AUDIO_TRACK_LIST&&t!==r&&(Kh(this,ba,Yo(r)),Dl(this,Ml,qh).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Dl(this,Pl,Yh))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Dl(this,Pl,Yh))}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:qe(this).querySelector("media-audio-track-menu-button")}get mediaAudioTrackList(){return _E(this,ba)}set mediaAudioTrackList(e){Kh(this,ba,e),Dl(this,Ml,qh).call(this)}get mediaAudioTrackEnabled(){return ue(this,b.MEDIA_AUDIO_TRACK_ENABLED)}set mediaAudioTrackEnabled(e){le(this,b.MEDIA_AUDIO_TRACK_ENABLED,e)}};ba=new WeakMap;Ol=new WeakMap;Ml=new WeakSet;qh=function(){if(_E(this,Ol)===JSON.stringify(this.mediaAudioTrackList))return;Kh(this,Ol,JSON.stringify(this.mediaAudioTrackList));let i=this.mediaAudioTrackList;this.defaultSlot.textContent="";for(let e of i){let t=this.formatMenuItemText(e.label,e),r=Ii({type:"radio",text:t,value:`${e.id}`,checked:e.enabled});r.prepend(di(this,"checked-indicator")),this.defaultSlot.append(r)}};Pl=new WeakSet;Yh=function(){if(this.value==null)return;let i=new A.CustomEvent(F.MEDIA_AUDIO_TRACK_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};A.customElements.get("media-audio-track-menu")||A.customElements.define("media-audio-track-menu",zh);var $t=class extends be{connectedCallback(){super.connectedCallback(),this.invokeTargetElement&&this.setAttribute("aria-haspopup","menu")}get invokeTarget(){return this.getAttribute("invoketarget")}set invokeTarget(e){this.setAttribute("invoketarget",`${e}`)}get invokeTargetElement(){var e;return this.invokeTarget?(e=Qr(this))==null?void 0:e.querySelector(`#${this.invokeTarget}`):null}handleClick(){this.invokeTargetElement.dispatchEvent(new Sr({relatedTarget:this}))}};A.customElements.get("media-chrome-menu-button")||A.customElements.define("media-chrome-menu-button",$t);var SS=`<svg aria-hidden="true" viewBox="0 0 24 24">
375
+ `;var ns={STYLE:"style",HIDDEN:"hidden",DISABLED:"disabled",ANCHOR:"anchor"},Tt=class extends _.HTMLElement{constructor(){super(),Ie(this,Ph),Ie(this,xl),Ie(this,Nh),Ie(this,Uh),Ie(this,Fh),Ie(this,ls),Ie(this,Il),Ie(this,Bh),Ie(this,Yh),Ie(this,$h),Ie(this,zh),Ie(this,Hh),Ie(this,Gh),Ie(this,ga),Ie(this,Wh),Ie(this,va),Ie(this,Ll),Ie(this,ki,void 0),Ie(this,as,void 0),Ie(this,xr,void 0),Ie(this,uE,""),Ie(this,cE,null),Ie(this,Al,new Set),Ie(this,Sl,void 0),Ie(this,os,!1),Ie(this,kl,()=>{let e=Se(this,Al),t=new Set(this.items);for(let r of e)t.has(r)||this.dispatchEvent(new CustomEvent("removemenuitem",{detail:r}));for(let r of t)e.has(r)||this.dispatchEvent(new CustomEvent("addmenuitem",{detail:r}));ar(this,Al,t)}),Ie(this,fn,()=>{we(this,ls,pn).call(this,!1),we(this,Il,qh).call(this,!1)}),Ie(this,mn,()=>{we(this,ls,pn).call(this,!1)}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.nativeEl=this.constructor.template.content.cloneNode(!0),this.shadowRoot.append(this.nativeEl)),this.container=this.shadowRoot.querySelector("#container"),this.defaultSlot=this.shadowRoot.querySelector("slot:not([name])"),this.shadowRoot.addEventListener("slotchange",this),ar(this,Sl,new MutationObserver(Se(this,kl))),Se(this,Sl).observe(this.defaultSlot,{childList:!0})}static get observedAttributes(){return[ns.DISABLED,ns.HIDDEN,ns.STYLE,ns.ANCHOR,te.MEDIA_CONTROLLER]}static formatMenuItemText(e){return e}enable(){this.addEventListener("click",this),this.addEventListener("focusout",this),this.addEventListener("keydown",this),this.addEventListener("invoke",this),this.addEventListener("toggle",this)}disable(){this.removeEventListener("click",this),this.removeEventListener("focusout",this),this.removeEventListener("keyup",this),this.removeEventListener("invoke",this),this.removeEventListener("toggle",this)}handleEvent(e){switch(e.type){case"slotchange":we(this,Ph,hE).call(this,e);break;case"invoke":we(this,Nh,fE).call(this,e);break;case"click":we(this,Bh,gE).call(this,e);break;case"toggle":we(this,$h,EE).call(this,e);break;case"focusout":we(this,Hh,yE).call(this,e);break;case"keydown":we(this,Gh,TE).call(this,e);break}}connectedCallback(){var e,t;we(this,xl,Oh).call(this),this.hasAttribute("disabled")||this.enable(),this.role||(this.role="menu"),ar(this,ki,Jo(this)),(t=(e=Se(this,ki))==null?void 0:e.associateElement)==null||t.call(e,this),this.hidden||(Vt(Ea(this),Se(this,fn)),Vt(this,Se(this,mn)))}disconnectedCallback(){var e,t;Si(Ea(this),Se(this,fn)),Si(this,Se(this,mn)),this.disable(),(t=(e=Se(this,ki))==null?void 0:e.unassociateElement)==null||t.call(e,this),ar(this,ki,null)}attributeChangedCallback(e,t,r){var s,n,a,o;e===ns.HIDDEN&&r!==t?(Se(this,os)||ar(this,os,!0),this.hidden?we(this,Fh,pE).call(this):we(this,Uh,mE).call(this),this.dispatchEvent(new _l({oldState:this.hidden?"open":"closed",newState:this.hidden?"closed":"open",bubbles:!0}))):e===te.MEDIA_CONTROLLER?(t&&((n=(s=Se(this,ki))==null?void 0:s.unassociateElement)==null||n.call(s,this),ar(this,ki,null)),r&&this.isConnected&&(ar(this,ki,Jo(this)),(o=(a=Se(this,ki))==null?void 0:a.associateElement)==null||o.call(a,this))):e===ns.DISABLED&&r!==t?r==null?this.enable():this.disable():e===ns.STYLE&&r!==t&&we(this,xl,Oh).call(this)}formatMenuItemText(e,t){return this.constructor.formatMenuItemText(e,t)}get anchor(){return this.getAttribute("anchor")}set anchor(e){this.setAttribute("anchor",`${e}`)}get anchorElement(){var e;return this.anchor?(e=Zr(this))==null?void 0:e.querySelector(`#${this.anchor}`):null}get items(){return this.defaultSlot.assignedElements({flatten:!0}).filter(TS)}get radioGroupItems(){return this.items.filter(e=>e.role==="menuitemradio")}get checkedItems(){return this.items.filter(e=>e.checked)}get value(){var e,t;return(t=(e=this.checkedItems[0])==null?void 0:e.value)!=null?t:""}set value(e){let t=this.items.find(r=>r.value===e);t&&we(this,Ll,Kh).call(this,t)}focus(){if(ar(this,as,Qr()),this.items.length){we(this,va,wl).call(this,this.items[0]),this.items[0].focus();return}let e=this.querySelector('[autofocus], [tabindex]:not([tabindex="-1"]), [role="menu"]');e==null||e.focus()}handleSelect(e){var t;let r=we(this,ga,Rl).call(this,e);r&&(we(this,Ll,Kh).call(this,r,r.type==="checkbox"),Se(this,xr)&&!this.hidden&&((t=Se(this,as))==null||t.focus(),this.hidden=!0))}get keysUsed(){return["Enter","Escape","Tab"," ","ArrowDown","ArrowUp","Home","End"]}handleMove(e){var t,r;let{key:s}=e,n=this.items,a=(r=(t=we(this,ga,Rl).call(this,e))!=null?t:we(this,Wh,_E).call(this))!=null?r:n[0],o=n.indexOf(a),l=Math.max(0,o);s==="ArrowDown"?l++:s==="ArrowUp"?l--:e.key==="Home"?l=0:e.key==="End"&&(l=n.length-1),l<0&&(l=n.length-1),l>n.length-1&&(l=0),we(this,va,wl).call(this,n[l]),n[l].focus()}};ki=new WeakMap;as=new WeakMap;xr=new WeakMap;uE=new WeakMap;cE=new WeakMap;Al=new WeakMap;Sl=new WeakMap;os=new WeakMap;Ph=new WeakSet;hE=function(i){let e=i.target;for(let t of e.assignedNodes({flatten:!0}))t.nodeType===3&&t.textContent.trim()===""&&t.remove();if(["header","title"].includes(e.name)){let t=this.shadowRoot.querySelector('slot[name="header"]');t.hidden=e.assignedNodes().length===0}e.name||Se(this,kl).call(this)};kl=new WeakMap;xl=new WeakSet;Oh=function(){var i;let e=this.shadowRoot.querySelector("#layout-row"),t=(i=getComputedStyle(this).getPropertyValue("--media-menu-layout"))==null?void 0:i.trim();e.setAttribute("media",t==="row"?"":"width:0")};Nh=new WeakSet;fE=function(i){ar(this,xr,i.relatedTarget),yt(this,i.relatedTarget)||(this.hidden=!this.hidden)};Uh=new WeakSet;mE=function(){var i;(i=Se(this,xr))==null||i.setAttribute("aria-expanded","true"),requestAnimationFrame(()=>we(this,ls,pn).call(this,!1)),this.addEventListener("transitionend",()=>this.focus(),{once:!0}),Vt(Ea(this),Se(this,fn)),Vt(this,Se(this,mn))};Fh=new WeakSet;pE=function(){var i;(i=Se(this,xr))==null||i.setAttribute("aria-expanded","false"),Si(Ea(this),Se(this,fn)),Si(this,Se(this,mn))};fn=new WeakMap;mn=new WeakMap;ls=new WeakSet;pn=function(i,e){if(this.hasAttribute("mediacontroller")&&!this.anchor||this.hidden||!this.anchorElement)return;let{x:t,y:r}=lE({anchor:this.anchorElement,floating:this,placement:"top-start"});e!=null||(e=this.offsetWidth);let n=Ea(this).getBoundingClientRect(),a=this.anchorElement.getBoundingClientRect(),o=n.width-t-e,l=n.height-r-this.offsetHeight,d=n.height-a.height,{style:u}=Te(this.shadowRoot,":host");i||u.setProperty("--media-menu-transition-in","none"),u.setProperty("position","absolute"),u.setProperty("right",`${Math.max(0,o)}px`),u.setProperty("bottom",`${l}px`),u.setProperty("--_menu-max-height",`${d}px`),u.removeProperty("--media-menu-transition-in")};Il=new WeakSet;qh=function(i){let e=this.querySelector('[role="menuitem"][aria-haspopup][aria-expanded="true"]'),t=e==null?void 0:e.querySelector('[role="menu"]'),{style:r}=Te(this.shadowRoot,":host");if(i||r.setProperty("--media-menu-transition-in","none"),t){let s=t.offsetHeight,n=Math.max(t.offsetWidth,e.offsetWidth);this.style.setProperty("min-width",`${n}px`),this.style.setProperty("min-height",`${s}px`),we(this,ls,pn).call(this,i,n)}else this.style.removeProperty("min-width"),this.style.removeProperty("min-height"),we(this,ls,pn).call(this,i);r.removeProperty("--media-menu-transition-in")};Bh=new WeakSet;gE=function(i){var e;if(i.stopPropagation(),i.composedPath().includes(Se(this,Yh,vE))){(e=Se(this,as))==null||e.focus(),this.hidden=!0;return}let t=we(this,ga,Rl).call(this,i);!t||t.hasAttribute("disabled")||(we(this,va,wl).call(this,t),this.handleSelect(i))};Yh=new WeakSet;vE=function(){var i;return(i=this.shadowRoot.querySelector('slot[name="header"]').assignedElements({flatten:!0}))==null?void 0:i.find(t=>t.part.contains("back")&&t.part.contains("button"))};$h=new WeakSet;EE=function(i){if(i.target===this)return;we(this,zh,bE).call(this);let e=Array.from(this.querySelectorAll('[role="menuitem"][aria-haspopup]'));for(let t of e)t.invokeTargetElement!=i.target&&i.newState=="open"&&t.getAttribute("aria-expanded")=="true"&&!t.invokeTargetElement.hidden&&t.invokeTargetElement.dispatchEvent(new Sr({relatedTarget:t}));for(let t of e)t.setAttribute("aria-expanded",`${!t.submenuElement.hidden}`);we(this,Il,qh).call(this,!0)};zh=new WeakSet;bE=function(){let i='[role="menuitem"] > [role="menu"]:not([hidden])',e=this.querySelector(i);this.container.classList.toggle("has-expanded",!!e)};Hh=new WeakSet;yE=function(i){var e;yt(this,i.relatedTarget)||(Se(this,os)&&((e=Se(this,as))==null||e.focus()),Se(this,xr)&&Se(this,xr)!==i.relatedTarget&&!this.hidden&&(this.hidden=!0))};Gh=new WeakSet;TE=function(i){var e,t,r,s,n;let{key:a,ctrlKey:o,altKey:l,metaKey:d}=i;if(!(o||l||d)&&this.keysUsed.includes(a))if(i.preventDefault(),i.stopPropagation(),a==="Tab"){if(Se(this,os)){this.hidden=!0;return}i.shiftKey?(t=(e=this.previousElementSibling)==null?void 0:e.focus)==null||t.call(e):(s=(r=this.nextElementSibling)==null?void 0:r.focus)==null||s.call(r),this.blur()}else a==="Escape"?((n=Se(this,as))==null||n.focus(),Se(this,os)&&(this.hidden=!0)):a==="Enter"||a===" "?this.handleSelect(i):this.handleMove(i)};ga=new WeakSet;Rl=function(i){return i.composedPath().find(e=>["menuitemradio","menuitemcheckbox"].includes(e.role))};Wh=new WeakSet;_E=function(){return this.items.find(i=>i.tabIndex===0)};va=new WeakSet;wl=function(i){for(let e of this.items)e.tabIndex=e===i?0:-1};Ll=new WeakSet;Kh=function(i,e){let t=[...this.checkedItems];i.type==="radio"&&this.radioGroupItems.forEach(r=>r.checked=!1),e?i.checked=!i.checked:i.checked=!0,this.checkedItems.some((r,s)=>r!=t[s])&&this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))};yS(Tt,"template",AE);function TS(i){return["menuitem","menuitemradio","menuitemcheckbox"].includes(i==null?void 0:i.role)}function Ea(i){var e;return(e=i.getAttribute("bounds")?ai(i,`#${i.getAttribute("bounds")}`):Ye(i)||i.parentElement)!=null?e:i}_.customElements.get("media-chrome-menu")||_.customElements.define("media-chrome-menu",Tt);var Jh=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},SE=(i,e,t)=>(Jh(i,e,"read from private field"),t?t.call(i):e.get(i)),Cl=(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)},jh=(i,e,t,r)=>(Jh(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Dl=(i,e,t)=>(Jh(i,e,"access private method"),t),ba,Ol,Ml,Xh,Pl,Qh,Zh=class extends Tt{constructor(){super(...arguments),Cl(this,Ml),Cl(this,Pl),Cl(this,ba,[]),Cl(this,Ol,void 0)}static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_AUDIO_TRACK_LIST,b.MEDIA_AUDIO_TRACK_ENABLED,b.MEDIA_AUDIO_TRACK_UNAVAILABLE]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_AUDIO_TRACK_ENABLED&&t!==r?this.value=r:e===b.MEDIA_AUDIO_TRACK_LIST&&t!==r&&(jh(this,ba,Yo(r)),Dl(this,Ml,Xh).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Dl(this,Pl,Qh))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Dl(this,Pl,Qh))}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:Ye(this).querySelector("media-audio-track-menu-button")}get mediaAudioTrackList(){return SE(this,ba)}set mediaAudioTrackList(e){jh(this,ba,e),Dl(this,Ml,Xh).call(this)}get mediaAudioTrackEnabled(){return ue(this,b.MEDIA_AUDIO_TRACK_ENABLED)}set mediaAudioTrackEnabled(e){le(this,b.MEDIA_AUDIO_TRACK_ENABLED,e)}};ba=new WeakMap;Ol=new WeakMap;Ml=new WeakSet;Xh=function(){if(SE(this,Ol)===JSON.stringify(this.mediaAudioTrackList))return;jh(this,Ol,JSON.stringify(this.mediaAudioTrackList));let i=this.mediaAudioTrackList;this.defaultSlot.textContent="";for(let e of i){let t=this.formatMenuItemText(e.label,e),r=Ii({type:"radio",text:t,value:`${e.id}`,checked:e.enabled});r.prepend(di(this,"checked-indicator")),this.defaultSlot.append(r)}};Pl=new WeakSet;Qh=function(){if(this.value==null)return;let i=new _.CustomEvent(B.MEDIA_AUDIO_TRACK_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};_.customElements.get("media-audio-track-menu")||_.customElements.define("media-audio-track-menu",Zh);var $t=class extends be{connectedCallback(){super.connectedCallback(),this.invokeTargetElement&&this.setAttribute("aria-haspopup","menu")}get invokeTarget(){return this.getAttribute("invoketarget")}set invokeTarget(e){this.setAttribute("invoketarget",`${e}`)}get invokeTargetElement(){var e;return this.invokeTarget?(e=Zr(this))==null?void 0:e.querySelector(`#${this.invokeTarget}`):null}handleClick(){this.invokeTargetElement.dispatchEvent(new Sr({relatedTarget:this}))}};_.customElements.get("media-chrome-menu-button")||_.customElements.define("media-chrome-menu-button",$t);var _S=`<svg aria-hidden="true" viewBox="0 0 24 24">
376
376
  <path d="M11 17H9.5V7H11v10Zm-3-3H6.5v-4H8v4Zm6-5h-1.5v6H14V9Zm3 7h-1.5V8H17v8Z"/>
377
377
  <path d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Zm-2 0a8 8 0 1 0-16 0 8 8 0 0 0 16 0Z"/>
378
- </svg>`,AE=O.createElement("template");AE.innerHTML=`
379
- <slot name="icon">${SS}</slot>
380
- `;var Xh=class extends $t{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_AUDIO_TRACK_ENABLED,b.MEDIA_AUDIO_TRACK_UNAVAILABLE]}constructor(){super({slotTemplate:AE})}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",Ce.AUDIO_TRACKS())}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:qe(this).querySelector("media-audio-track-menu")}get mediaAudioTrackEnabled(){return ue(this,b.MEDIA_AUDIO_TRACK_ENABLED)}set mediaAudioTrackEnabled(e){le(this,b.MEDIA_AUDIO_TRACK_ENABLED,e)}};A.customElements.get("media-audio-track-menu-button")||A.customElements.define("media-audio-track-menu-button",Xh);var xS=`<svg aria-hidden="true" viewBox="0 0 26 24">
378
+ </svg>`,xE=O.createElement("template");xE.innerHTML=`
379
+ <slot name="icon">${_S}</slot>
380
+ `;var ef=class extends $t{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_AUDIO_TRACK_ENABLED,b.MEDIA_AUDIO_TRACK_UNAVAILABLE]}constructor(){super({slotTemplate:xE})}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",De.AUDIO_TRACKS())}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:Ye(this).querySelector("media-audio-track-menu")}get mediaAudioTrackEnabled(){return ue(this,b.MEDIA_AUDIO_TRACK_ENABLED)}set mediaAudioTrackEnabled(e){le(this,b.MEDIA_AUDIO_TRACK_ENABLED,e)}};_.customElements.get("media-audio-track-menu-button")||_.customElements.define("media-audio-track-menu-button",ef);var AS=`<svg aria-hidden="true" viewBox="0 0 26 24">
381
381
  <path d="M22.83 5.68a2.58 2.58 0 0 0-2.3-2.5c-3.62-.24-11.44-.24-15.06 0a2.58 2.58 0 0 0-2.3 2.5c-.23 4.21-.23 8.43 0 12.64a2.58 2.58 0 0 0 2.3 2.5c3.62.24 11.44.24 15.06 0a2.58 2.58 0 0 0 2.3-2.5c.23-4.21.23-8.43 0-12.64Zm-11.39 9.45a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.92 3.92 0 0 1 .92-2.77 3.18 3.18 0 0 1 2.43-1 2.94 2.94 0 0 1 2.13.78c.364.359.62.813.74 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.17 1.61 1.61 0 0 0-1.29.58 2.79 2.79 0 0 0-.5 1.89 3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.48 1.48 0 0 0 1-.37 2.1 2.1 0 0 0 .59-1.14l1.4.44a3.23 3.23 0 0 1-1.07 1.69Zm7.22 0a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.88 3.88 0 0 1 .93-2.77 3.14 3.14 0 0 1 2.42-1 3 3 0 0 1 2.16.82 2.8 2.8 0 0 1 .73 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.21 1.61 1.61 0 0 0-1.29.58A2.79 2.79 0 0 0 15 12a3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.44 1.44 0 0 0 1-.37 2.1 2.1 0 0 0 .6-1.15l1.4.44a3.17 3.17 0 0 1-1.1 1.7Z"/>
382
- </svg>`,LS=`<svg aria-hidden="true" viewBox="0 0 26 24">
382
+ </svg>`,SS=`<svg aria-hidden="true" viewBox="0 0 26 24">
383
383
  <path d="M17.73 14.09a1.4 1.4 0 0 1-1 .37 1.579 1.579 0 0 1-1.27-.58A3 3 0 0 1 15 12a2.8 2.8 0 0 1 .5-1.85 1.63 1.63 0 0 1 1.29-.57 1.47 1.47 0 0 1 1.51 1.2l1.43-.34A2.89 2.89 0 0 0 19 9.07a3 3 0 0 0-2.14-.78 3.14 3.14 0 0 0-2.42 1 3.91 3.91 0 0 0-.93 2.78 3.74 3.74 0 0 0 .92 2.66 3.07 3.07 0 0 0 2.34 1 3.07 3.07 0 0 0 1.91-.57 3.17 3.17 0 0 0 1.07-1.74l-1.4-.45c-.083.43-.3.822-.62 1.12Zm-7.22 0a1.43 1.43 0 0 1-1 .37 1.58 1.58 0 0 1-1.27-.58A3 3 0 0 1 7.76 12a2.8 2.8 0 0 1 .5-1.85 1.63 1.63 0 0 1 1.29-.57 1.47 1.47 0 0 1 1.51 1.2l1.43-.34a2.81 2.81 0 0 0-.74-1.32 2.94 2.94 0 0 0-2.13-.78 3.18 3.18 0 0 0-2.43 1 4 4 0 0 0-.92 2.78 3.74 3.74 0 0 0 .92 2.66 3.07 3.07 0 0 0 2.34 1 3.07 3.07 0 0 0 1.91-.57 3.23 3.23 0 0 0 1.07-1.74l-1.4-.45a2.06 2.06 0 0 1-.6 1.07Zm12.32-8.41a2.59 2.59 0 0 0-2.3-2.51C18.72 3.05 15.86 3 13 3c-2.86 0-5.72.05-7.53.17a2.59 2.59 0 0 0-2.3 2.51c-.23 4.207-.23 8.423 0 12.63a2.57 2.57 0 0 0 2.3 2.5c1.81.13 4.67.19 7.53.19 2.86 0 5.72-.06 7.53-.19a2.57 2.57 0 0 0 2.3-2.5c.23-4.207.23-8.423 0-12.63Zm-1.49 12.53a1.11 1.11 0 0 1-.91 1.11c-1.67.11-4.45.18-7.43.18-2.98 0-5.76-.07-7.43-.18a1.11 1.11 0 0 1-.91-1.11c-.21-4.14-.21-8.29 0-12.43a1.11 1.11 0 0 1 .91-1.11C7.24 4.56 10 4.49 13 4.49s5.76.07 7.43.18a1.11 1.11 0 0 1 .91 1.11c.21 4.14.21 8.29 0 12.43Z"/>
384
- </svg>`,kE=O.createElement("template");kE.innerHTML=`
384
+ </svg>`,RE=O.createElement("template");RE.innerHTML=`
385
385
  <style>
386
386
  :host([aria-checked="true"]) slot[name=off] {
387
387
  display: none !important;
@@ -394,18 +394,18 @@
394
394
  </style>
395
395
 
396
396
  <slot name="icon">
397
- <slot name="on">${xS}</slot>
398
- <slot name="off">${LS}</slot>
397
+ <slot name="on">${AS}</slot>
398
+ <slot name="off">${SS}</slot>
399
399
  </slot>
400
- `;var SE=i=>{i.setAttribute("aria-checked",ll(i))},Qh=class extends be{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_SUBTITLES_LIST,b.MEDIA_SUBTITLES_SHOWING]}constructor(e={}){super({slotTemplate:kE,...e}),this._captionsReady=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("role","switch"),this.setAttribute("aria-label",Ce.CLOSED_CAPTIONS()),SE(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_SUBTITLES_SHOWING&&SE(this)}get mediaSubtitlesList(){return xE(this,b.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){LE(this,b.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return xE(this,b.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){LE(this,b.MEDIA_SUBTITLES_SHOWING,e)}handleClick(){this.dispatchEvent(new A.CustomEvent(F.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0}))}},xE=(i,e)=>{let t=i.getAttribute(e);return t?sr(t):[]},LE=(i,e,t)=>{if(!(t!=null&&t.length)){i.removeAttribute(e);return}let r=li(t);i.getAttribute(e)!==r&&i.setAttribute(e,r)};A.customElements.get("media-captions-button")||A.customElements.define("media-captions-button",Qh);var kS=Object.defineProperty,IS=(i,e,t)=>e in i?kS(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,RS=(i,e,t)=>(IS(i,typeof e!="symbol"?e+"":e,t),t),rf=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},wS=(i,e,t)=>(rf(i,e,"read from private field"),t?t.call(i):e.get(i)),Zh=(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)},CS=(i,e,t,r)=>(rf(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Jh=(i,e,t)=>(rf(i,e,"access private method"),t),Ul,ef,wE,Nl,tf,DS=`
400
+ `;var LE=i=>{i.setAttribute("aria-checked",ll(i))},tf=class extends be{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_SUBTITLES_LIST,b.MEDIA_SUBTITLES_SHOWING]}constructor(e={}){super({slotTemplate:RE,...e}),this._captionsReady=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("role","switch"),this.setAttribute("aria-label",De.CLOSED_CAPTIONS()),LE(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_SUBTITLES_SHOWING&&LE(this)}get mediaSubtitlesList(){return kE(this,b.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){IE(this,b.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return kE(this,b.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){IE(this,b.MEDIA_SUBTITLES_SHOWING,e)}handleClick(){this.dispatchEvent(new _.CustomEvent(B.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0}))}},kE=(i,e)=>{let t=i.getAttribute(e);return t?sr(t):[]},IE=(i,e,t)=>{if(!(t!=null&&t.length)){i.removeAttribute(e);return}let r=li(t);i.getAttribute(e)!==r&&i.setAttribute(e,r)};_.customElements.get("media-captions-button")||_.customElements.define("media-captions-button",tf);var xS=Object.defineProperty,LS=(i,e,t)=>e in i?xS(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,kS=(i,e,t)=>(LS(i,typeof e!="symbol"?e+"":e,t),t),of=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},IS=(i,e,t)=>(of(i,e,"read from private field"),t?t.call(i):e.get(i)),rf=(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)},RS=(i,e,t,r)=>(of(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),sf=(i,e,t)=>(of(i,e,"access private method"),t),Ul,nf,DE,Nl,af,wS=`
401
401
  <svg aria-hidden="true" viewBox="0 0 26 24" part="captions-indicator indicator">
402
402
  <path d="M22.83 5.68a2.58 2.58 0 0 0-2.3-2.5c-3.62-.24-11.44-.24-15.06 0a2.58 2.58 0 0 0-2.3 2.5c-.23 4.21-.23 8.43 0 12.64a2.58 2.58 0 0 0 2.3 2.5c3.62.24 11.44.24 15.06 0a2.58 2.58 0 0 0 2.3-2.5c.23-4.21.23-8.43 0-12.64Zm-11.39 9.45a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.92 3.92 0 0 1 .92-2.77 3.18 3.18 0 0 1 2.43-1 2.94 2.94 0 0 1 2.13.78c.364.359.62.813.74 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.17 1.61 1.61 0 0 0-1.29.58 2.79 2.79 0 0 0-.5 1.89 3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.48 1.48 0 0 0 1-.37 2.1 2.1 0 0 0 .59-1.14l1.4.44a3.23 3.23 0 0 1-1.07 1.69Zm7.22 0a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.88 3.88 0 0 1 .93-2.77 3.14 3.14 0 0 1 2.42-1 3 3 0 0 1 2.16.82 2.8 2.8 0 0 1 .73 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.21 1.61 1.61 0 0 0-1.29.58A2.79 2.79 0 0 0 15 12a3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.44 1.44 0 0 0 1-.37 2.1 2.1 0 0 0 .6-1.15l1.4.44a3.17 3.17 0 0 1-1.1 1.7Z"/>
403
- </svg>`,CE=O.createElement("template");CE.innerHTML=Tt.template.innerHTML+`
404
- <slot name="captions-indicator" hidden>${DS}</slot>`;var Fl=class extends Tt{constructor(){super(...arguments),Zh(this,ef),Zh(this,Nl),Zh(this,Ul,void 0)}static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_SUBTITLES_LIST,b.MEDIA_SUBTITLES_SHOWING]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_SUBTITLES_LIST&&t!==r?Jh(this,ef,wE).call(this):e===b.MEDIA_SUBTITLES_SHOWING&&t!==r&&(this.value=r)}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Jh(this,Nl,tf))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Jh(this,Nl,tf))}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:qe(this).querySelector("media-captions-menu-button")}get mediaSubtitlesList(){return IE(this,b.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){RE(this,b.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return IE(this,b.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){RE(this,b.MEDIA_SUBTITLES_SHOWING,e)}};Ul=new WeakMap;ef=new WeakSet;wE=function(){var i;if(wS(this,Ul)===JSON.stringify(this.mediaSubtitlesList))return;CS(this,Ul,JSON.stringify(this.mediaSubtitlesList)),this.defaultSlot.textContent="";let e=!this.value,t=Ii({type:"radio",text:this.formatMenuItemText("Off"),value:"off",checked:e});t.prepend(di(this,"checked-indicator")),this.defaultSlot.append(t);let r=this.mediaSubtitlesList;for(let s of r){let n=Ii({type:"radio",text:this.formatMenuItemText(s.label,s),value:es(s),checked:this.value==es(s)});n.prepend(di(this,"checked-indicator")),((i=s.kind)!=null?i:"subs")==="captions"&&n.append(di(this,"captions-indicator")),this.defaultSlot.append(n)}};Nl=new WeakSet;tf=function(){let i=this.mediaSubtitlesShowing,e=this.getAttribute(b.MEDIA_SUBTITLES_SHOWING),t=this.value!==e;if(i!=null&&i.length&&t&&this.dispatchEvent(new A.CustomEvent(F.MEDIA_DISABLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:i})),!this.value||!t)return;let r=new A.CustomEvent(F.MEDIA_SHOW_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(r)};RS(Fl,"template",CE);var IE=(i,e)=>{let t=i.getAttribute(e);return t?sr(t):[]},RE=(i,e,t)=>{if(!(t!=null&&t.length)){i.removeAttribute(e);return}let r=li(t);i.getAttribute(e)!==r&&i.setAttribute(e,r)};A.customElements.get("media-captions-menu")||A.customElements.define("media-captions-menu",Fl);var MS=`<svg aria-hidden="true" viewBox="0 0 26 24">
403
+ </svg>`,ME=O.createElement("template");ME.innerHTML=Tt.template.innerHTML+`
404
+ <slot name="captions-indicator" hidden>${wS}</slot>`;var Fl=class extends Tt{constructor(){super(...arguments),rf(this,nf),rf(this,Nl),rf(this,Ul,void 0)}static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_SUBTITLES_LIST,b.MEDIA_SUBTITLES_SHOWING]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_SUBTITLES_LIST&&t!==r?sf(this,nf,DE).call(this):e===b.MEDIA_SUBTITLES_SHOWING&&t!==r&&(this.value=r)}connectedCallback(){super.connectedCallback(),this.addEventListener("change",sf(this,Nl,af))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",sf(this,Nl,af))}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:Ye(this).querySelector("media-captions-menu-button")}get mediaSubtitlesList(){return wE(this,b.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){CE(this,b.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return wE(this,b.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){CE(this,b.MEDIA_SUBTITLES_SHOWING,e)}};Ul=new WeakMap;nf=new WeakSet;DE=function(){var i;if(IS(this,Ul)===JSON.stringify(this.mediaSubtitlesList))return;RS(this,Ul,JSON.stringify(this.mediaSubtitlesList)),this.defaultSlot.textContent="";let e=!this.value,t=Ii({type:"radio",text:this.formatMenuItemText("Off"),value:"off",checked:e});t.prepend(di(this,"checked-indicator")),this.defaultSlot.append(t);let r=this.mediaSubtitlesList;for(let s of r){let n=Ii({type:"radio",text:this.formatMenuItemText(s.label,s),value:ts(s),checked:this.value==ts(s)});n.prepend(di(this,"checked-indicator")),((i=s.kind)!=null?i:"subs")==="captions"&&n.append(di(this,"captions-indicator")),this.defaultSlot.append(n)}};Nl=new WeakSet;af=function(){let i=this.mediaSubtitlesShowing,e=this.getAttribute(b.MEDIA_SUBTITLES_SHOWING),t=this.value!==e;if(i!=null&&i.length&&t&&this.dispatchEvent(new _.CustomEvent(B.MEDIA_DISABLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:i})),!this.value||!t)return;let r=new _.CustomEvent(B.MEDIA_SHOW_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(r)};kS(Fl,"template",ME);var wE=(i,e)=>{let t=i.getAttribute(e);return t?sr(t):[]},CE=(i,e,t)=>{if(!(t!=null&&t.length)){i.removeAttribute(e);return}let r=li(t);i.getAttribute(e)!==r&&i.setAttribute(e,r)};_.customElements.get("media-captions-menu")||_.customElements.define("media-captions-menu",Fl);var CS=`<svg aria-hidden="true" viewBox="0 0 26 24">
405
405
  <path d="M22.83 5.68a2.58 2.58 0 0 0-2.3-2.5c-3.62-.24-11.44-.24-15.06 0a2.58 2.58 0 0 0-2.3 2.5c-.23 4.21-.23 8.43 0 12.64a2.58 2.58 0 0 0 2.3 2.5c3.62.24 11.44.24 15.06 0a2.58 2.58 0 0 0 2.3-2.5c.23-4.21.23-8.43 0-12.64Zm-11.39 9.45a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.92 3.92 0 0 1 .92-2.77 3.18 3.18 0 0 1 2.43-1 2.94 2.94 0 0 1 2.13.78c.364.359.62.813.74 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.17 1.61 1.61 0 0 0-1.29.58 2.79 2.79 0 0 0-.5 1.89 3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.48 1.48 0 0 0 1-.37 2.1 2.1 0 0 0 .59-1.14l1.4.44a3.23 3.23 0 0 1-1.07 1.69Zm7.22 0a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.88 3.88 0 0 1 .93-2.77 3.14 3.14 0 0 1 2.42-1 3 3 0 0 1 2.16.82 2.8 2.8 0 0 1 .73 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.21 1.61 1.61 0 0 0-1.29.58A2.79 2.79 0 0 0 15 12a3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.44 1.44 0 0 0 1-.37 2.1 2.1 0 0 0 .6-1.15l1.4.44a3.17 3.17 0 0 1-1.1 1.7Z"/>
406
- </svg>`,PS=`<svg aria-hidden="true" viewBox="0 0 26 24">
406
+ </svg>`,DS=`<svg aria-hidden="true" viewBox="0 0 26 24">
407
407
  <path d="M17.73 14.09a1.4 1.4 0 0 1-1 .37 1.579 1.579 0 0 1-1.27-.58A3 3 0 0 1 15 12a2.8 2.8 0 0 1 .5-1.85 1.63 1.63 0 0 1 1.29-.57 1.47 1.47 0 0 1 1.51 1.2l1.43-.34A2.89 2.89 0 0 0 19 9.07a3 3 0 0 0-2.14-.78 3.14 3.14 0 0 0-2.42 1 3.91 3.91 0 0 0-.93 2.78 3.74 3.74 0 0 0 .92 2.66 3.07 3.07 0 0 0 2.34 1 3.07 3.07 0 0 0 1.91-.57 3.17 3.17 0 0 0 1.07-1.74l-1.4-.45c-.083.43-.3.822-.62 1.12Zm-7.22 0a1.43 1.43 0 0 1-1 .37 1.58 1.58 0 0 1-1.27-.58A3 3 0 0 1 7.76 12a2.8 2.8 0 0 1 .5-1.85 1.63 1.63 0 0 1 1.29-.57 1.47 1.47 0 0 1 1.51 1.2l1.43-.34a2.81 2.81 0 0 0-.74-1.32 2.94 2.94 0 0 0-2.13-.78 3.18 3.18 0 0 0-2.43 1 4 4 0 0 0-.92 2.78 3.74 3.74 0 0 0 .92 2.66 3.07 3.07 0 0 0 2.34 1 3.07 3.07 0 0 0 1.91-.57 3.23 3.23 0 0 0 1.07-1.74l-1.4-.45a2.06 2.06 0 0 1-.6 1.07Zm12.32-8.41a2.59 2.59 0 0 0-2.3-2.51C18.72 3.05 15.86 3 13 3c-2.86 0-5.72.05-7.53.17a2.59 2.59 0 0 0-2.3 2.51c-.23 4.207-.23 8.423 0 12.63a2.57 2.57 0 0 0 2.3 2.5c1.81.13 4.67.19 7.53.19 2.86 0 5.72-.06 7.53-.19a2.57 2.57 0 0 0 2.3-2.5c.23-4.207.23-8.423 0-12.63Zm-1.49 12.53a1.11 1.11 0 0 1-.91 1.11c-1.67.11-4.45.18-7.43.18-2.98 0-5.76-.07-7.43-.18a1.11 1.11 0 0 1-.91-1.11c-.21-4.14-.21-8.29 0-12.43a1.11 1.11 0 0 1 .91-1.11C7.24 4.56 10 4.49 13 4.49s5.76.07 7.43.18a1.11 1.11 0 0 1 .91 1.11c.21 4.14.21 8.29 0 12.43Z"/>
408
- </svg>`,OE=O.createElement("template");OE.innerHTML=`
408
+ </svg>`,UE=O.createElement("template");UE.innerHTML=`
409
409
  <style>
410
410
  :host([aria-checked="true"]) slot[name=off] {
411
411
  display: none !important;
@@ -418,10 +418,10 @@
418
418
  </style>
419
419
 
420
420
  <slot name="icon">
421
- <slot name="on">${MS}</slot>
422
- <slot name="off">${PS}</slot>
421
+ <slot name="on">${CS}</slot>
422
+ <slot name="off">${DS}</slot>
423
423
  </slot>
424
- `;var DE=i=>{i.setAttribute("aria-checked",ll(i))},sf=class extends $t{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_SUBTITLES_LIST,b.MEDIA_SUBTITLES_SHOWING]}constructor(e={}){super({slotTemplate:OE,...e}),this._captionsReady=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",Ce.CLOSED_CAPTIONS()),DE(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_SUBTITLES_SHOWING&&DE(this)}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:qe(this).querySelector("media-captions-menu")}get mediaSubtitlesList(){return ME(this,b.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){PE(this,b.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return ME(this,b.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){PE(this,b.MEDIA_SUBTITLES_SHOWING,e)}},ME=(i,e)=>{let t=i.getAttribute(e);return t?sr(t):[]},PE=(i,e,t)=>{if(!(t!=null&&t.length)){i.removeAttribute(e);return}let r=li(t);i.getAttribute(e)!==r&&i.setAttribute(e,r)};A.customElements.get("media-captions-menu-button")||A.customElements.define("media-captions-menu-button",sf);var OS='<svg aria-hidden="true" viewBox="0 0 24 24"><g><path class="cast_caf_icon_arch0" d="M1,18 L1,21 L4,21 C4,19.3 2.66,18 1,18 L1,18 Z"/><path class="cast_caf_icon_arch1" d="M1,14 L1,16 C3.76,16 6,18.2 6,21 L8,21 C8,17.13 4.87,14 1,14 L1,14 Z"/><path class="cast_caf_icon_arch2" d="M1,10 L1,12 C5.97,12 10,16.0 10,21 L12,21 C12,14.92 7.07,10 1,10 L1,10 Z"/><path class="cast_caf_icon_box" d="M21,3 L3,3 C1.9,3 1,3.9 1,5 L1,8 L3,8 L3,5 L21,5 L21,19 L14,19 L14,21 L21,21 C22.1,21 23,20.1 23,19 L23,5 C23,3.9 22.1,3 21,3 L21,3 Z"/></g></svg>',NS='<svg aria-hidden="true" viewBox="0 0 24 24"><g><path class="cast_caf_icon_arch0" d="M1,18 L1,21 L4,21 C4,19.3 2.66,18 1,18 L1,18 Z"/><path class="cast_caf_icon_arch1" d="M1,14 L1,16 C3.76,16 6,18.2 6,21 L8,21 C8,17.13 4.87,14 1,14 L1,14 Z"/><path class="cast_caf_icon_arch2" d="M1,10 L1,12 C5.97,12 10,16.0 10,21 L12,21 C12,14.92 7.07,10 1,10 L1,10 Z"/><path class="cast_caf_icon_box" d="M21,3 L3,3 C1.9,3 1,3.9 1,5 L1,8 L3,8 L3,5 L21,5 L21,19 L14,19 L14,21 L21,21 C22.1,21 23,20.1 23,19 L23,5 C23,3.9 22.1,3 21,3 L21,3 Z"/><path class="cast_caf_icon_boxfill" d="M5,7 L5,8.63 C8,8.6 13.37,14 13.37,17 L19,17 L19,7 Z"/></g></svg>',UE=O.createElement("template");UE.innerHTML=`
424
+ `;var PE=i=>{i.setAttribute("aria-checked",ll(i))},lf=class extends $t{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_SUBTITLES_LIST,b.MEDIA_SUBTITLES_SHOWING]}constructor(e={}){super({slotTemplate:UE,...e}),this._captionsReady=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",De.CLOSED_CAPTIONS()),PE(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_SUBTITLES_SHOWING&&PE(this)}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:Ye(this).querySelector("media-captions-menu")}get mediaSubtitlesList(){return OE(this,b.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){NE(this,b.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return OE(this,b.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){NE(this,b.MEDIA_SUBTITLES_SHOWING,e)}},OE=(i,e)=>{let t=i.getAttribute(e);return t?sr(t):[]},NE=(i,e,t)=>{if(!(t!=null&&t.length)){i.removeAttribute(e);return}let r=li(t);i.getAttribute(e)!==r&&i.setAttribute(e,r)};_.customElements.get("media-captions-menu-button")||_.customElements.define("media-captions-menu-button",lf);var MS='<svg aria-hidden="true" viewBox="0 0 24 24"><g><path class="cast_caf_icon_arch0" d="M1,18 L1,21 L4,21 C4,19.3 2.66,18 1,18 L1,18 Z"/><path class="cast_caf_icon_arch1" d="M1,14 L1,16 C3.76,16 6,18.2 6,21 L8,21 C8,17.13 4.87,14 1,14 L1,14 Z"/><path class="cast_caf_icon_arch2" d="M1,10 L1,12 C5.97,12 10,16.0 10,21 L12,21 C12,14.92 7.07,10 1,10 L1,10 Z"/><path class="cast_caf_icon_box" d="M21,3 L3,3 C1.9,3 1,3.9 1,5 L1,8 L3,8 L3,5 L21,5 L21,19 L14,19 L14,21 L21,21 C22.1,21 23,20.1 23,19 L23,5 C23,3.9 22.1,3 21,3 L21,3 Z"/></g></svg>',PS='<svg aria-hidden="true" viewBox="0 0 24 24"><g><path class="cast_caf_icon_arch0" d="M1,18 L1,21 L4,21 C4,19.3 2.66,18 1,18 L1,18 Z"/><path class="cast_caf_icon_arch1" d="M1,14 L1,16 C3.76,16 6,18.2 6,21 L8,21 C8,17.13 4.87,14 1,14 L1,14 Z"/><path class="cast_caf_icon_arch2" d="M1,10 L1,12 C5.97,12 10,16.0 10,21 L12,21 C12,14.92 7.07,10 1,10 L1,10 Z"/><path class="cast_caf_icon_box" d="M21,3 L3,3 C1.9,3 1,3.9 1,5 L1,8 L3,8 L3,5 L21,5 L21,19 L14,19 L14,21 L21,21 C22.1,21 23,20.1 23,19 L23,5 C23,3.9 22.1,3 21,3 L21,3 Z"/><path class="cast_caf_icon_boxfill" d="M5,7 L5,8.63 C8,8.6 13.37,14 13.37,17 L19,17 L19,7 Z"/></g></svg>',BE=O.createElement("template");BE.innerHTML=`
425
425
  <style>
426
426
  :host([${b.MEDIA_IS_CASTING}]) slot:not([name=exit]):not([name=icon]) {
427
427
  display: none !important;
@@ -434,10 +434,10 @@
434
434
  </style>
435
435
 
436
436
  <slot name="icon">
437
- <slot name="enter">${OS}</slot>
438
- <slot name="exit">${NS}</slot>
437
+ <slot name="enter">${MS}</slot>
438
+ <slot name="exit">${PS}</slot>
439
439
  </slot>
440
- `;var NE=i=>{let e=i.mediaIsCasting?De.EXIT_CAST():De.ENTER_CAST();i.setAttribute("aria-label",e)},nf=class extends be{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_IS_CASTING,b.MEDIA_CAST_UNAVAILABLE]}constructor(e={}){super({slotTemplate:UE,...e})}connectedCallback(){super.connectedCallback(),NE(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_IS_CASTING&&NE(this)}get mediaIsCasting(){return Le(this,b.MEDIA_IS_CASTING)}set mediaIsCasting(e){Ae(this,b.MEDIA_IS_CASTING,e)}get mediaCastUnavailable(){return ue(this,b.MEDIA_CAST_UNAVAILABLE)}set mediaCastUnavailable(e){le(this,b.MEDIA_CAST_UNAVAILABLE,e)}handleClick(){let e=this.mediaIsCasting?F.MEDIA_EXIT_CAST_REQUEST:F.MEDIA_ENTER_CAST_REQUEST;this.dispatchEvent(new A.CustomEvent(e,{composed:!0,bubbles:!0}))}};A.customElements.get("media-cast-button")||A.customElements.define("media-cast-button",nf);var US=Object.defineProperty,FS=(i,e,t)=>e in i?US(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,BS=(i,e,t)=>(FS(i,typeof e!="symbol"?e+"":e,t),t),hf=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},pn=(i,e,t)=>(hf(i,e,"read from private field"),t?t.call(i):e.get(i)),ls=(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)},FE=(i,e,t,r)=>(hf(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),ya=(i,e,t)=>(hf(i,e,"access private method"),t),Ta,ds,of,BE,lf,$E,df,HE,uf,GE,cf,WE,VE=O.createElement("template");VE.innerHTML=`
440
+ `;var FE=i=>{let e=i.mediaIsCasting?Me.EXIT_CAST():Me.ENTER_CAST();i.setAttribute("aria-label",e)},df=class extends be{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_IS_CASTING,b.MEDIA_CAST_UNAVAILABLE]}constructor(e={}){super({slotTemplate:BE,...e})}connectedCallback(){super.connectedCallback(),FE(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_IS_CASTING&&FE(this)}get mediaIsCasting(){return Le(this,b.MEDIA_IS_CASTING)}set mediaIsCasting(e){Ae(this,b.MEDIA_IS_CASTING,e)}get mediaCastUnavailable(){return ue(this,b.MEDIA_CAST_UNAVAILABLE)}set mediaCastUnavailable(e){le(this,b.MEDIA_CAST_UNAVAILABLE,e)}handleClick(){let e=this.mediaIsCasting?B.MEDIA_EXIT_CAST_REQUEST:B.MEDIA_ENTER_CAST_REQUEST;this.dispatchEvent(new _.CustomEvent(e,{composed:!0,bubbles:!0}))}};_.customElements.get("media-cast-button")||_.customElements.define("media-cast-button",df);var OS=Object.defineProperty,NS=(i,e,t)=>e in i?OS(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,US=(i,e,t)=>(NS(i,typeof e!="symbol"?e+"":e,t),t),gf=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},gn=(i,e,t)=>(gf(i,e,"read from private field"),t?t.call(i):e.get(i)),ds=(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)},$E=(i,e,t,r)=>(gf(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),ya=(i,e,t)=>(gf(i,e,"access private method"),t),Ta,us,cf,HE,hf,GE,ff,WE,mf,KE,pf,VE,qE=O.createElement("template");qE.innerHTML=`
441
441
  <style>
442
442
  :host {
443
443
  font: var(--media-font,
@@ -474,7 +474,7 @@
474
474
  }
475
475
  </style>
476
476
  <slot></slot>
477
- `;var af={HIDDEN:"hidden",ANCHOR:"anchor"},Bl=class extends A.HTMLElement{constructor(){super(),ls(this,of),ls(this,lf),ls(this,df),ls(this,uf),ls(this,cf),ls(this,Ta,void 0),ls(this,ds,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.nativeEl=this.constructor.template.content.cloneNode(!0),this.shadowRoot.append(this.nativeEl)),this.addEventListener("invoke",this),this.addEventListener("focusout",this),this.addEventListener("keydown",this)}static get observedAttributes(){return[af.HIDDEN,af.ANCHOR]}handleEvent(e){switch(e.type){case"invoke":ya(this,df,HE).call(this,e);break;case"focusout":ya(this,uf,GE).call(this,e);break;case"keydown":ya(this,cf,WE).call(this,e);break}}connectedCallback(){this.role||(this.role="dialog")}attributeChangedCallback(e,t,r){e===af.HIDDEN&&r!==t&&(this.hidden?ya(this,lf,$E).call(this):ya(this,of,BE).call(this))}focus(){FE(this,Ta,Xr());let e=this.querySelector('[autofocus], [tabindex]:not([tabindex="-1"]), [role="menu"]');e==null||e.focus()}get keysUsed(){return["Escape","Tab"]}};Ta=new WeakMap;ds=new WeakMap;of=new WeakSet;BE=function(){var i;(i=pn(this,ds))==null||i.setAttribute("aria-expanded","true"),this.addEventListener("transitionend",()=>this.focus(),{once:!0})};lf=new WeakSet;$E=function(){var i;(i=pn(this,ds))==null||i.setAttribute("aria-expanded","false")};df=new WeakSet;HE=function(i){FE(this,ds,i.relatedTarget),yt(this,i.relatedTarget)||(this.hidden=!this.hidden)};uf=new WeakSet;GE=function(i){var e;yt(this,i.relatedTarget)||((e=pn(this,Ta))==null||e.focus(),pn(this,ds)&&pn(this,ds)!==i.relatedTarget&&!this.hidden&&(this.hidden=!0))};cf=new WeakSet;WE=function(i){var e,t,r,s,n;let{key:a,ctrlKey:o,altKey:l,metaKey:d}=i;o||l||d||this.keysUsed.includes(a)&&(i.preventDefault(),i.stopPropagation(),a==="Tab"?(i.shiftKey?(t=(e=this.previousElementSibling)==null?void 0:e.focus)==null||t.call(e):(s=(r=this.nextElementSibling)==null?void 0:r.focus)==null||s.call(r),this.blur()):a==="Escape"&&((n=pn(this,Ta))==null||n.focus(),this.hidden=!0))};BS(Bl,"template",VE);A.customElements.get("media-chrome-dialog")||A.customElements.define("media-chrome-dialog",Bl);var $S=Object.defineProperty,HS=(i,e,t)=>e in i?$S(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,GS=(i,e,t)=>(HS(i,typeof e!="symbol"?e+"":e,t),t),Ef=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},wi=(i,e,t)=>(Ef(i,e,"read from private field"),t?t.call(i):e.get(i)),or=(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)},ff=(i,e,t,r)=>(Ef(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Ri=(i,e,t)=>(Ef(i,e,"access private method"),t),$l,Aa,mf,KE,bf,qE,yf,YE,Ci,gn,Sa,pf,zE,Hl,gf,jE=O.createElement("template");jE.innerHTML=`
477
+ `;var uf={HIDDEN:"hidden",ANCHOR:"anchor"},Bl=class extends _.HTMLElement{constructor(){super(),ds(this,cf),ds(this,hf),ds(this,ff),ds(this,mf),ds(this,pf),ds(this,Ta,void 0),ds(this,us,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.nativeEl=this.constructor.template.content.cloneNode(!0),this.shadowRoot.append(this.nativeEl)),this.addEventListener("invoke",this),this.addEventListener("focusout",this),this.addEventListener("keydown",this)}static get observedAttributes(){return[uf.HIDDEN,uf.ANCHOR]}handleEvent(e){switch(e.type){case"invoke":ya(this,ff,WE).call(this,e);break;case"focusout":ya(this,mf,KE).call(this,e);break;case"keydown":ya(this,pf,VE).call(this,e);break}}connectedCallback(){this.role||(this.role="dialog")}attributeChangedCallback(e,t,r){e===uf.HIDDEN&&r!==t&&(this.hidden?ya(this,hf,GE).call(this):ya(this,cf,HE).call(this))}focus(){$E(this,Ta,Qr());let e=this.querySelector('[autofocus], [tabindex]:not([tabindex="-1"]), [role="menu"]');e==null||e.focus()}get keysUsed(){return["Escape","Tab"]}};Ta=new WeakMap;us=new WeakMap;cf=new WeakSet;HE=function(){var i;(i=gn(this,us))==null||i.setAttribute("aria-expanded","true"),this.addEventListener("transitionend",()=>this.focus(),{once:!0})};hf=new WeakSet;GE=function(){var i;(i=gn(this,us))==null||i.setAttribute("aria-expanded","false")};ff=new WeakSet;WE=function(i){$E(this,us,i.relatedTarget),yt(this,i.relatedTarget)||(this.hidden=!this.hidden)};mf=new WeakSet;KE=function(i){var e;yt(this,i.relatedTarget)||((e=gn(this,Ta))==null||e.focus(),gn(this,us)&&gn(this,us)!==i.relatedTarget&&!this.hidden&&(this.hidden=!0))};pf=new WeakSet;VE=function(i){var e,t,r,s,n;let{key:a,ctrlKey:o,altKey:l,metaKey:d}=i;o||l||d||this.keysUsed.includes(a)&&(i.preventDefault(),i.stopPropagation(),a==="Tab"?(i.shiftKey?(t=(e=this.previousElementSibling)==null?void 0:e.focus)==null||t.call(e):(s=(r=this.nextElementSibling)==null?void 0:r.focus)==null||s.call(r),this.blur()):a==="Escape"&&((n=gn(this,Ta))==null||n.focus(),this.hidden=!0))};US(Bl,"template",qE);_.customElements.get("media-chrome-dialog")||_.customElements.define("media-chrome-dialog",Bl);var FS=Object.defineProperty,BS=(i,e,t)=>e in i?FS(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,$S=(i,e,t)=>(BS(i,typeof e!="symbol"?e+"":e,t),t),_f=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},wi=(i,e,t)=>(_f(i,e,"read from private field"),t?t.call(i):e.get(i)),or=(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)},vf=(i,e,t,r)=>(_f(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Ri=(i,e,t)=>(_f(i,e,"access private method"),t),$l,Aa,Ef,YE,Af,zE,Sf,jE,Ci,vn,Sa,bf,XE,Hl,yf,QE=O.createElement("template");QE.innerHTML=`
478
478
  <style>
479
479
  :host {
480
480
  transition: var(--media-menu-item-transition,
@@ -590,7 +590,7 @@
590
590
  <slot name="description"></slot>
591
591
  <slot name="suffix"></slot>
592
592
  <slot name="submenu"></slot>
593
- `;var zt={TYPE:"type",VALUE:"value",CHECKED:"checked",DISABLED:"disabled"},us=class extends A.HTMLElement{constructor(){super(),or(this,mf),or(this,bf),or(this,yf),or(this,gn),or(this,pf),or(this,Hl),or(this,$l,!1),or(this,Aa,void 0),or(this,Ci,()=>{var e,t;this.setAttribute("submenusize",`${this.submenuElement.items.length}`);let r=this.shadowRoot.querySelector('slot[name="description"]'),s=(t=(e=this.submenuElement.checkedItems)==null?void 0:e[0])==null?void 0:t.text,n=O.createElement("span");n.textContent=s!=null?s:"",r.replaceChildren(n)}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.append(this.constructor.template.content.cloneNode(!0))),this.shadowRoot.addEventListener("slotchange",this)}static get observedAttributes(){return[zt.TYPE,zt.DISABLED,zt.CHECKED,zt.VALUE]}enable(){this.hasAttribute("tabindex")||this.setAttribute("tabindex","-1"),_a(this)&&!this.hasAttribute("aria-checked")&&this.setAttribute("aria-checked","false"),this.addEventListener("click",this),this.addEventListener("keydown",this)}disable(){this.removeAttribute("tabindex"),this.removeEventListener("click",this),this.removeEventListener("keydown",this),this.removeEventListener("keyup",this)}handleEvent(e){switch(e.type){case"slotchange":Ri(this,mf,KE).call(this,e);break;case"click":this.handleClick(e);break;case"keydown":Ri(this,pf,zE).call(this,e);break;case"keyup":Ri(this,gn,Sa).call(this,e);break}}attributeChangedCallback(e,t,r){e===zt.CHECKED&&_a(this)&&!wi(this,$l)?this.setAttribute("aria-checked",r!=null?"true":"false"):e===zt.TYPE&&r!==t?this.role="menuitem"+r:e===zt.DISABLED&&r!==t&&(r==null?this.enable():this.disable())}connectedCallback(){this.hasAttribute(zt.DISABLED)||this.enable(),this.role="menuitem"+this.type,ff(this,Aa,vf(this,this.parentNode)),Ri(this,Hl,gf).call(this)}disconnectedCallback(){this.disable(),Ri(this,Hl,gf).call(this),ff(this,Aa,null)}get invokeTarget(){return this.getAttribute("invoketarget")}set invokeTarget(e){this.setAttribute("invoketarget",`${e}`)}get invokeTargetElement(){var e;return this.invokeTarget?(e=Qr(this))==null?void 0:e.querySelector(`#${this.invokeTarget}`):this.submenuElement}get submenuElement(){return this.shadowRoot.querySelector('slot[name="submenu"]').assignedElements({flatten:!0})[0]}get type(){var e;return(e=this.getAttribute(zt.TYPE))!=null?e:""}set type(e){this.setAttribute(zt.TYPE,`${e}`)}get value(){var e;return(e=this.getAttribute(zt.VALUE))!=null?e:this.text}set value(e){this.setAttribute(zt.VALUE,e)}get text(){var e;return((e=this.textContent)!=null?e:"").trim()}get checked(){if(_a(this))return this.getAttribute("aria-checked")==="true"}set checked(e){_a(this)&&(ff(this,$l,!0),this.setAttribute("aria-checked",e?"true":"false"),e?this.part.add("checked"):this.part.remove("checked"))}handleClick(e){_a(this)||this.invokeTargetElement&&yt(this,e.target)&&this.invokeTargetElement.dispatchEvent(new Sr({relatedTarget:this}))}get keysUsed(){return["Enter"," "]}};$l=new WeakMap;Aa=new WeakMap;mf=new WeakSet;KE=function(i){let e=i.target;if(!(e!=null&&e.name))for(let r of e.assignedNodes({flatten:!0}))r instanceof Text&&r.textContent.trim()===""&&r.remove();e.name==="submenu"&&(this.submenuElement?Ri(this,bf,qE).call(this):Ri(this,yf,YE).call(this))};bf=new WeakSet;qE=async function(){this.setAttribute("aria-haspopup","menu"),this.setAttribute("aria-expanded",`${!this.submenuElement.hidden}`),this.submenuElement.addEventListener("change",wi(this,Ci)),this.submenuElement.addEventListener("addmenuitem",wi(this,Ci)),this.submenuElement.addEventListener("removemenuitem",wi(this,Ci)),wi(this,Ci).call(this)};yf=new WeakSet;YE=function(){this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded"),this.submenuElement.removeEventListener("change",wi(this,Ci)),this.submenuElement.removeEventListener("addmenuitem",wi(this,Ci)),this.submenuElement.removeEventListener("removemenuitem",wi(this,Ci)),wi(this,Ci).call(this)};Ci=new WeakMap;gn=new WeakSet;Sa=function(i){let{key:e}=i;if(!this.keysUsed.includes(e)){this.removeEventListener("keyup",Ri(this,gn,Sa));return}this.handleClick(i)};pf=new WeakSet;zE=function(i){let{metaKey:e,altKey:t,key:r}=i;if(e||t||!this.keysUsed.includes(r)){this.removeEventListener("keyup",Ri(this,gn,Sa));return}this.addEventListener("keyup",Ri(this,gn,Sa),{once:!0})};Hl=new WeakSet;gf=function(){var i;let e=(i=wi(this,Aa))==null?void 0:i.radioGroupItems;if(!e)return;let t=e.filter(r=>r.getAttribute("aria-checked")==="true").pop();t||(t=e[0]);for(let r of e)r.setAttribute("aria-checked","false");t==null||t.setAttribute("aria-checked","true")};GS(us,"template",jE);function _a(i){return i.type==="radio"||i.type==="checkbox"}function vf(i,e){if(!i)return null;let{host:t}=i.getRootNode();return!e&&t?vf(i,t):e!=null&&e.items?e:vf(e,e==null?void 0:e.parentNode)}A.customElements.get("media-chrome-menu-item")||A.customElements.define("media-chrome-menu-item",us);var kf=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},He=(i,e,t)=>(kf(i,e,"read from private field"),t?t.call(i):e.get(i)),pt=(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)},Lr=(i,e,t,r)=>(kf(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),ui=(i,e,t)=>(kf(i,e,"access private method"),t),Di,Ql,Gl,Wl,ci,jl,Vl,Kl,ql,If,XE,Yl,Tf,zl,_f,Xl,Rf,Af,QE,Sf,ZE,xf,JE,Lf,eb,tb=O.createElement("template");tb.innerHTML=`
593
+ `;var zt={TYPE:"type",VALUE:"value",CHECKED:"checked",DISABLED:"disabled"},cs=class extends _.HTMLElement{constructor(){super(),or(this,Ef),or(this,Af),or(this,Sf),or(this,vn),or(this,bf),or(this,Hl),or(this,$l,!1),or(this,Aa,void 0),or(this,Ci,()=>{var e,t;this.setAttribute("submenusize",`${this.submenuElement.items.length}`);let r=this.shadowRoot.querySelector('slot[name="description"]'),s=(t=(e=this.submenuElement.checkedItems)==null?void 0:e[0])==null?void 0:t.text,n=O.createElement("span");n.textContent=s!=null?s:"",r.replaceChildren(n)}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.append(this.constructor.template.content.cloneNode(!0))),this.shadowRoot.addEventListener("slotchange",this)}static get observedAttributes(){return[zt.TYPE,zt.DISABLED,zt.CHECKED,zt.VALUE]}enable(){this.hasAttribute("tabindex")||this.setAttribute("tabindex","-1"),_a(this)&&!this.hasAttribute("aria-checked")&&this.setAttribute("aria-checked","false"),this.addEventListener("click",this),this.addEventListener("keydown",this)}disable(){this.removeAttribute("tabindex"),this.removeEventListener("click",this),this.removeEventListener("keydown",this),this.removeEventListener("keyup",this)}handleEvent(e){switch(e.type){case"slotchange":Ri(this,Ef,YE).call(this,e);break;case"click":this.handleClick(e);break;case"keydown":Ri(this,bf,XE).call(this,e);break;case"keyup":Ri(this,vn,Sa).call(this,e);break}}attributeChangedCallback(e,t,r){e===zt.CHECKED&&_a(this)&&!wi(this,$l)?this.setAttribute("aria-checked",r!=null?"true":"false"):e===zt.TYPE&&r!==t?this.role="menuitem"+r:e===zt.DISABLED&&r!==t&&(r==null?this.enable():this.disable())}connectedCallback(){this.hasAttribute(zt.DISABLED)||this.enable(),this.role="menuitem"+this.type,vf(this,Aa,Tf(this,this.parentNode)),Ri(this,Hl,yf).call(this)}disconnectedCallback(){this.disable(),Ri(this,Hl,yf).call(this),vf(this,Aa,null)}get invokeTarget(){return this.getAttribute("invoketarget")}set invokeTarget(e){this.setAttribute("invoketarget",`${e}`)}get invokeTargetElement(){var e;return this.invokeTarget?(e=Zr(this))==null?void 0:e.querySelector(`#${this.invokeTarget}`):this.submenuElement}get submenuElement(){return this.shadowRoot.querySelector('slot[name="submenu"]').assignedElements({flatten:!0})[0]}get type(){var e;return(e=this.getAttribute(zt.TYPE))!=null?e:""}set type(e){this.setAttribute(zt.TYPE,`${e}`)}get value(){var e;return(e=this.getAttribute(zt.VALUE))!=null?e:this.text}set value(e){this.setAttribute(zt.VALUE,e)}get text(){var e;return((e=this.textContent)!=null?e:"").trim()}get checked(){if(_a(this))return this.getAttribute("aria-checked")==="true"}set checked(e){_a(this)&&(vf(this,$l,!0),this.setAttribute("aria-checked",e?"true":"false"),e?this.part.add("checked"):this.part.remove("checked"))}handleClick(e){_a(this)||this.invokeTargetElement&&yt(this,e.target)&&this.invokeTargetElement.dispatchEvent(new Sr({relatedTarget:this}))}get keysUsed(){return["Enter"," "]}};$l=new WeakMap;Aa=new WeakMap;Ef=new WeakSet;YE=function(i){let e=i.target;if(!(e!=null&&e.name))for(let r of e.assignedNodes({flatten:!0}))r instanceof Text&&r.textContent.trim()===""&&r.remove();e.name==="submenu"&&(this.submenuElement?Ri(this,Af,zE).call(this):Ri(this,Sf,jE).call(this))};Af=new WeakSet;zE=async function(){this.setAttribute("aria-haspopup","menu"),this.setAttribute("aria-expanded",`${!this.submenuElement.hidden}`),this.submenuElement.addEventListener("change",wi(this,Ci)),this.submenuElement.addEventListener("addmenuitem",wi(this,Ci)),this.submenuElement.addEventListener("removemenuitem",wi(this,Ci)),wi(this,Ci).call(this)};Sf=new WeakSet;jE=function(){this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded"),this.submenuElement.removeEventListener("change",wi(this,Ci)),this.submenuElement.removeEventListener("addmenuitem",wi(this,Ci)),this.submenuElement.removeEventListener("removemenuitem",wi(this,Ci)),wi(this,Ci).call(this)};Ci=new WeakMap;vn=new WeakSet;Sa=function(i){let{key:e}=i;if(!this.keysUsed.includes(e)){this.removeEventListener("keyup",Ri(this,vn,Sa));return}this.handleClick(i)};bf=new WeakSet;XE=function(i){let{metaKey:e,altKey:t,key:r}=i;if(e||t||!this.keysUsed.includes(r)){this.removeEventListener("keyup",Ri(this,vn,Sa));return}this.addEventListener("keyup",Ri(this,vn,Sa),{once:!0})};Hl=new WeakSet;yf=function(){var i;let e=(i=wi(this,Aa))==null?void 0:i.radioGroupItems;if(!e)return;let t=e.filter(r=>r.getAttribute("aria-checked")==="true").pop();t||(t=e[0]);for(let r of e)r.setAttribute("aria-checked","false");t==null||t.setAttribute("aria-checked","true")};$S(cs,"template",QE);function _a(i){return i.type==="radio"||i.type==="checkbox"}function Tf(i,e){if(!i)return null;let{host:t}=i.getRootNode();return!e&&t?Tf(i,t):e!=null&&e.items?e:Tf(e,e==null?void 0:e.parentNode)}_.customElements.get("media-chrome-menu-item")||_.customElements.define("media-chrome-menu-item",cs);var Cf=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Ge=(i,e,t)=>(Cf(i,e,"read from private field"),t?t.call(i):e.get(i)),pt=(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)},Lr=(i,e,t,r)=>(Cf(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),ui=(i,e,t)=>(Cf(i,e,"access private method"),t),Di,Ql,Gl,Wl,ci,jl,Kl,Vl,ql,Df,ZE,Yl,xf,zl,Lf,Xl,Mf,kf,JE,If,eb,Rf,tb,wf,ib,rb=O.createElement("template");rb.innerHTML=`
594
594
  <style>
595
595
  :host {
596
596
  --_focus-box-shadow: var(--media-focus-box-shadow, inset 0 0 0 2px rgb(27 127 204 / .9));
@@ -826,7 +826,7 @@
826
826
  <input id="range" type="range" min="0" max="1" step="any" value="0">
827
827
  </div>
828
828
  <div id="rightgap"></div>
829
- `;var cs=class extends A.HTMLElement{constructor(){super(),pt(this,If),pt(this,Yl),pt(this,zl),pt(this,Xl),pt(this,Af),pt(this,Sf),pt(this,xf),pt(this,Lf),pt(this,Di,void 0),pt(this,Ql,void 0),pt(this,Gl,void 0),pt(this,Wl,void 0),pt(this,ci,{}),pt(this,jl,[]),pt(this,Vl,()=>{if(this.range.matches(":focus-visible")){let{style:e}=Te(this.shadowRoot,":host");e.setProperty("--_focus-visible-box-shadow","var(--_focus-box-shadow)")}}),pt(this,Kl,()=>{let{style:e}=Te(this.shadowRoot,":host");e.removeProperty("--_focus-visible-box-shadow")}),pt(this,ql,()=>{let e=this.shadowRoot.querySelector("#segments-clipping");e&&e.parentNode.append(e)}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(tb.content.cloneNode(!0))),this.container=this.shadowRoot.querySelector("#container"),Lr(this,Gl,this.shadowRoot.querySelector("#startpoint")),Lr(this,Wl,this.shadowRoot.querySelector("#endpoint")),this.range=this.shadowRoot.querySelector("#range"),this.appearance=this.shadowRoot.querySelector("#appearance")}static get observedAttributes(){return["disabled","aria-disabled",ee.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===ee.MEDIA_CONTROLLER?(t&&((n=(s=He(this,Di))==null?void 0:s.unassociateElement)==null||n.call(s,this),Lr(this,Di,null)),r&&this.isConnected&&(Lr(this,Di,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=He(this,Di))==null?void 0:o.associateElement)==null||l.call(o,this))):(e==="disabled"||e==="aria-disabled"&&t!==r)&&(r==null?(this.range.removeAttribute(e),ui(this,Yl,Tf).call(this)):(this.range.setAttribute(e,r),ui(this,zl,_f).call(this)))}connectedCallback(){var e,t,r;let{style:s}=Te(this.shadowRoot,":host");s.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`),He(this,ci).pointer=Te(this.shadowRoot,"#pointer"),He(this,ci).progress=Te(this.shadowRoot,"#progress"),He(this,ci).thumb=Te(this.shadowRoot,"#thumb");let n=this.getAttribute(ee.MEDIA_CONTROLLER);n&&(Lr(this,Di,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(r=(t=He(this,Di))==null?void 0:t.associateElement)==null||r.call(t,this)),this.updateBar(),this.shadowRoot.addEventListener("focusin",He(this,Vl)),this.shadowRoot.addEventListener("focusout",He(this,Kl)),ui(this,Yl,Tf).call(this),Kt(this.container,He(this,ql))}disconnectedCallback(){var e,t;ui(this,zl,_f).call(this),(t=(e=He(this,Di))==null?void 0:e.unassociateElement)==null||t.call(e,this),Lr(this,Di,null),this.shadowRoot.removeEventListener("focusin",He(this,Vl)),this.shadowRoot.removeEventListener("focusout",He(this,Kl)),Si(this.container,He(this,ql))}updatePointerBar(e){var t;(t=He(this,ci).pointer)==null||t.style.setProperty("width",`${this.getPointerRatio(e)*100}%`)}updateBar(){var e,t;let r=this.range.valueAsNumber*100;(e=He(this,ci).progress)==null||e.style.setProperty("width",`${r}%`),(t=He(this,ci).thumb)==null||t.style.setProperty("left",`${r}%`)}updateSegments(e){let t=this.shadowRoot.querySelector("#segments-clipping");if(t.textContent="",this.container.classList.toggle("segments",!!(e!=null&&e.length)),!(e!=null&&e.length))return;He(this,ci).activeSegment=ch(this.shadowRoot,"#segments-clipping rect:nth-child(0)");let r=[...new Set([+this.range.min,...e.flatMap(n=>[n.start,n.end]),+this.range.max])];Lr(this,jl,[...r]);let s=r.pop();for(let[n,a]of r.entries()){let[o,l]=[n===0,n===r.length-1],d=o?"calc(var(--segments-gap) / -1)":`${a*100}%`,c=`calc(${((l?s:r[n+1])-a)*100}%${o||l?"":" - var(--segments-gap)"})`,h=O.createElementNS("http://www.w3.org/2000/svg","rect"),f=Te(this.shadowRoot,`#segments-clipping rect:nth-child(${n+1})`);f.style.setProperty("x",d),f.style.setProperty("width",c),t.append(h)}}getPointerRatio(e){let t=Dv(e.clientX,e.clientY,He(this,Gl).getBoundingClientRect(),He(this,Wl).getBoundingClientRect());return Math.max(0,Math.min(1,t))}get dragging(){return this.hasAttribute("dragging")}handleEvent(e){switch(e.type){case"pointermove":ui(this,Lf,eb).call(this,e);break;case"input":this.updateBar();break;case"pointerenter":ui(this,Af,QE).call(this,e);break;case"pointerdown":ui(this,Xl,Rf).call(this,e);break;case"pointerup":ui(this,Sf,ZE).call(this);break;case"pointerleave":ui(this,xf,JE).call(this);break}}get keysUsed(){return["ArrowUp","ArrowRight","ArrowDown","ArrowLeft"]}};Di=new WeakMap;Ql=new WeakMap;Gl=new WeakMap;Wl=new WeakMap;ci=new WeakMap;jl=new WeakMap;Vl=new WeakMap;Kl=new WeakMap;ql=new WeakMap;If=new WeakSet;XE=function(i){let e=He(this,ci).activeSegment;if(!e)return;let t=this.getPointerRatio(i),s=`#segments-clipping rect:nth-child(${He(this,jl).findIndex((n,a,o)=>{let l=o[a+1];return l!=null&&t>=n&&t<=l})+1})`;(e.selectorText!=s||!e.style.transform)&&(e.selectorText=s,e.style.setProperty("transform","var(--media-range-segment-hover-transform, scaleY(2))"))};Yl=new WeakSet;Tf=function(){this.hasAttribute("disabled")||(this.addEventListener("input",this),this.addEventListener("pointerdown",this),this.addEventListener("pointerenter",this))};zl=new WeakSet;_f=function(){var i,e;this.removeEventListener("input",this),this.removeEventListener("pointerdown",this),this.removeEventListener("pointerenter",this),(i=A.window)==null||i.removeEventListener("pointerup",this),(e=A.window)==null||e.removeEventListener("pointermove",this)};Xl=new WeakSet;Rf=function(i){var e;Lr(this,Ql,i.composedPath().includes(this.range)),(e=A.window)==null||e.addEventListener("pointerup",this)};Af=new WeakSet;QE=function(i){var e;i.pointerType!=="mouse"&&ui(this,Xl,Rf).call(this,i),this.addEventListener("pointerleave",this),(e=A.window)==null||e.addEventListener("pointermove",this)};Sf=new WeakSet;ZE=function(){var i;(i=A.window)==null||i.removeEventListener("pointerup",this),this.toggleAttribute("dragging",!1),this.range.disabled=this.hasAttribute("disabled")};xf=new WeakSet;JE=function(){var i,e;this.removeEventListener("pointerleave",this),(i=A.window)==null||i.removeEventListener("pointermove",this),this.toggleAttribute("dragging",!1),this.range.disabled=this.hasAttribute("disabled"),(e=He(this,ci).activeSegment)==null||e.style.removeProperty("transform")};Lf=new WeakSet;eb=function(i){this.toggleAttribute("dragging",i.buttons===1||i.pointerType!=="mouse"),this.updatePointerBar(i),ui(this,If,XE).call(this,i),this.dragging&&(i.pointerType!=="mouse"||!He(this,Ql))&&(this.range.disabled=!0,this.range.valueAsNumber=this.getPointerRatio(i),this.range.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})))};A.customElements.get("media-chrome-range")||A.customElements.define("media-chrome-range",cs);var ib=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Zl=(i,e,t)=>(ib(i,e,"read from private field"),t?t.call(i):e.get(i)),WS=(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)},Jl=(i,e,t,r)=>(ib(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Mi,rb=O.createElement("template");rb.innerHTML=`
829
+ `;var hs=class extends _.HTMLElement{constructor(){super(),pt(this,Df),pt(this,Yl),pt(this,zl),pt(this,Xl),pt(this,kf),pt(this,If),pt(this,Rf),pt(this,wf),pt(this,Di,void 0),pt(this,Ql,void 0),pt(this,Gl,void 0),pt(this,Wl,void 0),pt(this,ci,{}),pt(this,jl,[]),pt(this,Kl,()=>{if(this.range.matches(":focus-visible")){let{style:e}=Te(this.shadowRoot,":host");e.setProperty("--_focus-visible-box-shadow","var(--_focus-box-shadow)")}}),pt(this,Vl,()=>{let{style:e}=Te(this.shadowRoot,":host");e.removeProperty("--_focus-visible-box-shadow")}),pt(this,ql,()=>{let e=this.shadowRoot.querySelector("#segments-clipping");e&&e.parentNode.append(e)}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(rb.content.cloneNode(!0))),this.container=this.shadowRoot.querySelector("#container"),Lr(this,Gl,this.shadowRoot.querySelector("#startpoint")),Lr(this,Wl,this.shadowRoot.querySelector("#endpoint")),this.range=this.shadowRoot.querySelector("#range"),this.appearance=this.shadowRoot.querySelector("#appearance")}static get observedAttributes(){return["disabled","aria-disabled",te.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===te.MEDIA_CONTROLLER?(t&&((n=(s=Ge(this,Di))==null?void 0:s.unassociateElement)==null||n.call(s,this),Lr(this,Di,null)),r&&this.isConnected&&(Lr(this,Di,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=Ge(this,Di))==null?void 0:o.associateElement)==null||l.call(o,this))):(e==="disabled"||e==="aria-disabled"&&t!==r)&&(r==null?(this.range.removeAttribute(e),ui(this,Yl,xf).call(this)):(this.range.setAttribute(e,r),ui(this,zl,Lf).call(this)))}connectedCallback(){var e,t,r;let{style:s}=Te(this.shadowRoot,":host");s.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`),Ge(this,ci).pointer=Te(this.shadowRoot,"#pointer"),Ge(this,ci).progress=Te(this.shadowRoot,"#progress"),Ge(this,ci).thumb=Te(this.shadowRoot,"#thumb");let n=this.getAttribute(te.MEDIA_CONTROLLER);n&&(Lr(this,Di,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(r=(t=Ge(this,Di))==null?void 0:t.associateElement)==null||r.call(t,this)),this.updateBar(),this.shadowRoot.addEventListener("focusin",Ge(this,Kl)),this.shadowRoot.addEventListener("focusout",Ge(this,Vl)),ui(this,Yl,xf).call(this),Vt(this.container,Ge(this,ql))}disconnectedCallback(){var e,t;ui(this,zl,Lf).call(this),(t=(e=Ge(this,Di))==null?void 0:e.unassociateElement)==null||t.call(e,this),Lr(this,Di,null),this.shadowRoot.removeEventListener("focusin",Ge(this,Kl)),this.shadowRoot.removeEventListener("focusout",Ge(this,Vl)),Si(this.container,Ge(this,ql))}updatePointerBar(e){var t;(t=Ge(this,ci).pointer)==null||t.style.setProperty("width",`${this.getPointerRatio(e)*100}%`)}updateBar(){var e,t;let r=this.range.valueAsNumber*100;(e=Ge(this,ci).progress)==null||e.style.setProperty("width",`${r}%`),(t=Ge(this,ci).thumb)==null||t.style.setProperty("left",`${r}%`)}updateSegments(e){let t=this.shadowRoot.querySelector("#segments-clipping");if(t.textContent="",this.container.classList.toggle("segments",!!(e!=null&&e.length)),!(e!=null&&e.length))return;Ge(this,ci).activeSegment=ph(this.shadowRoot,"#segments-clipping rect:nth-child(0)");let r=[...new Set([+this.range.min,...e.flatMap(n=>[n.start,n.end]),+this.range.max])];Lr(this,jl,[...r]);let s=r.pop();for(let[n,a]of r.entries()){let[o,l]=[n===0,n===r.length-1],d=o?"calc(var(--segments-gap) / -1)":`${a*100}%`,c=`calc(${((l?s:r[n+1])-a)*100}%${o||l?"":" - var(--segments-gap)"})`,h=O.createElementNS("http://www.w3.org/2000/svg","rect"),f=Te(this.shadowRoot,`#segments-clipping rect:nth-child(${n+1})`);f.style.setProperty("x",d),f.style.setProperty("width",c),t.append(h)}}getPointerRatio(e){let t=Pv(e.clientX,e.clientY,Ge(this,Gl).getBoundingClientRect(),Ge(this,Wl).getBoundingClientRect());return Math.max(0,Math.min(1,t))}get dragging(){return this.hasAttribute("dragging")}handleEvent(e){switch(e.type){case"pointermove":ui(this,wf,ib).call(this,e);break;case"input":this.updateBar();break;case"pointerenter":ui(this,kf,JE).call(this,e);break;case"pointerdown":ui(this,Xl,Mf).call(this,e);break;case"pointerup":ui(this,If,eb).call(this);break;case"pointerleave":ui(this,Rf,tb).call(this);break}}get keysUsed(){return["ArrowUp","ArrowRight","ArrowDown","ArrowLeft"]}};Di=new WeakMap;Ql=new WeakMap;Gl=new WeakMap;Wl=new WeakMap;ci=new WeakMap;jl=new WeakMap;Kl=new WeakMap;Vl=new WeakMap;ql=new WeakMap;Df=new WeakSet;ZE=function(i){let e=Ge(this,ci).activeSegment;if(!e)return;let t=this.getPointerRatio(i),s=`#segments-clipping rect:nth-child(${Ge(this,jl).findIndex((n,a,o)=>{let l=o[a+1];return l!=null&&t>=n&&t<=l})+1})`;(e.selectorText!=s||!e.style.transform)&&(e.selectorText=s,e.style.setProperty("transform","var(--media-range-segment-hover-transform, scaleY(2))"))};Yl=new WeakSet;xf=function(){this.hasAttribute("disabled")||(this.addEventListener("input",this),this.addEventListener("pointerdown",this),this.addEventListener("pointerenter",this))};zl=new WeakSet;Lf=function(){var i,e;this.removeEventListener("input",this),this.removeEventListener("pointerdown",this),this.removeEventListener("pointerenter",this),(i=_.window)==null||i.removeEventListener("pointerup",this),(e=_.window)==null||e.removeEventListener("pointermove",this)};Xl=new WeakSet;Mf=function(i){var e;Lr(this,Ql,i.composedPath().includes(this.range)),(e=_.window)==null||e.addEventListener("pointerup",this)};kf=new WeakSet;JE=function(i){var e;i.pointerType!=="mouse"&&ui(this,Xl,Mf).call(this,i),this.addEventListener("pointerleave",this),(e=_.window)==null||e.addEventListener("pointermove",this)};If=new WeakSet;eb=function(){var i;(i=_.window)==null||i.removeEventListener("pointerup",this),this.toggleAttribute("dragging",!1),this.range.disabled=this.hasAttribute("disabled")};Rf=new WeakSet;tb=function(){var i,e;this.removeEventListener("pointerleave",this),(i=_.window)==null||i.removeEventListener("pointermove",this),this.toggleAttribute("dragging",!1),this.range.disabled=this.hasAttribute("disabled"),(e=Ge(this,ci).activeSegment)==null||e.style.removeProperty("transform")};wf=new WeakSet;ib=function(i){this.toggleAttribute("dragging",i.buttons===1||i.pointerType!=="mouse"),this.updatePointerBar(i),ui(this,Df,ZE).call(this,i),this.dragging&&(i.pointerType!=="mouse"||!Ge(this,Ql))&&(this.range.disabled=!0,this.range.valueAsNumber=this.getPointerRatio(i),this.range.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})))};_.customElements.get("media-chrome-range")||_.customElements.define("media-chrome-range",hs);var sb=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Zl=(i,e,t)=>(sb(i,e,"read from private field"),t?t.call(i):e.get(i)),HS=(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)},Jl=(i,e,t,r)=>(sb(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Mi,nb=O.createElement("template");nb.innerHTML=`
830
830
  <style>
831
831
  :host {
832
832
 
@@ -848,7 +848,7 @@
848
848
  </style>
849
849
 
850
850
  <slot></slot>
851
- `;var wf=class extends A.HTMLElement{constructor(){super(),WS(this,Mi,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(rb.content.cloneNode(!0)))}static get observedAttributes(){return[ee.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===ee.MEDIA_CONTROLLER&&(t&&((n=(s=Zl(this,Mi))==null?void 0:s.unassociateElement)==null||n.call(s,this),Jl(this,Mi,null)),r&&this.isConnected&&(Jl(this,Mi,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=Zl(this,Mi))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r;let s=this.getAttribute(ee.MEDIA_CONTROLLER);s&&(Jl(this,Mi,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=Zl(this,Mi))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=Zl(this,Mi))==null?void 0:e.unassociateElement)==null||t.call(e,this),Jl(this,Mi,null)}};Mi=new WeakMap;A.customElements.get("media-control-bar")||A.customElements.define("media-control-bar",wf);var sb=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ed=(i,e,t)=>(sb(i,e,"read from private field"),t?t.call(i):e.get(i)),VS=(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)},td=(i,e,t,r)=>(sb(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Pi,nb=O.createElement("template");nb.innerHTML=`
851
+ `;var Pf=class extends _.HTMLElement{constructor(){super(),HS(this,Mi,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(nb.content.cloneNode(!0)))}static get observedAttributes(){return[te.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===te.MEDIA_CONTROLLER&&(t&&((n=(s=Zl(this,Mi))==null?void 0:s.unassociateElement)==null||n.call(s,this),Jl(this,Mi,null)),r&&this.isConnected&&(Jl(this,Mi,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=Zl(this,Mi))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r;let s=this.getAttribute(te.MEDIA_CONTROLLER);s&&(Jl(this,Mi,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=Zl(this,Mi))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=Zl(this,Mi))==null?void 0:e.unassociateElement)==null||t.call(e,this),Jl(this,Mi,null)}};Mi=new WeakMap;_.customElements.get("media-control-bar")||_.customElements.define("media-control-bar",Pf);var ab=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ed=(i,e,t)=>(ab(i,e,"read from private field"),t?t.call(i):e.get(i)),GS=(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)},td=(i,e,t,r)=>(ab(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Pi,ob=O.createElement("template");ob.innerHTML=`
852
852
  <style>
853
853
  :host {
854
854
  font: var(--media-font,
@@ -881,11 +881,11 @@
881
881
  }
882
882
  </style>
883
883
  <slot></slot>
884
- `;var Oi=class extends A.HTMLElement{constructor(){super(),VS(this,Pi,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(nb.content.cloneNode(!0)))}static get observedAttributes(){return[ee.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===ee.MEDIA_CONTROLLER&&(t&&((n=(s=ed(this,Pi))==null?void 0:s.unassociateElement)==null||n.call(s,this),td(this,Pi,null)),r&&this.isConnected&&(td(this,Pi,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=ed(this,Pi))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r;let{style:s}=Te(this.shadowRoot,":host");s.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`);let n=this.getAttribute(ee.MEDIA_CONTROLLER);n&&(td(this,Pi,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(r=(t=ed(this,Pi))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=ed(this,Pi))==null?void 0:e.unassociateElement)==null||t.call(e,this),td(this,Pi,null)}};Pi=new WeakMap;A.customElements.get("media-text-display")||A.customElements.define("media-text-display",Oi);var ab=Oi;var lb=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ob=(i,e,t)=>(lb(i,e,"read from private field"),t?t.call(i):e.get(i)),KS=(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)},qS=(i,e,t,r)=>(lb(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),xa,Cf=class extends Oi{constructor(){super(),KS(this,xa,void 0),qS(this,xa,this.shadowRoot.querySelector("slot")),ob(this,xa).textContent=Ai(0)}static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_DURATION]}attributeChangedCallback(e,t,r){e===b.MEDIA_DURATION&&(ob(this,xa).textContent=Ai(+r)),super.attributeChangedCallback(e,t,r)}get mediaDuration(){return ve(this,b.MEDIA_DURATION)}set mediaDuration(e){_e(this,b.MEDIA_DURATION,e)}};xa=new WeakMap;A.customElements.get("media-duration-display")||A.customElements.define("media-duration-display",Cf);var YS=`<svg aria-hidden="true" viewBox="0 0 26 24">
884
+ `;var Oi=class extends _.HTMLElement{constructor(){super(),GS(this,Pi,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(ob.content.cloneNode(!0)))}static get observedAttributes(){return[te.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===te.MEDIA_CONTROLLER&&(t&&((n=(s=ed(this,Pi))==null?void 0:s.unassociateElement)==null||n.call(s,this),td(this,Pi,null)),r&&this.isConnected&&(td(this,Pi,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=ed(this,Pi))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r;let{style:s}=Te(this.shadowRoot,":host");s.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`);let n=this.getAttribute(te.MEDIA_CONTROLLER);n&&(td(this,Pi,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(r=(t=ed(this,Pi))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=ed(this,Pi))==null?void 0:e.unassociateElement)==null||t.call(e,this),td(this,Pi,null)}};Pi=new WeakMap;_.customElements.get("media-text-display")||_.customElements.define("media-text-display",Oi);var lb=Oi;var ub=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},db=(i,e,t)=>(ub(i,e,"read from private field"),t?t.call(i):e.get(i)),WS=(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)},KS=(i,e,t,r)=>(ub(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),xa,Of=class extends Oi{constructor(){super(),WS(this,xa,void 0),KS(this,xa,this.shadowRoot.querySelector("slot")),db(this,xa).textContent=Ai(0)}static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_DURATION]}attributeChangedCallback(e,t,r){e===b.MEDIA_DURATION&&(db(this,xa).textContent=Ai(+r)),super.attributeChangedCallback(e,t,r)}get mediaDuration(){return ve(this,b.MEDIA_DURATION)}set mediaDuration(e){_e(this,b.MEDIA_DURATION,e)}};xa=new WeakMap;_.customElements.get("media-duration-display")||_.customElements.define("media-duration-display",Of);var VS=`<svg aria-hidden="true" viewBox="0 0 26 24">
885
885
  <path d="M16 3v2.5h3.5V9H22V3h-6ZM4 9h2.5V5.5H10V3H4v6Zm15.5 9.5H16V21h6v-6h-2.5v3.5ZM6.5 15H4v6h6v-2.5H6.5V15Z"/>
886
- </svg>`,zS=`<svg aria-hidden="true" viewBox="0 0 26 24">
886
+ </svg>`,qS=`<svg aria-hidden="true" viewBox="0 0 26 24">
887
887
  <path d="M18.5 6.5V3H16v6h6V6.5h-3.5ZM16 21h2.5v-3.5H22V15h-6v6ZM4 17.5h3.5V21H10v-6H4v2.5Zm3.5-11H4V9h6V3H7.5v3.5Z"/>
888
- </svg>`,ub=O.createElement("template");ub.innerHTML=`
888
+ </svg>`,hb=O.createElement("template");hb.innerHTML=`
889
889
  <style>
890
890
  :host([${b.MEDIA_IS_FULLSCREEN}]) slot:not([name=exit]):not([name=icon]) {
891
891
  display: none !important;
@@ -898,10 +898,10 @@
898
898
  </style>
899
899
 
900
900
  <slot name="icon">
901
- <slot name="enter">${YS}</slot>
902
- <slot name="exit">${zS}</slot>
901
+ <slot name="enter">${VS}</slot>
902
+ <slot name="exit">${qS}</slot>
903
903
  </slot>
904
- `;var db=i=>{let e=i.mediaIsFullscreen?De.EXIT_FULLSCREEN():De.ENTER_FULLSCREEN();i.setAttribute("aria-label",e)},Df=class extends be{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_IS_FULLSCREEN,b.MEDIA_FULLSCREEN_UNAVAILABLE]}constructor(e={}){super({slotTemplate:ub,...e})}connectedCallback(){super.connectedCallback(),db(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_IS_FULLSCREEN&&db(this)}get mediaFullscreenUnavailable(){return ue(this,b.MEDIA_FULLSCREEN_UNAVAILABLE)}set mediaFullscreenUnavailable(e){le(this,b.MEDIA_FULLSCREEN_UNAVAILABLE,e)}get mediaIsFullscreen(){return Le(this,b.MEDIA_IS_FULLSCREEN)}set mediaIsFullscreen(e){Ae(this,b.MEDIA_IS_FULLSCREEN,e)}handleClick(){let e=this.mediaIsFullscreen?F.MEDIA_EXIT_FULLSCREEN_REQUEST:F.MEDIA_ENTER_FULLSCREEN_REQUEST;this.dispatchEvent(new A.CustomEvent(e,{composed:!0,bubbles:!0}))}};A.customElements.get("media-fullscreen-button")||A.customElements.define("media-fullscreen-button",Df);var{MEDIA_TIME_IS_LIVE:id,MEDIA_PAUSED:La}=b,{MEDIA_SEEK_TO_LIVE_REQUEST:jS,MEDIA_PLAY_REQUEST:XS}=F,QS='<svg viewBox="0 0 6 12"><circle cx="3" cy="6" r="2"></circle></svg>',hb=O.createElement("template");hb.innerHTML=`
904
+ `;var cb=i=>{let e=i.mediaIsFullscreen?Me.EXIT_FULLSCREEN():Me.ENTER_FULLSCREEN();i.setAttribute("aria-label",e)},Nf=class extends be{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_IS_FULLSCREEN,b.MEDIA_FULLSCREEN_UNAVAILABLE]}constructor(e={}){super({slotTemplate:hb,...e})}connectedCallback(){super.connectedCallback(),cb(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_IS_FULLSCREEN&&cb(this)}get mediaFullscreenUnavailable(){return ue(this,b.MEDIA_FULLSCREEN_UNAVAILABLE)}set mediaFullscreenUnavailable(e){le(this,b.MEDIA_FULLSCREEN_UNAVAILABLE,e)}get mediaIsFullscreen(){return Le(this,b.MEDIA_IS_FULLSCREEN)}set mediaIsFullscreen(e){Ae(this,b.MEDIA_IS_FULLSCREEN,e)}handleClick(){let e=this.mediaIsFullscreen?B.MEDIA_EXIT_FULLSCREEN_REQUEST:B.MEDIA_ENTER_FULLSCREEN_REQUEST;this.dispatchEvent(new _.CustomEvent(e,{composed:!0,bubbles:!0}))}};_.customElements.get("media-fullscreen-button")||_.customElements.define("media-fullscreen-button",Nf);var{MEDIA_TIME_IS_LIVE:id,MEDIA_PAUSED:La}=b,{MEDIA_SEEK_TO_LIVE_REQUEST:YS,MEDIA_PLAY_REQUEST:zS}=B,jS='<svg viewBox="0 0 6 12"><circle cx="3" cy="6" r="2"></circle></svg>',mb=O.createElement("template");mb.innerHTML=`
905
905
  <style>
906
906
 
907
907
  slot[name=indicator] > *,
@@ -924,10 +924,10 @@
924
924
 
925
925
  </style>
926
926
 
927
- <slot name="indicator">${QS}</slot>
927
+ <slot name="indicator">${jS}</slot>
928
928
 
929
929
  <slot name="spacer">&nbsp;</slot><slot name="text">LIVE</slot>
930
- `;var cb=i=>{let e=i.mediaPaused||!i.mediaTimeIsLive,t=e?De.SEEK_LIVE():De.PLAYING_LIVE();i.setAttribute("aria-label",t),e?i.removeAttribute("aria-disabled"):i.setAttribute("aria-disabled","true")},Mf=class extends be{static get observedAttributes(){return[...super.observedAttributes,La,id]}constructor(e={}){super({slotTemplate:hb,...e})}connectedCallback(){cb(this),super.connectedCallback()}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),cb(this)}get mediaPaused(){return Le(this,b.MEDIA_PAUSED)}set mediaPaused(e){Ae(this,b.MEDIA_PAUSED,e)}get mediaTimeIsLive(){return Le(this,b.MEDIA_TIME_IS_LIVE)}set mediaTimeIsLive(e){Ae(this,b.MEDIA_TIME_IS_LIVE,e)}handleClick(){!this.mediaPaused&&this.mediaTimeIsLive||(this.dispatchEvent(new A.CustomEvent(jS,{composed:!0,bubbles:!0})),this.hasAttribute(La)&&this.dispatchEvent(new A.CustomEvent(XS,{composed:!0,bubbles:!0})))}};A.customElements.get("media-live-button")||A.customElements.define("media-live-button",Mf);var pb=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ka=(i,e,t)=>(pb(i,e,"read from private field"),t?t.call(i):e.get(i)),fb=(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)},Ia=(i,e,t,r)=>(pb(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Ni,rd,mb={LOADING_DELAY:"loadingdelay"},gb=500,vb=O.createElement("template"),ZS=`
930
+ `;var fb=i=>{let e=i.mediaPaused||!i.mediaTimeIsLive,t=e?Me.SEEK_LIVE():Me.PLAYING_LIVE();i.setAttribute("aria-label",t),e?i.removeAttribute("aria-disabled"):i.setAttribute("aria-disabled","true")},Uf=class extends be{static get observedAttributes(){return[...super.observedAttributes,La,id]}constructor(e={}){super({slotTemplate:mb,...e})}connectedCallback(){fb(this),super.connectedCallback()}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),fb(this)}get mediaPaused(){return Le(this,b.MEDIA_PAUSED)}set mediaPaused(e){Ae(this,b.MEDIA_PAUSED,e)}get mediaTimeIsLive(){return Le(this,b.MEDIA_TIME_IS_LIVE)}set mediaTimeIsLive(e){Ae(this,b.MEDIA_TIME_IS_LIVE,e)}handleClick(){!this.mediaPaused&&this.mediaTimeIsLive||(this.dispatchEvent(new _.CustomEvent(YS,{composed:!0,bubbles:!0})),this.hasAttribute(La)&&this.dispatchEvent(new _.CustomEvent(zS,{composed:!0,bubbles:!0})))}};_.customElements.get("media-live-button")||_.customElements.define("media-live-button",Uf);var vb=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ka=(i,e,t)=>(vb(i,e,"read from private field"),t?t.call(i):e.get(i)),pb=(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)},Ia=(i,e,t,r)=>(vb(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Ni,rd,gb={LOADING_DELAY:"loadingdelay"},Eb=500,bb=O.createElement("template"),XS=`
931
931
  <svg aria-hidden="true" viewBox="0 0 100 100">
932
932
  <path d="M73,50c0-12.7-10.3-23-23-23S27,37.3,27,50 M30.9,50c0-10.5,8.5-19.1,19.1-19.1S69.1,39.5,69.1,50">
933
933
  <animateTransform
@@ -940,13 +940,13 @@
940
940
  repeatCount="indefinite" />
941
941
  </path>
942
942
  </svg>
943
- `;vb.innerHTML=`
943
+ `;bb.innerHTML=`
944
944
  <style>
945
945
  :host {
946
946
  display: var(--media-control-display, var(--media-loading-indicator-display, inline-block));
947
947
  vertical-align: middle;
948
948
  box-sizing: border-box;
949
- --_loading-indicator-delay: var(--media-loading-indicator-transition-delay, ${gb}ms);
949
+ --_loading-indicator-delay: var(--media-loading-indicator-transition-delay, ${Eb}ms);
950
950
  }
951
951
 
952
952
  #status {
@@ -985,15 +985,15 @@ svg, img, ::slotted(svg), ::slotted(img) {
985
985
  }
986
986
  </style>
987
987
 
988
- <slot name="icon">${ZS}</slot>
989
- <div id="status" role="status" aria-live="polite">${Ce.MEDIA_LOADING()}</div>
990
- `;var Pf=class extends A.HTMLElement{constructor(){if(super(),fb(this,Ni,void 0),fb(this,rd,gb),!this.shadowRoot){let e=this.attachShadow({mode:"open"}),t=vb.content.cloneNode(!0);e.appendChild(t)}}static get observedAttributes(){return[ee.MEDIA_CONTROLLER,b.MEDIA_PAUSED,b.MEDIA_LOADING,mb.LOADING_DELAY]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===mb.LOADING_DELAY&&t!==r?this.loadingDelay=Number(r):e===ee.MEDIA_CONTROLLER&&(t&&((n=(s=ka(this,Ni))==null?void 0:s.unassociateElement)==null||n.call(s,this),Ia(this,Ni,null)),r&&this.isConnected&&(Ia(this,Ni,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=ka(this,Ni))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r;let s=this.getAttribute(ee.MEDIA_CONTROLLER);s&&(Ia(this,Ni,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=ka(this,Ni))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=ka(this,Ni))==null?void 0:e.unassociateElement)==null||t.call(e,this),Ia(this,Ni,null)}get loadingDelay(){return ka(this,rd)}set loadingDelay(e){Ia(this,rd,e);let{style:t}=Te(this.shadowRoot,":host");t.setProperty("--_loading-indicator-delay",`var(--media-loading-indicator-transition-delay, ${e}ms)`)}get mediaPaused(){return Le(this,b.MEDIA_PAUSED)}set mediaPaused(e){Ae(this,b.MEDIA_PAUSED,e)}get mediaLoading(){return Le(this,b.MEDIA_LOADING)}set mediaLoading(e){Ae(this,b.MEDIA_LOADING,e)}};Ni=new WeakMap;rd=new WeakMap;A.customElements.get("media-loading-indicator")||A.customElements.define("media-loading-indicator",Pf);var{MEDIA_VOLUME_LEVEL:Ra}=b,JS=`<svg aria-hidden="true" viewBox="0 0 24 24">
988
+ <slot name="icon">${XS}</slot>
989
+ <div id="status" role="status" aria-live="polite">${De.MEDIA_LOADING()}</div>
990
+ `;var Ff=class extends _.HTMLElement{constructor(){if(super(),pb(this,Ni,void 0),pb(this,rd,Eb),!this.shadowRoot){let e=this.attachShadow({mode:"open"}),t=bb.content.cloneNode(!0);e.appendChild(t)}}static get observedAttributes(){return[te.MEDIA_CONTROLLER,b.MEDIA_PAUSED,b.MEDIA_LOADING,gb.LOADING_DELAY]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===gb.LOADING_DELAY&&t!==r?this.loadingDelay=Number(r):e===te.MEDIA_CONTROLLER&&(t&&((n=(s=ka(this,Ni))==null?void 0:s.unassociateElement)==null||n.call(s,this),Ia(this,Ni,null)),r&&this.isConnected&&(Ia(this,Ni,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=ka(this,Ni))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r;let s=this.getAttribute(te.MEDIA_CONTROLLER);s&&(Ia(this,Ni,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=ka(this,Ni))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=ka(this,Ni))==null?void 0:e.unassociateElement)==null||t.call(e,this),Ia(this,Ni,null)}get loadingDelay(){return ka(this,rd)}set loadingDelay(e){Ia(this,rd,e);let{style:t}=Te(this.shadowRoot,":host");t.setProperty("--_loading-indicator-delay",`var(--media-loading-indicator-transition-delay, ${e}ms)`)}get mediaPaused(){return Le(this,b.MEDIA_PAUSED)}set mediaPaused(e){Ae(this,b.MEDIA_PAUSED,e)}get mediaLoading(){return Le(this,b.MEDIA_LOADING)}set mediaLoading(e){Ae(this,b.MEDIA_LOADING,e)}};Ni=new WeakMap;rd=new WeakMap;_.customElements.get("media-loading-indicator")||_.customElements.define("media-loading-indicator",Ff);var{MEDIA_VOLUME_LEVEL:Ra}=b,QS=`<svg aria-hidden="true" viewBox="0 0 24 24">
991
991
  <path d="M16.5 12A4.5 4.5 0 0 0 14 8v2.18l2.45 2.45a4.22 4.22 0 0 0 .05-.63Zm2.5 0a6.84 6.84 0 0 1-.54 2.64L20 16.15A8.8 8.8 0 0 0 21 12a9 9 0 0 0-7-8.77v2.06A7 7 0 0 1 19 12ZM4.27 3 3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25A6.92 6.92 0 0 1 14 18.7v2.06A9 9 0 0 0 17.69 19l2 2.05L21 19.73l-9-9L4.27 3ZM12 4 9.91 6.09 12 8.18V4Z"/>
992
- </svg>`,Eb=`<svg aria-hidden="true" viewBox="0 0 24 24">
992
+ </svg>`,yb=`<svg aria-hidden="true" viewBox="0 0 24 24">
993
993
  <path d="M3 9v6h4l5 5V4L7 9H3Zm13.5 3A4.5 4.5 0 0 0 14 8v8a4.47 4.47 0 0 0 2.5-4Z"/>
994
- </svg>`,ex=`<svg aria-hidden="true" viewBox="0 0 24 24">
994
+ </svg>`,ZS=`<svg aria-hidden="true" viewBox="0 0 24 24">
995
995
  <path d="M3 9v6h4l5 5V4L7 9H3Zm13.5 3A4.5 4.5 0 0 0 14 8v8a4.47 4.47 0 0 0 2.5-4ZM14 3.23v2.06a7 7 0 0 1 0 13.42v2.06a9 9 0 0 0 0-17.54Z"/>
996
- </svg>`,yb=O.createElement("template");yb.innerHTML=`
996
+ </svg>`,_b=O.createElement("template");_b.innerHTML=`
997
997
  <style>
998
998
 
999
999
  :host(:not([${Ra}])) slot:not([name=high]):not([name=icon]),
@@ -1015,14 +1015,14 @@ svg, img, ::slotted(svg), ::slotted(img) {
1015
1015
  </style>
1016
1016
 
1017
1017
  <slot name="icon">
1018
- <slot name="off">${JS}</slot>
1019
- <slot name="low">${Eb}</slot>
1020
- <slot name="medium">${Eb}</slot>
1021
- <slot name="high">${ex}</slot>
1018
+ <slot name="off">${QS}</slot>
1019
+ <slot name="low">${yb}</slot>
1020
+ <slot name="medium">${yb}</slot>
1021
+ <slot name="high">${ZS}</slot>
1022
1022
  </slot>
1023
- `;var bb=i=>{let t=i.mediaVolumeLevel==="off"?De.UNMUTE():De.MUTE();i.setAttribute("aria-label",t)},Of=class extends be{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_VOLUME_LEVEL]}constructor(e={}){super({slotTemplate:yb,...e})}connectedCallback(){bb(this),super.connectedCallback()}attributeChangedCallback(e,t,r){e===b.MEDIA_VOLUME_LEVEL&&bb(this),super.attributeChangedCallback(e,t,r)}get mediaVolumeLevel(){return ue(this,b.MEDIA_VOLUME_LEVEL)}set mediaVolumeLevel(e){le(this,b.MEDIA_VOLUME_LEVEL,e)}handleClick(){let e=this.mediaVolumeLevel==="off"?F.MEDIA_UNMUTE_REQUEST:F.MEDIA_MUTE_REQUEST;this.dispatchEvent(new A.CustomEvent(e,{composed:!0,bubbles:!0}))}};A.customElements.get("media-mute-button")||A.customElements.define("media-mute-button",Of);var Tb=`<svg aria-hidden="true" viewBox="0 0 28 24">
1023
+ `;var Tb=i=>{let t=i.mediaVolumeLevel==="off"?Me.UNMUTE():Me.MUTE();i.setAttribute("aria-label",t)},Bf=class extends be{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_VOLUME_LEVEL]}constructor(e={}){super({slotTemplate:_b,...e})}connectedCallback(){Tb(this),super.connectedCallback()}attributeChangedCallback(e,t,r){e===b.MEDIA_VOLUME_LEVEL&&Tb(this),super.attributeChangedCallback(e,t,r)}get mediaVolumeLevel(){return ue(this,b.MEDIA_VOLUME_LEVEL)}set mediaVolumeLevel(e){le(this,b.MEDIA_VOLUME_LEVEL,e)}handleClick(){let e=this.mediaVolumeLevel==="off"?B.MEDIA_UNMUTE_REQUEST:B.MEDIA_MUTE_REQUEST;this.dispatchEvent(new _.CustomEvent(e,{composed:!0,bubbles:!0}))}};_.customElements.get("media-mute-button")||_.customElements.define("media-mute-button",Bf);var Ab=`<svg aria-hidden="true" viewBox="0 0 28 24">
1024
1024
  <path d="M24 3H4a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h20a1 1 0 0 0 1-1V4a1 1 0 0 0-1-1Zm-1 16H5V5h18v14Zm-3-8h-7v5h7v-5Z"/>
1025
- </svg>`,Ab=O.createElement("template");Ab.innerHTML=`
1025
+ </svg>`,xb=O.createElement("template");xb.innerHTML=`
1026
1026
  <style>
1027
1027
  :host([${b.MEDIA_IS_PIP}]) slot:not([name=exit]):not([name=icon]) {
1028
1028
  display: none !important;
@@ -1035,10 +1035,10 @@ svg, img, ::slotted(svg), ::slotted(img) {
1035
1035
  </style>
1036
1036
 
1037
1037
  <slot name="icon">
1038
- <slot name="enter">${Tb}</slot>
1039
- <slot name="exit">${Tb}</slot>
1038
+ <slot name="enter">${Ab}</slot>
1039
+ <slot name="exit">${Ab}</slot>
1040
1040
  </slot>
1041
- `;var _b=i=>{let e=i.mediaIsPip?De.EXIT_PIP():De.ENTER_PIP();i.setAttribute("aria-label",e)},Nf=class extends be{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_IS_PIP,b.MEDIA_PIP_UNAVAILABLE]}constructor(e={}){super({slotTemplate:Ab,...e})}connectedCallback(){_b(this),super.connectedCallback()}attributeChangedCallback(e,t,r){e===b.MEDIA_IS_PIP&&_b(this),super.attributeChangedCallback(e,t,r)}get mediaPipUnavailable(){return ue(this,b.MEDIA_PIP_UNAVAILABLE)}set mediaPipUnavailable(e){le(this,b.MEDIA_PIP_UNAVAILABLE,e)}get mediaIsPip(){return Le(this,b.MEDIA_IS_PIP)}set mediaIsPip(e){Ae(this,b.MEDIA_IS_PIP,e)}handleClick(){let e=this.mediaIsPip?F.MEDIA_EXIT_PIP_REQUEST:F.MEDIA_ENTER_PIP_REQUEST;this.dispatchEvent(new A.CustomEvent(e,{composed:!0,bubbles:!0}))}};A.customElements.get("media-pip-button")||A.customElements.define("media-pip-button",Nf);var tx=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},sd=(i,e,t)=>(tx(i,e,"read from private field"),t?t.call(i):e.get(i)),ix=(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)},vn,Uf={RATES:"rates"},wa=[1,1.2,1.5,1.7,2],kr=1,Sb=O.createElement("template");Sb.innerHTML=`
1041
+ `;var Sb=i=>{let e=i.mediaIsPip?Me.EXIT_PIP():Me.ENTER_PIP();i.setAttribute("aria-label",e)},$f=class extends be{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_IS_PIP,b.MEDIA_PIP_UNAVAILABLE]}constructor(e={}){super({slotTemplate:xb,...e})}connectedCallback(){Sb(this),super.connectedCallback()}attributeChangedCallback(e,t,r){e===b.MEDIA_IS_PIP&&Sb(this),super.attributeChangedCallback(e,t,r)}get mediaPipUnavailable(){return ue(this,b.MEDIA_PIP_UNAVAILABLE)}set mediaPipUnavailable(e){le(this,b.MEDIA_PIP_UNAVAILABLE,e)}get mediaIsPip(){return Le(this,b.MEDIA_IS_PIP)}set mediaIsPip(e){Ae(this,b.MEDIA_IS_PIP,e)}handleClick(){let e=this.mediaIsPip?B.MEDIA_EXIT_PIP_REQUEST:B.MEDIA_ENTER_PIP_REQUEST;this.dispatchEvent(new _.CustomEvent(e,{composed:!0,bubbles:!0}))}};_.customElements.get("media-pip-button")||_.customElements.define("media-pip-button",$f);var JS=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},sd=(i,e,t)=>(JS(i,e,"read from private field"),t?t.call(i):e.get(i)),ex=(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)},En,Hf={RATES:"rates"},wa=[1,1.2,1.5,1.7,2],kr=1,Lb=O.createElement("template");Lb.innerHTML=`
1042
1042
  <style>
1043
1043
  :host {
1044
1044
  min-width: 5ch;
@@ -1046,7 +1046,7 @@ svg, img, ::slotted(svg), ::slotted(img) {
1046
1046
  }
1047
1047
  </style>
1048
1048
  <slot name="icon"></slot>
1049
- `;var Ff=class extends be{constructor(e={}){super({slotTemplate:Sb,...e}),ix(this,vn,new qt(this,Uf.RATES,{defaultValue:wa})),this.container=this.shadowRoot.querySelector('slot[name="icon"]'),this.container.innerHTML=`${kr}x`}static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_PLAYBACK_RATE,Uf.RATES]}attributeChangedCallback(e,t,r){if(super.attributeChangedCallback(e,t,r),e===Uf.RATES&&(sd(this,vn).value=r),e===b.MEDIA_PLAYBACK_RATE){let s=r?+r:Number.NaN,n=Number.isNaN(s)?kr:s;this.container.innerHTML=`${n}x`,this.setAttribute("aria-label",Ce.PLAYBACK_RATE({playbackRate:n}))}}get rates(){return sd(this,vn)}set rates(e){e?Array.isArray(e)&&(sd(this,vn).value=e.join(" ")):sd(this,vn).value=""}get mediaPlaybackRate(){return ve(this,b.MEDIA_PLAYBACK_RATE,kr)}set mediaPlaybackRate(e){_e(this,b.MEDIA_PLAYBACK_RATE,e)}handleClick(){var e,t;let r=Array.from(this.rates.values(),a=>+a).sort((a,o)=>a-o),s=(t=(e=r.find(a=>a>this.mediaPlaybackRate))!=null?e:r[0])!=null?t:kr,n=new A.CustomEvent(F.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:s});this.dispatchEvent(n)}};vn=new WeakMap;A.customElements.get("media-playback-rate-button")||A.customElements.define("media-playback-rate-button",Ff);var xb=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},nd=(i,e,t)=>(xb(i,e,"read from private field"),t?t.call(i):e.get(i)),Bf=(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)},Ca=(i,e,t)=>(xb(i,e,"access private method"),t),En,Da,ad,od,Hf,$f={RATES:"rates"},Gf=class extends Tt{constructor(){super(),Bf(this,Da),Bf(this,od),Bf(this,En,new qt(this,$f.RATES,{defaultValue:wa})),Ca(this,Da,ad).call(this)}static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_PLAYBACK_RATE,$f.RATES]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_PLAYBACK_RATE&&t!=r?this.value=r:e===$f.RATES&&t!=r&&(nd(this,En).value=r,Ca(this,Da,ad).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Ca(this,od,Hf))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Ca(this,od,Hf))}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:qe(this).querySelector("media-playback-rate-menu-button")}get rates(){return nd(this,En)}set rates(e){e?Array.isArray(e)&&(nd(this,En).value=e.join(" ")):nd(this,En).value="",Ca(this,Da,ad).call(this)}get mediaPlaybackRate(){return ve(this,b.MEDIA_PLAYBACK_RATE,kr)}set mediaPlaybackRate(e){_e(this,b.MEDIA_PLAYBACK_RATE,e)}};En=new WeakMap;Da=new WeakSet;ad=function(){this.defaultSlot.textContent="";for(let i of this.rates){let e=Ii({type:"radio",text:this.formatMenuItemText(`${i}x`,i),value:i,checked:this.mediaPlaybackRate==i});e.prepend(di(this,"checked-indicator")),this.defaultSlot.append(e)}};od=new WeakSet;Hf=function(){if(!this.value)return;let i=new A.CustomEvent(F.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};A.customElements.get("media-playback-rate-menu")||A.customElements.define("media-playback-rate-menu",Gf);var rx=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ld=(i,e,t)=>(rx(i,e,"read from private field"),t?t.call(i):e.get(i)),sx=(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)},bn,Wf={RATES:"rates"},nx=[1,1.2,1.5,1.7,2],Vf=1,Lb=O.createElement("template");Lb.innerHTML=`
1049
+ `;var Gf=class extends be{constructor(e={}){super({slotTemplate:Lb,...e}),ex(this,En,new qt(this,Hf.RATES,{defaultValue:wa})),this.container=this.shadowRoot.querySelector('slot[name="icon"]'),this.container.innerHTML=`${kr}x`}static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_PLAYBACK_RATE,Hf.RATES]}attributeChangedCallback(e,t,r){if(super.attributeChangedCallback(e,t,r),e===Hf.RATES&&(sd(this,En).value=r),e===b.MEDIA_PLAYBACK_RATE){let s=r?+r:Number.NaN,n=Number.isNaN(s)?kr:s;this.container.innerHTML=`${n}x`,this.setAttribute("aria-label",De.PLAYBACK_RATE({playbackRate:n}))}}get rates(){return sd(this,En)}set rates(e){e?Array.isArray(e)&&(sd(this,En).value=e.join(" ")):sd(this,En).value=""}get mediaPlaybackRate(){return ve(this,b.MEDIA_PLAYBACK_RATE,kr)}set mediaPlaybackRate(e){_e(this,b.MEDIA_PLAYBACK_RATE,e)}handleClick(){var e,t;let r=Array.from(this.rates.values(),a=>+a).sort((a,o)=>a-o),s=(t=(e=r.find(a=>a>this.mediaPlaybackRate))!=null?e:r[0])!=null?t:kr,n=new _.CustomEvent(B.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:s});this.dispatchEvent(n)}};En=new WeakMap;_.customElements.get("media-playback-rate-button")||_.customElements.define("media-playback-rate-button",Gf);var kb=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},nd=(i,e,t)=>(kb(i,e,"read from private field"),t?t.call(i):e.get(i)),Wf=(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)},Ca=(i,e,t)=>(kb(i,e,"access private method"),t),bn,Da,ad,od,Vf,Kf={RATES:"rates"},qf=class extends Tt{constructor(){super(),Wf(this,Da),Wf(this,od),Wf(this,bn,new qt(this,Kf.RATES,{defaultValue:wa})),Ca(this,Da,ad).call(this)}static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_PLAYBACK_RATE,Kf.RATES]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_PLAYBACK_RATE&&t!=r?this.value=r:e===Kf.RATES&&t!=r&&(nd(this,bn).value=r,Ca(this,Da,ad).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Ca(this,od,Vf))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Ca(this,od,Vf))}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:Ye(this).querySelector("media-playback-rate-menu-button")}get rates(){return nd(this,bn)}set rates(e){e?Array.isArray(e)&&(nd(this,bn).value=e.join(" ")):nd(this,bn).value="",Ca(this,Da,ad).call(this)}get mediaPlaybackRate(){return ve(this,b.MEDIA_PLAYBACK_RATE,kr)}set mediaPlaybackRate(e){_e(this,b.MEDIA_PLAYBACK_RATE,e)}};bn=new WeakMap;Da=new WeakSet;ad=function(){this.defaultSlot.textContent="";for(let i of this.rates){let e=Ii({type:"radio",text:this.formatMenuItemText(`${i}x`,i),value:i,checked:this.mediaPlaybackRate==i});e.prepend(di(this,"checked-indicator")),this.defaultSlot.append(e)}};od=new WeakSet;Vf=function(){if(!this.value)return;let i=new _.CustomEvent(B.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};_.customElements.get("media-playback-rate-menu")||_.customElements.define("media-playback-rate-menu",qf);var tx=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ld=(i,e,t)=>(tx(i,e,"read from private field"),t?t.call(i):e.get(i)),ix=(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)},yn,Yf={RATES:"rates"},rx=[1,1.2,1.5,1.7,2],zf=1,Ib=O.createElement("template");Ib.innerHTML=`
1050
1050
  <style>
1051
1051
  :host {
1052
1052
  min-width: 5ch;
@@ -1054,11 +1054,11 @@ svg, img, ::slotted(svg), ::slotted(img) {
1054
1054
  }
1055
1055
  </style>
1056
1056
  <slot name="icon"></slot>
1057
- `;var Kf=class extends $t{constructor(e={}){super({slotTemplate:Lb,...e}),sx(this,bn,new qt(this,Wf.RATES,{defaultValue:nx})),this.container=this.shadowRoot.querySelector('slot[name="icon"]'),this.container.innerHTML=`${Vf}x`}static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_PLAYBACK_RATE,Wf.RATES]}attributeChangedCallback(e,t,r){if(super.attributeChangedCallback(e,t,r),e===Wf.RATES&&(ld(this,bn).value=r),e===b.MEDIA_PLAYBACK_RATE){let s=r?+r:Number.NaN,n=Number.isNaN(s)?Vf:s;this.container.innerHTML=`${n}x`,this.setAttribute("aria-label",Ce.PLAYBACK_RATE({playbackRate:n}))}}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:qe(this).querySelector("media-playback-rate-menu")}get rates(){return ld(this,bn)}set rates(e){e?Array.isArray(e)&&(ld(this,bn).value=e.join(" ")):ld(this,bn).value=""}get mediaPlaybackRate(){return ve(this,b.MEDIA_PLAYBACK_RATE,Vf)}set mediaPlaybackRate(e){_e(this,b.MEDIA_PLAYBACK_RATE,e)}};bn=new WeakMap;A.customElements.get("media-playback-rate-menu-button")||A.customElements.define("media-playback-rate-menu-button",Kf);var ax=`<svg aria-hidden="true" viewBox="0 0 24 24">
1057
+ `;var jf=class extends $t{constructor(e={}){super({slotTemplate:Ib,...e}),ix(this,yn,new qt(this,Yf.RATES,{defaultValue:rx})),this.container=this.shadowRoot.querySelector('slot[name="icon"]'),this.container.innerHTML=`${zf}x`}static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_PLAYBACK_RATE,Yf.RATES]}attributeChangedCallback(e,t,r){if(super.attributeChangedCallback(e,t,r),e===Yf.RATES&&(ld(this,yn).value=r),e===b.MEDIA_PLAYBACK_RATE){let s=r?+r:Number.NaN,n=Number.isNaN(s)?zf:s;this.container.innerHTML=`${n}x`,this.setAttribute("aria-label",De.PLAYBACK_RATE({playbackRate:n}))}}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:Ye(this).querySelector("media-playback-rate-menu")}get rates(){return ld(this,yn)}set rates(e){e?Array.isArray(e)&&(ld(this,yn).value=e.join(" ")):ld(this,yn).value=""}get mediaPlaybackRate(){return ve(this,b.MEDIA_PLAYBACK_RATE,zf)}set mediaPlaybackRate(e){_e(this,b.MEDIA_PLAYBACK_RATE,e)}};yn=new WeakMap;_.customElements.get("media-playback-rate-menu-button")||_.customElements.define("media-playback-rate-menu-button",jf);var sx=`<svg aria-hidden="true" viewBox="0 0 24 24">
1058
1058
  <path d="m6 21 15-9L6 3v18Z"/>
1059
- </svg>`,ox=`<svg aria-hidden="true" viewBox="0 0 24 24">
1059
+ </svg>`,nx=`<svg aria-hidden="true" viewBox="0 0 24 24">
1060
1060
  <path d="M6 20h4V4H6v16Zm8-16v16h4V4h-4Z"/>
1061
- </svg>`,Ib=O.createElement("template");Ib.innerHTML=`
1061
+ </svg>`,wb=O.createElement("template");wb.innerHTML=`
1062
1062
  <style>
1063
1063
  :host([${b.MEDIA_PAUSED}]) slot[name=pause] {
1064
1064
  display: none !important;
@@ -1070,10 +1070,10 @@ svg, img, ::slotted(svg), ::slotted(img) {
1070
1070
  </style>
1071
1071
 
1072
1072
  <slot name="icon">
1073
- <slot name="play">${ax}</slot>
1074
- <slot name="pause">${ox}</slot>
1073
+ <slot name="play">${sx}</slot>
1074
+ <slot name="pause">${nx}</slot>
1075
1075
  </slot>
1076
- `;var kb=i=>{let e=i.mediaPaused?De.PLAY():De.PAUSE();i.setAttribute("aria-label",e)},qf=class extends be{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_PAUSED,b.MEDIA_ENDED]}constructor(e={}){super({slotTemplate:Ib,...e})}connectedCallback(){kb(this),super.connectedCallback()}attributeChangedCallback(e,t,r){e===b.MEDIA_PAUSED&&kb(this),super.attributeChangedCallback(e,t,r)}get mediaPaused(){return Le(this,b.MEDIA_PAUSED)}set mediaPaused(e){Ae(this,b.MEDIA_PAUSED,e)}handleClick(){let e=this.mediaPaused?F.MEDIA_PLAY_REQUEST:F.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new A.CustomEvent(e,{composed:!0,bubbles:!0}))}};A.customElements.get("media-play-button")||A.customElements.define("media-play-button",qf);var Ui={PLACEHOLDER_SRC:"placeholdersrc",SRC:"src"},Rb=O.createElement("template");Rb.innerHTML=`
1076
+ `;var Rb=i=>{let e=i.mediaPaused?Me.PLAY():Me.PAUSE();i.setAttribute("aria-label",e)},Xf=class extends be{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_PAUSED,b.MEDIA_ENDED]}constructor(e={}){super({slotTemplate:wb,...e})}connectedCallback(){Rb(this),super.connectedCallback()}attributeChangedCallback(e,t,r){e===b.MEDIA_PAUSED&&Rb(this),super.attributeChangedCallback(e,t,r)}get mediaPaused(){return Le(this,b.MEDIA_PAUSED)}set mediaPaused(e){Ae(this,b.MEDIA_PAUSED,e)}handleClick(){let e=this.mediaPaused?B.MEDIA_PLAY_REQUEST:B.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new _.CustomEvent(e,{composed:!0,bubbles:!0}))}};_.customElements.get("media-play-button")||_.customElements.define("media-play-button",Xf);var Ui={PLACEHOLDER_SRC:"placeholdersrc",SRC:"src"},Cb=O.createElement("template");Cb.innerHTML=`
1077
1077
  <style>
1078
1078
  :host {
1079
1079
  pointer-events: none;
@@ -1095,7 +1095,7 @@ svg, img, ::slotted(svg), ::slotted(img) {
1095
1095
  </style>
1096
1096
 
1097
1097
  <img part="poster img" aria-hidden="true" id="image"/>
1098
- `;var lx=i=>{i.style.removeProperty("background-image")},dx=(i,e)=>{i.style["background-image"]=`url('${e}')`},Yf=class extends A.HTMLElement{static get observedAttributes(){return[Ui.PLACEHOLDER_SRC,Ui.SRC]}constructor(){super(),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Rb.content.cloneNode(!0))),this.image=this.shadowRoot.querySelector("#image")}attributeChangedCallback(e,t,r){e===Ui.SRC&&(r==null?this.image.removeAttribute(Ui.SRC):this.image.setAttribute(Ui.SRC,r)),e===Ui.PLACEHOLDER_SRC&&(r==null?lx(this.image):dx(this.image,r))}get placeholderSrc(){return ue(this,Ui.PLACEHOLDER_SRC)}set placeholderSrc(e){le(this,Ui.SRC,e)}get src(){return ue(this,Ui.SRC)}set src(e){le(this,Ui.SRC,e)}};A.customElements.get("media-poster-image")||A.customElements.define("media-poster-image",Yf);var wb=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ux=(i,e,t)=>(wb(i,e,"read from private field"),t?t.call(i):e.get(i)),cx=(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)},hx=(i,e,t,r)=>(wb(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),dd,zf=class extends ab{constructor(){super(),cx(this,dd,void 0),hx(this,dd,this.shadowRoot.querySelector("slot"))}static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_PREVIEW_CHAPTER]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_PREVIEW_CHAPTER&&r!==t&&r!=null&&(ux(this,dd).textContent=r,r!==""?this.setAttribute("aria-valuetext",`chapter: ${r}`):this.removeAttribute("aria-valuetext"))}get mediaPreviewChapter(){return ue(this,b.MEDIA_PREVIEW_CHAPTER)}set mediaPreviewChapter(e){le(this,b.MEDIA_PREVIEW_CHAPTER,e)}};dd=new WeakMap;A.customElements.get("media-preview-chapter-display")||A.customElements.define("media-preview-chapter-display",zf);var Cb=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ud=(i,e,t)=>(Cb(i,e,"read from private field"),t?t.call(i):e.get(i)),fx=(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)},cd=(i,e,t,r)=>(Cb(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Fi,Db=O.createElement("template");Db.innerHTML=`
1098
+ `;var ax=i=>{i.style.removeProperty("background-image")},ox=(i,e)=>{i.style["background-image"]=`url('${e}')`},Qf=class extends _.HTMLElement{static get observedAttributes(){return[Ui.PLACEHOLDER_SRC,Ui.SRC]}constructor(){super(),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Cb.content.cloneNode(!0))),this.image=this.shadowRoot.querySelector("#image")}attributeChangedCallback(e,t,r){e===Ui.SRC&&(r==null?this.image.removeAttribute(Ui.SRC):this.image.setAttribute(Ui.SRC,r)),e===Ui.PLACEHOLDER_SRC&&(r==null?ax(this.image):ox(this.image,r))}get placeholderSrc(){return ue(this,Ui.PLACEHOLDER_SRC)}set placeholderSrc(e){le(this,Ui.SRC,e)}get src(){return ue(this,Ui.SRC)}set src(e){le(this,Ui.SRC,e)}};_.customElements.get("media-poster-image")||_.customElements.define("media-poster-image",Qf);var Db=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},lx=(i,e,t)=>(Db(i,e,"read from private field"),t?t.call(i):e.get(i)),dx=(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)},ux=(i,e,t,r)=>(Db(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),dd,Zf=class extends lb{constructor(){super(),dx(this,dd,void 0),ux(this,dd,this.shadowRoot.querySelector("slot"))}static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_PREVIEW_CHAPTER]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_PREVIEW_CHAPTER&&r!==t&&r!=null&&(lx(this,dd).textContent=r,r!==""?this.setAttribute("aria-valuetext",`chapter: ${r}`):this.removeAttribute("aria-valuetext"))}get mediaPreviewChapter(){return ue(this,b.MEDIA_PREVIEW_CHAPTER)}set mediaPreviewChapter(e){le(this,b.MEDIA_PREVIEW_CHAPTER,e)}};dd=new WeakMap;_.customElements.get("media-preview-chapter-display")||_.customElements.define("media-preview-chapter-display",Zf);var Mb=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ud=(i,e,t)=>(Mb(i,e,"read from private field"),t?t.call(i):e.get(i)),cx=(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)},cd=(i,e,t,r)=>(Mb(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Fi,Pb=O.createElement("template");Pb.innerHTML=`
1099
1099
  <style>
1100
1100
  :host {
1101
1101
  box-sizing: border-box;
@@ -1109,15 +1109,15 @@ svg, img, ::slotted(svg), ::slotted(img) {
1109
1109
  }
1110
1110
  </style>
1111
1111
  <img crossorigin loading="eager" decoding="async">
1112
- `;var jf=class extends A.HTMLElement{constructor(){super(),fx(this,Fi,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Db.content.cloneNode(!0)))}static get observedAttributes(){return[ee.MEDIA_CONTROLLER,b.MEDIA_PREVIEW_IMAGE,b.MEDIA_PREVIEW_COORDS]}connectedCallback(){var e,t,r;let s=this.getAttribute(ee.MEDIA_CONTROLLER);s&&(cd(this,Fi,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=ud(this,Fi))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=ud(this,Fi))==null?void 0:e.unassociateElement)==null||t.call(e,this),cd(this,Fi,null)}attributeChangedCallback(e,t,r){var s,n,a,o,l;[b.MEDIA_PREVIEW_IMAGE,b.MEDIA_PREVIEW_COORDS].includes(e)&&this.update(),e===ee.MEDIA_CONTROLLER&&(t&&((n=(s=ud(this,Fi))==null?void 0:s.unassociateElement)==null||n.call(s,this),cd(this,Fi,null)),r&&this.isConnected&&(cd(this,Fi,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=ud(this,Fi))==null?void 0:o.associateElement)==null||l.call(o,this)))}get mediaPreviewImage(){return ue(this,b.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){le(this,b.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewCoords(){let e=this.getAttribute(b.MEDIA_PREVIEW_COORDS);if(e)return e.split(/\s+/).map(t=>+t)}set mediaPreviewCoords(e){if(!e){this.removeAttribute(b.MEDIA_PREVIEW_COORDS);return}this.setAttribute(b.MEDIA_PREVIEW_COORDS,e.join(" "))}update(){let e=this.mediaPreviewCoords,t=this.mediaPreviewImage;if(!(e&&t))return;let[r,s,n,a]=e,o=t.split("#")[0],l=getComputedStyle(this),{maxWidth:d,maxHeight:u,minWidth:c,minHeight:h}=l,f=Math.min(parseInt(d)/n,parseInt(u)/a),m=Math.max(parseInt(c)/n,parseInt(h)/a),p=f<1,g=p?f:m>1?m:1,{style:E}=Te(this.shadowRoot,":host"),T=Te(this.shadowRoot,"img").style,y=this.shadowRoot.querySelector("img"),S=p?"min":"max";E.setProperty(`${S}-width`,"initial","important"),E.setProperty(`${S}-height`,"initial","important"),E.width=`${n*g}px`,E.height=`${a*g}px`;let _=()=>{T.width=`${this.imgWidth*g}px`,T.height=`${this.imgHeight*g}px`,T.display="block"};y.src!==o&&(y.onload=()=>{this.imgWidth=y.naturalWidth,this.imgHeight=y.naturalHeight,_()},y.src=o,_()),_(),T.transform=`translate(-${r*g}px, -${s*g}px)`}};Fi=new WeakMap;A.customElements.get("media-preview-thumbnail")||A.customElements.define("media-preview-thumbnail",jf);var Pb=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Mb=(i,e,t)=>(Pb(i,e,"read from private field"),t?t.call(i):e.get(i)),mx=(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)},px=(i,e,t,r)=>(Pb(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Ma,Xf=class extends Oi{constructor(){super(),mx(this,Ma,void 0),px(this,Ma,this.shadowRoot.querySelector("slot")),Mb(this,Ma).textContent=Ai(0)}static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_PREVIEW_TIME]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_PREVIEW_TIME&&r!=null&&(Mb(this,Ma).textContent=Ai(r))}get mediaPreviewTime(){return ve(this,b.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){_e(this,b.MEDIA_PREVIEW_TIME,e)}};Ma=new WeakMap;A.customElements.get("media-preview-time-display")||A.customElements.define("media-preview-time-display",Xf);var tm=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Ob=(i,e,t)=>(tm(i,e,"read from private field"),t?t.call(i):e.get(i)),hd=(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)},Qf=(i,e,t,r)=>(tm(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),fd=(i,e,t)=>(tm(i,e,"access private method"),t),Pa,gd,md,Zf,pd,Jf,em=class extends Tt{constructor(){super(...arguments),hd(this,md),hd(this,pd),hd(this,Pa,[]),hd(this,gd,void 0)}static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_RENDITION_LIST,b.MEDIA_RENDITION_SELECTED,b.MEDIA_RENDITION_UNAVAILABLE]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_RENDITION_SELECTED&&t!==r?this.value=r!=null?r:"auto":e===b.MEDIA_RENDITION_LIST&&t!==r&&(Qf(this,Pa,qo(r)),fd(this,md,Zf).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",fd(this,pd,Jf))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",fd(this,pd,Jf))}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:qe(this).querySelector("media-rendition-menu-button")}get mediaRenditionList(){return Ob(this,Pa)}set mediaRenditionList(e){Qf(this,Pa,e),fd(this,md,Zf).call(this)}get mediaRenditionSelected(){return ue(this,b.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){le(this,b.MEDIA_RENDITION_SELECTED,e)}};Pa=new WeakMap;gd=new WeakMap;md=new WeakSet;Zf=function(){if(Ob(this,gd)===JSON.stringify(this.mediaRenditionList))return;Qf(this,gd,JSON.stringify(this.mediaRenditionList));let i=this.mediaRenditionList.sort((r,s)=>s.height-r.height);this.defaultSlot.textContent="";let e=!this.mediaRenditionSelected;for(let r of i){let s=this.formatMenuItemText(`${Math.min(r.width,r.height)}p`,r),n=Ii({type:"radio",text:s,value:`${r.id}`,checked:r.selected&&!e});n.prepend(di(this,"checked-indicator")),this.defaultSlot.append(n)}let t=Ii({type:"radio",text:this.formatMenuItemText("Auto"),value:"auto",checked:e});t.prepend(di(this,"checked-indicator")),this.defaultSlot.append(t)};pd=new WeakSet;Jf=function(){if(this.value==null)return;let i=new A.CustomEvent(F.MEDIA_RENDITION_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};A.customElements.get("media-rendition-menu")||A.customElements.define("media-rendition-menu",em);var gx=`<svg aria-hidden="true" viewBox="0 0 24 24">
1112
+ `;var Jf=class extends _.HTMLElement{constructor(){super(),cx(this,Fi,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Pb.content.cloneNode(!0)))}static get observedAttributes(){return[te.MEDIA_CONTROLLER,b.MEDIA_PREVIEW_IMAGE,b.MEDIA_PREVIEW_COORDS]}connectedCallback(){var e,t,r;let s=this.getAttribute(te.MEDIA_CONTROLLER);s&&(cd(this,Fi,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=ud(this,Fi))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=ud(this,Fi))==null?void 0:e.unassociateElement)==null||t.call(e,this),cd(this,Fi,null)}attributeChangedCallback(e,t,r){var s,n,a,o,l;[b.MEDIA_PREVIEW_IMAGE,b.MEDIA_PREVIEW_COORDS].includes(e)&&this.update(),e===te.MEDIA_CONTROLLER&&(t&&((n=(s=ud(this,Fi))==null?void 0:s.unassociateElement)==null||n.call(s,this),cd(this,Fi,null)),r&&this.isConnected&&(cd(this,Fi,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=ud(this,Fi))==null?void 0:o.associateElement)==null||l.call(o,this)))}get mediaPreviewImage(){return ue(this,b.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){le(this,b.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewCoords(){let e=this.getAttribute(b.MEDIA_PREVIEW_COORDS);if(e)return e.split(/\s+/).map(t=>+t)}set mediaPreviewCoords(e){if(!e){this.removeAttribute(b.MEDIA_PREVIEW_COORDS);return}this.setAttribute(b.MEDIA_PREVIEW_COORDS,e.join(" "))}update(){let e=this.mediaPreviewCoords,t=this.mediaPreviewImage;if(!(e&&t))return;let[r,s,n,a]=e,o=t.split("#")[0],l=getComputedStyle(this),{maxWidth:d,maxHeight:u,minWidth:c,minHeight:h}=l,f=Math.min(parseInt(d)/n,parseInt(u)/a),m=Math.max(parseInt(c)/n,parseInt(h)/a),p=f<1,g=p?f:m>1?m:1,{style:E}=Te(this.shadowRoot,":host"),T=Te(this.shadowRoot,"img").style,y=this.shadowRoot.querySelector("img"),S=p?"min":"max";E.setProperty(`${S}-width`,"initial","important"),E.setProperty(`${S}-height`,"initial","important"),E.width=`${n*g}px`,E.height=`${a*g}px`;let A=()=>{T.width=`${this.imgWidth*g}px`,T.height=`${this.imgHeight*g}px`,T.display="block"};y.src!==o&&(y.onload=()=>{this.imgWidth=y.naturalWidth,this.imgHeight=y.naturalHeight,A()},y.src=o,A()),A(),T.transform=`translate(-${r*g}px, -${s*g}px)`}};Fi=new WeakMap;_.customElements.get("media-preview-thumbnail")||_.customElements.define("media-preview-thumbnail",Jf);var Nb=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Ob=(i,e,t)=>(Nb(i,e,"read from private field"),t?t.call(i):e.get(i)),hx=(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)},fx=(i,e,t,r)=>(Nb(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Ma,em=class extends Oi{constructor(){super(),hx(this,Ma,void 0),fx(this,Ma,this.shadowRoot.querySelector("slot")),Ob(this,Ma).textContent=Ai(0)}static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_PREVIEW_TIME]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_PREVIEW_TIME&&r!=null&&(Ob(this,Ma).textContent=Ai(r))}get mediaPreviewTime(){return ve(this,b.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){_e(this,b.MEDIA_PREVIEW_TIME,e)}};Ma=new WeakMap;_.customElements.get("media-preview-time-display")||_.customElements.define("media-preview-time-display",em);var nm=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Ub=(i,e,t)=>(nm(i,e,"read from private field"),t?t.call(i):e.get(i)),hd=(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)},tm=(i,e,t,r)=>(nm(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),fd=(i,e,t)=>(nm(i,e,"access private method"),t),Pa,gd,md,im,pd,rm,sm=class extends Tt{constructor(){super(...arguments),hd(this,md),hd(this,pd),hd(this,Pa,[]),hd(this,gd,void 0)}static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_RENDITION_LIST,b.MEDIA_RENDITION_SELECTED,b.MEDIA_RENDITION_UNAVAILABLE]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_RENDITION_SELECTED&&t!==r?this.value=r!=null?r:"auto":e===b.MEDIA_RENDITION_LIST&&t!==r&&(tm(this,Pa,qo(r)),fd(this,md,im).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",fd(this,pd,rm))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",fd(this,pd,rm))}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:Ye(this).querySelector("media-rendition-menu-button")}get mediaRenditionList(){return Ub(this,Pa)}set mediaRenditionList(e){tm(this,Pa,e),fd(this,md,im).call(this)}get mediaRenditionSelected(){return ue(this,b.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){le(this,b.MEDIA_RENDITION_SELECTED,e)}};Pa=new WeakMap;gd=new WeakMap;md=new WeakSet;im=function(){if(Ub(this,gd)===JSON.stringify(this.mediaRenditionList))return;tm(this,gd,JSON.stringify(this.mediaRenditionList));let i=this.mediaRenditionList.sort((r,s)=>s.height-r.height);this.defaultSlot.textContent="";let e=!this.mediaRenditionSelected;for(let r of i){let s=this.formatMenuItemText(`${Math.min(r.width,r.height)}p`,r),n=Ii({type:"radio",text:s,value:`${r.id}`,checked:r.selected&&!e});n.prepend(di(this,"checked-indicator")),this.defaultSlot.append(n)}let t=Ii({type:"radio",text:this.formatMenuItemText("Auto"),value:"auto",checked:e});t.prepend(di(this,"checked-indicator")),this.defaultSlot.append(t)};pd=new WeakSet;rm=function(){if(this.value==null)return;let i=new _.CustomEvent(B.MEDIA_RENDITION_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};_.customElements.get("media-rendition-menu")||_.customElements.define("media-rendition-menu",sm);var mx=`<svg aria-hidden="true" viewBox="0 0 24 24">
1113
1113
  <path d="M13.5 2.5h2v6h-2v-2h-11v-2h11v-2Zm4 2h4v2h-4v-2Zm-12 4h2v6h-2v-2h-3v-2h3v-2Zm4 2h12v2h-12v-2Zm1 4h2v6h-2v-2h-8v-2h8v-2Zm4 2h7v2h-7v-2Z" />
1114
- </svg>`,Nb=O.createElement("template");Nb.innerHTML=`
1115
- <slot name="icon">${gx}</slot>
1116
- `;var im=class extends $t{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_RENDITION_SELECTED,b.MEDIA_RENDITION_UNAVAILABLE]}constructor(){super({slotTemplate:Nb})}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",Ce.QUALITY())}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:qe(this).querySelector("media-rendition-menu")}get mediaRenditionSelected(){return ue(this,b.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){le(this,b.MEDIA_RENDITION_SELECTED,e)}};A.customElements.get("media-rendition-menu-button")||A.customElements.define("media-rendition-menu-button",im);var yn={SEEK_OFFSET:"seekoffset"},vd=30,vx=`<svg aria-hidden="true" viewBox="0 0 20 24"><defs><style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style></defs><text class="text value" transform="translate(2.18 19.87)">${vd}</text><path d="M10 6V3L4.37 7 10 10.94V8a5.54 5.54 0 0 1 1.9 10.48v2.12A7.5 7.5 0 0 0 10 6Z"/></svg>`,Ub=O.createElement("template");Ub.innerHTML=`
1114
+ </svg>`,Fb=O.createElement("template");Fb.innerHTML=`
1115
+ <slot name="icon">${mx}</slot>
1116
+ `;var am=class extends $t{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_RENDITION_SELECTED,b.MEDIA_RENDITION_UNAVAILABLE]}constructor(){super({slotTemplate:Fb})}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",De.QUALITY())}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:Ye(this).querySelector("media-rendition-menu")}get mediaRenditionSelected(){return ue(this,b.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){le(this,b.MEDIA_RENDITION_SELECTED,e)}};_.customElements.get("media-rendition-menu-button")||_.customElements.define("media-rendition-menu-button",am);var Tn={SEEK_OFFSET:"seekoffset"},vd=30,px=`<svg aria-hidden="true" viewBox="0 0 20 24"><defs><style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style></defs><text class="text value" transform="translate(2.18 19.87)">${vd}</text><path d="M10 6V3L4.37 7 10 10.94V8a5.54 5.54 0 0 1 1.9 10.48v2.12A7.5 7.5 0 0 0 10 6Z"/></svg>`,Bb=O.createElement("template");Bb.innerHTML=`
1117
+ <slot name="icon">${px}</slot>
1118
+ `;var gx=0,om=class extends be{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_CURRENT_TIME,Tn.SEEK_OFFSET]}constructor(e={}){super({slotTemplate:Bb,...e})}connectedCallback(){this.seekOffset=ve(this,Tn.SEEK_OFFSET,vd),super.connectedCallback()}attributeChangedCallback(e,t,r){e===Tn.SEEK_OFFSET&&(this.seekOffset=ve(this,Tn.SEEK_OFFSET,vd)),super.attributeChangedCallback(e,t,r)}get seekOffset(){return ve(this,Tn.SEEK_OFFSET,vd)}set seekOffset(e){_e(this,Tn.SEEK_OFFSET,e),this.setAttribute("aria-label",Me.SEEK_BACK_N_SECS({seekOffset:this.seekOffset})),el(tl(this,"icon"),this.seekOffset)}get mediaCurrentTime(){return ve(this,b.MEDIA_CURRENT_TIME,gx)}set mediaCurrentTime(e){_e(this,b.MEDIA_CURRENT_TIME,e)}handleClick(){let e=Math.max(this.mediaCurrentTime-this.seekOffset,0),t=new _.CustomEvent(B.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}};_.customElements.get("media-seek-backward-button")||_.customElements.define("media-seek-backward-button",om);var _n={SEEK_OFFSET:"seekoffset"},Ed=30,vx=`<svg aria-hidden="true" viewBox="0 0 20 24"><defs><style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style></defs><text class="text value" transform="translate(8.9 19.87)">${Ed}</text><path d="M10 6V3l5.61 4L10 10.94V8a5.54 5.54 0 0 0-1.9 10.48v2.12A7.5 7.5 0 0 1 10 6Z"/></svg>`,$b=O.createElement("template");$b.innerHTML=`
1117
1119
  <slot name="icon">${vx}</slot>
1118
- `;var Ex=0,rm=class extends be{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_CURRENT_TIME,yn.SEEK_OFFSET]}constructor(e={}){super({slotTemplate:Ub,...e})}connectedCallback(){this.seekOffset=ve(this,yn.SEEK_OFFSET,vd),super.connectedCallback()}attributeChangedCallback(e,t,r){e===yn.SEEK_OFFSET&&(this.seekOffset=ve(this,yn.SEEK_OFFSET,vd)),super.attributeChangedCallback(e,t,r)}get seekOffset(){return ve(this,yn.SEEK_OFFSET,vd)}set seekOffset(e){_e(this,yn.SEEK_OFFSET,e),this.setAttribute("aria-label",De.SEEK_BACK_N_SECS({seekOffset:this.seekOffset})),el(tl(this,"icon"),this.seekOffset)}get mediaCurrentTime(){return ve(this,b.MEDIA_CURRENT_TIME,Ex)}set mediaCurrentTime(e){_e(this,b.MEDIA_CURRENT_TIME,e)}handleClick(){let e=Math.max(this.mediaCurrentTime-this.seekOffset,0),t=new A.CustomEvent(F.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}};A.customElements.get("media-seek-backward-button")||A.customElements.define("media-seek-backward-button",rm);var Tn={SEEK_OFFSET:"seekoffset"},Ed=30,bx=`<svg aria-hidden="true" viewBox="0 0 20 24"><defs><style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style></defs><text class="text value" transform="translate(8.9 19.87)">${Ed}</text><path d="M10 6V3l5.61 4L10 10.94V8a5.54 5.54 0 0 0-1.9 10.48v2.12A7.5 7.5 0 0 1 10 6Z"/></svg>`,Fb=O.createElement("template");Fb.innerHTML=`
1119
- <slot name="icon">${bx}</slot>
1120
- `;var yx=0,sm=class extends be{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_CURRENT_TIME,Tn.SEEK_OFFSET]}constructor(e={}){super({slotTemplate:Fb,...e})}connectedCallback(){this.seekOffset=ve(this,Tn.SEEK_OFFSET,Ed),super.connectedCallback()}attributeChangedCallback(e,t,r){e===Tn.SEEK_OFFSET&&(this.seekOffset=ve(this,Tn.SEEK_OFFSET,Ed)),super.attributeChangedCallback(e,t,r)}get seekOffset(){return ve(this,Tn.SEEK_OFFSET,Ed)}set seekOffset(e){_e(this,Tn.SEEK_OFFSET,e),this.setAttribute("aria-label",De.SEEK_FORWARD_N_SECS({seekOffset:this.seekOffset})),el(tl(this,"icon"),this.seekOffset)}get mediaCurrentTime(){return ve(this,b.MEDIA_CURRENT_TIME,yx)}set mediaCurrentTime(e){_e(this,b.MEDIA_CURRENT_TIME,e)}handleClick(){let e=this.mediaCurrentTime+this.seekOffset,t=new A.CustomEvent(F.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}};A.customElements.get("media-seek-forward-button")||A.customElements.define("media-seek-forward-button",sm);var Tx=Object.defineProperty,_x=(i,e,t)=>e in i?Tx(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Ax=(i,e,t)=>(_x(i,typeof e!="symbol"?e+"":e,t),t),Bb=O.createElement("template");Bb.innerHTML=Tt.template.innerHTML+`
1120
+ `;var Ex=0,lm=class extends be{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_CURRENT_TIME,_n.SEEK_OFFSET]}constructor(e={}){super({slotTemplate:$b,...e})}connectedCallback(){this.seekOffset=ve(this,_n.SEEK_OFFSET,Ed),super.connectedCallback()}attributeChangedCallback(e,t,r){e===_n.SEEK_OFFSET&&(this.seekOffset=ve(this,_n.SEEK_OFFSET,Ed)),super.attributeChangedCallback(e,t,r)}get seekOffset(){return ve(this,_n.SEEK_OFFSET,Ed)}set seekOffset(e){_e(this,_n.SEEK_OFFSET,e),this.setAttribute("aria-label",Me.SEEK_FORWARD_N_SECS({seekOffset:this.seekOffset})),el(tl(this,"icon"),this.seekOffset)}get mediaCurrentTime(){return ve(this,b.MEDIA_CURRENT_TIME,Ex)}set mediaCurrentTime(e){_e(this,b.MEDIA_CURRENT_TIME,e)}handleClick(){let e=this.mediaCurrentTime+this.seekOffset,t=new _.CustomEvent(B.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}};_.customElements.get("media-seek-forward-button")||_.customElements.define("media-seek-forward-button",lm);var bx=Object.defineProperty,yx=(i,e,t)=>e in i?bx(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Tx=(i,e,t)=>(yx(i,typeof e!="symbol"?e+"":e,t),t),Hb=O.createElement("template");Hb.innerHTML=Tt.template.innerHTML+`
1121
1121
  <style>
1122
1122
  :host {
1123
1123
  background: var(--media-settings-menu-background,
@@ -1144,13 +1144,13 @@ svg, img, ::slotted(svg), ::slotted(img) {
1144
1144
  --media-settings-menu-item-opacity: 0;
1145
1145
  }
1146
1146
  </style>
1147
- `;var bd=class extends Tt{get anchorElement(){return this.anchor!=="auto"?super.anchorElement:qe(this).querySelector("media-settings-menu-button")}};Ax(bd,"template",Bb);A.customElements.get("media-settings-menu")||A.customElements.define("media-settings-menu",bd);var $b=O.createElement("template");$b.innerHTML=`
1147
+ `;var bd=class extends Tt{get anchorElement(){return this.anchor!=="auto"?super.anchorElement:Ye(this).querySelector("media-settings-menu-button")}};Tx(bd,"template",Hb);_.customElements.get("media-settings-menu")||_.customElements.define("media-settings-menu",bd);var Gb=O.createElement("template");Gb.innerHTML=`
1148
1148
  <slot name="icon">
1149
1149
  <svg aria-hidden="true" viewBox="0 0 24 24">
1150
1150
  <path d="M4.5 14.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Zm7.5 0a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Zm7.5 0a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Z"/>
1151
1151
  </svg>
1152
1152
  </slot>
1153
- `;var nm=class extends $t{static get observedAttributes(){return[...super.observedAttributes,"target"]}constructor(){super({slotTemplate:$b})}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",Ce.SETTINGS())}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:qe(this).querySelector("media-settings-menu")}};A.customElements.get("media-settings-menu-button")||A.customElements.define("media-settings-menu-button",nm);var Sx=Object.defineProperty,xx=(i,e,t)=>e in i?Sx(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Lx=(i,e,t)=>(xx(i,typeof e!="symbol"?e+"":e,t),t),Hb,yd=O.createElement("template");yd.innerHTML=us.template.innerHTML+`
1153
+ `;var dm=class extends $t{static get observedAttributes(){return[...super.observedAttributes,"target"]}constructor(){super({slotTemplate:Gb})}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",De.SETTINGS())}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:Ye(this).querySelector("media-settings-menu")}};_.customElements.get("media-settings-menu-button")||_.customElements.define("media-settings-menu-button",dm);var _x=Object.defineProperty,Ax=(i,e,t)=>e in i?_x(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Sx=(i,e,t)=>(Ax(i,typeof e!="symbol"?e+"":e,t),t),Wb,yd=O.createElement("template");yd.innerHTML=cs.template.innerHTML+`
1154
1154
  <style>
1155
1155
  slot:not([name="submenu"]) {
1156
1156
  opacity: var(--media-settings-menu-item-opacity, var(--media-menu-item-opacity));
@@ -1160,11 +1160,11 @@ svg, img, ::slotted(svg), ::slotted(img) {
1160
1160
  background: transparent;
1161
1161
  }
1162
1162
  </style>
1163
- `;(Hb=yd.content)!=null&&Hb.querySelector&&(yd.content.querySelector('slot[name="suffix"]').innerHTML=`
1163
+ `;(Wb=yd.content)!=null&&Wb.querySelector&&(yd.content.querySelector('slot[name="suffix"]').innerHTML=`
1164
1164
  <svg aria-hidden="true" viewBox="0 0 20 24">
1165
1165
  <path d="m8.12 17.585-.742-.669 4.2-4.665-4.2-4.666.743-.669 4.803 5.335-4.803 5.334Z"/>
1166
1166
  </svg>
1167
- `);var Td=class extends us{};Lx(Td,"template",yd);A.customElements.get("media-settings-menu-item")||A.customElements.define("media-settings-menu-item",Td);var Kb=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},am=(i,e,t)=>(Kb(i,e,"read from private field"),t?t.call(i):e.get(i)),kx=(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)},Ix=(i,e,t,r)=>(Kb(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),_n,hi={REMAINING:"remaining",SHOW_DURATION:"showduration",NO_TOGGLE:"notoggle"},Gb=[...Object.values(hi),b.MEDIA_CURRENT_TIME,b.MEDIA_DURATION,b.MEDIA_SEEKABLE],Wb=["Enter"," "],Rx="&nbsp;/&nbsp;",Vb=(i,{timesSep:e=Rx}={})=>{var t,r;let s=i.hasAttribute(hi.REMAINING),n=i.hasAttribute(hi.SHOW_DURATION),a=(t=i.mediaCurrentTime)!=null?t:0,[,o]=(r=i.mediaSeekable)!=null?r:[],l=0;Number.isFinite(i.mediaDuration)?l=i.mediaDuration:Number.isFinite(o)&&(l=o);let d=s?Ai(0-(l-a)):Ai(a);return n?`${d}${e}${Ai(l)}`:d},wx="video not loaded, unknown time.",Cx=i=>{var e;let t=i.mediaCurrentTime,[,r]=(e=i.mediaSeekable)!=null?e:[],s=null;if(Number.isFinite(i.mediaDuration)?s=i.mediaDuration:Number.isFinite(r)&&(s=r),t==null||s===null){i.setAttribute("aria-valuetext",wx);return}let n=i.hasAttribute(hi.REMAINING),a=i.hasAttribute(hi.SHOW_DURATION),o=n?jr(0-(s-t)):jr(t);if(!a){i.setAttribute("aria-valuetext",o);return}let l=jr(s),d=`${o} of ${l}`;i.setAttribute("aria-valuetext",d)},om=class extends Oi{constructor(){super(),kx(this,_n,void 0),Ix(this,_n,this.shadowRoot.querySelector("slot")),am(this,_n).innerHTML=`${Vb(this)}`}static get observedAttributes(){return[...super.observedAttributes,...Gb,"disabled"]}connectedCallback(){let{style:e}=Te(this.shadowRoot,":host(:hover:not([notoggle]))");e.setProperty("cursor","pointer"),e.setProperty("background","var(--media-control-hover-background, rgba(50 50 70 / .7))"),this.hasAttribute("disabled")||this.enable(),this.setAttribute("role","progressbar"),this.setAttribute("aria-label",Ce.PLAYBACK_TIME());let t=r=>{let{key:s}=r;if(!Wb.includes(s)){this.removeEventListener("keyup",t);return}this.toggleTimeDisplay()};this.addEventListener("keydown",r=>{let{metaKey:s,altKey:n,key:a}=r;if(s||n||!Wb.includes(a)){this.removeEventListener("keyup",t);return}this.addEventListener("keyup",t)}),this.addEventListener("click",this.toggleTimeDisplay),super.connectedCallback()}toggleTimeDisplay(){this.noToggle||(this.hasAttribute("remaining")?this.removeAttribute("remaining"):this.setAttribute("remaining",""))}disconnectedCallback(){this.disable(),super.disconnectedCallback()}attributeChangedCallback(e,t,r){Gb.includes(e)?this.update():e==="disabled"&&r!==t&&(r==null?this.enable():this.disable()),super.attributeChangedCallback(e,t,r)}enable(){this.tabIndex=0}disable(){this.tabIndex=-1}get remaining(){return Le(this,hi.REMAINING)}set remaining(e){Ae(this,hi.REMAINING,e)}get showDuration(){return Le(this,hi.SHOW_DURATION)}set showDuration(e){Ae(this,hi.SHOW_DURATION,e)}get noToggle(){return Le(this,hi.NO_TOGGLE)}set noToggle(e){Ae(this,hi.NO_TOGGLE,e)}get mediaDuration(){return ve(this,b.MEDIA_DURATION)}set mediaDuration(e){_e(this,b.MEDIA_DURATION,e)}get mediaCurrentTime(){return ve(this,b.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){_e(this,b.MEDIA_CURRENT_TIME,e)}get mediaSeekable(){let e=this.getAttribute(b.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(b.MEDIA_SEEKABLE);return}this.setAttribute(b.MEDIA_SEEKABLE,e.join(":"))}update(){let e=Vb(this);Cx(this),e!==am(this,_n).innerHTML&&(am(this,_n).innerHTML=e)}};_n=new WeakMap;A.customElements.get("media-time-display")||A.customElements.define("media-time-display",om);var qb=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ot=(i,e,t)=>(qb(i,e,"read from private field"),t?t.call(i):e.get(i)),Bi=(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)=>(qb(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Dx=(i,e,t,r)=>({set _(s){Ht(i,e,s,t)},get _(){return ot(i,e,r)}}),An,_d,Sn,Oa,Ad,Sd,xd,xn,hs,Ld,kd=class{constructor(e,t,r){Bi(this,An,void 0),Bi(this,_d,void 0),Bi(this,Sn,void 0),Bi(this,Oa,void 0),Bi(this,Ad,void 0),Bi(this,Sd,void 0),Bi(this,xd,void 0),Bi(this,xn,void 0),Bi(this,hs,0),Bi(this,Ld,(s=performance.now())=>{Ht(this,hs,requestAnimationFrame(ot(this,Ld))),Ht(this,Oa,performance.now()-ot(this,Sn));let n=1e3/this.fps;if(ot(this,Oa)>n){Ht(this,Sn,s-ot(this,Oa)%n);let a=1e3/((s-ot(this,_d))/++Dx(this,Ad)._),o=(s-ot(this,Sd))/1e3/this.duration,l=ot(this,xd)+o*this.playbackRate;l-ot(this,An).valueAsNumber>0?Ht(this,xn,this.playbackRate/this.duration/a):(Ht(this,xn,.995*ot(this,xn)),l=ot(this,An).valueAsNumber+ot(this,xn)),this.callback(l)}}),Ht(this,An,e),this.callback=t,this.fps=r}start(){ot(this,hs)===0&&(Ht(this,Sn,performance.now()),Ht(this,_d,ot(this,Sn)),Ht(this,Ad,0),ot(this,Ld).call(this))}stop(){ot(this,hs)!==0&&(cancelAnimationFrame(ot(this,hs)),Ht(this,hs,0))}update({start:e,duration:t,playbackRate:r}){let s=e-ot(this,An).valueAsNumber,n=Math.abs(t-this.duration);(s>0||s<-.03||n>=.5)&&this.callback(e),Ht(this,xd,e),Ht(this,Sd,performance.now()),this.duration=t,this.playbackRate=r}};An=new WeakMap;_d=new WeakMap;Sn=new WeakMap;Oa=new WeakMap;Ad=new WeakMap;Sd=new WeakMap;xd=new WeakMap;xn=new WeakMap;hs=new WeakMap;Ld=new WeakMap;var hm=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},et=(i,e,t)=>(hm(i,e,"read from private field"),t?t.call(i):e.get(i)),lt=(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)},$i=(i,e,t,r)=>(hm(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),_t=(i,e,t)=>(hm(i,e,"access private method"),t),Ln,fs,wd,Ua,Cd,Rd,Fa,Ba,kn,In,Na,fm,Yb,lm,Dd,mm,Md,pm,Pd,gm,dm,zb,$a,Od,um,jb,Mx="video not loaded, unknown time.",Px=i=>{let e=i.range,t=jr(+Qb(i)),r=jr(+i.mediaSeekableEnd),s=t&&r?`${t} of ${r}`:Mx;e.setAttribute("aria-valuetext",s)},Xb=O.createElement("template");Xb.innerHTML=`
1167
+ `);var Td=class extends cs{};Sx(Td,"template",yd);_.customElements.get("media-settings-menu-item")||_.customElements.define("media-settings-menu-item",Td);var Yb=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},um=(i,e,t)=>(Yb(i,e,"read from private field"),t?t.call(i):e.get(i)),xx=(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)},Lx=(i,e,t,r)=>(Yb(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),An,hi={REMAINING:"remaining",SHOW_DURATION:"showduration",NO_TOGGLE:"notoggle"},Kb=[...Object.values(hi),b.MEDIA_CURRENT_TIME,b.MEDIA_DURATION,b.MEDIA_SEEKABLE],Vb=["Enter"," "],kx="&nbsp;/&nbsp;",qb=(i,{timesSep:e=kx}={})=>{var t,r;let s=i.hasAttribute(hi.REMAINING),n=i.hasAttribute(hi.SHOW_DURATION),a=(t=i.mediaCurrentTime)!=null?t:0,[,o]=(r=i.mediaSeekable)!=null?r:[],l=0;Number.isFinite(i.mediaDuration)?l=i.mediaDuration:Number.isFinite(o)&&(l=o);let d=s?Ai(0-(l-a)):Ai(a);return n?`${d}${e}${Ai(l)}`:d},Ix="video not loaded, unknown time.",Rx=i=>{var e;let t=i.mediaCurrentTime,[,r]=(e=i.mediaSeekable)!=null?e:[],s=null;if(Number.isFinite(i.mediaDuration)?s=i.mediaDuration:Number.isFinite(r)&&(s=r),t==null||s===null){i.setAttribute("aria-valuetext",Ix);return}let n=i.hasAttribute(hi.REMAINING),a=i.hasAttribute(hi.SHOW_DURATION),o=n?Xr(0-(s-t)):Xr(t);if(!a){i.setAttribute("aria-valuetext",o);return}let l=Xr(s),d=`${o} of ${l}`;i.setAttribute("aria-valuetext",d)},cm=class extends Oi{constructor(){super(),xx(this,An,void 0),Lx(this,An,this.shadowRoot.querySelector("slot")),um(this,An).innerHTML=`${qb(this)}`}static get observedAttributes(){return[...super.observedAttributes,...Kb,"disabled"]}connectedCallback(){let{style:e}=Te(this.shadowRoot,":host(:hover:not([notoggle]))");e.setProperty("cursor","pointer"),e.setProperty("background","var(--media-control-hover-background, rgba(50 50 70 / .7))"),this.hasAttribute("disabled")||this.enable(),this.setAttribute("role","progressbar"),this.setAttribute("aria-label",De.PLAYBACK_TIME());let t=r=>{let{key:s}=r;if(!Vb.includes(s)){this.removeEventListener("keyup",t);return}this.toggleTimeDisplay()};this.addEventListener("keydown",r=>{let{metaKey:s,altKey:n,key:a}=r;if(s||n||!Vb.includes(a)){this.removeEventListener("keyup",t);return}this.addEventListener("keyup",t)}),this.addEventListener("click",this.toggleTimeDisplay),super.connectedCallback()}toggleTimeDisplay(){this.noToggle||(this.hasAttribute("remaining")?this.removeAttribute("remaining"):this.setAttribute("remaining",""))}disconnectedCallback(){this.disable(),super.disconnectedCallback()}attributeChangedCallback(e,t,r){Kb.includes(e)?this.update():e==="disabled"&&r!==t&&(r==null?this.enable():this.disable()),super.attributeChangedCallback(e,t,r)}enable(){this.tabIndex=0}disable(){this.tabIndex=-1}get remaining(){return Le(this,hi.REMAINING)}set remaining(e){Ae(this,hi.REMAINING,e)}get showDuration(){return Le(this,hi.SHOW_DURATION)}set showDuration(e){Ae(this,hi.SHOW_DURATION,e)}get noToggle(){return Le(this,hi.NO_TOGGLE)}set noToggle(e){Ae(this,hi.NO_TOGGLE,e)}get mediaDuration(){return ve(this,b.MEDIA_DURATION)}set mediaDuration(e){_e(this,b.MEDIA_DURATION,e)}get mediaCurrentTime(){return ve(this,b.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){_e(this,b.MEDIA_CURRENT_TIME,e)}get mediaSeekable(){let e=this.getAttribute(b.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(b.MEDIA_SEEKABLE);return}this.setAttribute(b.MEDIA_SEEKABLE,e.join(":"))}update(){let e=qb(this);Rx(this),e!==um(this,An).innerHTML&&(um(this,An).innerHTML=e)}};An=new WeakMap;_.customElements.get("media-time-display")||_.customElements.define("media-time-display",cm);var zb=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},lt=(i,e,t)=>(zb(i,e,"read from private field"),t?t.call(i):e.get(i)),Bi=(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)=>(zb(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),wx=(i,e,t,r)=>({set _(s){Ht(i,e,s,t)},get _(){return lt(i,e,r)}}),Sn,_d,xn,Oa,Ad,Sd,xd,Ln,fs,Ld,kd=class{constructor(e,t,r){Bi(this,Sn,void 0),Bi(this,_d,void 0),Bi(this,xn,void 0),Bi(this,Oa,void 0),Bi(this,Ad,void 0),Bi(this,Sd,void 0),Bi(this,xd,void 0),Bi(this,Ln,void 0),Bi(this,fs,0),Bi(this,Ld,(s=performance.now())=>{Ht(this,fs,requestAnimationFrame(lt(this,Ld))),Ht(this,Oa,performance.now()-lt(this,xn));let n=1e3/this.fps;if(lt(this,Oa)>n){Ht(this,xn,s-lt(this,Oa)%n);let a=1e3/((s-lt(this,_d))/++wx(this,Ad)._),o=(s-lt(this,Sd))/1e3/this.duration,l=lt(this,xd)+o*this.playbackRate;l-lt(this,Sn).valueAsNumber>0?Ht(this,Ln,this.playbackRate/this.duration/a):(Ht(this,Ln,.995*lt(this,Ln)),l=lt(this,Sn).valueAsNumber+lt(this,Ln)),this.callback(l)}}),Ht(this,Sn,e),this.callback=t,this.fps=r}start(){lt(this,fs)===0&&(Ht(this,xn,performance.now()),Ht(this,_d,lt(this,xn)),Ht(this,Ad,0),lt(this,Ld).call(this))}stop(){lt(this,fs)!==0&&(cancelAnimationFrame(lt(this,fs)),Ht(this,fs,0))}update({start:e,duration:t,playbackRate:r}){let s=e-lt(this,Sn).valueAsNumber,n=Math.abs(t-this.duration);(s>0||s<-.03||n>=.5)&&this.callback(e),Ht(this,xd,e),Ht(this,Sd,performance.now()),this.duration=t,this.playbackRate=r}};Sn=new WeakMap;_d=new WeakMap;xn=new WeakMap;Oa=new WeakMap;Ad=new WeakMap;Sd=new WeakMap;xd=new WeakMap;Ln=new WeakMap;fs=new WeakMap;Ld=new WeakMap;var gm=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},et=(i,e,t)=>(gm(i,e,"read from private field"),t?t.call(i):e.get(i)),dt=(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)},$i=(i,e,t,r)=>(gm(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),_t=(i,e,t)=>(gm(i,e,"access private method"),t),kn,ms,wd,Ua,Cd,Rd,Fa,Ba,In,Rn,Na,vm,jb,hm,Dd,Em,Md,bm,Pd,ym,fm,Xb,$a,Od,mm,Qb,Cx="video not loaded, unknown time.",Dx=i=>{let e=i.range,t=Xr(+Jb(i)),r=Xr(+i.mediaSeekableEnd),s=t&&r?`${t} of ${r}`:Cx;e.setAttribute("aria-valuetext",s)},Zb=O.createElement("template");Zb.innerHTML=`
1168
1168
  <style>
1169
1169
  :host {
1170
1170
  --media-box-border-radius: 4px;
@@ -1375,10 +1375,10 @@ svg, img, ::slotted(svg), ::slotted(img) {
1375
1375
 
1376
1376
  </slot>
1377
1377
  </div>
1378
- `;var Id=(i,e=i.mediaCurrentTime)=>{let t=Number.isFinite(i.mediaSeekableStart)?i.mediaSeekableStart:0,r=Number.isFinite(i.mediaDuration)?i.mediaDuration:i.mediaSeekableEnd;if(Number.isNaN(r))return 0;let s=(e-t)/(r-t);return Math.max(0,Math.min(s,1))},Qb=(i,e=i.range.valueAsNumber)=>{let t=Number.isFinite(i.mediaSeekableStart)?i.mediaSeekableStart:0,r=Number.isFinite(i.mediaDuration)?i.mediaDuration:i.mediaSeekableEnd;return Number.isNaN(r)?0:e*(r-t)+t},cm=class extends cs{constructor(){super(),lt(this,In),lt(this,fm),lt(this,Dd),lt(this,Md),lt(this,Pd),lt(this,dm),lt(this,$a),lt(this,um),lt(this,Ln,void 0),lt(this,fs,void 0),lt(this,wd,void 0),lt(this,Ua,void 0),lt(this,Cd,void 0),lt(this,Rd,void 0),lt(this,Fa,void 0),lt(this,Ba,void 0),lt(this,kn,void 0),lt(this,lm,t=>{this.dragging||(this.range.valueAsNumber=t,this.updateBar())}),this.container.appendChild(Xb.content.cloneNode(!0)),$i(this,wd,this.shadowRoot.querySelectorAll('[part~="box"]')),$i(this,Cd,this.shadowRoot.querySelector('[part~="preview-box"]')),$i(this,Rd,this.shadowRoot.querySelector('[part~="current-box"]'));let e=getComputedStyle(this);$i(this,Fa,parseInt(e.getPropertyValue("--media-box-padding-left"))),$i(this,Ba,parseInt(e.getPropertyValue("--media-box-padding-right"))),$i(this,fs,new kd(this.range,et(this,lm),60))}static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_PAUSED,b.MEDIA_DURATION,b.MEDIA_SEEKABLE,b.MEDIA_CURRENT_TIME,b.MEDIA_PREVIEW_IMAGE,b.MEDIA_PREVIEW_TIME,b.MEDIA_PREVIEW_CHAPTER,b.MEDIA_BUFFERED,b.MEDIA_PLAYBACK_RATE,b.MEDIA_LOADING,b.MEDIA_ENDED]}connectedCallback(){var e;super.connectedCallback(),this.range.setAttribute("aria-label",Ce.SEEK()),_t(this,In,Na).call(this),$i(this,Ln,this.getRootNode()),(e=et(this,Ln))==null||e.addEventListener("transitionstart",this)}disconnectedCallback(){var e;super.disconnectedCallback(),_t(this,In,Na).call(this),(e=et(this,Ln))==null||e.removeEventListener("transitionstart",this),$i(this,Ln,null)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),t!=r&&(e===b.MEDIA_CURRENT_TIME||e===b.MEDIA_PAUSED||e===b.MEDIA_ENDED||e===b.MEDIA_LOADING||e===b.MEDIA_DURATION||e===b.MEDIA_SEEKABLE?(et(this,fs).update({start:Id(this),duration:this.mediaSeekableEnd-this.mediaSeekableStart,playbackRate:this.mediaPlaybackRate}),_t(this,In,Na).call(this),Px(this)):e===b.MEDIA_BUFFERED&&this.updateBufferedBar(),(e===b.MEDIA_DURATION||e===b.MEDIA_SEEKABLE)&&(this.mediaChaptersCues=et(this,kn),this.updateBar()))}get mediaChaptersCues(){return et(this,kn)}set mediaChaptersCues(e){var t;$i(this,kn,e),this.updateSegments((t=et(this,kn))==null?void 0:t.map(r=>({start:Id(this,r.startTime),end:Id(this,r.endTime)})))}get mediaPaused(){return Le(this,b.MEDIA_PAUSED)}set mediaPaused(e){Ae(this,b.MEDIA_PAUSED,e)}get mediaLoading(){return Le(this,b.MEDIA_LOADING)}set mediaLoading(e){Ae(this,b.MEDIA_LOADING,e)}get mediaDuration(){return ve(this,b.MEDIA_DURATION)}set mediaDuration(e){_e(this,b.MEDIA_DURATION,e)}get mediaCurrentTime(){return ve(this,b.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){_e(this,b.MEDIA_CURRENT_TIME,e)}get mediaPlaybackRate(){return ve(this,b.MEDIA_PLAYBACK_RATE,1)}set mediaPlaybackRate(e){_e(this,b.MEDIA_PLAYBACK_RATE,e)}get mediaBuffered(){let e=this.getAttribute(b.MEDIA_BUFFERED);return e?e.split(" ").map(t=>t.split(":").map(r=>+r)):[]}set mediaBuffered(e){if(!e){this.removeAttribute(b.MEDIA_BUFFERED);return}let t=e.map(r=>r.join(":")).join(" ");this.setAttribute(b.MEDIA_BUFFERED,t)}get mediaSeekable(){let e=this.getAttribute(b.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(b.MEDIA_SEEKABLE);return}this.setAttribute(b.MEDIA_SEEKABLE,e.join(":"))}get mediaSeekableEnd(){var e;let[,t=this.mediaDuration]=(e=this.mediaSeekable)!=null?e:[];return t}get mediaSeekableStart(){var e;let[t=0]=(e=this.mediaSeekable)!=null?e:[];return t}get mediaPreviewImage(){return ue(this,b.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){le(this,b.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewTime(){return ve(this,b.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){_e(this,b.MEDIA_PREVIEW_TIME,e)}get mediaEnded(){return Le(this,b.MEDIA_ENDED)}set mediaEnded(e){Ae(this,b.MEDIA_ENDED,e)}updateBar(){super.updateBar(),this.updateBufferedBar(),this.updateCurrentBox()}updateBufferedBar(){var e;let t=this.mediaBuffered;if(!t.length)return;let r;if(this.mediaEnded)r=1;else{let n=this.mediaCurrentTime,[,a=this.mediaSeekableStart]=(e=t.find(([o,l])=>o<=n&&n<=l))!=null?e:[];r=Id(this,a)}let{style:s}=Te(this.shadowRoot,"#highlight");s.setProperty("width",`${r*100}%`)}updateCurrentBox(){if(!this.shadowRoot.querySelector('slot[name="current"]').assignedElements().length)return;let t=Te(this.shadowRoot,"#current-rail"),r=Te(this.shadowRoot,'[part~="current-box"]'),s=_t(this,Dd,mm).call(this,et(this,Rd)),n=_t(this,Md,pm).call(this,s,this.range.valueAsNumber),a=_t(this,Pd,gm).call(this,s,this.range.valueAsNumber);t.style.transform=`translateX(${n})`,t.style.setProperty("--_range-width",`${s.range.width}`),r.style.setProperty("--_box-shift",`${a}`),r.style.setProperty("--_box-width",`${s.box.width}px`),r.style.setProperty("visibility","initial")}handleEvent(e){switch(super.handleEvent(e),e.type){case"input":_t(this,um,jb).call(this);break;case"pointermove":_t(this,dm,zb).call(this,e);break;case"pointerup":case"pointerleave":_t(this,$a,Od).call(this,null);break;case"transitionstart":yt(e.target,this)&&setTimeout(()=>_t(this,In,Na).call(this),0);break}}};Ln=new WeakMap;fs=new WeakMap;wd=new WeakMap;Ua=new WeakMap;Cd=new WeakMap;Rd=new WeakMap;Fa=new WeakMap;Ba=new WeakMap;kn=new WeakMap;In=new WeakSet;Na=function(){_t(this,fm,Yb).call(this)?et(this,fs).start():et(this,fs).stop()};fm=new WeakSet;Yb=function(){return this.isConnected&&!this.mediaPaused&&!this.mediaLoading&&!this.mediaEnded&&this.mediaSeekableEnd>0&&Cv(this)};lm=new WeakMap;Dd=new WeakSet;mm=function(i){var e;let r=((e=this.getAttribute("bounds")?ai(this,`#${this.getAttribute("bounds")}`):this.parentElement)!=null?e:this).getBoundingClientRect(),s=this.range.getBoundingClientRect(),n=i.offsetWidth,a=-(s.left-r.left-n/2),o=r.right-s.left-n/2;return{box:{width:n,min:a,max:o},bounds:r,range:s}};Md=new WeakSet;pm=function(i,e){let t=`${e*100}%`,{width:r,min:s,max:n}=i.box;if(!r)return t;if(Number.isNaN(s)||(t=`max(${`calc(1 / var(--_range-width) * 100 * ${s}% + var(--media-box-padding-left))`}, ${t})`),!Number.isNaN(n)){let o=`calc(1 / var(--_range-width) * 100 * ${n}% - var(--media-box-padding-right))`;t=`min(${t}, ${o})`}return t};Pd=new WeakSet;gm=function(i,e){let{width:t,min:r,max:s}=i.box,n=e*i.range.width;if(n<r+et(this,Fa)){let a=i.range.left-i.bounds.left-et(this,Fa);return`${n-t/2+a}px`}if(n>s-et(this,Ba)){let a=i.bounds.right-i.range.right-et(this,Ba);return`${n+t/2-a-i.range.width}px`}return 0};dm=new WeakSet;zb=function(i){let e=[...et(this,wd)].some(u=>i.composedPath().includes(u));if(!this.dragging&&(e||!i.composedPath().includes(this))){_t(this,$a,Od).call(this,null);return}let t=this.mediaSeekableEnd;if(!t)return;let r=Te(this.shadowRoot,"#preview-rail"),s=Te(this.shadowRoot,'[part~="preview-box"]'),n=_t(this,Dd,mm).call(this,et(this,Cd)),a=(i.clientX-n.range.left)/n.range.width;a=Math.max(0,Math.min(1,a));let o=_t(this,Md,pm).call(this,n,a),l=_t(this,Pd,gm).call(this,n,a);r.style.transform=`translateX(${o})`,r.style.setProperty("--_range-width",`${n.range.width}`),s.style.setProperty("--_box-shift",`${l}`),s.style.setProperty("--_box-width",`${n.box.width}px`);let d=Math.round(et(this,Ua))-Math.round(a*t);Math.abs(d)<1&&a>.01&&a<.99||($i(this,Ua,a*t),_t(this,$a,Od).call(this,et(this,Ua)))};$a=new WeakSet;Od=function(i){this.dispatchEvent(new A.CustomEvent(F.MEDIA_PREVIEW_REQUEST,{composed:!0,bubbles:!0,detail:i}))};um=new WeakSet;jb=function(){et(this,fs).stop();let i=Qb(this);this.dispatchEvent(new A.CustomEvent(F.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:i}))};A.customElements.get("media-time-range")||A.customElements.define("media-time-range",cm);var Ox=1,Nx=i=>i.mediaMuted?0:i.mediaVolume,Ux=({value:i})=>`${Math.round(i*100)}%`,vm=class extends cs{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_VOLUME,b.MEDIA_MUTED,b.MEDIA_VOLUME_UNAVAILABLE]}constructor(){super(),this.range.addEventListener("input",()=>{let e=this.range.value,t=new A.CustomEvent(F.MEDIA_VOLUME_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)})}connectedCallback(){super.connectedCallback(),this.range.setAttribute("aria-label",Ce.VOLUME())}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),(e===b.MEDIA_VOLUME||e===b.MEDIA_MUTED)&&(this.range.valueAsNumber=Nx(this),this.range.setAttribute("aria-valuetext",Ux(this.range)),this.updateBar())}get mediaVolume(){return ve(this,b.MEDIA_VOLUME,Ox)}set mediaVolume(e){_e(this,b.MEDIA_VOLUME,e)}get mediaMuted(){return Le(this,b.MEDIA_MUTED)}set mediaMuted(e){Ae(this,b.MEDIA_MUTED,e)}get mediaVolumeUnavailable(){return ue(this,b.MEDIA_VOLUME_UNAVAILABLE)}set mediaVolumeUnavailable(e){le(this,b.MEDIA_VOLUME_UNAVAILABLE,e)}};A.customElements.get("media-volume-range")||A.customElements.define("media-volume-range",vm);var Am=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},gt=(i,e,t)=>(Am(i,e,"read from private field"),t?t.call(i):e.get(i)),Gt=(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)},mi=(i,e,t,r)=>(Am(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),fi=(i,e,t)=>(Am(i,e,"access private method"),t),Hi,Ir,wn,Ha,Nd,Ud,Em,Rn,bm,Fd,ym,Ga,Bd,$d,Tm,_m,Zb,Sm,Jb,Fx=`
1378
+ `;var Id=(i,e=i.mediaCurrentTime)=>{let t=Number.isFinite(i.mediaSeekableStart)?i.mediaSeekableStart:0,r=Number.isFinite(i.mediaDuration)?i.mediaDuration:i.mediaSeekableEnd;if(Number.isNaN(r))return 0;let s=(e-t)/(r-t);return Math.max(0,Math.min(s,1))},Jb=(i,e=i.range.valueAsNumber)=>{let t=Number.isFinite(i.mediaSeekableStart)?i.mediaSeekableStart:0,r=Number.isFinite(i.mediaDuration)?i.mediaDuration:i.mediaSeekableEnd;return Number.isNaN(r)?0:e*(r-t)+t},pm=class extends hs{constructor(){super(),dt(this,Rn),dt(this,vm),dt(this,Dd),dt(this,Md),dt(this,Pd),dt(this,fm),dt(this,$a),dt(this,mm),dt(this,kn,void 0),dt(this,ms,void 0),dt(this,wd,void 0),dt(this,Ua,void 0),dt(this,Cd,void 0),dt(this,Rd,void 0),dt(this,Fa,void 0),dt(this,Ba,void 0),dt(this,In,void 0),dt(this,hm,t=>{this.dragging||(this.range.valueAsNumber=t,this.updateBar())}),this.container.appendChild(Zb.content.cloneNode(!0)),$i(this,wd,this.shadowRoot.querySelectorAll('[part~="box"]')),$i(this,Cd,this.shadowRoot.querySelector('[part~="preview-box"]')),$i(this,Rd,this.shadowRoot.querySelector('[part~="current-box"]'));let e=getComputedStyle(this);$i(this,Fa,parseInt(e.getPropertyValue("--media-box-padding-left"))),$i(this,Ba,parseInt(e.getPropertyValue("--media-box-padding-right"))),$i(this,ms,new kd(this.range,et(this,hm),60))}static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_PAUSED,b.MEDIA_DURATION,b.MEDIA_SEEKABLE,b.MEDIA_CURRENT_TIME,b.MEDIA_PREVIEW_IMAGE,b.MEDIA_PREVIEW_TIME,b.MEDIA_PREVIEW_CHAPTER,b.MEDIA_BUFFERED,b.MEDIA_PLAYBACK_RATE,b.MEDIA_LOADING,b.MEDIA_ENDED]}connectedCallback(){var e;super.connectedCallback(),this.range.setAttribute("aria-label",De.SEEK()),_t(this,Rn,Na).call(this),$i(this,kn,this.getRootNode()),(e=et(this,kn))==null||e.addEventListener("transitionstart",this)}disconnectedCallback(){var e;super.disconnectedCallback(),_t(this,Rn,Na).call(this),(e=et(this,kn))==null||e.removeEventListener("transitionstart",this),$i(this,kn,null)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),t!=r&&(e===b.MEDIA_CURRENT_TIME||e===b.MEDIA_PAUSED||e===b.MEDIA_ENDED||e===b.MEDIA_LOADING||e===b.MEDIA_DURATION||e===b.MEDIA_SEEKABLE?(et(this,ms).update({start:Id(this),duration:this.mediaSeekableEnd-this.mediaSeekableStart,playbackRate:this.mediaPlaybackRate}),_t(this,Rn,Na).call(this),Dx(this)):e===b.MEDIA_BUFFERED&&this.updateBufferedBar(),(e===b.MEDIA_DURATION||e===b.MEDIA_SEEKABLE)&&(this.mediaChaptersCues=et(this,In),this.updateBar()))}get mediaChaptersCues(){return et(this,In)}set mediaChaptersCues(e){var t;$i(this,In,e),this.updateSegments((t=et(this,In))==null?void 0:t.map(r=>({start:Id(this,r.startTime),end:Id(this,r.endTime)})))}get mediaPaused(){return Le(this,b.MEDIA_PAUSED)}set mediaPaused(e){Ae(this,b.MEDIA_PAUSED,e)}get mediaLoading(){return Le(this,b.MEDIA_LOADING)}set mediaLoading(e){Ae(this,b.MEDIA_LOADING,e)}get mediaDuration(){return ve(this,b.MEDIA_DURATION)}set mediaDuration(e){_e(this,b.MEDIA_DURATION,e)}get mediaCurrentTime(){return ve(this,b.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){_e(this,b.MEDIA_CURRENT_TIME,e)}get mediaPlaybackRate(){return ve(this,b.MEDIA_PLAYBACK_RATE,1)}set mediaPlaybackRate(e){_e(this,b.MEDIA_PLAYBACK_RATE,e)}get mediaBuffered(){let e=this.getAttribute(b.MEDIA_BUFFERED);return e?e.split(" ").map(t=>t.split(":").map(r=>+r)):[]}set mediaBuffered(e){if(!e){this.removeAttribute(b.MEDIA_BUFFERED);return}let t=e.map(r=>r.join(":")).join(" ");this.setAttribute(b.MEDIA_BUFFERED,t)}get mediaSeekable(){let e=this.getAttribute(b.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(b.MEDIA_SEEKABLE);return}this.setAttribute(b.MEDIA_SEEKABLE,e.join(":"))}get mediaSeekableEnd(){var e;let[,t=this.mediaDuration]=(e=this.mediaSeekable)!=null?e:[];return t}get mediaSeekableStart(){var e;let[t=0]=(e=this.mediaSeekable)!=null?e:[];return t}get mediaPreviewImage(){return ue(this,b.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){le(this,b.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewTime(){return ve(this,b.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){_e(this,b.MEDIA_PREVIEW_TIME,e)}get mediaEnded(){return Le(this,b.MEDIA_ENDED)}set mediaEnded(e){Ae(this,b.MEDIA_ENDED,e)}updateBar(){super.updateBar(),this.updateBufferedBar(),this.updateCurrentBox()}updateBufferedBar(){var e;let t=this.mediaBuffered;if(!t.length)return;let r;if(this.mediaEnded)r=1;else{let n=this.mediaCurrentTime,[,a=this.mediaSeekableStart]=(e=t.find(([o,l])=>o<=n&&n<=l))!=null?e:[];r=Id(this,a)}let{style:s}=Te(this.shadowRoot,"#highlight");s.setProperty("width",`${r*100}%`)}updateCurrentBox(){if(!this.shadowRoot.querySelector('slot[name="current"]').assignedElements().length)return;let t=Te(this.shadowRoot,"#current-rail"),r=Te(this.shadowRoot,'[part~="current-box"]'),s=_t(this,Dd,Em).call(this,et(this,Rd)),n=_t(this,Md,bm).call(this,s,this.range.valueAsNumber),a=_t(this,Pd,ym).call(this,s,this.range.valueAsNumber);t.style.transform=`translateX(${n})`,t.style.setProperty("--_range-width",`${s.range.width}`),r.style.setProperty("--_box-shift",`${a}`),r.style.setProperty("--_box-width",`${s.box.width}px`),r.style.setProperty("visibility","initial")}handleEvent(e){switch(super.handleEvent(e),e.type){case"input":_t(this,mm,Qb).call(this);break;case"pointermove":_t(this,fm,Xb).call(this,e);break;case"pointerup":case"pointerleave":_t(this,$a,Od).call(this,null);break;case"transitionstart":yt(e.target,this)&&setTimeout(()=>_t(this,Rn,Na).call(this),0);break}}};kn=new WeakMap;ms=new WeakMap;wd=new WeakMap;Ua=new WeakMap;Cd=new WeakMap;Rd=new WeakMap;Fa=new WeakMap;Ba=new WeakMap;In=new WeakMap;Rn=new WeakSet;Na=function(){_t(this,vm,jb).call(this)?et(this,ms).start():et(this,ms).stop()};vm=new WeakSet;jb=function(){return this.isConnected&&!this.mediaPaused&&!this.mediaLoading&&!this.mediaEnded&&this.mediaSeekableEnd>0&&Mv(this)};hm=new WeakMap;Dd=new WeakSet;Em=function(i){var e;let r=((e=this.getAttribute("bounds")?ai(this,`#${this.getAttribute("bounds")}`):this.parentElement)!=null?e:this).getBoundingClientRect(),s=this.range.getBoundingClientRect(),n=i.offsetWidth,a=-(s.left-r.left-n/2),o=r.right-s.left-n/2;return{box:{width:n,min:a,max:o},bounds:r,range:s}};Md=new WeakSet;bm=function(i,e){let t=`${e*100}%`,{width:r,min:s,max:n}=i.box;if(!r)return t;if(Number.isNaN(s)||(t=`max(${`calc(1 / var(--_range-width) * 100 * ${s}% + var(--media-box-padding-left))`}, ${t})`),!Number.isNaN(n)){let o=`calc(1 / var(--_range-width) * 100 * ${n}% - var(--media-box-padding-right))`;t=`min(${t}, ${o})`}return t};Pd=new WeakSet;ym=function(i,e){let{width:t,min:r,max:s}=i.box,n=e*i.range.width;if(n<r+et(this,Fa)){let a=i.range.left-i.bounds.left-et(this,Fa);return`${n-t/2+a}px`}if(n>s-et(this,Ba)){let a=i.bounds.right-i.range.right-et(this,Ba);return`${n+t/2-a-i.range.width}px`}return 0};fm=new WeakSet;Xb=function(i){let e=[...et(this,wd)].some(u=>i.composedPath().includes(u));if(!this.dragging&&(e||!i.composedPath().includes(this))){_t(this,$a,Od).call(this,null);return}let t=this.mediaSeekableEnd;if(!t)return;let r=Te(this.shadowRoot,"#preview-rail"),s=Te(this.shadowRoot,'[part~="preview-box"]'),n=_t(this,Dd,Em).call(this,et(this,Cd)),a=(i.clientX-n.range.left)/n.range.width;a=Math.max(0,Math.min(1,a));let o=_t(this,Md,bm).call(this,n,a),l=_t(this,Pd,ym).call(this,n,a);r.style.transform=`translateX(${o})`,r.style.setProperty("--_range-width",`${n.range.width}`),s.style.setProperty("--_box-shift",`${l}`),s.style.setProperty("--_box-width",`${n.box.width}px`);let d=Math.round(et(this,Ua))-Math.round(a*t);Math.abs(d)<1&&a>.01&&a<.99||($i(this,Ua,a*t),_t(this,$a,Od).call(this,et(this,Ua)))};$a=new WeakSet;Od=function(i){this.dispatchEvent(new _.CustomEvent(B.MEDIA_PREVIEW_REQUEST,{composed:!0,bubbles:!0,detail:i}))};mm=new WeakSet;Qb=function(){et(this,ms).stop();let i=Jb(this);this.dispatchEvent(new _.CustomEvent(B.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:i}))};_.customElements.get("media-time-range")||_.customElements.define("media-time-range",pm);var Mx=1,Px=i=>i.mediaMuted?0:i.mediaVolume,Ox=({value:i})=>`${Math.round(i*100)}%`,Tm=class extends hs{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_VOLUME,b.MEDIA_MUTED,b.MEDIA_VOLUME_UNAVAILABLE]}constructor(){super(),this.range.addEventListener("input",()=>{let e=this.range.value,t=new _.CustomEvent(B.MEDIA_VOLUME_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)})}connectedCallback(){super.connectedCallback(),this.range.setAttribute("aria-label",De.VOLUME())}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),(e===b.MEDIA_VOLUME||e===b.MEDIA_MUTED)&&(this.range.valueAsNumber=Px(this),this.range.setAttribute("aria-valuetext",Ox(this.range)),this.updateBar())}get mediaVolume(){return ve(this,b.MEDIA_VOLUME,Mx)}set mediaVolume(e){_e(this,b.MEDIA_VOLUME,e)}get mediaMuted(){return Le(this,b.MEDIA_MUTED)}set mediaMuted(e){Ae(this,b.MEDIA_MUTED,e)}get mediaVolumeUnavailable(){return ue(this,b.MEDIA_VOLUME_UNAVAILABLE)}set mediaVolumeUnavailable(e){le(this,b.MEDIA_VOLUME_UNAVAILABLE,e)}};_.customElements.get("media-volume-range")||_.customElements.define("media-volume-range",Tm);var km=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},gt=(i,e,t)=>(km(i,e,"read from private field"),t?t.call(i):e.get(i)),Gt=(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)},mi=(i,e,t,r)=>(km(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),fi=(i,e,t)=>(km(i,e,"access private method"),t),Hi,Ir,Cn,Ha,Nd,Ud,_m,wn,Am,Fd,Sm,Ga,Bd,$d,xm,Lm,ey,Im,ty,Nx=`
1379
1379
  <svg aria-hidden="true" viewBox="0 1 24 24" part="select-indicator indicator">
1380
1380
  <path d="m10 15.17 9.193-9.191 1.414 1.414-10.606 10.606-6.364-6.364 1.414-1.414 4.95 4.95Z"/>
1381
- </svg>`;function Gi(i,e,t){let r=O.createElement("media-chrome-option");r.part.add("option"),r.value=e,r.selected=t;let s=O.createElement("span");return s.textContent=i,r.append(s),r}function pi(i,e){let t=i.querySelector(`:scope > [slot="${e}"]`);return(t==null?void 0:t.nodeName)=="SLOT"&&(t=t.assignedElements({flatten:!0})[0]),t?(t=t.cloneNode(!0),t.removeAttribute("slot"),t):i.shadowRoot.querySelector(`[name="${e}"] > svg`).cloneNode(!0)}var ey=O.createElement("template");ey.innerHTML=`
1381
+ </svg>`;function Gi(i,e,t){let r=O.createElement("media-chrome-option");r.part.add("option"),r.value=e,r.selected=t;let s=O.createElement("span");return s.textContent=i,r.append(s),r}function pi(i,e){let t=i.querySelector(`:scope > [slot="${e}"]`);return(t==null?void 0:t.nodeName)=="SLOT"&&(t=t.assignedElements({flatten:!0})[0]),t?(t=t.cloneNode(!0),t.removeAttribute("slot"),t):i.shadowRoot.querySelector(`[name="${e}"] > svg`).cloneNode(!0)}var iy=O.createElement("template");iy.innerHTML=`
1382
1382
  <style>
1383
1383
  :host {
1384
1384
  font: var(--media-font,
@@ -1457,8 +1457,8 @@ svg, img, ::slotted(svg), ::slotted(img) {
1457
1457
  </style>
1458
1458
  <slot name="header"></slot>
1459
1459
  <slot id="container"></slot>
1460
- <slot name="select-indicator" hidden>${Fx}</slot>
1461
- `;var jt=class extends A.HTMLElement{constructor(e={}){super(),Gt(this,Ud),Gt(this,Fd),Gt(this,Ga),Gt(this,$d),Gt(this,_m),Gt(this,Sm),Gt(this,Hi,void 0),Gt(this,Ir,""),Gt(this,wn,null),Gt(this,Ha,!1),Gt(this,Nd,t=>{this.handleClick(t)}),Gt(this,Rn,t=>{let{key:r}=t;if(r==="Escape"){this.removeEventListener("keyup",gt(this,Rn));return}if(r==="Meta"){mi(this,Ha,!1);return}fi(this,Ud,Em).call(this,t)}),Gt(this,bm,t=>{let{key:r,altKey:s}=t;if(s){this.removeEventListener("keyup",gt(this,Rn));return}if(r==="Meta"){mi(this,Ha,!0);return}if(this.keysUsed.includes(r)&&t.preventDefault(),gt(this,Ha)&&this.keysUsed.includes(r)){fi(this,Ud,Em).call(this,t);return}this.addEventListener("keyup",gt(this,Rn),{once:!0})}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.nativeEl=ey.content.cloneNode(!0),e.slotTemplate&&this.nativeEl.append(e.slotTemplate.content.cloneNode(!0)),this.shadowRoot.append(this.nativeEl)),this.container=this.shadowRoot.querySelector("#container"),this.container.addEventListener("slotchange",t=>{for(let r of t.target.assignedNodes({flatten:!0}))r.nodeType===3&&r.textContent.trim()===""&&r.remove()})}static get observedAttributes(){return["disabled","style",ee.MEDIA_CONTROLLER]}static formatOptionText(e){return e}formatOptionText(e,t){return this.constructor.formatOptionText(e,t)}get options(){var e;let t=this.querySelectorAll("media-chrome-option");return t.length||(t=(e=this.container)==null?void 0:e.querySelectorAll("media-chrome-option")),Array.from(t)}get selectedOptions(){return this.options.filter(e=>e.selected)}get value(){var e,t;return(t=(e=this.selectedOptions[0])==null?void 0:e.value)!=null?t:""}set value(e){let t=this.options.find(r=>r.value===e);t&&fi(this,$d,Tm).call(this,t)}focus(){var e;(e=this.selectedOptions[0])==null||e.focus()}enable(){this.addEventListener("click",gt(this,Nd)),this.addEventListener("keydown",gt(this,bm))}disable(){this.removeEventListener("click",gt(this,Nd)),this.removeEventListener("keyup",gt(this,Rn))}attributeChangedCallback(e,t,r){var s,n,a,o,l;e==="style"&&r!==t?fi(this,Fd,ym).call(this):e===ee.MEDIA_CONTROLLER?(t&&((n=(s=gt(this,Hi))==null?void 0:s.unassociateElement)==null||n.call(s,this),mi(this,Hi,null)),r&&this.isConnected&&(mi(this,Hi,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=gt(this,Hi))==null?void 0:o.associateElement)==null||l.call(o,this))):e==="disabled"&&r!==t&&(r==null?this.enable():this.disable())}connectedCallback(){var e,t,r;fi(this,Fd,ym).call(this),this.hasAttribute("disabled")||this.enable(),this.hasAttribute("role")||this.setAttribute("role","listbox");let s=this.getAttribute(ee.MEDIA_CONTROLLER);s&&(mi(this,Hi,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=gt(this,Hi))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;this.disable(),(t=(e=gt(this,Hi))==null?void 0:e.unassociateElement)==null||t.call(e,this),mi(this,Hi,null)}get keysUsed(){return["Enter"," ","ArrowDown","ArrowUp","Home","End"]}handleSelection(e,t){let r=fi(this,Ga,Bd).call(this,e);r&&fi(this,$d,Tm).call(this,r,t)}handleMovement(e){let{key:t}=e,r=this.options,s=fi(this,Ga,Bd).call(this,e);s||(s=r.filter(a=>a.getAttribute("tabindex")==="0")[0]);let n;switch(t){case"ArrowDown":n=s.nextElementSibling,n!=null&&n.hasAttribute("disabled")&&(n=n.nextElementSibling);break;case"ArrowUp":n=s.previousElementSibling,n!=null&&n.hasAttribute("disabled")&&(n=n.previousElementSibling);break;case"Home":n=r[0];break;case"End":n=r[r.length-1];break;default:n=fi(this,_m,Zb).call(this,t);break}n&&(r.forEach(a=>a.setAttribute("tabindex","-1")),n.setAttribute("tabindex","0"),n.focus())}handleClick(e){let t=fi(this,Ga,Bd).call(this,e);!t||t.hasAttribute("disabled")||(this.options.forEach(r=>r.setAttribute("tabindex","-1")),t.setAttribute("tabindex","0"),this.handleSelection(e,this.hasAttribute("aria-multiselectable")&&this.getAttribute("aria-multiselectable")==="true"))}};Hi=new WeakMap;Ir=new WeakMap;wn=new WeakMap;Ha=new WeakMap;Nd=new WeakMap;Ud=new WeakSet;Em=function(i){let{key:e}=i;e==="Enter"||e===" "?this.handleSelection(i,this.hasAttribute("aria-multiselectable")&&this.getAttribute("aria-multiselectable")==="true"):this.handleMovement(i)};Rn=new WeakMap;bm=new WeakMap;Fd=new WeakSet;ym=function(){var i;let e=this.shadowRoot.querySelector("#layout-row"),t=((i=getComputedStyle(this).getPropertyValue("--media-listbox-layout"))==null?void 0:i.trim())==="row";e.setAttribute("media",t?"":"width:0")};Ga=new WeakSet;Bd=function(i){let e=i.composedPath(),t=e.findIndex(r=>r.nodeName==="MEDIA-CHROME-OPTION");return e[t]};$d=new WeakSet;Tm=function(i,e){let t=[...this.selectedOptions];(!this.hasAttribute("aria-multiselectable")||this.getAttribute("aria-multiselectable")!=="true")&&this.options.forEach(r=>r.selected=!1),e?i.selected=!i.selected:i.selected=!0,this.selectedOptions.some((r,s)=>r!=t[s])&&this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))};_m=new WeakSet;Zb=function(i){fi(this,Sm,Jb).call(this);let e=this.options,t=e.findIndex(d=>d.getAttribute("tabindex")==="0");mi(this,Ir,gt(this,Ir)+i);let r=gt(this,Ir).split("").every(d=>d===i),s=e.slice(t+(r?1:0)).filter(d=>d.textContent.toLowerCase().startsWith(gt(this,Ir))),n=e.slice(0,t-(r?1:0)).filter(d=>d.textContent.toLowerCase().startsWith(gt(this,Ir))),a=[],o=[];return r&&(a=e.slice(t+(r?1:0)).filter(d=>d.textContent.startsWith(i)),o=e.slice(0,t-(r?1:0)).filter(d=>d.textContent.startsWith(i))),[...s,...n,...a,...o][0]};Sm=new WeakSet;Jb=function(){clearTimeout(gt(this,wn)),mi(this,wn,null),mi(this,wn,setTimeout(()=>{mi(this,Ir,""),mi(this,wn,null)},500))};A.customElements.get("media-chrome-listbox")||A.customElements.define("media-chrome-listbox",jt);var wm=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},km=(i,e,t)=>(wm(i,e,"read from private field"),t?t.call(i):e.get(i)),xm=(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)},Lm=(i,e,t,r)=>(wm(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),ty=(i,e,t)=>(wm(i,e,"access private method"),t),Hd,Cn,Gd,Im,iy=O.createElement("template");iy.innerHTML=`
1460
+ <slot name="select-indicator" hidden>${Nx}</slot>
1461
+ `;var jt=class extends _.HTMLElement{constructor(e={}){super(),Gt(this,Ud),Gt(this,Fd),Gt(this,Ga),Gt(this,$d),Gt(this,Lm),Gt(this,Im),Gt(this,Hi,void 0),Gt(this,Ir,""),Gt(this,Cn,null),Gt(this,Ha,!1),Gt(this,Nd,t=>{this.handleClick(t)}),Gt(this,wn,t=>{let{key:r}=t;if(r==="Escape"){this.removeEventListener("keyup",gt(this,wn));return}if(r==="Meta"){mi(this,Ha,!1);return}fi(this,Ud,_m).call(this,t)}),Gt(this,Am,t=>{let{key:r,altKey:s}=t;if(s){this.removeEventListener("keyup",gt(this,wn));return}if(r==="Meta"){mi(this,Ha,!0);return}if(this.keysUsed.includes(r)&&t.preventDefault(),gt(this,Ha)&&this.keysUsed.includes(r)){fi(this,Ud,_m).call(this,t);return}this.addEventListener("keyup",gt(this,wn),{once:!0})}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.nativeEl=iy.content.cloneNode(!0),e.slotTemplate&&this.nativeEl.append(e.slotTemplate.content.cloneNode(!0)),this.shadowRoot.append(this.nativeEl)),this.container=this.shadowRoot.querySelector("#container"),this.container.addEventListener("slotchange",t=>{for(let r of t.target.assignedNodes({flatten:!0}))r.nodeType===3&&r.textContent.trim()===""&&r.remove()})}static get observedAttributes(){return["disabled","style",te.MEDIA_CONTROLLER]}static formatOptionText(e){return e}formatOptionText(e,t){return this.constructor.formatOptionText(e,t)}get options(){var e;let t=this.querySelectorAll("media-chrome-option");return t.length||(t=(e=this.container)==null?void 0:e.querySelectorAll("media-chrome-option")),Array.from(t)}get selectedOptions(){return this.options.filter(e=>e.selected)}get value(){var e,t;return(t=(e=this.selectedOptions[0])==null?void 0:e.value)!=null?t:""}set value(e){let t=this.options.find(r=>r.value===e);t&&fi(this,$d,xm).call(this,t)}focus(){var e;(e=this.selectedOptions[0])==null||e.focus()}enable(){this.addEventListener("click",gt(this,Nd)),this.addEventListener("keydown",gt(this,Am))}disable(){this.removeEventListener("click",gt(this,Nd)),this.removeEventListener("keyup",gt(this,wn))}attributeChangedCallback(e,t,r){var s,n,a,o,l;e==="style"&&r!==t?fi(this,Fd,Sm).call(this):e===te.MEDIA_CONTROLLER?(t&&((n=(s=gt(this,Hi))==null?void 0:s.unassociateElement)==null||n.call(s,this),mi(this,Hi,null)),r&&this.isConnected&&(mi(this,Hi,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=gt(this,Hi))==null?void 0:o.associateElement)==null||l.call(o,this))):e==="disabled"&&r!==t&&(r==null?this.enable():this.disable())}connectedCallback(){var e,t,r;fi(this,Fd,Sm).call(this),this.hasAttribute("disabled")||this.enable(),this.hasAttribute("role")||this.setAttribute("role","listbox");let s=this.getAttribute(te.MEDIA_CONTROLLER);s&&(mi(this,Hi,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=gt(this,Hi))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;this.disable(),(t=(e=gt(this,Hi))==null?void 0:e.unassociateElement)==null||t.call(e,this),mi(this,Hi,null)}get keysUsed(){return["Enter"," ","ArrowDown","ArrowUp","Home","End"]}handleSelection(e,t){let r=fi(this,Ga,Bd).call(this,e);r&&fi(this,$d,xm).call(this,r,t)}handleMovement(e){let{key:t}=e,r=this.options,s=fi(this,Ga,Bd).call(this,e);s||(s=r.filter(a=>a.getAttribute("tabindex")==="0")[0]);let n;switch(t){case"ArrowDown":n=s.nextElementSibling,n!=null&&n.hasAttribute("disabled")&&(n=n.nextElementSibling);break;case"ArrowUp":n=s.previousElementSibling,n!=null&&n.hasAttribute("disabled")&&(n=n.previousElementSibling);break;case"Home":n=r[0];break;case"End":n=r[r.length-1];break;default:n=fi(this,Lm,ey).call(this,t);break}n&&(r.forEach(a=>a.setAttribute("tabindex","-1")),n.setAttribute("tabindex","0"),n.focus())}handleClick(e){let t=fi(this,Ga,Bd).call(this,e);!t||t.hasAttribute("disabled")||(this.options.forEach(r=>r.setAttribute("tabindex","-1")),t.setAttribute("tabindex","0"),this.handleSelection(e,this.hasAttribute("aria-multiselectable")&&this.getAttribute("aria-multiselectable")==="true"))}};Hi=new WeakMap;Ir=new WeakMap;Cn=new WeakMap;Ha=new WeakMap;Nd=new WeakMap;Ud=new WeakSet;_m=function(i){let{key:e}=i;e==="Enter"||e===" "?this.handleSelection(i,this.hasAttribute("aria-multiselectable")&&this.getAttribute("aria-multiselectable")==="true"):this.handleMovement(i)};wn=new WeakMap;Am=new WeakMap;Fd=new WeakSet;Sm=function(){var i;let e=this.shadowRoot.querySelector("#layout-row"),t=((i=getComputedStyle(this).getPropertyValue("--media-listbox-layout"))==null?void 0:i.trim())==="row";e.setAttribute("media",t?"":"width:0")};Ga=new WeakSet;Bd=function(i){let e=i.composedPath(),t=e.findIndex(r=>r.nodeName==="MEDIA-CHROME-OPTION");return e[t]};$d=new WeakSet;xm=function(i,e){let t=[...this.selectedOptions];(!this.hasAttribute("aria-multiselectable")||this.getAttribute("aria-multiselectable")!=="true")&&this.options.forEach(r=>r.selected=!1),e?i.selected=!i.selected:i.selected=!0,this.selectedOptions.some((r,s)=>r!=t[s])&&this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))};Lm=new WeakSet;ey=function(i){fi(this,Im,ty).call(this);let e=this.options,t=e.findIndex(d=>d.getAttribute("tabindex")==="0");mi(this,Ir,gt(this,Ir)+i);let r=gt(this,Ir).split("").every(d=>d===i),s=e.slice(t+(r?1:0)).filter(d=>d.textContent.toLowerCase().startsWith(gt(this,Ir))),n=e.slice(0,t-(r?1:0)).filter(d=>d.textContent.toLowerCase().startsWith(gt(this,Ir))),a=[],o=[];return r&&(a=e.slice(t+(r?1:0)).filter(d=>d.textContent.startsWith(i)),o=e.slice(0,t-(r?1:0)).filter(d=>d.textContent.startsWith(i))),[...s,...n,...a,...o][0]};Im=new WeakSet;ty=function(){clearTimeout(gt(this,Cn)),mi(this,Cn,null),mi(this,Cn,setTimeout(()=>{mi(this,Ir,""),mi(this,Cn,null)},500))};_.customElements.get("media-chrome-listbox")||_.customElements.define("media-chrome-listbox",jt);var Pm=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Cm=(i,e,t)=>(Pm(i,e,"read from private field"),t?t.call(i):e.get(i)),Rm=(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)},wm=(i,e,t,r)=>(Pm(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),ry=(i,e,t)=>(Pm(i,e,"access private method"),t),Hd,Dn,Gd,Dm,sy=O.createElement("template");sy.innerHTML=`
1462
1462
  <style>
1463
1463
  :host {
1464
1464
  cursor: pointer;
@@ -1496,7 +1496,7 @@ svg, img, ::slotted(svg), ::slotted(img) {
1496
1496
  }
1497
1497
  </style>
1498
1498
  <slot></slot>
1499
- `;var Rr={VALUE:"value",SELECTED:"selected",DISABLED:"disabled"},Wd=class extends A.HTMLElement{constructor(){super(),xm(this,Gd),xm(this,Hd,!1),xm(this,Cn,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(iy.content.cloneNode(!0)))}static get observedAttributes(){return[Rr.DISABLED,Rr.SELECTED,Rr.VALUE]}get value(){var e;return(e=this.getAttribute(Rr.VALUE))!=null?e:this.text}set value(e){this.setAttribute(Rr.VALUE,e)}get text(){var e;return((e=this.textContent)!=null?e:"").trim()}get selected(){return this.getAttribute("aria-selected")==="true"}set selected(e){Lm(this,Hd,!0),this.setAttribute("aria-selected",e?"true":"false"),e?this.part.add("option-selected"):this.part.remove("option-selected")}enable(){this.hasAttribute("tabindex")||this.setAttribute("tabindex",-1),this.hasAttribute("aria-selected")||this.setAttribute("aria-selected","false")}disable(){this.removeAttribute("tabindex")}attributeChangedCallback(e,t,r){e===Rr.SELECTED&&!km(this,Hd)?this.setAttribute("aria-selected",r!=null?"true":"false"):e===Rr.DISABLED&&r!==t&&(r==null?this.enable():this.disable())}connectedCallback(){this.hasAttribute(Rr.DISABLED)||this.enable(),this.setAttribute("role","option"),Lm(this,Cn,Rm(this,this.parentNode)),ty(this,Gd,Im).call(this)}disconnectedCallback(){this.disable(),ty(this,Gd,Im).call(this),Lm(this,Cn,null)}handleClick(){}};Hd=new WeakMap;Cn=new WeakMap;Gd=new WeakSet;Im=function(){var i;let e=(i=km(this,Cn))==null?void 0:i.options;if(!e)return;let t=e.filter(r=>r.getAttribute("aria-selected")==="true").pop();t||(t=e[0]),km(this,Cn).getAttribute("aria-multiselectable")!=="true"&&e.forEach(r=>{r.setAttribute("tabindex","-1"),r.setAttribute("aria-selected","false")}),t==null||t.setAttribute("tabindex","0"),t==null||t.setAttribute("aria-selected","true")};function Rm(i,e){if(!i)return null;let{host:t}=i.getRootNode();return!e&&t?Rm(i,t):e!=null&&e.options?e:Rm(e,e==null?void 0:e.parentNode)}A.customElements.get("media-chrome-option")||A.customElements.define("media-chrome-option",Wd);var Dm=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Y=(i,e,t)=>(Dm(i,e,"read from private field"),t?t.call(i):e.get(i)),Ct=(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)},Wi=(i,e,t,r)=>(Dm(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),ms=(i,e,t)=>(Dm(i,e,"access private method"),t),Vi,At,Wa,Ye,gi,Dn,Vd,Kd,qd,Yd,zd,Cm,Mm,ry,Mn,Va,ps,sy=O.createElement("template");sy.innerHTML=`
1499
+ `;var Rr={VALUE:"value",SELECTED:"selected",DISABLED:"disabled"},Wd=class extends _.HTMLElement{constructor(){super(),Rm(this,Gd),Rm(this,Hd,!1),Rm(this,Dn,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(sy.content.cloneNode(!0)))}static get observedAttributes(){return[Rr.DISABLED,Rr.SELECTED,Rr.VALUE]}get value(){var e;return(e=this.getAttribute(Rr.VALUE))!=null?e:this.text}set value(e){this.setAttribute(Rr.VALUE,e)}get text(){var e;return((e=this.textContent)!=null?e:"").trim()}get selected(){return this.getAttribute("aria-selected")==="true"}set selected(e){wm(this,Hd,!0),this.setAttribute("aria-selected",e?"true":"false"),e?this.part.add("option-selected"):this.part.remove("option-selected")}enable(){this.hasAttribute("tabindex")||this.setAttribute("tabindex",-1),this.hasAttribute("aria-selected")||this.setAttribute("aria-selected","false")}disable(){this.removeAttribute("tabindex")}attributeChangedCallback(e,t,r){e===Rr.SELECTED&&!Cm(this,Hd)?this.setAttribute("aria-selected",r!=null?"true":"false"):e===Rr.DISABLED&&r!==t&&(r==null?this.enable():this.disable())}connectedCallback(){this.hasAttribute(Rr.DISABLED)||this.enable(),this.setAttribute("role","option"),wm(this,Dn,Mm(this,this.parentNode)),ry(this,Gd,Dm).call(this)}disconnectedCallback(){this.disable(),ry(this,Gd,Dm).call(this),wm(this,Dn,null)}handleClick(){}};Hd=new WeakMap;Dn=new WeakMap;Gd=new WeakSet;Dm=function(){var i;let e=(i=Cm(this,Dn))==null?void 0:i.options;if(!e)return;let t=e.filter(r=>r.getAttribute("aria-selected")==="true").pop();t||(t=e[0]),Cm(this,Dn).getAttribute("aria-multiselectable")!=="true"&&e.forEach(r=>{r.setAttribute("tabindex","-1"),r.setAttribute("aria-selected","false")}),t==null||t.setAttribute("tabindex","0"),t==null||t.setAttribute("aria-selected","true")};function Mm(i,e){if(!i)return null;let{host:t}=i.getRootNode();return!e&&t?Mm(i,t):e!=null&&e.options?e:Mm(e,e==null?void 0:e.parentNode)}_.customElements.get("media-chrome-option")||_.customElements.define("media-chrome-option",Wd);var Nm=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Y=(i,e,t)=>(Nm(i,e,"read from private field"),t?t.call(i):e.get(i)),Ct=(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)},Wi=(i,e,t,r)=>(Nm(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),ps=(i,e,t)=>(Nm(i,e,"access private method"),t),Ki,At,Wa,ze,gi,Mn,Kd,Vd,qd,Yd,zd,Om,Um,ny,Pn,Ka,gs,ay=O.createElement("template");ay.innerHTML=`
1500
1500
  <style>
1501
1501
  :host {
1502
1502
  font: var(--media-font,
@@ -1547,23 +1547,23 @@ svg, img, ::slotted(svg), ::slotted(img) {
1547
1547
  <slot></slot>
1548
1548
  </media-chrome-listbox>
1549
1549
  </slot>
1550
- `;var Xt=class extends A.HTMLElement{constructor(){var e;super(),Ct(this,zd),Ct(this,Mm),Ct(this,Mn),Ct(this,Vi,void 0),Ct(this,At,void 0),Ct(this,Wa,void 0),Ct(this,Ye,void 0),Ct(this,gi,void 0),Ct(this,Dn,t=>{let{key:r}=t;if(!this.keysUsed.includes(r)){this.removeEventListener("keyup",Y(this,Dn));return}t.composedPath().includes(Y(this,At))&&(r==="Enter"||r===" ")?ms(this,zd,Cm).call(this):r==="Escape"&&ms(this,Mn,Va).call(this)}),Ct(this,Vd,t=>{let{metaKey:r,altKey:s,key:n}=t;if(r||s||!this.keysUsed.includes(n)){this.removeEventListener("keyup",Y(this,Dn));return}t.preventDefault(),this.addEventListener("keyup",Y(this,Dn),{once:!0})}),Ct(this,Kd,t=>{t.composedPath().includes(this)||ms(this,Mn,Va).call(this)}),Ct(this,qd,t=>{t.composedPath().includes(Y(this,At))&&ms(this,zd,Cm).call(this)}),Ct(this,Yd,()=>{ms(this,Mn,Va).call(this)}),Ct(this,ps,()=>{if(Y(this,Ye).offsetWidth===0)return;let t=Y(this,Ye).offsetWidth,r=Y(this,At).getBoundingClientRect();if(this.hasAttribute("mediacontroller")||Y(this,At).hasAttribute("mediacontroller")||Y(this,Ye).hasAttribute("mediacontroller")){Y(this,Ye).style.zIndex="1",Y(this,Ye).style.bottom="unset",Y(this,Ye).style.right=null,Y(this,Ye).style.left="0",Y(this,Ye).style.top=`${r.height}px`;return}let n=Ka(this).getBoundingClientRect(),a=r.x+t,o=Math.max(r.right-a,r.right-n.right);Y(this,Ye).style.left=null,Y(this,Ye).style.right=`${o}px`,Y(this,Ye).style.maxHeight=`${n.height-r.height}px`}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(sy.content.cloneNode(!0))),(e=this.init)==null||e.call(this),Wi(this,At,this.shadowRoot.querySelector("[part=button]")),Wi(this,Ye,this.shadowRoot.querySelector("[part=listbox]")),Wi(this,Wa,this.shadowRoot.querySelector("slot[name=button]")),Y(this,Wa).addEventListener("slotchange",()=>{let t=Y(this,Wa).assignedElements()[0];if(!t)return;Wi(this,At,t),Y(this,At).preventClick=!0,this.hasAttribute("disabled")||Y(this,At).hasAttribute("disabled")?this.disable():(this.enable(),Y(this,At).setAttribute("aria-haspopup","listbox"))}),Wi(this,gi,this.shadowRoot.querySelector("slot[name=listbox]")),Y(this,gi).addEventListener("slotchange",()=>{Wi(this,Ye,Y(this,gi).assignedElements()[0]||Y(this,Ye))})}static get observedAttributes(){return["disabled",ee.MEDIA_CONTROLLER]}enable(){Y(this,At).toggleAttribute("disabled",!1),this.addEventListener("change",Y(this,Yd)),this.addEventListener("keydown",Y(this,Vd)),this.addEventListener("click",Y(this,qd)),O.addEventListener("click",Y(this,Kd))}disable(){Y(this,At).toggleAttribute("disabled",!0),this.removeEventListener("change",Y(this,Yd)),this.removeEventListener("keydown",Y(this,Vd)),this.removeEventListener("keyup",Y(this,Dn)),this.removeEventListener("click",Y(this,qd)),O.removeEventListener("click",Y(this,Kd))}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===ee.MEDIA_CONTROLLER?(t&&((n=(s=Y(this,Vi))==null?void 0:s.unassociateElement)==null||n.call(s,this),Wi(this,Vi,null),Y(this,Ye).removeAttribute(ee.MEDIA_CONTROLLER)),r&&this.isConnected&&(Wi(this,Vi,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=Y(this,Vi))==null?void 0:o.associateElement)==null||l.call(o,this),Y(this,Ye).setAttribute(ee.MEDIA_CONTROLLER,r))):e==="disabled"&&r!==t&&(r==null?this.enable():this.disable())}connectedCallback(){var e,t,r;let{style:s}=Te(this.shadowRoot,":host");s.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`);let n=this.getAttribute(ee.MEDIA_CONTROLLER);n&&(Wi(this,Vi,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(r=(t=Y(this,Vi))==null?void 0:t.associateElement)==null||r.call(t,this),Y(this,Ye).setAttribute(ee.MEDIA_CONTROLLER,n)),this.hasAttribute("disabled")||this.enable(),Y(this,gi).hidden||Kt(Ka(this),Y(this,ps))}disconnectedCallback(){var e,t;Si(Ka(this),Y(this,ps)),this.disable(),(t=(e=Y(this,Vi))==null?void 0:e.unassociateElement)==null||t.call(e,this),Wi(this,Vi,null),Y(this,Ye).removeAttribute(ee.MEDIA_CONTROLLER)}get keysUsed(){return["Enter","Escape"," ","ArrowUp","ArrowDown","f","c","k","m"]}};Vi=new WeakMap;At=new WeakMap;Wa=new WeakMap;Ye=new WeakMap;gi=new WeakMap;Dn=new WeakMap;Vd=new WeakMap;Kd=new WeakMap;qd=new WeakMap;Yd=new WeakMap;zd=new WeakSet;Cm=function(){Y(this,gi).hidden?ms(this,Mm,ry).call(this):ms(this,Mn,Va).call(this)};Mm=new WeakSet;ry=function(){Y(this,gi).hidden&&(Y(this,gi).hidden=!1,Y(this,At).setAttribute("aria-expanded","true"),Y(this,ps).call(this),Y(this,Ye).focus(),Kt(Ka(this),Y(this,ps)))};Mn=new WeakSet;Va=function(){if(Y(this,gi).hidden)return;Si(Ka(this),Y(this,ps));let i=Xr();Y(this,gi).hidden=!0,Y(this,At).setAttribute("aria-expanded","false"),yt(Y(this,Ye),i)&&Y(this,At).focus()};ps=new WeakMap;function Ka(i){var e;return(e=i.getAttribute("bounds")?ai(i,`#${i.getAttribute("bounds")}`):Bx(i)||i.parentElement)!=null?e:i}function Bx(i){var e;let t=i.getAttribute(ee.MEDIA_CONTROLLER);return t?(e=i.getRootNode())==null?void 0:e.getElementById(t):ai(i,"media-controller")}A.customElements.get("media-chrome-selectmenu")||A.customElements.define("media-chrome-selectmenu",Xt);var Fm=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},$x=(i,e,t)=>(Fm(i,e,"read from private field"),t?t.call(i):e.get(i)),Pm=(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)},Hx=(i,e,t,r)=>(Fm(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Om=(i,e,t)=>(Fm(i,e,"access private method"),t),Xd,Nm,oy,jd,Um,Gx=`
1550
+ `;var Xt=class extends _.HTMLElement{constructor(){var e;super(),Ct(this,zd),Ct(this,Um),Ct(this,Pn),Ct(this,Ki,void 0),Ct(this,At,void 0),Ct(this,Wa,void 0),Ct(this,ze,void 0),Ct(this,gi,void 0),Ct(this,Mn,t=>{let{key:r}=t;if(!this.keysUsed.includes(r)){this.removeEventListener("keyup",Y(this,Mn));return}t.composedPath().includes(Y(this,At))&&(r==="Enter"||r===" ")?ps(this,zd,Om).call(this):r==="Escape"&&ps(this,Pn,Ka).call(this)}),Ct(this,Kd,t=>{let{metaKey:r,altKey:s,key:n}=t;if(r||s||!this.keysUsed.includes(n)){this.removeEventListener("keyup",Y(this,Mn));return}t.preventDefault(),this.addEventListener("keyup",Y(this,Mn),{once:!0})}),Ct(this,Vd,t=>{t.composedPath().includes(this)||ps(this,Pn,Ka).call(this)}),Ct(this,qd,t=>{t.composedPath().includes(Y(this,At))&&ps(this,zd,Om).call(this)}),Ct(this,Yd,()=>{ps(this,Pn,Ka).call(this)}),Ct(this,gs,()=>{if(Y(this,ze).offsetWidth===0)return;let t=Y(this,ze).offsetWidth,r=Y(this,At).getBoundingClientRect();if(this.hasAttribute("mediacontroller")||Y(this,At).hasAttribute("mediacontroller")||Y(this,ze).hasAttribute("mediacontroller")){Y(this,ze).style.zIndex="1",Y(this,ze).style.bottom="unset",Y(this,ze).style.right=null,Y(this,ze).style.left="0",Y(this,ze).style.top=`${r.height}px`;return}let n=Va(this).getBoundingClientRect(),a=r.x+t,o=Math.max(r.right-a,r.right-n.right);Y(this,ze).style.left=null,Y(this,ze).style.right=`${o}px`,Y(this,ze).style.maxHeight=`${n.height-r.height}px`}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(ay.content.cloneNode(!0))),(e=this.init)==null||e.call(this),Wi(this,At,this.shadowRoot.querySelector("[part=button]")),Wi(this,ze,this.shadowRoot.querySelector("[part=listbox]")),Wi(this,Wa,this.shadowRoot.querySelector("slot[name=button]")),Y(this,Wa).addEventListener("slotchange",()=>{let t=Y(this,Wa).assignedElements()[0];if(!t)return;Wi(this,At,t),Y(this,At).preventClick=!0,this.hasAttribute("disabled")||Y(this,At).hasAttribute("disabled")?this.disable():(this.enable(),Y(this,At).setAttribute("aria-haspopup","listbox"))}),Wi(this,gi,this.shadowRoot.querySelector("slot[name=listbox]")),Y(this,gi).addEventListener("slotchange",()=>{Wi(this,ze,Y(this,gi).assignedElements()[0]||Y(this,ze))})}static get observedAttributes(){return["disabled",te.MEDIA_CONTROLLER]}enable(){Y(this,At).toggleAttribute("disabled",!1),this.addEventListener("change",Y(this,Yd)),this.addEventListener("keydown",Y(this,Kd)),this.addEventListener("click",Y(this,qd)),O.addEventListener("click",Y(this,Vd))}disable(){Y(this,At).toggleAttribute("disabled",!0),this.removeEventListener("change",Y(this,Yd)),this.removeEventListener("keydown",Y(this,Kd)),this.removeEventListener("keyup",Y(this,Mn)),this.removeEventListener("click",Y(this,qd)),O.removeEventListener("click",Y(this,Vd))}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===te.MEDIA_CONTROLLER?(t&&((n=(s=Y(this,Ki))==null?void 0:s.unassociateElement)==null||n.call(s,this),Wi(this,Ki,null),Y(this,ze).removeAttribute(te.MEDIA_CONTROLLER)),r&&this.isConnected&&(Wi(this,Ki,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=Y(this,Ki))==null?void 0:o.associateElement)==null||l.call(o,this),Y(this,ze).setAttribute(te.MEDIA_CONTROLLER,r))):e==="disabled"&&r!==t&&(r==null?this.enable():this.disable())}connectedCallback(){var e,t,r;let{style:s}=Te(this.shadowRoot,":host");s.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`);let n=this.getAttribute(te.MEDIA_CONTROLLER);n&&(Wi(this,Ki,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(r=(t=Y(this,Ki))==null?void 0:t.associateElement)==null||r.call(t,this),Y(this,ze).setAttribute(te.MEDIA_CONTROLLER,n)),this.hasAttribute("disabled")||this.enable(),Y(this,gi).hidden||Vt(Va(this),Y(this,gs))}disconnectedCallback(){var e,t;Si(Va(this),Y(this,gs)),this.disable(),(t=(e=Y(this,Ki))==null?void 0:e.unassociateElement)==null||t.call(e,this),Wi(this,Ki,null),Y(this,ze).removeAttribute(te.MEDIA_CONTROLLER)}get keysUsed(){return["Enter","Escape"," ","ArrowUp","ArrowDown","f","c","k","m"]}};Ki=new WeakMap;At=new WeakMap;Wa=new WeakMap;ze=new WeakMap;gi=new WeakMap;Mn=new WeakMap;Kd=new WeakMap;Vd=new WeakMap;qd=new WeakMap;Yd=new WeakMap;zd=new WeakSet;Om=function(){Y(this,gi).hidden?ps(this,Um,ny).call(this):ps(this,Pn,Ka).call(this)};Um=new WeakSet;ny=function(){Y(this,gi).hidden&&(Y(this,gi).hidden=!1,Y(this,At).setAttribute("aria-expanded","true"),Y(this,gs).call(this),Y(this,ze).focus(),Vt(Va(this),Y(this,gs)))};Pn=new WeakSet;Ka=function(){if(Y(this,gi).hidden)return;Si(Va(this),Y(this,gs));let i=Qr();Y(this,gi).hidden=!0,Y(this,At).setAttribute("aria-expanded","false"),yt(Y(this,ze),i)&&Y(this,At).focus()};gs=new WeakMap;function Va(i){var e;return(e=i.getAttribute("bounds")?ai(i,`#${i.getAttribute("bounds")}`):Ux(i)||i.parentElement)!=null?e:i}function Ux(i){var e;let t=i.getAttribute(te.MEDIA_CONTROLLER);return t?(e=i.getRootNode())==null?void 0:e.getElementById(t):ai(i,"media-controller")}_.customElements.get("media-chrome-selectmenu")||_.customElements.define("media-chrome-selectmenu",Xt);var Gm=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Fx=(i,e,t)=>(Gm(i,e,"read from private field"),t?t.call(i):e.get(i)),Fm=(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)},Bx=(i,e,t,r)=>(Gm(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Bm=(i,e,t)=>(Gm(i,e,"access private method"),t),Xd,$m,dy,jd,Hm,$x=`
1551
1551
  <svg aria-hidden="true" viewBox="0 0 26 24" part="captions-indicator indicator">
1552
1552
  <path d="M22.83 5.68a2.58 2.58 0 0 0-2.3-2.5c-3.62-.24-11.44-.24-15.06 0a2.58 2.58 0 0 0-2.3 2.5c-.23 4.21-.23 8.43 0 12.64a2.58 2.58 0 0 0 2.3 2.5c3.62.24 11.44.24 15.06 0a2.58 2.58 0 0 0 2.3-2.5c.23-4.21.23-8.43 0-12.64Zm-11.39 9.45a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.92 3.92 0 0 1 .92-2.77 3.18 3.18 0 0 1 2.43-1 2.94 2.94 0 0 1 2.13.78c.364.359.62.813.74 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.17 1.61 1.61 0 0 0-1.29.58 2.79 2.79 0 0 0-.5 1.89 3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.48 1.48 0 0 0 1-.37 2.1 2.1 0 0 0 .59-1.14l1.4.44a3.23 3.23 0 0 1-1.07 1.69Zm7.22 0a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.88 3.88 0 0 1 .93-2.77 3.14 3.14 0 0 1 2.42-1 3 3 0 0 1 2.16.82 2.8 2.8 0 0 1 .73 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.21 1.61 1.61 0 0 0-1.29.58A2.79 2.79 0 0 0 15 12a3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.44 1.44 0 0 0 1-.37 2.1 2.1 0 0 0 .6-1.15l1.4.44a3.17 3.17 0 0 1-1.1 1.7Z"/>
1553
- </svg>`,ly=O.createElement("template");ly.innerHTML=`
1554
- <slot name="captions-indicator" hidden>${Gx}</slot>
1555
- `;var Qd=class extends jt{constructor(){super({slotTemplate:ly}),Pm(this,Nm),Pm(this,jd),Pm(this,Xd,void 0)}static get observedAttributes(){return[...super.observedAttributes,"aria-multiselectable",b.MEDIA_SUBTITLES_LIST,b.MEDIA_SUBTITLES_SHOWING]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_SUBTITLES_LIST&&t!==r?Om(this,Nm,oy).call(this):e===b.MEDIA_SUBTITLES_SHOWING&&t!==r?this.value=r:e==="aria-multiselectable"&&(this.removeAttribute("aria-multiselectable"),console.warn("Captions List doesn't currently support multiple selections. You can enable multiple items via the media.textTracks API."))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Om(this,jd,Um))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Om(this,jd,Um))}get mediaSubtitlesList(){return ny(this,b.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){ay(this,b.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return ny(this,b.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){ay(this,b.MEDIA_SUBTITLES_SHOWING,e)}};Xd=new WeakMap;Nm=new WeakSet;oy=function(){var i;if($x(this,Xd)===JSON.stringify(this.mediaSubtitlesList))return;Hx(this,Xd,JSON.stringify(this.mediaSubtitlesList));let e=this.shadowRoot.querySelector("#container");e.textContent="";let t=!this.value,r=Gi(this.formatOptionText("Off"),"off",t);r.prepend(pi(this,"select-indicator")),e.append(r);let s=this.mediaSubtitlesList;for(let n of s){let a=Gi(this.formatOptionText(n.label,n),es(n),this.value==es(n));a.prepend(pi(this,"select-indicator")),((i=n.kind)!=null?i:"subs")==="captions"&&a.append(pi(this,"captions-indicator")),e.append(a)}};jd=new WeakSet;Um=function(){let i=this.mediaSubtitlesShowing,e=this.getAttribute(b.MEDIA_SUBTITLES_SHOWING),t=this.value!==e;if(i!=null&&i.length&&t&&this.dispatchEvent(new A.CustomEvent(F.MEDIA_DISABLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:i})),!this.value||!t)return;let r=new A.CustomEvent(F.MEDIA_SHOW_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(r)};var ny=(i,e)=>{let t=i.getAttribute(e);return t?sr(t):[]},ay=(i,e,t)=>{if(!(t!=null&&t.length)){i.removeAttribute(e);return}let r=li(t);i.getAttribute(e)!==r&&i.setAttribute(e,r)};A.customElements.get("media-captions-listbox")||A.customElements.define("media-captions-listbox",Qd);var Zd=class extends Xt{init(){let e=O.createElement("media-captions-button");e.part.add("button"),e.preventClick=!0;let t=O.createElement("media-captions-listbox");t.part.add("listbox"),t.setAttribute("exportparts","option, option-selected, indicator");let r=this.shadowRoot.querySelector("slot[name=button]"),s=this.shadowRoot.querySelector("slot[name=listbox]");r.textContent="",s.textContent="",r.append(e),s.append(t)}};A.customElements.get("media-captions-selectmenu")||A.customElements.define("media-captions-selectmenu",Zd);var dy=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Jd=(i,e,t)=>(dy(i,e,"read from private field"),t?t.call(i):e.get(i)),Bm=(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)},qa=(i,e,t)=>(dy(i,e,"access private method"),t),Pn,Ya,eu,tu,Hm,$m={RATES:"rates"},iu=class extends jt{constructor(){super(),Bm(this,Ya),Bm(this,tu),Bm(this,Pn,new qt(this,$m.RATES,{defaultValue:wa})),qa(this,Ya,eu).call(this)}static get observedAttributes(){return[...super.observedAttributes,"aria-multiselectable",b.MEDIA_PLAYBACK_RATE,$m.RATES]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_PLAYBACK_RATE&&t!=r?this.value=r:e===$m.RATES&&t!=r&&(Jd(this,Pn).value=r,qa(this,Ya,eu).call(this))}get rates(){return Jd(this,Pn)}set rates(e){e?Array.isArray(e)&&(Jd(this,Pn).value=e.join(" ")):Jd(this,Pn).value="",qa(this,Ya,eu).call(this)}get mediaPlaybackRate(){return ve(this,b.MEDIA_PLAYBACK_RATE,kr)}set mediaPlaybackRate(e){_e(this,b.MEDIA_PLAYBACK_RATE,e)}connectedCallback(){super.connectedCallback(),this.addEventListener("change",qa(this,tu,Hm))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",qa(this,tu,Hm))}};Pn=new WeakMap;Ya=new WeakSet;eu=function(){let i=this.shadowRoot.querySelector("#container");i.textContent="";for(let e of this.rates){let t=Gi(this.formatOptionText(`${e}x`,e),e,this.mediaPlaybackRate==e);t.prepend(pi(this,"select-indicator")),i.append(t)}};tu=new WeakSet;Hm=function(){if(!this.value)return;let i=new A.CustomEvent(F.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};A.customElements.get("media-playback-rate-listbox")||A.customElements.define("media-playback-rate-listbox",iu);var ru=class extends Xt{init(){let e=O.createElement("media-playback-rate-button");e.part.add("button"),e.preventClick=!0;let t=O.createElement("media-playback-rate-listbox");t.part.add("listbox"),t.setAttribute("exportparts","option, option-selected, indicator");let r=this.shadowRoot.querySelector("slot[name=button]"),s=this.shadowRoot.querySelector("slot[name=listbox]");r.textContent="",s.textContent="",r.append(e),s.append(t)}};A.customElements.get("media-playback-rate-selectmenu")||A.customElements.define("media-playback-rate-selectmenu",ru);var Km=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},uy=(i,e,t)=>(Km(i,e,"read from private field"),t?t.call(i):e.get(i)),su=(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)},Gm=(i,e,t,r)=>(Km(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),nu=(i,e,t)=>(Km(i,e,"access private method"),t),za,lu,au,Wm,ou,Vm,du=class extends jt{constructor(){super(...arguments),su(this,au),su(this,ou),su(this,za,[]),su(this,lu,void 0)}static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_RENDITION_LIST,b.MEDIA_RENDITION_SELECTED]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_RENDITION_SELECTED&&t!==r?this.value=r!=null?r:"auto":e===b.MEDIA_RENDITION_LIST&&t!==r&&(Gm(this,za,qo(r)),nu(this,au,Wm).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",nu(this,ou,Vm))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",nu(this,ou,Vm))}get mediaRenditionList(){return uy(this,za)}set mediaRenditionList(e){Gm(this,za,e),nu(this,au,Wm).call(this)}get mediaRenditionSelected(){return ue(this,b.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){le(this,b.MEDIA_RENDITION_SELECTED,e)}};za=new WeakMap;lu=new WeakMap;au=new WeakSet;Wm=function(){if(uy(this,lu)===JSON.stringify(this.mediaRenditionList))return;Gm(this,lu,JSON.stringify(this.mediaRenditionList));let i=this.mediaRenditionList.sort((s,n)=>n.height-s.height),e=this.shadowRoot.querySelector("#container");e.textContent="";let t=!this.mediaRenditionSelected;for(let s of i){let n=this.formatOptionText(`${Math.min(s.width,s.height)}p`,s),a=Gi(n,`${s.id}`,s.selected&&!t);a.prepend(pi(this,"select-indicator")),e.append(a)}let r=Gi(this.formatOptionText("Auto"),"auto",t);r.prepend(pi(this,"select-indicator")),e.append(r)};ou=new WeakSet;Vm=function(){if(this.value==null)return;let i=new A.CustomEvent(F.MEDIA_RENDITION_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};A.customElements.get("media-rendition-listbox")||A.customElements.define("media-rendition-listbox",du);var Wx=`<svg aria-hidden="true" viewBox="0 0 24 24">
1553
+ </svg>`,uy=O.createElement("template");uy.innerHTML=`
1554
+ <slot name="captions-indicator" hidden>${$x}</slot>
1555
+ `;var Qd=class extends jt{constructor(){super({slotTemplate:uy}),Fm(this,$m),Fm(this,jd),Fm(this,Xd,void 0)}static get observedAttributes(){return[...super.observedAttributes,"aria-multiselectable",b.MEDIA_SUBTITLES_LIST,b.MEDIA_SUBTITLES_SHOWING]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_SUBTITLES_LIST&&t!==r?Bm(this,$m,dy).call(this):e===b.MEDIA_SUBTITLES_SHOWING&&t!==r?this.value=r:e==="aria-multiselectable"&&(this.removeAttribute("aria-multiselectable"),console.warn("Captions List doesn't currently support multiple selections. You can enable multiple items via the media.textTracks API."))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Bm(this,jd,Hm))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Bm(this,jd,Hm))}get mediaSubtitlesList(){return oy(this,b.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){ly(this,b.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return oy(this,b.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){ly(this,b.MEDIA_SUBTITLES_SHOWING,e)}};Xd=new WeakMap;$m=new WeakSet;dy=function(){var i;if(Fx(this,Xd)===JSON.stringify(this.mediaSubtitlesList))return;Bx(this,Xd,JSON.stringify(this.mediaSubtitlesList));let e=this.shadowRoot.querySelector("#container");e.textContent="";let t=!this.value,r=Gi(this.formatOptionText("Off"),"off",t);r.prepend(pi(this,"select-indicator")),e.append(r);let s=this.mediaSubtitlesList;for(let n of s){let a=Gi(this.formatOptionText(n.label,n),ts(n),this.value==ts(n));a.prepend(pi(this,"select-indicator")),((i=n.kind)!=null?i:"subs")==="captions"&&a.append(pi(this,"captions-indicator")),e.append(a)}};jd=new WeakSet;Hm=function(){let i=this.mediaSubtitlesShowing,e=this.getAttribute(b.MEDIA_SUBTITLES_SHOWING),t=this.value!==e;if(i!=null&&i.length&&t&&this.dispatchEvent(new _.CustomEvent(B.MEDIA_DISABLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:i})),!this.value||!t)return;let r=new _.CustomEvent(B.MEDIA_SHOW_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(r)};var oy=(i,e)=>{let t=i.getAttribute(e);return t?sr(t):[]},ly=(i,e,t)=>{if(!(t!=null&&t.length)){i.removeAttribute(e);return}let r=li(t);i.getAttribute(e)!==r&&i.setAttribute(e,r)};_.customElements.get("media-captions-listbox")||_.customElements.define("media-captions-listbox",Qd);var Zd=class extends Xt{init(){let e=O.createElement("media-captions-button");e.part.add("button"),e.preventClick=!0;let t=O.createElement("media-captions-listbox");t.part.add("listbox"),t.setAttribute("exportparts","option, option-selected, indicator");let r=this.shadowRoot.querySelector("slot[name=button]"),s=this.shadowRoot.querySelector("slot[name=listbox]");r.textContent="",s.textContent="",r.append(e),s.append(t)}};_.customElements.get("media-captions-selectmenu")||_.customElements.define("media-captions-selectmenu",Zd);var cy=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Jd=(i,e,t)=>(cy(i,e,"read from private field"),t?t.call(i):e.get(i)),Wm=(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)},qa=(i,e,t)=>(cy(i,e,"access private method"),t),On,Ya,eu,tu,Vm,Km={RATES:"rates"},iu=class extends jt{constructor(){super(),Wm(this,Ya),Wm(this,tu),Wm(this,On,new qt(this,Km.RATES,{defaultValue:wa})),qa(this,Ya,eu).call(this)}static get observedAttributes(){return[...super.observedAttributes,"aria-multiselectable",b.MEDIA_PLAYBACK_RATE,Km.RATES]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_PLAYBACK_RATE&&t!=r?this.value=r:e===Km.RATES&&t!=r&&(Jd(this,On).value=r,qa(this,Ya,eu).call(this))}get rates(){return Jd(this,On)}set rates(e){e?Array.isArray(e)&&(Jd(this,On).value=e.join(" ")):Jd(this,On).value="",qa(this,Ya,eu).call(this)}get mediaPlaybackRate(){return ve(this,b.MEDIA_PLAYBACK_RATE,kr)}set mediaPlaybackRate(e){_e(this,b.MEDIA_PLAYBACK_RATE,e)}connectedCallback(){super.connectedCallback(),this.addEventListener("change",qa(this,tu,Vm))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",qa(this,tu,Vm))}};On=new WeakMap;Ya=new WeakSet;eu=function(){let i=this.shadowRoot.querySelector("#container");i.textContent="";for(let e of this.rates){let t=Gi(this.formatOptionText(`${e}x`,e),e,this.mediaPlaybackRate==e);t.prepend(pi(this,"select-indicator")),i.append(t)}};tu=new WeakSet;Vm=function(){if(!this.value)return;let i=new _.CustomEvent(B.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};_.customElements.get("media-playback-rate-listbox")||_.customElements.define("media-playback-rate-listbox",iu);var ru=class extends Xt{init(){let e=O.createElement("media-playback-rate-button");e.part.add("button"),e.preventClick=!0;let t=O.createElement("media-playback-rate-listbox");t.part.add("listbox"),t.setAttribute("exportparts","option, option-selected, indicator");let r=this.shadowRoot.querySelector("slot[name=button]"),s=this.shadowRoot.querySelector("slot[name=listbox]");r.textContent="",s.textContent="",r.append(e),s.append(t)}};_.customElements.get("media-playback-rate-selectmenu")||_.customElements.define("media-playback-rate-selectmenu",ru);var jm=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},hy=(i,e,t)=>(jm(i,e,"read from private field"),t?t.call(i):e.get(i)),su=(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)},qm=(i,e,t,r)=>(jm(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),nu=(i,e,t)=>(jm(i,e,"access private method"),t),za,lu,au,Ym,ou,zm,du=class extends jt{constructor(){super(...arguments),su(this,au),su(this,ou),su(this,za,[]),su(this,lu,void 0)}static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_RENDITION_LIST,b.MEDIA_RENDITION_SELECTED]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_RENDITION_SELECTED&&t!==r?this.value=r!=null?r:"auto":e===b.MEDIA_RENDITION_LIST&&t!==r&&(qm(this,za,qo(r)),nu(this,au,Ym).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",nu(this,ou,zm))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",nu(this,ou,zm))}get mediaRenditionList(){return hy(this,za)}set mediaRenditionList(e){qm(this,za,e),nu(this,au,Ym).call(this)}get mediaRenditionSelected(){return ue(this,b.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){le(this,b.MEDIA_RENDITION_SELECTED,e)}};za=new WeakMap;lu=new WeakMap;au=new WeakSet;Ym=function(){if(hy(this,lu)===JSON.stringify(this.mediaRenditionList))return;qm(this,lu,JSON.stringify(this.mediaRenditionList));let i=this.mediaRenditionList.sort((s,n)=>n.height-s.height),e=this.shadowRoot.querySelector("#container");e.textContent="";let t=!this.mediaRenditionSelected;for(let s of i){let n=this.formatOptionText(`${Math.min(s.width,s.height)}p`,s),a=Gi(n,`${s.id}`,s.selected&&!t);a.prepend(pi(this,"select-indicator")),e.append(a)}let r=Gi(this.formatOptionText("Auto"),"auto",t);r.prepend(pi(this,"select-indicator")),e.append(r)};ou=new WeakSet;zm=function(){if(this.value==null)return;let i=new _.CustomEvent(B.MEDIA_RENDITION_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};_.customElements.get("media-rendition-listbox")||_.customElements.define("media-rendition-listbox",du);var Hx=`<svg aria-hidden="true" viewBox="0 0 24 24">
1556
1556
  <path d="M13.5 2.5h2v6h-2v-2h-11v-2h11v-2Zm4 2h4v2h-4v-2Zm-12 4h2v6h-2v-2h-3v-2h3v-2Zm4 2h12v2h-12v-2Zm1 4h2v6h-2v-2h-8v-2h8v-2Zm4 2h7v2h-7v-2Z" />
1557
- </svg>`,cy=O.createElement("template");cy.innerHTML=`
1558
- <slot name="icon">${Wx}</slot>
1559
- `;var qm=class extends be{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_RENDITION_SELECTED,b.MEDIA_RENDITION_UNAVAILABLE]}constructor(){super({slotTemplate:cy})}get mediaRenditionSelected(){return ue(this,b.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){le(this,b.MEDIA_RENDITION_SELECTED,e)}};A.customElements.get("media-rendition-button")||A.customElements.define("media-rendition-button",qm);var uu=class extends Xt{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_RENDITION_SELECTED,b.MEDIA_RENDITION_UNAVAILABLE]}init(){let e=O.createElement("media-rendition-button");e.part.add("button"),e.preventClick=!0;let t=O.createElement("media-rendition-listbox");t.part.add("listbox"),t.setAttribute("exportparts","option, option-selected, indicator");let r=this.shadowRoot.querySelector("slot[name=button]"),s=this.shadowRoot.querySelector("slot[name=listbox]");r.textContent="",s.textContent="",r.append(e),s.append(t)}};A.customElements.get("media-rendition-selectmenu")||A.customElements.define("media-rendition-selectmenu",uu);var Xm=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},hy=(i,e,t)=>(Xm(i,e,"read from private field"),t?t.call(i):e.get(i)),cu=(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)},Ym=(i,e,t,r)=>(Xm(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),hu=(i,e,t)=>(Xm(i,e,"access private method"),t),ja,pu,fu,zm,mu,jm,gu=class extends jt{constructor(){super(...arguments),cu(this,fu),cu(this,mu),cu(this,ja,[]),cu(this,pu,void 0)}static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_AUDIO_TRACK_LIST,b.MEDIA_AUDIO_TRACK_ENABLED]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_AUDIO_TRACK_ENABLED&&t!==r?this.value=r:e===b.MEDIA_AUDIO_TRACK_LIST&&t!==r&&(Ym(this,ja,Yo(r)),hu(this,fu,zm).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",hu(this,mu,jm))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",hu(this,mu,jm))}get mediaAudioTrackList(){return hy(this,ja)}set mediaAudioTrackList(e){Ym(this,ja,e),hu(this,fu,zm).call(this)}get mediaAudioTrackEnabled(){return ue(this,b.MEDIA_AUDIO_TRACK_ENABLED)}set mediaAudioTrackEnabled(e){le(this,b.MEDIA_AUDIO_TRACK_ENABLED,e)}};ja=new WeakMap;pu=new WeakMap;fu=new WeakSet;zm=function(){if(hy(this,pu)===JSON.stringify(this.mediaAudioTrackList))return;Ym(this,pu,JSON.stringify(this.mediaAudioTrackList));let i=this.mediaAudioTrackList,e=this.shadowRoot.querySelector("#container");e.textContent="";for(let t of i){let r=this.formatOptionText(t.label,t),s=Gi(r,`${t.id}`,t.enabled);s.prepend(pi(this,"select-indicator")),e.append(s)}};mu=new WeakSet;jm=function(){if(this.value==null)return;let i=new A.CustomEvent(F.MEDIA_AUDIO_TRACK_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};A.customElements.get("media-audio-track-listbox")||A.customElements.define("media-audio-track-listbox",gu);var Vx=`<svg aria-hidden="true" viewBox="0 0 24 24">
1557
+ </svg>`,fy=O.createElement("template");fy.innerHTML=`
1558
+ <slot name="icon">${Hx}</slot>
1559
+ `;var Xm=class extends be{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_RENDITION_SELECTED,b.MEDIA_RENDITION_UNAVAILABLE]}constructor(){super({slotTemplate:fy})}get mediaRenditionSelected(){return ue(this,b.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){le(this,b.MEDIA_RENDITION_SELECTED,e)}};_.customElements.get("media-rendition-button")||_.customElements.define("media-rendition-button",Xm);var uu=class extends Xt{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_RENDITION_SELECTED,b.MEDIA_RENDITION_UNAVAILABLE]}init(){let e=O.createElement("media-rendition-button");e.part.add("button"),e.preventClick=!0;let t=O.createElement("media-rendition-listbox");t.part.add("listbox"),t.setAttribute("exportparts","option, option-selected, indicator");let r=this.shadowRoot.querySelector("slot[name=button]"),s=this.shadowRoot.querySelector("slot[name=listbox]");r.textContent="",s.textContent="",r.append(e),s.append(t)}};_.customElements.get("media-rendition-selectmenu")||_.customElements.define("media-rendition-selectmenu",uu);var ep=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},my=(i,e,t)=>(ep(i,e,"read from private field"),t?t.call(i):e.get(i)),cu=(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)},Qm=(i,e,t,r)=>(ep(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),hu=(i,e,t)=>(ep(i,e,"access private method"),t),ja,pu,fu,Zm,mu,Jm,gu=class extends jt{constructor(){super(...arguments),cu(this,fu),cu(this,mu),cu(this,ja,[]),cu(this,pu,void 0)}static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_AUDIO_TRACK_LIST,b.MEDIA_AUDIO_TRACK_ENABLED]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===b.MEDIA_AUDIO_TRACK_ENABLED&&t!==r?this.value=r:e===b.MEDIA_AUDIO_TRACK_LIST&&t!==r&&(Qm(this,ja,Yo(r)),hu(this,fu,Zm).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",hu(this,mu,Jm))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",hu(this,mu,Jm))}get mediaAudioTrackList(){return my(this,ja)}set mediaAudioTrackList(e){Qm(this,ja,e),hu(this,fu,Zm).call(this)}get mediaAudioTrackEnabled(){return ue(this,b.MEDIA_AUDIO_TRACK_ENABLED)}set mediaAudioTrackEnabled(e){le(this,b.MEDIA_AUDIO_TRACK_ENABLED,e)}};ja=new WeakMap;pu=new WeakMap;fu=new WeakSet;Zm=function(){if(my(this,pu)===JSON.stringify(this.mediaAudioTrackList))return;Qm(this,pu,JSON.stringify(this.mediaAudioTrackList));let i=this.mediaAudioTrackList,e=this.shadowRoot.querySelector("#container");e.textContent="";for(let t of i){let r=this.formatOptionText(t.label,t),s=Gi(r,`${t.id}`,t.enabled);s.prepend(pi(this,"select-indicator")),e.append(s)}};mu=new WeakSet;Jm=function(){if(this.value==null)return;let i=new _.CustomEvent(B.MEDIA_AUDIO_TRACK_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};_.customElements.get("media-audio-track-listbox")||_.customElements.define("media-audio-track-listbox",gu);var Gx=`<svg aria-hidden="true" viewBox="0 0 24 24">
1560
1560
  <path d="M11 17H9.5V7H11v10Zm-3-3H6.5v-4H8v4Zm6-5h-1.5v6H14V9Zm3 7h-1.5V8H17v8Z"/>
1561
1561
  <path d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Zm-2 0a8 8 0 1 0-16 0 8 8 0 0 0 16 0Z"/>
1562
- </svg>`,fy=O.createElement("template");fy.innerHTML=`
1563
- <slot name="icon">${Vx}</slot>
1564
- `;var Qm=class extends be{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_AUDIO_TRACK_ENABLED,b.MEDIA_AUDIO_TRACK_UNAVAILABLE]}constructor(){super({slotTemplate:fy})}get mediaAudioTrackEnabled(){return ue(this,b.MEDIA_AUDIO_TRACK_ENABLED)}set mediaAudioTrackEnabled(e){le(this,b.MEDIA_AUDIO_TRACK_ENABLED,e)}};A.customElements.get("media-audio-track-button")||A.customElements.define("media-audio-track-button",Qm);var vu=class extends Xt{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_AUDIO_TRACK_ENABLED,b.MEDIA_AUDIO_TRACK_UNAVAILABLE]}init(){let e=O.createElement("media-audio-track-button");e.part.add("button"),e.preventClick=!0;let t=O.createElement("media-audio-track-listbox");t.part.add("listbox"),t.setAttribute("exportparts","option, option-selected, indicator");let r=this.shadowRoot.querySelector("slot[name=button]"),s=this.shadowRoot.querySelector("slot[name=listbox]");r.textContent="",s.textContent="",r.append(e),s.append(t)}};A.customElements.get("media-audio-track-selectmenu")||A.customElements.define("media-audio-track-selectmenu",vu);var Kx=Object.create,_y=Object.defineProperty,qx=Object.getOwnPropertyDescriptor,Yx=Object.getOwnPropertyNames,zx=Object.getPrototypeOf,jx=Object.prototype.hasOwnProperty,Ay=function(i,e){return function(){return i&&(e=i(i=0)),e}},vt=function(i,e){return function(){return e||i((e={exports:{}}).exports,e),e.exports}},Xx=function(i,e,t,r){if(e&&typeof e=="object"||typeof e=="function")for(var s=Yx(e),n=0,a=s.length,o;n<a;n++)o=s[n],!jx.call(i,o)&&o!==t&&_y(i,o,{get:function(l){return e[l]}.bind(null,o),enumerable:!(r=qx(e,o))||r.enumerable});return i},Dt=function(i,e,t){return t=i!=null?Kx(zx(i)):{},Xx(e||!i||!i.__esModule?_y(t,"default",{value:i,enumerable:!0}):t,i)},Ki=vt(function(i,e){var t;typeof window!="undefined"?t=window:typeof global!="undefined"?t=global:typeof self!="undefined"?t=self:t={},e.exports=t});function St(i){"@swc/helpers - typeof";return i&&typeof Symbol!="undefined"&&i.constructor===Symbol?"symbol":typeof i}var Au=Ay(function(){}),Qx=vt(function(i,e){Au(),function(t,r){"use strict";typeof define=="function"&&define.amd?define(r):typeof e=="object"&&e.exports?e.exports=r():t.log=r()}(i,function(){"use strict";var t=function(){},r="undefined",s=(typeof window=="undefined"?"undefined":St(window))!==r&&St(window.navigator)!==r&&/Trident\/|MSIE /.test(window.navigator.userAgent),n=["trace","debug","info","warn","error"];function a(g,E){var T=g[E];if(typeof T.bind=="function")return T.bind(g);try{return Function.prototype.bind.call(T,g)}catch{return function(){return Function.prototype.apply.apply(T,[g,arguments])}}}function o(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function l(g){return g==="debug"&&(g="log"),(typeof console=="undefined"?"undefined":St(console))===r?!1:g==="trace"&&s?o:console[g]!==void 0?a(console,g):console.log!==void 0?a(console,"log"):t}function d(g,E){for(var T=0;T<n.length;T++){var y=n[T];this[y]=T<g?t:this.methodFactory(y,g,E)}this.log=this.debug}function u(g,E,T){return function(){(typeof console=="undefined"?"undefined":St(console))!==r&&(d.call(this,E,T),this[g].apply(this,arguments))}}function c(g,E,T){return l(g)||u.apply(this,arguments)}function h(g,E,T){var y=this,S;E=E==null?"WARN":E;var _="loglevel";typeof g=="string"?_+=":"+g:(typeof g=="undefined"?"undefined":St(g))==="symbol"&&(_=void 0);function L(k){var D=(n[k]||"silent").toUpperCase();if(!((typeof window=="undefined"?"undefined":St(window))===r||!_)){try{window.localStorage[_]=D;return}catch{}try{window.document.cookie=encodeURIComponent(_)+"="+D+";"}catch{}}}function x(){var k;if(!((typeof window=="undefined"?"undefined":St(window))===r||!_)){try{k=window.localStorage[_]}catch{}if((typeof k=="undefined"?"undefined":St(k))===r)try{var D=window.document.cookie,U=D.indexOf(encodeURIComponent(_)+"=");U!==-1&&(k=/^([^;]+)/.exec(D.slice(U))[1])}catch{}return y.levels[k]===void 0&&(k=void 0),k}}function w(){if(!((typeof window=="undefined"?"undefined":St(window))===r||!_)){try{window.localStorage.removeItem(_);return}catch{}try{window.document.cookie=encodeURIComponent(_)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}y.name=g,y.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},y.methodFactory=T||c,y.getLevel=function(){return S},y.setLevel=function(k,D){if(typeof k=="string"&&y.levels[k.toUpperCase()]!==void 0&&(k=y.levels[k.toUpperCase()]),typeof k=="number"&&k>=0&&k<=y.levels.SILENT){if(S=k,D!==!1&&L(k),d.call(y,k,g),(typeof console=="undefined"?"undefined":St(console))===r&&k<y.levels.SILENT)return"No console available for logging"}else throw"log.setLevel() called with invalid level: "+k},y.setDefaultLevel=function(k){E=k,x()||y.setLevel(k,!1)},y.resetLevel=function(){y.setLevel(E,!1),w()},y.enableAll=function(k){y.setLevel(y.levels.TRACE,k)},y.disableAll=function(k){y.setLevel(y.levels.SILENT,k)};var M=x();M==null&&(M=E),y.setLevel(M,!1)}var f=new h,m={};f.getLogger=function(g){if((typeof g=="undefined"?"undefined":St(g))!=="symbol"&&typeof g!="string"||g==="")throw new TypeError("You must supply a name when creating a logger.");var E=m[g];return E||(E=m[g]=new h(g,f.getLevel(),f.methodFactory)),E};var p=(typeof window=="undefined"?"undefined":St(window))!==r?window.log:void 0;return f.noConflict=function(){return(typeof window=="undefined"?"undefined":St(window))!==r&&window.log===f&&(window.log=p),f},f.getLoggers=function(){return m},f.default=f,f})});function ys(i,e){return e!=null&&typeof Symbol!="undefined"&&e[Symbol.hasInstance]?!!e[Symbol.hasInstance](i):ys(i,e)}var Ts=Ay(function(){Ts()}),Zx=vt(function(i){"use strict";var e=Object.prototype.hasOwnProperty,t;function r(o){try{return decodeURIComponent(o.replace(/\+/g," "))}catch{return null}}function s(o){try{return encodeURIComponent(o)}catch{return null}}function n(o){for(var l=/([^=?#&]+)=?([^&]*)/g,d={},u;u=l.exec(o);){var c=r(u[1]),h=r(u[2]);c===null||h===null||c in d||(d[c]=h)}return d}function a(o,l){l=l||"";var d=[],u,c;typeof l!="string"&&(l="?");for(c in o)if(e.call(o,c)){if(u=o[c],!u&&(u===null||u===t||isNaN(u))&&(u=""),c=s(c),u=s(u),c===null||u===null)continue;d.push(c+"="+u)}return d.length?l+d.join("&"):""}i.stringify=a,i.parse=n}),Jx=vt(function(i,e){"use strict";(function(t){var r=!1;if(typeof define=="function"&&define.amd&&(define(t),r=!0),typeof i=="object"&&(e.exports=t(),r=!0),!r){var s=window.Cookies,n=window.Cookies=t();n.noConflict=function(){return window.Cookies=s,n}}})(function(){var t=function(){for(var s=0,n={};s<arguments.length;s++){var a=arguments[s];for(var o in a)n[o]=a[o]}return n};function r(s){function n(a,o,l){var d;if(typeof document!="undefined"){if(arguments.length>1){if(l=t({path:"/"},n.defaults,l),typeof l.expires=="number"){var u=new Date;u.setMilliseconds(u.getMilliseconds()+l.expires*864e5),l.expires=u}try{d=JSON.stringify(o),/^[\{\[]/.test(d)&&(o=d)}catch{}return s.write?o=s.write(o,a):o=encodeURIComponent(String(o)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),a=encodeURIComponent(String(a)),a=a.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent),a=a.replace(/[\(\)]/g,escape),document.cookie=[a,"=",o,l.expires?"; expires="+l.expires.toUTCString():"",l.path?"; path="+l.path:"",l.domain?"; domain="+l.domain:"",l.secure?"; secure":""].join("")}a||(d={});for(var c=document.cookie?document.cookie.split("; "):[],h=/(%[0-9A-Z]{2})+/g,f=0;f<c.length;f++){var m=c[f].split("="),p=m.slice(1).join("=");p.charAt(0)==='"'&&(p=p.slice(1,-1));try{var g=m[0].replace(h,decodeURIComponent);if(p=s.read?s.read(p,g):s(p,g)||p.replace(h,decodeURIComponent),this.json)try{p=JSON.parse(p)}catch{}if(a===g){d=p;break}a||(d[g]=p)}catch{}}return d}}return n.set=n,n.get=function(a){return n.call(n,a)},n.getJSON=function(){return n.apply({json:!0},[].slice.call(arguments))},n.defaults={},n.remove=function(a,o){n(a,"",t(o,{expires:-1}))},n.withConverter=r,n}return r(function(){})})}),Sy=vt(function(i,e){var t=Array.prototype.slice;e.exports=r;function r(s,n){for(("length"in s)||(s=[s]),s=t.call(s);s.length;){var a=s.shift(),o=n(a);if(o)return o;a.childNodes&&a.childNodes.length&&(s=t.call(a.childNodes).concat(s))}}}),eL=vt(function(i,e){Ts(),e.exports=t;function t(r,s){if(!ys(this,t))return new t(r,s);this.data=r,this.nodeValue=r,this.length=r.length,this.ownerDocument=s||null}t.prototype.nodeType=8,t.prototype.nodeName="#comment",t.prototype.toString=function(){return"[object Comment]"}}),tL=vt(function(i,e){Ts(),e.exports=t;function t(r,s){if(!ys(this,t))return new t(r);this.data=r||"",this.length=this.data.length,this.ownerDocument=s||null}t.prototype.type="DOMTextNode",t.prototype.nodeType=3,t.prototype.nodeName="#text",t.prototype.toString=function(){return this.data},t.prototype.replaceData=function(r,s,n){var a=this.data,o=a.substring(0,r),l=a.substring(r+s,a.length);this.data=o+n+l,this.length=this.data.length}}),xy=vt(function(i,e){e.exports=t;function t(r){var s=this,n=r.type;r.target||(r.target=s),s.listeners||(s.listeners={});var a=s.listeners[n];if(a)return a.forEach(function(o){r.currentTarget=s,typeof o=="function"?o(r):o.handleEvent(r)});s.parentNode&&s.parentNode.dispatchEvent(r)}}),Ly=vt(function(i,e){e.exports=t;function t(r,s){var n=this;n.listeners||(n.listeners={}),n.listeners[r]||(n.listeners[r]=[]),n.listeners[r].indexOf(s)===-1&&n.listeners[r].push(s)}}),ky=vt(function(i,e){e.exports=t;function t(r,s){var n=this;if(n.listeners&&n.listeners[r]){var a=n.listeners[r],o=a.indexOf(s);o!==-1&&a.splice(o,1)}}}),iL=vt(function(i,e){Au(),e.exports=r;var t=["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"];function r(h){switch(h.nodeType){case 3:return u(h.data);case 8:return"<!--"+h.data+"-->";default:return s(h)}}function s(h){var f=[],m=h.tagName;return h.namespaceURI==="http://www.w3.org/1999/xhtml"&&(m=m.toLowerCase()),f.push("<"+m+d(h)+o(h)),t.indexOf(m)>-1?f.push(" />"):(f.push(">"),h.childNodes.length?f.push.apply(f,h.childNodes.map(r)):h.textContent||h.innerText?f.push(u(h.textContent||h.innerText)):h.innerHTML&&f.push(h.innerHTML),f.push("</"+m+">")),f.join("")}function n(h,f){var m=St(h[f]);return f==="style"&&Object.keys(h.style).length>0?!0:h.hasOwnProperty(f)&&(m==="string"||m==="boolean"||m==="number")&&f!=="nodeName"&&f!=="className"&&f!=="tagName"&&f!=="textContent"&&f!=="innerText"&&f!=="namespaceURI"&&f!=="innerHTML"}function a(h){if(typeof h=="string")return h;var f="";return Object.keys(h).forEach(function(m){var p=h[m];m=m.replace(/[A-Z]/g,function(g){return"-"+g.toLowerCase()}),f+=m+":"+p+";"}),f}function o(h){var f=h.dataset,m=[];for(var p in f)m.push({name:"data-"+p,value:f[p]});return m.length?l(m):""}function l(h){var f=[];return h.forEach(function(m){var p=m.name,g=m.value;p==="style"&&(g=a(g)),f.push(p+'="'+c(g)+'"')}),f.length?" "+f.join(" "):""}function d(h){var f=[];for(var m in h)n(h,m)&&f.push({name:m,value:h[m]});for(var p in h._attributes)for(var g in h._attributes[p]){var E=h._attributes[p][g],T=(E.prefix?E.prefix+":":"")+g;f.push({name:T,value:E.value})}return h.className&&f.push({name:"class",value:h.className}),f.length?l(f):""}function u(h){var f="";return typeof h=="string"?f=h:h&&(f=h.toString()),f.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function c(h){return u(h).replace(/"/g,"&quot;")}}),Iy=vt(function(i,e){Ts();var t=Sy(),r=xy(),s=Ly(),n=ky(),a=iL(),o="http://www.w3.org/1999/xhtml";e.exports=l;function l(d,u,c){if(!ys(this,l))return new l(d);var h=c===void 0?o:c||null;this.tagName=h===o?String(d).toUpperCase():d,this.nodeName=this.tagName,this.className="",this.dataset={},this.childNodes=[],this.parentNode=null,this.style={},this.ownerDocument=u||null,this.namespaceURI=h,this._attributes={},this.tagName==="INPUT"&&(this.type="text")}l.prototype.type="DOMElement",l.prototype.nodeType=1,l.prototype.appendChild=function(d){return d.parentNode&&d.parentNode.removeChild(d),this.childNodes.push(d),d.parentNode=this,d},l.prototype.replaceChild=function(d,u){d.parentNode&&d.parentNode.removeChild(d);var c=this.childNodes.indexOf(u);return u.parentNode=null,this.childNodes[c]=d,d.parentNode=this,u},l.prototype.removeChild=function(d){var u=this.childNodes.indexOf(d);return this.childNodes.splice(u,1),d.parentNode=null,d},l.prototype.insertBefore=function(d,u){d.parentNode&&d.parentNode.removeChild(d);var c=u==null?-1:this.childNodes.indexOf(u);return c>-1?this.childNodes.splice(c,0,d):this.childNodes.push(d),d.parentNode=this,d},l.prototype.setAttributeNS=function(d,u,c){var h=null,f=u,m=u.indexOf(":");if(m>-1&&(h=u.substr(0,m),f=u.substr(m+1)),this.tagName==="INPUT"&&u==="type")this.type=c;else{var p=this._attributes[d]||(this._attributes[d]={});p[f]={value:c,prefix:h}}},l.prototype.getAttributeNS=function(d,u){var c=this._attributes[d],h=c&&c[u]&&c[u].value;return this.tagName==="INPUT"&&u==="type"?this.type:typeof h!="string"?null:h},l.prototype.removeAttributeNS=function(d,u){var c=this._attributes[d];c&&delete c[u]},l.prototype.hasAttributeNS=function(d,u){var c=this._attributes[d];return!!c&&u in c},l.prototype.setAttribute=function(d,u){return this.setAttributeNS(null,d,u)},l.prototype.getAttribute=function(d){return this.getAttributeNS(null,d)},l.prototype.removeAttribute=function(d){return this.removeAttributeNS(null,d)},l.prototype.hasAttribute=function(d){return this.hasAttributeNS(null,d)},l.prototype.removeEventListener=n,l.prototype.addEventListener=s,l.prototype.dispatchEvent=r,l.prototype.focus=function(){},l.prototype.toString=function(){return a(this)},l.prototype.getElementsByClassName=function(d){var u=d.split(" "),c=[];return t(this,function(h){if(h.nodeType===1){var f=h.className||"",m=f.split(" ");u.every(function(p){return m.indexOf(p)!==-1})&&c.push(h)}}),c},l.prototype.getElementsByTagName=function(d){d=d.toLowerCase();var u=[];return t(this.childNodes,function(c){c.nodeType===1&&(d==="*"||c.tagName.toLowerCase()===d)&&u.push(c)}),u},l.prototype.contains=function(d){return t(this,function(u){return d===u})||!1}}),rL=vt(function(i,e){Ts();var t=Iy();e.exports=r;function r(s){if(!ys(this,r))return new r;this.childNodes=[],this.parentNode=null,this.ownerDocument=s||null}r.prototype.type="DocumentFragment",r.prototype.nodeType=11,r.prototype.nodeName="#document-fragment",r.prototype.appendChild=t.prototype.appendChild,r.prototype.replaceChild=t.prototype.replaceChild,r.prototype.removeChild=t.prototype.removeChild,r.prototype.toString=function(){return this.childNodes.map(function(s){return String(s)}).join("")}}),sL=vt(function(i,e){e.exports=t;function t(r){}t.prototype.initEvent=function(r,s,n){this.type=r,this.bubbles=s,this.cancelable=n},t.prototype.preventDefault=function(){}}),nL=vt(function(i,e){Ts();var t=Sy(),r=eL(),s=tL(),n=Iy(),a=rL(),o=sL(),l=xy(),d=Ly(),u=ky();e.exports=c;function c(){if(!ys(this,c))return new c;this.head=this.createElement("head"),this.body=this.createElement("body"),this.documentElement=this.createElement("html"),this.documentElement.appendChild(this.head),this.documentElement.appendChild(this.body),this.childNodes=[this.documentElement],this.nodeType=9}var h=c.prototype;h.createTextNode=function(f){return new s(f,this)},h.createElementNS=function(f,m){var p=f===null?null:String(f);return new n(m,this,p)},h.createElement=function(f){return new n(f,this)},h.createDocumentFragment=function(){return new a(this)},h.createEvent=function(f){return new o(f)},h.createComment=function(f){return new r(f,this)},h.getElementById=function(f){f=String(f);var m=t(this.childNodes,function(p){if(String(p.id)===f)return p});return m||null},h.getElementsByClassName=n.prototype.getElementsByClassName,h.getElementsByTagName=n.prototype.getElementsByTagName,h.contains=n.prototype.contains,h.removeEventListener=u,h.addEventListener=d,h.dispatchEvent=l}),aL=vt(function(i,e){var t=nL();e.exports=new t}),oL=vt(function(i,e){var t=typeof global!="undefined"?global:typeof window!="undefined"?window:{},r=aL(),s;typeof document!="undefined"?s=document:(s=t["__GLOBAL_DOCUMENT_CACHE@4"],s||(s=t["__GLOBAL_DOCUMENT_CACHE@4"]=r)),e.exports=s});function lL(i){if(Array.isArray(i))return i}function dL(i,e){var t=i==null?null:typeof Symbol!="undefined"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var r=[],s=!0,n=!1,a,o;try{for(t=t.call(i);!(s=(a=t.next()).done)&&(r.push(a.value),!(e&&r.length===e));s=!0);}catch(l){n=!0,o=l}finally{try{!s&&t.return!=null&&t.return()}finally{if(n)throw o}}return r}}function uL(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1565
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function my(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,r=new Array(e);t<e;t++)r[t]=i[t];return r}function cL(i,e){if(i){if(typeof i=="string")return my(i,e);var t=Object.prototype.toString.call(i).slice(8,-1);if(t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set")return Array.from(t);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return my(i,e)}}function bs(i,e){return lL(i)||dL(i,e)||cL(i,e)||uL()}var Za=Dt(Ki()),eo=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(i){var e=Math.random()*16|0,t=i==="x"?e:e&3|8;return t.toString(16)})},Ry=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},vs=function(i){if(i&&typeof i.nodeName!="undefined")return i.muxId||(i.muxId=Ry()),i.muxId;var e;try{e=document.querySelector(i)}catch{}return e&&!e.muxId&&(e.muxId=i),(e==null?void 0:e.muxId)||i},rp=function(i){var e;i&&typeof i.nodeName!="undefined"?(e=i,i=vs(e)):e=document.querySelector(i);var t=e&&e.nodeName?e.nodeName.toLowerCase():"";return[e,i,t]},to=Dt(Qx()),hL=to.default.methodFactory;to.default.methodFactory=function(i,e,t){var r=hL(i,e,t);return function(){for(var s=["[mux]"],n=0;n<arguments.length;n++)s.push(arguments[n]);r.apply(void 0,s)}};to.default.setLevel(to.default.getLevel());var Ge=to.default,Zm=Dt(Ki());function sp(){var i=Zm.default.doNotTrack||Zm.default.navigator&&Zm.default.navigator.doNotTrack;return i==="1"}var fL=Dt(Ki()),mL={now:function(){var i=fL.default.performance,e=i&&i.timing,t=e&&e.navigationStart,r=typeof t=="number"&&typeof i.now=="function"?t+i.now():Date.now();return Math.round(r)}},tt=mL;function re(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}Ts();function dt(i,e){if(!ys(i,e))throw new TypeError("Cannot call a class as a function")}function py(i,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(i,r.key,r)}}function qi(i,e,t){return e&&py(i.prototype,e),t&&py(i,t),i}function H(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function np(i,e){return np=Object.setPrototypeOf||function(t,r){return t.__proto__=r,t},np(i,e)}function pL(i,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),e&&np(i,e)}function bu(i){return bu=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},bu(i)}function gL(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}Au();function vL(i,e){return e&&(St(e)==="object"||typeof e=="function")?e:re(i)}function EL(i){var e=gL();return function(){var t=bu(i),r;if(e){var s=bu(this).constructor;r=Reflect.construct(t,arguments,s)}else r=t.apply(this,arguments);return vL(this,r)}}var vi=function(i){return io(i)[0]},io=function(i){if(typeof i!="string"||i==="")return["localhost"];var e=/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/,t=i.match(e)||[],r=t[4],s;return r&&(s=(r.match(/[^\.]+\.[^\.]+$/)||[])[0]),[r,s]},Jm=Dt(Ki()),bL={exists:function(){var i=Jm.default.performance,e=i&&i.timing;return e!==void 0},domContentLoadedEventEnd:function(){var i=Jm.default.performance,e=i&&i.timing;return e&&e.domContentLoadedEventEnd},navigationStart:function(){var i=Jm.default.performance,e=i&&i.timing;return e&&e.navigationStart}},yu=bL;function Ze(i,e,t){t=t===void 0?1:t,i[e]=i[e]||0,i[e]+=t}function Tu(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{},r=Object.keys(t);typeof Object.getOwnPropertySymbols=="function"&&(r=r.concat(Object.getOwnPropertySymbols(t).filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable}))),r.forEach(function(s){H(i,s,t[s])})}return i}function yL(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(i);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,r)}return t}function op(i,e){return e=e!=null?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(e)):yL(Object(e)).forEach(function(t){Object.defineProperty(i,t,Object.getOwnPropertyDescriptor(e,t))}),i}var TL=["x-cdn","content-type"],wy=["x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"],_L=TL.concat(wy);function lp(i){i=i||"";var e={},t=i.trim().split(/[\r\n]+/);return t.forEach(function(r){if(r){var s=r.split(": "),n=s.shift();n&&(_L.indexOf(n.toLowerCase())>=0||n.toLowerCase().indexOf("x-litix-")===0)&&(e[n]=s.join(": "))}}),e}function _u(i){if(i){var e=wy.find(function(t){return i[t]!==void 0});return e?i[e]:void 0}}var AL=function(i){var e={};for(var t in i){var r=i[t],s=r["DATA-ID"].search("io.litix.data.");if(s!==-1){var n=r["DATA-ID"].replace("io.litix.data.","");e[n]=r.VALUE}}return e},Cy=AL,Eu=function(i){if(!i)return{};var e=yu.navigationStart(),t=i.loading,r=t?t.start:i.trequest,s=t?t.first:i.tfirst,n=t?t.end:i.tload;return{bytesLoaded:i.total,requestStart:Math.round(e+r),responseStart:Math.round(e+s),responseEnd:Math.round(e+n)}},Xa=function(i){if(!(!i||typeof i.getAllResponseHeaders!="function"))return lp(i.getAllResponseHeaders())},SL=function(i,e,t){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},s=arguments.length>4?arguments[4]:void 0,n=i.log,a=i.utils.secondsToMs,o=function(E){var T=parseInt(s.version),y;return T===1&&E.programDateTime!==null&&(y=E.programDateTime),T===0&&E.pdt!==null&&(y=E.pdt),y};if(!yu.exists()){n.warn("performance timing not supported. Not tracking HLS.js.");return}var l=function(E,T){return i.emit(e,E,T)},d=function(E,T){var y=T.levels,S=T.audioTracks,_=T.url,L=T.stats,x=T.networkDetails,w=T.sessionData,M={},k={};y.forEach(function(V,se){M[se]={width:V.width,height:V.height,bitrate:V.bitrate,attrs:V.attrs}}),S.forEach(function(V,se){k[se]={name:V.name,language:V.lang,bitrate:V.bitrate}});var D=Eu(L),U=D.bytesLoaded,B=D.requestStart,X=D.responseStart,z=D.responseEnd;l("requestcompleted",op(Tu({},Cy(w)),{request_event_type:E,request_bytes_loaded:U,request_start:B,request_response_start:X,request_response_end:z,request_type:"manifest",request_hostname:vi(_),request_response_headers:Xa(x),request_rendition_lists:{media:M,audio:k,video:{}}}))};t.on(s.Events.MANIFEST_LOADED,d);var u=function(E,T){var y=T.details,S=T.level,_=T.networkDetails,L=T.stats,x=Eu(L),w=x.bytesLoaded,M=x.requestStart,k=x.responseStart,D=x.responseEnd,U=y.fragments[y.fragments.length-1],B=o(U)+a(U.duration);l("requestcompleted",{request_event_type:E,request_bytes_loaded:w,request_start:M,request_response_start:k,request_response_end:D,request_current_level:S,request_type:"manifest",request_hostname:vi(y.url),request_response_headers:Xa(_),video_holdback:y.holdBack&&a(y.holdBack),video_part_holdback:y.partHoldBack&&a(y.partHoldBack),video_part_target_duration:y.partTarget&&a(y.partTarget),video_target_duration:y.targetduration&&a(y.targetduration),video_source_is_live:y.live,player_manifest_newest_program_time:isNaN(B)?void 0:B})};t.on(s.Events.LEVEL_LOADED,u);var c=function(E,T){var y=T.details,S=T.networkDetails,_=T.stats,L=Eu(_),x=L.bytesLoaded,w=L.requestStart,M=L.responseStart,k=L.responseEnd;l("requestcompleted",{request_event_type:E,request_bytes_loaded:x,request_start:w,request_response_start:M,request_response_end:k,request_type:"manifest",request_hostname:vi(y.url),request_response_headers:Xa(S)})};t.on(s.Events.AUDIO_TRACK_LOADED,c);var h=function(E,T){var y=T.stats,S=T.networkDetails,_=T.frag;y=y||_.stats;var L=Eu(y),x=L.bytesLoaded,w=L.requestStart,M=L.responseStart,k=L.responseEnd,D=S?Xa(S):void 0,U={request_event_type:E,request_bytes_loaded:x,request_start:w,request_response_start:M,request_response_end:k,request_hostname:S?vi(S.responseURL):void 0,request_id:D?_u(D):void 0,request_response_headers:D,request_media_duration:_.duration,request_url:S==null?void 0:S.responseURL};_.type==="main"?(U.request_type="media",U.request_current_level=_.level,U.request_video_width=(t.levels[_.level]||{}).width,U.request_video_height=(t.levels[_.level]||{}).height,U.request_labeled_bitrate=(t.levels[_.level]||{}).bitrate):U.request_type=_.type,l("requestcompleted",U)};t.on(s.Events.FRAG_LOADED,h);var f=function(E,T){var y=T.frag,S=y.start,_=o(y),L={currentFragmentPDT:_,currentFragmentStart:a(S)};l("fragmentchange",L)};t.on(s.Events.FRAG_CHANGED,f);var m=function(E,T){var y=T.type,S=T.details,_=T.response,L=T.fatal,x=T.frag,w=T.networkDetails,M=(x==null?void 0:x.url)||T.url||"",k=w?Xa(w):void 0;if((S===s.ErrorDetails.MANIFEST_LOAD_ERROR||S===s.ErrorDetails.MANIFEST_LOAD_TIMEOUT||S===s.ErrorDetails.FRAG_LOAD_ERROR||S===s.ErrorDetails.FRAG_LOAD_TIMEOUT||S===s.ErrorDetails.LEVEL_LOAD_ERROR||S===s.ErrorDetails.LEVEL_LOAD_TIMEOUT||S===s.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||S===s.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT||S===s.ErrorDetails.SUBTITLE_LOAD_ERROR||S===s.ErrorDetails.SUBTITLE_LOAD_TIMEOUT||S===s.ErrorDetails.KEY_LOAD_ERROR||S===s.ErrorDetails.KEY_LOAD_TIMEOUT)&&l("requestfailed",{request_error:S,request_url:M,request_hostname:vi(M),request_id:k?_u(k):void 0,request_type:S===s.ErrorDetails.FRAG_LOAD_ERROR||S===s.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":S===s.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||S===s.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT?"audio":S===s.ErrorDetails.SUBTITLE_LOAD_ERROR||S===s.ErrorDetails.SUBTITLE_LOAD_TIMEOUT?"subtitle":S===s.ErrorDetails.KEY_LOAD_ERROR||S===s.ErrorDetails.KEY_LOAD_TIMEOUT?"encryption":"manifest",request_error_code:_==null?void 0:_.code,request_error_text:_==null?void 0:_.text}),L){var D,U="".concat(M?"url: ".concat(M,`
1566
- `):"")+"".concat(_&&(_.code||_.text)?"response: ".concat(_.code,", ").concat(_.text,`
1562
+ </svg>`,py=O.createElement("template");py.innerHTML=`
1563
+ <slot name="icon">${Gx}</slot>
1564
+ `;var tp=class extends be{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_AUDIO_TRACK_ENABLED,b.MEDIA_AUDIO_TRACK_UNAVAILABLE]}constructor(){super({slotTemplate:py})}get mediaAudioTrackEnabled(){return ue(this,b.MEDIA_AUDIO_TRACK_ENABLED)}set mediaAudioTrackEnabled(e){le(this,b.MEDIA_AUDIO_TRACK_ENABLED,e)}};_.customElements.get("media-audio-track-button")||_.customElements.define("media-audio-track-button",tp);var vu=class extends Xt{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_AUDIO_TRACK_ENABLED,b.MEDIA_AUDIO_TRACK_UNAVAILABLE]}init(){let e=O.createElement("media-audio-track-button");e.part.add("button"),e.preventClick=!0;let t=O.createElement("media-audio-track-listbox");t.part.add("listbox"),t.setAttribute("exportparts","option, option-selected, indicator");let r=this.shadowRoot.querySelector("slot[name=button]"),s=this.shadowRoot.querySelector("slot[name=listbox]");r.textContent="",s.textContent="",r.append(e),s.append(t)}};_.customElements.get("media-audio-track-selectmenu")||_.customElements.define("media-audio-track-selectmenu",vu);var Wx=Object.create,Sy=Object.defineProperty,Kx=Object.getOwnPropertyDescriptor,Vx=Object.getOwnPropertyNames,qx=Object.getPrototypeOf,Yx=Object.prototype.hasOwnProperty,xy=function(i,e){return function(){return i&&(e=i(i=0)),e}},vt=function(i,e){return function(){return e||i((e={exports:{}}).exports,e),e.exports}},zx=function(i,e,t,r){if(e&&typeof e=="object"||typeof e=="function")for(var s=Vx(e),n=0,a=s.length,o;n<a;n++)o=s[n],!Yx.call(i,o)&&o!==t&&Sy(i,o,{get:function(l){return e[l]}.bind(null,o),enumerable:!(r=Kx(e,o))||r.enumerable});return i},Dt=function(i,e,t){return t=i!=null?Wx(qx(i)):{},zx(e||!i||!i.__esModule?Sy(t,"default",{value:i,enumerable:!0}):t,i)},Vi=vt(function(i,e){var t;typeof window!="undefined"?t=window:typeof global!="undefined"?t=global:typeof self!="undefined"?t=self:t={},e.exports=t});function St(i){"@swc/helpers - typeof";return i&&typeof Symbol!="undefined"&&i.constructor===Symbol?"symbol":typeof i}var Au=xy(function(){}),jx=vt(function(i,e){Au(),function(t,r){"use strict";typeof define=="function"&&define.amd?define(r):typeof e=="object"&&e.exports?e.exports=r():t.log=r()}(i,function(){"use strict";var t=function(){},r="undefined",s=(typeof window=="undefined"?"undefined":St(window))!==r&&St(window.navigator)!==r&&/Trident\/|MSIE /.test(window.navigator.userAgent),n=["trace","debug","info","warn","error"];function a(g,E){var T=g[E];if(typeof T.bind=="function")return T.bind(g);try{return Function.prototype.bind.call(T,g)}catch{return function(){return Function.prototype.apply.apply(T,[g,arguments])}}}function o(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function l(g){return g==="debug"&&(g="log"),(typeof console=="undefined"?"undefined":St(console))===r?!1:g==="trace"&&s?o:console[g]!==void 0?a(console,g):console.log!==void 0?a(console,"log"):t}function d(g,E){for(var T=0;T<n.length;T++){var y=n[T];this[y]=T<g?t:this.methodFactory(y,g,E)}this.log=this.debug}function u(g,E,T){return function(){(typeof console=="undefined"?"undefined":St(console))!==r&&(d.call(this,E,T),this[g].apply(this,arguments))}}function c(g,E,T){return l(g)||u.apply(this,arguments)}function h(g,E,T){var y=this,S;E=E==null?"WARN":E;var A="loglevel";typeof g=="string"?A+=":"+g:(typeof g=="undefined"?"undefined":St(g))==="symbol"&&(A=void 0);function L(k){var D=(n[k]||"silent").toUpperCase();if(!((typeof window=="undefined"?"undefined":St(window))===r||!A)){try{window.localStorage[A]=D;return}catch{}try{window.document.cookie=encodeURIComponent(A)+"="+D+";"}catch{}}}function x(){var k;if(!((typeof window=="undefined"?"undefined":St(window))===r||!A)){try{k=window.localStorage[A]}catch{}if((typeof k=="undefined"?"undefined":St(k))===r)try{var D=window.document.cookie,U=D.indexOf(encodeURIComponent(A)+"=");U!==-1&&(k=/^([^;]+)/.exec(D.slice(U))[1])}catch{}return y.levels[k]===void 0&&(k=void 0),k}}function w(){if(!((typeof window=="undefined"?"undefined":St(window))===r||!A)){try{window.localStorage.removeItem(A);return}catch{}try{window.document.cookie=encodeURIComponent(A)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}y.name=g,y.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},y.methodFactory=T||c,y.getLevel=function(){return S},y.setLevel=function(k,D){if(typeof k=="string"&&y.levels[k.toUpperCase()]!==void 0&&(k=y.levels[k.toUpperCase()]),typeof k=="number"&&k>=0&&k<=y.levels.SILENT){if(S=k,D!==!1&&L(k),d.call(y,k,g),(typeof console=="undefined"?"undefined":St(console))===r&&k<y.levels.SILENT)return"No console available for logging"}else throw"log.setLevel() called with invalid level: "+k},y.setDefaultLevel=function(k){E=k,x()||y.setLevel(k,!1)},y.resetLevel=function(){y.setLevel(E,!1),w()},y.enableAll=function(k){y.setLevel(y.levels.TRACE,k)},y.disableAll=function(k){y.setLevel(y.levels.SILENT,k)};var P=x();P==null&&(P=E),y.setLevel(P,!1)}var f=new h,m={};f.getLogger=function(g){if((typeof g=="undefined"?"undefined":St(g))!=="symbol"&&typeof g!="string"||g==="")throw new TypeError("You must supply a name when creating a logger.");var E=m[g];return E||(E=m[g]=new h(g,f.getLevel(),f.methodFactory)),E};var p=(typeof window=="undefined"?"undefined":St(window))!==r?window.log:void 0;return f.noConflict=function(){return(typeof window=="undefined"?"undefined":St(window))!==r&&window.log===f&&(window.log=p),f},f.getLoggers=function(){return m},f.default=f,f})});function Ts(i,e){return e!=null&&typeof Symbol!="undefined"&&e[Symbol.hasInstance]?!!e[Symbol.hasInstance](i):Ts(i,e)}var _s=xy(function(){_s()}),Xx=vt(function(i){"use strict";var e=Object.prototype.hasOwnProperty,t;function r(o){try{return decodeURIComponent(o.replace(/\+/g," "))}catch{return null}}function s(o){try{return encodeURIComponent(o)}catch{return null}}function n(o){for(var l=/([^=?#&]+)=?([^&]*)/g,d={},u;u=l.exec(o);){var c=r(u[1]),h=r(u[2]);c===null||h===null||c in d||(d[c]=h)}return d}function a(o,l){l=l||"";var d=[],u,c;typeof l!="string"&&(l="?");for(c in o)if(e.call(o,c)){if(u=o[c],!u&&(u===null||u===t||isNaN(u))&&(u=""),c=s(c),u=s(u),c===null||u===null)continue;d.push(c+"="+u)}return d.length?l+d.join("&"):""}i.stringify=a,i.parse=n}),Qx=vt(function(i,e){"use strict";(function(t){var r=!1;if(typeof define=="function"&&define.amd&&(define(t),r=!0),typeof i=="object"&&(e.exports=t(),r=!0),!r){var s=window.Cookies,n=window.Cookies=t();n.noConflict=function(){return window.Cookies=s,n}}})(function(){var t=function(){for(var s=0,n={};s<arguments.length;s++){var a=arguments[s];for(var o in a)n[o]=a[o]}return n};function r(s){function n(a,o,l){var d;if(typeof document!="undefined"){if(arguments.length>1){if(l=t({path:"/"},n.defaults,l),typeof l.expires=="number"){var u=new Date;u.setMilliseconds(u.getMilliseconds()+l.expires*864e5),l.expires=u}try{d=JSON.stringify(o),/^[\{\[]/.test(d)&&(o=d)}catch{}return s.write?o=s.write(o,a):o=encodeURIComponent(String(o)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),a=encodeURIComponent(String(a)),a=a.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent),a=a.replace(/[\(\)]/g,escape),document.cookie=[a,"=",o,l.expires?"; expires="+l.expires.toUTCString():"",l.path?"; path="+l.path:"",l.domain?"; domain="+l.domain:"",l.secure?"; secure":""].join("")}a||(d={});for(var c=document.cookie?document.cookie.split("; "):[],h=/(%[0-9A-Z]{2})+/g,f=0;f<c.length;f++){var m=c[f].split("="),p=m.slice(1).join("=");p.charAt(0)==='"'&&(p=p.slice(1,-1));try{var g=m[0].replace(h,decodeURIComponent);if(p=s.read?s.read(p,g):s(p,g)||p.replace(h,decodeURIComponent),this.json)try{p=JSON.parse(p)}catch{}if(a===g){d=p;break}a||(d[g]=p)}catch{}}return d}}return n.set=n,n.get=function(a){return n.call(n,a)},n.getJSON=function(){return n.apply({json:!0},[].slice.call(arguments))},n.defaults={},n.remove=function(a,o){n(a,"",t(o,{expires:-1}))},n.withConverter=r,n}return r(function(){})})}),Ly=vt(function(i,e){var t=Array.prototype.slice;e.exports=r;function r(s,n){for(("length"in s)||(s=[s]),s=t.call(s);s.length;){var a=s.shift(),o=n(a);if(o)return o;a.childNodes&&a.childNodes.length&&(s=t.call(a.childNodes).concat(s))}}}),Zx=vt(function(i,e){_s(),e.exports=t;function t(r,s){if(!Ts(this,t))return new t(r,s);this.data=r,this.nodeValue=r,this.length=r.length,this.ownerDocument=s||null}t.prototype.nodeType=8,t.prototype.nodeName="#comment",t.prototype.toString=function(){return"[object Comment]"}}),Jx=vt(function(i,e){_s(),e.exports=t;function t(r,s){if(!Ts(this,t))return new t(r);this.data=r||"",this.length=this.data.length,this.ownerDocument=s||null}t.prototype.type="DOMTextNode",t.prototype.nodeType=3,t.prototype.nodeName="#text",t.prototype.toString=function(){return this.data},t.prototype.replaceData=function(r,s,n){var a=this.data,o=a.substring(0,r),l=a.substring(r+s,a.length);this.data=o+n+l,this.length=this.data.length}}),ky=vt(function(i,e){e.exports=t;function t(r){var s=this,n=r.type;r.target||(r.target=s),s.listeners||(s.listeners={});var a=s.listeners[n];if(a)return a.forEach(function(o){r.currentTarget=s,typeof o=="function"?o(r):o.handleEvent(r)});s.parentNode&&s.parentNode.dispatchEvent(r)}}),Iy=vt(function(i,e){e.exports=t;function t(r,s){var n=this;n.listeners||(n.listeners={}),n.listeners[r]||(n.listeners[r]=[]),n.listeners[r].indexOf(s)===-1&&n.listeners[r].push(s)}}),Ry=vt(function(i,e){e.exports=t;function t(r,s){var n=this;if(n.listeners&&n.listeners[r]){var a=n.listeners[r],o=a.indexOf(s);o!==-1&&a.splice(o,1)}}}),eL=vt(function(i,e){Au(),e.exports=r;var t=["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"];function r(h){switch(h.nodeType){case 3:return u(h.data);case 8:return"<!--"+h.data+"-->";default:return s(h)}}function s(h){var f=[],m=h.tagName;return h.namespaceURI==="http://www.w3.org/1999/xhtml"&&(m=m.toLowerCase()),f.push("<"+m+d(h)+o(h)),t.indexOf(m)>-1?f.push(" />"):(f.push(">"),h.childNodes.length?f.push.apply(f,h.childNodes.map(r)):h.textContent||h.innerText?f.push(u(h.textContent||h.innerText)):h.innerHTML&&f.push(h.innerHTML),f.push("</"+m+">")),f.join("")}function n(h,f){var m=St(h[f]);return f==="style"&&Object.keys(h.style).length>0?!0:h.hasOwnProperty(f)&&(m==="string"||m==="boolean"||m==="number")&&f!=="nodeName"&&f!=="className"&&f!=="tagName"&&f!=="textContent"&&f!=="innerText"&&f!=="namespaceURI"&&f!=="innerHTML"}function a(h){if(typeof h=="string")return h;var f="";return Object.keys(h).forEach(function(m){var p=h[m];m=m.replace(/[A-Z]/g,function(g){return"-"+g.toLowerCase()}),f+=m+":"+p+";"}),f}function o(h){var f=h.dataset,m=[];for(var p in f)m.push({name:"data-"+p,value:f[p]});return m.length?l(m):""}function l(h){var f=[];return h.forEach(function(m){var p=m.name,g=m.value;p==="style"&&(g=a(g)),f.push(p+'="'+c(g)+'"')}),f.length?" "+f.join(" "):""}function d(h){var f=[];for(var m in h)n(h,m)&&f.push({name:m,value:h[m]});for(var p in h._attributes)for(var g in h._attributes[p]){var E=h._attributes[p][g],T=(E.prefix?E.prefix+":":"")+g;f.push({name:T,value:E.value})}return h.className&&f.push({name:"class",value:h.className}),f.length?l(f):""}function u(h){var f="";return typeof h=="string"?f=h:h&&(f=h.toString()),f.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function c(h){return u(h).replace(/"/g,"&quot;")}}),wy=vt(function(i,e){_s();var t=Ly(),r=ky(),s=Iy(),n=Ry(),a=eL(),o="http://www.w3.org/1999/xhtml";e.exports=l;function l(d,u,c){if(!Ts(this,l))return new l(d);var h=c===void 0?o:c||null;this.tagName=h===o?String(d).toUpperCase():d,this.nodeName=this.tagName,this.className="",this.dataset={},this.childNodes=[],this.parentNode=null,this.style={},this.ownerDocument=u||null,this.namespaceURI=h,this._attributes={},this.tagName==="INPUT"&&(this.type="text")}l.prototype.type="DOMElement",l.prototype.nodeType=1,l.prototype.appendChild=function(d){return d.parentNode&&d.parentNode.removeChild(d),this.childNodes.push(d),d.parentNode=this,d},l.prototype.replaceChild=function(d,u){d.parentNode&&d.parentNode.removeChild(d);var c=this.childNodes.indexOf(u);return u.parentNode=null,this.childNodes[c]=d,d.parentNode=this,u},l.prototype.removeChild=function(d){var u=this.childNodes.indexOf(d);return this.childNodes.splice(u,1),d.parentNode=null,d},l.prototype.insertBefore=function(d,u){d.parentNode&&d.parentNode.removeChild(d);var c=u==null?-1:this.childNodes.indexOf(u);return c>-1?this.childNodes.splice(c,0,d):this.childNodes.push(d),d.parentNode=this,d},l.prototype.setAttributeNS=function(d,u,c){var h=null,f=u,m=u.indexOf(":");if(m>-1&&(h=u.substr(0,m),f=u.substr(m+1)),this.tagName==="INPUT"&&u==="type")this.type=c;else{var p=this._attributes[d]||(this._attributes[d]={});p[f]={value:c,prefix:h}}},l.prototype.getAttributeNS=function(d,u){var c=this._attributes[d],h=c&&c[u]&&c[u].value;return this.tagName==="INPUT"&&u==="type"?this.type:typeof h!="string"?null:h},l.prototype.removeAttributeNS=function(d,u){var c=this._attributes[d];c&&delete c[u]},l.prototype.hasAttributeNS=function(d,u){var c=this._attributes[d];return!!c&&u in c},l.prototype.setAttribute=function(d,u){return this.setAttributeNS(null,d,u)},l.prototype.getAttribute=function(d){return this.getAttributeNS(null,d)},l.prototype.removeAttribute=function(d){return this.removeAttributeNS(null,d)},l.prototype.hasAttribute=function(d){return this.hasAttributeNS(null,d)},l.prototype.removeEventListener=n,l.prototype.addEventListener=s,l.prototype.dispatchEvent=r,l.prototype.focus=function(){},l.prototype.toString=function(){return a(this)},l.prototype.getElementsByClassName=function(d){var u=d.split(" "),c=[];return t(this,function(h){if(h.nodeType===1){var f=h.className||"",m=f.split(" ");u.every(function(p){return m.indexOf(p)!==-1})&&c.push(h)}}),c},l.prototype.getElementsByTagName=function(d){d=d.toLowerCase();var u=[];return t(this.childNodes,function(c){c.nodeType===1&&(d==="*"||c.tagName.toLowerCase()===d)&&u.push(c)}),u},l.prototype.contains=function(d){return t(this,function(u){return d===u})||!1}}),tL=vt(function(i,e){_s();var t=wy();e.exports=r;function r(s){if(!Ts(this,r))return new r;this.childNodes=[],this.parentNode=null,this.ownerDocument=s||null}r.prototype.type="DocumentFragment",r.prototype.nodeType=11,r.prototype.nodeName="#document-fragment",r.prototype.appendChild=t.prototype.appendChild,r.prototype.replaceChild=t.prototype.replaceChild,r.prototype.removeChild=t.prototype.removeChild,r.prototype.toString=function(){return this.childNodes.map(function(s){return String(s)}).join("")}}),iL=vt(function(i,e){e.exports=t;function t(r){}t.prototype.initEvent=function(r,s,n){this.type=r,this.bubbles=s,this.cancelable=n},t.prototype.preventDefault=function(){}}),rL=vt(function(i,e){_s();var t=Ly(),r=Zx(),s=Jx(),n=wy(),a=tL(),o=iL(),l=ky(),d=Iy(),u=Ry();e.exports=c;function c(){if(!Ts(this,c))return new c;this.head=this.createElement("head"),this.body=this.createElement("body"),this.documentElement=this.createElement("html"),this.documentElement.appendChild(this.head),this.documentElement.appendChild(this.body),this.childNodes=[this.documentElement],this.nodeType=9}var h=c.prototype;h.createTextNode=function(f){return new s(f,this)},h.createElementNS=function(f,m){var p=f===null?null:String(f);return new n(m,this,p)},h.createElement=function(f){return new n(f,this)},h.createDocumentFragment=function(){return new a(this)},h.createEvent=function(f){return new o(f)},h.createComment=function(f){return new r(f,this)},h.getElementById=function(f){f=String(f);var m=t(this.childNodes,function(p){if(String(p.id)===f)return p});return m||null},h.getElementsByClassName=n.prototype.getElementsByClassName,h.getElementsByTagName=n.prototype.getElementsByTagName,h.contains=n.prototype.contains,h.removeEventListener=u,h.addEventListener=d,h.dispatchEvent=l}),sL=vt(function(i,e){var t=rL();e.exports=new t}),nL=vt(function(i,e){var t=typeof global!="undefined"?global:typeof window!="undefined"?window:{},r=sL(),s;typeof document!="undefined"?s=document:(s=t["__GLOBAL_DOCUMENT_CACHE@4"],s||(s=t["__GLOBAL_DOCUMENT_CACHE@4"]=r)),e.exports=s});function aL(i){if(Array.isArray(i))return i}function oL(i,e){var t=i==null?null:typeof Symbol!="undefined"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var r=[],s=!0,n=!1,a,o;try{for(t=t.call(i);!(s=(a=t.next()).done)&&(r.push(a.value),!(e&&r.length===e));s=!0);}catch(l){n=!0,o=l}finally{try{!s&&t.return!=null&&t.return()}finally{if(n)throw o}}return r}}function lL(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1565
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function gy(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,r=new Array(e);t<e;t++)r[t]=i[t];return r}function dL(i,e){if(i){if(typeof i=="string")return gy(i,e);var t=Object.prototype.toString.call(i).slice(8,-1);if(t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set")return Array.from(t);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return gy(i,e)}}function ys(i,e){return aL(i)||oL(i,e)||dL(i,e)||lL()}var Za=Dt(Vi()),eo=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(i){var e=Math.random()*16|0,t=i==="x"?e:e&3|8;return t.toString(16)})},Cy=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},Es=function(i){if(i&&typeof i.nodeName!="undefined")return i.muxId||(i.muxId=Cy()),i.muxId;var e;try{e=document.querySelector(i)}catch{}return e&&!e.muxId&&(e.muxId=i),(e==null?void 0:e.muxId)||i},op=function(i){var e;i&&typeof i.nodeName!="undefined"?(e=i,i=Es(e)):e=document.querySelector(i);var t=e&&e.nodeName?e.nodeName.toLowerCase():"";return[e,i,t]},to=Dt(jx()),uL=to.default.methodFactory;to.default.methodFactory=function(i,e,t){var r=uL(i,e,t);return function(){for(var s=["[mux]"],n=0;n<arguments.length;n++)s.push(arguments[n]);r.apply(void 0,s)}};to.default.setLevel(to.default.getLevel());var We=to.default,ip=Dt(Vi());function lp(){var i=ip.default.doNotTrack||ip.default.navigator&&ip.default.navigator.doNotTrack;return i==="1"}var cL=Dt(Vi()),hL={now:function(){var i=cL.default.performance,e=i&&i.timing,t=e&&e.navigationStart,r=typeof t=="number"&&typeof i.now=="function"?t+i.now():Date.now();return Math.round(r)}},tt=hL;function re(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}_s();function ut(i,e){if(!Ts(i,e))throw new TypeError("Cannot call a class as a function")}function vy(i,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(i,r.key,r)}}function qi(i,e,t){return e&&vy(i.prototype,e),t&&vy(i,t),i}function H(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function dp(i,e){return dp=Object.setPrototypeOf||function(t,r){return t.__proto__=r,t},dp(i,e)}function fL(i,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),e&&dp(i,e)}function bu(i){return bu=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},bu(i)}function mL(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}Au();function pL(i,e){return e&&(St(e)==="object"||typeof e=="function")?e:re(i)}function gL(i){var e=mL();return function(){var t=bu(i),r;if(e){var s=bu(this).constructor;r=Reflect.construct(t,arguments,s)}else r=t.apply(this,arguments);return pL(this,r)}}var vi=function(i){return io(i)[0]},io=function(i){if(typeof i!="string"||i==="")return["localhost"];var e=/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/,t=i.match(e)||[],r=t[4],s;return r&&(s=(r.match(/[^\.]+\.[^\.]+$/)||[])[0]),[r,s]},rp=Dt(Vi()),vL={exists:function(){var i=rp.default.performance,e=i&&i.timing;return e!==void 0},domContentLoadedEventEnd:function(){var i=rp.default.performance,e=i&&i.timing;return e&&e.domContentLoadedEventEnd},navigationStart:function(){var i=rp.default.performance,e=i&&i.timing;return e&&e.navigationStart}},yu=vL;function Ze(i,e,t){t=t===void 0?1:t,i[e]=i[e]||0,i[e]+=t}function Tu(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{},r=Object.keys(t);typeof Object.getOwnPropertySymbols=="function"&&(r=r.concat(Object.getOwnPropertySymbols(t).filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable}))),r.forEach(function(s){H(i,s,t[s])})}return i}function EL(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(i);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,r)}return t}function cp(i,e){return e=e!=null?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(e)):EL(Object(e)).forEach(function(t){Object.defineProperty(i,t,Object.getOwnPropertyDescriptor(e,t))}),i}var bL=["x-cdn","content-type"],Dy=["x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"],yL=bL.concat(Dy);function hp(i){i=i||"";var e={},t=i.trim().split(/[\r\n]+/);return t.forEach(function(r){if(r){var s=r.split(": "),n=s.shift();n&&(yL.indexOf(n.toLowerCase())>=0||n.toLowerCase().indexOf("x-litix-")===0)&&(e[n]=s.join(": "))}}),e}function _u(i){if(i){var e=Dy.find(function(t){return i[t]!==void 0});return e?i[e]:void 0}}var TL=function(i){var e={};for(var t in i){var r=i[t],s=r["DATA-ID"].search("io.litix.data.");if(s!==-1){var n=r["DATA-ID"].replace("io.litix.data.","");e[n]=r.VALUE}}return e},My=TL,Eu=function(i){if(!i)return{};var e=yu.navigationStart(),t=i.loading,r=t?t.start:i.trequest,s=t?t.first:i.tfirst,n=t?t.end:i.tload;return{bytesLoaded:i.total,requestStart:Math.round(e+r),responseStart:Math.round(e+s),responseEnd:Math.round(e+n)}},Xa=function(i){if(!(!i||typeof i.getAllResponseHeaders!="function"))return hp(i.getAllResponseHeaders())},_L=function(i,e,t){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},s=arguments.length>4?arguments[4]:void 0,n=i.log,a=i.utils.secondsToMs,o=function(E){var T=parseInt(s.version),y;return T===1&&E.programDateTime!==null&&(y=E.programDateTime),T===0&&E.pdt!==null&&(y=E.pdt),y};if(!yu.exists()){n.warn("performance timing not supported. Not tracking HLS.js.");return}var l=function(E,T){return i.emit(e,E,T)},d=function(E,T){var y=T.levels,S=T.audioTracks,A=T.url,L=T.stats,x=T.networkDetails,w=T.sessionData,P={},k={};y.forEach(function(K,se){P[se]={width:K.width,height:K.height,bitrate:K.bitrate,attrs:K.attrs}}),S.forEach(function(K,se){k[se]={name:K.name,language:K.lang,bitrate:K.bitrate}});var D=Eu(L),U=D.bytesLoaded,F=D.requestStart,z=D.responseStart,j=D.responseEnd;l("requestcompleted",cp(Tu({},My(w)),{request_event_type:E,request_bytes_loaded:U,request_start:F,request_response_start:z,request_response_end:j,request_type:"manifest",request_hostname:vi(A),request_response_headers:Xa(x),request_rendition_lists:{media:P,audio:k,video:{}}}))};t.on(s.Events.MANIFEST_LOADED,d);var u=function(E,T){var y=T.details,S=T.level,A=T.networkDetails,L=T.stats,x=Eu(L),w=x.bytesLoaded,P=x.requestStart,k=x.responseStart,D=x.responseEnd,U=y.fragments[y.fragments.length-1],F=o(U)+a(U.duration);l("requestcompleted",{request_event_type:E,request_bytes_loaded:w,request_start:P,request_response_start:k,request_response_end:D,request_current_level:S,request_type:"manifest",request_hostname:vi(y.url),request_response_headers:Xa(A),video_holdback:y.holdBack&&a(y.holdBack),video_part_holdback:y.partHoldBack&&a(y.partHoldBack),video_part_target_duration:y.partTarget&&a(y.partTarget),video_target_duration:y.targetduration&&a(y.targetduration),video_source_is_live:y.live,player_manifest_newest_program_time:isNaN(F)?void 0:F})};t.on(s.Events.LEVEL_LOADED,u);var c=function(E,T){var y=T.details,S=T.networkDetails,A=T.stats,L=Eu(A),x=L.bytesLoaded,w=L.requestStart,P=L.responseStart,k=L.responseEnd;l("requestcompleted",{request_event_type:E,request_bytes_loaded:x,request_start:w,request_response_start:P,request_response_end:k,request_type:"manifest",request_hostname:vi(y.url),request_response_headers:Xa(S)})};t.on(s.Events.AUDIO_TRACK_LOADED,c);var h=function(E,T){var y=T.stats,S=T.networkDetails,A=T.frag;y=y||A.stats;var L=Eu(y),x=L.bytesLoaded,w=L.requestStart,P=L.responseStart,k=L.responseEnd,D=S?Xa(S):void 0,U={request_event_type:E,request_bytes_loaded:x,request_start:w,request_response_start:P,request_response_end:k,request_hostname:S?vi(S.responseURL):void 0,request_id:D?_u(D):void 0,request_response_headers:D,request_media_duration:A.duration,request_url:S==null?void 0:S.responseURL};A.type==="main"?(U.request_type="media",U.request_current_level=A.level,U.request_video_width=(t.levels[A.level]||{}).width,U.request_video_height=(t.levels[A.level]||{}).height,U.request_labeled_bitrate=(t.levels[A.level]||{}).bitrate):U.request_type=A.type,l("requestcompleted",U)};t.on(s.Events.FRAG_LOADED,h);var f=function(E,T){var y=T.frag,S=y.start,A=o(y),L={currentFragmentPDT:A,currentFragmentStart:a(S)};l("fragmentchange",L)};t.on(s.Events.FRAG_CHANGED,f);var m=function(E,T){var y=T.type,S=T.details,A=T.response,L=T.fatal,x=T.frag,w=T.networkDetails,P=(x==null?void 0:x.url)||T.url||"",k=w?Xa(w):void 0;if((S===s.ErrorDetails.MANIFEST_LOAD_ERROR||S===s.ErrorDetails.MANIFEST_LOAD_TIMEOUT||S===s.ErrorDetails.FRAG_LOAD_ERROR||S===s.ErrorDetails.FRAG_LOAD_TIMEOUT||S===s.ErrorDetails.LEVEL_LOAD_ERROR||S===s.ErrorDetails.LEVEL_LOAD_TIMEOUT||S===s.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||S===s.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT||S===s.ErrorDetails.SUBTITLE_LOAD_ERROR||S===s.ErrorDetails.SUBTITLE_LOAD_TIMEOUT||S===s.ErrorDetails.KEY_LOAD_ERROR||S===s.ErrorDetails.KEY_LOAD_TIMEOUT)&&l("requestfailed",{request_error:S,request_url:P,request_hostname:vi(P),request_id:k?_u(k):void 0,request_type:S===s.ErrorDetails.FRAG_LOAD_ERROR||S===s.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":S===s.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||S===s.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT?"audio":S===s.ErrorDetails.SUBTITLE_LOAD_ERROR||S===s.ErrorDetails.SUBTITLE_LOAD_TIMEOUT?"subtitle":S===s.ErrorDetails.KEY_LOAD_ERROR||S===s.ErrorDetails.KEY_LOAD_TIMEOUT?"encryption":"manifest",request_error_code:A==null?void 0:A.code,request_error_text:A==null?void 0:A.text}),L){var D,U="".concat(P?"url: ".concat(P,`
1566
+ `):"")+"".concat(A&&(A.code||A.text)?"response: ".concat(A.code,", ").concat(A.text,`
1567
1567
  `):"")+"".concat(T.reason?"failure reason: ".concat(T.reason,`
1568
1568
  `):"")+"".concat(T.level?"level: ".concat(T.level,`
1569
1569
  `):"")+"".concat(T.parent?"parent stream controller: ".concat(T.parent,`
@@ -1571,38 +1571,38 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1571
1571
  `):"")+"".concat(T.error?"error: ".concat(T.error,`
1572
1572
  `):"")+"".concat(T.event?"event: ".concat(T.event,`
1573
1573
  `):"")+"".concat(T.err?"error message: ".concat((D=T.err)===null||D===void 0?void 0:D.message,`
1574
- `):"");l("error",{player_error_code:y,player_error_message:S,player_error_context:U})}};t.on(s.Events.ERROR,m);var p=function(E,T){var y=T.frag,S=y&&y._url||"";l("requestcanceled",{request_event_type:E,request_url:S,request_type:"media",request_hostname:vi(S)})};t.on(s.Events.FRAG_LOAD_EMERGENCY_ABORTED,p);var g=function(E,T){var y=T.level,S=t.levels[y];if(S&&S.attrs&&S.attrs.BANDWIDTH){var _=S.attrs.BANDWIDTH,L,x=parseFloat(S.attrs["FRAME-RATE"]);isNaN(x)||(L=x),_?l("renditionchange",{video_source_fps:L,video_source_bitrate:_,video_source_width:S.width,video_source_height:S.height,video_source_rendition_name:S.name,video_source_codec:S==null?void 0:S.videoCodec}):n.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};t.on(s.Events.LEVEL_SWITCHED,g),t._stopMuxMonitor=function(){t.off(s.Events.MANIFEST_LOADED,d),t.off(s.Events.LEVEL_LOADED,u),t.off(s.Events.AUDIO_TRACK_LOADED,c),t.off(s.Events.FRAG_LOADED,h),t.off(s.Events.FRAG_CHANGED,f),t.off(s.Events.ERROR,m),t.off(s.Events.FRAG_LOAD_EMERGENCY_ABORTED,p),t.off(s.Events.LEVEL_SWITCHED,g),t.off(s.Events.DESTROYING,t._stopMuxMonitor),delete t._stopMuxMonitor},t.on(s.Events.DESTROYING,t._stopMuxMonitor)},xL=function(i){i&&typeof i._stopMuxMonitor=="function"&&i._stopMuxMonitor()},gy=function(i,e){if(!i||!i.requestEndDate)return{};var t=vi(i.url),r=i.url,s=i.bytesLoaded,n=new Date(i.requestStartDate).getTime(),a=new Date(i.firstByteDate).getTime(),o=new Date(i.requestEndDate).getTime(),l=isNaN(i.duration)?0:i.duration,d=typeof e.getMetricsFor=="function"?e.getMetricsFor(i.mediaType).HttpList:e.getDashMetrics().getHttpRequests(i.mediaType),u;d.length>0&&(u=lp(d[d.length-1]._responseHeaders||""));var c=u?_u(u):void 0;return{requestStart:n,requestResponseStart:a,requestResponseEnd:o,requestBytesLoaded:s,requestResponseHeaders:u,requestMediaDuration:l,requestHostname:t,requestUrl:r,requestId:c}},LL=function(i,e){var t=e.getQualityFor(i),r=e.getCurrentTrackFor(i).bitrateList;return r?{currentLevel:t,renditionWidth:r[t].width||null,renditionHeight:r[t].height||null,renditionBitrate:r[t].bandwidth}:{}},kL=function(i){var e;return(e=i.match(/.*codecs\*?="(.*)"/))===null||e===void 0?void 0:e[1]},IL=function(i){try{var e,t,r=(t=i.getVersion)===null||t===void 0||(e=t.call(i))===null||e===void 0?void 0:e.split(".").map(function(s){return parseInt(s)})[0];return r}catch{return!1}},RL=function(i,e,t){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},s=i.log;if(!t||!t.on){s.warn("Invalid dash.js player reference. Monitoring blocked.");return}var n=IL(t),a=function(y,S){return i.emit(e,y,S)},o=function(y){var S=y.type,_=y.data,L=(_||{}).url;a("requestcompleted",{request_event_type:S,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:vi(L),request_url:L})};t.on("manifestLoaded",o);var l={},d=function(y){if(typeof y.getRequests!="function")return null;var S=y.getRequests({state:"executed"});return S.length===0?null:S[S.length-1]},u=function(y){var S=y.type,_=y.fragmentModel,L=y.chunk,x=d(_);c({type:S,request:x,chunk:L})},c=function(y){var S=y.type,_=y.chunk,L=y.request,x=(_||{}).mediaInfo,w=x||{},M=w.type,k=w.bitrateList;k=k||[];var D={};k.forEach(function(oe,Q){D[Q]={},D[Q].width=oe.width,D[Q].height=oe.height,D[Q].bitrate=oe.bandwidth,D[Q].attrs={}}),M==="video"?l.video=D:M==="audio"?l.audio=D:l.media=D;var U=gy(L,t),B=U.requestStart,X=U.requestResponseStart,z=U.requestResponseEnd,V=U.requestResponseHeaders,se=U.requestMediaDuration,ae=U.requestHostname,W=U.requestUrl,G=U.requestId;a("requestcompleted",{request_event_type:S,request_start:B,request_response_start:X,request_response_end:z,request_bytes_loaded:-1,request_type:M+"_init",request_response_headers:V,request_hostname:ae,request_id:G,request_url:W,request_media_duration:se,request_rendition_lists:l})};n>=4?t.on("initFragmentLoaded",c):t.on("initFragmentLoaded",u);var h=function(y){var S=y.type,_=y.fragmentModel,L=y.chunk,x=d(_);f({type:S,request:x,chunk:L})},f=function(y){var S=y.type,_=y.chunk,L=y.request,x=_||{},w=x.mediaInfo,M=x.start,k=w||{},D=k.type,U=gy(L,t),B=U.requestStart,X=U.requestResponseStart,z=U.requestResponseEnd,V=U.requestBytesLoaded,se=U.requestResponseHeaders,ae=U.requestMediaDuration,W=U.requestHostname,G=U.requestUrl,oe=U.requestId,Q=LL(D,t),me=Q.currentLevel,Pe=Q.renditionWidth,Be=Q.renditionHeight,Ke=Q.renditionBitrate;a("requestcompleted",{request_event_type:S,request_start:B,request_response_start:X,request_response_end:z,request_bytes_loaded:V,request_type:D,request_response_headers:se,request_hostname:W,request_id:oe,request_url:G,request_media_start_time:M,request_media_duration:ae,request_current_level:me,request_labeled_bitrate:Ke,request_video_width:Pe,request_video_height:Be})};n>=4?t.on("mediaFragmentLoaded",f):t.on("mediaFragmentLoaded",h);var m={video:void 0,audio:void 0,totalBitrate:void 0},p=function(){if(m.video&&typeof m.video.bitrate=="number"){if(!(m.video.width&&m.video.height)){s.warn("have bitrate info for video but missing width/height");return}var y=m.video.bitrate;if(m.audio&&typeof m.audio.bitrate=="number"&&(y+=m.audio.bitrate),y!==m.totalBitrate)return m.totalBitrate=y,{video_source_bitrate:y,video_source_height:m.video.height,video_source_width:m.video.width,video_source_codec:kL(m.video.codec)}}},g=function(y,S,_){if(typeof y.newQuality!="number"){s.warn("missing evt.newQuality in qualityChangeRendered event",y);return}var L=y.mediaType;if(L==="audio"||L==="video"){var x=t.getBitrateInfoListFor(L).find(function(M){var k=M.qualityIndex;return k===y.newQuality});if(!(x&&typeof x.bitrate=="number")){s.warn("missing bitrate info for ".concat(L));return}m[L]=op(Tu({},x),{codec:t.getCurrentTrackFor(L).codec});var w=p();w&&a("renditionchange",w)}};t.on("qualityChangeRendered",g);var E=function(y){var S=y.request,_=y.mediaType;S=S||{},a("requestcanceled",{request_event_type:S.type+"_"+S.action,request_url:S.url,request_type:_,request_hostname:vi(S.url)})};t.on("fragmentLoadingAbandoned",E);var T=function(y){var S=y.error,_,L,x=(S==null||(_=S.data)===null||_===void 0?void 0:_.request)||{},w=(S==null||(L=S.data)===null||L===void 0?void 0:L.response)||{};(S==null?void 0:S.code)===27&&a("requestfailed",{request_error:x.type+"_"+x.action,request_url:x.url,request_hostname:vi(x.url),request_type:x.mediaType,request_error_code:w.status,request_error_text:w.statusText});var M="".concat(x!=null&&x.url?"url: ".concat(x.url,`
1574
+ `):"");l("error",{player_error_code:y,player_error_message:S,player_error_context:U})}};t.on(s.Events.ERROR,m);var p=function(E,T){var y=T.frag,S=y&&y._url||"";l("requestcanceled",{request_event_type:E,request_url:S,request_type:"media",request_hostname:vi(S)})};t.on(s.Events.FRAG_LOAD_EMERGENCY_ABORTED,p);var g=function(E,T){var y=T.level,S=t.levels[y];if(S&&S.attrs&&S.attrs.BANDWIDTH){var A=S.attrs.BANDWIDTH,L,x=parseFloat(S.attrs["FRAME-RATE"]);isNaN(x)||(L=x),A?l("renditionchange",{video_source_fps:L,video_source_bitrate:A,video_source_width:S.width,video_source_height:S.height,video_source_rendition_name:S.name,video_source_codec:S==null?void 0:S.videoCodec}):n.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};t.on(s.Events.LEVEL_SWITCHED,g),t._stopMuxMonitor=function(){t.off(s.Events.MANIFEST_LOADED,d),t.off(s.Events.LEVEL_LOADED,u),t.off(s.Events.AUDIO_TRACK_LOADED,c),t.off(s.Events.FRAG_LOADED,h),t.off(s.Events.FRAG_CHANGED,f),t.off(s.Events.ERROR,m),t.off(s.Events.FRAG_LOAD_EMERGENCY_ABORTED,p),t.off(s.Events.LEVEL_SWITCHED,g),t.off(s.Events.DESTROYING,t._stopMuxMonitor),delete t._stopMuxMonitor},t.on(s.Events.DESTROYING,t._stopMuxMonitor)},AL=function(i){i&&typeof i._stopMuxMonitor=="function"&&i._stopMuxMonitor()},Ey=function(i,e){if(!i||!i.requestEndDate)return{};var t=vi(i.url),r=i.url,s=i.bytesLoaded,n=new Date(i.requestStartDate).getTime(),a=new Date(i.firstByteDate).getTime(),o=new Date(i.requestEndDate).getTime(),l=isNaN(i.duration)?0:i.duration,d=typeof e.getMetricsFor=="function"?e.getMetricsFor(i.mediaType).HttpList:e.getDashMetrics().getHttpRequests(i.mediaType),u;d.length>0&&(u=hp(d[d.length-1]._responseHeaders||""));var c=u?_u(u):void 0;return{requestStart:n,requestResponseStart:a,requestResponseEnd:o,requestBytesLoaded:s,requestResponseHeaders:u,requestMediaDuration:l,requestHostname:t,requestUrl:r,requestId:c}},SL=function(i,e){var t=e.getQualityFor(i),r=e.getCurrentTrackFor(i).bitrateList;return r?{currentLevel:t,renditionWidth:r[t].width||null,renditionHeight:r[t].height||null,renditionBitrate:r[t].bandwidth}:{}},xL=function(i){var e;return(e=i.match(/.*codecs\*?="(.*)"/))===null||e===void 0?void 0:e[1]},LL=function(i){try{var e,t,r=(t=i.getVersion)===null||t===void 0||(e=t.call(i))===null||e===void 0?void 0:e.split(".").map(function(s){return parseInt(s)})[0];return r}catch{return!1}},kL=function(i,e,t){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},s=i.log;if(!t||!t.on){s.warn("Invalid dash.js player reference. Monitoring blocked.");return}var n=LL(t),a=function(y,S){return i.emit(e,y,S)},o=function(y){var S=y.type,A=y.data,L=(A||{}).url;a("requestcompleted",{request_event_type:S,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:vi(L),request_url:L})};t.on("manifestLoaded",o);var l={},d=function(y){if(typeof y.getRequests!="function")return null;var S=y.getRequests({state:"executed"});return S.length===0?null:S[S.length-1]},u=function(y){var S=y.type,A=y.fragmentModel,L=y.chunk,x=d(A);c({type:S,request:x,chunk:L})},c=function(y){var S=y.type,A=y.chunk,L=y.request,x=(A||{}).mediaInfo,w=x||{},P=w.type,k=w.bitrateList;k=k||[];var D={};k.forEach(function(ne,Q){D[Q]={},D[Q].width=ne.width,D[Q].height=ne.height,D[Q].bitrate=ne.bandwidth,D[Q].attrs={}}),P==="video"?l.video=D:P==="audio"?l.audio=D:l.media=D;var U=Ey(L,t),F=U.requestStart,z=U.requestResponseStart,j=U.requestResponseEnd,K=U.requestResponseHeaders,se=U.requestMediaDuration,oe=U.requestHostname,W=U.requestUrl,G=U.requestId;a("requestcompleted",{request_event_type:S,request_start:F,request_response_start:z,request_response_end:j,request_bytes_loaded:-1,request_type:P+"_init",request_response_headers:K,request_hostname:oe,request_id:G,request_url:W,request_media_duration:se,request_rendition_lists:l})};n>=4?t.on("initFragmentLoaded",c):t.on("initFragmentLoaded",u);var h=function(y){var S=y.type,A=y.fragmentModel,L=y.chunk,x=d(A);f({type:S,request:x,chunk:L})},f=function(y){var S=y.type,A=y.chunk,L=y.request,x=A||{},w=x.mediaInfo,P=x.start,k=w||{},D=k.type,U=Ey(L,t),F=U.requestStart,z=U.requestResponseStart,j=U.requestResponseEnd,K=U.requestBytesLoaded,se=U.requestResponseHeaders,oe=U.requestMediaDuration,W=U.requestHostname,G=U.requestUrl,ne=U.requestId,Q=SL(D,t),me=Q.currentLevel,Pe=Q.renditionWidth,$e=Q.renditionHeight,qe=Q.renditionBitrate;a("requestcompleted",{request_event_type:S,request_start:F,request_response_start:z,request_response_end:j,request_bytes_loaded:K,request_type:D,request_response_headers:se,request_hostname:W,request_id:ne,request_url:G,request_media_start_time:P,request_media_duration:oe,request_current_level:me,request_labeled_bitrate:qe,request_video_width:Pe,request_video_height:$e})};n>=4?t.on("mediaFragmentLoaded",f):t.on("mediaFragmentLoaded",h);var m={video:void 0,audio:void 0,totalBitrate:void 0},p=function(){if(m.video&&typeof m.video.bitrate=="number"){if(!(m.video.width&&m.video.height)){s.warn("have bitrate info for video but missing width/height");return}var y=m.video.bitrate;if(m.audio&&typeof m.audio.bitrate=="number"&&(y+=m.audio.bitrate),y!==m.totalBitrate)return m.totalBitrate=y,{video_source_bitrate:y,video_source_height:m.video.height,video_source_width:m.video.width,video_source_codec:xL(m.video.codec)}}},g=function(y,S,A){if(typeof y.newQuality!="number"){s.warn("missing evt.newQuality in qualityChangeRendered event",y);return}var L=y.mediaType;if(L==="audio"||L==="video"){var x=t.getBitrateInfoListFor(L).find(function(P){var k=P.qualityIndex;return k===y.newQuality});if(!(x&&typeof x.bitrate=="number")){s.warn("missing bitrate info for ".concat(L));return}m[L]=cp(Tu({},x),{codec:t.getCurrentTrackFor(L).codec});var w=p();w&&a("renditionchange",w)}};t.on("qualityChangeRendered",g);var E=function(y){var S=y.request,A=y.mediaType;S=S||{},a("requestcanceled",{request_event_type:S.type+"_"+S.action,request_url:S.url,request_type:A,request_hostname:vi(S.url)})};t.on("fragmentLoadingAbandoned",E);var T=function(y){var S=y.error,A,L,x=(S==null||(A=S.data)===null||A===void 0?void 0:A.request)||{},w=(S==null||(L=S.data)===null||L===void 0?void 0:L.response)||{};(S==null?void 0:S.code)===27&&a("requestfailed",{request_error:x.type+"_"+x.action,request_url:x.url,request_hostname:vi(x.url),request_type:x.mediaType,request_error_code:w.status,request_error_text:w.statusText});var P="".concat(x!=null&&x.url?"url: ".concat(x.url,`
1575
1575
  `):"")+"".concat(w!=null&&w.status||w!=null&&w.statusText?"response: ".concat(w==null?void 0:w.status,", ").concat(w==null?void 0:w.statusText,`
1576
- `):"");a("error",{player_error_code:S==null?void 0:S.code,player_error_message:S==null?void 0:S.message,player_error_context:M})};t.on("error",T),t._stopMuxMonitor=function(){t.off("manifestLoaded",o),t.off("initFragmentLoaded",c),t.off("mediaFragmentLoaded",f),t.off("qualityChangeRendered",g),t.off("error",T),t.off("fragmentLoadingAbandoned",E),delete t._stopMuxMonitor}},wL=function(i){i&&typeof i._stopMuxMonitor=="function"&&i._stopMuxMonitor()},vy=0,CL=function(){"use strict";function i(){dt(this,i),H(this,"_listeners",void 0)}return qi(i,[{key:"on",value:function(e,t,r){return t._eventEmitterGuid=t._eventEmitterGuid||++vy,this._listeners=this._listeners||{},this._listeners[e]=this._listeners[e]||[],r&&(t=t.bind(r)),this._listeners[e].push(t),t}},{key:"off",value:function(e,t){var r=this._listeners&&this._listeners[e];r&&r.forEach(function(s,n){s._eventEmitterGuid===t._eventEmitterGuid&&r.splice(n,1)})}},{key:"one",value:function(e,t,r){var s=this;t._eventEmitterGuid=t._eventEmitterGuid||++vy;var n=function(){s.off(e,n),t.apply(r||this,arguments)};n._eventEmitterGuid=t._eventEmitterGuid,this.on(e,n)}},{key:"emit",value:function(e,t){var r=this;if(this._listeners){t=t||{};var s=this._listeners["before*"]||[],n=this._listeners[e]||[],a=this._listeners["after"+e]||[],o=function(l,d){l=l.slice(),l.forEach(function(u){u.call(r,{type:e},d)})};o(s,t),o(n,t),o(a,t)}}}]),i}(),DL=CL,ep=Dt(Ki()),ML=function(){"use strict";function i(e){var t=this;dt(this,i),H(this,"_playbackHeartbeatInterval",void 0),H(this,"_playheadShouldBeProgressing",void 0),H(this,"pm",void 0),this.pm=e,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,e.on("playing",function(){t._playheadShouldBeProgressing=!0}),e.on("play",this._startPlaybackHeartbeatInterval.bind(this)),e.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),e.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),e.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),e.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),e.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),e.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),e.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),e.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("seeked",function(){e.data.player_is_paused?t._stopPlaybackHeartbeatInterval():t._startPlaybackHeartbeatInterval()}),e.on("timeupdate",function(){t._playbackHeartbeatInterval!==null&&e.emit("playbackheartbeat")}),e.on("devicesleep",function(r,s){t._playbackHeartbeatInterval!==null&&(ep.default.clearInterval(t._playbackHeartbeatInterval),e.emit("playbackheartbeatend",{viewer_time:s.viewer_time}),t._playbackHeartbeatInterval=null)})}return qi(i,[{key:"_startPlaybackHeartbeatInterval",value:function(){var e=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=ep.default.setInterval(function(){e.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(ep.default.clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}]),i}(),PL=ML,OL=function i(e){"use strict";var t=this;dt(this,i),H(this,"viewErrored",void 0),e.on("viewinit",function(){t.viewErrored=!1}),e.on("error",function(r,s){try{var n=e.errorTranslator({player_error_code:s.player_error_code,player_error_message:s.player_error_message,player_error_context:s.player_error_context,player_error_severity:s.player_error_severity,player_error_business_exception:s.player_error_business_exception});n&&(e.data.player_error_code=n.player_error_code||s.player_error_code,e.data.player_error_message=n.player_error_message||s.player_error_message,e.data.player_error_context=n.player_error_context||s.player_error_context,e.data.player_error_severity=n.player_error_severity||s.player_error_severity,e.data.player_error_business_exception=n.player_error_business_exception||s.player_error_business_exception,t.viewErrored=!0)}catch(a){e.mux.log.warn("Exception in error translator callback.",a),t.viewErrored=!0}}),e.on("aftererror",function(){var r,s,n,a,o;(r=e.data)===null||r===void 0||delete r.player_error_code,(s=e.data)===null||s===void 0||delete s.player_error_message,(n=e.data)===null||n===void 0||delete n.player_error_context,(a=e.data)===null||a===void 0||delete a.player_error_severity,(o=e.data)===null||o===void 0||delete o.player_error_business_exception})},NL=OL,UL=function(){"use strict";function i(e){dt(this,i),H(this,"_watchTimeTrackerLastCheckedTime",void 0),H(this,"pm",void 0),this.pm=e,this._watchTimeTrackerLastCheckedTime=null,e.on("playbackheartbeat",this._updateWatchTime.bind(this)),e.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}return qi(i,[{key:"_updateWatchTime",value:function(e,t){var r=t.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=r),Ze(this.pm.data,"view_watch_time",r-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=r}},{key:"_clearWatchTimeState",value:function(e,t){this._updateWatchTime(e,t),this._watchTimeTrackerLastCheckedTime=null}}]),i}(),FL=UL,BL=function(){"use strict";function i(e){var t=this;dt(this,i),H(this,"_playbackTimeTrackerLastPlayheadPosition",void 0),H(this,"_lastTime",void 0),H(this,"_isAdPlaying",void 0),H(this,"_callbackUpdatePlaybackTime",void 0),H(this,"pm",void 0),this.pm=e,this._playbackTimeTrackerLastPlayheadPosition=-1,this._lastTime=tt.now(),this._isAdPlaying=!1,this._callbackUpdatePlaybackTime=null;var r=this._startPlaybackTimeTracking.bind(this);e.on("playing",r),e.on("adplaying",r),e.on("seeked",r);var s=this._stopPlaybackTimeTracking.bind(this);e.on("playbackheartbeatend",s),e.on("seeking",s),e.on("adplaying",function(){t._isAdPlaying=!0}),e.on("adended",function(){t._isAdPlaying=!1}),e.on("adpause",function(){t._isAdPlaying=!1}),e.on("adbreakstart",function(){t._isAdPlaying=!1}),e.on("adbreakend",function(){t._isAdPlaying=!1}),e.on("adplay",function(){t._isAdPlaying=!1}),e.on("viewinit",function(){t._playbackTimeTrackerLastPlayheadPosition=-1,t._lastTime=tt.now(),t._isAdPlaying=!1,t._callbackUpdatePlaybackTime=null})}return qi(i,[{key:"_startPlaybackTimeTracking",value:function(){this._callbackUpdatePlaybackTime===null&&(this._callbackUpdatePlaybackTime=this._updatePlaybackTime.bind(this),this._playbackTimeTrackerLastPlayheadPosition=this.pm.data.player_playhead_time,this.pm.on("playbackheartbeat",this._callbackUpdatePlaybackTime))}},{key:"_stopPlaybackTimeTracking",value:function(){this._callbackUpdatePlaybackTime&&(this._updatePlaybackTime(),this.pm.off("playbackheartbeat",this._callbackUpdatePlaybackTime),this._callbackUpdatePlaybackTime=null,this._playbackTimeTrackerLastPlayheadPosition=-1)}},{key:"_updatePlaybackTime",value:function(){var e=this.pm.data.player_playhead_time,t=tt.now(),r=-1;this._playbackTimeTrackerLastPlayheadPosition>=0&&e>this._playbackTimeTrackerLastPlayheadPosition?r=e-this._playbackTimeTrackerLastPlayheadPosition:this._isAdPlaying&&(r=t-this._lastTime),r>0&&r<=1e3&&Ze(this.pm.data,"view_content_playback_time",r),this._playbackTimeTrackerLastPlayheadPosition=e,this._lastTime=t}}]),i}(),$L=BL,HL=function(){"use strict";function i(e){dt(this,i),H(this,"pm",void 0),this.pm=e;var t=this._updatePlayheadTime.bind(this);e.on("playbackheartbeat",t),e.on("playbackheartbeatend",t),e.on("timeupdate",t),e.on("destroy",function(){e.off("timeupdate",t)})}return qi(i,[{key:"_updateMaxPlayheadPosition",value:function(){this.pm.data.view_max_playhead_position=typeof this.pm.data.view_max_playhead_position=="undefined"?this.pm.data.player_playhead_time:Math.max(this.pm.data.view_max_playhead_position,this.pm.data.player_playhead_time)}},{key:"_updatePlayheadTime",value:function(e,t){var r=this,s=function(){r.pm.currentFragmentPDT&&r.pm.currentFragmentStart&&(r.pm.data.player_program_time=r.pm.currentFragmentPDT+r.pm.data.player_playhead_time-r.pm.currentFragmentStart)};if(t&&t.player_playhead_time)this.pm.data.player_playhead_time=t.player_playhead_time,s(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var n=this.pm.getPlayheadTime();typeof n!="undefined"&&(this.pm.data.player_playhead_time=n,s(),this._updateMaxPlayheadPosition())}}}]),i}(),GL=HL,Ey=5*60*1e3,WL=function i(e){"use strict";if(dt(this,i),!e.disableRebufferTracking){var t,r=function(n,a){s(a),t=void 0},s=function(n){if(t){var a=n.viewer_time-t;Ze(e.data,"view_rebuffer_duration",a),t=n.viewer_time,e.data.view_rebuffer_duration>Ey&&(e.emit("viewend"),e.send("viewend"),e.mux.log.warn("Ending view after rebuffering for longer than ".concat(Ey,"ms, future events will be ignored unless a programchange or videochange occurs.")))}e.data.view_watch_time>=0&&e.data.view_rebuffer_count>0&&(e.data.view_rebuffer_frequency=e.data.view_rebuffer_count/e.data.view_watch_time,e.data.view_rebuffer_percentage=e.data.view_rebuffer_duration/e.data.view_watch_time)};e.on("playbackheartbeat",function(n,a){return s(a)}),e.on("rebufferstart",function(n,a){t||(Ze(e.data,"view_rebuffer_count",1),t=a.viewer_time,e.one("rebufferend",r))}),e.on("viewinit",function(){t=void 0,e.off("rebufferend",r)})}},VL=WL,KL=function(){"use strict";function i(e){var t=this;dt(this,i),H(this,"_lastCheckedTime",void 0),H(this,"_lastPlayheadTime",void 0),H(this,"_lastPlayheadTimeUpdatedTime",void 0),H(this,"_rebuffering",void 0),H(this,"pm",void 0),this.pm=e,!(e.disableRebufferTracking||e.disablePlayheadRebufferTracking)&&(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,e.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),e.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),e.on("seeking",function(){t._cleanupRebufferTracker(null,{viewer_time:tt.now()})}))}return qi(i,[{key:"_checkIfRebuffering",value:function(e,t){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing){this._cleanupRebufferTracker(e,t);return}if(this._lastCheckedTime===null){this._prepareRebufferTrackerState(t.viewer_time);return}if(this._lastPlayheadTime!==this.pm.data.player_playhead_time){this._cleanupRebufferTracker(e,t,!0);return}var r=t.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&r>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=t.viewer_time}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(e){this._lastCheckedTime=e,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=e}},{key:"_cleanupRebufferTracker",value:function(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:t.viewer_time});else{if(this._lastCheckedTime===null)return;var s=this.pm.data.player_playhead_time-this._lastPlayheadTime,n=t.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&s>0&&n-s>this.pm.minimumRebufferDuration&&(this._lastCheckedTime=null,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+n-s}))}r?this._prepareRebufferTrackerState(t.viewer_time):this._clearRebufferTrackerState()}}]),i}(),qL=KL,YL=function(){"use strict";function i(e){var t=this;dt(this,i),H(this,"NAVIGATION_START",void 0),H(this,"pm",void 0),this.pm=e,e.on("viewinit",function(){var r=e.data,s=r.view_id;if(!r.view_program_changed){var n=function(a,o){var l=o.viewer_time;(a.type==="playing"&&typeof e.data.view_time_to_first_frame=="undefined"||a.type==="adplaying"&&(typeof e.data.view_time_to_first_frame=="undefined"||t._inPrerollPosition()))&&t.calculateTimeToFirstFrame(l||tt.now(),s)};e.one("playing",n),e.one("adplaying",n),e.one("viewend",function(){e.off("playing",n),e.off("adplaying",n)})}})}return qi(i,[{key:"_inPrerollPosition",value:function(){return typeof this.pm.data.view_content_playback_time=="undefined"||this.pm.data.view_content_playback_time<=1e3}},{key:"calculateTimeToFirstFrame",value:function(e,t){t===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:e}),this.pm.data.view_time_to_first_frame=this.pm.data.view_watch_time,(this.pm.data.player_autoplay_on||this.pm.data.video_is_autoplay)&&this.NAVIGATION_START&&(this.pm.data.view_aggregate_startup_time=this.pm.data.view_start+this.pm.data.view_watch_time-this.NAVIGATION_START))}}]),i}(),zL=YL,jL=function i(e){"use strict";var t=this;dt(this,i),H(this,"_lastPlayerHeight",void 0),H(this,"_lastPlayerWidth",void 0),H(this,"_lastPlayheadPosition",void 0),H(this,"_lastSourceHeight",void 0),H(this,"_lastSourceWidth",void 0),e.on("viewinit",function(){t._lastPlayheadPosition=-1});var r=["pause","rebufferstart","seeking","error","adbreakstart","hb"],s=["playing","hb"];r.forEach(function(n){e.on(n,function(){if(t._lastPlayheadPosition>=0&&e.data.player_playhead_time>=0&&t._lastPlayerWidth>=0&&t._lastSourceWidth>0&&t._lastPlayerHeight>=0&&t._lastSourceHeight>0){var a=e.data.player_playhead_time-t._lastPlayheadPosition;if(a<0){t._lastPlayheadPosition=-1;return}var o=Math.min(t._lastPlayerWidth/t._lastSourceWidth,t._lastPlayerHeight/t._lastSourceHeight),l=Math.max(0,o-1),d=Math.max(0,1-o);e.data.view_max_upscale_percentage=Math.max(e.data.view_max_upscale_percentage||0,l),e.data.view_max_downscale_percentage=Math.max(e.data.view_max_downscale_percentage||0,d),Ze(e.data,"view_total_content_playback_time",a),Ze(e.data,"view_total_upscaling",l*a),Ze(e.data,"view_total_downscaling",d*a)}t._lastPlayheadPosition=-1})}),s.forEach(function(n){e.on(n,function(){t._lastPlayheadPosition=e.data.player_playhead_time,t._lastPlayerWidth=e.data.player_width,t._lastPlayerHeight=e.data.player_height,t._lastSourceWidth=e.data.video_source_width,t._lastSourceHeight=e.data.video_source_height})})},XL=jL,QL=2e3,ZL=function i(e){"use strict";var t=this;dt(this,i),H(this,"isSeeking",void 0),this.isSeeking=!1;var r=-1,s=function(){var n=tt.now(),a=(e.data.viewer_time||n)-(r||n);Ze(e.data,"view_seek_duration",a),e.data.view_max_seek_time=Math.max(e.data.view_max_seek_time||0,a),t.isSeeking=!1,r=-1};e.on("seeking",function(n,a){if(Object.assign(e.data,a),t.isSeeking&&a.viewer_time-r<=QL){r=a.viewer_time;return}t.isSeeking&&s(),t.isSeeking=!0,r=a.viewer_time,Ze(e.data,"view_seek_count",1),e.send("seeking")}),e.on("seeked",function(){s()}),e.on("viewend",function(){t.isSeeking&&(s(),e.send("seeked")),t.isSeeking=!1,r=-1})},JL=ZL,by=function(i,e){i.push(e),i.sort(function(t,r){return t.viewer_time-r.viewer_time})},ek=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror","adclicked","adskipped"],tk=function(){"use strict";function i(e){var t=this;dt(this,i),H(this,"_adHasPlayed",void 0),H(this,"_adRequests",void 0),H(this,"_adResponses",void 0),H(this,"_currentAdRequestNumber",void 0),H(this,"_currentAdResponseNumber",void 0),H(this,"_prerollPlayTime",void 0),H(this,"_wouldBeNewAdPlay",void 0),H(this,"isAdBreak",void 0),H(this,"pm",void 0),this.pm=e,e.on("viewinit",function(){t.isAdBreak=!1,t._currentAdRequestNumber=0,t._currentAdResponseNumber=0,t._adRequests=[],t._adResponses=[],t._adHasPlayed=!1,t._wouldBeNewAdPlay=!0,t._prerollPlayTime=void 0}),ek.forEach(function(s){return e.on(s,t._updateAdData.bind(t))});var r=function(){t.isAdBreak=!1};e.on("adbreakstart",function(){t.isAdBreak=!0}),e.on("play",r),e.on("playing",r),e.on("viewend",r),e.on("adrequest",function(s,n){n=Object.assign({ad_request_id:"generatedAdRequestId"+t._currentAdRequestNumber++},n),by(t._adRequests,n),Ze(e.data,"view_ad_request_count"),t.inPrerollPosition()&&(e.data.view_preroll_requested=!0,t._adHasPlayed||Ze(e.data,"view_preroll_request_count"))}),e.on("adresponse",function(s,n){n=Object.assign({ad_request_id:"generatedAdRequestId"+t._currentAdResponseNumber++},n),by(t._adResponses,n);var a=t.findAdRequest(n.ad_request_id);a&&Ze(e.data,"view_ad_request_time",Math.max(0,n.viewer_time-a.viewer_time))}),e.on("adplay",function(s,n){t._adHasPlayed=!0,t._wouldBeNewAdPlay&&(t._wouldBeNewAdPlay=!1,Ze(e.data,"view_ad_played_count")),t.inPrerollPosition()&&!e.data.view_preroll_played&&(e.data.view_preroll_played=!0,t._adRequests.length>0&&(e.data.view_preroll_request_time=Math.max(0,n.viewer_time-t._adRequests[0].viewer_time)),e.data.view_start&&(e.data.view_startup_preroll_request_time=Math.max(0,n.viewer_time-e.data.view_start)),t._prerollPlayTime=n.viewer_time)}),e.on("adplaying",function(s,n){t.inPrerollPosition()&&typeof e.data.view_preroll_load_time=="undefined"&&typeof t._prerollPlayTime!="undefined"&&(e.data.view_preroll_load_time=n.viewer_time-t._prerollPlayTime,e.data.view_startup_preroll_load_time=n.viewer_time-t._prerollPlayTime)}),e.on("adclicked",function(s,n){t._wouldBeNewAdPlay||Ze(e.data,"view_ad_clicked_count")}),e.on("adskipped",function(s,n){t._wouldBeNewAdPlay||Ze(e.data,"view_ad_skipped_count")}),e.on("adended",function(){t._wouldBeNewAdPlay=!0}),e.on("aderror",function(){t._wouldBeNewAdPlay=!0})}return qi(i,[{key:"inPrerollPosition",value:function(){return typeof this.pm.data.view_content_playback_time=="undefined"||this.pm.data.view_content_playback_time<=1e3}},{key:"findAdRequest",value:function(e){for(var t=0;t<this._adRequests.length;t++)if(this._adRequests[t].ad_request_id===e)return this._adRequests[t]}},{key:"_updateAdData",value:function(e,t){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&t.ad_tag_url){var r=bs(io(t.ad_tag_url),2),s=r[0],n=r[1];this.pm.data.view_preroll_ad_tag_domain=n,this.pm.data.view_preroll_ad_tag_hostname=s}if(!this.pm.data.view_preroll_ad_asset_hostname&&t.ad_asset_url){var a=bs(io(t.ad_asset_url),2),o=a[0],l=a[1];this.pm.data.view_preroll_ad_asset_domain=l,this.pm.data.view_preroll_ad_asset_hostname=o}}this.pm.data.ad_asset_url=t==null?void 0:t.ad_asset_url,this.pm.data.ad_tag_url=t==null?void 0:t.ad_tag_url,this.pm.data.ad_creative_id=t==null?void 0:t.ad_creative_id,this.pm.data.ad_id=t==null?void 0:t.ad_id,this.pm.data.ad_universal_id=t==null?void 0:t.ad_universal_id}}]),i}(),ik=tk,yy=Dt(Ki()),rk=function i(e){"use strict";dt(this,i);var t,r,s=function(){e.disableRebufferTracking||(Ze(e.data,"view_waiting_rebuffer_count",1),t=tt.now(),r=yy.default.setInterval(function(){if(t){var d=tt.now();Ze(e.data,"view_waiting_rebuffer_duration",d-t),t=d}},250))},n=function(){e.disableRebufferTracking||t&&(Ze(e.data,"view_waiting_rebuffer_duration",tt.now()-t),t=!1,yy.default.clearInterval(r))},a=!1,o=function(){a=!0},l=function(){a=!1,n()};e.on("waiting",function(){a&&s()}),e.on("playing",function(){n(),o()}),e.on("pause",l),e.on("seeking",l)},sk=rk,nk=function i(e){"use strict";var t=this;dt(this,i),H(this,"lastWallClockTime",void 0);var r=function(){t.lastWallClockTime=tt.now(),e.on("before*",s)},s=function(n){var a=tt.now(),o=t.lastWallClockTime;t.lastWallClockTime=a,a-o>3e4&&(e.emit("devicesleep",{viewer_time:o}),Object.assign(e.data,{viewer_time:o}),e.send("devicesleep"),e.emit("devicewake",{viewer_time:a}),Object.assign(e.data,{viewer_time:a}),e.send("devicewake"))};e.one("playbackheartbeat",r),e.on("playbackheartbeatend",function(){e.off("before*",s),e.one("playbackheartbeat",r)})},ak=nk,tp=Dt(Ki()),Dy=Dt(Zx()),My=Dt(Jx()),Py="muxData",Oy=function(){var i;try{i=Dy.default.parse(My.default.get(Py)||"")}catch{i={}}return i},Ny=function(i){try{My.default.set(Py,Dy.default.stringify(i),{expires:365})}catch{}},ok=function(){var i=Oy();return i.mux_viewer_id=i.mux_viewer_id||eo(),i.msn=i.msn||Math.random(),Ny(i),{mux_viewer_id:i.mux_viewer_id,mux_sample_number:i.msn}},lk=function(){var i=Oy(),e=tt.now();return i.session_start&&(i.sst=i.session_start,delete i.session_start),i.session_id&&(i.sid=i.session_id,delete i.session_id),i.session_expires&&(i.sex=i.session_expires,delete i.session_expires),(!i.sex||i.sex<e)&&(i.sid=eo(),i.sst=e),i.sex=e+25*60*1e3,Ny(i),{session_id:i.sid,session_start:i.sst,session_expires:i.sex}};function dk(i,e){var t=e.beaconCollectionDomain,r=e.beaconDomain;if(t)return"https://"+t;i=i||"inferred";var s=r||"litix.io";return i.match(/^[a-z0-9]+$/)?"https://"+i+"."+s:"https://img.litix.io/a.gif"}var uk=Dt(Ki()),Uy=function(){var i;switch(Fy()){case"cellular":i="cellular";break;case"ethernet":i="wired";break;case"wifi":i="wifi";break;case void 0:break;default:i="other"}return i},Fy=function(){var i=uk.default.navigator,e=i&&(i.connection||i.mozConnection||i.webkitConnection);return e&&e.type};Uy.getConnectionFromAPI=Fy;var ck=Uy,hk={a:"env",b:"beacon",c:"custom",d:"ad",e:"event",f:"experiment",i:"internal",m:"mux",n:"response",p:"player",q:"request",r:"retry",s:"session",t:"timestamp",u:"viewer",v:"video",w:"page",x:"view",y:"sub"},fk=By(hk),mk={ad:"ad",ag:"aggregate",ap:"api",al:"application",ar:"architecture",as:"asset",au:"autoplay",av:"average",bi:"bitrate",br:"break",bw:"browser",by:"bytes",bz:"business",ca:"cached",cb:"cancel",cc:"codec",cd:"code",cg:"category",ch:"changed",ck:"clicked",cl:"canceled",cn:"config",co:"count",ce:"counter",cp:"complete",cr:"creative",ct:"content",cu:"current",cx:"connection",cz:"context",dg:"downscaling",dm:"domain",dn:"cdn",do:"downscale",dr:"drm",dp:"dropped",du:"duration",dv:"device",ec:"encoding",ed:"edge",en:"end",eg:"engine",em:"embed",er:"error",ep:"experiments",es:"errorcode",et:"errortext",ee:"event",ev:"events",ex:"expires",ez:"exception",fa:"failed",fi:"first",fm:"family",ft:"format",fp:"fps",fq:"frequency",fr:"frame",fs:"fullscreen",ha:"has",hb:"holdback",he:"headers",ho:"host",hn:"hostname",ht:"height",id:"id",ii:"init",in:"instance",ip:"ip",is:"is",ke:"key",la:"language",lb:"labeled",le:"level",li:"live",ld:"loaded",lo:"load",ls:"lists",lt:"latency",ma:"max",md:"media",me:"message",mf:"manifest",mi:"mime",ml:"midroll",mm:"min",mn:"manufacturer",mo:"model",mx:"mux",ne:"newest",nm:"name",no:"number",on:"on",os:"os",pa:"paused",pb:"playback",pd:"producer",pe:"percentage",pf:"played",pg:"program",ph:"playhead",pi:"plugin",pl:"preroll",pn:"playing",po:"poster",pr:"preload",ps:"position",pt:"part",py:"property",ra:"rate",rd:"requested",re:"rebuffer",rf:"rendition",rm:"remote",ro:"ratio",rp:"response",rq:"request",rs:"requests",sa:"sample",sd:"skipped",se:"session",sk:"seek",sm:"stream",so:"source",sq:"sequence",sr:"series",st:"start",su:"startup",sv:"server",sw:"software",sy:"severity",ta:"tag",tc:"tech",te:"text",tg:"target",th:"throughput",ti:"time",tl:"total",to:"to",tt:"title",ty:"type",ug:"upscaling",un:"universal",up:"upscale",ur:"url",us:"user",va:"variant",vd:"viewed",vi:"video",ve:"version",vw:"view",vr:"viewer",wd:"width",wa:"watch",wt:"waiting"},Ty=By(mk);function By(i){var e={};for(var t in i)i.hasOwnProperty(t)&&(e[i[t]]=t);return e}function ap(i){var e={},t={};return Object.keys(i).forEach(function(r){var s=!1;if(i.hasOwnProperty(r)&&i[r]!==void 0){var n=r.split("_"),a=n[0],o=fk[a];o||(Ge.info("Data key word `"+n[0]+"` not expected in "+r),o=a+"_"),n.splice(1).forEach(function(l){l==="url"&&(s=!0),Ty[l]?o+=Ty[l]:Number(l)&&Math.floor(Number(l))===Number(l)?o+=l:(Ge.info("Data key word `"+l+"` not expected in "+r),o+="_"+l+"_")}),s?t[o]=i[r]:e[o]=i[r]}}),Object.assign(e,t)}var Es=Dt(Ki()),pk={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},gk=56*1024,vk=["hb","requestcompleted","requestfailed","requestcanceled"],Ek="https://img.litix.io",lr=function(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=i||Ek,this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=Object.assign({},pk,e)};lr.prototype.queueEvent=function(i,e){var t=Object.assign({},e);return this._eventQueue.length<=this._options.maxQueueLength||i==="eventrateexceeded"?(this._eventQueue.push(t),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength):!1};lr.prototype.flushEvents=function(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;if(i&&this._eventQueue.length===1){this._eventQueue.pop();return}this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending()};lr.prototype.destroy=function(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;this.destroyed=!0,i?this._clearBeaconQueue():this.flushEvents(),Es.default.clearTimeout(this._sendTimeout)};lr.prototype._clearBeaconQueue=function(){var i=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,e=this._eventQueue.slice(i);i>0&&Object.assign(e[e.length-1],ap({mux_view_message:"event queue truncated"}));var t=this._createPayload(e);$y(this._beaconUrl,t,!0,function(){})};lr.prototype._sendBeaconQueue=function(){var i=this;if(!this._postInFlight){var e=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var t=this._createPayload(e),r=tt.now();$y(this._beaconUrl,t,!1,function(s,n){n?(i._eventQueue=e.concat(i._eventQueue),i._failureCount+=1,Ge.info("Error sending beacon: "+n)):i._failureCount=0,i._roundTripTime=tt.now()-r,i._postInFlight=!1})}};lr.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var i=Math.pow(2,this._failureCount-1);return i=i*Math.random(),(1+i)*this._options.baseTimeBetweenBeacons};lr.prototype._startBeaconSending=function(){var i=this;Es.default.clearTimeout(this._sendTimeout),!this.destroyed&&(this._sendTimeout=Es.default.setTimeout(function(){i._eventQueue.length&&i._sendBeaconQueue(),i._startBeaconSending()},this._getNextBeaconTime()))};lr.prototype._createPayload=function(i){var e=this,t={transmission_timestamp:Math.round(tt.now())};this._roundTripTime&&(t.rtt_ms=Math.round(this._roundTripTime));var r,s,n,a=function(){r=JSON.stringify({metadata:t,events:s||i}),n=r.length/1024},o=function(){return n<=e._options.maxPayloadKBSize};return a(),o()||(Ge.info("Payload size is too big ("+n+" kb). Removing unnecessary events."),s=i.filter(function(l){return vk.indexOf(l.e)===-1}),a()),o()||(Ge.info("Payload size still too big ("+n+" kb). Cropping fields.."),s.forEach(function(l){for(var d in l){var u=l[d],c=50*1024;typeof u=="string"&&u.length>c&&(l[d]=u.substring(0,c))}}),a()),r};var bk=function(i){return i.length<=gk},$y=function(i,e,t,r){if(t&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(i,e)){r();return}if(Es.default.fetch){Es.default.fetch(i,{method:"POST",body:e,headers:{"Content-Type":"text/plain"},keepalive:bk(e)}).then(function(n){return r(null,n.ok?null:"Error")}).catch(function(n){return r(null,n)});return}if(Es.default.XMLHttpRequest){var s=new Es.default.XMLHttpRequest;s.onreadystatechange=function(){if(s.readyState===4)return r(null,s.status!==200?"error":void 0)},s.open("POST",i),s.setRequestHeader("Content-Type","text/plain"),s.send(e);return}r()},yk=lr,Tk=["env_key","view_id","view_sequence_number","player_sequence_number","beacon_domain","player_playhead_time","viewer_time","mux_api_version","event","video_id","player_instance_id","player_error_code","player_error_message","player_error_context","player_error_severity","player_error_business_exception"],_k=["adplay","adplaying","adpause","adfirstquartile","admidpoint","adthirdquartile","adended","adresponse","adrequest"],Ak=["ad_id","ad_creative_id","ad_universal_id"],Sk=["viewstart","error","ended","viewend"],xk=10*60*1e3,Lk=function(){"use strict";function i(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};dt(this,i);var s,n,a,o,l,d,u,c,h,f,m,p;H(this,"mux",void 0),H(this,"envKey",void 0),H(this,"options",void 0),H(this,"eventQueue",void 0),H(this,"sampleRate",void 0),H(this,"disableCookies",void 0),H(this,"respectDoNotTrack",void 0),H(this,"previousBeaconData",void 0),H(this,"lastEventTime",void 0),H(this,"rateLimited",void 0),H(this,"pageLevelData",void 0),H(this,"viewerData",void 0),this.mux=e,this.envKey=t,this.options=r,this.previousBeaconData=null,this.lastEventTime=0,this.rateLimited=!1,this.eventQueue=new yk(dk(this.envKey,this.options));var g;this.sampleRate=(g=this.options.sampleRate)!==null&&g!==void 0?g:1;var E;this.disableCookies=(E=this.options.disableCookies)!==null&&E!==void 0?E:!1;var T;this.respectDoNotTrack=(T=this.options.respectDoNotTrack)!==null&&T!==void 0?T:!1,this.previousBeaconData=null,this.lastEventTime=0,this.rateLimited=!1,this.pageLevelData={mux_api_version:this.mux.API_VERSION,mux_embed:this.mux.NAME,mux_embed_version:this.mux.VERSION,viewer_application_name:(s=this.options.platform)===null||s===void 0?void 0:s.name,viewer_application_version:(n=this.options.platform)===null||n===void 0?void 0:n.version,viewer_application_engine:(a=this.options.platform)===null||a===void 0?void 0:a.layout,viewer_device_name:(o=this.options.platform)===null||o===void 0?void 0:o.product,viewer_device_category:"",viewer_device_manufacturer:(l=this.options.platform)===null||l===void 0?void 0:l.manufacturer,viewer_os_family:(u=this.options.platform)===null||u===void 0||(d=u.os)===null||d===void 0?void 0:d.family,viewer_os_architecture:(h=this.options.platform)===null||h===void 0||(c=h.os)===null||c===void 0?void 0:c.architecture,viewer_os_version:(m=this.options.platform)===null||m===void 0||(f=m.os)===null||f===void 0?void 0:f.version,viewer_connection_type:ck(),page_url:tp.default===null||tp.default===void 0||(p=tp.default.location)===null||p===void 0?void 0:p.href},this.viewerData=this.disableCookies?{}:ok()}return qi(i,[{key:"send",value:function(e,t){if(!(!e||!(t!=null&&t.view_id))){if(this.respectDoNotTrack&&sp())return Ge.info("Not sending `"+e+"` because Do Not Track is enabled");if(!t||typeof t!="object")return Ge.error("A data object was expected in send() but was not provided");var r=this.disableCookies?{}:lk(),s=op(Tu({},this.pageLevelData,t,r,this.viewerData),{event:e,env_key:this.envKey});s.user_id&&(s.viewer_user_id=s.user_id,delete s.user_id);var n,a=((n=s.mux_sample_number)!==null&&n!==void 0?n:0)>=this.sampleRate,o=this._deduplicateBeaconData(e,s),l=ap(o);if(this.lastEventTime=this.mux.utils.now(),a)return Ge.info("Not sending event due to sample rate restriction",e,s,l);if(this.envKey||Ge.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",e,s,l),!this.rateLimited){if(Ge.info("Sending event",e,s,l),this.rateLimited=!this.eventQueue.queueEvent(e,l),this.mux.WINDOW_UNLOADING&&e==="viewend")this.eventQueue.destroy(!0);else if(this.mux.WINDOW_HIDDEN&&e==="hb"?this.eventQueue.flushEvents(!0):Sk.indexOf(e)>=0&&this.eventQueue.flushEvents(),this.rateLimited)return s.event="eventrateexceeded",l=ap(s),this.eventQueue.queueEvent(s.event,l),Ge.error("Beaconing disabled due to rate limit.")}}}},{key:"destroy",value:function(){this.eventQueue.destroy(!1)}},{key:"_deduplicateBeaconData",value:function(e,t){var r=this,s={},n=t.view_id;if(n==="-1"||e==="viewstart"||e==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=xk)s=Tu({},t),n&&(this.previousBeaconData=s),n&&e==="viewend"&&(this.previousBeaconData=null);else{var a=e.indexOf("request")===0;Object.entries(t).forEach(function(o){var l=bs(o,2),d=l[0],u=l[1];r.previousBeaconData&&(u!==r.previousBeaconData[d]||Tk.indexOf(d)>-1||r.objectHasChanged(a,d,u,r.previousBeaconData[d])||r.eventRequiresKey(e,d))&&(s[d]=u,r.previousBeaconData[d]=u)})}return s}},{key:"objectHasChanged",value:function(e,t,r,s){return!e||t.indexOf("request_")!==0?!1:t==="request_response_headers"||typeof r!="object"||typeof s!="object"?!0:Object.keys(r||{}).length!==Object.keys(s||{}).length}},{key:"eventRequiresKey",value:function(e,t){return!!(e==="renditionchange"&&t.indexOf("video_source_")===0||Ak.includes(t)&&_k.includes(e))}}]),i}(),kk=function i(e){"use strict";dt(this,i);var t=0,r=0,s=0,n=0,a=0,o=0,l=0,d=function(h,f){var m=f.request_start,p=f.request_response_start,g=f.request_response_end,E=f.request_bytes_loaded;n++;var T,y;if(p?(T=p-(m!=null?m:0),y=(g!=null?g:0)-p):y=(g!=null?g:0)-(m!=null?m:0),y>0&&E&&E>0){var S=E/y*8e3;a++,r+=E,s+=y,e.data.view_min_request_throughput=Math.min(e.data.view_min_request_throughput||1/0,S),e.data.view_average_request_throughput=r/s*8e3,e.data.view_request_count=n,T>0&&(t+=T,e.data.view_max_request_latency=Math.max(e.data.view_max_request_latency||0,T),e.data.view_average_request_latency=t/a)}},u=function(h,f){n++,o++,e.data.view_request_count=n,e.data.view_request_failed_count=o},c=function(h,f){n++,l++,e.data.view_request_count=n,e.data.view_request_canceled_count=l};e.on("requestcompleted",d),e.on("requestfailed",u),e.on("requestcanceled",c)},Ik=kk,Rk=60*60*1e3,wk=function i(e){"use strict";var t=this;dt(this,i),H(this,"_lastEventTime",void 0),e.on("before*",function(r,s){var n=s.viewer_time,a=tt.now(),o=t._lastEventTime;if(t._lastEventTime=a,o&&a-o>Rk){var l=Object.keys(e.data).reduce(function(d,u){return u.indexOf("video_")===0?Object.assign(d,H({},u,e.data[u])):d},{});e.mux.log.info("Received event after at least an hour inactivity, creating a new view"),e.emit("viewinit",Object.assign({viewer_time:n},l)),e.playbackHeartbeat._playheadShouldBeProgressing&&r.type!=="play"&&r.type!=="adbreakstart"&&(e.emit("play",{viewer_time:n}),r.type!=="playing"&&e.emit("playing",{viewer_time:n}))}})},Ck=wk,Dk=["viewstart","ended","loadstart","pause","play","playing","ratechange","waiting","adplay","adpause","adended","aderror","adplaying","adrequest","adresponse","adbreakstart","adbreakend","adfirstquartile","admidpoint","adthirdquartile","rebufferstart","rebufferend","seeked","error","hb","requestcompleted","requestfailed","requestcanceled","renditionchange"],Mk=function(i){"use strict";pL(t,i);var e=EL(t);function t(r,s,n){dt(this,t);var a;a=e.call(this),H(re(a),"DOM_CONTENT_LOADED_EVENT_END",void 0),H(re(a),"NAVIGATION_START",void 0),H(re(a),"_destroyed",void 0),H(re(a),"_heartBeatTimeout",void 0),H(re(a),"adTracker",void 0),H(re(a),"dashjs",void 0),H(re(a),"data",void 0),H(re(a),"disablePlayheadRebufferTracking",void 0),H(re(a),"disableRebufferTracking",void 0),H(re(a),"errorTracker",void 0),H(re(a),"errorTranslator",void 0),H(re(a),"getAdData",void 0),H(re(a),"getPlayheadTime",void 0),H(re(a),"getStateData",void 0),H(re(a),"hlsjs",void 0),H(re(a),"id",void 0),H(re(a),"longResumeTracker",void 0),H(re(a),"minimumRebufferDuration",void 0),H(re(a),"mux",void 0),H(re(a),"oldEmit",void 0),H(re(a),"playbackEventDispatcher",void 0),H(re(a),"playbackHeartbeat",void 0),H(re(a),"playbackHeartbeatTime",void 0),H(re(a),"playheadTime",void 0),H(re(a),"seekingTracker",void 0),H(re(a),"sustainedRebufferThreshold",void 0),H(re(a),"watchTimeTracker",void 0),H(re(a),"currentFragmentPDT",void 0),H(re(a),"currentFragmentStart",void 0),a.DOM_CONTENT_LOADED_EVENT_END=yu.domContentLoadedEventEnd(),a.NAVIGATION_START=yu.navigationStart();var o={debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(f){return f}};a.mux=r,a.id=s,n!=null&&n.beaconDomain&&a.mux.log.warn("The `beaconDomain` setting has been deprecated in favor of `beaconCollectionDomain`. Please change your integration to use `beaconCollectionDomain` instead of `beaconDomain`."),n=Object.assign(o,n),n.data=n.data||{},n.data.property_key&&(n.data.env_key=n.data.property_key,delete n.data.property_key),Ge.setLevel(n.debug?"debug":"warn"),a.getPlayheadTime=n.getPlayheadTime,a.getStateData=n.getStateData||function(){return{}},a.getAdData=n.getAdData||function(){},a.minimumRebufferDuration=n.minimumRebufferDuration,a.sustainedRebufferThreshold=n.sustainedRebufferThreshold,a.playbackHeartbeatTime=n.playbackHeartbeatTime,a.disableRebufferTracking=n.disableRebufferTracking,a.disableRebufferTracking&&a.mux.log.warn("Disabling rebuffer tracking. This should only be used in specific circumstances as a last resort when your player is known to unreliably track rebuffering."),a.disablePlayheadRebufferTracking=n.disablePlayheadRebufferTracking,a.errorTranslator=n.errorTranslator,a.playbackEventDispatcher=new Lk(r,n.data.env_key,n),a.data={player_instance_id:eo(),mux_sample_rate:n.sampleRate,beacon_domain:n.beaconCollectionDomain||n.beaconDomain},a.data.view_sequence_number=1,a.data.player_sequence_number=1,a.oldEmit=a.emit,a.emit=function(f,m){m=Object.assign({viewer_time:this.mux.utils.now()},m),this.oldEmit(f,m)};var l=function(){typeof this.data.view_start=="undefined"&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(re(a));a.on("viewinit",function(f,m){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),Object.assign(this.data,m),this._initializeViewData(),this.one("play",l),this.one("adbreakstart",l)});var d=function(f){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",f)}.bind(re(a));if(a.on("videochange",function(f,m){d(m)}),a.on("programchange",function(f,m){this.data.player_is_paused&&this.mux.log.warn("The `programchange` event is intended to be used when the content changes mid playback without the video source changing, however the video is not currently playing. If the video source is changing please use the videochange event otherwise you will lose startup time information."),d(Object.assign(m,{view_program_changed:!0})),l(),this.emit("play"),this.emit("playing")}),a.on("fragmentchange",function(f,m){this.currentFragmentPDT=m.currentFragmentPDT,this.currentFragmentStart=m.currentFragmentStart}),a.on("destroy",a.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var u=function(){var f=typeof a.data.view_start!="undefined";a.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",f&&a.mux.WINDOW_HIDDEN&&(a.data.player_is_paused||a.emit("hb"))};window.addEventListener("visibilitychange",u,!1);var c=function(f){f.persisted||a.destroy()};window.addEventListener("pagehide",c,!1),a.on("destroy",function(){window.removeEventListener("visibilitychange",u),window.removeEventListener("pagehide",c)})}a.on("playerready",function(f,m){Object.assign(this.data,m)}),Dk.forEach(function(f){a.on(f,function(m,p){f.indexOf("ad")!==0&&this._updateStateData(),Object.assign(this.data,p),this._sanitizeData()}),a.on("after"+f,function(){(f!=="error"||this.errorTracker.viewErrored)&&this.send(f)})}),a.on("viewend",function(f,m){Object.assign(a.data,m)});var h=function(f){var m=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=m-this.data.player_init_time),!this.mux.PLAYER_TRACKED&&this.NAVIGATION_START&&(this.mux.PLAYER_TRACKED=!0,(this.data.player_init_time||this.DOM_CONTENT_LOADED_EVENT_END)&&(this.data.page_load_time=Math.min(this.data.player_init_time||1/0,this.DOM_CONTENT_LOADED_EVENT_END||1/0)-this.NAVIGATION_START)),this.send("playerready"),delete this.data.player_startup_time,delete this.data.page_load_time};return a.one("playerready",h),a.longResumeTracker=new Ck(re(a)),a.errorTracker=new NL(re(a)),new ak(re(a)),a.seekingTracker=new JL(re(a)),a.playheadTime=new GL(re(a)),a.playbackHeartbeat=new PL(re(a)),new XL(re(a)),a.watchTimeTracker=new FL(re(a)),new $L(re(a)),a.adTracker=new ik(re(a)),new qL(re(a)),new VL(re(a)),new zL(re(a)),new sk(re(a)),new Ik(re(a)),n.hlsjs&&a.addHLSJS(n),n.dashjs&&a.addDashJS(n),a.emit("viewinit",n.data),a}return qi(t,[{key:"destroy",value:function(){this._destroyed||(this._destroyed=!0,typeof this.data.view_start!="undefined"&&(this.emit("viewend"),this.send("viewend")),this.playbackEventDispatcher.destroy(),this.removeHLSJS(),this.removeDashJS(),window.clearTimeout(this._heartBeatTimeout))}},{key:"send",value:function(r){if(this.data.view_id){var s=Object.assign({},this.data),n=["player_program_time","player_manifest_newest_program_time","player_live_edge_program_time","player_program_time","video_holdback","video_part_holdback","video_target_duration","video_part_target_duration"];if(s.video_source_is_live===void 0&&(s.player_source_duration===1/0||s.video_source_duration===1/0?s.video_source_is_live=!0:(s.player_source_duration>0||s.video_source_duration>0)&&(s.video_source_is_live=!1)),s.video_source_is_live||n.forEach(function(d){s[d]=void 0}),s.video_source_url=s.video_source_url||s.player_source_url,s.video_source_url){var a=bs(io(s.video_source_url),2),o=a[0],l=a[1];s.video_source_domain=l,s.video_source_hostname=o}delete s.ad_request_id,this.playbackEventDispatcher.send(r,s),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat(),r==="viewend"&&delete this.data.view_id}}},{key:"_updateStateData",value:function(){Object.assign(this.data,this.getStateData()),this.playheadTime._updatePlayheadTime(),this._sanitizeData()}},{key:"_sanitizeData",value:function(){var r=this,s=["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"];s.forEach(function(a){var o=parseInt(r.data[a],10);r.data[a]=isNaN(o)?void 0:o});var n=["player_source_url","video_source_url"];n.forEach(function(a){if(r.data[a]){var o=r.data[a].toLowerCase();(o.indexOf("data:")===0||o.indexOf("blob:")===0)&&(r.data[a]="MSE style URL")}})}},{key:"_resetVideoData",value:function(){var r=this;Object.keys(this.data).forEach(function(s){s.indexOf("video_")===0&&delete r.data[s]})}},{key:"_resetViewData",value:function(){var r=this;Object.keys(this.data).forEach(function(s){s.indexOf("view_")===0&&delete r.data[s]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(){delete this.data.player_error_code,delete this.data.player_error_message,delete this.data.player_error_context,delete this.data.player_error_severity,delete this.data.player_error_business_exception}},{key:"_initializeViewData",value:function(){var r=this,s=this.data.view_id=eo(),n=function(){s===r.data.view_id&&Ze(r.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",n):n()}},{key:"_restartHeartBeat",value:function(){var r=this;window.clearTimeout(this._heartBeatTimeout),this.errorTracker.viewErrored||(this._heartBeatTimeout=window.setTimeout(function(){r.data.player_is_paused||r.emit("hb")},1e4))}},{key:"addHLSJS",value:function(r){if(!r.hlsjs){this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.");return}if(this.hlsjs){this.mux.log.warn("An instance of HLS.js is already being monitored for this player.");return}this.hlsjs=r.hlsjs,SL(this.mux,this.id,r.hlsjs,{},r.Hls||window.Hls)}},{key:"removeHLSJS",value:function(){this.hlsjs&&(xL(this.hlsjs),this.hlsjs=void 0)}},{key:"addDashJS",value:function(r){if(!r.dashjs){this.mux.log.warn("You must pass a valid dashjs instance in order to track it.");return}if(this.dashjs){this.mux.log.warn("An instance of Dash.js is already being monitored for this player.");return}this.dashjs=r.dashjs,RL(this.mux,this.id,r.dashjs)}},{key:"removeDashJS",value:function(){this.dashjs&&(wL(this.dashjs),this.dashjs=void 0)}}]),t}(DL),Pk=Mk;Au();var Qa=Dt(oL());function Ok(){return Qa.default&&!!(Qa.default.fullscreenElement||Qa.default.webkitFullscreenElement||Qa.default.mozFullScreenElement||Qa.default.msFullscreenElement)}var Nk=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],Uk={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"};function Fk(i,e,t){var r=bs(rp(e),3),s=r[0],n=r[1],a=r[2],o=i.log,l=i.utils.getComputedStyle,d=i.utils.secondsToMs,u={automaticErrorTracking:!0};if(s){if(a!=="video"&&a!=="audio")return o.error("The element of `"+n+"` was not a media element.")}else return o.error("No element was found with the `"+n+"` query selector.");s.mux&&(s.mux.destroy(),delete s.mux,o.warn("Already monitoring this video element, replacing existing event listeners")),t=Object.assign(u,t),t.data=Object.assign({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:i.VERSION},t.data),t.getPlayheadTime=function(){return d(s.currentTime)},t.getStateData=function(){var h,f=this.hlsjs&&this.hlsjs.url,m=this.dashjs&&St(this.dashjs.getSource==="function")&&this.dashjs.getSource(),p={player_is_paused:s.paused,player_playhead_time:d(s.currentTime),player_width:parseInt(l(s,"width")),player_height:parseInt(l(s,"height")),player_autoplay_on:s.autoplay,player_preload_on:s.preload,player_language_code:s.lang,player_is_fullscreen:Ok(),video_poster_url:s.poster,video_source_url:f||m||s.currentSrc,video_source_duration:d(s.duration),video_source_height:s.videoHeight,video_source_width:s.videoWidth,view_dropped_frame_count:s==null||(h=s.getVideoPlaybackQuality)===null||h===void 0?void 0:h.call(s).droppedVideoFrames},g=t.getPlayheadTime();if(s.getStartDate&&g>0){var E=s.getStartDate();if(E&&typeof E.getTime=="function"&&E.getTime()){var T=E.getTime();if(p.player_program_time=T+g,s.seekable.length>0){var y=T+s.seekable.end(s.seekable.length-1);p.player_live_edge_program_time=y}}}return p},s.mux=s.mux||{},s.mux.deleted=!1,s.mux.emit=function(h,f){i.emit(n,h,f)};var c=function(){o.error("The monitor for this video element has already been destroyed.")};s.mux.destroy=function(){Object.keys(s.mux.listeners).forEach(function(h){s.removeEventListener(h,s.mux.listeners[h],!1)}),delete s.mux.listeners,s.mux.destroy=c,s.mux.swapElement=c,s.mux.emit=c,s.mux.addHLSJS=c,s.mux.addDashJS=c,s.mux.removeHLSJS=c,s.mux.removeDashJS=c,s.mux.deleted=!0,i.emit(n,"destroy")},s.mux.swapElement=function(h){var f=bs(rp(h),3),m=f[0],p=f[1],g=f[2];if(m){if(g!=="video"&&g!=="audio")return i.log.error("The element of `"+p+"` was not a media element.")}else return i.log.error("No element was found with the `"+p+"` query selector.");m.muxId=s.muxId,delete s.muxId,m.mux=m.mux||{},m.mux.listeners=Object.assign({},s.mux.listeners),delete s.mux.listeners,Object.keys(m.mux.listeners).forEach(function(E){s.removeEventListener(E,m.mux.listeners[E],!1),m.addEventListener(E,m.mux.listeners[E],!1)}),m.mux.swapElement=s.mux.swapElement,m.mux.destroy=s.mux.destroy,delete s.mux,s=m},s.mux.addHLSJS=function(h){i.addHLSJS(n,h)},s.mux.addDashJS=function(h){i.addDashJS(n,h)},s.mux.removeHLSJS=function(){i.removeHLSJS(n)},s.mux.removeDashJS=function(){i.removeDashJS(n)},i.init(n,t),i.emit(n,"playerready"),s.paused||(i.emit(n,"play"),s.readyState>2&&i.emit(n,"playing")),s.mux.listeners={},Nk.forEach(function(h){h==="error"&&!t.automaticErrorTracking||(s.mux.listeners[h]=function(){var f={};if(h==="error"){if(!s.error||s.error.code===1)return;f.player_error_code=s.error.code,f.player_error_message=Uk[s.error.code]||s.error.message}i.emit(n,h,f)},s.addEventListener(h,s.mux.listeners[h],!1))})}function Bk(i,e,t,r){var s=r;if(i&&typeof i[e]=="function")try{s=i[e].apply(i,t)}catch(n){Ge.info("safeCall error",n)}return s}var Ja=Dt(Ki()),On;Ja.default&&Ja.default.WeakMap&&(On=new WeakMap);function $k(i,e){if(!i||!e||!Ja.default||typeof Ja.default.getComputedStyle!="function")return"";var t;return On&&On.has(i)&&(t=On.get(i)),t||(t=Ja.default.getComputedStyle(i,null),On&&On.set(i,t)),t.getPropertyValue(e)}function Hk(i){return Math.floor(i*1e3)}var gs={TARGET_DURATION:"#EXT-X-TARGETDURATION",PART_INF:"#EXT-X-PART-INF",SERVER_CONTROL:"#EXT-X-SERVER-CONTROL",INF:"#EXTINF",PROGRAM_DATE_TIME:"#EXT-X-PROGRAM-DATE-TIME",VERSION:"#EXT-X-VERSION",SESSION_DATA:"#EXT-X-SESSION-DATA"},Su=function(i){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(i),this.manifest};Su.prototype.process=function(i){var e;for(this.buffer+=i,e=this.buffer.indexOf(`
1576
+ `):"");a("error",{player_error_code:S==null?void 0:S.code,player_error_message:S==null?void 0:S.message,player_error_context:P})};t.on("error",T),t._stopMuxMonitor=function(){t.off("manifestLoaded",o),t.off("initFragmentLoaded",c),t.off("mediaFragmentLoaded",f),t.off("qualityChangeRendered",g),t.off("error",T),t.off("fragmentLoadingAbandoned",E),delete t._stopMuxMonitor}},IL=function(i){i&&typeof i._stopMuxMonitor=="function"&&i._stopMuxMonitor()},by=0,RL=function(){"use strict";function i(){ut(this,i),H(this,"_listeners",void 0)}return qi(i,[{key:"on",value:function(e,t,r){return t._eventEmitterGuid=t._eventEmitterGuid||++by,this._listeners=this._listeners||{},this._listeners[e]=this._listeners[e]||[],r&&(t=t.bind(r)),this._listeners[e].push(t),t}},{key:"off",value:function(e,t){var r=this._listeners&&this._listeners[e];r&&r.forEach(function(s,n){s._eventEmitterGuid===t._eventEmitterGuid&&r.splice(n,1)})}},{key:"one",value:function(e,t,r){var s=this;t._eventEmitterGuid=t._eventEmitterGuid||++by;var n=function(){s.off(e,n),t.apply(r||this,arguments)};n._eventEmitterGuid=t._eventEmitterGuid,this.on(e,n)}},{key:"emit",value:function(e,t){var r=this;if(this._listeners){t=t||{};var s=this._listeners["before*"]||[],n=this._listeners[e]||[],a=this._listeners["after"+e]||[],o=function(l,d){l=l.slice(),l.forEach(function(u){u.call(r,{type:e},d)})};o(s,t),o(n,t),o(a,t)}}}]),i}(),wL=RL,sp=Dt(Vi()),CL=function(){"use strict";function i(e){var t=this;ut(this,i),H(this,"_playbackHeartbeatInterval",void 0),H(this,"_playheadShouldBeProgressing",void 0),H(this,"pm",void 0),this.pm=e,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,e.on("playing",function(){t._playheadShouldBeProgressing=!0}),e.on("play",this._startPlaybackHeartbeatInterval.bind(this)),e.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),e.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),e.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),e.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),e.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),e.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),e.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),e.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("seeked",function(){e.data.player_is_paused?t._stopPlaybackHeartbeatInterval():t._startPlaybackHeartbeatInterval()}),e.on("timeupdate",function(){t._playbackHeartbeatInterval!==null&&e.emit("playbackheartbeat")}),e.on("devicesleep",function(r,s){t._playbackHeartbeatInterval!==null&&(sp.default.clearInterval(t._playbackHeartbeatInterval),e.emit("playbackheartbeatend",{viewer_time:s.viewer_time}),t._playbackHeartbeatInterval=null)})}return qi(i,[{key:"_startPlaybackHeartbeatInterval",value:function(){var e=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=sp.default.setInterval(function(){e.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(sp.default.clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}]),i}(),DL=CL,ML=function i(e){"use strict";var t=this;ut(this,i),H(this,"viewErrored",void 0),e.on("viewinit",function(){t.viewErrored=!1}),e.on("error",function(r,s){try{var n=e.errorTranslator({player_error_code:s.player_error_code,player_error_message:s.player_error_message,player_error_context:s.player_error_context,player_error_severity:s.player_error_severity,player_error_business_exception:s.player_error_business_exception});n&&(e.data.player_error_code=n.player_error_code||s.player_error_code,e.data.player_error_message=n.player_error_message||s.player_error_message,e.data.player_error_context=n.player_error_context||s.player_error_context,e.data.player_error_severity=n.player_error_severity||s.player_error_severity,e.data.player_error_business_exception=n.player_error_business_exception||s.player_error_business_exception,t.viewErrored=!0)}catch(a){e.mux.log.warn("Exception in error translator callback.",a),t.viewErrored=!0}}),e.on("aftererror",function(){var r,s,n,a,o;(r=e.data)===null||r===void 0||delete r.player_error_code,(s=e.data)===null||s===void 0||delete s.player_error_message,(n=e.data)===null||n===void 0||delete n.player_error_context,(a=e.data)===null||a===void 0||delete a.player_error_severity,(o=e.data)===null||o===void 0||delete o.player_error_business_exception})},PL=ML,OL=function(){"use strict";function i(e){ut(this,i),H(this,"_watchTimeTrackerLastCheckedTime",void 0),H(this,"pm",void 0),this.pm=e,this._watchTimeTrackerLastCheckedTime=null,e.on("playbackheartbeat",this._updateWatchTime.bind(this)),e.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}return qi(i,[{key:"_updateWatchTime",value:function(e,t){var r=t.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=r),Ze(this.pm.data,"view_watch_time",r-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=r}},{key:"_clearWatchTimeState",value:function(e,t){this._updateWatchTime(e,t),this._watchTimeTrackerLastCheckedTime=null}}]),i}(),NL=OL,UL=function(){"use strict";function i(e){var t=this;ut(this,i),H(this,"_playbackTimeTrackerLastPlayheadPosition",void 0),H(this,"_lastTime",void 0),H(this,"_isAdPlaying",void 0),H(this,"_callbackUpdatePlaybackTime",void 0),H(this,"pm",void 0),this.pm=e,this._playbackTimeTrackerLastPlayheadPosition=-1,this._lastTime=tt.now(),this._isAdPlaying=!1,this._callbackUpdatePlaybackTime=null;var r=this._startPlaybackTimeTracking.bind(this);e.on("playing",r),e.on("adplaying",r),e.on("seeked",r);var s=this._stopPlaybackTimeTracking.bind(this);e.on("playbackheartbeatend",s),e.on("seeking",s),e.on("adplaying",function(){t._isAdPlaying=!0}),e.on("adended",function(){t._isAdPlaying=!1}),e.on("adpause",function(){t._isAdPlaying=!1}),e.on("adbreakstart",function(){t._isAdPlaying=!1}),e.on("adbreakend",function(){t._isAdPlaying=!1}),e.on("adplay",function(){t._isAdPlaying=!1}),e.on("viewinit",function(){t._playbackTimeTrackerLastPlayheadPosition=-1,t._lastTime=tt.now(),t._isAdPlaying=!1,t._callbackUpdatePlaybackTime=null})}return qi(i,[{key:"_startPlaybackTimeTracking",value:function(){this._callbackUpdatePlaybackTime===null&&(this._callbackUpdatePlaybackTime=this._updatePlaybackTime.bind(this),this._playbackTimeTrackerLastPlayheadPosition=this.pm.data.player_playhead_time,this.pm.on("playbackheartbeat",this._callbackUpdatePlaybackTime))}},{key:"_stopPlaybackTimeTracking",value:function(){this._callbackUpdatePlaybackTime&&(this._updatePlaybackTime(),this.pm.off("playbackheartbeat",this._callbackUpdatePlaybackTime),this._callbackUpdatePlaybackTime=null,this._playbackTimeTrackerLastPlayheadPosition=-1)}},{key:"_updatePlaybackTime",value:function(){var e=this.pm.data.player_playhead_time,t=tt.now(),r=-1;this._playbackTimeTrackerLastPlayheadPosition>=0&&e>this._playbackTimeTrackerLastPlayheadPosition?r=e-this._playbackTimeTrackerLastPlayheadPosition:this._isAdPlaying&&(r=t-this._lastTime),r>0&&r<=1e3&&Ze(this.pm.data,"view_content_playback_time",r),this._playbackTimeTrackerLastPlayheadPosition=e,this._lastTime=t}}]),i}(),FL=UL,BL=function(){"use strict";function i(e){ut(this,i),H(this,"pm",void 0),this.pm=e;var t=this._updatePlayheadTime.bind(this);e.on("playbackheartbeat",t),e.on("playbackheartbeatend",t),e.on("timeupdate",t),e.on("destroy",function(){e.off("timeupdate",t)})}return qi(i,[{key:"_updateMaxPlayheadPosition",value:function(){this.pm.data.view_max_playhead_position=typeof this.pm.data.view_max_playhead_position=="undefined"?this.pm.data.player_playhead_time:Math.max(this.pm.data.view_max_playhead_position,this.pm.data.player_playhead_time)}},{key:"_updatePlayheadTime",value:function(e,t){var r=this,s=function(){r.pm.currentFragmentPDT&&r.pm.currentFragmentStart&&(r.pm.data.player_program_time=r.pm.currentFragmentPDT+r.pm.data.player_playhead_time-r.pm.currentFragmentStart)};if(t&&t.player_playhead_time)this.pm.data.player_playhead_time=t.player_playhead_time,s(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var n=this.pm.getPlayheadTime();typeof n!="undefined"&&(this.pm.data.player_playhead_time=n,s(),this._updateMaxPlayheadPosition())}}}]),i}(),$L=BL,yy=5*60*1e3,HL=function i(e){"use strict";if(ut(this,i),!e.disableRebufferTracking){var t,r=function(n,a){s(a),t=void 0},s=function(n){if(t){var a=n.viewer_time-t;Ze(e.data,"view_rebuffer_duration",a),t=n.viewer_time,e.data.view_rebuffer_duration>yy&&(e.emit("viewend"),e.send("viewend"),e.mux.log.warn("Ending view after rebuffering for longer than ".concat(yy,"ms, future events will be ignored unless a programchange or videochange occurs.")))}e.data.view_watch_time>=0&&e.data.view_rebuffer_count>0&&(e.data.view_rebuffer_frequency=e.data.view_rebuffer_count/e.data.view_watch_time,e.data.view_rebuffer_percentage=e.data.view_rebuffer_duration/e.data.view_watch_time)};e.on("playbackheartbeat",function(n,a){return s(a)}),e.on("rebufferstart",function(n,a){t||(Ze(e.data,"view_rebuffer_count",1),t=a.viewer_time,e.one("rebufferend",r))}),e.on("viewinit",function(){t=void 0,e.off("rebufferend",r)})}},GL=HL,WL=function(){"use strict";function i(e){var t=this;ut(this,i),H(this,"_lastCheckedTime",void 0),H(this,"_lastPlayheadTime",void 0),H(this,"_lastPlayheadTimeUpdatedTime",void 0),H(this,"_rebuffering",void 0),H(this,"pm",void 0),this.pm=e,!(e.disableRebufferTracking||e.disablePlayheadRebufferTracking)&&(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,e.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),e.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),e.on("seeking",function(){t._cleanupRebufferTracker(null,{viewer_time:tt.now()})}))}return qi(i,[{key:"_checkIfRebuffering",value:function(e,t){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing){this._cleanupRebufferTracker(e,t);return}if(this._lastCheckedTime===null){this._prepareRebufferTrackerState(t.viewer_time);return}if(this._lastPlayheadTime!==this.pm.data.player_playhead_time){this._cleanupRebufferTracker(e,t,!0);return}var r=t.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&r>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=t.viewer_time}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(e){this._lastCheckedTime=e,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=e}},{key:"_cleanupRebufferTracker",value:function(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:t.viewer_time});else{if(this._lastCheckedTime===null)return;var s=this.pm.data.player_playhead_time-this._lastPlayheadTime,n=t.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&s>0&&n-s>this.pm.minimumRebufferDuration&&(this._lastCheckedTime=null,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+n-s}))}r?this._prepareRebufferTrackerState(t.viewer_time):this._clearRebufferTrackerState()}}]),i}(),KL=WL,VL=function(){"use strict";function i(e){var t=this;ut(this,i),H(this,"NAVIGATION_START",void 0),H(this,"pm",void 0),this.pm=e,e.on("viewinit",function(){var r=e.data,s=r.view_id;if(!r.view_program_changed){var n=function(a,o){var l=o.viewer_time;(a.type==="playing"&&typeof e.data.view_time_to_first_frame=="undefined"||a.type==="adplaying"&&(typeof e.data.view_time_to_first_frame=="undefined"||t._inPrerollPosition()))&&t.calculateTimeToFirstFrame(l||tt.now(),s)};e.one("playing",n),e.one("adplaying",n),e.one("viewend",function(){e.off("playing",n),e.off("adplaying",n)})}})}return qi(i,[{key:"_inPrerollPosition",value:function(){return typeof this.pm.data.view_content_playback_time=="undefined"||this.pm.data.view_content_playback_time<=1e3}},{key:"calculateTimeToFirstFrame",value:function(e,t){t===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:e}),this.pm.data.view_time_to_first_frame=this.pm.data.view_watch_time,(this.pm.data.player_autoplay_on||this.pm.data.video_is_autoplay)&&this.NAVIGATION_START&&(this.pm.data.view_aggregate_startup_time=this.pm.data.view_start+this.pm.data.view_watch_time-this.NAVIGATION_START))}}]),i}(),qL=VL,YL=function i(e){"use strict";var t=this;ut(this,i),H(this,"_lastPlayerHeight",void 0),H(this,"_lastPlayerWidth",void 0),H(this,"_lastPlayheadPosition",void 0),H(this,"_lastSourceHeight",void 0),H(this,"_lastSourceWidth",void 0),e.on("viewinit",function(){t._lastPlayheadPosition=-1});var r=["pause","rebufferstart","seeking","error","adbreakstart","hb"],s=["playing","hb"];r.forEach(function(n){e.on(n,function(){if(t._lastPlayheadPosition>=0&&e.data.player_playhead_time>=0&&t._lastPlayerWidth>=0&&t._lastSourceWidth>0&&t._lastPlayerHeight>=0&&t._lastSourceHeight>0){var a=e.data.player_playhead_time-t._lastPlayheadPosition;if(a<0){t._lastPlayheadPosition=-1;return}var o=Math.min(t._lastPlayerWidth/t._lastSourceWidth,t._lastPlayerHeight/t._lastSourceHeight),l=Math.max(0,o-1),d=Math.max(0,1-o);e.data.view_max_upscale_percentage=Math.max(e.data.view_max_upscale_percentage||0,l),e.data.view_max_downscale_percentage=Math.max(e.data.view_max_downscale_percentage||0,d),Ze(e.data,"view_total_content_playback_time",a),Ze(e.data,"view_total_upscaling",l*a),Ze(e.data,"view_total_downscaling",d*a)}t._lastPlayheadPosition=-1})}),s.forEach(function(n){e.on(n,function(){t._lastPlayheadPosition=e.data.player_playhead_time,t._lastPlayerWidth=e.data.player_width,t._lastPlayerHeight=e.data.player_height,t._lastSourceWidth=e.data.video_source_width,t._lastSourceHeight=e.data.video_source_height})})},zL=YL,jL=2e3,XL=function i(e){"use strict";var t=this;ut(this,i),H(this,"isSeeking",void 0),this.isSeeking=!1;var r=-1,s=function(){var n=tt.now(),a=(e.data.viewer_time||n)-(r||n);Ze(e.data,"view_seek_duration",a),e.data.view_max_seek_time=Math.max(e.data.view_max_seek_time||0,a),t.isSeeking=!1,r=-1};e.on("seeking",function(n,a){if(Object.assign(e.data,a),t.isSeeking&&a.viewer_time-r<=jL){r=a.viewer_time;return}t.isSeeking&&s(),t.isSeeking=!0,r=a.viewer_time,Ze(e.data,"view_seek_count",1),e.send("seeking")}),e.on("seeked",function(){s()}),e.on("viewend",function(){t.isSeeking&&(s(),e.send("seeked")),t.isSeeking=!1,r=-1})},QL=XL,Ty=function(i,e){i.push(e),i.sort(function(t,r){return t.viewer_time-r.viewer_time})},ZL=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror","adclicked","adskipped"],JL=function(){"use strict";function i(e){var t=this;ut(this,i),H(this,"_adHasPlayed",void 0),H(this,"_adRequests",void 0),H(this,"_adResponses",void 0),H(this,"_currentAdRequestNumber",void 0),H(this,"_currentAdResponseNumber",void 0),H(this,"_prerollPlayTime",void 0),H(this,"_wouldBeNewAdPlay",void 0),H(this,"isAdBreak",void 0),H(this,"pm",void 0),this.pm=e,e.on("viewinit",function(){t.isAdBreak=!1,t._currentAdRequestNumber=0,t._currentAdResponseNumber=0,t._adRequests=[],t._adResponses=[],t._adHasPlayed=!1,t._wouldBeNewAdPlay=!0,t._prerollPlayTime=void 0}),ZL.forEach(function(s){return e.on(s,t._updateAdData.bind(t))});var r=function(){t.isAdBreak=!1};e.on("adbreakstart",function(){t.isAdBreak=!0}),e.on("play",r),e.on("playing",r),e.on("viewend",r),e.on("adrequest",function(s,n){n=Object.assign({ad_request_id:"generatedAdRequestId"+t._currentAdRequestNumber++},n),Ty(t._adRequests,n),Ze(e.data,"view_ad_request_count"),t.inPrerollPosition()&&(e.data.view_preroll_requested=!0,t._adHasPlayed||Ze(e.data,"view_preroll_request_count"))}),e.on("adresponse",function(s,n){n=Object.assign({ad_request_id:"generatedAdRequestId"+t._currentAdResponseNumber++},n),Ty(t._adResponses,n);var a=t.findAdRequest(n.ad_request_id);a&&Ze(e.data,"view_ad_request_time",Math.max(0,n.viewer_time-a.viewer_time))}),e.on("adplay",function(s,n){t._adHasPlayed=!0,t._wouldBeNewAdPlay&&(t._wouldBeNewAdPlay=!1,Ze(e.data,"view_ad_played_count")),t.inPrerollPosition()&&!e.data.view_preroll_played&&(e.data.view_preroll_played=!0,t._adRequests.length>0&&(e.data.view_preroll_request_time=Math.max(0,n.viewer_time-t._adRequests[0].viewer_time)),e.data.view_start&&(e.data.view_startup_preroll_request_time=Math.max(0,n.viewer_time-e.data.view_start)),t._prerollPlayTime=n.viewer_time)}),e.on("adplaying",function(s,n){t.inPrerollPosition()&&typeof e.data.view_preroll_load_time=="undefined"&&typeof t._prerollPlayTime!="undefined"&&(e.data.view_preroll_load_time=n.viewer_time-t._prerollPlayTime,e.data.view_startup_preroll_load_time=n.viewer_time-t._prerollPlayTime)}),e.on("adclicked",function(s,n){t._wouldBeNewAdPlay||Ze(e.data,"view_ad_clicked_count")}),e.on("adskipped",function(s,n){t._wouldBeNewAdPlay||Ze(e.data,"view_ad_skipped_count")}),e.on("adended",function(){t._wouldBeNewAdPlay=!0}),e.on("aderror",function(){t._wouldBeNewAdPlay=!0})}return qi(i,[{key:"inPrerollPosition",value:function(){return typeof this.pm.data.view_content_playback_time=="undefined"||this.pm.data.view_content_playback_time<=1e3}},{key:"findAdRequest",value:function(e){for(var t=0;t<this._adRequests.length;t++)if(this._adRequests[t].ad_request_id===e)return this._adRequests[t]}},{key:"_updateAdData",value:function(e,t){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&t.ad_tag_url){var r=ys(io(t.ad_tag_url),2),s=r[0],n=r[1];this.pm.data.view_preroll_ad_tag_domain=n,this.pm.data.view_preroll_ad_tag_hostname=s}if(!this.pm.data.view_preroll_ad_asset_hostname&&t.ad_asset_url){var a=ys(io(t.ad_asset_url),2),o=a[0],l=a[1];this.pm.data.view_preroll_ad_asset_domain=l,this.pm.data.view_preroll_ad_asset_hostname=o}}this.pm.data.ad_asset_url=t==null?void 0:t.ad_asset_url,this.pm.data.ad_tag_url=t==null?void 0:t.ad_tag_url,this.pm.data.ad_creative_id=t==null?void 0:t.ad_creative_id,this.pm.data.ad_id=t==null?void 0:t.ad_id,this.pm.data.ad_universal_id=t==null?void 0:t.ad_universal_id}}]),i}(),ek=JL,_y=Dt(Vi()),tk=function i(e){"use strict";ut(this,i);var t,r,s=function(){e.disableRebufferTracking||(Ze(e.data,"view_waiting_rebuffer_count",1),t=tt.now(),r=_y.default.setInterval(function(){if(t){var d=tt.now();Ze(e.data,"view_waiting_rebuffer_duration",d-t),t=d}},250))},n=function(){e.disableRebufferTracking||t&&(Ze(e.data,"view_waiting_rebuffer_duration",tt.now()-t),t=!1,_y.default.clearInterval(r))},a=!1,o=function(){a=!0},l=function(){a=!1,n()};e.on("waiting",function(){a&&s()}),e.on("playing",function(){n(),o()}),e.on("pause",l),e.on("seeking",l)},ik=tk,rk=function i(e){"use strict";var t=this;ut(this,i),H(this,"lastWallClockTime",void 0);var r=function(){t.lastWallClockTime=tt.now(),e.on("before*",s)},s=function(n){var a=tt.now(),o=t.lastWallClockTime;t.lastWallClockTime=a,a-o>3e4&&(e.emit("devicesleep",{viewer_time:o}),Object.assign(e.data,{viewer_time:o}),e.send("devicesleep"),e.emit("devicewake",{viewer_time:a}),Object.assign(e.data,{viewer_time:a}),e.send("devicewake"))};e.one("playbackheartbeat",r),e.on("playbackheartbeatend",function(){e.off("before*",s),e.one("playbackheartbeat",r)})},sk=rk,np=Dt(Vi()),Py=Dt(Xx()),Oy=Dt(Qx()),Ny="muxData",Uy=function(){var i;try{i=Py.default.parse(Oy.default.get(Ny)||"")}catch{i={}}return i},Fy=function(i){try{Oy.default.set(Ny,Py.default.stringify(i),{expires:365})}catch{}},nk=function(){var i=Uy();return i.mux_viewer_id=i.mux_viewer_id||eo(),i.msn=i.msn||Math.random(),Fy(i),{mux_viewer_id:i.mux_viewer_id,mux_sample_number:i.msn}},ak=function(){var i=Uy(),e=tt.now();return i.session_start&&(i.sst=i.session_start,delete i.session_start),i.session_id&&(i.sid=i.session_id,delete i.session_id),i.session_expires&&(i.sex=i.session_expires,delete i.session_expires),(!i.sex||i.sex<e)&&(i.sid=eo(),i.sst=e),i.sex=e+25*60*1e3,Fy(i),{session_id:i.sid,session_start:i.sst,session_expires:i.sex}};function ok(i,e){var t=e.beaconCollectionDomain,r=e.beaconDomain;if(t)return"https://"+t;i=i||"inferred";var s=r||"litix.io";return i.match(/^[a-z0-9]+$/)?"https://"+i+"."+s:"https://img.litix.io/a.gif"}var lk=Dt(Vi()),By=function(){var i;switch($y()){case"cellular":i="cellular";break;case"ethernet":i="wired";break;case"wifi":i="wifi";break;case void 0:break;default:i="other"}return i},$y=function(){var i=lk.default.navigator,e=i&&(i.connection||i.mozConnection||i.webkitConnection);return e&&e.type};By.getConnectionFromAPI=$y;var dk=By,uk={a:"env",b:"beacon",c:"custom",d:"ad",e:"event",f:"experiment",i:"internal",m:"mux",n:"response",p:"player",q:"request",r:"retry",s:"session",t:"timestamp",u:"viewer",v:"video",w:"page",x:"view",y:"sub"},ck=Hy(uk),hk={ad:"ad",ag:"aggregate",ap:"api",al:"application",ar:"architecture",as:"asset",au:"autoplay",av:"average",bi:"bitrate",br:"break",bw:"browser",by:"bytes",bz:"business",ca:"cached",cb:"cancel",cc:"codec",cd:"code",cg:"category",ch:"changed",ck:"clicked",cl:"canceled",cn:"config",co:"count",ce:"counter",cp:"complete",cr:"creative",ct:"content",cu:"current",cx:"connection",cz:"context",dg:"downscaling",dm:"domain",dn:"cdn",do:"downscale",dr:"drm",dp:"dropped",du:"duration",dv:"device",ec:"encoding",ed:"edge",en:"end",eg:"engine",em:"embed",er:"error",ep:"experiments",es:"errorcode",et:"errortext",ee:"event",ev:"events",ex:"expires",ez:"exception",fa:"failed",fi:"first",fm:"family",ft:"format",fp:"fps",fq:"frequency",fr:"frame",fs:"fullscreen",ha:"has",hb:"holdback",he:"headers",ho:"host",hn:"hostname",ht:"height",id:"id",ii:"init",in:"instance",ip:"ip",is:"is",ke:"key",la:"language",lb:"labeled",le:"level",li:"live",ld:"loaded",lo:"load",ls:"lists",lt:"latency",ma:"max",md:"media",me:"message",mf:"manifest",mi:"mime",ml:"midroll",mm:"min",mn:"manufacturer",mo:"model",mx:"mux",ne:"newest",nm:"name",no:"number",on:"on",os:"os",pa:"paused",pb:"playback",pd:"producer",pe:"percentage",pf:"played",pg:"program",ph:"playhead",pi:"plugin",pl:"preroll",pn:"playing",po:"poster",pr:"preload",ps:"position",pt:"part",py:"property",ra:"rate",rd:"requested",re:"rebuffer",rf:"rendition",rm:"remote",ro:"ratio",rp:"response",rq:"request",rs:"requests",sa:"sample",sd:"skipped",se:"session",sk:"seek",sm:"stream",so:"source",sq:"sequence",sr:"series",st:"start",su:"startup",sv:"server",sw:"software",sy:"severity",ta:"tag",tc:"tech",te:"text",tg:"target",th:"throughput",ti:"time",tl:"total",to:"to",tt:"title",ty:"type",ug:"upscaling",un:"universal",up:"upscale",ur:"url",us:"user",va:"variant",vd:"viewed",vi:"video",ve:"version",vw:"view",vr:"viewer",wd:"width",wa:"watch",wt:"waiting"},Ay=Hy(hk);function Hy(i){var e={};for(var t in i)i.hasOwnProperty(t)&&(e[i[t]]=t);return e}function up(i){var e={},t={};return Object.keys(i).forEach(function(r){var s=!1;if(i.hasOwnProperty(r)&&i[r]!==void 0){var n=r.split("_"),a=n[0],o=ck[a];o||(We.info("Data key word `"+n[0]+"` not expected in "+r),o=a+"_"),n.splice(1).forEach(function(l){l==="url"&&(s=!0),Ay[l]?o+=Ay[l]:Number(l)&&Math.floor(Number(l))===Number(l)?o+=l:(We.info("Data key word `"+l+"` not expected in "+r),o+="_"+l+"_")}),s?t[o]=i[r]:e[o]=i[r]}}),Object.assign(e,t)}var bs=Dt(Vi()),fk={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},mk=56*1024,pk=["hb","requestcompleted","requestfailed","requestcanceled"],gk="https://img.litix.io",lr=function(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=i||gk,this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=Object.assign({},fk,e)};lr.prototype.queueEvent=function(i,e){var t=Object.assign({},e);return this._eventQueue.length<=this._options.maxQueueLength||i==="eventrateexceeded"?(this._eventQueue.push(t),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength):!1};lr.prototype.flushEvents=function(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;if(i&&this._eventQueue.length===1){this._eventQueue.pop();return}this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending()};lr.prototype.destroy=function(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;this.destroyed=!0,i?this._clearBeaconQueue():this.flushEvents(),bs.default.clearTimeout(this._sendTimeout)};lr.prototype._clearBeaconQueue=function(){var i=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,e=this._eventQueue.slice(i);i>0&&Object.assign(e[e.length-1],up({mux_view_message:"event queue truncated"}));var t=this._createPayload(e);Gy(this._beaconUrl,t,!0,function(){})};lr.prototype._sendBeaconQueue=function(){var i=this;if(!this._postInFlight){var e=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var t=this._createPayload(e),r=tt.now();Gy(this._beaconUrl,t,!1,function(s,n){n?(i._eventQueue=e.concat(i._eventQueue),i._failureCount+=1,We.info("Error sending beacon: "+n)):i._failureCount=0,i._roundTripTime=tt.now()-r,i._postInFlight=!1})}};lr.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var i=Math.pow(2,this._failureCount-1);return i=i*Math.random(),(1+i)*this._options.baseTimeBetweenBeacons};lr.prototype._startBeaconSending=function(){var i=this;bs.default.clearTimeout(this._sendTimeout),!this.destroyed&&(this._sendTimeout=bs.default.setTimeout(function(){i._eventQueue.length&&i._sendBeaconQueue(),i._startBeaconSending()},this._getNextBeaconTime()))};lr.prototype._createPayload=function(i){var e=this,t={transmission_timestamp:Math.round(tt.now())};this._roundTripTime&&(t.rtt_ms=Math.round(this._roundTripTime));var r,s,n,a=function(){r=JSON.stringify({metadata:t,events:s||i}),n=r.length/1024},o=function(){return n<=e._options.maxPayloadKBSize};return a(),o()||(We.info("Payload size is too big ("+n+" kb). Removing unnecessary events."),s=i.filter(function(l){return pk.indexOf(l.e)===-1}),a()),o()||(We.info("Payload size still too big ("+n+" kb). Cropping fields.."),s.forEach(function(l){for(var d in l){var u=l[d],c=50*1024;typeof u=="string"&&u.length>c&&(l[d]=u.substring(0,c))}}),a()),r};var vk=function(i){return i.length<=mk},Gy=function(i,e,t,r){if(t&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(i,e)){r();return}if(bs.default.fetch){bs.default.fetch(i,{method:"POST",body:e,headers:{"Content-Type":"text/plain"},keepalive:vk(e)}).then(function(n){return r(null,n.ok?null:"Error")}).catch(function(n){return r(null,n)});return}if(bs.default.XMLHttpRequest){var s=new bs.default.XMLHttpRequest;s.onreadystatechange=function(){if(s.readyState===4)return r(null,s.status!==200?"error":void 0)},s.open("POST",i),s.setRequestHeader("Content-Type","text/plain"),s.send(e);return}r()},Ek=lr,bk=["env_key","view_id","view_sequence_number","player_sequence_number","beacon_domain","player_playhead_time","viewer_time","mux_api_version","event","video_id","player_instance_id","player_error_code","player_error_message","player_error_context","player_error_severity","player_error_business_exception"],yk=["adplay","adplaying","adpause","adfirstquartile","admidpoint","adthirdquartile","adended","adresponse","adrequest"],Tk=["ad_id","ad_creative_id","ad_universal_id"],_k=["viewstart","error","ended","viewend"],Ak=10*60*1e3,Sk=function(){"use strict";function i(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};ut(this,i);var s,n,a,o,l,d,u,c,h,f,m,p;H(this,"mux",void 0),H(this,"envKey",void 0),H(this,"options",void 0),H(this,"eventQueue",void 0),H(this,"sampleRate",void 0),H(this,"disableCookies",void 0),H(this,"respectDoNotTrack",void 0),H(this,"previousBeaconData",void 0),H(this,"lastEventTime",void 0),H(this,"rateLimited",void 0),H(this,"pageLevelData",void 0),H(this,"viewerData",void 0),this.mux=e,this.envKey=t,this.options=r,this.previousBeaconData=null,this.lastEventTime=0,this.rateLimited=!1,this.eventQueue=new Ek(ok(this.envKey,this.options));var g;this.sampleRate=(g=this.options.sampleRate)!==null&&g!==void 0?g:1;var E;this.disableCookies=(E=this.options.disableCookies)!==null&&E!==void 0?E:!1;var T;this.respectDoNotTrack=(T=this.options.respectDoNotTrack)!==null&&T!==void 0?T:!1,this.previousBeaconData=null,this.lastEventTime=0,this.rateLimited=!1,this.pageLevelData={mux_api_version:this.mux.API_VERSION,mux_embed:this.mux.NAME,mux_embed_version:this.mux.VERSION,viewer_application_name:(s=this.options.platform)===null||s===void 0?void 0:s.name,viewer_application_version:(n=this.options.platform)===null||n===void 0?void 0:n.version,viewer_application_engine:(a=this.options.platform)===null||a===void 0?void 0:a.layout,viewer_device_name:(o=this.options.platform)===null||o===void 0?void 0:o.product,viewer_device_category:"",viewer_device_manufacturer:(l=this.options.platform)===null||l===void 0?void 0:l.manufacturer,viewer_os_family:(u=this.options.platform)===null||u===void 0||(d=u.os)===null||d===void 0?void 0:d.family,viewer_os_architecture:(h=this.options.platform)===null||h===void 0||(c=h.os)===null||c===void 0?void 0:c.architecture,viewer_os_version:(m=this.options.platform)===null||m===void 0||(f=m.os)===null||f===void 0?void 0:f.version,viewer_connection_type:dk(),page_url:np.default===null||np.default===void 0||(p=np.default.location)===null||p===void 0?void 0:p.href},this.viewerData=this.disableCookies?{}:nk()}return qi(i,[{key:"send",value:function(e,t){if(!(!e||!(t!=null&&t.view_id))){if(this.respectDoNotTrack&&lp())return We.info("Not sending `"+e+"` because Do Not Track is enabled");if(!t||typeof t!="object")return We.error("A data object was expected in send() but was not provided");var r=this.disableCookies?{}:ak(),s=cp(Tu({},this.pageLevelData,t,r,this.viewerData),{event:e,env_key:this.envKey});s.user_id&&(s.viewer_user_id=s.user_id,delete s.user_id);var n,a=((n=s.mux_sample_number)!==null&&n!==void 0?n:0)>=this.sampleRate,o=this._deduplicateBeaconData(e,s),l=up(o);if(this.lastEventTime=this.mux.utils.now(),a)return We.info("Not sending event due to sample rate restriction",e,s,l);if(this.envKey||We.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",e,s,l),!this.rateLimited){if(We.info("Sending event",e,s,l),this.rateLimited=!this.eventQueue.queueEvent(e,l),this.mux.WINDOW_UNLOADING&&e==="viewend")this.eventQueue.destroy(!0);else if(this.mux.WINDOW_HIDDEN&&e==="hb"?this.eventQueue.flushEvents(!0):_k.indexOf(e)>=0&&this.eventQueue.flushEvents(),this.rateLimited)return s.event="eventrateexceeded",l=up(s),this.eventQueue.queueEvent(s.event,l),We.error("Beaconing disabled due to rate limit.")}}}},{key:"destroy",value:function(){this.eventQueue.destroy(!1)}},{key:"_deduplicateBeaconData",value:function(e,t){var r=this,s={},n=t.view_id;if(n==="-1"||e==="viewstart"||e==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=Ak)s=Tu({},t),n&&(this.previousBeaconData=s),n&&e==="viewend"&&(this.previousBeaconData=null);else{var a=e.indexOf("request")===0;Object.entries(t).forEach(function(o){var l=ys(o,2),d=l[0],u=l[1];r.previousBeaconData&&(u!==r.previousBeaconData[d]||bk.indexOf(d)>-1||r.objectHasChanged(a,d,u,r.previousBeaconData[d])||r.eventRequiresKey(e,d))&&(s[d]=u,r.previousBeaconData[d]=u)})}return s}},{key:"objectHasChanged",value:function(e,t,r,s){return!e||t.indexOf("request_")!==0?!1:t==="request_response_headers"||typeof r!="object"||typeof s!="object"?!0:Object.keys(r||{}).length!==Object.keys(s||{}).length}},{key:"eventRequiresKey",value:function(e,t){return!!(e==="renditionchange"&&t.indexOf("video_source_")===0||Tk.includes(t)&&yk.includes(e))}}]),i}(),xk=function i(e){"use strict";ut(this,i);var t=0,r=0,s=0,n=0,a=0,o=0,l=0,d=function(h,f){var m=f.request_start,p=f.request_response_start,g=f.request_response_end,E=f.request_bytes_loaded;n++;var T,y;if(p?(T=p-(m!=null?m:0),y=(g!=null?g:0)-p):y=(g!=null?g:0)-(m!=null?m:0),y>0&&E&&E>0){var S=E/y*8e3;a++,r+=E,s+=y,e.data.view_min_request_throughput=Math.min(e.data.view_min_request_throughput||1/0,S),e.data.view_average_request_throughput=r/s*8e3,e.data.view_request_count=n,T>0&&(t+=T,e.data.view_max_request_latency=Math.max(e.data.view_max_request_latency||0,T),e.data.view_average_request_latency=t/a)}},u=function(h,f){n++,o++,e.data.view_request_count=n,e.data.view_request_failed_count=o},c=function(h,f){n++,l++,e.data.view_request_count=n,e.data.view_request_canceled_count=l};e.on("requestcompleted",d),e.on("requestfailed",u),e.on("requestcanceled",c)},Lk=xk,kk=60*60*1e3,Ik=function i(e){"use strict";var t=this;ut(this,i),H(this,"_lastEventTime",void 0),e.on("before*",function(r,s){var n=s.viewer_time,a=tt.now(),o=t._lastEventTime;if(t._lastEventTime=a,o&&a-o>kk){var l=Object.keys(e.data).reduce(function(d,u){return u.indexOf("video_")===0?Object.assign(d,H({},u,e.data[u])):d},{});e.mux.log.info("Received event after at least an hour inactivity, creating a new view"),e.emit("viewinit",Object.assign({viewer_time:n},l)),e.playbackHeartbeat._playheadShouldBeProgressing&&r.type!=="play"&&r.type!=="adbreakstart"&&(e.emit("play",{viewer_time:n}),r.type!=="playing"&&e.emit("playing",{viewer_time:n}))}})},Rk=Ik,wk=["viewstart","ended","loadstart","pause","play","playing","ratechange","waiting","adplay","adpause","adended","aderror","adplaying","adrequest","adresponse","adbreakstart","adbreakend","adfirstquartile","admidpoint","adthirdquartile","rebufferstart","rebufferend","seeked","error","hb","requestcompleted","requestfailed","requestcanceled","renditionchange"],Ck=function(i){"use strict";fL(t,i);var e=gL(t);function t(r,s,n){ut(this,t);var a;a=e.call(this),H(re(a),"DOM_CONTENT_LOADED_EVENT_END",void 0),H(re(a),"NAVIGATION_START",void 0),H(re(a),"_destroyed",void 0),H(re(a),"_heartBeatTimeout",void 0),H(re(a),"adTracker",void 0),H(re(a),"dashjs",void 0),H(re(a),"data",void 0),H(re(a),"disablePlayheadRebufferTracking",void 0),H(re(a),"disableRebufferTracking",void 0),H(re(a),"errorTracker",void 0),H(re(a),"errorTranslator",void 0),H(re(a),"getAdData",void 0),H(re(a),"getPlayheadTime",void 0),H(re(a),"getStateData",void 0),H(re(a),"hlsjs",void 0),H(re(a),"id",void 0),H(re(a),"longResumeTracker",void 0),H(re(a),"minimumRebufferDuration",void 0),H(re(a),"mux",void 0),H(re(a),"oldEmit",void 0),H(re(a),"playbackEventDispatcher",void 0),H(re(a),"playbackHeartbeat",void 0),H(re(a),"playbackHeartbeatTime",void 0),H(re(a),"playheadTime",void 0),H(re(a),"seekingTracker",void 0),H(re(a),"sustainedRebufferThreshold",void 0),H(re(a),"watchTimeTracker",void 0),H(re(a),"currentFragmentPDT",void 0),H(re(a),"currentFragmentStart",void 0),a.DOM_CONTENT_LOADED_EVENT_END=yu.domContentLoadedEventEnd(),a.NAVIGATION_START=yu.navigationStart();var o={debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(f){return f}};a.mux=r,a.id=s,n!=null&&n.beaconDomain&&a.mux.log.warn("The `beaconDomain` setting has been deprecated in favor of `beaconCollectionDomain`. Please change your integration to use `beaconCollectionDomain` instead of `beaconDomain`."),n=Object.assign(o,n),n.data=n.data||{},n.data.property_key&&(n.data.env_key=n.data.property_key,delete n.data.property_key),We.setLevel(n.debug?"debug":"warn"),a.getPlayheadTime=n.getPlayheadTime,a.getStateData=n.getStateData||function(){return{}},a.getAdData=n.getAdData||function(){},a.minimumRebufferDuration=n.minimumRebufferDuration,a.sustainedRebufferThreshold=n.sustainedRebufferThreshold,a.playbackHeartbeatTime=n.playbackHeartbeatTime,a.disableRebufferTracking=n.disableRebufferTracking,a.disableRebufferTracking&&a.mux.log.warn("Disabling rebuffer tracking. This should only be used in specific circumstances as a last resort when your player is known to unreliably track rebuffering."),a.disablePlayheadRebufferTracking=n.disablePlayheadRebufferTracking,a.errorTranslator=n.errorTranslator,a.playbackEventDispatcher=new Sk(r,n.data.env_key,n),a.data={player_instance_id:eo(),mux_sample_rate:n.sampleRate,beacon_domain:n.beaconCollectionDomain||n.beaconDomain},a.data.view_sequence_number=1,a.data.player_sequence_number=1,a.oldEmit=a.emit,a.emit=function(f,m){m=Object.assign({viewer_time:this.mux.utils.now()},m),this.oldEmit(f,m)};var l=function(){typeof this.data.view_start=="undefined"&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(re(a));a.on("viewinit",function(f,m){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),Object.assign(this.data,m),this._initializeViewData(),this.one("play",l),this.one("adbreakstart",l)});var d=function(f){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",f)}.bind(re(a));if(a.on("videochange",function(f,m){d(m)}),a.on("programchange",function(f,m){this.data.player_is_paused&&this.mux.log.warn("The `programchange` event is intended to be used when the content changes mid playback without the video source changing, however the video is not currently playing. If the video source is changing please use the videochange event otherwise you will lose startup time information."),d(Object.assign(m,{view_program_changed:!0})),l(),this.emit("play"),this.emit("playing")}),a.on("fragmentchange",function(f,m){this.currentFragmentPDT=m.currentFragmentPDT,this.currentFragmentStart=m.currentFragmentStart}),a.on("destroy",a.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var u=function(){var f=typeof a.data.view_start!="undefined";a.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",f&&a.mux.WINDOW_HIDDEN&&(a.data.player_is_paused||a.emit("hb"))};window.addEventListener("visibilitychange",u,!1);var c=function(f){f.persisted||a.destroy()};window.addEventListener("pagehide",c,!1),a.on("destroy",function(){window.removeEventListener("visibilitychange",u),window.removeEventListener("pagehide",c)})}a.on("playerready",function(f,m){Object.assign(this.data,m)}),wk.forEach(function(f){a.on(f,function(m,p){f.indexOf("ad")!==0&&this._updateStateData(),Object.assign(this.data,p),this._sanitizeData()}),a.on("after"+f,function(){(f!=="error"||this.errorTracker.viewErrored)&&this.send(f)})}),a.on("viewend",function(f,m){Object.assign(a.data,m)});var h=function(f){var m=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=m-this.data.player_init_time),!this.mux.PLAYER_TRACKED&&this.NAVIGATION_START&&(this.mux.PLAYER_TRACKED=!0,(this.data.player_init_time||this.DOM_CONTENT_LOADED_EVENT_END)&&(this.data.page_load_time=Math.min(this.data.player_init_time||1/0,this.DOM_CONTENT_LOADED_EVENT_END||1/0)-this.NAVIGATION_START)),this.send("playerready"),delete this.data.player_startup_time,delete this.data.page_load_time};return a.one("playerready",h),a.longResumeTracker=new Rk(re(a)),a.errorTracker=new PL(re(a)),new sk(re(a)),a.seekingTracker=new QL(re(a)),a.playheadTime=new $L(re(a)),a.playbackHeartbeat=new DL(re(a)),new zL(re(a)),a.watchTimeTracker=new NL(re(a)),new FL(re(a)),a.adTracker=new ek(re(a)),new KL(re(a)),new GL(re(a)),new qL(re(a)),new ik(re(a)),new Lk(re(a)),n.hlsjs&&a.addHLSJS(n),n.dashjs&&a.addDashJS(n),a.emit("viewinit",n.data),a}return qi(t,[{key:"destroy",value:function(){this._destroyed||(this._destroyed=!0,typeof this.data.view_start!="undefined"&&(this.emit("viewend"),this.send("viewend")),this.playbackEventDispatcher.destroy(),this.removeHLSJS(),this.removeDashJS(),window.clearTimeout(this._heartBeatTimeout))}},{key:"send",value:function(r){if(this.data.view_id){var s=Object.assign({},this.data),n=["player_program_time","player_manifest_newest_program_time","player_live_edge_program_time","player_program_time","video_holdback","video_part_holdback","video_target_duration","video_part_target_duration"];if(s.video_source_is_live===void 0&&(s.player_source_duration===1/0||s.video_source_duration===1/0?s.video_source_is_live=!0:(s.player_source_duration>0||s.video_source_duration>0)&&(s.video_source_is_live=!1)),s.video_source_is_live||n.forEach(function(d){s[d]=void 0}),s.video_source_url=s.video_source_url||s.player_source_url,s.video_source_url){var a=ys(io(s.video_source_url),2),o=a[0],l=a[1];s.video_source_domain=l,s.video_source_hostname=o}delete s.ad_request_id,this.playbackEventDispatcher.send(r,s),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat(),r==="viewend"&&delete this.data.view_id}}},{key:"_updateStateData",value:function(){Object.assign(this.data,this.getStateData()),this.playheadTime._updatePlayheadTime(),this._sanitizeData()}},{key:"_sanitizeData",value:function(){var r=this,s=["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"];s.forEach(function(a){var o=parseInt(r.data[a],10);r.data[a]=isNaN(o)?void 0:o});var n=["player_source_url","video_source_url"];n.forEach(function(a){if(r.data[a]){var o=r.data[a].toLowerCase();(o.indexOf("data:")===0||o.indexOf("blob:")===0)&&(r.data[a]="MSE style URL")}})}},{key:"_resetVideoData",value:function(){var r=this;Object.keys(this.data).forEach(function(s){s.indexOf("video_")===0&&delete r.data[s]})}},{key:"_resetViewData",value:function(){var r=this;Object.keys(this.data).forEach(function(s){s.indexOf("view_")===0&&delete r.data[s]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(){delete this.data.player_error_code,delete this.data.player_error_message,delete this.data.player_error_context,delete this.data.player_error_severity,delete this.data.player_error_business_exception}},{key:"_initializeViewData",value:function(){var r=this,s=this.data.view_id=eo(),n=function(){s===r.data.view_id&&Ze(r.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",n):n()}},{key:"_restartHeartBeat",value:function(){var r=this;window.clearTimeout(this._heartBeatTimeout),this.errorTracker.viewErrored||(this._heartBeatTimeout=window.setTimeout(function(){r.data.player_is_paused||r.emit("hb")},1e4))}},{key:"addHLSJS",value:function(r){if(!r.hlsjs){this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.");return}if(this.hlsjs){this.mux.log.warn("An instance of HLS.js is already being monitored for this player.");return}this.hlsjs=r.hlsjs,_L(this.mux,this.id,r.hlsjs,{},r.Hls||window.Hls)}},{key:"removeHLSJS",value:function(){this.hlsjs&&(AL(this.hlsjs),this.hlsjs=void 0)}},{key:"addDashJS",value:function(r){if(!r.dashjs){this.mux.log.warn("You must pass a valid dashjs instance in order to track it.");return}if(this.dashjs){this.mux.log.warn("An instance of Dash.js is already being monitored for this player.");return}this.dashjs=r.dashjs,kL(this.mux,this.id,r.dashjs)}},{key:"removeDashJS",value:function(){this.dashjs&&(IL(this.dashjs),this.dashjs=void 0)}}]),t}(wL),Dk=Ck;Au();var Qa=Dt(nL());function Mk(){return Qa.default&&!!(Qa.default.fullscreenElement||Qa.default.webkitFullscreenElement||Qa.default.mozFullScreenElement||Qa.default.msFullscreenElement)}var Pk=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],Ok={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"};function Nk(i,e,t){var r=ys(op(e),3),s=r[0],n=r[1],a=r[2],o=i.log,l=i.utils.getComputedStyle,d=i.utils.secondsToMs,u={automaticErrorTracking:!0};if(s){if(a!=="video"&&a!=="audio")return o.error("The element of `"+n+"` was not a media element.")}else return o.error("No element was found with the `"+n+"` query selector.");s.mux&&(s.mux.destroy(),delete s.mux,o.warn("Already monitoring this video element, replacing existing event listeners")),t=Object.assign(u,t),t.data=Object.assign({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:i.VERSION},t.data),t.getPlayheadTime=function(){return d(s.currentTime)},t.getStateData=function(){var h,f=this.hlsjs&&this.hlsjs.url,m=this.dashjs&&St(this.dashjs.getSource==="function")&&this.dashjs.getSource(),p={player_is_paused:s.paused,player_playhead_time:d(s.currentTime),player_width:parseInt(l(s,"width")),player_height:parseInt(l(s,"height")),player_autoplay_on:s.autoplay,player_preload_on:s.preload,player_language_code:s.lang,player_is_fullscreen:Mk(),video_poster_url:s.poster,video_source_url:f||m||s.currentSrc,video_source_duration:d(s.duration),video_source_height:s.videoHeight,video_source_width:s.videoWidth,view_dropped_frame_count:s==null||(h=s.getVideoPlaybackQuality)===null||h===void 0?void 0:h.call(s).droppedVideoFrames},g=t.getPlayheadTime();if(s.getStartDate&&g>0){var E=s.getStartDate();if(E&&typeof E.getTime=="function"&&E.getTime()){var T=E.getTime();if(p.player_program_time=T+g,s.seekable.length>0){var y=T+s.seekable.end(s.seekable.length-1);p.player_live_edge_program_time=y}}}return p},s.mux=s.mux||{},s.mux.deleted=!1,s.mux.emit=function(h,f){i.emit(n,h,f)};var c=function(){o.error("The monitor for this video element has already been destroyed.")};s.mux.destroy=function(){Object.keys(s.mux.listeners).forEach(function(h){s.removeEventListener(h,s.mux.listeners[h],!1)}),delete s.mux.listeners,s.mux.destroy=c,s.mux.swapElement=c,s.mux.emit=c,s.mux.addHLSJS=c,s.mux.addDashJS=c,s.mux.removeHLSJS=c,s.mux.removeDashJS=c,s.mux.deleted=!0,i.emit(n,"destroy")},s.mux.swapElement=function(h){var f=ys(op(h),3),m=f[0],p=f[1],g=f[2];if(m){if(g!=="video"&&g!=="audio")return i.log.error("The element of `"+p+"` was not a media element.")}else return i.log.error("No element was found with the `"+p+"` query selector.");m.muxId=s.muxId,delete s.muxId,m.mux=m.mux||{},m.mux.listeners=Object.assign({},s.mux.listeners),delete s.mux.listeners,Object.keys(m.mux.listeners).forEach(function(E){s.removeEventListener(E,m.mux.listeners[E],!1),m.addEventListener(E,m.mux.listeners[E],!1)}),m.mux.swapElement=s.mux.swapElement,m.mux.destroy=s.mux.destroy,delete s.mux,s=m},s.mux.addHLSJS=function(h){i.addHLSJS(n,h)},s.mux.addDashJS=function(h){i.addDashJS(n,h)},s.mux.removeHLSJS=function(){i.removeHLSJS(n)},s.mux.removeDashJS=function(){i.removeDashJS(n)},i.init(n,t),i.emit(n,"playerready"),s.paused||(i.emit(n,"play"),s.readyState>2&&i.emit(n,"playing")),s.mux.listeners={},Pk.forEach(function(h){h==="error"&&!t.automaticErrorTracking||(s.mux.listeners[h]=function(){var f={};if(h==="error"){if(!s.error||s.error.code===1)return;f.player_error_code=s.error.code,f.player_error_message=Ok[s.error.code]||s.error.message}i.emit(n,h,f)},s.addEventListener(h,s.mux.listeners[h],!1))})}function Uk(i,e,t,r){var s=r;if(i&&typeof i[e]=="function")try{s=i[e].apply(i,t)}catch(n){We.info("safeCall error",n)}return s}var Ja=Dt(Vi()),Nn;Ja.default&&Ja.default.WeakMap&&(Nn=new WeakMap);function Fk(i,e){if(!i||!e||!Ja.default||typeof Ja.default.getComputedStyle!="function")return"";var t;return Nn&&Nn.has(i)&&(t=Nn.get(i)),t||(t=Ja.default.getComputedStyle(i,null),Nn&&Nn.set(i,t)),t.getPropertyValue(e)}function Bk(i){return Math.floor(i*1e3)}var vs={TARGET_DURATION:"#EXT-X-TARGETDURATION",PART_INF:"#EXT-X-PART-INF",SERVER_CONTROL:"#EXT-X-SERVER-CONTROL",INF:"#EXTINF",PROGRAM_DATE_TIME:"#EXT-X-PROGRAM-DATE-TIME",VERSION:"#EXT-X-VERSION",SESSION_DATA:"#EXT-X-SESSION-DATA"},Su=function(i){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(i),this.manifest};Su.prototype.process=function(i){var e;for(this.buffer+=i,e=this.buffer.indexOf(`
1577
1577
  `);e>-1;e=this.buffer.indexOf(`
1578
- `))this.processLine(this.buffer.substring(0,e)),this.buffer=this.buffer.substring(e+1)};Su.prototype.processLine=function(i){var e=i.indexOf(":"),t=Kk(i,e),r=t[0],s=t.length===2?dp(t[1]):void 0;if(r[0]!=="#")this.currentUri.uri=r,this.manifest.segments.push(this.currentUri),this.manifest.targetDuration&&!("duration"in this.currentUri)&&(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(r){case gs.TARGET_DURATION:{if(!isFinite(s)||s<0)return;this.manifest.targetDuration=s,this.setHoldBack();break}case gs.PART_INF:{ip(this.manifest,t),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break}case gs.SERVER_CONTROL:{ip(this.manifest,t),this.setHoldBack();break}case gs.INF:{s===0?this.currentUri.duration=.01:s>0&&(this.currentUri.duration=s);break}case gs.PROGRAM_DATE_TIME:{var n=s,a=new Date(n);this.manifest.dateTimeString||(this.manifest.dateTimeString=n,this.manifest.dateTimeObject=a),this.currentUri.dateTimeString=n,this.currentUri.dateTimeObject=a;break}case gs.VERSION:{ip(this.manifest,t);break}case gs.SESSION_DATA:{var o=qk(t[1]),l=Cy(o);Object.assign(this.manifest.sessionData,l)}}};Su.prototype.setHoldBack=function(){var i=this.manifest,e=i.serverControl,t=i.targetDuration,r=i.partTargetDuration;if(e){var s="holdBack",n="partHoldBack",a=t&&t*3,o=r&&r*2;t&&!e.hasOwnProperty(s)&&(e[s]=a),a&&e[s]<a&&(e[s]=a),r&&!e.hasOwnProperty(n)&&(e[n]=r*3),r&&e[n]<o&&(e[n]=o)}};var ip=function(i,e){var t=Hy(e[0].replace("#EXT-X-","")),r;Vk(e[1])?(r={},r=Object.assign(Wk(e[1]),r)):r=dp(e[1]),i[t]=r},Hy=function(i){return i.toLowerCase().replace(/-(\w)/g,function(e){return e[1].toUpperCase()})},dp=function(i){if(i.toLowerCase()==="yes"||i.toLowerCase()==="no")return i.toLowerCase()==="yes";var e=i.indexOf(":")!==-1?i:parseFloat(i);return isNaN(e)?i:e},Gk=function(i){var e={},t=i.split("=");if(t.length>1){var r=Hy(t[0]);e[r]=dp(t[1])}return e},Wk=function(i){for(var e=i.split(","),t={},r=0;e.length>r;r++){var s=e[r],n=Gk(s);t=Object.assign(n,t)}return t},Vk=function(i){return i.indexOf("=")>-1},Kk=function(i,e){return e===-1?[i]:[i.substring(0,e),i.substring(e+1)]},qk=function(i){var e={};if(i){var t=i.search(","),r=i.slice(0,t),s=i.slice(t+1),n=[r,s];return n.forEach(function(a,o){for(var l=a.replace(/['"]+/g,"").split("="),d=0;d<l.length;d++)l[d]==="DATA-ID"&&(e["DATA-ID"]=l[1-d]),l[d]==="VALUE"&&(e.VALUE=l[1-d])}),{data:e}}},Yk=Su,zk={safeCall:Bk,safeIncrement:Ze,getComputedStyle:$k,secondsToMs:Hk,assign:Object.assign,headersStringToObject:lp,cdnHeadersToRequestId:_u,extractHostnameAndDomain:io,extractHostname:vi,manifestParser:Yk,generateShortID:Ry,generateUUID:eo,now:tt.now},jk=zk,Xk={PLAYER_READY:"playerready",VIEW_INIT:"viewinit",VIDEO_CHANGE:"videochange",PLAY:"play",PAUSE:"pause",PLAYING:"playing",TIME_UPDATE:"timeupdate",SEEKING:"seeking",SEEKED:"seeked",REBUFFER_START:"rebufferstart",REBUFFER_END:"rebufferend",ERROR:"error",ENDED:"ended",RENDITION_CHANGE:"renditionchange",ORIENTATION_CHANGE:"orientationchange",AD_REQUEST:"adrequest",AD_RESPONSE:"adresponse",AD_BREAK_START:"adbreakstart",AD_PLAY:"adplay",AD_PLAYING:"adplaying",AD_PAUSE:"adpause",AD_FIRST_QUARTILE:"adfirstquartile",AD_MID_POINT:"admidpoint",AD_THIRD_QUARTILE:"adthirdquartile",AD_ENDED:"adended",AD_BREAK_END:"adbreakend",AD_ERROR:"aderror",REQUEST_COMPLETED:"requestcompleted",REQUEST_FAILED:"requestfailed",REQUEST_CANCELLED:"requestcanceled"},Qk=Xk,Zk="mux-embed",Jk="5.2.0",eI="2.1",Qt={},wr=function(i){var e=arguments;typeof i=="string"?wr.hasOwnProperty(i)?Za.default.setTimeout(function(){e=Array.prototype.splice.call(e,1),wr[i].apply(null,e)},0):Ge.warn("`"+i+"` is an unknown task"):typeof i=="function"?Za.default.setTimeout(function(){i(wr)},0):Ge.warn("`"+i+"` is invalid.")},tI={loaded:tt.now(),NAME:Zk,VERSION:Jk,API_VERSION:eI,PLAYER_TRACKED:!1,monitor:function(i,e){return Fk(wr,i,e)},destroyMonitor:function(i){var e=bs(rp(i),1),t=e[0];t&&t.mux&&typeof t.mux.destroy=="function"?t.mux.destroy():Ge.error("A video element monitor for `"+i+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(i,e){var t=vs(i);Qt[t]?Qt[t].addHLSJS(e):Ge.error("A monitor for `"+t+"` has not been initialized.")},addDashJS:function(i,e){var t=vs(i);Qt[t]?Qt[t].addDashJS(e):Ge.error("A monitor for `"+t+"` has not been initialized.")},removeHLSJS:function(i){var e=vs(i);Qt[e]?Qt[e].removeHLSJS():Ge.error("A monitor for `"+e+"` has not been initialized.")},removeDashJS:function(i){var e=vs(i);Qt[e]?Qt[e].removeDashJS():Ge.error("A monitor for `"+e+"` has not been initialized.")},init:function(i,e){sp()&&e&&e.respectDoNotTrack&&Ge.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var t=vs(i);Qt[t]=new Pk(wr,t,e)},emit:function(i,e,t){var r=vs(i);Qt[r]?(Qt[r].emit(e,t),e==="destroy"&&delete Qt[r]):Ge.error("A monitor for `"+r+"` has not been initialized.")},checkDoNotTrack:sp,log:Ge,utils:jk,events:Qk,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(wr,tI);typeof Za.default!="undefined"&&typeof Za.default.addEventListener=="function"&&Za.default.addEventListener("pagehide",function(i){i.persisted||(wr.WINDOW_UNLOADING=!0)},!1);var xu=wr;function iI(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var BT={exports:{}};(function(i,e){(function(t){var r=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,s=/^(?=([^\/?#]*))\1([^]*)$/,n=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(l,d,u){if(u=u||{},l=l.trim(),d=d.trim(),!d){if(!u.alwaysNormalize)return l;var c=o.parseURL(l);if(!c)throw new Error("Error trying to parse base URL.");return c.path=o.normalizePath(c.path),o.buildURLFromParts(c)}var h=o.parseURL(d);if(!h)throw new Error("Error trying to parse relative URL.");if(h.scheme)return u.alwaysNormalize?(h.path=o.normalizePath(h.path),o.buildURLFromParts(h)):d;var f=o.parseURL(l);if(!f)throw new Error("Error trying to parse base URL.");if(!f.netLoc&&f.path&&f.path[0]!=="/"){var m=s.exec(f.path);f.netLoc=m[1],f.path=m[2]}f.netLoc&&!f.path&&(f.path="/");var p={scheme:f.scheme,netLoc:h.netLoc,path:null,params:h.params,query:h.query,fragment:h.fragment};if(!h.netLoc&&(p.netLoc=f.netLoc,h.path[0]!=="/"))if(!h.path)p.path=f.path,h.params||(p.params=f.params,h.query||(p.query=f.query));else{var g=f.path,E=g.substring(0,g.lastIndexOf("/")+1)+h.path;p.path=o.normalizePath(E)}return p.path===null&&(p.path=u.alwaysNormalize?o.normalizePath(h.path):h.path),o.buildURLFromParts(p)},parseURL:function(l){var d=r.exec(l);return d?{scheme:d[1]||"",netLoc:d[2]||"",path:d[3]||"",params:d[4]||"",query:d[5]||"",fragment:d[6]||""}:null},normalizePath:function(l){for(l=l.split("").reverse().join("").replace(n,"");l.length!==(l=l.replace(a,"")).length;);return l.split("").reverse().join("")},buildURLFromParts:function(l){return l.scheme+l.netLoc+l.path+l.params+l.query+l.fragment}};i.exports=o})()})(BT);var Fg=BT.exports;function Gy(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(i);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,r)}return t}function ft(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Gy(Object(t),!0).forEach(function(r){nI(i,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):Gy(Object(t)).forEach(function(r){Object.defineProperty(i,r,Object.getOwnPropertyDescriptor(t,r))})}return i}function rI(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var r=t.call(i,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function sI(i){var e=rI(i,"string");return typeof e=="symbol"?e:String(e)}function nI(i,e,t){return e=sI(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Je(){return Je=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},Je.apply(this,arguments)}var q=Number.isFinite||function(i){return typeof i=="number"&&isFinite(i)},aI=Number.isSafeInteger||function(i){return typeof i=="number"&&Math.abs(i)<=oI},oI=Number.MAX_SAFE_INTEGER||9007199254740991,v=function(i){return i.MEDIA_ATTACHING="hlsMediaAttaching",i.MEDIA_ATTACHED="hlsMediaAttached",i.MEDIA_DETACHING="hlsMediaDetaching",i.MEDIA_DETACHED="hlsMediaDetached",i.BUFFER_RESET="hlsBufferReset",i.BUFFER_CODECS="hlsBufferCodecs",i.BUFFER_CREATED="hlsBufferCreated",i.BUFFER_APPENDING="hlsBufferAppending",i.BUFFER_APPENDED="hlsBufferAppended",i.BUFFER_EOS="hlsBufferEos",i.BUFFER_FLUSHING="hlsBufferFlushing",i.BUFFER_FLUSHED="hlsBufferFlushed",i.MANIFEST_LOADING="hlsManifestLoading",i.MANIFEST_LOADED="hlsManifestLoaded",i.MANIFEST_PARSED="hlsManifestParsed",i.LEVEL_SWITCHING="hlsLevelSwitching",i.LEVEL_SWITCHED="hlsLevelSwitched",i.LEVEL_LOADING="hlsLevelLoading",i.LEVEL_LOADED="hlsLevelLoaded",i.LEVEL_UPDATED="hlsLevelUpdated",i.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",i.LEVELS_UPDATED="hlsLevelsUpdated",i.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",i.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",i.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",i.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",i.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",i.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",i.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",i.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",i.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",i.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",i.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",i.CUES_PARSED="hlsCuesParsed",i.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",i.INIT_PTS_FOUND="hlsInitPtsFound",i.FRAG_LOADING="hlsFragLoading",i.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",i.FRAG_LOADED="hlsFragLoaded",i.FRAG_DECRYPTED="hlsFragDecrypted",i.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",i.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",i.FRAG_PARSING_METADATA="hlsFragParsingMetadata",i.FRAG_PARSED="hlsFragParsed",i.FRAG_BUFFERED="hlsFragBuffered",i.FRAG_CHANGED="hlsFragChanged",i.FPS_DROP="hlsFpsDrop",i.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",i.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",i.ERROR="hlsError",i.DESTROYING="hlsDestroying",i.KEY_LOADING="hlsKeyLoading",i.KEY_LOADED="hlsKeyLoaded",i.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",i.BACK_BUFFER_REACHED="hlsBackBufferReached",i.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",i}({}),ie=function(i){return i.NETWORK_ERROR="networkError",i.MEDIA_ERROR="mediaError",i.KEY_SYSTEM_ERROR="keySystemError",i.MUX_ERROR="muxError",i.OTHER_ERROR="otherError",i}({}),C=function(i){return i.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",i.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",i.KEY_SYSTEM_NO_SESSION="keySystemNoSession",i.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",i.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",i.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",i.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",i.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",i.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",i.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",i.MANIFEST_LOAD_ERROR="manifestLoadError",i.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",i.MANIFEST_PARSING_ERROR="manifestParsingError",i.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",i.LEVEL_EMPTY_ERROR="levelEmptyError",i.LEVEL_LOAD_ERROR="levelLoadError",i.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",i.LEVEL_PARSING_ERROR="levelParsingError",i.LEVEL_SWITCH_ERROR="levelSwitchError",i.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",i.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",i.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",i.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",i.FRAG_LOAD_ERROR="fragLoadError",i.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",i.FRAG_DECRYPT_ERROR="fragDecryptError",i.FRAG_PARSING_ERROR="fragParsingError",i.FRAG_GAP="fragGap",i.REMUX_ALLOC_ERROR="remuxAllocError",i.KEY_LOAD_ERROR="keyLoadError",i.KEY_LOAD_TIMEOUT="keyLoadTimeOut",i.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",i.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",i.BUFFER_APPEND_ERROR="bufferAppendError",i.BUFFER_APPENDING_ERROR="bufferAppendingError",i.BUFFER_STALLED_ERROR="bufferStalledError",i.BUFFER_FULL_ERROR="bufferFullError",i.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",i.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",i.INTERNAL_EXCEPTION="internalException",i.INTERNAL_ABORTED="aborted",i.UNKNOWN="unknown",i}({}),As=function(){},Rp={trace:As,debug:As,log:As,warn:As,info:As,error:As},so=Rp;function lI(i){let e=self.console[i];return e?e.bind(self.console,`[${i}] >`):As}function dI(i,...e){e.forEach(function(t){so[t]=i[t]?i[t].bind(i):lI(t)})}function uI(i,e){if(typeof console=="object"&&i===!0||typeof i=="object"){dI(i,"debug","log","info","warn","error");try{so.log(`Debug logs enabled for "${e}" in hls.js version 1.5.8`)}catch{so=Rp}}else so=Rp}var I=so,cI=/^(\d+)x(\d+)$/,Wy=/(.+?)=(".*?"|.*?)(?:,|$)/g,We=class i{constructor(e){typeof e=="string"&&(e=i.parseAttrList(e)),Je(this,e)}get clientAttrs(){return Object.keys(this).filter(e=>e.substring(0,2)==="X-")}decimalInteger(e){let t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2);t=(t.length&1?"0":"")+t;let r=new Uint8Array(t.length/2);for(let s=0;s<t.length/2;s++)r[s]=parseInt(t.slice(s*2,s*2+2),16);return r}else return null}hexadecimalIntegerAsNumber(e){let t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){let r=this[e];return r?parseFloat(r):t}enumeratedString(e){return this[e]}bool(e){return this[e]==="YES"}decimalResolution(e){let t=cI.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e){let t,r={},s='"';for(Wy.lastIndex=0;(t=Wy.exec(e))!==null;){let n=t[2];n.indexOf(s)===0&&n.lastIndexOf(s)===n.length-1&&(n=n.slice(1,-1));let a=t[1].trim();r[a]=n}return r}};function hI(i){return i!=="ID"&&i!=="CLASS"&&i!=="START-DATE"&&i!=="DURATION"&&i!=="END-DATE"&&i!=="END-ON-NEXT"}function fI(i){return i==="SCTE35-OUT"||i==="SCTE35-IN"}var Gu=class{constructor(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){let r=t.attr;for(let s in r)if(Object.prototype.hasOwnProperty.call(e,s)&&e[s]!==r[s]){I.warn(`DATERANGE tag attribute: "${s}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=s;break}e=Je(new We({}),r,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){let r=new Date(this.attr["END-DATE"]);q(r.getTime())&&(this._endDate=r)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){if(this._endDate)return this._endDate;let e=this.duration;return e!==null?new Date(this._startDate.getTime()+e*1e3):null}get duration(){if("DURATION"in this.attr){let e=this.attr.decimalFloatingPoint("DURATION");if(q(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isValid(){return!!this.id&&!this._badValueForSameId&&q(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}},Kn=class{constructor(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}},ke={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"},Wu=class{constructor(e){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[ke.AUDIO]:null,[ke.VIDEO]:null,[ke.AUDIOVIDEO]:null},this.baseurl=e}setByteRange(e,t){let r=e.split("@",2),s;r.length===1?s=(t==null?void 0:t.byteRangeEndOffset)||0:s=parseInt(r[1]),this._byteRange=[s,parseInt(r[0])+s]}get byteRange(){return this._byteRange?this._byteRange:[]}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Fg.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}},no=class extends Wu{constructor(e,t){super(t),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new Kn,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.urlId=0,this.type=e}get decryptdata(){let{levelkeys:e}=this;if(!e&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){let t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{let r=Object.keys(this.levelkeys);if(r.length===1)return this._decryptdata=this.levelkeys[r[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null||!q(this.programDateTime))return null;let e=q(this.duration)?this.duration:0;return this.programDateTime+e*1e3}get encrypted(){var e;if((e=this._decryptdata)!=null&&e.encrypted)return!0;if(this.levelkeys){let t=Object.keys(this.levelkeys),r=t.length;if(r>1||r===1&&this.levelkeys[t[0]].encrypted)return!0}return!1}setKeyFormat(e){if(this.levelkeys){let t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}}abortRequests(){var e,t;(e=this.loader)==null||e.abort(),(t=this.keyLoader)==null||t.abort()}setElementaryStreamInfo(e,t,r,s,n,a=!1){let{elementaryStreams:o}=this,l=o[e];if(!l){o[e]={startPTS:t,endPTS:r,startDTS:s,endDTS:n,partial:a};return}l.startPTS=Math.min(l.startPTS,t),l.endPTS=Math.max(l.endPTS,r),l.startDTS=Math.min(l.startDTS,s),l.endDTS=Math.max(l.endDTS,n)}clearElementaryStreamInfo(){let{elementaryStreams:e}=this;e[ke.AUDIO]=null,e[ke.VIDEO]=null,e[ke.AUDIOVIDEO]=null}},wp=class extends Wu{constructor(e,t,r,s,n){super(r),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.stats=new Kn,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=s;let a=e.enumeratedString("BYTERANGE");a&&this.setByteRange(a,n),n&&(this.fragOffset=n.fragOffset+n.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){let{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo)}},mI=10,Cp=class{constructor(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}reloaded(e){if(!e){this.advanced=!0,this.updated=!0;return}let t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||t===0&&r>0,this.updated||this.advanced?this.misses=Math.floor(e.misses*.6):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay}get hasProgramDateTime(){return this.fragments.length?q(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||mI}get drift(){let e=this.driftEndTime-this.driftStartTime;return e>0?(this.driftEnd-this.driftStart)*1e3/e:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var e;return(e=this.fragments)!=null&&e.length?this.fragments[this.fragments.length-1].end:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}};function Bg(i){return Uint8Array.from(atob(i),e=>e.charCodeAt(0))}function pI(i){let e=Dp(i).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function gI(i){let e=function(r,s,n){let a=r[s];r[s]=r[n],r[n]=a};e(i,0,3),e(i,1,2),e(i,4,5),e(i,6,7)}function vI(i){let e=i.split(":"),t=null;if(e[0]==="data"&&e.length===2){let r=e[1].split(";"),s=r[r.length-1].split(",");if(s.length===2){let n=s[0]==="base64",a=s[1];n?(r.splice(-1,1),t=Bg(a)):t=pI(a)}}return t}function Dp(i){return Uint8Array.from(unescape(encodeURIComponent(i)),e=>e.charCodeAt(0))}var qn=typeof self!="undefined"?self:void 0,Fe={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Ot={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function Vy(i){switch(i){case Ot.FAIRPLAY:return Fe.FAIRPLAY;case Ot.PLAYREADY:return Fe.PLAYREADY;case Ot.WIDEVINE:return Fe.WIDEVINE;case Ot.CLEARKEY:return Fe.CLEARKEY}}var $T={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function EI(i){if(i===$T.WIDEVINE)return Fe.WIDEVINE}function Ky(i){switch(i){case Fe.FAIRPLAY:return Ot.FAIRPLAY;case Fe.PLAYREADY:return Ot.PLAYREADY;case Fe.WIDEVINE:return Ot.WIDEVINE;case Fe.CLEARKEY:return Ot.CLEARKEY}}function up(i){let{drmSystems:e,widevineLicenseUrl:t}=i,r=e?[Fe.FAIRPLAY,Fe.WIDEVINE,Fe.PLAYREADY,Fe.CLEARKEY].filter(s=>!!e[s]):[];return!r[Fe.WIDEVINE]&&t&&r.push(Fe.WIDEVINE),r}var HT=function(i){return qn!=null&&(i=qn.navigator)!=null&&i.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function bI(i,e,t,r){let s;switch(i){case Fe.FAIRPLAY:s=["cenc","sinf"];break;case Fe.WIDEVINE:case Fe.PLAYREADY:s=["cenc"];break;case Fe.CLEARKEY:s=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${i}`)}return yI(s,e,t,r)}function yI(i,e,t,r){return[{initDataTypes:i,persistentState:r.persistentState||"optional",distinctiveIdentifier:r.distinctiveIdentifier||"optional",sessionTypes:r.sessionTypes||[r.sessionType||"temporary"],audioCapabilities:e.map(n=>({contentType:`audio/mp4; codecs="${n}"`,robustness:r.audioRobustness||"",encryptionScheme:r.audioEncryptionScheme||null})),videoCapabilities:t.map(n=>({contentType:`video/mp4; codecs="${n}"`,robustness:r.videoRobustness||"",encryptionScheme:r.videoEncryptionScheme||null}))}]}function Ls(i,e,t){return Uint8Array.prototype.slice?i.slice(e,t):new Uint8Array(Array.prototype.slice.call(i,e,t))}var $g=(i,e)=>e+10<=i.length&&i[e]===73&&i[e+1]===68&&i[e+2]===51&&i[e+3]<255&&i[e+4]<255&&i[e+6]<128&&i[e+7]<128&&i[e+8]<128&&i[e+9]<128,GT=(i,e)=>e+10<=i.length&&i[e]===51&&i[e+1]===68&&i[e+2]===73&&i[e+3]<255&&i[e+4]<255&&i[e+6]<128&&i[e+7]<128&&i[e+8]<128&&i[e+9]<128,oo=(i,e)=>{let t=e,r=0;for(;$g(i,e);){r+=10;let s=mc(i,e+6);r+=s,GT(i,e+10)&&(r+=10),e+=r}if(r>0)return i.subarray(t,t+r)},mc=(i,e)=>{let t=0;return t=(i[e]&127)<<21,t|=(i[e+1]&127)<<14,t|=(i[e+2]&127)<<7,t|=i[e+3]&127,t},TI=(i,e)=>$g(i,e)&&mc(i,e+6)+10<=i.length-e,Hg=i=>{let e=VT(i);for(let t=0;t<e.length;t++){let r=e[t];if(WT(r))return kI(r)}},WT=i=>i&&i.key==="PRIV"&&i.info==="com.apple.streaming.transportStreamTimestamp",_I=i=>{let e=String.fromCharCode(i[0],i[1],i[2],i[3]),t=mc(i,4),r=10;return{type:e,size:t,data:i.subarray(r,r+t)}},VT=i=>{let e=0,t=[];for(;$g(i,e);){let r=mc(i,e+6);e+=10;let s=e+r;for(;e+8<s;){let n=_I(i.subarray(e)),a=AI(n);a&&t.push(a),e+=n.size+10}GT(i,e)&&(e+=10)}return t},AI=i=>i.type==="PRIV"?SI(i):i.type[0]==="W"?LI(i):xI(i),SI=i=>{if(i.size<2)return;let e=Qi(i.data,!0),t=new Uint8Array(i.data.subarray(e.length+1));return{key:i.type,info:e,data:t.buffer}},xI=i=>{if(i.size<2)return;if(i.type==="TXXX"){let t=1,r=Qi(i.data.subarray(t),!0);t+=r.length+1;let s=Qi(i.data.subarray(t));return{key:i.type,info:r,data:s}}let e=Qi(i.data.subarray(1));return{key:i.type,data:e}},LI=i=>{if(i.type==="WXXX"){if(i.size<2)return;let t=1,r=Qi(i.data.subarray(t),!0);t+=r.length+1;let s=Qi(i.data.subarray(t));return{key:i.type,info:r,data:s}}let e=Qi(i.data);return{key:i.type,data:e}},kI=i=>{if(i.data.byteLength===8){let e=new Uint8Array(i.data),t=e[3]&1,r=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return r/=45,t&&(r+=4772185884e-2),Math.round(r)}},Qi=(i,e=!1)=>{let t=II();if(t){let d=t.decode(i);if(e){let u=d.indexOf("\0");return u!==-1?d.substring(0,u):d}return d.replace(/\0/g,"")}let r=i.length,s,n,a,o="",l=0;for(;l<r;){if(s=i[l++],s===0&&e)return o;if(s===0||s===3)continue;switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(s);break;case 12:case 13:n=i[l++],o+=String.fromCharCode((s&31)<<6|n&63);break;case 14:n=i[l++],a=i[l++],o+=String.fromCharCode((s&15)<<12|(n&63)<<6|(a&63)<<0);break}}return o},cp;function II(){if(!navigator.userAgent.includes("PlayStation 4"))return!cp&&typeof self.TextDecoder!="undefined"&&(cp=new self.TextDecoder("utf-8")),cp}var zi={hexDump:function(i){let e="";for(let t=0;t<i.length;t++){let r=i[t].toString(16);r.length<2&&(r="0"+r),e+=r}return e}},Vu=Math.pow(2,32)-1,RI=[].push,KT={video:1,audio:2,id3:3,text:4};function it(i){return String.fromCharCode.apply(null,i)}function qT(i,e){let t=i[e]<<8|i[e+1];return t<0?65536+t:t}function Z(i,e){let t=YT(i,e);return t<0?4294967296+t:t}function qy(i,e){let t=Z(i,e);return t*=Math.pow(2,32),t+=Z(i,e+4),t}function YT(i,e){return i[e]<<24|i[e+1]<<16|i[e+2]<<8|i[e+3]}function hp(i,e,t){i[e]=t>>24,i[e+1]=t>>16&255,i[e+2]=t>>8&255,i[e+3]=t&255}function wI(i){let e=i.byteLength;for(let t=0;t<e;){let r=Z(i,t);if(r>8&&i[t+4]===109&&i[t+5]===111&&i[t+6]===111&&i[t+7]===102)return!0;t=r>1?t+r:e}return!1}function ne(i,e){let t=[];if(!e.length)return t;let r=i.byteLength;for(let s=0;s<r;){let n=Z(i,s),a=it(i.subarray(s+4,s+8)),o=n>1?s+n:r;if(a===e[0])if(e.length===1)t.push(i.subarray(s+8,o));else{let l=ne(i.subarray(s+8,o),e.slice(1));l.length&&RI.apply(t,l)}s=o}return t}function CI(i){let e=[],t=i[0],r=8,s=Z(i,r);r+=4;let n=0,a=0;t===0?(n=Z(i,r),a=Z(i,r+4),r+=8):(n=qy(i,r),a=qy(i,r+8),r+=16),r+=2;let o=i.length+a,l=qT(i,r);r+=2;for(let d=0;d<l;d++){let u=r,c=Z(i,u);u+=4;let h=c&2147483647;if((c&2147483648)>>>31===1)return I.warn("SIDX has hierarchical references (not supported)"),null;let m=Z(i,u);u+=4,e.push({referenceSize:h,subsegmentDuration:m,info:{duration:m/s,start:o,end:o+h-1}}),o+=h,u+=4,r=u}return{earliestPresentationTime:n,timescale:s,version:t,referencesCount:l,references:e}}function zT(i){let e=[],t=ne(i,["moov","trak"]);for(let s=0;s<t.length;s++){let n=t[s],a=ne(n,["tkhd"])[0];if(a){let o=a[0],l=Z(a,o===0?12:20),d=ne(n,["mdia","mdhd"])[0];if(d){o=d[0];let u=Z(d,o===0?12:20),c=ne(n,["mdia","hdlr"])[0];if(c){let h=it(c.subarray(8,12)),f={soun:ke.AUDIO,vide:ke.VIDEO}[h];if(f){let m=ne(n,["mdia","minf","stbl","stsd"])[0],p=DI(m);e[l]={timescale:u,type:f},e[f]=ft({timescale:u,id:l},p)}}}}}return ne(i,["moov","mvex","trex"]).forEach(s=>{let n=Z(s,4),a=e[n];a&&(a.default={duration:Z(s,12),flags:Z(s,20)})}),e}function DI(i){let e=i.subarray(8),t=e.subarray(86),r=it(e.subarray(4,8)),s=r,n=r==="enca"||r==="encv";if(n){let o=ne(e,[r])[0].subarray(r==="enca"?28:78);ne(o,["sinf"]).forEach(d=>{let u=ne(d,["schm"])[0];if(u){let c=it(u.subarray(4,8));if(c==="cbcs"||c==="cenc"){let h=ne(d,["frma"])[0];h&&(s=it(h))}}})}switch(s){case"avc1":case"avc2":case"avc3":case"avc4":{let a=ne(t,["avcC"])[0];s+="."+Lu(a[1])+Lu(a[2])+Lu(a[3]);break}case"mp4a":{let a=ne(e,[r])[0],o=ne(a.subarray(28),["esds"])[0];if(o&&o.length>12){let l=4;if(o[l++]!==3)break;l=fp(o,l),l+=2;let d=o[l++];if(d&128&&(l+=2),d&64&&(l+=o[l++]),o[l++]!==4)break;l=fp(o,l);let u=o[l++];if(u===64)s+="."+Lu(u);else break;if(l+=12,o[l++]!==5)break;l=fp(o,l);let c=o[l++],h=(c&248)>>3;h===31&&(h+=1+((c&7)<<3)+((o[l]&224)>>5)),s+="."+h}break}case"hvc1":case"hev1":{let a=ne(t,["hvcC"])[0],o=a[1],l=["","A","B","C"][o>>6],d=o&31,u=Z(a,2),c=(o&32)>>5?"H":"L",h=a[12],f=a.subarray(6,12);s+="."+l+d,s+="."+u.toString(16).toUpperCase(),s+="."+c+h;let m="";for(let p=f.length;p--;){let g=f[p];(g||m)&&(m="."+g.toString(16).toUpperCase()+m)}s+=m;break}case"dvh1":case"dvhe":{let a=ne(t,["dvcC"])[0],o=a[2]>>1&127,l=a[2]<<5&32|a[3]>>3&31;s+="."+Yi(o)+"."+Yi(l);break}case"vp09":{let a=ne(t,["vpcC"])[0],o=a[4],l=a[5],d=a[6]>>4&15;s+="."+Yi(o)+"."+Yi(l)+"."+Yi(d);break}case"av01":{let a=ne(t,["av1C"])[0],o=a[1]>>>5,l=a[1]&31,d=a[2]>>>7?"H":"M",u=(a[2]&64)>>6,c=(a[2]&32)>>5,h=o===2&&u?c?12:10:u?10:8,f=(a[2]&16)>>4,m=(a[2]&8)>>3,p=(a[2]&4)>>2,g=a[2]&3,E=1,T=1,y=1,S=0;s+="."+o+"."+Yi(l)+d+"."+Yi(h)+"."+f+"."+m+p+g+"."+Yi(E)+"."+Yi(T)+"."+Yi(y)+"."+S;break}}return{codec:s,encrypted:n}}function fp(i,e){let t=e+5;for(;i[e++]&128&&e<t;);return e}function Lu(i){return("0"+i.toString(16).toUpperCase()).slice(-2)}function Yi(i){return(i<10?"0":"")+i}function MI(i,e){if(!i||!e)return i;let t=e.keyId;return t&&e.isCommonEncryption&&ne(i,["moov","trak"]).forEach(s=>{let a=ne(s,["mdia","minf","stbl","stsd"])[0].subarray(8),o=ne(a,["enca"]),l=o.length>0;l||(o=ne(a,["encv"])),o.forEach(d=>{let u=l?d.subarray(28):d.subarray(78);ne(u,["sinf"]).forEach(h=>{let f=jT(h);if(f){let m=f.subarray(8,24);m.some(p=>p!==0)||(I.log(`[eme] Patching keyId in 'enc${l?"a":"v"}>sinf>>tenc' box: ${zi.hexDump(m)} -> ${zi.hexDump(t)}`),f.set(t,8))}})})}),i}function jT(i){let e=ne(i,["schm"])[0];if(e){let t=it(e.subarray(4,8));if(t==="cbcs"||t==="cenc")return ne(i,["schi","tenc"])[0]}return I.error("[eme] missing 'schm' box"),null}function PI(i,e){return ne(e,["moof","traf"]).reduce((t,r)=>{let s=ne(r,["tfdt"])[0],n=s[0],a=ne(r,["tfhd"]).reduce((o,l)=>{let d=Z(l,4),u=i[d];if(u){let c=Z(s,4);if(n===1){if(c===Vu)return I.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),o;c*=Vu+1,c+=Z(s,8)}let h=u.timescale||9e4,f=c/h;if(q(f)&&(o===null||f<o))return f}return o},null);return a!==null&&q(a)&&(t===null||a<t)?a:t},null)}function OI(i,e){let t=0,r=0,s=0,n=ne(i,["moof","traf"]);for(let a=0;a<n.length;a++){let o=n[a],l=ne(o,["tfhd"])[0],d=Z(l,4),u=e[d];if(!u)continue;let c=u.default,h=Z(l,0)|(c==null?void 0:c.flags),f=c==null?void 0:c.duration;h&8&&(h&2?f=Z(l,12):f=Z(l,8));let m=u.timescale||9e4,p=ne(o,["trun"]);for(let g=0;g<p.length;g++){if(t=NI(p[g]),!t&&f){let E=Z(p[g],4);t=f*E}u.type===ke.VIDEO?r+=t/m:u.type===ke.AUDIO&&(s+=t/m)}}if(r===0&&s===0){let a=1/0,o=0,l=0,d=ne(i,["sidx"]);for(let u=0;u<d.length;u++){let c=CI(d[u]);if(c!=null&&c.references){a=Math.min(a,c.earliestPresentationTime/c.timescale);let h=c.references.reduce((f,m)=>f+m.info.duration||0,0);o=Math.max(o,h+c.earliestPresentationTime/c.timescale),l=o-a}}if(l&&q(l))return l}return r||s}function NI(i){let e=Z(i,0),t=8;e&1&&(t+=4),e&4&&(t+=4);let r=0,s=Z(i,4);for(let n=0;n<s;n++){if(e&256){let a=Z(i,t);r+=a,t+=4}e&512&&(t+=4),e&1024&&(t+=4),e&2048&&(t+=4)}return r}function UI(i,e,t){ne(e,["moof","traf"]).forEach(r=>{ne(r,["tfhd"]).forEach(s=>{let n=Z(s,4),a=i[n];if(!a)return;let o=a.timescale||9e4;ne(r,["tfdt"]).forEach(l=>{let d=l[0],u=t*o;if(u){let c=Z(l,4);if(d===0)c-=u,c=Math.max(c,0),hp(l,4,c);else{c*=Math.pow(2,32),c+=Z(l,8),c-=u,c=Math.max(c,0);let h=Math.floor(c/(Vu+1)),f=Math.floor(c%(Vu+1));hp(l,4,h),hp(l,8,f)}}})})})}function FI(i){let e={valid:null,remainder:null},t=ne(i,["moof"]);if(t.length<2)return e.remainder=i,e;let r=t[t.length-1];return e.valid=Ls(i,0,r.byteOffset-8),e.remainder=Ls(i,r.byteOffset-8),e}function Jt(i,e){let t=new Uint8Array(i.length+e.length);return t.set(i),t.set(e,i.length),t}function Yy(i,e){let t=[],r=e.samples,s=e.timescale,n=e.id,a=!1;return ne(r,["moof"]).map(l=>{let d=l.byteOffset-8;ne(l,["traf"]).map(c=>{let h=ne(c,["tfdt"]).map(f=>{let m=f[0],p=Z(f,4);return m===1&&(p*=Math.pow(2,32),p+=Z(f,8)),p/s})[0];return h!==void 0&&(i=h),ne(c,["tfhd"]).map(f=>{let m=Z(f,4),p=Z(f,0)&16777215,g=(p&1)!==0,E=(p&2)!==0,T=(p&8)!==0,y=0,S=(p&16)!==0,_=0,L=(p&32)!==0,x=8;m===n&&(g&&(x+=8),E&&(x+=4),T&&(y=Z(f,x),x+=4),S&&(_=Z(f,x),x+=4),L&&(x+=4),e.type==="video"&&(a=BI(e.codec)),ne(c,["trun"]).map(w=>{let M=w[0],k=Z(w,0)&16777215,D=(k&1)!==0,U=0,B=(k&4)!==0,X=(k&256)!==0,z=0,V=(k&512)!==0,se=0,ae=(k&1024)!==0,W=(k&2048)!==0,G=0,oe=Z(w,4),Q=8;D&&(U=Z(w,Q),Q+=4),B&&(Q+=4);let me=U+d;for(let Pe=0;Pe<oe;Pe++){if(X?(z=Z(w,Q),Q+=4):z=y,V?(se=Z(w,Q),Q+=4):se=_,ae&&(Q+=4),W&&(M===0?G=Z(w,Q):G=YT(w,Q),Q+=4),e.type===ke.VIDEO){let Be=0;for(;Be<se;){let Ke=Z(r,me);if(me+=4,$I(a,r[me])){let kt=r.subarray(me,me+Ke);XT(kt,a?2:1,i+G/s,t)}me+=Ke,Be+=Ke+4}}i+=z/s}}))})})}),t}function BI(i){if(!i)return!1;let e=i.indexOf("."),t=e<0?i:i.substring(0,e);return t==="hvc1"||t==="hev1"||t==="dvh1"||t==="dvhe"}function $I(i,e){if(i){let t=e>>1&63;return t===39||t===40}else return(e&31)===6}function XT(i,e,t,r){let s=QT(i),n=0;n+=e;let a=0,o=0,l=0;for(;n<s.length;){a=0;do{if(n>=s.length)break;l=s[n++],a+=l}while(l===255);o=0;do{if(n>=s.length)break;l=s[n++],o+=l}while(l===255);let d=s.length-n,u=n;if(o<d)n+=o;else if(o>d){I.error(`Malformed SEI payload. ${o} is too small, only ${d} bytes left to parse.`);break}if(a===4){if(s[u++]===181){let h=qT(s,u);if(u+=2,h===49){let f=Z(s,u);if(u+=4,f===1195456820){let m=s[u++];if(m===3){let p=s[u++],g=31&p,E=64&p,T=E?2+g*3:0,y=new Uint8Array(T);if(E){y[0]=p;for(let S=1;S<T;S++)y[S]=s[u++]}r.push({type:m,payloadType:a,pts:t,bytes:y})}}}}}else if(a===5&&o>16){let c=[];for(let m=0;m<16;m++){let p=s[u++].toString(16);c.push(p.length==1?"0"+p:p),(m===3||m===5||m===7||m===9)&&c.push("-")}let h=o-16,f=new Uint8Array(h);for(let m=0;m<h;m++)f[m]=s[u++];r.push({payloadType:a,pts:t,uuid:c.join(""),userData:Qi(f),userDataBytes:f})}}}function QT(i){let e=i.byteLength,t=[],r=1;for(;r<e-2;)i[r]===0&&i[r+1]===0&&i[r+2]===3?(t.push(r+2),r+=2):r++;if(t.length===0)return i;let s=e-t.length,n=new Uint8Array(s),a=0;for(r=0;r<s;a++,r++)a===t[0]&&(a++,t.shift()),n[r]=i[a];return n}function HI(i){let e=i[0],t="",r="",s=0,n=0,a=0,o=0,l=0,d=0;if(e===0){for(;it(i.subarray(d,d+1))!=="\0";)t+=it(i.subarray(d,d+1)),d+=1;for(t+=it(i.subarray(d,d+1)),d+=1;it(i.subarray(d,d+1))!=="\0";)r+=it(i.subarray(d,d+1)),d+=1;r+=it(i.subarray(d,d+1)),d+=1,s=Z(i,12),n=Z(i,16),o=Z(i,20),l=Z(i,24),d=28}else if(e===1){d+=4,s=Z(i,d),d+=4;let c=Z(i,d);d+=4;let h=Z(i,d);for(d+=4,a=2**32*c+h,aI(a)||(a=Number.MAX_SAFE_INTEGER,I.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=Z(i,d),d+=4,l=Z(i,d),d+=4;it(i.subarray(d,d+1))!=="\0";)t+=it(i.subarray(d,d+1)),d+=1;for(t+=it(i.subarray(d,d+1)),d+=1;it(i.subarray(d,d+1))!=="\0";)r+=it(i.subarray(d,d+1)),d+=1;r+=it(i.subarray(d,d+1)),d+=1}let u=i.subarray(d,i.byteLength);return{schemeIdUri:t,value:r,timeScale:s,presentationTime:a,presentationTimeDelta:n,eventDuration:o,id:l,payload:u}}function GI(i,...e){let t=e.length,r=8,s=t;for(;s--;)r+=e[s].byteLength;let n=new Uint8Array(r);for(n[0]=r>>24&255,n[1]=r>>16&255,n[2]=r>>8&255,n[3]=r&255,n.set(i,4),s=0,r=8;s<t;s++)n.set(e[s],r),r+=e[s].byteLength;return n}function WI(i,e,t){if(i.byteLength!==16)throw new RangeError("Invalid system id");let r,s;if(e){r=1,s=new Uint8Array(e.length*16);for(let o=0;o<e.length;o++){let l=e[o];if(l.byteLength!==16)throw new RangeError("Invalid key");s.set(l,o*16)}}else r=0,s=new Uint8Array;let n;r>0?(n=new Uint8Array(4),e.length>0&&new DataView(n.buffer).setUint32(0,e.length,!1)):n=new Uint8Array;let a=new Uint8Array(4);return t&&t.byteLength>0&&new DataView(a.buffer).setUint32(0,t.byteLength,!1),GI([112,115,115,104],new Uint8Array([r,0,0,0]),i,n,s,a,t||new Uint8Array)}function VI(i){if(!(i instanceof ArrayBuffer)||i.byteLength<32)return null;let e={version:0,systemId:"",kids:null,data:null},t=new DataView(i),r=t.getUint32(0);if(i.byteLength!==r&&r>44||t.getUint32(4)!==1886614376||(e.version=t.getUint32(8)>>>24,e.version>1))return null;e.systemId=zi.hexDump(new Uint8Array(i,12,16));let n=t.getUint32(28);if(e.version===0){if(r-32<n)return null;e.data=new Uint8Array(i,32,n)}else if(e.version===1){e.kids=[];for(let a=0;a<n;a++)e.kids.push(new Uint8Array(i,32+a*16,16))}return e}var ku={},lo=class i{static clearKeyUriToKeyIdMap(){ku={}}constructor(e,t,r,s=[1],n=null){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=r,this.keyFormatVersions=s,this.iv=n,this.encrypted=e?e!=="NONE":!1,this.isCommonEncryption=this.encrypted&&e!=="AES-128"}isSupported(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case Ot.FAIRPLAY:case Ot.WIDEVINE:case Ot.PLAYREADY:case Ot.CLEARKEY:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1}getDecryptData(e){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof e!="number"&&(this.method==="AES-128"&&!this.iv&&I.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0);let r=KI(e);return new i(this.method,this.uri,"identity",this.keyFormatVersions,r)}let t=vI(this.uri);if(t)switch(this.keyFormat){case Ot.WIDEVINE:this.pssh=t,t.length>=22&&(this.keyId=t.subarray(t.length-22,t.length-6));break;case Ot.PLAYREADY:{let r=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=WI(r,null,t);let s=new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2),n=String.fromCharCode.apply(null,Array.from(s)),a=n.substring(n.indexOf("<"),n.length),d=new DOMParser().parseFromString(a,"text/xml").getElementsByTagName("KID")[0];if(d){let u=d.childNodes[0]?d.childNodes[0].nodeValue:d.getAttribute("VALUE");if(u){let c=Bg(u).subarray(0,16);gI(c),this.keyId=c}}break}default:{let r=t.subarray(0,16);if(r.length!==16){let s=new Uint8Array(16);s.set(r,16-r.length),r=s}this.keyId=r;break}}if(!this.keyId||this.keyId.byteLength!==16){let r=ku[this.uri];if(!r){let s=Object.keys(ku).length%Number.MAX_SAFE_INTEGER;r=new Uint8Array(16),new DataView(r.buffer,12,4).setUint32(0,s),ku[this.uri]=r}this.keyId=r}return this}};function KI(i){let e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=i>>8*(15-t)&255;return e}var ZT=/\{\$([a-zA-Z0-9-_]+)\}/g;function zy(i){return ZT.test(i)}function Mt(i,e,t){if(i.variableList!==null||i.hasVariableRefs)for(let r=t.length;r--;){let s=t[r],n=e[s];n&&(e[s]=Mp(i,n))}}function Mp(i,e){if(i.variableList!==null||i.hasVariableRefs){let t=i.variableList;return e.replace(ZT,r=>{let s=r.substring(2,r.length-1),n=t==null?void 0:t[s];return n===void 0?(i.playlistParsingError||(i.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${s}"`)),r):n})}return e}function jy(i,e,t){let r=i.variableList;r||(i.variableList=r={});let s,n;if("QUERYPARAM"in e){s=e.QUERYPARAM;try{let a=new self.URL(t).searchParams;if(a.has(s))n=a.get(s);else throw new Error(`"${s}" does not match any query parameter in URI: "${t}"`)}catch(a){i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${a.message}`))}}else s=e.NAME,n=e.VALUE;s in r?i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${s}"`)):r[s]=n||""}function qI(i,e,t){let r=e.IMPORT;if(t&&r in t){let s=i.variableList;s||(i.variableList=s={}),s[r]=t[r]}else i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${r}"`))}function ks(i=!0){return typeof self=="undefined"?void 0:(i||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function YI(i){return typeof self!="undefined"&&i===self.ManagedMediaSource}var Ku={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function zI(i,e){let t=Ku[e];return!!t&&!!t[i.slice(0,4)]}function mp(i,e,t=!0){return!i.split(",").some(r=>!JT(r,e,t))}function JT(i,e,t=!0){var r;let s=ks(t);return(r=s==null?void 0:s.isTypeSupported(uo(i,e)))!=null?r:!1}function uo(i,e){return`${e}/mp4;codecs="${i}"`}function Xy(i){if(i){let e=i.substring(0,4);return Ku.video[e]}return 2}function qu(i){return i.split(",").reduce((e,t)=>{let r=Ku.video[t];return r?(r*2+e)/(e?3:2):(Ku.audio[t]+e)/(e?2:1)},0)}var pp={};function jI(i,e=!0){if(pp[i])return pp[i];let t={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"]}[i];for(let r=0;r<t.length;r++)if(JT(t[r],"audio",e))return pp[i]=t[r],t[r];return i}var XI=/flac|opus/i;function Yu(i,e=!0){return i.replace(XI,t=>jI(t.toLowerCase(),e))}function Qy(i,e){return i&&i!=="mp4a"?i:e&&e.split(",")[0]}function QI(i){let e=i.split(".");if(e.length>2){let t=e.shift()+".";return t+=parseInt(e.shift()).toString(16),t+=("000"+parseInt(e.shift()).toString(16)).slice(-4),t}return i}var Zy=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,Jy=/#EXT-X-MEDIA:(.*)/g,ZI=/^#EXT(?:INF|-X-TARGETDURATION):/m,eT=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),JI=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),Ss=class i{static findGroup(e,t){for(let r=0;r<e.length;r++){let s=e[r];if(s.id===t)return s}}static resolve(e,t){return Fg.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return ZI.test(e)}static parseMasterPlaylist(e,t){let r=zy(e),s={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:r},n=[];Zy.lastIndex=0;let a;for(;(a=Zy.exec(e))!=null;)if(a[1]){var o;let d=new We(a[1]);Mt(s,d,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);let u=Mp(s,a[2]),c={attrs:d,bitrate:d.decimalInteger("BANDWIDTH")||d.decimalInteger("AVERAGE-BANDWIDTH"),name:d.NAME,url:i.resolve(u,t)},h=d.decimalResolution("RESOLUTION");h&&(c.width=h.width,c.height=h.height),eR(d.CODECS,c),(o=c.unknownCodecs)!=null&&o.length||n.push(c),s.levels.push(c)}else if(a[3]){let d=a[3],u=a[4];switch(d){case"SESSION-DATA":{let c=new We(u);Mt(s,c,["DATA-ID","LANGUAGE","VALUE","URI"]);let h=c["DATA-ID"];h&&(s.sessionData===null&&(s.sessionData={}),s.sessionData[h]=c);break}case"SESSION-KEY":{let c=tT(u,t,s);c.encrypted&&c.isSupported()?(s.sessionKeys===null&&(s.sessionKeys=[]),s.sessionKeys.push(c)):I.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${u}"`);break}case"DEFINE":{{let c=new We(u);Mt(s,c,["NAME","VALUE","QUERYPARAM"]),jy(s,c,t)}break}case"CONTENT-STEERING":{let c=new We(u);Mt(s,c,["SERVER-URI","PATHWAY-ID"]),s.contentSteering={uri:i.resolve(c["SERVER-URI"],t),pathwayId:c["PATHWAY-ID"]||"."};break}case"START":{s.startTimeOffset=iT(u);break}}}let l=n.length>0&&n.length<s.levels.length;return s.levels=l?n:s.levels,s.levels.length===0&&(s.playlistParsingError=new Error("no levels found in manifest")),s}static parseMasterPlaylistMedia(e,t,r){let s,n={},a=r.levels,o={AUDIO:a.map(d=>({id:d.attrs.AUDIO,audioCodec:d.audioCodec})),SUBTITLES:a.map(d=>({id:d.attrs.SUBTITLES,textCodec:d.textCodec})),"CLOSED-CAPTIONS":[]},l=0;for(Jy.lastIndex=0;(s=Jy.exec(e))!==null;){let d=new We(s[1]),u=d.TYPE;if(u){let c=o[u],h=n[u]||[];n[u]=h,Mt(r,d,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);let f=d.LANGUAGE,m=d["ASSOC-LANGUAGE"],p=d.CHANNELS,g=d.CHARACTERISTICS,E=d["INSTREAM-ID"],T={attrs:d,bitrate:0,id:l++,groupId:d["GROUP-ID"]||"",name:d.NAME||f||"",type:u,default:d.bool("DEFAULT"),autoselect:d.bool("AUTOSELECT"),forced:d.bool("FORCED"),lang:f,url:d.URI?i.resolve(d.URI,t):""};if(m&&(T.assocLang=m),p&&(T.channels=p),g&&(T.characteristics=g),E&&(T.instreamId=E),c!=null&&c.length){let y=i.findGroup(c,T.groupId)||c[0];rT(T,y,"audioCodec"),rT(T,y,"textCodec")}h.push(T)}}return n}static parseLevelPlaylist(e,t,r,s,n,a){let o=new Cp(t),l=o.fragments,d=null,u=0,c=0,h=0,f=0,m=null,p=new no(s,t),g,E,T,y=-1,S=!1,_=null;for(eT.lastIndex=0,o.m3u8=e,o.hasVariableRefs=zy(e);(g=eT.exec(e))!==null;){S&&(S=!1,p=new no(s,t),p.start=h,p.sn=u,p.cc=f,p.level=r,d&&(p.initSegment=d,p.rawProgramDateTime=d.rawProgramDateTime,d.rawProgramDateTime=null,_&&(p.setByteRange(_),_=null)));let M=g[1];if(M){p.duration=parseFloat(M);let k=(" "+g[2]).slice(1);p.title=k||null,p.tagList.push(k?["INF",M,k]:["INF",M])}else if(g[3]){if(q(p.duration)){p.start=h,T&&aT(p,T,o),p.sn=u,p.level=r,p.cc=f,l.push(p);let k=(" "+g[3]).slice(1);p.relurl=Mp(o,k),sT(p,m),m=p,h+=p.duration,u++,c=0,S=!0}}else if(g[4]){let k=(" "+g[4]).slice(1);m?p.setByteRange(k,m):p.setByteRange(k)}else if(g[5])p.rawProgramDateTime=(" "+g[5]).slice(1),p.tagList.push(["PROGRAM-DATE-TIME",p.rawProgramDateTime]),y===-1&&(y=l.length);else{if(g=g[0].match(JI),!g){I.warn("No matches on slow regex match for level playlist!");continue}for(E=1;E<g.length&&typeof g[E]=="undefined";E++);let k=(" "+g[E]).slice(1),D=(" "+g[E+1]).slice(1),U=g[E+2]?(" "+g[E+2]).slice(1):"";switch(k){case"PLAYLIST-TYPE":o.type=D.toUpperCase();break;case"MEDIA-SEQUENCE":u=o.startSN=parseInt(D);break;case"SKIP":{let B=new We(D);Mt(o,B,["RECENTLY-REMOVED-DATERANGES"]);let X=B.decimalInteger("SKIPPED-SEGMENTS");if(q(X)){o.skippedSegments=X;for(let V=X;V--;)l.unshift(null);u+=X}let z=B.enumeratedString("RECENTLY-REMOVED-DATERANGES");z&&(o.recentlyRemovedDateranges=z.split(" "));break}case"TARGETDURATION":o.targetduration=Math.max(parseInt(D),1);break;case"VERSION":o.version=parseInt(D);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":break;case"ENDLIST":o.live=!1;break;case"#":(D||U)&&p.tagList.push(U?[D,U]:[D]);break;case"DISCONTINUITY":f++,p.tagList.push(["DIS"]);break;case"GAP":p.gap=!0,p.tagList.push([k]);break;case"BITRATE":p.tagList.push([k,D]);break;case"DATERANGE":{let B=new We(D);Mt(o,B,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),Mt(o,B,B.clientAttrs);let X=new Gu(B,o.dateRanges[B.ID]);X.isValid||o.skippedSegments?o.dateRanges[X.id]=X:I.warn(`Ignoring invalid DATERANGE tag: "${D}"`),p.tagList.push(["EXT-X-DATERANGE",D]);break}case"DEFINE":{{let B=new We(D);Mt(o,B,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in B?qI(o,B,a):jy(o,B,t)}break}case"DISCONTINUITY-SEQUENCE":f=parseInt(D);break;case"KEY":{let B=tT(D,t,o);if(B.isSupported()){if(B.method==="NONE"){T=void 0;break}T||(T={}),T[B.keyFormat]&&(T=Je({},T)),T[B.keyFormat]=B}else I.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${D}"`);break}case"START":o.startTimeOffset=iT(D);break;case"MAP":{let B=new We(D);if(Mt(o,B,["BYTERANGE","URI"]),p.duration){let X=new no(s,t);nT(X,B,r,T),d=X,p.initSegment=d,d.rawProgramDateTime&&!p.rawProgramDateTime&&(p.rawProgramDateTime=d.rawProgramDateTime)}else{let X=p.byteRangeEndOffset;if(X){let z=p.byteRangeStartOffset;_=`${X-z}@${z}`}else _=null;nT(p,B,r,T),d=p,S=!0}break}case"SERVER-CONTROL":{let B=new We(D);o.canBlockReload=B.bool("CAN-BLOCK-RELOAD"),o.canSkipUntil=B.optionalFloat("CAN-SKIP-UNTIL",0),o.canSkipDateRanges=o.canSkipUntil>0&&B.bool("CAN-SKIP-DATERANGES"),o.partHoldBack=B.optionalFloat("PART-HOLD-BACK",0),o.holdBack=B.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{let B=new We(D);o.partTarget=B.decimalFloatingPoint("PART-TARGET");break}case"PART":{let B=o.partList;B||(B=o.partList=[]);let X=c>0?B[B.length-1]:void 0,z=c++,V=new We(D);Mt(o,V,["BYTERANGE","URI"]);let se=new wp(V,p,t,z,X);B.push(se),p.duration+=se.duration;break}case"PRELOAD-HINT":{let B=new We(D);Mt(o,B,["URI"]),o.preloadHint=B;break}case"RENDITION-REPORT":{let B=new We(D);Mt(o,B,["URI"]),o.renditionReports=o.renditionReports||[],o.renditionReports.push(B);break}default:I.warn(`line parsed but not handled: ${g}`);break}}}m&&!m.relurl?(l.pop(),h-=m.duration,o.partList&&(o.fragmentHint=m)):o.partList&&(sT(p,m),p.cc=f,o.fragmentHint=p,T&&aT(p,T,o));let L=l.length,x=l[0],w=l[L-1];if(h+=o.skippedSegments*o.targetduration,h>0&&L&&w){o.averagetargetduration=h/L;let M=w.sn;o.endSN=M!=="initSegment"?M:0,o.live||(w.endList=!0),x&&(o.startCC=x.cc)}else o.endSN=0,o.startCC=0;return o.fragmentHint&&(h+=o.fragmentHint.duration),o.totalduration=h,o.endCC=f,y>0&&tR(l,y),o}};function tT(i,e,t){var r,s;let n=new We(i);Mt(t,n,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);let a=(r=n.METHOD)!=null?r:"",o=n.URI,l=n.hexadecimalInteger("IV"),d=n.KEYFORMATVERSIONS,u=(s=n.KEYFORMAT)!=null?s:"identity";o&&n.IV&&!l&&I.error(`Invalid IV: ${n.IV}`);let c=o?Ss.resolve(o,e):"",h=(d||"1").split("/").map(Number).filter(Number.isFinite);return new lo(a,c,u,h,l)}function iT(i){let t=new We(i).decimalFloatingPoint("TIME-OFFSET");return q(t)?t:null}function eR(i,e){let t=(i||"").split(/[ ,]+/).filter(r=>r);["video","audio","text"].forEach(r=>{let s=t.filter(n=>zI(n,r));s.length&&(e[`${r}Codec`]=s.join(","),t=t.filter(n=>s.indexOf(n)===-1))}),e.unknownCodecs=t}function rT(i,e,t){let r=e[t];r&&(i[t]=r)}function tR(i,e){let t=i[e];for(let r=e;r--;){let s=i[r];if(!s)return;s.programDateTime=t.programDateTime-s.duration*1e3,t=s}}function sT(i,e){i.rawProgramDateTime?i.programDateTime=Date.parse(i.rawProgramDateTime):e!=null&&e.programDateTime&&(i.programDateTime=e.endProgramDateTime),q(i.programDateTime)||(i.programDateTime=null,i.rawProgramDateTime=null)}function nT(i,e,t,r){i.relurl=e.URI,e.BYTERANGE&&i.setByteRange(e.BYTERANGE),i.level=t,i.sn="initSegment",r&&(i.levelkeys=r),i.initSegment=null}function aT(i,e,t){i.levelkeys=e;let{encryptedFragments:r}=t;(!r.length||r[r.length-1].levelkeys!==e)&&Object.keys(e).some(s=>e[s].isCommonEncryption)&&r.push(i)}var ge={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},te={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function oT(i){let{type:e}=i;switch(e){case ge.AUDIO_TRACK:return te.AUDIO;case ge.SUBTITLE_TRACK:return te.SUBTITLE;default:return te.MAIN}}function gp(i,e){let t=i.url;return(t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}var Pp=class{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){let{hls:e}=this;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.LEVEL_LOADING,this.onLevelLoading,this),e.on(v.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(v.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){let{hls:e}=this;e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.LEVEL_LOADING,this.onLevelLoading,this),e.off(v.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(v.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(e){let t=this.hls.config,r=t.pLoader,s=t.loader,n=r||s,a=new n(t);return this.loaders[e.type]=a,a}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(let e in this.loaders){let t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){let{url:r}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:ge.MANIFEST,url:r,deliveryDirectives:null})}onLevelLoading(e,t){let{id:r,level:s,pathwayId:n,url:a,deliveryDirectives:o}=t;this.load({id:r,level:s,pathwayId:n,responseType:"text",type:ge.LEVEL,url:a,deliveryDirectives:o})}onAudioTrackLoading(e,t){let{id:r,groupId:s,url:n,deliveryDirectives:a}=t;this.load({id:r,groupId:s,level:null,responseType:"text",type:ge.AUDIO_TRACK,url:n,deliveryDirectives:a})}onSubtitleTrackLoading(e,t){let{id:r,groupId:s,url:n,deliveryDirectives:a}=t;this.load({id:r,groupId:s,level:null,responseType:"text",type:ge.SUBTITLE_TRACK,url:n,deliveryDirectives:a})}load(e){var t;let r=this.hls.config,s=this.getInternalLoader(e);if(s){let d=s.context;if(d&&d.url===e.url&&d.level===e.level){I.trace("[playlist-loader]: playlist request ongoing");return}I.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),s.abort()}let n;if(e.type===ge.MANIFEST?n=r.manifestLoadPolicy.default:n=Je({},r.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),q((t=e.deliveryDirectives)==null?void 0:t.part)){let d;if(e.type===ge.LEVEL&&e.level!==null?d=this.hls.levels[e.level].details:e.type===ge.AUDIO_TRACK&&e.id!==null?d=this.hls.audioTracks[e.id].details:e.type===ge.SUBTITLE_TRACK&&e.id!==null&&(d=this.hls.subtitleTracks[e.id].details),d){let u=d.partTarget,c=d.targetduration;if(u&&c){let h=Math.max(u*3,c*.8)*1e3;n=Je({},n,{maxTimeToFirstByteMs:Math.min(h,n.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(h,n.maxTimeToFirstByteMs)})}}}let a=n.errorRetry||n.timeoutRetry||{},o={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},l={onSuccess:(d,u,c,h)=>{let f=this.getInternalLoader(c);this.resetInternalLoader(c.type);let m=d.data;if(m.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(d,c,new Error("no EXTM3U delimiter"),h||null,u);return}u.parsing.start=performance.now(),Ss.isMediaPlaylist(m)?this.handleTrackOrLevelPlaylist(d,u,c,h||null,f):this.handleMasterPlaylist(d,u,c,h)},onError:(d,u,c,h)=>{this.handleNetworkError(u,c,!1,d,h)},onTimeout:(d,u,c)=>{this.handleNetworkError(u,c,!0,void 0,d)}};s.load(e,o,l)}handleMasterPlaylist(e,t,r,s){let n=this.hls,a=e.data,o=gp(e,r),l=Ss.parseMasterPlaylist(a,o);if(l.playlistParsingError){this.handleManifestParsingError(e,r,l.playlistParsingError,s,t);return}let{contentSteering:d,levels:u,sessionData:c,sessionKeys:h,startTimeOffset:f,variableList:m}=l;this.variableList=m;let{AUDIO:p=[],SUBTITLES:g,"CLOSED-CAPTIONS":E}=Ss.parseMasterPlaylistMedia(a,o,l);p.length&&!p.some(y=>!y.url)&&u[0].audioCodec&&!u[0].attrs.AUDIO&&(I.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),p.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new We({}),bitrate:0,url:""})),n.trigger(v.MANIFEST_LOADED,{levels:u,audioTracks:p,subtitles:g,captions:E,contentSteering:d,url:o,stats:t,networkDetails:s,sessionData:c,sessionKeys:h,startTimeOffset:f,variableList:m})}handleTrackOrLevelPlaylist(e,t,r,s,n){let a=this.hls,{id:o,level:l,type:d}=r,u=gp(e,r),c=0,h=q(l)?l:q(o)?o:0,f=oT(r),m=Ss.parseLevelPlaylist(e.data,u,h,f,c,this.variableList);if(d===ge.MANIFEST){let p={attrs:new We({}),bitrate:0,details:m,name:"",url:u};a.trigger(v.MANIFEST_LOADED,{levels:[p],audioTracks:[],url:u,stats:t,networkDetails:s,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=m,this.handlePlaylistLoaded(m,e,t,r,s,n)}handleManifestParsingError(e,t,r,s,n){this.hls.trigger(v.ERROR,{type:ie.NETWORK_ERROR,details:C.MANIFEST_PARSING_ERROR,fatal:t.type===ge.MANIFEST,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:s,stats:n})}handleNetworkError(e,t,r=!1,s,n){let a=`A network ${r?"timeout":"error"+(s?" (status "+s.code+")":"")} occurred while loading ${e.type}`;e.type===ge.LEVEL?a+=`: ${e.level} id: ${e.id}`:(e.type===ge.AUDIO_TRACK||e.type===ge.SUBTITLE_TRACK)&&(a+=` id: ${e.id} group-id: "${e.groupId}"`);let o=new Error(a);I.warn(`[playlist-loader]: ${a}`);let l=C.UNKNOWN,d=!1,u=this.getInternalLoader(e);switch(e.type){case ge.MANIFEST:l=r?C.MANIFEST_LOAD_TIMEOUT:C.MANIFEST_LOAD_ERROR,d=!0;break;case ge.LEVEL:l=r?C.LEVEL_LOAD_TIMEOUT:C.LEVEL_LOAD_ERROR,d=!1;break;case ge.AUDIO_TRACK:l=r?C.AUDIO_TRACK_LOAD_TIMEOUT:C.AUDIO_TRACK_LOAD_ERROR,d=!1;break;case ge.SUBTITLE_TRACK:l=r?C.SUBTITLE_TRACK_LOAD_TIMEOUT:C.SUBTITLE_LOAD_ERROR,d=!1;break}u&&this.resetInternalLoader(e.type);let c={type:ie.NETWORK_ERROR,details:l,fatal:d,url:e.url,loader:u,context:e,error:o,networkDetails:t,stats:n};if(s){let h=(t==null?void 0:t.url)||e.url;c.response=ft({url:h,data:void 0},s)}this.hls.trigger(v.ERROR,c)}handlePlaylistLoaded(e,t,r,s,n,a){let o=this.hls,{type:l,level:d,id:u,groupId:c,deliveryDirectives:h}=s,f=gp(t,s),m=oT(s),p=typeof s.level=="number"&&m===te.MAIN?d:void 0;if(!e.fragments.length){let E=new Error("No Segments found in Playlist");o.trigger(v.ERROR,{type:ie.NETWORK_ERROR,details:C.LEVEL_EMPTY_ERROR,fatal:!1,url:f,error:E,reason:E.message,response:t,context:s,level:p,parent:m,networkDetails:n,stats:r});return}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));let g=e.playlistParsingError;if(g){o.trigger(v.ERROR,{type:ie.NETWORK_ERROR,details:C.LEVEL_PARSING_ERROR,fatal:!1,url:f,error:g,reason:g.message,response:t,context:s,level:p,parent:m,networkDetails:n,stats:r});return}switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),(!a.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),l){case ge.MANIFEST:case ge.LEVEL:o.trigger(v.LEVEL_LOADED,{details:e,level:p||0,id:u||0,stats:r,networkDetails:n,deliveryDirectives:h});break;case ge.AUDIO_TRACK:o.trigger(v.AUDIO_TRACK_LOADED,{details:e,id:u||0,groupId:c||"",stats:r,networkDetails:n,deliveryDirectives:h});break;case ge.SUBTITLE_TRACK:o.trigger(v.SUBTITLE_TRACK_LOADED,{details:e,id:u||0,groupId:c||"",stats:r,networkDetails:n,deliveryDirectives:h});break}}};function e_(i,e){let t;try{t=new Event("addtrack")}catch{t=document.createEvent("Event"),t.initEvent("addtrack",!1,!1)}t.track=i,e.dispatchEvent(t)}function t_(i,e){let t=i.mode;if(t==="disabled"&&(i.mode="hidden"),i.cues&&!i.cues.getCueById(e.id))try{if(i.addCue(e),!i.cues.getCueById(e.id))throw new Error(`addCue is failed for: ${e}`)}catch(r){I.debug(`[texttrack-utils]: ${r}`);try{let s=new self.TextTrackCue(e.startTime,e.endTime,e.text);s.id=e.id,i.addCue(s)}catch(s){I.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${s}`)}}t==="disabled"&&(i.mode=t)}function Hn(i){let e=i.mode;if(e==="disabled"&&(i.mode="hidden"),i.cues)for(let t=i.cues.length;t--;)i.removeCue(i.cues[t]);e==="disabled"&&(i.mode=e)}function Op(i,e,t,r){let s=i.mode;if(s==="disabled"&&(i.mode="hidden"),i.cues&&i.cues.length>0){let n=rR(i.cues,e,t);for(let a=0;a<n.length;a++)(!r||r(n[a]))&&i.removeCue(n[a])}s==="disabled"&&(i.mode=s)}function iR(i,e){if(e<i[0].startTime)return 0;let t=i.length-1;if(e>i[t].endTime)return-1;let r=0,s=t;for(;r<=s;){let n=Math.floor((s+r)/2);if(e<i[n].startTime)s=n-1;else if(e>i[n].startTime&&r<t)r=n+1;else return n}return i[r].startTime-e<e-i[s].startTime?r:s}function rR(i,e,t){let r=[],s=iR(i,e);if(s>-1)for(let n=s,a=i.length;n<a;n++){let o=i[n];if(o.startTime>=e&&o.endTime<=t)r.push(o);else if(o.startTime>t)return r}return r}function Ou(i){let e=[];for(let t=0;t<i.length;t++){let r=i[t];(r.kind==="subtitles"||r.kind==="captions")&&r.label&&e.push(i[t])}return e}var Ti={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"},sR=.25;function Np(){if(typeof self!="undefined")return self.VTTCue||self.TextTrackCue}function lT(i,e,t,r,s){let n=new i(e,t,"");try{n.value=r,s&&(n.type=s)}catch{n=new i(e,t,JSON.stringify(s?ft({type:s},r):r))}return n}var Iu=(()=>{let i=Np();try{i&&new i(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function vp(i,e){return i.getTime()/1e3-e}function nR(i){return Uint8Array.from(i.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var Up=class{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){let{hls:e}=this;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(v.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){let{hls:e}=this;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(v.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(e,t){this.media=t.media}onMediaDetaching(){this.id3Track&&(Hn(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){let t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){let r=e[t];if(r.kind==="metadata"&&r.label==="id3")return e_(r,this.media),r}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media)return;let{hls:{config:{enableEmsgMetadataCues:r,enableID3MetadataCues:s}}}=this;if(!r&&!s)return;let{samples:n}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));let a=Np();if(a)for(let o=0;o<n.length;o++){let l=n[o].type;if(l===Ti.emsg&&!r||!s)continue;let d=VT(n[o].data);if(d){let u=n[o].pts,c=u+n[o].duration;c>Iu&&(c=Iu),c-u<=0&&(c=u+sR);for(let f=0;f<d.length;f++){let m=d[f];if(!WT(m)){this.updateId3CueEnds(u,l);let p=lT(a,u,c,m,l);p&&this.id3Track.addCue(p)}}}}}updateId3CueEnds(e,t){var r;let s=(r=this.id3Track)==null?void 0:r.cues;if(s)for(let n=s.length;n--;){let a=s[n];a.type===t&&a.startTime<e&&a.endTime===Iu&&(a.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:r,type:s}){let{id3Track:n,hls:a}=this;if(!a)return;let{config:{enableEmsgMetadataCues:o,enableID3MetadataCues:l}}=a;if(n&&(o||l)){let d;s==="audio"?d=u=>u.type===Ti.audioId3&&l:s==="video"?d=u=>u.type===Ti.emsg&&o:d=u=>u.type===Ti.audioId3&&l||u.type===Ti.emsg&&o,Op(n,t,r,d)}}onLevelUpdated(e,{details:t}){if(!this.media||!t.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;let{dateRangeCuesAppended:r,id3Track:s}=this,{dateRanges:n}=t,a=Object.keys(n);if(s){let u=Object.keys(r).filter(c=>!a.includes(c));for(let c=u.length;c--;){let h=u[c];Object.keys(r[h].cues).forEach(f=>{s.removeCue(r[h].cues[f])}),delete r[h]}}let o=t.fragments[t.fragments.length-1];if(a.length===0||!q(o==null?void 0:o.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));let l=o.programDateTime/1e3-o.start,d=Np();for(let u=0;u<a.length;u++){let c=a[u],h=n[c],f=vp(h.startDate,l),m=r[c],p=(m==null?void 0:m.cues)||{},g=(m==null?void 0:m.durationKnown)||!1,E=Iu,T=h.endDate;if(T)E=vp(T,l),g=!0;else if(h.endOnNext&&!g){let S=a.reduce((_,L)=>{if(L!==h.id){let x=n[L];if(x.class===h.class&&x.startDate>h.startDate&&(!_||h.startDate<_.startDate))return x}return _},null);S&&(E=vp(S.startDate,l),g=!0)}let y=Object.keys(h.attr);for(let S=0;S<y.length;S++){let _=y[S];if(!hI(_))continue;let L=p[_];if(L)g&&!m.durationKnown&&(L.endTime=E);else if(d){let x=h.attr[_];fI(_)&&(x=nR(x));let w=lT(d,f,E,{key:_,data:x},Ti.dateRange);w&&(w.id=c,this.id3Track.addCue(w),p[_]=w)}}r[c]={cues:p,dateRange:h,durationKnown:g}}}},Fp=class{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=()=>this.timeupdate(),this.hls=e,this.config=e.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){let{config:e,levelDetails:t}=this;return e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){let{levelDetails:e}=this;if(e===null)return null;let{holdBack:t,partHoldBack:r,targetduration:s}=e,{liveSyncDuration:n,liveSyncDurationCount:a,lowLatencyMode:o}=this.config,l=this.hls.userConfig,d=o&&r||t;(l.liveSyncDuration||l.liveSyncDurationCount||d===0)&&(d=n!==void 0?n:a*s);let u=s,c=1;return d+Math.min(this.stallCount*c,u)}get liveSyncPosition(){let e=this.estimateLiveEdge(),t=this.targetLatency,r=this.levelDetails;if(e===null||t===null||r===null)return null;let s=r.edge,n=e-t-this.edgeStalled,a=s-r.totalduration,o=s-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(a,n),o)}get drift(){let{levelDetails:e}=this;return e===null?1:e.drift}get edgeStalled(){let{levelDetails:e}=this;if(e===null)return 0;let t=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-t,0)}get forwardBufferLength(){let{media:e,levelDetails:t}=this;if(!e||!t)return 0;let r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(v.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(v.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(v.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(v.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(v.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(v.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){this.levelDetails=t,t.advanced&&this.timeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(e,t){var r;t.details===C.BUFFER_STALLED_ERROR&&(this.stallCount++,(r=this.levelDetails)!=null&&r.live&&I.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){let{media:e,levelDetails:t}=this;if(!e||!t)return;this.currentTime=e.currentTime;let r=this.computeLatency();if(r===null)return;this._latency=r;let{lowLatencyMode:s,maxLiveSyncPlaybackRate:n}=this.config;if(!s||n===1||!t.live)return;let a=this.targetLatency;if(a===null)return;let o=r-a,l=Math.min(this.maxLatency,a+t.targetduration);if(o<l&&o>.05&&this.forwardBufferLength>1){let u=Math.min(2,Math.max(1,n)),c=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;e.playbackRate=Math.min(u,Math.max(1,c))}else e.playbackRate!==1&&e.playbackRate!==0&&(e.playbackRate=1)}estimateLiveEdge(){let{levelDetails:e}=this;return e===null?null:e.edge+e.age}computeLatency(){let e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}},Bp=["NONE","TYPE-0","TYPE-1",null];function aR(i){return Bp.indexOf(i)>-1}var zu=["SDR","PQ","HLG"];function oR(i){return!!i&&zu.indexOf(i)>-1}var Nu={No:"",Yes:"YES",v2:"v2"};function dT(i){let{canSkipUntil:e,canSkipDateRanges:t,age:r}=i,s=r<e/2;return e&&s?t?Nu.v2:Nu.Yes:Nu.No}var ju=class{constructor(e,t,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=r}addDirectives(e){let t=new self.URL(e);return this.msn!==void 0&&t.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}},Mr=class{constructor(e){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter(t=>!!t).map(t=>t.substring(0,4)).join(","),this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES)}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get averageBitrate(){return this._avgBitrate||this.realBitrate||this.bitrate}get attrs(){return this._attrs[0]}get codecs(){return this.attrs.CODECS||""}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get videoRange(){return this.attrs["VIDEO-RANGE"]||"SDR"}get score(){return this.attrs.optionalFloat("SCORE",0)}get uri(){return this.url[0]||""}hasAudioGroup(e){return uT(this._audioGroups,e)}hasSubtitleGroup(e){return uT(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,t){if(t){if(e==="audio"){let r=this._audioGroups;r||(r=this._audioGroups=[]),r.indexOf(t)===-1&&r.push(t)}else if(e==="text"){let r=this._subtitleGroups;r||(r=this._subtitleGroups=[]),r.indexOf(t)===-1&&r.push(t)}}}get urlId(){return 0}set urlId(e){}get audioGroupIds(){return this.audioGroups?[this.audioGroupId]:void 0}get textGroupIds(){return this.subtitleGroups?[this.textGroupId]:void 0}get audioGroupId(){var e;return(e=this.audioGroups)==null?void 0:e[0]}get textGroupId(){var e;return(e=this.subtitleGroups)==null?void 0:e[0]}addFallback(){}};function uT(i,e){return!e||!i?!1:i.indexOf(e)!==-1}function Ep(i,e){let t=e.startPTS;if(q(t)){let r=0,s;e.sn>i.sn?(r=t-i.start,s=i):(r=i.start-t,s=e),s.duration!==r&&(s.duration=r)}else e.sn>i.sn?i.cc===e.cc&&i.minEndPTS?e.start=i.start+(i.minEndPTS-i.start):e.start=i.start+i.duration:e.start=Math.max(i.start-e.duration,0)}function i_(i,e,t,r,s,n){r-t<=0&&(I.warn("Fragment should have a positive duration",e),r=t+e.duration,n=s+e.duration);let o=t,l=r,d=e.startPTS,u=e.endPTS;if(q(d)){let g=Math.abs(d-t);q(e.deltaPTS)?e.deltaPTS=Math.max(g,e.deltaPTS):e.deltaPTS=g,o=Math.max(t,d),t=Math.min(t,d),s=Math.min(s,e.startDTS),l=Math.min(r,u),r=Math.max(r,u),n=Math.max(n,e.endDTS)}let c=t-e.start;e.start!==0&&(e.start=t),e.duration=r-e.start,e.startPTS=t,e.maxStartPTS=o,e.startDTS=s,e.endPTS=r,e.minEndPTS=l,e.endDTS=n;let h=e.sn;if(!i||h<i.startSN||h>i.endSN)return 0;let f,m=h-i.startSN,p=i.fragments;for(p[m]=e,f=m;f>0;f--)Ep(p[f],p[f-1]);for(f=m;f<p.length-1;f++)Ep(p[f],p[f+1]);return i.fragmentHint&&Ep(p[p.length-1],i.fragmentHint),i.PTSKnown=i.alignedSliding=!0,c}function lR(i,e){let t=null,r=i.fragments;for(let l=r.length-1;l>=0;l--){let d=r[l].initSegment;if(d){t=d;break}}i.fragmentHint&&delete i.fragmentHint.endPTS;let s=0,n;if(cR(i,e,(l,d)=>{l.relurl&&(s=l.cc-d.cc),q(l.startPTS)&&q(l.endPTS)&&(d.start=d.startPTS=l.startPTS,d.startDTS=l.startDTS,d.maxStartPTS=l.maxStartPTS,d.endPTS=l.endPTS,d.endDTS=l.endDTS,d.minEndPTS=l.minEndPTS,d.duration=l.endPTS-l.startPTS,d.duration&&(n=d),e.PTSKnown=e.alignedSliding=!0),d.elementaryStreams=l.elementaryStreams,d.loader=l.loader,d.stats=l.stats,l.initSegment&&(d.initSegment=l.initSegment,t=l.initSegment)}),t&&(e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments).forEach(d=>{var u;d&&(!d.initSegment||d.initSegment.relurl===((u=t)==null?void 0:u.relurl))&&(d.initSegment=t)}),e.skippedSegments)if(e.deltaUpdateFailed=e.fragments.some(l=>!l),e.deltaUpdateFailed){I.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let l=e.skippedSegments;l--;)e.fragments.shift();e.startSN=e.fragments[0].sn,e.startCC=e.fragments[0].cc}else e.canSkipDateRanges&&(e.dateRanges=dR(i.dateRanges,e.dateRanges,e.recentlyRemovedDateranges));let a=e.fragments;if(s){I.warn("discontinuity sliding from playlist, take drift into account");for(let l=0;l<a.length;l++)a[l].cc+=s}e.skippedSegments&&(e.startCC=e.fragments[0].cc),uR(i.partList,e.partList,(l,d)=>{d.elementaryStreams=l.elementaryStreams,d.stats=l.stats}),n?i_(e,n,n.startPTS,n.endPTS,n.startDTS,n.endDTS):r_(i,e),a.length&&(e.totalduration=e.edge-a[0].start),e.driftStartTime=i.driftStartTime,e.driftStart=i.driftStart;let o=e.advancedDateTime;if(e.advanced&&o){let l=e.edge;e.driftStart||(e.driftStartTime=o,e.driftStart=l),e.driftEndTime=o,e.driftEnd=l}else e.driftEndTime=i.driftEndTime,e.driftEnd=i.driftEnd,e.advancedDateTime=i.advancedDateTime}function dR(i,e,t){let r=Je({},i);return t&&t.forEach(s=>{delete r[s]}),Object.keys(e).forEach(s=>{let n=new Gu(e[s].attr,r[s]);n.isValid?r[s]=n:I.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(e[s].attr)}"`)}),r}function uR(i,e,t){if(i&&e){let r=0;for(let s=0,n=i.length;s<=n;s++){let a=i[s],o=e[s+r];a&&o&&a.index===o.index&&a.fragment.sn===o.fragment.sn?t(a,o):r--}}}function cR(i,e,t){let r=e.skippedSegments,s=Math.max(i.startSN,e.startSN)-e.startSN,n=(i.fragmentHint?1:0)+(r?e.endSN:Math.min(i.endSN,e.endSN))-e.startSN,a=e.startSN-i.startSN,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments;for(let d=s;d<=n;d++){let u=l[a+d],c=o[d];r&&!c&&d<r&&(c=e.fragments[d]=u),u&&c&&t(u,c)}}function r_(i,e){let t=e.startSN+e.skippedSegments-i.startSN,r=i.fragments;t<0||t>=r.length||$p(e,r[t].start)}function $p(i,e){if(e){let t=i.fragments;for(let r=i.skippedSegments;r<t.length;r++)t[r].start+=e;i.fragmentHint&&(i.fragmentHint.start+=e)}}function hR(i,e=1/0){let t=1e3*i.targetduration;if(i.updated){let r=i.fragments,s=4;if(r.length&&t*s>e){let n=r[r.length-1].duration*1e3;n<t&&(t=n)}}else t/=2;return Math.round(t)}function fR(i,e,t){if(!(i!=null&&i.details))return null;let r=i.details,s=r.fragments[e-r.startSN];return s||(s=r.fragmentHint,s&&s.sn===e)?s:e<r.startSN&&t&&t.sn===e?t:null}function cT(i,e,t){var r;return i!=null&&i.details?s_((r=i.details)==null?void 0:r.partList,e,t):null}function s_(i,e,t){if(i)for(let r=i.length;r--;){let s=i[r];if(s.index===t&&s.fragment.sn===e)return s}return null}function n_(i){i.forEach((e,t)=>{let{details:r}=e;r!=null&&r.fragments&&r.fragments.forEach(s=>{s.level=t})})}function Xu(i){switch(i.details){case C.FRAG_LOAD_TIMEOUT:case C.KEY_LOAD_TIMEOUT:case C.LEVEL_LOAD_TIMEOUT:case C.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function hT(i,e){let t=Xu(e);return i.default[`${t?"timeout":"error"}Retry`]}function Gg(i,e){let t=i.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*i.retryDelayMs,i.maxRetryDelayMs)}function fT(i){return ft(ft({},i),{errorRetry:null,timeoutRetry:null})}function Qu(i,e,t,r){if(!i)return!1;let s=r==null?void 0:r.code,n=e<i.maxNumRetry&&(mR(s)||!!t);return i.shouldRetry?i.shouldRetry(i,e,t,r,n):n}function mR(i){return i===0&&navigator.onLine===!1||!!i&&(i<400||i>499)}var a_={search:function(i,e){let t=0,r=i.length-1,s=null,n=null;for(;t<=r;){s=(t+r)/2|0,n=i[s];let a=e(n);if(a>0)t=s+1;else if(a<0)r=s-1;else return n}return null}};function pR(i,e,t){if(e===null||!Array.isArray(i)||!i.length||!q(e))return null;let r=i[0].programDateTime;if(e<(r||0))return null;let s=i[i.length-1].endProgramDateTime;if(e>=(s||0))return null;t=t||0;for(let n=0;n<i.length;++n){let a=i[n];if(gR(e,t,a))return a}return null}function Zu(i,e,t=0,r=0){let s=null;if(i){s=e[i.sn-e[0].sn+1]||null;let a=i.endDTS-t;a>0&&a<15e-7&&(t+=15e-7)}else t===0&&e[0].start===0&&(s=e[0]);if(s&&(!i||i.level===s.level)&&Hp(t,r,s)===0)return s;let n=a_.search(e,Hp.bind(null,t,r));return n&&(n!==i||!s)?n:s}function Hp(i=0,e=0,t){if(t.start<=i&&t.start+t.duration>i)return 0;let r=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0));return t.start+t.duration-r<=i?1:t.start-r>i&&t.start?-1:0}function gR(i,e,t){let r=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return(t.endProgramDateTime||0)-r>i}function vR(i,e){return a_.search(i,t=>t.cc<e?1:t.cc>e?-1:0)}var ct={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},Ei={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4},Gp=class{constructor(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=I.log.bind(I,"[info]:"),this.warn=I.warn.bind(I,"[warning]:"),this.error=I.error.bind(I,"[error]:"),this.registerListeners()}registerListeners(){let e=this.hls;e.on(v.ERROR,this.onError,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){let e=this.hls;e&&(e.off(v.ERROR,this.onError,this),e.off(v.ERROR,this.onErrorOut,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(e){}stopLoad(){this.playlistError=0}getVariantLevelIndex(e){return(e==null?void 0:e.type)===te.MAIN?e.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(e,t){var r,s;if(t.fatal)return;let n=this.hls,a=t.context;switch(t.details){case C.FRAG_LOAD_ERROR:case C.FRAG_LOAD_TIMEOUT:case C.KEY_LOAD_ERROR:case C.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case C.FRAG_PARSING_ERROR:if((r=t.frag)!=null&&r.gap){t.errorAction={action:ct.DoNothing,flags:Ei.None};return}case C.FRAG_GAP:case C.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=ct.SendAlternateToPenaltyBox;return}case C.LEVEL_EMPTY_ERROR:case C.LEVEL_PARSING_ERROR:{var o,l;let d=t.parent===te.MAIN?t.level:n.loadLevel;t.details===C.LEVEL_EMPTY_ERROR&&((o=t.context)!=null&&(l=o.levelDetails)!=null&&l.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,d):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,d))}return;case C.LEVEL_LOAD_ERROR:case C.LEVEL_LOAD_TIMEOUT:typeof(a==null?void 0:a.level)=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level));return;case C.AUDIO_TRACK_LOAD_ERROR:case C.AUDIO_TRACK_LOAD_TIMEOUT:case C.SUBTITLE_LOAD_ERROR:case C.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){let d=n.levels[n.loadLevel];if(d&&(a.type===ge.AUDIO_TRACK&&d.hasAudioGroup(a.groupId)||a.type===ge.SUBTITLE_TRACK&&d.hasSubtitleGroup(a.groupId))){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.loadLevel),t.errorAction.action=ct.SendAlternateToPenaltyBox,t.errorAction.flags=Ei.MoveAllAlternatesMatchingHost;return}}return;case C.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{let d=n.levels[n.loadLevel],u=d==null?void 0:d.attrs["HDCP-LEVEL"];u?t.errorAction={action:ct.SendAlternateToPenaltyBox,flags:Ei.MoveAllAlternatesMatchingHDCP,hdcpLevel:u}:this.keySystemError(t)}return;case C.BUFFER_ADD_CODEC_ERROR:case C.REMUX_ALLOC_ERROR:case C.BUFFER_APPEND_ERROR:t.errorAction=this.getLevelSwitchAction(t,(s=t.level)!=null?s:n.loadLevel);return;case C.INTERNAL_EXCEPTION:case C.BUFFER_APPENDING_ERROR:case C.BUFFER_FULL_ERROR:case C.LEVEL_SWITCH_ERROR:case C.BUFFER_STALLED_ERROR:case C.BUFFER_SEEK_OVER_HOLE:case C.BUFFER_NUDGE_ON_STALL:t.errorAction={action:ct.DoNothing,flags:Ei.None};return}t.type===ie.KEY_SYSTEM_ERROR&&this.keySystemError(t)}keySystemError(e){let t=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t)}getPlaylistRetryOrSwitchAction(e,t){let r=this.hls,s=hT(r.config.playlistLoadPolicy,e),n=this.playlistError++;if(Qu(s,n,Xu(e),e.response))return{action:ct.RetryRequest,flags:Ei.None,retryConfig:s,retryCount:n};let o=this.getLevelSwitchAction(e,t);return s&&(o.retryConfig=s,o.retryCount=n),o}getFragRetryOrSwitchAction(e){let t=this.hls,r=this.getVariantLevelIndex(e.frag),s=t.levels[r],{fragLoadPolicy:n,keyLoadPolicy:a}=t.config,o=hT(e.details.startsWith("key")?a:n,e),l=t.levels.reduce((u,c)=>u+c.fragmentError,0);if(s&&(e.details!==C.FRAG_GAP&&s.fragmentError++,Qu(o,l,Xu(e),e.response)))return{action:ct.RetryRequest,flags:Ei.None,retryConfig:o,retryCount:l};let d=this.getLevelSwitchAction(e,r);return o&&(d.retryConfig=o,d.retryCount=l),d}getLevelSwitchAction(e,t){let r=this.hls;t==null&&(t=r.loadLevel);let s=this.hls.levels[t];if(s){var n,a;let d=e.details;s.loadError++,d===C.BUFFER_APPEND_ERROR&&s.fragmentError++;let u=-1,{levels:c,loadLevel:h,minAutoLevel:f,maxAutoLevel:m}=r;r.autoLevelEnabled||(r.loadLevel=-1);let p=(n=e.frag)==null?void 0:n.type,E=(p===te.AUDIO&&d===C.FRAG_PARSING_ERROR||e.sourceBufferName==="audio"&&(d===C.BUFFER_ADD_CODEC_ERROR||d===C.BUFFER_APPEND_ERROR))&&c.some(({audioCodec:L})=>s.audioCodec!==L),y=e.sourceBufferName==="video"&&(d===C.BUFFER_ADD_CODEC_ERROR||d===C.BUFFER_APPEND_ERROR)&&c.some(({codecSet:L,audioCodec:x})=>s.codecSet!==L&&s.audioCodec===x),{type:S,groupId:_}=(a=e.context)!=null?a:{};for(let L=c.length;L--;){let x=(L+h)%c.length;if(x!==h&&x>=f&&x<=m&&c[x].loadError===0){var o,l;let w=c[x];if(d===C.FRAG_GAP&&e.frag){let M=c[x].details;if(M){let k=Zu(e.frag,M.fragments,e.frag.start);if(k!=null&&k.gap)continue}}else{if(S===ge.AUDIO_TRACK&&w.hasAudioGroup(_)||S===ge.SUBTITLE_TRACK&&w.hasSubtitleGroup(_))continue;if(p===te.AUDIO&&(o=s.audioGroups)!=null&&o.some(M=>w.hasAudioGroup(M))||p===te.SUBTITLE&&(l=s.subtitleGroups)!=null&&l.some(M=>w.hasSubtitleGroup(M))||E&&s.audioCodec===w.audioCodec||!E&&s.audioCodec!==w.audioCodec||y&&s.codecSet===w.codecSet)continue}u=x;break}}if(u>-1&&r.loadLevel!==u)return e.levelRetry=!0,this.playlistError=0,{action:ct.SendAlternateToPenaltyBox,flags:Ei.None,nextAutoLevel:u}}return{action:ct.SendAlternateToPenaltyBox,flags:Ei.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var r;switch((r=t.errorAction)==null?void 0:r.action){case ct.DoNothing:break;case ct.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==C.FRAG_GAP?t.fatal=!0:/MediaSource readyState: ended/.test(t.error.message)&&(this.warn(`MediaSource ended after "${t.sourceBufferName}" sourceBuffer append error. Attempting to recover from media error.`),this.hls.recoverMediaError());break;case ct.RetryRequest:break}if(t.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(e){let t=this.hls,r=e.errorAction;if(!r)return;let{flags:s,hdcpLevel:n,nextAutoLevel:a}=r;switch(s){case Ei.None:this.switchLevel(e,a);break;case Ei.MoveAllAlternatesMatchingHDCP:n&&(t.maxHdcpLevel=Bp[Bp.indexOf(n)-1],r.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}r.resolved||this.switchLevel(e,a)}switchLevel(e,t){t!==void 0&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}},co=class{constructor(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=I.log.bind(I,`${t}:`),this.warn=I.warn.bind(I,`${t}:`),this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){this.timer!==-1&&(self.clearTimeout(this.timer),this.timer=-1)}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t,r){let s=t==null?void 0:t.renditionReports;if(s){let n=-1;for(let a=0;a<s.length;a++){let o=s[a],l;try{l=new self.URL(o.URI,t.url).href}catch(d){I.warn(`Could not construct new URL for Rendition Report: ${d}`),l=o.URI||""}if(l===e){n=a;break}else l===e.substring(0,l.length)&&(n=a)}if(n!==-1){let a=s[n],o=parseInt(a["LAST-MSN"])||(t==null?void 0:t.lastPartSn),l=parseInt(a["LAST-PART"])||(t==null?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){let u=Math.min(t.age-t.partTarget,t.targetduration);l>=0&&u>t.partTarget&&(l+=1)}let d=r&&dT(r);return new ju(o,l>=0?l:void 0,d)}}}loadPlaylist(e){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}shouldReloadPlaylist(e){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(e)}playlistLoaded(e,t,r){let{details:s,stats:n}=t,a=self.performance.now(),o=n.loading.first?Math.max(0,a-n.loading.first):0;if(s.advancedDateTime=Date.now()-o,s.live||r!=null&&r.live){if(s.reloaded(r),r&&this.log(`live playlist ${e} ${s.advanced?"REFRESHED "+s.lastPartSn+"-"+s.lastPartIndex:s.updated?"UPDATED":"MISSED"}`),r&&s.fragments.length>0&&lR(r,s),!this.canLoad||!s.live)return;let l,d,u;if(s.canBlockReload&&s.endSN&&s.advanced){let g=this.hls.config.lowLatencyMode,E=s.lastPartSn,T=s.endSN,y=s.lastPartIndex,S=y!==-1,_=E===T,L=g?0:y;S?(d=_?T+1:E,u=_?L:y+1):d=T+1;let x=s.age,w=x+s.ageHeader,M=Math.min(w-s.partTarget,s.targetduration*1.5);if(M>0){if(r&&M>r.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${r.tuneInGoal} to: ${M} with playlist age: ${s.age}`),M=0;else{let k=Math.floor(M/s.targetduration);if(d+=k,u!==void 0){let D=Math.round(M%s.targetduration/s.partTarget);u+=D}this.log(`CDN Tune-in age: ${s.ageHeader}s last advanced ${x.toFixed(2)}s goal: ${M} skip sn ${k} to part ${u}`)}s.tuneInGoal=M}if(l=this.getDeliveryDirectives(s,t.deliveryDirectives,d,u),g||!_){this.loadPlaylist(l);return}}else(s.canBlockReload||s.canSkipUntil)&&(l=this.getDeliveryDirectives(s,t.deliveryDirectives,d,u));let c=this.hls.mainForwardBufferInfo,h=c?c.end-c.len:0,f=(s.edge-h)*1e3,m=hR(s,f);s.updated&&a>this.requestScheduled+m&&(this.requestScheduled=n.loading.start),d!==void 0&&s.canBlockReload?this.requestScheduled=n.loading.first+m-(s.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+m<a?this.requestScheduled=a:this.requestScheduled-a<=0&&(this.requestScheduled+=m);let p=this.requestScheduled-a;p=Math.max(0,p),this.log(`reload live playlist ${e} in ${Math.round(p)} ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(l),p)}else this.clearTimer()}getDeliveryDirectives(e,t,r,s){let n=dT(e);return t!=null&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,s=t.part,n=Nu.No),new ju(r,s,n)}checkRetry(e){let t=e.details,r=Xu(e),s=e.errorAction,{action:n,retryCount:a=0,retryConfig:o}=s||{},l=!!s&&!!o&&(n===ct.RetryRequest||!s.resolved&&n===ct.SendAlternateToPenaltyBox);if(l){var d;if(this.requestScheduled=-1,a>=o.maxNumRetry)return!1;if(r&&(d=e.context)!=null&&d.deliveryDirectives)this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{let u=Gg(o,a);this.timer=self.setTimeout(()=>this.loadPlaylist(),u),this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" in ${u}ms`)}e.levelRetry=!0,s.resolved=!0}return l}},Dr=class{constructor(e,t=0,r=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=r}sample(e,t){let r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){let e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}},Wp=class{constructor(e,t,r,s=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new Dr(e),this.fast_=new Dr(t),this.defaultTTFB_=s,this.ttfb_=new Dr(e)}update(e,t){let{slow_:r,fast_:s,ttfb_:n}=this;r.halfLife!==e&&(this.slow_=new Dr(e,r.getEstimate(),r.getTotalWeight())),s.halfLife!==t&&(this.fast_=new Dr(t,s.getEstimate(),s.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new Dr(e,n.getEstimate(),n.getTotalWeight()))}sample(e,t){e=Math.max(e,this.minDelayMs_);let r=8*t,s=e/1e3,n=r/s;this.fast_.sample(s,n),this.slow_.sample(s,n)}sampleTTFB(e){let t=e/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(r,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}destroy(){}},o_={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]},mT={};function ER(i,e,t,r,s,n){let a=i.audioCodec?i.audioGroups:null,o=n==null?void 0:n.audioCodec,l=n==null?void 0:n.channels,d=l?parseInt(l):o?1/0:2,u=null;if(a!=null&&a.length)try{a.length===1&&a[0]?u=e.groups[a[0]].channels:u=a.reduce((c,h)=>{if(h){let f=e.groups[h];if(!f)throw new Error(`Audio track group ${h} not found`);Object.keys(f.channels).forEach(m=>{c[m]=(c[m]||0)+f.channels[m]})}return c},{2:0})}catch{return!0}return i.videoCodec!==void 0&&(i.width>1920&&i.height>1088||i.height>1920&&i.width>1088||i.frameRate>Math.max(r,30)||i.videoRange!=="SDR"&&i.videoRange!==t||i.bitrate>Math.max(s,8e6))||!!u&&q(d)&&Object.keys(u).some(c=>parseInt(c)>d)}function bR(i,e,t){let r=i.videoCodec,s=i.audioCodec;if(!r||!s||!t)return Promise.resolve(o_);let n={width:i.width,height:i.height,bitrate:Math.ceil(Math.max(i.bitrate*.9,i.averageBitrate)),framerate:i.frameRate||30},a=i.videoRange;a!=="SDR"&&(n.transferFunction=a.toLowerCase());let o=r.split(",").map(l=>({type:"media-source",video:ft(ft({},n),{},{contentType:uo(l,"video")})}));return s&&i.audioGroups&&i.audioGroups.forEach(l=>{var d;l&&((d=e.groups[l])==null||d.tracks.forEach(u=>{if(u.groupId===l){let c=u.channels||"",h=parseFloat(c);q(h)&&h>2&&o.push.apply(o,s.split(",").map(f=>({type:"media-source",audio:{contentType:uo(f,"audio"),channels:""+h}})))}}))}),Promise.all(o.map(l=>{let d=yR(l);return mT[d]||(mT[d]=t.decodingInfo(l))})).then(l=>({supported:!l.some(d=>!d.supported),configurations:o,decodingInfoResults:l})).catch(l=>({supported:!1,configurations:o,decodingInfoResults:[],error:l}))}function yR(i){let{audio:e,video:t}=i,r=t||e;if(r){let s=r.contentType.split('"')[1];if(t)return`r${t.height}x${t.width}f${Math.ceil(t.framerate)}${t.transferFunction||"sd"}_${s}_${Math.ceil(t.bitrate/1e5)}`;if(e)return`c${e.channels}${e.spatialRendering?"s":"n"}_${s}`}return""}function TR(){if(typeof matchMedia=="function"){let i=matchMedia("(dynamic-range: high)"),e=matchMedia("bad query");if(i.media!==e.media)return i.matches===!0}return!1}function _R(i,e){let t=!1,r=[];return i&&(t=i!=="SDR",r=[i]),e&&(r=e.allowedVideoRanges||zu.slice(0),t=e.preferHDR!==void 0?e.preferHDR:TR(),t?r=r.filter(s=>s!=="SDR"):r=["SDR"]),{preferHDR:t,allowedVideoRanges:r}}function AR(i,e,t,r,s){let n=Object.keys(i),a=r==null?void 0:r.channels,o=r==null?void 0:r.audioCodec,l=a&&parseInt(a)===2,d=!0,u=!1,c=1/0,h=1/0,f=1/0,m=0,p=[],{preferHDR:g,allowedVideoRanges:E}=_R(e,s);for(let _=n.length;_--;){let L=i[n[_]];d=L.channels[2]>0,c=Math.min(c,L.minHeight),h=Math.min(h,L.minFramerate),f=Math.min(f,L.minBitrate);let x=E.filter(w=>L.videoRanges[w]>0);x.length>0&&(u=!0,p=x)}c=q(c)?c:0,h=q(h)?h:0;let T=Math.max(1080,c),y=Math.max(30,h);return f=q(f)?f:t,t=Math.max(f,t),u||(e=void 0,p=[]),{codecSet:n.reduce((_,L)=>{let x=i[L];if(L===_)return _;if(x.minBitrate>t)return dr(L,`min bitrate of ${x.minBitrate} > current estimate of ${t}`),_;if(!x.hasDefaultAudio)return dr(L,"no renditions with default or auto-select sound found"),_;if(o&&L.indexOf(o.substring(0,4))%5!==0)return dr(L,`audio codec preference "${o}" not found`),_;if(a&&!l){if(!x.channels[a])return dr(L,`no renditions with ${a} channel sound found (channels options: ${Object.keys(x.channels)})`),_}else if((!o||l)&&d&&x.channels[2]===0)return dr(L,"no renditions with stereo sound found"),_;return x.minHeight>T?(dr(L,`min resolution of ${x.minHeight} > maximum of ${T}`),_):x.minFramerate>y?(dr(L,`min framerate of ${x.minFramerate} > maximum of ${y}`),_):p.some(w=>x.videoRanges[w]>0)?x.maxScore<m?(dr(L,`max score of ${x.maxScore} < selected max of ${m}`),_):_&&(qu(L)>=qu(_)||x.fragmentError>i[_].fragmentError)?_:(m=x.maxScore,L):(dr(L,`no variants with VIDEO-RANGE of ${JSON.stringify(p)} found`),_)},void 0),videoRanges:p,preferHDR:g,minFramerate:h,minBitrate:f}}function dr(i,e){I.log(`[abr] start candidates with "${i}" ignored because ${e}`)}function SR(i){return i.reduce((e,t)=>{let r=e.groups[t.groupId];r||(r=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),r.tracks.push(t);let s=t.channels||"2";return r.channels[s]=(r.channels[s]||0)+1,r.hasDefault=r.hasDefault||t.default,r.hasAutoSelect=r.hasAutoSelect||t.autoselect,r.hasDefault&&(e.hasDefaultAudio=!0),r.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function xR(i,e,t,r){return i.slice(t,r+1).reduce((s,n)=>{if(!n.codecSet)return s;let a=n.audioGroups,o=s[n.codecSet];o||(s[n.codecSet]=o={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!a,fragmentError:0}),o.minBitrate=Math.min(o.minBitrate,n.bitrate);let l=Math.min(n.height,n.width);return o.minHeight=Math.min(o.minHeight,l),o.minFramerate=Math.min(o.minFramerate,n.frameRate),o.maxScore=Math.max(o.maxScore,n.score),o.fragmentError+=n.fragmentError,o.videoRanges[n.videoRange]=(o.videoRanges[n.videoRange]||0)+1,a&&a.forEach(d=>{if(!d)return;let u=e.groups[d];u&&(o.hasDefaultAudio=o.hasDefaultAudio||e.hasDefaultAudio?u.hasDefault:u.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(u.channels).forEach(c=>{o.channels[c]=(o.channels[c]||0)+u.channels[c]}))}),s},{})}function Xi(i,e,t){if("attrs"in i){let r=e.indexOf(i);if(r!==-1)return r}for(let r=0;r<e.length;r++){let s=e[r];if(Wn(i,s,t))return r}return-1}function Wn(i,e,t){let{groupId:r,name:s,lang:n,assocLang:a,characteristics:o,default:l}=i,d=i.forced;return(r===void 0||e.groupId===r)&&(s===void 0||e.name===s)&&(n===void 0||e.lang===n)&&(n===void 0||e.assocLang===a)&&(l===void 0||e.default===l)&&(d===void 0||e.forced===d)&&(o===void 0||LR(o,e.characteristics))&&(t===void 0||t(i,e))}function LR(i,e=""){let t=i.split(","),r=e.split(",");return t.length===r.length&&!t.some(s=>r.indexOf(s)===-1)}function Nn(i,e){let{audioCodec:t,channels:r}=i;return(t===void 0||(e.audioCodec||"").substring(0,4)===t.substring(0,4))&&(r===void 0||r===(e.channels||"2"))}function kR(i,e,t,r,s){let n=e[r],o=e.reduce((h,f,m)=>{let p=f.uri;return(h[p]||(h[p]=[])).push(m),h},{})[n.uri];o.length>1&&(r=Math.max.apply(Math,o));let l=n.videoRange,d=n.frameRate,u=n.codecSet.substring(0,4),c=pT(e,r,h=>{if(h.videoRange!==l||h.frameRate!==d||h.codecSet.substring(0,4)!==u)return!1;let f=h.audioGroups,m=t.filter(p=>!f||f.indexOf(p.groupId)!==-1);return Xi(i,m,s)>-1});return c>-1?c:pT(e,r,h=>{let f=h.audioGroups,m=t.filter(p=>!f||f.indexOf(p.groupId)!==-1);return Xi(i,m,s)>-1})}function pT(i,e,t){for(let r=e;r;r--)if(t(i[r]))return r;for(let r=e+1;r<i.length;r++)if(t(i[r]))return r;return-1}var Vp=class{constructor(e){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this._abandonRulesCheck=()=>{let{fragCurrent:t,partCurrent:r,hls:s}=this,{autoLevelEnabled:n,media:a}=s;if(!t||!a)return;let o=performance.now(),l=r?r.stats:t.stats,d=r?r.duration:t.duration,u=o-l.loading.start,c=s.minAutoLevel;if(l.aborted||l.loaded&&l.loaded===l.total||t.level<=c){this.clearTimer(),this._nextAutoLevel=-1;return}if(!n||a.paused||!a.playbackRate||!a.readyState)return;let h=s.mainForwardBufferInfo;if(h===null)return;let f=this.bwEstimator.getEstimateTTFB(),m=Math.abs(a.playbackRate);if(u<=Math.max(f,1e3*(d/(m*2))))return;let p=h.len/m,g=l.loading.first?l.loading.first-l.loading.start:-1,E=l.loaded&&g>-1,T=this.getBwEstimate(),y=s.levels,S=y[t.level],_=l.total||Math.max(l.loaded,Math.round(d*S.averageBitrate/8)),L=E?u-g:u;L<1&&E&&(L=Math.min(u,l.loaded*8/T));let x=E?l.loaded*1e3/L:0,w=x?(_-l.loaded)/x:_*8/T+f/1e3;if(w<=p)return;let M=x?x*8:T,k=Number.POSITIVE_INFINITY,D;for(D=t.level-1;D>c;D--){let B=y[D].maxBitrate;if(k=this.getTimeToLoadFrag(f/1e3,M,d*B,!y[D].details),k<p)break}if(k>=w||k>d*10)return;s.nextLoadLevel=s.nextAutoLevel=D,E?this.bwEstimator.sample(u-Math.min(f,g),l.loaded):this.bwEstimator.sampleTTFB(u);let U=y[D].maxBitrate;this.getBwEstimate()*this.hls.config.abrBandWidthUpFactor>U&&this.resetEstimator(U),this.clearTimer(),I.warn(`[abr] Fragment ${t.sn}${r?" part "+r.index:""} of level ${t.level} is loading too slowly;
1578
+ `))this.processLine(this.buffer.substring(0,e)),this.buffer=this.buffer.substring(e+1)};Su.prototype.processLine=function(i){var e=i.indexOf(":"),t=Wk(i,e),r=t[0],s=t.length===2?fp(t[1]):void 0;if(r[0]!=="#")this.currentUri.uri=r,this.manifest.segments.push(this.currentUri),this.manifest.targetDuration&&!("duration"in this.currentUri)&&(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(r){case vs.TARGET_DURATION:{if(!isFinite(s)||s<0)return;this.manifest.targetDuration=s,this.setHoldBack();break}case vs.PART_INF:{ap(this.manifest,t),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break}case vs.SERVER_CONTROL:{ap(this.manifest,t),this.setHoldBack();break}case vs.INF:{s===0?this.currentUri.duration=.01:s>0&&(this.currentUri.duration=s);break}case vs.PROGRAM_DATE_TIME:{var n=s,a=new Date(n);this.manifest.dateTimeString||(this.manifest.dateTimeString=n,this.manifest.dateTimeObject=a),this.currentUri.dateTimeString=n,this.currentUri.dateTimeObject=a;break}case vs.VERSION:{ap(this.manifest,t);break}case vs.SESSION_DATA:{var o=Kk(t[1]),l=My(o);Object.assign(this.manifest.sessionData,l)}}};Su.prototype.setHoldBack=function(){var i=this.manifest,e=i.serverControl,t=i.targetDuration,r=i.partTargetDuration;if(e){var s="holdBack",n="partHoldBack",a=t&&t*3,o=r&&r*2;t&&!e.hasOwnProperty(s)&&(e[s]=a),a&&e[s]<a&&(e[s]=a),r&&!e.hasOwnProperty(n)&&(e[n]=r*3),r&&e[n]<o&&(e[n]=o)}};var ap=function(i,e){var t=Wy(e[0].replace("#EXT-X-","")),r;Gk(e[1])?(r={},r=Object.assign(Hk(e[1]),r)):r=fp(e[1]),i[t]=r},Wy=function(i){return i.toLowerCase().replace(/-(\w)/g,function(e){return e[1].toUpperCase()})},fp=function(i){if(i.toLowerCase()==="yes"||i.toLowerCase()==="no")return i.toLowerCase()==="yes";var e=i.indexOf(":")!==-1?i:parseFloat(i);return isNaN(e)?i:e},$k=function(i){var e={},t=i.split("=");if(t.length>1){var r=Wy(t[0]);e[r]=fp(t[1])}return e},Hk=function(i){for(var e=i.split(","),t={},r=0;e.length>r;r++){var s=e[r],n=$k(s);t=Object.assign(n,t)}return t},Gk=function(i){return i.indexOf("=")>-1},Wk=function(i,e){return e===-1?[i]:[i.substring(0,e),i.substring(e+1)]},Kk=function(i){var e={};if(i){var t=i.search(","),r=i.slice(0,t),s=i.slice(t+1),n=[r,s];return n.forEach(function(a,o){for(var l=a.replace(/['"]+/g,"").split("="),d=0;d<l.length;d++)l[d]==="DATA-ID"&&(e["DATA-ID"]=l[1-d]),l[d]==="VALUE"&&(e.VALUE=l[1-d])}),{data:e}}},Vk=Su,qk={safeCall:Uk,safeIncrement:Ze,getComputedStyle:Fk,secondsToMs:Bk,assign:Object.assign,headersStringToObject:hp,cdnHeadersToRequestId:_u,extractHostnameAndDomain:io,extractHostname:vi,manifestParser:Vk,generateShortID:Cy,generateUUID:eo,now:tt.now},Yk=qk,zk={PLAYER_READY:"playerready",VIEW_INIT:"viewinit",VIDEO_CHANGE:"videochange",PLAY:"play",PAUSE:"pause",PLAYING:"playing",TIME_UPDATE:"timeupdate",SEEKING:"seeking",SEEKED:"seeked",REBUFFER_START:"rebufferstart",REBUFFER_END:"rebufferend",ERROR:"error",ENDED:"ended",RENDITION_CHANGE:"renditionchange",ORIENTATION_CHANGE:"orientationchange",AD_REQUEST:"adrequest",AD_RESPONSE:"adresponse",AD_BREAK_START:"adbreakstart",AD_PLAY:"adplay",AD_PLAYING:"adplaying",AD_PAUSE:"adpause",AD_FIRST_QUARTILE:"adfirstquartile",AD_MID_POINT:"admidpoint",AD_THIRD_QUARTILE:"adthirdquartile",AD_ENDED:"adended",AD_BREAK_END:"adbreakend",AD_ERROR:"aderror",REQUEST_COMPLETED:"requestcompleted",REQUEST_FAILED:"requestfailed",REQUEST_CANCELLED:"requestcanceled"},jk=zk,Xk="mux-embed",Qk="5.2.0",Zk="2.1",Qt={},wr=function(i){var e=arguments;typeof i=="string"?wr.hasOwnProperty(i)?Za.default.setTimeout(function(){e=Array.prototype.splice.call(e,1),wr[i].apply(null,e)},0):We.warn("`"+i+"` is an unknown task"):typeof i=="function"?Za.default.setTimeout(function(){i(wr)},0):We.warn("`"+i+"` is invalid.")},Jk={loaded:tt.now(),NAME:Xk,VERSION:Qk,API_VERSION:Zk,PLAYER_TRACKED:!1,monitor:function(i,e){return Nk(wr,i,e)},destroyMonitor:function(i){var e=ys(op(i),1),t=e[0];t&&t.mux&&typeof t.mux.destroy=="function"?t.mux.destroy():We.error("A video element monitor for `"+i+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(i,e){var t=Es(i);Qt[t]?Qt[t].addHLSJS(e):We.error("A monitor for `"+t+"` has not been initialized.")},addDashJS:function(i,e){var t=Es(i);Qt[t]?Qt[t].addDashJS(e):We.error("A monitor for `"+t+"` has not been initialized.")},removeHLSJS:function(i){var e=Es(i);Qt[e]?Qt[e].removeHLSJS():We.error("A monitor for `"+e+"` has not been initialized.")},removeDashJS:function(i){var e=Es(i);Qt[e]?Qt[e].removeDashJS():We.error("A monitor for `"+e+"` has not been initialized.")},init:function(i,e){lp()&&e&&e.respectDoNotTrack&&We.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var t=Es(i);Qt[t]=new Dk(wr,t,e)},emit:function(i,e,t){var r=Es(i);Qt[r]?(Qt[r].emit(e,t),e==="destroy"&&delete Qt[r]):We.error("A monitor for `"+r+"` has not been initialized.")},checkDoNotTrack:lp,log:We,utils:Yk,events:jk,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(wr,Jk);typeof Za.default!="undefined"&&typeof Za.default.addEventListener=="function"&&Za.default.addEventListener("pagehide",function(i){i.persisted||(wr.WINDOW_UNLOADING=!0)},!1);var xu=wr;function eI(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var FT={exports:{}};(function(i,e){(function(t){var r=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,s=/^(?=([^\/?#]*))\1([^]*)$/,n=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(l,d,u){if(u=u||{},l=l.trim(),d=d.trim(),!d){if(!u.alwaysNormalize)return l;var c=o.parseURL(l);if(!c)throw new Error("Error trying to parse base URL.");return c.path=o.normalizePath(c.path),o.buildURLFromParts(c)}var h=o.parseURL(d);if(!h)throw new Error("Error trying to parse relative URL.");if(h.scheme)return u.alwaysNormalize?(h.path=o.normalizePath(h.path),o.buildURLFromParts(h)):d;var f=o.parseURL(l);if(!f)throw new Error("Error trying to parse base URL.");if(!f.netLoc&&f.path&&f.path[0]!=="/"){var m=s.exec(f.path);f.netLoc=m[1],f.path=m[2]}f.netLoc&&!f.path&&(f.path="/");var p={scheme:f.scheme,netLoc:h.netLoc,path:null,params:h.params,query:h.query,fragment:h.fragment};if(!h.netLoc&&(p.netLoc=f.netLoc,h.path[0]!=="/"))if(!h.path)p.path=f.path,h.params||(p.params=f.params,h.query||(p.query=f.query));else{var g=f.path,E=g.substring(0,g.lastIndexOf("/")+1)+h.path;p.path=o.normalizePath(E)}return p.path===null&&(p.path=u.alwaysNormalize?o.normalizePath(h.path):h.path),o.buildURLFromParts(p)},parseURL:function(l){var d=r.exec(l);return d?{scheme:d[1]||"",netLoc:d[2]||"",path:d[3]||"",params:d[4]||"",query:d[5]||"",fragment:d[6]||""}:null},normalizePath:function(l){for(l=l.split("").reverse().join("").replace(n,"");l.length!==(l=l.replace(a,"")).length;);return l.split("").reverse().join("")},buildURLFromParts:function(l){return l.scheme+l.netLoc+l.path+l.params+l.query+l.fragment}};i.exports=o})()})(FT);var Gg=FT.exports;function Ky(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(i);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,r)}return t}function mt(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Ky(Object(t),!0).forEach(function(r){rI(i,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):Ky(Object(t)).forEach(function(r){Object.defineProperty(i,r,Object.getOwnPropertyDescriptor(t,r))})}return i}function tI(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var r=t.call(i,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function iI(i){var e=tI(i,"string");return typeof e=="symbol"?e:String(e)}function rI(i,e,t){return e=iI(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Je(){return Je=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},Je.apply(this,arguments)}var q=Number.isFinite||function(i){return typeof i=="number"&&isFinite(i)},sI=Number.isSafeInteger||function(i){return typeof i=="number"&&Math.abs(i)<=nI},nI=Number.MAX_SAFE_INTEGER||9007199254740991,v=function(i){return i.MEDIA_ATTACHING="hlsMediaAttaching",i.MEDIA_ATTACHED="hlsMediaAttached",i.MEDIA_DETACHING="hlsMediaDetaching",i.MEDIA_DETACHED="hlsMediaDetached",i.BUFFER_RESET="hlsBufferReset",i.BUFFER_CODECS="hlsBufferCodecs",i.BUFFER_CREATED="hlsBufferCreated",i.BUFFER_APPENDING="hlsBufferAppending",i.BUFFER_APPENDED="hlsBufferAppended",i.BUFFER_EOS="hlsBufferEos",i.BUFFER_FLUSHING="hlsBufferFlushing",i.BUFFER_FLUSHED="hlsBufferFlushed",i.MANIFEST_LOADING="hlsManifestLoading",i.MANIFEST_LOADED="hlsManifestLoaded",i.MANIFEST_PARSED="hlsManifestParsed",i.LEVEL_SWITCHING="hlsLevelSwitching",i.LEVEL_SWITCHED="hlsLevelSwitched",i.LEVEL_LOADING="hlsLevelLoading",i.LEVEL_LOADED="hlsLevelLoaded",i.LEVEL_UPDATED="hlsLevelUpdated",i.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",i.LEVELS_UPDATED="hlsLevelsUpdated",i.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",i.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",i.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",i.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",i.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",i.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",i.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",i.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",i.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",i.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",i.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",i.CUES_PARSED="hlsCuesParsed",i.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",i.INIT_PTS_FOUND="hlsInitPtsFound",i.FRAG_LOADING="hlsFragLoading",i.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",i.FRAG_LOADED="hlsFragLoaded",i.FRAG_DECRYPTED="hlsFragDecrypted",i.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",i.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",i.FRAG_PARSING_METADATA="hlsFragParsingMetadata",i.FRAG_PARSED="hlsFragParsed",i.FRAG_BUFFERED="hlsFragBuffered",i.FRAG_CHANGED="hlsFragChanged",i.FPS_DROP="hlsFpsDrop",i.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",i.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",i.ERROR="hlsError",i.DESTROYING="hlsDestroying",i.KEY_LOADING="hlsKeyLoading",i.KEY_LOADED="hlsKeyLoaded",i.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",i.BACK_BUFFER_REACHED="hlsBackBufferReached",i.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",i}({}),ie=function(i){return i.NETWORK_ERROR="networkError",i.MEDIA_ERROR="mediaError",i.KEY_SYSTEM_ERROR="keySystemError",i.MUX_ERROR="muxError",i.OTHER_ERROR="otherError",i}({}),C=function(i){return i.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",i.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",i.KEY_SYSTEM_NO_SESSION="keySystemNoSession",i.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",i.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",i.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",i.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",i.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",i.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",i.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",i.MANIFEST_LOAD_ERROR="manifestLoadError",i.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",i.MANIFEST_PARSING_ERROR="manifestParsingError",i.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",i.LEVEL_EMPTY_ERROR="levelEmptyError",i.LEVEL_LOAD_ERROR="levelLoadError",i.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",i.LEVEL_PARSING_ERROR="levelParsingError",i.LEVEL_SWITCH_ERROR="levelSwitchError",i.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",i.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",i.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",i.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",i.FRAG_LOAD_ERROR="fragLoadError",i.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",i.FRAG_DECRYPT_ERROR="fragDecryptError",i.FRAG_PARSING_ERROR="fragParsingError",i.FRAG_GAP="fragGap",i.REMUX_ALLOC_ERROR="remuxAllocError",i.KEY_LOAD_ERROR="keyLoadError",i.KEY_LOAD_TIMEOUT="keyLoadTimeOut",i.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",i.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",i.BUFFER_APPEND_ERROR="bufferAppendError",i.BUFFER_APPENDING_ERROR="bufferAppendingError",i.BUFFER_STALLED_ERROR="bufferStalledError",i.BUFFER_FULL_ERROR="bufferFullError",i.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",i.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",i.INTERNAL_EXCEPTION="internalException",i.INTERNAL_ABORTED="aborted",i.UNKNOWN="unknown",i}({}),Ss=function(){},Mp={trace:Ss,debug:Ss,log:Ss,warn:Ss,info:Ss,error:Ss},so=Mp;function aI(i){let e=self.console[i];return e?e.bind(self.console,`[${i}] >`):Ss}function oI(i,...e){e.forEach(function(t){so[t]=i[t]?i[t].bind(i):aI(t)})}function lI(i,e){if(typeof console=="object"&&i===!0||typeof i=="object"){oI(i,"debug","log","info","warn","error");try{so.log(`Debug logs enabled for "${e}" in hls.js version 1.5.11`)}catch{so=Mp}}else so=Mp}var I=so,dI=/^(\d+)x(\d+)$/,Vy=/(.+?)=(".*?"|.*?)(?:,|$)/g,Ke=class i{constructor(e){typeof e=="string"&&(e=i.parseAttrList(e)),Je(this,e)}get clientAttrs(){return Object.keys(this).filter(e=>e.substring(0,2)==="X-")}decimalInteger(e){let t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2);t=(t.length&1?"0":"")+t;let r=new Uint8Array(t.length/2);for(let s=0;s<t.length/2;s++)r[s]=parseInt(t.slice(s*2,s*2+2),16);return r}else return null}hexadecimalIntegerAsNumber(e){let t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){let r=this[e];return r?parseFloat(r):t}enumeratedString(e){return this[e]}bool(e){return this[e]==="YES"}decimalResolution(e){let t=dI.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e){let t,r={},s='"';for(Vy.lastIndex=0;(t=Vy.exec(e))!==null;){let n=t[2];n.indexOf(s)===0&&n.lastIndexOf(s)===n.length-1&&(n=n.slice(1,-1));let a=t[1].trim();r[a]=n}return r}};function uI(i){return i!=="ID"&&i!=="CLASS"&&i!=="START-DATE"&&i!=="DURATION"&&i!=="END-DATE"&&i!=="END-ON-NEXT"}function cI(i){return i==="SCTE35-OUT"||i==="SCTE35-IN"}var Wu=class{constructor(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){let r=t.attr;for(let s in r)if(Object.prototype.hasOwnProperty.call(e,s)&&e[s]!==r[s]){I.warn(`DATERANGE tag attribute: "${s}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=s;break}e=Je(new Ke({}),r,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){let r=new Date(this.attr["END-DATE"]);q(r.getTime())&&(this._endDate=r)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){if(this._endDate)return this._endDate;let e=this.duration;return e!==null?new Date(this._startDate.getTime()+e*1e3):null}get duration(){if("DURATION"in this.attr){let e=this.attr.decimalFloatingPoint("DURATION");if(q(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isValid(){return!!this.id&&!this._badValueForSameId&&q(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}},Vn=class{constructor(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}},ke={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"},Ku=class{constructor(e){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[ke.AUDIO]:null,[ke.VIDEO]:null,[ke.AUDIOVIDEO]:null},this.baseurl=e}setByteRange(e,t){let r=e.split("@",2),s;r.length===1?s=(t==null?void 0:t.byteRangeEndOffset)||0:s=parseInt(r[1]),this._byteRange=[s,parseInt(r[0])+s]}get byteRange(){return this._byteRange?this._byteRange:[]}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Gg.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}},no=class extends Ku{constructor(e,t){super(t),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new Vn,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.urlId=0,this.type=e}get decryptdata(){let{levelkeys:e}=this;if(!e&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){let t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{let r=Object.keys(this.levelkeys);if(r.length===1)return this._decryptdata=this.levelkeys[r[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null||!q(this.programDateTime))return null;let e=q(this.duration)?this.duration:0;return this.programDateTime+e*1e3}get encrypted(){var e;if((e=this._decryptdata)!=null&&e.encrypted)return!0;if(this.levelkeys){let t=Object.keys(this.levelkeys),r=t.length;if(r>1||r===1&&this.levelkeys[t[0]].encrypted)return!0}return!1}setKeyFormat(e){if(this.levelkeys){let t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}}abortRequests(){var e,t;(e=this.loader)==null||e.abort(),(t=this.keyLoader)==null||t.abort()}setElementaryStreamInfo(e,t,r,s,n,a=!1){let{elementaryStreams:o}=this,l=o[e];if(!l){o[e]={startPTS:t,endPTS:r,startDTS:s,endDTS:n,partial:a};return}l.startPTS=Math.min(l.startPTS,t),l.endPTS=Math.max(l.endPTS,r),l.startDTS=Math.min(l.startDTS,s),l.endDTS=Math.max(l.endDTS,n)}clearElementaryStreamInfo(){let{elementaryStreams:e}=this;e[ke.AUDIO]=null,e[ke.VIDEO]=null,e[ke.AUDIOVIDEO]=null}},Pp=class extends Ku{constructor(e,t,r,s,n){super(r),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.stats=new Vn,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=s;let a=e.enumeratedString("BYTERANGE");a&&this.setByteRange(a,n),n&&(this.fragOffset=n.fragOffset+n.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){let{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo)}},hI=10,Op=class{constructor(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}reloaded(e){if(!e){this.advanced=!0,this.updated=!0;return}let t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||t===0&&r>0,this.updated||this.advanced?this.misses=Math.floor(e.misses*.6):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay}get hasProgramDateTime(){return this.fragments.length?q(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||hI}get drift(){let e=this.driftEndTime-this.driftStartTime;return e>0?(this.driftEnd-this.driftStart)*1e3/e:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var e;return(e=this.fragments)!=null&&e.length?this.fragments[this.fragments.length-1].end:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}};function Wg(i){return Uint8Array.from(atob(i),e=>e.charCodeAt(0))}function fI(i){let e=Np(i).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function mI(i){let e=function(r,s,n){let a=r[s];r[s]=r[n],r[n]=a};e(i,0,3),e(i,1,2),e(i,4,5),e(i,6,7)}function pI(i){let e=i.split(":"),t=null;if(e[0]==="data"&&e.length===2){let r=e[1].split(";"),s=r[r.length-1].split(",");if(s.length===2){let n=s[0]==="base64",a=s[1];n?(r.splice(-1,1),t=Wg(a)):t=fI(a)}}return t}function Np(i){return Uint8Array.from(unescape(encodeURIComponent(i)),e=>e.charCodeAt(0))}var qn=typeof self!="undefined"?self:void 0,Fe={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Ot={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function qy(i){switch(i){case Ot.FAIRPLAY:return Fe.FAIRPLAY;case Ot.PLAYREADY:return Fe.PLAYREADY;case Ot.WIDEVINE:return Fe.WIDEVINE;case Ot.CLEARKEY:return Fe.CLEARKEY}}var BT={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function gI(i){if(i===BT.WIDEVINE)return Fe.WIDEVINE}function Yy(i){switch(i){case Fe.FAIRPLAY:return Ot.FAIRPLAY;case Fe.PLAYREADY:return Ot.PLAYREADY;case Fe.WIDEVINE:return Ot.WIDEVINE;case Fe.CLEARKEY:return Ot.CLEARKEY}}function mp(i){let{drmSystems:e,widevineLicenseUrl:t}=i,r=e?[Fe.FAIRPLAY,Fe.WIDEVINE,Fe.PLAYREADY,Fe.CLEARKEY].filter(s=>!!e[s]):[];return!r[Fe.WIDEVINE]&&t&&r.push(Fe.WIDEVINE),r}var $T=function(i){return qn!=null&&(i=qn.navigator)!=null&&i.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function vI(i,e,t,r){let s;switch(i){case Fe.FAIRPLAY:s=["cenc","sinf"];break;case Fe.WIDEVINE:case Fe.PLAYREADY:s=["cenc"];break;case Fe.CLEARKEY:s=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${i}`)}return EI(s,e,t,r)}function EI(i,e,t,r){return[{initDataTypes:i,persistentState:r.persistentState||"optional",distinctiveIdentifier:r.distinctiveIdentifier||"optional",sessionTypes:r.sessionTypes||[r.sessionType||"temporary"],audioCapabilities:e.map(n=>({contentType:`audio/mp4; codecs="${n}"`,robustness:r.audioRobustness||"",encryptionScheme:r.audioEncryptionScheme||null})),videoCapabilities:t.map(n=>({contentType:`video/mp4; codecs="${n}"`,robustness:r.videoRobustness||"",encryptionScheme:r.videoEncryptionScheme||null}))}]}function ks(i,e,t){return Uint8Array.prototype.slice?i.slice(e,t):new Uint8Array(Array.prototype.slice.call(i,e,t))}var Kg=(i,e)=>e+10<=i.length&&i[e]===73&&i[e+1]===68&&i[e+2]===51&&i[e+3]<255&&i[e+4]<255&&i[e+6]<128&&i[e+7]<128&&i[e+8]<128&&i[e+9]<128,HT=(i,e)=>e+10<=i.length&&i[e]===51&&i[e+1]===68&&i[e+2]===73&&i[e+3]<255&&i[e+4]<255&&i[e+6]<128&&i[e+7]<128&&i[e+8]<128&&i[e+9]<128,oo=(i,e)=>{let t=e,r=0;for(;Kg(i,e);){r+=10;let s=gc(i,e+6);r+=s,HT(i,e+10)&&(r+=10),e+=r}if(r>0)return i.subarray(t,t+r)},gc=(i,e)=>{let t=0;return t=(i[e]&127)<<21,t|=(i[e+1]&127)<<14,t|=(i[e+2]&127)<<7,t|=i[e+3]&127,t},bI=(i,e)=>Kg(i,e)&&gc(i,e+6)+10<=i.length-e,Vg=i=>{let e=WT(i);for(let t=0;t<e.length;t++){let r=e[t];if(GT(r))return xI(r)}},GT=i=>i&&i.key==="PRIV"&&i.info==="com.apple.streaming.transportStreamTimestamp",yI=i=>{let e=String.fromCharCode(i[0],i[1],i[2],i[3]),t=gc(i,4),r=10;return{type:e,size:t,data:i.subarray(r,r+t)}},WT=i=>{let e=0,t=[];for(;Kg(i,e);){let r=gc(i,e+6);e+=10;let s=e+r;for(;e+8<s;){let n=yI(i.subarray(e)),a=TI(n);a&&t.push(a),e+=n.size+10}HT(i,e)&&(e+=10)}return t},TI=i=>i.type==="PRIV"?_I(i):i.type[0]==="W"?SI(i):AI(i),_I=i=>{if(i.size<2)return;let e=Qi(i.data,!0),t=new Uint8Array(i.data.subarray(e.length+1));return{key:i.type,info:e,data:t.buffer}},AI=i=>{if(i.size<2)return;if(i.type==="TXXX"){let t=1,r=Qi(i.data.subarray(t),!0);t+=r.length+1;let s=Qi(i.data.subarray(t));return{key:i.type,info:r,data:s}}let e=Qi(i.data.subarray(1));return{key:i.type,data:e}},SI=i=>{if(i.type==="WXXX"){if(i.size<2)return;let t=1,r=Qi(i.data.subarray(t),!0);t+=r.length+1;let s=Qi(i.data.subarray(t));return{key:i.type,info:r,data:s}}let e=Qi(i.data);return{key:i.type,data:e}},xI=i=>{if(i.data.byteLength===8){let e=new Uint8Array(i.data),t=e[3]&1,r=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return r/=45,t&&(r+=4772185884e-2),Math.round(r)}},Qi=(i,e=!1)=>{let t=LI();if(t){let d=t.decode(i);if(e){let u=d.indexOf("\0");return u!==-1?d.substring(0,u):d}return d.replace(/\0/g,"")}let r=i.length,s,n,a,o="",l=0;for(;l<r;){if(s=i[l++],s===0&&e)return o;if(s===0||s===3)continue;switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(s);break;case 12:case 13:n=i[l++],o+=String.fromCharCode((s&31)<<6|n&63);break;case 14:n=i[l++],a=i[l++],o+=String.fromCharCode((s&15)<<12|(n&63)<<6|(a&63)<<0);break}}return o},pp;function LI(){if(!navigator.userAgent.includes("PlayStation 4"))return!pp&&typeof self.TextDecoder!="undefined"&&(pp=new self.TextDecoder("utf-8")),pp}var zi={hexDump:function(i){let e="";for(let t=0;t<i.length;t++){let r=i[t].toString(16);r.length<2&&(r="0"+r),e+=r}return e}},Vu=Math.pow(2,32)-1,kI=[].push,KT={video:1,audio:2,id3:3,text:4};function it(i){return String.fromCharCode.apply(null,i)}function VT(i,e){let t=i[e]<<8|i[e+1];return t<0?65536+t:t}function Z(i,e){let t=qT(i,e);return t<0?4294967296+t:t}function zy(i,e){let t=Z(i,e);return t*=Math.pow(2,32),t+=Z(i,e+4),t}function qT(i,e){return i[e]<<24|i[e+1]<<16|i[e+2]<<8|i[e+3]}function gp(i,e,t){i[e]=t>>24,i[e+1]=t>>16&255,i[e+2]=t>>8&255,i[e+3]=t&255}function II(i){let e=i.byteLength;for(let t=0;t<e;){let r=Z(i,t);if(r>8&&i[t+4]===109&&i[t+5]===111&&i[t+6]===111&&i[t+7]===102)return!0;t=r>1?t+r:e}return!1}function ae(i,e){let t=[];if(!e.length)return t;let r=i.byteLength;for(let s=0;s<r;){let n=Z(i,s),a=it(i.subarray(s+4,s+8)),o=n>1?s+n:r;if(a===e[0])if(e.length===1)t.push(i.subarray(s+8,o));else{let l=ae(i.subarray(s+8,o),e.slice(1));l.length&&kI.apply(t,l)}s=o}return t}function RI(i){let e=[],t=i[0],r=8,s=Z(i,r);r+=4;let n=0,a=0;t===0?(n=Z(i,r),a=Z(i,r+4),r+=8):(n=zy(i,r),a=zy(i,r+8),r+=16),r+=2;let o=i.length+a,l=VT(i,r);r+=2;for(let d=0;d<l;d++){let u=r,c=Z(i,u);u+=4;let h=c&2147483647;if((c&2147483648)>>>31===1)return I.warn("SIDX has hierarchical references (not supported)"),null;let m=Z(i,u);u+=4,e.push({referenceSize:h,subsegmentDuration:m,info:{duration:m/s,start:o,end:o+h-1}}),o+=h,u+=4,r=u}return{earliestPresentationTime:n,timescale:s,version:t,referencesCount:l,references:e}}function YT(i){let e=[],t=ae(i,["moov","trak"]);for(let s=0;s<t.length;s++){let n=t[s],a=ae(n,["tkhd"])[0];if(a){let o=a[0],l=Z(a,o===0?12:20),d=ae(n,["mdia","mdhd"])[0];if(d){o=d[0];let u=Z(d,o===0?12:20),c=ae(n,["mdia","hdlr"])[0];if(c){let h=it(c.subarray(8,12)),f={soun:ke.AUDIO,vide:ke.VIDEO}[h];if(f){let m=ae(n,["mdia","minf","stbl","stsd"])[0],p=wI(m);e[l]={timescale:u,type:f},e[f]=mt({timescale:u,id:l},p)}}}}}return ae(i,["moov","mvex","trex"]).forEach(s=>{let n=Z(s,4),a=e[n];a&&(a.default={duration:Z(s,12),flags:Z(s,20)})}),e}function wI(i){let e=i.subarray(8),t=e.subarray(86),r=it(e.subarray(4,8)),s=r,n=r==="enca"||r==="encv";if(n){let o=ae(e,[r])[0].subarray(r==="enca"?28:78);ae(o,["sinf"]).forEach(d=>{let u=ae(d,["schm"])[0];if(u){let c=it(u.subarray(4,8));if(c==="cbcs"||c==="cenc"){let h=ae(d,["frma"])[0];h&&(s=it(h))}}})}switch(s){case"avc1":case"avc2":case"avc3":case"avc4":{let a=ae(t,["avcC"])[0];s+="."+Lu(a[1])+Lu(a[2])+Lu(a[3]);break}case"mp4a":{let a=ae(e,[r])[0],o=ae(a.subarray(28),["esds"])[0];if(o&&o.length>12){let l=4;if(o[l++]!==3)break;l=vp(o,l),l+=2;let d=o[l++];if(d&128&&(l+=2),d&64&&(l+=o[l++]),o[l++]!==4)break;l=vp(o,l);let u=o[l++];if(u===64)s+="."+Lu(u);else break;if(l+=12,o[l++]!==5)break;l=vp(o,l);let c=o[l++],h=(c&248)>>3;h===31&&(h+=1+((c&7)<<3)+((o[l]&224)>>5)),s+="."+h}break}case"hvc1":case"hev1":{let a=ae(t,["hvcC"])[0],o=a[1],l=["","A","B","C"][o>>6],d=o&31,u=Z(a,2),c=(o&32)>>5?"H":"L",h=a[12],f=a.subarray(6,12);s+="."+l+d,s+="."+u.toString(16).toUpperCase(),s+="."+c+h;let m="";for(let p=f.length;p--;){let g=f[p];(g||m)&&(m="."+g.toString(16).toUpperCase()+m)}s+=m;break}case"dvh1":case"dvhe":{let a=ae(t,["dvcC"])[0],o=a[2]>>1&127,l=a[2]<<5&32|a[3]>>3&31;s+="."+Yi(o)+"."+Yi(l);break}case"vp09":{let a=ae(t,["vpcC"])[0],o=a[4],l=a[5],d=a[6]>>4&15;s+="."+Yi(o)+"."+Yi(l)+"."+Yi(d);break}case"av01":{let a=ae(t,["av1C"])[0],o=a[1]>>>5,l=a[1]&31,d=a[2]>>>7?"H":"M",u=(a[2]&64)>>6,c=(a[2]&32)>>5,h=o===2&&u?c?12:10:u?10:8,f=(a[2]&16)>>4,m=(a[2]&8)>>3,p=(a[2]&4)>>2,g=a[2]&3,E=1,T=1,y=1,S=0;s+="."+o+"."+Yi(l)+d+"."+Yi(h)+"."+f+"."+m+p+g+"."+Yi(E)+"."+Yi(T)+"."+Yi(y)+"."+S;break}}return{codec:s,encrypted:n}}function vp(i,e){let t=e+5;for(;i[e++]&128&&e<t;);return e}function Lu(i){return("0"+i.toString(16).toUpperCase()).slice(-2)}function Yi(i){return(i<10?"0":"")+i}function CI(i,e){if(!i||!e)return i;let t=e.keyId;return t&&e.isCommonEncryption&&ae(i,["moov","trak"]).forEach(s=>{let a=ae(s,["mdia","minf","stbl","stsd"])[0].subarray(8),o=ae(a,["enca"]),l=o.length>0;l||(o=ae(a,["encv"])),o.forEach(d=>{let u=l?d.subarray(28):d.subarray(78);ae(u,["sinf"]).forEach(h=>{let f=zT(h);if(f){let m=f.subarray(8,24);m.some(p=>p!==0)||(I.log(`[eme] Patching keyId in 'enc${l?"a":"v"}>sinf>>tenc' box: ${zi.hexDump(m)} -> ${zi.hexDump(t)}`),f.set(t,8))}})})}),i}function zT(i){let e=ae(i,["schm"])[0];if(e){let t=it(e.subarray(4,8));if(t==="cbcs"||t==="cenc")return ae(i,["schi","tenc"])[0]}return I.error("[eme] missing 'schm' box"),null}function DI(i,e){return ae(e,["moof","traf"]).reduce((t,r)=>{let s=ae(r,["tfdt"])[0],n=s[0],a=ae(r,["tfhd"]).reduce((o,l)=>{let d=Z(l,4),u=i[d];if(u){let c=Z(s,4);if(n===1){if(c===Vu)return I.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),o;c*=Vu+1,c+=Z(s,8)}let h=u.timescale||9e4,f=c/h;if(q(f)&&(o===null||f<o))return f}return o},null);return a!==null&&q(a)&&(t===null||a<t)?a:t},null)}function MI(i,e){let t=0,r=0,s=0,n=ae(i,["moof","traf"]);for(let a=0;a<n.length;a++){let o=n[a],l=ae(o,["tfhd"])[0],d=Z(l,4),u=e[d];if(!u)continue;let c=u.default,h=Z(l,0)|(c==null?void 0:c.flags),f=c==null?void 0:c.duration;h&8&&(h&2?f=Z(l,12):f=Z(l,8));let m=u.timescale||9e4,p=ae(o,["trun"]);for(let g=0;g<p.length;g++){if(t=PI(p[g]),!t&&f){let E=Z(p[g],4);t=f*E}u.type===ke.VIDEO?r+=t/m:u.type===ke.AUDIO&&(s+=t/m)}}if(r===0&&s===0){let a=1/0,o=0,l=0,d=ae(i,["sidx"]);for(let u=0;u<d.length;u++){let c=RI(d[u]);if(c!=null&&c.references){a=Math.min(a,c.earliestPresentationTime/c.timescale);let h=c.references.reduce((f,m)=>f+m.info.duration||0,0);o=Math.max(o,h+c.earliestPresentationTime/c.timescale),l=o-a}}if(l&&q(l))return l}return r||s}function PI(i){let e=Z(i,0),t=8;e&1&&(t+=4),e&4&&(t+=4);let r=0,s=Z(i,4);for(let n=0;n<s;n++){if(e&256){let a=Z(i,t);r+=a,t+=4}e&512&&(t+=4),e&1024&&(t+=4),e&2048&&(t+=4)}return r}function OI(i,e,t){ae(e,["moof","traf"]).forEach(r=>{ae(r,["tfhd"]).forEach(s=>{let n=Z(s,4),a=i[n];if(!a)return;let o=a.timescale||9e4;ae(r,["tfdt"]).forEach(l=>{let d=l[0],u=t*o;if(u){let c=Z(l,4);if(d===0)c-=u,c=Math.max(c,0),gp(l,4,c);else{c*=Math.pow(2,32),c+=Z(l,8),c-=u,c=Math.max(c,0);let h=Math.floor(c/(Vu+1)),f=Math.floor(c%(Vu+1));gp(l,4,h),gp(l,8,f)}}})})})}function NI(i){let e={valid:null,remainder:null},t=ae(i,["moof"]);if(t.length<2)return e.remainder=i,e;let r=t[t.length-1];return e.valid=ks(i,0,r.byteOffset-8),e.remainder=ks(i,r.byteOffset-8),e}function Jt(i,e){let t=new Uint8Array(i.length+e.length);return t.set(i),t.set(e,i.length),t}function jy(i,e){let t=[],r=e.samples,s=e.timescale,n=e.id,a=!1;return ae(r,["moof"]).map(l=>{let d=l.byteOffset-8;ae(l,["traf"]).map(c=>{let h=ae(c,["tfdt"]).map(f=>{let m=f[0],p=Z(f,4);return m===1&&(p*=Math.pow(2,32),p+=Z(f,8)),p/s})[0];return h!==void 0&&(i=h),ae(c,["tfhd"]).map(f=>{let m=Z(f,4),p=Z(f,0)&16777215,g=(p&1)!==0,E=(p&2)!==0,T=(p&8)!==0,y=0,S=(p&16)!==0,A=0,L=(p&32)!==0,x=8;m===n&&(g&&(x+=8),E&&(x+=4),T&&(y=Z(f,x),x+=4),S&&(A=Z(f,x),x+=4),L&&(x+=4),e.type==="video"&&(a=UI(e.codec)),ae(c,["trun"]).map(w=>{let P=w[0],k=Z(w,0)&16777215,D=(k&1)!==0,U=0,F=(k&4)!==0,z=(k&256)!==0,j=0,K=(k&512)!==0,se=0,oe=(k&1024)!==0,W=(k&2048)!==0,G=0,ne=Z(w,4),Q=8;D&&(U=Z(w,Q),Q+=4),F&&(Q+=4);let me=U+d;for(let Pe=0;Pe<ne;Pe++){if(z?(j=Z(w,Q),Q+=4):j=y,K?(se=Z(w,Q),Q+=4):se=A,oe&&(Q+=4),W&&(P===0?G=Z(w,Q):G=qT(w,Q),Q+=4),e.type===ke.VIDEO){let $e=0;for(;$e<se;){let qe=Z(r,me);if(me+=4,FI(a,r[me])){let kt=r.subarray(me,me+qe);jT(kt,a?2:1,i+G/s,t)}me+=qe,$e+=qe+4}}i+=j/s}}))})})}),t}function UI(i){if(!i)return!1;let e=i.indexOf("."),t=e<0?i:i.substring(0,e);return t==="hvc1"||t==="hev1"||t==="dvh1"||t==="dvhe"}function FI(i,e){if(i){let t=e>>1&63;return t===39||t===40}else return(e&31)===6}function jT(i,e,t,r){let s=XT(i),n=0;n+=e;let a=0,o=0,l=0;for(;n<s.length;){a=0;do{if(n>=s.length)break;l=s[n++],a+=l}while(l===255);o=0;do{if(n>=s.length)break;l=s[n++],o+=l}while(l===255);let d=s.length-n,u=n;if(o<d)n+=o;else if(o>d){I.error(`Malformed SEI payload. ${o} is too small, only ${d} bytes left to parse.`);break}if(a===4){if(s[u++]===181){let h=VT(s,u);if(u+=2,h===49){let f=Z(s,u);if(u+=4,f===1195456820){let m=s[u++];if(m===3){let p=s[u++],g=31&p,E=64&p,T=E?2+g*3:0,y=new Uint8Array(T);if(E){y[0]=p;for(let S=1;S<T;S++)y[S]=s[u++]}r.push({type:m,payloadType:a,pts:t,bytes:y})}}}}}else if(a===5&&o>16){let c=[];for(let m=0;m<16;m++){let p=s[u++].toString(16);c.push(p.length==1?"0"+p:p),(m===3||m===5||m===7||m===9)&&c.push("-")}let h=o-16,f=new Uint8Array(h);for(let m=0;m<h;m++)f[m]=s[u++];r.push({payloadType:a,pts:t,uuid:c.join(""),userData:Qi(f),userDataBytes:f})}}}function XT(i){let e=i.byteLength,t=[],r=1;for(;r<e-2;)i[r]===0&&i[r+1]===0&&i[r+2]===3?(t.push(r+2),r+=2):r++;if(t.length===0)return i;let s=e-t.length,n=new Uint8Array(s),a=0;for(r=0;r<s;a++,r++)a===t[0]&&(a++,t.shift()),n[r]=i[a];return n}function BI(i){let e=i[0],t="",r="",s=0,n=0,a=0,o=0,l=0,d=0;if(e===0){for(;it(i.subarray(d,d+1))!=="\0";)t+=it(i.subarray(d,d+1)),d+=1;for(t+=it(i.subarray(d,d+1)),d+=1;it(i.subarray(d,d+1))!=="\0";)r+=it(i.subarray(d,d+1)),d+=1;r+=it(i.subarray(d,d+1)),d+=1,s=Z(i,12),n=Z(i,16),o=Z(i,20),l=Z(i,24),d=28}else if(e===1){d+=4,s=Z(i,d),d+=4;let c=Z(i,d);d+=4;let h=Z(i,d);for(d+=4,a=2**32*c+h,sI(a)||(a=Number.MAX_SAFE_INTEGER,I.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=Z(i,d),d+=4,l=Z(i,d),d+=4;it(i.subarray(d,d+1))!=="\0";)t+=it(i.subarray(d,d+1)),d+=1;for(t+=it(i.subarray(d,d+1)),d+=1;it(i.subarray(d,d+1))!=="\0";)r+=it(i.subarray(d,d+1)),d+=1;r+=it(i.subarray(d,d+1)),d+=1}let u=i.subarray(d,i.byteLength);return{schemeIdUri:t,value:r,timeScale:s,presentationTime:a,presentationTimeDelta:n,eventDuration:o,id:l,payload:u}}function $I(i,...e){let t=e.length,r=8,s=t;for(;s--;)r+=e[s].byteLength;let n=new Uint8Array(r);for(n[0]=r>>24&255,n[1]=r>>16&255,n[2]=r>>8&255,n[3]=r&255,n.set(i,4),s=0,r=8;s<t;s++)n.set(e[s],r),r+=e[s].byteLength;return n}function HI(i,e,t){if(i.byteLength!==16)throw new RangeError("Invalid system id");let r,s;if(e){r=1,s=new Uint8Array(e.length*16);for(let o=0;o<e.length;o++){let l=e[o];if(l.byteLength!==16)throw new RangeError("Invalid key");s.set(l,o*16)}}else r=0,s=new Uint8Array;let n;r>0?(n=new Uint8Array(4),e.length>0&&new DataView(n.buffer).setUint32(0,e.length,!1)):n=new Uint8Array;let a=new Uint8Array(4);return t&&t.byteLength>0&&new DataView(a.buffer).setUint32(0,t.byteLength,!1),$I([112,115,115,104],new Uint8Array([r,0,0,0]),i,n,s,a,t||new Uint8Array)}function GI(i){if(!(i instanceof ArrayBuffer)||i.byteLength<32)return null;let e={version:0,systemId:"",kids:null,data:null},t=new DataView(i),r=t.getUint32(0);if(i.byteLength!==r&&r>44||t.getUint32(4)!==1886614376||(e.version=t.getUint32(8)>>>24,e.version>1))return null;e.systemId=zi.hexDump(new Uint8Array(i,12,16));let n=t.getUint32(28);if(e.version===0){if(r-32<n)return null;e.data=new Uint8Array(i,32,n)}else if(e.version===1){e.kids=[];for(let a=0;a<n;a++)e.kids.push(new Uint8Array(i,32+a*16,16))}return e}var ku={},lo=class i{static clearKeyUriToKeyIdMap(){ku={}}constructor(e,t,r,s=[1],n=null){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=r,this.keyFormatVersions=s,this.iv=n,this.encrypted=e?e!=="NONE":!1,this.isCommonEncryption=this.encrypted&&e!=="AES-128"}isSupported(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case Ot.FAIRPLAY:case Ot.WIDEVINE:case Ot.PLAYREADY:case Ot.CLEARKEY:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1}getDecryptData(e){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof e!="number"&&(this.method==="AES-128"&&!this.iv&&I.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0);let r=WI(e);return new i(this.method,this.uri,"identity",this.keyFormatVersions,r)}let t=pI(this.uri);if(t)switch(this.keyFormat){case Ot.WIDEVINE:this.pssh=t,t.length>=22&&(this.keyId=t.subarray(t.length-22,t.length-6));break;case Ot.PLAYREADY:{let r=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=HI(r,null,t);let s=new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2),n=String.fromCharCode.apply(null,Array.from(s)),a=n.substring(n.indexOf("<"),n.length),d=new DOMParser().parseFromString(a,"text/xml").getElementsByTagName("KID")[0];if(d){let u=d.childNodes[0]?d.childNodes[0].nodeValue:d.getAttribute("VALUE");if(u){let c=Wg(u).subarray(0,16);mI(c),this.keyId=c}}break}default:{let r=t.subarray(0,16);if(r.length!==16){let s=new Uint8Array(16);s.set(r,16-r.length),r=s}this.keyId=r;break}}if(!this.keyId||this.keyId.byteLength!==16){let r=ku[this.uri];if(!r){let s=Object.keys(ku).length%Number.MAX_SAFE_INTEGER;r=new Uint8Array(16),new DataView(r.buffer,12,4).setUint32(0,s),ku[this.uri]=r}this.keyId=r}return this}};function WI(i){let e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=i>>8*(15-t)&255;return e}var QT=/\{\$([a-zA-Z0-9-_]+)\}/g;function Xy(i){return QT.test(i)}function Mt(i,e,t){if(i.variableList!==null||i.hasVariableRefs)for(let r=t.length;r--;){let s=t[r],n=e[s];n&&(e[s]=Up(i,n))}}function Up(i,e){if(i.variableList!==null||i.hasVariableRefs){let t=i.variableList;return e.replace(QT,r=>{let s=r.substring(2,r.length-1),n=t==null?void 0:t[s];return n===void 0?(i.playlistParsingError||(i.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${s}"`)),r):n})}return e}function Qy(i,e,t){let r=i.variableList;r||(i.variableList=r={});let s,n;if("QUERYPARAM"in e){s=e.QUERYPARAM;try{let a=new self.URL(t).searchParams;if(a.has(s))n=a.get(s);else throw new Error(`"${s}" does not match any query parameter in URI: "${t}"`)}catch(a){i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${a.message}`))}}else s=e.NAME,n=e.VALUE;s in r?i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${s}"`)):r[s]=n||""}function KI(i,e,t){let r=e.IMPORT;if(t&&r in t){let s=i.variableList;s||(i.variableList=s={}),s[r]=t[r]}else i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${r}"`))}function Is(i=!0){return typeof self=="undefined"?void 0:(i||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function VI(i){return typeof self!="undefined"&&i===self.ManagedMediaSource}var qu={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function qI(i,e){let t=qu[e];return!!t&&!!t[i.slice(0,4)]}function Ep(i,e,t=!0){return!i.split(",").some(r=>!ZT(r,e,t))}function ZT(i,e,t=!0){var r;let s=Is(t);return(r=s==null?void 0:s.isTypeSupported(uo(i,e)))!=null?r:!1}function uo(i,e){return`${e}/mp4;codecs="${i}"`}function Zy(i){if(i){let e=i.substring(0,4);return qu.video[e]}return 2}function Yu(i){return i.split(",").reduce((e,t)=>{let r=qu.video[t];return r?(r*2+e)/(e?3:2):(qu.audio[t]+e)/(e?2:1)},0)}var bp={};function YI(i,e=!0){if(bp[i])return bp[i];let t={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"]}[i];for(let r=0;r<t.length;r++)if(ZT(t[r],"audio",e))return bp[i]=t[r],t[r];return i}var zI=/flac|opus/i;function zu(i,e=!0){return i.replace(zI,t=>YI(t.toLowerCase(),e))}function Jy(i,e){return i&&i!=="mp4a"?i:e&&e.split(",")[0]}function jI(i){let e=i.split(".");if(e.length>2){let t=e.shift()+".";return t+=parseInt(e.shift()).toString(16),t+=("000"+parseInt(e.shift()).toString(16)).slice(-4),t}return i}var eT=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,tT=/#EXT-X-MEDIA:(.*)/g,XI=/^#EXT(?:INF|-X-TARGETDURATION):/m,iT=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),QI=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),xs=class i{static findGroup(e,t){for(let r=0;r<e.length;r++){let s=e[r];if(s.id===t)return s}}static resolve(e,t){return Gg.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return XI.test(e)}static parseMasterPlaylist(e,t){let r=Xy(e),s={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:r},n=[];eT.lastIndex=0;let a;for(;(a=eT.exec(e))!=null;)if(a[1]){var o;let d=new Ke(a[1]);Mt(s,d,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);let u=Up(s,a[2]),c={attrs:d,bitrate:d.decimalInteger("BANDWIDTH")||d.decimalInteger("AVERAGE-BANDWIDTH"),name:d.NAME,url:i.resolve(u,t)},h=d.decimalResolution("RESOLUTION");h&&(c.width=h.width,c.height=h.height),ZI(d.CODECS,c),(o=c.unknownCodecs)!=null&&o.length||n.push(c),s.levels.push(c)}else if(a[3]){let d=a[3],u=a[4];switch(d){case"SESSION-DATA":{let c=new Ke(u);Mt(s,c,["DATA-ID","LANGUAGE","VALUE","URI"]);let h=c["DATA-ID"];h&&(s.sessionData===null&&(s.sessionData={}),s.sessionData[h]=c);break}case"SESSION-KEY":{let c=rT(u,t,s);c.encrypted&&c.isSupported()?(s.sessionKeys===null&&(s.sessionKeys=[]),s.sessionKeys.push(c)):I.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${u}"`);break}case"DEFINE":{{let c=new Ke(u);Mt(s,c,["NAME","VALUE","QUERYPARAM"]),Qy(s,c,t)}break}case"CONTENT-STEERING":{let c=new Ke(u);Mt(s,c,["SERVER-URI","PATHWAY-ID"]),s.contentSteering={uri:i.resolve(c["SERVER-URI"],t),pathwayId:c["PATHWAY-ID"]||"."};break}case"START":{s.startTimeOffset=sT(u);break}}}let l=n.length>0&&n.length<s.levels.length;return s.levels=l?n:s.levels,s.levels.length===0&&(s.playlistParsingError=new Error("no levels found in manifest")),s}static parseMasterPlaylistMedia(e,t,r){let s,n={},a=r.levels,o={AUDIO:a.map(d=>({id:d.attrs.AUDIO,audioCodec:d.audioCodec})),SUBTITLES:a.map(d=>({id:d.attrs.SUBTITLES,textCodec:d.textCodec})),"CLOSED-CAPTIONS":[]},l=0;for(tT.lastIndex=0;(s=tT.exec(e))!==null;){let d=new Ke(s[1]),u=d.TYPE;if(u){let c=o[u],h=n[u]||[];n[u]=h,Mt(r,d,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);let f=d.LANGUAGE,m=d["ASSOC-LANGUAGE"],p=d.CHANNELS,g=d.CHARACTERISTICS,E=d["INSTREAM-ID"],T={attrs:d,bitrate:0,id:l++,groupId:d["GROUP-ID"]||"",name:d.NAME||f||"",type:u,default:d.bool("DEFAULT"),autoselect:d.bool("AUTOSELECT"),forced:d.bool("FORCED"),lang:f,url:d.URI?i.resolve(d.URI,t):""};if(m&&(T.assocLang=m),p&&(T.channels=p),g&&(T.characteristics=g),E&&(T.instreamId=E),c!=null&&c.length){let y=i.findGroup(c,T.groupId)||c[0];nT(T,y,"audioCodec"),nT(T,y,"textCodec")}h.push(T)}}return n}static parseLevelPlaylist(e,t,r,s,n,a){let o=new Op(t),l=o.fragments,d=null,u=0,c=0,h=0,f=0,m=null,p=new no(s,t),g,E,T,y=-1,S=!1,A=null;for(iT.lastIndex=0,o.m3u8=e,o.hasVariableRefs=Xy(e);(g=iT.exec(e))!==null;){S&&(S=!1,p=new no(s,t),p.start=h,p.sn=u,p.cc=f,p.level=r,d&&(p.initSegment=d,p.rawProgramDateTime=d.rawProgramDateTime,d.rawProgramDateTime=null,A&&(p.setByteRange(A),A=null)));let P=g[1];if(P){p.duration=parseFloat(P);let k=(" "+g[2]).slice(1);p.title=k||null,p.tagList.push(k?["INF",P,k]:["INF",P])}else if(g[3]){if(q(p.duration)){p.start=h,T&&lT(p,T,o),p.sn=u,p.level=r,p.cc=f,l.push(p);let k=(" "+g[3]).slice(1);p.relurl=Up(o,k),aT(p,m),m=p,h+=p.duration,u++,c=0,S=!0}}else if(g[4]){let k=(" "+g[4]).slice(1);m?p.setByteRange(k,m):p.setByteRange(k)}else if(g[5])p.rawProgramDateTime=(" "+g[5]).slice(1),p.tagList.push(["PROGRAM-DATE-TIME",p.rawProgramDateTime]),y===-1&&(y=l.length);else{if(g=g[0].match(QI),!g){I.warn("No matches on slow regex match for level playlist!");continue}for(E=1;E<g.length&&typeof g[E]=="undefined";E++);let k=(" "+g[E]).slice(1),D=(" "+g[E+1]).slice(1),U=g[E+2]?(" "+g[E+2]).slice(1):"";switch(k){case"PLAYLIST-TYPE":o.type=D.toUpperCase();break;case"MEDIA-SEQUENCE":u=o.startSN=parseInt(D);break;case"SKIP":{let F=new Ke(D);Mt(o,F,["RECENTLY-REMOVED-DATERANGES"]);let z=F.decimalInteger("SKIPPED-SEGMENTS");if(q(z)){o.skippedSegments=z;for(let K=z;K--;)l.unshift(null);u+=z}let j=F.enumeratedString("RECENTLY-REMOVED-DATERANGES");j&&(o.recentlyRemovedDateranges=j.split(" "));break}case"TARGETDURATION":o.targetduration=Math.max(parseInt(D),1);break;case"VERSION":o.version=parseInt(D);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":break;case"ENDLIST":o.live=!1;break;case"#":(D||U)&&p.tagList.push(U?[D,U]:[D]);break;case"DISCONTINUITY":f++,p.tagList.push(["DIS"]);break;case"GAP":p.gap=!0,p.tagList.push([k]);break;case"BITRATE":p.tagList.push([k,D]);break;case"DATERANGE":{let F=new Ke(D);Mt(o,F,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),Mt(o,F,F.clientAttrs);let z=new Wu(F,o.dateRanges[F.ID]);z.isValid||o.skippedSegments?o.dateRanges[z.id]=z:I.warn(`Ignoring invalid DATERANGE tag: "${D}"`),p.tagList.push(["EXT-X-DATERANGE",D]);break}case"DEFINE":{{let F=new Ke(D);Mt(o,F,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in F?KI(o,F,a):Qy(o,F,t)}break}case"DISCONTINUITY-SEQUENCE":f=parseInt(D);break;case"KEY":{let F=rT(D,t,o);if(F.isSupported()){if(F.method==="NONE"){T=void 0;break}T||(T={}),T[F.keyFormat]&&(T=Je({},T)),T[F.keyFormat]=F}else I.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${D}"`);break}case"START":o.startTimeOffset=sT(D);break;case"MAP":{let F=new Ke(D);if(Mt(o,F,["BYTERANGE","URI"]),p.duration){let z=new no(s,t);oT(z,F,r,T),d=z,p.initSegment=d,d.rawProgramDateTime&&!p.rawProgramDateTime&&(p.rawProgramDateTime=d.rawProgramDateTime)}else{let z=p.byteRangeEndOffset;if(z){let j=p.byteRangeStartOffset;A=`${z-j}@${j}`}else A=null;oT(p,F,r,T),d=p,S=!0}break}case"SERVER-CONTROL":{let F=new Ke(D);o.canBlockReload=F.bool("CAN-BLOCK-RELOAD"),o.canSkipUntil=F.optionalFloat("CAN-SKIP-UNTIL",0),o.canSkipDateRanges=o.canSkipUntil>0&&F.bool("CAN-SKIP-DATERANGES"),o.partHoldBack=F.optionalFloat("PART-HOLD-BACK",0),o.holdBack=F.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{let F=new Ke(D);o.partTarget=F.decimalFloatingPoint("PART-TARGET");break}case"PART":{let F=o.partList;F||(F=o.partList=[]);let z=c>0?F[F.length-1]:void 0,j=c++,K=new Ke(D);Mt(o,K,["BYTERANGE","URI"]);let se=new Pp(K,p,t,j,z);F.push(se),p.duration+=se.duration;break}case"PRELOAD-HINT":{let F=new Ke(D);Mt(o,F,["URI"]),o.preloadHint=F;break}case"RENDITION-REPORT":{let F=new Ke(D);Mt(o,F,["URI"]),o.renditionReports=o.renditionReports||[],o.renditionReports.push(F);break}default:I.warn(`line parsed but not handled: ${g}`);break}}}m&&!m.relurl?(l.pop(),h-=m.duration,o.partList&&(o.fragmentHint=m)):o.partList&&(aT(p,m),p.cc=f,o.fragmentHint=p,T&&lT(p,T,o));let L=l.length,x=l[0],w=l[L-1];if(h+=o.skippedSegments*o.targetduration,h>0&&L&&w){o.averagetargetduration=h/L;let P=w.sn;o.endSN=P!=="initSegment"?P:0,o.live||(w.endList=!0),x&&(o.startCC=x.cc)}else o.endSN=0,o.startCC=0;return o.fragmentHint&&(h+=o.fragmentHint.duration),o.totalduration=h,o.endCC=f,y>0&&JI(l,y),o}};function rT(i,e,t){var r,s;let n=new Ke(i);Mt(t,n,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);let a=(r=n.METHOD)!=null?r:"",o=n.URI,l=n.hexadecimalInteger("IV"),d=n.KEYFORMATVERSIONS,u=(s=n.KEYFORMAT)!=null?s:"identity";o&&n.IV&&!l&&I.error(`Invalid IV: ${n.IV}`);let c=o?xs.resolve(o,e):"",h=(d||"1").split("/").map(Number).filter(Number.isFinite);return new lo(a,c,u,h,l)}function sT(i){let t=new Ke(i).decimalFloatingPoint("TIME-OFFSET");return q(t)?t:null}function ZI(i,e){let t=(i||"").split(/[ ,]+/).filter(r=>r);["video","audio","text"].forEach(r=>{let s=t.filter(n=>qI(n,r));s.length&&(e[`${r}Codec`]=s.join(","),t=t.filter(n=>s.indexOf(n)===-1))}),e.unknownCodecs=t}function nT(i,e,t){let r=e[t];r&&(i[t]=r)}function JI(i,e){let t=i[e];for(let r=e;r--;){let s=i[r];if(!s)return;s.programDateTime=t.programDateTime-s.duration*1e3,t=s}}function aT(i,e){i.rawProgramDateTime?i.programDateTime=Date.parse(i.rawProgramDateTime):e!=null&&e.programDateTime&&(i.programDateTime=e.endProgramDateTime),q(i.programDateTime)||(i.programDateTime=null,i.rawProgramDateTime=null)}function oT(i,e,t,r){i.relurl=e.URI,e.BYTERANGE&&i.setByteRange(e.BYTERANGE),i.level=t,i.sn="initSegment",r&&(i.levelkeys=r),i.initSegment=null}function lT(i,e,t){i.levelkeys=e;let{encryptedFragments:r}=t;(!r.length||r[r.length-1].levelkeys!==e)&&Object.keys(e).some(s=>e[s].isCommonEncryption)&&r.push(i)}var ge={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},J={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function dT(i){let{type:e}=i;switch(e){case ge.AUDIO_TRACK:return J.AUDIO;case ge.SUBTITLE_TRACK:return J.SUBTITLE;default:return J.MAIN}}function yp(i,e){let t=i.url;return(t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}var Fp=class{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){let{hls:e}=this;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.LEVEL_LOADING,this.onLevelLoading,this),e.on(v.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(v.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){let{hls:e}=this;e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.LEVEL_LOADING,this.onLevelLoading,this),e.off(v.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(v.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(e){let t=this.hls.config,r=t.pLoader,s=t.loader,n=r||s,a=new n(t);return this.loaders[e.type]=a,a}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(let e in this.loaders){let t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){let{url:r}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:ge.MANIFEST,url:r,deliveryDirectives:null})}onLevelLoading(e,t){let{id:r,level:s,pathwayId:n,url:a,deliveryDirectives:o}=t;this.load({id:r,level:s,pathwayId:n,responseType:"text",type:ge.LEVEL,url:a,deliveryDirectives:o})}onAudioTrackLoading(e,t){let{id:r,groupId:s,url:n,deliveryDirectives:a}=t;this.load({id:r,groupId:s,level:null,responseType:"text",type:ge.AUDIO_TRACK,url:n,deliveryDirectives:a})}onSubtitleTrackLoading(e,t){let{id:r,groupId:s,url:n,deliveryDirectives:a}=t;this.load({id:r,groupId:s,level:null,responseType:"text",type:ge.SUBTITLE_TRACK,url:n,deliveryDirectives:a})}load(e){var t;let r=this.hls.config,s=this.getInternalLoader(e);if(s){let d=s.context;if(d&&d.url===e.url&&d.level===e.level){I.trace("[playlist-loader]: playlist request ongoing");return}I.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),s.abort()}let n;if(e.type===ge.MANIFEST?n=r.manifestLoadPolicy.default:n=Je({},r.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),q((t=e.deliveryDirectives)==null?void 0:t.part)){let d;if(e.type===ge.LEVEL&&e.level!==null?d=this.hls.levels[e.level].details:e.type===ge.AUDIO_TRACK&&e.id!==null?d=this.hls.audioTracks[e.id].details:e.type===ge.SUBTITLE_TRACK&&e.id!==null&&(d=this.hls.subtitleTracks[e.id].details),d){let u=d.partTarget,c=d.targetduration;if(u&&c){let h=Math.max(u*3,c*.8)*1e3;n=Je({},n,{maxTimeToFirstByteMs:Math.min(h,n.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(h,n.maxTimeToFirstByteMs)})}}}let a=n.errorRetry||n.timeoutRetry||{},o={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},l={onSuccess:(d,u,c,h)=>{let f=this.getInternalLoader(c);this.resetInternalLoader(c.type);let m=d.data;if(m.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(d,c,new Error("no EXTM3U delimiter"),h||null,u);return}u.parsing.start=performance.now(),xs.isMediaPlaylist(m)?this.handleTrackOrLevelPlaylist(d,u,c,h||null,f):this.handleMasterPlaylist(d,u,c,h)},onError:(d,u,c,h)=>{this.handleNetworkError(u,c,!1,d,h)},onTimeout:(d,u,c)=>{this.handleNetworkError(u,c,!0,void 0,d)}};s.load(e,o,l)}handleMasterPlaylist(e,t,r,s){let n=this.hls,a=e.data,o=yp(e,r),l=xs.parseMasterPlaylist(a,o);if(l.playlistParsingError){this.handleManifestParsingError(e,r,l.playlistParsingError,s,t);return}let{contentSteering:d,levels:u,sessionData:c,sessionKeys:h,startTimeOffset:f,variableList:m}=l;this.variableList=m;let{AUDIO:p=[],SUBTITLES:g,"CLOSED-CAPTIONS":E}=xs.parseMasterPlaylistMedia(a,o,l);p.length&&!p.some(y=>!y.url)&&u[0].audioCodec&&!u[0].attrs.AUDIO&&(I.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),p.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new Ke({}),bitrate:0,url:""})),n.trigger(v.MANIFEST_LOADED,{levels:u,audioTracks:p,subtitles:g,captions:E,contentSteering:d,url:o,stats:t,networkDetails:s,sessionData:c,sessionKeys:h,startTimeOffset:f,variableList:m})}handleTrackOrLevelPlaylist(e,t,r,s,n){let a=this.hls,{id:o,level:l,type:d}=r,u=yp(e,r),c=0,h=q(l)?l:q(o)?o:0,f=dT(r),m=xs.parseLevelPlaylist(e.data,u,h,f,c,this.variableList);if(d===ge.MANIFEST){let p={attrs:new Ke({}),bitrate:0,details:m,name:"",url:u};a.trigger(v.MANIFEST_LOADED,{levels:[p],audioTracks:[],url:u,stats:t,networkDetails:s,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=m,this.handlePlaylistLoaded(m,e,t,r,s,n)}handleManifestParsingError(e,t,r,s,n){this.hls.trigger(v.ERROR,{type:ie.NETWORK_ERROR,details:C.MANIFEST_PARSING_ERROR,fatal:t.type===ge.MANIFEST,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:s,stats:n})}handleNetworkError(e,t,r=!1,s,n){let a=`A network ${r?"timeout":"error"+(s?" (status "+s.code+")":"")} occurred while loading ${e.type}`;e.type===ge.LEVEL?a+=`: ${e.level} id: ${e.id}`:(e.type===ge.AUDIO_TRACK||e.type===ge.SUBTITLE_TRACK)&&(a+=` id: ${e.id} group-id: "${e.groupId}"`);let o=new Error(a);I.warn(`[playlist-loader]: ${a}`);let l=C.UNKNOWN,d=!1,u=this.getInternalLoader(e);switch(e.type){case ge.MANIFEST:l=r?C.MANIFEST_LOAD_TIMEOUT:C.MANIFEST_LOAD_ERROR,d=!0;break;case ge.LEVEL:l=r?C.LEVEL_LOAD_TIMEOUT:C.LEVEL_LOAD_ERROR,d=!1;break;case ge.AUDIO_TRACK:l=r?C.AUDIO_TRACK_LOAD_TIMEOUT:C.AUDIO_TRACK_LOAD_ERROR,d=!1;break;case ge.SUBTITLE_TRACK:l=r?C.SUBTITLE_TRACK_LOAD_TIMEOUT:C.SUBTITLE_LOAD_ERROR,d=!1;break}u&&this.resetInternalLoader(e.type);let c={type:ie.NETWORK_ERROR,details:l,fatal:d,url:e.url,loader:u,context:e,error:o,networkDetails:t,stats:n};if(s){let h=(t==null?void 0:t.url)||e.url;c.response=mt({url:h,data:void 0},s)}this.hls.trigger(v.ERROR,c)}handlePlaylistLoaded(e,t,r,s,n,a){let o=this.hls,{type:l,level:d,id:u,groupId:c,deliveryDirectives:h}=s,f=yp(t,s),m=dT(s),p=typeof s.level=="number"&&m===J.MAIN?d:void 0;if(!e.fragments.length){let E=new Error("No Segments found in Playlist");o.trigger(v.ERROR,{type:ie.NETWORK_ERROR,details:C.LEVEL_EMPTY_ERROR,fatal:!1,url:f,error:E,reason:E.message,response:t,context:s,level:p,parent:m,networkDetails:n,stats:r});return}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));let g=e.playlistParsingError;if(g){o.trigger(v.ERROR,{type:ie.NETWORK_ERROR,details:C.LEVEL_PARSING_ERROR,fatal:!1,url:f,error:g,reason:g.message,response:t,context:s,level:p,parent:m,networkDetails:n,stats:r});return}switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),(!a.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),l){case ge.MANIFEST:case ge.LEVEL:o.trigger(v.LEVEL_LOADED,{details:e,level:p||0,id:u||0,stats:r,networkDetails:n,deliveryDirectives:h});break;case ge.AUDIO_TRACK:o.trigger(v.AUDIO_TRACK_LOADED,{details:e,id:u||0,groupId:c||"",stats:r,networkDetails:n,deliveryDirectives:h});break;case ge.SUBTITLE_TRACK:o.trigger(v.SUBTITLE_TRACK_LOADED,{details:e,id:u||0,groupId:c||"",stats:r,networkDetails:n,deliveryDirectives:h});break}}};function JT(i,e){let t;try{t=new Event("addtrack")}catch{t=document.createEvent("Event"),t.initEvent("addtrack",!1,!1)}t.track=i,e.dispatchEvent(t)}function e_(i,e){let t=i.mode;if(t==="disabled"&&(i.mode="hidden"),i.cues&&!i.cues.getCueById(e.id))try{if(i.addCue(e),!i.cues.getCueById(e.id))throw new Error(`addCue is failed for: ${e}`)}catch(r){I.debug(`[texttrack-utils]: ${r}`);try{let s=new self.TextTrackCue(e.startTime,e.endTime,e.text);s.id=e.id,i.addCue(s)}catch(s){I.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${s}`)}}t==="disabled"&&(i.mode=t)}function Hn(i){let e=i.mode;if(e==="disabled"&&(i.mode="hidden"),i.cues)for(let t=i.cues.length;t--;)i.removeCue(i.cues[t]);e==="disabled"&&(i.mode=e)}function Bp(i,e,t,r){let s=i.mode;if(s==="disabled"&&(i.mode="hidden"),i.cues&&i.cues.length>0){let n=tR(i.cues,e,t);for(let a=0;a<n.length;a++)(!r||r(n[a]))&&i.removeCue(n[a])}s==="disabled"&&(i.mode=s)}function eR(i,e){if(e<i[0].startTime)return 0;let t=i.length-1;if(e>i[t].endTime)return-1;let r=0,s=t;for(;r<=s;){let n=Math.floor((s+r)/2);if(e<i[n].startTime)s=n-1;else if(e>i[n].startTime&&r<t)r=n+1;else return n}return i[r].startTime-e<e-i[s].startTime?r:s}function tR(i,e,t){let r=[],s=eR(i,e);if(s>-1)for(let n=s,a=i.length;n<a;n++){let o=i[n];if(o.startTime>=e&&o.endTime<=t)r.push(o);else if(o.startTime>t)return r}return r}function Nu(i){let e=[];for(let t=0;t<i.length;t++){let r=i[t];(r.kind==="subtitles"||r.kind==="captions")&&r.label&&e.push(i[t])}return e}var Ti={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"},iR=.25;function $p(){if(typeof self!="undefined")return self.VTTCue||self.TextTrackCue}function uT(i,e,t,r,s){let n=new i(e,t,"");try{n.value=r,s&&(n.type=s)}catch{n=new i(e,t,JSON.stringify(s?mt({type:s},r):r))}return n}var Iu=(()=>{let i=$p();try{i&&new i(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function Tp(i,e){return i.getTime()/1e3-e}function rR(i){return Uint8Array.from(i.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var Hp=class{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){let{hls:e}=this;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(v.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){let{hls:e}=this;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(v.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(e,t){this.media=t.media}onMediaDetaching(){this.id3Track&&(Hn(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){let t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){let r=e[t];if(r.kind==="metadata"&&r.label==="id3")return JT(r,this.media),r}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media)return;let{hls:{config:{enableEmsgMetadataCues:r,enableID3MetadataCues:s}}}=this;if(!r&&!s)return;let{samples:n}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));let a=$p();if(a)for(let o=0;o<n.length;o++){let l=n[o].type;if(l===Ti.emsg&&!r||!s)continue;let d=WT(n[o].data);if(d){let u=n[o].pts,c=u+n[o].duration;c>Iu&&(c=Iu),c-u<=0&&(c=u+iR);for(let f=0;f<d.length;f++){let m=d[f];if(!GT(m)){this.updateId3CueEnds(u,l);let p=uT(a,u,c,m,l);p&&this.id3Track.addCue(p)}}}}}updateId3CueEnds(e,t){var r;let s=(r=this.id3Track)==null?void 0:r.cues;if(s)for(let n=s.length;n--;){let a=s[n];a.type===t&&a.startTime<e&&a.endTime===Iu&&(a.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:r,type:s}){let{id3Track:n,hls:a}=this;if(!a)return;let{config:{enableEmsgMetadataCues:o,enableID3MetadataCues:l}}=a;if(n&&(o||l)){let d;s==="audio"?d=u=>u.type===Ti.audioId3&&l:s==="video"?d=u=>u.type===Ti.emsg&&o:d=u=>u.type===Ti.audioId3&&l||u.type===Ti.emsg&&o,Bp(n,t,r,d)}}onLevelUpdated(e,{details:t}){if(!this.media||!t.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;let{dateRangeCuesAppended:r,id3Track:s}=this,{dateRanges:n}=t,a=Object.keys(n);if(s){let u=Object.keys(r).filter(c=>!a.includes(c));for(let c=u.length;c--;){let h=u[c];Object.keys(r[h].cues).forEach(f=>{s.removeCue(r[h].cues[f])}),delete r[h]}}let o=t.fragments[t.fragments.length-1];if(a.length===0||!q(o==null?void 0:o.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));let l=o.programDateTime/1e3-o.start,d=$p();for(let u=0;u<a.length;u++){let c=a[u],h=n[c],f=Tp(h.startDate,l),m=r[c],p=(m==null?void 0:m.cues)||{},g=(m==null?void 0:m.durationKnown)||!1,E=Iu,T=h.endDate;if(T)E=Tp(T,l),g=!0;else if(h.endOnNext&&!g){let S=a.reduce((A,L)=>{if(L!==h.id){let x=n[L];if(x.class===h.class&&x.startDate>h.startDate&&(!A||h.startDate<A.startDate))return x}return A},null);S&&(E=Tp(S.startDate,l),g=!0)}let y=Object.keys(h.attr);for(let S=0;S<y.length;S++){let A=y[S];if(!uI(A))continue;let L=p[A];if(L)g&&!m.durationKnown&&(L.endTime=E);else if(d){let x=h.attr[A];cI(A)&&(x=rR(x));let w=uT(d,f,E,{key:A,data:x},Ti.dateRange);w&&(w.id=c,this.id3Track.addCue(w),p[A]=w)}}r[c]={cues:p,dateRange:h,durationKnown:g}}}},Gp=class{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=()=>this.timeupdate(),this.hls=e,this.config=e.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){let{config:e,levelDetails:t}=this;return e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){let{levelDetails:e}=this;if(e===null)return null;let{holdBack:t,partHoldBack:r,targetduration:s}=e,{liveSyncDuration:n,liveSyncDurationCount:a,lowLatencyMode:o}=this.config,l=this.hls.userConfig,d=o&&r||t;(l.liveSyncDuration||l.liveSyncDurationCount||d===0)&&(d=n!==void 0?n:a*s);let u=s,c=1;return d+Math.min(this.stallCount*c,u)}get liveSyncPosition(){let e=this.estimateLiveEdge(),t=this.targetLatency,r=this.levelDetails;if(e===null||t===null||r===null)return null;let s=r.edge,n=e-t-this.edgeStalled,a=s-r.totalduration,o=s-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(a,n),o)}get drift(){let{levelDetails:e}=this;return e===null?1:e.drift}get edgeStalled(){let{levelDetails:e}=this;if(e===null)return 0;let t=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-t,0)}get forwardBufferLength(){let{media:e,levelDetails:t}=this;if(!e||!t)return 0;let r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(v.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(v.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(v.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(v.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(v.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(v.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){this.levelDetails=t,t.advanced&&this.timeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(e,t){var r;t.details===C.BUFFER_STALLED_ERROR&&(this.stallCount++,(r=this.levelDetails)!=null&&r.live&&I.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){let{media:e,levelDetails:t}=this;if(!e||!t)return;this.currentTime=e.currentTime;let r=this.computeLatency();if(r===null)return;this._latency=r;let{lowLatencyMode:s,maxLiveSyncPlaybackRate:n}=this.config;if(!s||n===1||!t.live)return;let a=this.targetLatency;if(a===null)return;let o=r-a,l=Math.min(this.maxLatency,a+t.targetduration);if(o<l&&o>.05&&this.forwardBufferLength>1){let u=Math.min(2,Math.max(1,n)),c=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;e.playbackRate=Math.min(u,Math.max(1,c))}else e.playbackRate!==1&&e.playbackRate!==0&&(e.playbackRate=1)}estimateLiveEdge(){let{levelDetails:e}=this;return e===null?null:e.edge+e.age}computeLatency(){let e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}},Wp=["NONE","TYPE-0","TYPE-1",null];function sR(i){return Wp.indexOf(i)>-1}var ju=["SDR","PQ","HLG"];function nR(i){return!!i&&ju.indexOf(i)>-1}var Uu={No:"",Yes:"YES",v2:"v2"};function cT(i){let{canSkipUntil:e,canSkipDateRanges:t,age:r}=i,s=r<e/2;return e&&s?t?Uu.v2:Uu.Yes:Uu.No}var Xu=class{constructor(e,t,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=r}addDirectives(e){let t=new self.URL(e);return this.msn!==void 0&&t.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}},Mr=class{constructor(e){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter(t=>!!t).map(t=>t.substring(0,4)).join(","),this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES)}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get averageBitrate(){return this._avgBitrate||this.realBitrate||this.bitrate}get attrs(){return this._attrs[0]}get codecs(){return this.attrs.CODECS||""}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get videoRange(){return this.attrs["VIDEO-RANGE"]||"SDR"}get score(){return this.attrs.optionalFloat("SCORE",0)}get uri(){return this.url[0]||""}hasAudioGroup(e){return hT(this._audioGroups,e)}hasSubtitleGroup(e){return hT(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,t){if(t){if(e==="audio"){let r=this._audioGroups;r||(r=this._audioGroups=[]),r.indexOf(t)===-1&&r.push(t)}else if(e==="text"){let r=this._subtitleGroups;r||(r=this._subtitleGroups=[]),r.indexOf(t)===-1&&r.push(t)}}}get urlId(){return 0}set urlId(e){}get audioGroupIds(){return this.audioGroups?[this.audioGroupId]:void 0}get textGroupIds(){return this.subtitleGroups?[this.textGroupId]:void 0}get audioGroupId(){var e;return(e=this.audioGroups)==null?void 0:e[0]}get textGroupId(){var e;return(e=this.subtitleGroups)==null?void 0:e[0]}addFallback(){}};function hT(i,e){return!e||!i?!1:i.indexOf(e)!==-1}function _p(i,e){let t=e.startPTS;if(q(t)){let r=0,s;e.sn>i.sn?(r=t-i.start,s=i):(r=i.start-t,s=e),s.duration!==r&&(s.duration=r)}else e.sn>i.sn?i.cc===e.cc&&i.minEndPTS?e.start=i.start+(i.minEndPTS-i.start):e.start=i.start+i.duration:e.start=Math.max(i.start-e.duration,0)}function t_(i,e,t,r,s,n){r-t<=0&&(I.warn("Fragment should have a positive duration",e),r=t+e.duration,n=s+e.duration);let o=t,l=r,d=e.startPTS,u=e.endPTS;if(q(d)){let g=Math.abs(d-t);q(e.deltaPTS)?e.deltaPTS=Math.max(g,e.deltaPTS):e.deltaPTS=g,o=Math.max(t,d),t=Math.min(t,d),s=Math.min(s,e.startDTS),l=Math.min(r,u),r=Math.max(r,u),n=Math.max(n,e.endDTS)}let c=t-e.start;e.start!==0&&(e.start=t),e.duration=r-e.start,e.startPTS=t,e.maxStartPTS=o,e.startDTS=s,e.endPTS=r,e.minEndPTS=l,e.endDTS=n;let h=e.sn;if(!i||h<i.startSN||h>i.endSN)return 0;let f,m=h-i.startSN,p=i.fragments;for(p[m]=e,f=m;f>0;f--)_p(p[f],p[f-1]);for(f=m;f<p.length-1;f++)_p(p[f],p[f+1]);return i.fragmentHint&&_p(p[p.length-1],i.fragmentHint),i.PTSKnown=i.alignedSliding=!0,c}function aR(i,e){let t=null,r=i.fragments;for(let l=r.length-1;l>=0;l--){let d=r[l].initSegment;if(d){t=d;break}}i.fragmentHint&&delete i.fragmentHint.endPTS;let s=0,n;if(dR(i,e,(l,d)=>{l.relurl&&(s=l.cc-d.cc),q(l.startPTS)&&q(l.endPTS)&&(d.start=d.startPTS=l.startPTS,d.startDTS=l.startDTS,d.maxStartPTS=l.maxStartPTS,d.endPTS=l.endPTS,d.endDTS=l.endDTS,d.minEndPTS=l.minEndPTS,d.duration=l.endPTS-l.startPTS,d.duration&&(n=d),e.PTSKnown=e.alignedSliding=!0),d.elementaryStreams=l.elementaryStreams,d.loader=l.loader,d.stats=l.stats,l.initSegment&&(d.initSegment=l.initSegment,t=l.initSegment)}),t&&(e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments).forEach(d=>{var u;d&&(!d.initSegment||d.initSegment.relurl===((u=t)==null?void 0:u.relurl))&&(d.initSegment=t)}),e.skippedSegments)if(e.deltaUpdateFailed=e.fragments.some(l=>!l),e.deltaUpdateFailed){I.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let l=e.skippedSegments;l--;)e.fragments.shift();e.startSN=e.fragments[0].sn,e.startCC=e.fragments[0].cc}else e.canSkipDateRanges&&(e.dateRanges=oR(i.dateRanges,e.dateRanges,e.recentlyRemovedDateranges));let a=e.fragments;if(s){I.warn("discontinuity sliding from playlist, take drift into account");for(let l=0;l<a.length;l++)a[l].cc+=s}e.skippedSegments&&(e.startCC=e.fragments[0].cc),lR(i.partList,e.partList,(l,d)=>{d.elementaryStreams=l.elementaryStreams,d.stats=l.stats}),n?t_(e,n,n.startPTS,n.endPTS,n.startDTS,n.endDTS):i_(i,e),a.length&&(e.totalduration=e.edge-a[0].start),e.driftStartTime=i.driftStartTime,e.driftStart=i.driftStart;let o=e.advancedDateTime;if(e.advanced&&o){let l=e.edge;e.driftStart||(e.driftStartTime=o,e.driftStart=l),e.driftEndTime=o,e.driftEnd=l}else e.driftEndTime=i.driftEndTime,e.driftEnd=i.driftEnd,e.advancedDateTime=i.advancedDateTime}function oR(i,e,t){let r=Je({},i);return t&&t.forEach(s=>{delete r[s]}),Object.keys(e).forEach(s=>{let n=new Wu(e[s].attr,r[s]);n.isValid?r[s]=n:I.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(e[s].attr)}"`)}),r}function lR(i,e,t){if(i&&e){let r=0;for(let s=0,n=i.length;s<=n;s++){let a=i[s],o=e[s+r];a&&o&&a.index===o.index&&a.fragment.sn===o.fragment.sn?t(a,o):r--}}}function dR(i,e,t){let r=e.skippedSegments,s=Math.max(i.startSN,e.startSN)-e.startSN,n=(i.fragmentHint?1:0)+(r?e.endSN:Math.min(i.endSN,e.endSN))-e.startSN,a=e.startSN-i.startSN,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments;for(let d=s;d<=n;d++){let u=l[a+d],c=o[d];r&&!c&&d<r&&(c=e.fragments[d]=u),u&&c&&t(u,c)}}function i_(i,e){let t=e.startSN+e.skippedSegments-i.startSN,r=i.fragments;t<0||t>=r.length||Kp(e,r[t].start)}function Kp(i,e){if(e){let t=i.fragments;for(let r=i.skippedSegments;r<t.length;r++)t[r].start+=e;i.fragmentHint&&(i.fragmentHint.start+=e)}}function uR(i,e=1/0){let t=1e3*i.targetduration;if(i.updated){let r=i.fragments,s=4;if(r.length&&t*s>e){let n=r[r.length-1].duration*1e3;n<t&&(t=n)}}else t/=2;return Math.round(t)}function cR(i,e,t){if(!(i!=null&&i.details))return null;let r=i.details,s=r.fragments[e-r.startSN];return s||(s=r.fragmentHint,s&&s.sn===e)?s:e<r.startSN&&t&&t.sn===e?t:null}function fT(i,e,t){var r;return i!=null&&i.details?r_((r=i.details)==null?void 0:r.partList,e,t):null}function r_(i,e,t){if(i)for(let r=i.length;r--;){let s=i[r];if(s.index===t&&s.fragment.sn===e)return s}return null}function s_(i){i.forEach((e,t)=>{let{details:r}=e;r!=null&&r.fragments&&r.fragments.forEach(s=>{s.level=t})})}function Qu(i){switch(i.details){case C.FRAG_LOAD_TIMEOUT:case C.KEY_LOAD_TIMEOUT:case C.LEVEL_LOAD_TIMEOUT:case C.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function mT(i,e){let t=Qu(e);return i.default[`${t?"timeout":"error"}Retry`]}function qg(i,e){let t=i.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*i.retryDelayMs,i.maxRetryDelayMs)}function pT(i){return mt(mt({},i),{errorRetry:null,timeoutRetry:null})}function Zu(i,e,t,r){if(!i)return!1;let s=r==null?void 0:r.code,n=e<i.maxNumRetry&&(hR(s)||!!t);return i.shouldRetry?i.shouldRetry(i,e,t,r,n):n}function hR(i){return i===0&&navigator.onLine===!1||!!i&&(i<400||i>499)}var n_={search:function(i,e){let t=0,r=i.length-1,s=null,n=null;for(;t<=r;){s=(t+r)/2|0,n=i[s];let a=e(n);if(a>0)t=s+1;else if(a<0)r=s-1;else return n}return null}};function fR(i,e,t){if(e===null||!Array.isArray(i)||!i.length||!q(e))return null;let r=i[0].programDateTime;if(e<(r||0))return null;let s=i[i.length-1].endProgramDateTime;if(e>=(s||0))return null;t=t||0;for(let n=0;n<i.length;++n){let a=i[n];if(pR(e,t,a))return a}return null}function Ju(i,e,t=0,r=0,s=.005){let n=null;if(i){n=e[i.sn-e[0].sn+1]||null;let o=i.endDTS-t;o>0&&o<15e-7&&(t+=15e-7)}else t===0&&e[0].start===0&&(n=e[0]);if(n&&((!i||i.level===n.level)&&Vp(t,r,n)===0||mR(n,i,Math.min(s,r))))return n;let a=n_.search(e,Vp.bind(null,t,r));return a&&(a!==i||!n)?a:n}function mR(i,e,t){if(e&&e.start===0&&e.level<i.level&&(e.endPTS||0)>0){let r=e.tagList.reduce((s,n)=>(n[0]==="INF"&&(s+=parseFloat(n[1])),s),t);return i.start<=r}return!1}function Vp(i=0,e=0,t){if(t.start<=i&&t.start+t.duration>i)return 0;let r=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0));return t.start+t.duration-r<=i?1:t.start-r>i&&t.start?-1:0}function pR(i,e,t){let r=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return(t.endProgramDateTime||0)-r>i}function gR(i,e){return n_.search(i,t=>t.cc<e?1:t.cc>e?-1:0)}var ht={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},Ei={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4},qp=class{constructor(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=I.log.bind(I,"[info]:"),this.warn=I.warn.bind(I,"[warning]:"),this.error=I.error.bind(I,"[error]:"),this.registerListeners()}registerListeners(){let e=this.hls;e.on(v.ERROR,this.onError,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){let e=this.hls;e&&(e.off(v.ERROR,this.onError,this),e.off(v.ERROR,this.onErrorOut,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(e){}stopLoad(){this.playlistError=0}getVariantLevelIndex(e){return(e==null?void 0:e.type)===J.MAIN?e.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(e,t){var r,s;if(t.fatal)return;let n=this.hls,a=t.context;switch(t.details){case C.FRAG_LOAD_ERROR:case C.FRAG_LOAD_TIMEOUT:case C.KEY_LOAD_ERROR:case C.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case C.FRAG_PARSING_ERROR:if((r=t.frag)!=null&&r.gap){t.errorAction={action:ht.DoNothing,flags:Ei.None};return}case C.FRAG_GAP:case C.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=ht.SendAlternateToPenaltyBox;return}case C.LEVEL_EMPTY_ERROR:case C.LEVEL_PARSING_ERROR:{var o,l;let d=t.parent===J.MAIN?t.level:n.loadLevel;t.details===C.LEVEL_EMPTY_ERROR&&((o=t.context)!=null&&(l=o.levelDetails)!=null&&l.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,d):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,d))}return;case C.LEVEL_LOAD_ERROR:case C.LEVEL_LOAD_TIMEOUT:typeof(a==null?void 0:a.level)=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level));return;case C.AUDIO_TRACK_LOAD_ERROR:case C.AUDIO_TRACK_LOAD_TIMEOUT:case C.SUBTITLE_LOAD_ERROR:case C.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){let d=n.levels[n.loadLevel];if(d&&(a.type===ge.AUDIO_TRACK&&d.hasAudioGroup(a.groupId)||a.type===ge.SUBTITLE_TRACK&&d.hasSubtitleGroup(a.groupId))){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.loadLevel),t.errorAction.action=ht.SendAlternateToPenaltyBox,t.errorAction.flags=Ei.MoveAllAlternatesMatchingHost;return}}return;case C.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{let d=n.levels[n.loadLevel],u=d==null?void 0:d.attrs["HDCP-LEVEL"];u?t.errorAction={action:ht.SendAlternateToPenaltyBox,flags:Ei.MoveAllAlternatesMatchingHDCP,hdcpLevel:u}:this.keySystemError(t)}return;case C.BUFFER_ADD_CODEC_ERROR:case C.REMUX_ALLOC_ERROR:case C.BUFFER_APPEND_ERROR:t.errorAction=this.getLevelSwitchAction(t,(s=t.level)!=null?s:n.loadLevel);return;case C.INTERNAL_EXCEPTION:case C.BUFFER_APPENDING_ERROR:case C.BUFFER_FULL_ERROR:case C.LEVEL_SWITCH_ERROR:case C.BUFFER_STALLED_ERROR:case C.BUFFER_SEEK_OVER_HOLE:case C.BUFFER_NUDGE_ON_STALL:t.errorAction={action:ht.DoNothing,flags:Ei.None};return}t.type===ie.KEY_SYSTEM_ERROR&&this.keySystemError(t)}keySystemError(e){let t=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t)}getPlaylistRetryOrSwitchAction(e,t){let r=this.hls,s=mT(r.config.playlistLoadPolicy,e),n=this.playlistError++;if(Zu(s,n,Qu(e),e.response))return{action:ht.RetryRequest,flags:Ei.None,retryConfig:s,retryCount:n};let o=this.getLevelSwitchAction(e,t);return s&&(o.retryConfig=s,o.retryCount=n),o}getFragRetryOrSwitchAction(e){let t=this.hls,r=this.getVariantLevelIndex(e.frag),s=t.levels[r],{fragLoadPolicy:n,keyLoadPolicy:a}=t.config,o=mT(e.details.startsWith("key")?a:n,e),l=t.levels.reduce((u,c)=>u+c.fragmentError,0);if(s&&(e.details!==C.FRAG_GAP&&s.fragmentError++,Zu(o,l,Qu(e),e.response)))return{action:ht.RetryRequest,flags:Ei.None,retryConfig:o,retryCount:l};let d=this.getLevelSwitchAction(e,r);return o&&(d.retryConfig=o,d.retryCount=l),d}getLevelSwitchAction(e,t){let r=this.hls;t==null&&(t=r.loadLevel);let s=this.hls.levels[t];if(s){var n,a;let d=e.details;s.loadError++,d===C.BUFFER_APPEND_ERROR&&s.fragmentError++;let u=-1,{levels:c,loadLevel:h,minAutoLevel:f,maxAutoLevel:m}=r;r.autoLevelEnabled||(r.loadLevel=-1);let p=(n=e.frag)==null?void 0:n.type,E=(p===J.AUDIO&&d===C.FRAG_PARSING_ERROR||e.sourceBufferName==="audio"&&(d===C.BUFFER_ADD_CODEC_ERROR||d===C.BUFFER_APPEND_ERROR))&&c.some(({audioCodec:L})=>s.audioCodec!==L),y=e.sourceBufferName==="video"&&(d===C.BUFFER_ADD_CODEC_ERROR||d===C.BUFFER_APPEND_ERROR)&&c.some(({codecSet:L,audioCodec:x})=>s.codecSet!==L&&s.audioCodec===x),{type:S,groupId:A}=(a=e.context)!=null?a:{};for(let L=c.length;L--;){let x=(L+h)%c.length;if(x!==h&&x>=f&&x<=m&&c[x].loadError===0){var o,l;let w=c[x];if(d===C.FRAG_GAP&&p===J.MAIN&&e.frag){let P=c[x].details;if(P){let k=Ju(e.frag,P.fragments,e.frag.start);if(k!=null&&k.gap)continue}}else{if(S===ge.AUDIO_TRACK&&w.hasAudioGroup(A)||S===ge.SUBTITLE_TRACK&&w.hasSubtitleGroup(A))continue;if(p===J.AUDIO&&(o=s.audioGroups)!=null&&o.some(P=>w.hasAudioGroup(P))||p===J.SUBTITLE&&(l=s.subtitleGroups)!=null&&l.some(P=>w.hasSubtitleGroup(P))||E&&s.audioCodec===w.audioCodec||!E&&s.audioCodec!==w.audioCodec||y&&s.codecSet===w.codecSet)continue}u=x;break}}if(u>-1&&r.loadLevel!==u)return e.levelRetry=!0,this.playlistError=0,{action:ht.SendAlternateToPenaltyBox,flags:Ei.None,nextAutoLevel:u}}return{action:ht.SendAlternateToPenaltyBox,flags:Ei.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var r;switch((r=t.errorAction)==null?void 0:r.action){case ht.DoNothing:break;case ht.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==C.FRAG_GAP?t.fatal=!0:/MediaSource readyState: ended/.test(t.error.message)&&(this.warn(`MediaSource ended after "${t.sourceBufferName}" sourceBuffer append error. Attempting to recover from media error.`),this.hls.recoverMediaError());break;case ht.RetryRequest:break}if(t.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(e){let t=this.hls,r=e.errorAction;if(!r)return;let{flags:s,hdcpLevel:n,nextAutoLevel:a}=r;switch(s){case Ei.None:this.switchLevel(e,a);break;case Ei.MoveAllAlternatesMatchingHDCP:n&&(t.maxHdcpLevel=Wp[Wp.indexOf(n)-1],r.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}r.resolved||this.switchLevel(e,a)}switchLevel(e,t){t!==void 0&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}},co=class{constructor(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=I.log.bind(I,`${t}:`),this.warn=I.warn.bind(I,`${t}:`),this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){this.timer!==-1&&(self.clearTimeout(this.timer),this.timer=-1)}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t,r){let s=t==null?void 0:t.renditionReports;if(s){let n=-1;for(let a=0;a<s.length;a++){let o=s[a],l;try{l=new self.URL(o.URI,t.url).href}catch(d){I.warn(`Could not construct new URL for Rendition Report: ${d}`),l=o.URI||""}if(l===e){n=a;break}else l===e.substring(0,l.length)&&(n=a)}if(n!==-1){let a=s[n],o=parseInt(a["LAST-MSN"])||(t==null?void 0:t.lastPartSn),l=parseInt(a["LAST-PART"])||(t==null?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){let u=Math.min(t.age-t.partTarget,t.targetduration);l>=0&&u>t.partTarget&&(l+=1)}let d=r&&cT(r);return new Xu(o,l>=0?l:void 0,d)}}}loadPlaylist(e){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}shouldReloadPlaylist(e){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(e)}playlistLoaded(e,t,r){let{details:s,stats:n}=t,a=self.performance.now(),o=n.loading.first?Math.max(0,a-n.loading.first):0;if(s.advancedDateTime=Date.now()-o,s.live||r!=null&&r.live){if(s.reloaded(r),r&&this.log(`live playlist ${e} ${s.advanced?"REFRESHED "+s.lastPartSn+"-"+s.lastPartIndex:s.updated?"UPDATED":"MISSED"}`),r&&s.fragments.length>0&&aR(r,s),!this.canLoad||!s.live)return;let l,d,u;if(s.canBlockReload&&s.endSN&&s.advanced){let g=this.hls.config.lowLatencyMode,E=s.lastPartSn,T=s.endSN,y=s.lastPartIndex,S=y!==-1,A=E===T,L=g?0:y;S?(d=A?T+1:E,u=A?L:y+1):d=T+1;let x=s.age,w=x+s.ageHeader,P=Math.min(w-s.partTarget,s.targetduration*1.5);if(P>0){if(r&&P>r.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${r.tuneInGoal} to: ${P} with playlist age: ${s.age}`),P=0;else{let k=Math.floor(P/s.targetduration);if(d+=k,u!==void 0){let D=Math.round(P%s.targetduration/s.partTarget);u+=D}this.log(`CDN Tune-in age: ${s.ageHeader}s last advanced ${x.toFixed(2)}s goal: ${P} skip sn ${k} to part ${u}`)}s.tuneInGoal=P}if(l=this.getDeliveryDirectives(s,t.deliveryDirectives,d,u),g||!A){this.loadPlaylist(l);return}}else(s.canBlockReload||s.canSkipUntil)&&(l=this.getDeliveryDirectives(s,t.deliveryDirectives,d,u));let c=this.hls.mainForwardBufferInfo,h=c?c.end-c.len:0,f=(s.edge-h)*1e3,m=uR(s,f);s.updated&&a>this.requestScheduled+m&&(this.requestScheduled=n.loading.start),d!==void 0&&s.canBlockReload?this.requestScheduled=n.loading.first+m-(s.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+m<a?this.requestScheduled=a:this.requestScheduled-a<=0&&(this.requestScheduled+=m);let p=this.requestScheduled-a;p=Math.max(0,p),this.log(`reload live playlist ${e} in ${Math.round(p)} ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(l),p)}else this.clearTimer()}getDeliveryDirectives(e,t,r,s){let n=cT(e);return t!=null&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,s=t.part,n=Uu.No),new Xu(r,s,n)}checkRetry(e){let t=e.details,r=Qu(e),s=e.errorAction,{action:n,retryCount:a=0,retryConfig:o}=s||{},l=!!s&&!!o&&(n===ht.RetryRequest||!s.resolved&&n===ht.SendAlternateToPenaltyBox);if(l){var d;if(this.requestScheduled=-1,a>=o.maxNumRetry)return!1;if(r&&(d=e.context)!=null&&d.deliveryDirectives)this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{let u=qg(o,a);this.timer=self.setTimeout(()=>this.loadPlaylist(),u),this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" in ${u}ms`)}e.levelRetry=!0,s.resolved=!0}return l}},Dr=class{constructor(e,t=0,r=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=r}sample(e,t){let r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){let e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}},Yp=class{constructor(e,t,r,s=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new Dr(e),this.fast_=new Dr(t),this.defaultTTFB_=s,this.ttfb_=new Dr(e)}update(e,t){let{slow_:r,fast_:s,ttfb_:n}=this;r.halfLife!==e&&(this.slow_=new Dr(e,r.getEstimate(),r.getTotalWeight())),s.halfLife!==t&&(this.fast_=new Dr(t,s.getEstimate(),s.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new Dr(e,n.getEstimate(),n.getTotalWeight()))}sample(e,t){e=Math.max(e,this.minDelayMs_);let r=8*t,s=e/1e3,n=r/s;this.fast_.sample(s,n),this.slow_.sample(s,n)}sampleTTFB(e){let t=e/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(r,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}destroy(){}},a_={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]},gT={};function vR(i,e,t,r,s,n){let a=i.audioCodec?i.audioGroups:null,o=n==null?void 0:n.audioCodec,l=n==null?void 0:n.channels,d=l?parseInt(l):o?1/0:2,u=null;if(a!=null&&a.length)try{a.length===1&&a[0]?u=e.groups[a[0]].channels:u=a.reduce((c,h)=>{if(h){let f=e.groups[h];if(!f)throw new Error(`Audio track group ${h} not found`);Object.keys(f.channels).forEach(m=>{c[m]=(c[m]||0)+f.channels[m]})}return c},{2:0})}catch{return!0}return i.videoCodec!==void 0&&(i.width>1920&&i.height>1088||i.height>1920&&i.width>1088||i.frameRate>Math.max(r,30)||i.videoRange!=="SDR"&&i.videoRange!==t||i.bitrate>Math.max(s,8e6))||!!u&&q(d)&&Object.keys(u).some(c=>parseInt(c)>d)}function ER(i,e,t){let r=i.videoCodec,s=i.audioCodec;if(!r||!s||!t)return Promise.resolve(a_);let n={width:i.width,height:i.height,bitrate:Math.ceil(Math.max(i.bitrate*.9,i.averageBitrate)),framerate:i.frameRate||30},a=i.videoRange;a!=="SDR"&&(n.transferFunction=a.toLowerCase());let o=r.split(",").map(l=>({type:"media-source",video:mt(mt({},n),{},{contentType:uo(l,"video")})}));return s&&i.audioGroups&&i.audioGroups.forEach(l=>{var d;l&&((d=e.groups[l])==null||d.tracks.forEach(u=>{if(u.groupId===l){let c=u.channels||"",h=parseFloat(c);q(h)&&h>2&&o.push.apply(o,s.split(",").map(f=>({type:"media-source",audio:{contentType:uo(f,"audio"),channels:""+h}})))}}))}),Promise.all(o.map(l=>{let d=bR(l);return gT[d]||(gT[d]=t.decodingInfo(l))})).then(l=>({supported:!l.some(d=>!d.supported),configurations:o,decodingInfoResults:l})).catch(l=>({supported:!1,configurations:o,decodingInfoResults:[],error:l}))}function bR(i){let{audio:e,video:t}=i,r=t||e;if(r){let s=r.contentType.split('"')[1];if(t)return`r${t.height}x${t.width}f${Math.ceil(t.framerate)}${t.transferFunction||"sd"}_${s}_${Math.ceil(t.bitrate/1e5)}`;if(e)return`c${e.channels}${e.spatialRendering?"s":"n"}_${s}`}return""}function yR(){if(typeof matchMedia=="function"){let i=matchMedia("(dynamic-range: high)"),e=matchMedia("bad query");if(i.media!==e.media)return i.matches===!0}return!1}function TR(i,e){let t=!1,r=[];return i&&(t=i!=="SDR",r=[i]),e&&(r=e.allowedVideoRanges||ju.slice(0),t=e.preferHDR!==void 0?e.preferHDR:yR(),t?r=r.filter(s=>s!=="SDR"):r=["SDR"]),{preferHDR:t,allowedVideoRanges:r}}function _R(i,e,t,r,s){let n=Object.keys(i),a=r==null?void 0:r.channels,o=r==null?void 0:r.audioCodec,l=a&&parseInt(a)===2,d=!0,u=!1,c=1/0,h=1/0,f=1/0,m=0,p=[],{preferHDR:g,allowedVideoRanges:E}=TR(e,s);for(let A=n.length;A--;){let L=i[n[A]];d=L.channels[2]>0,c=Math.min(c,L.minHeight),h=Math.min(h,L.minFramerate),f=Math.min(f,L.minBitrate);let x=E.filter(w=>L.videoRanges[w]>0);x.length>0&&(u=!0,p=x)}c=q(c)?c:0,h=q(h)?h:0;let T=Math.max(1080,c),y=Math.max(30,h);return f=q(f)?f:t,t=Math.max(f,t),u||(e=void 0,p=[]),{codecSet:n.reduce((A,L)=>{let x=i[L];if(L===A)return A;if(x.minBitrate>t)return dr(L,`min bitrate of ${x.minBitrate} > current estimate of ${t}`),A;if(!x.hasDefaultAudio)return dr(L,"no renditions with default or auto-select sound found"),A;if(o&&L.indexOf(o.substring(0,4))%5!==0)return dr(L,`audio codec preference "${o}" not found`),A;if(a&&!l){if(!x.channels[a])return dr(L,`no renditions with ${a} channel sound found (channels options: ${Object.keys(x.channels)})`),A}else if((!o||l)&&d&&x.channels[2]===0)return dr(L,"no renditions with stereo sound found"),A;return x.minHeight>T?(dr(L,`min resolution of ${x.minHeight} > maximum of ${T}`),A):x.minFramerate>y?(dr(L,`min framerate of ${x.minFramerate} > maximum of ${y}`),A):p.some(w=>x.videoRanges[w]>0)?x.maxScore<m?(dr(L,`max score of ${x.maxScore} < selected max of ${m}`),A):A&&(Yu(L)>=Yu(A)||x.fragmentError>i[A].fragmentError)?A:(m=x.maxScore,L):(dr(L,`no variants with VIDEO-RANGE of ${JSON.stringify(p)} found`),A)},void 0),videoRanges:p,preferHDR:g,minFramerate:h,minBitrate:f}}function dr(i,e){I.log(`[abr] start candidates with "${i}" ignored because ${e}`)}function AR(i){return i.reduce((e,t)=>{let r=e.groups[t.groupId];r||(r=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),r.tracks.push(t);let s=t.channels||"2";return r.channels[s]=(r.channels[s]||0)+1,r.hasDefault=r.hasDefault||t.default,r.hasAutoSelect=r.hasAutoSelect||t.autoselect,r.hasDefault&&(e.hasDefaultAudio=!0),r.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function SR(i,e,t,r){return i.slice(t,r+1).reduce((s,n)=>{if(!n.codecSet)return s;let a=n.audioGroups,o=s[n.codecSet];o||(s[n.codecSet]=o={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!a,fragmentError:0}),o.minBitrate=Math.min(o.minBitrate,n.bitrate);let l=Math.min(n.height,n.width);return o.minHeight=Math.min(o.minHeight,l),o.minFramerate=Math.min(o.minFramerate,n.frameRate),o.maxScore=Math.max(o.maxScore,n.score),o.fragmentError+=n.fragmentError,o.videoRanges[n.videoRange]=(o.videoRanges[n.videoRange]||0)+1,a&&a.forEach(d=>{if(!d)return;let u=e.groups[d];u&&(o.hasDefaultAudio=o.hasDefaultAudio||e.hasDefaultAudio?u.hasDefault:u.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(u.channels).forEach(c=>{o.channels[c]=(o.channels[c]||0)+u.channels[c]}))}),s},{})}function Xi(i,e,t){if("attrs"in i){let r=e.indexOf(i);if(r!==-1)return r}for(let r=0;r<e.length;r++){let s=e[r];if(Wn(i,s,t))return r}return-1}function Wn(i,e,t){let{groupId:r,name:s,lang:n,assocLang:a,characteristics:o,default:l}=i,d=i.forced;return(r===void 0||e.groupId===r)&&(s===void 0||e.name===s)&&(n===void 0||e.lang===n)&&(n===void 0||e.assocLang===a)&&(l===void 0||e.default===l)&&(d===void 0||e.forced===d)&&(o===void 0||xR(o,e.characteristics))&&(t===void 0||t(i,e))}function xR(i,e=""){let t=i.split(","),r=e.split(",");return t.length===r.length&&!t.some(s=>r.indexOf(s)===-1)}function Un(i,e){let{audioCodec:t,channels:r}=i;return(t===void 0||(e.audioCodec||"").substring(0,4)===t.substring(0,4))&&(r===void 0||r===(e.channels||"2"))}function LR(i,e,t,r,s){let n=e[r],o=e.reduce((h,f,m)=>{let p=f.uri;return(h[p]||(h[p]=[])).push(m),h},{})[n.uri];o.length>1&&(r=Math.max.apply(Math,o));let l=n.videoRange,d=n.frameRate,u=n.codecSet.substring(0,4),c=vT(e,r,h=>{if(h.videoRange!==l||h.frameRate!==d||h.codecSet.substring(0,4)!==u)return!1;let f=h.audioGroups,m=t.filter(p=>!f||f.indexOf(p.groupId)!==-1);return Xi(i,m,s)>-1});return c>-1?c:vT(e,r,h=>{let f=h.audioGroups,m=t.filter(p=>!f||f.indexOf(p.groupId)!==-1);return Xi(i,m,s)>-1})}function vT(i,e,t){for(let r=e;r;r--)if(t(i[r]))return r;for(let r=e+1;r<i.length;r++)if(t(i[r]))return r;return-1}var zp=class{constructor(e){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this._abandonRulesCheck=()=>{let{fragCurrent:t,partCurrent:r,hls:s}=this,{autoLevelEnabled:n,media:a}=s;if(!t||!a)return;let o=performance.now(),l=r?r.stats:t.stats,d=r?r.duration:t.duration,u=o-l.loading.start,c=s.minAutoLevel;if(l.aborted||l.loaded&&l.loaded===l.total||t.level<=c){this.clearTimer(),this._nextAutoLevel=-1;return}if(!n||a.paused||!a.playbackRate||!a.readyState)return;let h=s.mainForwardBufferInfo;if(h===null)return;let f=this.bwEstimator.getEstimateTTFB(),m=Math.abs(a.playbackRate);if(u<=Math.max(f,1e3*(d/(m*2))))return;let p=h.len/m,g=l.loading.first?l.loading.first-l.loading.start:-1,E=l.loaded&&g>-1,T=this.getBwEstimate(),y=s.levels,S=y[t.level],A=l.total||Math.max(l.loaded,Math.round(d*S.averageBitrate/8)),L=E?u-g:u;L<1&&E&&(L=Math.min(u,l.loaded*8/T));let x=E?l.loaded*1e3/L:0,w=x?(A-l.loaded)/x:A*8/T+f/1e3;if(w<=p)return;let P=x?x*8:T,k=Number.POSITIVE_INFINITY,D;for(D=t.level-1;D>c;D--){let F=y[D].maxBitrate;if(k=this.getTimeToLoadFrag(f/1e3,P,d*F,!y[D].details),k<p)break}if(k>=w||k>d*10)return;s.nextLoadLevel=s.nextAutoLevel=D,E?this.bwEstimator.sample(u-Math.min(f,g),l.loaded):this.bwEstimator.sampleTTFB(u);let U=y[D].maxBitrate;this.getBwEstimate()*this.hls.config.abrBandWidthUpFactor>U&&this.resetEstimator(U),this.clearTimer(),I.warn(`[abr] Fragment ${t.sn}${r?" part "+r.index:""} of level ${t.level} is loading too slowly;
1579
1579
  Time to underbuffer: ${p.toFixed(3)} s
1580
1580
  Estimated load time for current fragment: ${w.toFixed(3)} s
1581
1581
  Estimated load time for down switch fragment: ${k.toFixed(3)} s
1582
1582
  TTFB estimate: ${g|0} ms
1583
1583
  Current BW estimate: ${q(T)?T|0:"Unknown"} bps
1584
1584
  New BW estimate: ${this.getBwEstimate()|0} bps
1585
- Switching to level ${D} @ ${U|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&&(I.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 Wp(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 C.BUFFER_ADD_CODEC_ERROR:case C.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case C.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===te.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!==te.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 I.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,I.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(I.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 T=m[c],y=!!(T!=null&&(l=T.details)!=null&&l.live),S=g===-1||u===-1,_,L="SDR",x=(T==null?void 0:T.frameRate)||0,{audioPreference:w,videoPreference:M}=E,k=this.audioTracksByGroup||(this.audioTracksByGroup=SR(p));if(S){if(this.firstSelection!==-1)return this.firstSelection;let z=this.codecTiers||(this.codecTiers=xR(m,k,t,r)),V=AR(z,L,e,w,M),{codecSet:se,videoRanges:ae,minFramerate:W,minBitrate:G,preferHDR:oe}=V;_=se,L=oe?ae[ae.length-1]:ae[0],x=W,e=Math.max(e,G),I.log(`[abr] picked start tier ${JSON.stringify(V)}`)}else _=T==null?void 0:T.codecSet,L=T==null?void 0:T.videoRange;let D=f?f.duration:h?h.duration:0,U=this.bwEstimator.getEstimateTTFB()/1e3,B=[];for(let z=r;z>=t;z--){var X;let V=m[z],se=z>c;if(!V)continue;if(E.useMediaCapabilities&&!V.supportedResult&&!V.supportedPromise){let Pe=navigator.mediaCapabilities;typeof(Pe==null?void 0:Pe.decodingInfo)=="function"&&ER(V,k,L,x,e,w)?(V.supportedPromise=bR(V,k,Pe),V.supportedPromise.then(Be=>{if(!this.hls)return;V.supportedResult=Be;let Ke=this.hls.levels,kt=Ke.indexOf(V);Be.error?I.warn(`[abr] MediaCapabilities decodingInfo error: "${Be.error}" for level ${kt} ${JSON.stringify(Be)}`):Be.supported||(I.warn(`[abr] Unsupported MediaCapabilities decodingInfo result for level ${kt} ${JSON.stringify(Be)}`),kt>-1&&Ke.length>1&&(I.log(`[abr] Removing unsupported level ${kt}`),this.hls.removeLevel(kt)))})):V.supportedResult=o_}if(_&&V.codecSet!==_||L&&V.videoRange!==L||se&&x>V.frameRate||!se&&x>0&&x<V.frameRate||V.supportedResult&&!((X=V.supportedResult.decodingInfoResults)!=null&&X[0].smooth)){B.push(z);continue}let ae=V.details,W=(f?ae==null?void 0:ae.partTarget:ae==null?void 0:ae.averagetargetduration)||D,G;se?G=o*e:G=a*e;let oe=D&&s>=D*2&&n===0?m[z].averageBitrate:m[z].maxBitrate,Q=this.getTimeToLoadFrag(U,G,oe*W,ae===void 0);if(G>=oe&&(z===u||V.loadError===0&&V.fragmentError===0)&&(Q<=U||!q(Q)||y&&!this.bitrateTestDelay||Q<d)){let Pe=this.forcedAutoLevel;return z!==g&&(Pe===-1||Pe!==g)&&(B.length&&I.trace(`[abr] Skipped level(s) ${B.join(",")} of ${r} max with CODECS and VIDEO-RANGE:"${m[B[0]].codecs}" ${m[B[0]].videoRange}; not compatible with "${T.codecs}" ${L}`),I.info(`[abr] switch candidate:${c}->${z} adjustedbw(${Math.round(G)})-bitrate=${Math.round(G-oe)} ttfb:${U.toFixed(1)} avgDuration:${W.toFixed(1)} maxFetchDuration:${d.toFixed(1)} fetchDuration:${Q.toFixed(1)} firstSelection:${S} codecSet:${_} videoRange:${L} hls.loadLevel:${g}`)),S&&(this.firstSelection=z),z}}return-1}set nextAutoLevel(e){let{maxAutoLevel:t,minAutoLevel:r}=this.hls,s=Math.min(Math.max(e,r),t);this._nextAutoLevel!==s&&(this.nextAutoLevelKey="",this._nextAutoLevel=s)}},Kp=class{constructor(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(e){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1}clearNextTick(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1}tick(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}},ht={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"},qp=class{constructor(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}_registerListeners(){let{hls:e}=this;e.on(v.BUFFER_APPENDED,this.onBufferAppended,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this),e.on(v.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){let{hls:e}=this;e.off(v.BUFFER_APPENDED,this.onBufferAppended,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this),e.off(v.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){let r=this.activePartLists[t];if(r)for(let s=r.length;s--;){let n=r[s];if(!n)break;let a=n.end;if(n.start<=e&&a!==null&&e<=a)return n}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){let{fragments:r}=this,s=Object.keys(r);for(let n=s.length;n--;){let a=r[s[n]];if((a==null?void 0:a.body.type)===t&&a.buffered){let o=a.body;if(o.start<=e&&e<=o.end)return o}}return null}detectEvictedFragments(e,t,r,s){this.timeRanges&&(this.timeRanges[e]=t);let n=(s==null?void 0:s.fragment.sn)||-1;Object.keys(this.fragments).forEach(a=>{let o=this.fragments[a];if(!o||n>=o.body.sn)return;if(!o.buffered&&!o.loaded){o.body.type===r&&this.removeFragment(o.body);return}let l=o.range[e];l&&l.time.some(d=>{let u=!this.isTimeBuffered(d.startPTS,d.endPTS,t);return u&&this.removeFragment(o.body),u})})}detectPartialFragments(e){let t=this.timeRanges,{frag:r,part:s}=e;if(!t||r.sn==="initSegment")return;let n=Un(r),a=this.fragments[n];if(!a||a.buffered&&r.gap)return;let o=!r.relurl;Object.keys(t).forEach(l=>{let d=r.elementaryStreams[l];if(!d)return;let u=t[l],c=o||d.partial===!0;a.range[l]=this.getBufferedTimes(r,s,c,u)}),a.loaded=null,Object.keys(a.range).length?(a.buffered=!0,(a.body.endList=r.endList||a.body.endList)&&(this.endListFragments[a.body.type]=a),Ru(a)||this.removeParts(r.sn-1,r.type)):this.removeFragment(a.body)}removeParts(e,t){let r=this.activePartLists[t];r&&(this.activePartLists[t]=r.filter(s=>s.fragment.sn>=e))}fragBuffered(e,t){let r=Un(e),s=this.fragments[r];!s&&t&&(s=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),s&&(s.loaded=null,s.buffered=!0)}getBufferedTimes(e,t,r,s){let n={time:[],partial:r},a=e.start,o=e.end,l=e.minEndPTS||o,d=e.maxStartPTS||a;for(let u=0;u<s.length;u++){let c=s.start(u)-this.bufferPadding,h=s.end(u)+this.bufferPadding;if(d>=c&&l<=h){n.time.push({startPTS:Math.max(a,s.start(u)),endPTS:Math.min(o,s.end(u))});break}else if(a<h&&o>c){let f=Math.max(a,s.start(u)),m=Math.min(o,s.end(u));m>f&&(n.partial=!0,n.time.push({startPTS:f,endPTS:m}))}else if(o<=c)break}return n}getPartialFragment(e){let t=null,r,s,n,a=0,{bufferPadding:o,fragments:l}=this;return Object.keys(l).forEach(d=>{let u=l[d];u&&Ru(u)&&(s=u.body.start-o,n=u.body.end+o,e>=s&&e<=n&&(r=Math.min(e-s,n-e),a<=r&&(t=u.body,a=r)))}),t}isEndListAppended(e){let t=this.endListFragments[e];return t!==void 0&&(t.buffered||Ru(t))}getState(e){let t=Un(e),r=this.fragments[t];return r?r.buffered?Ru(r)?ht.PARTIAL:ht.OK:ht.APPENDING:ht.NOT_LOADED}isTimeBuffered(e,t,r){let s,n;for(let a=0;a<r.length;a++){if(s=r.start(a)-this.bufferPadding,n=r.end(a)+this.bufferPadding,e>=s&&t<=n)return!0;if(t<=s)return!1}return!1}onFragLoaded(e,t){let{frag:r,part:s}=t;if(r.sn==="initSegment"||r.bitrateTest)return;let n=s?null:t,a=Un(r);this.fragments[a]={body:r,appendedPTS:null,loaded:n,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){let{frag:r,part:s,timeRanges:n}=t;if(r.sn==="initSegment")return;let a=r.type;if(s){let o=this.activePartLists[a];o||(this.activePartLists[a]=o=[]),o.push(s)}this.timeRanges=n,Object.keys(n).forEach(o=>{let l=n[o];this.detectEvictedFragments(o,l,a,s)})}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){let t=Un(e);return!!this.fragments[t]}hasParts(e){var t;return!!((t=this.activePartLists[e])!=null&&t.length)}removeFragmentsInRange(e,t,r,s,n){s&&!this.hasGaps||Object.keys(this.fragments).forEach(a=>{let o=this.fragments[a];if(!o)return;let l=o.body;l.type!==r||s&&!l.gap||l.start<t&&l.end>e&&(o.buffered||n)&&this.removeFragment(l)})}removeFragment(e){let t=Un(e);e.stats.loaded=0,e.clearElementaryStreamInfo();let r=this.activePartLists[e.type];if(r){let s=e.sn;this.activePartLists[e.type]=r.filter(n=>n.fragment.sn!==s)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}};function Ru(i){var e,t,r;return i.buffered&&(i.body.gap||((e=i.range.video)==null?void 0:e.partial)||((t=i.range.audio)==null?void 0:t.partial)||((r=i.range.audiovideo)==null?void 0:r.partial))}function Un(i){return`${i.type}_${i.level}_${i.sn}`}var IR={length:0,start:()=>0,end:()=>0},Ue=class i{static isBuffered(e,t){try{if(e){let r=i.getBuffered(e);for(let s=0;s<r.length;s++)if(t>=r.start(s)&&t<=r.end(s))return!0}}catch{}return!1}static bufferInfo(e,t,r){try{if(e){let s=i.getBuffered(e),n=[],a;for(a=0;a<s.length;a++)n.push({start:s.start(a),end:s.end(a)});return this.bufferedInfo(n,t,r)}}catch{}return{len:0,start:t,end:t,nextStart:void 0}}static bufferedInfo(e,t,r){t=Math.max(0,t),e.sort(function(d,u){let c=d.start-u.start;return c||u.end-d.end});let s=[];if(r)for(let d=0;d<e.length;d++){let u=s.length;if(u){let c=s[u-1].end;e[d].start-c<r?e[d].end>c&&(s[u-1].end=e[d].end):s.push(e[d])}else s.push(e[d])}else s=e;let n=0,a,o=t,l=t;for(let d=0;d<s.length;d++){let u=s[d].start,c=s[d].end;if(t+r>=u&&t<c)o=u,l=c,n=l-t;else if(t+r<u){a=u;break}}return{len:n,start:o||0,end:l||0,nextStart:a}}static getBuffered(e){try{return e.buffered}catch(t){return I.log("failed to get media.buffered",t),IR}}},ho=class{constructor(e,t,r,s=0,n=-1,a=!1){this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=wu(),this.buffering={audio:wu(),video:wu(),audiovideo:wu()},this.level=e,this.sn=t,this.id=r,this.size=s,this.part=n,this.partial=a}};function wu(){return{start:0,executeStart:0,executeEnd:0,end:0}}function Uu(i,e){for(let r=0,s=i.length;r<s;r++){var t;if(((t=i[r])==null?void 0:t.cc)===e)return i[r]}return null}function RR(i,e,t){return!!(e&&(t.endCC>t.startCC||i&&i.cc<t.startCC))}function wR(i,e){let t=i.fragments,r=e.fragments;if(!r.length||!t.length){I.log("No fragments to align");return}let s=Uu(t,r[0].cc);if(!s||s&&!s.startPTS){I.log("No frag in previous level to align on");return}return s}function gT(i,e){if(i){let t=i.start+e;i.start=i.startPTS=t,i.endPTS=t+i.duration}}function l_(i,e){let t=e.fragments;for(let r=0,s=t.length;r<s;r++)gT(t[r],i);e.fragmentHint&&gT(e.fragmentHint,i),e.alignedSliding=!0}function CR(i,e,t){e&&(DR(i,t,e),!t.alignedSliding&&e&&Ju(t,e),!t.alignedSliding&&e&&!t.skippedSegments&&r_(e,t))}function DR(i,e,t){if(RR(i,t,e)){let r=wR(t,e);r&&q(r.start)&&(I.log(`Adjusting PTS using last level due to CC increase within current level ${e.url}`),l_(r.start,e))}}function Ju(i,e){if(!i.hasProgramDateTime||!e.hasProgramDateTime)return;let t=i.fragments,r=e.fragments;if(!t.length||!r.length)return;let s,n,a=Math.min(e.endCC,i.endCC);e.startCC<a&&i.startCC<a&&(s=Uu(r,a),n=Uu(t,a)),(!s||!n)&&(s=r[Math.floor(r.length/2)],n=Uu(t,s.cc)||t[Math.floor(t.length/2)]);let o=s.programDateTime,l=n.programDateTime;if(!o||!l)return;let d=(l-o)/1e3-(n.start-s.start);l_(d,i)}var vT=Math.pow(2,17),Yp=class{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(e,t){let r=e.url;if(!r)return Promise.reject(new yi({type:ie.NETWORK_ERROR,details:C.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error(`Fragment does not have a ${r?"part list":"url"}`),networkDetails:null}));this.abort();let s=this.config,n=s.fLoader,a=s.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(f=>f[0]==="GAP")){l(bT(e));return}else e.gap=!1;let d=this.loader=e.loader=n?new n(s):new a(s),u=ET(e),c=fT(s.fragLoadPolicy.default),h={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:vT};e.stats=d.stats,d.load(u,h,{onSuccess:(f,m,p,g)=>{this.resetLoader(e,d);let E=f.data;p.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(E.slice(0,16)),E=E.slice(16)),o({frag:e,part:null,payload:E,networkDetails:g})},onError:(f,m,p,g)=>{this.resetLoader(e,d),l(new yi({type:ie.NETWORK_ERROR,details:C.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:ft({url:r,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:p,stats:g}))},onAbort:(f,m,p)=>{this.resetLoader(e,d),l(new yi({type:ie.NETWORK_ERROR,details:C.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:p,stats:f}))},onTimeout:(f,m,p)=>{this.resetLoader(e,d),l(new yi({type:ie.NETWORK_ERROR,details:C.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:p,stats:f}))},onProgress:(f,m,p,g)=>{t&&t({frag:e,part:null,payload:p,networkDetails:g})}})})}loadPart(e,t,r){this.abort();let s=this.config,n=s.fLoader,a=s.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap){l(bT(e,t));return}let d=this.loader=e.loader=n?new n(s):new a(s),u=ET(e,t),c=fT(s.fragLoadPolicy.default),h={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:vT};t.stats=d.stats,d.load(u,h,{onSuccess:(f,m,p,g)=>{this.resetLoader(e,d),this.updateStatsFromPart(e,t);let E={frag:e,part:t,payload:f.data,networkDetails:g};r(E),o(E)},onError:(f,m,p,g)=>{this.resetLoader(e,d),l(new yi({type:ie.NETWORK_ERROR,details:C.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:ft({url:u.url,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:p,stats:g}))},onAbort:(f,m,p)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,d),l(new yi({type:ie.NETWORK_ERROR,details:C.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:p,stats:f}))},onTimeout:(f,m,p)=>{this.resetLoader(e,d),l(new yi({type:ie.NETWORK_ERROR,details:C.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:p,stats:f}))}})})}updateStatsFromPart(e,t){let r=e.stats,s=t.stats,n=s.total;if(r.loaded+=s.loaded,n){let l=Math.round(e.duration/t.duration),d=Math.min(Math.round(r.loaded/n),l),c=(l-d)*Math.round(r.loaded/d);r.total=r.loaded+c}else r.total=Math.max(r.loaded,r.total);let a=r.loading,o=s.loading;a.start?a.first+=o.first-o.start:(a.start=o.start,a.first=o.first),a.end=o.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}};function ET(i,e=null){let t=e||i,r={frag:i,part:e,responseType:"arraybuffer",url:t.url,headers:{},rangeStart:0,rangeEnd:0},s=t.byteRangeStartOffset,n=t.byteRangeEndOffset;if(q(s)&&q(n)){var a;let o=s,l=n;if(i.sn==="initSegment"&&((a=i.decryptdata)==null?void 0:a.method)==="AES-128"){let d=n-s;d%16&&(l=n+(16-d%16)),s!==0&&(r.resetIV=!0,o=s-16)}r.rangeStart=o,r.rangeEnd=l}return r}function bT(i,e){let t=new Error(`GAP ${i.gap?"tag":"attribute"} found`),r={type:ie.MEDIA_ERROR,details:C.FRAG_GAP,fatal:!1,frag:i,error:t,networkDetails:null};return e&&(r.part=e),(e||i).stats.aborted=!0,new yi(r)}var yi=class extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}},zp=class{constructor(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t}decrypt(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)}},jp=class{constructor(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}};function MR(i){let e=i.byteLength,t=e&&new DataView(i.buffer).getUint8(e-1);return t?Ls(i,0,e-t):i}var Xp=class{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}uint8ArrayToUint32Array_(e){let t=new DataView(e),r=new Uint32Array(4);for(let s=0;s<4;s++)r[s]=t.getUint32(s*4);return r}initTable(){let e=this.sBox,t=this.invSBox,r=this.subMix,s=r[0],n=r[1],a=r[2],o=r[3],l=this.invSubMix,d=l[0],u=l[1],c=l[2],h=l[3],f=new Uint32Array(256),m=0,p=0,g=0;for(g=0;g<256;g++)g<128?f[g]=g<<1:f[g]=g<<1^283;for(g=0;g<256;g++){let E=p^p<<1^p<<2^p<<3^p<<4;E=E>>>8^E&255^99,e[m]=E,t[E]=m;let T=f[m],y=f[T],S=f[y],_=f[E]*257^E*16843008;s[m]=_<<24|_>>>8,n[m]=_<<16|_>>>16,a[m]=_<<8|_>>>24,o[m]=_,_=S*16843009^y*65537^T*257^m*16843008,d[E]=_<<24|_>>>8,u[E]=_<<16|_>>>16,c[E]=_<<8|_>>>24,h[E]=_,m?(m=T^f[f[f[S^T]]],p^=f[f[p]]):m=p=1}}expandKey(e){let t=this.uint8ArrayToUint32Array_(e),r=!0,s=0;for(;s<t.length&&r;)r=t[s]===this.key[s],s++;if(r)return;this.key=t;let n=this.keySize=t.length;if(n!==4&&n!==6&&n!==8)throw new Error("Invalid aes key size="+n);let a=this.ksRows=(n+6+1)*4,o,l,d=this.keySchedule=new Uint32Array(a),u=this.invKeySchedule=new Uint32Array(a),c=this.sBox,h=this.rcon,f=this.invSubMix,m=f[0],p=f[1],g=f[2],E=f[3],T,y;for(o=0;o<a;o++){if(o<n){T=d[o]=t[o];continue}y=T,o%n===0?(y=y<<8|y>>>24,y=c[y>>>24]<<24|c[y>>>16&255]<<16|c[y>>>8&255]<<8|c[y&255],y^=h[o/n|0]<<24):n>6&&o%n===4&&(y=c[y>>>24]<<24|c[y>>>16&255]<<16|c[y>>>8&255]<<8|c[y&255]),d[o]=T=(d[o-n]^y)>>>0}for(l=0;l<a;l++)o=a-l,l&3?y=d[o]:y=d[o-4],l<4||o<=4?u[l]=y:u[l]=m[c[y>>>24]]^p[c[y>>>16&255]]^g[c[y>>>8&255]]^E[c[y&255]],u[l]=u[l]>>>0}networkToHostOrderSwap(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24}decrypt(e,t,r){let s=this.keySize+6,n=this.invKeySchedule,a=this.invSBox,o=this.invSubMix,l=o[0],d=o[1],u=o[2],c=o[3],h=this.uint8ArrayToUint32Array_(r),f=h[0],m=h[1],p=h[2],g=h[3],E=new Int32Array(e),T=new Int32Array(E.length),y,S,_,L,x,w,M,k,D,U,B,X,z,V,se=this.networkToHostOrderSwap;for(;t<E.length;){for(D=se(E[t]),U=se(E[t+1]),B=se(E[t+2]),X=se(E[t+3]),x=D^n[0],w=X^n[1],M=B^n[2],k=U^n[3],z=4,V=1;V<s;V++)y=l[x>>>24]^d[w>>16&255]^u[M>>8&255]^c[k&255]^n[z],S=l[w>>>24]^d[M>>16&255]^u[k>>8&255]^c[x&255]^n[z+1],_=l[M>>>24]^d[k>>16&255]^u[x>>8&255]^c[w&255]^n[z+2],L=l[k>>>24]^d[x>>16&255]^u[w>>8&255]^c[M&255]^n[z+3],x=y,w=S,M=_,k=L,z=z+4;y=a[x>>>24]<<24^a[w>>16&255]<<16^a[M>>8&255]<<8^a[k&255]^n[z],S=a[w>>>24]<<24^a[M>>16&255]<<16^a[k>>8&255]<<8^a[x&255]^n[z+1],_=a[M>>>24]<<24^a[k>>16&255]<<16^a[x>>8&255]<<8^a[w&255]^n[z+2],L=a[k>>>24]<<24^a[x>>16&255]<<16^a[w>>8&255]<<8^a[M&255]^n[z+3],T[t]=se(y^f),T[t+1]=se(L^m),T[t+2]=se(_^p),T[t+3]=se(S^g),f=D,m=U,p=B,g=X,t=t+4}return T.buffer}},PR=16,fo=class{constructor(e,{removePKCS7Padding:t=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{let r=self.crypto;r&&(this.subtle=r.subtle||r.webkitSubtle)}catch{}this.subtle===null&&(this.useSoftware=!0)}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){let{currentResult:e,remainderData:t}=this;if(!e||t)return this.reset(),null;let r=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?MR(r):r}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,r){return this.useSoftware?new Promise((s,n)=>{this.softwareDecrypt(new Uint8Array(e),t,r);let a=this.flush();a?s(a.buffer):n(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,r)}softwareDecrypt(e,t,r){let{currentIV:s,currentResult:n,remainderData:a}=this;this.logOnce("JS AES decrypt"),a&&(e=Jt(a,e),this.remainderData=null);let o=this.getValidChunk(e);if(!o.length)return null;s&&(r=s);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new Xp),l.expandKey(t);let d=n;return this.currentResult=l.decrypt(o.buffer,0,r),this.currentIV=Ls(o,-16).buffer,d||null}webCryptoDecrypt(e,t,r){let s=this.subtle;return(this.key!==t||!this.fastAesKey)&&(this.key=t,this.fastAesKey=new jp(s,t)),this.fastAesKey.expandKey().then(n=>s?(this.logOnce("WebCrypto AES decrypt"),new zp(s,new Uint8Array(r)).decrypt(e.buffer,n)):Promise.reject(new Error("web crypto not initialized"))).catch(n=>(I.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${n.name}: ${n.message}`),this.onWebCryptoError(e,t,r)))}onWebCryptoError(e,t,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r);let s=this.flush();if(s)return s.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(e){let t=e,r=e.length-e.length%PR;return r!==e.length&&(t=Ls(e,0,r),this.remainderData=Ls(e,r)),t}logOnce(e){this.logEnabled&&(I.log(`[decrypter]: ${e}`),this.logEnabled=!1)}},OR={toString:function(i){let e="",t=i.length;for(let r=0;r<t;r++)e+=`[${i.start(r).toFixed(3)}-${i.end(r).toFixed(3)}]`;return e}},N={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},mo=class extends Kp{constructor(e,t,r,s,n){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=N.STOPPED,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.loadedmetadata=!1,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=n,this.logPrefix=s,this.log=I.log.bind(I,`${s}:`),this.warn=I.warn.bind(I,`${s}:`),this.hls=e,this.fragmentLoader=new Yp(e.config),this.keyLoader=r,this.fragmentTracker=t,this.config=e.config,this.decrypter=new fo(e.config),e.on(v.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);let e=this.fragCurrent;e!=null&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=N.STOPPED}_streamEnded(e,t){if(t.live||e.nextStart||!e.end||!this.media)return!1;let r=t.partList;if(r!=null&&r.length){let n=r[r.length-1];return Ue.isBuffered(this.media,n.start+n.duration/2)}let s=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(s)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null){var e;return(e=this.levelLastLoaded)==null?void 0:e.details}}onMediaAttached(e,t){let r=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),r.addEventListener("seeking",this.onvseeking),r.addEventListener("ended",this.onvended);let s=this.config;this.levels&&s.autoStartLoad&&this.state===N.STOPPED&&this.startLoad(s.startPosition)}onMediaDetaching(){let e=this.media;e!=null&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&this.onvseeking&&this.onvended&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}onMediaSeeking(){let{config:e,fragCurrent:t,media:r,mediaBuffer:s,state:n}=this,a=r?r.currentTime:0,o=Ue.bufferInfo(s||r,a,e.maxBufferHole);if(this.log(`media seeking to ${q(a)?a.toFixed(3):a}, state: ${n}`),this.state===N.ENDED)this.resetLoadingState();else if(t){let l=e.maxFragLookUpTolerance,d=t.start-l,u=t.start+t.duration+l;if(!o.len||u<o.start||d>o.end){let c=a>u;(a<d||c)&&(c&&t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}r&&(this.fragmentTracker.removeFragmentsInRange(a,1/0,this.playlistType,!0),this.lastCurrentTime=a),!this.loadedmetadata&&!o.len&&(this.nextLoadPosition=this.startPosition=a),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.hls.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),this.stopLoad(),super.onHandlerDestroying(),this.hls=null}onHandlerDestroyed(){this.state=N.STOPPED,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(e,t,r){this._loadFragForPlayback(e,t,r)}_loadFragForPlayback(e,t,r){let s=n=>{if(this.fragContextChanged(e)){this.warn(`Fragment ${e.sn}${n.part?" p: "+n.part.index:""} of level ${e.level} was dropped during download.`),this.fragmentTracker.removeFragment(e);return}e.stats.chunkCount++,this._handleFragmentLoadProgress(n)};this._doFragLoad(e,t,r,s).then(n=>{if(!n)return;let a=this.state;if(this.fragContextChanged(e)){(a===N.FRAG_LOADING||!this.fragCurrent&&a===N.PARSING)&&(this.fragmentTracker.removeFragment(e),this.state=N.IDLE);return}"payload"in n&&(this.log(`Loaded fragment ${e.sn} of level ${e.level}`),this.hls.trigger(v.FRAG_LOADED,n)),this._handleFragmentLoadComplete(n)}).catch(n=>{this.state===N.STOPPED||this.state===N.ERROR||(this.warn(n),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;let{fragmentTracker:r}=this;if(r.getState(e)===ht.APPENDING){let n=e.type,a=this.getFwdBufferInfo(this.mediaBuffer,n),o=Math.max(e.duration,a?a.len:this.config.maxBufferLength);this.reduceMaxBufferLength(o)&&r.removeFragment(e)}else((t=this.mediaBuffer)==null?void 0:t.buffered.length)===0?r.removeAllFragments():r.hasParts(e.type)&&(r.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),r.getState(e)===ht.PARTIAL&&r.removeFragment(e))}checkLiveUpdate(e){if(e.updated&&!e.live){let t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}flushMainBuffer(e,t,r=null){if(!(e-t))return;let s={startOffset:e,endOffset:t,type:r};this.hls.trigger(v.BUFFER_FLUSHING,s)}_loadInitSegment(e,t){this._doFragLoad(e,t).then(r=>{if(!r||this.fragContextChanged(e)||!this.levels)throw new Error("init load aborted");return r}).then(r=>{let{hls:s}=this,{payload:n}=r,a=e.decryptdata;if(n&&n.byteLength>0&&a!=null&&a.key&&a.iv&&a.method==="AES-128"){let o=self.performance.now();return this.decrypter.decrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer).catch(l=>{throw s.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:C.FRAG_DECRYPT_ERROR,fatal:!1,error:l,reason:l.message,frag:e}),l}).then(l=>{let d=self.performance.now();return s.trigger(v.FRAG_DECRYPTED,{frag:e,payload:l,stats:{tstart:o,tdecrypt:d}}),r.payload=l,this.completeInitSegmentLoad(r)})}return this.completeInitSegmentLoad(r)}).catch(r=>{this.state===N.STOPPED||this.state===N.ERROR||(this.warn(r),this.resetFragmentLoading(e))})}completeInitSegmentLoad(e){let{levels:t}=this;if(!t)throw new Error("init load aborted, missing levels");let r=e.frag.stats;this.state=N.IDLE,e.frag.data=new Uint8Array(e.payload),r.parsing.start=r.buffering.start=self.performance.now(),r.parsing.end=r.buffering.end=self.performance.now(),this.tick()}fragContextChanged(e){let{fragCurrent:t}=this;return!e||!t||e.sn!==t.sn||e.level!==t.level}fragBufferedComplete(e,t){var r,s,n,a;let o=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.playlistType===te.MAIN?"level":"track"} ${e.level} (frag:[${((r=e.startPTS)!=null?r:NaN).toFixed(3)}-${((s=e.endPTS)!=null?s:NaN).toFixed(3)}] > buffer:${o?OR.toString(Ue.getBuffered(o)):"(detached)"})`),e.sn!=="initSegment"){var l;if(e.type!==te.SUBTITLE){let u=e.elementaryStreams;if(!Object.keys(u).some(c=>!!u[c])){this.state=N.IDLE;return}}let d=(l=this.levels)==null?void 0:l[e.level];d!=null&&d.fragmentError&&(this.log(`Resetting level fragment error count of ${d.fragmentError} on frag buffered`),d.fragmentError=0)}this.state=N.IDLE,o&&(!this.loadedmetadata&&e.type==te.MAIN&&o.buffered.length&&((n=this.fragCurrent)==null?void 0:n.sn)===((a=this.fragPrevious)==null?void 0:a.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(e){let{transmuxer:t}=this;if(!t)return;let{frag:r,part:s,partsLoaded:n}=e,a=!n||n.length===0||n.some(l=>!l),o=new ho(r.level,r.sn,r.stats.chunkCount+1,0,s?s.index:-1,!a);t.flush(o)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,r=null,s){var n;let a=t==null?void 0:t.details;if(!this.levels||!a)throw new Error(`frag load aborted, missing level${a?"":" detail"}s`);let o=null;if(e.encrypted&&!((n=e.decryptdata)!=null&&n.key)?(this.log(`Loading key for ${e.sn} of [${a.startSN}-${a.endSN}], ${this.logPrefix==="[stream-controller]"?"level":"track"} ${e.level}`),this.state=N.KEY_LOADING,this.fragCurrent=e,o=this.keyLoader.load(e).then(u=>{if(!this.fragContextChanged(u.frag))return this.hls.trigger(v.KEY_LOADED,u),this.state===N.KEY_LOADING&&(this.state=N.IDLE),u}),this.hls.trigger(v.KEY_LOADING,{frag:e}),this.fragCurrent===null&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!e.encrypted&&a.encryptedFragments.length&&this.keyLoader.loadClear(e,a.encryptedFragments),r=Math.max(e.start,r||0),this.config.lowLatencyMode&&e.sn!=="initSegment"){let u=a.partList;if(u&&s){r>e.end&&a.fragmentHint&&(e=a.fragmentHint);let c=this.getNextPart(u,e,r);if(c>-1){let h=u[c];this.log(`Loading part sn: ${e.sn} p: ${h.index} cc: ${e.cc} of playlist [${a.startSN}-${a.endSN}] parts [0-${c}-${u.length-1}] ${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(r.toFixed(3))}`),this.nextLoadPosition=h.start+h.duration,this.state=N.FRAG_LOADING;let f;return o?f=o.then(m=>!m||this.fragContextChanged(m.frag)?null:this.doFragPartsLoad(e,h,t,s)).catch(m=>this.handleFragLoadError(m)):f=this.doFragPartsLoad(e,h,t,s).catch(m=>this.handleFragLoadError(m)),this.hls.trigger(v.FRAG_LOADING,{frag:e,part:h,targetBufferTime:r}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):f}else if(!e.url||this.loadedEndOfParts(u,r))return Promise.resolve(null)}}this.log(`Loading fragment ${e.sn} cc: ${e.cc} ${a?"of ["+a.startSN+"-"+a.endSN+"] ":""}${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(r.toFixed(3))}`),q(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=N.FRAG_LOADING;let l=this.config.progressive,d;return l&&o?d=o.then(u=>!u||this.fragContextChanged(u==null?void 0:u.frag)?null:this.fragmentLoader.load(e,s)).catch(u=>this.handleFragLoadError(u)):d=Promise.all([this.fragmentLoader.load(e,l?s:void 0),o]).then(([u])=>(!l&&u&&s&&s(u),u)).catch(u=>this.handleFragLoadError(u)),this.hls.trigger(v.FRAG_LOADING,{frag:e,targetBufferTime:r}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):d}doFragPartsLoad(e,t,r,s){return new Promise((n,a)=>{var o;let l=[],d=(o=r.details)==null?void 0:o.partList,u=c=>{this.fragmentLoader.loadPart(e,c,s).then(h=>{l[c.index]=h;let f=h.part;this.hls.trigger(v.FRAG_LOADED,h);let m=cT(r,e.sn,c.index+1)||s_(d,e.sn,c.index+1);if(m)u(m);else return n({frag:e,part:f,partsLoaded:l})}).catch(a)};u(t)})}handleFragLoadError(e){if("data"in e){let t=e.data;e.data&&t.details===C.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(v.ERROR,t)}else this.hls.trigger(v.ERROR,{type:ie.OTHER_ERROR,details:C.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){let t=this.getCurrentContext(e);if(!t||this.state!==N.PARSING){!this.fragCurrent&&this.state!==N.STOPPED&&this.state!==N.ERROR&&(this.state=N.IDLE);return}let{frag:r,part:s,level:n}=t,a=self.performance.now();r.stats.parsing.end=a,s&&(s.stats.parsing.end=a),this.updateLevelTiming(r,s,n,e.partial)}getCurrentContext(e){let{levels:t,fragCurrent:r}=this,{level:s,sn:n,part:a}=e;if(!(t!=null&&t[s]))return this.warn(`Levels object was unset while buffering fragment ${n} of level ${s}. The current chunk will not be buffered.`),null;let o=t[s],l=a>-1?cT(o,n,a):null,d=l?l.fragment:fR(o,n,r);return d?(r&&r!==d&&(d.stats=r.stats),{frag:d,part:l,level:o}):null}bufferFragmentData(e,t,r,s,n){var a;if(!e||this.state!==N.PARSING)return;let{data1:o,data2:l}=e,d=o;if(o&&l&&(d=Jt(o,l)),!((a=d)!=null&&a.length))return;let u={type:e.type,frag:t,part:r,chunkMeta:s,parent:t.type,data:d};if(this.hls.trigger(v.BUFFER_APPENDING,u),e.dropped&&e.independent&&!r){if(n)return;this.flushBufferGap(t)}}flushBufferGap(e){let t=this.media;if(!t)return;if(!Ue.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}let r=t.currentTime,s=Ue.bufferInfo(t,r,0),n=e.duration,a=Math.min(this.config.maxFragLookUpTolerance*2,n*.25),o=Math.max(Math.min(e.start-a,s.end-a),r+a);e.start-o>a&&this.flushMainBuffer(o,e.start)}getFwdBufferInfo(e,t){let r=this.getLoadPosition();return q(r)?this.getFwdBufferInfoAtPos(e,r,t):null}getFwdBufferInfoAtPos(e,t,r){let{config:{maxBufferHole:s}}=this,n=Ue.bufferInfo(e,t,s);if(n.len===0&&n.nextStart!==void 0){let a=this.fragmentTracker.getBufferedFrag(t,r);if(a&&n.nextStart<a.end)return Ue.bufferInfo(e,t,Math.max(n.nextStart,s))}return n}getMaxBufferLength(e){let{config:t}=this,r;return e?r=Math.max(8*t.maxBufferSize/e,t.maxBufferLength):r=t.maxBufferLength,Math.min(r,t.maxMaxBufferLength)}reduceMaxBufferLength(e){let t=this.config,r=e||t.maxBufferLength;return t.maxMaxBufferLength>=r?(t.maxMaxBufferLength/=2,this.warn(`Reduce max buffer length to ${t.maxMaxBufferLength}s`),!0):!1}getAppendedFrag(e,t=te.MAIN){let r=this.fragmentTracker.getAppendedFrag(e,te.MAIN);return r&&"fragment"in r?r.fragment:r}getNextFragment(e,t){let r=t.fragments,s=r.length;if(!s)return null;let{config:n}=this,a=r[0].start,o;if(t.live){let l=n.initialLiveManifestSize;if(s<l)return this.warn(`Not enough fragments to start playback (have: ${s}, need: ${l})`),null;(!t.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||e<a)&&(o=this.getInitialLiveFragment(t,r),this.startPosition=this.nextLoadPosition=o?this.hls.liveSyncPosition||o.start:e)}else e<=a&&(o=r[0]);if(!o){let l=n.lowLatencyMode?t.partEnd:t.fragmentEnd;o=this.getFragmentAtPosition(e,l,t)}return this.mapToInitFragWhenRequired(o)}isLoopLoading(e,t){let r=this.fragmentTracker.getState(e);return(r===ht.OK||r===ht.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,r,s,n){let a=e.gap,o=this.getNextFragment(this.nextLoadPosition,t);if(o===null)return o;if(e=o,a&&e&&!e.gap&&r.nextStart){let l=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,s);if(l!==null&&r.len+l.len>=n)return this.log(`buffer full after gaps in "${s}" playlist starting at sn: ${e.sn}`),null}return e}mapToInitFragWhenRequired(e){return e!=null&&e.initSegment&&!(e!=null&&e.initSegment.data)&&!this.bitrateTest?e.initSegment:e}getNextPart(e,t,r){let s=-1,n=!1,a=!0;for(let o=0,l=e.length;o<l;o++){let d=e[o];if(a=a&&!d.independent,s>-1&&r<d.start)break;let u=d.loaded;u?s=-1:(n||d.independent||a)&&d.fragment===t&&(s=o),n=u}return s}loadedEndOfParts(e,t){let r=e[e.length-1];return r&&t>r.start&&r.loaded}getInitialLiveFragment(e,t){let r=this.fragPrevious,s=null;if(r){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${r.programDateTime}`),s=pR(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!s){let n=r.sn+1;if(n>=e.startSN&&n<=e.endSN){let a=t[n-e.startSN];r.cc===a.cc&&(s=a,this.log(`Live playlist, switching playlist, load frag with next SN: ${s.sn}`))}s||(s=vR(t,r.cc),s&&this.log(`Live playlist, switching playlist, load frag with same CC: ${s.sn}`))}}else{let n=this.hls.liveSyncPosition;n!==null&&(s=this.getFragmentAtPosition(n,this.bitrateTest?e.fragmentEnd:e.edge,e))}return s}getFragmentAtPosition(e,t,r){let{config:s}=this,{fragPrevious:n}=this,{fragments:a,endSN:o}=r,{fragmentHint:l}=r,d=s.maxFragLookUpTolerance,u=r.partList,c=!!(s.lowLatencyMode&&u!=null&&u.length&&l);c&&l&&!this.bitrateTest&&(a=a.concat(l),o=l.sn);let h;if(e<t){let f=e>t-d?0:d;h=Zu(n,a,e,f)}else h=a[a.length-1];if(h){let f=h.sn-r.startSN,m=this.fragmentTracker.getState(h);if((m===ht.OK||m===ht.PARTIAL&&h.gap)&&(n=h),n&&h.sn===n.sn&&(!c||u[0].fragment.sn>h.sn)&&n&&h.level===n.level){let g=a[f+1];h.sn<o&&this.fragmentTracker.getState(g)!==ht.OK?h=g:h=null}}return h}synchronizeToLiveEdge(e){let{config:t,media:r}=this;if(!r)return;let s=this.hls.liveSyncPosition,n=r.currentTime,a=e.fragments[0].start,o=e.edge,l=n>=a-t.maxFragLookUpTolerance&&n<=o;if(s!==null&&r.duration>s&&(n<s||!l)){let d=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!l&&r.readyState<4||n<o-d)&&(this.loadedmetadata||(this.nextLoadPosition=s),r.readyState&&(this.warn(`Playback: ${n.toFixed(3)} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${s.toFixed(3)}`),r.currentTime=s))}}alignPlaylists(e,t,r){let s=e.fragments.length;if(!s)return this.warn("No fragments in live playlist"),0;let n=e.fragments[0].start,a=!t,o=e.alignedSliding&&q(n);if(a||!o&&!n){let{fragPrevious:l}=this;CR(l,r,e);let d=e.fragments[0].start;return this.log(`Live playlist sliding: ${d.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${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<t&&(r=-1),r===-1||this.lastCurrentTime===-1){let s=this.startTimeOffset!==null,n=s?this.startTimeOffset:e.startTimeOffset;n!==null&&q(n)?(r=t+n,n<0&&(r+=e.totalduration),r=Math.min(Math.max(t,r),t+e.totalduration),this.log(`Start time offset ${n} found in ${s?"multivariant":"media"} playlist, adjust startPosition to ${r}`),this.startPosition=r):e.live?r=this.hls.liveSyncPosition||t:this.startPosition=r=0,this.lastCurrentTime=r}this.nextLoadPosition=r}getLoadPosition(){let{media:e}=this,t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t}handleFragLoadAborted(e,t){this.transmuxer&&e.sn!=="initSegment"&&e.stats.aborted&&(this.warn(`Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){(!this.fragCurrent||!this.fragContextChanged(e)&&this.state!==N.FRAG_LOADING_WAITING_RETRY)&&(this.state=N.IDLE)}onFragmentOrKeyLoadError(e,t){if(t.chunkMeta&&!t.frag){let u=this.getCurrentContext(t.chunkMeta);u&&(t.frag=u.frag)}let r=t.frag;if(!r||r.type!==e||!this.levels)return;if(this.fragContextChanged(r)){var s;this.warn(`Frag load error must match current frag to retry ${r.url} > ${(s=this.fragCurrent)==null?void 0:s.url}`);return}let n=t.details===C.FRAG_GAP;n&&this.fragmentTracker.fragBuffered(r,!0);let a=t.errorAction,{action:o,retryCount:l=0,retryConfig:d}=a||{};if(a&&o===ct.RetryRequest&&d){this.resetStartWhenNotLoaded(this.levelLastLoaded);let u=Gg(d,l);this.warn(`Fragment ${r.sn} of ${e} ${r.level} errored with ${t.details}, retrying loading ${l+1}/${d.maxNumRetry} in ${u}ms`),a.resolved=!0,this.retryDate=self.performance.now()+u,this.state=N.FRAG_LOADING_WAITING_RETRY}else if(d&&a)if(this.resetFragmentErrors(e),l<d.maxNumRetry)!n&&o!==ct.RemoveAlternatePermanently&&(a.resolved=!0);else{I.warn(`${t.details} reached or exceeded max retry (${l})`);return}else(a==null?void 0:a.action)===ct.SendAlternateToPenaltyBox?this.state=N.WAITING_LEVEL:this.state=N.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(e){if(this.state===N.PARSING||this.state===N.PARSED){let t=e.parent,r=this.getFwdBufferInfo(this.mediaBuffer,t),s=r&&r.len>.5;s&&this.reduceMaxBufferLength(r.len);let n=!s;return n&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${t} buffer`),e.frag&&(this.fragmentTracker.removeFragment(e.frag),this.nextLoadPosition=e.frag.start),this.resetLoadingState(),n}return!1}resetFragmentErrors(e){e===te.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==N.STOPPED&&(this.state=N.IDLE)}afterBufferFlushed(e,t,r){if(!e)return;let s=Ue.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,s,r),this.state===N.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=N.IDLE}resetStartWhenNotLoaded(e){if(!this.loadedmetadata){this.startFragRequested=!1;let t=e?e.details:null;t!=null&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){this.warn(`The loading context changed while buffering fragment ${e.sn} of level ${e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,r,s){var n;let a=r.details;if(!a){this.warn("level.details undefined");return}if(!Object.keys(e.elementaryStreams).reduce((l,d)=>{let u=e.elementaryStreams[d];if(u){let c=u.endPTS-u.startPTS;if(c<=0)return this.warn(`Could not parse fragment ${e.sn} ${d} duration reliably (${c})`),l||!1;let h=s?0:i_(a,e,u.startPTS,u.endPTS,u.startDTS,u.endDTS);return this.hls.trigger(v.LEVEL_PTS_UPDATED,{details:a,level:r,drift:h,type:d,frag:e,start:u.startPTS,end:u.endPTS}),!0}return l},!1)&&((n=this.transmuxer)==null?void 0:n.error)===null){let l=new Error(`Found no media in fragment ${e.sn} of level ${e.level} resetting transmuxer to fallback to playlist timing`);if(r.fragmentError===0&&(r.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)),this.warn(l.message),this.hls.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:C.FRAG_PARSING_ERROR,fatal:!1,error:l,frag:e,reason:`Found no media in msn ${e.sn} of level "${r.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=N.PARSED,this.hls.trigger(v.FRAG_PARSED,{frag:e,part:t})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(e){e.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())}set state(e){let t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}},ec=class{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){let{chunks:e,dataLength:t}=this,r;if(e.length)e.length===1?r=e[0]:r=NR(e,t);else return new Uint8Array(0);return this.reset(),r}reset(){this.chunks.length=0,this.dataLength=0}};function NR(i,e){let t=new Uint8Array(e),r=0;for(let s=0;s<i.length;s++){let n=i[s];t.set(n,r),r+=n.length}return t}function UR(){return typeof __HLS_WORKER_BUNDLE__=="function"}function FR(){let i=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),e=self.URL.createObjectURL(i);return{worker:new self.Worker(e),objectURL:e}}function BR(i){let e=new self.URL(i,self.location.href).href;return{worker:new self.Worker(e),scriptURL:e}}function ji(i="",e=9e4){return{type:i,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}var po=class{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,t,r,s){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,r){}demux(e,t){this.cachedData&&(e=Jt(this.cachedData,e),this.cachedData=null);let r=oo(e,0),s=r?r.length:0,n,a=this._audioTrack,o=this._id3Track,l=r?Hg(r):void 0,d=e.length;for((this.basePTS===null||this.frameIndex===0&&q(l))&&(this.basePTS=$R(l,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),r&&r.length>0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:Ti.audioId3,duration:Number.POSITIVE_INFINITY});s<d;){if(this.canParse(e,s)){let u=this.appendFrame(a,e,s);u?(this.frameIndex++,this.lastPTS=u.sample.pts,s+=u.length,n=s):s=d}else TI(e,s)?(r=oo(e,s),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:Ti.audioId3,duration:Number.POSITIVE_INFINITY}),s+=r.length,n=s):s++;if(s===d&&n!==d){let u=Ls(e,n);this.cachedData?this.cachedData=Jt(this.cachedData,u):this.cachedData=u}}return{audioTrack:a,videoTrack:ji(),id3Track:o,textTrack:ji()}}demuxSampleAes(e,t,r){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){let t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:ji(),id3Track:this._id3Track,textTrack:ji()}}destroy(){}},$R=(i,e,t)=>{if(q(i))return i*90;let r=t?t.baseTime*9e4/t.timescale:0;return e*9e4+r};function HR(i,e,t,r){let s,n,a,o,l=navigator.userAgent.toLowerCase(),d=r,u=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];s=((e[t+2]&192)>>>6)+1;let c=(e[t+2]&60)>>>2;if(c>u.length-1){let h=new Error(`invalid ADTS sampling index:${c}`);i.emit(v.ERROR,v.ERROR,{type:ie.MEDIA_ERROR,details:C.FRAG_PARSING_ERROR,fatal:!0,error:h,reason:h.message});return}return a=(e[t+2]&1)<<2,a|=(e[t+3]&192)>>>6,I.log(`manifest codec:${r}, ADTS type:${s}, samplingIndex:${c}`),/firefox/i.test(l)?c>=6?(s=5,o=new Array(4),n=c-3):(s=2,o=new Array(2),n=c):l.indexOf("android")!==-1?(s=2,o=new Array(2),n=c):(s=5,o=new Array(4),r&&(r.indexOf("mp4a.40.29")!==-1||r.indexOf("mp4a.40.5")!==-1)||!r&&c>=6?n=c-3:((r&&r.indexOf("mp4a.40.2")!==-1&&(c>=6&&a===1||/vivaldi/i.test(l))||!r&&a===1)&&(s=2,o=new Array(2)),n=c)),o[0]=s<<3,o[0]|=(c&14)>>1,o[1]|=(c&1)<<7,o[1]|=a<<3,s===5&&(o[1]|=(n&14)>>1,o[2]=(n&1)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:u[c],channelCount:a,codec:"mp4a.40."+s,manifestCodec:d}}function d_(i,e){return i[e]===255&&(i[e+1]&246)===240}function u_(i,e){return i[e+1]&1?7:9}function Wg(i,e){return(i[e+3]&3)<<11|i[e+4]<<3|(i[e+5]&224)>>>5}function GR(i,e){return e+5<i.length}function tc(i,e){return e+1<i.length&&d_(i,e)}function WR(i,e){return GR(i,e)&&d_(i,e)&&Wg(i,e)<=i.length-e}function VR(i,e){if(tc(i,e)){let t=u_(i,e);if(e+t>=i.length)return!1;let r=Wg(i,e);if(r<=t)return!1;let s=e+r;return s===i.length||tc(i,s)}return!1}function c_(i,e,t,r,s){if(!i.samplerate){let n=HR(e,t,r,s);if(!n)return;i.config=n.config,i.samplerate=n.samplerate,i.channelCount=n.channelCount,i.codec=n.codec,i.manifestCodec=n.manifestCodec,I.log(`parsed codec:${i.codec}, rate:${n.samplerate}, channels:${n.channelCount}`)}}function h_(i){return 1024*9e4/i}function KR(i,e){let t=u_(i,e);if(e+t<=i.length){let r=Wg(i,e)-t;if(r>0)return{headerLength:t,frameLength:r}}}function f_(i,e,t,r,s){let n=h_(i.samplerate),a=r+s*n,o=KR(e,t),l;if(o){let{frameLength:c,headerLength:h}=o,f=h+c,m=Math.max(0,t+f-e.length);m?(l=new Uint8Array(f-h),l.set(e.subarray(t+h,e.length),0)):l=e.subarray(t+h,t+f);let p={unit:l,pts:a};return m||i.samples.push(p),{sample:p,length:f,missing:m}}let d=e.length-t;return l=new Uint8Array(d),l.set(e.subarray(t,e.length),0),{sample:{unit:l,pts:a},length:d,missing:-1}}var Cu=null,qR=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],YR=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],zR=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],jR=[0,1,1,4];function m_(i,e,t,r,s){if(t+24>e.length)return;let n=p_(e,t);if(n&&t+n.frameLength<=e.length){let a=n.samplesPerFrame*9e4/n.sampleRate,o=r+s*a,l={unit:e.subarray(t,t+n.frameLength),pts:o,dts:o};return i.config=[],i.channelCount=n.channelCount,i.samplerate=n.sampleRate,i.samples.push(l),{sample:l,length:n.frameLength,missing:0}}}function p_(i,e){let t=i[e+1]>>3&3,r=i[e+1]>>1&3,s=i[e+2]>>4&15,n=i[e+2]>>2&3;if(t!==1&&s!==0&&s!==15&&n!==3){let a=i[e+2]>>1&1,o=i[e+3]>>6,l=t===3?3-r:r===3?3:4,d=qR[l*14+s-1]*1e3,c=YR[(t===3?0:t===2?1:2)*3+n],h=o===3?1:2,f=zR[t][r],m=jR[r],p=f*8*m,g=Math.floor(f*d/c+a)*m;if(Cu===null){let y=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Cu=y?parseInt(y[1]):0}return!!Cu&&Cu<=87&&r===2&&d>=224e3&&o===0&&(i[e+3]=i[e+3]|128),{sampleRate:c,channelCount:h,frameLength:g,samplesPerFrame:p}}}function Vg(i,e){return i[e]===255&&(i[e+1]&224)===224&&(i[e+1]&6)!==0}function g_(i,e){return e+1<i.length&&Vg(i,e)}function XR(i,e){return Vg(i,e)&&4<=i.length-e}function v_(i,e){if(e+1<i.length&&Vg(i,e)){let r=p_(i,e),s=4;r!=null&&r.frameLength&&(s=r.frameLength);let n=e+s;return n===i.length||g_(i,n)}return!1}var Qp=class extends po{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,r,s){super.resetInitSegment(e,t,r,s),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;let t=oo(e,0),r=(t==null?void 0:t.length)||0;if(v_(e,r))return!1;for(let s=e.length;r<s;r++)if(VR(e,r))return I.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return WR(e,t)}appendFrame(e,t,r){c_(e,this.observer,t,r,e.manifestCodec);let s=f_(e,t,r,this.basePTS,this.frameIndex);if(s&&s.missing===0)return s}},QR=/\/emsg[-/]ID3/i,Zp=class{constructor(e,t){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=t}resetTimeStamp(){}resetInitSegment(e,t,r,s){let n=this.videoTrack=ji("video",1),a=this.audioTrack=ji("audio",1),o=this.txtTrack=ji("text",1);if(this.id3Track=ji("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;let l=zT(e);if(l.video){let{id:d,timescale:u,codec:c}=l.video;n.id=d,n.timescale=o.timescale=u,n.codec=c}if(l.audio){let{id:d,timescale:u,codec:c}=l.audio;a.id=d,a.timescale=u,a.codec=c}o.id=KT.text,n.sampleDuration=0,n.duration=a.duration=s}resetContiguity(){this.remainderData=null}static probe(e){return wI(e)}demux(e,t){this.timeOffset=t;let r=e,s=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=Jt(this.remainderData,e));let o=FI(r);this.remainderData=o.remainder,s.samples=o.valid||new Uint8Array}else s.samples=r;let a=this.extractID3Track(s,t);return n.samples=Yy(t,s),{videoTrack:s,audioTrack:this.audioTrack,id3Track:a,textTrack:this.txtTrack}}flush(){let e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;let s=this.extractID3Track(t,this.timeOffset);return r.samples=Yy(e,t),{videoTrack:t,audioTrack:ji(),id3Track:s,textTrack:ji()}}extractID3Track(e,t){let r=this.id3Track;if(e.samples.length){let s=ne(e.samples,["emsg"]);s&&s.forEach(n=>{let a=HI(n);if(QR.test(a.schemeIdUri)){let o=q(a.presentationTime)?a.presentationTime/a.timeScale:t+a.presentationTimeDelta/a.timeScale,l=a.eventDuration===4294967295?Number.POSITIVE_INFINITY:a.eventDuration/a.timeScale;l<=.001&&(l=Number.POSITIVE_INFINITY);let d=a.payload;r.samples.push({data:d,len:d.byteLength,dts:o,pts:o,type:Ti.emsg,duration:l})}})}return r}demuxSampleAes(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}},E_=(i,e)=>{let t=0,r=5;e+=r;let s=new Uint32Array(1),n=new Uint32Array(1),a=new Uint8Array(1);for(;r>0;){a[0]=i[e];let o=Math.min(r,8),l=8-o;n[0]=4278190080>>>24+l<<l,s[0]=(a[0]&n[0])>>l,t=t?t<<o|s[0]:s[0],e+=1,r-=o}return t},Jp=class extends po{constructor(e){super(),this.observer=void 0,this.observer=e}resetInitSegment(e,t,r,s){super.resetInitSegment(e,t,r,s),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}canParse(e,t){return t+64<e.length}appendFrame(e,t,r){let s=b_(e,t,r,this.basePTS,this.frameIndex);if(s!==-1)return{sample:e.samples[e.samples.length-1],length:s,missing:0}}static probe(e){if(!e)return!1;let t=oo(e,0);if(!t)return!1;let r=t.length;return e[r]===11&&e[r+1]===119&&Hg(t)!==void 0&&E_(e,r)<16}};function b_(i,e,t,r,s){if(t+8>e.length||e[t]!==11||e[t+1]!==119)return-1;let n=e[t+4]>>6;if(n>=3)return-1;let o=[48e3,44100,32e3][n],l=e[t+4]&63,u=[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][l*3+n]*2;if(t+u>e.length)return-1;let c=e[t+6]>>5,h=0;c===2?h+=2:(c&1&&c!==1&&(h+=2),c&4&&(h+=2));let f=(e[t+6]<<8|e[t+7])>>12-h&1,p=[2,1,2,3,3,4,4,5][c]+f,g=e[t+5]>>3,E=e[t+5]&7,T=new Uint8Array([n<<6|g<<1|E>>2,(E&3)<<6|c<<3|f<<2|l>>4,l<<4&224]),y=1536/o*9e4,S=r+s*y,_=e.subarray(t,t+u);return i.config=T,i.channelCount=p,i.samplerate=o,i.samples.push({unit:_,pts:S}),u}var eg=class{constructor(){this.VideoSample=null}createVideoSample(e,t,r,s){return{key:e,frame:!1,pts:t,dts:r,units:[],debug:s,length:0}}getLastNalUnit(e){var t;let r=this.VideoSample,s;if((!r||r.units.length===0)&&(r=e[e.length-1]),(t=r)!=null&&t.units){let n=r.units;s=n[n.length-1]}return s}pushAccessUnit(e,t){if(e.units.length&&e.frame){if(e.pts===void 0){let r=t.samples,s=r.length;if(s){let n=r[s-1];e.pts=n.pts,e.dts=n.dts}else{t.dropped++;return}}t.samples.push(e)}e.debug.length&&I.log(e.pts+"/"+e.dts+":"+e.debug)}},ic=class{constructor(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){let e=this.data,t=this.bytesAvailable,r=e.byteLength-t,s=new Uint8Array(4),n=Math.min(4,t);if(n===0)throw new Error("no bytes available");s.set(e.subarray(r,r+n)),this.word=new DataView(s.buffer).getUint32(0),this.bitsAvailable=n*8,this.bytesAvailable-=n}skipBits(e){let t;e=Math.min(e,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}readBits(e){let t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;if(e>32&&I.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return t=e-t,t>0&&this.bitsAvailable?r<<t|this.readBits(t):r}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if(this.word&2147483648>>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){let e=this.skipLZ();return this.readBits(e+1)-1}readEG(){let e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return this.readBits(1)===1}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(e){let t=8,r=8,s;for(let n=0;n<e;n++)r!==0&&(s=this.readEG(),r=(t+s+256)%256),t=r===0?t:r}readSPS(){let e=0,t=0,r=0,s=0,n,a,o,l=this.readUByte.bind(this),d=this.readBits.bind(this),u=this.readUEG.bind(this),c=this.readBoolean.bind(this),h=this.skipBits.bind(this),f=this.skipEG.bind(this),m=this.skipUEG.bind(this),p=this.skipScalingList.bind(this);l();let g=l();if(d(5),h(3),l(),m(),g===100||g===110||g===122||g===244||g===44||g===83||g===86||g===118||g===128){let L=u();if(L===3&&h(1),m(),m(),h(1),c())for(a=L!==3?8:12,o=0;o<a;o++)c()&&(o<6?p(16):p(64))}m();let E=u();if(E===0)u();else if(E===1)for(h(1),f(),f(),n=u(),o=0;o<n;o++)f();m(),h(1);let T=u(),y=u(),S=d(1);S===0&&h(1),h(1),c()&&(e=u(),t=u(),r=u(),s=u());let _=[1,1];if(c()&&c())switch(l()){case 1:_=[1,1];break;case 2:_=[12,11];break;case 3:_=[10,11];break;case 4:_=[16,11];break;case 5:_=[40,33];break;case 6:_=[24,11];break;case 7:_=[20,11];break;case 8:_=[32,11];break;case 9:_=[80,33];break;case 10:_=[18,11];break;case 11:_=[15,11];break;case 12:_=[64,33];break;case 13:_=[160,99];break;case 14:_=[4,3];break;case 15:_=[3,2];break;case 16:_=[2,1];break;case 255:{_=[l()<<8|l(),l()<<8|l()];break}}return{width:Math.ceil((T+1)*16-e*2-t*2),height:(2-S)*(y+1)*16-(S?2:4)*(r+s),pixelRatio:_}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}},tg=class extends eg{parseAVCPES(e,t,r,s,n){let a=this.parseAVCNALu(e,r.data),o=this.VideoSample,l,d=!1;r.data=null,o&&a.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts,"")),a.forEach(u=>{var c;switch(u.type){case 1:{let p=!1;l=!0;let g=u.data;if(d&&g.length>4){let E=new ic(g).readSliceType();(E===2||E===4||E===7||E===9)&&(p=!0)}if(p){var h;(h=o)!=null&&h.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null)}o||(o=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts,"")),o.frame=!0,o.key=p;break}case 5:l=!0,(c=o)!=null&&c.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null),o||(o=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts,"")),o.key=!0,o.frame=!0;break;case 6:{l=!0,XT(u.data,1,r.pts,t.samples);break}case 7:{var f,m;l=!0,d=!0;let p=u.data,E=new ic(p).readSPS();if(!e.sps||e.width!==E.width||e.height!==E.height||((f=e.pixelRatio)==null?void 0:f[0])!==E.pixelRatio[0]||((m=e.pixelRatio)==null?void 0:m[1])!==E.pixelRatio[1]){e.width=E.width,e.height=E.height,e.pixelRatio=E.pixelRatio,e.sps=[p],e.duration=n;let T=p.subarray(1,4),y="avc1.";for(let S=0;S<3;S++){let _=T[S].toString(16);_.length<2&&(_="0"+_),y+=_}e.codec=y}break}case 8:l=!0,e.pps=[u.data];break;case 9:l=!0,e.audFound=!0,o&&this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts,"");break;case 12:l=!0;break;default:l=!1,o&&(o.debug+="unknown NAL "+u.type+" ");break}o&&l&&o.units.push(u)}),s&&o&&(this.pushAccessUnit(o,e),this.VideoSample=null)}parseAVCNALu(e,t){let r=t.byteLength,s=e.naluState||0,n=s,a=[],o=0,l,d,u,c=-1,h=0;for(s===-1&&(c=0,h=t[0]&31,s=0,o=1);o<r;){if(l=t[o++],!s){s=l?0:1;continue}if(s===1){s=l?0:2;continue}if(!l)s=3;else if(l===1){if(d=o-s-1,c>=0){let f={data:t.subarray(c,d),type:h};a.push(f)}else{let f=this.getLastNalUnit(e.samples);f&&(n&&o<=4-n&&f.state&&(f.data=f.data.subarray(0,f.data.byteLength-n)),d>0&&(f.data=Jt(f.data,t.subarray(0,d)),f.state=0))}o<r?(u=t[o]&31,c=o,h=u,s=0):s=-1}else s=0}if(c>=0&&s>=0){let f={data:t.subarray(c,r),type:h,state:s};a.push(f)}if(a.length===0){let f=this.getLastNalUnit(e.samples);f&&(f.data=Jt(f.data,t))}return e.naluState=s,a}},ig=class{constructor(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new fo(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(e,t,r){let s=e[t].unit;if(s.length<=16)return;let n=s.subarray(16,s.length-s.length%16),a=n.buffer.slice(n.byteOffset,n.byteOffset+n.length);this.decryptBuffer(a).then(o=>{let l=new Uint8Array(o);s.set(l,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,r)})}decryptAacSamples(e,t,r){for(;;t++){if(t>=e.length){r();return}if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,r),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){let t=Math.floor((e.length-48)/160)*16+16,r=new Int8Array(t),s=0;for(let n=32;n<e.length-16;n+=160,s+=16)r.set(e.subarray(n,n+16),s);return r}getAvcDecryptedUnit(e,t){let r=new Uint8Array(t),s=0;for(let n=32;n<e.length-16;n+=160,s+=16)e.set(r.subarray(s,s+16),n);return e}decryptAvcSample(e,t,r,s,n){let a=QT(n.data),o=this.getAvcEncryptedData(a);this.decryptBuffer(o.buffer).then(l=>{n.data=this.getAvcDecryptedUnit(a,l),this.decrypter.isSync()||this.decryptAvcSamples(e,t,r+1,s)})}decryptAvcSamples(e,t,r,s){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length){s();return}let n=e[t].units;for(;!(r>=n.length);r++){let a=n[r];if(!(a.data.length<=48||a.type!==1&&a.type!==5)&&(this.decryptAvcSample(e,t,r,s,a),!this.decrypter.isSync()))return}}}},ut=188,rg=class i{constructor(e,t,r){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=e,this.config=t,this.typeSupported=r,this.videoParser=new tg}static probe(e){let t=i.syncOffset(e);return t>0&&I.warn(`MPEG2-TS detected but first sync word found @ offset ${t}`),t!==-1}static syncOffset(e){let t=e.length,r=Math.min(ut*5,t-ut)+1,s=0;for(;s<r;){let n=!1,a=-1,o=0;for(let l=s;l<t;l+=ut)if(e[l]===71&&(t-l===ut||e[l+ut]===71)){if(o++,a===-1&&(a=l,a!==0&&(r=Math.min(a+ut*99,e.length-ut)+1)),n||(n=sg(e,l)===0),n&&o>1&&(a===0&&o>2||l+ut>r))return a}else{if(o)return-1;break}s++}return-1}static createTrack(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:KT[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}}resetInitSegment(e,t,r,s){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=i.createTrack("video"),this._audioTrack=i.createTrack("audio",s),this._id3Track=i.createTrack("id3"),this._txtTrack=i.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=r,this._duration=s}resetTimeStamp(){}resetContiguity(){let{_audioTrack:e,_videoTrack:t,_id3Track:r}=this;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.remainderData=null}demux(e,t,r=!1,s=!1){r||(this.sampleAes=null);let n,a=this._videoTrack,o=this._audioTrack,l=this._id3Track,d=this._txtTrack,u=a.pid,c=a.pesData,h=o.pid,f=l.pid,m=o.pesData,p=l.pesData,g=null,E=this.pmtParsed,T=this._pmtId,y=e.length;if(this.remainderData&&(e=Jt(this.remainderData,e),y=e.length,this.remainderData=null),y<ut&&!s)return this.remainderData=e,{audioTrack:o,videoTrack:a,id3Track:l,textTrack:d};let S=Math.max(0,i.syncOffset(e));y-=(y-S)%ut,y<e.byteLength&&!s&&(this.remainderData=new Uint8Array(e.buffer,y,e.buffer.byteLength-y));let _=0;for(let x=S;x<y;x+=ut)if(e[x]===71){let w=!!(e[x+1]&64),M=sg(e,x),k=(e[x+3]&48)>>4,D;if(k>1){if(D=x+5+e[x+4],D===x+ut)continue}else D=x+4;switch(M){case u:w&&(c&&(n=Fn(c))&&this.videoParser.parseAVCPES(a,d,n,!1,this._duration),c={data:[],size:0}),c&&(c.data.push(e.subarray(D,x+ut)),c.size+=x+ut-D);break;case h:if(w){if(m&&(n=Fn(m)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,n);break;case"mp3":this.parseMPEGPES(o,n);break;case"ac3":this.parseAC3PES(o,n);break}m={data:[],size:0}}m&&(m.data.push(e.subarray(D,x+ut)),m.size+=x+ut-D);break;case f:w&&(p&&(n=Fn(p))&&this.parseID3PES(l,n),p={data:[],size:0}),p&&(p.data.push(e.subarray(D,x+ut)),p.size+=x+ut-D);break;case 0:w&&(D+=e[D]+1),T=this._pmtId=ZR(e,D);break;case T:{w&&(D+=e[D]+1);let U=JR(e,D,this.typeSupported,r);u=U.videoPid,u>0&&(a.pid=u,a.segmentCodec=U.segmentVideoCodec),h=U.audioPid,h>0&&(o.pid=h,o.segmentCodec=U.segmentAudioCodec),f=U.id3Pid,f>0&&(l.pid=f),g!==null&&!E&&(I.warn(`MPEG-TS PMT found at ${x} after unknown PID '${g}'. Backtracking to sync byte @${S} to parse all TS packets.`),g=null,x=S-188),E=this.pmtParsed=!0;break}case 17:case 8191:break;default:g=M;break}}else _++;if(_>0){let x=new Error(`Found ${_} TS packet/s that do not start with 0x47`);this.observer.emit(v.ERROR,v.ERROR,{type:ie.MEDIA_ERROR,details:C.FRAG_PARSING_ERROR,fatal:!1,error:x,reason:x.message})}a.pesData=c,o.pesData=m,l.pesData=p;let L={audioTrack:o,videoTrack:a,id3Track:l,textTrack:d};return s&&this.extractRemainingSamples(L),L}flush(){let{remainderData:e}=this;this.remainderData=null;let t;return e?t=this.demux(e,-1,!1,!0):t={videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t}extractRemainingSamples(e){let{audioTrack:t,videoTrack:r,id3Track:s,textTrack:n}=e,a=r.pesData,o=t.pesData,l=s.pesData,d;if(a&&(d=Fn(a))?(this.videoParser.parseAVCPES(r,n,d,!0,this._duration),r.pesData=null):r.pesData=a,o&&(d=Fn(o))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,d);break;case"mp3":this.parseMPEGPES(t,d);break;case"ac3":this.parseAC3PES(t,d);break}t.pesData=null}else o!=null&&o.size&&I.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=o;l&&(d=Fn(l))?(this.parseID3PES(s,d),s.pesData=null):s.pesData=l}demuxSampleAes(e,t,r){let s=this.demux(e,r,!0,!this.config.progressive),n=this.sampleAes=new ig(this.observer,this.config,t);return this.decrypt(s,n)}decrypt(e,t){return new Promise(r=>{let{audioTrack:s,videoTrack:n}=e;s.samples&&s.segmentCodec==="aac"?t.decryptAacSamples(s.samples,0,()=>{n.samples?t.decryptAvcSamples(n.samples,0,0,()=>{r(e)}):r(e)}):n.samples&&t.decryptAvcSamples(n.samples,0,0,()=>{r(e)})})}destroy(){this._duration=0}parseAACPES(e,t){let r=0,s=this.aacOverFlow,n=t.data;if(s){this.aacOverFlow=null;let c=s.missing,h=s.sample.unit.byteLength;if(c===-1)n=Jt(s.sample.unit,n);else{let f=h-c;s.sample.unit.set(n.subarray(0,c),f),e.samples.push(s.sample),r=s.missing}}let a,o;for(a=r,o=n.length;a<o-1&&!tc(n,a);a++);if(a!==r){let c,h=a<o-1;h?c=`AAC PES did not start with ADTS header,offset:${a}`:c="No ADTS header found in AAC PES";let f=new Error(c);if(I.warn(`parsing error: ${c}`),this.observer.emit(v.ERROR,v.ERROR,{type:ie.MEDIA_ERROR,details:C.FRAG_PARSING_ERROR,fatal:!1,levelRetry:h,error:f,reason:c}),!h)return}c_(e,this.observer,n,a,this.audioCodec);let l;if(t.pts!==void 0)l=t.pts;else if(s){let c=h_(e.samplerate);l=s.sample.pts+c}else{I.warn("[tsdemuxer]: AAC PES unknown PTS");return}let d=0,u;for(;a<o;)if(u=f_(e,n,a,l,d),a+=u.length,u.missing){this.aacOverFlow=u;break}else for(d++;a<o-1&&!tc(n,a);a++);}parseMPEGPES(e,t){let r=t.data,s=r.length,n=0,a=0,o=t.pts;if(o===void 0){I.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<s;)if(g_(r,a)){let l=m_(e,r,a,o,n);if(l)a+=l.length,n++;else break}else a++}parseAC3PES(e,t){{let r=t.data,s=t.pts;if(s===void 0){I.warn("[tsdemuxer]: AC3 PES unknown PTS");return}let n=r.length,a=0,o=0,l;for(;o<n&&(l=b_(e,r,o,s,a++))>0;)o+=l}}parseID3PES(e,t){if(t.pts===void 0){I.warn("[tsdemuxer]: ID3 PES unknown PTS");return}let r=Je({},t,{type:this._videoTrack?Ti.emsg:Ti.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}};function sg(i,e){return((i[e+1]&31)<<8)+i[e+2]}function ZR(i,e){return(i[e+10]&31)<<8|i[e+11]}function JR(i,e,t,r){let s={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},n=(i[e+1]&15)<<8|i[e+2],a=e+3+n-4,o=(i[e+10]&15)<<8|i[e+11];for(e+=12+o;e<a;){let l=sg(i,e),d=(i[e+3]&15)<<8|i[e+4];switch(i[e]){case 207:if(!r){bp("ADTS AAC");break}case 15:s.audioPid===-1&&(s.audioPid=l);break;case 21:s.id3Pid===-1&&(s.id3Pid=l);break;case 219:if(!r){bp("H.264");break}case 27:s.videoPid===-1&&(s.videoPid=l,s.segmentVideoCodec="avc");break;case 3:case 4:!t.mpeg&&!t.mp3?I.log("MPEG audio found, not supported in this browser"):s.audioPid===-1&&(s.audioPid=l,s.segmentAudioCodec="mp3");break;case 193:if(!r){bp("AC-3");break}case 129:t.ac3?s.audioPid===-1&&(s.audioPid=l,s.segmentAudioCodec="ac3"):I.log("AC-3 audio found, not supported in this browser");break;case 6:if(s.audioPid===-1&&d>0){let u=e+5,c=d;for(;c>2;){switch(i[u]){case 106:t.ac3!==!0?I.log("AC-3 audio found, not supported in this browser for now"):(s.audioPid=l,s.segmentAudioCodec="ac3");break}let f=i[u+1]+2;u+=f,c-=f}}break;case 194:case 135:I.warn("Unsupported EC-3 in M2TS found");break;case 36:I.warn("Unsupported HEVC in M2TS found");break}e+=d+5}return s}function bp(i){I.log(`${i} with AES-128-CBC encryption found in unencrypted stream`)}function Fn(i){let e=0,t,r,s,n,a,o=i.data;if(!i||i.size===0)return null;for(;o[0].length<19&&o.length>1;)o[0]=Jt(o[0],o[1]),o.splice(1,1);if(t=o[0],(t[0]<<16)+(t[1]<<8)+t[2]===1){if(r=(t[4]<<8)+t[5],r&&r>i.size-6)return null;let d=t[7];d&192&&(n=(t[9]&14)*536870912+(t[10]&255)*4194304+(t[11]&254)*16384+(t[12]&255)*128+(t[13]&254)/2,d&64?(a=(t[14]&14)*536870912+(t[15]&255)*4194304+(t[16]&254)*16384+(t[17]&255)*128+(t[18]&254)/2,n-a>60*9e4&&(I.warn(`${Math.round((n-a)/9e4)}s delta between PTS and DTS, align them`),n=a)):a=n),s=t[8];let u=s+9;if(i.size<=u)return null;i.size-=u;let c=new Uint8Array(i.size);for(let h=0,f=o.length;h<f;h++){t=o[h];let m=t.byteLength;if(u)if(u>m){u-=m;continue}else t=t.subarray(u),m-=u,u=0;c.set(t,e),e+=m}return r&&(r-=s+3),{data:c,pts:n,dts:a,len:r}}return null}var ng=class extends po{resetInitSegment(e,t,r,s){super.resetInitSegment(e,t,r,s),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;let t=oo(e,0),r=(t==null?void 0:t.length)||0;if(t&&e[r]===11&&e[r+1]===119&&Hg(t)!==void 0&&E_(e,r)<=16)return!1;for(let s=e.length;r<s;r++)if(v_(e,r))return I.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return XR(e,t)}appendFrame(e,t,r){if(this.basePTS!==null)return m_(e,t,r,this.basePTS,this.frameIndex)}},rc=class{static getSilentFrame(e,t){switch(e){case"mp4a.40.2":if(t===1)return new Uint8Array([0,200,0,128,35,128]);if(t===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(t===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(t===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(t===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(t===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(t===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}}},Cr=Math.pow(2,32)-1,rt=class i{static init(){i.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};let e;for(e in i.types)i.types.hasOwnProperty(e)&&(i.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);let t=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),r=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);i.HDLR_TYPES={video:t,audio:r};let s=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),n=new Uint8Array([0,0,0,0,0,0,0,0]);i.STTS=i.STSC=i.STCO=n,i.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),i.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),i.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),i.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);let a=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);i.FTYP=i.box(i.types.ftyp,a,l,a,o),i.DINF=i.box(i.types.dinf,i.box(i.types.dref,s))}static box(e,...t){let r=8,s=t.length,n=s;for(;s--;)r+=t[s].byteLength;let a=new Uint8Array(r);for(a[0]=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<n;s++)a.set(t[s],r),r+=t[s].byteLength;return a}static hdlr(e){return i.box(i.types.hdlr,i.HDLR_TYPES[e])}static mdat(e){return i.box(i.types.mdat,e)}static mdhd(e,t){t*=e;let r=Math.floor(t/(Cr+1)),s=Math.floor(t%(Cr+1));return i.box(i.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,r>>24,r>>16&255,r>>8&255,r&255,s>>24,s>>16&255,s>>8&255,s&255,85,196,0,0]))}static mdia(e){return i.box(i.types.mdia,i.mdhd(e.timescale,e.duration),i.hdlr(e.type),i.minf(e))}static mfhd(e){return i.box(i.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255]))}static minf(e){return e.type==="audio"?i.box(i.types.minf,i.box(i.types.smhd,i.SMHD),i.DINF,i.stbl(e)):i.box(i.types.minf,i.box(i.types.vmhd,i.VMHD),i.DINF,i.stbl(e))}static moof(e,t,r){return i.box(i.types.moof,i.mfhd(e),i.traf(r,t))}static moov(e){let t=e.length,r=[];for(;t--;)r[t]=i.trak(e[t]);return i.box.apply(null,[i.types.moov,i.mvhd(e[0].timescale,e[0].duration)].concat(r).concat(i.mvex(e)))}static mvex(e){let t=e.length,r=[];for(;t--;)r[t]=i.trex(e[t]);return i.box.apply(null,[i.types.mvex,...r])}static mvhd(e,t){t*=e;let r=Math.floor(t/(Cr+1)),s=Math.floor(t%(Cr+1)),n=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,r>>24,r>>16&255,r>>8&255,r&255,s>>24,s>>16&255,s>>8&255,s&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return i.box(i.types.mvhd,n)}static sdtp(e){let t=e.samples||[],r=new Uint8Array(4+t.length),s,n;for(s=0;s<t.length;s++)n=t[s].flags,r[s+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return i.box(i.types.sdtp,r)}static stbl(e){return i.box(i.types.stbl,i.stsd(e),i.box(i.types.stts,i.STTS),i.box(i.types.stsc,i.STSC),i.box(i.types.stsz,i.STSZ),i.box(i.types.stco,i.STCO))}static avc1(e){let t=[],r=[],s,n,a;for(s=0;s<e.sps.length;s++)n=e.sps[s],a=n.byteLength,t.push(a>>>8&255),t.push(a&255),t=t.concat(Array.prototype.slice.call(n));for(s=0;s<e.pps.length;s++)n=e.pps[s],a=n.byteLength,r.push(a>>>8&255),r.push(a&255),r=r.concat(Array.prototype.slice.call(n));let o=i.box(i.types.avcC,new Uint8Array([1,t[3],t[4],t[5],255,224|e.sps.length].concat(t).concat([e.pps.length]).concat(r))),l=e.width,d=e.height,u=e.pixelRatio[0],c=e.pixelRatio[1];return i.box(i.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,l&255,d>>8&255,d&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,i.box(i.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),i.box(i.types.pasp,new Uint8Array([u>>24,u>>16&255,u>>8&255,u&255,c>>24,c>>16&255,c>>8&255,c&255])))}static esds(e){let t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))}static audioStsd(e){let t=e.samplerate;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,t&255,0,0])}static mp4a(e){return i.box(i.types.mp4a,i.audioStsd(e),i.box(i.types.esds,i.esds(e)))}static mp3(e){return i.box(i.types[".mp3"],i.audioStsd(e))}static ac3(e){return i.box(i.types["ac-3"],i.audioStsd(e),i.box(i.types.dac3,e.config))}static stsd(e){return e.type==="audio"?e.segmentCodec==="mp3"&&e.codec==="mp3"?i.box(i.types.stsd,i.STSD,i.mp3(e)):e.segmentCodec==="ac3"?i.box(i.types.stsd,i.STSD,i.ac3(e)):i.box(i.types.stsd,i.STSD,i.mp4a(e)):i.box(i.types.stsd,i.STSD,i.avc1(e))}static tkhd(e){let t=e.id,r=e.duration*e.timescale,s=e.width,n=e.height,a=Math.floor(r/(Cr+1)),o=Math.floor(r%(Cr+1));return i.box(i.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,0,0,0,0,a>>24,a>>16&255,a>>8&255,a&255,o>>24,o>>16&255,o>>8&255,o&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,s>>8&255,s&255,0,0,n>>8&255,n&255,0,0]))}static traf(e,t){let r=i.sdtp(e),s=e.id,n=Math.floor(t/(Cr+1)),a=Math.floor(t%(Cr+1));return i.box(i.types.traf,i.box(i.types.tfhd,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,s&255])),i.box(i.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,n&255,a>>24,a>>16&255,a>>8&255,a&255])),i.trun(e,r.length+16+20+8+16+8+8),r)}static trak(e){return e.duration=e.duration||4294967295,i.box(i.types.trak,i.tkhd(e),i.mdia(e))}static trex(e){let t=e.id;return i.box(i.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){let r=e.samples||[],s=r.length,n=12+16*s,a=new Uint8Array(n),o,l,d,u,c,h;for(t+=8+n,a.set([e.type==="video"?1:0,0,15,1,s>>>24&255,s>>>16&255,s>>>8&255,s&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0),o=0;o<s;o++)l=r[o],d=l.duration,u=l.size,c=l.flags,h=l.cts,a.set([d>>>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 Jt(i.FTYP,t)}};rt.types=void 0;rt.HDLR_TYPES=void 0;rt.STTS=void 0;rt.STSC=void 0;rt.STCO=void 0;rt.STSZ=void 0;rt.VMHD=void 0;rt.SMHD=void 0;rt.STSD=void 0;rt.FTYP=void 0;rt.DINF=void 0;var y_=9e4;function Kg(i,e,t=1,r=!1){let s=i*e*t;return r?Math.round(s):s}function ew(i,e,t=1,r=!1){return Kg(i,e,1/t,r)}function ro(i,e=!1){return Kg(i,1e3,1/y_,e)}function tw(i,e=1){return Kg(i,y_,1/e)}var iw=10*1e3,yT=1024,rw=1152,sw=1536,Bn=null,yp=null,Vn=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,Bn===null){let a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Bn=a?parseInt(a[1]):0}if(yp===null){let n=navigator.userAgent.match(/Safari\/(\d+)/i);yp=n?parseInt(n[1]):0}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(e){I.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}resetNextTimestamp(){I.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){I.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,Zt(s,n.pts)):a>0?s:n.pts},e[0].pts);return t&&I.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,T=t.pid>-1,y=t.samples.length,S=e.samples.length>0,_=o&&y>0||y>1;if((!E||S)&&(!T||_)||this.ISGenerated||o){if(this.ISGenerated){var x,w,M,k;let X=this.videoTrackConfig;X&&(t.width!==X.width||t.height!==X.height||((x=t.pixelRatio)==null?void 0:x[0])!==((w=X.pixelRatio)==null?void 0:w[0])||((M=t.pixelRatio)==null?void 0:M[1])!==((k=X.pixelRatio)==null?void 0:k[1]))&&this.resetInitSegment()}else c=this.generateIS(e,t,n,a);let D=this.isVideoContiguous,U=-1,B;if(_&&(U=nw(t.samples),!D&&this.config.forceKeyFrameOnDiscontinuity))if(m=!0,U>0){I.warn(`[mp4-remuxer]: Dropped ${U} out of ${y} video samples due to a missing keyframe`);let X=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(U),t.dropped+=U,g+=(t.samples[0].pts-X)/t.inputTimeScale,B=g}else U===-1&&(I.warn(`[mp4-remuxer]: No keyframe found out of ${y} video samples`),m=!1);if(this.ISGenerated){if(S&&_){let X=this.getVideoStartPts(t.samples),V=(Zt(e.samples[0].pts,X)-X)/t.inputTimeScale;p+=Math.max(0,V),g+=Math.max(0,-V)}if(S){if(e.samplerate||(I.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),c=this.generateIS(e,t,n,a)),u=this.remuxAudio(e,p,this.isAudioContiguous,a,T||_||l===te.AUDIO?g:void 0),_){let X=u?u.endPTS-u.startPTS:0;t.inputTimeScale||(I.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),c=this.generateIS(e,t,n,a)),d=this.remuxVideo(t,g,D,X)}}else _&&(d=this.remuxVideo(t,g,D,0));d&&(d.firstKeyFrame=U,d.independent=U!==-1,d.firstKeyFramePTS=B)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(f=T_(r,n,this._initPTS,this._initDTS)),s.samples.length&&(h=__(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):rt.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:rt.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,Zt(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-Zt(a[0].dts,a[0].pts);Bn&&u!==null&&Math.abs(W-G-u)<15e3?r=!0:u=W-G}let T=d.baseTime*n/d.timescale;for(let W=0;W<l;W++){let G=a[W];G.pts=Zt(G.pts-T,u),G.dts=Zt(G.dts-T,u),G.dts<a[W>0?W-1:W].dts&&(E=!0)}E&&a.sort(function(W,G){let oe=W.dts-G.dts,Q=W.pts-G.pts;return oe||Q}),f=a[0].dts,m=a[a.length-1].dts;let y=m-f,S=y?Math.round(y/(l-1)):h||e.inputTimeScale/30;if(r){let W=f-u,G=W>S,oe=W<-1;if((G||oe)&&(G?I.warn(`AVC: ${ro(W,!0)} ms (${W}dts) hole between fragments detected at ${t.toFixed(3)}`):I.warn(`AVC: ${ro(-W,!0)} ms (${W}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!oe||u>=a[0].pts||Bn)){f=u;let Q=a[0].pts-W;if(G)a[0].dts=f,a[0].pts=Q;else for(let me=0;me<a.length&&!(a[me].dts>Q);me++)a[me].dts-=W,a[me].pts-=W;I.log(`Video: Initial PTS/DTS adjusted: ${ro(Q,!0)}/${ro(f,!0)}, delta: ${ro(W,!0)} ms`)}}f=Math.max(0,f);let _=0,L=0,x=f;for(let W=0;W<l;W++){let G=a[W],oe=G.units,Q=oe.length,me=0;for(let Pe=0;Pe<Q;Pe++)me+=oe[Pe].data.length;L+=me,_+=Q,G.length=me,G.dts<x?(G.dts=x,x+=S/4|0||1):x=G.dts,p=Math.min(G.pts,p),g=Math.max(G.pts,g)}m=a[l-1].dts;let w=L+4*_+8,M;try{M=new Uint8Array(w)}catch(W){this.observer.emit(v.ERROR,v.ERROR,{type:ie.MUX_ERROR,details:C.REMUX_ALLOC_ERROR,fatal:!1,error:W,bytes:w,reason:`fail allocating video mdat ${w}`});return}let k=new DataView(M.buffer);k.setUint32(0,w),M.set(rt.types.mdat,4);let D=!1,U=Number.POSITIVE_INFINITY,B=Number.POSITIVE_INFINITY,X=Number.NEGATIVE_INFINITY,z=Number.NEGATIVE_INFINITY;for(let W=0;W<l;W++){let G=a[W],oe=G.units,Q=0;for(let Be=0,Ke=oe.length;Be<Ke;Be++){let kt=oe[Be],vr=kt.data,tn=kt.data.byteLength;k.setUint32(c,tn),c+=4,M.set(vr,c),c+=tn,Q+=4+tn}let me;if(W<l-1)h=a[W+1].dts-G.dts,me=a[W+1].pts-G.pts;else{let Be=this.config,Ke=W>0?G.dts-a[W-1].dts:S;if(me=W>0?G.pts-a[W-1].pts:S,Be.stretchShortVideoTrack&&this.nextAudioPts!==null){let kt=Math.floor(Be.maxBufferHole*n),vr=(s?p+s*n:this.nextAudioPts)-G.pts;vr>kt?(h=vr-Ke,h<0?h=Ke:D=!0,I.log(`[mp4-remuxer]: It is approximately ${vr/90} ms to the next segment; using duration ${h/90} ms for the last video frame.`)):h=Ke}else h=Ke}let Pe=Math.round(G.pts-G.dts);U=Math.min(U,h),X=Math.max(X,h),B=Math.min(B,me),z=Math.max(z,me),o.push(new sc(G.key,h,Q,Pe))}if(o.length){if(Bn){if(Bn<70){let W=o[0].flags;W.dependsOn=2,W.isNonSync=0}}else if(yp&&z-B<X-U&&S/X<.025&&o[0].cts===0){I.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let W=f;for(let G=0,oe=o.length;G<oe;G++){let Q=W+o[G].duration,me=W+o[G].cts;if(G<oe-1){let Pe=Q+o[G+1].cts;o[G].duration=Pe-me}else o[G].duration=G?o[G-1].duration:S;o[G].cts=0,W=Q}}}h=D||!h?S:h,this.nextAvcDts=u=m+h,this.videoSampleDuration=h,this.isVideoContiguous=!0;let V=rt.moof(e.sequenceNumber++,f,Je({},e,{samples:o})),se="video",ae={data1:V,data2:M,startPTS:p/n,endPTS:(g+h)/n,startDTS:f/n,endDTS:u/n,type:se,hasAudio:!1,hasVideo:!0,nb:o.length,dropped:e.dropped};return e.samples=[],e.dropped=0,ae}getSamplesPerFrame(e){switch(e.segmentCodec){case"mp3":return rw;case"ac3":return sw;default:return yT}}remuxAudio(e,t,r,s,n){let a=e.inputTimeScale,o=e.samplerate?e.samplerate:a,l=a/o,d=this.getSamplesPerFrame(e),u=d*l,c=this._initPTS,h=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,f=[],m=n!==void 0,p=e.samples,g=h?0:8,E=this.nextAudioPts||-1,T=t*a,y=c.baseTime*a/c.timescale;if(this.isAudioContiguous=r=r||p.length&&E>0&&(s&&Math.abs(T-E)<9e3||Math.abs(Zt(p[0].pts-y,T)-E)<20*u),p.forEach(function(V){V.pts=Zt(V.pts-y,T)}),!r||E<0){if(p=p.filter(V=>V.pts>=0),!p.length)return;n===0?E=0:s&&!m?E=Math.max(0,T):E=p[0].pts}if(e.segmentCodec==="aac"){let V=this.config.maxAudioFramesDrift;for(let se=0,ae=E;se<p.length;se++){let W=p[se],G=W.pts,oe=G-ae,Q=Math.abs(1e3*oe/a);if(oe<=-V*u&&m)se===0&&(I.warn(`Audio frame @ ${(G/a).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*oe/a)} ms.`),this.nextAudioPts=E=ae=G);else if(oe>=V*u&&Q<iw&&m){let me=Math.round(oe/u);ae=G-me*u,ae<0&&(me--,ae+=u),se===0&&(this.nextAudioPts=E=ae),I.warn(`[mp4-remuxer]: Injecting ${me} audio frame @ ${(ae/a).toFixed(3)}s due to ${Math.round(1e3*oe/a)} ms gap.`);for(let Pe=0;Pe<me;Pe++){let Be=Math.max(ae,0),Ke=rc.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);Ke||(I.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Ke=W.unit.subarray()),p.splice(se,0,{unit:Ke,pts:Be}),ae+=u,se++}}W.pts=ae,ae+=u}}let S=null,_=null,L,x=0,w=p.length;for(;w--;)x+=p[w].unit.byteLength;for(let V=0,se=p.length;V<se;V++){let ae=p[V],W=ae.unit,G=ae.pts;if(_!==null){let Q=f[V-1];Q.duration=Math.round((G-_)/l)}else if(r&&e.segmentCodec==="aac"&&(G=E),S=G,x>0){x+=g;try{L=new Uint8Array(x)}catch(Q){this.observer.emit(v.ERROR,v.ERROR,{type:ie.MUX_ERROR,details:C.REMUX_ALLOC_ERROR,fatal:!1,error:Q,bytes:x,reason:`fail allocating audio mdat ${x}`});return}h||(new DataView(L.buffer).setUint32(0,x),L.set(rt.types.mdat,4))}else return;L.set(W,g);let oe=W.byteLength;g+=oe,f.push(new sc(!0,d,oe,0)),_=G}let M=f.length;if(!M)return;let k=f[f.length-1];this.nextAudioPts=E=_+l*k.duration;let D=h?new Uint8Array(0):rt.moof(e.sequenceNumber++,S/l,Je({},e,{samples:f}));e.samples=[];let U=S/a,B=E/a,z={data1:D,data2:L,startPTS:U,endPTS:B,startDTS:U,endDTS:B,type:"audio",hasAudio:!0,hasVideo:!1,nb:M};return this.isAudioContiguous=!0,z}remuxEmptyAudio(e,t,r,s){let n=e.inputTimeScale,a=e.samplerate?e.samplerate:n,o=n/a,l=this.nextAudioPts,d=this._initDTS,u=d.baseTime*9e4/d.timescale,c=(l!==null?l:s.startDTS*n)+u,h=s.endDTS*n+u,f=o*yT,m=Math.ceil((h-c)/f),p=rc.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(I.warn("[mp4-remuxer]: remux empty Audio"),!p){I.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}let g=[];for(let E=0;E<m;E++){let T=c+E*f;g.push({unit:p,pts:T,dts:T})}return e.samples=g,this.remuxAudio(e,t,r,!1)}};function Zt(i,e){let t;if(e===null)return i;for(e<i?t=-8589934592:t=8589934592;Math.abs(i-e)>4294967296;)i+=t;return i}function nw(i){for(let e=0;e<i.length;e++)if(i[e].key)return e;return-1}function T_(i,e,t,r){let s=i.samples.length;if(!s)return;let n=i.inputTimeScale;for(let o=0;o<s;o++){let l=i.samples[o];l.pts=Zt(l.pts-t.baseTime*n/t.timescale,e*n)/n,l.dts=Zt(l.dts-r.baseTime*n/r.timescale,e*n)/n}let a=i.samples;return i.samples=[],{samples:a}}function __(i,e,t){let r=i.samples.length;if(!r)return;let s=i.inputTimeScale;for(let a=0;a<r;a++){let o=i.samples[a];o.pts=Zt(o.pts-t.baseTime*s/t.timescale,e*s)/s}i.samples.sort((a,o)=>a.pts-o.pts);let n=i.samples;return i.samples=[],{samples:n}}var sc=class{constructor(e,t,r,s){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=r,this.cts=s,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:e?0:1}}},ag=class{constructor(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}destroy(){}resetTimeStamp(e){this.initPTS=e,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(e,t,r,s){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(MI(e,s)),this.emitInitSegment=!0}generateInitSegment(e){let{audioCodec:t,videoCodec:r}=this;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}let s=this.initData=zT(e);s.audio&&(t=TT(s.audio,ke.AUDIO)),s.video&&(r=TT(s.video,ke.VIDEO));let n={};s.audio&&s.video?n.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:s.audio?n.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:s.video?n.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:I.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n}remux(e,t,r,s,n,a){var o,l;let{initPTS:d,lastEndTime:u}=this,c={audio:void 0,video:void 0,text:s,id3:r,initSegment:void 0};q(u)||(u=this.lastEndTime=n||0);let h=t.samples;if(!(h!=null&&h.length))return c;let f={initPTS:void 0,timescale:1},m=this.initData;if((o=m)!=null&&o.length||(this.generateInitSegment(h),m=this.initData),!((l=m)!=null&&l.length))return I.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),c;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1);let p=OI(h,m),g=PI(m,h),E=g===null?n:g;(aw(d,E,n,p)||f.timescale!==d.timescale&&a)&&(f.initPTS=E-n,d&&d.timescale===1&&I.warn(`Adjusting initPTS by ${f.initPTS-d.baseTime}`),this.initPTS=d={baseTime:f.initPTS,timescale:1});let T=e?E-d.baseTime/d.timescale:u,y=T+p;UI(m,h,d.baseTime/d.timescale),p>0?this.lastEndTime=y:(I.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());let S=!!m.audio,_=!!m.video,L="";S&&(L+="audio"),_&&(L+="video");let x={data1:h,startPTS:T,startDTS:T,endPTS:y,endDTS:y,type:L,hasAudio:S,hasVideo:_,nb:1,dropped:0};return c.audio=x.type==="audio"?x:void 0,c.video=x.type!=="audio"?x:void 0,c.initSegment=f,c.id3=T_(r,n,d,d),s.samples.length&&(c.text=__(s,n,d)),c}};function aw(i,e,t,r){if(i===null)return!0;let s=Math.max(r,1),n=e-i.baseTime/i.timescale;return Math.abs(n-t)>s}function TT(i,e){let t=i==null?void 0:i.codec;if(t&&t.length>4)return t;if(e===ke.AUDIO){if(t==="ec-3"||t==="ac-3"||t==="alac")return t;if(t==="fLaC"||t==="Opus")return Yu(t,!1);let r="mp4a.40.5";return I.info(`Parsed audio codec "${t}" or audio object type not handled. Using "${r}"`),r}return I.warn(`Unhandled video codec "${t}"`),t==="hvc1"||t==="hev1"?"hvc1.1.6.L120.90":t==="av01"?"av01.0.04M.08":"avc1.42e01e"}var cr;try{cr=self.performance.now.bind(self.performance)}catch{I.debug("Unable to use Performance API on this environment"),cr=qn==null?void 0:qn.Date.now}var Fu=[{demux:Zp,remux:ag},{demux:rg,remux:Vn},{demux:Qp,remux:Vn},{demux:ng,remux:Vn}];Fu.splice(2,0,{demux:Jp,remux:Vn});var nc=class{constructor(e,t,r,s,n){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=r,this.vendor=s,this.id=n}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,r,s){let n=r.transmuxing;n.executeStart=cr();let a=new Uint8Array(e),{currentTransmuxState:o,transmuxConfig:l}=this;s&&(this.currentTransmuxState=s);let{contiguous:d,discontinuity:u,trackSwitch:c,accurateTimeOffset:h,timeOffset:f,initSegmentChange:m}=s||o,{audioCodec:p,videoCodec:g,defaultInitPts:E,duration:T,initSegmentData:y}=l,S=ow(a,t);if(S&&S.method==="AES-128"){let w=this.getDecrypter();if(w.isSync()){let M=w.softwareDecrypt(a,S.key.buffer,S.iv.buffer);if(r.part>-1&&(M=w.flush()),!M)return n.executeEnd=cr(),Tp(r);a=new Uint8Array(M)}else return this.decryptionPromise=w.webCryptoDecrypt(a,S.key.buffer,S.iv.buffer).then(M=>{let k=this.push(M,null,r);return this.decryptionPromise=null,k}),this.decryptionPromise}let _=this.needsProbing(u,c);if(_){let w=this.configureTransmuxer(a);if(w)return I.warn(`[transmuxer] ${w.message}`),this.observer.emit(v.ERROR,v.ERROR,{type:ie.MEDIA_ERROR,details:C.FRAG_PARSING_ERROR,fatal:!1,error:w,reason:w.message}),n.executeEnd=cr(),Tp(r)}(u||c||m||_)&&this.resetInitSegment(y,p,g,T,t),(u||m||_)&&this.resetInitialTimestamp(E),d||this.resetContiguity();let L=this.transmux(a,S,f,h,r),x=this.currentTransmuxState;return x.contiguous=!0,x.discontinuity=!1,x.trackSwitch=!1,n.executeEnd=cr(),L}flush(e){let t=e.transmuxing;t.executeStart=cr();let{decrypter:r,currentTransmuxState:s,decryptionPromise:n}=this;if(n)return n.then(()=>this.flush(e));let a=[],{timeOffset:o}=s;if(r){let c=r.flush();c&&a.push(this.push(c,null,e))}let{demuxer:l,remuxer:d}=this;if(!l||!d)return t.executeEnd=cr(),[Tp(e)];let u=l.flush(o);return Bu(u)?u.then(c=>(this.flushRemux(a,c,e),a)):(this.flushRemux(a,u,e),a)}flushRemux(e,t,r){let{audioTrack:s,videoTrack:n,id3Track:a,textTrack:o}=t,{accurateTimeOffset:l,timeOffset:d}=this.currentTransmuxState;I.log(`[transmuxer.ts]: Flushed fragment ${r.sn}${r.part>-1?" p: "+r.part:""} of level ${r.level}`);let u=this.remuxer.remux(s,n,a,o,d,l,!0,this.id);e.push({remuxResult:u,chunkMeta:r}),r.transmuxing.executeEnd=cr()}resetInitialTimestamp(e){let{demuxer:t,remuxer:r}=this;!t||!r||(t.resetTimeStamp(e),r.resetTimeStamp(e))}resetContiguity(){let{demuxer:e,remuxer:t}=this;!e||!t||(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,r,s,n){let{demuxer:a,remuxer:o}=this;!a||!o||(a.resetInitSegment(e,t,r,s),o.resetInitSegment(e,t,r,n))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,r,s,n){let a;return t&&t.method==="SAMPLE-AES"?a=this.transmuxSampleAes(e,t,r,s,n):a=this.transmuxUnencrypted(e,r,s,n),a}transmuxUnencrypted(e,t,r,s){let{audioTrack:n,videoTrack:a,id3Track:o,textTrack:l}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(n,a,o,l,t,r,!1,this.id),chunkMeta:s}}transmuxSampleAes(e,t,r,s,n){return this.demuxer.demuxSampleAes(e,t,r).then(a=>({remuxResult:this.remuxer.remux(a.audioTrack,a.videoTrack,a.id3Track,a.textTrack,r,s,!1,this.id),chunkMeta:n}))}configureTransmuxer(e){let{config:t,observer:r,typeSupported:s,vendor:n}=this,a;for(let h=0,f=Fu.length;h<f;h++){var o;if((o=Fu[h].demux)!=null&&o.probe(e)){a=Fu[h];break}}if(!a)return new Error("Failed to find demuxer by probing fragment data");let l=this.demuxer,d=this.remuxer,u=a.remux,c=a.demux;(!d||!(d instanceof u))&&(this.remuxer=new u(r,t,s,n)),(!l||!(l instanceof c))&&(this.demuxer=new c(r,t,s),this.probe=c.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new fo(this.config)),e}};function ow(i,e){let t=null;return i.byteLength>0&&(e==null?void 0:e.key)!=null&&e.iv!==null&&e.method!=null&&(t=e),t}var Tp=i=>({remuxResult:{},chunkMeta:i});function Bu(i){return"then"in i&&i.then instanceof Function}var og=class{constructor(e,t,r,s,n){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=r,this.duration=s,this.defaultInitPts=n||null}},lg=class{constructor(e,t,r,s,n,a){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=r,this.trackSwitch=s,this.timeOffset=n,this.initSegmentChange=a}},A_={exports:{}};(function(i){var e=Object.prototype.hasOwnProperty,t="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(t=!1));function s(l,d,u){this.fn=l,this.context=d,this.once=u||!1}function n(l,d,u,c,h){if(typeof u!="function")throw new TypeError("The listener must be a function");var f=new s(u,c||l,h),m=t?t+d:d;return l._events[m]?l._events[m].fn?l._events[m]=[l._events[m],f]:l._events[m].push(f):(l._events[m]=f,l._eventsCount++),l}function a(l,d){--l._eventsCount===0?l._events=new r:delete l._events[d]}function o(){this._events=new r,this._eventsCount=0}o.prototype.eventNames=function(){var d=[],u,c;if(this._eventsCount===0)return d;for(c in u=this._events)e.call(u,c)&&d.push(t?c.slice(1):c);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(u)):d},o.prototype.listeners=function(d){var u=t?t+d:d,c=this._events[u];if(!c)return[];if(c.fn)return[c.fn];for(var h=0,f=c.length,m=new Array(f);h<f;h++)m[h]=c[h].fn;return m},o.prototype.listenerCount=function(d){var u=t?t+d:d,c=this._events[u];return c?c.fn?1:c.length:0},o.prototype.emit=function(d,u,c,h,f,m){var p=t?t+d:d;if(!this._events[p])return!1;var g=this._events[p],E=arguments.length,T,y;if(g.fn){switch(g.once&&this.removeListener(d,g.fn,void 0,!0),E){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,u),!0;case 3:return g.fn.call(g.context,u,c),!0;case 4:return g.fn.call(g.context,u,c,h),!0;case 5:return g.fn.call(g.context,u,c,h,f),!0;case 6:return g.fn.call(g.context,u,c,h,f,m),!0}for(y=1,T=new Array(E-1);y<E;y++)T[y-1]=arguments[y];g.fn.apply(g.context,T)}else{var S=g.length,_;for(y=0;y<S;y++)switch(g[y].once&&this.removeListener(d,g[y].fn,void 0,!0),E){case 1:g[y].fn.call(g[y].context);break;case 2:g[y].fn.call(g[y].context,u);break;case 3:g[y].fn.call(g[y].context,u,c);break;case 4:g[y].fn.call(g[y].context,u,c,h);break;default:if(!T)for(_=1,T=new Array(E-1);_<E;_++)T[_-1]=arguments[_];g[y].fn.apply(g[y].context,T)}}return!0},o.prototype.on=function(d,u,c){return n(this,d,u,c,!1)},o.prototype.once=function(d,u,c){return n(this,d,u,c,!0)},o.prototype.removeListener=function(d,u,c,h){var f=t?t+d:d;if(!this._events[f])return this;if(!u)return a(this,f),this;var m=this._events[f];if(m.fn)m.fn===u&&(!h||m.once)&&(!c||m.context===c)&&a(this,f);else{for(var p=0,g=[],E=m.length;p<E;p++)(m[p].fn!==u||h&&!m[p].once||c&&m[p].context!==c)&&g.push(m[p]);g.length?this._events[f]=g.length===1?g[0]:g:a(this,f)}return this},o.prototype.removeAllListeners=function(d){var u;return d?(u=t?t+d:d,this._events[u]&&a(this,u)):(this._events=new r,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=t,o.EventEmitter=o,i.exports=o})(A_);var lw=A_.exports,qg=iI(lw),ac=class{constructor(e,t,r,s){this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;let n=e.config;this.hls=e,this.id=t,this.useWorker=!!n.enableWorker,this.onTransmuxComplete=r,this.onFlush=s;let a=(u,c)=>{c=c||{},c.frag=this.frag,c.id=this.id,u===v.ERROR&&(this.error=c.error),this.hls.trigger(u,c)};this.observer=new qg,this.observer.on(v.FRAG_DECRYPTED,a),this.observer.on(v.ERROR,a);let o=ks(n.preferManagedMediaSource)||{isTypeSupported:()=>!1},l={mpeg:o.isTypeSupported("audio/mpeg"),mp3:o.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:o.isTypeSupported('audio/mp4; codecs="ac-3"')},d=navigator.vendor;if(this.useWorker&&typeof Worker!="undefined"&&(n.workerPath||UR())){try{n.workerPath?(I.log(`loading Web Worker ${n.workerPath} for "${t}"`),this.workerContext=BR(n.workerPath)):(I.log(`injecting Web Worker for "${t}"`),this.workerContext=FR()),this.onwmsg=h=>this.onWorkerMessage(h);let{worker:c}=this.workerContext;c.addEventListener("message",this.onwmsg),c.onerror=h=>{let f=new Error(`${h.message} (${h.filename}:${h.lineno})`);n.enableWorker=!1,I.warn(`Error in "${t}" Web Worker, fallback to inline`),this.hls.trigger(v.ERROR,{type:ie.OTHER_ERROR,details:C.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:f})},c.postMessage({cmd:"init",typeSupported:l,vendor:d,id:t,config:JSON.stringify(n)})}catch(c){I.warn(`Error setting up "${t}" Web Worker, fallback to inline`,c),this.resetWorker(),this.error=null,this.transmuxer=new nc(this.observer,l,n,d,t)}return}this.transmuxer=new nc(this.observer,l,n,d,t)}resetWorker(){if(this.workerContext){let{worker:e,objectURL:t}=this.workerContext;t&&self.URL.revokeObjectURL(t),e.removeEventListener("message",this.onwmsg),e.onerror=null,e.terminate(),this.workerContext=null}}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{let t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}let e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(e,t,r,s,n,a,o,l,d,u){var c,h;d.transmuxing.start=self.performance.now();let{transmuxer:f}=this,m=a?a.start:n.start,p=n.decryptdata,g=this.frag,E=!(g&&n.cc===g.cc),T=!(g&&d.level===g.level),y=g?d.sn-g.sn:-1,S=this.part?d.part-this.part.index:-1,_=y===0&&d.id>1&&d.id===(g==null?void 0:g.stats.chunkCount),L=!T&&(y===1||y===0&&(S===1||_&&S<=0)),x=self.performance.now();(T||y||n.stats.parsing.start===0)&&(n.stats.parsing.start=x),a&&(S||!L)&&(a.stats.parsing.start=x);let w=!(g&&((c=n.initSegment)==null?void 0:c.url)===((h=g.initSegment)==null?void 0:h.url)),M=new lg(E,L,l,T,m,w);if(!L||E||w){I.log(`[transmuxer-interface, ${n.type}]: Starting new transmux session for sn: ${d.sn} p: ${d.part} level: ${d.level} id: ${d.id}
1585
+ Switching to level ${D} @ ${U|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&&(I.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 Yp(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 C.BUFFER_ADD_CODEC_ERROR:case C.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case C.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===J.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!==J.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 I.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,I.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(I.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 T=m[c],y=!!(T!=null&&(l=T.details)!=null&&l.live),S=g===-1||u===-1,A,L="SDR",x=(T==null?void 0:T.frameRate)||0,{audioPreference:w,videoPreference:P}=E,k=this.audioTracksByGroup||(this.audioTracksByGroup=AR(p));if(S){if(this.firstSelection!==-1)return this.firstSelection;let j=this.codecTiers||(this.codecTiers=SR(m,k,t,r)),K=_R(j,L,e,w,P),{codecSet:se,videoRanges:oe,minFramerate:W,minBitrate:G,preferHDR:ne}=K;A=se,L=ne?oe[oe.length-1]:oe[0],x=W,e=Math.max(e,G),I.log(`[abr] picked start tier ${JSON.stringify(K)}`)}else A=T==null?void 0:T.codecSet,L=T==null?void 0:T.videoRange;let D=f?f.duration:h?h.duration:0,U=this.bwEstimator.getEstimateTTFB()/1e3,F=[];for(let j=r;j>=t;j--){var z;let K=m[j],se=j>c;if(!K)continue;if(E.useMediaCapabilities&&!K.supportedResult&&!K.supportedPromise){let Pe=navigator.mediaCapabilities;typeof(Pe==null?void 0:Pe.decodingInfo)=="function"&&vR(K,k,L,x,e,w)?(K.supportedPromise=ER(K,k,Pe),K.supportedPromise.then($e=>{if(!this.hls)return;K.supportedResult=$e;let qe=this.hls.levels,kt=qe.indexOf(K);$e.error?I.warn(`[abr] MediaCapabilities decodingInfo error: "${$e.error}" for level ${kt} ${JSON.stringify($e)}`):$e.supported||(I.warn(`[abr] Unsupported MediaCapabilities decodingInfo result for level ${kt} ${JSON.stringify($e)}`),kt>-1&&qe.length>1&&(I.log(`[abr] Removing unsupported level ${kt}`),this.hls.removeLevel(kt)))})):K.supportedResult=a_}if(A&&K.codecSet!==A||L&&K.videoRange!==L||se&&x>K.frameRate||!se&&x>0&&x<K.frameRate||K.supportedResult&&!((z=K.supportedResult.decodingInfoResults)!=null&&z[0].smooth)){F.push(j);continue}let oe=K.details,W=(f?oe==null?void 0:oe.partTarget:oe==null?void 0:oe.averagetargetduration)||D,G;se?G=o*e:G=a*e;let ne=D&&s>=D*2&&n===0?m[j].averageBitrate:m[j].maxBitrate,Q=this.getTimeToLoadFrag(U,G,ne*W,oe===void 0);if(G>=ne&&(j===u||K.loadError===0&&K.fragmentError===0)&&(Q<=U||!q(Q)||y&&!this.bitrateTestDelay||Q<d)){let Pe=this.forcedAutoLevel;return j!==g&&(Pe===-1||Pe!==g)&&(F.length&&I.trace(`[abr] Skipped level(s) ${F.join(",")} of ${r} max with CODECS and VIDEO-RANGE:"${m[F[0]].codecs}" ${m[F[0]].videoRange}; not compatible with "${T.codecs}" ${L}`),I.info(`[abr] switch candidate:${c}->${j} adjustedbw(${Math.round(G)})-bitrate=${Math.round(G-ne)} ttfb:${U.toFixed(1)} avgDuration:${W.toFixed(1)} maxFetchDuration:${d.toFixed(1)} fetchDuration:${Q.toFixed(1)} firstSelection:${S} codecSet:${A} videoRange:${L} hls.loadLevel:${g}`)),S&&(this.firstSelection=j),j}}return-1}set nextAutoLevel(e){let{maxAutoLevel:t,minAutoLevel:r}=this.hls,s=Math.min(Math.max(e,r),t);this._nextAutoLevel!==s&&(this.nextAutoLevelKey="",this._nextAutoLevel=s)}},jp=class{constructor(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(e){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1}clearNextTick(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1}tick(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}},ft={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"},Xp=class{constructor(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}_registerListeners(){let{hls:e}=this;e.on(v.BUFFER_APPENDED,this.onBufferAppended,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this),e.on(v.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){let{hls:e}=this;e.off(v.BUFFER_APPENDED,this.onBufferAppended,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this),e.off(v.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){let r=this.activePartLists[t];if(r)for(let s=r.length;s--;){let n=r[s];if(!n)break;let a=n.end;if(n.start<=e&&a!==null&&e<=a)return n}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){let{fragments:r}=this,s=Object.keys(r);for(let n=s.length;n--;){let a=r[s[n]];if((a==null?void 0:a.body.type)===t&&a.buffered){let o=a.body;if(o.start<=e&&e<=o.end)return o}}return null}detectEvictedFragments(e,t,r,s){this.timeRanges&&(this.timeRanges[e]=t);let n=(s==null?void 0:s.fragment.sn)||-1;Object.keys(this.fragments).forEach(a=>{let o=this.fragments[a];if(!o||n>=o.body.sn)return;if(!o.buffered&&!o.loaded){o.body.type===r&&this.removeFragment(o.body);return}let l=o.range[e];l&&l.time.some(d=>{let u=!this.isTimeBuffered(d.startPTS,d.endPTS,t);return u&&this.removeFragment(o.body),u})})}detectPartialFragments(e){let t=this.timeRanges,{frag:r,part:s}=e;if(!t||r.sn==="initSegment")return;let n=Fn(r),a=this.fragments[n];if(!a||a.buffered&&r.gap)return;let o=!r.relurl;Object.keys(t).forEach(l=>{let d=r.elementaryStreams[l];if(!d)return;let u=t[l],c=o||d.partial===!0;a.range[l]=this.getBufferedTimes(r,s,c,u)}),a.loaded=null,Object.keys(a.range).length?(a.buffered=!0,(a.body.endList=r.endList||a.body.endList)&&(this.endListFragments[a.body.type]=a),Ru(a)||this.removeParts(r.sn-1,r.type)):this.removeFragment(a.body)}removeParts(e,t){let r=this.activePartLists[t];r&&(this.activePartLists[t]=r.filter(s=>s.fragment.sn>=e))}fragBuffered(e,t){let r=Fn(e),s=this.fragments[r];!s&&t&&(s=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),s&&(s.loaded=null,s.buffered=!0)}getBufferedTimes(e,t,r,s){let n={time:[],partial:r},a=e.start,o=e.end,l=e.minEndPTS||o,d=e.maxStartPTS||a;for(let u=0;u<s.length;u++){let c=s.start(u)-this.bufferPadding,h=s.end(u)+this.bufferPadding;if(d>=c&&l<=h){n.time.push({startPTS:Math.max(a,s.start(u)),endPTS:Math.min(o,s.end(u))});break}else if(a<h&&o>c){let f=Math.max(a,s.start(u)),m=Math.min(o,s.end(u));m>f&&(n.partial=!0,n.time.push({startPTS:f,endPTS:m}))}else if(o<=c)break}return n}getPartialFragment(e){let t=null,r,s,n,a=0,{bufferPadding:o,fragments:l}=this;return Object.keys(l).forEach(d=>{let u=l[d];u&&Ru(u)&&(s=u.body.start-o,n=u.body.end+o,e>=s&&e<=n&&(r=Math.min(e-s,n-e),a<=r&&(t=u.body,a=r)))}),t}isEndListAppended(e){let t=this.endListFragments[e];return t!==void 0&&(t.buffered||Ru(t))}getState(e){let t=Fn(e),r=this.fragments[t];return r?r.buffered?Ru(r)?ft.PARTIAL:ft.OK:ft.APPENDING:ft.NOT_LOADED}isTimeBuffered(e,t,r){let s,n;for(let a=0;a<r.length;a++){if(s=r.start(a)-this.bufferPadding,n=r.end(a)+this.bufferPadding,e>=s&&t<=n)return!0;if(t<=s)return!1}return!1}onFragLoaded(e,t){let{frag:r,part:s}=t;if(r.sn==="initSegment"||r.bitrateTest)return;let n=s?null:t,a=Fn(r);this.fragments[a]={body:r,appendedPTS:null,loaded:n,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){let{frag:r,part:s,timeRanges:n}=t;if(r.sn==="initSegment")return;let a=r.type;if(s){let o=this.activePartLists[a];o||(this.activePartLists[a]=o=[]),o.push(s)}this.timeRanges=n,Object.keys(n).forEach(o=>{let l=n[o];this.detectEvictedFragments(o,l,a,s)})}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){let t=Fn(e);return!!this.fragments[t]}hasParts(e){var t;return!!((t=this.activePartLists[e])!=null&&t.length)}removeFragmentsInRange(e,t,r,s,n){s&&!this.hasGaps||Object.keys(this.fragments).forEach(a=>{let o=this.fragments[a];if(!o)return;let l=o.body;l.type!==r||s&&!l.gap||l.start<t&&l.end>e&&(o.buffered||n)&&this.removeFragment(l)})}removeFragment(e){let t=Fn(e);e.stats.loaded=0,e.clearElementaryStreamInfo();let r=this.activePartLists[e.type];if(r){let s=e.sn;this.activePartLists[e.type]=r.filter(n=>n.fragment.sn!==s)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}};function Ru(i){var e,t,r;return i.buffered&&(i.body.gap||((e=i.range.video)==null?void 0:e.partial)||((t=i.range.audio)==null?void 0:t.partial)||((r=i.range.audiovideo)==null?void 0:r.partial))}function Fn(i){return`${i.type}_${i.level}_${i.sn}`}var kR={length:0,start:()=>0,end:()=>0},Ue=class i{static isBuffered(e,t){try{if(e){let r=i.getBuffered(e);for(let s=0;s<r.length;s++)if(t>=r.start(s)&&t<=r.end(s))return!0}}catch{}return!1}static bufferInfo(e,t,r){try{if(e){let s=i.getBuffered(e),n=[],a;for(a=0;a<s.length;a++)n.push({start:s.start(a),end:s.end(a)});return this.bufferedInfo(n,t,r)}}catch{}return{len:0,start:t,end:t,nextStart:void 0}}static bufferedInfo(e,t,r){t=Math.max(0,t),e.sort(function(d,u){let c=d.start-u.start;return c||u.end-d.end});let s=[];if(r)for(let d=0;d<e.length;d++){let u=s.length;if(u){let c=s[u-1].end;e[d].start-c<r?e[d].end>c&&(s[u-1].end=e[d].end):s.push(e[d])}else s.push(e[d])}else s=e;let n=0,a,o=t,l=t;for(let d=0;d<s.length;d++){let u=s[d].start,c=s[d].end;if(t+r>=u&&t<c)o=u,l=c,n=l-t;else if(t+r<u){a=u;break}}return{len:n,start:o||0,end:l||0,nextStart:a}}static getBuffered(e){try{return e.buffered}catch(t){return I.log("failed to get media.buffered",t),kR}}},ho=class{constructor(e,t,r,s=0,n=-1,a=!1){this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=wu(),this.buffering={audio:wu(),video:wu(),audiovideo:wu()},this.level=e,this.sn=t,this.id=r,this.size=s,this.part=n,this.partial=a}};function wu(){return{start:0,executeStart:0,executeEnd:0,end:0}}function Fu(i,e){for(let r=0,s=i.length;r<s;r++){var t;if(((t=i[r])==null?void 0:t.cc)===e)return i[r]}return null}function IR(i,e,t){return!!(e&&(t.endCC>t.startCC||i&&i.cc<t.startCC))}function RR(i,e){let t=i.fragments,r=e.fragments;if(!r.length||!t.length){I.log("No fragments to align");return}let s=Fu(t,r[0].cc);if(!s||s&&!s.startPTS){I.log("No frag in previous level to align on");return}return s}function ET(i,e){if(i){let t=i.start+e;i.start=i.startPTS=t,i.endPTS=t+i.duration}}function o_(i,e){let t=e.fragments;for(let r=0,s=t.length;r<s;r++)ET(t[r],i);e.fragmentHint&&ET(e.fragmentHint,i),e.alignedSliding=!0}function wR(i,e,t){e&&(CR(i,t,e),!t.alignedSliding&&e&&ec(t,e),!t.alignedSliding&&e&&!t.skippedSegments&&i_(e,t))}function CR(i,e,t){if(IR(i,t,e)){let r=RR(t,e);r&&q(r.start)&&(I.log(`Adjusting PTS using last level due to CC increase within current level ${e.url}`),o_(r.start,e))}}function ec(i,e){if(!i.hasProgramDateTime||!e.hasProgramDateTime)return;let t=i.fragments,r=e.fragments;if(!t.length||!r.length)return;let s,n,a=Math.min(e.endCC,i.endCC);e.startCC<a&&i.startCC<a&&(s=Fu(r,a),n=Fu(t,a)),(!s||!n)&&(s=r[Math.floor(r.length/2)],n=Fu(t,s.cc)||t[Math.floor(t.length/2)]);let o=s.programDateTime,l=n.programDateTime;if(!o||!l)return;let d=(l-o)/1e3-(n.start-s.start);o_(d,i)}var bT=Math.pow(2,17),Qp=class{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(e,t){let r=e.url;if(!r)return Promise.reject(new yi({type:ie.NETWORK_ERROR,details:C.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error(`Fragment does not have a ${r?"part list":"url"}`),networkDetails:null}));this.abort();let s=this.config,n=s.fLoader,a=s.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(f=>f[0]==="GAP")){l(TT(e));return}else e.gap=!1;let d=this.loader=e.loader=n?new n(s):new a(s),u=yT(e),c=pT(s.fragLoadPolicy.default),h={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:bT};e.stats=d.stats,d.load(u,h,{onSuccess:(f,m,p,g)=>{this.resetLoader(e,d);let E=f.data;p.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(E.slice(0,16)),E=E.slice(16)),o({frag:e,part:null,payload:E,networkDetails:g})},onError:(f,m,p,g)=>{this.resetLoader(e,d),l(new yi({type:ie.NETWORK_ERROR,details:C.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:mt({url:r,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:p,stats:g}))},onAbort:(f,m,p)=>{this.resetLoader(e,d),l(new yi({type:ie.NETWORK_ERROR,details:C.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:p,stats:f}))},onTimeout:(f,m,p)=>{this.resetLoader(e,d),l(new yi({type:ie.NETWORK_ERROR,details:C.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:p,stats:f}))},onProgress:(f,m,p,g)=>{t&&t({frag:e,part:null,payload:p,networkDetails:g})}})})}loadPart(e,t,r){this.abort();let s=this.config,n=s.fLoader,a=s.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap){l(TT(e,t));return}let d=this.loader=e.loader=n?new n(s):new a(s),u=yT(e,t),c=pT(s.fragLoadPolicy.default),h={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:bT};t.stats=d.stats,d.load(u,h,{onSuccess:(f,m,p,g)=>{this.resetLoader(e,d),this.updateStatsFromPart(e,t);let E={frag:e,part:t,payload:f.data,networkDetails:g};r(E),o(E)},onError:(f,m,p,g)=>{this.resetLoader(e,d),l(new yi({type:ie.NETWORK_ERROR,details:C.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:mt({url:u.url,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:p,stats:g}))},onAbort:(f,m,p)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,d),l(new yi({type:ie.NETWORK_ERROR,details:C.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:p,stats:f}))},onTimeout:(f,m,p)=>{this.resetLoader(e,d),l(new yi({type:ie.NETWORK_ERROR,details:C.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:p,stats:f}))}})})}updateStatsFromPart(e,t){let r=e.stats,s=t.stats,n=s.total;if(r.loaded+=s.loaded,n){let l=Math.round(e.duration/t.duration),d=Math.min(Math.round(r.loaded/n),l),c=(l-d)*Math.round(r.loaded/d);r.total=r.loaded+c}else r.total=Math.max(r.loaded,r.total);let a=r.loading,o=s.loading;a.start?a.first+=o.first-o.start:(a.start=o.start,a.first=o.first),a.end=o.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}};function yT(i,e=null){let t=e||i,r={frag:i,part:e,responseType:"arraybuffer",url:t.url,headers:{},rangeStart:0,rangeEnd:0},s=t.byteRangeStartOffset,n=t.byteRangeEndOffset;if(q(s)&&q(n)){var a;let o=s,l=n;if(i.sn==="initSegment"&&((a=i.decryptdata)==null?void 0:a.method)==="AES-128"){let d=n-s;d%16&&(l=n+(16-d%16)),s!==0&&(r.resetIV=!0,o=s-16)}r.rangeStart=o,r.rangeEnd=l}return r}function TT(i,e){let t=new Error(`GAP ${i.gap?"tag":"attribute"} found`),r={type:ie.MEDIA_ERROR,details:C.FRAG_GAP,fatal:!1,frag:i,error:t,networkDetails:null};return e&&(r.part=e),(e||i).stats.aborted=!0,new yi(r)}var yi=class extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}},Zp=class{constructor(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t}decrypt(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)}},Jp=class{constructor(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}};function DR(i){let e=i.byteLength,t=e&&new DataView(i.buffer).getUint8(e-1);return t?ks(i,0,e-t):i}var eg=class{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}uint8ArrayToUint32Array_(e){let t=new DataView(e),r=new Uint32Array(4);for(let s=0;s<4;s++)r[s]=t.getUint32(s*4);return r}initTable(){let e=this.sBox,t=this.invSBox,r=this.subMix,s=r[0],n=r[1],a=r[2],o=r[3],l=this.invSubMix,d=l[0],u=l[1],c=l[2],h=l[3],f=new Uint32Array(256),m=0,p=0,g=0;for(g=0;g<256;g++)g<128?f[g]=g<<1:f[g]=g<<1^283;for(g=0;g<256;g++){let E=p^p<<1^p<<2^p<<3^p<<4;E=E>>>8^E&255^99,e[m]=E,t[E]=m;let T=f[m],y=f[T],S=f[y],A=f[E]*257^E*16843008;s[m]=A<<24|A>>>8,n[m]=A<<16|A>>>16,a[m]=A<<8|A>>>24,o[m]=A,A=S*16843009^y*65537^T*257^m*16843008,d[E]=A<<24|A>>>8,u[E]=A<<16|A>>>16,c[E]=A<<8|A>>>24,h[E]=A,m?(m=T^f[f[f[S^T]]],p^=f[f[p]]):m=p=1}}expandKey(e){let t=this.uint8ArrayToUint32Array_(e),r=!0,s=0;for(;s<t.length&&r;)r=t[s]===this.key[s],s++;if(r)return;this.key=t;let n=this.keySize=t.length;if(n!==4&&n!==6&&n!==8)throw new Error("Invalid aes key size="+n);let a=this.ksRows=(n+6+1)*4,o,l,d=this.keySchedule=new Uint32Array(a),u=this.invKeySchedule=new Uint32Array(a),c=this.sBox,h=this.rcon,f=this.invSubMix,m=f[0],p=f[1],g=f[2],E=f[3],T,y;for(o=0;o<a;o++){if(o<n){T=d[o]=t[o];continue}y=T,o%n===0?(y=y<<8|y>>>24,y=c[y>>>24]<<24|c[y>>>16&255]<<16|c[y>>>8&255]<<8|c[y&255],y^=h[o/n|0]<<24):n>6&&o%n===4&&(y=c[y>>>24]<<24|c[y>>>16&255]<<16|c[y>>>8&255]<<8|c[y&255]),d[o]=T=(d[o-n]^y)>>>0}for(l=0;l<a;l++)o=a-l,l&3?y=d[o]:y=d[o-4],l<4||o<=4?u[l]=y:u[l]=m[c[y>>>24]]^p[c[y>>>16&255]]^g[c[y>>>8&255]]^E[c[y&255]],u[l]=u[l]>>>0}networkToHostOrderSwap(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24}decrypt(e,t,r){let s=this.keySize+6,n=this.invKeySchedule,a=this.invSBox,o=this.invSubMix,l=o[0],d=o[1],u=o[2],c=o[3],h=this.uint8ArrayToUint32Array_(r),f=h[0],m=h[1],p=h[2],g=h[3],E=new Int32Array(e),T=new Int32Array(E.length),y,S,A,L,x,w,P,k,D,U,F,z,j,K,se=this.networkToHostOrderSwap;for(;t<E.length;){for(D=se(E[t]),U=se(E[t+1]),F=se(E[t+2]),z=se(E[t+3]),x=D^n[0],w=z^n[1],P=F^n[2],k=U^n[3],j=4,K=1;K<s;K++)y=l[x>>>24]^d[w>>16&255]^u[P>>8&255]^c[k&255]^n[j],S=l[w>>>24]^d[P>>16&255]^u[k>>8&255]^c[x&255]^n[j+1],A=l[P>>>24]^d[k>>16&255]^u[x>>8&255]^c[w&255]^n[j+2],L=l[k>>>24]^d[x>>16&255]^u[w>>8&255]^c[P&255]^n[j+3],x=y,w=S,P=A,k=L,j=j+4;y=a[x>>>24]<<24^a[w>>16&255]<<16^a[P>>8&255]<<8^a[k&255]^n[j],S=a[w>>>24]<<24^a[P>>16&255]<<16^a[k>>8&255]<<8^a[x&255]^n[j+1],A=a[P>>>24]<<24^a[k>>16&255]<<16^a[x>>8&255]<<8^a[w&255]^n[j+2],L=a[k>>>24]<<24^a[x>>16&255]<<16^a[w>>8&255]<<8^a[P&255]^n[j+3],T[t]=se(y^f),T[t+1]=se(L^m),T[t+2]=se(A^p),T[t+3]=se(S^g),f=D,m=U,p=F,g=z,t=t+4}return T.buffer}},MR=16,fo=class{constructor(e,{removePKCS7Padding:t=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{let r=self.crypto;r&&(this.subtle=r.subtle||r.webkitSubtle)}catch{}this.useSoftware=!this.subtle}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){let{currentResult:e,remainderData:t}=this;if(!e||t)return this.reset(),null;let r=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?DR(r):r}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,r){return this.useSoftware?new Promise((s,n)=>{this.softwareDecrypt(new Uint8Array(e),t,r);let a=this.flush();a?s(a.buffer):n(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,r)}softwareDecrypt(e,t,r){let{currentIV:s,currentResult:n,remainderData:a}=this;this.logOnce("JS AES decrypt"),a&&(e=Jt(a,e),this.remainderData=null);let o=this.getValidChunk(e);if(!o.length)return null;s&&(r=s);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new eg),l.expandKey(t);let d=n;return this.currentResult=l.decrypt(o.buffer,0,r),this.currentIV=ks(o,-16).buffer,d||null}webCryptoDecrypt(e,t,r){if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,r));this.key=t,this.fastAesKey=new Jp(this.subtle,t)}return this.fastAesKey.expandKey().then(s=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new Zp(this.subtle,new Uint8Array(r)).decrypt(e.buffer,s)):Promise.reject(new Error("web crypto not initialized"))).catch(s=>(I.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${s.name}: ${s.message}`),this.onWebCryptoError(e,t,r)))}onWebCryptoError(e,t,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r);let s=this.flush();if(s)return s.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(e){let t=e,r=e.length-e.length%MR;return r!==e.length&&(t=ks(e,0,r),this.remainderData=ks(e,r)),t}logOnce(e){this.logEnabled&&(I.log(`[decrypter]: ${e}`),this.logEnabled=!1)}},PR={toString:function(i){let e="",t=i.length;for(let r=0;r<t;r++)e+=`[${i.start(r).toFixed(3)}-${i.end(r).toFixed(3)}]`;return e}},N={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},mo=class extends jp{constructor(e,t,r,s,n){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=N.STOPPED,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.loadedmetadata=!1,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=n,this.logPrefix=s,this.log=I.log.bind(I,`${s}:`),this.warn=I.warn.bind(I,`${s}:`),this.hls=e,this.fragmentLoader=new Qp(e.config),this.keyLoader=r,this.fragmentTracker=t,this.config=e.config,this.decrypter=new fo(e.config),e.on(v.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);let e=this.fragCurrent;e!=null&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=N.STOPPED}_streamEnded(e,t){if(t.live||e.nextStart||!e.end||!this.media)return!1;let r=t.partList;if(r!=null&&r.length){let n=r[r.length-1];return Ue.isBuffered(this.media,n.start+n.duration/2)}let s=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(s)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null){var e;return(e=this.levelLastLoaded)==null?void 0:e.details}}onMediaAttached(e,t){let r=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),r.addEventListener("seeking",this.onvseeking),r.addEventListener("ended",this.onvended);let s=this.config;this.levels&&s.autoStartLoad&&this.state===N.STOPPED&&this.startLoad(s.startPosition)}onMediaDetaching(){let e=this.media;e!=null&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&this.onvseeking&&this.onvended&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}onMediaSeeking(){let{config:e,fragCurrent:t,media:r,mediaBuffer:s,state:n}=this,a=r?r.currentTime:0,o=Ue.bufferInfo(s||r,a,e.maxBufferHole);if(this.log(`media seeking to ${q(a)?a.toFixed(3):a}, state: ${n}`),this.state===N.ENDED)this.resetLoadingState();else if(t){let l=e.maxFragLookUpTolerance,d=t.start-l,u=t.start+t.duration+l;if(!o.len||u<o.start||d>o.end){let c=a>u;(a<d||c)&&(c&&t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}r&&(this.fragmentTracker.removeFragmentsInRange(a,1/0,this.playlistType,!0),this.lastCurrentTime=a),!this.loadedmetadata&&!o.len&&(this.nextLoadPosition=this.startPosition=a),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.hls.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),this.stopLoad(),super.onHandlerDestroying(),this.hls=null}onHandlerDestroyed(){this.state=N.STOPPED,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(e,t,r){this._loadFragForPlayback(e,t,r)}_loadFragForPlayback(e,t,r){let s=n=>{if(this.fragContextChanged(e)){this.warn(`Fragment ${e.sn}${n.part?" p: "+n.part.index:""} of level ${e.level} was dropped during download.`),this.fragmentTracker.removeFragment(e);return}e.stats.chunkCount++,this._handleFragmentLoadProgress(n)};this._doFragLoad(e,t,r,s).then(n=>{if(!n)return;let a=this.state;if(this.fragContextChanged(e)){(a===N.FRAG_LOADING||!this.fragCurrent&&a===N.PARSING)&&(this.fragmentTracker.removeFragment(e),this.state=N.IDLE);return}"payload"in n&&(this.log(`Loaded fragment ${e.sn} of level ${e.level}`),this.hls.trigger(v.FRAG_LOADED,n)),this._handleFragmentLoadComplete(n)}).catch(n=>{this.state===N.STOPPED||this.state===N.ERROR||(this.warn(`Frag error: ${(n==null?void 0:n.message)||n}`),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;let{fragmentTracker:r}=this;if(r.getState(e)===ft.APPENDING){let n=e.type,a=this.getFwdBufferInfo(this.mediaBuffer,n),o=Math.max(e.duration,a?a.len:this.config.maxBufferLength),l=this.backtrackFragment;((l?e.sn-l.sn:0)===1||this.reduceMaxBufferLength(o))&&r.removeFragment(e)}else((t=this.mediaBuffer)==null?void 0:t.buffered.length)===0?r.removeAllFragments():r.hasParts(e.type)&&(r.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),r.getState(e)===ft.PARTIAL&&r.removeFragment(e))}checkLiveUpdate(e){if(e.updated&&!e.live){let t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}flushMainBuffer(e,t,r=null){if(!(e-t))return;let s={startOffset:e,endOffset:t,type:r};this.hls.trigger(v.BUFFER_FLUSHING,s)}_loadInitSegment(e,t){this._doFragLoad(e,t).then(r=>{if(!r||this.fragContextChanged(e)||!this.levels)throw new Error("init load aborted");return r}).then(r=>{let{hls:s}=this,{payload:n}=r,a=e.decryptdata;if(n&&n.byteLength>0&&a!=null&&a.key&&a.iv&&a.method==="AES-128"){let o=self.performance.now();return this.decrypter.decrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer).catch(l=>{throw s.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:C.FRAG_DECRYPT_ERROR,fatal:!1,error:l,reason:l.message,frag:e}),l}).then(l=>{let d=self.performance.now();return s.trigger(v.FRAG_DECRYPTED,{frag:e,payload:l,stats:{tstart:o,tdecrypt:d}}),r.payload=l,this.completeInitSegmentLoad(r)})}return this.completeInitSegmentLoad(r)}).catch(r=>{this.state===N.STOPPED||this.state===N.ERROR||(this.warn(r),this.resetFragmentLoading(e))})}completeInitSegmentLoad(e){let{levels:t}=this;if(!t)throw new Error("init load aborted, missing levels");let r=e.frag.stats;this.state=N.IDLE,e.frag.data=new Uint8Array(e.payload),r.parsing.start=r.buffering.start=self.performance.now(),r.parsing.end=r.buffering.end=self.performance.now(),this.tick()}fragContextChanged(e){let{fragCurrent:t}=this;return!e||!t||e.sn!==t.sn||e.level!==t.level}fragBufferedComplete(e,t){var r,s,n,a;let o=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.playlistType===J.MAIN?"level":"track"} ${e.level} (frag:[${((r=e.startPTS)!=null?r:NaN).toFixed(3)}-${((s=e.endPTS)!=null?s:NaN).toFixed(3)}] > buffer:${o?PR.toString(Ue.getBuffered(o)):"(detached)"})`),e.sn!=="initSegment"){var l;if(e.type!==J.SUBTITLE){let u=e.elementaryStreams;if(!Object.keys(u).some(c=>!!u[c])){this.state=N.IDLE;return}}let d=(l=this.levels)==null?void 0:l[e.level];d!=null&&d.fragmentError&&(this.log(`Resetting level fragment error count of ${d.fragmentError} on frag buffered`),d.fragmentError=0)}this.state=N.IDLE,o&&(!this.loadedmetadata&&e.type==J.MAIN&&o.buffered.length&&((n=this.fragCurrent)==null?void 0:n.sn)===((a=this.fragPrevious)==null?void 0:a.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(e){let{transmuxer:t}=this;if(!t)return;let{frag:r,part:s,partsLoaded:n}=e,a=!n||n.length===0||n.some(l=>!l),o=new ho(r.level,r.sn,r.stats.chunkCount+1,0,s?s.index:-1,!a);t.flush(o)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,r=null,s){var n;let a=t==null?void 0:t.details;if(!this.levels||!a)throw new Error(`frag load aborted, missing level${a?"":" detail"}s`);let o=null;if(e.encrypted&&!((n=e.decryptdata)!=null&&n.key)?(this.log(`Loading key for ${e.sn} of [${a.startSN}-${a.endSN}], ${this.logPrefix==="[stream-controller]"?"level":"track"} ${e.level}`),this.state=N.KEY_LOADING,this.fragCurrent=e,o=this.keyLoader.load(e).then(u=>{if(!this.fragContextChanged(u.frag))return this.hls.trigger(v.KEY_LOADED,u),this.state===N.KEY_LOADING&&(this.state=N.IDLE),u}),this.hls.trigger(v.KEY_LOADING,{frag:e}),this.fragCurrent===null&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!e.encrypted&&a.encryptedFragments.length&&this.keyLoader.loadClear(e,a.encryptedFragments),r=Math.max(e.start,r||0),this.config.lowLatencyMode&&e.sn!=="initSegment"){let u=a.partList;if(u&&s){r>e.end&&a.fragmentHint&&(e=a.fragmentHint);let c=this.getNextPart(u,e,r);if(c>-1){let h=u[c];this.log(`Loading part sn: ${e.sn} p: ${h.index} cc: ${e.cc} of playlist [${a.startSN}-${a.endSN}] parts [0-${c}-${u.length-1}] ${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(r.toFixed(3))}`),this.nextLoadPosition=h.start+h.duration,this.state=N.FRAG_LOADING;let f;return o?f=o.then(m=>!m||this.fragContextChanged(m.frag)?null:this.doFragPartsLoad(e,h,t,s)).catch(m=>this.handleFragLoadError(m)):f=this.doFragPartsLoad(e,h,t,s).catch(m=>this.handleFragLoadError(m)),this.hls.trigger(v.FRAG_LOADING,{frag:e,part:h,targetBufferTime:r}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):f}else if(!e.url||this.loadedEndOfParts(u,r))return Promise.resolve(null)}}this.log(`Loading fragment ${e.sn} cc: ${e.cc} ${a?"of ["+a.startSN+"-"+a.endSN+"] ":""}${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(r.toFixed(3))}`),q(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=N.FRAG_LOADING;let l=this.config.progressive,d;return l&&o?d=o.then(u=>!u||this.fragContextChanged(u==null?void 0:u.frag)?null:this.fragmentLoader.load(e,s)).catch(u=>this.handleFragLoadError(u)):d=Promise.all([this.fragmentLoader.load(e,l?s:void 0),o]).then(([u])=>(!l&&u&&s&&s(u),u)).catch(u=>this.handleFragLoadError(u)),this.hls.trigger(v.FRAG_LOADING,{frag:e,targetBufferTime:r}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):d}doFragPartsLoad(e,t,r,s){return new Promise((n,a)=>{var o;let l=[],d=(o=r.details)==null?void 0:o.partList,u=c=>{this.fragmentLoader.loadPart(e,c,s).then(h=>{l[c.index]=h;let f=h.part;this.hls.trigger(v.FRAG_LOADED,h);let m=fT(r,e.sn,c.index+1)||r_(d,e.sn,c.index+1);if(m)u(m);else return n({frag:e,part:f,partsLoaded:l})}).catch(a)};u(t)})}handleFragLoadError(e){if("data"in e){let t=e.data;e.data&&t.details===C.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(v.ERROR,t)}else this.hls.trigger(v.ERROR,{type:ie.OTHER_ERROR,details:C.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){let t=this.getCurrentContext(e);if(!t||this.state!==N.PARSING){!this.fragCurrent&&this.state!==N.STOPPED&&this.state!==N.ERROR&&(this.state=N.IDLE);return}let{frag:r,part:s,level:n}=t,a=self.performance.now();r.stats.parsing.end=a,s&&(s.stats.parsing.end=a),this.updateLevelTiming(r,s,n,e.partial)}getCurrentContext(e){let{levels:t,fragCurrent:r}=this,{level:s,sn:n,part:a}=e;if(!(t!=null&&t[s]))return this.warn(`Levels object was unset while buffering fragment ${n} of level ${s}. The current chunk will not be buffered.`),null;let o=t[s],l=a>-1?fT(o,n,a):null,d=l?l.fragment:cR(o,n,r);return d?(r&&r!==d&&(d.stats=r.stats),{frag:d,part:l,level:o}):null}bufferFragmentData(e,t,r,s,n){var a;if(!e||this.state!==N.PARSING)return;let{data1:o,data2:l}=e,d=o;if(o&&l&&(d=Jt(o,l)),!((a=d)!=null&&a.length))return;let u={type:e.type,frag:t,part:r,chunkMeta:s,parent:t.type,data:d};if(this.hls.trigger(v.BUFFER_APPENDING,u),e.dropped&&e.independent&&!r){if(n)return;this.flushBufferGap(t)}}flushBufferGap(e){let t=this.media;if(!t)return;if(!Ue.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}let r=t.currentTime,s=Ue.bufferInfo(t,r,0),n=e.duration,a=Math.min(this.config.maxFragLookUpTolerance*2,n*.25),o=Math.max(Math.min(e.start-a,s.end-a),r+a);e.start-o>a&&this.flushMainBuffer(o,e.start)}getFwdBufferInfo(e,t){let r=this.getLoadPosition();return q(r)?this.getFwdBufferInfoAtPos(e,r,t):null}getFwdBufferInfoAtPos(e,t,r){let{config:{maxBufferHole:s}}=this,n=Ue.bufferInfo(e,t,s);if(n.len===0&&n.nextStart!==void 0){let a=this.fragmentTracker.getBufferedFrag(t,r);if(a&&n.nextStart<a.end)return Ue.bufferInfo(e,t,Math.max(n.nextStart,s))}return n}getMaxBufferLength(e){let{config:t}=this,r;return e?r=Math.max(8*t.maxBufferSize/e,t.maxBufferLength):r=t.maxBufferLength,Math.min(r,t.maxMaxBufferLength)}reduceMaxBufferLength(e){let t=this.config,r=e||t.maxBufferLength,s=t.maxMaxBufferLength/2;return s>=r?(t.maxMaxBufferLength=s,this.warn(`Reduce max buffer length to ${s}s`),!0):!1}getAppendedFrag(e,t=J.MAIN){let r=this.fragmentTracker.getAppendedFrag(e,J.MAIN);return r&&"fragment"in r?r.fragment:r}getNextFragment(e,t){let r=t.fragments,s=r.length;if(!s)return null;let{config:n}=this,a=r[0].start,o;if(t.live){let l=n.initialLiveManifestSize;if(s<l)return this.warn(`Not enough fragments to start playback (have: ${s}, need: ${l})`),null;(!t.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||e<a)&&(o=this.getInitialLiveFragment(t,r),this.startPosition=this.nextLoadPosition=o?this.hls.liveSyncPosition||o.start:e)}else e<=a&&(o=r[0]);if(!o){let l=n.lowLatencyMode?t.partEnd:t.fragmentEnd;o=this.getFragmentAtPosition(e,l,t)}return this.mapToInitFragWhenRequired(o)}isLoopLoading(e,t){let r=this.fragmentTracker.getState(e);return(r===ft.OK||r===ft.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,r,s,n){let a=e.gap,o=this.getNextFragment(this.nextLoadPosition,t);if(o===null)return o;if(e=o,a&&e&&!e.gap&&r.nextStart){let l=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,s);if(l!==null&&r.len+l.len>=n)return this.log(`buffer full after gaps in "${s}" playlist starting at sn: ${e.sn}`),null}return e}mapToInitFragWhenRequired(e){return e!=null&&e.initSegment&&!(e!=null&&e.initSegment.data)&&!this.bitrateTest?e.initSegment:e}getNextPart(e,t,r){let s=-1,n=!1,a=!0;for(let o=0,l=e.length;o<l;o++){let d=e[o];if(a=a&&!d.independent,s>-1&&r<d.start)break;let u=d.loaded;u?s=-1:(n||d.independent||a)&&d.fragment===t&&(s=o),n=u}return s}loadedEndOfParts(e,t){let r=e[e.length-1];return r&&t>r.start&&r.loaded}getInitialLiveFragment(e,t){let r=this.fragPrevious,s=null;if(r){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${r.programDateTime}`),s=fR(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!s){let n=r.sn+1;if(n>=e.startSN&&n<=e.endSN){let a=t[n-e.startSN];r.cc===a.cc&&(s=a,this.log(`Live playlist, switching playlist, load frag with next SN: ${s.sn}`))}s||(s=gR(t,r.cc),s&&this.log(`Live playlist, switching playlist, load frag with same CC: ${s.sn}`))}}else{let n=this.hls.liveSyncPosition;n!==null&&(s=this.getFragmentAtPosition(n,this.bitrateTest?e.fragmentEnd:e.edge,e))}return s}getFragmentAtPosition(e,t,r){let{config:s}=this,{fragPrevious:n}=this,{fragments:a,endSN:o}=r,{fragmentHint:l}=r,{maxFragLookUpTolerance:d}=s,u=r.partList,c=!!(s.lowLatencyMode&&u!=null&&u.length&&l);c&&l&&!this.bitrateTest&&(a=a.concat(l),o=l.sn);let h;if(e<t){let f=e>t-d?0:d;h=Ju(n,a,e,f)}else h=a[a.length-1];if(h){let f=h.sn-r.startSN,m=this.fragmentTracker.getState(h);if((m===ft.OK||m===ft.PARTIAL&&h.gap)&&(n=h),n&&h.sn===n.sn&&(!c||u[0].fragment.sn>h.sn)&&n&&h.level===n.level){let g=a[f+1];h.sn<o&&this.fragmentTracker.getState(g)!==ft.OK?h=g:h=null}}return h}synchronizeToLiveEdge(e){let{config:t,media:r}=this;if(!r)return;let s=this.hls.liveSyncPosition,n=r.currentTime,a=e.fragments[0].start,o=e.edge,l=n>=a-t.maxFragLookUpTolerance&&n<=o;if(s!==null&&r.duration>s&&(n<s||!l)){let d=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!l&&r.readyState<4||n<o-d)&&(this.loadedmetadata||(this.nextLoadPosition=s),r.readyState&&(this.warn(`Playback: ${n.toFixed(3)} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${s.toFixed(3)}`),r.currentTime=s))}}alignPlaylists(e,t,r){let s=e.fragments.length;if(!s)return this.warn("No fragments in live playlist"),0;let n=e.fragments[0].start,a=!t,o=e.alignedSliding&&q(n);if(a||!o&&!n){let{fragPrevious:l}=this;wR(l,r,e);let d=e.fragments[0].start;return this.log(`Live playlist sliding: ${d.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${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<t&&(r=-1),r===-1||this.lastCurrentTime===-1){let s=this.startTimeOffset!==null,n=s?this.startTimeOffset:e.startTimeOffset;n!==null&&q(n)?(r=t+n,n<0&&(r+=e.totalduration),r=Math.min(Math.max(t,r),t+e.totalduration),this.log(`Start time offset ${n} found in ${s?"multivariant":"media"} playlist, adjust startPosition to ${r}`),this.startPosition=r):e.live?r=this.hls.liveSyncPosition||t:this.startPosition=r=0,this.lastCurrentTime=r}this.nextLoadPosition=r}getLoadPosition(){let{media:e}=this,t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t}handleFragLoadAborted(e,t){this.transmuxer&&e.sn!=="initSegment"&&e.stats.aborted&&(this.warn(`Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){(!this.fragCurrent||!this.fragContextChanged(e)&&this.state!==N.FRAG_LOADING_WAITING_RETRY)&&(this.state=N.IDLE)}onFragmentOrKeyLoadError(e,t){if(t.chunkMeta&&!t.frag){let u=this.getCurrentContext(t.chunkMeta);u&&(t.frag=u.frag)}let r=t.frag;if(!r||r.type!==e||!this.levels)return;if(this.fragContextChanged(r)){var s;this.warn(`Frag load error must match current frag to retry ${r.url} > ${(s=this.fragCurrent)==null?void 0:s.url}`);return}let n=t.details===C.FRAG_GAP;n&&this.fragmentTracker.fragBuffered(r,!0);let a=t.errorAction,{action:o,retryCount:l=0,retryConfig:d}=a||{};if(a&&o===ht.RetryRequest&&d){this.resetStartWhenNotLoaded(this.levelLastLoaded);let u=qg(d,l);this.warn(`Fragment ${r.sn} of ${e} ${r.level} errored with ${t.details}, retrying loading ${l+1}/${d.maxNumRetry} in ${u}ms`),a.resolved=!0,this.retryDate=self.performance.now()+u,this.state=N.FRAG_LOADING_WAITING_RETRY}else if(d&&a)if(this.resetFragmentErrors(e),l<d.maxNumRetry)!n&&o!==ht.RemoveAlternatePermanently&&(a.resolved=!0);else{I.warn(`${t.details} reached or exceeded max retry (${l})`);return}else(a==null?void 0:a.action)===ht.SendAlternateToPenaltyBox?this.state=N.WAITING_LEVEL:this.state=N.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(e){if(this.state===N.PARSING||this.state===N.PARSED){let t=e.parent,r=this.getFwdBufferInfo(this.mediaBuffer,t),s=r&&r.len>.5;s&&this.reduceMaxBufferLength(r.len);let n=!s;return n&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${t} buffer`),e.frag&&(this.fragmentTracker.removeFragment(e.frag),this.nextLoadPosition=e.frag.start),this.resetLoadingState(),n}return!1}resetFragmentErrors(e){e===J.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==N.STOPPED&&(this.state=N.IDLE)}afterBufferFlushed(e,t,r){if(!e)return;let s=Ue.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,s,r),this.state===N.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=N.IDLE}resetStartWhenNotLoaded(e){if(!this.loadedmetadata){this.startFragRequested=!1;let t=e?e.details:null;t!=null&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){this.warn(`The loading context changed while buffering fragment ${e.sn} of level ${e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,r,s){var n;let a=r.details;if(!a){this.warn("level.details undefined");return}if(!Object.keys(e.elementaryStreams).reduce((l,d)=>{let u=e.elementaryStreams[d];if(u){let c=u.endPTS-u.startPTS;if(c<=0)return this.warn(`Could not parse fragment ${e.sn} ${d} duration reliably (${c})`),l||!1;let h=s?0:t_(a,e,u.startPTS,u.endPTS,u.startDTS,u.endDTS);return this.hls.trigger(v.LEVEL_PTS_UPDATED,{details:a,level:r,drift:h,type:d,frag:e,start:u.startPTS,end:u.endPTS}),!0}return l},!1)&&((n=this.transmuxer)==null?void 0:n.error)===null){let l=new Error(`Found no media in fragment ${e.sn} of level ${e.level} resetting transmuxer to fallback to playlist timing`);if(r.fragmentError===0&&(r.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)),this.warn(l.message),this.hls.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:C.FRAG_PARSING_ERROR,fatal:!1,error:l,frag:e,reason:`Found no media in msn ${e.sn} of level "${r.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=N.PARSED,this.hls.trigger(v.FRAG_PARSED,{frag:e,part:t})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(e){e.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())}set state(e){let t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}},tc=class{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){let{chunks:e,dataLength:t}=this,r;if(e.length)e.length===1?r=e[0]:r=OR(e,t);else return new Uint8Array(0);return this.reset(),r}reset(){this.chunks.length=0,this.dataLength=0}};function OR(i,e){let t=new Uint8Array(e),r=0;for(let s=0;s<i.length;s++){let n=i[s];t.set(n,r),r+=n.length}return t}function NR(){return typeof __HLS_WORKER_BUNDLE__=="function"}function UR(){let i=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),e=self.URL.createObjectURL(i);return{worker:new self.Worker(e),objectURL:e}}function FR(i){let e=new self.URL(i,self.location.href).href;return{worker:new self.Worker(e),scriptURL:e}}function ji(i="",e=9e4){return{type:i,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}var po=class{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,t,r,s){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,r){}demux(e,t){this.cachedData&&(e=Jt(this.cachedData,e),this.cachedData=null);let r=oo(e,0),s=r?r.length:0,n,a=this._audioTrack,o=this._id3Track,l=r?Vg(r):void 0,d=e.length;for((this.basePTS===null||this.frameIndex===0&&q(l))&&(this.basePTS=BR(l,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),r&&r.length>0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:Ti.audioId3,duration:Number.POSITIVE_INFINITY});s<d;){if(this.canParse(e,s)){let u=this.appendFrame(a,e,s);u?(this.frameIndex++,this.lastPTS=u.sample.pts,s+=u.length,n=s):s=d}else bI(e,s)?(r=oo(e,s),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:Ti.audioId3,duration:Number.POSITIVE_INFINITY}),s+=r.length,n=s):s++;if(s===d&&n!==d){let u=ks(e,n);this.cachedData?this.cachedData=Jt(this.cachedData,u):this.cachedData=u}}return{audioTrack:a,videoTrack:ji(),id3Track:o,textTrack:ji()}}demuxSampleAes(e,t,r){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){let t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:ji(),id3Track:this._id3Track,textTrack:ji()}}destroy(){}},BR=(i,e,t)=>{if(q(i))return i*90;let r=t?t.baseTime*9e4/t.timescale:0;return e*9e4+r};function $R(i,e,t,r){let s,n,a,o,l=navigator.userAgent.toLowerCase(),d=r,u=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];s=((e[t+2]&192)>>>6)+1;let c=(e[t+2]&60)>>>2;if(c>u.length-1){let h=new Error(`invalid ADTS sampling index:${c}`);i.emit(v.ERROR,v.ERROR,{type:ie.MEDIA_ERROR,details:C.FRAG_PARSING_ERROR,fatal:!0,error:h,reason:h.message});return}return a=(e[t+2]&1)<<2,a|=(e[t+3]&192)>>>6,I.log(`manifest codec:${r}, ADTS type:${s}, samplingIndex:${c}`),/firefox/i.test(l)?c>=6?(s=5,o=new Array(4),n=c-3):(s=2,o=new Array(2),n=c):l.indexOf("android")!==-1?(s=2,o=new Array(2),n=c):(s=5,o=new Array(4),r&&(r.indexOf("mp4a.40.29")!==-1||r.indexOf("mp4a.40.5")!==-1)||!r&&c>=6?n=c-3:((r&&r.indexOf("mp4a.40.2")!==-1&&(c>=6&&a===1||/vivaldi/i.test(l))||!r&&a===1)&&(s=2,o=new Array(2)),n=c)),o[0]=s<<3,o[0]|=(c&14)>>1,o[1]|=(c&1)<<7,o[1]|=a<<3,s===5&&(o[1]|=(n&14)>>1,o[2]=(n&1)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:u[c],channelCount:a,codec:"mp4a.40."+s,manifestCodec:d}}function l_(i,e){return i[e]===255&&(i[e+1]&246)===240}function d_(i,e){return i[e+1]&1?7:9}function Yg(i,e){return(i[e+3]&3)<<11|i[e+4]<<3|(i[e+5]&224)>>>5}function HR(i,e){return e+5<i.length}function ic(i,e){return e+1<i.length&&l_(i,e)}function GR(i,e){return HR(i,e)&&l_(i,e)&&Yg(i,e)<=i.length-e}function WR(i,e){if(ic(i,e)){let t=d_(i,e);if(e+t>=i.length)return!1;let r=Yg(i,e);if(r<=t)return!1;let s=e+r;return s===i.length||ic(i,s)}return!1}function u_(i,e,t,r,s){if(!i.samplerate){let n=$R(e,t,r,s);if(!n)return;i.config=n.config,i.samplerate=n.samplerate,i.channelCount=n.channelCount,i.codec=n.codec,i.manifestCodec=n.manifestCodec,I.log(`parsed codec:${i.codec}, rate:${n.samplerate}, channels:${n.channelCount}`)}}function c_(i){return 1024*9e4/i}function KR(i,e){let t=d_(i,e);if(e+t<=i.length){let r=Yg(i,e)-t;if(r>0)return{headerLength:t,frameLength:r}}}function h_(i,e,t,r,s){let n=c_(i.samplerate),a=r+s*n,o=KR(e,t),l;if(o){let{frameLength:c,headerLength:h}=o,f=h+c,m=Math.max(0,t+f-e.length);m?(l=new Uint8Array(f-h),l.set(e.subarray(t+h,e.length),0)):l=e.subarray(t+h,t+f);let p={unit:l,pts:a};return m||i.samples.push(p),{sample:p,length:f,missing:m}}let d=e.length-t;return l=new Uint8Array(d),l.set(e.subarray(t,e.length),0),{sample:{unit:l,pts:a},length:d,missing:-1}}var Cu=null,VR=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],qR=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],YR=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],zR=[0,1,1,4];function f_(i,e,t,r,s){if(t+24>e.length)return;let n=m_(e,t);if(n&&t+n.frameLength<=e.length){let a=n.samplesPerFrame*9e4/n.sampleRate,o=r+s*a,l={unit:e.subarray(t,t+n.frameLength),pts:o,dts:o};return i.config=[],i.channelCount=n.channelCount,i.samplerate=n.sampleRate,i.samples.push(l),{sample:l,length:n.frameLength,missing:0}}}function m_(i,e){let t=i[e+1]>>3&3,r=i[e+1]>>1&3,s=i[e+2]>>4&15,n=i[e+2]>>2&3;if(t!==1&&s!==0&&s!==15&&n!==3){let a=i[e+2]>>1&1,o=i[e+3]>>6,l=t===3?3-r:r===3?3:4,d=VR[l*14+s-1]*1e3,c=qR[(t===3?0:t===2?1:2)*3+n],h=o===3?1:2,f=YR[t][r],m=zR[r],p=f*8*m,g=Math.floor(f*d/c+a)*m;if(Cu===null){let y=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Cu=y?parseInt(y[1]):0}return!!Cu&&Cu<=87&&r===2&&d>=224e3&&o===0&&(i[e+3]=i[e+3]|128),{sampleRate:c,channelCount:h,frameLength:g,samplesPerFrame:p}}}function zg(i,e){return i[e]===255&&(i[e+1]&224)===224&&(i[e+1]&6)!==0}function p_(i,e){return e+1<i.length&&zg(i,e)}function jR(i,e){return zg(i,e)&&4<=i.length-e}function g_(i,e){if(e+1<i.length&&zg(i,e)){let r=m_(i,e),s=4;r!=null&&r.frameLength&&(s=r.frameLength);let n=e+s;return n===i.length||p_(i,n)}return!1}var tg=class extends po{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,r,s){super.resetInitSegment(e,t,r,s),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;let t=oo(e,0),r=(t==null?void 0:t.length)||0;if(g_(e,r))return!1;for(let s=e.length;r<s;r++)if(WR(e,r))return I.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return GR(e,t)}appendFrame(e,t,r){u_(e,this.observer,t,r,e.manifestCodec);let s=h_(e,t,r,this.basePTS,this.frameIndex);if(s&&s.missing===0)return s}},XR=/\/emsg[-/]ID3/i,ig=class{constructor(e,t){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=t}resetTimeStamp(){}resetInitSegment(e,t,r,s){let n=this.videoTrack=ji("video",1),a=this.audioTrack=ji("audio",1),o=this.txtTrack=ji("text",1);if(this.id3Track=ji("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;let l=YT(e);if(l.video){let{id:d,timescale:u,codec:c}=l.video;n.id=d,n.timescale=o.timescale=u,n.codec=c}if(l.audio){let{id:d,timescale:u,codec:c}=l.audio;a.id=d,a.timescale=u,a.codec=c}o.id=KT.text,n.sampleDuration=0,n.duration=a.duration=s}resetContiguity(){this.remainderData=null}static probe(e){return II(e)}demux(e,t){this.timeOffset=t;let r=e,s=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=Jt(this.remainderData,e));let o=NI(r);this.remainderData=o.remainder,s.samples=o.valid||new Uint8Array}else s.samples=r;let a=this.extractID3Track(s,t);return n.samples=jy(t,s),{videoTrack:s,audioTrack:this.audioTrack,id3Track:a,textTrack:this.txtTrack}}flush(){let e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;let s=this.extractID3Track(t,this.timeOffset);return r.samples=jy(e,t),{videoTrack:t,audioTrack:ji(),id3Track:s,textTrack:ji()}}extractID3Track(e,t){let r=this.id3Track;if(e.samples.length){let s=ae(e.samples,["emsg"]);s&&s.forEach(n=>{let a=BI(n);if(XR.test(a.schemeIdUri)){let o=q(a.presentationTime)?a.presentationTime/a.timeScale:t+a.presentationTimeDelta/a.timeScale,l=a.eventDuration===4294967295?Number.POSITIVE_INFINITY:a.eventDuration/a.timeScale;l<=.001&&(l=Number.POSITIVE_INFINITY);let d=a.payload;r.samples.push({data:d,len:d.byteLength,dts:o,pts:o,type:Ti.emsg,duration:l})}})}return r}demuxSampleAes(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}},v_=(i,e)=>{let t=0,r=5;e+=r;let s=new Uint32Array(1),n=new Uint32Array(1),a=new Uint8Array(1);for(;r>0;){a[0]=i[e];let o=Math.min(r,8),l=8-o;n[0]=4278190080>>>24+l<<l,s[0]=(a[0]&n[0])>>l,t=t?t<<o|s[0]:s[0],e+=1,r-=o}return t},rg=class extends po{constructor(e){super(),this.observer=void 0,this.observer=e}resetInitSegment(e,t,r,s){super.resetInitSegment(e,t,r,s),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}canParse(e,t){return t+64<e.length}appendFrame(e,t,r){let s=E_(e,t,r,this.basePTS,this.frameIndex);if(s!==-1)return{sample:e.samples[e.samples.length-1],length:s,missing:0}}static probe(e){if(!e)return!1;let t=oo(e,0);if(!t)return!1;let r=t.length;return e[r]===11&&e[r+1]===119&&Vg(t)!==void 0&&v_(e,r)<16}};function E_(i,e,t,r,s){if(t+8>e.length||e[t]!==11||e[t+1]!==119)return-1;let n=e[t+4]>>6;if(n>=3)return-1;let o=[48e3,44100,32e3][n],l=e[t+4]&63,u=[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][l*3+n]*2;if(t+u>e.length)return-1;let c=e[t+6]>>5,h=0;c===2?h+=2:(c&1&&c!==1&&(h+=2),c&4&&(h+=2));let f=(e[t+6]<<8|e[t+7])>>12-h&1,p=[2,1,2,3,3,4,4,5][c]+f,g=e[t+5]>>3,E=e[t+5]&7,T=new Uint8Array([n<<6|g<<1|E>>2,(E&3)<<6|c<<3|f<<2|l>>4,l<<4&224]),y=1536/o*9e4,S=r+s*y,A=e.subarray(t,t+u);return i.config=T,i.channelCount=p,i.samplerate=o,i.samples.push({unit:A,pts:S}),u}var sg=class{constructor(){this.VideoSample=null}createVideoSample(e,t,r,s){return{key:e,frame:!1,pts:t,dts:r,units:[],debug:s,length:0}}getLastNalUnit(e){var t;let r=this.VideoSample,s;if((!r||r.units.length===0)&&(r=e[e.length-1]),(t=r)!=null&&t.units){let n=r.units;s=n[n.length-1]}return s}pushAccessUnit(e,t){if(e.units.length&&e.frame){if(e.pts===void 0){let r=t.samples,s=r.length;if(s){let n=r[s-1];e.pts=n.pts,e.dts=n.dts}else{t.dropped++;return}}t.samples.push(e)}e.debug.length&&I.log(e.pts+"/"+e.dts+":"+e.debug)}},rc=class{constructor(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){let e=this.data,t=this.bytesAvailable,r=e.byteLength-t,s=new Uint8Array(4),n=Math.min(4,t);if(n===0)throw new Error("no bytes available");s.set(e.subarray(r,r+n)),this.word=new DataView(s.buffer).getUint32(0),this.bitsAvailable=n*8,this.bytesAvailable-=n}skipBits(e){let t;e=Math.min(e,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}readBits(e){let t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;if(e>32&&I.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return t=e-t,t>0&&this.bitsAvailable?r<<t|this.readBits(t):r}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if(this.word&2147483648>>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){let e=this.skipLZ();return this.readBits(e+1)-1}readEG(){let e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return this.readBits(1)===1}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(e){let t=8,r=8,s;for(let n=0;n<e;n++)r!==0&&(s=this.readEG(),r=(t+s+256)%256),t=r===0?t:r}readSPS(){let e=0,t=0,r=0,s=0,n,a,o,l=this.readUByte.bind(this),d=this.readBits.bind(this),u=this.readUEG.bind(this),c=this.readBoolean.bind(this),h=this.skipBits.bind(this),f=this.skipEG.bind(this),m=this.skipUEG.bind(this),p=this.skipScalingList.bind(this);l();let g=l();if(d(5),h(3),l(),m(),g===100||g===110||g===122||g===244||g===44||g===83||g===86||g===118||g===128){let L=u();if(L===3&&h(1),m(),m(),h(1),c())for(a=L!==3?8:12,o=0;o<a;o++)c()&&(o<6?p(16):p(64))}m();let E=u();if(E===0)u();else if(E===1)for(h(1),f(),f(),n=u(),o=0;o<n;o++)f();m(),h(1);let T=u(),y=u(),S=d(1);S===0&&h(1),h(1),c()&&(e=u(),t=u(),r=u(),s=u());let A=[1,1];if(c()&&c())switch(l()){case 1:A=[1,1];break;case 2:A=[12,11];break;case 3:A=[10,11];break;case 4:A=[16,11];break;case 5:A=[40,33];break;case 6:A=[24,11];break;case 7:A=[20,11];break;case 8:A=[32,11];break;case 9:A=[80,33];break;case 10:A=[18,11];break;case 11:A=[15,11];break;case 12:A=[64,33];break;case 13:A=[160,99];break;case 14:A=[4,3];break;case 15:A=[3,2];break;case 16:A=[2,1];break;case 255:{A=[l()<<8|l(),l()<<8|l()];break}}return{width:Math.ceil((T+1)*16-e*2-t*2),height:(2-S)*(y+1)*16-(S?2:4)*(r+s),pixelRatio:A}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}},ng=class extends sg{parseAVCPES(e,t,r,s,n){let a=this.parseAVCNALu(e,r.data),o=this.VideoSample,l,d=!1;r.data=null,o&&a.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts,"")),a.forEach(u=>{var c;switch(u.type){case 1:{let p=!1;l=!0;let g=u.data;if(d&&g.length>4){let E=new rc(g).readSliceType();(E===2||E===4||E===7||E===9)&&(p=!0)}if(p){var h;(h=o)!=null&&h.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null)}o||(o=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts,"")),o.frame=!0,o.key=p;break}case 5:l=!0,(c=o)!=null&&c.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null),o||(o=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts,"")),o.key=!0,o.frame=!0;break;case 6:{l=!0,jT(u.data,1,r.pts,t.samples);break}case 7:{var f,m;l=!0,d=!0;let p=u.data,E=new rc(p).readSPS();if(!e.sps||e.width!==E.width||e.height!==E.height||((f=e.pixelRatio)==null?void 0:f[0])!==E.pixelRatio[0]||((m=e.pixelRatio)==null?void 0:m[1])!==E.pixelRatio[1]){e.width=E.width,e.height=E.height,e.pixelRatio=E.pixelRatio,e.sps=[p],e.duration=n;let T=p.subarray(1,4),y="avc1.";for(let S=0;S<3;S++){let A=T[S].toString(16);A.length<2&&(A="0"+A),y+=A}e.codec=y}break}case 8:l=!0,e.pps=[u.data];break;case 9:l=!0,e.audFound=!0,o&&this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts,"");break;case 12:l=!0;break;default:l=!1,o&&(o.debug+="unknown NAL "+u.type+" ");break}o&&l&&o.units.push(u)}),s&&o&&(this.pushAccessUnit(o,e),this.VideoSample=null)}parseAVCNALu(e,t){let r=t.byteLength,s=e.naluState||0,n=s,a=[],o=0,l,d,u,c=-1,h=0;for(s===-1&&(c=0,h=t[0]&31,s=0,o=1);o<r;){if(l=t[o++],!s){s=l?0:1;continue}if(s===1){s=l?0:2;continue}if(!l)s=3;else if(l===1){if(d=o-s-1,c>=0){let f={data:t.subarray(c,d),type:h};a.push(f)}else{let f=this.getLastNalUnit(e.samples);f&&(n&&o<=4-n&&f.state&&(f.data=f.data.subarray(0,f.data.byteLength-n)),d>0&&(f.data=Jt(f.data,t.subarray(0,d)),f.state=0))}o<r?(u=t[o]&31,c=o,h=u,s=0):s=-1}else s=0}if(c>=0&&s>=0){let f={data:t.subarray(c,r),type:h,state:s};a.push(f)}if(a.length===0){let f=this.getLastNalUnit(e.samples);f&&(f.data=Jt(f.data,t))}return e.naluState=s,a}},ag=class{constructor(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new fo(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(e,t,r){let s=e[t].unit;if(s.length<=16)return;let n=s.subarray(16,s.length-s.length%16),a=n.buffer.slice(n.byteOffset,n.byteOffset+n.length);this.decryptBuffer(a).then(o=>{let l=new Uint8Array(o);s.set(l,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,r)})}decryptAacSamples(e,t,r){for(;;t++){if(t>=e.length){r();return}if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,r),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){let t=Math.floor((e.length-48)/160)*16+16,r=new Int8Array(t),s=0;for(let n=32;n<e.length-16;n+=160,s+=16)r.set(e.subarray(n,n+16),s);return r}getAvcDecryptedUnit(e,t){let r=new Uint8Array(t),s=0;for(let n=32;n<e.length-16;n+=160,s+=16)e.set(r.subarray(s,s+16),n);return e}decryptAvcSample(e,t,r,s,n){let a=XT(n.data),o=this.getAvcEncryptedData(a);this.decryptBuffer(o.buffer).then(l=>{n.data=this.getAvcDecryptedUnit(a,l),this.decrypter.isSync()||this.decryptAvcSamples(e,t,r+1,s)})}decryptAvcSamples(e,t,r,s){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length){s();return}let n=e[t].units;for(;!(r>=n.length);r++){let a=n[r];if(!(a.data.length<=48||a.type!==1&&a.type!==5)&&(this.decryptAvcSample(e,t,r,s,a),!this.decrypter.isSync()))return}}}},ct=188,og=class i{constructor(e,t,r){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=e,this.config=t,this.typeSupported=r,this.videoParser=new ng}static probe(e){let t=i.syncOffset(e);return t>0&&I.warn(`MPEG2-TS detected but first sync word found @ offset ${t}`),t!==-1}static syncOffset(e){let t=e.length,r=Math.min(ct*5,t-ct)+1,s=0;for(;s<r;){let n=!1,a=-1,o=0;for(let l=s;l<t;l+=ct)if(e[l]===71&&(t-l===ct||e[l+ct]===71)){if(o++,a===-1&&(a=l,a!==0&&(r=Math.min(a+ct*99,e.length-ct)+1)),n||(n=lg(e,l)===0),n&&o>1&&(a===0&&o>2||l+ct>r))return a}else{if(o)return-1;break}s++}return-1}static createTrack(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:KT[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}}resetInitSegment(e,t,r,s){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=i.createTrack("video"),this._audioTrack=i.createTrack("audio",s),this._id3Track=i.createTrack("id3"),this._txtTrack=i.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=r,this._duration=s}resetTimeStamp(){}resetContiguity(){let{_audioTrack:e,_videoTrack:t,_id3Track:r}=this;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.remainderData=null}demux(e,t,r=!1,s=!1){r||(this.sampleAes=null);let n,a=this._videoTrack,o=this._audioTrack,l=this._id3Track,d=this._txtTrack,u=a.pid,c=a.pesData,h=o.pid,f=l.pid,m=o.pesData,p=l.pesData,g=null,E=this.pmtParsed,T=this._pmtId,y=e.length;if(this.remainderData&&(e=Jt(this.remainderData,e),y=e.length,this.remainderData=null),y<ct&&!s)return this.remainderData=e,{audioTrack:o,videoTrack:a,id3Track:l,textTrack:d};let S=Math.max(0,i.syncOffset(e));y-=(y-S)%ct,y<e.byteLength&&!s&&(this.remainderData=new Uint8Array(e.buffer,y,e.buffer.byteLength-y));let A=0;for(let x=S;x<y;x+=ct)if(e[x]===71){let w=!!(e[x+1]&64),P=lg(e,x),k=(e[x+3]&48)>>4,D;if(k>1){if(D=x+5+e[x+4],D===x+ct)continue}else D=x+4;switch(P){case u:w&&(c&&(n=Bn(c))&&this.videoParser.parseAVCPES(a,d,n,!1,this._duration),c={data:[],size:0}),c&&(c.data.push(e.subarray(D,x+ct)),c.size+=x+ct-D);break;case h:if(w){if(m&&(n=Bn(m)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,n);break;case"mp3":this.parseMPEGPES(o,n);break;case"ac3":this.parseAC3PES(o,n);break}m={data:[],size:0}}m&&(m.data.push(e.subarray(D,x+ct)),m.size+=x+ct-D);break;case f:w&&(p&&(n=Bn(p))&&this.parseID3PES(l,n),p={data:[],size:0}),p&&(p.data.push(e.subarray(D,x+ct)),p.size+=x+ct-D);break;case 0:w&&(D+=e[D]+1),T=this._pmtId=QR(e,D);break;case T:{w&&(D+=e[D]+1);let U=ZR(e,D,this.typeSupported,r,this.observer);u=U.videoPid,u>0&&(a.pid=u,a.segmentCodec=U.segmentVideoCodec),h=U.audioPid,h>0&&(o.pid=h,o.segmentCodec=U.segmentAudioCodec),f=U.id3Pid,f>0&&(l.pid=f),g!==null&&!E&&(I.warn(`MPEG-TS PMT found at ${x} after unknown PID '${g}'. Backtracking to sync byte @${S} to parse all TS packets.`),g=null,x=S-188),E=this.pmtParsed=!0;break}case 17:case 8191:break;default:g=P;break}}else A++;A>0&&sc(this.observer,new Error(`Found ${A} TS packet/s that do not start with 0x47`)),a.pesData=c,o.pesData=m,l.pesData=p;let L={audioTrack:o,videoTrack:a,id3Track:l,textTrack:d};return s&&this.extractRemainingSamples(L),L}flush(){let{remainderData:e}=this;this.remainderData=null;let t;return e?t=this.demux(e,-1,!1,!0):t={videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t}extractRemainingSamples(e){let{audioTrack:t,videoTrack:r,id3Track:s,textTrack:n}=e,a=r.pesData,o=t.pesData,l=s.pesData,d;if(a&&(d=Bn(a))?(this.videoParser.parseAVCPES(r,n,d,!0,this._duration),r.pesData=null):r.pesData=a,o&&(d=Bn(o))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,d);break;case"mp3":this.parseMPEGPES(t,d);break;case"ac3":this.parseAC3PES(t,d);break}t.pesData=null}else o!=null&&o.size&&I.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=o;l&&(d=Bn(l))?(this.parseID3PES(s,d),s.pesData=null):s.pesData=l}demuxSampleAes(e,t,r){let s=this.demux(e,r,!0,!this.config.progressive),n=this.sampleAes=new ag(this.observer,this.config,t);return this.decrypt(s,n)}decrypt(e,t){return new Promise(r=>{let{audioTrack:s,videoTrack:n}=e;s.samples&&s.segmentCodec==="aac"?t.decryptAacSamples(s.samples,0,()=>{n.samples?t.decryptAvcSamples(n.samples,0,0,()=>{r(e)}):r(e)}):n.samples&&t.decryptAvcSamples(n.samples,0,0,()=>{r(e)})})}destroy(){this._duration=0}parseAACPES(e,t){let r=0,s=this.aacOverFlow,n=t.data;if(s){this.aacOverFlow=null;let c=s.missing,h=s.sample.unit.byteLength;if(c===-1)n=Jt(s.sample.unit,n);else{let f=h-c;s.sample.unit.set(n.subarray(0,c),f),e.samples.push(s.sample),r=s.missing}}let a,o;for(a=r,o=n.length;a<o-1&&!ic(n,a);a++);if(a!==r){let c,h=a<o-1;if(h?c=`AAC PES did not start with ADTS header,offset:${a}`:c="No ADTS header found in AAC PES",sc(this.observer,new Error(c),h),!h)return}u_(e,this.observer,n,a,this.audioCodec);let l;if(t.pts!==void 0)l=t.pts;else if(s){let c=c_(e.samplerate);l=s.sample.pts+c}else{I.warn("[tsdemuxer]: AAC PES unknown PTS");return}let d=0,u;for(;a<o;)if(u=h_(e,n,a,l,d),a+=u.length,u.missing){this.aacOverFlow=u;break}else for(d++;a<o-1&&!ic(n,a);a++);}parseMPEGPES(e,t){let r=t.data,s=r.length,n=0,a=0,o=t.pts;if(o===void 0){I.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<s;)if(p_(r,a)){let l=f_(e,r,a,o,n);if(l)a+=l.length,n++;else break}else a++}parseAC3PES(e,t){{let r=t.data,s=t.pts;if(s===void 0){I.warn("[tsdemuxer]: AC3 PES unknown PTS");return}let n=r.length,a=0,o=0,l;for(;o<n&&(l=E_(e,r,o,s,a++))>0;)o+=l}}parseID3PES(e,t){if(t.pts===void 0){I.warn("[tsdemuxer]: ID3 PES unknown PTS");return}let r=Je({},t,{type:this._videoTrack?Ti.emsg:Ti.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}};function lg(i,e){return((i[e+1]&31)<<8)+i[e+2]}function QR(i,e){return(i[e+10]&31)<<8|i[e+11]}function ZR(i,e,t,r,s){let n={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},a=(i[e+1]&15)<<8|i[e+2],o=e+3+a-4,l=(i[e+10]&15)<<8|i[e+11];for(e+=12+l;e<o;){let d=lg(i,e),u=(i[e+3]&15)<<8|i[e+4];switch(i[e]){case 207:if(!r){Ap("ADTS AAC");break}case 15:n.audioPid===-1&&(n.audioPid=d);break;case 21:n.id3Pid===-1&&(n.id3Pid=d);break;case 219:if(!r){Ap("H.264");break}case 27:n.videoPid===-1&&(n.videoPid=d,n.segmentVideoCodec="avc");break;case 3:case 4:!t.mpeg&&!t.mp3?I.log("MPEG audio found, not supported in this browser"):n.audioPid===-1&&(n.audioPid=d,n.segmentAudioCodec="mp3");break;case 193:if(!r){Ap("AC-3");break}case 129:t.ac3?n.audioPid===-1&&(n.audioPid=d,n.segmentAudioCodec="ac3"):I.log("AC-3 audio found, not supported in this browser");break;case 6:if(n.audioPid===-1&&u>0){let c=e+5,h=u;for(;h>2;){switch(i[c]){case 106:t.ac3!==!0?I.log("AC-3 audio found, not supported in this browser for now"):(n.audioPid=d,n.segmentAudioCodec="ac3");break}let m=i[c+1]+2;c+=m,h-=m}}break;case 194:case 135:return sc(s,new Error("Unsupported EC-3 in M2TS found")),n;case 36:return sc(s,new Error("Unsupported HEVC in M2TS found")),n}e+=u+5}return n}function sc(i,e,t){I.warn(`parsing error: ${e.message}`),i.emit(v.ERROR,v.ERROR,{type:ie.MEDIA_ERROR,details:C.FRAG_PARSING_ERROR,fatal:!1,levelRetry:t,error:e,reason:e.message})}function Ap(i){I.log(`${i} with AES-128-CBC encryption found in unencrypted stream`)}function Bn(i){let e=0,t,r,s,n,a,o=i.data;if(!i||i.size===0)return null;for(;o[0].length<19&&o.length>1;)o[0]=Jt(o[0],o[1]),o.splice(1,1);if(t=o[0],(t[0]<<16)+(t[1]<<8)+t[2]===1){if(r=(t[4]<<8)+t[5],r&&r>i.size-6)return null;let d=t[7];d&192&&(n=(t[9]&14)*536870912+(t[10]&255)*4194304+(t[11]&254)*16384+(t[12]&255)*128+(t[13]&254)/2,d&64?(a=(t[14]&14)*536870912+(t[15]&255)*4194304+(t[16]&254)*16384+(t[17]&255)*128+(t[18]&254)/2,n-a>60*9e4&&(I.warn(`${Math.round((n-a)/9e4)}s delta between PTS and DTS, align them`),n=a)):a=n),s=t[8];let u=s+9;if(i.size<=u)return null;i.size-=u;let c=new Uint8Array(i.size);for(let h=0,f=o.length;h<f;h++){t=o[h];let m=t.byteLength;if(u)if(u>m){u-=m;continue}else t=t.subarray(u),m-=u,u=0;c.set(t,e),e+=m}return r&&(r-=s+3),{data:c,pts:n,dts:a,len:r}}return null}var dg=class extends po{resetInitSegment(e,t,r,s){super.resetInitSegment(e,t,r,s),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;let t=oo(e,0),r=(t==null?void 0:t.length)||0;if(t&&e[r]===11&&e[r+1]===119&&Vg(t)!==void 0&&v_(e,r)<=16)return!1;for(let s=e.length;r<s;r++)if(g_(e,r))return I.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return jR(e,t)}appendFrame(e,t,r){if(this.basePTS!==null)return f_(e,t,r,this.basePTS,this.frameIndex)}},nc=class{static getSilentFrame(e,t){switch(e){case"mp4a.40.2":if(t===1)return new Uint8Array([0,200,0,128,35,128]);if(t===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(t===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(t===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(t===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(t===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(t===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}}},Cr=Math.pow(2,32)-1,rt=class i{static init(){i.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};let e;for(e in i.types)i.types.hasOwnProperty(e)&&(i.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);let t=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),r=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);i.HDLR_TYPES={video:t,audio:r};let s=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),n=new Uint8Array([0,0,0,0,0,0,0,0]);i.STTS=i.STSC=i.STCO=n,i.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),i.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),i.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),i.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);let a=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);i.FTYP=i.box(i.types.ftyp,a,l,a,o),i.DINF=i.box(i.types.dinf,i.box(i.types.dref,s))}static box(e,...t){let r=8,s=t.length,n=s;for(;s--;)r+=t[s].byteLength;let a=new Uint8Array(r);for(a[0]=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<n;s++)a.set(t[s],r),r+=t[s].byteLength;return a}static hdlr(e){return i.box(i.types.hdlr,i.HDLR_TYPES[e])}static mdat(e){return i.box(i.types.mdat,e)}static mdhd(e,t){t*=e;let r=Math.floor(t/(Cr+1)),s=Math.floor(t%(Cr+1));return i.box(i.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,r>>24,r>>16&255,r>>8&255,r&255,s>>24,s>>16&255,s>>8&255,s&255,85,196,0,0]))}static mdia(e){return i.box(i.types.mdia,i.mdhd(e.timescale,e.duration),i.hdlr(e.type),i.minf(e))}static mfhd(e){return i.box(i.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255]))}static minf(e){return e.type==="audio"?i.box(i.types.minf,i.box(i.types.smhd,i.SMHD),i.DINF,i.stbl(e)):i.box(i.types.minf,i.box(i.types.vmhd,i.VMHD),i.DINF,i.stbl(e))}static moof(e,t,r){return i.box(i.types.moof,i.mfhd(e),i.traf(r,t))}static moov(e){let t=e.length,r=[];for(;t--;)r[t]=i.trak(e[t]);return i.box.apply(null,[i.types.moov,i.mvhd(e[0].timescale,e[0].duration)].concat(r).concat(i.mvex(e)))}static mvex(e){let t=e.length,r=[];for(;t--;)r[t]=i.trex(e[t]);return i.box.apply(null,[i.types.mvex,...r])}static mvhd(e,t){t*=e;let r=Math.floor(t/(Cr+1)),s=Math.floor(t%(Cr+1)),n=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,r>>24,r>>16&255,r>>8&255,r&255,s>>24,s>>16&255,s>>8&255,s&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return i.box(i.types.mvhd,n)}static sdtp(e){let t=e.samples||[],r=new Uint8Array(4+t.length),s,n;for(s=0;s<t.length;s++)n=t[s].flags,r[s+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return i.box(i.types.sdtp,r)}static stbl(e){return i.box(i.types.stbl,i.stsd(e),i.box(i.types.stts,i.STTS),i.box(i.types.stsc,i.STSC),i.box(i.types.stsz,i.STSZ),i.box(i.types.stco,i.STCO))}static avc1(e){let t=[],r=[],s,n,a;for(s=0;s<e.sps.length;s++)n=e.sps[s],a=n.byteLength,t.push(a>>>8&255),t.push(a&255),t=t.concat(Array.prototype.slice.call(n));for(s=0;s<e.pps.length;s++)n=e.pps[s],a=n.byteLength,r.push(a>>>8&255),r.push(a&255),r=r.concat(Array.prototype.slice.call(n));let o=i.box(i.types.avcC,new Uint8Array([1,t[3],t[4],t[5],255,224|e.sps.length].concat(t).concat([e.pps.length]).concat(r))),l=e.width,d=e.height,u=e.pixelRatio[0],c=e.pixelRatio[1];return i.box(i.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,l&255,d>>8&255,d&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,i.box(i.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),i.box(i.types.pasp,new Uint8Array([u>>24,u>>16&255,u>>8&255,u&255,c>>24,c>>16&255,c>>8&255,c&255])))}static esds(e){let t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))}static audioStsd(e){let t=e.samplerate;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,t&255,0,0])}static mp4a(e){return i.box(i.types.mp4a,i.audioStsd(e),i.box(i.types.esds,i.esds(e)))}static mp3(e){return i.box(i.types[".mp3"],i.audioStsd(e))}static ac3(e){return i.box(i.types["ac-3"],i.audioStsd(e),i.box(i.types.dac3,e.config))}static stsd(e){return e.type==="audio"?e.segmentCodec==="mp3"&&e.codec==="mp3"?i.box(i.types.stsd,i.STSD,i.mp3(e)):e.segmentCodec==="ac3"?i.box(i.types.stsd,i.STSD,i.ac3(e)):i.box(i.types.stsd,i.STSD,i.mp4a(e)):i.box(i.types.stsd,i.STSD,i.avc1(e))}static tkhd(e){let t=e.id,r=e.duration*e.timescale,s=e.width,n=e.height,a=Math.floor(r/(Cr+1)),o=Math.floor(r%(Cr+1));return i.box(i.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,0,0,0,0,a>>24,a>>16&255,a>>8&255,a&255,o>>24,o>>16&255,o>>8&255,o&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,s>>8&255,s&255,0,0,n>>8&255,n&255,0,0]))}static traf(e,t){let r=i.sdtp(e),s=e.id,n=Math.floor(t/(Cr+1)),a=Math.floor(t%(Cr+1));return i.box(i.types.traf,i.box(i.types.tfhd,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,s&255])),i.box(i.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,n&255,a>>24,a>>16&255,a>>8&255,a&255])),i.trun(e,r.length+16+20+8+16+8+8),r)}static trak(e){return e.duration=e.duration||4294967295,i.box(i.types.trak,i.tkhd(e),i.mdia(e))}static trex(e){let t=e.id;return i.box(i.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){let r=e.samples||[],s=r.length,n=12+16*s,a=new Uint8Array(n),o,l,d,u,c,h;for(t+=8+n,a.set([e.type==="video"?1:0,0,15,1,s>>>24&255,s>>>16&255,s>>>8&255,s&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0),o=0;o<s;o++)l=r[o],d=l.duration,u=l.size,c=l.flags,h=l.cts,a.set([d>>>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 Jt(i.FTYP,t)}};rt.types=void 0;rt.HDLR_TYPES=void 0;rt.STTS=void 0;rt.STSC=void 0;rt.STCO=void 0;rt.STSZ=void 0;rt.VMHD=void 0;rt.SMHD=void 0;rt.STSD=void 0;rt.FTYP=void 0;rt.DINF=void 0;var b_=9e4;function jg(i,e,t=1,r=!1){let s=i*e*t;return r?Math.round(s):s}function JR(i,e,t=1,r=!1){return jg(i,e,1/t,r)}function ro(i,e=!1){return jg(i,1e3,1/b_,e)}function ew(i,e=1){return jg(i,b_,1/e)}var tw=10*1e3,_T=1024,iw=1152,rw=1536,$n=null,Sp=null,Kn=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,$n===null){let a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);$n=a?parseInt(a[1]):0}if(Sp===null){let n=navigator.userAgent.match(/Safari\/(\d+)/i);Sp=n?parseInt(n[1]):0}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(e){I.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}resetNextTimestamp(){I.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){I.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,Zt(s,n.pts)):a>0?s:n.pts},e[0].pts);return t&&I.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,T=t.pid>-1,y=t.samples.length,S=e.samples.length>0,A=o&&y>0||y>1;if((!E||S)&&(!T||A)||this.ISGenerated||o){if(this.ISGenerated){var x,w,P,k;let z=this.videoTrackConfig;z&&(t.width!==z.width||t.height!==z.height||((x=t.pixelRatio)==null?void 0:x[0])!==((w=z.pixelRatio)==null?void 0:w[0])||((P=t.pixelRatio)==null?void 0:P[1])!==((k=z.pixelRatio)==null?void 0:k[1]))&&this.resetInitSegment()}else c=this.generateIS(e,t,n,a);let D=this.isVideoContiguous,U=-1,F;if(A&&(U=sw(t.samples),!D&&this.config.forceKeyFrameOnDiscontinuity))if(m=!0,U>0){I.warn(`[mp4-remuxer]: Dropped ${U} out of ${y} video samples due to a missing keyframe`);let z=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(U),t.dropped+=U,g+=(t.samples[0].pts-z)/t.inputTimeScale,F=g}else U===-1&&(I.warn(`[mp4-remuxer]: No keyframe found out of ${y} video samples`),m=!1);if(this.ISGenerated){if(S&&A){let z=this.getVideoStartPts(t.samples),K=(Zt(e.samples[0].pts,z)-z)/t.inputTimeScale;p+=Math.max(0,K),g+=Math.max(0,-K)}if(S){if(e.samplerate||(I.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),c=this.generateIS(e,t,n,a)),u=this.remuxAudio(e,p,this.isAudioContiguous,a,T||A||l===J.AUDIO?g:void 0),A){let z=u?u.endPTS-u.startPTS:0;t.inputTimeScale||(I.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),c=this.generateIS(e,t,n,a)),d=this.remuxVideo(t,g,D,z)}}else A&&(d=this.remuxVideo(t,g,D,0));d&&(d.firstKeyFrame=U,d.independent=U!==-1,d.firstKeyFramePTS=F)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(f=y_(r,n,this._initPTS,this._initDTS)),s.samples.length&&(h=T_(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):rt.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:rt.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,Zt(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-Zt(a[0].dts,a[0].pts);$n&&u!==null&&Math.abs(W-G-u)<15e3?r=!0:u=W-G}let T=d.baseTime*n/d.timescale;for(let W=0;W<l;W++){let G=a[W];G.pts=Zt(G.pts-T,u),G.dts=Zt(G.dts-T,u),G.dts<a[W>0?W-1:W].dts&&(E=!0)}E&&a.sort(function(W,G){let ne=W.dts-G.dts,Q=W.pts-G.pts;return ne||Q}),f=a[0].dts,m=a[a.length-1].dts;let y=m-f,S=y?Math.round(y/(l-1)):h||e.inputTimeScale/30;if(r){let W=f-u,G=W>S,ne=W<-1;if((G||ne)&&(G?I.warn(`AVC: ${ro(W,!0)} ms (${W}dts) hole between fragments detected at ${t.toFixed(3)}`):I.warn(`AVC: ${ro(-W,!0)} ms (${W}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!ne||u>=a[0].pts||$n)){f=u;let Q=a[0].pts-W;if(G)a[0].dts=f,a[0].pts=Q;else for(let me=0;me<a.length&&!(a[me].dts>Q);me++)a[me].dts-=W,a[me].pts-=W;I.log(`Video: Initial PTS/DTS adjusted: ${ro(Q,!0)}/${ro(f,!0)}, delta: ${ro(W,!0)} ms`)}}f=Math.max(0,f);let A=0,L=0,x=f;for(let W=0;W<l;W++){let G=a[W],ne=G.units,Q=ne.length,me=0;for(let Pe=0;Pe<Q;Pe++)me+=ne[Pe].data.length;L+=me,A+=Q,G.length=me,G.dts<x?(G.dts=x,x+=S/4|0||1):x=G.dts,p=Math.min(G.pts,p),g=Math.max(G.pts,g)}m=a[l-1].dts;let w=L+4*A+8,P;try{P=new Uint8Array(w)}catch(W){this.observer.emit(v.ERROR,v.ERROR,{type:ie.MUX_ERROR,details:C.REMUX_ALLOC_ERROR,fatal:!1,error:W,bytes:w,reason:`fail allocating video mdat ${w}`});return}let k=new DataView(P.buffer);k.setUint32(0,w),P.set(rt.types.mdat,4);let D=!1,U=Number.POSITIVE_INFINITY,F=Number.POSITIVE_INFINITY,z=Number.NEGATIVE_INFINITY,j=Number.NEGATIVE_INFINITY;for(let W=0;W<l;W++){let G=a[W],ne=G.units,Q=0;for(let $e=0,qe=ne.length;$e<qe;$e++){let kt=ne[$e],vr=kt.data,rn=kt.data.byteLength;k.setUint32(c,rn),c+=4,P.set(vr,c),c+=rn,Q+=4+rn}let me;if(W<l-1)h=a[W+1].dts-G.dts,me=a[W+1].pts-G.pts;else{let $e=this.config,qe=W>0?G.dts-a[W-1].dts:S;if(me=W>0?G.pts-a[W-1].pts:S,$e.stretchShortVideoTrack&&this.nextAudioPts!==null){let kt=Math.floor($e.maxBufferHole*n),vr=(s?p+s*n:this.nextAudioPts)-G.pts;vr>kt?(h=vr-qe,h<0?h=qe:D=!0,I.log(`[mp4-remuxer]: It is approximately ${vr/90} ms to the next segment; using duration ${h/90} ms for the last video frame.`)):h=qe}else h=qe}let Pe=Math.round(G.pts-G.dts);U=Math.min(U,h),z=Math.max(z,h),F=Math.min(F,me),j=Math.max(j,me),o.push(new ac(G.key,h,Q,Pe))}if(o.length){if($n){if($n<70){let W=o[0].flags;W.dependsOn=2,W.isNonSync=0}}else if(Sp&&j-F<z-U&&S/z<.025&&o[0].cts===0){I.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let W=f;for(let G=0,ne=o.length;G<ne;G++){let Q=W+o[G].duration,me=W+o[G].cts;if(G<ne-1){let Pe=Q+o[G+1].cts;o[G].duration=Pe-me}else o[G].duration=G?o[G-1].duration:S;o[G].cts=0,W=Q}}}h=D||!h?S:h,this.nextAvcDts=u=m+h,this.videoSampleDuration=h,this.isVideoContiguous=!0;let K=rt.moof(e.sequenceNumber++,f,Je({},e,{samples:o})),se="video",oe={data1:K,data2:P,startPTS:p/n,endPTS:(g+h)/n,startDTS:f/n,endDTS:u/n,type:se,hasAudio:!1,hasVideo:!0,nb:o.length,dropped:e.dropped};return e.samples=[],e.dropped=0,oe}getSamplesPerFrame(e){switch(e.segmentCodec){case"mp3":return iw;case"ac3":return rw;default:return _T}}remuxAudio(e,t,r,s,n){let a=e.inputTimeScale,o=e.samplerate?e.samplerate:a,l=a/o,d=this.getSamplesPerFrame(e),u=d*l,c=this._initPTS,h=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,f=[],m=n!==void 0,p=e.samples,g=h?0:8,E=this.nextAudioPts||-1,T=t*a,y=c.baseTime*a/c.timescale;if(this.isAudioContiguous=r=r||p.length&&E>0&&(s&&Math.abs(T-E)<9e3||Math.abs(Zt(p[0].pts-y,T)-E)<20*u),p.forEach(function(K){K.pts=Zt(K.pts-y,T)}),!r||E<0){if(p=p.filter(K=>K.pts>=0),!p.length)return;n===0?E=0:s&&!m?E=Math.max(0,T):E=p[0].pts}if(e.segmentCodec==="aac"){let K=this.config.maxAudioFramesDrift;for(let se=0,oe=E;se<p.length;se++){let W=p[se],G=W.pts,ne=G-oe,Q=Math.abs(1e3*ne/a);if(ne<=-K*u&&m)se===0&&(I.warn(`Audio frame @ ${(G/a).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*ne/a)} ms.`),this.nextAudioPts=E=oe=G);else if(ne>=K*u&&Q<tw&&m){let me=Math.round(ne/u);oe=G-me*u,oe<0&&(me--,oe+=u),se===0&&(this.nextAudioPts=E=oe),I.warn(`[mp4-remuxer]: Injecting ${me} audio frame @ ${(oe/a).toFixed(3)}s due to ${Math.round(1e3*ne/a)} ms gap.`);for(let Pe=0;Pe<me;Pe++){let $e=Math.max(oe,0),qe=nc.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);qe||(I.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),qe=W.unit.subarray()),p.splice(se,0,{unit:qe,pts:$e}),oe+=u,se++}}W.pts=oe,oe+=u}}let S=null,A=null,L,x=0,w=p.length;for(;w--;)x+=p[w].unit.byteLength;for(let K=0,se=p.length;K<se;K++){let oe=p[K],W=oe.unit,G=oe.pts;if(A!==null){let Q=f[K-1];Q.duration=Math.round((G-A)/l)}else if(r&&e.segmentCodec==="aac"&&(G=E),S=G,x>0){x+=g;try{L=new Uint8Array(x)}catch(Q){this.observer.emit(v.ERROR,v.ERROR,{type:ie.MUX_ERROR,details:C.REMUX_ALLOC_ERROR,fatal:!1,error:Q,bytes:x,reason:`fail allocating audio mdat ${x}`});return}h||(new DataView(L.buffer).setUint32(0,x),L.set(rt.types.mdat,4))}else return;L.set(W,g);let ne=W.byteLength;g+=ne,f.push(new ac(!0,d,ne,0)),A=G}let P=f.length;if(!P)return;let k=f[f.length-1];this.nextAudioPts=E=A+l*k.duration;let D=h?new Uint8Array(0):rt.moof(e.sequenceNumber++,S/l,Je({},e,{samples:f}));e.samples=[];let U=S/a,F=E/a,j={data1:D,data2:L,startPTS:U,endPTS:F,startDTS:U,endDTS:F,type:"audio",hasAudio:!0,hasVideo:!1,nb:P};return this.isAudioContiguous=!0,j}remuxEmptyAudio(e,t,r,s){let n=e.inputTimeScale,a=e.samplerate?e.samplerate:n,o=n/a,l=this.nextAudioPts,d=this._initDTS,u=d.baseTime*9e4/d.timescale,c=(l!==null?l:s.startDTS*n)+u,h=s.endDTS*n+u,f=o*_T,m=Math.ceil((h-c)/f),p=nc.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(I.warn("[mp4-remuxer]: remux empty Audio"),!p){I.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}let g=[];for(let E=0;E<m;E++){let T=c+E*f;g.push({unit:p,pts:T,dts:T})}return e.samples=g,this.remuxAudio(e,t,r,!1)}};function Zt(i,e){let t;if(e===null)return i;for(e<i?t=-8589934592:t=8589934592;Math.abs(i-e)>4294967296;)i+=t;return i}function sw(i){for(let e=0;e<i.length;e++)if(i[e].key)return e;return-1}function y_(i,e,t,r){let s=i.samples.length;if(!s)return;let n=i.inputTimeScale;for(let o=0;o<s;o++){let l=i.samples[o];l.pts=Zt(l.pts-t.baseTime*n/t.timescale,e*n)/n,l.dts=Zt(l.dts-r.baseTime*n/r.timescale,e*n)/n}let a=i.samples;return i.samples=[],{samples:a}}function T_(i,e,t){let r=i.samples.length;if(!r)return;let s=i.inputTimeScale;for(let a=0;a<r;a++){let o=i.samples[a];o.pts=Zt(o.pts-t.baseTime*s/t.timescale,e*s)/s}i.samples.sort((a,o)=>a.pts-o.pts);let n=i.samples;return i.samples=[],{samples:n}}var ac=class{constructor(e,t,r,s){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=r,this.cts=s,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:e?0:1}}},ug=class{constructor(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}destroy(){}resetTimeStamp(e){this.initPTS=e,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(e,t,r,s){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(CI(e,s)),this.emitInitSegment=!0}generateInitSegment(e){let{audioCodec:t,videoCodec:r}=this;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}let s=this.initData=YT(e);s.audio&&(t=AT(s.audio,ke.AUDIO)),s.video&&(r=AT(s.video,ke.VIDEO));let n={};s.audio&&s.video?n.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:s.audio?n.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:s.video?n.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:I.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n}remux(e,t,r,s,n,a){var o,l;let{initPTS:d,lastEndTime:u}=this,c={audio:void 0,video:void 0,text:s,id3:r,initSegment:void 0};q(u)||(u=this.lastEndTime=n||0);let h=t.samples;if(!(h!=null&&h.length))return c;let f={initPTS:void 0,timescale:1},m=this.initData;if((o=m)!=null&&o.length||(this.generateInitSegment(h),m=this.initData),!((l=m)!=null&&l.length))return I.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),c;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1);let p=MI(h,m),g=DI(m,h),E=g===null?n:g;(nw(d,E,n,p)||f.timescale!==d.timescale&&a)&&(f.initPTS=E-n,d&&d.timescale===1&&I.warn(`Adjusting initPTS by ${f.initPTS-d.baseTime}`),this.initPTS=d={baseTime:f.initPTS,timescale:1});let T=e?E-d.baseTime/d.timescale:u,y=T+p;OI(m,h,d.baseTime/d.timescale),p>0?this.lastEndTime=y:(I.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());let S=!!m.audio,A=!!m.video,L="";S&&(L+="audio"),A&&(L+="video");let x={data1:h,startPTS:T,startDTS:T,endPTS:y,endDTS:y,type:L,hasAudio:S,hasVideo:A,nb:1,dropped:0};return c.audio=x.type==="audio"?x:void 0,c.video=x.type!=="audio"?x:void 0,c.initSegment=f,c.id3=y_(r,n,d,d),s.samples.length&&(c.text=T_(s,n,d)),c}};function nw(i,e,t,r){if(i===null)return!0;let s=Math.max(r,1),n=e-i.baseTime/i.timescale;return Math.abs(n-t)>s}function AT(i,e){let t=i==null?void 0:i.codec;if(t&&t.length>4)return t;if(e===ke.AUDIO){if(t==="ec-3"||t==="ac-3"||t==="alac")return t;if(t==="fLaC"||t==="Opus")return zu(t,!1);let r="mp4a.40.5";return I.info(`Parsed audio codec "${t}" or audio object type not handled. Using "${r}"`),r}return I.warn(`Unhandled video codec "${t}"`),t==="hvc1"||t==="hev1"?"hvc1.1.6.L120.90":t==="av01"?"av01.0.04M.08":"avc1.42e01e"}var cr;try{cr=self.performance.now.bind(self.performance)}catch{I.debug("Unable to use Performance API on this environment"),cr=qn==null?void 0:qn.Date.now}var Bu=[{demux:ig,remux:ug},{demux:og,remux:Kn},{demux:tg,remux:Kn},{demux:dg,remux:Kn}];Bu.splice(2,0,{demux:rg,remux:Kn});var oc=class{constructor(e,t,r,s,n){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=r,this.vendor=s,this.id=n}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,r,s){let n=r.transmuxing;n.executeStart=cr();let a=new Uint8Array(e),{currentTransmuxState:o,transmuxConfig:l}=this;s&&(this.currentTransmuxState=s);let{contiguous:d,discontinuity:u,trackSwitch:c,accurateTimeOffset:h,timeOffset:f,initSegmentChange:m}=s||o,{audioCodec:p,videoCodec:g,defaultInitPts:E,duration:T,initSegmentData:y}=l,S=aw(a,t);if(S&&S.method==="AES-128"){let w=this.getDecrypter();if(w.isSync()){let P=w.softwareDecrypt(a,S.key.buffer,S.iv.buffer);if(r.part>-1&&(P=w.flush()),!P)return n.executeEnd=cr(),xp(r);a=new Uint8Array(P)}else return this.decryptionPromise=w.webCryptoDecrypt(a,S.key.buffer,S.iv.buffer).then(P=>{let k=this.push(P,null,r);return this.decryptionPromise=null,k}),this.decryptionPromise}let A=this.needsProbing(u,c);if(A){let w=this.configureTransmuxer(a);if(w)return I.warn(`[transmuxer] ${w.message}`),this.observer.emit(v.ERROR,v.ERROR,{type:ie.MEDIA_ERROR,details:C.FRAG_PARSING_ERROR,fatal:!1,error:w,reason:w.message}),n.executeEnd=cr(),xp(r)}(u||c||m||A)&&this.resetInitSegment(y,p,g,T,t),(u||m||A)&&this.resetInitialTimestamp(E),d||this.resetContiguity();let L=this.transmux(a,S,f,h,r),x=this.currentTransmuxState;return x.contiguous=!0,x.discontinuity=!1,x.trackSwitch=!1,n.executeEnd=cr(),L}flush(e){let t=e.transmuxing;t.executeStart=cr();let{decrypter:r,currentTransmuxState:s,decryptionPromise:n}=this;if(n)return n.then(()=>this.flush(e));let a=[],{timeOffset:o}=s;if(r){let c=r.flush();c&&a.push(this.push(c,null,e))}let{demuxer:l,remuxer:d}=this;if(!l||!d)return t.executeEnd=cr(),[xp(e)];let u=l.flush(o);return $u(u)?u.then(c=>(this.flushRemux(a,c,e),a)):(this.flushRemux(a,u,e),a)}flushRemux(e,t,r){let{audioTrack:s,videoTrack:n,id3Track:a,textTrack:o}=t,{accurateTimeOffset:l,timeOffset:d}=this.currentTransmuxState;I.log(`[transmuxer.ts]: Flushed fragment ${r.sn}${r.part>-1?" p: "+r.part:""} of level ${r.level}`);let u=this.remuxer.remux(s,n,a,o,d,l,!0,this.id);e.push({remuxResult:u,chunkMeta:r}),r.transmuxing.executeEnd=cr()}resetInitialTimestamp(e){let{demuxer:t,remuxer:r}=this;!t||!r||(t.resetTimeStamp(e),r.resetTimeStamp(e))}resetContiguity(){let{demuxer:e,remuxer:t}=this;!e||!t||(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,r,s,n){let{demuxer:a,remuxer:o}=this;!a||!o||(a.resetInitSegment(e,t,r,s),o.resetInitSegment(e,t,r,n))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,r,s,n){let a;return t&&t.method==="SAMPLE-AES"?a=this.transmuxSampleAes(e,t,r,s,n):a=this.transmuxUnencrypted(e,r,s,n),a}transmuxUnencrypted(e,t,r,s){let{audioTrack:n,videoTrack:a,id3Track:o,textTrack:l}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(n,a,o,l,t,r,!1,this.id),chunkMeta:s}}transmuxSampleAes(e,t,r,s,n){return this.demuxer.demuxSampleAes(e,t,r).then(a=>({remuxResult:this.remuxer.remux(a.audioTrack,a.videoTrack,a.id3Track,a.textTrack,r,s,!1,this.id),chunkMeta:n}))}configureTransmuxer(e){let{config:t,observer:r,typeSupported:s,vendor:n}=this,a;for(let h=0,f=Bu.length;h<f;h++){var o;if((o=Bu[h].demux)!=null&&o.probe(e)){a=Bu[h];break}}if(!a)return new Error("Failed to find demuxer by probing fragment data");let l=this.demuxer,d=this.remuxer,u=a.remux,c=a.demux;(!d||!(d instanceof u))&&(this.remuxer=new u(r,t,s,n)),(!l||!(l instanceof c))&&(this.demuxer=new c(r,t,s),this.probe=c.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new fo(this.config)),e}};function aw(i,e){let t=null;return i.byteLength>0&&(e==null?void 0:e.key)!=null&&e.iv!==null&&e.method!=null&&(t=e),t}var xp=i=>({remuxResult:{},chunkMeta:i});function $u(i){return"then"in i&&i.then instanceof Function}var cg=class{constructor(e,t,r,s,n){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=r,this.duration=s,this.defaultInitPts=n||null}},hg=class{constructor(e,t,r,s,n,a){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=r,this.trackSwitch=s,this.timeOffset=n,this.initSegmentChange=a}},__={exports:{}};(function(i){var e=Object.prototype.hasOwnProperty,t="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(t=!1));function s(l,d,u){this.fn=l,this.context=d,this.once=u||!1}function n(l,d,u,c,h){if(typeof u!="function")throw new TypeError("The listener must be a function");var f=new s(u,c||l,h),m=t?t+d:d;return l._events[m]?l._events[m].fn?l._events[m]=[l._events[m],f]:l._events[m].push(f):(l._events[m]=f,l._eventsCount++),l}function a(l,d){--l._eventsCount===0?l._events=new r:delete l._events[d]}function o(){this._events=new r,this._eventsCount=0}o.prototype.eventNames=function(){var d=[],u,c;if(this._eventsCount===0)return d;for(c in u=this._events)e.call(u,c)&&d.push(t?c.slice(1):c);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(u)):d},o.prototype.listeners=function(d){var u=t?t+d:d,c=this._events[u];if(!c)return[];if(c.fn)return[c.fn];for(var h=0,f=c.length,m=new Array(f);h<f;h++)m[h]=c[h].fn;return m},o.prototype.listenerCount=function(d){var u=t?t+d:d,c=this._events[u];return c?c.fn?1:c.length:0},o.prototype.emit=function(d,u,c,h,f,m){var p=t?t+d:d;if(!this._events[p])return!1;var g=this._events[p],E=arguments.length,T,y;if(g.fn){switch(g.once&&this.removeListener(d,g.fn,void 0,!0),E){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,u),!0;case 3:return g.fn.call(g.context,u,c),!0;case 4:return g.fn.call(g.context,u,c,h),!0;case 5:return g.fn.call(g.context,u,c,h,f),!0;case 6:return g.fn.call(g.context,u,c,h,f,m),!0}for(y=1,T=new Array(E-1);y<E;y++)T[y-1]=arguments[y];g.fn.apply(g.context,T)}else{var S=g.length,A;for(y=0;y<S;y++)switch(g[y].once&&this.removeListener(d,g[y].fn,void 0,!0),E){case 1:g[y].fn.call(g[y].context);break;case 2:g[y].fn.call(g[y].context,u);break;case 3:g[y].fn.call(g[y].context,u,c);break;case 4:g[y].fn.call(g[y].context,u,c,h);break;default:if(!T)for(A=1,T=new Array(E-1);A<E;A++)T[A-1]=arguments[A];g[y].fn.apply(g[y].context,T)}}return!0},o.prototype.on=function(d,u,c){return n(this,d,u,c,!1)},o.prototype.once=function(d,u,c){return n(this,d,u,c,!0)},o.prototype.removeListener=function(d,u,c,h){var f=t?t+d:d;if(!this._events[f])return this;if(!u)return a(this,f),this;var m=this._events[f];if(m.fn)m.fn===u&&(!h||m.once)&&(!c||m.context===c)&&a(this,f);else{for(var p=0,g=[],E=m.length;p<E;p++)(m[p].fn!==u||h&&!m[p].once||c&&m[p].context!==c)&&g.push(m[p]);g.length?this._events[f]=g.length===1?g[0]:g:a(this,f)}return this},o.prototype.removeAllListeners=function(d){var u;return d?(u=t?t+d:d,this._events[u]&&a(this,u)):(this._events=new r,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=t,o.EventEmitter=o,i.exports=o})(__);var ow=__.exports,Xg=eI(ow),lc=class{constructor(e,t,r,s){this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;let n=e.config;this.hls=e,this.id=t,this.useWorker=!!n.enableWorker,this.onTransmuxComplete=r,this.onFlush=s;let a=(d,u)=>{u=u||{},u.frag=this.frag,u.id=this.id,d===v.ERROR&&(this.error=u.error),this.hls.trigger(d,u)};this.observer=new Xg,this.observer.on(v.FRAG_DECRYPTED,a),this.observer.on(v.ERROR,a);let o=Is(n.preferManagedMediaSource)||{isTypeSupported:()=>!1},l={mpeg:o.isTypeSupported("audio/mpeg"),mp3:o.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:o.isTypeSupported('audio/mp4; codecs="ac-3"')};if(this.useWorker&&typeof Worker!="undefined"&&(n.workerPath||NR())){try{n.workerPath?(I.log(`loading Web Worker ${n.workerPath} for "${t}"`),this.workerContext=FR(n.workerPath)):(I.log(`injecting Web Worker for "${t}"`),this.workerContext=UR()),this.onwmsg=c=>this.onWorkerMessage(c);let{worker:u}=this.workerContext;u.addEventListener("message",this.onwmsg),u.onerror=c=>{let h=new Error(`${c.message} (${c.filename}:${c.lineno})`);n.enableWorker=!1,I.warn(`Error in "${t}" Web Worker, fallback to inline`),this.hls.trigger(v.ERROR,{type:ie.OTHER_ERROR,details:C.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:h})},u.postMessage({cmd:"init",typeSupported:l,vendor:"",id:t,config:JSON.stringify(n)})}catch(u){I.warn(`Error setting up "${t}" Web Worker, fallback to inline`,u),this.resetWorker(),this.error=null,this.transmuxer=new oc(this.observer,l,n,"",t)}return}this.transmuxer=new oc(this.observer,l,n,"",t)}resetWorker(){if(this.workerContext){let{worker:e,objectURL:t}=this.workerContext;t&&self.URL.revokeObjectURL(t),e.removeEventListener("message",this.onwmsg),e.onerror=null,e.terminate(),this.workerContext=null}}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{let t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}let e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(e,t,r,s,n,a,o,l,d,u){var c,h;d.transmuxing.start=self.performance.now();let{transmuxer:f}=this,m=a?a.start:n.start,p=n.decryptdata,g=this.frag,E=!(g&&n.cc===g.cc),T=!(g&&d.level===g.level),y=g?d.sn-g.sn:-1,S=this.part?d.part-this.part.index:-1,A=y===0&&d.id>1&&d.id===(g==null?void 0:g.stats.chunkCount),L=!T&&(y===1||y===0&&(S===1||A&&S<=0)),x=self.performance.now();(T||y||n.stats.parsing.start===0)&&(n.stats.parsing.start=x),a&&(S||!L)&&(a.stats.parsing.start=x);let w=!(g&&((c=n.initSegment)==null?void 0:c.url)===((h=g.initSegment)==null?void 0:h.url)),P=new hg(E,L,l,T,m,w);if(!L||E||w){I.log(`[transmuxer-interface, ${n.type}]: Starting new transmux session for sn: ${d.sn} p: ${d.part} level: ${d.level} id: ${d.id}
1586
1586
  discontinuity: ${E}
1587
1587
  trackSwitch: ${T}
1588
1588
  contiguous: ${L}
1589
1589
  accurateTimeOffset: ${l}
1590
1590
  timeOffset: ${m}
1591
- initSegmentChange: ${w}`);let k=new og(r,s,t,o,u);this.configureTransmuxer(k)}if(this.frag=n,this.part=a,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:p,chunkMeta:d,state:M},e instanceof ArrayBuffer?[e]:[]);else if(f){let k=f.push(e,p,d,M);Bu(k)?(f.async=!0,k.then(D=>{this.handleTransmuxComplete(D)}).catch(D=>{this.transmuxerError(D,d,"transmuxer-interface push error")})):(f.async=!1,this.handleTransmuxComplete(k))}}flush(e){e.transmuxing.start=self.performance.now();let{transmuxer:t}=this;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(t){let r=t.flush(e);Bu(r)||t.async?(Bu(r)||(r=Promise.resolve(r)),r.then(n=>{this.handleFlushResult(n,e)}).catch(n=>{this.transmuxerError(n,e,"transmuxer-interface flush error")})):this.handleFlushResult(r,e)}}transmuxerError(e,t,r){this.hls&&(this.error=e,this.hls.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:C.FRAG_PARSING_ERROR,chunkMeta:t,fatal:!1,error:e,err:e,reason:r}))}handleFlushResult(e,t){e.forEach(r=>{this.handleTransmuxComplete(r)}),this.onFlush(t)}onWorkerMessage(e){let t=e.data,r=this.hls;switch(t.event){case"init":{var s;let n=(s=this.workerContext)==null?void 0:s.objectURL;n&&self.URL.revokeObjectURL(n);break}case"transmuxComplete":{this.handleTransmuxComplete(t.data);break}case"flush":{this.onFlush(t.data);break}case"workerLog":I[t.data.logType]&&I[t.data.logType](t.data.message);break;default:{t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,r.trigger(t.event,t.data);break}}}configureTransmuxer(e){let{transmuxer:t}=this;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}};function S_(i,e){if(i.length!==e.length)return!1;for(let t=0;t<i.length;t++)if(!Yn(i[t].attrs,e[t].attrs))return!1;return!0}function Yn(i,e,t){let r=i["STABLE-RENDITION-ID"];return r&&!t?r===e["STABLE-RENDITION-ID"]:!(t||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(s=>i[s]!==e[s])}function dg(i,e){return e.label.toLowerCase()===i.name.toLowerCase()&&(!e.language||e.language.toLowerCase()===(i.lang||"").toLowerCase())}var _T=100,ug=class extends mo{constructor(e,t,r){super(e,t,r,"[audio-stream-controller]",te.AUDIO),this.videoBuffer=null,this.videoTrackCC=-1,this.waitingVideoCC=-1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.flushing=!1,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null}_registerListeners(){let{hls:e}=this;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(v.ERROR,this.onError,this),e.on(v.BUFFER_RESET,this.onBufferReset,this),e.on(v.BUFFER_CREATED,this.onBufferCreated,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(v.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(v.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){let{hls:e}=this;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(v.ERROR,this.onError,this),e.off(v.BUFFER_RESET,this.onBufferReset,this),e.off(v.BUFFER_CREATED,this.onBufferCreated,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(v.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(v.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(e,{frag:t,id:r,initPTS:s,timescale:n}){if(r==="main"){let a=t.cc;this.initPTS[t.cc]={baseTime:s,timescale:n},this.log(`InitPTS for cc: ${a} found from main: ${s}`),this.videoTrackCC=a,this.state===N.WAITING_INIT_PTS&&this.tick()}}startLoad(e){if(!this.levels){this.startPosition=e,this.state=N.STOPPED;return}let t=this.lastCurrentTime;this.stopLoad(),this.setInterval(_T),t>0&&e===-1?(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t,this.state=N.IDLE):(this.loadedmetadata=!1,this.state=N.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}doTick(){switch(this.state){case N.IDLE:this.doTickIdle();break;case N.WAITING_TRACK:{var e;let{levels:r,trackId:s}=this,n=r==null||(e=r[s])==null?void 0:e.details;if(n){if(this.waitForCdnTuneIn(n))break;this.state=N.WAITING_INIT_PTS}break}case N.FRAG_LOADING_WAITING_RETRY:{var t;let r=performance.now(),s=this.retryDate;if(!s||r>=s||(t=this.media)!=null&&t.seeking){let{levels:n,trackId:a}=this;this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded((n==null?void 0:n[a])||null),this.state=N.IDLE}break}case N.WAITING_INIT_PTS:{let r=this.waitingData;if(r){let{frag:s,part:n,cache:a,complete:o}=r;if(this.initPTS[s.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=N.FRAG_LOADING;let l=a.flush(),d={frag:s,part:n,payload:l,networkDetails:null};this._handleFragmentLoadProgress(d),o&&super._handleFragmentLoadComplete(d)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${s.cc}) cancelled because video is at cc ${this.videoTrackCC}`),this.clearWaitingFragment();else{let l=this.getLoadPosition(),d=Ue.bufferInfo(this.mediaBuffer,l,this.config.maxBufferHole);Hp(d.end,this.config.maxFragLookUpTolerance,s)<0&&(this.log(`Waiting fragment cc (${s.cc}) @ ${s.start} cancelled because another fragment at ${d.end} is needed`),this.clearWaitingFragment())}}else this.state=N.IDLE}}this.onTickEnd()}clearWaitingFragment(){let e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=N.IDLE)}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){let{media:e}=this;e!=null&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){let{hls:e,levels:t,media:r,trackId:s}=this,n=e.config;if(!r&&(this.startFragRequested||!n.startFragPrefetch)||!(t!=null&&t[s]))return;let a=t[s],o=a.details;if(!o||o.live&&this.levelLastLoaded!==a||this.waitForCdnTuneIn(o)){this.state=N.WAITING_TRACK;return}let l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,ke.AUDIO,te.AUDIO));let d=this.getFwdBufferInfo(l,te.AUDIO);if(d===null)return;let{bufferedTrack:u,switchingTrack:c}=this;if(!c&&this._streamEnded(d,o)){e.trigger(v.BUFFER_EOS,{type:"audio"}),this.state=N.ENDED;return}let h=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,te.MAIN),f=d.len,m=this.getMaxBufferLength(h==null?void 0:h.len),p=o.fragments,g=p[0].start,E=this.flushing?this.getLoadPosition():d.end;if(c&&r){let _=this.getLoadPosition();u&&!Yn(c.attrs,u.attrs)&&(E=_),o.PTSKnown&&_<g&&(d.end>g||d.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),r.currentTime=g+.05)}if(f>=m&&!c&&E<p[p.length-1].start)return;let T=this.getNextFragment(E,o),y=!1;if(T&&this.isLoopLoading(T,E)&&(y=!!T.gap,T=this.getNextFragmentLoopLoading(T,o,d,te.MAIN,m)),!T){this.bufferFlushed=!0;return}let S=h&&T.start>h.end+o.targetduration;if(S||!(h!=null&&h.len)&&d.len){let _=this.getAppendedFrag(T.start,te.MAIN);if(_===null||(y||(y=!!_.gap||!!S&&h.len===0),S&&!y||y&&d.nextStart&&d.nextStart<_.end))return}this.loadFragment(T,a,E)}getMaxBufferLength(e){let t=super.getMaxBufferLength();return e?Math.min(Math.max(t,e),this.config.maxMaxBufferLength):t}onMediaDetaching(){this.videoBuffer=null,this.bufferFlushed=this.flushing=!1,super.onMediaDetaching()}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(r=>new Mr(r))}onAudioTrackSwitching(e,t){let r=!!t.url;this.trackId=t.id;let{fragCurrent:s}=this;s&&(s.abortRequests(),this.removeUnbufferedFrags(s.start)),this.resetLoadingState(),r?this.setInterval(_T):this.resetTransmuxer(),r?(this.switchingTrack=t,this.state=N.IDLE,this.flushAudioIfNeeded(t)):(this.switchingTrack=null,this.bufferedTrack=t,this.state=N.STOPPED),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=this.flushing=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1}onLevelLoaded(e,t){this.mainDetails=t.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(v.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(e,t){var r;if(this.mainDetails==null){this.cachedTrackLoadedData=t;return}let{levels:s}=this,{details:n,id:a}=t;if(!s){this.warn(`Audio tracks were reset while loading level ${a}`);return}this.log(`Audio track ${a} loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`);let o=s[a],l=0;if(n.live||(r=o.details)!=null&&r.live){this.checkLiveUpdate(n);let u=this.mainDetails;if(n.deltaUpdateFailed||!u)return;if(!o.details&&n.hasProgramDateTime&&u.hasProgramDateTime)Ju(n,u),l=n.fragments[0].start;else{var d;l=this.alignPlaylists(n,o.details,(d=this.levelLastLoaded)==null?void 0:d.details)}}o.details=n,this.levelLastLoaded=o,!this.startFragRequested&&(this.mainDetails||!n.live)&&this.setStartPosition(this.mainDetails||n,l),this.state===N.WAITING_TRACK&&!this.waitForCdnTuneIn(n)&&(this.state=N.IDLE),this.tick()}_handleFragmentLoadProgress(e){var t;let{frag:r,part:s,payload:n}=e,{config:a,trackId:o,levels:l}=this;if(!l){this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);return}let d=l[o];if(!d){this.warn("Audio track is undefined on fragment load progress");return}let u=d.details;if(!u){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(r.start);return}let c=a.defaultAudioCodec||d.audioCodec||"mp4a.40.2",h=this.transmuxer;h||(h=this.transmuxer=new ac(this.hls,te.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));let f=this.initPTS[r.cc],m=(t=r.initSegment)==null?void 0:t.data;if(f!==void 0){let g=s?s.index:-1,E=g!==-1,T=new ho(r.level,r.sn,r.stats.chunkCount,n.byteLength,g,E);h.push(n,m,c,"",r,s,u.totalduration,!1,T,f)}else{this.log(`Unknown video PTS for cc ${r.cc}, waiting for video PTS before demuxing audio frag ${r.sn} of [${u.startSN} ,${u.endSN}],track ${o}`);let{cache:p}=this.waitingData=this.waitingData||{frag:r,part:s,cache:new ec,complete:!1};p.push(new Uint8Array(n)),this.waitingVideoCC=this.videoTrackCC,this.state=N.WAITING_INIT_PTS}}_handleFragmentLoadComplete(e){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(e,t){let r=t.tracks.audio;r&&(this.mediaBuffer=r.buffer||null),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer||null)}onFragBuffered(e,t){let{frag:r,part:s}=t;if(r.type!==te.AUDIO){if(!this.loadedmetadata&&r.type===te.MAIN){let n=this.videoBuffer||this.media;n&&Ue.getBuffered(n).length&&(this.loadedmetadata=!0)}return}if(this.fragContextChanged(r)){this.warn(`Fragment ${r.sn}${s?" p: "+s.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if(r.sn!=="initSegment"){this.fragPrevious=r;let n=this.switchingTrack;n&&(this.bufferedTrack=n,this.switchingTrack=null,this.hls.trigger(v.AUDIO_TRACK_SWITCHED,ft({},n)))}this.fragBufferedComplete(r,s)}onError(e,t){var r;if(t.fatal){this.state=N.ERROR;return}switch(t.details){case C.FRAG_GAP:case C.FRAG_PARSING_ERROR:case C.FRAG_DECRYPT_ERROR:case C.FRAG_LOAD_ERROR:case C.FRAG_LOAD_TIMEOUT:case C.KEY_LOAD_ERROR:case C.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(te.AUDIO,t);break;case C.AUDIO_TRACK_LOAD_ERROR:case C.AUDIO_TRACK_LOAD_TIMEOUT:case C.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===N.WAITING_TRACK&&((r=t.context)==null?void 0:r.type)===ge.AUDIO_TRACK&&(this.state=N.IDLE);break;case C.BUFFER_APPEND_ERROR:case C.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="audio")return;if(t.details===C.BUFFER_APPEND_ERROR){this.resetLoadingState();return}this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case C.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onBufferFlushing(e,{type:t}){t!==ke.VIDEO&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==ke.VIDEO){this.flushing=!1,this.bufferFlushed=!0,this.state===N.ENDED&&(this.state=N.IDLE);let r=this.mediaBuffer||this.media;r&&(this.afterBufferFlushed(r,t,te.AUDIO),this.tick())}}_handleTransmuxComplete(e){var t;let r="audio",{hls:s}=this,{remuxResult:n,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}let{frag:l,part:d,level:u}=o,{details:c}=u,{audio:h,text:f,id3:m,initSegment:p}=n;if(this.fragContextChanged(l)||!c){this.fragmentTracker.removeFragment(l);return}if(this.state=N.PARSING,this.switchingTrack&&h&&this.completeAudioSwitch(this.switchingTrack),p!=null&&p.tracks){let g=l.initSegment||l;this._bufferInitSegment(u,p.tracks,g,a),s.trigger(v.FRAG_PARSING_INIT_SEGMENT,{frag:g,id:r,tracks:p.tracks})}if(h){let{startPTS:g,endPTS:E,startDTS:T,endDTS:y}=h;d&&(d.elementaryStreams[ke.AUDIO]={startPTS:g,endPTS:E,startDTS:T,endDTS:y}),l.setElementaryStreamInfo(ke.AUDIO,g,E,T,y),this.bufferFragmentData(h,l,d,a)}if(m!=null&&(t=m.samples)!=null&&t.length){let g=Je({id:r,frag:l,details:c},m);s.trigger(v.FRAG_PARSING_METADATA,g)}if(f){let g=Je({id:r,frag:l,details:c},f);s.trigger(v.FRAG_PARSING_USERDATA,g)}}_bufferInitSegment(e,t,r,s){if(this.state!==N.PARSING)return;t.video&&delete t.video;let n=t.audio;if(!n)return;n.id="audio";let a=e.audioCodec;this.log(`Init audio buffer, container:${n.container}, codecs[level/parsed]=[${a}/${n.codec}]`),a&&a.split(",").length===1&&(n.levelCodec=a),this.hls.trigger(v.BUFFER_CODECS,t);let o=n.initSegment;if(o!=null&&o.byteLength){let l={type:"audio",frag:r,part:null,chunkMeta:s,parent:r.type,data:o};this.hls.trigger(v.BUFFER_APPENDING,l)}this.tickImmediate()}loadFragment(e,t,r){let s=this.fragmentTracker.getState(e);if(this.fragCurrent=e,this.switchingTrack||s===ht.NOT_LOADED||s===ht.PARTIAL){var n;if(e.sn==="initSegment")this._loadInitSegment(e,t);else if((n=t.details)!=null&&n.live&&!this.initPTS[e.cc]){this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=N.WAITING_INIT_PTS;let a=this.mainDetails;a&&a.fragments[0].start!==t.details.fragments[0].start&&Ju(t.details,a)}else this.startFragRequested=!0,super.loadFragment(e,t,r)}else this.clearTrackerIfNeeded(e)}flushAudioIfNeeded(e){let{media:t,bufferedTrack:r}=this,s=r==null?void 0:r.attrs,n=e.attrs;t&&s&&(s.CHANNELS!==n.CHANNELS||r.name!==e.name||r.lang!==e.lang)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null)}completeAudioSwitch(e){let{hls:t}=this;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(v.AUDIO_TRACK_SWITCHED,ft({},e))}},cg=class extends co{constructor(e){super(e,"[audio-track-controller]"),this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){let{hls:e}=this;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.LEVEL_LOADING,this.onLevelLoading,this),e.on(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(v.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.LEVEL_LOADING,this.onLevelLoading,this),e.off(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(v.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){let{id:r,groupId:s,details:n}=t,a=this.tracksInGroup[r];if(!a||a.groupId!==s){this.warn(`Audio track with id:${r} and group:${s} not found in active group ${a==null?void 0:a.groupId}`);return}let o=a.details;a.details=t.details,this.log(`Audio track ${r} "${a.name}" lang:${a.lang} group:${s} loaded [${n.startSN}-${n.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){let t=this.hls.levels[e];if(!t)return;let r=t.audioGroups||null,s=this.groupIds,n=this.currentTrack;if(!r||(s==null?void 0:s.length)!==(r==null?void 0:r.length)||r!=null&&r.some(o=>(s==null?void 0:s.indexOf(o))===-1)){this.groupIds=r,this.trackId=-1,this.currentTrack=null;let o=this.tracks.filter(h=>!r||r.indexOf(h.groupId)!==-1);if(o.length)this.selectDefaultTrack&&!o.some(h=>h.default)&&(this.selectDefaultTrack=!1),o.forEach((h,f)=>{h.id=f});else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=o;let l=this.hls.config.audioPreference;if(!n&&l){let h=Xi(l,o,Nn);if(h>-1)n=o[h];else{let f=Xi(l,this.tracks);n=this.tracks[f]}}let d=this.findTrackId(n);d===-1&&n&&(d=this.findTrackId(null));let u={audioTracks:o};this.log(`Updating audio tracks, ${o.length} track(s) found in group(s): ${r==null?void 0:r.join(",")}`),this.hls.trigger(v.AUDIO_TRACKS_UPDATED,u);let c=this.trackId;if(d!==-1&&c===-1)this.setAudioTrack(d);else if(o.length&&c===-1){var a;let h=new Error(`No audio track selected for current audio group-ID(s): ${(a=this.groupIds)==null?void 0:a.join(",")} track count: ${o.length}`);this.warn(h.message),this.hls.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:C.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:h})}}else this.shouldReloadPlaylist(n)&&this.setAudioTrack(this.trackId)}onError(e,t){t.fatal||!t.context||t.context.type===ge.AUDIO_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&(this.requestScheduled=-1,this.checkRetry(t))}get allAudioTracks(){return this.tracks}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioOption(e){let t=this.hls;if(t.config.audioPreference=e,e){let r=this.allAudioTracks;if(this.selectDefaultTrack=!1,r.length){let s=this.currentTrack;if(s&&Wn(e,s,Nn))return s;let n=Xi(e,this.tracksInGroup,Nn);if(n>-1){let a=this.tracksInGroup[n];return this.setAudioTrack(n),a}else if(s){let a=t.loadLevel;a===-1&&(a=t.firstAutoLevel);let o=kR(e,t.levels,r,a,Nn);if(o===-1)return null;t.nextLoadLevel=o}if(e.channels||e.audioCodec){let a=Xi(e,r);if(a>-1)return r[a]}}}return null}setAudioTrack(e){let t=this.tracksInGroup;if(e<0||e>=t.length){this.warn(`Invalid audio track id: ${e}`);return}this.clearTimer(),this.selectDefaultTrack=!1;let r=this.currentTrack,s=t[e],n=s.details&&!s.details.live;if(e===this.trackId&&s===r&&n||(this.log(`Switching to audio-track ${e} "${s.name}" lang:${s.lang} group:${s.groupId} channels:${s.channels}`),this.trackId=e,this.currentTrack=s,this.hls.trigger(v.AUDIO_TRACK_SWITCHING,ft({},s)),n))return;let a=this.switchParams(s.url,r==null?void 0:r.details,s.details);this.loadPlaylist(a)}findTrackId(e){let t=this.tracksInGroup;for(let r=0;r<t.length;r++){let s=t[r];if(!(this.selectDefaultTrack&&!s.default)&&(!e||Wn(e,s,Nn)))return r}if(e){let{name:r,lang:s,assocLang:n,characteristics:a,audioCodec:o,channels:l}=e;for(let d=0;d<t.length;d++){let u=t[d];if(Wn({name:r,lang:s,assocLang:n,characteristics:a,audioCodec:o,channels:l},u,Nn))return d}for(let d=0;d<t.length;d++){let u=t[d];if(Yn(e.attrs,u.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return d}for(let d=0;d<t.length;d++){let u=t[d];if(Yn(e.attrs,u.attrs,["LANGUAGE"]))return d}}return-1}loadPlaylist(e){let t=this.currentTrack;if(this.shouldLoadPlaylist(t)&&t){super.loadPlaylist();let r=t.id,s=t.groupId,n=t.url;if(e)try{n=e.addDirectives(n)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}this.log(`loading audio-track playlist ${r} "${t.name}" lang:${t.lang} group:${s}`),this.clearTimer(),this.hls.trigger(v.AUDIO_TRACK_LOADING,{url:n,id:r,groupId:s,deliveryDirectives:e||null})}}},AT=500,hg=class extends mo{constructor(e,t,r){super(e,t,r,"[subtitle-stream-controller]",te.SUBTITLE),this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null}_registerListeners(){let{hls:e}=this;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.ERROR,this.onError,this),e.on(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(v.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(v.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){let{hls:e}=this;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.ERROR,this.onError,this),e.off(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(v.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(v.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(e){this.stopLoad(),this.state=N.IDLE,this.setInterval(AT),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){let{frag:r,success:s}=t;if(this.fragPrevious=r,this.state=N.IDLE,!s)return;let n=this.tracksBuffered[this.currentTrackId];if(!n)return;let a,o=r.start;for(let d=0;d<n.length;d++)if(o>=n[d].start&&o<=n[d].end){a=n[d];break}let l=r.start+r.duration;a?a.end=l:(a={start:o,end:l},n.push(a)),this.fragmentTracker.fragBuffered(r),this.fragBufferedComplete(r,null)}onBufferFlushing(e,t){let{startOffset:r,endOffset:s}=t;if(r===0&&s!==Number.POSITIVE_INFINITY){let n=s-1;if(n<=0)return;t.endOffsetSubtitles=Math.max(0,n),this.tracksBuffered.forEach(a=>{for(let o=0;o<a.length;){if(a[o].end<=n){a.shift();continue}else if(a[o].start<n)a[o].start=n;else break;o++}}),this.fragmentTracker.removeFragmentsInRange(r,n,te.SUBTITLE)}}onFragBuffered(e,t){if(!this.loadedmetadata&&t.frag.type===te.MAIN){var r;(r=this.media)!=null&&r.buffered.length&&(this.loadedmetadata=!0)}}onError(e,t){let r=t.frag;(r==null?void 0:r.type)===te.SUBTITLE&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==N.STOPPED&&(this.state=N.IDLE))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(this.levels&&S_(this.levels,t)){this.levels=t.map(r=>new Mr(r));return}this.tracksBuffered=[],this.levels=t.map(r=>{let s=new Mr(r);return this.tracksBuffered[s.id]=[],s}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,te.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null}onSubtitleTrackSwitch(e,t){var r;if(this.currentTrackId=t.id,!((r=this.levels)!=null&&r.length)||this.currentTrackId===-1){this.clearInterval();return}let s=this.levels[this.currentTrackId];s!=null&&s.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,s&&this.setInterval(AT)}onSubtitleTrackLoaded(e,t){var r;let{currentTrackId:s,levels:n}=this,{details:a,id:o}=t;if(!n){this.warn(`Subtitle tracks were reset while loading level ${o}`);return}let l=n[s];if(o>=n.length||o!==s||!l)return;this.log(`Subtitle track ${o} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""},duration:${a.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let d=0;if(a.live||(r=l.details)!=null&&r.live){let c=this.mainDetails;if(a.deltaUpdateFailed||!c)return;let h=c.fragments[0];if(!l.details)a.hasProgramDateTime&&c.hasProgramDateTime?(Ju(a,c),d=a.fragments[0].start):h&&(d=h.start,$p(a,d));else{var u;d=this.alignPlaylists(a,l.details,(u=this.levelLastLoaded)==null?void 0:u.details),d===0&&h&&(d=h.start,$p(a,d))}}l.details=a,this.levelLastLoaded=l,!this.startFragRequested&&(this.mainDetails||!a.live)&&this.setStartPosition(this.mainDetails||a,d),this.tick(),a.live&&!this.fragCurrent&&this.media&&this.state===N.IDLE&&(Zu(null,a.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),l.details=void 0))}_handleFragmentLoadComplete(e){let{frag:t,payload:r}=e,s=t.decryptdata,n=this.hls;if(!this.fragContextChanged(t)&&r&&r.byteLength>0&&s!=null&&s.key&&s.iv&&s.method==="AES-128"){let a=performance.now();this.decrypter.decrypt(new Uint8Array(r),s.key.buffer,s.iv.buffer).catch(o=>{throw n.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:C.FRAG_DECRYPT_ERROR,fatal:!1,error:o,reason:o.message,frag:t}),o}).then(o=>{let l=performance.now();n.trigger(v.FRAG_DECRYPTED,{frag:t,payload:o,stats:{tstart:a,tdecrypt:l}})}).catch(o=>{this.warn(`${o.name}: ${o.message}`),this.state=N.IDLE})}}doTick(){if(!this.media){this.state=N.IDLE;return}if(this.state===N.IDLE){let{currentTrackId:e,levels:t}=this,r=t==null?void 0:t[e];if(!r||!t.length||!r.details)return;let{config:s}=this,n=this.getLoadPosition(),a=Ue.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,s.maxBufferHole),{end:o,len:l}=a,d=this.getFwdBufferInfo(this.media,te.MAIN),u=r.details,c=this.getMaxBufferLength(d==null?void 0:d.len)+u.levelTargetDuration;if(l>c)return;let h=u.fragments,f=h.length,m=u.edge,p=null,g=this.fragPrevious;if(o<m){let E=s.maxFragLookUpTolerance,T=o>m-E?0:E;p=Zu(g,h,Math.max(h[0].start,o),T),!p&&g&&g.start<h[0].start&&(p=h[0])}else p=h[f-1];if(!p)return;if(p=this.mapToInitFragWhenRequired(p),p.sn!=="initSegment"){let E=p.sn-u.startSN,T=h[E-1];T&&T.cc===p.cc&&this.fragmentTracker.getState(T)===ht.NOT_LOADED&&(p=T)}this.fragmentTracker.getState(p)===ht.NOT_LOADED&&this.loadFragment(p,r,o)}}getMaxBufferLength(e){let t=super.getMaxBufferLength();return e?Math.max(t,e):t}loadFragment(e,t,r){this.fragCurrent=e,e.sn==="initSegment"?this._loadInitSegment(e,t):(this.startFragRequested=!0,super.loadFragment(e,t,r))}get mediaBufferTimeRanges(){return new fg(this.tracksBuffered[this.currentTrackId]||[])}},fg=class{constructor(e){this.buffered=void 0;let t=(r,s,n)=>{if(s=s>>>0,s>n-1)throw new DOMException(`Failed to execute '${r}' on 'TimeRanges': The index provided (${s}) is greater than the maximum bound (${n})`);return e[s][r]};this.buffered={get length(){return e.length},end(r){return t("end",r,e.length)},start(r){return t("start",r,e.length)}}}},mg=class extends co{constructor(e){super(e,"[subtitle-track-controller]"),this.media=null,this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.onTextTracksChanged=()=>{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let t=null,r=Ou(this.media.textTracks);for(let n=0;n<r.length;n++)if(r[n].mode==="hidden")t=r[n];else if(r[n].mode==="showing"){t=r[n];break}let s=this.findTrackForTextTrack(t);this.subtitleTrack!==s&&this.setSubtitleTrack(s)},this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}registerListeners(){let{hls:e}=this;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.LEVEL_LOADING,this.onLevelLoading,this),e.on(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(v.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.LEVEL_LOADING,this.onLevelLoading,this),e.off(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(v.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}pollTrackChange(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,e)}onMediaDetaching(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),Ou(this.media.textTracks).forEach(t=>{Hn(t)}),this.subtitleTrack=-1,this.media=null}onManifestLoading(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){let{id:r,groupId:s,details:n}=t,a=this.tracksInGroup[r];if(!a||a.groupId!==s){this.warn(`Subtitle track with id:${r} and group:${s} not found in active group ${a==null?void 0:a.groupId}`);return}let o=a.details;a.details=t.details,this.log(`Subtitle track ${r} "${a.name}" lang:${a.lang} group:${s} loaded [${n.startSN}-${n.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){let t=this.hls.levels[e];if(!t)return;let r=t.subtitleGroups||null,s=this.groupIds,n=this.currentTrack;if(!r||(s==null?void 0:s.length)!==(r==null?void 0:r.length)||r!=null&&r.some(a=>(s==null?void 0:s.indexOf(a))===-1)){this.groupIds=r,this.trackId=-1,this.currentTrack=null;let a=this.tracks.filter(u=>!r||r.indexOf(u.groupId)!==-1);if(a.length)this.selectDefaultTrack&&!a.some(u=>u.default)&&(this.selectDefaultTrack=!1),a.forEach((u,c)=>{u.id=c});else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=a;let o=this.hls.config.subtitlePreference;if(!n&&o){this.selectDefaultTrack=!1;let u=Xi(o,a);if(u>-1)n=a[u];else{let c=Xi(o,this.tracks);n=this.tracks[c]}}let l=this.findTrackId(n);l===-1&&n&&(l=this.findTrackId(null));let d={subtitleTracks:a};this.log(`Updating subtitle tracks, ${a.length} track(s) found in "${r==null?void 0:r.join(",")}" group-id`),this.hls.trigger(v.SUBTITLE_TRACKS_UPDATED,d),l!==-1&&this.trackId===-1&&this.setSubtitleTrack(l)}else this.shouldReloadPlaylist(n)&&this.setSubtitleTrack(this.trackId)}findTrackId(e){let t=this.tracksInGroup,r=this.selectDefaultTrack;for(let s=0;s<t.length;s++){let n=t[s];if(!(r&&!n.default||!r&&!e)&&(!e||Wn(n,e)))return s}if(e){for(let s=0;s<t.length;s++){let n=t[s];if(Yn(e.attrs,n.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return s}for(let s=0;s<t.length;s++){let n=t[s];if(Yn(e.attrs,n.attrs,["LANGUAGE"]))return s}}return-1}findTrackForTextTrack(e){if(e){let t=this.tracksInGroup;for(let r=0;r<t.length;r++){let s=t[r];if(dg(s,e))return r}}return-1}onError(e,t){t.fatal||!t.context||t.context.type===ge.SUBTITLE_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&this.checkRetry(t)}get allSubtitleTracks(){return this.tracks}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e)}setSubtitleOption(e){if(this.hls.config.subtitlePreference=e,e){let t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){let r=this.currentTrack;if(r&&Wn(e,r))return r;let s=Xi(e,this.tracksInGroup);if(s>-1){let n=this.tracksInGroup[s];return this.setSubtitleTrack(s),n}else{if(r)return null;{let n=Xi(e,t);if(n>-1)return t[n]}}}}return null}loadPlaylist(e){super.loadPlaylist();let t=this.currentTrack;if(this.shouldLoadPlaylist(t)&&t){let r=t.id,s=t.groupId,n=t.url;if(e)try{n=e.addDirectives(n)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}this.log(`Loading subtitle playlist for id ${r}`),this.hls.trigger(v.SUBTITLE_TRACK_LOADING,{url:n,id:r,groupId:s,deliveryDirectives:e||null})}}toggleTrackModes(){let{media:e}=this;if(!e)return;let t=Ou(e.textTracks),r=this.currentTrack,s;if(r&&(s=t.filter(n=>dg(r,n))[0],s||this.warn(`Unable to find subtitle TextTrack with name "${r.name}" and language "${r.lang}"`)),[].slice.call(t).forEach(n=>{n.mode!=="disabled"&&n!==s&&(n.mode="disabled")}),s){let n=this.subtitleDisplay?"showing":"hidden";s.mode!==n&&(s.mode=n)}}setSubtitleTrack(e){let t=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(e<-1||e>=t.length||!q(e)){this.warn(`Invalid subtitle track id: ${e}`);return}this.clearTimer(),this.selectDefaultTrack=!1;let r=this.currentTrack,s=t[e]||null;if(this.trackId=e,this.currentTrack=s,this.toggleTrackModes(),!s){this.hls.trigger(v.SUBTITLE_TRACK_SWITCH,{id:e});return}let n=!!s.details&&!s.details.live;if(e===this.trackId&&s===r&&n)return;this.log(`Switching to subtitle-track ${e}`+(s?` "${s.name}" lang:${s.lang} group:${s.groupId}`:""));let{id:a,groupId:o="",name:l,type:d,url:u}=s;this.hls.trigger(v.SUBTITLE_TRACK_SWITCH,{id:a,groupId:o,name:l,type:d,url:u});let c=this.switchParams(s.url,r==null?void 0:r.details,s.details);this.loadPlaylist(c)}},pg=class{constructor(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}append(e,t,r){let s=this.queues[t];s.push(e),s.length===1&&!r&&this.executeNext(t)}insertAbort(e,t){this.queues[t].unshift(e),this.executeNext(t)}appendBlocker(e){let t,r=new Promise(n=>{t=n}),s={execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(s,e),r}executeNext(e){let t=this.queues[e];if(t.length){let r=t[0];try{r.execute()}catch(s){I.warn(`[buffer-operation-queue]: Exception executing "${e}" SourceBuffer operation: ${s}`),r.onError(s);let n=this.buffers[e];n!=null&&n.updating||this.shiftAndExecuteNext(e)}}}shiftAndExecuteNext(e){this.queues[e].shift(),this.executeNext(e)}current(e){return this.queues[e][0]}},ST=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,gg=class{constructor(e){this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendSource=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this.log=void 0,this.warn=void 0,this.error=void 0,this._onEndStreaming=r=>{this.hls&&this.hls.pauseBuffering()},this._onStartStreaming=r=>{this.hls&&this.hls.resumeBuffering()},this._onMediaSourceOpen=()=>{let{media:r,mediaSource:s}=this;this.log("Media source opened"),r&&(r.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(v.MEDIA_ATTACHED,{media:r,mediaSource:s})),s&&s.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{this.log("Media source closed")},this._onMediaSourceEnded=()=>{this.log("Media source ended")},this._onMediaEmptied=()=>{let{mediaSrc:r,_objectUrl:s}=this;r!==s&&I.error(`Media element src was set while attaching MediaSource (${s} > ${r})`)},this.hls=e;let t="[buffer-controller]";this.appendSource=YI(ks(e.config.preferManagedMediaSource)),this.log=I.log.bind(I,t),this.warn=I.warn.bind(I,t),this.error=I.error.bind(I,t),this._initSourceBuffer(),this.registerListeners()}hasSourceTypes(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null,this.hls=null}registerListeners(){let{hls:e}=this;e.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.BUFFER_RESET,this.onBufferReset,this),e.on(v.BUFFER_APPENDING,this.onBufferAppending,this),e.on(v.BUFFER_CODECS,this.onBufferCodecs,this),e.on(v.BUFFER_EOS,this.onBufferEos,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(v.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(v.FRAG_PARSED,this.onFragParsed,this),e.on(v.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){let{hls:e}=this;e.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.BUFFER_RESET,this.onBufferReset,this),e.off(v.BUFFER_APPENDING,this.onBufferAppending,this),e.off(v.BUFFER_CODECS,this.onBufferCodecs,this),e.off(v.BUFFER_EOS,this.onBufferEos,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(v.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(v.FRAG_PARSED,this.onFragParsed,this),e.off(v.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new pg(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.appendErrors={audio:0,video:0,audiovideo:0},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){let r=2;(t.audio&&!t.video||!t.altAudio)&&(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,this.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(e,t){let r=this.media=t.media,s=ks(this.appendSource);if(r&&s){var n;let a=this.mediaSource=new s;this.log(`created media source: ${(n=a.constructor)==null?void 0:n.name}`),a.addEventListener("sourceopen",this._onMediaSourceOpen),a.addEventListener("sourceended",this._onMediaSourceEnded),a.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(a.addEventListener("startstreaming",this._onStartStreaming),a.addEventListener("endstreaming",this._onEndStreaming));let o=this._objectUrl=self.URL.createObjectURL(a);if(this.appendSource)try{r.removeAttribute("src");let l=self.ManagedMediaSource;r.disableRemotePlayback=r.disableRemotePlayback||l&&a instanceof l,xT(r),dw(r,o),r.load()}catch{r.src=o}else r.src=o;r.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){let{media:e,mediaSource:t,_objectUrl:r}=this;if(t){if(this.log("media source detaching"),t.readyState==="open")try{t.endOfStream()}catch(s){this.warn(`onMediaDetaching: ${s.message} while calling endOfStream`)}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(t.removeEventListener("startstreaming",this._onStartStreaming),t.removeEventListener("endstreaming",this._onEndStreaming)),e&&(e.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),this.mediaSrc===r?(e.removeAttribute("src"),this.appendSource&&xT(e),e.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(v.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach(e=>{this.resetBuffer(e)}),this._initSourceBuffer()}resetBuffer(e){let t=this.sourceBuffer[e];try{if(t){var r;this.removeBufferListeners(e),this.sourceBuffer[e]=void 0,(r=this.mediaSource)!=null&&r.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(t)}}catch(s){this.warn(`onBufferReset ${e}`,s)}}onBufferCodecs(e,t){let r=this.getSourceBufferTypes().length,s=Object.keys(t);if(s.forEach(a=>{if(r){let l=this.tracks[a];if(l&&typeof l.buffer.changeType=="function"){var o;let{id:d,codec:u,levelCodec:c,container:h,metadata:f}=t[a],m=Qy(l.codec,l.levelCodec),p=m==null?void 0:m.replace(ST,"$1"),g=Qy(u,c),E=(o=g)==null?void 0:o.replace(ST,"$1");if(g&&p!==E){a.slice(0,5)==="audio"&&(g=Yu(g,this.appendSource));let T=`${h};codecs=${g}`;this.appendChangeType(a,T),this.log(`switching codec ${m} to ${g}`),this.tracks[a]={buffer:l.buffer,codec:u,container:h,levelCodec:c,metadata:f,id:d}}}}else this.pendingTracks[a]=t[a]}),r)return;let n=Math.max(this.bufferCodecEventsExpected-1,0);this.bufferCodecEventsExpected!==n&&(this.log(`${n} bufferCodec event(s) expected ${s.join(",")}`),this.bufferCodecEventsExpected=n),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()}appendChangeType(e,t){let{operationQueue:r}=this,s={execute:()=>{let n=this.sourceBuffer[e];n&&(this.log(`changing ${e} sourceBuffer type to ${t}`),n.changeType(t)),r.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:n=>{this.warn(`Failed to change ${e} SourceBuffer type`,n)}};r.append(s,e,!!this.pendingTracks[e])}onBufferAppending(e,t){let{hls:r,operationQueue:s,tracks:n}=this,{data:a,type:o,frag:l,part:d,chunkMeta:u}=t,c=u.buffering[o],h=self.performance.now();c.start=h;let f=l.stats.buffering,m=d?d.stats.buffering:null;f.start===0&&(f.start=h),m&&m.start===0&&(m.start=h);let p=n.audio,g=!1;o==="audio"&&(p==null?void 0:p.container)==="audio/mpeg"&&(g=!this.lastMpegAudioChunk||u.id===1||this.lastMpegAudioChunk.sn!==u.sn,this.lastMpegAudioChunk=u);let E=l.start,T={execute:()=>{if(c.executeStart=self.performance.now(),g){let y=this.sourceBuffer[o];if(y){let S=E-y.timestampOffset;Math.abs(S)>=.1&&(this.log(`Updating audio SourceBuffer timestampOffset to ${E} (delta: ${S}) sn: ${l.sn})`),y.timestampOffset=E)}}this.appendExecutor(a,o)},onStart:()=>{},onComplete:()=>{let y=self.performance.now();c.executeEnd=c.end=y,f.first===0&&(f.first=y),m&&m.first===0&&(m.first=y);let{sourceBuffer:S}=this,_={};for(let L in S)_[L]=Ue.getBuffered(S[L]);this.appendErrors[o]=0,o==="audio"||o==="video"?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(v.BUFFER_APPENDED,{type:o,frag:l,part:d,chunkMeta:u,parent:l.type,timeRanges:_})},onError:y=>{let S={type:ie.MEDIA_ERROR,parent:l.type,details:C.BUFFER_APPEND_ERROR,sourceBufferName:o,frag:l,part:d,chunkMeta:u,error:y,err:y,fatal:!1};if(y.code===DOMException.QUOTA_EXCEEDED_ERR)S.details=C.BUFFER_FULL_ERROR;else{let _=++this.appendErrors[o];S.details=C.BUFFER_APPEND_ERROR,this.warn(`Failed ${_}/${r.config.appendErrorMaxRetry} times to append segment in "${o}" sourceBuffer`),_>=r.config.appendErrorMaxRetry&&(S.fatal=!0)}r.trigger(v.ERROR,S)}};s.append(T,o,!!this.pendingTracks[o])}onBufferFlushing(e,t){let{operationQueue:r}=this,s=n=>({execute:this.removeExecutor.bind(this,n,t.startOffset,t.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(v.BUFFER_FLUSHED,{type:n})},onError:a=>{this.warn(`Failed to remove from ${n} SourceBuffer`,a)}});t.type?r.append(s(t.type),t.type):this.getSourceBufferTypes().forEach(n=>{r.append(s(n),n)})}onFragParsed(e,t){let{frag:r,part:s}=t,n=[],a=s?s.elementaryStreams:r.elementaryStreams;a[ke.AUDIOVIDEO]?n.push("audiovideo"):(a[ke.AUDIO]&&n.push("audio"),a[ke.VIDEO]&&n.push("video"));let o=()=>{let l=self.performance.now();r.stats.buffering.end=l,s&&(s.stats.buffering.end=l);let d=s?s.stats:r.stats;this.hls.trigger(v.FRAG_BUFFERED,{frag:r,part:s,stats:d,id:r.type})};n.length===0&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${r.type} level: ${r.level} sn: ${r.sn}`),this.blockBuffers(o,n)}onFragChanged(e,t){this.trimBuffers()}onBufferEos(e,t){this.getSourceBufferTypes().reduce((s,n)=>{let a=this.sourceBuffer[n];return a&&(!t.type||t.type===n)&&(a.ending=!0,a.ended||(a.ended=!0,this.log(`${n} sourceBuffer now EOS`))),s&&!!(!a||a.ended)},!0)&&(this.log("Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(n=>{let a=this.sourceBuffer[n];a&&(a.ending=!1)});let{mediaSource:s}=this;if(!s||s.readyState!=="open"){s&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${s.readyState}`);return}this.log("Calling mediaSource.endOfStream()"),s.endOfStream()}))}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}trimBuffers(){let{hls:e,details:t,media:r}=this;if(!r||t===null||!this.getSourceBufferTypes().length)return;let n=e.config,a=r.currentTime,o=t.levelTargetDuration,l=t.live&&n.liveBackBufferLength!==null?n.liveBackBufferLength:n.backBufferLength;if(q(l)&&l>0){let d=Math.max(l,o),u=Math.floor(a/o)*o-d;this.flushBackBuffer(a,o,u)}if(q(n.frontBufferFlushThreshold)&&n.frontBufferFlushThreshold>0){let d=Math.max(n.maxBufferLength,n.frontBufferFlushThreshold),u=Math.max(d,o),c=Math.floor(a/o)*o+u;this.flushFrontBuffer(a,o,c)}}flushBackBuffer(e,t,r){let{details:s,sourceBuffer:n}=this;this.getSourceBufferTypes().forEach(o=>{let l=n[o];if(l){let d=Ue.getBuffered(l);if(d.length>0&&r>d.start(0)){if(this.hls.trigger(v.BACK_BUFFER_REACHED,{bufferEnd:r}),s!=null&&s.live)this.hls.trigger(v.LIVE_BACK_BUFFER_REACHED,{bufferEnd:r});else if(l.ended&&d.end(d.length-1)-e<t*2){this.log(`Cannot flush ${o} back buffer while SourceBuffer is in ended state`);return}this.hls.trigger(v.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:o})}}})}flushFrontBuffer(e,t,r){let{sourceBuffer:s}=this;this.getSourceBufferTypes().forEach(a=>{let o=s[a];if(o){let l=Ue.getBuffered(o),d=l.length;if(d<2)return;let u=l.start(d-1),c=l.end(d-1);if(r>u||e>=u&&e<=c)return;if(o.ended&&e-c<2*t){this.log(`Cannot flush ${a} front buffer while SourceBuffer is in ended state`);return}this.hls.trigger(v.BUFFER_FLUSHING,{startOffset:u,endOffset:1/0,type:a})}})}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;let{details:e,hls:t,media:r,mediaSource:s}=this,n=e.fragments[0].start+e.totalduration,a=r.duration,o=q(s.duration)?s.duration:0;e.live&&t.config.liveDurationInfinity?(s.duration=1/0,this.updateSeekableRange(e)):(n>o&&n>a||!q(a))&&(this.log(`Updating Media Source duration to ${n.toFixed(3)}`),s.duration=n)}updateSeekableRange(e){let t=this.mediaSource,r=e.fragments;if(r.length&&e.live&&t!=null&&t.setLiveSeekableRange){let n=Math.max(0,r[0].start),a=Math.max(n,n+e.totalduration);this.log(`Media Source duration is set to ${t.duration}. Setting seekable range to ${n}-${a}.`),t.setLiveSeekableRange(n,a)}}checkPendingTracks(){let{bufferCodecEventsExpected:e,operationQueue:t,pendingTracks:r}=this,s=Object.keys(r).length;if(s&&(!e||s===2||"audiovideo"in r)){this.createSourceBuffers(r),this.pendingTracks={};let n=this.getSourceBufferTypes();if(n.length)this.hls.trigger(v.BUFFER_CREATED,{tracks:this.tracks}),n.forEach(a=>{t.executeNext(a)});else{let a=new Error("could not create source buffer for media codec(s)");this.hls.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:C.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:a,reason:a.message})}}}createSourceBuffers(e){let{sourceBuffer:t,mediaSource:r}=this;if(!r)throw Error("createSourceBuffers called when mediaSource was null");for(let n in e)if(!t[n]){var s;let a=e[n];if(!a)throw Error(`source buffer exists for track ${n}, however track does not`);let o=((s=a.levelCodec)==null?void 0:s.indexOf(","))===-1?a.levelCodec:a.codec;o&&n.slice(0,5)==="audio"&&(o=Yu(o,this.appendSource));let l=`${a.container};codecs=${o}`;this.log(`creating sourceBuffer(${l})`);try{let d=t[n]=r.addSourceBuffer(l),u=n;this.addBufferListener(u,"updatestart",this._onSBUpdateStart),this.addBufferListener(u,"updateend",this._onSBUpdateEnd),this.addBufferListener(u,"error",this._onSBUpdateError),this.appendSource&&this.addBufferListener(u,"bufferedchange",(c,h)=>{let f=h.removedRanges;f!=null&&f.length&&this.hls.trigger(v.BUFFER_FLUSHED,{type:n})}),this.tracks[n]={buffer:d,codec:o,container:a.container,levelCodec:a.levelCodec,metadata:a.metadata,id:a.id}}catch(d){this.error(`error while trying to add sourceBuffer: ${d.message}`),this.hls.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:C.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:d,sourceBufferName:n,mimeType:l})}}}get mediaSrc(){var e;let t=((e=this.media)==null?void 0:e.firstChild)||this.media;return t==null?void 0:t.src}_onSBUpdateStart(e){let{operationQueue:t}=this;t.current(e).onStart()}_onSBUpdateEnd(e){var t;if(((t=this.mediaSource)==null?void 0:t.readyState)==="closed"){this.resetBuffer(e);return}let{operationQueue:r}=this;r.current(e).onComplete(),r.shiftAndExecuteNext(e)}_onSBUpdateError(e,t){var r;let s=new Error(`${e} SourceBuffer error. MediaSource readyState: ${(r=this.mediaSource)==null?void 0:r.readyState}`);this.error(`${s}`,t),this.hls.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:C.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:s,fatal:!1});let n=this.operationQueue.current(e);n&&n.onError(s)}removeExecutor(e,t,r){let{media:s,mediaSource:n,operationQueue:a,sourceBuffer:o}=this,l=o[e];if(!s||!n||!l){this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),a.shiftAndExecuteNext(e);return}let d=q(s.duration)?s.duration:1/0,u=q(n.duration)?n.duration:1/0,c=Math.max(0,t),h=Math.min(r,d,u);h>c&&(!l.ending||l.ended)?(l.ended=!1,this.log(`Removing [${c},${h}] from the ${e} SourceBuffer`),l.remove(c,h)):a.shiftAndExecuteNext(e)}appendExecutor(e,t){let r=this.sourceBuffer[t];if(!r){if(!this.pendingTracks[t])throw new Error(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);return}r.ended=!1,r.appendBuffer(e)}blockBuffers(e,t=this.getSourceBufferTypes()){if(!t.length){this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}let{operationQueue:r}=this,s=t.map(n=>r.appendBlocker(n));Promise.all(s).then(()=>{e(),t.forEach(n=>{let a=this.sourceBuffer[n];a!=null&&a.updating||r.shiftAndExecuteNext(n)})})}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(e,t,r){let s=this.sourceBuffer[e];if(!s)return;let n=r.bind(this,e);this.listeners[e].push({event:t,listener:n}),s.addEventListener(t,n)}removeBufferListeners(e){let t=this.sourceBuffer[e];t&&this.listeners[e].forEach(r=>{t.removeEventListener(r.event,r.listener)})}};function xT(i){let e=i.querySelectorAll("source");[].slice.call(e).forEach(t=>{i.removeChild(t)})}function dw(i,e){let t=self.document.createElement("source");t.type="video/mp4",t.src=e,i.appendChild(t)}var LT={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},x_=function(e){let t=e;return LT.hasOwnProperty(e)&&(t=LT[e]),String.fromCharCode(t)},bi=15,ur=100,uw={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},cw={17:2,18:4,21:6,22:8,23:10,19:13,20:15},hw={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},fw={25:2,26:4,29:6,30:8,31:10,27:13,28:15},mw=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],vg=class{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){let r=typeof t=="function"?t():t;I.log(`${this.time} [${e}] ${r}`)}}},_s=function(e){let t=[];for(let r=0;r<e.length;r++)t.push(e[r].toString(16));return t},oc=class{constructor(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(e){let t=["foreground","underline","italics","background","flash"];for(let r=0;r<t.length;r++){let s=t[r];e.hasOwnProperty(s)&&(this[s]=e[s])}}isDefault(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash}equals(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}copy(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}},Eg=class{constructor(){this.uchar=" ",this.penState=new oc}reset(){this.uchar=" ",this.penState.reset()}setChar(e,t){this.uchar=e,this.penState.copy(t)}setPenState(e){this.penState.copy(e)}equals(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}copy(e){this.uchar=e.uchar,this.penState.copy(e.penState)}isEmpty(){return this.uchar===" "&&this.penState.isDefault()}},bg=class{constructor(e){this.chars=[],this.pos=0,this.currPenState=new oc,this.cueStartTime=null,this.logger=void 0;for(let t=0;t<ur;t++)this.chars.push(new Eg);this.logger=e}equals(e){for(let t=0;t<ur;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}copy(e){for(let t=0;t<ur;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<ur;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}setCursor(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>ur&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=ur)}moveCursor(e){let t=this.pos+e;if(e>1)for(let r=this.pos+1;r<t+1;r++)this.chars[r].setPenState(this.currPenState);this.setCursor(t)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(e){e>=144&&this.backSpace();let t=x_(e);if(this.pos>=ur){this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1)}clearFromPos(e){let t;for(t=e;t<ur;t++)this.chars[t].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){let e=[],t=!0;for(let r=0;r<ur;r++){let s=this.chars[r].uchar;s!==" "&&(t=!1),e.push(s)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}},ao=class{constructor(e){this.rows=[],this.currRow=bi-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<bi;t++)this.rows.push(new bg(e));this.logger=e}reset(){for(let e=0;e<bi;e++)this.rows[e].clear();this.currRow=bi-1}equals(e){let t=!0;for(let r=0;r<bi;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t}copy(e){for(let t=0;t<bi;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<bi;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(e){this.rows[this.currRow].insertChar(e)}setPen(e){this.rows[this.currRow].setPenStyles(e)}moveCursor(e){this.rows[this.currRow].moveCursor(e)}setCursor(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)}setPAC(e){this.logger.log(2,()=>"pacData = "+JSON.stringify(e));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let o=0;o<bi;o++)this.rows[o].clear();let n=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){let o=a.rows[n].cueStartTime,l=this.logger.time;if(o!==null&&l!==null&&o<l)for(let d=0;d<this.nrRollUpRows;d++)this.rows[t-this.nrRollUpRows+d+1].copy(a.rows[n+d])}}this.currRow=t;let r=this.rows[this.currRow];if(e.indent!==null){let n=e.indent,a=Math.max(n-1,0);r.setCursor(e.indent),e.color=r.chars[a].penState.foreground}let s={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(s)}setBkgData(e){this.logger.log(2,()=>"bkgData = "+JSON.stringify(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){if(this.nrRollUpRows===null){this.logger.log(3,"roll_up but nrRollUpRows not set yet");return}this.logger.log(1,()=>this.getDisplayText());let e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}getDisplayText(e){e=e||!1;let t=[],r="",s=-1;for(let n=0;n<bi;n++){let a=this.rows[n].getTextString();a&&(s=n+1,e?t.push("Row "+s+": '"+a+"'"):t.push(a.trim()))}return t.length>0&&(e?r="["+t.join(" | ")+"]":r=t.join(`
1592
- `)),r}getTextAndFormat(){return this.rows}},lc=class{constructor(e,t,r){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new ao(r),this.nonDisplayedMemory=new ao(r),this.lastOutputScreen=new ao(r),this.currRollUpRow=this.displayedMemory.rows[bi-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=r}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[bi-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(e){this.outputFilter=e}setPAC(e){this.writeScreen.setPAC(e)}setBkgData(e){this.writeScreen.setBkgData(e)}setMode(e){e!==this.mode&&(this.mode=e,this.logger.log(2,()=>"MODE="+e),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}insertChars(e){for(let r=0;r<e.length;r++)this.writeScreen.insertChar(e[r]);let t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>t+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){let e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}ccMIDROW(e){let t={flash:!1};if(t.underline=e%2===1,t.italics=e>=46,t.italics)t.foreground="white";else{let r=Math.floor(e/2)-16,s=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=s[r]}this.logger.log(2,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){let t=this.logger.time;t!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=t:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t),this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}},dc=class{constructor(e,t,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=IT(),this.logger=void 0;let s=this.logger=new vg;this.channels=[null,new lc(e,t,s),new lc(e+1,r,s)]}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){let r,s,n,a=!1;this.logger.time=e;for(let o=0;o<t.length;o+=2)if(s=t[o]&127,n=t[o+1]&127,!(s===0&&n===0)){if(this.logger.log(3,"["+_s([t[o],t[o+1]])+"] -> ("+_s([s,n])+")"),r=this.parseCmd(s,n),r||(r=this.parseMidrow(s,n)),r||(r=this.parsePAC(s,n)),r||(r=this.parseBackgroundAttributes(s,n)),!r&&(a=this.parseChars(s,n),a)){let l=this.currentChannel;l&&l>0?this.channels[l].insertChars(a):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!r&&!a&&this.logger.log(2,"Couldn't parse cleaned data "+_s([s,n])+" orig: "+_s([t[o],t[o+1]]))}}parseCmd(e,t){let{cmdHistory:r}=this,s=(e===20||e===28||e===21||e===29)&&t>=32&&t<=47,n=(e===23||e===31)&&t>=33&&t<=35;if(!(s||n))return!1;if(kT(e,t,r))return $n(null,null,r),this.logger.log(3,"Repeated command ("+_s([e,t])+") is dropped"),!0;let a=e===20||e===21||e===23?1:2,o=this.channels[a];return e===20||e===21||e===28||e===29?t===32?o.ccRCL():t===33?o.ccBS():t===34?o.ccAOF():t===35?o.ccAON():t===36?o.ccDER():t===37?o.ccRU(2):t===38?o.ccRU(3):t===39?o.ccRU(4):t===40?o.ccFON():t===41?o.ccRDC():t===42?o.ccTR():t===43?o.ccRTD():t===44?o.ccEDM():t===45?o.ccCR():t===46?o.ccENM():t===47&&o.ccEOC():o.ccTO(t-32),$n(e,t,r),this.currentChannel=a,!0}parseMidrow(e,t){let r=0;if((e===17||e===25)&&t>=32&&t<=47){if(e===17?r=1:r=2,r!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;let s=this.channels[r];return s?(s.ccMIDROW(t),this.logger.log(3,"MIDROW ("+_s([e,t])+")"),!0):!1}return!1}parsePAC(e,t){let r,s=this.cmdHistory,n=(e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127,a=(e===16||e===24)&&t>=64&&t<=95;if(!(n||a))return!1;if(kT(e,t,s))return $n(null,null,s),!0;let o=e<=23?1:2;t>=64&&t<=95?r=o===1?uw[e]:hw[e]:r=o===1?cw[e]:fw[e];let l=this.channels[o];return l?(l.setPAC(this.interpretPAC(r,t)),$n(e,t,s),this.currentChannel=o,!0):!1}interpretPAC(e,t){let r,s={color:null,italics:!1,indent:null,underline:!1,row:e};return t>95?r=t-96:r=t-64,s.underline=(r&1)===1,r<=13?s.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(s.italics=!0,s.color="white"):s.indent=Math.floor((r-16)/2)*4,s}parseChars(e,t){let r,s=null,n=null;if(e>=25?(r=2,n=e-8):(r=1,n=e),n>=17&&n<=19){let a;n===17?a=t+80:n===18?a=t+112:a=t+144,this.logger.log(2,"Special char '"+x_(a)+"' in channel "+r),s=[a]}else e>=32&&e<=127&&(s=t===0?[e]:[e,t]);if(s){let a=_s(s);this.logger.log(3,"Char codes = "+a.join(",")),$n(e,t,this.cmdHistory)}return s}parseBackgroundAttributes(e,t){let r=(e===16||e===24)&&t>=32&&t<=47,s=(e===23||e===31)&&t>=45&&t<=47;if(!(r||s))return!1;let n,a={};e===16||e===24?(n=Math.floor((t-32)/2),a.background=mw[n],t%2===1&&(a.background=a.background+"_semi")):t===45?a.background="transparent":(a.foreground="black",t===47&&(a.underline=!0));let o=e<=23?1:2;return this.channels[o].setBkgData(a),$n(e,t,this.cmdHistory),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){let t=this.channels[e];t&&t.reset()}this.cmdHistory=IT()}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){let r=this.channels[t];r&&r.cueSplitAtTime(e)}}};function $n(i,e,t){t.a=i,t.b=e}function kT(i,e,t){return t.a===i&&t.b===e}function IT(){return{a:null,b:null}}var Gn=class{constructor(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}dispatchCue(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,t,r){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}},Yg=function(){if(qn!=null&&qn.VTTCue)return self.VTTCue;let i=["","lr","rl"],e=["start","middle","end","left","right"];function t(o,l){if(typeof l!="string"||!Array.isArray(o))return!1;let d=l.toLowerCase();return~o.indexOf(d)?d:!1}function r(o){return t(i,o)}function s(o){return t(e,o)}function n(o,...l){let d=1;for(;d<arguments.length;d++){let u=arguments[d];for(let c in u)o[c]=u[c]}return o}function a(o,l,d){let u=this,c={enumerable:!0};u.hasBeenReset=!1;let h="",f=!1,m=o,p=l,g=d,E=null,T="",y=!0,S="auto",_="start",L=50,x="middle",w=50,M="middle";Object.defineProperty(u,"id",n({},c,{get:function(){return h},set:function(k){h=""+k}})),Object.defineProperty(u,"pauseOnExit",n({},c,{get:function(){return f},set:function(k){f=!!k}})),Object.defineProperty(u,"startTime",n({},c,{get:function(){return m},set:function(k){if(typeof k!="number")throw new TypeError("Start time must be set to a number.");m=k,this.hasBeenReset=!0}})),Object.defineProperty(u,"endTime",n({},c,{get:function(){return p},set:function(k){if(typeof k!="number")throw new TypeError("End time must be set to a number.");p=k,this.hasBeenReset=!0}})),Object.defineProperty(u,"text",n({},c,{get:function(){return g},set:function(k){g=""+k,this.hasBeenReset=!0}})),Object.defineProperty(u,"region",n({},c,{get:function(){return E},set:function(k){E=k,this.hasBeenReset=!0}})),Object.defineProperty(u,"vertical",n({},c,{get:function(){return T},set:function(k){let D=r(k);if(D===!1)throw new SyntaxError("An invalid or illegal string was specified.");T=D,this.hasBeenReset=!0}})),Object.defineProperty(u,"snapToLines",n({},c,{get:function(){return y},set:function(k){y=!!k,this.hasBeenReset=!0}})),Object.defineProperty(u,"line",n({},c,{get:function(){return S},set:function(k){if(typeof k!="number"&&k!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");S=k,this.hasBeenReset=!0}})),Object.defineProperty(u,"lineAlign",n({},c,{get:function(){return _},set:function(k){let D=s(k);if(!D)throw new SyntaxError("An invalid or illegal string was specified.");_=D,this.hasBeenReset=!0}})),Object.defineProperty(u,"position",n({},c,{get:function(){return L},set:function(k){if(k<0||k>100)throw new Error("Position must be between 0 and 100.");L=k,this.hasBeenReset=!0}})),Object.defineProperty(u,"positionAlign",n({},c,{get:function(){return x},set:function(k){let D=s(k);if(!D)throw new SyntaxError("An invalid or illegal string was specified.");x=D,this.hasBeenReset=!0}})),Object.defineProperty(u,"size",n({},c,{get:function(){return w},set:function(k){if(k<0||k>100)throw new Error("Size must be between 0 and 100.");w=k,this.hasBeenReset=!0}})),Object.defineProperty(u,"align",n({},c,{get:function(){return M},set:function(k){let D=s(k);if(!D)throw new SyntaxError("An invalid or illegal string was specified.");M=D,this.hasBeenReset=!0}})),u.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}(),yg=class{decode(e,t){if(!e)return"";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}};function L_(i){function e(r,s,n,a){return(r|0)*3600+(s|0)*60+(n|0)+parseFloat(a||0)}let t=i.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return t?parseFloat(t[2])>59?e(t[2],t[3],0,t[4]):e(t[1],t[2],t[3],t[4]):null}var Tg=class{constructor(){this.values=Object.create(null)}set(e,t){!this.get(e)&&t!==""&&(this.values[e]=t)}get(e,t,r){return r?this.has(e)?this.values[e]:t[r]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,r){for(let s=0;s<r.length;++s)if(t===r[s]){this.set(e,t);break}}integer(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}percent(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){let r=parseFloat(t);if(r>=0&&r<=100)return this.set(e,r),!0}return!1}};function k_(i,e,t,r){let s=r?i.split(r):[i];for(let n in s){if(typeof s[n]!="string")continue;let a=s[n].split(t);if(a.length!==2)continue;let o=a[0],l=a[1];e(o,l)}}var _g=new Yg(0,0,""),Du=_g.align==="middle"?"middle":"center";function pw(i,e,t){let r=i;function s(){let o=L_(i);if(o===null)throw new Error("Malformed timestamp: "+r);return i=i.replace(/^[^\sa-zA-Z-]+/,""),o}function n(o,l){let d=new Tg;k_(o,function(h,f){let m;switch(h){case"region":for(let p=t.length-1;p>=0;p--)if(t[p].id===f){d.set(h,t[p].region);break}break;case"vertical":d.alt(h,f,["rl","lr"]);break;case"line":m=f.split(","),d.integer(h,m[0]),d.percent(h,m[0])&&d.set("snapToLines",!1),d.alt(h,m[0],["auto"]),m.length===2&&d.alt("lineAlign",m[1],["start",Du,"end"]);break;case"position":m=f.split(","),d.percent(h,m[0]),m.length===2&&d.alt("positionAlign",m[1],["start",Du,"end","line-left","line-right","auto"]);break;case"size":d.percent(h,f);break;case"align":d.alt(h,f,["start",Du,"end","left","right"]);break}},/:/,/\s/),l.region=d.get("region",null),l.vertical=d.get("vertical","");let u=d.get("line","auto");u==="auto"&&_g.line===-1&&(u=-1),l.line=u,l.lineAlign=d.get("lineAlign","start"),l.snapToLines=d.get("snapToLines",!0),l.size=d.get("size",100),l.align=d.get("align",Du);let c=d.get("position","auto");c==="auto"&&_g.position===50&&(c=l.align==="start"||l.align==="left"?0:l.align==="end"||l.align==="right"?100:50),l.position=c}function a(){i=i.replace(/^\s+/,"")}if(a(),e.startTime=s(),a(),i.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+r);i=i.slice(3),a(),e.endTime=s(),a(),n(i,e)}function I_(i){return i.replace(/<br(?: \/)?>/gi,`
1593
- `)}var Ag=class{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new yg,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=I_(n);a<n.length&&n[a]!=="\r"&&n[a]!==`
1591
+ initSegmentChange: ${w}`);let k=new cg(r,s,t,o,u);this.configureTransmuxer(k)}if(this.frag=n,this.part=a,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:p,chunkMeta:d,state:P},e instanceof ArrayBuffer?[e]:[]);else if(f){let k=f.push(e,p,d,P);$u(k)?(f.async=!0,k.then(D=>{this.handleTransmuxComplete(D)}).catch(D=>{this.transmuxerError(D,d,"transmuxer-interface push error")})):(f.async=!1,this.handleTransmuxComplete(k))}}flush(e){e.transmuxing.start=self.performance.now();let{transmuxer:t}=this;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(t){let r=t.flush(e);$u(r)||t.async?($u(r)||(r=Promise.resolve(r)),r.then(n=>{this.handleFlushResult(n,e)}).catch(n=>{this.transmuxerError(n,e,"transmuxer-interface flush error")})):this.handleFlushResult(r,e)}}transmuxerError(e,t,r){this.hls&&(this.error=e,this.hls.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:C.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,fatal:!1,error:e,err:e,reason:r}))}handleFlushResult(e,t){e.forEach(r=>{this.handleTransmuxComplete(r)}),this.onFlush(t)}onWorkerMessage(e){let t=e.data;if(!(t!=null&&t.event)){I.warn(`worker message received with no ${t?"event name":"data"}`);return}let r=this.hls;if(this.hls)switch(t.event){case"init":{var s;let n=(s=this.workerContext)==null?void 0:s.objectURL;n&&self.URL.revokeObjectURL(n);break}case"transmuxComplete":{this.handleTransmuxComplete(t.data);break}case"flush":{this.onFlush(t.data);break}case"workerLog":I[t.data.logType]&&I[t.data.logType](t.data.message);break;default:{t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,r.trigger(t.event,t.data);break}}}configureTransmuxer(e){let{transmuxer:t}=this;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}};function A_(i,e){if(i.length!==e.length)return!1;for(let t=0;t<i.length;t++)if(!Yn(i[t].attrs,e[t].attrs))return!1;return!0}function Yn(i,e,t){let r=i["STABLE-RENDITION-ID"];return r&&!t?r===e["STABLE-RENDITION-ID"]:!(t||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(s=>i[s]!==e[s])}function fg(i,e){return e.label.toLowerCase()===i.name.toLowerCase()&&(!e.language||e.language.toLowerCase()===(i.lang||"").toLowerCase())}var ST=100,mg=class extends mo{constructor(e,t,r){super(e,t,r,"[audio-stream-controller]",J.AUDIO),this.videoBuffer=null,this.videoTrackCC=-1,this.waitingVideoCC=-1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.flushing=!1,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null}_registerListeners(){let{hls:e}=this;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(v.ERROR,this.onError,this),e.on(v.BUFFER_RESET,this.onBufferReset,this),e.on(v.BUFFER_CREATED,this.onBufferCreated,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(v.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(v.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){let{hls:e}=this;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(v.ERROR,this.onError,this),e.off(v.BUFFER_RESET,this.onBufferReset,this),e.off(v.BUFFER_CREATED,this.onBufferCreated,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(v.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(v.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(e,{frag:t,id:r,initPTS:s,timescale:n}){if(r==="main"){let a=t.cc;this.initPTS[t.cc]={baseTime:s,timescale:n},this.log(`InitPTS for cc: ${a} found from main: ${s}`),this.videoTrackCC=a,this.state===N.WAITING_INIT_PTS&&this.tick()}}startLoad(e){if(!this.levels){this.startPosition=e,this.state=N.STOPPED;return}let t=this.lastCurrentTime;this.stopLoad(),this.setInterval(ST),t>0&&e===-1?(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t,this.state=N.IDLE):(this.loadedmetadata=!1,this.state=N.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}doTick(){switch(this.state){case N.IDLE:this.doTickIdle();break;case N.WAITING_TRACK:{var e;let{levels:r,trackId:s}=this,n=r==null||(e=r[s])==null?void 0:e.details;if(n){if(this.waitForCdnTuneIn(n))break;this.state=N.WAITING_INIT_PTS}break}case N.FRAG_LOADING_WAITING_RETRY:{var t;let r=performance.now(),s=this.retryDate;if(!s||r>=s||(t=this.media)!=null&&t.seeking){let{levels:n,trackId:a}=this;this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded((n==null?void 0:n[a])||null),this.state=N.IDLE}break}case N.WAITING_INIT_PTS:{let r=this.waitingData;if(r){let{frag:s,part:n,cache:a,complete:o}=r;if(this.initPTS[s.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=N.FRAG_LOADING;let l=a.flush(),d={frag:s,part:n,payload:l,networkDetails:null};this._handleFragmentLoadProgress(d),o&&super._handleFragmentLoadComplete(d)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${s.cc}) cancelled because video is at cc ${this.videoTrackCC}`),this.clearWaitingFragment();else{let l=this.getLoadPosition(),d=Ue.bufferInfo(this.mediaBuffer,l,this.config.maxBufferHole);Vp(d.end,this.config.maxFragLookUpTolerance,s)<0&&(this.log(`Waiting fragment cc (${s.cc}) @ ${s.start} cancelled because another fragment at ${d.end} is needed`),this.clearWaitingFragment())}}else this.state=N.IDLE}}this.onTickEnd()}clearWaitingFragment(){let e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=N.IDLE)}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){let{media:e}=this;e!=null&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){let{hls:e,levels:t,media:r,trackId:s}=this,n=e.config;if(!r&&(this.startFragRequested||!n.startFragPrefetch)||!(t!=null&&t[s]))return;let a=t[s],o=a.details;if(!o||o.live&&this.levelLastLoaded!==a||this.waitForCdnTuneIn(o)){this.state=N.WAITING_TRACK;return}let l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,ke.AUDIO,J.AUDIO));let d=this.getFwdBufferInfo(l,J.AUDIO);if(d===null)return;let{bufferedTrack:u,switchingTrack:c}=this;if(!c&&this._streamEnded(d,o)){e.trigger(v.BUFFER_EOS,{type:"audio"}),this.state=N.ENDED;return}let h=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,J.MAIN),f=d.len,m=this.getMaxBufferLength(h==null?void 0:h.len),p=o.fragments,g=p[0].start,E=this.flushing?this.getLoadPosition():d.end;if(c&&r){let A=this.getLoadPosition();u&&!Yn(c.attrs,u.attrs)&&(E=A),o.PTSKnown&&A<g&&(d.end>g||d.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),r.currentTime=g+.05)}if(f>=m&&!c&&E<p[p.length-1].start)return;let T=this.getNextFragment(E,o),y=!1;if(T&&this.isLoopLoading(T,E)&&(y=!!T.gap,T=this.getNextFragmentLoopLoading(T,o,d,J.MAIN,m)),!T){this.bufferFlushed=!0;return}let S=h&&T.start>h.end+o.targetduration;if(S||!(h!=null&&h.len)&&d.len){let A=this.getAppendedFrag(T.start,J.MAIN);if(A===null||(y||(y=!!A.gap||!!S&&h.len===0),S&&!y||y&&d.nextStart&&d.nextStart<A.end))return}this.loadFragment(T,a,E)}getMaxBufferLength(e){let t=super.getMaxBufferLength();return e?Math.min(Math.max(t,e),this.config.maxMaxBufferLength):t}onMediaDetaching(){this.videoBuffer=null,this.bufferFlushed=this.flushing=!1,super.onMediaDetaching()}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(r=>new Mr(r))}onAudioTrackSwitching(e,t){let r=!!t.url;this.trackId=t.id;let{fragCurrent:s}=this;s&&(s.abortRequests(),this.removeUnbufferedFrags(s.start)),this.resetLoadingState(),r?this.setInterval(ST):this.resetTransmuxer(),r?(this.switchingTrack=t,this.state=N.IDLE,this.flushAudioIfNeeded(t)):(this.switchingTrack=null,this.bufferedTrack=t,this.state=N.STOPPED),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=this.flushing=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1}onLevelLoaded(e,t){this.mainDetails=t.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(v.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(e,t){var r;if(this.mainDetails==null){this.cachedTrackLoadedData=t;return}let{levels:s}=this,{details:n,id:a}=t;if(!s){this.warn(`Audio tracks were reset while loading level ${a}`);return}this.log(`Audio track ${a} loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`);let o=s[a],l=0;if(n.live||(r=o.details)!=null&&r.live){this.checkLiveUpdate(n);let u=this.mainDetails;if(n.deltaUpdateFailed||!u)return;if(!o.details&&n.hasProgramDateTime&&u.hasProgramDateTime)ec(n,u),l=n.fragments[0].start;else{var d;l=this.alignPlaylists(n,o.details,(d=this.levelLastLoaded)==null?void 0:d.details)}}o.details=n,this.levelLastLoaded=o,!this.startFragRequested&&(this.mainDetails||!n.live)&&this.setStartPosition(this.mainDetails||n,l),this.state===N.WAITING_TRACK&&!this.waitForCdnTuneIn(n)&&(this.state=N.IDLE),this.tick()}_handleFragmentLoadProgress(e){var t;let{frag:r,part:s,payload:n}=e,{config:a,trackId:o,levels:l}=this;if(!l){this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);return}let d=l[o];if(!d){this.warn("Audio track is undefined on fragment load progress");return}let u=d.details;if(!u){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(r.start);return}let c=a.defaultAudioCodec||d.audioCodec||"mp4a.40.2",h=this.transmuxer;h||(h=this.transmuxer=new lc(this.hls,J.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));let f=this.initPTS[r.cc],m=(t=r.initSegment)==null?void 0:t.data;if(f!==void 0){let g=s?s.index:-1,E=g!==-1,T=new ho(r.level,r.sn,r.stats.chunkCount,n.byteLength,g,E);h.push(n,m,c,"",r,s,u.totalduration,!1,T,f)}else{this.log(`Unknown video PTS for cc ${r.cc}, waiting for video PTS before demuxing audio frag ${r.sn} of [${u.startSN} ,${u.endSN}],track ${o}`);let{cache:p}=this.waitingData=this.waitingData||{frag:r,part:s,cache:new tc,complete:!1};p.push(new Uint8Array(n)),this.waitingVideoCC=this.videoTrackCC,this.state=N.WAITING_INIT_PTS}}_handleFragmentLoadComplete(e){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(e,t){let r=t.tracks.audio;r&&(this.mediaBuffer=r.buffer||null),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer||null)}onFragBuffered(e,t){let{frag:r,part:s}=t;if(r.type!==J.AUDIO){if(!this.loadedmetadata&&r.type===J.MAIN){let n=this.videoBuffer||this.media;n&&Ue.getBuffered(n).length&&(this.loadedmetadata=!0)}return}if(this.fragContextChanged(r)){this.warn(`Fragment ${r.sn}${s?" p: "+s.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if(r.sn!=="initSegment"){this.fragPrevious=r;let n=this.switchingTrack;n&&(this.bufferedTrack=n,this.switchingTrack=null,this.hls.trigger(v.AUDIO_TRACK_SWITCHED,mt({},n)))}this.fragBufferedComplete(r,s)}onError(e,t){var r;if(t.fatal){this.state=N.ERROR;return}switch(t.details){case C.FRAG_GAP:case C.FRAG_PARSING_ERROR:case C.FRAG_DECRYPT_ERROR:case C.FRAG_LOAD_ERROR:case C.FRAG_LOAD_TIMEOUT:case C.KEY_LOAD_ERROR:case C.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(J.AUDIO,t);break;case C.AUDIO_TRACK_LOAD_ERROR:case C.AUDIO_TRACK_LOAD_TIMEOUT:case C.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===N.WAITING_TRACK&&((r=t.context)==null?void 0:r.type)===ge.AUDIO_TRACK&&(this.state=N.IDLE);break;case C.BUFFER_APPEND_ERROR:case C.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="audio")return;if(t.details===C.BUFFER_APPEND_ERROR){this.resetLoadingState();return}this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case C.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onBufferFlushing(e,{type:t}){t!==ke.VIDEO&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==ke.VIDEO){this.flushing=!1,this.bufferFlushed=!0,this.state===N.ENDED&&(this.state=N.IDLE);let r=this.mediaBuffer||this.media;r&&(this.afterBufferFlushed(r,t,J.AUDIO),this.tick())}}_handleTransmuxComplete(e){var t;let r="audio",{hls:s}=this,{remuxResult:n,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}let{frag:l,part:d,level:u}=o,{details:c}=u,{audio:h,text:f,id3:m,initSegment:p}=n;if(this.fragContextChanged(l)||!c){this.fragmentTracker.removeFragment(l);return}if(this.state=N.PARSING,this.switchingTrack&&h&&this.completeAudioSwitch(this.switchingTrack),p!=null&&p.tracks){let g=l.initSegment||l;this._bufferInitSegment(u,p.tracks,g,a),s.trigger(v.FRAG_PARSING_INIT_SEGMENT,{frag:g,id:r,tracks:p.tracks})}if(h){let{startPTS:g,endPTS:E,startDTS:T,endDTS:y}=h;d&&(d.elementaryStreams[ke.AUDIO]={startPTS:g,endPTS:E,startDTS:T,endDTS:y}),l.setElementaryStreamInfo(ke.AUDIO,g,E,T,y),this.bufferFragmentData(h,l,d,a)}if(m!=null&&(t=m.samples)!=null&&t.length){let g=Je({id:r,frag:l,details:c},m);s.trigger(v.FRAG_PARSING_METADATA,g)}if(f){let g=Je({id:r,frag:l,details:c},f);s.trigger(v.FRAG_PARSING_USERDATA,g)}}_bufferInitSegment(e,t,r,s){if(this.state!==N.PARSING)return;t.video&&delete t.video;let n=t.audio;if(!n)return;n.id="audio";let a=e.audioCodec;this.log(`Init audio buffer, container:${n.container}, codecs[level/parsed]=[${a}/${n.codec}]`),a&&a.split(",").length===1&&(n.levelCodec=a),this.hls.trigger(v.BUFFER_CODECS,t);let o=n.initSegment;if(o!=null&&o.byteLength){let l={type:"audio",frag:r,part:null,chunkMeta:s,parent:r.type,data:o};this.hls.trigger(v.BUFFER_APPENDING,l)}this.tickImmediate()}loadFragment(e,t,r){let s=this.fragmentTracker.getState(e);if(this.fragCurrent=e,this.switchingTrack||s===ft.NOT_LOADED||s===ft.PARTIAL){var n;if(e.sn==="initSegment")this._loadInitSegment(e,t);else if((n=t.details)!=null&&n.live&&!this.initPTS[e.cc]){this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=N.WAITING_INIT_PTS;let a=this.mainDetails;a&&a.fragments[0].start!==t.details.fragments[0].start&&ec(t.details,a)}else this.startFragRequested=!0,super.loadFragment(e,t,r)}else this.clearTrackerIfNeeded(e)}flushAudioIfNeeded(e){let{media:t,bufferedTrack:r}=this,s=r==null?void 0:r.attrs,n=e.attrs;t&&s&&(s.CHANNELS!==n.CHANNELS||r.name!==e.name||r.lang!==e.lang)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null)}completeAudioSwitch(e){let{hls:t}=this;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(v.AUDIO_TRACK_SWITCHED,mt({},e))}},pg=class extends co{constructor(e){super(e,"[audio-track-controller]"),this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){let{hls:e}=this;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.LEVEL_LOADING,this.onLevelLoading,this),e.on(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(v.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.LEVEL_LOADING,this.onLevelLoading,this),e.off(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(v.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){let{id:r,groupId:s,details:n}=t,a=this.tracksInGroup[r];if(!a||a.groupId!==s){this.warn(`Audio track with id:${r} and group:${s} not found in active group ${a==null?void 0:a.groupId}`);return}let o=a.details;a.details=t.details,this.log(`Audio track ${r} "${a.name}" lang:${a.lang} group:${s} loaded [${n.startSN}-${n.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){let t=this.hls.levels[e];if(!t)return;let r=t.audioGroups||null,s=this.groupIds,n=this.currentTrack;if(!r||(s==null?void 0:s.length)!==(r==null?void 0:r.length)||r!=null&&r.some(o=>(s==null?void 0:s.indexOf(o))===-1)){this.groupIds=r,this.trackId=-1,this.currentTrack=null;let o=this.tracks.filter(h=>!r||r.indexOf(h.groupId)!==-1);if(o.length)this.selectDefaultTrack&&!o.some(h=>h.default)&&(this.selectDefaultTrack=!1),o.forEach((h,f)=>{h.id=f});else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=o;let l=this.hls.config.audioPreference;if(!n&&l){let h=Xi(l,o,Un);if(h>-1)n=o[h];else{let f=Xi(l,this.tracks);n=this.tracks[f]}}let d=this.findTrackId(n);d===-1&&n&&(d=this.findTrackId(null));let u={audioTracks:o};this.log(`Updating audio tracks, ${o.length} track(s) found in group(s): ${r==null?void 0:r.join(",")}`),this.hls.trigger(v.AUDIO_TRACKS_UPDATED,u);let c=this.trackId;if(d!==-1&&c===-1)this.setAudioTrack(d);else if(o.length&&c===-1){var a;let h=new Error(`No audio track selected for current audio group-ID(s): ${(a=this.groupIds)==null?void 0:a.join(",")} track count: ${o.length}`);this.warn(h.message),this.hls.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:C.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:h})}}else this.shouldReloadPlaylist(n)&&this.setAudioTrack(this.trackId)}onError(e,t){t.fatal||!t.context||t.context.type===ge.AUDIO_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&(this.requestScheduled=-1,this.checkRetry(t))}get allAudioTracks(){return this.tracks}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioOption(e){let t=this.hls;if(t.config.audioPreference=e,e){let r=this.allAudioTracks;if(this.selectDefaultTrack=!1,r.length){let s=this.currentTrack;if(s&&Wn(e,s,Un))return s;let n=Xi(e,this.tracksInGroup,Un);if(n>-1){let a=this.tracksInGroup[n];return this.setAudioTrack(n),a}else if(s){let a=t.loadLevel;a===-1&&(a=t.firstAutoLevel);let o=LR(e,t.levels,r,a,Un);if(o===-1)return null;t.nextLoadLevel=o}if(e.channels||e.audioCodec){let a=Xi(e,r);if(a>-1)return r[a]}}}return null}setAudioTrack(e){let t=this.tracksInGroup;if(e<0||e>=t.length){this.warn(`Invalid audio track id: ${e}`);return}this.clearTimer(),this.selectDefaultTrack=!1;let r=this.currentTrack,s=t[e],n=s.details&&!s.details.live;if(e===this.trackId&&s===r&&n||(this.log(`Switching to audio-track ${e} "${s.name}" lang:${s.lang} group:${s.groupId} channels:${s.channels}`),this.trackId=e,this.currentTrack=s,this.hls.trigger(v.AUDIO_TRACK_SWITCHING,mt({},s)),n))return;let a=this.switchParams(s.url,r==null?void 0:r.details,s.details);this.loadPlaylist(a)}findTrackId(e){let t=this.tracksInGroup;for(let r=0;r<t.length;r++){let s=t[r];if(!(this.selectDefaultTrack&&!s.default)&&(!e||Wn(e,s,Un)))return r}if(e){let{name:r,lang:s,assocLang:n,characteristics:a,audioCodec:o,channels:l}=e;for(let d=0;d<t.length;d++){let u=t[d];if(Wn({name:r,lang:s,assocLang:n,characteristics:a,audioCodec:o,channels:l},u,Un))return d}for(let d=0;d<t.length;d++){let u=t[d];if(Yn(e.attrs,u.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return d}for(let d=0;d<t.length;d++){let u=t[d];if(Yn(e.attrs,u.attrs,["LANGUAGE"]))return d}}return-1}loadPlaylist(e){let t=this.currentTrack;if(this.shouldLoadPlaylist(t)&&t){super.loadPlaylist();let r=t.id,s=t.groupId,n=t.url;if(e)try{n=e.addDirectives(n)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}this.log(`loading audio-track playlist ${r} "${t.name}" lang:${t.lang} group:${s}`),this.clearTimer(),this.hls.trigger(v.AUDIO_TRACK_LOADING,{url:n,id:r,groupId:s,deliveryDirectives:e||null})}}},xT=500,gg=class extends mo{constructor(e,t,r){super(e,t,r,"[subtitle-stream-controller]",J.SUBTITLE),this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null}_registerListeners(){let{hls:e}=this;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.ERROR,this.onError,this),e.on(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(v.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(v.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){let{hls:e}=this;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.ERROR,this.onError,this),e.off(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(v.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(v.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(e){this.stopLoad(),this.state=N.IDLE,this.setInterval(xT),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){let{frag:r,success:s}=t;if(this.fragPrevious=r,this.state=N.IDLE,!s)return;let n=this.tracksBuffered[this.currentTrackId];if(!n)return;let a,o=r.start;for(let d=0;d<n.length;d++)if(o>=n[d].start&&o<=n[d].end){a=n[d];break}let l=r.start+r.duration;a?a.end=l:(a={start:o,end:l},n.push(a)),this.fragmentTracker.fragBuffered(r),this.fragBufferedComplete(r,null)}onBufferFlushing(e,t){let{startOffset:r,endOffset:s}=t;if(r===0&&s!==Number.POSITIVE_INFINITY){let n=s-1;if(n<=0)return;t.endOffsetSubtitles=Math.max(0,n),this.tracksBuffered.forEach(a=>{for(let o=0;o<a.length;){if(a[o].end<=n){a.shift();continue}else if(a[o].start<n)a[o].start=n;else break;o++}}),this.fragmentTracker.removeFragmentsInRange(r,n,J.SUBTITLE)}}onFragBuffered(e,t){if(!this.loadedmetadata&&t.frag.type===J.MAIN){var r;(r=this.media)!=null&&r.buffered.length&&(this.loadedmetadata=!0)}}onError(e,t){let r=t.frag;(r==null?void 0:r.type)===J.SUBTITLE&&(t.details===C.FRAG_GAP&&this.fragmentTracker.fragBuffered(r,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==N.STOPPED&&(this.state=N.IDLE))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(this.levels&&A_(this.levels,t)){this.levels=t.map(r=>new Mr(r));return}this.tracksBuffered=[],this.levels=t.map(r=>{let s=new Mr(r);return this.tracksBuffered[s.id]=[],s}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,J.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null}onSubtitleTrackSwitch(e,t){var r;if(this.currentTrackId=t.id,!((r=this.levels)!=null&&r.length)||this.currentTrackId===-1){this.clearInterval();return}let s=this.levels[this.currentTrackId];s!=null&&s.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,s&&this.setInterval(xT)}onSubtitleTrackLoaded(e,t){var r;let{currentTrackId:s,levels:n}=this,{details:a,id:o}=t;if(!n){this.warn(`Subtitle tracks were reset while loading level ${o}`);return}let l=n[o];if(o>=n.length||!l)return;this.log(`Subtitle track ${o} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""},duration:${a.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let d=0;if(a.live||(r=l.details)!=null&&r.live){let c=this.mainDetails;if(a.deltaUpdateFailed||!c)return;let h=c.fragments[0];if(!l.details)a.hasProgramDateTime&&c.hasProgramDateTime?(ec(a,c),d=a.fragments[0].start):h&&(d=h.start,Kp(a,d));else{var u;d=this.alignPlaylists(a,l.details,(u=this.levelLastLoaded)==null?void 0:u.details),d===0&&h&&(d=h.start,Kp(a,d))}}l.details=a,this.levelLastLoaded=l,o===s&&(!this.startFragRequested&&(this.mainDetails||!a.live)&&this.setStartPosition(this.mainDetails||a,d),this.tick(),a.live&&!this.fragCurrent&&this.media&&this.state===N.IDLE&&(Ju(null,a.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),l.details=void 0)))}_handleFragmentLoadComplete(e){let{frag:t,payload:r}=e,s=t.decryptdata,n=this.hls;if(!this.fragContextChanged(t)&&r&&r.byteLength>0&&s!=null&&s.key&&s.iv&&s.method==="AES-128"){let a=performance.now();this.decrypter.decrypt(new Uint8Array(r),s.key.buffer,s.iv.buffer).catch(o=>{throw n.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:C.FRAG_DECRYPT_ERROR,fatal:!1,error:o,reason:o.message,frag:t}),o}).then(o=>{let l=performance.now();n.trigger(v.FRAG_DECRYPTED,{frag:t,payload:o,stats:{tstart:a,tdecrypt:l}})}).catch(o=>{this.warn(`${o.name}: ${o.message}`),this.state=N.IDLE})}}doTick(){if(!this.media){this.state=N.IDLE;return}if(this.state===N.IDLE){let{currentTrackId:e,levels:t}=this,r=t==null?void 0:t[e];if(!r||!t.length||!r.details)return;let{config:s}=this,n=this.getLoadPosition(),a=Ue.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,s.maxBufferHole),{end:o,len:l}=a,d=this.getFwdBufferInfo(this.media,J.MAIN),u=r.details,c=this.getMaxBufferLength(d==null?void 0:d.len)+u.levelTargetDuration;if(l>c)return;let h=u.fragments,f=h.length,m=u.edge,p=null,g=this.fragPrevious;if(o<m){let E=s.maxFragLookUpTolerance,T=o>m-E?0:E;p=Ju(g,h,Math.max(h[0].start,o),T),!p&&g&&g.start<h[0].start&&(p=h[0])}else p=h[f-1];if(!p)return;if(p=this.mapToInitFragWhenRequired(p),p.sn!=="initSegment"){let E=p.sn-u.startSN,T=h[E-1];T&&T.cc===p.cc&&this.fragmentTracker.getState(T)===ft.NOT_LOADED&&(p=T)}this.fragmentTracker.getState(p)===ft.NOT_LOADED&&this.loadFragment(p,r,o)}}getMaxBufferLength(e){let t=super.getMaxBufferLength();return e?Math.max(t,e):t}loadFragment(e,t,r){this.fragCurrent=e,e.sn==="initSegment"?this._loadInitSegment(e,t):(this.startFragRequested=!0,super.loadFragment(e,t,r))}get mediaBufferTimeRanges(){return new vg(this.tracksBuffered[this.currentTrackId]||[])}},vg=class{constructor(e){this.buffered=void 0;let t=(r,s,n)=>{if(s=s>>>0,s>n-1)throw new DOMException(`Failed to execute '${r}' on 'TimeRanges': The index provided (${s}) is greater than the maximum bound (${n})`);return e[s][r]};this.buffered={get length(){return e.length},end(r){return t("end",r,e.length)},start(r){return t("start",r,e.length)}}}},Eg=class extends co{constructor(e){super(e,"[subtitle-track-controller]"),this.media=null,this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.onTextTracksChanged=()=>{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let t=null,r=Nu(this.media.textTracks);for(let n=0;n<r.length;n++)if(r[n].mode==="hidden")t=r[n];else if(r[n].mode==="showing"){t=r[n];break}let s=this.findTrackForTextTrack(t);this.subtitleTrack!==s&&this.setSubtitleTrack(s)},this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}registerListeners(){let{hls:e}=this;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.LEVEL_LOADING,this.onLevelLoading,this),e.on(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(v.ERROR,this.onError,this)}unregisterListeners(){let{hls:e}=this;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.LEVEL_LOADING,this.onLevelLoading,this),e.off(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(v.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}pollTrackChange(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,e)}onMediaDetaching(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),Nu(this.media.textTracks).forEach(t=>{Hn(t)}),this.subtitleTrack=-1,this.media=null}onManifestLoading(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){let{id:r,groupId:s,details:n}=t,a=this.tracksInGroup[r];if(!a||a.groupId!==s){this.warn(`Subtitle track with id:${r} and group:${s} not found in active group ${a==null?void 0:a.groupId}`);return}let o=a.details;a.details=t.details,this.log(`Subtitle track ${r} "${a.name}" lang:${a.lang} group:${s} loaded [${n.startSN}-${n.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){let t=this.hls.levels[e];if(!t)return;let r=t.subtitleGroups||null,s=this.groupIds,n=this.currentTrack;if(!r||(s==null?void 0:s.length)!==(r==null?void 0:r.length)||r!=null&&r.some(a=>(s==null?void 0:s.indexOf(a))===-1)){this.groupIds=r,this.trackId=-1,this.currentTrack=null;let a=this.tracks.filter(u=>!r||r.indexOf(u.groupId)!==-1);if(a.length)this.selectDefaultTrack&&!a.some(u=>u.default)&&(this.selectDefaultTrack=!1),a.forEach((u,c)=>{u.id=c});else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=a;let o=this.hls.config.subtitlePreference;if(!n&&o){this.selectDefaultTrack=!1;let u=Xi(o,a);if(u>-1)n=a[u];else{let c=Xi(o,this.tracks);n=this.tracks[c]}}let l=this.findTrackId(n);l===-1&&n&&(l=this.findTrackId(null));let d={subtitleTracks:a};this.log(`Updating subtitle tracks, ${a.length} track(s) found in "${r==null?void 0:r.join(",")}" group-id`),this.hls.trigger(v.SUBTITLE_TRACKS_UPDATED,d),l!==-1&&this.trackId===-1&&this.setSubtitleTrack(l)}else this.shouldReloadPlaylist(n)&&this.setSubtitleTrack(this.trackId)}findTrackId(e){let t=this.tracksInGroup,r=this.selectDefaultTrack;for(let s=0;s<t.length;s++){let n=t[s];if(!(r&&!n.default||!r&&!e)&&(!e||Wn(n,e)))return s}if(e){for(let s=0;s<t.length;s++){let n=t[s];if(Yn(e.attrs,n.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return s}for(let s=0;s<t.length;s++){let n=t[s];if(Yn(e.attrs,n.attrs,["LANGUAGE"]))return s}}return-1}findTrackForTextTrack(e){if(e){let t=this.tracksInGroup;for(let r=0;r<t.length;r++){let s=t[r];if(fg(s,e))return r}}return-1}onError(e,t){t.fatal||!t.context||t.context.type===ge.SUBTITLE_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&this.checkRetry(t)}get allSubtitleTracks(){return this.tracks}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e)}setSubtitleOption(e){if(this.hls.config.subtitlePreference=e,e){let t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){let r=this.currentTrack;if(r&&Wn(e,r))return r;let s=Xi(e,this.tracksInGroup);if(s>-1){let n=this.tracksInGroup[s];return this.setSubtitleTrack(s),n}else{if(r)return null;{let n=Xi(e,t);if(n>-1)return t[n]}}}}return null}loadPlaylist(e){super.loadPlaylist();let t=this.currentTrack;if(this.shouldLoadPlaylist(t)&&t){let r=t.id,s=t.groupId,n=t.url;if(e)try{n=e.addDirectives(n)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}this.log(`Loading subtitle playlist for id ${r}`),this.hls.trigger(v.SUBTITLE_TRACK_LOADING,{url:n,id:r,groupId:s,deliveryDirectives:e||null})}}toggleTrackModes(){let{media:e}=this;if(!e)return;let t=Nu(e.textTracks),r=this.currentTrack,s;if(r&&(s=t.filter(n=>fg(r,n))[0],s||this.warn(`Unable to find subtitle TextTrack with name "${r.name}" and language "${r.lang}"`)),[].slice.call(t).forEach(n=>{n.mode!=="disabled"&&n!==s&&(n.mode="disabled")}),s){let n=this.subtitleDisplay?"showing":"hidden";s.mode!==n&&(s.mode=n)}}setSubtitleTrack(e){let t=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(e<-1||e>=t.length||!q(e)){this.warn(`Invalid subtitle track id: ${e}`);return}this.clearTimer(),this.selectDefaultTrack=!1;let r=this.currentTrack,s=t[e]||null;if(this.trackId=e,this.currentTrack=s,this.toggleTrackModes(),!s){this.hls.trigger(v.SUBTITLE_TRACK_SWITCH,{id:e});return}let n=!!s.details&&!s.details.live;if(e===this.trackId&&s===r&&n)return;this.log(`Switching to subtitle-track ${e}`+(s?` "${s.name}" lang:${s.lang} group:${s.groupId}`:""));let{id:a,groupId:o="",name:l,type:d,url:u}=s;this.hls.trigger(v.SUBTITLE_TRACK_SWITCH,{id:a,groupId:o,name:l,type:d,url:u});let c=this.switchParams(s.url,r==null?void 0:r.details,s.details);this.loadPlaylist(c)}},bg=class{constructor(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}append(e,t,r){let s=this.queues[t];s.push(e),s.length===1&&!r&&this.executeNext(t)}insertAbort(e,t){this.queues[t].unshift(e),this.executeNext(t)}appendBlocker(e){let t,r=new Promise(n=>{t=n}),s={execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(s,e),r}executeNext(e){let t=this.queues[e];if(t.length){let r=t[0];try{r.execute()}catch(s){I.warn(`[buffer-operation-queue]: Exception executing "${e}" SourceBuffer operation: ${s}`),r.onError(s);let n=this.buffers[e];n!=null&&n.updating||this.shiftAndExecuteNext(e)}}}shiftAndExecuteNext(e){this.queues[e].shift(),this.executeNext(e)}current(e){return this.queues[e][0]}},LT=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,yg=class{constructor(e){this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendSource=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this.log=void 0,this.warn=void 0,this.error=void 0,this._onEndStreaming=r=>{this.hls&&this.hls.pauseBuffering()},this._onStartStreaming=r=>{this.hls&&this.hls.resumeBuffering()},this._onMediaSourceOpen=()=>{let{media:r,mediaSource:s}=this;this.log("Media source opened"),r&&(r.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(v.MEDIA_ATTACHED,{media:r,mediaSource:s})),s&&s.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{this.log("Media source closed")},this._onMediaSourceEnded=()=>{this.log("Media source ended")},this._onMediaEmptied=()=>{let{mediaSrc:r,_objectUrl:s}=this;r!==s&&I.error(`Media element src was set while attaching MediaSource (${s} > ${r})`)},this.hls=e;let t="[buffer-controller]";this.appendSource=VI(Is(e.config.preferManagedMediaSource)),this.log=I.log.bind(I,t),this.warn=I.warn.bind(I,t),this.error=I.error.bind(I,t),this._initSourceBuffer(),this.registerListeners()}hasSourceTypes(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null,this.hls=null}registerListeners(){let{hls:e}=this;e.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.BUFFER_RESET,this.onBufferReset,this),e.on(v.BUFFER_APPENDING,this.onBufferAppending,this),e.on(v.BUFFER_CODECS,this.onBufferCodecs,this),e.on(v.BUFFER_EOS,this.onBufferEos,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(v.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(v.FRAG_PARSED,this.onFragParsed,this),e.on(v.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){let{hls:e}=this;e.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.BUFFER_RESET,this.onBufferReset,this),e.off(v.BUFFER_APPENDING,this.onBufferAppending,this),e.off(v.BUFFER_CODECS,this.onBufferCodecs,this),e.off(v.BUFFER_EOS,this.onBufferEos,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(v.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(v.FRAG_PARSED,this.onFragParsed,this),e.off(v.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new bg(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.appendErrors={audio:0,video:0,audiovideo:0},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){let r=2;(t.audio&&!t.video||!t.altAudio)&&(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,this.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(e,t){let r=this.media=t.media,s=Is(this.appendSource);if(r&&s){var n;let a=this.mediaSource=new s;this.log(`created media source: ${(n=a.constructor)==null?void 0:n.name}`),a.addEventListener("sourceopen",this._onMediaSourceOpen),a.addEventListener("sourceended",this._onMediaSourceEnded),a.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(a.addEventListener("startstreaming",this._onStartStreaming),a.addEventListener("endstreaming",this._onEndStreaming));let o=this._objectUrl=self.URL.createObjectURL(a);if(this.appendSource)try{r.removeAttribute("src");let l=self.ManagedMediaSource;r.disableRemotePlayback=r.disableRemotePlayback||l&&a instanceof l,kT(r),lw(r,o),r.load()}catch{r.src=o}else r.src=o;r.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){let{media:e,mediaSource:t,_objectUrl:r}=this;if(t){if(this.log("media source detaching"),t.readyState==="open")try{t.endOfStream()}catch(s){this.warn(`onMediaDetaching: ${s.message} while calling endOfStream`)}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(t.removeEventListener("startstreaming",this._onStartStreaming),t.removeEventListener("endstreaming",this._onEndStreaming)),e&&(e.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),this.mediaSrc===r?(e.removeAttribute("src"),this.appendSource&&kT(e),e.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(v.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach(e=>{this.resetBuffer(e)}),this._initSourceBuffer()}resetBuffer(e){let t=this.sourceBuffer[e];try{if(t){var r;this.removeBufferListeners(e),this.sourceBuffer[e]=void 0,(r=this.mediaSource)!=null&&r.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(t)}}catch(s){this.warn(`onBufferReset ${e}`,s)}}onBufferCodecs(e,t){let r=this.getSourceBufferTypes().length,s=Object.keys(t);if(s.forEach(a=>{if(r){let l=this.tracks[a];if(l&&typeof l.buffer.changeType=="function"){var o;let{id:d,codec:u,levelCodec:c,container:h,metadata:f}=t[a],m=Jy(l.codec,l.levelCodec),p=m==null?void 0:m.replace(LT,"$1"),g=Jy(u,c),E=(o=g)==null?void 0:o.replace(LT,"$1");if(g&&p!==E){a.slice(0,5)==="audio"&&(g=zu(g,this.appendSource));let T=`${h};codecs=${g}`;this.appendChangeType(a,T),this.log(`switching codec ${m} to ${g}`),this.tracks[a]={buffer:l.buffer,codec:u,container:h,levelCodec:c,metadata:f,id:d}}}}else this.pendingTracks[a]=t[a]}),r)return;let n=Math.max(this.bufferCodecEventsExpected-1,0);this.bufferCodecEventsExpected!==n&&(this.log(`${n} bufferCodec event(s) expected ${s.join(",")}`),this.bufferCodecEventsExpected=n),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()}appendChangeType(e,t){let{operationQueue:r}=this,s={execute:()=>{let n=this.sourceBuffer[e];n&&(this.log(`changing ${e} sourceBuffer type to ${t}`),n.changeType(t)),r.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:n=>{this.warn(`Failed to change ${e} SourceBuffer type`,n)}};r.append(s,e,!!this.pendingTracks[e])}onBufferAppending(e,t){let{hls:r,operationQueue:s,tracks:n}=this,{data:a,type:o,frag:l,part:d,chunkMeta:u}=t,c=u.buffering[o],h=self.performance.now();c.start=h;let f=l.stats.buffering,m=d?d.stats.buffering:null;f.start===0&&(f.start=h),m&&m.start===0&&(m.start=h);let p=n.audio,g=!1;o==="audio"&&(p==null?void 0:p.container)==="audio/mpeg"&&(g=!this.lastMpegAudioChunk||u.id===1||this.lastMpegAudioChunk.sn!==u.sn,this.lastMpegAudioChunk=u);let E=l.start,T={execute:()=>{if(c.executeStart=self.performance.now(),g){let y=this.sourceBuffer[o];if(y){let S=E-y.timestampOffset;Math.abs(S)>=.1&&(this.log(`Updating audio SourceBuffer timestampOffset to ${E} (delta: ${S}) sn: ${l.sn})`),y.timestampOffset=E)}}this.appendExecutor(a,o)},onStart:()=>{},onComplete:()=>{let y=self.performance.now();c.executeEnd=c.end=y,f.first===0&&(f.first=y),m&&m.first===0&&(m.first=y);let{sourceBuffer:S}=this,A={};for(let L in S)A[L]=Ue.getBuffered(S[L]);this.appendErrors[o]=0,o==="audio"||o==="video"?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(v.BUFFER_APPENDED,{type:o,frag:l,part:d,chunkMeta:u,parent:l.type,timeRanges:A})},onError:y=>{let S={type:ie.MEDIA_ERROR,parent:l.type,details:C.BUFFER_APPEND_ERROR,sourceBufferName:o,frag:l,part:d,chunkMeta:u,error:y,err:y,fatal:!1};if(y.code===DOMException.QUOTA_EXCEEDED_ERR)S.details=C.BUFFER_FULL_ERROR;else{let A=++this.appendErrors[o];S.details=C.BUFFER_APPEND_ERROR,this.warn(`Failed ${A}/${r.config.appendErrorMaxRetry} times to append segment in "${o}" sourceBuffer`),A>=r.config.appendErrorMaxRetry&&(S.fatal=!0)}r.trigger(v.ERROR,S)}};s.append(T,o,!!this.pendingTracks[o])}onBufferFlushing(e,t){let{operationQueue:r}=this,s=n=>({execute:this.removeExecutor.bind(this,n,t.startOffset,t.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(v.BUFFER_FLUSHED,{type:n})},onError:a=>{this.warn(`Failed to remove from ${n} SourceBuffer`,a)}});t.type?r.append(s(t.type),t.type):this.getSourceBufferTypes().forEach(n=>{r.append(s(n),n)})}onFragParsed(e,t){let{frag:r,part:s}=t,n=[],a=s?s.elementaryStreams:r.elementaryStreams;a[ke.AUDIOVIDEO]?n.push("audiovideo"):(a[ke.AUDIO]&&n.push("audio"),a[ke.VIDEO]&&n.push("video"));let o=()=>{let l=self.performance.now();r.stats.buffering.end=l,s&&(s.stats.buffering.end=l);let d=s?s.stats:r.stats;this.hls.trigger(v.FRAG_BUFFERED,{frag:r,part:s,stats:d,id:r.type})};n.length===0&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${r.type} level: ${r.level} sn: ${r.sn}`),this.blockBuffers(o,n)}onFragChanged(e,t){this.trimBuffers()}onBufferEos(e,t){this.getSourceBufferTypes().reduce((s,n)=>{let a=this.sourceBuffer[n];return a&&(!t.type||t.type===n)&&(a.ending=!0,a.ended||(a.ended=!0,this.log(`${n} sourceBuffer now EOS`))),s&&!!(!a||a.ended)},!0)&&(this.log("Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(n=>{let a=this.sourceBuffer[n];a&&(a.ending=!1)});let{mediaSource:s}=this;if(!s||s.readyState!=="open"){s&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${s.readyState}`);return}this.log("Calling mediaSource.endOfStream()"),s.endOfStream()}))}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}trimBuffers(){let{hls:e,details:t,media:r}=this;if(!r||t===null||!this.getSourceBufferTypes().length)return;let n=e.config,a=r.currentTime,o=t.levelTargetDuration,l=t.live&&n.liveBackBufferLength!==null?n.liveBackBufferLength:n.backBufferLength;if(q(l)&&l>0){let d=Math.max(l,o),u=Math.floor(a/o)*o-d;this.flushBackBuffer(a,o,u)}if(q(n.frontBufferFlushThreshold)&&n.frontBufferFlushThreshold>0){let d=Math.max(n.maxBufferLength,n.frontBufferFlushThreshold),u=Math.max(d,o),c=Math.floor(a/o)*o+u;this.flushFrontBuffer(a,o,c)}}flushBackBuffer(e,t,r){let{details:s,sourceBuffer:n}=this;this.getSourceBufferTypes().forEach(o=>{let l=n[o];if(l){let d=Ue.getBuffered(l);if(d.length>0&&r>d.start(0)){if(this.hls.trigger(v.BACK_BUFFER_REACHED,{bufferEnd:r}),s!=null&&s.live)this.hls.trigger(v.LIVE_BACK_BUFFER_REACHED,{bufferEnd:r});else if(l.ended&&d.end(d.length-1)-e<t*2){this.log(`Cannot flush ${o} back buffer while SourceBuffer is in ended state`);return}this.hls.trigger(v.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:o})}}})}flushFrontBuffer(e,t,r){let{sourceBuffer:s}=this;this.getSourceBufferTypes().forEach(a=>{let o=s[a];if(o){let l=Ue.getBuffered(o),d=l.length;if(d<2)return;let u=l.start(d-1),c=l.end(d-1);if(r>u||e>=u&&e<=c)return;if(o.ended&&e-c<2*t){this.log(`Cannot flush ${a} front buffer while SourceBuffer is in ended state`);return}this.hls.trigger(v.BUFFER_FLUSHING,{startOffset:u,endOffset:1/0,type:a})}})}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;let{details:e,hls:t,media:r,mediaSource:s}=this,n=e.fragments[0].start+e.totalduration,a=r.duration,o=q(s.duration)?s.duration:0;e.live&&t.config.liveDurationInfinity?(s.duration=1/0,this.updateSeekableRange(e)):(n>o&&n>a||!q(a))&&(this.log(`Updating Media Source duration to ${n.toFixed(3)}`),s.duration=n)}updateSeekableRange(e){let t=this.mediaSource,r=e.fragments;if(r.length&&e.live&&t!=null&&t.setLiveSeekableRange){let n=Math.max(0,r[0].start),a=Math.max(n,n+e.totalduration);this.log(`Media Source duration is set to ${t.duration}. Setting seekable range to ${n}-${a}.`),t.setLiveSeekableRange(n,a)}}checkPendingTracks(){let{bufferCodecEventsExpected:e,operationQueue:t,pendingTracks:r}=this,s=Object.keys(r).length;if(s&&(!e||s===2||"audiovideo"in r)){this.createSourceBuffers(r),this.pendingTracks={};let n=this.getSourceBufferTypes();if(n.length)this.hls.trigger(v.BUFFER_CREATED,{tracks:this.tracks}),n.forEach(a=>{t.executeNext(a)});else{let a=new Error("could not create source buffer for media codec(s)");this.hls.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:C.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:a,reason:a.message})}}}createSourceBuffers(e){let{sourceBuffer:t,mediaSource:r}=this;if(!r)throw Error("createSourceBuffers called when mediaSource was null");for(let n in e)if(!t[n]){var s;let a=e[n];if(!a)throw Error(`source buffer exists for track ${n}, however track does not`);let o=((s=a.levelCodec)==null?void 0:s.indexOf(","))===-1?a.levelCodec:a.codec;o&&n.slice(0,5)==="audio"&&(o=zu(o,this.appendSource));let l=`${a.container};codecs=${o}`;this.log(`creating sourceBuffer(${l})`);try{let d=t[n]=r.addSourceBuffer(l),u=n;this.addBufferListener(u,"updatestart",this._onSBUpdateStart),this.addBufferListener(u,"updateend",this._onSBUpdateEnd),this.addBufferListener(u,"error",this._onSBUpdateError),this.appendSource&&this.addBufferListener(u,"bufferedchange",(c,h)=>{let f=h.removedRanges;f!=null&&f.length&&this.hls.trigger(v.BUFFER_FLUSHED,{type:n})}),this.tracks[n]={buffer:d,codec:o,container:a.container,levelCodec:a.levelCodec,metadata:a.metadata,id:a.id}}catch(d){this.error(`error while trying to add sourceBuffer: ${d.message}`),this.hls.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:C.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:d,sourceBufferName:n,mimeType:l})}}}get mediaSrc(){var e;let t=((e=this.media)==null?void 0:e.firstChild)||this.media;return t==null?void 0:t.src}_onSBUpdateStart(e){let{operationQueue:t}=this;t.current(e).onStart()}_onSBUpdateEnd(e){var t;if(((t=this.mediaSource)==null?void 0:t.readyState)==="closed"){this.resetBuffer(e);return}let{operationQueue:r}=this;r.current(e).onComplete(),r.shiftAndExecuteNext(e)}_onSBUpdateError(e,t){var r;let s=new Error(`${e} SourceBuffer error. MediaSource readyState: ${(r=this.mediaSource)==null?void 0:r.readyState}`);this.error(`${s}`,t),this.hls.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:C.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:s,fatal:!1});let n=this.operationQueue.current(e);n&&n.onError(s)}removeExecutor(e,t,r){let{media:s,mediaSource:n,operationQueue:a,sourceBuffer:o}=this,l=o[e];if(!s||!n||!l){this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),a.shiftAndExecuteNext(e);return}let d=q(s.duration)?s.duration:1/0,u=q(n.duration)?n.duration:1/0,c=Math.max(0,t),h=Math.min(r,d,u);h>c&&(!l.ending||l.ended)?(l.ended=!1,this.log(`Removing [${c},${h}] from the ${e} SourceBuffer`),l.remove(c,h)):a.shiftAndExecuteNext(e)}appendExecutor(e,t){let r=this.sourceBuffer[t];if(!r){if(!this.pendingTracks[t])throw new Error(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);return}r.ended=!1,r.appendBuffer(e)}blockBuffers(e,t=this.getSourceBufferTypes()){if(!t.length){this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}let{operationQueue:r}=this,s=t.map(n=>r.appendBlocker(n));Promise.all(s).then(()=>{e(),t.forEach(n=>{let a=this.sourceBuffer[n];a!=null&&a.updating||r.shiftAndExecuteNext(n)})})}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(e,t,r){let s=this.sourceBuffer[e];if(!s)return;let n=r.bind(this,e);this.listeners[e].push({event:t,listener:n}),s.addEventListener(t,n)}removeBufferListeners(e){let t=this.sourceBuffer[e];t&&this.listeners[e].forEach(r=>{t.removeEventListener(r.event,r.listener)})}};function kT(i){let e=i.querySelectorAll("source");[].slice.call(e).forEach(t=>{i.removeChild(t)})}function lw(i,e){let t=self.document.createElement("source");t.type="video/mp4",t.src=e,i.appendChild(t)}var dw={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},S_=i=>String.fromCharCode(dw[i]||i),bi=15,ur=100,uw={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},cw={17:2,18:4,21:6,22:8,23:10,19:13,20:15},hw={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},fw={25:2,26:4,29:6,30:8,31:10,27:13,28:15},mw=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],Tg=class{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){let r=typeof t=="function"?t():t;I.log(`${this.time} [${e}] ${r}`)}}},As=function(e){let t=[];for(let r=0;r<e.length;r++)t.push(e[r].toString(16));return t},dc=class{constructor(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(e){let t=["foreground","underline","italics","background","flash"];for(let r=0;r<t.length;r++){let s=t[r];e.hasOwnProperty(s)&&(this[s]=e[s])}}isDefault(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash}equals(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}copy(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}},_g=class{constructor(){this.uchar=" ",this.penState=new dc}reset(){this.uchar=" ",this.penState.reset()}setChar(e,t){this.uchar=e,this.penState.copy(t)}setPenState(e){this.penState.copy(e)}equals(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}copy(e){this.uchar=e.uchar,this.penState.copy(e.penState)}isEmpty(){return this.uchar===" "&&this.penState.isDefault()}},Ag=class{constructor(e){this.chars=[],this.pos=0,this.currPenState=new dc,this.cueStartTime=null,this.logger=void 0;for(let t=0;t<ur;t++)this.chars.push(new _g);this.logger=e}equals(e){for(let t=0;t<ur;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}copy(e){for(let t=0;t<ur;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<ur;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}setCursor(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>ur&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=ur)}moveCursor(e){let t=this.pos+e;if(e>1)for(let r=this.pos+1;r<t+1;r++)this.chars[r].setPenState(this.currPenState);this.setCursor(t)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(e){e>=144&&this.backSpace();let t=S_(e);if(this.pos>=ur){this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1)}clearFromPos(e){let t;for(t=e;t<ur;t++)this.chars[t].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){let e=[],t=!0;for(let r=0;r<ur;r++){let s=this.chars[r].uchar;s!==" "&&(t=!1),e.push(s)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}},ao=class{constructor(e){this.rows=[],this.currRow=bi-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<bi;t++)this.rows.push(new Ag(e));this.logger=e}reset(){for(let e=0;e<bi;e++)this.rows[e].clear();this.currRow=bi-1}equals(e){let t=!0;for(let r=0;r<bi;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t}copy(e){for(let t=0;t<bi;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<bi;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(e){this.rows[this.currRow].insertChar(e)}setPen(e){this.rows[this.currRow].setPenStyles(e)}moveCursor(e){this.rows[this.currRow].moveCursor(e)}setCursor(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)}setPAC(e){this.logger.log(2,()=>"pacData = "+JSON.stringify(e));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let o=0;o<bi;o++)this.rows[o].clear();let n=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){let o=a.rows[n].cueStartTime,l=this.logger.time;if(o!==null&&l!==null&&o<l)for(let d=0;d<this.nrRollUpRows;d++)this.rows[t-this.nrRollUpRows+d+1].copy(a.rows[n+d])}}this.currRow=t;let r=this.rows[this.currRow];if(e.indent!==null){let n=e.indent,a=Math.max(n-1,0);r.setCursor(e.indent),e.color=r.chars[a].penState.foreground}let s={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(s)}setBkgData(e){this.logger.log(2,()=>"bkgData = "+JSON.stringify(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){if(this.nrRollUpRows===null){this.logger.log(3,"roll_up but nrRollUpRows not set yet");return}this.logger.log(1,()=>this.getDisplayText());let e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}getDisplayText(e){e=e||!1;let t=[],r="",s=-1;for(let n=0;n<bi;n++){let a=this.rows[n].getTextString();a&&(s=n+1,e?t.push("Row "+s+": '"+a+"'"):t.push(a.trim()))}return t.length>0&&(e?r="["+t.join(" | ")+"]":r=t.join(`
1592
+ `)),r}getTextAndFormat(){return this.rows}},uc=class{constructor(e,t,r){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new ao(r),this.nonDisplayedMemory=new ao(r),this.lastOutputScreen=new ao(r),this.currRollUpRow=this.displayedMemory.rows[bi-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=r}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[bi-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(e){this.outputFilter=e}setPAC(e){this.writeScreen.setPAC(e)}setBkgData(e){this.writeScreen.setBkgData(e)}setMode(e){e!==this.mode&&(this.mode=e,this.logger.log(2,()=>"MODE="+e),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}insertChars(e){for(let r=0;r<e.length;r++)this.writeScreen.insertChar(e[r]);let t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>t+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){let e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}ccMIDROW(e){let t={flash:!1};if(t.underline=e%2===1,t.italics=e>=46,t.italics)t.foreground="white";else{let r=Math.floor(e/2)-16,s=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=s[r]}this.logger.log(2,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){let t=this.logger.time;t!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=t:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t),this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}},cc=class{constructor(e,t,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=gw(),this.logger=void 0;let s=this.logger=new Tg;this.channels=[null,new uc(e,t,s),new uc(e+1,r,s)]}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){this.logger.time=e;for(let r=0;r<t.length;r+=2){let s=t[r]&127,n=t[r+1]&127,a=!1,o=null;if(s===0&&n===0)continue;this.logger.log(3,()=>"["+As([t[r],t[r+1]])+"] -> ("+As([s,n])+")");let l=this.cmdHistory;if(s>=16&&s<=31){if(pw(s,n,l)){Du(null,null,l),this.logger.log(3,()=>"Repeated command ("+As([s,n])+") is dropped");continue}Du(s,n,this.cmdHistory),a=this.parseCmd(s,n),a||(a=this.parseMidrow(s,n)),a||(a=this.parsePAC(s,n)),a||(a=this.parseBackgroundAttributes(s,n))}else Du(null,null,l);if(!a&&(o=this.parseChars(s,n),o)){let u=this.currentChannel;u&&u>0?this.channels[u].insertChars(o):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!a&&!o&&this.logger.log(2,()=>"Couldn't parse cleaned data "+As([s,n])+" orig: "+As([t[r],t[r+1]]))}}parseCmd(e,t){let r=(e===20||e===28||e===21||e===29)&&t>=32&&t<=47,s=(e===23||e===31)&&t>=33&&t<=35;if(!(r||s))return!1;let n=e===20||e===21||e===23?1:2,a=this.channels[n];return e===20||e===21||e===28||e===29?t===32?a.ccRCL():t===33?a.ccBS():t===34?a.ccAOF():t===35?a.ccAON():t===36?a.ccDER():t===37?a.ccRU(2):t===38?a.ccRU(3):t===39?a.ccRU(4):t===40?a.ccFON():t===41?a.ccRDC():t===42?a.ccTR():t===43?a.ccRTD():t===44?a.ccEDM():t===45?a.ccCR():t===46?a.ccENM():t===47&&a.ccEOC():a.ccTO(t-32),this.currentChannel=n,!0}parseMidrow(e,t){let r=0;if((e===17||e===25)&&t>=32&&t<=47){if(e===17?r=1:r=2,r!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;let s=this.channels[r];return s?(s.ccMIDROW(t),this.logger.log(3,()=>"MIDROW ("+As([e,t])+")"),!0):!1}return!1}parsePAC(e,t){let r,s=(e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127,n=(e===16||e===24)&&t>=64&&t<=95;if(!(s||n))return!1;let a=e<=23?1:2;t>=64&&t<=95?r=a===1?uw[e]:hw[e]:r=a===1?cw[e]:fw[e];let o=this.channels[a];return o?(o.setPAC(this.interpretPAC(r,t)),this.currentChannel=a,!0):!1}interpretPAC(e,t){let r,s={color:null,italics:!1,indent:null,underline:!1,row:e};return t>95?r=t-96:r=t-64,s.underline=(r&1)===1,r<=13?s.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(s.italics=!0,s.color="white"):s.indent=Math.floor((r-16)/2)*4,s}parseChars(e,t){let r,s=null,n=null;if(e>=25?(r=2,n=e-8):(r=1,n=e),n>=17&&n<=19){let a;n===17?a=t+80:n===18?a=t+112:a=t+144,this.logger.log(2,()=>"Special char '"+S_(a)+"' in channel "+r),s=[a]}else e>=32&&e<=127&&(s=t===0?[e]:[e,t]);return s&&this.logger.log(3,()=>"Char codes = "+As(s).join(",")),s}parseBackgroundAttributes(e,t){let r=(e===16||e===24)&&t>=32&&t<=47,s=(e===23||e===31)&&t>=45&&t<=47;if(!(r||s))return!1;let n,a={};e===16||e===24?(n=Math.floor((t-32)/2),a.background=mw[n],t%2===1&&(a.background=a.background+"_semi")):t===45?a.background="transparent":(a.foreground="black",t===47&&(a.underline=!0));let o=e<=23?1:2;return this.channels[o].setBkgData(a),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){let t=this.channels[e];t&&t.reset()}Du(null,null,this.cmdHistory)}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){let r=this.channels[t];r&&r.cueSplitAtTime(e)}}};function Du(i,e,t){t.a=i,t.b=e}function pw(i,e,t){return t.a===i&&t.b===e}function gw(){return{a:null,b:null}}var Gn=class{constructor(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}dispatchCue(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,t,r){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}},Qg=function(){if(qn!=null&&qn.VTTCue)return self.VTTCue;let i=["","lr","rl"],e=["start","middle","end","left","right"];function t(o,l){if(typeof l!="string"||!Array.isArray(o))return!1;let d=l.toLowerCase();return~o.indexOf(d)?d:!1}function r(o){return t(i,o)}function s(o){return t(e,o)}function n(o,...l){let d=1;for(;d<arguments.length;d++){let u=arguments[d];for(let c in u)o[c]=u[c]}return o}function a(o,l,d){let u=this,c={enumerable:!0};u.hasBeenReset=!1;let h="",f=!1,m=o,p=l,g=d,E=null,T="",y=!0,S="auto",A="start",L=50,x="middle",w=50,P="middle";Object.defineProperty(u,"id",n({},c,{get:function(){return h},set:function(k){h=""+k}})),Object.defineProperty(u,"pauseOnExit",n({},c,{get:function(){return f},set:function(k){f=!!k}})),Object.defineProperty(u,"startTime",n({},c,{get:function(){return m},set:function(k){if(typeof k!="number")throw new TypeError("Start time must be set to a number.");m=k,this.hasBeenReset=!0}})),Object.defineProperty(u,"endTime",n({},c,{get:function(){return p},set:function(k){if(typeof k!="number")throw new TypeError("End time must be set to a number.");p=k,this.hasBeenReset=!0}})),Object.defineProperty(u,"text",n({},c,{get:function(){return g},set:function(k){g=""+k,this.hasBeenReset=!0}})),Object.defineProperty(u,"region",n({},c,{get:function(){return E},set:function(k){E=k,this.hasBeenReset=!0}})),Object.defineProperty(u,"vertical",n({},c,{get:function(){return T},set:function(k){let D=r(k);if(D===!1)throw new SyntaxError("An invalid or illegal string was specified.");T=D,this.hasBeenReset=!0}})),Object.defineProperty(u,"snapToLines",n({},c,{get:function(){return y},set:function(k){y=!!k,this.hasBeenReset=!0}})),Object.defineProperty(u,"line",n({},c,{get:function(){return S},set:function(k){if(typeof k!="number"&&k!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");S=k,this.hasBeenReset=!0}})),Object.defineProperty(u,"lineAlign",n({},c,{get:function(){return A},set:function(k){let D=s(k);if(!D)throw new SyntaxError("An invalid or illegal string was specified.");A=D,this.hasBeenReset=!0}})),Object.defineProperty(u,"position",n({},c,{get:function(){return L},set:function(k){if(k<0||k>100)throw new Error("Position must be between 0 and 100.");L=k,this.hasBeenReset=!0}})),Object.defineProperty(u,"positionAlign",n({},c,{get:function(){return x},set:function(k){let D=s(k);if(!D)throw new SyntaxError("An invalid or illegal string was specified.");x=D,this.hasBeenReset=!0}})),Object.defineProperty(u,"size",n({},c,{get:function(){return w},set:function(k){if(k<0||k>100)throw new Error("Size must be between 0 and 100.");w=k,this.hasBeenReset=!0}})),Object.defineProperty(u,"align",n({},c,{get:function(){return P},set:function(k){let D=s(k);if(!D)throw new SyntaxError("An invalid or illegal string was specified.");P=D,this.hasBeenReset=!0}})),u.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}(),Sg=class{decode(e,t){if(!e)return"";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}};function x_(i){function e(r,s,n,a){return(r|0)*3600+(s|0)*60+(n|0)+parseFloat(a||0)}let t=i.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return t?parseFloat(t[2])>59?e(t[2],t[3],0,t[4]):e(t[1],t[2],t[3],t[4]):null}var xg=class{constructor(){this.values=Object.create(null)}set(e,t){!this.get(e)&&t!==""&&(this.values[e]=t)}get(e,t,r){return r?this.has(e)?this.values[e]:t[r]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,r){for(let s=0;s<r.length;++s)if(t===r[s]){this.set(e,t);break}}integer(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}percent(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){let r=parseFloat(t);if(r>=0&&r<=100)return this.set(e,r),!0}return!1}};function L_(i,e,t,r){let s=r?i.split(r):[i];for(let n in s){if(typeof s[n]!="string")continue;let a=s[n].split(t);if(a.length!==2)continue;let o=a[0],l=a[1];e(o,l)}}var Lg=new Qg(0,0,""),Mu=Lg.align==="middle"?"middle":"center";function vw(i,e,t){let r=i;function s(){let o=x_(i);if(o===null)throw new Error("Malformed timestamp: "+r);return i=i.replace(/^[^\sa-zA-Z-]+/,""),o}function n(o,l){let d=new xg;L_(o,function(h,f){let m;switch(h){case"region":for(let p=t.length-1;p>=0;p--)if(t[p].id===f){d.set(h,t[p].region);break}break;case"vertical":d.alt(h,f,["rl","lr"]);break;case"line":m=f.split(","),d.integer(h,m[0]),d.percent(h,m[0])&&d.set("snapToLines",!1),d.alt(h,m[0],["auto"]),m.length===2&&d.alt("lineAlign",m[1],["start",Mu,"end"]);break;case"position":m=f.split(","),d.percent(h,m[0]),m.length===2&&d.alt("positionAlign",m[1],["start",Mu,"end","line-left","line-right","auto"]);break;case"size":d.percent(h,f);break;case"align":d.alt(h,f,["start",Mu,"end","left","right"]);break}},/:/,/\s/),l.region=d.get("region",null),l.vertical=d.get("vertical","");let u=d.get("line","auto");u==="auto"&&Lg.line===-1&&(u=-1),l.line=u,l.lineAlign=d.get("lineAlign","start"),l.snapToLines=d.get("snapToLines",!0),l.size=d.get("size",100),l.align=d.get("align",Mu);let c=d.get("position","auto");c==="auto"&&Lg.position===50&&(c=l.align==="start"||l.align==="left"?0:l.align==="end"||l.align==="right"?100:50),l.position=c}function a(){i=i.replace(/^\s+/,"")}if(a(),e.startTime=s(),a(),i.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+r);i=i.slice(3),a(),e.endTime=s(),a(),n(i,e)}function k_(i){return i.replace(/<br(?: \/)?>/gi,`
1593
+ `)}var kg=class{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new Sg,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=k_(n);a<n.length&&n[a]!=="\r"&&n[a]!==`
1594
1594
  `;)++a;let o=n.slice(0,a);return n[a]==="\r"&&++a,n[a]===`
1595
- `&&++a,t.buffer=n.slice(a),o}function s(n){k_(n,function(a,o){},/:/)}try{let n="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;n=r();let o=n.match(/^()?WEBVTT([ \t].*)?$/);if(!(o!=null&&o[0]))throw new Error("Malformed WebVTT signature.");t.state="HEADER"}let a=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(a?a=!1:n=r(),t.state){case"HEADER":/:/.test(n)?s(n):n||(t.state="ID");continue;case"NOTE":n||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(n)){t.state="NOTE";break}if(!n)continue;if(t.cue=new Yg(0,0,""),t.state="CUE",n.indexOf("-->")===-1){t.cue.id=n;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{pw(n,t.cue,t.regionList)}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{let o=n.indexOf("-->")!==-1;if(!n||o&&(a=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(t.cue===null)continue;t.cue.text&&(t.cue.text+=`
1595
+ `&&++a,t.buffer=n.slice(a),o}function s(n){L_(n,function(a,o){},/:/)}try{let n="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;n=r();let o=n.match(/^()?WEBVTT([ \t].*)?$/);if(!(o!=null&&o[0]))throw new Error("Malformed WebVTT signature.");t.state="HEADER"}let a=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(a?a=!1:n=r(),t.state){case"HEADER":/:/.test(n)?s(n):n||(t.state="ID");continue;case"NOTE":n||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(n)){t.state="NOTE";break}if(!n)continue;if(t.cue=new Qg(0,0,""),t.state="CUE",n.indexOf("-->")===-1){t.cue.id=n;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{vw(n,t.cue,t.regionList)}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{let o=n.indexOf("-->")!==-1;if(!n||o&&(a=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(t.cue===null)continue;t.cue.text&&(t.cue.text+=`
1596
1596
  `),t.cue.text+=n}continue;case"BADCUE":n||(t.state="ID")}}}catch{t.state==="CUETEXT"&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state=t.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this}flush(){let e=this;try{if((e.cue||e.state==="HEADER")&&(e.buffer+=`
1597
1597
 
1598
- `,e.parse()),e.state==="INITIAL"||e.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}},gw=/\r\n|\n\r|\n|\r/g,_p=function(e,t,r=0){return e.slice(r,r+t.length)===t},vw=function(e){let t=parseInt(e.slice(-3)),r=parseInt(e.slice(-6,-4)),s=parseInt(e.slice(-9,-7)),n=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!q(t)||!q(r)||!q(s)||!q(n))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*r,t+=60*1e3*s,t+=60*60*1e3*n,t},Ap=function(e){let t=5381,r=e.length;for(;r;)t=t*33^e.charCodeAt(--r);return(t>>>0).toString()};function zg(i,e,t){return Ap(i.toString())+Ap(e.toString())+Ap(t)}var Ew=function(e,t,r){let s=e[t],n=e[s.prevCC];if(!n||!n.new&&s.new){e.ccOffset=e.presentationOffset=s.start,s.new=!1;return}for(;(a=n)!=null&&a.new;){var a;e.ccOffset+=s.start-n.start,s.new=!1,s=n,n=e[s.prevCC]}e.presentationOffset=r};function bw(i,e,t,r,s,n,a){let o=new Ag,l=Qi(new Uint8Array(i)).trim().replace(gw,`
1598
+ `,e.parse()),e.state==="INITIAL"||e.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}},Ew=/\r\n|\n\r|\n|\r/g,Lp=function(e,t,r=0){return e.slice(r,r+t.length)===t},bw=function(e){let t=parseInt(e.slice(-3)),r=parseInt(e.slice(-6,-4)),s=parseInt(e.slice(-9,-7)),n=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!q(t)||!q(r)||!q(s)||!q(n))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*r,t+=60*1e3*s,t+=60*60*1e3*n,t},kp=function(e){let t=5381,r=e.length;for(;r;)t=t*33^e.charCodeAt(--r);return(t>>>0).toString()};function Zg(i,e,t){return kp(i.toString())+kp(e.toString())+kp(t)}var yw=function(e,t,r){let s=e[t],n=e[s.prevCC];if(!n||!n.new&&s.new){e.ccOffset=e.presentationOffset=s.start,s.new=!1;return}for(;(a=n)!=null&&a.new;){var a;e.ccOffset+=s.start-n.start,s.new=!1,s=n,n=e[s.prevCC]}e.presentationOffset=r};function Tw(i,e,t,r,s,n,a){let o=new kg,l=Qi(new Uint8Array(i)).trim().replace(Ew,`
1599
1599
  `).split(`
1600
- `),d=[],u=e?tw(e.baseTime,e.timescale):0,c="00:00.000",h=0,f=0,m,p=!0;o.oncue=function(g){let E=t[r],T=t.ccOffset,y=(h-u)/9e4;if(E!=null&&E.new&&(f!==void 0?T=t.ccOffset=E.start:Ew(t,r,y)),y){if(!e){m=new Error("Missing initPTS for VTT MPEGTS");return}T=y-t.presentationOffset}let S=g.endTime-g.startTime,_=Zt((g.startTime+T-f)*9e4,s*9e4)/9e4;g.startTime=Math.max(_,0),g.endTime=Math.max(_+S,0);let L=g.text.trim();g.text=decodeURIComponent(encodeURIComponent(L)),g.id||(g.id=zg(g.startTime,g.endTime,L)),g.endTime>0&&d.push(g)},o.onparsingerror=function(g){m=g},o.onflush=function(){if(m){a(m);return}n(d)},l.forEach(g=>{if(p)if(_p(g,"X-TIMESTAMP-MAP=")){p=!1,g.slice(16).split(",").forEach(E=>{_p(E,"LOCAL:")?c=E.slice(6):_p(E,"MPEGTS:")&&(h=parseInt(E.slice(7)))});try{f=vw(c)/1e3}catch(E){m=E}return}else g===""&&(p=!1);o.parse(g+`
1601
- `)}),o.flush()}var Sp="stpp.ttml.im1t",R_=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,w_=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,yw={left:"start",center:"center",right:"end",start:"start",end:"end"};function RT(i,e,t,r){let s=ne(new Uint8Array(i),["mdat"]);if(s.length===0){r(new Error("Could not parse IMSC1 mdat"));return}let n=s.map(o=>Qi(o)),a=ew(e.baseTime,1,e.timescale);try{n.forEach(o=>t(Tw(o,a)))}catch(o){r(o)}}function Tw(i,e){let s=new DOMParser().parseFromString(i,"text/xml").getElementsByTagName("tt")[0];if(!s)throw new Error("Invalid ttml");let n={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},a=Object.keys(n).reduce((c,h)=>(c[h]=s.getAttribute(`ttp:${h}`)||n[h],c),{}),o=s.getAttribute("xml:space")!=="preserve",l=wT(xp(s,"styling","style")),d=wT(xp(s,"layout","region")),u=xp(s,"body","[begin]");return[].map.call(u,c=>{let h=C_(c,o);if(!h||!c.hasAttribute("begin"))return null;let f=kp(c.getAttribute("begin"),a),m=kp(c.getAttribute("dur"),a),p=kp(c.getAttribute("end"),a);if(f===null)throw CT(c);if(p===null){if(m===null)throw CT(c);p=f+m}let g=new Yg(f-e,p-e,h);g.id=zg(g.startTime,g.endTime,g.text);let E=d[c.getAttribute("region")],T=l[c.getAttribute("style")],y=_w(E,T,l),{textAlign:S}=y;if(S){let _=yw[S];_&&(g.lineAlign=_),g.align=S}return Je(g,y),g}).filter(c=>c!==null)}function xp(i,e,t){let r=i.getElementsByTagName(e)[0];return r?[].slice.call(r.querySelectorAll(t)):[]}function wT(i){return i.reduce((e,t)=>{let r=t.getAttribute("xml:id");return r&&(e[r]=t),e},{})}function C_(i,e){return[].slice.call(i.childNodes).reduce((t,r,s)=>{var n;return r.nodeName==="br"&&s?t+`
1602
- `:(n=r.childNodes)!=null&&n.length?C_(r,e):e?t+r.textContent.trim().replace(/\s+/g," "):t+r.textContent},"")}function _w(i,e,t){let r="http://www.w3.org/ns/ttml#styling",s=null,n=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=i!=null&&i.hasAttribute("style")?i.getAttribute("style"):null;return a&&t.hasOwnProperty(a)&&(s=t[a]),n.reduce((o,l)=>{let d=Lp(e,r,l)||Lp(i,r,l)||Lp(s,r,l);return d&&(o[l]=d),o},{})}function Lp(i,e,t){return i&&i.hasAttributeNS(e,t)?i.getAttributeNS(e,t):null}function CT(i){return new Error(`Could not parse ttml timestamp ${i}`)}function kp(i,e){if(!i)return null;let t=L_(i);return t===null&&(R_.test(i)?t=Aw(i,e):w_.test(i)&&(t=Sw(i,e))),t}function Aw(i,e){let t=R_.exec(i),r=(t[4]|0)+(t[5]|0)/e.subFrameRate;return(t[1]|0)*3600+(t[2]|0)*60+(t[3]|0)+r/e.frameRate}function Sw(i,e){let t=w_.exec(i),r=Number(t[1]);switch(t[2]){case"h":return r*3600;case"m":return r*60;case"ms":return r*1e3;case"f":return r/e.frameRate;case"t":return r/e.tickRate}return r}var Sg=class{constructor(e){this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=MT(),this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},e.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(v.FRAG_LOADING,this.onFragLoading,this),e.on(v.FRAG_LOADED,this.onFragLoaded,this),e.on(v.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(v.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(v.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(v.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){let{hls:e}=this;e.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(v.FRAG_LOADING,this.onFragLoading,this),e.off(v.FRAG_LOADED,this.onFragLoaded,this),e.off(v.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(v.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(v.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(v.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){if(this.config.enableCEA708Captions&&(!this.cea608Parser1||!this.cea608Parser2)){let e=new Gn(this,"textTrack1"),t=new Gn(this,"textTrack2"),r=new Gn(this,"textTrack3"),s=new Gn(this,"textTrack4");this.cea608Parser1=new dc(1,e,t),this.cea608Parser2=new dc(3,r,s)}}addCues(e,t,r,s,n){let a=!1;for(let o=n.length;o--;){let l=n[o],d=xw(l[0],l[1],t,r);if(d>=0&&(l[0]=Math.min(l[0],t),l[1]=Math.max(l[1],r),a=!0,d/(r-t)>.5))return}if(a||n.push([t,r]),this.config.renderTextTracksNatively){let o=this.captionsTracks[e];this.Cues.newCue(o,t,r,s)}else{let o=this.Cues.newCue(null,t,r,s);this.hls.trigger(v.CUES_PARSED,{type:"captions",cues:o,track:e})}}onInitPtsFound(e,{frag:t,id:r,initPTS:s,timescale:n}){let{unparsedVttFrags:a}=this;r==="main"&&(this.initPTS[t.cc]={baseTime:s,timescale:n}),a.length&&(this.unparsedVttFrags=[],a.forEach(o=>{this.onFragLoaded(v.FRAG_LOADED,o)}))}getExistingTrack(e,t){let{media:r}=this;if(r)for(let s=0;s<r.textTracks.length;s++){let n=r.textTracks[s];if(DT(n,{name:e,lang:t,attrs:{}}))return n}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;let{captionsProperties:t,captionsTracks:r,media:s}=this,{label:n,languageCode:a}=t[e],o=this.getExistingTrack(n,a);if(o)r[e]=o,Hn(r[e]),e_(r[e],s);else{let l=this.createTextTrack("captions",n,a);l&&(l[e]=!0,r[e]=l)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;let t=this.captionsProperties[e];if(!t)return;let r=t.label,s={_id:e,label:r,kind:"captions",default:t.media?!!t.media.default:!1,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=s,this.hls.trigger(v.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[s]})}createTextTrack(e,t,r){let s=this.media;if(s)return s.addTextTrack(e,t,r)}onMediaAttaching(e,t){this.media=t.media,this._cleanTracks()}onMediaDetaching(){let{captionsTracks:e}=this;Object.keys(e).forEach(t=>{Hn(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=MT(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){let{media:e}=this;if(!e)return;let t=e.textTracks;if(t)for(let r=0;r<t.length;r++)Hn(t[r])}onSubtitleTracksUpdated(e,t){let r=t.subtitleTracks||[],s=r.some(n=>n.textCodec===Sp);if(this.config.enableWebVTT||s&&this.config.enableIMSC1){if(S_(this.tracks,r)){this.tracks=r;return}if(this.textTracks=[],this.tracks=r,this.config.renderTextTracksNatively){let a=this.media,o=a?Ou(a.textTracks):null;if(this.tracks.forEach((l,d)=>{let u;if(o){let c=null;for(let h=0;h<o.length;h++)if(o[h]&&DT(o[h],l)){c=o[h],o[h]=null;break}c&&(u=c)}if(u)Hn(u);else{let c=D_(l);u=this.createTextTrack(c,l.name,l.lang),u&&(u.mode="disabled")}u&&this.textTracks.push(u)}),o!=null&&o.length){let l=o.filter(d=>d!==null).map(d=>d.label);l.length&&I.warn(`Media element contains unused subtitle tracks: ${l.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){let a=this.tracks.map(o=>({label:o.name,kind:o.type.toLowerCase(),default:o.default,subtitleTrack:o}));this.hls.trigger(v.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:a})}}}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(r=>{let s=/(?:CC|SERVICE)([1-4])/.exec(r.instreamId);if(!s)return;let n=`textTrack${s[1]}`,a=this.captionsProperties[n];a&&(a.label=r.name,r.lang&&(a.languageCode=r.lang),a.media=r)})}closedCaptionsForLevel(e){let t=this.hls.levels[e.level];return t==null?void 0:t.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){this.initCea608Parsers();let{cea608Parser1:r,cea608Parser2:s,lastCc:n,lastSn:a,lastPartIndex:o}=this;if(!(!this.enabled||!r||!s)&&t.frag.type===te.MAIN){var l,d;let{cc:u,sn:c}=t.frag,h=(l=t==null||(d=t.part)==null?void 0:d.index)!=null?l:-1;c===a+1||c===a&&h===o+1||u===n||(r.reset(),s.reset()),this.lastCc=u,this.lastSn=c,this.lastPartIndex=h}}onFragLoaded(e,t){let{frag:r,payload:s}=t;if(r.type===te.SUBTITLE)if(s.byteLength){let n=r.decryptdata,a="stats"in t;if(n==null||!n.encrypted||a){let o=this.tracks[r.level],l=this.vttCCs;l[r.cc]||(l[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),o&&o.textCodec===Sp?this._parseIMSC1(r,s):this._parseVTTs(t)}}else this.hls.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){let r=this.hls;RT(t,this.initPTS[e.cc],s=>{this._appendCues(s,e.level),r.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},s=>{I.log(`Failed to parse IMSC1: ${s}`),r.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:s})})}_parseVTTs(e){var t;let{frag:r,payload:s}=e,{initPTS:n,unparsedVttFrags:a}=this,o=n.length-1;if(!n[r.cc]&&o===-1){a.push(e);return}let l=this.hls,d=(t=r.initSegment)!=null&&t.data?Jt(r.initSegment.data,new Uint8Array(s)):s;bw(d,this.initPTS[r.cc],this.vttCCs,r.cc,r.start,u=>{this._appendCues(u,r.level),l.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:r})},u=>{let c=u.message==="Missing initPTS for VTT MPEGTS";c?a.push(e):this._fallbackToIMSC1(r,s),I.log(`Failed to parse VTT cue: ${u}`),!(c&&o>r.cc)&&l.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:u})})}_fallbackToIMSC1(e,t){let r=this.tracks[e.level];r.textCodec||RT(t,this.initPTS[e.cc],()=>{r.textCodec=Sp,this._parseIMSC1(e,t)},()=>{r.textCodec="wvtt"})}_appendCues(e,t){let r=this.hls;if(this.config.renderTextTracksNatively){let s=this.textTracks[t];if(!s||s.mode==="disabled")return;e.forEach(n=>t_(s,n))}else{let s=this.tracks[t];if(!s)return;let n=s.default?"default":"subtitles"+t;r.trigger(v.CUES_PARSED,{type:"subtitles",cues:e,track:n})}}onFragDecrypted(e,t){let{frag:r}=t;r.type===te.SUBTITLE&&this.onFragLoaded(v.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){this.initCea608Parsers();let{cea608Parser1:r,cea608Parser2:s}=this;if(!this.enabled||!r||!s)return;let{frag:n,samples:a}=t;if(!(n.type===te.MAIN&&this.closedCaptionsForLevel(n)==="NONE"))for(let o=0;o<a.length;o++){let l=a[o].bytes;if(l){let d=this.extractCea608Data(l);r.addData(a[o].pts,d[0]),s.addData(a[o].pts,d[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:r,endOffsetSubtitles:s,type:n}){let{media:a}=this;if(!(!a||a.currentTime<r)){if(!n||n==="video"){let{captionsTracks:o}=this;Object.keys(o).forEach(l=>Op(o[l],t,r))}if(this.config.renderTextTracksNatively&&t===0&&s!==void 0){let{textTracks:o}=this;Object.keys(o).forEach(l=>Op(o[l],t,s))}}}extractCea608Data(e){let t=[[],[]],r=e[0]&31,s=2;for(let n=0;n<r;n++){let a=e[s++],o=127&e[s++],l=127&e[s++];if(o===0&&l===0)continue;if((4&a)!==0){let u=3&a;(u===0||u===1)&&(t[u].push(o),t[u].push(l))}}return t}};function D_(i){return i.characteristics&&/transcribes-spoken-dialog/gi.test(i.characteristics)&&/describes-music-and-sound/gi.test(i.characteristics)?"captions":"subtitles"}function DT(i,e){return!!i&&i.kind===D_(e)&&dg(e,i)}function xw(i,e,t,r){return Math.min(e,r)-Math.max(i,t)}function MT(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}var xg=class i{constructor(e){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(e){this.streamController=e}destroy(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){let{hls:e}=this;e.on(v.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(v.BUFFER_CODECS,this.onBufferCodecs,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){let{hls:e}=this;e.off(v.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(v.BUFFER_CODECS,this.onBufferCodecs,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){let r=this.hls.levels[t.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}onManifestParsed(e,t){let r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onLevelsUpdated(e,t){this.timer&&q(this.autoLevelCapping)&&this.detectPlayerSize()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}let e=this.hls.levels;if(e.length){let t=this.hls,r=this.getMaxLevel(e.length-1);r!==this.autoLevelCapping&&I.log(`Setting autoLevelCapping to ${r}: ${e[r].height}p@${e[r].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=r,t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}getMaxLevel(e){let t=this.hls.levels;if(!t.length)return-1;let r=t.filter((s,n)=>this.isLevelAllowed(s)&&n<=e);return this.clientRect=null,i.getMaxLevelByMediaSize(r,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;let e=this.media,t={width:0,height:0};if(e){let r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,!t.width&&!t.height&&(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch{}return e}isLevelAllowed(e){return!this.restrictedLevels.some(r=>e.bitrate===r.bitrate&&e.width===r.width&&e.height===r.height)}static getMaxLevelByMediaSize(e,t,r){if(!(e!=null&&e.length))return-1;let s=(o,l)=>l?o.width!==l.width||o.height!==l.height:!0,n=e.length-1,a=Math.max(t,r);for(let o=0;o<e.length;o+=1){let l=e[o];if((l.width>=a||l.height>=a)&&s(l,e[o+1])){n=o;break}}return n}},Lg=class{constructor(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}setStreamController(e){this.streamController=e}registerListeners(){this.hls.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){let r=this.hls.config;if(r.capLevelOnFPSDrop){let s=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=s,s&&typeof s.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}}checkFPS(e,t,r){let s=performance.now();if(t){if(this.lastTime){let n=s-this.lastTime,a=r-this.lastDroppedFrames,o=t-this.lastDecodedFrames,l=1e3*a/n,d=this.hls;if(d.trigger(v.FPS_DROP,{currentDropped:a,currentDecoded:o,totalDroppedFrames:r}),l>0&&a>d.config.fpsDroppedMonitoringThreshold*o){let u=d.currentLevel;I.warn("drop FPS ratio greater than max allowed value for currentLevel: "+u),u>0&&(d.autoLevelCapping===-1||d.autoLevelCapping>=u)&&(u=u-1,d.trigger(v.FPS_DROP_LEVEL_CAPPING,{level:u,droppedLevel:d.currentLevel}),d.autoLevelCapping=u,this.streamController.nextLevelSwitch())}}this.lastTime=s,this.lastDroppedFrames=r,this.lastDecodedFrames=t}}checkFPSInterval(){let e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){let t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}},Mu="[eme]",uc=class i{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=i.CDMCleanupPromise?[i.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=I.debug.bind(I,Mu),this.log=I.log.bind(I,Mu),this.warn=I.warn.bind(I,Mu),this.error=I.error.bind(I,Mu),this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.unregisterListeners(),this.onMediaDetached();let e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null}registerListeners(){this.hls.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(v.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(v.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(v.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(v.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(v.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(v.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(e){let{drmSystems:t,widevineLicenseUrl:r}=this.config,s=t[e];if(s)return s.licenseUrl;if(e===Fe.WIDEVINE&&r)return r;throw new Error(`no license server URL configured for key-system "${e}"`)}getServerCertificateUrl(e){let{drmSystems:t}=this.config,r=t[e];if(r)return r.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){let t=this.hls.levels,r=(a,o,l)=>!!a&&l.indexOf(a)===o,s=t.map(a=>a.audioCodec).filter(r),n=t.map(a=>a.videoCodec).filter(r);return s.length+n.length===0&&n.push("avc1.42e01e"),new Promise((a,o)=>{let l=d=>{let u=d.shift();this.getMediaKeysPromise(u,s,n).then(c=>a({keySystem:u,mediaKeys:c})).catch(c=>{d.length?l(d):c instanceof Pt?o(c):o(new Pt({type:ie.KEY_SYSTEM_ERROR,details:C.KEY_SYSTEM_NO_ACCESS,error:c,fatal:!0},c.message))})};l(e)})}requestMediaKeySystemAccess(e,t){let{requestMediaKeySystemAccessFunc:r}=this.config;if(typeof r!="function"){let s=`Configured requestMediaKeySystemAccess is not a function ${r}`;return HT===null&&self.location.protocol==="http:"&&(s=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(s))}return r(e,t)}getMediaKeysPromise(e,t,r){let s=bI(e,t,r,this.config.drmSystemOptions),n=this.keySystemAccessPromises[e],a=n==null?void 0:n.keySystemAccess;if(!a){this.log(`Requesting encrypted media "${e}" key-system access with config: ${JSON.stringify(s)}`),a=this.requestMediaKeySystemAccess(e,s);let o=this.keySystemAccessPromises[e]={keySystemAccess:a};return a.catch(l=>{this.log(`Failed to obtain access to key-system "${e}": ${l}`)}),a.then(l=>{this.log(`Access for key-system "${l.keySystem}" obtained`);let d=this.fetchServerCertificate(e);return this.log(`Create media-keys for "${e}"`),o.mediaKeys=l.createMediaKeys().then(u=>(this.log(`Media-keys created for "${e}"`),d.then(c=>c?this.setMediaKeysServerCertificate(u,e,c):u))),o.mediaKeys.catch(u=>{this.error(`Failed to create media-keys for "${e}"}: ${u}`)}),o.mediaKeys})}return a.then(()=>n.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:r}){this.log(`Creating key-system session "${t}" keyId: ${zi.hexDump(e.keyId||[])}`);let s=r.createSession(),n={decryptdata:e,keySystem:t,mediaKeys:r,mediaKeysSession:s,keyStatus:"status-pending"};return this.mediaKeySessions.push(n),n}renewKeySession(e){let t=e.decryptdata;if(t.pssh){let r=this.createMediaKeySessionContext(e),s=this.getKeyIdString(t),n="cenc";this.keyIdToKeySessionPromise[s]=this.generateRequestWithPreferredKeySession(r,n,t.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}getKeyIdString(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(e.keyId===null)throw new Error("keyId is null");return zi.hexDump(e.keyId)}updateKeySession(e,t){var r;let s=e.mediaKeysSession;return this.log(`Updating key-session "${s.sessionId}" for keyID ${zi.hexDump(((r=e.decryptdata)==null?void 0:r.keyId)||[])}
1603
- } (data length: ${t&&t.byteLength})`),s.update(t)}selectKeySystemFormat(e){let t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){return new Promise((t,r)=>{let s=up(this.config),n=e.map(Vy).filter(a=>!!a&&s.indexOf(a)!==-1);return this.getKeySystemSelectionPromise(n).then(({keySystem:a})=>{let o=Ky(a);o?t(o):r(new Error(`Unable to find format for key-system "${a}"`))}).catch(r)})}loadKey(e){let t=e.keyInfo.decryptdata,r=this.getKeyIdString(t),s=`(keyId: ${r} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${s}`);let n=this.keyIdToKeySessionPromise[r];return n||(n=this.keyIdToKeySessionPromise[r]=this.getKeySystemForKeyPromise(t).then(({keySystem:a,mediaKeys:o})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${s}`),this.attemptSetMediaKeys(a,o).then(()=>{this.throwIfDestroyed();let l=this.createMediaKeySessionContext({keySystem:a,mediaKeys:o,decryptdata:t}),d="cenc";return this.generateRequestWithPreferredKeySession(l,d,t.pssh,"playlist-key")}))),n.catch(a=>this.handleError(a))),n}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e){this.hls&&(this.error(e.message),e instanceof Pt?this.hls.trigger(v.ERROR,e.data):this.hls.trigger(v.ERROR,{type:ie.KEY_SYSTEM_ERROR,details:C.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}getKeySystemForKeyPromise(e){let t=this.getKeyIdString(e),r=this.keyIdToKeySessionPromise[t];if(!r){let s=Vy(e.keyFormat),n=s?[s]:up(this.config);return this.attemptKeySystemAccess(n)}return r}getKeySystemSelectionPromise(e){if(e.length||(e=up(this.config)),e.length===0)throw new Pt({type:ie.KEY_SYSTEM_ERROR,details:C.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}_onMediaEncrypted(e){let{initDataType:t,initData:r}=e;if(this.debug(`"${e.type}" event: init data type: "${t}"`),r===null)return;let s,n;if(t==="sinf"&&this.config.drmSystems[Fe.FAIRPLAY]){let u=it(new Uint8Array(r));try{let c=Bg(JSON.parse(u).sinf),h=jT(new Uint8Array(c));if(!h)return;s=h.subarray(8,24),n=Fe.FAIRPLAY}catch{this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{let u=VI(r);if(u===null)return;u.version===0&&u.systemId===$T.WIDEVINE&&u.data&&(s=u.data.subarray(8,24)),n=EI(u.systemId)}if(!n||!s)return;let a=zi.hexDump(s),{keyIdToKeySessionPromise:o,mediaKeySessions:l}=this,d=o[a];for(let u=0;u<l.length;u++){let c=l[u],h=c.decryptdata;if(h.pssh||!h.keyId)continue;let f=zi.hexDump(h.keyId);if(a===f||h.uri.replace(/-/g,"").indexOf(a)!==-1){d=o[f],delete o[f],h.pssh=new Uint8Array(r),h.keyId=s,d=o[a]=d.then(()=>this.generateRequestWithPreferredKeySession(c,t,r,"encrypted-event-key-match"));break}}d||(d=o[a]=this.getKeySystemSelectionPromise([n]).then(({keySystem:u,mediaKeys:c})=>{var h;this.throwIfDestroyed();let f=new lo("ISO-23001-7",a,(h=Ky(u))!=null?h:"");return f.pssh=new Uint8Array(r),f.keyId=s,this.attemptSetMediaKeys(u,c).then(()=>{this.throwIfDestroyed();let m=this.createMediaKeySessionContext({decryptdata:f,keySystem:u,mediaKeys:c});return this.generateRequestWithPreferredKeySession(m,t,r,"encrypted-event-no-match")})})),d.catch(u=>this.handleError(u))}_onWaitingForKey(e){this.log(`"${e.type}" event`)}attemptSetMediaKeys(e,t){let r=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);let s=Promise.all(r).then(()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(t)});return this.setMediaKeysQueue.push(s),s.then(()=>{this.log(`Media-keys set for "${e}"`),r.push(s),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(n=>r.indexOf(n)===-1)})}generateRequestWithPreferredKeySession(e,t,r,s){var n,a;let o=(n=this.config.drmSystems)==null||(a=n[e.keySystem])==null?void 0:a.generateRequest;if(o)try{let m=o.call(this.hls,t,r,e);if(!m)throw new Error("Invalid response from configured generateRequest filter");t=m.initDataType,r=e.decryptdata.pssh=m.initData?new Uint8Array(m.initData):null}catch(m){var l;if(this.warn(m.message),(l=this.hls)!=null&&l.config.debug)throw m}if(r===null)return this.log(`Skipping key-session request for "${s}" (no initData)`),Promise.resolve(e);let d=this.getKeyIdString(e.decryptdata);this.log(`Generating key-session request for "${s}": ${d} (init data type: ${t} length: ${r?r.byteLength:null})`);let u=new qg,c=e._onmessage=m=>{let p=e.mediaKeysSession;if(!p){u.emit("error",new Error("invalid state"));return}let{messageType:g,message:E}=m;this.log(`"${g}" message event for session "${p.sessionId}" message size: ${E.byteLength}`),g==="license-request"||g==="license-renewal"?this.renewLicense(e,E).catch(T=>{this.handleError(T),u.emit("error",T)}):g==="license-release"?e.keySystem===Fe.FAIRPLAY&&(this.updateKeySession(e,Dp("acknowledged")),this.removeSession(e)):this.warn(`unhandled media key message type "${g}"`)},h=e._onkeystatuseschange=m=>{if(!e.mediaKeysSession){u.emit("error",new Error("invalid state"));return}this.onKeyStatusChange(e);let g=e.keyStatus;u.emit("keyStatus",g),g==="expired"&&(this.warn(`${e.keySystem} expired for key ${d}`),this.renewKeySession(e))};e.mediaKeysSession.addEventListener("message",c),e.mediaKeysSession.addEventListener("keystatuseschange",h);let f=new Promise((m,p)=>{u.on("error",p),u.on("keyStatus",g=>{g.startsWith("usable")?m():g==="output-restricted"?p(new Pt({type:ie.KEY_SYSTEM_ERROR,details:C.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):g==="internal-error"?p(new Pt({type:ie.KEY_SYSTEM_ERROR,details:C.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${g}"`)):g==="expired"?p(new Error("key expired while generating request")):this.warn(`unhandled key status change "${g}"`)})});return e.mediaKeysSession.generateRequest(t,r).then(()=>{var m;this.log(`Request generated for key-session "${(m=e.mediaKeysSession)==null?void 0:m.sessionId}" keyId: ${d}`)}).catch(m=>{throw new Pt({type:ie.KEY_SYSTEM_ERROR,details:C.KEY_SYSTEM_NO_SESSION,error:m,fatal:!1},`Error generating key-session request: ${m}`)}).then(()=>f).catch(m=>{throw u.removeAllListeners(),this.removeSession(e),m}).then(()=>(u.removeAllListeners(),e))}onKeyStatusChange(e){e.mediaKeysSession.keyStatuses.forEach((t,r)=>{this.log(`key status change "${t}" for keyStatuses keyId: ${zi.hexDump("buffer"in r?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r))} session keyId: ${zi.hexDump(new Uint8Array(e.decryptdata.keyId||[]))} uri: ${e.decryptdata.uri}`),e.keyStatus=t})}fetchServerCertificate(e){let t=this.config,r=t.loader,s=new r(t),n=this.getServerCertificateUrl(e);return n?(this.log(`Fetching server certificate for "${e}"`),new Promise((a,o)=>{let l={responseType:"arraybuffer",url:n},d=t.certLoadPolicy.default,u={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(h,f,m,p)=>{a(h.data)},onError:(h,f,m,p)=>{o(new Pt({type:ie.KEY_SYSTEM_ERROR,details:C.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:m,response:ft({url:l.url,data:void 0},h)},`"${e}" certificate request failed (${n}). Status: ${h.code} (${h.text})`))},onTimeout:(h,f,m)=>{o(new Pt({type:ie.KEY_SYSTEM_ERROR,details:C.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:m,response:{url:l.url,data:void 0}},`"${e}" certificate request timed out (${n})`))},onAbort:(h,f,m)=>{o(new Error("aborted"))}};s.load(l,u,c)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,r){return new Promise((s,n)=>{e.setServerCertificate(r).then(a=>{this.log(`setServerCertificate ${a?"success":"not supported by CDM"} (${r==null?void 0:r.byteLength}) on "${t}"`),s(e)}).catch(a=>{n(new Pt({type:ie.KEY_SYSTEM_ERROR,details:C.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:a,fatal:!0},a.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(r=>this.updateKeySession(e,new Uint8Array(r)).catch(s=>{throw new Pt({type:ie.KEY_SYSTEM_ERROR,details:C.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:s,fatal:!0},s.message)}))}unpackPlayReadyKeyMessage(e,t){let r=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!r.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;let s=new DOMParser().parseFromString(r,"application/xml"),n=s.querySelectorAll("HttpHeader");if(n.length>0){let u;for(let c=0,h=n.length;c<h;c++){var a,o;u=n[c];let f=(a=u.querySelector("name"))==null?void 0:a.textContent,m=(o=u.querySelector("value"))==null?void 0:o.textContent;f&&m&&e.setRequestHeader(f,m)}}let l=s.querySelector("Challenge"),d=l==null?void 0:l.textContent;if(!d)throw new Error("Cannot find <Challenge> in key message");return Dp(atob(d))}setupLicenseXHR(e,t,r,s){let n=this.config.licenseXhrSetup;return n?Promise.resolve().then(()=>{if(!r.decryptdata)throw new Error("Key removed");return n.call(this.hls,e,t,r,s)}).catch(a=>{if(!r.decryptdata)throw a;return e.open("POST",t,!0),n.call(this.hls,e,t,r,s)}).then(a=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:a||s})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:s}))}requestLicense(e,t){let r=this.config.keyLoadPolicy.default;return new Promise((s,n)=>{let a=this.getLicenseServerUrl(e.keySystem);this.log(`Sending license request to URL: ${a}`);let o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return n(new Error("invalid state"));if(o.readyState===4)if(o.status===200){this._requestLicenseFailureCount=0;let l=o.response;this.log(`License received ${l instanceof ArrayBuffer?l.byteLength:l}`);let d=this.config.licenseResponseCallback;if(d)try{l=d.call(this.hls,o,a,e)}catch(u){this.error(u)}s(l)}else{let l=r.errorRetry,d=l?l.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>d||o.status>=400&&o.status<500)n(new Pt({type:ie.KEY_SYSTEM_ERROR,details:C.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o,response:{url:a,data:void 0,code:o.status,text:o.statusText}},`License Request XHR failed (${a}). Status: ${o.status} (${o.statusText})`));else{let u=d-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${u} attempts left`),this.requestLicense(e,t).then(s,n)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,this.setupLicenseXHR(o,a,e,t).then(({xhr:l,licenseChallenge:d})=>{e.keySystem==Fe.PLAYREADY&&(d=this.unpackPlayReadyKeyMessage(l,d)),l.send(d)})})}onMediaAttached(e,t){if(!this.config.emeEnabled)return;let r=t.media;this.media=r,r.addEventListener("encrypted",this.onMediaEncrypted),r.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){let e=this.media,t=this.mediaKeySessions;e&&(e.removeEventListener("encrypted",this.onMediaEncrypted),e.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},lo.clearKeyUriToKeyIdMap();let r=t.length;i.CDMCleanupPromise=Promise.all(t.map(s=>this.removeSession(s)).concat(e==null?void 0:e.setMediaKeys(null).catch(s=>{this.log(`Could not clear media keys: ${s}`)}))).then(()=>{r&&(this.log("finished closing key sessions and clearing media keys"),t.length=0)}).catch(s=>{this.log(`Could not close sessions and clear media keys: ${s}`)})}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(e,{sessionKeys:t}){if(!(!t||!this.config.emeEnabled)&&!this.keyFormatPromise){let r=t.reduce((s,n)=>(s.indexOf(n.keyFormat)===-1&&s.push(n.keyFormat),s),[]);this.log(`Selecting key-system from session-keys ${r.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(r)}}removeSession(e){let{mediaKeysSession:t,licenseXhr:r}=e;if(t){this.log(`Remove licenses and keys and close session ${t.sessionId}`),e._onmessage&&(t.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(t.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),r&&r.readyState!==XMLHttpRequest.DONE&&r.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;let s=this.mediaKeySessions.indexOf(e);return s>-1&&this.mediaKeySessions.splice(s,1),t.remove().catch(n=>{this.log(`Could not remove session: ${n}`)}).then(()=>t.close()).catch(n=>{this.log(`Could not close session: ${n}`)})}}};uc.CDMCleanupPromise=void 0;var Pt=class extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=new Error(t)),this.data=e,e.err=e.error}},xt;(function(i){i.MANIFEST="m",i.AUDIO="a",i.VIDEO="v",i.MUXED="av",i.INIT="i",i.CAPTION="c",i.TIMED_TEXT="tt",i.KEY="k",i.OTHER="o"})(xt||(xt={}));var kg;(function(i){i.DASH="d",i.HLS="h",i.SMOOTH="s",i.OTHER="o"})(kg||(kg={}));var xs;(function(i){i.OBJECT="CMCD-Object",i.REQUEST="CMCD-Request",i.SESSION="CMCD-Session",i.STATUS="CMCD-Status"})(xs||(xs={}));var Lw={[xs.OBJECT]:["br","d","ot","tb"],[xs.REQUEST]:["bl","dl","mtp","nor","nrr","su"],[xs.SESSION]:["cid","pr","sf","sid","st","v"],[xs.STATUS]:["bs","rtp"]},go=class i{constructor(e,t){this.value=void 0,this.params=void 0,Array.isArray(e)&&(e=e.map(r=>r instanceof i?r:new i(r))),this.value=e,this.params=t}},cc=class{constructor(e){this.description=void 0,this.description=e}},kw="Dict";function Iw(i){return Array.isArray(i)?JSON.stringify(i):i instanceof Map?"Map{}":i instanceof Set?"Set{}":typeof i=="object"?JSON.stringify(i):String(i)}function Rw(i,e,t,r){return new Error(`failed to ${i} "${Iw(e)}" as ${t}`,{cause:r})}var PT="Bare Item",ww="Boolean",Cw="Byte Sequence",Dw="Decimal",Mw="Integer";function Pw(i){return i<-999999999999999||999999999999999<i}var Ow=/[\x00-\x1f\x7f]+/,Nw="Token",Uw="Key";function Zi(i,e,t){return Rw("serialize",i,e,t)}function Fw(i){if(typeof i!="boolean")throw Zi(i,ww);return i?"?1":"?0"}function Bw(i){return btoa(String.fromCharCode(...i))}function $w(i){if(ArrayBuffer.isView(i)===!1)throw Zi(i,Cw);return`:${Bw(i)}:`}function M_(i){if(Pw(i))throw Zi(i,Mw);return i.toString()}function Hw(i){return`@${M_(i.getTime()/1e3)}`}function P_(i,e){if(i<0)return-P_(-i,e);let t=Math.pow(10,e);if(Math.abs(i*t%1-.5)<Number.EPSILON){let s=Math.floor(i*t);return(s%2===0?s:s+1)/t}else return Math.round(i*t)/t}function Gw(i){let e=P_(i,3);if(Math.floor(Math.abs(e)).toString().length>12)throw Zi(i,Dw);let t=e.toString();return t.includes(".")?t:`${t}.0`}var Ww="String";function Vw(i){if(Ow.test(i))throw Zi(i,Ww);return`"${i.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function Kw(i){return i.description||i.toString().slice(7,-1)}function OT(i){let e=Kw(i);if(/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(e)===!1)throw Zi(e,Nw);return e}function Ig(i){switch(typeof i){case"number":if(!q(i))throw Zi(i,PT);return Number.isInteger(i)?M_(i):Gw(i);case"string":return Vw(i);case"symbol":return OT(i);case"boolean":return Fw(i);case"object":if(i instanceof Date)return Hw(i);if(i instanceof Uint8Array)return $w(i);if(i instanceof cc)return OT(i);default:throw Zi(i,PT)}}function Rg(i){if(/^[a-z*][a-z0-9\-_.*]*$/.test(i)===!1)throw Zi(i,Uw);return i}function jg(i){return i==null?"":Object.entries(i).map(([e,t])=>t===!0?`;${Rg(e)}`:`;${Rg(e)}=${Ig(t)}`).join("")}function O_(i){return i instanceof go?`${Ig(i.value)}${jg(i.params)}`:Ig(i)}function qw(i){return`(${i.value.map(O_).join(" ")})${jg(i.params)}`}function Yw(i,e={whitespace:!0}){if(typeof i!="object")throw Zi(i,kw);let t=i instanceof Map?i.entries():Object.entries(i),r=e!=null&&e.whitespace?" ":"";return Array.from(t).map(([s,n])=>{n instanceof go||(n=new go(n));let a=Rg(s);return n.value===!0?a+=jg(n.params):(a+="=",Array.isArray(n.value)?a+=qw(n):a+=O_(n)),a}).join(`,${r}`)}function zw(i,e){return Yw(i,e)}var jw=i=>i==="ot"||i==="sf"||i==="st",Xw=i=>typeof i=="number"?q(i):i!=null&&i!==""&&i!==!1;function Qw(i,e){let t=new URL(i),r=new URL(e);if(t.origin!==r.origin)return i;let s=t.pathname.split("/").slice(1),n=r.pathname.split("/").slice(1,-1);for(;s[0]===n[0];)s.shift(),n.shift();for(;n.length;)n.shift(),s.unshift("..");return s.join("/")}function Zw(){try{return crypto.randomUUID()}catch{try{let e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch{let t=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,s=>{let n=(t+Math.random()*16)%16|0;return t=Math.floor(t/16),(s=="x"?n:n&3|8).toString(16)})}}}var $u=i=>Math.round(i),Jw=(i,e)=>(e!=null&&e.baseUrl&&(i=Qw(i,e.baseUrl)),encodeURIComponent(i)),Pu=i=>$u(i/100)*100,eC={br:$u,d:$u,bl:Pu,dl:Pu,mtp:Pu,nor:Jw,rtp:Pu,tb:$u};function tC(i,e){let t={};if(i==null||typeof i!="object")return t;let r=Object.keys(i).sort(),s=Je({},eC,e==null?void 0:e.formatters),n=e==null?void 0:e.filter;return r.forEach(a=>{if(n!=null&&n(a))return;let o=i[a],l=s[a];l&&(o=l(o,e)),!(a==="v"&&o===1)&&(a=="pr"&&o===1||Xw(o)&&(jw(a)&&typeof o=="string"&&(o=new cc(o)),t[a]=o))}),t}function N_(i,e={}){return i?zw(tC(i,e),Je({whitespace:!1},e)):""}function iC(i,e={}){if(!i)return{};let t=Object.entries(i),r=Object.entries(Lw).concat(Object.entries((e==null?void 0:e.customHeaderMap)||{})),s=t.reduce((n,a)=>{var o,l;let[d,u]=a,c=((o=r.find(h=>h[1].includes(d)))==null?void 0:o[0])||xs.REQUEST;return(l=n[c])!=null||(n[c]={}),n[c][d]=u,n},{});return Object.entries(s).reduce((n,[a,o])=>(n[a]=N_(o,e),n),{})}function rC(i,e,t){return Je(i,iC(e,t))}var sC="CMCD";function nC(i,e={}){if(!i)return"";let t=N_(i,e);return`${sC}=${encodeURIComponent(t)}`}var NT=/CMCD=[^&#]+/;function aC(i,e,t){let r=nC(e,t);if(!r)return i;if(NT.test(i))return i.replace(NT,r);let s=i.includes("?")?"&":"?";return`${i}${s}${r}`}var wg=class{constructor(e){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.includeKeys=void 0,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=s=>{try{this.apply(s,{ot:xt.MANIFEST,su:!this.initialized})}catch(n){I.warn("Could not generate manifest CMCD data.",n)}},this.applyFragmentData=s=>{try{let n=s.frag,a=this.hls.levels[n.level],o=this.getObjectType(n),l={d:n.duration*1e3,ot:o};(o===xt.VIDEO||o===xt.AUDIO||o==xt.MUXED)&&(l.br=a.bitrate/1e3,l.tb=this.getTopBandwidth(o)/1e3,l.bl=this.getBufferLength(o)),this.apply(s,l)}catch(n){I.warn("Could not generate segment CMCD data.",n)}},this.hls=e;let t=this.config=e.config,{cmcd:r}=t;r!=null&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=r.sessionId||Zw(),this.cid=r.contentId,this.useHeaders=r.useHeaders===!0,this.includeKeys=r.includeKeys,this.registerListeners())}registerListeners(){let e=this.hls;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHED,this.onMediaDetached,this),e.on(v.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){let e=this.hls;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHED,this.onMediaDetached,this),e.off(v.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=null}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(e,t){var r,s;this.audioBuffer=(r=t.tracks.audio)==null?void 0:r.buffer,this.videoBuffer=(s=t.tracks.video)==null?void 0:s.buffer}createData(){var e;return{v:1,sf:kg.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){Je(t,this.createData());let r=t.ot===xt.INIT||t.ot===xt.VIDEO||t.ot===xt.MUXED;this.starved&&r&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering);let{includeKeys:s}=this;s&&(t=Object.keys(t).reduce((n,a)=>(s.includes(a)&&(n[a]=t[a]),n),{})),this.useHeaders?(e.headers||(e.headers={}),rC(e.headers,t)):e.url=aC(e.url,t)}getObjectType(e){let{type:t}=e;if(t==="subtitle")return xt.TIMED_TEXT;if(e.sn==="initSegment")return xt.INIT;if(t==="audio")return xt.AUDIO;if(t==="main")return this.hls.audioTracks.length?xt.VIDEO:xt.MUXED}getTopBandwidth(e){let t=0,r,s=this.hls;if(e===xt.AUDIO)r=s.audioTracks;else{let n=s.maxAutoLevel,a=n>-1?n+1:s.levels.length;r=s.levels.slice(0,a)}for(let n of r)n.bitrate>t&&(t=n.bitrate);return t>0?t:NaN}getBufferLength(e){let t=this.hls.media,r=e===xt.AUDIO?this.audioBuffer:this.videoBuffer;return!r||!t?NaN:Ue.bufferInfo(r,t.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){let{pLoader:e}=this.config,t=this.applyPlaylistData,r=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new r(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,a,o){t(n),this.loader.load(n,a,o)}}}createFragmentLoader(){let{fLoader:e}=this.config,t=this.applyFragmentData,r=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new r(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,a,o){t(n),this.loader.load(n,a,o)}}}},oC=3e5,Cg=class{constructor(e){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.log=I.log.bind(I,"[content-steering]:"),this.registerListeners()}registerListeners(){let e=this.hls;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.ERROR,this.onError,this)}unregisterListeners(){let e=this.hls;e&&(e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.ERROR,this.onError,this))}startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){let e=this.timeToLoad*1e3-(performance.now()-this.updated);if(e>0){this.scheduleRefresh(this.uri,e);return}}this.loadSteeringManifest(this.uri)}}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}clearTimeout(){this.reloadTimer!==-1&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){let t=this.levels;t&&(this.levels=t.filter(r=>r!==e))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){let{contentSteering:r}=t;r!==null&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){let{errorAction:r}=t;if((r==null?void 0:r.action)===ct.SendAlternateToPenaltyBox&&r.flags===Ei.MoveAllAlternatesMatchingHost){let s=this.levels,n=this.pathwayPriority,a=this.pathwayId;if(t.context){let{groupId:o,pathwayId:l,type:d}=t.context;o&&s?a=this.getPathwayForGroupId(o,d,a):l&&(a=l)}a in this.penalizedPathways||(this.penalizedPathways[a]=performance.now()),!n&&s&&(n=s.reduce((o,l)=>(o.indexOf(l.pathwayId)===-1&&o.push(l.pathwayId),o),[])),n&&n.length>1&&(this.updatePathwayPriority(n),r.resolved=this.pathwayId!==a),r.resolved||I.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${a} levels: ${s&&s.length} priorities: ${JSON.stringify(n)} penalized: ${JSON.stringify(this.penalizedPathways)}`)}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){let r=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${r}"`),t=this.getLevelsForPathway(r),this.pathwayId=r}return t.length!==e.length?(this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t):e}getLevelsForPathway(e){return this.levels===null?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){this.pathwayPriority=e;let t,r=this.penalizedPathways,s=performance.now();Object.keys(r).forEach(n=>{s-r[n]>oC&&delete r[n]});for(let n=0;n<e.length;n++){let a=e[n];if(a in r)continue;if(a===this.pathwayId)return;let o=this.hls.nextLoadLevel,l=this.hls.levels[o];if(t=this.getLevelsForPathway(a),t.length>0){this.log(`Setting Pathway to "${a}"`),this.pathwayId=a,n_(t),this.hls.trigger(v.LEVELS_UPDATED,{levels:t});let d=this.hls.levels[o];l&&d&&this.levels&&(d.attrs["STABLE-VARIANT-ID"]!==l.attrs["STABLE-VARIANT-ID"]&&d.bitrate!==l.bitrate&&this.log(`Unstable Pathways change from bitrate ${l.bitrate} to ${d.bitrate}`),this.hls.nextLoadLevel=o);break}}}getPathwayForGroupId(e,t,r){let s=this.getLevelsForPathway(r).concat(this.levels||[]);for(let n=0;n<s.length;n++)if(t===ge.AUDIO_TRACK&&s[n].hasAudioGroup(e)||t===ge.SUBTITLE_TRACK&&s[n].hasSubtitleGroup(e))return s[n].pathwayId;return r}clonePathways(e){let t=this.levels;if(!t)return;let r={},s={};e.forEach(n=>{let{ID:a,"BASE-ID":o,"URI-REPLACEMENT":l}=n;if(t.some(u=>u.pathwayId===a))return;let d=this.getLevelsForPathway(o).map(u=>{let c=new We(u.attrs);c["PATHWAY-ID"]=a;let h=c.AUDIO&&`${c.AUDIO}_clone_${a}`,f=c.SUBTITLES&&`${c.SUBTITLES}_clone_${a}`;h&&(r[c.AUDIO]=h,c.AUDIO=h),f&&(s[c.SUBTITLES]=f,c.SUBTITLES=f);let m=U_(u.uri,c["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l),p=new Mr({attrs:c,audioCodec:u.audioCodec,bitrate:u.bitrate,height:u.height,name:u.name,url:m,videoCodec:u.videoCodec,width:u.width});if(u.audioGroups)for(let g=1;g<u.audioGroups.length;g++)p.addGroupId("audio",`${u.audioGroups[g]}_clone_${a}`);if(u.subtitleGroups)for(let g=1;g<u.subtitleGroups.length;g++)p.addGroupId("text",`${u.subtitleGroups[g]}_clone_${a}`);return p});t.push(...d),UT(this.audioTracks,r,l,a),UT(this.subtitleTracks,s,l,a)})}loadSteeringManifest(e){let t=this.hls.config,r=t.loader;this.loader&&this.loader.destroy(),this.loader=new r(t);let s;try{s=new self.URL(e)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if(s.protocol!=="data:"){let u=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;s.searchParams.set("_HLS_pathway",this.pathwayId),s.searchParams.set("_HLS_throughput",""+u)}let n={responseType:"json",url:s.href},a=t.steeringManifestLoadPolicy.default,o=a.errorRetry||a.timeoutRetry||{},l={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},d={onSuccess:(u,c,h,f)=>{this.log(`Loaded steering manifest: "${s}"`);let m=u.data;if(m.VERSION!==1){this.log(`Steering VERSION ${m.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=m.TTL;let{"RELOAD-URI":p,"PATHWAY-CLONES":g,"PATHWAY-PRIORITY":E}=m;if(p)try{this.uri=new self.URL(p,s).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${p}`);return}this.scheduleRefresh(this.uri||h.url),g&&this.clonePathways(g);let T={steeringManifest:m,url:s.toString()};this.hls.trigger(v.STEERING_MANIFEST_LOADED,T),E&&this.updatePathwayPriority(E)},onError:(u,c,h,f)=>{if(this.log(`Error loading steering manifest: ${u.code} ${u.text} (${c.url})`),this.stopLoad(),u.code===410){this.enabled=!1,this.log(`Steering manifest ${c.url} no longer available`);return}let m=this.timeToLoad*1e3;if(u.code===429){let p=this.loader;if(typeof(p==null?void 0:p.getResponseHeader)=="function"){let g=p.getResponseHeader("Retry-After");g&&(m=parseFloat(g)*1e3)}this.log(`Steering manifest ${c.url} rate limited`);return}this.scheduleRefresh(this.uri||c.url,m)},onTimeout:(u,c,h)=>{this.log(`Timeout loading steering manifest (${c.url})`),this.scheduleRefresh(this.uri||c.url)}};this.log(`Requesting steering manifest: ${s}`),this.loader.load(n,l,d)}scheduleRefresh(e,t=this.timeToLoad*1e3){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var r;let s=(r=this.hls)==null?void 0:r.media;if(s&&!s.ended){this.loadSteeringManifest(e);return}this.scheduleRefresh(e,this.timeToLoad*1e3)},t)}};function UT(i,e,t,r){i&&Object.keys(e).forEach(s=>{let n=i.filter(a=>a.groupId===s).map(a=>{let o=Je({},a);return o.details=void 0,o.attrs=new We(o.attrs),o.url=o.attrs.URI=U_(a.url,a.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),o.groupId=o.attrs["GROUP-ID"]=e[s],o.attrs["PATHWAY-ID"]=r,o});i.push(...n)})}function U_(i,e,t,r){let{HOST:s,PARAMS:n,[t]:a}=r,o;e&&(o=a==null?void 0:a[e],o&&(i=o));let l=new self.URL(i);return s&&!o&&(l.host=s),n&&Object.keys(n).sort().forEach(d=>{d&&l.searchParams.set(d,n[d])}),l.href}var lC=/^age:\s*[\d.]+\s*$/im,hc=class{constructor(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new Kn,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null,this.stats=null}abortInternal(){let e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,e.readyState!==4&&(this.stats.aborted=!0,e.abort()))}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(e,t,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=r,this.loadInternal()}loadInternal(){let{config:e,context:t}=this;if(!e||!t)return;let r=this.loader=new self.XMLHttpRequest,s=this.stats;s.loading.first=0,s.loaded=0,s.aborted=!1;let n=this.xhrSetup;n?Promise.resolve().then(()=>{if(!this.stats.aborted)return n(r,t.url)}).catch(a=>(r.open("GET",t.url,!0),n(r,t.url))).then(()=>{this.stats.aborted||this.openAndSendXhr(r,t,e)}).catch(a=>{this.callbacks.onError({code:r.status,text:a.message},t,r,s)}):this.openAndSendXhr(r,t,e)}openAndSendXhr(e,t,r){e.readyState||e.open("GET",t.url,!0);let s=t.headers,{maxTimeToFirstByteMs:n,maxLoadTimeMs:a}=r.loadPolicy;if(s)for(let o in s)e.setRequestHeader(o,s[o]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),r.timeout=n&&q(n)?n:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()}readystatechange(){let{context:e,loader:t,stats:r}=this;if(!e||!t)return;let s=t.readyState,n=this.config;if(!r.aborted&&s>=2&&(r.loading.first===0&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),n.timeout!==n.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),n.timeout=n.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),s===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;let a=t.status,o=t.responseType!=="text";if(a>=200&&a<300&&(o&&t.response||t.responseText!==null)){r.loading.end=Math.max(self.performance.now(),r.loading.first);let l=o?t.response:t.responseText,d=t.responseType==="arraybuffer"?l.byteLength:l.length;if(r.loaded=r.total=d,r.bwEstimate=r.total*8e3/(r.loading.end-r.loading.first),!this.callbacks)return;let u=this.callbacks.onProgress;if(u&&u(r,e,l,t),!this.callbacks)return;let c={url:t.responseURL,data:l,code:a};this.callbacks.onSuccess(c,r,e,t)}else{let l=n.loadPolicy.errorRetry,d=r.retry,u={url:e.url,data:void 0,code:a};Qu(l,d,!1,u)?this.retry(l):(I.error(`${a} while loading ${e.url}`),this.callbacks.onError({code:a,text:t.statusText},e,t,r))}}}loadtimeout(){var e;let t=(e=this.config)==null?void 0:e.loadPolicy.timeoutRetry,r=this.stats.retry;if(Qu(t,r,!0))this.retry(t);else{var s;I.warn(`timeout while loading ${(s=this.context)==null?void 0:s.url}`);let n=this.callbacks;n&&(this.abortInternal(),n.onTimeout(this.stats,this.context,this.loader))}}retry(e){let{context:t,stats:r}=this;this.retryDelay=Gg(e,r.retry),r.retry++,I.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${t==null?void 0:t.url}, retrying ${r.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(e){let t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&lC.test(this.loader.getAllResponseHeaders())){let t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}};function dC(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var uC=/(\d+)-(\d+)\/(\d+)/,fc=class{constructor(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||mC,this.controller=new self.AbortController,this.stats=new Kn}destroy(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}abortInternal(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,r){let s=this.stats;if(s.loading.start)throw new Error("Loader can only be used once.");s.loading.start=self.performance.now();let n=cC(e,this.controller.signal),a=r.onProgress,o=e.responseType==="arraybuffer",l=o?"byteLength":"length",{maxTimeToFirstByteMs:d,maxLoadTimeMs:u}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,n),self.clearTimeout(this.requestTimeout),t.timeout=d&&q(d)?d:u,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),r.onTimeout(s,e,this.response)},t.timeout),self.fetch(this.request).then(c=>{this.response=this.loader=c;let h=Math.max(self.performance.now(),s.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=u,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),r.onTimeout(s,e,this.response)},u-(h-s.loading.start)),!c.ok){let{status:f,statusText:m}=c;throw new Dg(m||"fetch, bad network response",f,c)}return s.loading.first=h,s.total=fC(c.headers)||s.total,a&&q(t.highWaterMark)?this.loadProgressively(c,s,e,t.highWaterMark,a):o?c.arrayBuffer():e.responseType==="json"?c.json():c.text()}).then(c=>{let h=this.response;if(!h)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),s.loading.end=Math.max(self.performance.now(),s.loading.first);let f=c[l];f&&(s.loaded=s.total=f);let m={url:h.url,data:c,code:h.status};a&&!q(t.highWaterMark)&&a(s,e,c,h),r.onSuccess(m,s,e,h)}).catch(c=>{if(self.clearTimeout(this.requestTimeout),s.aborted)return;let h=c&&c.code||0,f=c?c.message:null;r.onError({code:h,text:f},e,c?c.details:null,s)})}getCacheAge(){let e=null;if(this.response){let t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,r,s=0,n){let a=new ec,o=e.body.getReader(),l=()=>o.read().then(d=>{if(d.done)return a.dataLength&&n(t,r,a.flush(),e),Promise.resolve(new ArrayBuffer(0));let u=d.value,c=u.length;return t.loaded+=c,c<s||a.dataLength?(a.push(u),a.dataLength>=s&&n(t,r,a.flush(),e)):n(t,r,u,e),l()}).catch(()=>Promise.reject());return l()}};function cC(i,e){let t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(Je({},i.headers))};return i.rangeEnd&&t.headers.set("Range","bytes="+i.rangeStart+"-"+String(i.rangeEnd-1)),t}function hC(i){let e=uC.exec(i);if(e)return parseInt(e[2])-parseInt(e[1])+1}function fC(i){let e=i.get("Content-Range");if(e){let r=hC(e);if(q(r))return r}let t=i.get("Content-Length");if(t)return parseInt(t)}function mC(i,e){return new self.Request(i.url,e)}var Dg=class extends Error{constructor(e,t,r){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=r}},pC=/\s/,gC={newCue(i,e,t,r){let s=[],n,a,o,l,d,u=self.VTTCue||self.TextTrackCue;for(let h=0;h<r.rows.length;h++)if(n=r.rows[h],o=!0,l=0,d="",!n.isEmpty()){var c;for(let p=0;p<n.chars.length;p++)pC.test(n.chars[p].uchar)&&o?l++:(d+=n.chars[p].uchar,o=!1);n.cueStartTime=e,e===t&&(t+=1e-4),l>=16?l--:l++;let f=I_(d.trim()),m=zg(e,t,f);i!=null&&(c=i.cues)!=null&&c.getCueById(m)||(a=new u(e,t,f),a.id=m,a.line=h+1,a.align="left",a.position=10+Math.min(80,Math.floor(l*8/32)*10),s.push(a))}return i&&s.length&&(s.sort((h,f)=>h.line==="auto"||f.line==="auto"?0:h.line>8&&f.line>8?f.line-h.line:h.line-f.line),s.forEach(h=>t_(i,h))),s}},vC={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},F_=ft(ft({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:hc,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Vp,bufferController:gg,capLevelController:xg,errorController:Gp,fpsController:Lg,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:HT,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,useMediaCapabilities:!0,certLoadPolicy:{default:vC},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},EC()),{},{subtitleStreamController:hg,subtitleTrackController:mg,timelineController:Sg,audioStreamController:ug,audioTrackController:cg,emeController:uc,cmcdController:wg,contentSteeringController:Cg});function EC(){return{cueHandler:gC,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function bC(i,e){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(e.liveMaxLatencyDurationCount!==void 0&&(e.liveSyncDurationCount===void 0||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(e.liveMaxLatencyDuration!==void 0&&(e.liveSyncDuration===void 0||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');let t=Mg(i),r=["manifest","level","frag"],s=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return r.forEach(n=>{let a=`${n==="level"?"playlist":n}LoadPolicy`,o=e[a]===void 0,l=[];s.forEach(d=>{let u=`${n}Loading${d}`,c=e[u];if(c!==void 0&&o){l.push(u);let h=t[a].default;switch(e[a]={default:h},d){case"TimeOut":h.maxLoadTimeMs=c,h.maxTimeToFirstByteMs=c;break;case"MaxRetry":h.errorRetry.maxNumRetry=c,h.timeoutRetry.maxNumRetry=c;break;case"RetryDelay":h.errorRetry.retryDelayMs=c,h.timeoutRetry.retryDelayMs=c;break;case"MaxRetryTimeout":h.errorRetry.maxRetryDelayMs=c,h.timeoutRetry.maxRetryDelayMs=c;break}}}),l.length&&I.warn(`hls.js config: "${l.join('", "')}" setting(s) are deprecated, use "${a}": ${JSON.stringify(e[a])}`)}),ft(ft({},t),e)}function Mg(i){return i&&typeof i=="object"?Array.isArray(i)?i.map(Mg):Object.keys(i).reduce((e,t)=>(e[t]=Mg(i[t]),e),{}):i}function yC(i){let e=i.loader;e!==fc&&e!==hc?(I.log("[config]: Custom loader detected, cannot enable progressive streaming"),i.progressive=!1):dC()&&(i.loader=fc,i.progressive=!0,i.enableSoftwareAES=!0,I.log("[config]: Progressive streaming enabled, using FetchLoader"))}var Ip,Pg=class extends co{constructor(e,t){super(e,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._maxAutoLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=t,this._registerListeners()}_registerListeners(){let{hls:e}=this;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this),e.on(v.ERROR,this.onError,this)}_unregisterListeners(){let{hls:e}=this;e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this),e.off(v.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}stopLoad(){this._levels.forEach(t=>{t.loadError=0,t.fragmentError=0}),super.stopLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){let r=this.hls.config.preferManagedMediaSource,s=[],n={},a={},o=!1,l=!1,d=!1;t.levels.forEach(u=>{var c,h;let f=u.attrs,{audioCodec:m,videoCodec:p}=u;((c=m)==null?void 0:c.indexOf("mp4a.40.34"))!==-1&&(Ip||(Ip=/chrome|firefox/i.test(navigator.userAgent)),Ip&&(u.audioCodec=m=void 0)),m&&(u.audioCodec=m=Yu(m,r)),((h=p)==null?void 0:h.indexOf("avc1"))===0&&(p=u.videoCodec=QI(p));let{width:g,height:E,unknownCodecs:T}=u;if(o||(o=!!(g&&E)),l||(l=!!p),d||(d=!!m),T!=null&&T.length||m&&!mp(m,"audio",r)||p&&!mp(p,"video",r))return;let{CODECS:y,"FRAME-RATE":S,"HDCP-LEVEL":_,"PATHWAY-ID":L,RESOLUTION:x,"VIDEO-RANGE":w}=f,k=`${`${L||"."}-`}${u.bitrate}-${x}-${S}-${y}-${w}-${_}`;if(n[k])if(n[k].uri!==u.url&&!u.attrs["PATHWAY-ID"]){let D=a[k]+=1;u.attrs["PATHWAY-ID"]=new Array(D+1).join(".");let U=new Mr(u);n[k]=U,s.push(U)}else n[k].addGroupId("audio",f.AUDIO),n[k].addGroupId("text",f.SUBTITLES);else{let D=new Mr(u);n[k]=D,a[k]=1,s.push(D)}}),this.filterAndSortMediaOptions(s,t,o,l,d)}filterAndSortMediaOptions(e,t,r,s,n){let a=[],o=[],l=e;if((r||s)&&n&&(l=l.filter(({videoCodec:m,videoRange:p,width:g,height:E})=>(!!m||!!(g&&E))&&oR(p))),l.length===0){Promise.resolve().then(()=>{if(this.hls){t.levels.length&&this.warn(`One or more CODECS in variant not supported: ${JSON.stringify(t.levels[0].attrs)}`);let m=new Error("no level with compatible codecs found in manifest");this.hls.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:C.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:m,reason:m.message})}});return}if(t.audioTracks){let{preferManagedMediaSource:m}=this.hls.config;a=t.audioTracks.filter(p=>!p.audioCodec||mp(p.audioCodec,"audio",m)),FT(a)}t.subtitles&&(o=t.subtitles,FT(o));let d=l.slice(0);l.sort((m,p)=>{if(m.attrs["HDCP-LEVEL"]!==p.attrs["HDCP-LEVEL"])return(m.attrs["HDCP-LEVEL"]||"")>(p.attrs["HDCP-LEVEL"]||"")?1:-1;if(r&&m.height!==p.height)return m.height-p.height;if(m.frameRate!==p.frameRate)return m.frameRate-p.frameRate;if(m.videoRange!==p.videoRange)return zu.indexOf(m.videoRange)-zu.indexOf(p.videoRange);if(m.videoCodec!==p.videoCodec){let g=Xy(m.videoCodec),E=Xy(p.videoCodec);if(g!==E)return E-g}if(m.uri===p.uri&&m.codecSet!==p.codecSet){let g=qu(m.codecSet),E=qu(p.codecSet);if(g!==E)return E-g}return m.averageBitrate!==p.averageBitrate?m.averageBitrate-p.averageBitrate:0});let u=d[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==d.length)){for(let m=0;m<d.length;m++)if(d[m].pathwayId===l[0].pathwayId){u=d[m];break}}this._levels=l;for(let m=0;m<l.length;m++)if(l[m]===u){var c;this._firstLevel=m;let p=u.bitrate,g=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: ${p}`),((c=this.hls.userConfig)==null?void 0:c.abrEwmaDefaultEstimate)===void 0){let E=Math.min(p,this.hls.config.abrEwmaDefaultEstimateMax);E>g&&g===F_.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=E)}break}let h=n&&!s,f={levels:l,audioTracks:a,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:n,video:s,altAudio:!h&&a.some(m=>!!m.url)};this.hls.trigger(v.MANIFEST_PARSED,f),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}get levels(){return this._levels.length===0?null:this._levels}get level(){return this.currentLevelIndex}set level(e){let t=this._levels;if(t.length===0)return;if(e<0||e>=t.length){let u=new Error("invalid level idx"),c=e<0;if(this.hls.trigger(v.ERROR,{type:ie.OTHER_ERROR,details:C.LEVEL_SWITCH_ERROR,level:e,fatal:c,error:u,reason:u.message}),c)return;e=Math.min(e,t.length-1)}let r=this.currentLevelIndex,s=this.currentLevel,n=s?s.attrs["PATHWAY-ID"]:void 0,a=t[e],o=a.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=a,r===e&&a.details&&s&&n===o)return;this.log(`Switching to level ${e} (${a.height?a.height+"p ":""}${a.videoRange?a.videoRange+" ":""}${a.codecSet?a.codecSet+" ":""}@${a.bitrate})${o?" with Pathway "+o:""} from level ${r}${n?" with Pathway "+n:""}`);let l={level:e,attrs:a.attrs,details:a.details,bitrate:a.bitrate,averageBitrate:a.averageBitrate,maxBitrate:a.maxBitrate,realBitrate:a.realBitrate,width:a.width,height:a.height,codecSet:a.codecSet,audioCodec:a.audioCodec,videoCodec:a.videoCodec,audioGroups:a.audioGroups,subtitleGroups:a.subtitleGroups,loaded:a.loaded,loadError:a.loadError,fragmentError:a.fragmentError,name:a.name,id:a.id,uri:a.uri,url:a.url,urlId:0,audioGroupIds:a.audioGroupIds,textGroupIds:a.textGroupIds};this.hls.trigger(v.LEVEL_SWITCHING,l);let d=a.details;if(!d||d.live){let u=this.switchParams(a.uri,s==null?void 0:s.details,d);this.loadPlaylist(u)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,this._startLevel===void 0&&(this._startLevel=e),e!==-1&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(this._startLevel===void 0){let e=this.hls.config.startLevel;return e!==void 0?e:this.hls.firstAutoLevel}return this._startLevel}set startLevel(e){this._startLevel=e}onError(e,t){t.fatal||!t.context||t.context.type===ge.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(t!==void 0&&t.type===te.MAIN){let r=t.elementaryStreams;if(!Object.keys(r).some(n=>!!r[n]))return;let s=this._levels[t.level];s!=null&&s.loadError&&(this.log(`Resetting level error count of ${s.loadError} on frag buffered`),s.loadError=0)}}onLevelLoaded(e,t){var r;let{level:s,details:n}=t,a=this._levels[s];if(!a){var o;this.warn(`Invalid level index ${s}`),(o=t.deliveryDirectives)!=null&&o.skip&&(n.deltaUpdateFailed=!0);return}s===this.currentLevelIndex?(a.fragmentError===0&&(a.loadError=0),this.playlistLoaded(s,t,a.details)):(r=t.deliveryDirectives)!=null&&r.skip&&(n.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist();let t=this.currentLevelIndex,r=this.currentLevel;if(r&&this.shouldLoadPlaylist(r)){let s=r.uri;if(e)try{s=e.addDirectives(s)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}let n=r.attrs["PATHWAY-ID"];this.log(`Loading level index ${t}${(e==null?void 0:e.msn)!==void 0?" at sn "+e.msn+" part "+e.part:""} with${n?" Pathway "+n:""} ${s}`),this.clearTimer(),this.hls.trigger(v.LEVEL_LOADING,{url:s,level:t,pathwayId:r.attrs["PATHWAY-ID"],id:0,deliveryDirectives:e||null})}}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=e)}removeLevel(e){var t;let r=this._levels.filter((s,n)=>n!==e?!0:(this.steering&&this.steering.removeLevel(s),s===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,s.details&&s.details.fragments.forEach(a=>a.level=-1)),!1));n_(r),this._levels=r,this.currentLevelIndex>-1&&(t=this.currentLevel)!=null&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.hls.trigger(v.LEVELS_UPDATED,{levels:r})}onLevelsUpdated(e,{levels:t}){this._levels=t}checkMaxAutoUpdated(){let{autoLevelCapping:e,maxAutoLevel:t,maxHdcpLevel:r}=this.hls;this._maxAutoLevel!==t&&(this._maxAutoLevel=t,this.hls.trigger(v.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:r}))}};function FT(i){let e={};i.forEach(t=>{let r=t.groupId||"";t.id=e[r]=e[r]||0,e[r]++})}var Og=class{constructor(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(let r in this.keyUriToKeyInfo){let s=this.keyUriToKeyInfo[r].loader;if(s){var t;if(e&&e!==((t=s.context)==null?void 0:t.frag.type))return;s.abort()}}}detach(){for(let e in this.keyUriToKeyInfo){let t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}destroy(){this.detach();for(let e in this.keyUriToKeyInfo){let t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(e,t=C.KEY_LOAD_ERROR,r,s,n){return new yi({type:ie.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:n,error:r,networkDetails:s})}loadClear(e,t){if(this.emeController&&this.config.emeEnabled){let{sn:r,cc:s}=e;for(let n=0;n<t.length;n++){let a=t[n];if(s<=a.cc&&(r==="initSegment"||a.sn==="initSegment"||r<a.sn)){this.emeController.selectKeySystemFormat(a).then(o=>{a.setKeyFormat(o)});break}}}}load(e){return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var r,s;t&&e.setKeyFormat(t);let n=e.decryptdata;if(!n){let d=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,C.KEY_LOAD_ERROR,d))}let a=n.uri;if(!a)return Promise.reject(this.createKeyLoadError(e,C.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${a}"`)));let o=this.keyUriToKeyInfo[a];if((r=o)!=null&&r.decryptdata.key)return n.key=o.decryptdata.key,Promise.resolve({frag:e,keyInfo:o});if((s=o)!=null&&s.keyLoadPromise){var l;switch((l=o.mediaKeySessionContext)==null?void 0:l.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return o.keyLoadPromise.then(d=>(n.key=d.keyInfo.decryptdata.key,{frag:e,keyInfo:o}))}}switch(o=this.keyUriToKeyInfo[a]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return n.keyFormat==="identity"?this.loadKeyHTTP(o,e):this.loadKeyEME(o,e);case"AES-128":return this.loadKeyHTTP(o,e);default:return Promise.reject(this.createKeyLoadError(e,C.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${n.method}"`)))}}loadKeyEME(e,t){let r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){let s=this.emeController.loadKey(r);if(s)return(e.keyLoadPromise=s.then(n=>(e.mediaKeySessionContext=n,r))).catch(n=>{throw e.keyLoadPromise=null,n})}return Promise.resolve(r)}loadKeyHTTP(e,t){let r=this.config,s=r.loader,n=new s(r);return t.keyLoader=e.loader=n,e.keyLoadPromise=new Promise((a,o)=>{let l={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},d=r.keyLoadPolicy.default,u={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(h,f,m,p)=>{let{frag:g,keyInfo:E,url:T}=m;if(!g.decryptdata||E!==this.keyUriToKeyInfo[T])return o(this.createKeyLoadError(g,C.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),p));E.decryptdata.key=g.decryptdata.key=new Uint8Array(h.data),g.keyLoader=null,E.loader=null,a({frag:g,keyInfo:E})},onError:(h,f,m,p)=>{this.resetLoader(f),o(this.createKeyLoadError(t,C.KEY_LOAD_ERROR,new Error(`HTTP Error ${h.code} loading key ${h.text}`),m,ft({url:l.url,data:void 0},h)))},onTimeout:(h,f,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,C.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),m))},onAbort:(h,f,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,C.INTERNAL_ABORTED,new Error("key loading aborted"),m))}};n.load(l,u,c)})}resetLoader(e){let{frag:t,keyInfo:r,url:s}=e,n=r.loader;t.keyLoader===n&&(t.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[s],n&&n.destroy()}};function B_(){return self.SourceBuffer||self.WebKitSourceBuffer}function $_(){if(!ks())return!1;let e=B_();return!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function"}function TC(){if(!$_())return!1;let i=ks();return typeof(i==null?void 0:i.isTypeSupported)=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(e=>i.isTypeSupported(uo(e,"video")))||["mp4a.40.2","fLaC"].some(e=>i.isTypeSupported(uo(e,"audio"))))}function _C(){var i;let e=B_();return typeof(e==null||(i=e.prototype)==null?void 0:i.changeType)=="function"}var AC=250,Hu=2,SC=.1,xC=.05,Ng=class{constructor(e,t,r,s){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=e,this.media=t,this.fragmentTracker=r,this.hls=s}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(e,t){let{config:r,media:s,stalled:n}=this;if(s===null)return;let{currentTime:a,seeking:o}=s,l=this.seeking&&!o,d=!this.seeking&&o;if(this.seeking=o,a!==e){if(this.moved=!0,o||(this.nudgeRetry=0),n!==null){if(this.stallReported){let g=self.performance.now()-n;I.warn(`playback not stuck anymore @${a}, after ${Math.round(g)}ms`),this.stallReported=!1}this.stalled=null}return}if(d||l){this.stalled=null;return}if(s.paused&&!o||s.ended||s.playbackRate===0||!Ue.getBuffered(s).length){this.nudgeRetry=0;return}let u=Ue.bufferInfo(s,a,0),c=u.nextStart||0;if(o){let g=u.len>Hu,E=!c||t&&t.start<=a||c-a>Hu&&!this.fragmentTracker.getPartialFragment(a);if(g||E)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var h;if(!(u.len>0)&&!c)return;let E=Math.max(c,u.start||0)-a,T=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,S=(T==null||(h=T.details)==null?void 0:h.live)?T.details.targetduration*2:Hu,_=this.fragmentTracker.getPartialFragment(a);if(E>0&&(E<=S||_)){s.paused||this._trySkipBufferHole(_);return}}let f=self.performance.now();if(n===null){this.stalled=f;return}let m=f-n;if(!o&&m>=AC&&(this._reportStall(u),!this.media))return;let p=Ue.bufferInfo(s,a,r.maxBufferHole);this._tryFixBufferStall(p,m)}_tryFixBufferStall(e,t){let{config:r,fragmentTracker:s,media:n}=this;if(n===null)return;let a=n.currentTime,o=s.getPartialFragment(a);o&&(this._trySkipBufferHole(o)||!this.media)||(e.len>r.maxBufferHole||e.nextStart&&e.nextStart-a<r.maxBufferHole)&&t>r.highBufferWatchdogPeriod*1e3&&(I.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(e){let{hls:t,media:r,stallReported:s}=this;if(!s&&r){this.stallReported=!0;let n=new Error(`Playback stalling at @${r.currentTime} due to low buffer (${JSON.stringify(e)})`);I.warn(n.message),t.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:C.BUFFER_STALLED_ERROR,fatal:!1,error:n,buffer:e.len})}}_trySkipBufferHole(e){let{config:t,hls:r,media:s}=this;if(s===null)return 0;let n=s.currentTime,a=Ue.bufferInfo(s,n,0),o=n<a.start?a.start:a.nextStart;if(o){let l=a.len<=t.maxBufferHole,d=a.len>0&&a.len<1&&s.readyState<3,u=o-n;if(u>0&&(l||d)){if(u>t.maxBufferHole){let{fragmentTracker:h}=this,f=!1;if(n===0){let m=h.getAppendedFrag(0,te.MAIN);m&&o<m.end&&(f=!0)}if(!f){let m=e||h.getAppendedFrag(n,te.MAIN);if(m){let p=!1,g=m.end;for(;g<o;){let E=h.getPartialFragment(g);if(E)g+=E.duration;else{p=!0;break}}if(p)return 0}}}let c=Math.max(o+xC,n+SC);if(I.warn(`skipping hole, adjusting currentTime from ${n} to ${c}`),this.moved=!0,this.stalled=null,s.currentTime=c,e&&!e.gap){let h=new Error(`fragment loaded with buffer holes, seeking from ${n} to ${c}`);r.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:C.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:h,reason:h.message,frag:e})}return c}}return 0}_tryNudgeBuffer(){let{config:e,hls:t,media:r,nudgeRetry:s}=this;if(r===null)return;let n=r.currentTime;if(this.nudgeRetry++,s<e.nudgeMaxRetry){let a=n+(s+1)*e.nudgeOffset,o=new Error(`Nudging 'currentTime' from ${n} to ${a}`);I.warn(o.message),r.currentTime=a,t.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:C.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1})}else{let a=new Error(`Playhead still not moving while enough data buffered @${n} after ${e.nudgeMaxRetry} nudges`);I.error(a.message),t.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:C.BUFFER_STALLED_ERROR,error:a,fatal:!0})}}},LC=100,Ug=class extends mo{constructor(e,t,r){super(e,t,r,"[stream-controller]",te.MAIN),this.audioCodecSwap=!1,this.gapController=null,this.level=-1,this._forceStartLoad=!1,this.altAudio=!1,this.audioOnly=!1,this.fragPlaying=null,this.onvplaying=null,this.onvseeked=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this._registerListeners()}_registerListeners(){let{hls:e}=this;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.LEVEL_LOADING,this.onLevelLoading,this),e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(v.ERROR,this.onError,this),e.on(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(v.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(v.BUFFER_CREATED,this.onBufferCreated,this),e.on(v.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){let{hls:e}=this;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(v.ERROR,this.onError,this),e.off(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(v.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(v.BUFFER_CREATED,this.onBufferCreated,this),e.off(v.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying()}startLoad(e){if(this.levels){let{lastCurrentTime:t,hls:r}=this;if(this.stopLoad(),this.setInterval(LC),this.level=-1,!this.startFragRequested){let s=r.startLevel;s===-1&&(r.config.testBandwidth&&this.levels.length>1?(s=0,this.bitrateTest=!0):s=r.firstAutoLevel),r.nextLoadLevel=s,this.level=r.loadLevel,this.loadedmetadata=!1}t>0&&e===-1&&(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t),this.state=N.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=N.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case N.WAITING_LEVEL:{let{levels:t,level:r}=this,s=t==null?void 0:t[r],n=s==null?void 0:s.details;if(n&&(!n.live||this.levelLastLoaded===s)){if(this.waitForCdnTuneIn(n))break;this.state=N.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=N.IDLE;break}break}case N.FRAG_LOADING_WAITING_RETRY:{var e;let t=self.performance.now(),r=this.retryDate;if(!r||t>=r||(e=this.media)!=null&&e.seeking){let{levels:s,level:n}=this,a=s==null?void 0:s[n];this.resetStartWhenNotLoaded(a||null),this.state=N.IDLE}}break}this.state===N.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){let{hls:e,levelLastLoaded:t,levels:r,media:s}=this;if(t===null||!s&&(this.startFragRequested||!e.config.startFragPrefetch)||this.altAudio&&this.audioOnly)return;let n=e.nextLoadLevel;if(!(r!=null&&r[n]))return;let a=r[n],o=this.getMainFwdBufferInfo();if(o===null)return;let l=this.getLevelDetails();if(l&&this._streamEnded(o,l)){let p={};this.altAudio&&(p.type="video"),this.hls.trigger(v.BUFFER_EOS,p),this.state=N.ENDED;return}e.loadLevel!==n&&e.manualLevel===-1&&this.log(`Adapting to level ${n} from level ${this.level}`),this.level=e.nextLoadLevel=n;let d=a.details;if(!d||this.state===N.WAITING_LEVEL||d.live&&this.levelLastLoaded!==a){this.level=n,this.state=N.WAITING_LEVEL;return}let u=o.len,c=this.getMaxBufferLength(a.maxBitrate);if(u>=c)return;this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);let h=this.backtrackFragment?this.backtrackFragment.start:o.end,f=this.getNextFragment(h,d);if(this.couldBacktrack&&!this.fragPrevious&&f&&f.sn!=="initSegment"&&this.fragmentTracker.getState(f)!==ht.OK){var m;let g=((m=this.backtrackFragment)!=null?m:f).sn-d.startSN,E=d.fragments[g-1];E&&f.cc===E.cc&&(f=E,this.fragmentTracker.removeFragment(E))}else this.backtrackFragment&&o.len&&(this.backtrackFragment=null);if(f&&this.isLoopLoading(f,h)){if(!f.gap){let g=this.audioOnly&&!this.altAudio?ke.AUDIO:ke.VIDEO,E=(g===ke.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;E&&this.afterBufferFlushed(E,g,te.MAIN)}f=this.getNextFragmentLoopLoading(f,d,o,te.MAIN,c)}f&&(f.initSegment&&!f.initSegment.data&&!this.bitrateTest&&(f=f.initSegment),this.loadFragment(f,a,h))}loadFragment(e,t,r){let s=this.fragmentTracker.getState(e);this.fragCurrent=e,s===ht.NOT_LOADED||s===ht.PARTIAL?e.sn==="initSegment"?this._loadInitSegment(e,t):this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):(this.startFragRequested=!0,super.loadFragment(e,t,r)):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,te.MAIN)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){let{levels:e,media:t}=this;if(t!=null&&t.readyState){let r,s=this.getAppendedFrag(t.currentTime);s&&s.start>1&&this.flushMainBuffer(0,s.start-1);let n=this.getLevelDetails();if(n!=null&&n.live){let o=this.getMainFwdBufferInfo();if(!o||o.len<n.targetduration*2)return}if(!t.paused&&e){let o=this.hls.nextLoadLevel,l=e[o],d=this.fragLastKbps;d&&this.fragCurrent?r=this.fragCurrent.duration*l.maxBitrate/(1e3*d)+1:r=0}else r=0;let a=this.getBufferedFrag(t.currentTime+r);if(a){let o=this.followingBufferedFrag(a);if(o){this.abortCurrentFrag();let l=o.maxStartPTS?o.maxStartPTS:o.start,d=o.duration,u=Math.max(a.end,l+Math.min(Math.max(d-this.config.maxFragLookUpTolerance,d*(this.couldBacktrack?.5:.125)),d*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(u,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){let e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case N.KEY_LOADING:case N.FRAG_LOADING:case N.FRAG_LOADING_WAITING_RETRY:case N.PARSING:case N.PARSED:this.state=N.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);let r=t.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),r.addEventListener("playing",this.onvplaying),r.addEventListener("seeked",this.onvseeked),this.gapController=new Ng(this.config,r,this.fragmentTracker,this.hls)}onMediaDetaching(){let{media:e}=this;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching()}onMediaPlaying(){this.tick()}onMediaSeeked(){let e=this.media,t=e?e.currentTime:null;q(t)&&this.log(`Media seeked to ${t.toFixed(3)}`);let r=this.getMainFwdBufferInfo();if(r===null||r.len===0){this.warn(`Main forward buffer length on "seeked" event ${r?r.len:"empty"})`);return}this.tick()}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(v.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=this.fragLastKbps=0,this.levels=this.fragPlaying=this.backtrackFragment=this.levelLastLoaded=null,this.altAudio=this.audioOnly=this.startFragRequested=!1}onManifestParsed(e,t){let r=!1,s=!1;t.levels.forEach(n=>{let a=n.audioCodec;a&&(r=r||a.indexOf("mp4a.40.2")!==-1,s=s||a.indexOf("mp4a.40.5")!==-1)}),this.audioCodecSwitch=r&&s&&!_C(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}onLevelLoading(e,t){let{levels:r}=this;if(!r||this.state!==N.IDLE)return;let s=r[t.level];(!s.details||s.details.live&&this.levelLastLoaded!==s||this.waitForCdnTuneIn(s.details))&&(this.state=N.WAITING_LEVEL)}onLevelLoaded(e,t){var r;let{levels:s}=this,n=t.level,a=t.details,o=a.totalduration;if(!s){this.warn(`Levels were reset while loading level ${n}`);return}this.log(`Level ${n} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""}, cc [${a.startCC}, ${a.endCC}] duration:${o}`);let l=s[n],d=this.fragCurrent;d&&(this.state===N.FRAG_LOADING||this.state===N.FRAG_LOADING_WAITING_RETRY)&&d.level!==t.level&&d.loader&&this.abortCurrentFrag();let u=0;if(a.live||(r=l.details)!=null&&r.live){var c;if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;u=this.alignPlaylists(a,l.details,(c=this.levelLastLoaded)==null?void 0:c.details)}if(l.details=a,this.levelLastLoaded=l,this.hls.trigger(v.LEVEL_UPDATED,{details:a,level:n}),this.state===N.WAITING_LEVEL){if(this.waitForCdnTuneIn(a))return;this.state=N.IDLE}this.startFragRequested?a.live&&this.synchronizeToLiveEdge(a):this.setStartPosition(a,u),this.tick()}_handleFragmentLoadProgress(e){var t;let{frag:r,part:s,payload:n}=e,{levels:a}=this;if(!a){this.warn(`Levels were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);return}let o=a[r.level],l=o.details;if(!l){this.warn(`Dropping fragment ${r.sn} of level ${r.level} after level details were reset`),this.fragmentTracker.removeFragment(r);return}let d=o.videoCodec,u=l.PTSKnown||!l.live,c=(t=r.initSegment)==null?void 0:t.data,h=this._getAudioCodec(o),f=this.transmuxer=this.transmuxer||new ac(this.hls,te.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),m=s?s.index:-1,p=m!==-1,g=new ho(r.level,r.sn,r.stats.chunkCount,n.byteLength,m,p),E=this.initPTS[r.cc];f.push(n,c,h,d,r,s,l.totalduration,u,g,E)}onAudioTrackSwitching(e,t){let r=this.altAudio;if(!!!t.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;let a=this.fragCurrent;a&&(this.log("Switching to main audio track, cancel main fragment load"),a.abortRequests(),this.fragmentTracker.removeFragment(a)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();let n=this.hls;r&&(n.trigger(v.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),n.trigger(v.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){let r=t.id,s=!!this.hls.audioTracks[r].url;if(s){let n=this.videoBuffer;n&&this.mediaBuffer!==n&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=n)}this.altAudio=s,this.tick()}onBufferCreated(e,t){let r=t.tracks,s,n,a=!1;for(let o in r){let l=r[o];if(l.id==="main"){if(n=o,s=l,o==="video"){let d=r[o];d&&(this.videoBuffer=d.buffer)}}else a=!0}a&&s?(this.log(`Alternate track found, use ${n}.buffered to schedule main fragment loading`),this.mediaBuffer=s.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){let{frag:r,part:s}=t;if(r&&r.type!==te.MAIN)return;if(this.fragContextChanged(r)){this.warn(`Fragment ${r.sn}${s?" p: "+s.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}`),this.state===N.PARSED&&(this.state=N.IDLE);return}let n=s?s.stats:r.stats;this.fragLastKbps=Math.round(8*n.total/(n.buffering.end-n.loading.first)),r.sn!=="initSegment"&&(this.fragPrevious=r),this.fragBufferedComplete(r,s)}onError(e,t){var r;if(t.fatal){this.state=N.ERROR;return}switch(t.details){case C.FRAG_GAP:case C.FRAG_PARSING_ERROR:case C.FRAG_DECRYPT_ERROR:case C.FRAG_LOAD_ERROR:case C.FRAG_LOAD_TIMEOUT:case C.KEY_LOAD_ERROR:case C.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(te.MAIN,t);break;case C.LEVEL_LOAD_ERROR:case C.LEVEL_LOAD_TIMEOUT:case C.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===N.WAITING_LEVEL&&((r=t.context)==null?void 0:r.type)===ge.LEVEL&&(this.state=N.IDLE);break;case C.BUFFER_APPEND_ERROR:case C.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="main")return;if(t.details===C.BUFFER_APPEND_ERROR){this.resetLoadingState();return}this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case C.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}checkBuffer(){let{media:e,gapController:t}=this;if(!(!e||!t||!e.readyState)){if(this.loadedmetadata||!Ue.getBuffered(e).length){let r=this.state!==N.IDLE?this.fragCurrent:null;t.poll(this.lastCurrentTime,r)}this.lastCurrentTime=e.currentTime}}onFragLoadEmergencyAborted(){this.state=N.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==ke.AUDIO||this.audioOnly&&!this.altAudio){let r=(t===ke.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(r,t,te.MAIN),this.tick()}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level),this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){let{media:e}=this;if(!e)return;let t=e.currentTime,r=this.startPosition;if(r>=0&&t<r){if(e.seeking){this.log(`could not seek to ${r}, already seeking at ${t}`);return}let s=Ue.getBuffered(e),a=(s.length?s.start(0):0)-r;a>0&&(a<this.config.maxBufferHole||a<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${a} to match buffer start`),r+=a,this.startPosition=r),this.log(`seek to target start position ${r} from current time ${t}`),e.currentTime=r}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t.indexOf("mp4a.40.5")!==-1?t="mp4a.40.2":t="mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(r=>{let{hls:s}=this;if(!r||this.fragContextChanged(e))return;t.fragmentError=0,this.state=N.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;let n=e.stats;n.parsing.start=n.parsing.end=n.buffering.start=n.buffering.end=self.performance.now(),s.trigger(v.FRAG_LOADED,r),e.bitrateTest=!1})}_handleTransmuxComplete(e){var t;let r="main",{hls:s}=this,{remuxResult:n,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}let{frag:l,part:d,level:u}=o,{video:c,text:h,id3:f,initSegment:m}=n,{details:p}=u,g=this.altAudio?void 0:n.audio;if(this.fragContextChanged(l)){this.fragmentTracker.removeFragment(l);return}if(this.state=N.PARSING,m){if(m!=null&&m.tracks){let y=l.initSegment||l;this._bufferInitSegment(u,m.tracks,y,a),s.trigger(v.FRAG_PARSING_INIT_SEGMENT,{frag:y,id:r,tracks:m.tracks})}let E=m.initPTS,T=m.timescale;q(E)&&(this.initPTS[l.cc]={baseTime:E,timescale:T},s.trigger(v.INIT_PTS_FOUND,{frag:l,id:r,initPTS:E,timescale:T}))}if(c&&p&&l.sn!=="initSegment"){let E=p.fragments[l.sn-1-p.startSN],T=l.sn===p.startSN,y=!E||l.cc>E.cc;if(n.independent!==!1){let{startPTS:S,endPTS:_,startDTS:L,endDTS:x}=c;if(d)d.elementaryStreams[c.type]={startPTS:S,endPTS:_,startDTS:L,endDTS:x};else if(c.firstKeyFrame&&c.independent&&a.id===1&&!y&&(this.couldBacktrack=!0),c.dropped&&c.independent){let w=this.getMainFwdBufferInfo(),M=(w?w.end:this.getLoadPosition())+this.config.maxBufferHole,k=c.firstKeyFramePTS?c.firstKeyFramePTS:S;if(!T&&M<k-this.config.maxBufferHole&&!y){this.backtrack(l);return}else y&&(l.gap=!0);l.setElementaryStreamInfo(c.type,l.start,_,l.start,x,!0)}else T&&S>Hu&&(l.gap=!0);l.setElementaryStreamInfo(c.type,S,_,L,x),this.backtrackFragment&&(this.backtrackFragment=l),this.bufferFragmentData(c,l,d,a,T||y)}else if(T||y)l.gap=!0;else{this.backtrack(l);return}}if(g){let{startPTS:E,endPTS:T,startDTS:y,endDTS:S}=g;d&&(d.elementaryStreams[ke.AUDIO]={startPTS:E,endPTS:T,startDTS:y,endDTS:S}),l.setElementaryStreamInfo(ke.AUDIO,E,T,y,S),this.bufferFragmentData(g,l,d,a)}if(p&&f!=null&&(t=f.samples)!=null&&t.length){let E={id:r,frag:l,details:p,samples:f.samples};s.trigger(v.FRAG_PARSING_METADATA,E)}if(p&&h){let E={id:r,frag:l,details:p,samples:h.samples};s.trigger(v.FRAG_PARSING_USERDATA,E)}}_bufferInitSegment(e,t,r,s){if(this.state!==N.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;let{audio:n,video:a,audiovideo:o}=t;if(n){let l=e.audioCodec,d=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(l&&(l.indexOf("mp4a.40.5")!==-1?l="mp4a.40.2":l="mp4a.40.5"),n.metadata.channelCount!==1&&d.indexOf("firefox")===-1&&(l="mp4a.40.5")),l&&l.indexOf("mp4a.40.5")!==-1&&d.indexOf("android")!==-1&&n.container!=="audio/mpeg"&&(l="mp4a.40.2",this.log(`Android: force audio codec to ${l}`)),e.audioCodec&&e.audioCodec!==l&&this.log(`Swapping manifest audio codec "${e.audioCodec}" for "${l}"`),n.levelCodec=l,n.id="main",this.log(`Init audio buffer, container:${n.container}, codecs[selected/level/parsed]=[${l||""}/${e.audioCodec||""}/${n.codec}]`)}a&&(a.levelCodec=e.videoCodec,a.id="main",this.log(`Init video buffer, container:${a.container}, codecs[level/parsed]=[${e.videoCodec||""}/${a.codec}]`)),o&&this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.codecs}/${o.codec}]`),this.hls.trigger(v.BUFFER_CODECS,t),Object.keys(t).forEach(l=>{let u=t[l].initSegment;u!=null&&u.byteLength&&this.hls.trigger(v.BUFFER_APPENDING,{type:l,data:u,frag:r,part:null,chunkMeta:s,parent:r.type})}),this.tickImmediate()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,te.MAIN)}backtrack(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=N.IDLE}checkFragmentChanged(){let e=this.media,t=null;if(e&&e.readyState>1&&e.seeking===!1){let r=e.currentTime;if(Ue.isBuffered(e,r)?t=this.getAppendedFrag(r):Ue.isBuffered(e,r+.1)&&(t=this.getAppendedFrag(r+.1)),t){this.backtrackFragment=null;let s=this.fragPlaying,n=t.level;(!s||t.sn!==s.sn||s.level!==n)&&(this.fragPlaying=t,this.hls.trigger(v.FRAG_CHANGED,{frag:t}),(!s||s.level!==n)&&this.hls.trigger(v.LEVEL_SWITCHED,{level:n}))}}}get nextLevel(){let e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){let e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}get currentProgramDateTime(){let e=this.media;if(e){let t=e.currentTime,r=this.currentFrag;if(r&&q(t)&&q(r.programDateTime)){let s=r.programDateTime+(t-r.start)*1e3;return new Date(s)}}return null}get currentLevel(){let e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){let e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}},vo=class i{static get version(){return"1.5.8"}static isMSESupported(){return $_()}static isSupported(){return TC()}static getMediaSource(){return ks()}static get Events(){return v}static get ErrorTypes(){return ie}static get ErrorDetails(){return C}static get DefaultConfig(){return i.defaultConfig?i.defaultConfig:F_}static set DefaultConfig(e){i.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this.started=!1,this._emitter=new qg,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,this.triggeringException=void 0,uI(e.debug||!1,"Hls instance");let t=this.config=bC(i.DefaultConfig,e);this.userConfig=e,t.progressive&&yC(t);let{abrController:r,bufferController:s,capLevelController:n,errorController:a,fpsController:o}=t,l=new a(this),d=this.abrController=new r(this),u=this.bufferController=new s(this),c=this.capLevelController=new n(this),h=new o(this),f=new Pp(this),m=new Up(this),p=t.contentSteeringController,g=p?new p(this):null,E=this.levelController=new Pg(this,g),T=new qp(this),y=new Og(this.config),S=this.streamController=new Ug(this,T,y);c.setStreamController(S),h.setStreamController(S);let _=[f,E,S];g&&_.splice(1,0,g),this.networkControllers=_;let L=[d,u,c,h,m,T];this.audioTrackController=this.createController(t.audioTrackController,_);let x=t.audioStreamController;x&&_.push(new x(this,T,y)),this.subtitleTrackController=this.createController(t.subtitleTrackController,_);let w=t.subtitleStreamController;w&&_.push(new w(this,T,y)),this.createController(t.timelineController,L),y.emeController=this.emeController=this.createController(t.emeController,L),this.cmcdController=this.createController(t.cmcdController,L),this.latencyController=this.createController(Fp,L),this.coreComponents=L,_.push(l);let M=l.onErrorOut;typeof M=="function"&&this.on(v.ERROR,M,l)}createController(e,t){if(e){let r=new e(this);return t&&t.push(r),r}return null}on(e,t,r=this){this._emitter.on(e,t,r)}once(e,t,r=this){this._emitter.once(e,t,r)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,r=this,s){this._emitter.off(e,t,r,s)}listeners(e){return this._emitter.listeners(e)}emit(e,t,r){return this._emitter.emit(e,t,r)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(r){if(I.error("An internal error happened while handling event "+e+'. Error message: "'+r.message+'". Here is a stacktrace:',r),!this.triggeringException){this.triggeringException=!0;let s=e===v.ERROR;this.trigger(v.ERROR,{type:ie.OTHER_ERROR,details:C.INTERNAL_EXCEPTION,fatal:s,event:e,error:r}),this.triggeringException=!1}}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){I.log("destroy"),this.trigger(v.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(t=>t.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(t=>t.destroy()),this.coreComponents.length=0;let e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){I.log("attachMedia"),this._media=e,this.trigger(v.MEDIA_ATTACHING,{media:e})}detachMedia(){I.log("detachMedia"),this.trigger(v.MEDIA_DETACHING,void 0),this._media=null}loadSource(e){this.stopLoad();let t=this.media,r=this.url,s=this.url=Fg.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,I.log(`loadSource:${s}`),t&&r&&(r!==s||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(v.MANIFEST_LOADING,{url:e})}startLoad(e=-1){I.log(`startLoad(${e})`),this.started=!0,this.networkControllers.forEach(t=>{t.startLoad(e)})}stopLoad(){I.log("stopLoad"),this.started=!1,this.networkControllers.forEach(e=>{e.stopLoad()})}resumeBuffering(){this.started&&this.networkControllers.forEach(e=>{"fragmentLoader"in e&&e.startLoad(-1)})}pauseBuffering(){this.networkControllers.forEach(e=>{"fragmentLoader"in e&&e.stopLoad()})}swapAudioCodec(){I.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){I.log("recoverMediaError");let e=this._media;this.detachMedia(),e&&this.attachMedia(e)}removeLevel(e){this.levelController.removeLevel(e)}get levels(){let e=this.levelController.levels;return e||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){I.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){I.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){I.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){I.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){let e=this.levelController.startLevel;return e===-1&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e}set startLevel(e){I.log(`set startLevel:${e}`),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){let t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){let{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}set bandwidthEstimate(e){this.abrController.resetEstimator(e)}get ttfbEstimate(){let{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(I.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){aR(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){let{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;let r=e.length;for(let s=0;s<r;s++)if(e[s].maxBitrate>=t)return s;return 0}get maxAutoLevel(){let{levels:e,autoLevelCapping:t,maxHdcpLevel:r}=this,s;if(t===-1&&e!=null&&e.length?s=e.length-1:s=t,r)for(let n=s;n--;){let a=e[n].attrs["HDCP-LEVEL"];if(a&&a<=r)return n}return s}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(e){this.abrController.nextAutoLevel=e}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}setAudioOption(e){var t;return(t=this.audioTrackController)==null?void 0:t.setAudioOption(e)}setSubtitleOption(e){var t;return(t=this.subtitleTrackController)==null||t.setSubtitleOption(e),null}get allAudioTracks(){let e=this.audioTrackController;return e?e.allAudioTracks:[]}get audioTracks(){let e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){let e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){let t=this.audioTrackController;t&&(t.audioTrack=e)}get allSubtitleTracks(){let e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}get subtitleTracks(){let e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){let e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){let t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){let e=this.subtitleTrackController;return e?e.subtitleDisplay:!1}set subtitleDisplay(e){let t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}};vo.defaultConfig=void 0;var Ve=vo,Pr=class Eo extends Error{constructor(e,t=Eo.MEDIA_ERR_CUSTOM,r,s){var n;super(e),this.name="MediaError",this.code=t,this.context=s,this.fatal=r!=null?r:t>=Eo.MEDIA_ERR_NETWORK&&t<=Eo.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(n=Eo.defaultMessages[this.code])!=null?n:"")}};Pr.MEDIA_ERR_ABORTED=1,Pr.MEDIA_ERR_NETWORK=2,Pr.MEDIA_ERR_DECODE=3,Pr.MEDIA_ERR_SRC_NOT_SUPPORTED=4,Pr.MEDIA_ERR_ENCRYPTED=5,Pr.MEDIA_ERR_CUSTOM=100,Pr.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 bt=Pr,kC=i=>i==null,q_=(i,e)=>kC(e)?!1:i in e,Jg={ANY:"any",MUTED:"muted"},ye={ON_DEMAND:"on-demand",LIVE:"live",UNKNOWN:"unknown"},ei={MSE:"mse",NATIVE:"native"},pc={HEADER:"header",QUERY:"query",NONE:"none"},zn=Object.values(pc),Or={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},e0={HLS:Or.M3U8},a5=Object.keys(e0),o5=[...Object.values(Or),"hls","HLS"];var mt=(i,e,t,r,s=i)=>{s.addEventListener(e,t,r),i.addEventListener("teardown",()=>{s.removeEventListener(e,t)},{once:!0})};function IC(i,e,t){e&&t>e&&(t=e);for(let r=0;r<i.length;r++)if(i.start(r)<=t&&i.end(r)>=t)return!0;return!1}var RC=i=>{let e=i.indexOf("?");if(e<0)return[i];let t=i.slice(0,e),r=i.slice(e);return[t,r]},vc=i=>{let e=i.type;if(e){let r=e.toUpperCase();return q_(r,e0)?e0[r]:e}let{src:t}=i;return t?wC(t):""},Y_=i=>i==="VOD"?ye.ON_DEMAND:ye.LIVE,z_=i=>i==="EVENT"?Number.POSITIVE_INFINITY:i==="VOD"?Number.NaN:0,wC=i=>{let e="";try{e=new URL(i).pathname}catch{console.error("invalid url")}let t=e.lastIndexOf(".");if(t<0)return"";let r=e.slice(t+1).toUpperCase();return q_(r,Or)?Or[r]:""},CC=Object.values(Jg),H_=i=>typeof i=="boolean"||typeof i=="string"&&CC.includes(i),DC=(i,e,t)=>{let{autoplay:r}=i,s=!1,n=!1,a=H_(r)?r:!!r,o=()=>{s||mt(e,"playing",()=>{s=!0},{once:!0})};if(o(),mt(e,"loadstart",()=>{s=!1,o(),Xg(e,a)},{once:!0}),mt(e,"loadstart",()=>{t||(i.streamType&&i.streamType!==ye.UNKNOWN?n=i.streamType===ye.LIVE:n=!Number.isFinite(e.duration)),Xg(e,a)},{once:!0}),t&&t.once(Ve.Events.LEVEL_LOADED,(l,d)=>{var u;i.streamType&&i.streamType!==ye.UNKNOWN?n=i.streamType===ye.LIVE:n=(u=d.details.live)!=null?u:!1}),!a){let l=()=>{!n||Number.isFinite(i.startTime)||(t!=null&&t.liveSyncPosition?e.currentTime=t.liveSyncPosition:Number.isFinite(e.seekable.end(0))&&(e.currentTime=e.seekable.end(0)))};t&&mt(e,"play",()=>{e.preload==="metadata"?t.once(Ve.Events.LEVEL_UPDATED,l):l()},{once:!0})}return l=>{s||(a=H_(l)?l:!!l,Xg(e,a))}},Xg=(i,e)=>{if(!e)return;let t=i.muted,r=()=>i.muted=t;switch(e){case Jg.ANY:i.play().catch(()=>{i.muted=!0,i.play().catch(r)});break;case Jg.MUTED:i.muted=!0,i.play().catch(r);break;default:i.play().catch(()=>{});break}},MC=({preload:i,src:e},t,r)=>{let s=c=>{c!=null&&["","none","metadata","auto"].includes(c)?t.setAttribute("preload",c):t.removeAttribute("preload")};if(!r)return s(i),s;let n=!1,a=!1,o=r.config.maxBufferLength,l=r.config.maxBufferSize,d=c=>{s(c);let h=c!=null?c:t.preload;a||h==="none"||(h==="metadata"?(r.config.maxBufferLength=1,r.config.maxBufferSize=1):(r.config.maxBufferLength=o,r.config.maxBufferSize=l),u())},u=()=>{!n&&e&&(n=!0,r.loadSource(e))};return mt(t,"play",()=>{a=!0,r.config.maxBufferLength=o,r.config.maxBufferSize=l,u()},{once:!0}),d(i),d};function PC(i,e){var t;if(!("videoTracks"in i))return;let r=new WeakMap;e.on(Ve.Events.MANIFEST_PARSED,function(d,u){l();let c=i.addVideoTrack("main");c.selected=!0;for(let[h,f]of u.levels.entries()){let m=c.addRendition(f.url[0],f.width,f.height,f.videoCodec,f.bitrate);r.set(f,`${h}`),m.id=`${h}`}}),e.on(Ve.Events.AUDIO_TRACKS_UPDATED,function(d,u){o();for(let c of u.audioTracks){let h=c.default?"main":"alternative",f=i.addAudioTrack(h,c.name,c.lang);f.id=`${c.id}`,c.default&&(f.enabled=!0)}}),i.audioTracks.addEventListener("change",()=>{var d;let u=+((d=[...i.audioTracks].find(h=>h.enabled))==null?void 0:d.id),c=e.audioTracks.map(h=>h.id);u!=e.audioTrack&&c.includes(u)&&(e.audioTrack=u)}),e.on(Ve.Events.LEVELS_UPDATED,function(d,u){var c;let h=i.videoTracks[(c=i.videoTracks.selectedIndex)!=null?c:0];if(!h)return;let f=u.levels.map(m=>r.get(m));for(let m of i.videoRenditions)m.id&&!f.includes(m.id)&&h.removeRendition(m)});let s=d=>{let u=d.target.selectedIndex;u!=e.nextLevel&&n(u)},n=d=>{let u=i.currentTime,c=!1,h=(f,m)=>{c||(c=!Number.isFinite(m.endOffset))};e.on(Ve.Events.BUFFER_FLUSHING,h),e.nextLevel=d,e.off(Ve.Events.BUFFER_FLUSHING,h),c||e.trigger(Ve.Events.BUFFER_FLUSHING,{startOffset:u+10,endOffset:1/0,type:"video"})};(t=i.videoRenditions)==null||t.addEventListener("change",s);let a=()=>{for(let d of i.videoTracks)i.removeVideoTrack(d)},o=()=>{for(let d of i.audioTracks)i.removeAudioTrack(d)},l=()=>{a(),o()};e.once(Ve.Events.DESTROYING,l)}var Qg=i=>"time"in i?i.time:i.startTime;function OC(i,e){e.on(Ve.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(s,{tracks:n})=>{n.forEach(a=>{var o;let l=(o=a.subtitleTrack)!=null?o:a.closedCaptions,d=e.subtitleTracks.findIndex(({lang:u,name:c,type:h})=>u==(l==null?void 0:l.lang)&&c===a.label&&h.toLowerCase()===a.kind);Ec(i,a.kind,a.label,l==null?void 0:l.lang,`${a.kind}${d}`)})});let t=()=>{var s;if(!e.subtitleTracks.length)return;let n=Array.from(i.textTracks).find(o=>o.id&&o.mode==="showing"&&["subtitles","captions"].includes(o.kind)),a=`${(s=e.subtitleTracks[e.subtitleTrack])==null?void 0:s.type.toLowerCase()}${e.subtitleTrack}`;if(n&&(e.subtitleTrack<0||(n==null?void 0:n.id)!==a)){let o=e.subtitleTracks.findIndex(({lang:l,name:d,type:u})=>l==n.language&&d===n.label&&u.toLowerCase()===n.kind);e.subtitleTrack=o}n&&(n==null?void 0:n.id)===a&&n.cues&&Array.from(n.cues).forEach(o=>{n.addCue(o)})};i.textTracks.addEventListener("change",t),e.on(Ve.Events.CUES_PARSED,(s,{track:n,cues:a})=>{let o=i.textTracks.getTrackById(n);if(!o)return;let l=o.mode==="disabled";l&&(o.mode="hidden"),a.forEach(d=>{var u;(u=o.cues)!=null&&u.getCueById(d.id)||o.addCue(d)}),l&&(o.mode="disabled")}),e.once(Ve.Events.DESTROYING,()=>{i.textTracks.removeEventListener("change",t),i.querySelectorAll("track[data-removeondestroy]").forEach(s=>{s.remove()})});let r=()=>{Array.from(i.textTracks).forEach(s=>{var n,a;if(!["subtitles","caption"].includes(s.kind)&&s.label==="thumbnails"){if(!((n=s.cues)!=null&&n.length)){let o=i.querySelector('track[label="thumbnails"]'),l=(a=o==null?void 0:o.getAttribute("src"))!=null?a:"";o==null||o.removeAttribute("src"),setTimeout(()=>{o==null||o.setAttribute("src",l)},0)}s.mode!=="hidden"&&(s.mode="hidden")}})};e.once(Ve.Events.MANIFEST_LOADED,r),e.once(Ve.Events.MEDIA_ATTACHED,r)}function Ec(i,e,t,r,s){let n=document.createElement("track");return n.kind=e,n.label=t,r&&(n.srclang=r),s&&(n.id=s),n.track.mode=["subtitles","captions"].includes(e)?"disabled":"hidden",n.setAttribute("data-removeondestroy",""),i.append(n),n.track}function j_(i,e){let t=Array.prototype.find.call(i.querySelectorAll("track"),r=>r.track===e);t==null||t.remove()}function yo(i,e,t){var r;return(r=Array.from(i.querySelectorAll("track")).find(s=>s.track.label===e&&s.track.kind===t))==null?void 0:r.track}async function X_(i,e,t,r){let s=yo(i,t,r);return s||(s=Ec(i,r,t),s.mode="hidden",await new Promise(n=>setTimeout(()=>n(void 0),0))),s.mode!=="hidden"&&(s.mode="hidden"),[...e].sort((n,a)=>Qg(a)-Qg(n)).forEach(n=>{var a,o;let l=n.value,d=Qg(n);if("endTime"in n&&n.endTime!=null)s==null||s.addCue(new VTTCue(d,n.endTime,r==="chapters"?l:JSON.stringify(l!=null?l:null)));else{let u=Array.prototype.findIndex.call(s==null?void 0:s.cues,m=>m.startTime>=d),c=(a=s==null?void 0:s.cues)==null?void 0:a[u],h=c?c.startTime:Number.isFinite(i.duration)?i.duration:Number.MAX_SAFE_INTEGER,f=(o=s==null?void 0:s.cues)==null?void 0:o[u-1];f&&(f.endTime=d),s==null||s.addCue(new VTTCue(d,h,r==="chapters"?l:JSON.stringify(l!=null?l:null)))}}),i.textTracks.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),s}var s0="cuepoints",Q_=Object.freeze({label:s0});async function n0(i,e,t=Q_){return X_(i,e,t.label,"metadata")}var t0=i=>({time:i.startTime,value:JSON.parse(i.text)});function Z_(i,e={label:s0}){let t=yo(i,e.label,"metadata");return t!=null&&t.cues?Array.from(t.cues,r=>t0(r)):[]}function a0(i,e={label:s0}){var t,r;let s=yo(i,e.label,"metadata");if(!((t=s==null?void 0:s.activeCues)!=null&&t.length))return;if(s.activeCues.length===1)return t0(s.activeCues[0]);let{currentTime:n}=i,a=Array.prototype.find.call((r=s.activeCues)!=null?r:[],({startTime:o,endTime:l})=>o<=n&&l>n);return t0(a||s.activeCues[0])}async function NC(i,e=Q_){return new Promise(t=>{mt(i,"loadstart",async()=>{let r=await n0(i,[],e);mt(i,"cuechange",()=>{let s=a0(i);if(s){let n=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:s});i.dispatchEvent(n)}},{},r),t(r)})})}var o0="chapters",J_=Object.freeze({label:o0}),i0=i=>({startTime:i.startTime,endTime:i.endTime,value:i.text});async function l0(i,e,t=J_){return X_(i,e,t.label,"chapters")}function eA(i,e={label:o0}){var t;let r=yo(i,e.label,"chapters");return(t=r==null?void 0:r.cues)!=null&&t.length?Array.from(r.cues,s=>i0(s)):[]}function d0(i,e={label:o0}){var t,r;let s=yo(i,e.label,"chapters");if(!((t=s==null?void 0:s.activeCues)!=null&&t.length))return;if(s.activeCues.length===1)return i0(s.activeCues[0]);let{currentTime:n}=i,a=Array.prototype.find.call((r=s.activeCues)!=null?r:[],({startTime:o,endTime:l})=>o<=n&&l>n);return i0(a||s.activeCues[0])}async function UC(i,e=J_){return new Promise(t=>{mt(i,"loadstart",async()=>{let r=await l0(i,[],e);mt(i,"cuechange",()=>{let s=d0(i);if(s){let n=new CustomEvent("chapterchange",{composed:!0,bubbles:!0,detail:s});i.dispatchEvent(n)}},{},r),t(r)})})}function tA(i,e){if(e){let t=e.playingDate;if(t!=null)return new Date(t.getTime()-i.currentTime*1e3)}return typeof i.getStartDate=="function"?i.getStartDate():new Date(NaN)}function iA(i,e){if(e&&e.playingDate)return e.playingDate;if(typeof i.getStartDate=="function"){let t=i.getStartDate();return new Date(t.getTime()+i.currentTime*1e3)}return new Date(NaN)}var FC=async i=>fetch(i).then(e=>e.text()).then(e=>{let t=e.split(`
1600
+ `),d=[],u=e?ew(e.baseTime,e.timescale):0,c="00:00.000",h=0,f=0,m,p=!0;o.oncue=function(g){let E=t[r],T=t.ccOffset,y=(h-u)/9e4;if(E!=null&&E.new&&(f!==void 0?T=t.ccOffset=E.start:yw(t,r,y)),y){if(!e){m=new Error("Missing initPTS for VTT MPEGTS");return}T=y-t.presentationOffset}let S=g.endTime-g.startTime,A=Zt((g.startTime+T-f)*9e4,s*9e4)/9e4;g.startTime=Math.max(A,0),g.endTime=Math.max(A+S,0);let L=g.text.trim();g.text=decodeURIComponent(encodeURIComponent(L)),g.id||(g.id=Zg(g.startTime,g.endTime,L)),g.endTime>0&&d.push(g)},o.onparsingerror=function(g){m=g},o.onflush=function(){if(m){a(m);return}n(d)},l.forEach(g=>{if(p)if(Lp(g,"X-TIMESTAMP-MAP=")){p=!1,g.slice(16).split(",").forEach(E=>{Lp(E,"LOCAL:")?c=E.slice(6):Lp(E,"MPEGTS:")&&(h=parseInt(E.slice(7)))});try{f=bw(c)/1e3}catch(E){m=E}return}else g===""&&(p=!1);o.parse(g+`
1601
+ `)}),o.flush()}var Ip="stpp.ttml.im1t",I_=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,R_=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,_w={left:"start",center:"center",right:"end",start:"start",end:"end"};function IT(i,e,t,r){let s=ae(new Uint8Array(i),["mdat"]);if(s.length===0){r(new Error("Could not parse IMSC1 mdat"));return}let n=s.map(o=>Qi(o)),a=JR(e.baseTime,1,e.timescale);try{n.forEach(o=>t(Aw(o,a)))}catch(o){r(o)}}function Aw(i,e){let s=new DOMParser().parseFromString(i,"text/xml").getElementsByTagName("tt")[0];if(!s)throw new Error("Invalid ttml");let n={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},a=Object.keys(n).reduce((c,h)=>(c[h]=s.getAttribute(`ttp:${h}`)||n[h],c),{}),o=s.getAttribute("xml:space")!=="preserve",l=RT(Rp(s,"styling","style")),d=RT(Rp(s,"layout","region")),u=Rp(s,"body","[begin]");return[].map.call(u,c=>{let h=w_(c,o);if(!h||!c.hasAttribute("begin"))return null;let f=Cp(c.getAttribute("begin"),a),m=Cp(c.getAttribute("dur"),a),p=Cp(c.getAttribute("end"),a);if(f===null)throw wT(c);if(p===null){if(m===null)throw wT(c);p=f+m}let g=new Qg(f-e,p-e,h);g.id=Zg(g.startTime,g.endTime,g.text);let E=d[c.getAttribute("region")],T=l[c.getAttribute("style")],y=Sw(E,T,l),{textAlign:S}=y;if(S){let A=_w[S];A&&(g.lineAlign=A),g.align=S}return Je(g,y),g}).filter(c=>c!==null)}function Rp(i,e,t){let r=i.getElementsByTagName(e)[0];return r?[].slice.call(r.querySelectorAll(t)):[]}function RT(i){return i.reduce((e,t)=>{let r=t.getAttribute("xml:id");return r&&(e[r]=t),e},{})}function w_(i,e){return[].slice.call(i.childNodes).reduce((t,r,s)=>{var n;return r.nodeName==="br"&&s?t+`
1602
+ `:(n=r.childNodes)!=null&&n.length?w_(r,e):e?t+r.textContent.trim().replace(/\s+/g," "):t+r.textContent},"")}function Sw(i,e,t){let r="http://www.w3.org/ns/ttml#styling",s=null,n=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=i!=null&&i.hasAttribute("style")?i.getAttribute("style"):null;return a&&t.hasOwnProperty(a)&&(s=t[a]),n.reduce((o,l)=>{let d=wp(e,r,l)||wp(i,r,l)||wp(s,r,l);return d&&(o[l]=d),o},{})}function wp(i,e,t){return i&&i.hasAttributeNS(e,t)?i.getAttributeNS(e,t):null}function wT(i){return new Error(`Could not parse ttml timestamp ${i}`)}function Cp(i,e){if(!i)return null;let t=x_(i);return t===null&&(I_.test(i)?t=xw(i,e):R_.test(i)&&(t=Lw(i,e))),t}function xw(i,e){let t=I_.exec(i),r=(t[4]|0)+(t[5]|0)/e.subFrameRate;return(t[1]|0)*3600+(t[2]|0)*60+(t[3]|0)+r/e.frameRate}function Lw(i,e){let t=R_.exec(i),r=Number(t[1]);switch(t[2]){case"h":return r*3600;case"m":return r*60;case"ms":return r*1e3;case"f":return r/e.frameRate;case"t":return r/e.tickRate}return r}var Ig=class{constructor(e){this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=DT(),this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},e.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(v.FRAG_LOADING,this.onFragLoading,this),e.on(v.FRAG_LOADED,this.onFragLoaded,this),e.on(v.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(v.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(v.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(v.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){let{hls:e}=this;e.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(v.FRAG_LOADING,this.onFragLoading,this),e.off(v.FRAG_LOADED,this.onFragLoaded,this),e.off(v.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(v.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(v.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(v.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){if(this.config.enableCEA708Captions&&(!this.cea608Parser1||!this.cea608Parser2)){let e=new Gn(this,"textTrack1"),t=new Gn(this,"textTrack2"),r=new Gn(this,"textTrack3"),s=new Gn(this,"textTrack4");this.cea608Parser1=new cc(1,e,t),this.cea608Parser2=new cc(3,r,s)}}addCues(e,t,r,s,n){let a=!1;for(let o=n.length;o--;){let l=n[o],d=kw(l[0],l[1],t,r);if(d>=0&&(l[0]=Math.min(l[0],t),l[1]=Math.max(l[1],r),a=!0,d/(r-t)>.5))return}if(a||n.push([t,r]),this.config.renderTextTracksNatively){let o=this.captionsTracks[e];this.Cues.newCue(o,t,r,s)}else{let o=this.Cues.newCue(null,t,r,s);this.hls.trigger(v.CUES_PARSED,{type:"captions",cues:o,track:e})}}onInitPtsFound(e,{frag:t,id:r,initPTS:s,timescale:n}){let{unparsedVttFrags:a}=this;r==="main"&&(this.initPTS[t.cc]={baseTime:s,timescale:n}),a.length&&(this.unparsedVttFrags=[],a.forEach(o=>{this.onFragLoaded(v.FRAG_LOADED,o)}))}getExistingTrack(e,t){let{media:r}=this;if(r)for(let s=0;s<r.textTracks.length;s++){let n=r.textTracks[s];if(CT(n,{name:e,lang:t,attrs:{}}))return n}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;let{captionsProperties:t,captionsTracks:r,media:s}=this,{label:n,languageCode:a}=t[e],o=this.getExistingTrack(n,a);if(o)r[e]=o,Hn(r[e]),JT(r[e],s);else{let l=this.createTextTrack("captions",n,a);l&&(l[e]=!0,r[e]=l)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;let t=this.captionsProperties[e];if(!t)return;let r=t.label,s={_id:e,label:r,kind:"captions",default:t.media?!!t.media.default:!1,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=s,this.hls.trigger(v.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[s]})}createTextTrack(e,t,r){let s=this.media;if(s)return s.addTextTrack(e,t,r)}onMediaAttaching(e,t){this.media=t.media,this._cleanTracks()}onMediaDetaching(){let{captionsTracks:e}=this;Object.keys(e).forEach(t=>{Hn(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=DT(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){let{media:e}=this;if(!e)return;let t=e.textTracks;if(t)for(let r=0;r<t.length;r++)Hn(t[r])}onSubtitleTracksUpdated(e,t){let r=t.subtitleTracks||[],s=r.some(n=>n.textCodec===Ip);if(this.config.enableWebVTT||s&&this.config.enableIMSC1){if(A_(this.tracks,r)){this.tracks=r;return}if(this.textTracks=[],this.tracks=r,this.config.renderTextTracksNatively){let a=this.media,o=a?Nu(a.textTracks):null;if(this.tracks.forEach((l,d)=>{let u;if(o){let c=null;for(let h=0;h<o.length;h++)if(o[h]&&CT(o[h],l)){c=o[h],o[h]=null;break}c&&(u=c)}if(u)Hn(u);else{let c=C_(l);u=this.createTextTrack(c,l.name,l.lang),u&&(u.mode="disabled")}u&&this.textTracks.push(u)}),o!=null&&o.length){let l=o.filter(d=>d!==null).map(d=>d.label);l.length&&I.warn(`Media element contains unused subtitle tracks: ${l.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){let a=this.tracks.map(o=>({label:o.name,kind:o.type.toLowerCase(),default:o.default,subtitleTrack:o}));this.hls.trigger(v.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:a})}}}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(r=>{let s=/(?:CC|SERVICE)([1-4])/.exec(r.instreamId);if(!s)return;let n=`textTrack${s[1]}`,a=this.captionsProperties[n];a&&(a.label=r.name,r.lang&&(a.languageCode=r.lang),a.media=r)})}closedCaptionsForLevel(e){let t=this.hls.levels[e.level];return t==null?void 0:t.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){if(this.enabled&&t.frag.type===J.MAIN){var r,s;let{cea608Parser1:n,cea608Parser2:a,lastSn:o}=this,{cc:l,sn:d}=t.frag,u=(r=(s=t.part)==null?void 0:s.index)!=null?r:-1;n&&a&&(d!==o+1||d===o&&u!==this.lastPartIndex+1||l!==this.lastCc)&&(n.reset(),a.reset()),this.lastCc=l,this.lastSn=d,this.lastPartIndex=u}}onFragLoaded(e,t){let{frag:r,payload:s}=t;if(r.type===J.SUBTITLE)if(s.byteLength){let n=r.decryptdata,a="stats"in t;if(n==null||!n.encrypted||a){let o=this.tracks[r.level],l=this.vttCCs;l[r.cc]||(l[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),o&&o.textCodec===Ip?this._parseIMSC1(r,s):this._parseVTTs(t)}}else this.hls.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){let r=this.hls;IT(t,this.initPTS[e.cc],s=>{this._appendCues(s,e.level),r.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},s=>{I.log(`Failed to parse IMSC1: ${s}`),r.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:s})})}_parseVTTs(e){var t;let{frag:r,payload:s}=e,{initPTS:n,unparsedVttFrags:a}=this,o=n.length-1;if(!n[r.cc]&&o===-1){a.push(e);return}let l=this.hls,d=(t=r.initSegment)!=null&&t.data?Jt(r.initSegment.data,new Uint8Array(s)):s;Tw(d,this.initPTS[r.cc],this.vttCCs,r.cc,r.start,u=>{this._appendCues(u,r.level),l.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:r})},u=>{let c=u.message==="Missing initPTS for VTT MPEGTS";c?a.push(e):this._fallbackToIMSC1(r,s),I.log(`Failed to parse VTT cue: ${u}`),!(c&&o>r.cc)&&l.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:u})})}_fallbackToIMSC1(e,t){let r=this.tracks[e.level];r.textCodec||IT(t,this.initPTS[e.cc],()=>{r.textCodec=Ip,this._parseIMSC1(e,t)},()=>{r.textCodec="wvtt"})}_appendCues(e,t){let r=this.hls;if(this.config.renderTextTracksNatively){let s=this.textTracks[t];if(!s||s.mode==="disabled")return;e.forEach(n=>e_(s,n))}else{let s=this.tracks[t];if(!s)return;let n=s.default?"default":"subtitles"+t;r.trigger(v.CUES_PARSED,{type:"subtitles",cues:e,track:n})}}onFragDecrypted(e,t){let{frag:r}=t;r.type===J.SUBTITLE&&this.onFragLoaded(v.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){this.initCea608Parsers();let{cea608Parser1:r,cea608Parser2:s}=this;if(!this.enabled||!r||!s)return;let{frag:n,samples:a}=t;if(!(n.type===J.MAIN&&this.closedCaptionsForLevel(n)==="NONE"))for(let o=0;o<a.length;o++){let l=a[o].bytes;if(l){let d=this.extractCea608Data(l);r.addData(a[o].pts,d[0]),s.addData(a[o].pts,d[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:r,endOffsetSubtitles:s,type:n}){let{media:a}=this;if(!(!a||a.currentTime<r)){if(!n||n==="video"){let{captionsTracks:o}=this;Object.keys(o).forEach(l=>Bp(o[l],t,r))}if(this.config.renderTextTracksNatively&&t===0&&s!==void 0){let{textTracks:o}=this;Object.keys(o).forEach(l=>Bp(o[l],t,s))}}}extractCea608Data(e){let t=[[],[]],r=e[0]&31,s=2;for(let n=0;n<r;n++){let a=e[s++],o=127&e[s++],l=127&e[s++];if(o===0&&l===0)continue;if((4&a)!==0){let u=3&a;(u===0||u===1)&&(t[u].push(o),t[u].push(l))}}return t}};function C_(i){return i.characteristics&&/transcribes-spoken-dialog/gi.test(i.characteristics)&&/describes-music-and-sound/gi.test(i.characteristics)?"captions":"subtitles"}function CT(i,e){return!!i&&i.kind===C_(e)&&fg(e,i)}function kw(i,e,t,r){return Math.min(e,r)-Math.max(i,t)}function DT(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}var Rg=class i{constructor(e){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(e){this.streamController=e}destroy(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){let{hls:e}=this;e.on(v.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(v.BUFFER_CODECS,this.onBufferCodecs,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){let{hls:e}=this;e.off(v.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(v.BUFFER_CODECS,this.onBufferCodecs,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){let r=this.hls.levels[t.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}onManifestParsed(e,t){let r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onLevelsUpdated(e,t){this.timer&&q(this.autoLevelCapping)&&this.detectPlayerSize()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}let e=this.hls.levels;if(e.length){let t=this.hls,r=this.getMaxLevel(e.length-1);r!==this.autoLevelCapping&&I.log(`Setting autoLevelCapping to ${r}: ${e[r].height}p@${e[r].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=r,t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}getMaxLevel(e){let t=this.hls.levels;if(!t.length)return-1;let r=t.filter((s,n)=>this.isLevelAllowed(s)&&n<=e);return this.clientRect=null,i.getMaxLevelByMediaSize(r,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;let e=this.media,t={width:0,height:0};if(e){let r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,!t.width&&!t.height&&(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch{}return e}isLevelAllowed(e){return!this.restrictedLevels.some(r=>e.bitrate===r.bitrate&&e.width===r.width&&e.height===r.height)}static getMaxLevelByMediaSize(e,t,r){if(!(e!=null&&e.length))return-1;let s=(o,l)=>l?o.width!==l.width||o.height!==l.height:!0,n=e.length-1,a=Math.max(t,r);for(let o=0;o<e.length;o+=1){let l=e[o];if((l.width>=a||l.height>=a)&&s(l,e[o+1])){n=o;break}}return n}},wg=class{constructor(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}setStreamController(e){this.streamController=e}registerListeners(){this.hls.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){let r=this.hls.config;if(r.capLevelOnFPSDrop){let s=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=s,s&&typeof s.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}}checkFPS(e,t,r){let s=performance.now();if(t){if(this.lastTime){let n=s-this.lastTime,a=r-this.lastDroppedFrames,o=t-this.lastDecodedFrames,l=1e3*a/n,d=this.hls;if(d.trigger(v.FPS_DROP,{currentDropped:a,currentDecoded:o,totalDroppedFrames:r}),l>0&&a>d.config.fpsDroppedMonitoringThreshold*o){let u=d.currentLevel;I.warn("drop FPS ratio greater than max allowed value for currentLevel: "+u),u>0&&(d.autoLevelCapping===-1||d.autoLevelCapping>=u)&&(u=u-1,d.trigger(v.FPS_DROP_LEVEL_CAPPING,{level:u,droppedLevel:d.currentLevel}),d.autoLevelCapping=u,this.streamController.nextLevelSwitch())}}this.lastTime=s,this.lastDroppedFrames=r,this.lastDecodedFrames=t}}checkFPSInterval(){let e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){let t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}},Pu="[eme]",hc=class i{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=i.CDMCleanupPromise?[i.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=I.debug.bind(I,Pu),this.log=I.log.bind(I,Pu),this.warn=I.warn.bind(I,Pu),this.error=I.error.bind(I,Pu),this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.unregisterListeners(),this.onMediaDetached();let e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null}registerListeners(){this.hls.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(v.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(v.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(v.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(v.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(v.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(v.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(e){let{drmSystems:t,widevineLicenseUrl:r}=this.config,s=t[e];if(s)return s.licenseUrl;if(e===Fe.WIDEVINE&&r)return r;throw new Error(`no license server URL configured for key-system "${e}"`)}getServerCertificateUrl(e){let{drmSystems:t}=this.config,r=t[e];if(r)return r.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){let t=this.hls.levels,r=(a,o,l)=>!!a&&l.indexOf(a)===o,s=t.map(a=>a.audioCodec).filter(r),n=t.map(a=>a.videoCodec).filter(r);return s.length+n.length===0&&n.push("avc1.42e01e"),new Promise((a,o)=>{let l=d=>{let u=d.shift();this.getMediaKeysPromise(u,s,n).then(c=>a({keySystem:u,mediaKeys:c})).catch(c=>{d.length?l(d):c instanceof Pt?o(c):o(new Pt({type:ie.KEY_SYSTEM_ERROR,details:C.KEY_SYSTEM_NO_ACCESS,error:c,fatal:!0},c.message))})};l(e)})}requestMediaKeySystemAccess(e,t){let{requestMediaKeySystemAccessFunc:r}=this.config;if(typeof r!="function"){let s=`Configured requestMediaKeySystemAccess is not a function ${r}`;return $T===null&&self.location.protocol==="http:"&&(s=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(s))}return r(e,t)}getMediaKeysPromise(e,t,r){let s=vI(e,t,r,this.config.drmSystemOptions),n=this.keySystemAccessPromises[e],a=n==null?void 0:n.keySystemAccess;if(!a){this.log(`Requesting encrypted media "${e}" key-system access with config: ${JSON.stringify(s)}`),a=this.requestMediaKeySystemAccess(e,s);let o=this.keySystemAccessPromises[e]={keySystemAccess:a};return a.catch(l=>{this.log(`Failed to obtain access to key-system "${e}": ${l}`)}),a.then(l=>{this.log(`Access for key-system "${l.keySystem}" obtained`);let d=this.fetchServerCertificate(e);return this.log(`Create media-keys for "${e}"`),o.mediaKeys=l.createMediaKeys().then(u=>(this.log(`Media-keys created for "${e}"`),d.then(c=>c?this.setMediaKeysServerCertificate(u,e,c):u))),o.mediaKeys.catch(u=>{this.error(`Failed to create media-keys for "${e}"}: ${u}`)}),o.mediaKeys})}return a.then(()=>n.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:r}){this.log(`Creating key-system session "${t}" keyId: ${zi.hexDump(e.keyId||[])}`);let s=r.createSession(),n={decryptdata:e,keySystem:t,mediaKeys:r,mediaKeysSession:s,keyStatus:"status-pending"};return this.mediaKeySessions.push(n),n}renewKeySession(e){let t=e.decryptdata;if(t.pssh){let r=this.createMediaKeySessionContext(e),s=this.getKeyIdString(t),n="cenc";this.keyIdToKeySessionPromise[s]=this.generateRequestWithPreferredKeySession(r,n,t.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}getKeyIdString(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(e.keyId===null)throw new Error("keyId is null");return zi.hexDump(e.keyId)}updateKeySession(e,t){var r;let s=e.mediaKeysSession;return this.log(`Updating key-session "${s.sessionId}" for keyID ${zi.hexDump(((r=e.decryptdata)==null?void 0:r.keyId)||[])}
1603
+ } (data length: ${t&&t.byteLength})`),s.update(t)}selectKeySystemFormat(e){let t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){return new Promise((t,r)=>{let s=mp(this.config),n=e.map(qy).filter(a=>!!a&&s.indexOf(a)!==-1);return this.getKeySystemSelectionPromise(n).then(({keySystem:a})=>{let o=Yy(a);o?t(o):r(new Error(`Unable to find format for key-system "${a}"`))}).catch(r)})}loadKey(e){let t=e.keyInfo.decryptdata,r=this.getKeyIdString(t),s=`(keyId: ${r} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${s}`);let n=this.keyIdToKeySessionPromise[r];return n||(n=this.keyIdToKeySessionPromise[r]=this.getKeySystemForKeyPromise(t).then(({keySystem:a,mediaKeys:o})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${s}`),this.attemptSetMediaKeys(a,o).then(()=>{this.throwIfDestroyed();let l=this.createMediaKeySessionContext({keySystem:a,mediaKeys:o,decryptdata:t}),d="cenc";return this.generateRequestWithPreferredKeySession(l,d,t.pssh,"playlist-key")}))),n.catch(a=>this.handleError(a))),n}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e){this.hls&&(this.error(e.message),e instanceof Pt?this.hls.trigger(v.ERROR,e.data):this.hls.trigger(v.ERROR,{type:ie.KEY_SYSTEM_ERROR,details:C.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}getKeySystemForKeyPromise(e){let t=this.getKeyIdString(e),r=this.keyIdToKeySessionPromise[t];if(!r){let s=qy(e.keyFormat),n=s?[s]:mp(this.config);return this.attemptKeySystemAccess(n)}return r}getKeySystemSelectionPromise(e){if(e.length||(e=mp(this.config)),e.length===0)throw new Pt({type:ie.KEY_SYSTEM_ERROR,details:C.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}_onMediaEncrypted(e){let{initDataType:t,initData:r}=e;if(this.debug(`"${e.type}" event: init data type: "${t}"`),r===null)return;let s,n;if(t==="sinf"&&this.config.drmSystems[Fe.FAIRPLAY]){let u=it(new Uint8Array(r));try{let c=Wg(JSON.parse(u).sinf),h=zT(new Uint8Array(c));if(!h)return;s=h.subarray(8,24),n=Fe.FAIRPLAY}catch{this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{let u=GI(r);if(u===null)return;u.version===0&&u.systemId===BT.WIDEVINE&&u.data&&(s=u.data.subarray(8,24)),n=gI(u.systemId)}if(!n||!s)return;let a=zi.hexDump(s),{keyIdToKeySessionPromise:o,mediaKeySessions:l}=this,d=o[a];for(let u=0;u<l.length;u++){let c=l[u],h=c.decryptdata;if(h.pssh||!h.keyId)continue;let f=zi.hexDump(h.keyId);if(a===f||h.uri.replace(/-/g,"").indexOf(a)!==-1){d=o[f],delete o[f],h.pssh=new Uint8Array(r),h.keyId=s,d=o[a]=d.then(()=>this.generateRequestWithPreferredKeySession(c,t,r,"encrypted-event-key-match"));break}}d||(d=o[a]=this.getKeySystemSelectionPromise([n]).then(({keySystem:u,mediaKeys:c})=>{var h;this.throwIfDestroyed();let f=new lo("ISO-23001-7",a,(h=Yy(u))!=null?h:"");return f.pssh=new Uint8Array(r),f.keyId=s,this.attemptSetMediaKeys(u,c).then(()=>{this.throwIfDestroyed();let m=this.createMediaKeySessionContext({decryptdata:f,keySystem:u,mediaKeys:c});return this.generateRequestWithPreferredKeySession(m,t,r,"encrypted-event-no-match")})})),d.catch(u=>this.handleError(u))}_onWaitingForKey(e){this.log(`"${e.type}" event`)}attemptSetMediaKeys(e,t){let r=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);let s=Promise.all(r).then(()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(t)});return this.setMediaKeysQueue.push(s),s.then(()=>{this.log(`Media-keys set for "${e}"`),r.push(s),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(n=>r.indexOf(n)===-1)})}generateRequestWithPreferredKeySession(e,t,r,s){var n,a;let o=(n=this.config.drmSystems)==null||(a=n[e.keySystem])==null?void 0:a.generateRequest;if(o)try{let m=o.call(this.hls,t,r,e);if(!m)throw new Error("Invalid response from configured generateRequest filter");t=m.initDataType,r=e.decryptdata.pssh=m.initData?new Uint8Array(m.initData):null}catch(m){var l;if(this.warn(m.message),(l=this.hls)!=null&&l.config.debug)throw m}if(r===null)return this.log(`Skipping key-session request for "${s}" (no initData)`),Promise.resolve(e);let d=this.getKeyIdString(e.decryptdata);this.log(`Generating key-session request for "${s}": ${d} (init data type: ${t} length: ${r?r.byteLength:null})`);let u=new Xg,c=e._onmessage=m=>{let p=e.mediaKeysSession;if(!p){u.emit("error",new Error("invalid state"));return}let{messageType:g,message:E}=m;this.log(`"${g}" message event for session "${p.sessionId}" message size: ${E.byteLength}`),g==="license-request"||g==="license-renewal"?this.renewLicense(e,E).catch(T=>{this.handleError(T),u.emit("error",T)}):g==="license-release"?e.keySystem===Fe.FAIRPLAY&&(this.updateKeySession(e,Np("acknowledged")),this.removeSession(e)):this.warn(`unhandled media key message type "${g}"`)},h=e._onkeystatuseschange=m=>{if(!e.mediaKeysSession){u.emit("error",new Error("invalid state"));return}this.onKeyStatusChange(e);let g=e.keyStatus;u.emit("keyStatus",g),g==="expired"&&(this.warn(`${e.keySystem} expired for key ${d}`),this.renewKeySession(e))};e.mediaKeysSession.addEventListener("message",c),e.mediaKeysSession.addEventListener("keystatuseschange",h);let f=new Promise((m,p)=>{u.on("error",p),u.on("keyStatus",g=>{g.startsWith("usable")?m():g==="output-restricted"?p(new Pt({type:ie.KEY_SYSTEM_ERROR,details:C.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):g==="internal-error"?p(new Pt({type:ie.KEY_SYSTEM_ERROR,details:C.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${g}"`)):g==="expired"?p(new Error("key expired while generating request")):this.warn(`unhandled key status change "${g}"`)})});return e.mediaKeysSession.generateRequest(t,r).then(()=>{var m;this.log(`Request generated for key-session "${(m=e.mediaKeysSession)==null?void 0:m.sessionId}" keyId: ${d}`)}).catch(m=>{throw new Pt({type:ie.KEY_SYSTEM_ERROR,details:C.KEY_SYSTEM_NO_SESSION,error:m,fatal:!1},`Error generating key-session request: ${m}`)}).then(()=>f).catch(m=>{throw u.removeAllListeners(),this.removeSession(e),m}).then(()=>(u.removeAllListeners(),e))}onKeyStatusChange(e){e.mediaKeysSession.keyStatuses.forEach((t,r)=>{this.log(`key status change "${t}" for keyStatuses keyId: ${zi.hexDump("buffer"in r?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r))} session keyId: ${zi.hexDump(new Uint8Array(e.decryptdata.keyId||[]))} uri: ${e.decryptdata.uri}`),e.keyStatus=t})}fetchServerCertificate(e){let t=this.config,r=t.loader,s=new r(t),n=this.getServerCertificateUrl(e);return n?(this.log(`Fetching server certificate for "${e}"`),new Promise((a,o)=>{let l={responseType:"arraybuffer",url:n},d=t.certLoadPolicy.default,u={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(h,f,m,p)=>{a(h.data)},onError:(h,f,m,p)=>{o(new Pt({type:ie.KEY_SYSTEM_ERROR,details:C.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:m,response:mt({url:l.url,data:void 0},h)},`"${e}" certificate request failed (${n}). Status: ${h.code} (${h.text})`))},onTimeout:(h,f,m)=>{o(new Pt({type:ie.KEY_SYSTEM_ERROR,details:C.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:m,response:{url:l.url,data:void 0}},`"${e}" certificate request timed out (${n})`))},onAbort:(h,f,m)=>{o(new Error("aborted"))}};s.load(l,u,c)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,r){return new Promise((s,n)=>{e.setServerCertificate(r).then(a=>{this.log(`setServerCertificate ${a?"success":"not supported by CDM"} (${r==null?void 0:r.byteLength}) on "${t}"`),s(e)}).catch(a=>{n(new Pt({type:ie.KEY_SYSTEM_ERROR,details:C.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:a,fatal:!0},a.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(r=>this.updateKeySession(e,new Uint8Array(r)).catch(s=>{throw new Pt({type:ie.KEY_SYSTEM_ERROR,details:C.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:s,fatal:!0},s.message)}))}unpackPlayReadyKeyMessage(e,t){let r=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!r.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;let s=new DOMParser().parseFromString(r,"application/xml"),n=s.querySelectorAll("HttpHeader");if(n.length>0){let u;for(let c=0,h=n.length;c<h;c++){var a,o;u=n[c];let f=(a=u.querySelector("name"))==null?void 0:a.textContent,m=(o=u.querySelector("value"))==null?void 0:o.textContent;f&&m&&e.setRequestHeader(f,m)}}let l=s.querySelector("Challenge"),d=l==null?void 0:l.textContent;if(!d)throw new Error("Cannot find <Challenge> in key message");return Np(atob(d))}setupLicenseXHR(e,t,r,s){let n=this.config.licenseXhrSetup;return n?Promise.resolve().then(()=>{if(!r.decryptdata)throw new Error("Key removed");return n.call(this.hls,e,t,r,s)}).catch(a=>{if(!r.decryptdata)throw a;return e.open("POST",t,!0),n.call(this.hls,e,t,r,s)}).then(a=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:a||s})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:s}))}requestLicense(e,t){let r=this.config.keyLoadPolicy.default;return new Promise((s,n)=>{let a=this.getLicenseServerUrl(e.keySystem);this.log(`Sending license request to URL: ${a}`);let o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return n(new Error("invalid state"));if(o.readyState===4)if(o.status===200){this._requestLicenseFailureCount=0;let l=o.response;this.log(`License received ${l instanceof ArrayBuffer?l.byteLength:l}`);let d=this.config.licenseResponseCallback;if(d)try{l=d.call(this.hls,o,a,e)}catch(u){this.error(u)}s(l)}else{let l=r.errorRetry,d=l?l.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>d||o.status>=400&&o.status<500)n(new Pt({type:ie.KEY_SYSTEM_ERROR,details:C.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o,response:{url:a,data:void 0,code:o.status,text:o.statusText}},`License Request XHR failed (${a}). Status: ${o.status} (${o.statusText})`));else{let u=d-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${u} attempts left`),this.requestLicense(e,t).then(s,n)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,this.setupLicenseXHR(o,a,e,t).then(({xhr:l,licenseChallenge:d})=>{e.keySystem==Fe.PLAYREADY&&(d=this.unpackPlayReadyKeyMessage(l,d)),l.send(d)})})}onMediaAttached(e,t){if(!this.config.emeEnabled)return;let r=t.media;this.media=r,r.addEventListener("encrypted",this.onMediaEncrypted),r.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){let e=this.media,t=this.mediaKeySessions;e&&(e.removeEventListener("encrypted",this.onMediaEncrypted),e.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},lo.clearKeyUriToKeyIdMap();let r=t.length;i.CDMCleanupPromise=Promise.all(t.map(s=>this.removeSession(s)).concat(e==null?void 0:e.setMediaKeys(null).catch(s=>{this.log(`Could not clear media keys: ${s}`)}))).then(()=>{r&&(this.log("finished closing key sessions and clearing media keys"),t.length=0)}).catch(s=>{this.log(`Could not close sessions and clear media keys: ${s}`)})}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(e,{sessionKeys:t}){if(!(!t||!this.config.emeEnabled)&&!this.keyFormatPromise){let r=t.reduce((s,n)=>(s.indexOf(n.keyFormat)===-1&&s.push(n.keyFormat),s),[]);this.log(`Selecting key-system from session-keys ${r.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(r)}}removeSession(e){let{mediaKeysSession:t,licenseXhr:r}=e;if(t){this.log(`Remove licenses and keys and close session ${t.sessionId}`),e._onmessage&&(t.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(t.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),r&&r.readyState!==XMLHttpRequest.DONE&&r.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;let s=this.mediaKeySessions.indexOf(e);return s>-1&&this.mediaKeySessions.splice(s,1),t.remove().catch(n=>{this.log(`Could not remove session: ${n}`)}).then(()=>t.close()).catch(n=>{this.log(`Could not close session: ${n}`)})}}};hc.CDMCleanupPromise=void 0;var Pt=class extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=new Error(t)),this.data=e,e.err=e.error}},xt;(function(i){i.MANIFEST="m",i.AUDIO="a",i.VIDEO="v",i.MUXED="av",i.INIT="i",i.CAPTION="c",i.TIMED_TEXT="tt",i.KEY="k",i.OTHER="o"})(xt||(xt={}));var Cg;(function(i){i.DASH="d",i.HLS="h",i.SMOOTH="s",i.OTHER="o"})(Cg||(Cg={}));var Ls;(function(i){i.OBJECT="CMCD-Object",i.REQUEST="CMCD-Request",i.SESSION="CMCD-Session",i.STATUS="CMCD-Status"})(Ls||(Ls={}));var Iw={[Ls.OBJECT]:["br","d","ot","tb"],[Ls.REQUEST]:["bl","dl","mtp","nor","nrr","su"],[Ls.SESSION]:["cid","pr","sf","sid","st","v"],[Ls.STATUS]:["bs","rtp"]},go=class i{constructor(e,t){this.value=void 0,this.params=void 0,Array.isArray(e)&&(e=e.map(r=>r instanceof i?r:new i(r))),this.value=e,this.params=t}},fc=class{constructor(e){this.description=void 0,this.description=e}},Rw="Dict";function ww(i){return Array.isArray(i)?JSON.stringify(i):i instanceof Map?"Map{}":i instanceof Set?"Set{}":typeof i=="object"?JSON.stringify(i):String(i)}function Cw(i,e,t,r){return new Error(`failed to ${i} "${ww(e)}" as ${t}`,{cause:r})}var MT="Bare Item",Dw="Boolean",Mw="Byte Sequence",Pw="Decimal",Ow="Integer";function Nw(i){return i<-999999999999999||999999999999999<i}var Uw=/[\x00-\x1f\x7f]+/,Fw="Token",Bw="Key";function Zi(i,e,t){return Cw("serialize",i,e,t)}function $w(i){if(typeof i!="boolean")throw Zi(i,Dw);return i?"?1":"?0"}function Hw(i){return btoa(String.fromCharCode(...i))}function Gw(i){if(ArrayBuffer.isView(i)===!1)throw Zi(i,Mw);return`:${Hw(i)}:`}function D_(i){if(Nw(i))throw Zi(i,Ow);return i.toString()}function Ww(i){return`@${D_(i.getTime()/1e3)}`}function M_(i,e){if(i<0)return-M_(-i,e);let t=Math.pow(10,e);if(Math.abs(i*t%1-.5)<Number.EPSILON){let s=Math.floor(i*t);return(s%2===0?s:s+1)/t}else return Math.round(i*t)/t}function Kw(i){let e=M_(i,3);if(Math.floor(Math.abs(e)).toString().length>12)throw Zi(i,Pw);let t=e.toString();return t.includes(".")?t:`${t}.0`}var Vw="String";function qw(i){if(Uw.test(i))throw Zi(i,Vw);return`"${i.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function Yw(i){return i.description||i.toString().slice(7,-1)}function PT(i){let e=Yw(i);if(/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(e)===!1)throw Zi(e,Fw);return e}function Dg(i){switch(typeof i){case"number":if(!q(i))throw Zi(i,MT);return Number.isInteger(i)?D_(i):Kw(i);case"string":return qw(i);case"symbol":return PT(i);case"boolean":return $w(i);case"object":if(i instanceof Date)return Ww(i);if(i instanceof Uint8Array)return Gw(i);if(i instanceof fc)return PT(i);default:throw Zi(i,MT)}}function Mg(i){if(/^[a-z*][a-z0-9\-_.*]*$/.test(i)===!1)throw Zi(i,Bw);return i}function Jg(i){return i==null?"":Object.entries(i).map(([e,t])=>t===!0?`;${Mg(e)}`:`;${Mg(e)}=${Dg(t)}`).join("")}function P_(i){return i instanceof go?`${Dg(i.value)}${Jg(i.params)}`:Dg(i)}function zw(i){return`(${i.value.map(P_).join(" ")})${Jg(i.params)}`}function jw(i,e={whitespace:!0}){if(typeof i!="object")throw Zi(i,Rw);let t=i instanceof Map?i.entries():Object.entries(i),r=e!=null&&e.whitespace?" ":"";return Array.from(t).map(([s,n])=>{n instanceof go||(n=new go(n));let a=Mg(s);return n.value===!0?a+=Jg(n.params):(a+="=",Array.isArray(n.value)?a+=zw(n):a+=P_(n)),a}).join(`,${r}`)}function Xw(i,e){return jw(i,e)}var Qw=i=>i==="ot"||i==="sf"||i==="st",Zw=i=>typeof i=="number"?q(i):i!=null&&i!==""&&i!==!1;function Jw(i,e){let t=new URL(i),r=new URL(e);if(t.origin!==r.origin)return i;let s=t.pathname.split("/").slice(1),n=r.pathname.split("/").slice(1,-1);for(;s[0]===n[0];)s.shift(),n.shift();for(;n.length;)n.shift(),s.unshift("..");return s.join("/")}function eC(){try{return crypto.randomUUID()}catch{try{let e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch{let t=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,s=>{let n=(t+Math.random()*16)%16|0;return t=Math.floor(t/16),(s=="x"?n:n&3|8).toString(16)})}}}var Hu=i=>Math.round(i),tC=(i,e)=>(e!=null&&e.baseUrl&&(i=Jw(i,e.baseUrl)),encodeURIComponent(i)),Ou=i=>Hu(i/100)*100,iC={br:Hu,d:Hu,bl:Ou,dl:Ou,mtp:Ou,nor:tC,rtp:Ou,tb:Hu};function rC(i,e){let t={};if(i==null||typeof i!="object")return t;let r=Object.keys(i).sort(),s=Je({},iC,e==null?void 0:e.formatters),n=e==null?void 0:e.filter;return r.forEach(a=>{if(n!=null&&n(a))return;let o=i[a],l=s[a];l&&(o=l(o,e)),!(a==="v"&&o===1)&&(a=="pr"&&o===1||Zw(o)&&(Qw(a)&&typeof o=="string"&&(o=new fc(o)),t[a]=o))}),t}function O_(i,e={}){return i?Xw(rC(i,e),Je({whitespace:!1},e)):""}function sC(i,e={}){if(!i)return{};let t=Object.entries(i),r=Object.entries(Iw).concat(Object.entries((e==null?void 0:e.customHeaderMap)||{})),s=t.reduce((n,a)=>{var o,l;let[d,u]=a,c=((o=r.find(h=>h[1].includes(d)))==null?void 0:o[0])||Ls.REQUEST;return(l=n[c])!=null||(n[c]={}),n[c][d]=u,n},{});return Object.entries(s).reduce((n,[a,o])=>(n[a]=O_(o,e),n),{})}function nC(i,e,t){return Je(i,sC(e,t))}var aC="CMCD";function oC(i,e={}){if(!i)return"";let t=O_(i,e);return`${aC}=${encodeURIComponent(t)}`}var OT=/CMCD=[^&#]+/;function lC(i,e,t){let r=oC(e,t);if(!r)return i;if(OT.test(i))return i.replace(OT,r);let s=i.includes("?")?"&":"?";return`${i}${s}${r}`}var Pg=class{constructor(e){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.includeKeys=void 0,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=s=>{try{this.apply(s,{ot:xt.MANIFEST,su:!this.initialized})}catch(n){I.warn("Could not generate manifest CMCD data.",n)}},this.applyFragmentData=s=>{try{let n=s.frag,a=this.hls.levels[n.level],o=this.getObjectType(n),l={d:n.duration*1e3,ot:o};(o===xt.VIDEO||o===xt.AUDIO||o==xt.MUXED)&&(l.br=a.bitrate/1e3,l.tb=this.getTopBandwidth(o)/1e3,l.bl=this.getBufferLength(o)),this.apply(s,l)}catch(n){I.warn("Could not generate segment CMCD data.",n)}},this.hls=e;let t=this.config=e.config,{cmcd:r}=t;r!=null&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=r.sessionId||eC(),this.cid=r.contentId,this.useHeaders=r.useHeaders===!0,this.includeKeys=r.includeKeys,this.registerListeners())}registerListeners(){let e=this.hls;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHED,this.onMediaDetached,this),e.on(v.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){let e=this.hls;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHED,this.onMediaDetached,this),e.off(v.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=null}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(e,t){var r,s;this.audioBuffer=(r=t.tracks.audio)==null?void 0:r.buffer,this.videoBuffer=(s=t.tracks.video)==null?void 0:s.buffer}createData(){var e;return{v:1,sf:Cg.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){Je(t,this.createData());let r=t.ot===xt.INIT||t.ot===xt.VIDEO||t.ot===xt.MUXED;this.starved&&r&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering);let{includeKeys:s}=this;s&&(t=Object.keys(t).reduce((n,a)=>(s.includes(a)&&(n[a]=t[a]),n),{})),this.useHeaders?(e.headers||(e.headers={}),nC(e.headers,t)):e.url=lC(e.url,t)}getObjectType(e){let{type:t}=e;if(t==="subtitle")return xt.TIMED_TEXT;if(e.sn==="initSegment")return xt.INIT;if(t==="audio")return xt.AUDIO;if(t==="main")return this.hls.audioTracks.length?xt.VIDEO:xt.MUXED}getTopBandwidth(e){let t=0,r,s=this.hls;if(e===xt.AUDIO)r=s.audioTracks;else{let n=s.maxAutoLevel,a=n>-1?n+1:s.levels.length;r=s.levels.slice(0,a)}for(let n of r)n.bitrate>t&&(t=n.bitrate);return t>0?t:NaN}getBufferLength(e){let t=this.hls.media,r=e===xt.AUDIO?this.audioBuffer:this.videoBuffer;return!r||!t?NaN:Ue.bufferInfo(r,t.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){let{pLoader:e}=this.config,t=this.applyPlaylistData,r=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new r(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,a,o){t(n),this.loader.load(n,a,o)}}}createFragmentLoader(){let{fLoader:e}=this.config,t=this.applyFragmentData,r=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new r(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,a,o){t(n),this.loader.load(n,a,o)}}}},dC=3e5,Og=class{constructor(e){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.log=I.log.bind(I,"[content-steering]:"),this.registerListeners()}registerListeners(){let e=this.hls;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.ERROR,this.onError,this)}unregisterListeners(){let e=this.hls;e&&(e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.ERROR,this.onError,this))}startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){let e=this.timeToLoad*1e3-(performance.now()-this.updated);if(e>0){this.scheduleRefresh(this.uri,e);return}}this.loadSteeringManifest(this.uri)}}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}clearTimeout(){this.reloadTimer!==-1&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){let t=this.levels;t&&(this.levels=t.filter(r=>r!==e))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){let{contentSteering:r}=t;r!==null&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){let{errorAction:r}=t;if((r==null?void 0:r.action)===ht.SendAlternateToPenaltyBox&&r.flags===Ei.MoveAllAlternatesMatchingHost){let s=this.levels,n=this.pathwayPriority,a=this.pathwayId;if(t.context){let{groupId:o,pathwayId:l,type:d}=t.context;o&&s?a=this.getPathwayForGroupId(o,d,a):l&&(a=l)}a in this.penalizedPathways||(this.penalizedPathways[a]=performance.now()),!n&&s&&(n=s.reduce((o,l)=>(o.indexOf(l.pathwayId)===-1&&o.push(l.pathwayId),o),[])),n&&n.length>1&&(this.updatePathwayPriority(n),r.resolved=this.pathwayId!==a),r.resolved||I.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${a} levels: ${s&&s.length} priorities: ${JSON.stringify(n)} penalized: ${JSON.stringify(this.penalizedPathways)}`)}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){let r=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${r}"`),t=this.getLevelsForPathway(r),this.pathwayId=r}return t.length!==e.length?(this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t):e}getLevelsForPathway(e){return this.levels===null?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){this.pathwayPriority=e;let t,r=this.penalizedPathways,s=performance.now();Object.keys(r).forEach(n=>{s-r[n]>dC&&delete r[n]});for(let n=0;n<e.length;n++){let a=e[n];if(a in r)continue;if(a===this.pathwayId)return;let o=this.hls.nextLoadLevel,l=this.hls.levels[o];if(t=this.getLevelsForPathway(a),t.length>0){this.log(`Setting Pathway to "${a}"`),this.pathwayId=a,s_(t),this.hls.trigger(v.LEVELS_UPDATED,{levels:t});let d=this.hls.levels[o];l&&d&&this.levels&&(d.attrs["STABLE-VARIANT-ID"]!==l.attrs["STABLE-VARIANT-ID"]&&d.bitrate!==l.bitrate&&this.log(`Unstable Pathways change from bitrate ${l.bitrate} to ${d.bitrate}`),this.hls.nextLoadLevel=o);break}}}getPathwayForGroupId(e,t,r){let s=this.getLevelsForPathway(r).concat(this.levels||[]);for(let n=0;n<s.length;n++)if(t===ge.AUDIO_TRACK&&s[n].hasAudioGroup(e)||t===ge.SUBTITLE_TRACK&&s[n].hasSubtitleGroup(e))return s[n].pathwayId;return r}clonePathways(e){let t=this.levels;if(!t)return;let r={},s={};e.forEach(n=>{let{ID:a,"BASE-ID":o,"URI-REPLACEMENT":l}=n;if(t.some(u=>u.pathwayId===a))return;let d=this.getLevelsForPathway(o).map(u=>{let c=new Ke(u.attrs);c["PATHWAY-ID"]=a;let h=c.AUDIO&&`${c.AUDIO}_clone_${a}`,f=c.SUBTITLES&&`${c.SUBTITLES}_clone_${a}`;h&&(r[c.AUDIO]=h,c.AUDIO=h),f&&(s[c.SUBTITLES]=f,c.SUBTITLES=f);let m=N_(u.uri,c["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l),p=new Mr({attrs:c,audioCodec:u.audioCodec,bitrate:u.bitrate,height:u.height,name:u.name,url:m,videoCodec:u.videoCodec,width:u.width});if(u.audioGroups)for(let g=1;g<u.audioGroups.length;g++)p.addGroupId("audio",`${u.audioGroups[g]}_clone_${a}`);if(u.subtitleGroups)for(let g=1;g<u.subtitleGroups.length;g++)p.addGroupId("text",`${u.subtitleGroups[g]}_clone_${a}`);return p});t.push(...d),NT(this.audioTracks,r,l,a),NT(this.subtitleTracks,s,l,a)})}loadSteeringManifest(e){let t=this.hls.config,r=t.loader;this.loader&&this.loader.destroy(),this.loader=new r(t);let s;try{s=new self.URL(e)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if(s.protocol!=="data:"){let u=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;s.searchParams.set("_HLS_pathway",this.pathwayId),s.searchParams.set("_HLS_throughput",""+u)}let n={responseType:"json",url:s.href},a=t.steeringManifestLoadPolicy.default,o=a.errorRetry||a.timeoutRetry||{},l={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},d={onSuccess:(u,c,h,f)=>{this.log(`Loaded steering manifest: "${s}"`);let m=u.data;if(m.VERSION!==1){this.log(`Steering VERSION ${m.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=m.TTL;let{"RELOAD-URI":p,"PATHWAY-CLONES":g,"PATHWAY-PRIORITY":E}=m;if(p)try{this.uri=new self.URL(p,s).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${p}`);return}this.scheduleRefresh(this.uri||h.url),g&&this.clonePathways(g);let T={steeringManifest:m,url:s.toString()};this.hls.trigger(v.STEERING_MANIFEST_LOADED,T),E&&this.updatePathwayPriority(E)},onError:(u,c,h,f)=>{if(this.log(`Error loading steering manifest: ${u.code} ${u.text} (${c.url})`),this.stopLoad(),u.code===410){this.enabled=!1,this.log(`Steering manifest ${c.url} no longer available`);return}let m=this.timeToLoad*1e3;if(u.code===429){let p=this.loader;if(typeof(p==null?void 0:p.getResponseHeader)=="function"){let g=p.getResponseHeader("Retry-After");g&&(m=parseFloat(g)*1e3)}this.log(`Steering manifest ${c.url} rate limited`);return}this.scheduleRefresh(this.uri||c.url,m)},onTimeout:(u,c,h)=>{this.log(`Timeout loading steering manifest (${c.url})`),this.scheduleRefresh(this.uri||c.url)}};this.log(`Requesting steering manifest: ${s}`),this.loader.load(n,l,d)}scheduleRefresh(e,t=this.timeToLoad*1e3){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var r;let s=(r=this.hls)==null?void 0:r.media;if(s&&!s.ended){this.loadSteeringManifest(e);return}this.scheduleRefresh(e,this.timeToLoad*1e3)},t)}};function NT(i,e,t,r){i&&Object.keys(e).forEach(s=>{let n=i.filter(a=>a.groupId===s).map(a=>{let o=Je({},a);return o.details=void 0,o.attrs=new Ke(o.attrs),o.url=o.attrs.URI=N_(a.url,a.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),o.groupId=o.attrs["GROUP-ID"]=e[s],o.attrs["PATHWAY-ID"]=r,o});i.push(...n)})}function N_(i,e,t,r){let{HOST:s,PARAMS:n,[t]:a}=r,o;e&&(o=a==null?void 0:a[e],o&&(i=o));let l=new self.URL(i);return s&&!o&&(l.host=s),n&&Object.keys(n).sort().forEach(d=>{d&&l.searchParams.set(d,n[d])}),l.href}var uC=/^age:\s*[\d.]+\s*$/im,mc=class{constructor(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new Vn,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null}abortInternal(){let e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,e.readyState!==4&&(this.stats.aborted=!0,e.abort()))}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(e,t,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=r,this.loadInternal()}loadInternal(){let{config:e,context:t}=this;if(!e||!t)return;let r=this.loader=new self.XMLHttpRequest,s=this.stats;s.loading.first=0,s.loaded=0,s.aborted=!1;let n=this.xhrSetup;n?Promise.resolve().then(()=>{if(!(this.loader!==r||this.stats.aborted))return n(r,t.url)}).catch(a=>{if(!(this.loader!==r||this.stats.aborted))return r.open("GET",t.url,!0),n(r,t.url)}).then(()=>{this.loader!==r||this.stats.aborted||this.openAndSendXhr(r,t,e)}).catch(a=>{this.callbacks.onError({code:r.status,text:a.message},t,r,s)}):this.openAndSendXhr(r,t,e)}openAndSendXhr(e,t,r){e.readyState||e.open("GET",t.url,!0);let s=t.headers,{maxTimeToFirstByteMs:n,maxLoadTimeMs:a}=r.loadPolicy;if(s)for(let o in s)e.setRequestHeader(o,s[o]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),r.timeout=n&&q(n)?n:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()}readystatechange(){let{context:e,loader:t,stats:r}=this;if(!e||!t)return;let s=t.readyState,n=this.config;if(!r.aborted&&s>=2&&(r.loading.first===0&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),n.timeout!==n.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),n.timeout=n.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),s===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;let a=t.status,o=t.responseType!=="text";if(a>=200&&a<300&&(o&&t.response||t.responseText!==null)){r.loading.end=Math.max(self.performance.now(),r.loading.first);let l=o?t.response:t.responseText,d=t.responseType==="arraybuffer"?l.byteLength:l.length;if(r.loaded=r.total=d,r.bwEstimate=r.total*8e3/(r.loading.end-r.loading.first),!this.callbacks)return;let u=this.callbacks.onProgress;if(u&&u(r,e,l,t),!this.callbacks)return;let c={url:t.responseURL,data:l,code:a};this.callbacks.onSuccess(c,r,e,t)}else{let l=n.loadPolicy.errorRetry,d=r.retry,u={url:e.url,data:void 0,code:a};Zu(l,d,!1,u)?this.retry(l):(I.error(`${a} while loading ${e.url}`),this.callbacks.onError({code:a,text:t.statusText},e,t,r))}}}loadtimeout(){if(!this.config)return;let e=this.config.loadPolicy.timeoutRetry,t=this.stats.retry;if(Zu(e,t,!0))this.retry(e);else{var r;I.warn(`timeout while loading ${(r=this.context)==null?void 0:r.url}`);let s=this.callbacks;s&&(this.abortInternal(),s.onTimeout(this.stats,this.context,this.loader))}}retry(e){let{context:t,stats:r}=this;this.retryDelay=qg(e,r.retry),r.retry++,I.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${t==null?void 0:t.url}, retrying ${r.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(e){let t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&uC.test(this.loader.getAllResponseHeaders())){let t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}};function cC(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var hC=/(\d+)-(\d+)\/(\d+)/,pc=class{constructor(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||gC,this.controller=new self.AbortController,this.stats=new Vn}destroy(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}abortInternal(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,r){let s=this.stats;if(s.loading.start)throw new Error("Loader can only be used once.");s.loading.start=self.performance.now();let n=fC(e,this.controller.signal),a=r.onProgress,o=e.responseType==="arraybuffer",l=o?"byteLength":"length",{maxTimeToFirstByteMs:d,maxLoadTimeMs:u}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,n),self.clearTimeout(this.requestTimeout),t.timeout=d&&q(d)?d:u,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),r.onTimeout(s,e,this.response)},t.timeout),self.fetch(this.request).then(c=>{this.response=this.loader=c;let h=Math.max(self.performance.now(),s.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=u,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),r.onTimeout(s,e,this.response)},u-(h-s.loading.start)),!c.ok){let{status:f,statusText:m}=c;throw new Ng(m||"fetch, bad network response",f,c)}return s.loading.first=h,s.total=pC(c.headers)||s.total,a&&q(t.highWaterMark)?this.loadProgressively(c,s,e,t.highWaterMark,a):o?c.arrayBuffer():e.responseType==="json"?c.json():c.text()}).then(c=>{let h=this.response;if(!h)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),s.loading.end=Math.max(self.performance.now(),s.loading.first);let f=c[l];f&&(s.loaded=s.total=f);let m={url:h.url,data:c,code:h.status};a&&!q(t.highWaterMark)&&a(s,e,c,h),r.onSuccess(m,s,e,h)}).catch(c=>{if(self.clearTimeout(this.requestTimeout),s.aborted)return;let h=c&&c.code||0,f=c?c.message:null;r.onError({code:h,text:f},e,c?c.details:null,s)})}getCacheAge(){let e=null;if(this.response){let t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,r,s=0,n){let a=new tc,o=e.body.getReader(),l=()=>o.read().then(d=>{if(d.done)return a.dataLength&&n(t,r,a.flush(),e),Promise.resolve(new ArrayBuffer(0));let u=d.value,c=u.length;return t.loaded+=c,c<s||a.dataLength?(a.push(u),a.dataLength>=s&&n(t,r,a.flush(),e)):n(t,r,u,e),l()}).catch(()=>Promise.reject());return l()}};function fC(i,e){let t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(Je({},i.headers))};return i.rangeEnd&&t.headers.set("Range","bytes="+i.rangeStart+"-"+String(i.rangeEnd-1)),t}function mC(i){let e=hC.exec(i);if(e)return parseInt(e[2])-parseInt(e[1])+1}function pC(i){let e=i.get("Content-Range");if(e){let r=mC(e);if(q(r))return r}let t=i.get("Content-Length");if(t)return parseInt(t)}function gC(i,e){return new self.Request(i.url,e)}var Ng=class extends Error{constructor(e,t,r){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=r}},vC=/\s/,EC={newCue(i,e,t,r){let s=[],n,a,o,l,d,u=self.VTTCue||self.TextTrackCue;for(let h=0;h<r.rows.length;h++)if(n=r.rows[h],o=!0,l=0,d="",!n.isEmpty()){var c;for(let p=0;p<n.chars.length;p++)vC.test(n.chars[p].uchar)&&o?l++:(d+=n.chars[p].uchar,o=!1);n.cueStartTime=e,e===t&&(t+=1e-4),l>=16?l--:l++;let f=k_(d.trim()),m=Zg(e,t,f);i!=null&&(c=i.cues)!=null&&c.getCueById(m)||(a=new u(e,t,f),a.id=m,a.line=h+1,a.align="left",a.position=10+Math.min(80,Math.floor(l*8/32)*10),s.push(a))}return i&&s.length&&(s.sort((h,f)=>h.line==="auto"||f.line==="auto"?0:h.line>8&&f.line>8?f.line-h.line:h.line-f.line),s.forEach(h=>e_(i,h))),s}},bC={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},U_=mt(mt({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:mc,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:zp,bufferController:yg,capLevelController:Rg,errorController:qp,fpsController:wg,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:$T,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,useMediaCapabilities:!0,certLoadPolicy:{default:bC},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},yC()),{},{subtitleStreamController:gg,subtitleTrackController:Eg,timelineController:Ig,audioStreamController:mg,audioTrackController:pg,emeController:hc,cmcdController:Pg,contentSteeringController:Og});function yC(){return{cueHandler:EC,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function TC(i,e){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(e.liveMaxLatencyDurationCount!==void 0&&(e.liveSyncDurationCount===void 0||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(e.liveMaxLatencyDuration!==void 0&&(e.liveSyncDuration===void 0||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');let t=Ug(i),r=["manifest","level","frag"],s=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return r.forEach(n=>{let a=`${n==="level"?"playlist":n}LoadPolicy`,o=e[a]===void 0,l=[];s.forEach(d=>{let u=`${n}Loading${d}`,c=e[u];if(c!==void 0&&o){l.push(u);let h=t[a].default;switch(e[a]={default:h},d){case"TimeOut":h.maxLoadTimeMs=c,h.maxTimeToFirstByteMs=c;break;case"MaxRetry":h.errorRetry.maxNumRetry=c,h.timeoutRetry.maxNumRetry=c;break;case"RetryDelay":h.errorRetry.retryDelayMs=c,h.timeoutRetry.retryDelayMs=c;break;case"MaxRetryTimeout":h.errorRetry.maxRetryDelayMs=c,h.timeoutRetry.maxRetryDelayMs=c;break}}}),l.length&&I.warn(`hls.js config: "${l.join('", "')}" setting(s) are deprecated, use "${a}": ${JSON.stringify(e[a])}`)}),mt(mt({},t),e)}function Ug(i){return i&&typeof i=="object"?Array.isArray(i)?i.map(Ug):Object.keys(i).reduce((e,t)=>(e[t]=Ug(i[t]),e),{}):i}function _C(i){let e=i.loader;e!==pc&&e!==mc?(I.log("[config]: Custom loader detected, cannot enable progressive streaming"),i.progressive=!1):cC()&&(i.loader=pc,i.progressive=!0,i.enableSoftwareAES=!0,I.log("[config]: Progressive streaming enabled, using FetchLoader"))}var Dp,Fg=class extends co{constructor(e,t){super(e,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._maxAutoLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=t,this._registerListeners()}_registerListeners(){let{hls:e}=this;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this),e.on(v.ERROR,this.onError,this)}_unregisterListeners(){let{hls:e}=this;e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this),e.off(v.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}stopLoad(){this._levels.forEach(t=>{t.loadError=0,t.fragmentError=0}),super.stopLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){let r=this.hls.config.preferManagedMediaSource,s=[],n={},a={},o=!1,l=!1,d=!1;t.levels.forEach(u=>{var c,h;let f=u.attrs,{audioCodec:m,videoCodec:p}=u;((c=m)==null?void 0:c.indexOf("mp4a.40.34"))!==-1&&(Dp||(Dp=/chrome|firefox/i.test(navigator.userAgent)),Dp&&(u.audioCodec=m=void 0)),m&&(u.audioCodec=m=zu(m,r)),((h=p)==null?void 0:h.indexOf("avc1"))===0&&(p=u.videoCodec=jI(p));let{width:g,height:E,unknownCodecs:T}=u;if(o||(o=!!(g&&E)),l||(l=!!p),d||(d=!!m),T!=null&&T.length||m&&!Ep(m,"audio",r)||p&&!Ep(p,"video",r))return;let{CODECS:y,"FRAME-RATE":S,"HDCP-LEVEL":A,"PATHWAY-ID":L,RESOLUTION:x,"VIDEO-RANGE":w}=f,k=`${`${L||"."}-`}${u.bitrate}-${x}-${S}-${y}-${w}-${A}`;if(n[k])if(n[k].uri!==u.url&&!u.attrs["PATHWAY-ID"]){let D=a[k]+=1;u.attrs["PATHWAY-ID"]=new Array(D+1).join(".");let U=new Mr(u);n[k]=U,s.push(U)}else n[k].addGroupId("audio",f.AUDIO),n[k].addGroupId("text",f.SUBTITLES);else{let D=new Mr(u);n[k]=D,a[k]=1,s.push(D)}}),this.filterAndSortMediaOptions(s,t,o,l,d)}filterAndSortMediaOptions(e,t,r,s,n){let a=[],o=[],l=e;if((r||s)&&n&&(l=l.filter(({videoCodec:m,videoRange:p,width:g,height:E})=>(!!m||!!(g&&E))&&nR(p))),l.length===0){Promise.resolve().then(()=>{if(this.hls){t.levels.length&&this.warn(`One or more CODECS in variant not supported: ${JSON.stringify(t.levels[0].attrs)}`);let m=new Error("no level with compatible codecs found in manifest");this.hls.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:C.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:m,reason:m.message})}});return}if(t.audioTracks){let{preferManagedMediaSource:m}=this.hls.config;a=t.audioTracks.filter(p=>!p.audioCodec||Ep(p.audioCodec,"audio",m)),UT(a)}t.subtitles&&(o=t.subtitles,UT(o));let d=l.slice(0);l.sort((m,p)=>{if(m.attrs["HDCP-LEVEL"]!==p.attrs["HDCP-LEVEL"])return(m.attrs["HDCP-LEVEL"]||"")>(p.attrs["HDCP-LEVEL"]||"")?1:-1;if(r&&m.height!==p.height)return m.height-p.height;if(m.frameRate!==p.frameRate)return m.frameRate-p.frameRate;if(m.videoRange!==p.videoRange)return ju.indexOf(m.videoRange)-ju.indexOf(p.videoRange);if(m.videoCodec!==p.videoCodec){let g=Zy(m.videoCodec),E=Zy(p.videoCodec);if(g!==E)return E-g}if(m.uri===p.uri&&m.codecSet!==p.codecSet){let g=Yu(m.codecSet),E=Yu(p.codecSet);if(g!==E)return E-g}return m.averageBitrate!==p.averageBitrate?m.averageBitrate-p.averageBitrate:0});let u=d[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==d.length)){for(let m=0;m<d.length;m++)if(d[m].pathwayId===l[0].pathwayId){u=d[m];break}}this._levels=l;for(let m=0;m<l.length;m++)if(l[m]===u){var c;this._firstLevel=m;let p=u.bitrate,g=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: ${p}`),((c=this.hls.userConfig)==null?void 0:c.abrEwmaDefaultEstimate)===void 0){let E=Math.min(p,this.hls.config.abrEwmaDefaultEstimateMax);E>g&&g===U_.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=E)}break}let h=n&&!s,f={levels:l,audioTracks:a,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:n,video:s,altAudio:!h&&a.some(m=>!!m.url)};this.hls.trigger(v.MANIFEST_PARSED,f),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}get levels(){return this._levels.length===0?null:this._levels}get level(){return this.currentLevelIndex}set level(e){let t=this._levels;if(t.length===0)return;if(e<0||e>=t.length){let u=new Error("invalid level idx"),c=e<0;if(this.hls.trigger(v.ERROR,{type:ie.OTHER_ERROR,details:C.LEVEL_SWITCH_ERROR,level:e,fatal:c,error:u,reason:u.message}),c)return;e=Math.min(e,t.length-1)}let r=this.currentLevelIndex,s=this.currentLevel,n=s?s.attrs["PATHWAY-ID"]:void 0,a=t[e],o=a.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=a,r===e&&a.details&&s&&n===o)return;this.log(`Switching to level ${e} (${a.height?a.height+"p ":""}${a.videoRange?a.videoRange+" ":""}${a.codecSet?a.codecSet+" ":""}@${a.bitrate})${o?" with Pathway "+o:""} from level ${r}${n?" with Pathway "+n:""}`);let l={level:e,attrs:a.attrs,details:a.details,bitrate:a.bitrate,averageBitrate:a.averageBitrate,maxBitrate:a.maxBitrate,realBitrate:a.realBitrate,width:a.width,height:a.height,codecSet:a.codecSet,audioCodec:a.audioCodec,videoCodec:a.videoCodec,audioGroups:a.audioGroups,subtitleGroups:a.subtitleGroups,loaded:a.loaded,loadError:a.loadError,fragmentError:a.fragmentError,name:a.name,id:a.id,uri:a.uri,url:a.url,urlId:0,audioGroupIds:a.audioGroupIds,textGroupIds:a.textGroupIds};this.hls.trigger(v.LEVEL_SWITCHING,l);let d=a.details;if(!d||d.live){let u=this.switchParams(a.uri,s==null?void 0:s.details,d);this.loadPlaylist(u)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,this._startLevel===void 0&&(this._startLevel=e),e!==-1&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(this._startLevel===void 0){let e=this.hls.config.startLevel;return e!==void 0?e:this.hls.firstAutoLevel}return this._startLevel}set startLevel(e){this._startLevel=e}onError(e,t){t.fatal||!t.context||t.context.type===ge.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(t!==void 0&&t.type===J.MAIN){let r=t.elementaryStreams;if(!Object.keys(r).some(n=>!!r[n]))return;let s=this._levels[t.level];s!=null&&s.loadError&&(this.log(`Resetting level error count of ${s.loadError} on frag buffered`),s.loadError=0)}}onLevelLoaded(e,t){var r;let{level:s,details:n}=t,a=this._levels[s];if(!a){var o;this.warn(`Invalid level index ${s}`),(o=t.deliveryDirectives)!=null&&o.skip&&(n.deltaUpdateFailed=!0);return}s===this.currentLevelIndex?(a.fragmentError===0&&(a.loadError=0),this.playlistLoaded(s,t,a.details)):(r=t.deliveryDirectives)!=null&&r.skip&&(n.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist();let t=this.currentLevelIndex,r=this.currentLevel;if(r&&this.shouldLoadPlaylist(r)){let s=r.uri;if(e)try{s=e.addDirectives(s)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}let n=r.attrs["PATHWAY-ID"];this.log(`Loading level index ${t}${(e==null?void 0:e.msn)!==void 0?" at sn "+e.msn+" part "+e.part:""} with${n?" Pathway "+n:""} ${s}`),this.clearTimer(),this.hls.trigger(v.LEVEL_LOADING,{url:s,level:t,pathwayId:r.attrs["PATHWAY-ID"],id:0,deliveryDirectives:e||null})}}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=e)}removeLevel(e){var t;let r=this._levels.filter((s,n)=>n!==e?!0:(this.steering&&this.steering.removeLevel(s),s===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,s.details&&s.details.fragments.forEach(a=>a.level=-1)),!1));s_(r),this._levels=r,this.currentLevelIndex>-1&&(t=this.currentLevel)!=null&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.hls.trigger(v.LEVELS_UPDATED,{levels:r})}onLevelsUpdated(e,{levels:t}){this._levels=t}checkMaxAutoUpdated(){let{autoLevelCapping:e,maxAutoLevel:t,maxHdcpLevel:r}=this.hls;this._maxAutoLevel!==t&&(this._maxAutoLevel=t,this.hls.trigger(v.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:r}))}};function UT(i){let e={};i.forEach(t=>{let r=t.groupId||"";t.id=e[r]=e[r]||0,e[r]++})}var Bg=class{constructor(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(let r in this.keyUriToKeyInfo){let s=this.keyUriToKeyInfo[r].loader;if(s){var t;if(e&&e!==((t=s.context)==null?void 0:t.frag.type))return;s.abort()}}}detach(){for(let e in this.keyUriToKeyInfo){let t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}destroy(){this.detach();for(let e in this.keyUriToKeyInfo){let t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(e,t=C.KEY_LOAD_ERROR,r,s,n){return new yi({type:ie.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:n,error:r,networkDetails:s})}loadClear(e,t){if(this.emeController&&this.config.emeEnabled){let{sn:r,cc:s}=e;for(let n=0;n<t.length;n++){let a=t[n];if(s<=a.cc&&(r==="initSegment"||a.sn==="initSegment"||r<a.sn)){this.emeController.selectKeySystemFormat(a).then(o=>{a.setKeyFormat(o)});break}}}}load(e){return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var r,s;t&&e.setKeyFormat(t);let n=e.decryptdata;if(!n){let d=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,C.KEY_LOAD_ERROR,d))}let a=n.uri;if(!a)return Promise.reject(this.createKeyLoadError(e,C.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${a}"`)));let o=this.keyUriToKeyInfo[a];if((r=o)!=null&&r.decryptdata.key)return n.key=o.decryptdata.key,Promise.resolve({frag:e,keyInfo:o});if((s=o)!=null&&s.keyLoadPromise){var l;switch((l=o.mediaKeySessionContext)==null?void 0:l.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return o.keyLoadPromise.then(d=>(n.key=d.keyInfo.decryptdata.key,{frag:e,keyInfo:o}))}}switch(o=this.keyUriToKeyInfo[a]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return n.keyFormat==="identity"?this.loadKeyHTTP(o,e):this.loadKeyEME(o,e);case"AES-128":return this.loadKeyHTTP(o,e);default:return Promise.reject(this.createKeyLoadError(e,C.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${n.method}"`)))}}loadKeyEME(e,t){let r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){let s=this.emeController.loadKey(r);if(s)return(e.keyLoadPromise=s.then(n=>(e.mediaKeySessionContext=n,r))).catch(n=>{throw e.keyLoadPromise=null,n})}return Promise.resolve(r)}loadKeyHTTP(e,t){let r=this.config,s=r.loader,n=new s(r);return t.keyLoader=e.loader=n,e.keyLoadPromise=new Promise((a,o)=>{let l={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},d=r.keyLoadPolicy.default,u={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(h,f,m,p)=>{let{frag:g,keyInfo:E,url:T}=m;if(!g.decryptdata||E!==this.keyUriToKeyInfo[T])return o(this.createKeyLoadError(g,C.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),p));E.decryptdata.key=g.decryptdata.key=new Uint8Array(h.data),g.keyLoader=null,E.loader=null,a({frag:g,keyInfo:E})},onError:(h,f,m,p)=>{this.resetLoader(f),o(this.createKeyLoadError(t,C.KEY_LOAD_ERROR,new Error(`HTTP Error ${h.code} loading key ${h.text}`),m,mt({url:l.url,data:void 0},h)))},onTimeout:(h,f,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,C.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),m))},onAbort:(h,f,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,C.INTERNAL_ABORTED,new Error("key loading aborted"),m))}};n.load(l,u,c)})}resetLoader(e){let{frag:t,keyInfo:r,url:s}=e,n=r.loader;t.keyLoader===n&&(t.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[s],n&&n.destroy()}};function F_(){return self.SourceBuffer||self.WebKitSourceBuffer}function B_(){if(!Is())return!1;let e=F_();return!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function"}function AC(){if(!B_())return!1;let i=Is();return typeof(i==null?void 0:i.isTypeSupported)=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(e=>i.isTypeSupported(uo(e,"video")))||["mp4a.40.2","fLaC"].some(e=>i.isTypeSupported(uo(e,"audio"))))}function SC(){var i;let e=F_();return typeof(e==null||(i=e.prototype)==null?void 0:i.changeType)=="function"}var xC=250,Gu=2,LC=.1,kC=.05,$g=class{constructor(e,t,r,s){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=e,this.media=t,this.fragmentTracker=r,this.hls=s}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(e,t){let{config:r,media:s,stalled:n}=this;if(s===null)return;let{currentTime:a,seeking:o}=s,l=this.seeking&&!o,d=!this.seeking&&o;if(this.seeking=o,a!==e){if(this.moved=!0,o||(this.nudgeRetry=0),n!==null){if(this.stallReported){let g=self.performance.now()-n;I.warn(`playback not stuck anymore @${a}, after ${Math.round(g)}ms`),this.stallReported=!1}this.stalled=null}return}if(d||l){this.stalled=null;return}if(s.paused&&!o||s.ended||s.playbackRate===0||!Ue.getBuffered(s).length){this.nudgeRetry=0;return}let u=Ue.bufferInfo(s,a,0),c=u.nextStart||0;if(o){let g=u.len>Gu,E=!c||t&&t.start<=a||c-a>Gu&&!this.fragmentTracker.getPartialFragment(a);if(g||E)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var h;if(!(u.len>0)&&!c)return;let E=Math.max(c,u.start||0)-a,T=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,S=(T==null||(h=T.details)==null?void 0:h.live)?T.details.targetduration*2:Gu,A=this.fragmentTracker.getPartialFragment(a);if(E>0&&(E<=S||A)){s.paused||this._trySkipBufferHole(A);return}}let f=self.performance.now();if(n===null){this.stalled=f;return}let m=f-n;if(!o&&m>=xC&&(this._reportStall(u),!this.media))return;let p=Ue.bufferInfo(s,a,r.maxBufferHole);this._tryFixBufferStall(p,m)}_tryFixBufferStall(e,t){let{config:r,fragmentTracker:s,media:n}=this;if(n===null)return;let a=n.currentTime,o=s.getPartialFragment(a);o&&(this._trySkipBufferHole(o)||!this.media)||(e.len>r.maxBufferHole||e.nextStart&&e.nextStart-a<r.maxBufferHole)&&t>r.highBufferWatchdogPeriod*1e3&&(I.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(e){let{hls:t,media:r,stallReported:s}=this;if(!s&&r){this.stallReported=!0;let n=new Error(`Playback stalling at @${r.currentTime} due to low buffer (${JSON.stringify(e)})`);I.warn(n.message),t.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:C.BUFFER_STALLED_ERROR,fatal:!1,error:n,buffer:e.len})}}_trySkipBufferHole(e){let{config:t,hls:r,media:s}=this;if(s===null)return 0;let n=s.currentTime,a=Ue.bufferInfo(s,n,0),o=n<a.start?a.start:a.nextStart;if(o){let l=a.len<=t.maxBufferHole,d=a.len>0&&a.len<1&&s.readyState<3,u=o-n;if(u>0&&(l||d)){if(u>t.maxBufferHole){let{fragmentTracker:h}=this,f=!1;if(n===0){let m=h.getAppendedFrag(0,J.MAIN);m&&o<m.end&&(f=!0)}if(!f){let m=e||h.getAppendedFrag(n,J.MAIN);if(m){let p=!1,g=m.end;for(;g<o;){let E=h.getPartialFragment(g);if(E)g+=E.duration;else{p=!0;break}}if(p)return 0}}}let c=Math.max(o+kC,n+LC);if(I.warn(`skipping hole, adjusting currentTime from ${n} to ${c}`),this.moved=!0,this.stalled=null,s.currentTime=c,e&&!e.gap){let h=new Error(`fragment loaded with buffer holes, seeking from ${n} to ${c}`);r.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:C.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:h,reason:h.message,frag:e})}return c}}return 0}_tryNudgeBuffer(){let{config:e,hls:t,media:r,nudgeRetry:s}=this;if(r===null)return;let n=r.currentTime;if(this.nudgeRetry++,s<e.nudgeMaxRetry){let a=n+(s+1)*e.nudgeOffset,o=new Error(`Nudging 'currentTime' from ${n} to ${a}`);I.warn(o.message),r.currentTime=a,t.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:C.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1})}else{let a=new Error(`Playhead still not moving while enough data buffered @${n} after ${e.nudgeMaxRetry} nudges`);I.error(a.message),t.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:C.BUFFER_STALLED_ERROR,error:a,fatal:!0})}}},IC=100,Hg=class extends mo{constructor(e,t,r){super(e,t,r,"[stream-controller]",J.MAIN),this.audioCodecSwap=!1,this.gapController=null,this.level=-1,this._forceStartLoad=!1,this.altAudio=!1,this.audioOnly=!1,this.fragPlaying=null,this.onvplaying=null,this.onvseeked=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this._registerListeners()}_registerListeners(){let{hls:e}=this;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.LEVEL_LOADING,this.onLevelLoading,this),e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(v.ERROR,this.onError,this),e.on(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(v.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(v.BUFFER_CREATED,this.onBufferCreated,this),e.on(v.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){let{hls:e}=this;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(v.ERROR,this.onError,this),e.off(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(v.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(v.BUFFER_CREATED,this.onBufferCreated,this),e.off(v.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying()}startLoad(e){if(this.levels){let{lastCurrentTime:t,hls:r}=this;if(this.stopLoad(),this.setInterval(IC),this.level=-1,!this.startFragRequested){let s=r.startLevel;s===-1&&(r.config.testBandwidth&&this.levels.length>1?(s=0,this.bitrateTest=!0):s=r.firstAutoLevel),r.nextLoadLevel=s,this.level=r.loadLevel,this.loadedmetadata=!1}t>0&&e===-1&&(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t),this.state=N.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=N.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case N.WAITING_LEVEL:{let{levels:t,level:r}=this,s=t==null?void 0:t[r],n=s==null?void 0:s.details;if(n&&(!n.live||this.levelLastLoaded===s)){if(this.waitForCdnTuneIn(n))break;this.state=N.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=N.IDLE;break}break}case N.FRAG_LOADING_WAITING_RETRY:{var e;let t=self.performance.now(),r=this.retryDate;if(!r||t>=r||(e=this.media)!=null&&e.seeking){let{levels:s,level:n}=this,a=s==null?void 0:s[n];this.resetStartWhenNotLoaded(a||null),this.state=N.IDLE}}break}this.state===N.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){let{hls:e,levelLastLoaded:t,levels:r,media:s}=this;if(t===null||!s&&(this.startFragRequested||!e.config.startFragPrefetch)||this.altAudio&&this.audioOnly)return;let n=e.nextLoadLevel;if(!(r!=null&&r[n]))return;let a=r[n],o=this.getMainFwdBufferInfo();if(o===null)return;let l=this.getLevelDetails();if(l&&this._streamEnded(o,l)){let p={};this.altAudio&&(p.type="video"),this.hls.trigger(v.BUFFER_EOS,p),this.state=N.ENDED;return}e.loadLevel!==n&&e.manualLevel===-1&&this.log(`Adapting to level ${n} from level ${this.level}`),this.level=e.nextLoadLevel=n;let d=a.details;if(!d||this.state===N.WAITING_LEVEL||d.live&&this.levelLastLoaded!==a){this.level=n,this.state=N.WAITING_LEVEL;return}let u=o.len,c=this.getMaxBufferLength(a.maxBitrate);if(u>=c)return;this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);let h=this.backtrackFragment?this.backtrackFragment.start:o.end,f=this.getNextFragment(h,d);if(this.couldBacktrack&&!this.fragPrevious&&f&&f.sn!=="initSegment"&&this.fragmentTracker.getState(f)!==ft.OK){var m;let g=((m=this.backtrackFragment)!=null?m:f).sn-d.startSN,E=d.fragments[g-1];E&&f.cc===E.cc&&(f=E,this.fragmentTracker.removeFragment(E))}else this.backtrackFragment&&o.len&&(this.backtrackFragment=null);if(f&&this.isLoopLoading(f,h)){if(!f.gap){let g=this.audioOnly&&!this.altAudio?ke.AUDIO:ke.VIDEO,E=(g===ke.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;E&&this.afterBufferFlushed(E,g,J.MAIN)}f=this.getNextFragmentLoopLoading(f,d,o,J.MAIN,c)}f&&(f.initSegment&&!f.initSegment.data&&!this.bitrateTest&&(f=f.initSegment),this.loadFragment(f,a,h))}loadFragment(e,t,r){let s=this.fragmentTracker.getState(e);this.fragCurrent=e,s===ft.NOT_LOADED||s===ft.PARTIAL?e.sn==="initSegment"?this._loadInitSegment(e,t):this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):(this.startFragRequested=!0,super.loadFragment(e,t,r)):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,J.MAIN)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){let{levels:e,media:t}=this;if(t!=null&&t.readyState){let r,s=this.getAppendedFrag(t.currentTime);s&&s.start>1&&this.flushMainBuffer(0,s.start-1);let n=this.getLevelDetails();if(n!=null&&n.live){let o=this.getMainFwdBufferInfo();if(!o||o.len<n.targetduration*2)return}if(!t.paused&&e){let o=this.hls.nextLoadLevel,l=e[o],d=this.fragLastKbps;d&&this.fragCurrent?r=this.fragCurrent.duration*l.maxBitrate/(1e3*d)+1:r=0}else r=0;let a=this.getBufferedFrag(t.currentTime+r);if(a){let o=this.followingBufferedFrag(a);if(o){this.abortCurrentFrag();let l=o.maxStartPTS?o.maxStartPTS:o.start,d=o.duration,u=Math.max(a.end,l+Math.min(Math.max(d-this.config.maxFragLookUpTolerance,d*(this.couldBacktrack?.5:.125)),d*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(u,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){let e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case N.KEY_LOADING:case N.FRAG_LOADING:case N.FRAG_LOADING_WAITING_RETRY:case N.PARSING:case N.PARSED:this.state=N.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);let r=t.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),r.addEventListener("playing",this.onvplaying),r.addEventListener("seeked",this.onvseeked),this.gapController=new $g(this.config,r,this.fragmentTracker,this.hls)}onMediaDetaching(){let{media:e}=this;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching()}onMediaPlaying(){this.tick()}onMediaSeeked(){let e=this.media,t=e?e.currentTime:null;q(t)&&this.log(`Media seeked to ${t.toFixed(3)}`);let r=this.getMainFwdBufferInfo();if(r===null||r.len===0){this.warn(`Main forward buffer length on "seeked" event ${r?r.len:"empty"})`);return}this.tick()}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(v.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=this.fragLastKbps=0,this.levels=this.fragPlaying=this.backtrackFragment=this.levelLastLoaded=null,this.altAudio=this.audioOnly=this.startFragRequested=!1}onManifestParsed(e,t){let r=!1,s=!1;t.levels.forEach(n=>{let a=n.audioCodec;a&&(r=r||a.indexOf("mp4a.40.2")!==-1,s=s||a.indexOf("mp4a.40.5")!==-1)}),this.audioCodecSwitch=r&&s&&!SC(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}onLevelLoading(e,t){let{levels:r}=this;if(!r||this.state!==N.IDLE)return;let s=r[t.level];(!s.details||s.details.live&&this.levelLastLoaded!==s||this.waitForCdnTuneIn(s.details))&&(this.state=N.WAITING_LEVEL)}onLevelLoaded(e,t){var r;let{levels:s}=this,n=t.level,a=t.details,o=a.totalduration;if(!s){this.warn(`Levels were reset while loading level ${n}`);return}this.log(`Level ${n} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""}, cc [${a.startCC}, ${a.endCC}] duration:${o}`);let l=s[n],d=this.fragCurrent;d&&(this.state===N.FRAG_LOADING||this.state===N.FRAG_LOADING_WAITING_RETRY)&&d.level!==t.level&&d.loader&&this.abortCurrentFrag();let u=0;if(a.live||(r=l.details)!=null&&r.live){var c;if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;u=this.alignPlaylists(a,l.details,(c=this.levelLastLoaded)==null?void 0:c.details)}if(l.details=a,this.levelLastLoaded=l,this.hls.trigger(v.LEVEL_UPDATED,{details:a,level:n}),this.state===N.WAITING_LEVEL){if(this.waitForCdnTuneIn(a))return;this.state=N.IDLE}this.startFragRequested?a.live&&this.synchronizeToLiveEdge(a):this.setStartPosition(a,u),this.tick()}_handleFragmentLoadProgress(e){var t;let{frag:r,part:s,payload:n}=e,{levels:a}=this;if(!a){this.warn(`Levels were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);return}let o=a[r.level],l=o.details;if(!l){this.warn(`Dropping fragment ${r.sn} of level ${r.level} after level details were reset`),this.fragmentTracker.removeFragment(r);return}let d=o.videoCodec,u=l.PTSKnown||!l.live,c=(t=r.initSegment)==null?void 0:t.data,h=this._getAudioCodec(o),f=this.transmuxer=this.transmuxer||new lc(this.hls,J.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),m=s?s.index:-1,p=m!==-1,g=new ho(r.level,r.sn,r.stats.chunkCount,n.byteLength,m,p),E=this.initPTS[r.cc];f.push(n,c,h,d,r,s,l.totalduration,u,g,E)}onAudioTrackSwitching(e,t){let r=this.altAudio;if(!!!t.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;let a=this.fragCurrent;a&&(this.log("Switching to main audio track, cancel main fragment load"),a.abortRequests(),this.fragmentTracker.removeFragment(a)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();let n=this.hls;r&&(n.trigger(v.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),n.trigger(v.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){let r=t.id,s=!!this.hls.audioTracks[r].url;if(s){let n=this.videoBuffer;n&&this.mediaBuffer!==n&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=n)}this.altAudio=s,this.tick()}onBufferCreated(e,t){let r=t.tracks,s,n,a=!1;for(let o in r){let l=r[o];if(l.id==="main"){if(n=o,s=l,o==="video"){let d=r[o];d&&(this.videoBuffer=d.buffer)}}else a=!0}a&&s?(this.log(`Alternate track found, use ${n}.buffered to schedule main fragment loading`),this.mediaBuffer=s.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){let{frag:r,part:s}=t;if(r&&r.type!==J.MAIN)return;if(this.fragContextChanged(r)){this.warn(`Fragment ${r.sn}${s?" p: "+s.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}`),this.state===N.PARSED&&(this.state=N.IDLE);return}let n=s?s.stats:r.stats;this.fragLastKbps=Math.round(8*n.total/(n.buffering.end-n.loading.first)),r.sn!=="initSegment"&&(this.fragPrevious=r),this.fragBufferedComplete(r,s)}onError(e,t){var r;if(t.fatal){this.state=N.ERROR;return}switch(t.details){case C.FRAG_GAP:case C.FRAG_PARSING_ERROR:case C.FRAG_DECRYPT_ERROR:case C.FRAG_LOAD_ERROR:case C.FRAG_LOAD_TIMEOUT:case C.KEY_LOAD_ERROR:case C.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(J.MAIN,t);break;case C.LEVEL_LOAD_ERROR:case C.LEVEL_LOAD_TIMEOUT:case C.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===N.WAITING_LEVEL&&((r=t.context)==null?void 0:r.type)===ge.LEVEL&&(this.state=N.IDLE);break;case C.BUFFER_APPEND_ERROR:case C.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="main")return;if(t.details===C.BUFFER_APPEND_ERROR){this.resetLoadingState();return}this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case C.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}checkBuffer(){let{media:e,gapController:t}=this;if(!(!e||!t||!e.readyState)){if(this.loadedmetadata||!Ue.getBuffered(e).length){let r=this.state!==N.IDLE?this.fragCurrent:null;t.poll(this.lastCurrentTime,r)}this.lastCurrentTime=e.currentTime}}onFragLoadEmergencyAborted(){this.state=N.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==ke.AUDIO||this.audioOnly&&!this.altAudio){let r=(t===ke.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(r,t,J.MAIN),this.tick()}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level),this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){let{media:e}=this;if(!e)return;let t=e.currentTime,r=this.startPosition;if(r>=0&&t<r){if(e.seeking){this.log(`could not seek to ${r}, already seeking at ${t}`);return}let s=Ue.getBuffered(e),a=(s.length?s.start(0):0)-r;a>0&&(a<this.config.maxBufferHole||a<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${a} to match buffer start`),r+=a,this.startPosition=r),this.log(`seek to target start position ${r} from current time ${t}`),e.currentTime=r}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t.indexOf("mp4a.40.5")!==-1?t="mp4a.40.2":t="mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(r=>{let{hls:s}=this;if(!r||this.fragContextChanged(e))return;t.fragmentError=0,this.state=N.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;let n=e.stats;n.parsing.start=n.parsing.end=n.buffering.start=n.buffering.end=self.performance.now(),s.trigger(v.FRAG_LOADED,r),e.bitrateTest=!1})}_handleTransmuxComplete(e){var t;let r="main",{hls:s}=this,{remuxResult:n,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}let{frag:l,part:d,level:u}=o,{video:c,text:h,id3:f,initSegment:m}=n,{details:p}=u,g=this.altAudio?void 0:n.audio;if(this.fragContextChanged(l)){this.fragmentTracker.removeFragment(l);return}if(this.state=N.PARSING,m){if(m!=null&&m.tracks){let y=l.initSegment||l;this._bufferInitSegment(u,m.tracks,y,a),s.trigger(v.FRAG_PARSING_INIT_SEGMENT,{frag:y,id:r,tracks:m.tracks})}let E=m.initPTS,T=m.timescale;q(E)&&(this.initPTS[l.cc]={baseTime:E,timescale:T},s.trigger(v.INIT_PTS_FOUND,{frag:l,id:r,initPTS:E,timescale:T}))}if(c&&p&&l.sn!=="initSegment"){let E=p.fragments[l.sn-1-p.startSN],T=l.sn===p.startSN,y=!E||l.cc>E.cc;if(n.independent!==!1){let{startPTS:S,endPTS:A,startDTS:L,endDTS:x}=c;if(d)d.elementaryStreams[c.type]={startPTS:S,endPTS:A,startDTS:L,endDTS:x};else if(c.firstKeyFrame&&c.independent&&a.id===1&&!y&&(this.couldBacktrack=!0),c.dropped&&c.independent){let w=this.getMainFwdBufferInfo(),P=(w?w.end:this.getLoadPosition())+this.config.maxBufferHole,k=c.firstKeyFramePTS?c.firstKeyFramePTS:S;if(!T&&P<k-this.config.maxBufferHole&&!y){this.backtrack(l);return}else y&&(l.gap=!0);l.setElementaryStreamInfo(c.type,l.start,A,l.start,x,!0)}else T&&S>Gu&&(l.gap=!0);l.setElementaryStreamInfo(c.type,S,A,L,x),this.backtrackFragment&&(this.backtrackFragment=l),this.bufferFragmentData(c,l,d,a,T||y)}else if(T||y)l.gap=!0;else{this.backtrack(l);return}}if(g){let{startPTS:E,endPTS:T,startDTS:y,endDTS:S}=g;d&&(d.elementaryStreams[ke.AUDIO]={startPTS:E,endPTS:T,startDTS:y,endDTS:S}),l.setElementaryStreamInfo(ke.AUDIO,E,T,y,S),this.bufferFragmentData(g,l,d,a)}if(p&&f!=null&&(t=f.samples)!=null&&t.length){let E={id:r,frag:l,details:p,samples:f.samples};s.trigger(v.FRAG_PARSING_METADATA,E)}if(p&&h){let E={id:r,frag:l,details:p,samples:h.samples};s.trigger(v.FRAG_PARSING_USERDATA,E)}}_bufferInitSegment(e,t,r,s){if(this.state!==N.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;let{audio:n,video:a,audiovideo:o}=t;if(n){let l=e.audioCodec,d=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){l&&(l.indexOf("mp4a.40.5")!==-1?l="mp4a.40.2":l="mp4a.40.5");let u=n.metadata;u&&"channelCount"in u&&(u.channelCount||1)!==1&&d.indexOf("firefox")===-1&&(l="mp4a.40.5")}l&&l.indexOf("mp4a.40.5")!==-1&&d.indexOf("android")!==-1&&n.container!=="audio/mpeg"&&(l="mp4a.40.2",this.log(`Android: force audio codec to ${l}`)),e.audioCodec&&e.audioCodec!==l&&this.log(`Swapping manifest audio codec "${e.audioCodec}" for "${l}"`),n.levelCodec=l,n.id="main",this.log(`Init audio buffer, container:${n.container}, codecs[selected/level/parsed]=[${l||""}/${e.audioCodec||""}/${n.codec}]`)}a&&(a.levelCodec=e.videoCodec,a.id="main",this.log(`Init video buffer, container:${a.container}, codecs[level/parsed]=[${e.videoCodec||""}/${a.codec}]`)),o&&this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.codecs}/${o.codec}]`),this.hls.trigger(v.BUFFER_CODECS,t),Object.keys(t).forEach(l=>{let u=t[l].initSegment;u!=null&&u.byteLength&&this.hls.trigger(v.BUFFER_APPENDING,{type:l,data:u,frag:r,part:null,chunkMeta:s,parent:r.type})}),this.tickImmediate()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,J.MAIN)}backtrack(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=N.IDLE}checkFragmentChanged(){let e=this.media,t=null;if(e&&e.readyState>1&&e.seeking===!1){let r=e.currentTime;if(Ue.isBuffered(e,r)?t=this.getAppendedFrag(r):Ue.isBuffered(e,r+.1)&&(t=this.getAppendedFrag(r+.1)),t){this.backtrackFragment=null;let s=this.fragPlaying,n=t.level;(!s||t.sn!==s.sn||s.level!==n)&&(this.fragPlaying=t,this.hls.trigger(v.FRAG_CHANGED,{frag:t}),(!s||s.level!==n)&&this.hls.trigger(v.LEVEL_SWITCHED,{level:n}))}}}get nextLevel(){let e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){let e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}get currentProgramDateTime(){let e=this.media;if(e){let t=e.currentTime,r=this.currentFrag;if(r&&q(t)&&q(r.programDateTime)){let s=r.programDateTime+(t-r.start)*1e3;return new Date(s)}}return null}get currentLevel(){let e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){let e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}},vo=class i{static get version(){return"1.5.11"}static isMSESupported(){return B_()}static isSupported(){return AC()}static getMediaSource(){return Is()}static get Events(){return v}static get ErrorTypes(){return ie}static get ErrorDetails(){return C}static get DefaultConfig(){return i.defaultConfig?i.defaultConfig:U_}static set DefaultConfig(e){i.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this.started=!1,this._emitter=new Xg,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,this.triggeringException=void 0,lI(e.debug||!1,"Hls instance");let t=this.config=TC(i.DefaultConfig,e);this.userConfig=e,t.progressive&&_C(t);let{abrController:r,bufferController:s,capLevelController:n,errorController:a,fpsController:o}=t,l=new a(this),d=this.abrController=new r(this),u=this.bufferController=new s(this),c=this.capLevelController=new n(this),h=new o(this),f=new Fp(this),m=new Hp(this),p=t.contentSteeringController,g=p?new p(this):null,E=this.levelController=new Fg(this,g),T=new Xp(this),y=new Bg(this.config),S=this.streamController=new Hg(this,T,y);c.setStreamController(S),h.setStreamController(S);let A=[f,E,S];g&&A.splice(1,0,g),this.networkControllers=A;let L=[d,u,c,h,m,T];this.audioTrackController=this.createController(t.audioTrackController,A);let x=t.audioStreamController;x&&A.push(new x(this,T,y)),this.subtitleTrackController=this.createController(t.subtitleTrackController,A);let w=t.subtitleStreamController;w&&A.push(new w(this,T,y)),this.createController(t.timelineController,L),y.emeController=this.emeController=this.createController(t.emeController,L),this.cmcdController=this.createController(t.cmcdController,L),this.latencyController=this.createController(Gp,L),this.coreComponents=L,A.push(l);let P=l.onErrorOut;typeof P=="function"&&this.on(v.ERROR,P,l)}createController(e,t){if(e){let r=new e(this);return t&&t.push(r),r}return null}on(e,t,r=this){this._emitter.on(e,t,r)}once(e,t,r=this){this._emitter.once(e,t,r)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,r=this,s){this._emitter.off(e,t,r,s)}listeners(e){return this._emitter.listeners(e)}emit(e,t,r){return this._emitter.emit(e,t,r)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(r){if(I.error("An internal error happened while handling event "+e+'. Error message: "'+r.message+'". Here is a stacktrace:',r),!this.triggeringException){this.triggeringException=!0;let s=e===v.ERROR;this.trigger(v.ERROR,{type:ie.OTHER_ERROR,details:C.INTERNAL_EXCEPTION,fatal:s,event:e,error:r}),this.triggeringException=!1}}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){I.log("destroy"),this.trigger(v.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(t=>t.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(t=>t.destroy()),this.coreComponents.length=0;let e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){I.log("attachMedia"),this._media=e,this.trigger(v.MEDIA_ATTACHING,{media:e})}detachMedia(){I.log("detachMedia"),this.trigger(v.MEDIA_DETACHING,void 0),this._media=null}loadSource(e){this.stopLoad();let t=this.media,r=this.url,s=this.url=Gg.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,I.log(`loadSource:${s}`),t&&r&&(r!==s||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(v.MANIFEST_LOADING,{url:e})}startLoad(e=-1){I.log(`startLoad(${e})`),this.started=!0,this.networkControllers.forEach(t=>{t.startLoad(e)})}stopLoad(){I.log("stopLoad"),this.started=!1,this.networkControllers.forEach(e=>{e.stopLoad()})}resumeBuffering(){this.started&&this.networkControllers.forEach(e=>{"fragmentLoader"in e&&e.startLoad(-1)})}pauseBuffering(){this.networkControllers.forEach(e=>{"fragmentLoader"in e&&e.stopLoad()})}swapAudioCodec(){I.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){I.log("recoverMediaError");let e=this._media;this.detachMedia(),e&&this.attachMedia(e)}removeLevel(e){this.levelController.removeLevel(e)}get levels(){let e=this.levelController.levels;return e||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){I.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){I.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){I.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){I.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){let e=this.levelController.startLevel;return e===-1&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e}set startLevel(e){I.log(`set startLevel:${e}`),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){let t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){let{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}set bandwidthEstimate(e){this.abrController.resetEstimator(e)}get ttfbEstimate(){let{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(I.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){sR(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){let{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;let r=e.length;for(let s=0;s<r;s++)if(e[s].maxBitrate>=t)return s;return 0}get maxAutoLevel(){let{levels:e,autoLevelCapping:t,maxHdcpLevel:r}=this,s;if(t===-1&&e!=null&&e.length?s=e.length-1:s=t,r)for(let n=s;n--;){let a=e[n].attrs["HDCP-LEVEL"];if(a&&a<=r)return n}return s}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(e){this.abrController.nextAutoLevel=e}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}setAudioOption(e){var t;return(t=this.audioTrackController)==null?void 0:t.setAudioOption(e)}setSubtitleOption(e){var t;return(t=this.subtitleTrackController)==null||t.setSubtitleOption(e),null}get allAudioTracks(){let e=this.audioTrackController;return e?e.allAudioTracks:[]}get audioTracks(){let e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){let e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){let t=this.audioTrackController;t&&(t.audioTrack=e)}get allSubtitleTracks(){let e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}get subtitleTracks(){let e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){let e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){let t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){let e=this.subtitleTrackController;return e?e.subtitleDisplay:!1}set subtitleDisplay(e){let t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}};vo.defaultConfig=void 0;var Ve=vo,Pr=class Eo extends Error{constructor(e,t=Eo.MEDIA_ERR_CUSTOM,r,s){var n;super(e),this.name="MediaError",this.code=t,this.context=s,this.fatal=r!=null?r:t>=Eo.MEDIA_ERR_NETWORK&&t<=Eo.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(n=Eo.defaultMessages[this.code])!=null?n:"")}};Pr.MEDIA_ERR_ABORTED=1,Pr.MEDIA_ERR_NETWORK=2,Pr.MEDIA_ERR_DECODE=3,Pr.MEDIA_ERR_SRC_NOT_SUPPORTED=4,Pr.MEDIA_ERR_ENCRYPTED=5,Pr.MEDIA_ERR_CUSTOM=100,Pr.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 bt=Pr,RC=i=>i==null,V_=(i,e)=>RC(e)?!1:i in e,r0={ANY:"any",MUTED:"muted"},ye={ON_DEMAND:"on-demand",LIVE:"live",UNKNOWN:"unknown"},ei={MSE:"mse",NATIVE:"native"},vc={HEADER:"header",QUERY:"query",NONE:"none"},zn=Object.values(vc),Nr={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},s0={HLS:Nr.M3U8},p5=Object.keys(s0),g5=[...Object.values(Nr),"hls","HLS"];var st=(i,e,t,r,s=i)=>{s.addEventListener(e,t,r),i.addEventListener("teardown",()=>{s.removeEventListener(e,t)},{once:!0})};function wC(i,e,t){e&&t>e&&(t=e);for(let r=0;r<i.length;r++)if(i.start(r)<=t&&i.end(r)>=t)return!0;return!1}var CC=i=>{let e=i.indexOf("?");if(e<0)return[i];let t=i.slice(0,e),r=i.slice(e);return[t,r]},yc=i=>{let e=i.type;if(e){let r=e.toUpperCase();return V_(r,s0)?s0[r]:e}let{src:t}=i;return t?DC(t):""},q_=i=>i==="VOD"?ye.ON_DEMAND:ye.LIVE,Y_=i=>i==="EVENT"?Number.POSITIVE_INFINITY:i==="VOD"?Number.NaN:0,DC=i=>{let e="";try{e=new URL(i).pathname}catch{console.error("invalid url")}let t=e.lastIndexOf(".");if(t<0)return"";let r=e.slice(t+1).toUpperCase();return V_(r,Nr)?Nr[r]:""},MC=Object.values(r0),$_=i=>typeof i=="boolean"||typeof i=="string"&&MC.includes(i),PC=(i,e,t)=>{let{autoplay:r}=i,s=!1,n=!1,a=$_(r)?r:!!r,o=()=>{s||st(e,"playing",()=>{s=!0},{once:!0})};if(o(),st(e,"loadstart",()=>{s=!1,o(),e0(e,a)},{once:!0}),st(e,"loadstart",()=>{t||(i.streamType&&i.streamType!==ye.UNKNOWN?n=i.streamType===ye.LIVE:n=!Number.isFinite(e.duration)),e0(e,a)},{once:!0}),t&&t.once(Ve.Events.LEVEL_LOADED,(l,d)=>{var u;i.streamType&&i.streamType!==ye.UNKNOWN?n=i.streamType===ye.LIVE:n=(u=d.details.live)!=null?u:!1}),!a){let l=()=>{!n||Number.isFinite(i.startTime)||(t!=null&&t.liveSyncPosition?e.currentTime=t.liveSyncPosition:Number.isFinite(e.seekable.end(0))&&(e.currentTime=e.seekable.end(0)))};t&&st(e,"play",()=>{e.preload==="metadata"?t.once(Ve.Events.LEVEL_UPDATED,l):l()},{once:!0})}return l=>{s||(a=$_(l)?l:!!l,e0(e,a))}},e0=(i,e)=>{if(!e)return;let t=i.muted,r=()=>i.muted=t;switch(e){case r0.ANY:i.play().catch(()=>{i.muted=!0,i.play().catch(r)});break;case r0.MUTED:i.muted=!0,i.play().catch(r);break;default:i.play().catch(()=>{});break}},OC=({preload:i,src:e},t,r)=>{let s=c=>{c!=null&&["","none","metadata","auto"].includes(c)?t.setAttribute("preload",c):t.removeAttribute("preload")};if(!r)return s(i),s;let n=!1,a=!1,o=r.config.maxBufferLength,l=r.config.maxBufferSize,d=c=>{s(c);let h=c!=null?c:t.preload;a||h==="none"||(h==="metadata"?(r.config.maxBufferLength=1,r.config.maxBufferSize=1):(r.config.maxBufferLength=o,r.config.maxBufferSize=l),u())},u=()=>{!n&&e&&(n=!0,r.loadSource(e))};return st(t,"play",()=>{a=!0,r.config.maxBufferLength=o,r.config.maxBufferSize=l,u()},{once:!0}),d(i),d};function NC(i,e){var t;if(!("videoTracks"in i))return;let r=new WeakMap;e.on(Ve.Events.MANIFEST_PARSED,function(d,u){l();let c=i.addVideoTrack("main");c.selected=!0;for(let[h,f]of u.levels.entries()){let m=c.addRendition(f.url[0],f.width,f.height,f.videoCodec,f.bitrate);r.set(f,`${h}`),m.id=`${h}`}}),e.on(Ve.Events.AUDIO_TRACKS_UPDATED,function(d,u){o();for(let c of u.audioTracks){let h=c.default?"main":"alternative",f=i.addAudioTrack(h,c.name,c.lang);f.id=`${c.id}`,c.default&&(f.enabled=!0)}}),i.audioTracks.addEventListener("change",()=>{var d;let u=+((d=[...i.audioTracks].find(h=>h.enabled))==null?void 0:d.id),c=e.audioTracks.map(h=>h.id);u!=e.audioTrack&&c.includes(u)&&(e.audioTrack=u)}),e.on(Ve.Events.LEVELS_UPDATED,function(d,u){var c;let h=i.videoTracks[(c=i.videoTracks.selectedIndex)!=null?c:0];if(!h)return;let f=u.levels.map(m=>r.get(m));for(let m of i.videoRenditions)m.id&&!f.includes(m.id)&&h.removeRendition(m)});let s=d=>{let u=d.target.selectedIndex;u!=e.nextLevel&&n(u)},n=d=>{let u=i.currentTime,c=!1,h=(f,m)=>{c||(c=!Number.isFinite(m.endOffset))};e.on(Ve.Events.BUFFER_FLUSHING,h),e.nextLevel=d,e.off(Ve.Events.BUFFER_FLUSHING,h),c||e.trigger(Ve.Events.BUFFER_FLUSHING,{startOffset:u+10,endOffset:1/0,type:"video"})};(t=i.videoRenditions)==null||t.addEventListener("change",s);let a=()=>{for(let d of i.videoTracks)i.removeVideoTrack(d)},o=()=>{for(let d of i.audioTracks)i.removeAudioTrack(d)},l=()=>{a(),o()};e.once(Ve.Events.DESTROYING,l)}var t0=i=>"time"in i?i.time:i.startTime;function UC(i,e){e.on(Ve.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(s,{tracks:n})=>{n.forEach(a=>{var o;let l=(o=a.subtitleTrack)!=null?o:a.closedCaptions,d=e.subtitleTracks.findIndex(({lang:u,name:c,type:h})=>u==(l==null?void 0:l.lang)&&c===a.label&&h.toLowerCase()===a.kind);Tc(i,a.kind,a.label,l==null?void 0:l.lang,`${a.kind}${d}`)})});let t=()=>{var s;if(!e.subtitleTracks.length)return;let n=Array.from(i.textTracks).find(o=>o.id&&o.mode==="showing"&&["subtitles","captions"].includes(o.kind)),a=`${(s=e.subtitleTracks[e.subtitleTrack])==null?void 0:s.type.toLowerCase()}${e.subtitleTrack}`;if(n&&(e.subtitleTrack<0||(n==null?void 0:n.id)!==a)){let o=e.subtitleTracks.findIndex(({lang:l,name:d,type:u})=>l==n.language&&d===n.label&&u.toLowerCase()===n.kind);e.subtitleTrack=o}n&&(n==null?void 0:n.id)===a&&n.cues&&Array.from(n.cues).forEach(o=>{n.addCue(o)})};i.textTracks.addEventListener("change",t),e.on(Ve.Events.CUES_PARSED,(s,{track:n,cues:a})=>{let o=i.textTracks.getTrackById(n);if(!o)return;let l=o.mode==="disabled";l&&(o.mode="hidden"),a.forEach(d=>{var u;(u=o.cues)!=null&&u.getCueById(d.id)||o.addCue(d)}),l&&(o.mode="disabled")}),e.once(Ve.Events.DESTROYING,()=>{i.textTracks.removeEventListener("change",t),i.querySelectorAll("track[data-removeondestroy]").forEach(s=>{s.remove()})});let r=()=>{Array.from(i.textTracks).forEach(s=>{var n,a;if(!["subtitles","caption"].includes(s.kind)&&s.label==="thumbnails"){if(!((n=s.cues)!=null&&n.length)){let o=i.querySelector('track[label="thumbnails"]'),l=(a=o==null?void 0:o.getAttribute("src"))!=null?a:"";o==null||o.removeAttribute("src"),setTimeout(()=>{o==null||o.setAttribute("src",l)},0)}s.mode!=="hidden"&&(s.mode="hidden")}})};e.once(Ve.Events.MANIFEST_LOADED,r),e.once(Ve.Events.MEDIA_ATTACHED,r)}function Tc(i,e,t,r,s){let n=document.createElement("track");return n.kind=e,n.label=t,r&&(n.srclang=r),s&&(n.id=s),n.track.mode=["subtitles","captions"].includes(e)?"disabled":"hidden",n.setAttribute("data-removeondestroy",""),i.append(n),n.track}function z_(i,e){let t=Array.prototype.find.call(i.querySelectorAll("track"),r=>r.track===e);t==null||t.remove()}function yo(i,e,t){var r;return(r=Array.from(i.querySelectorAll("track")).find(s=>s.track.label===e&&s.track.kind===t))==null?void 0:r.track}async function j_(i,e,t,r){let s=yo(i,t,r);return s||(s=Tc(i,r,t),s.mode="hidden",await new Promise(n=>setTimeout(()=>n(void 0),0))),s.mode!=="hidden"&&(s.mode="hidden"),[...e].sort((n,a)=>t0(a)-t0(n)).forEach(n=>{var a,o;let l=n.value,d=t0(n);if("endTime"in n&&n.endTime!=null)s==null||s.addCue(new VTTCue(d,n.endTime,r==="chapters"?l:JSON.stringify(l!=null?l:null)));else{let u=Array.prototype.findIndex.call(s==null?void 0:s.cues,m=>m.startTime>=d),c=(a=s==null?void 0:s.cues)==null?void 0:a[u],h=c?c.startTime:Number.isFinite(i.duration)?i.duration:Number.MAX_SAFE_INTEGER,f=(o=s==null?void 0:s.cues)==null?void 0:o[u-1];f&&(f.endTime=d),s==null||s.addCue(new VTTCue(d,h,r==="chapters"?l:JSON.stringify(l!=null?l:null)))}}),i.textTracks.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),s}var l0="cuepoints",X_=Object.freeze({label:l0});async function d0(i,e,t=X_){return j_(i,e,t.label,"metadata")}var n0=i=>({time:i.startTime,value:JSON.parse(i.text)});function Q_(i,e={label:l0}){let t=yo(i,e.label,"metadata");return t!=null&&t.cues?Array.from(t.cues,r=>n0(r)):[]}function u0(i,e={label:l0}){var t,r;let s=yo(i,e.label,"metadata");if(!((t=s==null?void 0:s.activeCues)!=null&&t.length))return;if(s.activeCues.length===1)return n0(s.activeCues[0]);let{currentTime:n}=i,a=Array.prototype.find.call((r=s.activeCues)!=null?r:[],({startTime:o,endTime:l})=>o<=n&&l>n);return n0(a||s.activeCues[0])}async function FC(i,e=X_){return new Promise(t=>{st(i,"loadstart",async()=>{let r=await d0(i,[],e);st(i,"cuechange",()=>{let s=u0(i);if(s){let n=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:s});i.dispatchEvent(n)}},{},r),t(r)})})}var c0="chapters",Z_=Object.freeze({label:c0}),a0=i=>({startTime:i.startTime,endTime:i.endTime,value:i.text});async function h0(i,e,t=Z_){return j_(i,e,t.label,"chapters")}function J_(i,e={label:c0}){var t;let r=yo(i,e.label,"chapters");return(t=r==null?void 0:r.cues)!=null&&t.length?Array.from(r.cues,s=>a0(s)):[]}function f0(i,e={label:c0}){var t,r;let s=yo(i,e.label,"chapters");if(!((t=s==null?void 0:s.activeCues)!=null&&t.length))return;if(s.activeCues.length===1)return a0(s.activeCues[0]);let{currentTime:n}=i,a=Array.prototype.find.call((r=s.activeCues)!=null?r:[],({startTime:o,endTime:l})=>o<=n&&l>n);return a0(a||s.activeCues[0])}async function BC(i,e=Z_){return new Promise(t=>{st(i,"loadstart",async()=>{let r=await h0(i,[],e);st(i,"cuechange",()=>{let s=f0(i);if(s){let n=new CustomEvent("chapterchange",{composed:!0,bubbles:!0,detail:s});i.dispatchEvent(n)}},{},r),t(r)})})}function eA(i,e){if(e){let t=e.playingDate;if(t!=null)return new Date(t.getTime()-i.currentTime*1e3)}return typeof i.getStartDate=="function"?i.getStartDate():new Date(NaN)}function tA(i,e){if(e&&e.playingDate)return e.playingDate;if(typeof i.getStartDate=="function"){let t=i.getStartDate();return new Date(t.getTime()+i.currentTime*1e3)}return new Date(NaN)}var $C=async i=>fetch(i).then(e=>e.text()).then(e=>{let t=e.split(`
1604
1604
  `).find((r,s,n)=>s&&n[s-1].startsWith("#EXT-X-STREAM-INF"));return fetch(t).then(r=>r.text()).then(r=>r.split(`
1605
- `))}),BC=i=>{var e,t,r;let s=(t=((e=i.find(l=>l.startsWith("#EXT-X-PLAYLIST-TYPE")))!=null?e:"").split(":")[1])==null?void 0:t.trim(),n=Y_(s),a=z_(s),o;if(n===ye.LIVE){let l=i.find(d=>d.startsWith("#EXT-X-PART-INF"));if(l)o=+l.split(":")[1].split("=")[1]*2;else{let d=i.find(c=>c.startsWith("#EXT-X-TARGETDURATION")),u=(r=d==null?void 0:d.split(":"))==null?void 0:r[1];o=+(u!=null?u:6)*3}}return{streamType:n,targetLiveWindow:a,liveEdgeStartOffset:o}},$C=async(i,e)=>{if(e===Or.MP4)return{streamType:ye.ON_DEMAND,targetLiveWindow:Number.NaN,liveEdgeStartOffset:void 0};if(e===Or.M3U8){let t=await FC(i);return BC(t)}return console.error(`Media type ${e} is an unrecognized or unsupported type for src ${i}.`),{streamType:void 0,targetLiveWindow:void 0,liveEdgeStartOffset:void 0}},Zg=async(i,e,t=vc({src:i}))=>{var r,s,n;let{streamType:a,targetLiveWindow:o,liveEdgeStartOffset:l}=await $C(i,t);((r=Et.get(e))!=null?r:{}).liveEdgeStartOffset=l,((s=Et.get(e))!=null?s:{}).targetLiveWindow=o,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((n=Et.get(e))!=null?n:{}).streamType=a,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},HC=i=>{var e;let t=i.type,r=Y_(t),s=z_(t),n,a=!!((e=i.partList)!=null&&e.length);return r===ye.LIVE&&(n=a?i.partTarget*2:i.targetduration*3),{streamType:r,targetLiveWindow:s,liveEdgeStartOffset:n,lowLatency:a}},GC=(i,e,t)=>{var r,s,n,a,o,l,d,u;let{streamType:c,targetLiveWindow:h,liveEdgeStartOffset:f,lowLatency:m}=HC(i);if(c===ye.LIVE){m?(t.config.backBufferLength=(r=t.userConfig.backBufferLength)!=null?r:4,t.config.maxFragLookUpTolerance=(s=t.userConfig.maxFragLookUpTolerance)!=null?s:.001,t.config.abrBandWidthUpFactor=(n=t.userConfig.abrBandWidthUpFactor)!=null?n:t.config.abrBandWidthFactor):t.config.backBufferLength=(a=t.userConfig.backBufferLength)!=null?a:8;let p=Object.freeze({get length(){return e.seekable.length},start(g){return e.seekable.start(g)},end(g){var E;return g>this.length||g<0||Number.isFinite(e.duration)?e.seekable.end(g):(E=t.liveSyncPosition)!=null?E:e.seekable.end(g)}});((o=Et.get(e))!=null?o:{}).seekable=p}((l=Et.get(e))!=null?l:{}).liveEdgeStartOffset=f,((d=Et.get(e))!=null?d:{}).targetLiveWindow=h,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((u=Et.get(e))!=null?u:{}).streamType=c,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},G_,W_,WC=(W_=(G_=globalThis==null?void 0:globalThis.navigator)==null?void 0:G_.userAgent)!=null?W_:"",VC=WC.toLowerCase().indexOf("android")!==-1,Et=new WeakMap,rA="mux.com",V_,K_,sA=(K_=(V_=Ve).isSupported)==null?void 0:K_.call(V_),KC=VC,nA=()=>xu.utils.now(),qC=xu.utils.generateUUID,To=({playbackId:i,customDomain:e=rA,maxResolution:t,minResolution:r,renditionOrder:s,programStartTime:n,programEndTime:a,tokens:{playback:o}={},extraSourceParams:l={}}={})=>{if(!i)return;let[d,u=""]=RC(i),c=new URL(`https://stream.${e}/${d}.m3u8${u}`);return o||c.searchParams.has("token")?(c.searchParams.forEach((h,f)=>{f!="token"&&c.searchParams.delete(f)}),o&&c.searchParams.set("token",o)):(t&&c.searchParams.set("max_resolution",t),r&&(c.searchParams.set("min_resolution",r),t&&+t.slice(0,-1)<+r.slice(0,-1)&&console.error("minResolution must be <= maxResolution","minResolution",r,"maxResolution",t)),s&&c.searchParams.set("rendition_order",s),n&&c.searchParams.set("program_start_time",`${n}`),a&&c.searchParams.set("program_end_time",`${a}`),Object.entries(l).forEach(([h,f])=>{f!=null&&c.searchParams.set(h,f)})),c.toString()},YC=i=>{if(!i)return;let[e]=i.split("?");return e||void 0},zC=i=>{if(!i||!i.startsWith("https://stream."))return;let[e]=new URL(i).pathname.slice(1).split(".m3u8");return e||void 0},jC=i=>{var e,t,r;return(e=i==null?void 0:i.metadata)!=null&&e.video_id?i.metadata.video_id:fA(i)&&(r=(t=YC(i.playbackId))!=null?t:zC(i.src))!=null?r:i.src},aA=i=>{var e;return(e=Et.get(i))==null?void 0:e.error},gc=i=>{var e,t;return(t=(e=Et.get(i))==null?void 0:e.streamType)!=null?t:ye.UNKNOWN},oA=i=>{var e,t;return(t=(e=Et.get(i))==null?void 0:e.targetLiveWindow)!=null?t:Number.NaN},bo=i=>{var e,t;return(t=(e=Et.get(i))==null?void 0:e.seekable)!=null?t:i.seekable},lA=i=>{var e;let t=(e=Et.get(i))==null?void 0:e.liveEdgeStartOffset;if(typeof t!="number")return Number.NaN;let r=bo(i);return r.length?r.end(r.length-1)-t:Number.NaN},u0=.034,XC=(i,e,t=u0)=>Math.abs(i-e)<=t,dA=(i,e,t=u0)=>i>e||XC(i,e,t),QC=(i,e=u0)=>i.paused&&dA(i.currentTime,i.duration,e),uA=(i,e)=>{var t,r,s;if(!e)return;if(i.readyState>2)return!1;let n=e.currentLevel>=0?(r=(t=e.levels)==null?void 0:t[e.currentLevel])==null?void 0:r.details:(s=e.levels.find(c=>!!c.details))==null?void 0:s.details;if(!n||n.live)return;let{fragments:a}=n;if(!(a!=null&&a.length))return;if(i.currentTime<i.duration-(n.targetduration+.5))return!1;let o=a[a.length-1];if(i.currentTime<=o.start)return!1;let l=o.start+o.duration/2,d=i.buffered.start(i.buffered.length-1),u=i.buffered.end(i.buffered.length-1);return l>d&&l<u},c0=(i,e)=>i.ended||i.loop?i.ended:e&&uA(i,e)?!0:QC(i),cA=(i,e,t)=>{h0(e,t);let{metadata:r={}}=i,{view_session_id:s=qC()}=r,n=jC(i);r.view_session_id=s,r.video_id=n,i.metadata=r,Et.set(e,{});let a=ZC(i,e),o=MC(i,e,a);eD(i,e,a),tD(i,e,a),NC(e),UC(e);let l=DC(i,e,a);return{engine:a,setAutoplay:l,setPreload:o}},h0=(i,e)=>{let t=e==null?void 0:e.engine;t&&(t.detachMedia(),t.destroy()),i!=null&&i.mux&&!i.mux.deleted&&(i.mux.destroy(),delete i.mux),i&&(i.removeAttribute("src"),i.load(),i.removeEventListener("error",pA),i.removeEventListener("error",r0),i.removeEventListener("durationchange",mA),Et.delete(i),i.dispatchEvent(new Event("teardown")))};function hA(i,e){var t;let r=vc(i);if(r!==Or.M3U8)return!0;let s=!r||((t=e.canPlayType(r))!=null?t:!0),{preferPlayback:n}=i,a=n===ei.MSE,o=n===ei.NATIVE;return s&&(o||!(sA&&(a||KC)))}var ZC=(i,e)=>{let{debug:t,streamType:r,startTime:s=-1,metadata:n,preferCmcd:a,_hlsConfig:o={}}=i,l=vc(i)===Or.M3U8,d=hA(i,e);if(l&&!d&&sA){let u={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelToPlayerSize:!0,capLevelOnFPSDrop:!0},c=JC(r),h=a!==pc.NONE?{useHeaders:a===pc.HEADER,sessionId:n==null?void 0:n.view_session_id,contentId:n==null?void 0:n.video_id}:void 0;return new Ve({debug:t,startPosition:s,cmcd:h,xhrSetup:(f,m)=>{var p,g;if(a&&a!==pc.QUERY)return;let E=new URL(m);if(!E.searchParams.has("CMCD"))return;let T=((g=(p=E.searchParams.get("CMCD"))==null?void 0:p.split(","))!=null?g:[]).filter(y=>y.startsWith("sid")||y.startsWith("cid")).join(",");E.searchParams.set("CMCD",T),f.open("GET",E)},...u,...c,...o})}},JC=i=>i===ye.LIVE?{backBufferLength:8}:{},fA=({playbackId:i,src:e,customDomain:t})=>{if(i)return!0;if(typeof e!="string")return!1;let r=window==null?void 0:window.location.href,s=new URL(e,r).hostname.toLocaleLowerCase();return s.includes(rA)||!!t&&s.includes(t.toLocaleLowerCase())},eD=(i,e,t)=>{var r;let{envKey:s,disableTracking:n}=i,a=fA(i);if(!n&&(s||a)){let{playerInitTime:o,playerSoftwareName:l,playerSoftwareVersion:d,beaconCollectionDomain:u,debug:c,disableCookies:h}=i,f={...i.metadata,video_title:((r=i==null?void 0:i.metadata)==null?void 0:r.video_title)||void 0},m=p=>typeof p.player_error_code=="string"?!1:typeof i.errorTranslator=="function"?i.errorTranslator(p):p;xu.monitor(e,{debug:c,beaconCollectionDomain:u,hlsjs:t,Hls:t?Ve:void 0,automaticErrorTracking:!1,errorTranslator:m,disableCookies:h,data:{...s?{env_key:s}:{},player_software_name:l,player_software:l,player_software_version:d,player_init_time:o,...f}})}},tD=(i,e,t)=>{var r;let s=hA(i,e),{src:n}=i,a=()=>{e.ended||!c0(e,t)||(uA(e,t)?e.currentTime=e.buffered.end(e.buffered.length-1):e.dispatchEvent(new Event("ended")))},o,l,d=()=>{var u,c;let h=(u=bo(e))==null?void 0:u.start(0),f=(c=bo(e))==null?void 0:c.end(0);(l!==f||o!==h)&&e.dispatchEvent(new CustomEvent("seekablechange",{composed:!0})),o=h,l=f};if(mt(e,"durationchange",d),e&&s){let u=vc(i);if(typeof n=="string"){let c=()=>{if(gc(e)!==ye.LIVE||Number.isFinite(e.duration))return;let h=setInterval(d,1e3);e.addEventListener("teardown",()=>{clearInterval(h)},{once:!0}),mt(e,"durationchange",()=>{Number.isFinite(e.duration)&&clearInterval(h)})};if(e.preload==="none"){let h=()=>{Zg(n,e,u).then(c),e.removeEventListener("loadedmetadata",f)},f=()=>{Zg(n,e,u).then(c),e.removeEventListener("play",h)};mt(e,"play",h,{once:!0}),mt(e,"loadedmetadata",f,{once:!0})}else Zg(n,e,u).then(c);e.setAttribute("src",n),i.startTime&&(((r=Et.get(e))!=null?r:{}).startTime=i.startTime,e.addEventListener("durationchange",mA,{once:!0}))}else e.removeAttribute("src");e.addEventListener("error",pA),e.addEventListener("error",r0),e.addEventListener("emptied",()=>{e.querySelectorAll("track[data-removeondestroy]").forEach(c=>{c.remove()})},{once:!0}),mt(e,"pause",a),mt(e,"seeked",a),mt(e,"play",()=>{e.ended||dA(e.currentTime,e.duration)&&(e.currentTime=e.seekable.start(0))})}else t&&n?(t.once(Ve.Events.LEVEL_LOADED,(u,c)=>{GC(c.details,e,t),d(),gc(e)===ye.LIVE&&!Number.isFinite(e.duration)&&(t.on(Ve.Events.LEVEL_UPDATED,d),mt(e,"durationchange",()=>{Number.isFinite(e.duration)&&t.off(Ve.Events.LEVELS_UPDATED,d)}))}),t.on(Ve.Events.ERROR,(u,c)=>{let h={[Ve.ErrorTypes.NETWORK_ERROR]:bt.MEDIA_ERR_NETWORK,[Ve.ErrorTypes.MEDIA_ERROR]:bt.MEDIA_ERR_DECODE},f=new bt("",h[c.type]);f.fatal=c.fatal,f.data=c,e.dispatchEvent(new CustomEvent("error",{detail:f}))}),e.addEventListener("error",r0),mt(e,"waiting",a),PC(i,t),OC(e,t),t.attachMedia(e)):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 mA(i){var e;let t=i.target,r=(e=Et.get(t))==null?void 0:e.startTime;if(r&&IC(t.seekable,t.duration,r)){let s=t.preload==="auto";s&&(t.preload="none"),t.currentTime=r,s&&(t.preload="auto")}}async function pA(i){if(!i.isTrusted)return;i.stopImmediatePropagation();let e=i.target;if(!(e!=null&&e.error))return;let{message:t,code:r}=e.error,s=new bt(t,r);if(e.src&&(r!==bt.MEDIA_ERR_DECODE||r!==void 0))try{let{status:n}=await fetch(e.src);s.data={response:{code:n}}}catch{}e.dispatchEvent(new CustomEvent("error",{detail:s}))}function r0(i){var e,t;if(!(i instanceof CustomEvent)||!(i.detail instanceof bt))return;let r=i.target,s=i.detail;!s||!s.fatal||(((e=Et.get(r))!=null?e:{}).error=s,(t=r.mux)==null||t.emit("error",{player_error_code:s.code,player_error_message:s.message,player_error_context:s.context}))}var iD=Object.defineProperty,rD=Object.getPrototypeOf,sD=Reflect.get,nD=(i,e,t)=>e in i?iD(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Me=(i,e,t)=>(nD(i,typeof e!="symbol"?e+"":e,t),t),N0=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},R=(i,e,t)=>(N0(i,e,"read from private field"),t?t.call(i):e.get(i)),j=(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)},J=(i,e,t,r)=>(N0(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),ze=(i,e,t)=>(N0(i,e,"access private method"),t),f0=(i,e,t)=>sD(rD(i),t,e),Mc=class{addEventListener(){}removeEventListener(){}dispatchEvent(i){return!0}};if(typeof DocumentFragment=="undefined"){class i extends Mc{}globalThis.DocumentFragment=i}var U0=class extends Mc{},aD=class extends Mc{},oD={get(i){},define(i,e,t){},upgrade(i){},whenDefined(i){return Promise.resolve(U0)}},bc,lD=class{constructor(i,e={}){j(this,bc,void 0),J(this,bc,e==null?void 0:e.detail)}get detail(){return R(this,bc)}initCustomEvent(){}};bc=new WeakMap;function dD(i,e){return new U0}var AA={document:{createElement:dD},DocumentFragment,customElements:oD,CustomEvent:lD,EventTarget:Mc,HTMLElement:U0,HTMLVideoElement:aD},SA=typeof window=="undefined"||typeof globalThis.customElements=="undefined",m0=SA?AA:globalThis,d5=SA?AA.document:globalThis.document,uD=()=>{try{return"0.19.0"}catch{}return"UNKNOWN"},cD=uD(),hD=()=>cD,Pc=["abort","canplay","canplaythrough","durationchange","emptied","encrypted","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting","waitingforkey","resize","enterpictureinpicture","leavepictureinpicture","webkitbeginfullscreen","webkitendfullscreen","webkitpresentationmodechanged"],gA,E0=(gA=globalThis.document)==null?void 0:gA.createElement("template");E0&&(E0.innerHTML=`
1605
+ `))}),HC=i=>{var e,t,r;let s=(t=((e=i.find(l=>l.startsWith("#EXT-X-PLAYLIST-TYPE")))!=null?e:"").split(":")[1])==null?void 0:t.trim(),n=q_(s),a=Y_(s),o;if(n===ye.LIVE){let l=i.find(d=>d.startsWith("#EXT-X-PART-INF"));if(l)o=+l.split(":")[1].split("=")[1]*2;else{let d=i.find(c=>c.startsWith("#EXT-X-TARGETDURATION")),u=(r=d==null?void 0:d.split(":"))==null?void 0:r[1];o=+(u!=null?u:6)*3}}return{streamType:n,targetLiveWindow:a,liveEdgeStartOffset:o}},GC=async(i,e)=>{if(e===Nr.MP4)return{streamType:ye.ON_DEMAND,targetLiveWindow:Number.NaN,liveEdgeStartOffset:void 0};if(e===Nr.M3U8){let t=await $C(i);return HC(t)}return console.error(`Media type ${e} is an unrecognized or unsupported type for src ${i}.`),{streamType:void 0,targetLiveWindow:void 0,liveEdgeStartOffset:void 0}},i0=async(i,e,t=yc({src:i}))=>{var r,s,n;let{streamType:a,targetLiveWindow:o,liveEdgeStartOffset:l}=await GC(i,t);((r=Et.get(e))!=null?r:{}).liveEdgeStartOffset=l,((s=Et.get(e))!=null?s:{}).targetLiveWindow=o,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((n=Et.get(e))!=null?n:{}).streamType=a,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},WC=i=>{var e;let t=i.type,r=q_(t),s=Y_(t),n,a=!!((e=i.partList)!=null&&e.length);return r===ye.LIVE&&(n=a?i.partTarget*2:i.targetduration*3),{streamType:r,targetLiveWindow:s,liveEdgeStartOffset:n,lowLatency:a}},KC=(i,e,t)=>{var r,s,n,a,o,l,d,u;let{streamType:c,targetLiveWindow:h,liveEdgeStartOffset:f,lowLatency:m}=WC(i);if(c===ye.LIVE){m?(t.config.backBufferLength=(r=t.userConfig.backBufferLength)!=null?r:4,t.config.maxFragLookUpTolerance=(s=t.userConfig.maxFragLookUpTolerance)!=null?s:.001,t.config.abrBandWidthUpFactor=(n=t.userConfig.abrBandWidthUpFactor)!=null?n:t.config.abrBandWidthFactor):t.config.backBufferLength=(a=t.userConfig.backBufferLength)!=null?a:8;let p=Object.freeze({get length(){return e.seekable.length},start(g){return e.seekable.start(g)},end(g){var E;return g>this.length||g<0||Number.isFinite(e.duration)?e.seekable.end(g):(E=t.liveSyncPosition)!=null?E:e.seekable.end(g)}});((o=Et.get(e))!=null?o:{}).seekable=p}((l=Et.get(e))!=null?l:{}).liveEdgeStartOffset=f,((d=Et.get(e))!=null?d:{}).targetLiveWindow=h,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((u=Et.get(e))!=null?u:{}).streamType=c,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},H_,G_,VC=(G_=(H_=globalThis==null?void 0:globalThis.navigator)==null?void 0:H_.userAgent)!=null?G_:"",qC=VC.toLowerCase().indexOf("android")!==-1,Et=new WeakMap,Or="mux.com",W_,K_,iA=(K_=(W_=Ve).isSupported)==null?void 0:K_.call(W_),YC=qC,rA=()=>xu.utils.now(),zC=xu.utils.generateUUID,To=({playbackId:i,customDomain:e=Or,maxResolution:t,minResolution:r,renditionOrder:s,programStartTime:n,programEndTime:a,tokens:{playback:o}={},extraSourceParams:l={}}={})=>{if(!i)return;let[d,u=""]=CC(i),c=new URL(`https://stream.${e}/${d}.m3u8${u}`);return o||c.searchParams.has("token")?(c.searchParams.forEach((h,f)=>{f!="token"&&c.searchParams.delete(f)}),o&&c.searchParams.set("token",o)):(t&&c.searchParams.set("max_resolution",t),r&&(c.searchParams.set("min_resolution",r),t&&+t.slice(0,-1)<+r.slice(0,-1)&&console.error("minResolution must be <= maxResolution","minResolution",r,"maxResolution",t)),s&&c.searchParams.set("rendition_order",s),n&&c.searchParams.set("program_start_time",`${n}`),a&&c.searchParams.set("program_end_time",`${a}`),Object.entries(l).forEach(([h,f])=>{f!=null&&c.searchParams.set(h,f)})),c.toString()},jC=i=>{if(!i)return;let[e]=i.split("?");return e||void 0},_c=i=>{if(!i||!i.startsWith("https://stream."))return;let[e]=new URL(i).pathname.slice(1).split(".m3u8");return e||void 0},XC=i=>{var e,t,r;return(e=i==null?void 0:i.metadata)!=null&&e.video_id?i.metadata.video_id:hA(i)&&(r=(t=jC(i.playbackId))!=null?t:_c(i.src))!=null?r:i.src},sA=i=>{var e;return(e=Et.get(i))==null?void 0:e.error},bc=i=>{var e,t;return(t=(e=Et.get(i))==null?void 0:e.streamType)!=null?t:ye.UNKNOWN},nA=i=>{var e,t;return(t=(e=Et.get(i))==null?void 0:e.targetLiveWindow)!=null?t:Number.NaN},bo=i=>{var e,t;return(t=(e=Et.get(i))==null?void 0:e.seekable)!=null?t:i.seekable},aA=i=>{var e;let t=(e=Et.get(i))==null?void 0:e.liveEdgeStartOffset;if(typeof t!="number")return Number.NaN;let r=bo(i);return r.length?r.end(r.length-1)-t:Number.NaN},m0=.034,QC=(i,e,t=m0)=>Math.abs(i-e)<=t,oA=(i,e,t=m0)=>i>e||QC(i,e,t),ZC=(i,e=m0)=>i.paused&&oA(i.currentTime,i.duration,e),lA=(i,e)=>{var t,r,s;if(!e||!i.buffered.length)return;if(i.readyState>2)return!1;let n=e.currentLevel>=0?(r=(t=e.levels)==null?void 0:t[e.currentLevel])==null?void 0:r.details:(s=e.levels.find(c=>!!c.details))==null?void 0:s.details;if(!n||n.live)return;let{fragments:a}=n;if(!(a!=null&&a.length))return;if(i.currentTime<i.duration-(n.targetduration+.5))return!1;let o=a[a.length-1];if(i.currentTime<=o.start)return!1;let l=o.start+o.duration/2,d=i.buffered.start(i.buffered.length-1),u=i.buffered.end(i.buffered.length-1);return l>d&&l<u},p0=(i,e)=>i.ended||i.loop?i.ended:e&&lA(i,e)?!0:ZC(i),dA=(i,e,t)=>{g0(e,t);let{metadata:r={}}=i,{view_session_id:s=zC()}=r,n=XC(i);r.view_session_id=s,r.video_id=n,i.metadata=r,Et.set(e,{});let a=JC(i,e),o=OC(i,e,a);nD(i,e,a),aD(i,e,a),FC(e),BC(e);let l=PC(i,e,a);return{engine:a,setAutoplay:l,setPreload:o}},g0=(i,e)=>{let t=e==null?void 0:e.engine;t&&(t.detachMedia(),t.destroy()),i!=null&&i.mux&&!i.mux.deleted&&(i.mux.destroy(),delete i.mux),i&&(i.removeAttribute("src"),i.load(),i.removeEventListener("error",mA),i.removeEventListener("error",o0),i.removeEventListener("durationchange",fA),Et.delete(i),i.dispatchEvent(new Event("teardown")))};function uA(i,e){var t;let r=yc(i);if(r!==Nr.M3U8)return!0;let s=!r||((t=e.canPlayType(r))!=null?t:!0),{preferPlayback:n}=i,a=n===ei.MSE,o=n===ei.NATIVE;return s&&(o||!(iA&&(a||YC)))}var JC=(i,e)=>{let{debug:t,streamType:r,startTime:s=-1,metadata:n,preferCmcd:a,_hlsConfig:o={}}=i,l=yc(i)===Nr.M3U8,d=uA(i,e);if(l&&!d&&iA){let u={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelToPlayerSize:!0,capLevelOnFPSDrop:!0},c=eD(r),h=tD(i),f=a!==vc.NONE?{useHeaders:a===vc.HEADER,sessionId:n==null?void 0:n.view_session_id,contentId:n==null?void 0:n.video_id}:void 0;return new Ve({debug:t,startPosition:s,cmcd:f,xhrSetup:(m,p)=>{var g,E;if(a&&a!==vc.QUERY)return;let T=new URL(p);if(!T.searchParams.has("CMCD"))return;let y=((E=(g=T.searchParams.get("CMCD"))==null?void 0:g.split(","))!=null?E:[]).filter(S=>S.startsWith("sid")||S.startsWith("cid")).join(",");T.searchParams.set("CMCD",y),m.open("GET",T)},...u,...c,...h,...o})}},eD=i=>i===ye.LIVE?{backBufferLength:8}:{},tD=i=>{let{drmToken:e,src:t,playbackId:r=_c(t)}=i;return!e||!r?{}:{emeEnabled:!0,drmSystems:{"com.apple.fps":{licenseUrl:Ec(i,"fairplay"),serverCertificateUrl:cA(i,"fairplay")},"com.widevine.alpha":{licenseUrl:Ec(i,"widevine")},"com.microsoft.playready":{licenseUrl:Ec(i,"playready")}},requestMediaKeySystemAccessFunc:(s,n)=>(s==="com.widevine.alpha"&&(n=[...n.map(a=>{var o;let l=(o=a.videoCapabilities)==null?void 0:o.map(d=>({...d,robustness:"HW_SECURE_ALL"}));return{...a,videoCapabilities:l}}),...n]),navigator.requestMediaKeySystemAccess(s,n))}},iD=async i=>await(await fetch(i)).arrayBuffer(),rD=async(i,e)=>{let t=await(await fetch(e,{method:"POST",headers:{"Content-type":"application/octet-stream"},body:i})).arrayBuffer();return new Uint8Array(t)},sD=(i,e)=>{st(e,"encrypted",async t=>{try{let r=t.initDataType;if(r!=="skd"){console.error(`Received unexpected initialization data type "${r}"`);return}if(!e.mediaKeys){let l=await(await navigator.requestMediaKeySystemAccess("com.apple.fps",[{initDataTypes:[r],videoCapabilities:[{contentType:"application/vnd.apple.mpegurl",robustness:""}],distinctiveIdentifier:"not-allowed",persistentState:"not-allowed",sessionTypes:["temporary"]}])).createMediaKeys(),d=await iD(cA(i,"fairplay"));await l.setServerCertificate(d),await e.setMediaKeys(l)}let s=t.initData;if(s==null){console.error(`Could not start encrypted playback due to missing initData in ${t.type} event`);return}let n=e.mediaKeys.createSession();n.generateRequest(r,s);let a=await new Promise(l=>{n.addEventListener("message",d=>{l(d.message)},{once:!0})}),o=await rD(a,Ec(i,"fairplay"));return await n.update(o),n}catch(r){console.error(`Could not start encrypted playback due to exception "${r}"`)}})},Ec=({playbackId:i,drmToken:e,customDomain:t=Or},r)=>`https://license.${t.toLocaleLowerCase().endsWith(Or)?t:Or}/license/${r}/${i}?token=${e}`,cA=({playbackId:i,drmToken:e,customDomain:t=Or},r)=>`https://license.${t.toLocaleLowerCase().endsWith(Or)?t:Or}/appcert/${r}/${i}?token=${e}`,hA=({playbackId:i,src:e,customDomain:t})=>{if(i)return!0;if(typeof e!="string")return!1;let r=window==null?void 0:window.location.href,s=new URL(e,r).hostname.toLocaleLowerCase();return s.includes(Or)||!!t&&s.includes(t.toLocaleLowerCase())},nD=(i,e,t)=>{var r;let{envKey:s,disableTracking:n}=i,a=hA(i);if(!n&&(s||a)){let{playerInitTime:o,playerSoftwareName:l,playerSoftwareVersion:d,beaconCollectionDomain:u,debug:c,disableCookies:h}=i,f={...i.metadata,video_title:((r=i==null?void 0:i.metadata)==null?void 0:r.video_title)||void 0},m=p=>typeof p.player_error_code=="string"?!1:typeof i.errorTranslator=="function"?i.errorTranslator(p):p;xu.monitor(e,{debug:c,beaconCollectionDomain:u,hlsjs:t,Hls:t?Ve:void 0,automaticErrorTracking:!1,errorTranslator:m,disableCookies:h,data:{...s?{env_key:s}:{},player_software_name:l,player_software:l,player_software_version:d,player_init_time:o,...f}})}},aD=(i,e,t)=>{var r;let s=uA(i,e),{src:n}=i,a=()=>{e.ended||!p0(e,t)||(lA(e,t)?e.currentTime=e.buffered.end(e.buffered.length-1):e.dispatchEvent(new Event("ended")))},o,l,d=()=>{var u,c;let h=(u=bo(e))==null?void 0:u.start(0),f=(c=bo(e))==null?void 0:c.end(0);(l!==f||o!==h)&&e.dispatchEvent(new CustomEvent("seekablechange",{composed:!0})),o=h,l=f};if(st(e,"durationchange",d),e&&s){let u=yc(i);if(typeof n=="string"){let c=()=>{if(bc(e)!==ye.LIVE||Number.isFinite(e.duration))return;let h=setInterval(d,1e3);e.addEventListener("teardown",()=>{clearInterval(h)},{once:!0}),st(e,"durationchange",()=>{Number.isFinite(e.duration)&&clearInterval(h)})};if(e.preload==="none"){let h=()=>{i0(n,e,u).then(c),e.removeEventListener("loadedmetadata",f)},f=()=>{i0(n,e,u).then(c),e.removeEventListener("play",h)};st(e,"play",h,{once:!0}),st(e,"loadedmetadata",f,{once:!0})}else i0(n,e,u).then(c);i.drmToken&&sD(i,e),e.setAttribute("src",n),i.startTime&&(((r=Et.get(e))!=null?r:{}).startTime=i.startTime,e.addEventListener("durationchange",fA,{once:!0}))}else e.removeAttribute("src");e.addEventListener("error",mA),e.addEventListener("error",o0),e.addEventListener("emptied",()=>{e.querySelectorAll("track[data-removeondestroy]").forEach(c=>{c.remove()})},{once:!0}),st(e,"pause",a),st(e,"seeked",a),st(e,"play",()=>{e.ended||oA(e.currentTime,e.duration)&&(e.currentTime=e.seekable.start(0))})}else t&&n?(t.once(Ve.Events.LEVEL_LOADED,(u,c)=>{KC(c.details,e,t),d(),bc(e)===ye.LIVE&&!Number.isFinite(e.duration)&&(t.on(Ve.Events.LEVEL_UPDATED,d),st(e,"durationchange",()=>{Number.isFinite(e.duration)&&t.off(Ve.Events.LEVELS_UPDATED,d)}))}),t.on(Ve.Events.ERROR,(u,c)=>{let h={[Ve.ErrorTypes.NETWORK_ERROR]:bt.MEDIA_ERR_NETWORK,[Ve.ErrorTypes.MEDIA_ERROR]:bt.MEDIA_ERR_DECODE},f=new bt("",h[c.type]);f.fatal=c.fatal,f.data=c,e.dispatchEvent(new CustomEvent("error",{detail:f}))}),e.addEventListener("error",o0),st(e,"waiting",a),NC(i,t),UC(e,t),t.attachMedia(e)):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 fA(i){var e;let t=i.target,r=(e=Et.get(t))==null?void 0:e.startTime;if(r&&wC(t.seekable,t.duration,r)){let s=t.preload==="auto";s&&(t.preload="none"),t.currentTime=r,s&&(t.preload="auto")}}async function mA(i){if(!i.isTrusted)return;i.stopImmediatePropagation();let e=i.target;if(!(e!=null&&e.error))return;let{message:t,code:r}=e.error,s=new bt(t,r);if(e.src&&(r!==bt.MEDIA_ERR_DECODE||r!==void 0))try{let{status:n}=await fetch(e.src);s.data={response:{code:n}}}catch{}e.dispatchEvent(new CustomEvent("error",{detail:s}))}function o0(i){var e,t;if(!(i instanceof CustomEvent)||!(i.detail instanceof bt))return;let r=i.target,s=i.detail;!s||!s.fatal||(((e=Et.get(r))!=null?e:{}).error=s,(t=r.mux)==null||t.emit("error",{player_error_code:s.code,player_error_message:s.message,player_error_context:s.context}))}var oD=Object.defineProperty,lD=Object.getPrototypeOf,dD=Reflect.get,uD=(i,e,t)=>e in i?oD(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Ce=(i,e,t)=>(uD(i,typeof e!="symbol"?e+"":e,t),t),F0=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},R=(i,e,t)=>(F0(i,e,"read from private field"),t?t.call(i):e.get(i)),X=(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)},ee=(i,e,t,r)=>(F0(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),Be=(i,e,t)=>(F0(i,e,"access private method"),t),v0=(i,e,t)=>dD(lD(i),t,e),Uc=class{addEventListener(){}removeEventListener(){}dispatchEvent(i){return!0}};if(typeof DocumentFragment=="undefined"){class i extends Uc{}globalThis.DocumentFragment=i}var B0=class extends Uc{},cD=class extends Uc{},hD={get(i){},define(i,e,t){},upgrade(i){},whenDefined(i){return Promise.resolve(B0)}},Ac,fD=class{constructor(i,e={}){X(this,Ac,void 0),ee(this,Ac,e==null?void 0:e.detail)}get detail(){return R(this,Ac)}initCustomEvent(){}};Ac=new WeakMap;function mD(i,e){return new B0}var _A={document:{createElement:mD},DocumentFragment,customElements:hD,CustomEvent:fD,EventTarget:Uc,HTMLElement:B0,HTMLVideoElement:cD},AA=typeof window=="undefined"||typeof globalThis.customElements=="undefined",E0=AA?_A:globalThis,E5=AA?_A.document:globalThis.document,pD=()=>{try{return"0.20.0"}catch{}return"UNKNOWN"},gD=pD(),vD=()=>gD,Fc=["abort","canplay","canplaythrough","durationchange","emptied","encrypted","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting","waitingforkey","resize","enterpictureinpicture","leavepictureinpicture","webkitbeginfullscreen","webkitendfullscreen","webkitpresentationmodechanged"];function ED(i){return`
1606
1606
  <style>
1607
1607
  :host {
1608
1608
  display: inline-flex;
@@ -1615,9 +1615,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1615
1615
  width: 100%;
1616
1616
  }
1617
1617
  </style>
1618
- <slot name="media"></slot>
1618
+ <slot name="media">
1619
+ <audio${xA(i)}></audio>
1620
+ </slot>
1619
1621
  <slot></slot>
1620
- `);var vA,b0=(vA=globalThis.document)==null?void 0:vA.createElement("template");b0&&(b0.innerHTML=`
1622
+ `}function bD(i){return`
1621
1623
  <style>
1622
1624
  :host {
1623
1625
  display: inline-block;
@@ -1638,10 +1640,12 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1638
1640
  transition: var(--media-webkit-text-track-transition);
1639
1641
  }
1640
1642
  </style>
1641
- <slot name="media"></slot>
1643
+ <slot name="media">
1644
+ <video${xA(i)}></video>
1645
+ </slot>
1642
1646
  <slot></slot>
1643
- `);var xA=(i,{tag:e,is:t})=>{var r,s,n,a,o,l,d,u,c,h,f,m,p,g,E,T;let y=(r=globalThis.document)==null?void 0:r.createElement(e,{is:t}),S=y?fD(y):[];return s=class extends i{constructor(){super(),j(this,c),j(this,f),j(this,p),j(this,E),j(this,l,void 0),j(this,d,void 0),j(this,u,new Map),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.append(this.constructor.template.content.cloneNode(!0)))}static get observedAttributes(){var _,L,x;return ze(_=s,a,o).call(_),[...(x=(L=y==null?void 0:y.constructor)==null?void 0:L.observedAttributes)!=null?x:[],"autopictureinpicture","disablepictureinpicture","disableremoteplayback","autoplay","controls","controlslist","crossorigin","loop","muted","playsinline","poster","preload","src"]}get nativeEl(){var _,L,x;return(x=(L=(_=R(this,d))!=null?_:this.shadowRoot.querySelector(e))!=null?L:this.querySelector(":scope > [slot=media]"))!=null?x:this.querySelector(e)}set nativeEl(_){J(this,d,_)}get defaultMuted(){return this.hasAttribute("muted")}set defaultMuted(_){this.toggleAttribute("muted",!!_)}get src(){return this.getAttribute("src")}set src(_){this.setAttribute("src",`${_}`)}get preload(){var _,L;return(L=this.getAttribute("preload"))!=null?L:(_=this.nativeEl)==null?void 0:_.preload}set preload(_){this.setAttribute("preload",`${_}`)}init(){var _,L;if(!this.nativeEl){let x=document.createElement(e,{is:t});x.part=e,this.shadowRoot.querySelector('slot[name="media"]').append(x)}this.nativeEl.muted=this.hasAttribute("muted");for(let x of S)ze(this,p,g).call(this,x);this.shadowRoot.addEventListener("slotchange",this);for(let x of this.constructor.Events)(L=(_=this.shadowRoot).addEventListener)==null||L.call(_,x,this,!0)}handleEvent(_){if(_.type==="slotchange"){ze(this,f,m).call(this);return}_.target===this.nativeEl&&this.dispatchEvent(new CustomEvent(_.type,{detail:_.detail}))}attributeChangedCallback(_,L,x){ze(this,c,h).call(this),ze(this,E,T).call(this,_,L,x)}connectedCallback(){ze(this,c,h).call(this)}},n=new WeakMap,a=new WeakSet,o=function(){if(R(this,n))return;J(this,n,!0);let _=new Set(this.observedAttributes);_.delete("muted");for(let L of S)if(!(L in this.prototype))if(typeof y[L]=="function")this.prototype[L]=function(...x){return ze(this,c,h).call(this),this.call?this.call(L,...x):this.nativeEl[L].apply(this.nativeEl,x)};else{let x={get(){var w,M,k;ze(this,c,h).call(this);let D=L.toLowerCase();if(_.has(D)){let U=this.getAttribute(D);return U===null?!1:U===""?!0:U}return(k=(w=this.get)==null?void 0:w.call(this,L))!=null?k:(M=this.nativeEl)==null?void 0:M[L]}};L!==L.toUpperCase()&&(x.set=function(w){ze(this,c,h).call(this);let M=L.toLowerCase();if(_.has(M)){w===!0||w===!1||w==null?this.toggleAttribute(M,!!w):this.setAttribute(M,w);return}if(this.set){this.set(L,w);return}this.nativeEl[L]=w}),Object.defineProperty(this.prototype,L,x)}},l=new WeakMap,d=new WeakMap,u=new WeakMap,c=new WeakSet,h=function(){R(this,l)||(J(this,l,!0),this.init())},f=new WeakSet,m=function(){let _=new Map(R(this,u));this.shadowRoot.querySelector("slot:not([name])").assignedElements().filter(L=>["track","source"].includes(L.localName)).forEach(L=>{var x,w;_.delete(L);let M=R(this,u).get(L);M||(M=L.cloneNode(),R(this,u).set(L,M)),(w=(x=this.nativeEl).append)==null||w.call(x,M),M.localName==="track"&&M.default&&(M.kind==="chapters"||M.kind==="metadata")&&M.track.mode==="disabled"&&(M.track.mode="hidden")}),_.forEach(L=>L.remove())},p=new WeakSet,g=function(_){if(Object.prototype.hasOwnProperty.call(this,_)){let L=this[_];delete this[_],this[_]=L}},E=new WeakSet,T=function(_,L,x){var w,M,k,D,U,B;["id","class"].includes(_)||!s.observedAttributes.includes(_)&&this.constructor.observedAttributes.includes(_)||(x===null?(M=(w=this.nativeEl).removeAttribute)==null||M.call(w,_):((D=(k=this.nativeEl).getAttribute)==null?void 0:D.call(k,_))!=x&&((B=(U=this.nativeEl).setAttribute)==null||B.call(U,_,x)))},j(s,a),Me(s,"Events",Pc),Me(s,"template",e.endsWith("audio")?E0:b0),j(s,n,void 0),s};function fD(i){let e=[];for(let t=Object.getPrototypeOf(i);t&&t!==HTMLElement.prototype;t=Object.getPrototypeOf(t))e.push(...Object.getOwnPropertyNames(t));return e}var p0=globalThis.document?xA(HTMLElement,{tag:"video"}):class{},c5=globalThis.document?xA(HTMLElement,{tag:"audio"}):class{},Gs=new WeakMap,g0=class extends Error{},mD=class extends Error{},pD=globalThis.WeakRef?class extends Set{add(i){super.add(new WeakRef(i))}forEach(i){super.forEach(e=>{let t=e.deref();t&&i(t)})}}:Set;function gD(i){LA()?kA()?i(chrome.cast.isAvailable):customElements.whenDefined("google-cast-button").then(()=>i(chrome.cast.isAvailable)):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(()=>i(chrome.cast.isAvailable))}}function vD(){return globalThis.chrome}function ED(){let i="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1";if(globalThis.chrome.cast||document.querySelector(`script[src="${i}"]`))return;let e=document.createElement("script");e.src=i,document.head.append(e)}function LA(){return typeof chrome!="undefined"&&chrome.cast&&chrome.cast.isAvailable}function kA(){return typeof cast!="undefined"&&cast.framework}function Ws(){if(kA())return cast.framework.CastContext.getInstance()}function F0(){var i;return(i=Ws())==null?void 0:i.getCurrentSession()}function B0(){var i;return(i=F0())==null?void 0:i.getSessionObj().media[0]}function bD(i){return new Promise((e,t)=>{B0().editTracksInfo(i,e,t)})}function yD(i){return new Promise((e,t)=>{B0().getStatus(i,e,t)})}function IA(i){return Ws().setOptions({...RA(),...i})}function RA(){return{receiverApplicationId:"CC1AD845",autoJoinPolicy:"origin_scoped",androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0}}var yc=new pD,Fr=new WeakSet,st;gD(i=>{i&&!st&&(st=cast.framework,Ws().addEventListener(st.CastContextEventType.CAST_STATE_CHANGED,e=>{yc.forEach(t=>{var r,s;return(s=(r=Gs.get(t)).onCastStateChanged)==null?void 0:s.call(r,e)})}),Ws().addEventListener(st.CastContextEventType.SESSION_STATE_CHANGED,e=>{yc.forEach(t=>{var r,s;return(s=(r=Gs.get(t)).onSessionStateChanged)==null?void 0:s.call(r,e)})}),yc.forEach(e=>{var t,r;return(r=(t=Gs.get(e)).init)==null?void 0:r.call(t)}))});var EA=0,xe,Tc,ti,Nr,Jn,jn,Hs,y0,Ur,Is,T0,bA,Cc,_0,A0,wA,_c,S0,x0,yA,Ac,v0,TD=class extends EventTarget{constructor(i){super(),j(this,Ur),j(this,T0),j(this,Cc),j(this,A0),j(this,_c),j(this,x0),j(this,Ac),j(this,xe,void 0),j(this,Tc,void 0),j(this,ti,void 0),j(this,Nr,void 0),j(this,Jn,"disconnected"),j(this,jn,!1),j(this,Hs,new Set),j(this,y0,new WeakMap),J(this,xe,i),yc.add(this),Gs.set(this,{init:()=>ze(this,_c,S0).call(this),onCastStateChanged:()=>ze(this,Cc,_0).call(this),onSessionStateChanged:()=>ze(this,A0,wA).call(this),getCastPlayer:()=>R(this,Ur,Is)}),ze(this,_c,S0).call(this)}get state(){return R(this,Jn)}async watchAvailability(i){if(R(this,xe).disableRemotePlayback)throw new g0("disableRemotePlayback attribute is present.");return R(this,y0).set(i,++EA),R(this,Hs).add(i),EA}async cancelWatchAvailability(i){if(R(this,xe).disableRemotePlayback)throw new g0("disableRemotePlayback attribute is present.");i?R(this,Hs).delete(i):R(this,Hs).clear()}async prompt(){var i,e;if(R(this,xe).disableRemotePlayback)throw new g0("disableRemotePlayback attribute is present.");if(!LA())throw new mD("The RemotePlayback API is disabled on this platform.");let t=Fr.has(R(this,xe));Fr.add(R(this,xe)),IA(R(this,xe).castOptions),Object.entries(R(this,Nr)).forEach(([r,s])=>{R(this,ti).controller.addEventListener(r,s)});try{await Ws().requestSession()}catch(r){if(r==="cancel"){t||Fr.delete(R(this,xe));return}throw new Error(r)}(e=(i=Gs.get(R(this,xe)))==null?void 0:i.loadOnPrompt)==null||e.call(i)}};xe=new WeakMap,Tc=new WeakMap,ti=new WeakMap,Nr=new WeakMap,Jn=new WeakMap,jn=new WeakMap,Hs=new WeakMap,y0=new WeakMap,Ur=new WeakSet,Is=function(){if(Fr.has(R(this,xe)))return R(this,ti)},T0=new WeakSet,bA=function(){Fr.has(R(this,xe))&&(Object.entries(R(this,Nr)).forEach(([i,e])=>{R(this,ti).controller.removeEventListener(i,e)}),Fr.delete(R(this,xe)),R(this,xe).muted=R(this,ti).isMuted,R(this,xe).currentTime=R(this,ti).savedPlayerState.currentTime,R(this,ti).savedPlayerState.isPaused===!1&&R(this,xe).play())},Cc=new WeakSet,_0=function(){let i=Ws().getCastState();if(Fr.has(R(this,xe))&&i==="CONNECTING"&&(J(this,Jn,"connecting"),this.dispatchEvent(new Event("connecting"))),!R(this,jn)&&i!=null&&i.includes("CONNECT")){J(this,jn,!0);for(let e of R(this,Hs))e(!0)}else if(R(this,jn)&&(!i||i==="NO_DEVICES_AVAILABLE")){J(this,jn,!1);for(let e of R(this,Hs))e(!1)}},A0=new WeakSet,wA=async function(){var i;let{SESSION_RESUMED:e}=st.SessionState;if(Ws().getSessionState()===e&&R(this,xe).castSrc===((i=B0())==null?void 0:i.media.contentId)){Fr.add(R(this,xe)),Object.entries(R(this,Nr)).forEach(([t,r])=>{R(this,ti).controller.addEventListener(t,r)});try{await yD(new chrome.cast.media.GetStatusRequest)}catch(t){console.error(t)}R(this,Nr)[st.RemotePlayerEventType.IS_PAUSED_CHANGED](),R(this,Nr)[st.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},_c=new WeakSet,S0=function(){!st||R(this,Tc)||(J(this,Tc,!0),IA(R(this,xe).castOptions),R(this,xe).textTracks.addEventListener("change",()=>ze(this,Ac,v0).call(this)),ze(this,Cc,_0).call(this),J(this,ti,new st.RemotePlayer),new st.RemotePlayerController(R(this,ti)),J(this,Nr,{[st.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:i})=>{i===!0?(J(this,Jn,"connected"),this.dispatchEvent(new Event("connect"))):(ze(this,T0,bA).call(this),J(this,Jn,"disconnected"),this.dispatchEvent(new Event("disconnect")))},[st.RemotePlayerEventType.DURATION_CHANGED]:()=>{R(this,xe).dispatchEvent(new Event("durationchange"))},[st.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]:()=>{R(this,xe).dispatchEvent(new Event("volumechange"))},[st.RemotePlayerEventType.IS_MUTED_CHANGED]:()=>{R(this,xe).dispatchEvent(new Event("volumechange"))},[st.RemotePlayerEventType.CURRENT_TIME_CHANGED]:()=>{var i;(i=R(this,Ur,Is))!=null&&i.isMediaLoaded&&R(this,xe).dispatchEvent(new Event("timeupdate"))},[st.RemotePlayerEventType.VIDEO_INFO_CHANGED]:()=>{R(this,xe).dispatchEvent(new Event("resize"))},[st.RemotePlayerEventType.IS_PAUSED_CHANGED]:()=>{R(this,xe).dispatchEvent(new Event(this.paused?"pause":"play"))},[st.RemotePlayerEventType.PLAYER_STATE_CHANGED]:()=>{var i,e;((i=R(this,Ur,Is))==null?void 0:i.playerState)!==chrome.cast.media.PlayerState.PAUSED&&R(this,xe).dispatchEvent(new Event({[chrome.cast.media.PlayerState.PLAYING]:"playing",[chrome.cast.media.PlayerState.BUFFERING]:"waiting",[chrome.cast.media.PlayerState.IDLE]:"emptied"}[(e=R(this,Ur,Is))==null?void 0:e.playerState]))},[st.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{var i;(i=R(this,Ur,Is))!=null&&i.isMediaLoaded&&(await Promise.resolve(),ze(this,x0,yA).call(this))}}))},x0=new WeakSet,yA=function(){ze(this,Ac,v0).call(this)},Ac=new WeakSet,v0=async function(){var i,e,t,r,s;if(!R(this,Ur,Is))return;let n=((e=(i=R(this,ti).mediaInfo)==null?void 0:i.tracks)!=null?e:[]).filter(({type:h})=>h===chrome.cast.media.TrackType.TEXT),a=[...R(this,xe).textTracks].filter(({kind:h})=>h==="subtitles"||h==="captions"),o=n.map(({language:h,name:f,trackId:m})=>{var p;let{mode:g}=(p=a.find(E=>E.language===h&&E.label===f))!=null?p:{};return g?{mode:g,trackId:m}:!1}).filter(Boolean),l=o.filter(({mode:h})=>h!=="showing").map(({trackId:h})=>h),d=o.find(({mode:h})=>h==="showing"),u=(s=(r=(t=F0())==null?void 0:t.getSessionObj().media[0])==null?void 0:r.activeTrackIds)!=null?s:[],c=u;if(u.length&&(c=c.filter(h=>!l.includes(h))),d!=null&&d.trackId&&(c=[...c,d.trackId]),c=[...new Set(c)],!((h,f)=>h.length===f.length&&h.every(m=>f.includes(m)))(u,c))try{let h=new chrome.cast.media.EditTracksInfoRequest(c);await bD(h)}catch(h){console.error(h)}};var _D=i=>{var e,t,r,s,n,a,o,l,d;return t=class extends i{constructor(){super(...arguments),j(this,a),j(this,l),j(this,r,{paused:!1}),j(this,s,RA()),j(this,n,void 0)}get remote(){return R(this,n)?R(this,n):vD()?(ED(),Gs.set(this,{loadOnPrompt:()=>ze(this,l,d).call(this)}),J(this,n,new TD(this))):super.remote}attributeChangedCallback(u,c,h){if(super.attributeChangedCallback(u,c,h),u==="cast-receiver"&&h){R(this,s).receiverApplicationId=h;return}if(R(this,a,o))switch(u){case"cast-stream-type":case"cast-src":this.load();break}}async load(){var u,c;if(!R(this,a,o))return super.load();let h=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType),f=[...this.querySelectorAll("track")].filter(({kind:E,src:T})=>T&&(E==="subtitles"||E==="captions")),m=[],p=0;f.length&&(h.tracks=f.map(E=>{let T=++p;m.length===0&&E.track.mode==="showing"&&m.push(T);let y=new chrome.cast.media.Track(T,chrome.cast.media.TrackType.TEXT);return y.trackContentId=E.src,y.trackContentType="text/vtt",y.subtype=E.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,y.name=E.label,y.language=E.srclang,y})),this.castStreamType==="live"?h.streamType=chrome.cast.media.StreamType.LIVE:h.streamType=chrome.cast.media.StreamType.BUFFERED,h.metadata=new chrome.cast.media.GenericMediaMetadata,h.metadata.title=this.title,h.metadata.images=[{url:this.poster}];let g=new chrome.cast.media.LoadRequest(h);g.currentTime=(u=super.currentTime)!=null?u:0,g.autoplay=!R(this,r).paused,g.activeTrackIds=m,await((c=F0())==null?void 0:c.loadMedia(g)),this.dispatchEvent(new Event("volumechange"))}play(){var u;if(R(this,a,o)){R(this,a,o).isPaused&&((u=R(this,a,o).controller)==null||u.playOrPause());return}return super.play()}pause(){var u;if(R(this,a,o)){R(this,a,o).isPaused||(u=R(this,a,o).controller)==null||u.playOrPause();return}super.pause()}get castOptions(){return R(this,s)}get castReceiver(){var u;return(u=this.getAttribute("cast-receiver"))!=null?u:void 0}set castReceiver(u){this.castReceiver!=u&&this.setAttribute("cast-receiver",`${u}`)}get castSrc(){var u,c,h;return(h=(c=this.getAttribute("cast-src"))!=null?c:(u=this.querySelector("source"))==null?void 0:u.src)!=null?h:this.currentSrc}set castSrc(u){this.castSrc!=u&&this.setAttribute("cast-src",`${u}`)}get castContentType(){var u;return(u=this.getAttribute("cast-content-type"))!=null?u:void 0}set castContentType(u){this.setAttribute("cast-content-type",`${u}`)}get castStreamType(){var u,c;return(c=(u=this.getAttribute("cast-stream-type"))!=null?u:this.streamType)!=null?c:void 0}set castStreamType(u){this.setAttribute("cast-stream-type",`${u}`)}get readyState(){if(R(this,a,o))switch(R(this,a,o).playerState){case chrome.cast.media.PlayerState.IDLE:return 0;case chrome.cast.media.PlayerState.BUFFERING:return 2;default:return 3}return super.readyState}get paused(){return R(this,a,o)?R(this,a,o).isPaused:super.paused}get muted(){var u;return R(this,a,o)?(u=R(this,a,o))==null?void 0:u.isMuted:super.muted}set muted(u){var c;if(R(this,a,o)){(u&&!R(this,a,o).isMuted||!u&&R(this,a,o).isMuted)&&((c=R(this,a,o).controller)==null||c.muteOrUnmute());return}super.muted=u}get volume(){var u,c;return R(this,a,o)?(c=(u=R(this,a,o))==null?void 0:u.volumeLevel)!=null?c:1:super.volume}set volume(u){var c;if(R(this,a,o)){R(this,a,o).volumeLevel=+u,(c=R(this,a,o).controller)==null||c.setVolumeLevel();return}super.volume=u}get duration(){var u,c,h;return R(this,a,o)&&(u=R(this,a,o))!=null&&u.isMediaLoaded?(h=(c=R(this,a,o))==null?void 0:c.duration)!=null?h:NaN:super.duration}get currentTime(){var u,c,h;return R(this,a,o)&&(u=R(this,a,o))!=null&&u.isMediaLoaded?(h=(c=R(this,a,o))==null?void 0:c.currentTime)!=null?h:0:super.currentTime}set currentTime(u){var c;if(R(this,a,o)){R(this,a,o).currentTime=u,(c=R(this,a,o).controller)==null||c.seek();return}super.currentTime=u}},r=new WeakMap,s=new WeakMap,n=new WeakMap,a=new WeakSet,o=function(){var u,c;return(c=(u=Gs.get(this.remote))==null?void 0:u.getCastPlayer)==null?void 0:c.call(u)},l=new WeakSet,d=async function(){R(this,r).paused=f0(t.prototype,this,"paused"),f0(t.prototype,this,"pause").call(this),this.muted=f0(t.prototype,this,"muted");try{await this.load()}catch(u){console.error(u)}},Me(t,"observedAttributes",[...(e=i.observedAttributes)!=null?e:[],"cast-src","cast-content-type","cast-stream-type","cast-receiver"]),t},Oc=class extends Event{constructor(i,e){super(i),Me(this,"track"),this.track=e.track}},L0=new WeakMap;function K(i){var e;return(e=L0.get(i))!=null?e:AD(i,{})}function AD(i,e){let t=L0.get(i);return t||L0.set(i,t={}),Object.assign(t,e)}function k0(i,e){let t=i.videoTracks;K(e).media=i,K(e).renditionSet||(K(e).renditionSet=new Set);let r=K(t).trackSet;r.add(e);let s=r.size-1;s in R0.prototype||Object.defineProperty(R0.prototype,s,{get(){return[...K(this).trackSet][s]}}),queueMicrotask(()=>{t.dispatchEvent(new Oc("addtrack",{track:e}))})}function I0(i){var e;let t=(e=K(i).media)==null?void 0:e.videoTracks;t&&(K(t).trackSet.delete(i),queueMicrotask(()=>{t.dispatchEvent(new Oc("removetrack",{track:i}))}))}function SD(i){var e;let t=(e=K(i).media.videoTracks)!=null?e:[],r=!1;for(let s of t)s!==i&&(s.selected=!1,r=!0);if(r){if(K(t).changeRequested)return;K(t).changeRequested=!0,queueMicrotask(()=>{delete K(t).changeRequested,t.dispatchEvent(new Event("change"))})}}var Rs,ws,Cs,Xn,_o,R0=class extends EventTarget{constructor(){super(),j(this,Xn),j(this,Rs,void 0),j(this,ws,void 0),j(this,Cs,void 0),K(this).trackSet=new Set}[Symbol.iterator](){return R(this,Xn,_o).values()}get length(){return R(this,Xn,_o).size}getTrackById(i){var e;return(e=[...R(this,Xn,_o)].find(t=>t.id===i))!=null?e:null}get selectedIndex(){return[...R(this,Xn,_o)].findIndex(i=>i.selected)}get onaddtrack(){return R(this,Rs)}set onaddtrack(i){R(this,Rs)&&(this.removeEventListener("addtrack",R(this,Rs)),J(this,Rs,void 0)),typeof i=="function"&&(J(this,Rs,i),this.addEventListener("addtrack",i))}get onremovetrack(){return R(this,ws)}set onremovetrack(i){R(this,ws)&&(this.removeEventListener("removetrack",R(this,ws)),J(this,ws,void 0)),typeof i=="function"&&(J(this,ws,i),this.addEventListener("removetrack",i))}get onchange(){return R(this,Cs)}set onchange(i){R(this,Cs)&&(this.removeEventListener("change",R(this,Cs)),J(this,Cs,void 0)),typeof i=="function"&&(J(this,Cs,i),this.addEventListener("change",i))}};Rs=new WeakMap,ws=new WeakMap,Cs=new WeakMap,Xn=new WeakSet,_o=function(){return K(this).trackSet};var Nc=class extends Event{constructor(i,e){super(i),Me(this,"rendition"),this.rendition=e.rendition}};function xD(i,e){let t=K(i).media.videoRenditions;K(e).media=K(i).media,K(e).track=i;let r=K(i).renditionSet;r.add(e);let s=r.size-1;s in w0.prototype||Object.defineProperty(w0.prototype,s,{get(){return Qn(this)[s]}}),queueMicrotask(()=>{i.selected&&t.dispatchEvent(new Nc("addrendition",{rendition:e}))})}function LD(i){let e=K(i).media.videoRenditions,t=K(i).track;K(t).renditionSet.delete(i),queueMicrotask(()=>{K(i).track.selected&&e.dispatchEvent(new Nc("removerendition",{rendition:i}))})}function kD(i){let e=K(i).media.videoRenditions;!e||K(e).changeRequested||(K(e).changeRequested=!0,queueMicrotask(()=>{delete K(e).changeRequested,K(i).track.selected&&e.dispatchEvent(new Event("change"))}))}function Qn(i){return[...K(i).media.videoTracks].filter(e=>e.selected).flatMap(e=>[...K(e).renditionSet])}var Ds,Ms,Ps,w0=class extends EventTarget{constructor(){super(...arguments),j(this,Ds,void 0),j(this,Ms,void 0),j(this,Ps,void 0)}[Symbol.iterator](){return Qn(this).values()}get length(){return Qn(this).length}getRenditionById(i){var e;return(e=Qn(this).find(t=>`${t.id}`==`${i}`))!=null?e:null}get selectedIndex(){return Qn(this).findIndex(i=>i.selected)}set selectedIndex(i){for(let[e,t]of Qn(this).entries())t.selected=e===i}get onaddrendition(){return R(this,Ds)}set onaddrendition(i){R(this,Ds)&&(this.removeEventListener("addrendition",R(this,Ds)),J(this,Ds,void 0)),typeof i=="function"&&(J(this,Ds,i),this.addEventListener("addrendition",i))}get onremoverendition(){return R(this,Ms)}set onremoverendition(i){R(this,Ms)&&(this.removeEventListener("removerendition",R(this,Ms)),J(this,Ms,void 0)),typeof i=="function"&&(J(this,Ms,i),this.addEventListener("removerendition",i))}get onchange(){return R(this,Ps)}set onchange(i){R(this,Ps)&&(this.removeEventListener("change",R(this,Ps)),J(this,Ps,void 0)),typeof i=="function"&&(J(this,Ps,i),this.addEventListener("change",i))}};Ds=new WeakMap,Ms=new WeakMap,Ps=new WeakMap;var Ao,ID=class{constructor(){Me(this,"src"),Me(this,"id"),Me(this,"width"),Me(this,"height"),Me(this,"bitrate"),Me(this,"frameRate"),Me(this,"codec"),j(this,Ao,!1)}get selected(){return R(this,Ao)}set selected(i){R(this,Ao)!==i&&(J(this,Ao,i),kD(this))}};Ao=new WeakMap;var So,CA=class{constructor(){Me(this,"id"),Me(this,"kind"),Me(this,"label",""),Me(this,"language",""),Me(this,"sourceBuffer"),j(this,So,!1)}addRendition(i,e,t,r,s,n){let a=new ID;return a.src=i,a.width=e,a.height=t,a.frameRate=n,a.bitrate=s,a.codec=r,xD(this,a),a}removeRendition(i){LD(i)}get selected(){return R(this,So)}set selected(i){R(this,So)!==i&&(J(this,So,i),i===!0&&SD(this))}};So=new WeakMap;function RD(i,e){let t=K(i).media.audioRenditions;K(e).media=K(i).media,K(e).track=i;let r=K(i).renditionSet;r.add(e);let s=r.size-1;s in C0.prototype||Object.defineProperty(C0.prototype,s,{get(){return Zn(this)[s]}}),queueMicrotask(()=>{i.enabled&&t.dispatchEvent(new Nc("addrendition",{rendition:e}))})}function wD(i){let e=K(i).media.audioRenditions,t=K(i).track;K(t).renditionSet.delete(i),queueMicrotask(()=>{K(i).track.enabled&&e.dispatchEvent(new Nc("removerendition",{rendition:i}))})}function CD(i){let e=K(i).media.audioRenditions;!e||K(e).changeRequested||(K(e).changeRequested=!0,queueMicrotask(()=>{delete K(e).changeRequested,K(i).track.enabled&&e.dispatchEvent(new Event("change"))}))}function Zn(i){return[...K(i).media.audioTracks].filter(e=>e.enabled).flatMap(e=>[...K(e).renditionSet])}var Os,Ns,Us,C0=class extends EventTarget{constructor(){super(...arguments),j(this,Os,void 0),j(this,Ns,void 0),j(this,Us,void 0)}[Symbol.iterator](){return Zn(this).values()}get length(){return Zn(this).length}getRenditionById(i){var e;return(e=Zn(this).find(t=>`${t.id}`==`${i}`))!=null?e:null}get selectedIndex(){return Zn(this).findIndex(i=>i.selected)}set selectedIndex(i){for(let[e,t]of Zn(this).entries())t.selected=e===i}get onaddrendition(){return R(this,Os)}set onaddrendition(i){R(this,Os)&&(this.removeEventListener("addrendition",R(this,Os)),J(this,Os,void 0)),typeof i=="function"&&(J(this,Os,i),this.addEventListener("addrendition",i))}get onremoverendition(){return R(this,Ns)}set onremoverendition(i){R(this,Ns)&&(this.removeEventListener("removerendition",R(this,Ns)),J(this,Ns,void 0)),typeof i=="function"&&(J(this,Ns,i),this.addEventListener("removerendition",i))}get onchange(){return R(this,Us)}set onchange(i){R(this,Us)&&(this.removeEventListener("change",R(this,Us)),J(this,Us,void 0)),typeof i=="function"&&(J(this,Us,i),this.addEventListener("change",i))}};Os=new WeakMap,Ns=new WeakMap,Us=new WeakMap;var xo,DD=class{constructor(){Me(this,"src"),Me(this,"id"),Me(this,"bitrate"),Me(this,"codec"),j(this,xo,!1)}get selected(){return R(this,xo)}set selected(i){R(this,xo)!==i&&(J(this,xo,i),CD(this))}};xo=new WeakMap;function D0(i,e){let t=i.audioTracks;K(e).media=i,K(e).renditionSet||(K(e).renditionSet=new Set);let r=K(t).trackSet;r.add(e);let s=r.size-1;s in P0.prototype||Object.defineProperty(P0.prototype,s,{get(){return[...K(this).trackSet][s]}}),queueMicrotask(()=>{t.dispatchEvent(new Oc("addtrack",{track:e}))})}function M0(i){var e;let t=(e=K(i).media)==null?void 0:e.audioTracks;t&&(K(t).trackSet.delete(i),queueMicrotask(()=>{t.dispatchEvent(new Oc("removetrack",{track:i}))}))}function MD(i){let e=K(i).media.audioTracks;!e||K(e).changeRequested||(K(e).changeRequested=!0,queueMicrotask(()=>{delete K(e).changeRequested,e.dispatchEvent(new Event("change"))}))}var Fs,Bs,$s,Lo,Sc,P0=class extends EventTarget{constructor(){super(),j(this,Lo),j(this,Fs,void 0),j(this,Bs,void 0),j(this,$s,void 0),K(this).trackSet=new Set}[Symbol.iterator](){return R(this,Lo,Sc).values()}get length(){return R(this,Lo,Sc).size}getTrackById(i){var e;return(e=[...R(this,Lo,Sc)].find(t=>t.id===i))!=null?e:null}get onaddtrack(){return R(this,Fs)}set onaddtrack(i){R(this,Fs)&&(this.removeEventListener("addtrack",R(this,Fs)),J(this,Fs,void 0)),typeof i=="function"&&(J(this,Fs,i),this.addEventListener("addtrack",i))}get onremovetrack(){return R(this,Bs)}set onremovetrack(i){R(this,Bs)&&(this.removeEventListener("removetrack",R(this,Bs)),J(this,Bs,void 0)),typeof i=="function"&&(J(this,Bs,i),this.addEventListener("removetrack",i))}get onchange(){return R(this,$s)}set onchange(i){R(this,$s)&&(this.removeEventListener("change",R(this,$s)),J(this,$s,void 0)),typeof i=="function"&&(J(this,$s,i),this.addEventListener("change",i))}};Fs=new WeakMap,Bs=new WeakMap,$s=new WeakMap,Lo=new WeakSet,Sc=function(){return K(this).trackSet};var ko,DA=class{constructor(){Me(this,"id"),Me(this,"kind"),Me(this,"label",""),Me(this,"language",""),Me(this,"sourceBuffer"),j(this,ko,!1)}addRendition(i,e,t){let r=new DD;return r.src=i,r.codec=e,r.bitrate=t,RD(this,r),r}removeRendition(i){wD(i)}get enabled(){return R(this,ko)}set enabled(i){R(this,ko)!==i&&(J(this,ko,i),MD(this))}};ko=new WeakMap;var TA=Dc(globalThis.HTMLMediaElement,"video"),_A=Dc(globalThis.HTMLMediaElement,"audio");function PD(i){if(!(i!=null&&i.prototype))return i;let e=Dc(i,"video");(!e||`${e}`.includes("[native code]"))&&Object.defineProperty(i.prototype,"videoTracks",{get(){return OD(this)}});let t=Dc(i,"audio");(!t||`${t}`.includes("[native code]"))&&Object.defineProperty(i.prototype,"audioTracks",{get(){return ND(this)}}),"addVideoTrack"in i.prototype||(i.prototype.addVideoTrack=function(n,a="",o=""){let l=new CA;return l.kind=n,l.label=a,l.language=o,k0(this,l),l}),"removeVideoTrack"in i.prototype||(i.prototype.removeVideoTrack=I0),"addAudioTrack"in i.prototype||(i.prototype.addAudioTrack=function(n,a="",o=""){let l=new DA;return l.kind=n,l.label=a,l.language=o,D0(this,l),l}),"removeAudioTrack"in i.prototype||(i.prototype.removeAudioTrack=M0),"videoRenditions"in i.prototype||Object.defineProperty(i.prototype,"videoRenditions",{get(){return r(this)}});let r=n=>{let a=K(n).videoRenditions;return a||(a=new w0,K(a).media=n,K(n).videoRenditions=a),a};"audioRenditions"in i.prototype||Object.defineProperty(i.prototype,"audioRenditions",{get(){return s(this)}});let s=n=>{let a=K(n).audioRenditions;return a||(a=new C0,K(a).media=n,K(n).audioRenditions=a),a};return i}function Dc(i,e){var t;if(i!=null&&i.prototype)return(t=Object.getOwnPropertyDescriptor(i.prototype,`${e}Tracks`))==null?void 0:t.get}function OD(i){var e;let t=K(i).videoTracks;if(!t&&(t=new R0,K(i).videoTracks=t,TA)){let r=TA.call((e=i.nativeEl)!=null?e:i);for(let s of r)k0(i,s);r.addEventListener("change",()=>{t.dispatchEvent(new Event("change"))}),r.addEventListener("addtrack",s=>{if([...t].some(n=>n instanceof CA)){for(let n of r)I0(n);return}k0(i,s.track)}),r.addEventListener("removetrack",s=>{I0(s.track)})}return t}function ND(i){var e;let t=K(i).audioTracks;if(!t&&(t=new P0,K(i).audioTracks=t,_A)){let r=_A.call((e=i.nativeEl)!=null?e:i);for(let s of r)D0(i,s);r.addEventListener("change",()=>{t.dispatchEvent(new Event("change"))}),r.addEventListener("addtrack",s=>{if([...t].some(n=>n instanceof DA)){for(let n of r)M0(n);return}D0(i,s.track)}),r.addEventListener("removetrack",s=>{M0(s.track)})}return t}Pc.push("castchange","entercast","leavecast");var P={BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",CUSTOM_DOMAIN:"custom-domain",DEBUG:"debug",DISABLE_TRACKING:"disable-tracking",DISABLE_COOKIES:"disable-cookies",ENV_KEY:"env-key",MAX_RESOLUTION:"max-resolution",MIN_RESOLUTION:"min-resolution",RENDITION_ORDER:"rendition-order",PROGRAM_START_TIME:"program-start-time",PROGRAM_END_TIME:"program-end-time",METADATA_URL:"metadata-url",PLAYBACK_ID:"playback-id",PLAYER_SOFTWARE_NAME:"player-software-name",PLAYER_SOFTWARE_VERSION:"player-software-version",PREFER_CMCD:"prefer-cmcd",PREFER_PLAYBACK:"prefer-playback",START_TIME:"start-time",STREAM_TYPE:"stream-type",TARGET_LIVE_WINDOW:"target-live-window",LIVE_EDGE_OFFSET:"live-edge-offset",TYPE:"type"},UD=Object.values(P),FD=hD(),BD="mux-video",Ji,Io,xc,Ro,Lc,kc,Ic,Rc,wo,wc,$D=class extends p0{constructor(){super(),j(this,wo),j(this,Ji,void 0),j(this,Io,void 0),j(this,xc,void 0),j(this,Ro,{}),j(this,Lc,void 0),j(this,kc,void 0),j(this,Ic,void 0),j(this,Rc,void 0),J(this,xc,nA())}static get observedAttributes(){var i;return[...UD,...(i=p0.observedAttributes)!=null?i:[]]}get preferCmcd(){var i;return(i=this.getAttribute(P.PREFER_CMCD))!=null?i:void 0}set preferCmcd(i){i!==this.preferCmcd&&(i?zn.includes(i)?this.setAttribute(P.PREFER_CMCD,i):console.warn(`Invalid value for preferCmcd. Must be one of ${zn.join()}`):this.removeAttribute(P.PREFER_CMCD))}get playerInitTime(){return R(this,xc)}get playerSoftwareName(){var i;return(i=R(this,Ic))!=null?i:BD}set playerSoftwareName(i){J(this,Ic,i)}get playerSoftwareVersion(){var i;return(i=R(this,kc))!=null?i:FD}set playerSoftwareVersion(i){J(this,kc,i)}get _hls(){var i;return(i=R(this,Ji))==null?void 0:i.engine}get mux(){var i;return(i=this.nativeEl)==null?void 0:i.mux}get error(){var i;return(i=aA(this.nativeEl))!=null?i:null}get errorTranslator(){return R(this,Rc)}set errorTranslator(i){J(this,Rc,i)}get src(){return this.getAttribute("src")}set src(i){i!==this.src&&(i==null?this.removeAttribute("src"):this.setAttribute("src",i))}get type(){var i;return(i=this.getAttribute(P.TYPE))!=null?i:void 0}set type(i){i!==this.type&&(i?this.setAttribute(P.TYPE,i):this.removeAttribute(P.TYPE))}get autoplay(){let i=this.getAttribute("autoplay");return i===null?!1:i===""?!0:i}set autoplay(i){let e=this.autoplay;i!==e&&(i?this.setAttribute("autoplay",typeof i=="string"?i:""):this.removeAttribute("autoplay"))}get preload(){let i=this.getAttribute("preload");return i===""?"auto":["none","metadata","auto"].includes(i)?i:super.preload}set preload(i){i!=this.getAttribute("preload")&&(["","none","metadata","auto"].includes(i)?this.setAttribute("preload",i):this.removeAttribute("preload"))}get debug(){return this.getAttribute(P.DEBUG)!=null}set debug(i){i!==this.debug&&(i?this.setAttribute(P.DEBUG,""):this.removeAttribute(P.DEBUG))}get disableTracking(){return this.hasAttribute(P.DISABLE_TRACKING)}set disableTracking(i){i!==this.disableTracking&&this.toggleAttribute(P.DISABLE_TRACKING,!!i)}get disableCookies(){return this.hasAttribute(P.DISABLE_COOKIES)}set disableCookies(i){i!==this.disableCookies&&(i?this.setAttribute(P.DISABLE_COOKIES,""):this.removeAttribute(P.DISABLE_COOKIES))}get startTime(){let i=this.getAttribute(P.START_TIME);if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}set startTime(i){i!==this.startTime&&(i==null?this.removeAttribute(P.START_TIME):this.setAttribute(P.START_TIME,`${i}`))}get playbackId(){var i;return(i=this.getAttribute(P.PLAYBACK_ID))!=null?i:void 0}set playbackId(i){i!==this.playbackId&&(i?this.setAttribute(P.PLAYBACK_ID,i):this.removeAttribute(P.PLAYBACK_ID))}get maxResolution(){var i;return(i=this.getAttribute(P.MAX_RESOLUTION))!=null?i:void 0}set maxResolution(i){i!==this.maxResolution&&(i?this.setAttribute(P.MAX_RESOLUTION,i):this.removeAttribute(P.MAX_RESOLUTION))}get minResolution(){var i;return(i=this.getAttribute(P.MIN_RESOLUTION))!=null?i:void 0}set minResolution(i){i!==this.minResolution&&(i?this.setAttribute(P.MIN_RESOLUTION,i):this.removeAttribute(P.MIN_RESOLUTION))}get renditionOrder(){var i;return(i=this.getAttribute(P.RENDITION_ORDER))!=null?i:void 0}set renditionOrder(i){i!==this.renditionOrder&&(i?this.setAttribute(P.RENDITION_ORDER,i):this.removeAttribute(P.RENDITION_ORDER))}get programStartTime(){let i=this.getAttribute(P.PROGRAM_START_TIME);if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}set programStartTime(i){i==null?this.removeAttribute(P.PROGRAM_START_TIME):this.setAttribute(P.PROGRAM_START_TIME,`${i}`)}get programEndTime(){let i=this.getAttribute(P.PROGRAM_END_TIME);if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}set programEndTime(i){i==null?this.removeAttribute(P.PROGRAM_END_TIME):this.setAttribute(P.PROGRAM_END_TIME,`${i}`)}get customDomain(){var i;return(i=this.getAttribute(P.CUSTOM_DOMAIN))!=null?i:void 0}set customDomain(i){i!==this.customDomain&&(i?this.setAttribute(P.CUSTOM_DOMAIN,i):this.removeAttribute(P.CUSTOM_DOMAIN))}get ended(){return c0(this.nativeEl,this._hls)}get envKey(){var i;return(i=this.getAttribute(P.ENV_KEY))!=null?i:void 0}set envKey(i){i!==this.envKey&&(i?this.setAttribute(P.ENV_KEY,i):this.removeAttribute(P.ENV_KEY))}get beaconCollectionDomain(){var i;return(i=this.getAttribute(P.BEACON_COLLECTION_DOMAIN))!=null?i:void 0}set beaconCollectionDomain(i){i!==this.beaconCollectionDomain&&(i?this.setAttribute(P.BEACON_COLLECTION_DOMAIN,i):this.removeAttribute(P.BEACON_COLLECTION_DOMAIN))}get streamType(){var i;return(i=this.getAttribute(P.STREAM_TYPE))!=null?i:gc(this.nativeEl)}set streamType(i){i!==this.streamType&&(i?this.setAttribute(P.STREAM_TYPE,i):this.removeAttribute(P.STREAM_TYPE))}get targetLiveWindow(){return this.hasAttribute(P.TARGET_LIVE_WINDOW)?+this.getAttribute(P.TARGET_LIVE_WINDOW):oA(this.nativeEl)}set targetLiveWindow(i){i!=this.targetLiveWindow&&(i==null?this.removeAttribute(P.TARGET_LIVE_WINDOW):this.setAttribute(P.TARGET_LIVE_WINDOW,`${+i}`))}get liveEdgeStart(){var i,e;if(this.hasAttribute(P.LIVE_EDGE_OFFSET)){let{liveEdgeOffset:t}=this,r=(i=this.nativeEl.seekable.end(0))!=null?i:0,s=(e=this.nativeEl.seekable.start(0))!=null?e:0;return Math.max(s,r-t)}return lA(this.nativeEl)}get liveEdgeOffset(){if(this.hasAttribute(P.LIVE_EDGE_OFFSET))return+this.getAttribute(P.LIVE_EDGE_OFFSET)}set liveEdgeOffset(i){i!=this.targetLiveWindow&&(i==null?this.removeAttribute(P.LIVE_EDGE_OFFSET):this.setAttribute(P.LIVE_EDGE_OFFSET,`${+i}`))}get seekable(){return bo(this.nativeEl)}async addCuePoints(i){return n0(this.nativeEl,i)}get activeCuePoint(){return a0(this.nativeEl)}get cuePoints(){return Z_(this.nativeEl)}async addChapters(i){return l0(this.nativeEl,i)}get activeChapter(){return d0(this.nativeEl)}get chapters(){return eA(this.nativeEl)}getStartDate(){return tA(this.nativeEl,this._hls)}get currentPdt(){return iA(this.nativeEl,this._hls)}get preferPlayback(){let i=this.getAttribute(P.PREFER_PLAYBACK);if(i===ei.MSE||i===ei.NATIVE)return i}set preferPlayback(i){i!==this.preferPlayback&&(i===ei.MSE||i===ei.NATIVE?this.setAttribute(P.PREFER_PLAYBACK,i):this.removeAttribute(P.PREFER_PLAYBACK))}get metadata(){return{...this.getAttributeNames().filter(i=>i.startsWith("metadata-")&&![P.METADATA_URL].includes(i)).reduce((i,e)=>{let t=this.getAttribute(e);return t!=null&&(i[e.replace(/^metadata-/,"").replace(/-/g,"_")]=t),i},{}),...R(this,Ro)}}set metadata(i){J(this,Ro,i!=null?i:{}),this.mux&&this.mux.emit("hb",R(this,Ro))}get _hlsConfig(){return R(this,Lc)}set _hlsConfig(i){J(this,Lc,i)}load(){J(this,Ji,cA(this,this.nativeEl,R(this,Ji)))}unload(){h0(this.nativeEl,R(this,Ji)),J(this,Ji,void 0)}attributeChangedCallback(i,e,t){var r,s;switch(p0.observedAttributes.includes(i)&&!["src","autoplay","preload"].includes(i)&&super.attributeChangedCallback(i,e,t),i){case P.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=t!=null?t:void 0;break;case P.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=t!=null?t:void 0;break;case"src":{let n=!!e,a=!!t;!n&&a?ze(this,wo,wc).call(this):n&&!a?this.unload():n&&a&&(this.unload(),ze(this,wo,wc).call(this));break}case"autoplay":if(t===e)break;(r=R(this,Ji))==null||r.setAutoplay(this.autoplay);break;case"preload":if(t===e)break;(s=R(this,Ji))==null||s.setPreload(t);break;case P.PLAYBACK_ID:this.src=To(this);break;case P.DEBUG:{let n=this.debug;this.mux&&console.info("Cannot toggle debug mode of mux data after initialization. Make sure you set all metadata to override before setting the src."),this._hls&&(this._hls.config.debug=n);break}case P.METADATA_URL:t&&fetch(t).then(n=>n.json()).then(n=>this.metadata=n).catch(()=>console.error(`Unable to load or parse metadata JSON from metadata-url ${t}!`));break;case P.STREAM_TYPE:(t==null||t!==e)&&this.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}));break;case P.TARGET_LIVE_WINDOW:(t==null||t!==e)&&this.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0,detail:this.targetLiveWindow}));break;default:break}}connectedCallback(){var i;(i=super.connectedCallback)==null||i.call(this),this.nativeEl&&this.src&&!R(this,Ji)&&ze(this,wo,wc).call(this)}disconnectedCallback(){this.unload()}};Ji=new WeakMap,Io=new WeakMap,xc=new WeakMap,Ro=new WeakMap,Lc=new WeakMap,kc=new WeakMap,Ic=new WeakMap,Rc=new WeakMap,wo=new WeakSet,wc=async function(){R(this,Io)||(await J(this,Io,Promise.resolve()),J(this,Io,null),this.load())};var O0=class extends _D(PD($D)){};m0.customElements.get("mux-video")||(m0.customElements.define("mux-video",O0),m0.MuxVideoElement=O0);var MA=O0;var HD="en",Vs={code:HD};var PA="en";function ce(i,e=!0){var s,n;let t=e&&(n=(s=Vs)==null?void 0:s[i])!=null?n:i,r=e?Vs.code:PA;return new $0(t,r)}var $0=class{constructor(e,t=(r=>(r=Vs.code)!=null?r:PA)()){this.message=e,this.locale=t}format(e){return this.message.replace(/\{(\w+)\}/g,(t,r)=>{var s;return(s=e[r])!=null?s:""})}toString(){return this.message}};function OA(i){let e="";return Object.entries(i).forEach(([t,r])=>{r!=null&&(e+=`${Uc(t)}: ${r}; `)}),e?e.trim():void 0}function Uc(i){return i.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function Fc(i){return i.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase())}function ii(i){if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}function H0(i){let e=GD(i).toString();return e?"?"+e:""}function GD(i){let e={};for(let t in i)i[t]!=null&&(e[t]=i[t]);return new URLSearchParams(e)}function Br(i){let e=(i!=null?i:"").split(".")[1];if(!e)return{};let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=decodeURIComponent(atob(t).split("").map(function(s){return"%"+("00"+s.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(r)}var G0=(i,e)=>!i||!e?!1:i.contains(e)?!0:G0(i,e.getRootNode().host);var NA="mux.com",WD=()=>{try{return"2.7.0"}catch{}return"UNKNOWN"},VD=WD(),$c=()=>VD,UA=(i,{token:e,customDomain:t=NA,thumbnailTime:r,programTime:s}={})=>{let n=e==null?r:void 0,{aud:a}=Br(e);if(!(e&&a!=="t"))return`https://image.${t}/${i}/thumbnail.webp${H0({token:e,time:n,program_time:s})}`},FA=(i,{token:e,customDomain:t=NA,programStartTime:r,programEndTime:s}={})=>{let{aud:n}=Br(e);if(!(e&&n!=="s"))return`https://image.${t}/${i}/storyboard.vtt${H0({token:e,format:"webp",program_start_time:r,program_end_time:s})}`},Co=i=>{if(i){if([ye.LIVE,ye.ON_DEMAND].includes(i))return i;if(i!=null&&i.includes("live"))return ye.LIVE}};var KD={crossorigin:"crossOrigin",playsinline:"playsInline"};function BA(i){var e;return(e=KD[i])!=null?e:Fc(i)}var Ks,qs,It,Bc=class{constructor(e,t){Xe(this,Ks,void 0);Xe(this,qs,void 0);Xe(this,It,[]);Vt(this,Ks,e),Vt(this,qs,t)}[Symbol.iterator](){return Ee(this,It).values()}get length(){return Ee(this,It).length}get value(){var e;return(e=Ee(this,It).join(" "))!=null?e:""}set value(e){var t;e!==this.value&&(Vt(this,It,[]),this.add(...(t=e==null?void 0:e.split(" "))!=null?t:[]))}toString(){return this.value}item(e){return Ee(this,It)[e]}values(){return Ee(this,It).values()}keys(){return Ee(this,It).keys()}forEach(e){Ee(this,It).forEach(e)}add(...e){var t,r;e.forEach(s=>{this.contains(s)||Ee(this,It).push(s)}),!(this.value===""&&!((t=Ee(this,Ks))!=null&&t.hasAttribute(`${Ee(this,qs)}`)))&&((r=Ee(this,Ks))==null||r.setAttribute(`${Ee(this,qs)}`,`${this.value}`))}remove(...e){var t;e.forEach(r=>{Ee(this,It).splice(Ee(this,It).indexOf(r),1)}),(t=Ee(this,Ks))==null||t.setAttribute(`${Ee(this,qs)}`,`${this.value}`)}contains(e){return Ee(this,It).includes(e)}toggle(e,t){return typeof t!="undefined"?t?(this.add(e),!0):(this.remove(e),!1):this.contains(e)?(this.remove(e),!1):(this.add(e),!0)}replace(e,t){this.remove(e),this.add(t)}};Ks=new WeakMap,qs=new WeakMap,It=new WeakMap;var $A=`[mux-player ${$c()}]`;function $r(...i){console.warn($A,...i)}function Wt(...i){console.error($A,...i)}function W0(i){var t;let e=(t=i.message)!=null?t:"";if(i.context&&(e+=` ${i.context}`),i.file){let r="https://github.com/muxinc/elements/blob/main/errors/";e+=` ${ce("Read more: ")}
1644
- ${r}${i.file}`}$r(e)}var Lt={AUTOPLAY:"autoplay",CROSSORIGIN:"crossorigin",LOOP:"loop",MUTED:"muted",PLAYSINLINE:"playsinline",PRELOAD:"preload"},Ys={VOLUME:"volume",PLAYBACKRATE:"playbackrate",MUTED:"muted"},GA=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}}),qD=Pc.filter(i=>i!=="error"),YD=Object.values(Lt).filter(i=>![Lt.PLAYSINLINE].includes(i)),zD=Object.values(Ys);function WA(i){i.querySelectorAll(":scope > track").forEach(e=>{var t;(t=i.media)==null||t.append(e.cloneNode())}),qD.forEach(e=>{var t;(t=i.media)==null||t.addEventListener(e,r=>{i.dispatchEvent(new Event(r.type))})})}var V0=class extends $e.HTMLElement{static get observedAttributes(){return[...YD,...zD]}constructor(){super(),this.querySelectorAll(":scope > track").forEach(r=>{var s;(s=this.media)==null||s.append(r.cloneNode())});let e=r=>{for(let s of r)s.type==="childList"&&(s.removedNodes.forEach(n=>{var o,l;let a=(o=this.media)==null?void 0:o.querySelector(`track[src="${n.src}"]`);a&&((l=this.media)==null||l.removeChild(a))}),s.addedNodes.forEach(n=>{var a;(a=this.media)==null||a.append(n.cloneNode())}))};new MutationObserver(e).observe(this,{childList:!0,subtree:!0})}attributeChangedCallback(e,t,r){var s,n;switch(e){case Ys.MUTED:{this.media&&(this.media.muted=r!=null,this.media.defaultMuted=r!=null);return}case Ys.VOLUME:{let a=(s=ii(r))!=null?s:1;this.media&&(this.media.volume=a);return}case Ys.PLAYBACKRATE:{let a=(n=ii(r))!=null?n:1;this.media&&(this.media.playbackRate=a,this.media.defaultPlaybackRate=a);return}}}play(){var e,t;return(t=(e=this.media)==null?void 0:e.play())!=null?t:Promise.reject()}pause(){var e;(e=this.media)==null||e.pause()}requestCast(e){var t;return(t=this.media)==null?void 0:t.requestCast(e)}get media(){var e;return(e=this.shadowRoot)==null?void 0:e.querySelector("mux-video")}get audioTracks(){return this.media.audioTracks}get videoTracks(){return this.media.videoTracks}get audioRenditions(){return this.media.audioRenditions}get videoRenditions(){return this.media.videoRenditions}get paused(){var e,t;return(t=(e=this.media)==null?void 0:e.paused)!=null?t:!0}get duration(){var e,t;return(t=(e=this.media)==null?void 0:e.duration)!=null?t:NaN}get ended(){var e,t;return(t=(e=this.media)==null?void 0:e.ended)!=null?t:!1}get buffered(){var e,t;return(t=(e=this.media)==null?void 0:e.buffered)!=null?t:GA}get seekable(){var e,t;return(t=(e=this.media)==null?void 0:e.seekable)!=null?t:GA}get readyState(){var e,t;return(t=(e=this.media)==null?void 0:e.readyState)!=null?t:0}get videoWidth(){var e,t;return(t=(e=this.media)==null?void 0:e.videoWidth)!=null?t:0}get videoHeight(){var e,t;return(t=(e=this.media)==null?void 0:e.videoHeight)!=null?t:0}get currentTime(){var e,t;return(t=(e=this.media)==null?void 0:e.currentTime)!=null?t:0}set currentTime(e){this.media&&(this.media.currentTime=Number(e))}get volume(){var e,t;return(t=(e=this.media)==null?void 0:e.volume)!=null?t:1}set volume(e){this.media&&(this.media.volume=Number(e))}get playbackRate(){var e,t;return(t=(e=this.media)==null?void 0:e.playbackRate)!=null?t:1}set playbackRate(e){this.media&&(this.media.playbackRate=Number(e))}get defaultPlaybackRate(){var e;return(e=ii(this.getAttribute(Ys.PLAYBACKRATE)))!=null?e:1}set defaultPlaybackRate(e){e!=null?this.setAttribute(Ys.PLAYBACKRATE,`${e}`):this.removeAttribute(Ys.PLAYBACKRATE)}get crossOrigin(){return Do(this,Lt.CROSSORIGIN)}set crossOrigin(e){this.setAttribute(Lt.CROSSORIGIN,`${e}`)}get autoplay(){return Do(this,Lt.AUTOPLAY)!=null}set autoplay(e){e?this.setAttribute(Lt.AUTOPLAY,typeof e=="string"?e:""):this.removeAttribute(Lt.AUTOPLAY)}get loop(){return Do(this,Lt.LOOP)!=null}set loop(e){e?this.setAttribute(Lt.LOOP,""):this.removeAttribute(Lt.LOOP)}get muted(){var e,t;return(t=(e=this.media)==null?void 0:e.muted)!=null?t:!1}set muted(e){this.media&&(this.media.muted=!!e)}get defaultMuted(){return Do(this,Lt.MUTED)!=null}set defaultMuted(e){e?this.setAttribute(Lt.MUTED,""):this.removeAttribute(Lt.MUTED)}get playsInline(){return Do(this,Lt.PLAYSINLINE)!=null}set playsInline(e){Wt("playsInline is set to true by default and is not currently supported as a setter.")}get preload(){return this.media?this.media.preload:this.getAttribute("preload")}set preload(e){["","none","metadata","auto"].includes(e)?this.setAttribute(Lt.PRELOAD,e):this.removeAttribute(Lt.PRELOAD)}};function Do(i,e){return i.media?i.media.getAttribute(e):i.getAttribute(e)}var K0=V0;var jD=Object.defineProperty,XD=(i,e,t)=>e in i?jD(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,QD=(i,e,t)=>(XD(i,typeof e!="symbol"?e+"":e,t),t),zA=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},de=(i,e,t)=>(zA(i,e,"read from private field"),t?t.call(i):e.get(i)),er=(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)},hr=(i,e,t,r)=>(zA(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),ea,Hc,zs,Mo,Hr,Gr,Wr,js,ta,Gc,_i,VA=1,KA=0,ZD=1,JD={processCallback(i,e,t){if(t){for(let[r,s]of e)if(r in t){let n=t[r];typeof n=="boolean"&&s instanceof Rt&&typeof s.element[s.attributeName]=="boolean"?s.booleanValue=n:typeof n=="function"&&s instanceof Rt?s.element[s.attributeName]=n:s.value=n}}}},fr=class extends A.DocumentFragment{constructor(e,t,r=JD){var s;super(),er(this,ea,void 0),er(this,Hc,void 0),this.append(e.content.cloneNode(!0)),hr(this,ea,jA(this)),hr(this,Hc,r),(s=r.createCallback)==null||s.call(r,this,de(this,ea),t),r.processCallback(this,de(this,ea),t)}update(e){de(this,Hc).processCallback(this,de(this,ea),e)}};ea=new WeakMap;Hc=new WeakMap;var jA=(i,e=[])=>{let t,r;for(let s of i.attributes||[])if(s.value.includes("{{")){let n=new q0;for([t,r]of YA(s.value))if(!t)n.append(r);else{let a=new Rt(i,s.name,s.namespaceURI);n.append(a),e.push([r,a])}s.value=n.toString()}for(let s of i.childNodes)if(s.nodeType===VA&&!(s instanceof HTMLTemplateElement))jA(s,e);else if(s.nodeType===VA||s.data.includes("{{")){let n=[];if(s.data)for([t,r]of YA(s.data))if(!t)n.push(new Text(r));else{let a=new mr(i);n.push(a),e.push([r,a])}else if(s instanceof HTMLTemplateElement){let a=new Po(i,s);n.push(a),e.push([a.expression,a])}s.replaceWith(...n.flatMap(a=>a.replacementNodes||[a]))}return e},qA={},YA=i=>{let e="",t=0,r=qA[i],s=0,n;if(r)return r;for(r=[];n=i[s];s++)n==="{"&&i[s+1]==="{"&&i[s-1]!=="\\"&&i[s+2]&&++t==1?(e&&r.push([KA,e]),e="",s++):n==="}"&&i[s+1]==="}"&&i[s-1]!=="\\"&&!--t?(r.push([ZD,e.trim()]),e="",s++):e+=n||"";return e&&r.push([KA,(t>0?"{{":"")+e]),qA[i]=r},eM=11,Wc=class{get value(){return""}set value(e){}toString(){return this.value}},XA=new WeakMap,q0=class{constructor(){er(this,zs,[])}[Symbol.iterator](){return de(this,zs).values()}get length(){return de(this,zs).length}item(e){return de(this,zs)[e]}append(...e){for(let t of e)t instanceof Rt&&XA.set(t,this),de(this,zs).push(t)}toString(){return de(this,zs).join("")}};zs=new WeakMap;var Rt=class extends Wc{constructor(e,t,r){super(),er(this,js),er(this,Mo,""),er(this,Hr,void 0),er(this,Gr,void 0),er(this,Wr,void 0),hr(this,Hr,e),hr(this,Gr,t),hr(this,Wr,r)}get attributeName(){return de(this,Gr)}get attributeNamespace(){return de(this,Wr)}get element(){return de(this,Hr)}get value(){return de(this,Mo)}set value(e){de(this,Mo)!==e&&(hr(this,Mo,e),!de(this,js,ta)||de(this,js,ta).length===1?e==null?de(this,Hr).removeAttributeNS(de(this,Wr),de(this,Gr)):de(this,Hr).setAttributeNS(de(this,Wr),de(this,Gr),e):de(this,Hr).setAttributeNS(de(this,Wr),de(this,Gr),de(this,js,ta)))}get booleanValue(){return de(this,Hr).hasAttributeNS(de(this,Wr),de(this,Gr))}set booleanValue(e){if(!de(this,js,ta)||de(this,js,ta).length===1)this.value=e?"":null;else throw new DOMException("Value is not fully templatized")}};Mo=new WeakMap;Hr=new WeakMap;Gr=new WeakMap;Wr=new WeakMap;js=new WeakSet;ta=function(){return XA.get(this)};var mr=class extends Wc{constructor(e,t){super(),er(this,Gc,void 0),er(this,_i,void 0),hr(this,Gc,e),hr(this,_i,t?[...t]:[new Text])}get replacementNodes(){return de(this,_i)}get parentNode(){return de(this,Gc)}get nextSibling(){return de(this,_i)[de(this,_i).length-1].nextSibling}get previousSibling(){return de(this,_i)[0].previousSibling}get value(){return de(this,_i).map(e=>e.textContent).join("")}set value(e){this.replace(e)}replace(...e){let t=e.flat().flatMap(r=>r==null?[new Text]:r.forEach?[...r]:r.nodeType===eM?[...r.childNodes]:r.nodeType?[r]:[new Text(r)]);t.length||t.push(new Text),hr(this,_i,tM(de(this,_i)[0].parentNode,de(this,_i),t,this.nextSibling))}};Gc=new WeakMap;_i=new WeakMap;var Po=class extends mr{constructor(e,t){let r=t.getAttribute("directive")||t.getAttribute("type"),s=t.getAttribute("expression")||t.getAttribute(r)||"";s.startsWith("{{")&&(s=s.trim().slice(2,-2).trim()),super(e),QD(this,"directive"),this.expression=s,this.template=t,this.directive=r}};function tM(i,e,t,r=null){let s=0,n,a,o,l=t.length,d=e.length;for(;s<l&&s<d&&e[s]==t[s];)s++;for(;s<l&&s<d&&t[l-1]==e[d-1];)r=t[--d,--l];if(s==d)for(;s<l;)i.insertBefore(t[s++],r);if(s==l)for(;s<d;)i.removeChild(e[s++]);else{for(n=e[s];s<l;)o=t[s++],a=n?n.nextSibling:r,n==o?n=a:s<l&&t[s]==a?(i.replaceChild(o,n),n=a):i.insertBefore(o,n);for(;n!=r;)a=n.nextSibling,i.removeChild(n),n=a}return t}var QA={string:i=>String(i)},Kc=class{constructor(e){this.template=e,this.state=void 0}},Xs=new WeakMap,Qs=new WeakMap,Y0={partial:(i,e)=>{e[i.expression]=new Kc(i.template)},if:(i,e)=>{var t;if(JA(i.expression,e))if(Xs.get(i)!==i.template){Xs.set(i,i.template);let r=new fr(i.template,e,qc);i.replace(r),Qs.set(i,r)}else(t=Qs.get(i))==null||t.update(e);else i.replace(""),Xs.delete(i),Qs.delete(i)}},iM=Object.keys(Y0),qc={processCallback(i,e,t){var r,s;if(t)for(let[n,a]of e){if(a instanceof Po){if(!a.directive){let l=iM.find(d=>a.template.hasAttribute(d));l&&(a.directive=l,a.expression=a.template.getAttribute(l))}(r=Y0[a.directive])==null||r.call(Y0,a,t);continue}let o=JA(n,t);if(o instanceof Kc){Xs.get(a)!==o.template?(Xs.set(a,o.template),o=new fr(o.template,o.state,qc),a.value=o,Qs.set(a,o)):(s=Qs.get(a))==null||s.update(o.state);continue}o?(a instanceof Rt&&a.attributeName.startsWith("aria-")&&(o=String(o)),a instanceof Rt?typeof o=="boolean"?a.booleanValue=o:typeof o=="function"?a.element[a.attributeName]=o:a.value=o:(a.value=o,Xs.delete(a),Qs.delete(a))):a instanceof Rt?a.value=void 0:(a.value=void 0,Xs.delete(a),Qs.delete(a))}}},ZA={"!":i=>!i,"!!":i=>!!i,"==":(i,e)=>i==e,"!=":(i,e)=>i!=e,">":(i,e)=>i>e,">=":(i,e)=>i>=e,"<":(i,e)=>i<e,"<=":(i,e)=>i<=e,"??":(i,e)=>i!=null?i:e,"|":(i,e)=>{var t;return(t=QA[e])==null?void 0:t.call(QA,i)}};function rM(i){return sM(i,{boolean:/true|false/,number:/-?\d+\.?\d*/,string:/(["'])((?:\\.|[^\\])*?)\1/,operator:/[!=><][=!]?|\?\?|\|/,ws:/\s+/,param:/[$a-z_][$\w]*/i}).filter(({type:e})=>e!=="ws")}function JA(i,e={}){var t,r,s,n,a,o,l;let d=rM(i);if(d.length===0||d.some(({type:u})=>!u))return Oo(i);if(((t=d[0])==null?void 0:t.token)===">"){let u=e[(r=d[1])==null?void 0:r.token];if(!u)return Oo(i);let c={...e};u.state=c;let h=d.slice(2);for(let f=0;f<h.length;f+=3){let m=(s=h[f])==null?void 0:s.token,p=(n=h[f+1])==null?void 0:n.token,g=(a=h[f+2])==null?void 0:a.token;m&&p==="="&&(c[m]=No(g,e))}return u}if(d.length===1)return Vc(d[0])?No(d[0].token,e):Oo(i);if(d.length===2){let u=(o=d[0])==null?void 0:o.token,c=ZA[u];if(!c||!Vc(d[1]))return Oo(i);let h=No(d[1].token,e);return c(h)}if(d.length===3){let u=(l=d[1])==null?void 0:l.token,c=ZA[u];if(!c||!Vc(d[0])||!Vc(d[2]))return Oo(i);let h=No(d[0].token,e);if(u==="|")return c(h,d[2].token);let f=No(d[2].token,e);return c(h,f)}}function Oo(i){return console.warn(`Warning: invalid expression \`${i}\``),!1}function Vc({type:i}){return["number","boolean","string","param"].includes(i)}function No(i,e){let t=i[0],r=i.slice(-1);return i==="true"||i==="false"?i==="true":t===r&&["'",'"'].includes(t)?i.slice(1,-1):zo(i)?parseFloat(i):e[i]}function sM(i,e){let t,r,s,n=[];for(;i;){s=null,t=i.length;for(let a in e)r=e[a].exec(i),r&&r.index<t&&(s={token:r[0],type:a,matches:r.slice(1)},t=r.index);t&&n.push({token:i.substr(0,t),type:void 0}),s&&n.push(s),i=i.substr(t+(s?s.token.length:0))}return n}var nM=Object.defineProperty,aM=(i,e,t)=>e in i?nM(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Fo=(i,e,t)=>(aM(i,typeof e!="symbol"?e+"":e,t),t),J0=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},X0=(i,e,t)=>(J0(i,e,"read from private field"),t?t.call(i):e.get(i)),Uo=(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)},Zs=(i,e,t,r)=>(J0(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),z0=(i,e,t)=>(J0(i,e,"access private method"),t),ia,Yc,ra,Q0,e1,zc,Z0,j0={mediatargetlivewindow:"targetlivewindow",mediastreamtype:"streamtype"},t1=O.createElement("template");t1.innerHTML=`
1647
+ `}var SA=(i,{tag:e,is:t})=>{var r,s,n,a,o,l,d,u,c,h,f,m,p,g,E,T,y;let S=(s=(r=globalThis.document)==null?void 0:r.createElement)==null?void 0:s.call(r,e,{is:t}),A=S?yD(S):[];return n=class extends i{constructor(){super(),X(this,h),X(this,m),X(this,g),X(this,T),X(this,d,void 0),X(this,u,void 0),X(this,c,new Map)}static get observedAttributes(){var L,x,w;return Be(L=n,o,l).call(L),[...(w=(x=S==null?void 0:S.constructor)==null?void 0:x.observedAttributes)!=null?w:[],"autopictureinpicture","disablepictureinpicture","disableremoteplayback","autoplay","controls","controlslist","crossorigin","loop","muted","playsinline","poster","preload","src"]}get nativeEl(){var L,x,w;return Be(this,h,f).call(this),(w=(x=(L=R(this,u))!=null?L:this.shadowRoot.querySelector(e))!=null?x:this.querySelector(":scope > [slot=media]"))!=null?w:this.querySelector(e)}set nativeEl(L){ee(this,u,L)}get defaultMuted(){return this.hasAttribute("muted")}set defaultMuted(L){this.toggleAttribute("muted",!!L)}get src(){return this.getAttribute("src")}set src(L){this.setAttribute("src",`${L}`)}get preload(){var L,x;return(x=this.getAttribute("preload"))!=null?x:(L=this.nativeEl)==null?void 0:L.preload}set preload(L){this.setAttribute("preload",`${L}`)}init(){var L,x;if(!this.shadowRoot){this.attachShadow({mode:"open"});let w=TD(this.attributes);t&&(w.is=t),e&&(w.part=e),this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(w)}this.nativeEl.muted=this.hasAttribute("muted");for(let w of A)Be(this,g,E).call(this,w);this.shadowRoot.addEventListener("slotchange",this),Be(this,m,p).call(this);for(let w of this.constructor.Events)(x=(L=this.shadowRoot).addEventListener)==null||x.call(L,w,this,!0)}handleEvent(L){if(L.type==="slotchange"){Be(this,m,p).call(this);return}L.target===this.nativeEl&&this.dispatchEvent(new CustomEvent(L.type,{detail:L.detail}))}attributeChangedCallback(L,x,w){Be(this,h,f).call(this),Be(this,T,y).call(this,L,x,w)}connectedCallback(){Be(this,h,f).call(this)}},a=new WeakMap,o=new WeakSet,l=function(){if(R(this,a))return;ee(this,a,!0);let L=new Set(this.observedAttributes);L.delete("muted");for(let x of A)if(!(x in this.prototype))if(typeof S[x]=="function")this.prototype[x]=function(...w){return Be(this,h,f).call(this),this.call?this.call(x,...w):this.nativeEl[x].apply(this.nativeEl,w)};else{let w={get(){var P,k,D;Be(this,h,f).call(this);let U=x.toLowerCase();if(L.has(U)){let F=this.getAttribute(U);return F===null?!1:F===""?!0:F}return(D=(P=this.get)==null?void 0:P.call(this,x))!=null?D:(k=this.nativeEl)==null?void 0:k[x]}};x!==x.toUpperCase()&&(w.set=function(P){Be(this,h,f).call(this);let k=x.toLowerCase();if(L.has(k)){P===!0||P===!1||P==null?this.toggleAttribute(k,!!P):this.setAttribute(k,P);return}if(this.set){this.set(x,P);return}this.nativeEl[x]=P}),Object.defineProperty(this.prototype,x,w)}},d=new WeakMap,u=new WeakMap,c=new WeakMap,h=new WeakSet,f=function(){R(this,d)||(ee(this,d,!0),this.init())},m=new WeakSet,p=function(){let L=new Map(R(this,c));this.shadowRoot.querySelector("slot:not([name])").assignedElements({flatten:!0}).filter(x=>["track","source"].includes(x.localName)).forEach(x=>{var w,P;L.delete(x);let k=R(this,c).get(x);k||(k=x.cloneNode(),R(this,c).set(x,k)),(P=(w=this.nativeEl).append)==null||P.call(w,k),k.localName==="track"&&k.default&&(k.kind==="chapters"||k.kind==="metadata")&&k.track.mode==="disabled"&&(k.track.mode="hidden")}),L.forEach(x=>x.remove())},g=new WeakSet,E=function(L){if(Object.prototype.hasOwnProperty.call(this,L)){let x=this[L];delete this[L],this[L]=x}},T=new WeakSet,y=function(L,x,w){var P,k,D,U,F,z;["id","class"].includes(L)||!n.observedAttributes.includes(L)&&this.constructor.observedAttributes.includes(L)||(w===null?(k=(P=this.nativeEl).removeAttribute)==null||k.call(P,L):((U=(D=this.nativeEl).getAttribute)==null?void 0:U.call(D,L))!=w&&((z=(F=this.nativeEl).setAttribute)==null||z.call(F,L,w)))},X(n,o),Ce(n,"getTemplateHTML",e.endsWith("audio")?ED:bD),Ce(n,"shadowRootOptions",{mode:"open"}),Ce(n,"Events",Fc),X(n,a,void 0),n};function yD(i){let e=[];for(let t=Object.getPrototypeOf(i);t&&t!==HTMLElement.prototype;t=Object.getPrototypeOf(t))e.push(...Object.getOwnPropertyNames(t));return e}function xA(i){let e="";for(let t in i){let r=i[t];r===""?e+=` ${t}`:e+=` ${t}="${r}"`}return e}function TD(i){let e={};for(let t of i)e[t.name]=t.value;return e}var pA,b0=SA((pA=globalThis.HTMLElement)!=null?pA:class{},{tag:"video"}),gA,y5=SA((gA=globalThis.HTMLElement)!=null?gA:class{},{tag:"audio"}),Ws=new WeakMap,y0=class extends Error{},_D=class extends Error{},AD=globalThis.WeakRef?class extends Set{add(i){super.add(new WeakRef(i))}forEach(i){super.forEach(e=>{let t=e.deref();t&&i(t)})}}:Set;function SD(i){var e,t,r;(t=(e=globalThis.chrome)==null?void 0:e.cast)!=null&&t.isAvailable?(r=globalThis.cast)!=null&&r.framework?i():customElements.whenDefined("google-cast-button").then(i):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(i)}}function xD(){return globalThis.chrome}function LD(){var i;let e="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1";if((i=globalThis.chrome)!=null&&i.cast||document.querySelector(`script[src="${e}"]`))return;let t=document.createElement("script");t.src=e,document.head.append(t)}function Ks(){var i,e;return(e=(i=globalThis.cast)==null?void 0:i.framework)==null?void 0:e.CastContext.getInstance()}function $0(){var i;return(i=Ks())==null?void 0:i.getCurrentSession()}function H0(){var i;return(i=$0())==null?void 0:i.getSessionObj().media[0]}function kD(i){return new Promise((e,t)=>{H0().editTracksInfo(i,e,t)})}function ID(i){return new Promise((e,t)=>{H0().getStatus(i,e,t)})}function LA(i){return Ks().setOptions({...kA(),...i})}function kA(){return{receiverApplicationId:"CC1AD845",autoJoinPolicy:"origin_scoped",androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0}}var Sc=new AD,Br=new WeakSet,nt;SD(()=>{var i,e,t,r;if(!((e=(i=globalThis.chrome)==null?void 0:i.cast)!=null&&e.isAvailable)){console.debug("chrome.cast.isAvailable",(r=(t=globalThis.chrome)==null?void 0:t.cast)==null?void 0:r.isAvailable);return}nt||(nt=cast.framework,Ks().addEventListener(nt.CastContextEventType.CAST_STATE_CHANGED,s=>{Sc.forEach(n=>{var a,o;return(o=(a=Ws.get(n)).onCastStateChanged)==null?void 0:o.call(a,s)})}),Ks().addEventListener(nt.CastContextEventType.SESSION_STATE_CHANGED,s=>{Sc.forEach(n=>{var a,o;return(o=(a=Ws.get(n)).onSessionStateChanged)==null?void 0:o.call(a,s)})}),Sc.forEach(s=>{var n,a;return(a=(n=Ws.get(s)).init)==null?void 0:a.call(n)}))});var vA=0,xe,xc,ti,Ur,Jn,jn,Gs,_0,Fr,Rs,A0,EA,Oc,S0,x0,IA,Lc,L0,k0,bA,kc,T0,RD=class extends EventTarget{constructor(i){super(),X(this,Fr),X(this,A0),X(this,Oc),X(this,x0),X(this,Lc),X(this,k0),X(this,kc),X(this,xe,void 0),X(this,xc,void 0),X(this,ti,void 0),X(this,Ur,void 0),X(this,Jn,"disconnected"),X(this,jn,!1),X(this,Gs,new Set),X(this,_0,new WeakMap),ee(this,xe,i),Sc.add(this),Ws.set(this,{init:()=>Be(this,Lc,L0).call(this),onCastStateChanged:()=>Be(this,Oc,S0).call(this),onSessionStateChanged:()=>Be(this,x0,IA).call(this),getCastPlayer:()=>R(this,Fr,Rs)}),Be(this,Lc,L0).call(this)}get state(){return R(this,Jn)}async watchAvailability(i){if(R(this,xe).disableRemotePlayback)throw new y0("disableRemotePlayback attribute is present.");return R(this,_0).set(i,++vA),R(this,Gs).add(i),vA}async cancelWatchAvailability(i){if(R(this,xe).disableRemotePlayback)throw new y0("disableRemotePlayback attribute is present.");i?R(this,Gs).delete(i):R(this,Gs).clear()}async prompt(){var i,e,t,r;if(R(this,xe).disableRemotePlayback)throw new y0("disableRemotePlayback attribute is present.");if(!((e=(i=globalThis.chrome)==null?void 0:i.cast)!=null&&e.isAvailable))throw new _D("The RemotePlayback API is disabled on this platform.");let s=Br.has(R(this,xe));Br.add(R(this,xe)),LA(R(this,xe).castOptions),Object.entries(R(this,Ur)).forEach(([n,a])=>{R(this,ti).controller.addEventListener(n,a)});try{await Ks().requestSession()}catch(n){if(n==="cancel"){s||Br.delete(R(this,xe));return}throw new Error(n)}(r=(t=Ws.get(R(this,xe)))==null?void 0:t.loadOnPrompt)==null||r.call(t)}};xe=new WeakMap,xc=new WeakMap,ti=new WeakMap,Ur=new WeakMap,Jn=new WeakMap,jn=new WeakMap,Gs=new WeakMap,_0=new WeakMap,Fr=new WeakSet,Rs=function(){if(Br.has(R(this,xe)))return R(this,ti)},A0=new WeakSet,EA=function(){Br.has(R(this,xe))&&(Object.entries(R(this,Ur)).forEach(([i,e])=>{R(this,ti).controller.removeEventListener(i,e)}),Br.delete(R(this,xe)),R(this,xe).muted=R(this,ti).isMuted,R(this,xe).currentTime=R(this,ti).savedPlayerState.currentTime,R(this,ti).savedPlayerState.isPaused===!1&&R(this,xe).play())},Oc=new WeakSet,S0=function(){let i=Ks().getCastState();if(Br.has(R(this,xe))&&i==="CONNECTING"&&(ee(this,Jn,"connecting"),this.dispatchEvent(new Event("connecting"))),!R(this,jn)&&i!=null&&i.includes("CONNECT")){ee(this,jn,!0);for(let e of R(this,Gs))e(!0)}else if(R(this,jn)&&(!i||i==="NO_DEVICES_AVAILABLE")){ee(this,jn,!1);for(let e of R(this,Gs))e(!1)}},x0=new WeakSet,IA=async function(){var i;let{SESSION_RESUMED:e}=nt.SessionState;if(Ks().getSessionState()===e&&R(this,xe).castSrc===((i=H0())==null?void 0:i.media.contentId)){Br.add(R(this,xe)),Object.entries(R(this,Ur)).forEach(([t,r])=>{R(this,ti).controller.addEventListener(t,r)});try{await ID(new chrome.cast.media.GetStatusRequest)}catch(t){console.error(t)}R(this,Ur)[nt.RemotePlayerEventType.IS_PAUSED_CHANGED](),R(this,Ur)[nt.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},Lc=new WeakSet,L0=function(){!nt||R(this,xc)||(ee(this,xc,!0),LA(R(this,xe).castOptions),R(this,xe).textTracks.addEventListener("change",()=>Be(this,kc,T0).call(this)),Be(this,Oc,S0).call(this),ee(this,ti,new nt.RemotePlayer),new nt.RemotePlayerController(R(this,ti)),ee(this,Ur,{[nt.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:i})=>{i===!0?(ee(this,Jn,"connected"),this.dispatchEvent(new Event("connect"))):(Be(this,A0,EA).call(this),ee(this,Jn,"disconnected"),this.dispatchEvent(new Event("disconnect")))},[nt.RemotePlayerEventType.DURATION_CHANGED]:()=>{R(this,xe).dispatchEvent(new Event("durationchange"))},[nt.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]:()=>{R(this,xe).dispatchEvent(new Event("volumechange"))},[nt.RemotePlayerEventType.IS_MUTED_CHANGED]:()=>{R(this,xe).dispatchEvent(new Event("volumechange"))},[nt.RemotePlayerEventType.CURRENT_TIME_CHANGED]:()=>{var i;(i=R(this,Fr,Rs))!=null&&i.isMediaLoaded&&R(this,xe).dispatchEvent(new Event("timeupdate"))},[nt.RemotePlayerEventType.VIDEO_INFO_CHANGED]:()=>{R(this,xe).dispatchEvent(new Event("resize"))},[nt.RemotePlayerEventType.IS_PAUSED_CHANGED]:()=>{R(this,xe).dispatchEvent(new Event(this.paused?"pause":"play"))},[nt.RemotePlayerEventType.PLAYER_STATE_CHANGED]:()=>{var i,e;((i=R(this,Fr,Rs))==null?void 0:i.playerState)!==chrome.cast.media.PlayerState.PAUSED&&R(this,xe).dispatchEvent(new Event({[chrome.cast.media.PlayerState.PLAYING]:"playing",[chrome.cast.media.PlayerState.BUFFERING]:"waiting",[chrome.cast.media.PlayerState.IDLE]:"emptied"}[(e=R(this,Fr,Rs))==null?void 0:e.playerState]))},[nt.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{var i;(i=R(this,Fr,Rs))!=null&&i.isMediaLoaded&&(await Promise.resolve(),Be(this,k0,bA).call(this))}}))},k0=new WeakSet,bA=function(){Be(this,kc,T0).call(this)},kc=new WeakSet,T0=async function(){var i,e,t,r,s;if(!R(this,Fr,Rs))return;let n=((e=(i=R(this,ti).mediaInfo)==null?void 0:i.tracks)!=null?e:[]).filter(({type:h})=>h===chrome.cast.media.TrackType.TEXT),a=[...R(this,xe).textTracks].filter(({kind:h})=>h==="subtitles"||h==="captions"),o=n.map(({language:h,name:f,trackId:m})=>{var p;let{mode:g}=(p=a.find(E=>E.language===h&&E.label===f))!=null?p:{};return g?{mode:g,trackId:m}:!1}).filter(Boolean),l=o.filter(({mode:h})=>h!=="showing").map(({trackId:h})=>h),d=o.find(({mode:h})=>h==="showing"),u=(s=(r=(t=$0())==null?void 0:t.getSessionObj().media[0])==null?void 0:r.activeTrackIds)!=null?s:[],c=u;if(u.length&&(c=c.filter(h=>!l.includes(h))),d!=null&&d.trackId&&(c=[...c,d.trackId]),c=[...new Set(c)],!((h,f)=>h.length===f.length&&h.every(m=>f.includes(m)))(u,c))try{let h=new chrome.cast.media.EditTracksInfoRequest(c);await kD(h)}catch(h){console.error(h)}};var wD=i=>{var e,t,r,s,n,a,o,l,d;return t=class extends i{constructor(){super(...arguments),X(this,a),X(this,l),X(this,r,{paused:!1}),X(this,s,kA()),X(this,n,void 0)}get remote(){return R(this,n)?R(this,n):xD()?(LD(),Ws.set(this,{loadOnPrompt:()=>Be(this,l,d).call(this)}),ee(this,n,new RD(this))):super.remote}attributeChangedCallback(u,c,h){if(super.attributeChangedCallback(u,c,h),u==="cast-receiver"&&h){R(this,s).receiverApplicationId=h;return}if(R(this,a,o))switch(u){case"cast-stream-type":case"cast-src":this.load();break}}async load(){var u,c;if(!R(this,a,o))return super.load();let h=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType),f=[...this.querySelectorAll("track")].filter(({kind:E,src:T})=>T&&(E==="subtitles"||E==="captions")),m=[],p=0;f.length&&(h.tracks=f.map(E=>{let T=++p;m.length===0&&E.track.mode==="showing"&&m.push(T);let y=new chrome.cast.media.Track(T,chrome.cast.media.TrackType.TEXT);return y.trackContentId=E.src,y.trackContentType="text/vtt",y.subtype=E.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,y.name=E.label,y.language=E.srclang,y})),this.castStreamType==="live"?h.streamType=chrome.cast.media.StreamType.LIVE:h.streamType=chrome.cast.media.StreamType.BUFFERED,h.metadata=new chrome.cast.media.GenericMediaMetadata,h.metadata.title=this.title,h.metadata.images=[{url:this.poster}];let g=new chrome.cast.media.LoadRequest(h);g.currentTime=(u=super.currentTime)!=null?u:0,g.autoplay=!R(this,r).paused,g.activeTrackIds=m,await((c=$0())==null?void 0:c.loadMedia(g)),this.dispatchEvent(new Event("volumechange"))}play(){var u;if(R(this,a,o)){R(this,a,o).isPaused&&((u=R(this,a,o).controller)==null||u.playOrPause());return}return super.play()}pause(){var u;if(R(this,a,o)){R(this,a,o).isPaused||(u=R(this,a,o).controller)==null||u.playOrPause();return}super.pause()}get castOptions(){return R(this,s)}get castReceiver(){var u;return(u=this.getAttribute("cast-receiver"))!=null?u:void 0}set castReceiver(u){this.castReceiver!=u&&this.setAttribute("cast-receiver",`${u}`)}get castSrc(){var u,c,h;return(h=(c=this.getAttribute("cast-src"))!=null?c:(u=this.querySelector("source"))==null?void 0:u.src)!=null?h:this.currentSrc}set castSrc(u){this.castSrc!=u&&this.setAttribute("cast-src",`${u}`)}get castContentType(){var u;return(u=this.getAttribute("cast-content-type"))!=null?u:void 0}set castContentType(u){this.setAttribute("cast-content-type",`${u}`)}get castStreamType(){var u,c;return(c=(u=this.getAttribute("cast-stream-type"))!=null?u:this.streamType)!=null?c:void 0}set castStreamType(u){this.setAttribute("cast-stream-type",`${u}`)}get readyState(){if(R(this,a,o))switch(R(this,a,o).playerState){case chrome.cast.media.PlayerState.IDLE:return 0;case chrome.cast.media.PlayerState.BUFFERING:return 2;default:return 3}return super.readyState}get paused(){return R(this,a,o)?R(this,a,o).isPaused:super.paused}get muted(){var u;return R(this,a,o)?(u=R(this,a,o))==null?void 0:u.isMuted:super.muted}set muted(u){var c;if(R(this,a,o)){(u&&!R(this,a,o).isMuted||!u&&R(this,a,o).isMuted)&&((c=R(this,a,o).controller)==null||c.muteOrUnmute());return}super.muted=u}get volume(){var u,c;return R(this,a,o)?(c=(u=R(this,a,o))==null?void 0:u.volumeLevel)!=null?c:1:super.volume}set volume(u){var c;if(R(this,a,o)){R(this,a,o).volumeLevel=+u,(c=R(this,a,o).controller)==null||c.setVolumeLevel();return}super.volume=u}get duration(){var u,c,h;return R(this,a,o)&&(u=R(this,a,o))!=null&&u.isMediaLoaded?(h=(c=R(this,a,o))==null?void 0:c.duration)!=null?h:NaN:super.duration}get currentTime(){var u,c,h;return R(this,a,o)&&(u=R(this,a,o))!=null&&u.isMediaLoaded?(h=(c=R(this,a,o))==null?void 0:c.currentTime)!=null?h:0:super.currentTime}set currentTime(u){var c;if(R(this,a,o)){R(this,a,o).currentTime=u,(c=R(this,a,o).controller)==null||c.seek();return}super.currentTime=u}},r=new WeakMap,s=new WeakMap,n=new WeakMap,a=new WeakSet,o=function(){var u,c;return(c=(u=Ws.get(this.remote))==null?void 0:u.getCastPlayer)==null?void 0:c.call(u)},l=new WeakSet,d=async function(){R(this,r).paused=v0(t.prototype,this,"paused"),v0(t.prototype,this,"pause").call(this),this.muted=v0(t.prototype,this,"muted");try{await this.load()}catch(u){console.error(u)}},Ce(t,"observedAttributes",[...(e=i.observedAttributes)!=null?e:[],"cast-src","cast-content-type","cast-stream-type","cast-receiver"]),t},Bc=class extends Event{constructor(i,e){super(i),Ce(this,"track"),this.track=e.track}},I0=new WeakMap;function V(i){var e;return(e=I0.get(i))!=null?e:CD(i,{})}function CD(i,e){let t=I0.get(i);return t||I0.set(i,t={}),Object.assign(t,e)}function R0(i,e){let t=i.videoTracks;V(e).media=i,V(e).renditionSet||(V(e).renditionSet=new Set);let r=V(t).trackSet;r.add(e);let s=r.size-1;s in C0.prototype||Object.defineProperty(C0.prototype,s,{get(){return[...V(this).trackSet][s]}}),queueMicrotask(()=>{t.dispatchEvent(new Bc("addtrack",{track:e}))})}function w0(i){var e;let t=(e=V(i).media)==null?void 0:e.videoTracks;t&&(V(t).trackSet.delete(i),queueMicrotask(()=>{t.dispatchEvent(new Bc("removetrack",{track:i}))}))}function DD(i){var e;let t=(e=V(i).media.videoTracks)!=null?e:[],r=!1;for(let s of t)s!==i&&(s.selected=!1,r=!0);if(r){if(V(t).changeRequested)return;V(t).changeRequested=!0,queueMicrotask(()=>{delete V(t).changeRequested,t.dispatchEvent(new Event("change"))})}}var ws,Cs,Ds,Xn,_o,C0=class extends EventTarget{constructor(){super(),X(this,Xn),X(this,ws,void 0),X(this,Cs,void 0),X(this,Ds,void 0),V(this).trackSet=new Set}[Symbol.iterator](){return R(this,Xn,_o).values()}get length(){return R(this,Xn,_o).size}getTrackById(i){var e;return(e=[...R(this,Xn,_o)].find(t=>t.id===i))!=null?e:null}get selectedIndex(){return[...R(this,Xn,_o)].findIndex(i=>i.selected)}get onaddtrack(){return R(this,ws)}set onaddtrack(i){R(this,ws)&&(this.removeEventListener("addtrack",R(this,ws)),ee(this,ws,void 0)),typeof i=="function"&&(ee(this,ws,i),this.addEventListener("addtrack",i))}get onremovetrack(){return R(this,Cs)}set onremovetrack(i){R(this,Cs)&&(this.removeEventListener("removetrack",R(this,Cs)),ee(this,Cs,void 0)),typeof i=="function"&&(ee(this,Cs,i),this.addEventListener("removetrack",i))}get onchange(){return R(this,Ds)}set onchange(i){R(this,Ds)&&(this.removeEventListener("change",R(this,Ds)),ee(this,Ds,void 0)),typeof i=="function"&&(ee(this,Ds,i),this.addEventListener("change",i))}};ws=new WeakMap,Cs=new WeakMap,Ds=new WeakMap,Xn=new WeakSet,_o=function(){return V(this).trackSet};var $c=class extends Event{constructor(i,e){super(i),Ce(this,"rendition"),this.rendition=e.rendition}};function MD(i,e){let t=V(i).media.videoRenditions;V(e).media=V(i).media,V(e).track=i;let r=V(i).renditionSet;r.add(e);let s=r.size-1;s in D0.prototype||Object.defineProperty(D0.prototype,s,{get(){return Qn(this)[s]}}),queueMicrotask(()=>{i.selected&&t.dispatchEvent(new $c("addrendition",{rendition:e}))})}function PD(i){let e=V(i).media.videoRenditions,t=V(i).track;V(t).renditionSet.delete(i),queueMicrotask(()=>{V(i).track.selected&&e.dispatchEvent(new $c("removerendition",{rendition:i}))})}function OD(i){let e=V(i).media.videoRenditions;!e||V(e).changeRequested||(V(e).changeRequested=!0,queueMicrotask(()=>{delete V(e).changeRequested,V(i).track.selected&&e.dispatchEvent(new Event("change"))}))}function Qn(i){return[...V(i).media.videoTracks].filter(e=>e.selected).flatMap(e=>[...V(e).renditionSet])}var Ms,Ps,Os,D0=class extends EventTarget{constructor(){super(...arguments),X(this,Ms,void 0),X(this,Ps,void 0),X(this,Os,void 0)}[Symbol.iterator](){return Qn(this).values()}get length(){return Qn(this).length}getRenditionById(i){var e;return(e=Qn(this).find(t=>`${t.id}`==`${i}`))!=null?e:null}get selectedIndex(){return Qn(this).findIndex(i=>i.selected)}set selectedIndex(i){for(let[e,t]of Qn(this).entries())t.selected=e===i}get onaddrendition(){return R(this,Ms)}set onaddrendition(i){R(this,Ms)&&(this.removeEventListener("addrendition",R(this,Ms)),ee(this,Ms,void 0)),typeof i=="function"&&(ee(this,Ms,i),this.addEventListener("addrendition",i))}get onremoverendition(){return R(this,Ps)}set onremoverendition(i){R(this,Ps)&&(this.removeEventListener("removerendition",R(this,Ps)),ee(this,Ps,void 0)),typeof i=="function"&&(ee(this,Ps,i),this.addEventListener("removerendition",i))}get onchange(){return R(this,Os)}set onchange(i){R(this,Os)&&(this.removeEventListener("change",R(this,Os)),ee(this,Os,void 0)),typeof i=="function"&&(ee(this,Os,i),this.addEventListener("change",i))}};Ms=new WeakMap,Ps=new WeakMap,Os=new WeakMap;var Ao,ND=class{constructor(){Ce(this,"src"),Ce(this,"id"),Ce(this,"width"),Ce(this,"height"),Ce(this,"bitrate"),Ce(this,"frameRate"),Ce(this,"codec"),X(this,Ao,!1)}get selected(){return R(this,Ao)}set selected(i){R(this,Ao)!==i&&(ee(this,Ao,i),OD(this))}};Ao=new WeakMap;var So,RA=class{constructor(){Ce(this,"id"),Ce(this,"kind"),Ce(this,"label",""),Ce(this,"language",""),Ce(this,"sourceBuffer"),X(this,So,!1)}addRendition(i,e,t,r,s,n){let a=new ND;return a.src=i,a.width=e,a.height=t,a.frameRate=n,a.bitrate=s,a.codec=r,MD(this,a),a}removeRendition(i){PD(i)}get selected(){return R(this,So)}set selected(i){R(this,So)!==i&&(ee(this,So,i),i===!0&&DD(this))}};So=new WeakMap;function UD(i,e){let t=V(i).media.audioRenditions;V(e).media=V(i).media,V(e).track=i;let r=V(i).renditionSet;r.add(e);let s=r.size-1;s in M0.prototype||Object.defineProperty(M0.prototype,s,{get(){return Zn(this)[s]}}),queueMicrotask(()=>{i.enabled&&t.dispatchEvent(new $c("addrendition",{rendition:e}))})}function FD(i){let e=V(i).media.audioRenditions,t=V(i).track;V(t).renditionSet.delete(i),queueMicrotask(()=>{V(i).track.enabled&&e.dispatchEvent(new $c("removerendition",{rendition:i}))})}function BD(i){let e=V(i).media.audioRenditions;!e||V(e).changeRequested||(V(e).changeRequested=!0,queueMicrotask(()=>{delete V(e).changeRequested,V(i).track.enabled&&e.dispatchEvent(new Event("change"))}))}function Zn(i){return[...V(i).media.audioTracks].filter(e=>e.enabled).flatMap(e=>[...V(e).renditionSet])}var Ns,Us,Fs,M0=class extends EventTarget{constructor(){super(...arguments),X(this,Ns,void 0),X(this,Us,void 0),X(this,Fs,void 0)}[Symbol.iterator](){return Zn(this).values()}get length(){return Zn(this).length}getRenditionById(i){var e;return(e=Zn(this).find(t=>`${t.id}`==`${i}`))!=null?e:null}get selectedIndex(){return Zn(this).findIndex(i=>i.selected)}set selectedIndex(i){for(let[e,t]of Zn(this).entries())t.selected=e===i}get onaddrendition(){return R(this,Ns)}set onaddrendition(i){R(this,Ns)&&(this.removeEventListener("addrendition",R(this,Ns)),ee(this,Ns,void 0)),typeof i=="function"&&(ee(this,Ns,i),this.addEventListener("addrendition",i))}get onremoverendition(){return R(this,Us)}set onremoverendition(i){R(this,Us)&&(this.removeEventListener("removerendition",R(this,Us)),ee(this,Us,void 0)),typeof i=="function"&&(ee(this,Us,i),this.addEventListener("removerendition",i))}get onchange(){return R(this,Fs)}set onchange(i){R(this,Fs)&&(this.removeEventListener("change",R(this,Fs)),ee(this,Fs,void 0)),typeof i=="function"&&(ee(this,Fs,i),this.addEventListener("change",i))}};Ns=new WeakMap,Us=new WeakMap,Fs=new WeakMap;var xo,$D=class{constructor(){Ce(this,"src"),Ce(this,"id"),Ce(this,"bitrate"),Ce(this,"codec"),X(this,xo,!1)}get selected(){return R(this,xo)}set selected(i){R(this,xo)!==i&&(ee(this,xo,i),BD(this))}};xo=new WeakMap;function P0(i,e){let t=i.audioTracks;V(e).media=i,V(e).renditionSet||(V(e).renditionSet=new Set);let r=V(t).trackSet;r.add(e);let s=r.size-1;s in N0.prototype||Object.defineProperty(N0.prototype,s,{get(){return[...V(this).trackSet][s]}}),queueMicrotask(()=>{t.dispatchEvent(new Bc("addtrack",{track:e}))})}function O0(i){var e;let t=(e=V(i).media)==null?void 0:e.audioTracks;t&&(V(t).trackSet.delete(i),queueMicrotask(()=>{t.dispatchEvent(new Bc("removetrack",{track:i}))}))}function HD(i){let e=V(i).media.audioTracks;!e||V(e).changeRequested||(V(e).changeRequested=!0,queueMicrotask(()=>{delete V(e).changeRequested,e.dispatchEvent(new Event("change"))}))}var Bs,$s,Hs,Lo,Ic,N0=class extends EventTarget{constructor(){super(),X(this,Lo),X(this,Bs,void 0),X(this,$s,void 0),X(this,Hs,void 0),V(this).trackSet=new Set}[Symbol.iterator](){return R(this,Lo,Ic).values()}get length(){return R(this,Lo,Ic).size}getTrackById(i){var e;return(e=[...R(this,Lo,Ic)].find(t=>t.id===i))!=null?e:null}get onaddtrack(){return R(this,Bs)}set onaddtrack(i){R(this,Bs)&&(this.removeEventListener("addtrack",R(this,Bs)),ee(this,Bs,void 0)),typeof i=="function"&&(ee(this,Bs,i),this.addEventListener("addtrack",i))}get onremovetrack(){return R(this,$s)}set onremovetrack(i){R(this,$s)&&(this.removeEventListener("removetrack",R(this,$s)),ee(this,$s,void 0)),typeof i=="function"&&(ee(this,$s,i),this.addEventListener("removetrack",i))}get onchange(){return R(this,Hs)}set onchange(i){R(this,Hs)&&(this.removeEventListener("change",R(this,Hs)),ee(this,Hs,void 0)),typeof i=="function"&&(ee(this,Hs,i),this.addEventListener("change",i))}};Bs=new WeakMap,$s=new WeakMap,Hs=new WeakMap,Lo=new WeakSet,Ic=function(){return V(this).trackSet};var ko,wA=class{constructor(){Ce(this,"id"),Ce(this,"kind"),Ce(this,"label",""),Ce(this,"language",""),Ce(this,"sourceBuffer"),X(this,ko,!1)}addRendition(i,e,t){let r=new $D;return r.src=i,r.codec=e,r.bitrate=t,UD(this,r),r}removeRendition(i){FD(i)}get enabled(){return R(this,ko)}set enabled(i){R(this,ko)!==i&&(ee(this,ko,i),HD(this))}};ko=new WeakMap;var yA=Nc(globalThis.HTMLMediaElement,"video"),TA=Nc(globalThis.HTMLMediaElement,"audio");function GD(i){if(!(i!=null&&i.prototype))return i;let e=Nc(i,"video");(!e||`${e}`.includes("[native code]"))&&Object.defineProperty(i.prototype,"videoTracks",{get(){return WD(this)}});let t=Nc(i,"audio");(!t||`${t}`.includes("[native code]"))&&Object.defineProperty(i.prototype,"audioTracks",{get(){return KD(this)}}),"addVideoTrack"in i.prototype||(i.prototype.addVideoTrack=function(n,a="",o=""){let l=new RA;return l.kind=n,l.label=a,l.language=o,R0(this,l),l}),"removeVideoTrack"in i.prototype||(i.prototype.removeVideoTrack=w0),"addAudioTrack"in i.prototype||(i.prototype.addAudioTrack=function(n,a="",o=""){let l=new wA;return l.kind=n,l.label=a,l.language=o,P0(this,l),l}),"removeAudioTrack"in i.prototype||(i.prototype.removeAudioTrack=O0),"videoRenditions"in i.prototype||Object.defineProperty(i.prototype,"videoRenditions",{get(){return r(this)}});let r=n=>{let a=V(n).videoRenditions;return a||(a=new D0,V(a).media=n,V(n).videoRenditions=a),a};"audioRenditions"in i.prototype||Object.defineProperty(i.prototype,"audioRenditions",{get(){return s(this)}});let s=n=>{let a=V(n).audioRenditions;return a||(a=new M0,V(a).media=n,V(n).audioRenditions=a),a};return i}function Nc(i,e){var t;if(i!=null&&i.prototype)return(t=Object.getOwnPropertyDescriptor(i.prototype,`${e}Tracks`))==null?void 0:t.get}function WD(i){var e;let t=V(i).videoTracks;if(!t&&(t=new C0,V(i).videoTracks=t,yA)){let r=yA.call((e=i.nativeEl)!=null?e:i);for(let s of r)R0(i,s);r.addEventListener("change",()=>{t.dispatchEvent(new Event("change"))}),r.addEventListener("addtrack",s=>{if([...t].some(n=>n instanceof RA)){for(let n of r)w0(n);return}R0(i,s.track)}),r.addEventListener("removetrack",s=>{w0(s.track)})}return t}function KD(i){var e;let t=V(i).audioTracks;if(!t&&(t=new N0,V(i).audioTracks=t,TA)){let r=TA.call((e=i.nativeEl)!=null?e:i);for(let s of r)P0(i,s);r.addEventListener("change",()=>{t.dispatchEvent(new Event("change"))}),r.addEventListener("addtrack",s=>{if([...t].some(n=>n instanceof wA)){for(let n of r)O0(n);return}P0(i,s.track)}),r.addEventListener("removetrack",s=>{O0(s.track)})}return t}Fc.push("castchange","entercast","leavecast");var M={BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",CUSTOM_DOMAIN:"custom-domain",DEBUG:"debug",DISABLE_TRACKING:"disable-tracking",DISABLE_COOKIES:"disable-cookies",DRM_TOKEN:"drm-token",ENV_KEY:"env-key",MAX_RESOLUTION:"max-resolution",MIN_RESOLUTION:"min-resolution",RENDITION_ORDER:"rendition-order",PROGRAM_START_TIME:"program-start-time",PROGRAM_END_TIME:"program-end-time",METADATA_URL:"metadata-url",PLAYBACK_ID:"playback-id",PLAYER_SOFTWARE_NAME:"player-software-name",PLAYER_SOFTWARE_VERSION:"player-software-version",PREFER_CMCD:"prefer-cmcd",PREFER_PLAYBACK:"prefer-playback",START_TIME:"start-time",STREAM_TYPE:"stream-type",TARGET_LIVE_WINDOW:"target-live-window",LIVE_EDGE_OFFSET:"live-edge-offset",TYPE:"type"},VD=Object.values(M),qD=vD(),YD="mux-video",Ji,Io,Rc,Ro,wc,Cc,Dc,Mc,wo,Pc,zD=class extends b0{constructor(){super(),X(this,wo),X(this,Ji,void 0),X(this,Io,void 0),X(this,Rc,void 0),X(this,Ro,{}),X(this,wc,void 0),X(this,Cc,void 0),X(this,Dc,void 0),X(this,Mc,void 0),ee(this,Rc,rA())}static get observedAttributes(){var i;return[...VD,...(i=b0.observedAttributes)!=null?i:[]]}get preferCmcd(){var i;return(i=this.getAttribute(M.PREFER_CMCD))!=null?i:void 0}set preferCmcd(i){i!==this.preferCmcd&&(i?zn.includes(i)?this.setAttribute(M.PREFER_CMCD,i):console.warn(`Invalid value for preferCmcd. Must be one of ${zn.join()}`):this.removeAttribute(M.PREFER_CMCD))}get playerInitTime(){return R(this,Rc)}get playerSoftwareName(){var i;return(i=R(this,Dc))!=null?i:YD}set playerSoftwareName(i){ee(this,Dc,i)}get playerSoftwareVersion(){var i;return(i=R(this,Cc))!=null?i:qD}set playerSoftwareVersion(i){ee(this,Cc,i)}get _hls(){var i;return(i=R(this,Ji))==null?void 0:i.engine}get mux(){var i;return(i=this.nativeEl)==null?void 0:i.mux}get error(){var i;return(i=sA(this.nativeEl))!=null?i:null}get errorTranslator(){return R(this,Mc)}set errorTranslator(i){ee(this,Mc,i)}get src(){return this.getAttribute("src")}set src(i){i!==this.src&&(i==null?this.removeAttribute("src"):this.setAttribute("src",i))}get type(){var i;return(i=this.getAttribute(M.TYPE))!=null?i:void 0}set type(i){i!==this.type&&(i?this.setAttribute(M.TYPE,i):this.removeAttribute(M.TYPE))}get autoplay(){let i=this.getAttribute("autoplay");return i===null?!1:i===""?!0:i}set autoplay(i){let e=this.autoplay;i!==e&&(i?this.setAttribute("autoplay",typeof i=="string"?i:""):this.removeAttribute("autoplay"))}get preload(){let i=this.getAttribute("preload");return i===""?"auto":["none","metadata","auto"].includes(i)?i:super.preload}set preload(i){i!=this.getAttribute("preload")&&(["","none","metadata","auto"].includes(i)?this.setAttribute("preload",i):this.removeAttribute("preload"))}get debug(){return this.getAttribute(M.DEBUG)!=null}set debug(i){i!==this.debug&&(i?this.setAttribute(M.DEBUG,""):this.removeAttribute(M.DEBUG))}get disableTracking(){return this.hasAttribute(M.DISABLE_TRACKING)}set disableTracking(i){i!==this.disableTracking&&this.toggleAttribute(M.DISABLE_TRACKING,!!i)}get disableCookies(){return this.hasAttribute(M.DISABLE_COOKIES)}set disableCookies(i){i!==this.disableCookies&&(i?this.setAttribute(M.DISABLE_COOKIES,""):this.removeAttribute(M.DISABLE_COOKIES))}get startTime(){let i=this.getAttribute(M.START_TIME);if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}set startTime(i){i!==this.startTime&&(i==null?this.removeAttribute(M.START_TIME):this.setAttribute(M.START_TIME,`${i}`))}get playbackId(){var i;return this.hasAttribute(M.PLAYBACK_ID)?this.getAttribute(M.PLAYBACK_ID):(i=_c(this.src))!=null?i:void 0}set playbackId(i){i!==this.playbackId&&(i?this.setAttribute(M.PLAYBACK_ID,i):this.removeAttribute(M.PLAYBACK_ID))}get maxResolution(){var i;return(i=this.getAttribute(M.MAX_RESOLUTION))!=null?i:void 0}set maxResolution(i){i!==this.maxResolution&&(i?this.setAttribute(M.MAX_RESOLUTION,i):this.removeAttribute(M.MAX_RESOLUTION))}get minResolution(){var i;return(i=this.getAttribute(M.MIN_RESOLUTION))!=null?i:void 0}set minResolution(i){i!==this.minResolution&&(i?this.setAttribute(M.MIN_RESOLUTION,i):this.removeAttribute(M.MIN_RESOLUTION))}get renditionOrder(){var i;return(i=this.getAttribute(M.RENDITION_ORDER))!=null?i:void 0}set renditionOrder(i){i!==this.renditionOrder&&(i?this.setAttribute(M.RENDITION_ORDER,i):this.removeAttribute(M.RENDITION_ORDER))}get programStartTime(){let i=this.getAttribute(M.PROGRAM_START_TIME);if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}set programStartTime(i){i==null?this.removeAttribute(M.PROGRAM_START_TIME):this.setAttribute(M.PROGRAM_START_TIME,`${i}`)}get programEndTime(){let i=this.getAttribute(M.PROGRAM_END_TIME);if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}set programEndTime(i){i==null?this.removeAttribute(M.PROGRAM_END_TIME):this.setAttribute(M.PROGRAM_END_TIME,`${i}`)}get customDomain(){var i;return(i=this.getAttribute(M.CUSTOM_DOMAIN))!=null?i:void 0}set customDomain(i){i!==this.customDomain&&(i?this.setAttribute(M.CUSTOM_DOMAIN,i):this.removeAttribute(M.CUSTOM_DOMAIN))}get drmToken(){var i;return(i=this.getAttribute(M.DRM_TOKEN))!=null?i:void 0}set drmToken(i){i!==this.drmToken&&(i?this.setAttribute(M.DRM_TOKEN,i):this.removeAttribute(M.DRM_TOKEN))}get ended(){return p0(this.nativeEl,this._hls)}get envKey(){var i;return(i=this.getAttribute(M.ENV_KEY))!=null?i:void 0}set envKey(i){i!==this.envKey&&(i?this.setAttribute(M.ENV_KEY,i):this.removeAttribute(M.ENV_KEY))}get beaconCollectionDomain(){var i;return(i=this.getAttribute(M.BEACON_COLLECTION_DOMAIN))!=null?i:void 0}set beaconCollectionDomain(i){i!==this.beaconCollectionDomain&&(i?this.setAttribute(M.BEACON_COLLECTION_DOMAIN,i):this.removeAttribute(M.BEACON_COLLECTION_DOMAIN))}get streamType(){var i;return(i=this.getAttribute(M.STREAM_TYPE))!=null?i:bc(this.nativeEl)}set streamType(i){i!==this.streamType&&(i?this.setAttribute(M.STREAM_TYPE,i):this.removeAttribute(M.STREAM_TYPE))}get targetLiveWindow(){return this.hasAttribute(M.TARGET_LIVE_WINDOW)?+this.getAttribute(M.TARGET_LIVE_WINDOW):nA(this.nativeEl)}set targetLiveWindow(i){i!=this.targetLiveWindow&&(i==null?this.removeAttribute(M.TARGET_LIVE_WINDOW):this.setAttribute(M.TARGET_LIVE_WINDOW,`${+i}`))}get liveEdgeStart(){var i,e;if(this.hasAttribute(M.LIVE_EDGE_OFFSET)){let{liveEdgeOffset:t}=this,r=(i=this.nativeEl.seekable.end(0))!=null?i:0,s=(e=this.nativeEl.seekable.start(0))!=null?e:0;return Math.max(s,r-t)}return aA(this.nativeEl)}get liveEdgeOffset(){if(this.hasAttribute(M.LIVE_EDGE_OFFSET))return+this.getAttribute(M.LIVE_EDGE_OFFSET)}set liveEdgeOffset(i){i!=this.targetLiveWindow&&(i==null?this.removeAttribute(M.LIVE_EDGE_OFFSET):this.setAttribute(M.LIVE_EDGE_OFFSET,`${+i}`))}get seekable(){return bo(this.nativeEl)}async addCuePoints(i){return d0(this.nativeEl,i)}get activeCuePoint(){return u0(this.nativeEl)}get cuePoints(){return Q_(this.nativeEl)}async addChapters(i){return h0(this.nativeEl,i)}get activeChapter(){return f0(this.nativeEl)}get chapters(){return J_(this.nativeEl)}getStartDate(){return eA(this.nativeEl,this._hls)}get currentPdt(){return tA(this.nativeEl,this._hls)}get preferPlayback(){let i=this.getAttribute(M.PREFER_PLAYBACK);if(i===ei.MSE||i===ei.NATIVE)return i}set preferPlayback(i){i!==this.preferPlayback&&(i===ei.MSE||i===ei.NATIVE?this.setAttribute(M.PREFER_PLAYBACK,i):this.removeAttribute(M.PREFER_PLAYBACK))}get metadata(){return{...this.getAttributeNames().filter(i=>i.startsWith("metadata-")&&![M.METADATA_URL].includes(i)).reduce((i,e)=>{let t=this.getAttribute(e);return t!=null&&(i[e.replace(/^metadata-/,"").replace(/-/g,"_")]=t),i},{}),...R(this,Ro)}}set metadata(i){ee(this,Ro,i!=null?i:{}),this.mux&&this.mux.emit("hb",R(this,Ro))}get _hlsConfig(){return R(this,wc)}set _hlsConfig(i){ee(this,wc,i)}load(){ee(this,Ji,dA(this,this.nativeEl,R(this,Ji)))}unload(){g0(this.nativeEl,R(this,Ji)),ee(this,Ji,void 0)}attributeChangedCallback(i,e,t){var r,s;switch(b0.observedAttributes.includes(i)&&!["src","autoplay","preload"].includes(i)&&super.attributeChangedCallback(i,e,t),i){case M.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=t!=null?t:void 0;break;case M.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=t!=null?t:void 0;break;case"src":{let n=!!e,a=!!t;!n&&a?Be(this,wo,Pc).call(this):n&&!a?this.unload():n&&a&&(this.unload(),Be(this,wo,Pc).call(this));break}case"autoplay":if(t===e)break;(r=R(this,Ji))==null||r.setAutoplay(this.autoplay);break;case"preload":if(t===e)break;(s=R(this,Ji))==null||s.setPreload(t);break;case M.PLAYBACK_ID:this.src=To(this);break;case M.DEBUG:{let n=this.debug;this.mux&&console.info("Cannot toggle debug mode of mux data after initialization. Make sure you set all metadata to override before setting the src."),this._hls&&(this._hls.config.debug=n);break}case M.METADATA_URL:t&&fetch(t).then(n=>n.json()).then(n=>this.metadata=n).catch(()=>console.error(`Unable to load or parse metadata JSON from metadata-url ${t}!`));break;case M.STREAM_TYPE:(t==null||t!==e)&&this.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}));break;case M.TARGET_LIVE_WINDOW:(t==null||t!==e)&&this.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0,detail:this.targetLiveWindow}));break;default:break}}connectedCallback(){var i;(i=super.connectedCallback)==null||i.call(this),this.nativeEl&&this.src&&!R(this,Ji)&&Be(this,wo,Pc).call(this)}disconnectedCallback(){this.unload()}};Ji=new WeakMap,Io=new WeakMap,Rc=new WeakMap,Ro=new WeakMap,wc=new WeakMap,Cc=new WeakMap,Dc=new WeakMap,Mc=new WeakMap,wo=new WeakSet,Pc=async function(){R(this,Io)||(await ee(this,Io,Promise.resolve()),ee(this,Io,null),this.load())};var U0=class extends wD(GD(zD)){};E0.customElements.get("mux-video")||(E0.customElements.define("mux-video",U0),E0.MuxVideoElement=U0);var CA=U0;var jD="en",Vs={code:jD};var DA="en";function ce(i,e=!0){var s,n;let t=e&&(n=(s=Vs)==null?void 0:s[i])!=null?n:i,r=e?Vs.code:DA;return new G0(t,r)}var G0=class{constructor(e,t=(r=>(r=Vs.code)!=null?r:DA)()){this.message=e,this.locale=t}format(e){return this.message.replace(/\{(\w+)\}/g,(t,r)=>{var s;return(s=e[r])!=null?s:""})}toString(){return this.message}};function MA(i){let e="";return Object.entries(i).forEach(([t,r])=>{r!=null&&(e+=`${Hc(t)}: ${r}; `)}),e?e.trim():void 0}function Hc(i){return i.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function Gc(i){return i.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase())}function ii(i){if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}function W0(i){let e=XD(i).toString();return e?"?"+e:""}function XD(i){let e={};for(let t in i)i[t]!=null&&(e[t]=i[t]);return new URLSearchParams(e)}function $r(i){let e=(i!=null?i:"").split(".")[1];if(!e)return{};let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=decodeURIComponent(atob(t).split("").map(function(s){return"%"+("00"+s.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(r)}var K0=(i,e)=>!i||!e?!1:i.contains(e)?!0:K0(i,e.getRootNode().host);var PA="mux.com",QD=()=>{try{return"2.8.0"}catch{}return"UNKNOWN"},ZD=QD(),Kc=()=>ZD,OA=(i,{token:e,customDomain:t=PA,thumbnailTime:r,programTime:s}={})=>{let n=e==null?r:void 0,{aud:a}=$r(e);if(!(e&&a!=="t"))return`https://image.${t}/${i}/thumbnail.webp${W0({token:e,time:n,program_time:s})}`},NA=(i,{token:e,customDomain:t=PA,programStartTime:r,programEndTime:s}={})=>{let{aud:n}=$r(e);if(!(e&&n!=="s"))return`https://image.${t}/${i}/storyboard.vtt${W0({token:e,format:"webp",program_start_time:r,program_end_time:s})}`},Co=i=>{if(i){if([ye.LIVE,ye.ON_DEMAND].includes(i))return i;if(i!=null&&i.includes("live"))return ye.LIVE}};var JD={crossorigin:"crossOrigin",playsinline:"playsInline"};function UA(i){var e;return(e=JD[i])!=null?e:Gc(i)}var qs,Ys,It,Wc=class{constructor(e,t){Xe(this,qs,void 0);Xe(this,Ys,void 0);Xe(this,It,[]);Kt(this,qs,e),Kt(this,Ys,t)}[Symbol.iterator](){return Ee(this,It).values()}get length(){return Ee(this,It).length}get value(){var e;return(e=Ee(this,It).join(" "))!=null?e:""}set value(e){var t;e!==this.value&&(Kt(this,It,[]),this.add(...(t=e==null?void 0:e.split(" "))!=null?t:[]))}toString(){return this.value}item(e){return Ee(this,It)[e]}values(){return Ee(this,It).values()}keys(){return Ee(this,It).keys()}forEach(e){Ee(this,It).forEach(e)}add(...e){var t,r;e.forEach(s=>{this.contains(s)||Ee(this,It).push(s)}),!(this.value===""&&!((t=Ee(this,qs))!=null&&t.hasAttribute(`${Ee(this,Ys)}`)))&&((r=Ee(this,qs))==null||r.setAttribute(`${Ee(this,Ys)}`,`${this.value}`))}remove(...e){var t;e.forEach(r=>{Ee(this,It).splice(Ee(this,It).indexOf(r),1)}),(t=Ee(this,qs))==null||t.setAttribute(`${Ee(this,Ys)}`,`${this.value}`)}contains(e){return Ee(this,It).includes(e)}toggle(e,t){return typeof t!="undefined"?t?(this.add(e),!0):(this.remove(e),!1):this.contains(e)?(this.remove(e),!1):(this.add(e),!0)}replace(e,t){this.remove(e),this.add(t)}};qs=new WeakMap,Ys=new WeakMap,It=new WeakMap;var FA=`[mux-player ${Kc()}]`;function Hr(...i){console.warn(FA,...i)}function Wt(...i){console.error(FA,...i)}function V0(i){var t;let e=(t=i.message)!=null?t:"";if(i.context&&(e+=` ${i.context}`),i.file){let r="https://github.com/muxinc/elements/blob/main/errors/";e+=` ${ce("Read more: ")}
1648
+ ${r}${i.file}`}Hr(e)}var Lt={AUTOPLAY:"autoplay",CROSSORIGIN:"crossorigin",LOOP:"loop",MUTED:"muted",PLAYSINLINE:"playsinline",PRELOAD:"preload"},zs={VOLUME:"volume",PLAYBACKRATE:"playbackrate",MUTED:"muted"},$A=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}}),eM=Fc.filter(i=>i!=="error"),tM=Object.values(Lt).filter(i=>![Lt.PLAYSINLINE].includes(i)),iM=Object.values(zs);function HA(i){i.querySelectorAll(":scope > track").forEach(e=>{var t;(t=i.media)==null||t.append(e.cloneNode())}),eM.forEach(e=>{var t;(t=i.media)==null||t.addEventListener(e,r=>{i.dispatchEvent(new Event(r.type))})})}var q0=class extends He.HTMLElement{static get observedAttributes(){return[...tM,...iM]}constructor(){super(),this.querySelectorAll(":scope > track").forEach(r=>{var s;(s=this.media)==null||s.append(r.cloneNode())});let e=r=>{for(let s of r)s.type==="childList"&&(s.removedNodes.forEach(n=>{var o,l;let a=(o=this.media)==null?void 0:o.querySelector(`track[src="${n.src}"]`);a&&((l=this.media)==null||l.removeChild(a))}),s.addedNodes.forEach(n=>{var a;(a=this.media)==null||a.append(n.cloneNode())}))};new MutationObserver(e).observe(this,{childList:!0,subtree:!0})}attributeChangedCallback(e,t,r){var s,n;switch(e){case zs.MUTED:{this.media&&(this.media.muted=r!=null,this.media.defaultMuted=r!=null);return}case zs.VOLUME:{let a=(s=ii(r))!=null?s:1;this.media&&(this.media.volume=a);return}case zs.PLAYBACKRATE:{let a=(n=ii(r))!=null?n:1;this.media&&(this.media.playbackRate=a,this.media.defaultPlaybackRate=a);return}}}play(){var e,t;return(t=(e=this.media)==null?void 0:e.play())!=null?t:Promise.reject()}pause(){var e;(e=this.media)==null||e.pause()}requestCast(e){var t;return(t=this.media)==null?void 0:t.requestCast(e)}get media(){var e;return(e=this.shadowRoot)==null?void 0:e.querySelector("mux-video")}get audioTracks(){return this.media.audioTracks}get videoTracks(){return this.media.videoTracks}get audioRenditions(){return this.media.audioRenditions}get videoRenditions(){return this.media.videoRenditions}get paused(){var e,t;return(t=(e=this.media)==null?void 0:e.paused)!=null?t:!0}get duration(){var e,t;return(t=(e=this.media)==null?void 0:e.duration)!=null?t:NaN}get ended(){var e,t;return(t=(e=this.media)==null?void 0:e.ended)!=null?t:!1}get buffered(){var e,t;return(t=(e=this.media)==null?void 0:e.buffered)!=null?t:$A}get seekable(){var e,t;return(t=(e=this.media)==null?void 0:e.seekable)!=null?t:$A}get readyState(){var e,t;return(t=(e=this.media)==null?void 0:e.readyState)!=null?t:0}get videoWidth(){var e,t;return(t=(e=this.media)==null?void 0:e.videoWidth)!=null?t:0}get videoHeight(){var e,t;return(t=(e=this.media)==null?void 0:e.videoHeight)!=null?t:0}get currentTime(){var e,t;return(t=(e=this.media)==null?void 0:e.currentTime)!=null?t:0}set currentTime(e){this.media&&(this.media.currentTime=Number(e))}get volume(){var e,t;return(t=(e=this.media)==null?void 0:e.volume)!=null?t:1}set volume(e){this.media&&(this.media.volume=Number(e))}get playbackRate(){var e,t;return(t=(e=this.media)==null?void 0:e.playbackRate)!=null?t:1}set playbackRate(e){this.media&&(this.media.playbackRate=Number(e))}get defaultPlaybackRate(){var e;return(e=ii(this.getAttribute(zs.PLAYBACKRATE)))!=null?e:1}set defaultPlaybackRate(e){e!=null?this.setAttribute(zs.PLAYBACKRATE,`${e}`):this.removeAttribute(zs.PLAYBACKRATE)}get crossOrigin(){return Do(this,Lt.CROSSORIGIN)}set crossOrigin(e){this.setAttribute(Lt.CROSSORIGIN,`${e}`)}get autoplay(){return Do(this,Lt.AUTOPLAY)!=null}set autoplay(e){e?this.setAttribute(Lt.AUTOPLAY,typeof e=="string"?e:""):this.removeAttribute(Lt.AUTOPLAY)}get loop(){return Do(this,Lt.LOOP)!=null}set loop(e){e?this.setAttribute(Lt.LOOP,""):this.removeAttribute(Lt.LOOP)}get muted(){var e,t;return(t=(e=this.media)==null?void 0:e.muted)!=null?t:!1}set muted(e){this.media&&(this.media.muted=!!e)}get defaultMuted(){return Do(this,Lt.MUTED)!=null}set defaultMuted(e){e?this.setAttribute(Lt.MUTED,""):this.removeAttribute(Lt.MUTED)}get playsInline(){return Do(this,Lt.PLAYSINLINE)!=null}set playsInline(e){Wt("playsInline is set to true by default and is not currently supported as a setter.")}get preload(){return this.media?this.media.preload:this.getAttribute("preload")}set preload(e){["","none","metadata","auto"].includes(e)?this.setAttribute(Lt.PRELOAD,e):this.removeAttribute(Lt.PRELOAD)}};function Do(i,e){return i.media?i.media.getAttribute(e):i.getAttribute(e)}var Y0=q0;var rM=Object.defineProperty,sM=(i,e,t)=>e in i?rM(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,nM=(i,e,t)=>(sM(i,typeof e!="symbol"?e+"":e,t),t),qA=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},de=(i,e,t)=>(qA(i,e,"read from private field"),t?t.call(i):e.get(i)),er=(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)},hr=(i,e,t,r)=>(qA(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),ea,Vc,js,Mo,Gr,Wr,Kr,Xs,ta,qc,_i,GA=1,WA=0,aM=1,oM={processCallback(i,e,t){if(t){for(let[r,s]of e)if(r in t){let n=t[r];typeof n=="boolean"&&s instanceof Rt&&typeof s.element[s.attributeName]=="boolean"?s.booleanValue=n:typeof n=="function"&&s instanceof Rt?s.element[s.attributeName]=n:s.value=n}}}},fr=class extends _.DocumentFragment{constructor(e,t,r=oM){var s;super(),er(this,ea,void 0),er(this,Vc,void 0),this.append(e.content.cloneNode(!0)),hr(this,ea,YA(this)),hr(this,Vc,r),(s=r.createCallback)==null||s.call(r,this,de(this,ea),t),r.processCallback(this,de(this,ea),t)}update(e){de(this,Vc).processCallback(this,de(this,ea),e)}};ea=new WeakMap;Vc=new WeakMap;var YA=(i,e=[])=>{let t,r;for(let s of i.attributes||[])if(s.value.includes("{{")){let n=new z0;for([t,r]of VA(s.value))if(!t)n.append(r);else{let a=new Rt(i,s.name,s.namespaceURI);n.append(a),e.push([r,a])}s.value=n.toString()}for(let s of i.childNodes)if(s.nodeType===GA&&!(s instanceof HTMLTemplateElement))YA(s,e);else if(s.nodeType===GA||s.data.includes("{{")){let n=[];if(s.data)for([t,r]of VA(s.data))if(!t)n.push(new Text(r));else{let a=new mr(i);n.push(a),e.push([r,a])}else if(s instanceof HTMLTemplateElement){let a=new Po(i,s);n.push(a),e.push([a.expression,a])}s.replaceWith(...n.flatMap(a=>a.replacementNodes||[a]))}return e},KA={},VA=i=>{let e="",t=0,r=KA[i],s=0,n;if(r)return r;for(r=[];n=i[s];s++)n==="{"&&i[s+1]==="{"&&i[s-1]!=="\\"&&i[s+2]&&++t==1?(e&&r.push([WA,e]),e="",s++):n==="}"&&i[s+1]==="}"&&i[s-1]!=="\\"&&!--t?(r.push([aM,e.trim()]),e="",s++):e+=n||"";return e&&r.push([WA,(t>0?"{{":"")+e]),KA[i]=r},lM=11,Yc=class{get value(){return""}set value(e){}toString(){return this.value}},zA=new WeakMap,z0=class{constructor(){er(this,js,[])}[Symbol.iterator](){return de(this,js).values()}get length(){return de(this,js).length}item(e){return de(this,js)[e]}append(...e){for(let t of e)t instanceof Rt&&zA.set(t,this),de(this,js).push(t)}toString(){return de(this,js).join("")}};js=new WeakMap;var Rt=class extends Yc{constructor(e,t,r){super(),er(this,Xs),er(this,Mo,""),er(this,Gr,void 0),er(this,Wr,void 0),er(this,Kr,void 0),hr(this,Gr,e),hr(this,Wr,t),hr(this,Kr,r)}get attributeName(){return de(this,Wr)}get attributeNamespace(){return de(this,Kr)}get element(){return de(this,Gr)}get value(){return de(this,Mo)}set value(e){de(this,Mo)!==e&&(hr(this,Mo,e),!de(this,Xs,ta)||de(this,Xs,ta).length===1?e==null?de(this,Gr).removeAttributeNS(de(this,Kr),de(this,Wr)):de(this,Gr).setAttributeNS(de(this,Kr),de(this,Wr),e):de(this,Gr).setAttributeNS(de(this,Kr),de(this,Wr),de(this,Xs,ta)))}get booleanValue(){return de(this,Gr).hasAttributeNS(de(this,Kr),de(this,Wr))}set booleanValue(e){if(!de(this,Xs,ta)||de(this,Xs,ta).length===1)this.value=e?"":null;else throw new DOMException("Value is not fully templatized")}};Mo=new WeakMap;Gr=new WeakMap;Wr=new WeakMap;Kr=new WeakMap;Xs=new WeakSet;ta=function(){return zA.get(this)};var mr=class extends Yc{constructor(e,t){super(),er(this,qc,void 0),er(this,_i,void 0),hr(this,qc,e),hr(this,_i,t?[...t]:[new Text])}get replacementNodes(){return de(this,_i)}get parentNode(){return de(this,qc)}get nextSibling(){return de(this,_i)[de(this,_i).length-1].nextSibling}get previousSibling(){return de(this,_i)[0].previousSibling}get value(){return de(this,_i).map(e=>e.textContent).join("")}set value(e){this.replace(e)}replace(...e){let t=e.flat().flatMap(r=>r==null?[new Text]:r.forEach?[...r]:r.nodeType===lM?[...r.childNodes]:r.nodeType?[r]:[new Text(r)]);t.length||t.push(new Text),hr(this,_i,dM(de(this,_i)[0].parentNode,de(this,_i),t,this.nextSibling))}};qc=new WeakMap;_i=new WeakMap;var Po=class extends mr{constructor(e,t){let r=t.getAttribute("directive")||t.getAttribute("type"),s=t.getAttribute("expression")||t.getAttribute(r)||"";s.startsWith("{{")&&(s=s.trim().slice(2,-2).trim()),super(e),nM(this,"directive"),this.expression=s,this.template=t,this.directive=r}};function dM(i,e,t,r=null){let s=0,n,a,o,l=t.length,d=e.length;for(;s<l&&s<d&&e[s]==t[s];)s++;for(;s<l&&s<d&&t[l-1]==e[d-1];)r=t[--d,--l];if(s==d)for(;s<l;)i.insertBefore(t[s++],r);if(s==l)for(;s<d;)i.removeChild(e[s++]);else{for(n=e[s];s<l;)o=t[s++],a=n?n.nextSibling:r,n==o?n=a:s<l&&t[s]==a?(i.replaceChild(o,n),n=a):i.insertBefore(o,n);for(;n!=r;)a=n.nextSibling,i.removeChild(n),n=a}return t}var jA={string:i=>String(i)},jc=class{constructor(e){this.template=e,this.state=void 0}},Qs=new WeakMap,Zs=new WeakMap,j0={partial:(i,e)=>{e[i.expression]=new jc(i.template)},if:(i,e)=>{var t;if(QA(i.expression,e))if(Qs.get(i)!==i.template){Qs.set(i,i.template);let r=new fr(i.template,e,Xc);i.replace(r),Zs.set(i,r)}else(t=Zs.get(i))==null||t.update(e);else i.replace(""),Qs.delete(i),Zs.delete(i)}},uM=Object.keys(j0),Xc={processCallback(i,e,t){var r,s;if(t)for(let[n,a]of e){if(a instanceof Po){if(!a.directive){let l=uM.find(d=>a.template.hasAttribute(d));l&&(a.directive=l,a.expression=a.template.getAttribute(l))}(r=j0[a.directive])==null||r.call(j0,a,t);continue}let o=QA(n,t);if(o instanceof jc){Qs.get(a)!==o.template?(Qs.set(a,o.template),o=new fr(o.template,o.state,Xc),a.value=o,Zs.set(a,o)):(s=Zs.get(a))==null||s.update(o.state);continue}o?(a instanceof Rt&&a.attributeName.startsWith("aria-")&&(o=String(o)),a instanceof Rt?typeof o=="boolean"?a.booleanValue=o:typeof o=="function"?a.element[a.attributeName]=o:a.value=o:(a.value=o,Qs.delete(a),Zs.delete(a))):a instanceof Rt?a.value=void 0:(a.value=void 0,Qs.delete(a),Zs.delete(a))}}},XA={"!":i=>!i,"!!":i=>!!i,"==":(i,e)=>i==e,"!=":(i,e)=>i!=e,">":(i,e)=>i>e,">=":(i,e)=>i>=e,"<":(i,e)=>i<e,"<=":(i,e)=>i<=e,"??":(i,e)=>i!=null?i:e,"|":(i,e)=>{var t;return(t=jA[e])==null?void 0:t.call(jA,i)}};function cM(i){return hM(i,{boolean:/true|false/,number:/-?\d+\.?\d*/,string:/(["'])((?:\\.|[^\\])*?)\1/,operator:/[!=><][=!]?|\?\?|\|/,ws:/\s+/,param:/[$a-z_][$\w]*/i}).filter(({type:e})=>e!=="ws")}function QA(i,e={}){var t,r,s,n,a,o,l;let d=cM(i);if(d.length===0||d.some(({type:u})=>!u))return Oo(i);if(((t=d[0])==null?void 0:t.token)===">"){let u=e[(r=d[1])==null?void 0:r.token];if(!u)return Oo(i);let c={...e};u.state=c;let h=d.slice(2);for(let f=0;f<h.length;f+=3){let m=(s=h[f])==null?void 0:s.token,p=(n=h[f+1])==null?void 0:n.token,g=(a=h[f+2])==null?void 0:a.token;m&&p==="="&&(c[m]=No(g,e))}return u}if(d.length===1)return zc(d[0])?No(d[0].token,e):Oo(i);if(d.length===2){let u=(o=d[0])==null?void 0:o.token,c=XA[u];if(!c||!zc(d[1]))return Oo(i);let h=No(d[1].token,e);return c(h)}if(d.length===3){let u=(l=d[1])==null?void 0:l.token,c=XA[u];if(!c||!zc(d[0])||!zc(d[2]))return Oo(i);let h=No(d[0].token,e);if(u==="|")return c(h,d[2].token);let f=No(d[2].token,e);return c(h,f)}}function Oo(i){return console.warn(`Warning: invalid expression \`${i}\``),!1}function zc({type:i}){return["number","boolean","string","param"].includes(i)}function No(i,e){let t=i[0],r=i.slice(-1);return i==="true"||i==="false"?i==="true":t===r&&["'",'"'].includes(t)?i.slice(1,-1):zo(i)?parseFloat(i):e[i]}function hM(i,e){let t,r,s,n=[];for(;i;){s=null,t=i.length;for(let a in e)r=e[a].exec(i),r&&r.index<t&&(s={token:r[0],type:a,matches:r.slice(1)},t=r.index);t&&n.push({token:i.substr(0,t),type:void 0}),s&&n.push(s),i=i.substr(t+(s?s.token.length:0))}return n}var fM=Object.defineProperty,mM=(i,e,t)=>e in i?fM(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Fo=(i,e,t)=>(mM(i,typeof e!="symbol"?e+"":e,t),t),tv=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Z0=(i,e,t)=>(tv(i,e,"read from private field"),t?t.call(i):e.get(i)),Uo=(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)},Js=(i,e,t,r)=>(tv(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),X0=(i,e,t)=>(tv(i,e,"access private method"),t),ia,Qc,ra,J0,ZA,Zc,ev,Q0={mediatargetlivewindow:"targetlivewindow",mediastreamtype:"streamtype"},JA=O.createElement("template");JA.innerHTML=`
1645
1649
  <style>
1646
1650
  :host {
1647
1651
  display: inline-block;
@@ -1665,7 +1669,7 @@ ${r}${i.file}`}$r(e)}var Lt={AUTOPLAY:"autoplay",CROSSORIGIN:"crossorigin",LOOP:
1665
1669
  display: none;
1666
1670
  }
1667
1671
  </style>
1668
- `;var Vr=class extends A.HTMLElement{constructor(){super(),Uo(this,Q0),Uo(this,zc),Fo(this,"renderRoot"),Fo(this,"renderer"),Uo(this,ia,void 0),Uo(this,Yc,void 0),Uo(this,ra,void 0),this.shadowRoot?this.renderRoot=this.shadowRoot:(this.renderRoot=this.attachShadow({mode:"open"}),this.createRenderer());let e=new MutationObserver(t=>{var r;this.mediaController&&!((r=this.mediaController)!=null&&r.breakpointsComputed)||t.some(s=>{let n=s.target;return n===this?!0:n.localName!=="media-controller"?!1:!!(j0[s.attributeName]||s.attributeName.startsWith("breakpoint"))})&&this.render()});e.observe(this,{attributes:!0}),e.observe(this.renderRoot,{attributes:!0,subtree:!0}),this.addEventListener(ir.BREAKPOINTS_COMPUTED,this.render),z0(this,Q0,e1).call(this,"template")}get mediaController(){return this.renderRoot.querySelector("media-controller")}get template(){var e;return(e=X0(this,ia))!=null?e:this.constructor.template}set template(e){Zs(this,ra,null),Zs(this,ia,e),this.createRenderer()}get props(){var e,t,r;let s=[...Array.from((t=(e=this.mediaController)==null?void 0:e.attributes)!=null?t:[]).filter(({name:a})=>j0[a]||a.startsWith("breakpoint")),...Array.from(this.attributes)],n={};for(let a of s){let o=(r=j0[a.name])!=null?r:Av(a.name),{value:l}=a;l!=null?(zo(l)&&(l=parseFloat(l)),n[o]=l===""?!0:l):n[o]=!1}return n}attributeChangedCallback(e,t,r){e==="template"&&t!=r&&z0(this,zc,Z0).call(this)}connectedCallback(){z0(this,zc,Z0).call(this)}createRenderer(){this.template&&this.template!==X0(this,Yc)&&(Zs(this,Yc,this.template),this.renderer=new fr(this.template,this.props,this.constructor.processor),this.renderRoot.textContent="",this.renderRoot.append(t1.content.cloneNode(!0),this.renderer))}render(){var e;(e=this.renderer)==null||e.update(this.props)}};ia=new WeakMap;Yc=new WeakMap;ra=new WeakMap;Q0=new WeakSet;e1=function(i){if(Object.prototype.hasOwnProperty.call(this,i)){let e=this[i];delete this[i],this[i]=e}};zc=new WeakSet;Z0=function(){var i;let e=this.getAttribute("template");if(!e||e===X0(this,ra))return;let t=this.getRootNode(),r=(i=t==null?void 0:t.getElementById)==null?void 0:i.call(t,e);if(r){Zs(this,ra,e),Zs(this,ia,r),this.createRenderer();return}oM(e)&&(Zs(this,ra,e),lM(e).then(s=>{let n=O.createElement("template");n.innerHTML=s,Zs(this,ia,n),this.createRenderer()}).catch(console.error))};Fo(Vr,"template");Fo(Vr,"observedAttributes",["template"]);Fo(Vr,"processor",qc);function oM(i){if(!/^(\/|\.\/|https?:\/\/)/.test(i))return!1;let e=/^https?:\/\//.test(i)?void 0:location.origin;try{new URL(i,e)}catch{return!1}return!0}async function lM(i){let e=await fetch(i);if(e.status!==200)throw new Error(`Failed to load resource: the server responded with a status of ${e.status}`);return e.text()}A.customElements.get("media-theme")||A.customElements.define("media-theme",Vr);var i1=`:host {
1672
+ `;var Vr=class extends _.HTMLElement{constructor(){super(),Uo(this,J0),Uo(this,Zc),Fo(this,"renderRoot"),Fo(this,"renderer"),Uo(this,ia,void 0),Uo(this,Qc,void 0),Uo(this,ra,void 0),this.shadowRoot?this.renderRoot=this.shadowRoot:(this.renderRoot=this.attachShadow({mode:"open"}),this.createRenderer());let e=new MutationObserver(t=>{var r;this.mediaController&&!((r=this.mediaController)!=null&&r.breakpointsComputed)||t.some(s=>{let n=s.target;return n===this?!0:n.localName!=="media-controller"?!1:!!(Q0[s.attributeName]||s.attributeName.startsWith("breakpoint"))})&&this.render()});e.observe(this,{attributes:!0}),e.observe(this.renderRoot,{attributes:!0,subtree:!0}),this.addEventListener(ir.BREAKPOINTS_COMPUTED,this.render),X0(this,J0,ZA).call(this,"template")}get mediaController(){return this.renderRoot.querySelector("media-controller")}get template(){var e;return(e=Z0(this,ia))!=null?e:this.constructor.template}set template(e){Js(this,ra,null),Js(this,ia,e),this.createRenderer()}get props(){var e,t,r;let s=[...Array.from((t=(e=this.mediaController)==null?void 0:e.attributes)!=null?t:[]).filter(({name:a})=>Q0[a]||a.startsWith("breakpoint")),...Array.from(this.attributes)],n={};for(let a of s){let o=(r=Q0[a.name])!=null?r:xv(a.name),{value:l}=a;l!=null?(zo(l)&&(l=parseFloat(l)),n[o]=l===""?!0:l):n[o]=!1}return n}attributeChangedCallback(e,t,r){e==="template"&&t!=r&&X0(this,Zc,ev).call(this)}connectedCallback(){X0(this,Zc,ev).call(this)}createRenderer(){this.template&&this.template!==Z0(this,Qc)&&(Js(this,Qc,this.template),this.renderer=new fr(this.template,this.props,this.constructor.processor),this.renderRoot.textContent="",this.renderRoot.append(JA.content.cloneNode(!0),this.renderer))}render(){var e;(e=this.renderer)==null||e.update(this.props)}};ia=new WeakMap;Qc=new WeakMap;ra=new WeakMap;J0=new WeakSet;ZA=function(i){if(Object.prototype.hasOwnProperty.call(this,i)){let e=this[i];delete this[i],this[i]=e}};Zc=new WeakSet;ev=function(){var i;let e=this.getAttribute("template");if(!e||e===Z0(this,ra))return;let t=this.getRootNode(),r=(i=t==null?void 0:t.getElementById)==null?void 0:i.call(t,e);if(r){Js(this,ra,e),Js(this,ia,r),this.createRenderer();return}pM(e)&&(Js(this,ra,e),gM(e).then(s=>{let n=O.createElement("template");n.innerHTML=s,Js(this,ia,n),this.createRenderer()}).catch(console.error))};Fo(Vr,"template");Fo(Vr,"observedAttributes",["template"]);Fo(Vr,"processor",Xc);function pM(i){if(!/^(\/|\.\/|https?:\/\/)/.test(i))return!1;let e=/^https?:\/\//.test(i)?void 0:location.origin;try{new URL(i,e)}catch{return!1}return!0}async function gM(i){let e=await fetch(i);if(e.status!==200)throw new Error(`Failed to load resource: the server responded with a status of ${e.status}`);return e.text()}_.customElements.get("media-theme")||_.customElements.define("media-theme",Vr);var e1=`:host {
1669
1673
  --media-control-display: var(--controls);
1670
1674
  --media-loading-indicator-display: var(--loading-indicator);
1671
1675
  --media-dialog-display: var(--dialog);
@@ -1681,7 +1685,7 @@ ${r}${i.file}`}$r(e)}var Lt={AUTOPLAY:"autoplay",CROSSORIGIN:"crossorigin",LOOP:
1681
1685
  --media-airplay-button-display: var(--airplay-button);
1682
1686
  --media-pip-button-display: var(--pip-button);
1683
1687
  --media-fullscreen-button-display: var(--fullscreen-button);
1684
- --media-cast-button-display: var(--cast-button);
1688
+ --media-cast-button-display: var(--cast-button, var(--_cast-button-drm-display));
1685
1689
  --media-playback-rate-button-display: var(--playback-rate-button);
1686
1690
  --media-playback-rate-selectmenu-display: var(--playback-rate-selectmenu);
1687
1691
  --media-volume-range-display: var(--volume-range);
@@ -1739,7 +1743,7 @@ media-poster-image:not([src]):not([placeholdersrc]) {
1739
1743
  --media-airplay-button-display: var(--airplay-button, var(--top-airplay-button));
1740
1744
  --media-pip-button-display: var(--pip-button, var(--top-pip-button));
1741
1745
  --media-fullscreen-button-display: var(--fullscreen-button, var(--top-fullscreen-button));
1742
- --media-cast-button-display: var(--cast-button, var(--top-cast-button));
1746
+ --media-cast-button-display: var(--cast-button, var(--top-cast-button, var(--_cast-button-drm-display)));
1743
1747
  --media-playback-rate-button-display: var(--playback-rate-button, var(--top-playback-rate-button));
1744
1748
  --media-playback-rate-selectmenu-display: var(
1745
1749
  --captions-selectmenu,
@@ -1770,7 +1774,7 @@ media-poster-image:not([src]):not([placeholdersrc]) {
1770
1774
  --media-airplay-button-display: var(--airplay-button, var(--center-airplay-button));
1771
1775
  --media-pip-button-display: var(--pip-button, var(--center-pip-button));
1772
1776
  --media-fullscreen-button-display: var(--fullscreen-button, var(--center-fullscreen-button));
1773
- --media-cast-button-display: var(--cast-button, var(--center-cast-button));
1777
+ --media-cast-button-display: var(--cast-button, var(--center-cast-button, var(--_cast-button-drm-display)));
1774
1778
  --media-playback-rate-button-display: var(--playback-rate-button, var(--center-playback-rate-button));
1775
1779
  --media-playback-rate-selectmenu-display: var(
1776
1780
  --playback-rate-selectmenu,
@@ -1800,7 +1804,7 @@ media-poster-image:not([src]):not([placeholdersrc]) {
1800
1804
  --media-airplay-button-display: var(--airplay-button, var(--bottom-airplay-button));
1801
1805
  --media-pip-button-display: var(--pip-button, var(--bottom-pip-button));
1802
1806
  --media-fullscreen-button-display: var(--fullscreen-button, var(--bottom-fullscreen-button));
1803
- --media-cast-button-display: var(--cast-button, var(--bottom-cast-button));
1807
+ --media-cast-button-display: var(--cast-button, var(--bottom-cast-button, var(--_cast-button-drm-display)));
1804
1808
  --media-playback-rate-button-display: var(--playback-rate-button, var(--bottom-playback-rate-button));
1805
1809
  --media-playback-rate-selectmenu-display: var(
1806
1810
  --playback-rate-selectmenu,
@@ -1812,7 +1816,7 @@ media-poster-image:not([src]):not([placeholdersrc]) {
1812
1816
  --media-duration-display-display: var(--duration-display, var(--bottom-duration-display));
1813
1817
  --media-title-display-display: var(--title-display, var(--bottom-title-display));
1814
1818
  }
1815
- `;var s1=`
1819
+ `;var i1=`
1816
1820
  :host {
1817
1821
  z-index: 100;
1818
1822
  display: var(--media-dialog-display, flex);
@@ -1864,17 +1868,17 @@ media-poster-image:not([src]):not([placeholdersrc]) {
1864
1868
  text-align: center;
1865
1869
  line-height: 1.4;
1866
1870
  }
1867
- `,n1=Ft.createElement("template");n1.innerHTML=`
1871
+ `,r1=Ft.createElement("template");r1.innerHTML=`
1868
1872
  <style>
1869
- ${s1}
1873
+ ${i1}
1870
1874
  </style>
1871
1875
 
1872
1876
  <div class="dialog">
1873
1877
  <slot></slot>
1874
1878
  </div>
1875
- `;var Kr=class extends $e.HTMLElement{constructor(){var t;super();this.attachShadow({mode:"open"}),(t=this.shadowRoot)==null||t.appendChild(this.constructor.template.content.cloneNode(!0))}show(){this.setAttribute("open",""),this.dispatchEvent(new CustomEvent("open",{composed:!0,bubbles:!0})),r1(this)}close(){this.hasAttribute("open")&&(this.removeAttribute("open"),this.dispatchEvent(new CustomEvent("close",{composed:!0,bubbles:!0})),uM(this))}attributeChangedCallback(t,r,s){t==="open"&&r!==s&&(s!=null?this.show():this.close())}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","dialog"),this.hasAttribute("open")&&r1(this)}};Kr.styles=s1,Kr.template=n1,Kr.observedAttributes=["open"];function r1(i){let e=new CustomEvent("initfocus",{composed:!0,bubbles:!0,cancelable:!0});if(i.dispatchEvent(e),e.defaultPrevented)return;let t=i.querySelector("[autofocus]:not([disabled])");!t&&i.tabIndex>=0&&(t=i),t||(t=a1(i.shadowRoot)),i._previouslyFocusedElement=Ft.activeElement,Ft.activeElement instanceof HTMLElement&&Ft.activeElement.blur(),i.addEventListener("transitionend",()=>{t instanceof HTMLElement&&t.focus({preventScroll:!0})},{once:!0})}function a1(i){let t=["button","input","keygen","select","textarea"].map(function(s){return s+":not([disabled])"});t.push('[tabindex]:not([disabled]):not([tabindex=""])');let r=i==null?void 0:i.querySelector(t.join(", "));if(!r&&"attachShadow"in Element.prototype){let s=(i==null?void 0:i.querySelectorAll("*"))||[];for(let n=0;n<s.length&&!(s[n].tagName&&s[n].shadowRoot&&(r=a1(s[n].shadowRoot),r));n++);}return r}function uM(i){i._previouslyFocusedElement instanceof HTMLElement&&i._previouslyFocusedElement.focus()}$e.customElements.get("media-dialog")||($e.customElements.define("media-dialog",Kr),$e.MediaDialog=Kr);var ev=Kr;var o1=Ft.createElement("template");o1.innerHTML=`
1879
+ `;var qr=class extends He.HTMLElement{constructor(){var t;super();this.attachShadow({mode:"open"}),(t=this.shadowRoot)==null||t.appendChild(this.constructor.template.content.cloneNode(!0))}show(){this.setAttribute("open",""),this.dispatchEvent(new CustomEvent("open",{composed:!0,bubbles:!0})),t1(this)}close(){this.hasAttribute("open")&&(this.removeAttribute("open"),this.dispatchEvent(new CustomEvent("close",{composed:!0,bubbles:!0})),EM(this))}attributeChangedCallback(t,r,s){t==="open"&&r!==s&&(s!=null?this.show():this.close())}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","dialog"),this.hasAttribute("open")&&t1(this)}};qr.styles=i1,qr.template=r1,qr.observedAttributes=["open"];function t1(i){let e=new CustomEvent("initfocus",{composed:!0,bubbles:!0,cancelable:!0});if(i.dispatchEvent(e),e.defaultPrevented)return;let t=i.querySelector("[autofocus]:not([disabled])");!t&&i.tabIndex>=0&&(t=i),t||(t=s1(i.shadowRoot)),i._previouslyFocusedElement=Ft.activeElement,Ft.activeElement instanceof HTMLElement&&Ft.activeElement.blur(),i.addEventListener("transitionend",()=>{t instanceof HTMLElement&&t.focus({preventScroll:!0})},{once:!0})}function s1(i){let t=["button","input","keygen","select","textarea"].map(function(s){return s+":not([disabled])"});t.push('[tabindex]:not([disabled]):not([tabindex=""])');let r=i==null?void 0:i.querySelector(t.join(", "));if(!r&&"attachShadow"in Element.prototype){let s=(i==null?void 0:i.querySelectorAll("*"))||[];for(let n=0;n<s.length&&!(s[n].tagName&&s[n].shadowRoot&&(r=s1(s[n].shadowRoot),r));n++);}return r}function EM(i){i._previouslyFocusedElement instanceof HTMLElement&&i._previouslyFocusedElement.focus()}He.customElements.get("media-dialog")||(He.customElements.define("media-dialog",qr),He.MediaDialog=qr);var iv=qr;var n1=Ft.createElement("template");n1.innerHTML=`
1876
1880
  <style>
1877
- ${ev.styles}
1881
+ ${iv.styles}
1878
1882
 
1879
1883
  .close {
1880
1884
  background: none;
@@ -1903,22 +1907,23 @@ media-poster-image:not([src]):not([placeholdersrc]) {
1903
1907
  </svg>
1904
1908
  </button>
1905
1909
  </slot>
1906
- `;var Bo=class extends ev{constructor(){var e,t;super(),(t=(e=this.shadowRoot)==null?void 0:e.querySelector(".close"))==null||t.addEventListener("click",()=>{this.close()})}};Bo.template=o1;$e.customElements.get("mxp-dialog")||($e.customElements.define("mxp-dialog",Bo),$e.MxpDialog=Bo);var $o=new WeakMap,iv=class i{constructor(e,t){this.element=e;this.type=t;this.element.addEventListener(this.type,this);let r=$o.get(this.element);r&&r.set(this.type,this)}set(e){if(typeof e=="function")this.handleEvent=e.bind(this.element);else if(typeof e=="object"&&typeof e.handleEvent=="function")this.handleEvent=e.handleEvent.bind(e);else{this.element.removeEventListener(this.type,this);let t=$o.get(this.element);t&&t.delete(this.type)}}static for(e){$o.has(e.element)||$o.set(e.element,new Map);let t=e.attributeName.slice(2),r=$o.get(e.element);return r&&r.has(t)?r.get(t):new i(e.element,t)}};function cM(i,e){return i instanceof Rt&&i.attributeName.startsWith("on")?(iv.for(i).set(e),i.element.removeAttributeNS(i.attributeNamespace,i.attributeName),!0):!1}function hM(i,e){return e instanceof jc&&i instanceof mr?(e.renderInto(i),!0):!1}function fM(i,e){return e instanceof DocumentFragment&&i instanceof mr?(e.childNodes.length&&i.replace(...e.childNodes),!0):!1}function mM(i,e){if(i instanceof Rt){let t=i.attributeNamespace,r=i.element.getAttributeNS(t,i.attributeName);return String(e)!==r&&(i.value=String(e)),!0}return i.value=String(e),!0}function pM(i,e){if(i instanceof Rt&&e instanceof Element){let t=i.element;return t[i.attributeName]!==e&&(i.element.removeAttributeNS(i.attributeNamespace,i.attributeName),t[i.attributeName]=e),!0}return!1}function gM(i,e){if(typeof e=="boolean"&&i instanceof Rt){let t=i.attributeNamespace,r=i.element.hasAttributeNS(t,i.attributeName);return e!==r&&(i.booleanValue=e),!0}return!1}function vM(i,e){return e===!1&&i instanceof mr?(i.replace(""),!0):!1}function EM(i,e){pM(i,e)||gM(i,e)||cM(i,e)||vM(i,e)||hM(i,e)||fM(i,e)||mM(i,e)}var tv=new Map,l1=new WeakMap,d1=new WeakMap,jc=class{constructor(e,t,r){this.strings=e;this.values=t;this.processor=r;this.stringsKey=this.strings.join("")}get template(){if(tv.has(this.stringsKey))return tv.get(this.stringsKey);{let e=Ft.createElement("template"),t=this.strings.length-1;return e.innerHTML=this.strings.reduce((r,s,n)=>r+s+(n<t?`{{ ${n} }}`:""),""),tv.set(this.stringsKey,e),e}}renderInto(e){var s;let t=this.template;if(l1.get(e)!==t){l1.set(e,t);let n=new fr(t,this.values,this.processor);d1.set(e,n),e instanceof mr?e.replace(...n.children):e.appendChild(n);return}let r=d1.get(e);(s=r==null?void 0:r.update)==null||s.call(r,this.values)}},bM={processCallback(i,e,t){var r;if(t){for(let[s,n]of e)if(s in t){let a=(r=t[s])!=null?r:"";EM(n,a)}}}};function pr(i,...e){return new jc(i,e,bM)}function u1(i,e){i.renderInto(e)}var c1=i=>pr`
1910
+ `;var Bo=class extends iv{constructor(){var e,t;super(),(t=(e=this.shadowRoot)==null?void 0:e.querySelector(".close"))==null||t.addEventListener("click",()=>{this.close()})}};Bo.template=n1;He.customElements.get("mxp-dialog")||(He.customElements.define("mxp-dialog",Bo),He.MxpDialog=Bo);var $o=new WeakMap,sv=class i{constructor(e,t){this.element=e;this.type=t;this.element.addEventListener(this.type,this);let r=$o.get(this.element);r&&r.set(this.type,this)}set(e){if(typeof e=="function")this.handleEvent=e.bind(this.element);else if(typeof e=="object"&&typeof e.handleEvent=="function")this.handleEvent=e.handleEvent.bind(e);else{this.element.removeEventListener(this.type,this);let t=$o.get(this.element);t&&t.delete(this.type)}}static for(e){$o.has(e.element)||$o.set(e.element,new Map);let t=e.attributeName.slice(2),r=$o.get(e.element);return r&&r.has(t)?r.get(t):new i(e.element,t)}};function bM(i,e){return i instanceof Rt&&i.attributeName.startsWith("on")?(sv.for(i).set(e),i.element.removeAttributeNS(i.attributeNamespace,i.attributeName),!0):!1}function yM(i,e){return e instanceof Jc&&i instanceof mr?(e.renderInto(i),!0):!1}function TM(i,e){return e instanceof DocumentFragment&&i instanceof mr?(e.childNodes.length&&i.replace(...e.childNodes),!0):!1}function _M(i,e){if(i instanceof Rt){let t=i.attributeNamespace,r=i.element.getAttributeNS(t,i.attributeName);return String(e)!==r&&(i.value=String(e)),!0}return i.value=String(e),!0}function AM(i,e){if(i instanceof Rt&&e instanceof Element){let t=i.element;return t[i.attributeName]!==e&&(i.element.removeAttributeNS(i.attributeNamespace,i.attributeName),t[i.attributeName]=e),!0}return!1}function SM(i,e){if(typeof e=="boolean"&&i instanceof Rt){let t=i.attributeNamespace,r=i.element.hasAttributeNS(t,i.attributeName);return e!==r&&(i.booleanValue=e),!0}return!1}function xM(i,e){return e===!1&&i instanceof mr?(i.replace(""),!0):!1}function LM(i,e){AM(i,e)||SM(i,e)||bM(i,e)||xM(i,e)||yM(i,e)||TM(i,e)||_M(i,e)}var rv=new Map,a1=new WeakMap,o1=new WeakMap,Jc=class{constructor(e,t,r){this.strings=e;this.values=t;this.processor=r;this.stringsKey=this.strings.join("")}get template(){if(rv.has(this.stringsKey))return rv.get(this.stringsKey);{let e=Ft.createElement("template"),t=this.strings.length-1;return e.innerHTML=this.strings.reduce((r,s,n)=>r+s+(n<t?`{{ ${n} }}`:""),""),rv.set(this.stringsKey,e),e}}renderInto(e){var s;let t=this.template;if(a1.get(e)!==t){a1.set(e,t);let n=new fr(t,this.values,this.processor);o1.set(e,n),e instanceof mr?e.replace(...n.children):e.appendChild(n);return}let r=o1.get(e);(s=r==null?void 0:r.update)==null||s.call(r,this.values)}},kM={processCallback(i,e,t){var r;if(t){for(let[s,n]of e)if(s in t){let a=(r=t[s])!=null?r:"";LM(n,a)}}}};function pr(i,...e){return new Jc(i,e,kM)}function l1(i,e){i.renderInto(e)}var IM=i=>{let{tokens:e}=i;return e.drm?":host { --_cast-button-drm-display: none; }":""},d1=i=>pr`
1907
1911
  <style>
1908
- ${i1}
1912
+ ${IM(i)}
1913
+ ${e1}
1909
1914
  </style>
1910
- ${AM(i)}
1911
- `,yM=i=>{let e=i.hotKeys?`${i.hotKeys}`:"";return Co(i.streamType)==="live"&&(e+=" noarrowleft noarrowright"),e},TM={TOP:"top",CENTER:"center",BOTTOM:"bottom",LAYER:"layer",MEDIA_LAYER:"media-layer",POSTER_LAYER:"poster-layer",VERTICAL_LAYER:"vertical-layer",CENTERED_LAYER:"centered-layer",GESTURE_LAYER:"gesture-layer",CONTROLLER_LAYER:"controller",BUTTON:"button",RANGE:"range",DISPLAY:"display",CONTROL_BAR:"control-bar",SELECTMENU:"selectmenu",LISTBOX:"listbox",OPTION:"option",POSTER:"poster",LIVE:"live",PLAY:"play",PRE_PLAY:"pre-play",SEEK_BACKWARD:"seek-backward",SEEK_FORWARD:"seek-forward",MUTE:"mute",CAPTIONS:"captions",AIRPLAY:"airplay",PIP:"pip",FULLSCREEN:"fullscreen",CAST:"cast",PLAYBACK_RATE:"playback-rate",VOLUME:"volume",TIME:"time",TITLE:"title",AUDIO_TRACK:"audio-track",RENDITION:"rendition"},_M=Object.values(TM).join(", "),AM=i=>{var e,t,r,s,n,a,o,l,d,u,c,h,f,m,p,g,E,T,y,S,_,L,x,w,M,k,D,U,B,X,z,V,se,ae,W,G;return pr`
1915
+ ${DM(i)}
1916
+ `,RM=i=>{let e=i.hotKeys?`${i.hotKeys}`:"";return Co(i.streamType)==="live"&&(e+=" noarrowleft noarrowright"),e},wM={TOP:"top",CENTER:"center",BOTTOM:"bottom",LAYER:"layer",MEDIA_LAYER:"media-layer",POSTER_LAYER:"poster-layer",VERTICAL_LAYER:"vertical-layer",CENTERED_LAYER:"centered-layer",GESTURE_LAYER:"gesture-layer",CONTROLLER_LAYER:"controller",BUTTON:"button",RANGE:"range",DISPLAY:"display",CONTROL_BAR:"control-bar",SELECTMENU:"selectmenu",LISTBOX:"listbox",OPTION:"option",POSTER:"poster",LIVE:"live",PLAY:"play",PRE_PLAY:"pre-play",SEEK_BACKWARD:"seek-backward",SEEK_FORWARD:"seek-forward",MUTE:"mute",CAPTIONS:"captions",AIRPLAY:"airplay",PIP:"pip",FULLSCREEN:"fullscreen",CAST:"cast",PLAYBACK_RATE:"playback-rate",VOLUME:"volume",TIME:"time",TITLE:"title",AUDIO_TRACK:"audio-track",RENDITION:"rendition"},CM=Object.values(wM).join(", "),DM=i=>{var e,t,r,s,n,a,o,l,d,u,c,h,f,m,p,g,E,T,y,S,A,L,x,w,P,k,D,U,F,z,j,K,se,oe,W,G,ne,Q;return pr`
1912
1917
  <media-theme
1913
1918
  template="${i.themeTemplate||!1}"
1914
1919
  defaultstreamtype="${(e=i.defaultStreamType)!=null?e:!1}"
1915
- hotkeys="${yM(i)||!1}"
1920
+ hotkeys="${RM(i)||!1}"
1916
1921
  nohotkeys="${i.noHotKeys||!i.hasSrc||i.isDialogOpen||!1}"
1917
1922
  noautoseektolive="${!!((t=i.streamType)!=null&&t.includes(ye.LIVE))&&i.targetLiveWindow!==0}"
1918
1923
  novolumepref="${i.novolumepref||!1}"
1919
1924
  disabled="${!i.hasSrc||i.isDialogOpen}"
1920
1925
  audio="${(r=i.audio)!=null?r:!1}"
1921
- style="${(s=OA({"--media-primary-color":i.primaryColor,"--media-secondary-color":i.secondaryColor,"--media-accent-color":i.accentColor}))!=null?s:!1}"
1926
+ style="${(s=MA({"--media-primary-color":i.primaryColor,"--media-secondary-color":i.secondaryColor,"--media-accent-color":i.accentColor}))!=null?s:!1}"
1922
1927
  defaultsubtitles="${!i.defaultHiddenCaptions}"
1923
1928
  forwardseekoffset="${(n=i.forwardSeekOffset)!=null?n:!1}"
1924
1929
  backwardseekoffset="${(a=i.backwardSeekOffset)!=null?a:!1}"
@@ -1927,7 +1932,7 @@ media-poster-image:not([src]):not([placeholdersrc]) {
1927
1932
  defaultduration="${(d=i.defaultDuration)!=null?d:!1}"
1928
1933
  hideduration="${(u=i.hideDuration)!=null?u:!1}"
1929
1934
  title="${(c=i.title)!=null?c:!1}"
1930
- exportparts="${_M}"
1935
+ exportparts="${CM}"
1931
1936
  >
1932
1937
  <mux-video
1933
1938
  slot="media"
@@ -1941,17 +1946,18 @@ media-poster-image:not([src]):not([placeholdersrc]) {
1941
1946
  preload="${(T=i.preload)!=null?T:!1}"
1942
1947
  debug="${(y=i.debug)!=null?y:!1}"
1943
1948
  prefer-cmcd="${(S=i.preferCmcd)!=null?S:!1}"
1944
- disable-tracking="${(_=i.disableTracking)!=null?_:!1}"
1949
+ disable-tracking="${(A=i.disableTracking)!=null?A:!1}"
1945
1950
  disable-cookies="${(L=i.disableCookies)!=null?L:!1}"
1946
1951
  prefer-playback="${(x=i.preferPlayback)!=null?x:!1}"
1947
1952
  start-time="${i.startTime!=null?i.startTime:!1}"
1948
1953
  beacon-collection-domain="${(w=i.beaconCollectionDomain)!=null?w:!1}"
1949
- player-software-name="${(M=i.playerSoftwareName)!=null?M:!1}"
1954
+ player-software-name="${(P=i.playerSoftwareName)!=null?P:!1}"
1950
1955
  player-software-version="${(k=i.playerSoftwareVersion)!=null?k:!1}"
1951
1956
  env-key="${(D=i.envKey)!=null?D:!1}"
1952
1957
  custom-domain="${(U=i.customDomain)!=null?U:!1}"
1953
1958
  src="${i.src?i.src:i.playbackId?To(i):!1}"
1954
1959
  cast-src="${i.src?i.src:i.playbackId?To(i):!1}"
1960
+ drm-token="${(z=(F=i.tokens)==null?void 0:F.drm)!=null?z:!1}"
1955
1961
  exportparts="video"
1956
1962
  >
1957
1963
  ${i.storyboard?pr`<track label="thumbnails" default kind="metadata" src="${i.storyboard}" />`:pr``}
@@ -1960,30 +1966,30 @@ media-poster-image:not([src]):not([placeholdersrc]) {
1960
1966
  <media-poster-image
1961
1967
  part="poster"
1962
1968
  exportparts="poster, img"
1963
- src="${i.poster===""?!1:(B=i.poster)!=null?B:!1}"
1964
- placeholdersrc="${(X=i.placeholder)!=null?X:!1}"
1969
+ src="${i.poster===""?!1:(j=i.poster)!=null?j:!1}"
1970
+ placeholdersrc="${(K=i.placeholder)!=null?K:!1}"
1965
1971
  ></media-poster-image>
1966
1972
  </slot>
1967
1973
  <mxp-dialog
1968
1974
  no-auto-hide
1969
- open="${(z=i.isDialogOpen)!=null?z:!1}"
1975
+ open="${(se=i.isDialogOpen)!=null?se:!1}"
1970
1976
  onclose="${i.onCloseErrorDialog}"
1971
1977
  oninitfocus="${i.onInitFocusDialog}"
1972
1978
  >
1973
- ${(V=i.dialog)!=null&&V.title?pr`<h3>${i.dialog.title}</h3>`:pr``}
1979
+ ${(oe=i.dialog)!=null&&oe.title?pr`<h3>${i.dialog.title}</h3>`:pr``}
1974
1980
  <p>
1975
- ${(se=i.dialog)==null?void 0:se.message}
1976
- ${(ae=i.dialog)!=null&&ae.linkUrl?pr`<a
1981
+ ${(W=i.dialog)==null?void 0:W.message}
1982
+ ${(G=i.dialog)!=null&&G.linkUrl?pr`<a
1977
1983
  href="${i.dialog.linkUrl}"
1978
1984
  target="_blank"
1979
1985
  rel="external noopener"
1980
- aria-label="${(W=i.dialog.linkText)!=null?W:""} ${ce("(opens in a new window)")}"
1981
- >${(G=i.dialog.linkText)!=null?G:i.dialog.linkUrl}</a
1986
+ aria-label="${(ne=i.dialog.linkText)!=null?ne:""} ${ce("(opens in a new window)")}"
1987
+ >${(Q=i.dialog.linkText)!=null?Q:i.dialog.linkUrl}</a
1982
1988
  >`:pr``}
1983
1989
  </p>
1984
1990
  </mxp-dialog>
1985
1991
  </media-theme>
1986
- `};function Xc(i,e,t,r,s){var o,l,d;let n={},a={};switch(i.code){case bt.MEDIA_ERR_NETWORK:{switch(n.title=ce("Network Error",s),n.message=i.message,(o=i.data)==null?void 0:o.response.code){case 412:{n.title=ce("Video is not currently available",s),n.message=ce("The live stream or video file are not yet ready.",s),a.message=ce("This playback-id may belong to a live stream that is not currently active or an asset that is not ready.",s),a.file="412-not-playable.md";break}case 404:{n.title=ce("Video does not exist",s),n.message="",a.message=ce("This playback-id does not exist. You may have used an Asset ID or an ID from a different resource.",s),a.file="404-not-found.md";break}case 403:{if(n.title=ce("Invalid playback URL",s),n.message=ce("The video URL or playback-token are formatted with incorrect or incomplete information.",s),a.message=ce("403 error trying to access this playback URL. If this is a signed URL, you might need to provide a playback-token.",s),a.file="missing-signed-tokens.md",!r)break;let{exp:u,aud:c,sub:h}=Br(r),f=Date.now()>u*1e3,m=h!==t,p=c!=="v",g={timeStyle:"medium",dateStyle:"medium"};if(f){n.title=ce("Video URL has expired",s),n.message=ce("The video\u2019s secured playback-token has expired.",s),a.message=ce("The video\u2019s secured playback-token has expired.",s),a.context=ce("Expired at: {expiredDate}. Current time: {currentDate}.",s).format({expiredDate:new Intl.DateTimeFormat(Vs.code,g).format(u*1e3),currentDate:new Intl.DateTimeFormat(Vs.code,g).format(Date.now())}),a.file="403-expired-token.md";break}if(m){n.title=ce("Video URL is formatted incorrectly",s),n.message=ce("The video\u2019s playback ID does not match the one encoded in the playback-token.",s),a.message=ce("The video\u2019s playback ID does not match the one encoded in the playback-token.",s),a.context=ce("Specified playback ID: {playbackId} and the playback ID encoded in the playback-token: {tokenPlaybackId}",s).format({playbackId:t,tokenPlaybackId:h}),a.file="403-playback-id-mismatch.md";break}if(p){n.title=ce("Video URL is formatted incorrectly",s),n.message=ce("The playback-token is formatted with incorrect information.",s),a.message=ce("The playback-token is formatted with incorrect information.",s),a.context=ce("The playback-token has an incorrect aud value: {tokenType}. aud value should be v.",s).format({tokenType:c}),a.file="403-incorrect-aud-value.md";break}a.message=ce("403 error trying to access this playback URL. If this is a signed playback ID, the token might not have been generated correctly.",s),a.file="403-malformatted-token.md";break}}break}case bt.MEDIA_ERR_DECODE:{let{message:u}=i;n={title:ce("Media Error",s),message:u},a.file="media-decode-error.md";break}case bt.MEDIA_ERR_SRC_NOT_SUPPORTED:{let u=(d=(l=i.data)==null?void 0:l.response)==null?void 0:d.code;if(u>=400&&u<500){i.code=bt.MEDIA_ERR_NETWORK,i.data={response:{code:u}},{dialog:n,devlog:a}=Xc(i,e,t,r);break}n={title:ce("Source Not Supported",s),message:i.message},a.file="media-src-not-supported.md";break}default:n={title:ce("Error",s),message:i.message};break}return e&&(n={title:ce("Your device appears to be offline",s),message:ce("Check your internet connection and try reloading this video.",s)}),{dialog:n,devlog:a}}var h1=`<template id="media-theme-gerwig">
1992
+ `};function eh(i,e,t,r,s){var o,l,d;let n={},a={};switch(i.code){case bt.MEDIA_ERR_NETWORK:{switch(n.title=ce("Network Error",s),n.message=i.message,(o=i.data)==null?void 0:o.response.code){case 412:{n.title=ce("Video is not currently available",s),n.message=ce("The live stream or video file are not yet ready.",s),a.message=ce("This playback-id may belong to a live stream that is not currently active or an asset that is not ready.",s),a.file="412-not-playable.md";break}case 404:{n.title=ce("Video does not exist",s),n.message="",a.message=ce("This playback-id does not exist. You may have used an Asset ID or an ID from a different resource.",s),a.file="404-not-found.md";break}case 403:{if(n.title=ce("Invalid playback URL",s),n.message=ce("The video URL or playback-token are formatted with incorrect or incomplete information.",s),a.message=ce("403 error trying to access this playback URL. If this is a signed URL, you might need to provide a playback-token.",s),a.file="missing-signed-tokens.md",!r)break;let{exp:u,aud:c,sub:h}=$r(r),f=Date.now()>u*1e3,m=h!==t,p=c!=="v",g={timeStyle:"medium",dateStyle:"medium"};if(f){n.title=ce("Video URL has expired",s),n.message=ce("The video\u2019s secured playback-token has expired.",s),a.message=ce("The video\u2019s secured playback-token has expired.",s),a.context=ce("Expired at: {expiredDate}. Current time: {currentDate}.",s).format({expiredDate:new Intl.DateTimeFormat(Vs.code,g).format(u*1e3),currentDate:new Intl.DateTimeFormat(Vs.code,g).format(Date.now())}),a.file="403-expired-token.md";break}if(m){n.title=ce("Video URL is formatted incorrectly",s),n.message=ce("The video\u2019s playback ID does not match the one encoded in the playback-token.",s),a.message=ce("The video\u2019s playback ID does not match the one encoded in the playback-token.",s),a.context=ce("Specified playback ID: {playbackId} and the playback ID encoded in the playback-token: {tokenPlaybackId}",s).format({playbackId:t,tokenPlaybackId:h}),a.file="403-playback-id-mismatch.md";break}if(p){n.title=ce("Video URL is formatted incorrectly",s),n.message=ce("The playback-token is formatted with incorrect information.",s),a.message=ce("The playback-token is formatted with incorrect information.",s),a.context=ce("The playback-token has an incorrect aud value: {tokenType}. aud value should be v.",s).format({tokenType:c}),a.file="403-incorrect-aud-value.md";break}a.message=ce("403 error trying to access this playback URL. If this is a signed playback ID, the token might not have been generated correctly.",s),a.file="403-malformatted-token.md";break}}break}case bt.MEDIA_ERR_DECODE:{let{message:u}=i;n={title:ce("Media Error",s),message:u},a.file="media-decode-error.md";break}case bt.MEDIA_ERR_SRC_NOT_SUPPORTED:{let u=(d=(l=i.data)==null?void 0:l.response)==null?void 0:d.code;if(u>=400&&u<500){i.code=bt.MEDIA_ERR_NETWORK,i.data={response:{code:u}},{dialog:n,devlog:a}=eh(i,e,t,r);break}n={title:ce("Source Not Supported",s),message:i.message},a.file="media-src-not-supported.md";break}default:n={title:ce("Error",s),message:i.message};break}return e&&(n={title:ce("Your device appears to be offline",s),message:ce("Check your internet connection and try reloading this video.",s)}),{dialog:n,devlog:a}}var u1=`<template id="media-theme-gerwig">
1987
1993
  <style>
1988
1994
  @keyframes pre-play-hide {
1989
1995
  0% {
@@ -2977,8 +2983,8 @@ media-poster-image:not([src]):not([placeholdersrc]) {
2977
2983
  <slot></slot>
2978
2984
  </media-controller>
2979
2985
  </template>
2980
- `;var rv=Ft.createElement("template");"innerHTML"in rv&&(rv.innerHTML=h1);var f1,m1,Qc=class extends Vr{};Qc.template=(m1=(f1=rv.content)==null?void 0:f1.children)==null?void 0:m1[0];$e.customElements.get("media-theme-gerwig")||$e.customElements.define("media-theme-gerwig",Qc);var xM="gerwig";var gr={SRC:"src",POSTER:"poster"},$={STYLE:"style",DEFAULT_HIDDEN_CAPTIONS:"default-hidden-captions",PRIMARY_COLOR:"primary-color",SECONDARY_COLOR:"secondary-color",ACCENT_COLOR:"accent-color",FORWARD_SEEK_OFFSET:"forward-seek-offset",BACKWARD_SEEK_OFFSET:"backward-seek-offset",PLAYBACK_TOKEN:"playback-token",THUMBNAIL_TOKEN:"thumbnail-token",STORYBOARD_TOKEN:"storyboard-token",STORYBOARD_SRC:"storyboard-src",THUMBNAIL_TIME:"thumbnail-time",AUDIO:"audio",NOHOTKEYS:"nohotkeys",HOTKEYS:"hotkeys",PLAYBACK_RATES:"playbackrates",DEFAULT_SHOW_REMAINING_TIME:"default-show-remaining-time",DEFAULT_DURATION:"default-duration",TITLE:"title",PLACEHOLDER:"placeholder",THEME:"theme",DEFAULT_STREAM_TYPE:"default-stream-type",TARGET_LIVE_WINDOW:"target-live-window",EXTRA_SOURCE_PARAMS:"extra-source-params",NO_VOLUME_PREF:"no-volume-pref"},sv=["audio","backwardseekoffset","defaultduration","defaultshowremainingtime","defaultsubtitles","noautoseektolive","disabled","exportparts","forwardseekoffset","hideduration","hotkeys","nohotkeys","playbackrates","defaultstreamtype","streamtype","style","targetlivewindow","template","title","novolumepref"];function LM(i,e){var r;return{src:!i.playbackId&&i.src,playbackId:i.playbackId,hasSrc:!!i.playbackId||!!i.src,poster:i.poster,storyboard:i.storyboard,storyboardSrc:i.getAttribute($.STORYBOARD_SRC),placeholder:i.getAttribute("placeholder"),themeTemplate:kM(i),thumbnailTime:!i.tokens.thumbnail&&i.thumbnailTime,autoplay:i.autoplay,crossOrigin:i.crossOrigin,loop:i.loop,noHotKeys:i.hasAttribute($.NOHOTKEYS),hotKeys:i.getAttribute($.HOTKEYS),muted:i.muted,paused:i.paused,preload:i.preload,envKey:i.envKey,preferCmcd:i.preferCmcd,debug:i.debug,disableTracking:i.disableTracking,disableCookies:i.disableCookies,tokens:i.tokens,beaconCollectionDomain:i.beaconCollectionDomain,maxResolution:i.maxResolution,minResolution:i.minResolution,programStartTime:i.programStartTime,programEndTime:i.programEndTime,renditionOrder:i.renditionOrder,metadata:i.metadata,playerSoftwareName:i.playerSoftwareName,playerSoftwareVersion:i.playerSoftwareVersion,startTime:i.startTime,preferPlayback:i.preferPlayback,audio:i.audio,defaultStreamType:i.defaultStreamType,targetLiveWindow:i.getAttribute(P.TARGET_LIVE_WINDOW),streamType:Co(i.getAttribute(P.STREAM_TYPE)),primaryColor:i.getAttribute($.PRIMARY_COLOR),secondaryColor:i.getAttribute($.SECONDARY_COLOR),accentColor:i.getAttribute($.ACCENT_COLOR),forwardSeekOffset:i.forwardSeekOffset,backwardSeekOffset:i.backwardSeekOffset,defaultHiddenCaptions:i.defaultHiddenCaptions,defaultDuration:i.defaultDuration,defaultShowRemainingTime:i.defaultShowRemainingTime,hideDuration:IM(i),playbackRates:i.getAttribute($.PLAYBACK_RATES),customDomain:(r=i.getAttribute(P.CUSTOM_DOMAIN))!=null?r:void 0,title:i.getAttribute($.TITLE),novolumepref:i.hasAttribute($.NO_VOLUME_PREF),...e,extraSourceParams:i.extraSourceParams}}function kM(i){var t,r;let e=i.theme;if(e){let s=(r=(t=i.getRootNode())==null?void 0:t.getElementById)==null?void 0:r.call(t,e);if(s&&s instanceof HTMLTemplateElement)return s;e.startsWith("media-theme-")||(e=`media-theme-${e}`);let n=$e.customElements.get(e);if(n!=null&&n.template)return n.template}}function IM(i){var t;let e=(t=i.mediaController)==null?void 0:t.querySelector("media-time-display");return e&&getComputedStyle(e).getPropertyValue("--media-duration-display-display").trim()==="none"}function p1(i){let e=i.hasAttribute($.TITLE)?{video_title:i.getAttribute($.TITLE)}:{};return i.getAttributeNames().filter(t=>t.startsWith("metadata-")).reduce((t,r)=>{let s=i.getAttribute(r);return s!==null&&(t[r.replace(/^metadata-/,"").replace(/-/g,"_")]=s),t},e)}var RM=Object.values(P),wM=Object.values(gr),CM=Object.values($),DM=$c(),MM="mux-player",g1={dialog:void 0,isDialogOpen:!1},PM={redundant_streams:!0},Go,Wo,Yr,Vo,en,tr,qr,Zc,v1,Ko,nv,zr,sa,Jc,E1,eh,b1,th,y1,ih,T1,Ho=class extends K0{constructor(){super();Xe(this,tr);Xe(this,Zc);Xe(this,Ko);Xe(this,zr);Xe(this,Jc);Xe(this,eh);Xe(this,th);Xe(this,ih);Xe(this,Go,!1);Xe(this,Wo,{});Xe(this,Yr,!0);Xe(this,Vo,new Bc(this,"hotkeys"));Xe(this,en,{...g1,onCloseErrorDialog:()=>Qe(this,Ko,nv).call(this,{dialog:void 0,isDialogOpen:!1}),onInitFocusDialog:t=>{G0(this,Ft.activeElement)||t.preventDefault()}});this.attachShadow({mode:"open"}),Qe(this,Zc,v1).call(this),this.isConnected&&Qe(this,tr,qr).call(this)}static get observedAttributes(){var t;return[...(t=K0.observedAttributes)!=null?t:[],...wM,...RM,...CM]}get mediaTheme(){var t;return(t=this.shadowRoot)==null?void 0:t.querySelector("media-theme")}get mediaController(){var t,r;return(r=(t=this.mediaTheme)==null?void 0:t.shadowRoot)==null?void 0:r.querySelector("media-controller")}connectedCallback(){var r;let t=(r=this.shadowRoot)==null?void 0:r.querySelector("mux-video");t&&(t.metadata=p1(this))}attributeChangedCallback(t,r,s){switch(Qe(this,tr,qr).call(this),super.attributeChangedCallback(t,r,s),t){case $.HOTKEYS:Ee(this,Vo).value=s;break;case $.THUMBNAIL_TIME:{s!=null&&this.tokens.thumbnail&&$r(ce("Use of thumbnail-time with thumbnail-token is currently unsupported. Ignore thumbnail-time.").format({}));break}case $.THUMBNAIL_TOKEN:{let{aud:a}=Br(s);s&&a!=="t"&&$r(ce("The provided thumbnail-token should have audience value 't' instead of '{aud}'.").format({aud:a}));break}case $.STORYBOARD_TOKEN:{let{aud:a}=Br(s);s&&a!=="s"&&$r(ce("The provided storyboard-token should have audience value 's' instead of '{aud}'.").format({aud:a}));break}case P.PLAYBACK_ID:{s!=null&&s.includes("?token")&&Wt(ce("The specificed playback ID {playbackId} contains a token which must be provided via the playback-token attribute.").format({playbackId:s}));break}case P.STREAM_TYPE:s&&![ye.LIVE,ye.ON_DEMAND,ye.UNKNOWN].includes(s)?["ll-live","live:dvr","ll-live:dvr"].includes(this.streamType)?this.targetLiveWindow=s.includes("dvr")?Number.POSITIVE_INFINITY:0:W0({file:"invalid-stream-type.md",message:ce("Invalid stream-type value supplied: `{streamType}`. Please provide stream-type as either: `on-demand` or `live`").format({streamType:this.streamType})}):s===ye.LIVE?this.getAttribute($.TARGET_LIVE_WINDOW)==null&&(this.targetLiveWindow=0):this.targetLiveWindow=Number.NaN}[P.PLAYBACK_ID,gr.SRC,$.PLAYBACK_TOKEN].includes(t)&&r!==s&&Vt(this,en,{...Ee(this,en),...g1}),Qe(this,zr,sa).call(this,{[BA(t)]:s})}get preferCmcd(){var t;return(t=this.getAttribute(P.PREFER_CMCD))!=null?t:void 0}set preferCmcd(t){t!==this.preferCmcd&&(t?zn.includes(t)?this.setAttribute(P.PREFER_CMCD,t):$r(`Invalid value for preferCmcd. Must be one of ${zn.join()}`):this.removeAttribute(P.PREFER_CMCD))}get hasPlayed(){var t,r;return(r=(t=this.mediaController)==null?void 0:t.hasAttribute(b.MEDIA_HAS_PLAYED))!=null?r:!1}get inLiveWindow(){var t;return(t=this.mediaController)==null?void 0:t.hasAttribute(b.MEDIA_TIME_IS_LIVE)}get _hls(){var t;return(t=this.media)==null?void 0:t._hls}get mux(){var t;return(t=this.media)==null?void 0:t.mux}get theme(){var t;return(t=this.getAttribute($.THEME))!=null?t:xM}set theme(t){this.setAttribute($.THEME,`${t}`)}get themeProps(){let t=this.mediaTheme;if(!t)return;let r={};for(let s of t.getAttributeNames()){if(sv.includes(s))continue;let n=t.getAttribute(s);r[Fc(s)]=n===""?!0:n}return r}set themeProps(t){var s,n;Qe(this,tr,qr).call(this);let r={...this.themeProps,...t};for(let a in r){if(sv.includes(a))continue;let o=t==null?void 0:t[a];typeof o=="boolean"||o==null?(s=this.mediaTheme)==null||s.toggleAttribute(Uc(a),!!o):(n=this.mediaTheme)==null||n.setAttribute(Uc(a),o)}}get playbackId(){var t;return(t=this.getAttribute(P.PLAYBACK_ID))!=null?t:void 0}set playbackId(t){t?this.setAttribute(P.PLAYBACK_ID,t):this.removeAttribute(P.PLAYBACK_ID)}get src(){var t,r;return this.playbackId?(t=Js(this,gr.SRC))!=null?t:void 0:(r=this.getAttribute(gr.SRC))!=null?r:void 0}set src(t){t?this.setAttribute(gr.SRC,t):this.removeAttribute(gr.SRC)}get poster(){var r;let t=this.getAttribute(gr.POSTER);if(t!=null)return t;if(this.playbackId&&!this.audio)return UA(this.playbackId,{customDomain:this.customDomain,thumbnailTime:(r=this.thumbnailTime)!=null?r:this.startTime,programTime:this.programStartTime,token:this.tokens.thumbnail})}set poster(t){t||t===""?this.setAttribute(gr.POSTER,t):this.removeAttribute(gr.POSTER)}get storyboardSrc(){var t;return(t=this.getAttribute($.STORYBOARD_SRC))!=null?t:void 0}set storyboardSrc(t){t?this.setAttribute($.STORYBOARD_SRC,t):this.removeAttribute($.STORYBOARD_SRC)}get storyboard(){if(this.storyboardSrc&&!this.tokens.storyboard)return this.storyboardSrc;if(!(this.audio||!this.playbackId||!this.streamType||[ye.LIVE,ye.UNKNOWN].includes(this.streamType)))return FA(this.playbackId,{customDomain:this.customDomain,token:this.tokens.storyboard,programStartTime:this.programStartTime,programEndTime:this.programEndTime})}get audio(){return this.hasAttribute($.AUDIO)}set audio(t){if(!t){this.removeAttribute($.AUDIO);return}this.setAttribute($.AUDIO,"")}get hotkeys(){return Ee(this,Vo)}get nohotkeys(){return this.hasAttribute($.NOHOTKEYS)}set nohotkeys(t){if(!t){this.removeAttribute($.NOHOTKEYS);return}this.setAttribute($.NOHOTKEYS,"")}get thumbnailTime(){return ii(this.getAttribute($.THUMBNAIL_TIME))}set thumbnailTime(t){this.setAttribute($.THUMBNAIL_TIME,`${t}`)}get title(){var t;return(t=this.getAttribute($.TITLE))!=null?t:""}set title(t){t!==this.title&&(t?this.setAttribute($.TITLE,t):this.removeAttribute("title"),super.title=t)}get placeholder(){var t;return(t=Js(this,$.PLACEHOLDER))!=null?t:""}set placeholder(t){this.setAttribute($.PLACEHOLDER,`${t}`)}get primaryColor(){var r,s;let t=this.getAttribute($.PRIMARY_COLOR);if(t!=null||this.mediaTheme&&(t=(s=(r=$e.getComputedStyle(this.mediaTheme))==null?void 0:r.getPropertyValue("--_primary-color"))==null?void 0:s.trim(),t))return t}set primaryColor(t){this.setAttribute($.PRIMARY_COLOR,`${t}`)}get secondaryColor(){var r,s;let t=this.getAttribute($.SECONDARY_COLOR);if(t!=null||this.mediaTheme&&(t=(s=(r=$e.getComputedStyle(this.mediaTheme))==null?void 0:r.getPropertyValue("--_secondary-color"))==null?void 0:s.trim(),t))return t}set secondaryColor(t){this.setAttribute($.SECONDARY_COLOR,`${t}`)}get accentColor(){var r,s;let t=this.getAttribute($.ACCENT_COLOR);if(t!=null||this.mediaTheme&&(t=(s=(r=$e.getComputedStyle(this.mediaTheme))==null?void 0:r.getPropertyValue("--_accent-color"))==null?void 0:s.trim(),t))return t}set accentColor(t){this.setAttribute($.ACCENT_COLOR,`${t}`)}get defaultShowRemainingTime(){return this.hasAttribute($.DEFAULT_SHOW_REMAINING_TIME)}set defaultShowRemainingTime(t){t?this.setAttribute($.DEFAULT_SHOW_REMAINING_TIME,""):this.removeAttribute($.DEFAULT_SHOW_REMAINING_TIME)}get playbackRates(){if(this.hasAttribute($.PLAYBACK_RATES))return this.getAttribute($.PLAYBACK_RATES).trim().split(/\s*,?\s+/).map(t=>Number(t)).filter(t=>!Number.isNaN(t)).sort((t,r)=>t-r)}set playbackRates(t){if(!t){this.removeAttribute($.PLAYBACK_RATES);return}this.setAttribute($.PLAYBACK_RATES,t.join(" "))}get forwardSeekOffset(){var t;return(t=ii(this.getAttribute($.FORWARD_SEEK_OFFSET)))!=null?t:10}set forwardSeekOffset(t){this.setAttribute($.FORWARD_SEEK_OFFSET,`${t}`)}get backwardSeekOffset(){var t;return(t=ii(this.getAttribute($.BACKWARD_SEEK_OFFSET)))!=null?t:10}set backwardSeekOffset(t){this.setAttribute($.BACKWARD_SEEK_OFFSET,`${t}`)}get defaultHiddenCaptions(){return this.hasAttribute($.DEFAULT_HIDDEN_CAPTIONS)}set defaultHiddenCaptions(t){t?this.setAttribute($.DEFAULT_HIDDEN_CAPTIONS,""):this.removeAttribute($.DEFAULT_HIDDEN_CAPTIONS)}get defaultDuration(){return ii(this.getAttribute($.DEFAULT_DURATION))}set defaultDuration(t){t==null?this.removeAttribute($.DEFAULT_DURATION):this.setAttribute($.DEFAULT_DURATION,`${t}`)}get playerSoftwareName(){var t;return(t=this.getAttribute(P.PLAYER_SOFTWARE_NAME))!=null?t:MM}get playerSoftwareVersion(){var t;return(t=this.getAttribute(P.PLAYER_SOFTWARE_VERSION))!=null?t:DM}get beaconCollectionDomain(){var t;return(t=this.getAttribute(P.BEACON_COLLECTION_DOMAIN))!=null?t:void 0}set beaconCollectionDomain(t){t!==this.beaconCollectionDomain&&(t?this.setAttribute(P.BEACON_COLLECTION_DOMAIN,t):this.removeAttribute(P.BEACON_COLLECTION_DOMAIN))}get maxResolution(){var t;return(t=this.getAttribute(P.MAX_RESOLUTION))!=null?t:void 0}set maxResolution(t){t!==this.maxResolution&&(t?this.setAttribute(P.MAX_RESOLUTION,t):this.removeAttribute(P.MAX_RESOLUTION))}get minResolution(){var t;return(t=this.getAttribute(P.MIN_RESOLUTION))!=null?t:void 0}set minResolution(t){t!==this.minResolution&&(t?this.setAttribute(P.MIN_RESOLUTION,t):this.removeAttribute(P.MIN_RESOLUTION))}get renditionOrder(){var t;return(t=this.getAttribute(P.RENDITION_ORDER))!=null?t:void 0}set renditionOrder(t){t!==this.renditionOrder&&(t?this.setAttribute(P.RENDITION_ORDER,t):this.removeAttribute(P.RENDITION_ORDER))}get programStartTime(){return ii(this.getAttribute(P.PROGRAM_START_TIME))}set programStartTime(t){t==null?this.removeAttribute(P.PROGRAM_START_TIME):this.setAttribute(P.PROGRAM_START_TIME,`${t}`)}get programEndTime(){return ii(this.getAttribute(P.PROGRAM_END_TIME))}set programEndTime(t){t==null?this.removeAttribute(P.PROGRAM_END_TIME):this.setAttribute(P.PROGRAM_END_TIME,`${t}`)}get extraSourceParams(){return this.hasAttribute($.EXTRA_SOURCE_PARAMS)?[...new URLSearchParams(this.getAttribute($.EXTRA_SOURCE_PARAMS)).entries()].reduce((t,[r,s])=>(t[r]=s,t),{}):PM}set extraSourceParams(t){t==null?this.removeAttribute($.EXTRA_SOURCE_PARAMS):this.setAttribute($.EXTRA_SOURCE_PARAMS,new URLSearchParams(t).toString())}get customDomain(){var t;return(t=this.getAttribute(P.CUSTOM_DOMAIN))!=null?t:void 0}set customDomain(t){t!==this.customDomain&&(t?this.setAttribute(P.CUSTOM_DOMAIN,t):this.removeAttribute(P.CUSTOM_DOMAIN))}get envKey(){var t;return(t=Js(this,P.ENV_KEY))!=null?t:void 0}set envKey(t){this.setAttribute(P.ENV_KEY,`${t}`)}get noVolumePref(){return this.hasAttribute($.NO_VOLUME_PREF)}set noVolumePref(t){t?this.setAttribute($.NO_VOLUME_PREF,""):this.removeAttribute($.NO_VOLUME_PREF)}get debug(){return Js(this,P.DEBUG)!=null}set debug(t){t?this.setAttribute(P.DEBUG,""):this.removeAttribute(P.DEBUG)}get disableTracking(){return Js(this,P.DISABLE_TRACKING)!=null}set disableTracking(t){this.toggleAttribute(P.DISABLE_TRACKING,!!t)}get disableCookies(){return Js(this,P.DISABLE_COOKIES)!=null}set disableCookies(t){t?this.setAttribute(P.DISABLE_COOKIES,""):this.removeAttribute(P.DISABLE_COOKIES)}get streamType(){var t,r,s;return(s=(r=this.getAttribute(P.STREAM_TYPE))!=null?r:(t=this.media)==null?void 0:t.streamType)!=null?s:ye.UNKNOWN}set streamType(t){this.setAttribute(P.STREAM_TYPE,`${t}`)}get defaultStreamType(){var t,r,s;return(s=(r=this.getAttribute($.DEFAULT_STREAM_TYPE))!=null?r:(t=this.mediaController)==null?void 0:t.getAttribute($.DEFAULT_STREAM_TYPE))!=null?s:ye.ON_DEMAND}set defaultStreamType(t){t?this.setAttribute($.DEFAULT_STREAM_TYPE,t):this.removeAttribute($.DEFAULT_STREAM_TYPE)}get targetLiveWindow(){var t,r;return this.hasAttribute($.TARGET_LIVE_WINDOW)?+this.getAttribute($.TARGET_LIVE_WINDOW):(r=(t=this.media)==null?void 0:t.targetLiveWindow)!=null?r:Number.NaN}set targetLiveWindow(t){t==this.targetLiveWindow||Number.isNaN(t)&&Number.isNaN(this.targetLiveWindow)||(t==null?this.removeAttribute($.TARGET_LIVE_WINDOW):this.setAttribute($.TARGET_LIVE_WINDOW,`${+t}`))}get liveEdgeStart(){var t;return(t=this.media)==null?void 0:t.liveEdgeStart}get startTime(){return ii(Js(this,P.START_TIME))}set startTime(t){this.setAttribute(P.START_TIME,`${t}`)}get preferPlayback(){let t=this.getAttribute(P.PREFER_PLAYBACK);if(t===ei.MSE||t===ei.NATIVE)return t}set preferPlayback(t){t!==this.preferPlayback&&(t===ei.MSE||t===ei.NATIVE?this.setAttribute(P.PREFER_PLAYBACK,t):this.removeAttribute(P.PREFER_PLAYBACK))}get metadata(){var t;return(t=this.media)==null?void 0:t.metadata}set metadata(t){if(Qe(this,tr,qr).call(this),!this.media){Wt("underlying media element missing when trying to set metadata. metadata will not be set.");return}this.media.metadata={...p1(this),...t}}get _hlsConfig(){var t;return(t=this.media)==null?void 0:t._hlsConfig}set _hlsConfig(t){if(Qe(this,tr,qr).call(this),!this.media){Wt("underlying media element missing when trying to set _hlsConfig. _hlsConfig will not be set.");return}this.media._hlsConfig=t}async addCuePoints(t){var r;if(Qe(this,tr,qr).call(this),!this.media){Wt("underlying media element missing when trying to addCuePoints. cuePoints will not be added.");return}return(r=this.media)==null?void 0:r.addCuePoints(t)}get activeCuePoint(){var t;return(t=this.media)==null?void 0:t.activeCuePoint}get cuePoints(){var t,r;return(r=(t=this.media)==null?void 0:t.cuePoints)!=null?r:[]}addChapters(t){var r;if(Qe(this,tr,qr).call(this),!this.media){Wt("underlying media element missing when trying to addChapters. chapters will not be added.");return}return(r=this.media)==null?void 0:r.addChapters(t)}get activeChapter(){var t;return(t=this.media)==null?void 0:t.activeChapter}get chapters(){var t,r;return(r=(t=this.media)==null?void 0:t.chapters)!=null?r:[]}getStartDate(){var t;return(t=this.media)==null?void 0:t.getStartDate()}get currentPdt(){var t;return(t=this.media)==null?void 0:t.currentPdt}get tokens(){let t=this.getAttribute($.PLAYBACK_TOKEN),r=this.getAttribute($.THUMBNAIL_TOKEN),s=this.getAttribute($.STORYBOARD_TOKEN);return{...Ee(this,Wo),...t!=null?{playback:t}:{},...r!=null?{thumbnail:r}:{},...s!=null?{storyboard:s}:{}}}set tokens(t){Vt(this,Wo,t!=null?t:{})}get playbackToken(){var t;return(t=this.getAttribute($.PLAYBACK_TOKEN))!=null?t:void 0}set playbackToken(t){this.setAttribute($.PLAYBACK_TOKEN,`${t}`)}get thumbnailToken(){var t;return(t=this.getAttribute($.THUMBNAIL_TOKEN))!=null?t:void 0}set thumbnailToken(t){this.setAttribute($.THUMBNAIL_TOKEN,`${t}`)}get storyboardToken(){var t;return(t=this.getAttribute($.STORYBOARD_TOKEN))!=null?t:void 0}set storyboardToken(t){this.setAttribute($.STORYBOARD_TOKEN,`${t}`)}addTextTrack(t,r,s,n){var o;let a=(o=this.media)==null?void 0:o.nativeEl;if(a)return Ec(a,t,r,s,n)}removeTextTrack(t){var s;let r=(s=this.media)==null?void 0:s.nativeEl;if(r)return j_(r,t)}get textTracks(){var t;return(t=this.media)==null?void 0:t.textTracks}};Go=new WeakMap,Wo=new WeakMap,Yr=new WeakMap,Vo=new WeakMap,en=new WeakMap,tr=new WeakSet,qr=function(){var t,r,s;if(!Ee(this,Go)){Vt(this,Go,!0),Qe(this,zr,sa).call(this);try{if(customElements.upgrade(this.mediaTheme),!(this.mediaTheme instanceof $e.HTMLElement))throw""}catch{Wt("<media-theme> failed to upgrade!")}try{if(customElements.upgrade(this.media),!(this.media instanceof MA))throw""}catch{Wt("<mux-video> failed to upgrade!")}try{if(customElements.upgrade(this.mediaController),!(this.mediaController instanceof Ih))throw""}catch{Wt("<media-controller> failed to upgrade!")}WA(this),Qe(this,Jc,E1).call(this),Qe(this,eh,b1).call(this),Qe(this,th,y1).call(this),Vt(this,Yr,(r=(t=this.mediaController)==null?void 0:t.hasAttribute(fe.USER_INACTIVE))!=null?r:!0),Qe(this,ih,T1).call(this),(s=this.media)==null||s.addEventListener("streamtypechange",()=>{Qe(this,zr,sa).call(this)})}},Zc=new WeakSet,v1=function(){var t,r;try{(t=window==null?void 0:window.CSS)==null||t.registerProperty({name:"--media-primary-color",syntax:"<color>",inherits:!0}),(r=window==null?void 0:window.CSS)==null||r.registerProperty({name:"--media-secondary-color",syntax:"<color>",inherits:!0})}catch{}},Ko=new WeakSet,nv=function(t){Object.assign(Ee(this,en),t),Qe(this,zr,sa).call(this)},zr=new WeakSet,sa=function(t={}){u1(c1(LM(this,{...Ee(this,en),...t})),this.shadowRoot)},Jc=new WeakSet,E1=function(){let t=s=>{var o,l;if(!(s!=null&&s.startsWith("theme-")))return;let n=s.replace(/^theme-/,"");if(sv.includes(n))return;let a=this.getAttribute(s);a!=null?(o=this.mediaTheme)==null||o.setAttribute(n,a):(l=this.mediaTheme)==null||l.removeAttribute(n)};new MutationObserver(s=>{for(let{attributeName:n}of s)t(n)}).observe(this,{attributes:!0}),this.getAttributeNames().forEach(t)},eh=new WeakSet,b1=function(){var r;let t=s=>{let{detail:n}=s;if(n instanceof bt||(n=new bt(n.message,n.code,n.fatal)),!(n!=null&&n.fatal)){$r(n),n.data&&$r(`${n.name} data:`,n.data);return}let{dialog:a,devlog:o}=Xc(n,!window.navigator.onLine,this.playbackId,this.playbackToken);o.message&&W0(o),Wt(n),n.data&&Wt(`${n.name} data:`,n.data),Qe(this,Ko,nv).call(this,{isDialogOpen:!0,dialog:a})};this.addEventListener("error",t),this.media&&(this.media.errorTranslator=(s={})=>{var a,o,l;if(!(((a=this.media)==null?void 0:a.error)instanceof bt))return s;let{devlog:n}=Xc((o=this.media)==null?void 0:o.error,!window.navigator.onLine,this.playbackId,this.playbackToken,!1);return{player_error_code:(l=this.media)==null?void 0:l.error.code,player_error_message:n.message?String(n.message):s.player_error_message,player_error_context:n.context?String(n.context):s.player_error_context}}),(r=this.media)==null||r.addEventListener("error",s=>{var a,o;let{detail:n}=s;if(!n){let{message:l,code:d}=(o=(a=this.media)==null?void 0:a.error)!=null?o:{};n=new bt(l,d)}n!=null&&n.fatal&&this.dispatchEvent(new CustomEvent("error",{detail:n}))})},th=new WeakSet,y1=function(){var r,s,n,a;let t=()=>Qe(this,zr,sa).call(this);(s=(r=this.media)==null?void 0:r.textTracks)==null||s.addEventListener("addtrack",t),(a=(n=this.media)==null?void 0:n.textTracks)==null||a.addEventListener("removetrack",t)},ih=new WeakSet,T1=function(){var d,u;if(!/Firefox/i.test(navigator.userAgent))return;let r,s=new WeakMap,n=()=>this.streamType===ye.LIVE&&!this.secondaryColor&&this.offsetWidth>=800,a=(c,h,f=!1)=>{if(n())return;Array.from(c&&c.activeCues||[]).forEach(p=>{if(!(!p.snapToLines||p.line<-5||p.line>=0&&p.line<10))if(!h||this.paused){let g=p.text.split(`
2981
- `).length,E=-3;this.streamType===ye.LIVE&&(E=-2);let T=E-g;if(p.line===T&&!f)return;s.has(p)||s.set(p,p.line),p.line=T}else setTimeout(()=>{p.line=s.get(p)||"auto"},500)})},o=()=>{var c,h;a(r,(h=(c=this.mediaController)==null?void 0:c.hasAttribute(fe.USER_INACTIVE))!=null?h:!1)},l=()=>{var f,m;let h=Array.from(((m=(f=this.mediaController)==null?void 0:f.media)==null?void 0:m.textTracks)||[]).filter(p=>["subtitles","captions"].includes(p.kind)&&p.mode==="showing")[0];h!==r&&(r==null||r.removeEventListener("cuechange",o)),r=h,r==null||r.addEventListener("cuechange",o),a(r,Ee(this,Yr))};l(),(d=this.textTracks)==null||d.addEventListener("change",l),(u=this.textTracks)==null||u.addEventListener("addtrack",l),this.addEventListener("userinactivechange",()=>{var h,f;let c=(f=(h=this.mediaController)==null?void 0:h.hasAttribute(fe.USER_INACTIVE))!=null?f:!0;Ee(this,Yr)!==c&&(Vt(this,Yr,c),a(r,Ee(this,Yr)))})};function Js(i,e){return i.media?i.media.getAttribute(e):i.getAttribute(e)}$e.customElements.get("mux-player")||($e.customElements.define("mux-player",Ho),$e.MuxPlayerElement=Ho);var X8=Ho;})();
2986
+ `;var nv=Ft.createElement("template");"innerHTML"in nv&&(nv.innerHTML=u1);var c1,h1,th=class extends Vr{};th.template=(h1=(c1=nv.content)==null?void 0:c1.children)==null?void 0:h1[0];He.customElements.get("media-theme-gerwig")||He.customElements.define("media-theme-gerwig",th);var PM="gerwig";var gr={SRC:"src",POSTER:"poster"},$={STYLE:"style",DEFAULT_HIDDEN_CAPTIONS:"default-hidden-captions",PRIMARY_COLOR:"primary-color",SECONDARY_COLOR:"secondary-color",ACCENT_COLOR:"accent-color",FORWARD_SEEK_OFFSET:"forward-seek-offset",BACKWARD_SEEK_OFFSET:"backward-seek-offset",PLAYBACK_TOKEN:"playback-token",THUMBNAIL_TOKEN:"thumbnail-token",STORYBOARD_TOKEN:"storyboard-token",DRM_TOKEN:"drm-token",STORYBOARD_SRC:"storyboard-src",THUMBNAIL_TIME:"thumbnail-time",AUDIO:"audio",NOHOTKEYS:"nohotkeys",HOTKEYS:"hotkeys",PLAYBACK_RATES:"playbackrates",DEFAULT_SHOW_REMAINING_TIME:"default-show-remaining-time",DEFAULT_DURATION:"default-duration",TITLE:"title",PLACEHOLDER:"placeholder",THEME:"theme",DEFAULT_STREAM_TYPE:"default-stream-type",TARGET_LIVE_WINDOW:"target-live-window",EXTRA_SOURCE_PARAMS:"extra-source-params",NO_VOLUME_PREF:"no-volume-pref"},av=["audio","backwardseekoffset","defaultduration","defaultshowremainingtime","defaultsubtitles","noautoseektolive","disabled","exportparts","forwardseekoffset","hideduration","hotkeys","nohotkeys","playbackrates","defaultstreamtype","streamtype","style","targetlivewindow","template","title","novolumepref"];function OM(i,e){var r;return{src:!i.playbackId&&i.src,playbackId:i.playbackId,hasSrc:!!i.playbackId||!!i.src,poster:i.poster,storyboard:i.storyboard,storyboardSrc:i.getAttribute($.STORYBOARD_SRC),placeholder:i.getAttribute("placeholder"),themeTemplate:NM(i),thumbnailTime:!i.tokens.thumbnail&&i.thumbnailTime,autoplay:i.autoplay,crossOrigin:i.crossOrigin,loop:i.loop,noHotKeys:i.hasAttribute($.NOHOTKEYS),hotKeys:i.getAttribute($.HOTKEYS),muted:i.muted,paused:i.paused,preload:i.preload,envKey:i.envKey,preferCmcd:i.preferCmcd,debug:i.debug,disableTracking:i.disableTracking,disableCookies:i.disableCookies,tokens:i.tokens,beaconCollectionDomain:i.beaconCollectionDomain,maxResolution:i.maxResolution,minResolution:i.minResolution,programStartTime:i.programStartTime,programEndTime:i.programEndTime,renditionOrder:i.renditionOrder,metadata:i.metadata,playerSoftwareName:i.playerSoftwareName,playerSoftwareVersion:i.playerSoftwareVersion,startTime:i.startTime,preferPlayback:i.preferPlayback,audio:i.audio,defaultStreamType:i.defaultStreamType,targetLiveWindow:i.getAttribute(M.TARGET_LIVE_WINDOW),streamType:Co(i.getAttribute(M.STREAM_TYPE)),primaryColor:i.getAttribute($.PRIMARY_COLOR),secondaryColor:i.getAttribute($.SECONDARY_COLOR),accentColor:i.getAttribute($.ACCENT_COLOR),forwardSeekOffset:i.forwardSeekOffset,backwardSeekOffset:i.backwardSeekOffset,defaultHiddenCaptions:i.defaultHiddenCaptions,defaultDuration:i.defaultDuration,defaultShowRemainingTime:i.defaultShowRemainingTime,hideDuration:UM(i),playbackRates:i.getAttribute($.PLAYBACK_RATES),customDomain:(r=i.getAttribute(M.CUSTOM_DOMAIN))!=null?r:void 0,title:i.getAttribute($.TITLE),novolumepref:i.hasAttribute($.NO_VOLUME_PREF),...e,extraSourceParams:i.extraSourceParams}}function NM(i){var t,r;let e=i.theme;if(e){let s=(r=(t=i.getRootNode())==null?void 0:t.getElementById)==null?void 0:r.call(t,e);if(s&&s instanceof HTMLTemplateElement)return s;e.startsWith("media-theme-")||(e=`media-theme-${e}`);let n=He.customElements.get(e);if(n!=null&&n.template)return n.template}}function UM(i){var t;let e=(t=i.mediaController)==null?void 0:t.querySelector("media-time-display");return e&&getComputedStyle(e).getPropertyValue("--media-duration-display-display").trim()==="none"}function f1(i){let e=i.hasAttribute($.TITLE)?{video_title:i.getAttribute($.TITLE)}:{};return i.getAttributeNames().filter(t=>t.startsWith("metadata-")).reduce((t,r)=>{let s=i.getAttribute(r);return s!==null&&(t[r.replace(/^metadata-/,"").replace(/-/g,"_")]=s),t},e)}var FM=Object.values(M),BM=Object.values(gr),$M=Object.values($),HM=Kc(),GM="mux-player",m1={dialog:void 0,isDialogOpen:!1},WM={redundant_streams:!0},Go,Wo,zr,Ko,tn,tr,Yr,ih,p1,Vo,ov,jr,sa,rh,g1,sh,v1,nh,E1,ah,b1,Ho=class extends Y0{constructor(){super();Xe(this,tr);Xe(this,ih);Xe(this,Vo);Xe(this,jr);Xe(this,rh);Xe(this,sh);Xe(this,nh);Xe(this,ah);Xe(this,Go,!1);Xe(this,Wo,{});Xe(this,zr,!0);Xe(this,Ko,new Wc(this,"hotkeys"));Xe(this,tn,{...m1,onCloseErrorDialog:()=>Qe(this,Vo,ov).call(this,{dialog:void 0,isDialogOpen:!1}),onInitFocusDialog:t=>{K0(this,Ft.activeElement)||t.preventDefault()}});this.attachShadow({mode:"open"}),Qe(this,ih,p1).call(this),this.isConnected&&Qe(this,tr,Yr).call(this)}static get observedAttributes(){var t;return[...(t=Y0.observedAttributes)!=null?t:[],...BM,...FM,...$M]}get mediaTheme(){var t;return(t=this.shadowRoot)==null?void 0:t.querySelector("media-theme")}get mediaController(){var t,r;return(r=(t=this.mediaTheme)==null?void 0:t.shadowRoot)==null?void 0:r.querySelector("media-controller")}connectedCallback(){var r;let t=(r=this.shadowRoot)==null?void 0:r.querySelector("mux-video");t&&(t.metadata=f1(this))}attributeChangedCallback(t,r,s){switch(Qe(this,tr,Yr).call(this),super.attributeChangedCallback(t,r,s),t){case $.HOTKEYS:Ee(this,Ko).value=s;break;case $.THUMBNAIL_TIME:{s!=null&&this.tokens.thumbnail&&Hr(ce("Use of thumbnail-time with thumbnail-token is currently unsupported. Ignore thumbnail-time.").format({}));break}case $.THUMBNAIL_TOKEN:{let{aud:a}=$r(s);s&&a!=="t"&&Hr(ce("The provided thumbnail-token should have audience value 't' instead of '{aud}'.").format({aud:a}));break}case $.STORYBOARD_TOKEN:{let{aud:a}=$r(s);s&&a!=="s"&&Hr(ce("The provided storyboard-token should have audience value 's' instead of '{aud}'.").format({aud:a}));break}case M.PLAYBACK_ID:{s!=null&&s.includes("?token")&&Wt(ce("The specificed playback ID {playbackId} contains a token which must be provided via the playback-token attribute.").format({playbackId:s}));break}case M.STREAM_TYPE:s&&![ye.LIVE,ye.ON_DEMAND,ye.UNKNOWN].includes(s)?["ll-live","live:dvr","ll-live:dvr"].includes(this.streamType)?this.targetLiveWindow=s.includes("dvr")?Number.POSITIVE_INFINITY:0:V0({file:"invalid-stream-type.md",message:ce("Invalid stream-type value supplied: `{streamType}`. Please provide stream-type as either: `on-demand` or `live`").format({streamType:this.streamType})}):s===ye.LIVE?this.getAttribute($.TARGET_LIVE_WINDOW)==null&&(this.targetLiveWindow=0):this.targetLiveWindow=Number.NaN}[M.PLAYBACK_ID,gr.SRC,$.PLAYBACK_TOKEN].includes(t)&&r!==s&&Kt(this,tn,{...Ee(this,tn),...m1}),Qe(this,jr,sa).call(this,{[UA(t)]:s})}get preferCmcd(){var t;return(t=this.getAttribute(M.PREFER_CMCD))!=null?t:void 0}set preferCmcd(t){t!==this.preferCmcd&&(t?zn.includes(t)?this.setAttribute(M.PREFER_CMCD,t):Hr(`Invalid value for preferCmcd. Must be one of ${zn.join()}`):this.removeAttribute(M.PREFER_CMCD))}get hasPlayed(){var t,r;return(r=(t=this.mediaController)==null?void 0:t.hasAttribute(b.MEDIA_HAS_PLAYED))!=null?r:!1}get inLiveWindow(){var t;return(t=this.mediaController)==null?void 0:t.hasAttribute(b.MEDIA_TIME_IS_LIVE)}get _hls(){var t;return(t=this.media)==null?void 0:t._hls}get mux(){var t;return(t=this.media)==null?void 0:t.mux}get theme(){var t;return(t=this.getAttribute($.THEME))!=null?t:PM}set theme(t){this.setAttribute($.THEME,`${t}`)}get themeProps(){let t=this.mediaTheme;if(!t)return;let r={};for(let s of t.getAttributeNames()){if(av.includes(s))continue;let n=t.getAttribute(s);r[Gc(s)]=n===""?!0:n}return r}set themeProps(t){var s,n;Qe(this,tr,Yr).call(this);let r={...this.themeProps,...t};for(let a in r){if(av.includes(a))continue;let o=t==null?void 0:t[a];typeof o=="boolean"||o==null?(s=this.mediaTheme)==null||s.toggleAttribute(Hc(a),!!o):(n=this.mediaTheme)==null||n.setAttribute(Hc(a),o)}}get playbackId(){var t;return(t=this.getAttribute(M.PLAYBACK_ID))!=null?t:void 0}set playbackId(t){t?this.setAttribute(M.PLAYBACK_ID,t):this.removeAttribute(M.PLAYBACK_ID)}get src(){var t,r;return this.playbackId?(t=en(this,gr.SRC))!=null?t:void 0:(r=this.getAttribute(gr.SRC))!=null?r:void 0}set src(t){t?this.setAttribute(gr.SRC,t):this.removeAttribute(gr.SRC)}get poster(){var r;let t=this.getAttribute(gr.POSTER);if(t!=null)return t;if(this.playbackId&&!this.audio)return OA(this.playbackId,{customDomain:this.customDomain,thumbnailTime:(r=this.thumbnailTime)!=null?r:this.startTime,programTime:this.programStartTime,token:this.tokens.thumbnail})}set poster(t){t||t===""?this.setAttribute(gr.POSTER,t):this.removeAttribute(gr.POSTER)}get storyboardSrc(){var t;return(t=this.getAttribute($.STORYBOARD_SRC))!=null?t:void 0}set storyboardSrc(t){t?this.setAttribute($.STORYBOARD_SRC,t):this.removeAttribute($.STORYBOARD_SRC)}get storyboard(){if(this.storyboardSrc&&!this.tokens.storyboard)return this.storyboardSrc;if(!(this.audio||!this.playbackId||!this.streamType||[ye.LIVE,ye.UNKNOWN].includes(this.streamType)))return NA(this.playbackId,{customDomain:this.customDomain,token:this.tokens.storyboard,programStartTime:this.programStartTime,programEndTime:this.programEndTime})}get audio(){return this.hasAttribute($.AUDIO)}set audio(t){if(!t){this.removeAttribute($.AUDIO);return}this.setAttribute($.AUDIO,"")}get hotkeys(){return Ee(this,Ko)}get nohotkeys(){return this.hasAttribute($.NOHOTKEYS)}set nohotkeys(t){if(!t){this.removeAttribute($.NOHOTKEYS);return}this.setAttribute($.NOHOTKEYS,"")}get thumbnailTime(){return ii(this.getAttribute($.THUMBNAIL_TIME))}set thumbnailTime(t){this.setAttribute($.THUMBNAIL_TIME,`${t}`)}get title(){var t;return(t=this.getAttribute($.TITLE))!=null?t:""}set title(t){t!==this.title&&(t?this.setAttribute($.TITLE,t):this.removeAttribute("title"),super.title=t)}get placeholder(){var t;return(t=en(this,$.PLACEHOLDER))!=null?t:""}set placeholder(t){this.setAttribute($.PLACEHOLDER,`${t}`)}get primaryColor(){var r,s;let t=this.getAttribute($.PRIMARY_COLOR);if(t!=null||this.mediaTheme&&(t=(s=(r=He.getComputedStyle(this.mediaTheme))==null?void 0:r.getPropertyValue("--_primary-color"))==null?void 0:s.trim(),t))return t}set primaryColor(t){this.setAttribute($.PRIMARY_COLOR,`${t}`)}get secondaryColor(){var r,s;let t=this.getAttribute($.SECONDARY_COLOR);if(t!=null||this.mediaTheme&&(t=(s=(r=He.getComputedStyle(this.mediaTheme))==null?void 0:r.getPropertyValue("--_secondary-color"))==null?void 0:s.trim(),t))return t}set secondaryColor(t){this.setAttribute($.SECONDARY_COLOR,`${t}`)}get accentColor(){var r,s;let t=this.getAttribute($.ACCENT_COLOR);if(t!=null||this.mediaTheme&&(t=(s=(r=He.getComputedStyle(this.mediaTheme))==null?void 0:r.getPropertyValue("--_accent-color"))==null?void 0:s.trim(),t))return t}set accentColor(t){this.setAttribute($.ACCENT_COLOR,`${t}`)}get defaultShowRemainingTime(){return this.hasAttribute($.DEFAULT_SHOW_REMAINING_TIME)}set defaultShowRemainingTime(t){t?this.setAttribute($.DEFAULT_SHOW_REMAINING_TIME,""):this.removeAttribute($.DEFAULT_SHOW_REMAINING_TIME)}get playbackRates(){if(this.hasAttribute($.PLAYBACK_RATES))return this.getAttribute($.PLAYBACK_RATES).trim().split(/\s*,?\s+/).map(t=>Number(t)).filter(t=>!Number.isNaN(t)).sort((t,r)=>t-r)}set playbackRates(t){if(!t){this.removeAttribute($.PLAYBACK_RATES);return}this.setAttribute($.PLAYBACK_RATES,t.join(" "))}get forwardSeekOffset(){var t;return(t=ii(this.getAttribute($.FORWARD_SEEK_OFFSET)))!=null?t:10}set forwardSeekOffset(t){this.setAttribute($.FORWARD_SEEK_OFFSET,`${t}`)}get backwardSeekOffset(){var t;return(t=ii(this.getAttribute($.BACKWARD_SEEK_OFFSET)))!=null?t:10}set backwardSeekOffset(t){this.setAttribute($.BACKWARD_SEEK_OFFSET,`${t}`)}get defaultHiddenCaptions(){return this.hasAttribute($.DEFAULT_HIDDEN_CAPTIONS)}set defaultHiddenCaptions(t){t?this.setAttribute($.DEFAULT_HIDDEN_CAPTIONS,""):this.removeAttribute($.DEFAULT_HIDDEN_CAPTIONS)}get defaultDuration(){return ii(this.getAttribute($.DEFAULT_DURATION))}set defaultDuration(t){t==null?this.removeAttribute($.DEFAULT_DURATION):this.setAttribute($.DEFAULT_DURATION,`${t}`)}get playerSoftwareName(){var t;return(t=this.getAttribute(M.PLAYER_SOFTWARE_NAME))!=null?t:GM}get playerSoftwareVersion(){var t;return(t=this.getAttribute(M.PLAYER_SOFTWARE_VERSION))!=null?t:HM}get beaconCollectionDomain(){var t;return(t=this.getAttribute(M.BEACON_COLLECTION_DOMAIN))!=null?t:void 0}set beaconCollectionDomain(t){t!==this.beaconCollectionDomain&&(t?this.setAttribute(M.BEACON_COLLECTION_DOMAIN,t):this.removeAttribute(M.BEACON_COLLECTION_DOMAIN))}get maxResolution(){var t;return(t=this.getAttribute(M.MAX_RESOLUTION))!=null?t:void 0}set maxResolution(t){t!==this.maxResolution&&(t?this.setAttribute(M.MAX_RESOLUTION,t):this.removeAttribute(M.MAX_RESOLUTION))}get minResolution(){var t;return(t=this.getAttribute(M.MIN_RESOLUTION))!=null?t:void 0}set minResolution(t){t!==this.minResolution&&(t?this.setAttribute(M.MIN_RESOLUTION,t):this.removeAttribute(M.MIN_RESOLUTION))}get renditionOrder(){var t;return(t=this.getAttribute(M.RENDITION_ORDER))!=null?t:void 0}set renditionOrder(t){t!==this.renditionOrder&&(t?this.setAttribute(M.RENDITION_ORDER,t):this.removeAttribute(M.RENDITION_ORDER))}get programStartTime(){return ii(this.getAttribute(M.PROGRAM_START_TIME))}set programStartTime(t){t==null?this.removeAttribute(M.PROGRAM_START_TIME):this.setAttribute(M.PROGRAM_START_TIME,`${t}`)}get programEndTime(){return ii(this.getAttribute(M.PROGRAM_END_TIME))}set programEndTime(t){t==null?this.removeAttribute(M.PROGRAM_END_TIME):this.setAttribute(M.PROGRAM_END_TIME,`${t}`)}get extraSourceParams(){return this.hasAttribute($.EXTRA_SOURCE_PARAMS)?[...new URLSearchParams(this.getAttribute($.EXTRA_SOURCE_PARAMS)).entries()].reduce((t,[r,s])=>(t[r]=s,t),{}):WM}set extraSourceParams(t){t==null?this.removeAttribute($.EXTRA_SOURCE_PARAMS):this.setAttribute($.EXTRA_SOURCE_PARAMS,new URLSearchParams(t).toString())}get customDomain(){var t;return(t=this.getAttribute(M.CUSTOM_DOMAIN))!=null?t:void 0}set customDomain(t){t!==this.customDomain&&(t?this.setAttribute(M.CUSTOM_DOMAIN,t):this.removeAttribute(M.CUSTOM_DOMAIN))}get envKey(){var t;return(t=en(this,M.ENV_KEY))!=null?t:void 0}set envKey(t){this.setAttribute(M.ENV_KEY,`${t}`)}get noVolumePref(){return this.hasAttribute($.NO_VOLUME_PREF)}set noVolumePref(t){t?this.setAttribute($.NO_VOLUME_PREF,""):this.removeAttribute($.NO_VOLUME_PREF)}get debug(){return en(this,M.DEBUG)!=null}set debug(t){t?this.setAttribute(M.DEBUG,""):this.removeAttribute(M.DEBUG)}get disableTracking(){return en(this,M.DISABLE_TRACKING)!=null}set disableTracking(t){this.toggleAttribute(M.DISABLE_TRACKING,!!t)}get disableCookies(){return en(this,M.DISABLE_COOKIES)!=null}set disableCookies(t){t?this.setAttribute(M.DISABLE_COOKIES,""):this.removeAttribute(M.DISABLE_COOKIES)}get streamType(){var t,r,s;return(s=(r=this.getAttribute(M.STREAM_TYPE))!=null?r:(t=this.media)==null?void 0:t.streamType)!=null?s:ye.UNKNOWN}set streamType(t){this.setAttribute(M.STREAM_TYPE,`${t}`)}get defaultStreamType(){var t,r,s;return(s=(r=this.getAttribute($.DEFAULT_STREAM_TYPE))!=null?r:(t=this.mediaController)==null?void 0:t.getAttribute($.DEFAULT_STREAM_TYPE))!=null?s:ye.ON_DEMAND}set defaultStreamType(t){t?this.setAttribute($.DEFAULT_STREAM_TYPE,t):this.removeAttribute($.DEFAULT_STREAM_TYPE)}get targetLiveWindow(){var t,r;return this.hasAttribute($.TARGET_LIVE_WINDOW)?+this.getAttribute($.TARGET_LIVE_WINDOW):(r=(t=this.media)==null?void 0:t.targetLiveWindow)!=null?r:Number.NaN}set targetLiveWindow(t){t==this.targetLiveWindow||Number.isNaN(t)&&Number.isNaN(this.targetLiveWindow)||(t==null?this.removeAttribute($.TARGET_LIVE_WINDOW):this.setAttribute($.TARGET_LIVE_WINDOW,`${+t}`))}get liveEdgeStart(){var t;return(t=this.media)==null?void 0:t.liveEdgeStart}get startTime(){return ii(en(this,M.START_TIME))}set startTime(t){this.setAttribute(M.START_TIME,`${t}`)}get preferPlayback(){let t=this.getAttribute(M.PREFER_PLAYBACK);if(t===ei.MSE||t===ei.NATIVE)return t}set preferPlayback(t){t!==this.preferPlayback&&(t===ei.MSE||t===ei.NATIVE?this.setAttribute(M.PREFER_PLAYBACK,t):this.removeAttribute(M.PREFER_PLAYBACK))}get metadata(){var t;return(t=this.media)==null?void 0:t.metadata}set metadata(t){if(Qe(this,tr,Yr).call(this),!this.media){Wt("underlying media element missing when trying to set metadata. metadata will not be set.");return}this.media.metadata={...f1(this),...t}}get _hlsConfig(){var t;return(t=this.media)==null?void 0:t._hlsConfig}set _hlsConfig(t){if(Qe(this,tr,Yr).call(this),!this.media){Wt("underlying media element missing when trying to set _hlsConfig. _hlsConfig will not be set.");return}this.media._hlsConfig=t}async addCuePoints(t){var r;if(Qe(this,tr,Yr).call(this),!this.media){Wt("underlying media element missing when trying to addCuePoints. cuePoints will not be added.");return}return(r=this.media)==null?void 0:r.addCuePoints(t)}get activeCuePoint(){var t;return(t=this.media)==null?void 0:t.activeCuePoint}get cuePoints(){var t,r;return(r=(t=this.media)==null?void 0:t.cuePoints)!=null?r:[]}addChapters(t){var r;if(Qe(this,tr,Yr).call(this),!this.media){Wt("underlying media element missing when trying to addChapters. chapters will not be added.");return}return(r=this.media)==null?void 0:r.addChapters(t)}get activeChapter(){var t;return(t=this.media)==null?void 0:t.activeChapter}get chapters(){var t,r;return(r=(t=this.media)==null?void 0:t.chapters)!=null?r:[]}getStartDate(){var t;return(t=this.media)==null?void 0:t.getStartDate()}get currentPdt(){var t;return(t=this.media)==null?void 0:t.currentPdt}get tokens(){let t=this.getAttribute($.PLAYBACK_TOKEN),r=this.getAttribute($.DRM_TOKEN),s=this.getAttribute($.THUMBNAIL_TOKEN),n=this.getAttribute($.STORYBOARD_TOKEN);return{...Ee(this,Wo),...t!=null?{playback:t}:{},...r!=null?{drm:r}:{},...s!=null?{thumbnail:s}:{},...n!=null?{storyboard:n}:{}}}set tokens(t){Kt(this,Wo,t!=null?t:{})}get playbackToken(){var t;return(t=this.getAttribute($.PLAYBACK_TOKEN))!=null?t:void 0}set playbackToken(t){this.setAttribute($.PLAYBACK_TOKEN,`${t}`)}get drmToken(){var t;return(t=this.getAttribute($.DRM_TOKEN))!=null?t:void 0}set drmToken(t){this.setAttribute($.DRM_TOKEN,`${t}`)}get thumbnailToken(){var t;return(t=this.getAttribute($.THUMBNAIL_TOKEN))!=null?t:void 0}set thumbnailToken(t){this.setAttribute($.THUMBNAIL_TOKEN,`${t}`)}get storyboardToken(){var t;return(t=this.getAttribute($.STORYBOARD_TOKEN))!=null?t:void 0}set storyboardToken(t){this.setAttribute($.STORYBOARD_TOKEN,`${t}`)}addTextTrack(t,r,s,n){var o;let a=(o=this.media)==null?void 0:o.nativeEl;if(a)return Tc(a,t,r,s,n)}removeTextTrack(t){var s;let r=(s=this.media)==null?void 0:s.nativeEl;if(r)return z_(r,t)}get textTracks(){var t;return(t=this.media)==null?void 0:t.textTracks}};Go=new WeakMap,Wo=new WeakMap,zr=new WeakMap,Ko=new WeakMap,tn=new WeakMap,tr=new WeakSet,Yr=function(){var t,r,s;if(!Ee(this,Go)){Kt(this,Go,!0),Qe(this,jr,sa).call(this);try{if(customElements.upgrade(this.mediaTheme),!(this.mediaTheme instanceof He.HTMLElement))throw""}catch{Wt("<media-theme> failed to upgrade!")}try{if(customElements.upgrade(this.media),!(this.media instanceof CA))throw""}catch{Wt("<mux-video> failed to upgrade!")}try{if(customElements.upgrade(this.mediaController),!(this.mediaController instanceof Dh))throw""}catch{Wt("<media-controller> failed to upgrade!")}HA(this),Qe(this,rh,g1).call(this),Qe(this,sh,v1).call(this),Qe(this,nh,E1).call(this),Kt(this,zr,(r=(t=this.mediaController)==null?void 0:t.hasAttribute(fe.USER_INACTIVE))!=null?r:!0),Qe(this,ah,b1).call(this),(s=this.media)==null||s.addEventListener("streamtypechange",()=>{Qe(this,jr,sa).call(this)})}},ih=new WeakSet,p1=function(){var t,r;try{(t=window==null?void 0:window.CSS)==null||t.registerProperty({name:"--media-primary-color",syntax:"<color>",inherits:!0}),(r=window==null?void 0:window.CSS)==null||r.registerProperty({name:"--media-secondary-color",syntax:"<color>",inherits:!0})}catch{}},Vo=new WeakSet,ov=function(t){Object.assign(Ee(this,tn),t),Qe(this,jr,sa).call(this)},jr=new WeakSet,sa=function(t={}){l1(d1(OM(this,{...Ee(this,tn),...t})),this.shadowRoot)},rh=new WeakSet,g1=function(){let t=s=>{var o,l;if(!(s!=null&&s.startsWith("theme-")))return;let n=s.replace(/^theme-/,"");if(av.includes(n))return;let a=this.getAttribute(s);a!=null?(o=this.mediaTheme)==null||o.setAttribute(n,a):(l=this.mediaTheme)==null||l.removeAttribute(n)};new MutationObserver(s=>{for(let{attributeName:n}of s)t(n)}).observe(this,{attributes:!0}),this.getAttributeNames().forEach(t)},sh=new WeakSet,v1=function(){var r;let t=s=>{let{detail:n}=s;if(n instanceof bt||(n=new bt(n.message,n.code,n.fatal)),!(n!=null&&n.fatal)){Hr(n),n.data&&Hr(`${n.name} data:`,n.data);return}let{dialog:a,devlog:o}=eh(n,!window.navigator.onLine,this.playbackId,this.playbackToken);o.message&&V0(o),Wt(n),n.data&&Wt(`${n.name} data:`,n.data),Qe(this,Vo,ov).call(this,{isDialogOpen:!0,dialog:a})};this.addEventListener("error",t),this.media&&(this.media.errorTranslator=(s={})=>{var a,o,l;if(!(((a=this.media)==null?void 0:a.error)instanceof bt))return s;let{devlog:n}=eh((o=this.media)==null?void 0:o.error,!window.navigator.onLine,this.playbackId,this.playbackToken,!1);return{player_error_code:(l=this.media)==null?void 0:l.error.code,player_error_message:n.message?String(n.message):s.player_error_message,player_error_context:n.context?String(n.context):s.player_error_context}}),(r=this.media)==null||r.addEventListener("error",s=>{var a,o;let{detail:n}=s;if(!n){let{message:l,code:d}=(o=(a=this.media)==null?void 0:a.error)!=null?o:{};n=new bt(l,d)}n!=null&&n.fatal&&this.dispatchEvent(new CustomEvent("error",{detail:n}))})},nh=new WeakSet,E1=function(){var r,s,n,a;let t=()=>Qe(this,jr,sa).call(this);(s=(r=this.media)==null?void 0:r.textTracks)==null||s.addEventListener("addtrack",t),(a=(n=this.media)==null?void 0:n.textTracks)==null||a.addEventListener("removetrack",t)},ah=new WeakSet,b1=function(){var d,u;if(!/Firefox/i.test(navigator.userAgent))return;let r,s=new WeakMap,n=()=>this.streamType===ye.LIVE&&!this.secondaryColor&&this.offsetWidth>=800,a=(c,h,f=!1)=>{if(n())return;Array.from(c&&c.activeCues||[]).forEach(p=>{if(!(!p.snapToLines||p.line<-5||p.line>=0&&p.line<10))if(!h||this.paused){let g=p.text.split(`
2987
+ `).length,E=-3;this.streamType===ye.LIVE&&(E=-2);let T=E-g;if(p.line===T&&!f)return;s.has(p)||s.set(p,p.line),p.line=T}else setTimeout(()=>{p.line=s.get(p)||"auto"},500)})},o=()=>{var c,h;a(r,(h=(c=this.mediaController)==null?void 0:c.hasAttribute(fe.USER_INACTIVE))!=null?h:!1)},l=()=>{var f,m;let h=Array.from(((m=(f=this.mediaController)==null?void 0:f.media)==null?void 0:m.textTracks)||[]).filter(p=>["subtitles","captions"].includes(p.kind)&&p.mode==="showing")[0];h!==r&&(r==null||r.removeEventListener("cuechange",o)),r=h,r==null||r.addEventListener("cuechange",o),a(r,Ee(this,zr))};l(),(d=this.textTracks)==null||d.addEventListener("change",l),(u=this.textTracks)==null||u.addEventListener("addtrack",l),this.addEventListener("userinactivechange",()=>{var h,f;let c=(f=(h=this.mediaController)==null?void 0:h.hasAttribute(fe.USER_INACTIVE))!=null?f:!0;Ee(this,zr)!==c&&(Kt(this,zr,c),a(r,Ee(this,zr)))})};function en(i,e){return i.media?i.media.getAttribute(e):i.getAttribute(e)}He.customElements.get("mux-player")||(He.customElements.define("mux-player",Ho),He.MuxPlayerElement=Ho);var nB=Ho;})();
2982
2988
  /*! Bundled license information:
2983
2989
 
2984
2990
  mux-embed/dist/mux.mjs: