PageSourceSearch

https://flask.do/assets/media-vendor-BKwxxWU2.js

js flask.do collected 2026-10-04 03:54:42 UTC 782,980 bytes, 1,378 lines download raw bytes

1const sm=["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"],Uu=["autopictureinpicture","disablepictureinpicture","disableremoteplayback","autoplay","controls","controlslist","crossorigin","loop","muted","playsinline","poster","preload","src"];function rm(s){return`
2    <style>
3      :host {
4        display: inline-flex;
5        line-height: 0;
6        flex-direction: column;
7        justify-content: end;
8      }
9
10      audio {
11        width: 100%;
12      }
13    </style>
14    <slot name="media">
15      <audio${Bu(s)}></audio>
16    </slot>
17    <slot></slot>
18  `}function nm(s){return`
19    <style>
20      :host {
21        display: inline-block;
22        line-height: 0;
23      }
24
25      video {
26        max-width: 100%;
27        max-height: 100%;
28        min-width: 100%;
29        min-height: 100%;
30        object-fit: var(--media-object-fit, contain);
31        object-position: var(--media-object-position, 50% 50%);
32      }
33
34      video::-webkit-media-text-track-container {
35        transform: var(--media-webkit-text-track-transform);
36        transition: var(--media-webkit-text-track-transition);
37      }
38    </style>
39    <slot name="media">
40      <video${Bu(s)}></video>
41    </slot>
42    <slot></slot>
43  `}function $u(s,{tag:e,is:t}){const i=globalThis.document?.createElement?.(e,{is:t}),r=i?am(i):[];return class uo extends s{static getTemplateHTML=e.endsWith("audio")?rm:nm;static shadowRootOptions={mode:"open"};static Events=sm;static#e=!1;static get observedAttributes(){return uo.#t(),[...i?.constructor?.observedAttributes??[],...Uu]}static#t(){if(this.#e)return;this.#e=!0;const a=new Set(this.observedAttributes);a.delete("muted");for(const o of r)if(!(o in this.prototype))if(typeof i[o]=="function")this.prototype[o]=function(...l){return this.#n(),this.call?this.call(o,...l):this.nativeEl?.[o]?.apply(this.nativeEl,l)};else{const l={get(){this.#n();const d=o.toLowerCase();if(a.has(d)){const c=this.getAttribute(d);return c===null?!1:c===""?!0:c}return this.get?.(o)??this.nativeEl?.[o]}};o!==o.toUpperCase()&&(l.set=function(d){this.#n();const c=o.toLowerCase();if(a.has(c)){d===!0||d===!1||d==null?this.toggleAttribute(c,!!d):this.setAttribute(c,d);return}if(this.set){this.set(o,d);return}this.nativeEl&&(this.nativeEl[o]=d)}),Object.defineProperty(this.prototype,o,l)}}#i=!1;#s=null;#r=new Map;#a;get;set;call;get nativeEl(){return this.#n(),this.#s??this.querySelector(":scope > [slot=media]")??this.querySelector(e)??this.shadowRoot?.querySelector(e)??null}set nativeEl(a){this.#s=a}get defaultMuted(){return this.hasAttribute("muted")}set defaultMuted(a){this.toggleAttribute("muted",a)}get src(){return this.getAttribute("src")}set src(a){this.setAttribute("src",`${a}`)}get preload(){return this.getAttribute("preload")??this.nativeEl?.preload}set preload(a){this.setAttribute("preload",`${a}`)}#n(){this.#i||(this.#i=!0,this.init())}init(){if(!this.shadowRoot){this.attachShadow({mode:"open"});const a=om(this.attributes);t&&(a.is=t),e&&(a.part=e),this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(a)}this.nativeEl.muted=this.hasAttribute("muted");for(const a of r)this.#c(a);this.#a=new MutationObserver(this.#d.bind(this)),this.shadowRoot.addEventListener("slotchange",()=>this.#o()),this.#o();for(const a of this.constructor.Events)this.shadowRoot.addEventListener(a,this,!0)}handleEvent(a){a.target===this.nativeEl&&this.dispatchEvent(new CustomEvent(a.type,{detail:a.detail}))}#o(){const a=new Map(this.#r);(this.shadowRoot?.querySelector("slot:not([name])")?.assignedElements({flatten:!0}).filter(d=>["track","source"].includes(d.localName))).forEach(d=>{a.delete(d);let c=this.#r.get(d);c||(c=d.cloneNode(),this.#r.set(d,c),this.#a?.observe(d,{attributes:!0})),this.nativeEl?.append(c),this.#l(c)}),a.forEach((d,c)=>{d.remove(),this.#r.delete(c)})}#d(a){for(const o of a)if(o.type==="attributes"){const{target:l,attributeName:d}=o,c=this.#r.get(l);c&&d&&(c.setAttribute(d,l.getAttribute(d)??""),this.#l(c))}}#l(a){a&&a.localName==="track"&&a.default&&(a.kind==="chapters"||a.kind==="metadata")&&a.track.mode==="disabled"&&(
43a.track.mode="hidden")}#c(a){if(Object.prototype.hasOwnProperty.call(this,a)){const o=this[a];delete this[a],this[a]=o}}attributeChangedCallback(a,o,l){this.#n(),this.#u(a,o,l)}#u(a,o,l){["id","class"].includes(a)||!uo.observedAttributes.includes(a)&&this.constructor.observedAttributes.includes(a)||(l===null?this.nativeEl?.removeAttribute(a):this.nativeEl?.getAttribute(a)!==l&&this.nativeEl?.setAttribute(a,l))}connectedCallback(){this.#n()}}}function am(s){const e=[];for(let t=Object.getPrototypeOf(s);t&&t!==HTMLElement.prototype;t=Object.getPrototypeOf(t)){const i=Object.getOwnPropertyNames(t);e.push(...i)}return e}function Bu(s){let e="";for(const t in s){if(!Uu.includes(t))continue;const i=s[t];i===""?e+=` ${t}`:e+=` ${t}="${i}"`}return e}function om(s){const e={};for(const t of s)e[t.name]=t.value;return e}const lm=$u(globalThis.HTMLElement??class{},{tag:"video"});$u(globalThis.HTMLElement??class{},{tag:"audio"});class ha extends Event{track;constructor(e,t){super(e),this.track=t.track}}const ho=new WeakMap;function Q(s){return ho.get(s)??dm(s,{})}function dm(s,e){let t=ho.get(s);return t||ho.set(s,t={}),Object.assign(t,e)}function fo(s,e){const t=s.videoTracks;Q(e).media=s,Q(e).renditionSet||(Q(e).renditionSet=new Set);const i=Q(t).trackSet;i.add(e);const r=i.size-1;r in mo.prototype||Object.defineProperty(mo.prototype,r,{get(){return[...Q(this).trackSet][r]}}),queueMicrotask(()=>{t.dispatchEvent(new ha("addtrack",{track:e}))})}function go(s){const e=Q(s).media?.videoTracks;if(!e)return;Q(e).trackSet.delete(s),queueMicrotask(()=>{e.dispatchEvent(new ha("removetrack",{track:s}))})}function cm(s){const e=Q(s).media.videoTracks??[];let t=!1;for(const i of e)i!==s&&(i.selected=!1,t=!0);if(t){if(Q(e).changeRequested)return;Q(e).changeRequested=!0,queueMicrotask(()=>{delete Q(e).changeRequested,e.dispatchEvent(new Event("change"))})}}
43class mo extends EventTarget{#e;#t;#i;constructor(){super(),Q(this).trackSet=new Set}get#s(){return Q(this).trackSet}[Symbol.iterator](){return this.#s.values()}get length(){return this.#s.size}getTrackById(e){return[...this.#s].find(t=>t.id===e)??null}get selectedIndex(){return[...this.#s].findIndex(e=>e.selected)}get onaddtrack(){return this.#e}set onaddtrack(e){this.#e&&(this.removeEventListener("addtrack",this.#e),this.#e=void 0),typeof e=="function"&&(this.#e=e,this.addEventListener("addtrack",e))}get onremovetrack(){return this.#t}set onremovetrack(e){this.#t&&(this.removeEventListener("removetrack",this.#t),this.#t=void 0),typeof e=="function"&&(this.#t=e,this.addEventListener("removetrack",e))}get onchange(){return this.#i}set onchange(e){this.#i&&(this.removeEventListener("change",this.#i),this.#i=void 0),typeof e=="function"&&(this.#i=e,this.addEventListener("change",e))}}class fa extends Event{rendition;constructor(e,t){super(e),this.rendition=t.rendition}}function um(s,e){const t=Q(s).media.videoRenditions;Q(e).media=Q(s).media,Q(e).track=s;const i=Q(s).renditionSet;i.add(e);const r=i.size-1;r in po.prototype||Object.defineProperty(po.prototype,r,{get(){return ss(this)[r]}}),queueMicrotask(()=>{s.selected&&t.dispatchEvent(new fa("addrendition",{rendition:e}))})}function hm(s){const e=Q(s).media.videoRenditions,t=Q(s).track;Q(t).renditionSet.delete(s),queueMicrotask(()=>{Q(s).track.selected&&e.dispatchEvent(new fa("removerendition",{rendition:s}))})}function fm(s){const e=Q(s).media.videoRenditions;!e||Q(e).changeRequested||(Q(e).changeRequested=!0,queueMicrotask(()=>{delete Q(e).changeRequested,Q(s).track.selected&&e.dispatchEvent(new Event("change"))}))}function ss(s){return[...Q(s).media.videoTracks].filter(t=>t.selected).flatMap(t=>[...Q(t).renditionSet])}class po extends EventTarget{#e;#t;#i;[Symbol.iterator](){return ss(this).values()}get length(){return ss(this).length}getRenditionById(e){return ss(this).find(t=>`${t.id}`==`${e}`)??null}get selectedIndex(){return ss(this).findIndex(e=>e.selected)}set selectedIndex(e){for(const[t,i]of ss(this).entries())i.selected=t===e}get onaddrendition(){return this.#e}set onaddrendition(e){this.#e&&(this.removeEventListener("addrendition",this.#e),this.#e=void 0),typeof e=="function"&&(this.#e=e,this.addEventListener("addrendition",e))}get onremoverendition(){return this.#t}set onremoverendition(e){this.#t&&(this.removeEventListener("removerendition",this.#t),this.#t=void 0),typeof e=="function"&&(this.#t=e,this.addEventListener("removerendition",e))}get onchange(){return this.#i}set onchange(e){this.#i&&(this.removeEventListener("change",this.#i),this.#i=void 0),typeof e=="function"&&(this.#i=e,this.addEventListener("change",e))}}class gm{src;id;width;height;bitrate;frameRate;codec;#e=!1;get selected(){return this.#e}set selected(e){this.#e!==e&&(this.#e=e,fm(this))}}class Gu{id;kind;label="";language="";sourceBuffer;#e=!1;addRendition(e,t,i,r,n,a){const o=new gm;return o.src=e,o.width=t,o.height=i,o.frameRate=a,o.bitrate=n,o.codec=r,um(this,o),o}removeRendition(e){hm(e)}get selected(){return this.#e}set selected(e){this.#e!==e&&(this.#e=e,e===!0&&cm(this))}}function mm(s,e){const t=Q(s).media.audioRenditions;Q(e).media=Q(s).media,Q(e).track=s;const i=Q(s).renditionSet;i.add(e);const r=i.size-1;r in Eo.prototype||Object.defineProperty(Eo.prototype,r,{get(){return rs(this)[r]}}),queueMicrotask(()=>{s.enabled&&t.dispatchEvent(new fa("addrendition",{rendition:e}))})}function pm(s){const e=Q(s).media.audioRenditions,t=Q(s).track;Q(t).renditionSet.delete(s),queueMicrotask(()=>{Q(s).track.enabled&&e.dispatchEvent(new fa("removerendition",{rendition:s}))})}function Em(s){const e=Q(s).media.audioRenditions;!e||Q(e).changeRequested||(Q(e).changeRequested=!0,queueMicrotask(()=>{delete Q(e).changeRequested,Q(s).track.enabled&&e.dispatchEvent(new Event("change"))}))}function rs(s){return[...Q(s).media.audioTracks].filter(t=>t.enabled).flatMap(t=>[...Q(t).renditionSet])}class Eo extends EventTarget{#e;#t;#i;[Symbol.iterator](){return rs(this).values()}get length(){return rs(this).length}getRenditionById(e){return rs(this).find(t=>`${t.id}`==`${e}`)??null}get selectedIndex(){return rs(this).findIndex(e=>e.selected)}set selectedIndex(e){for(const[t,i]of rs(this).entries())i.selected=t===e}get onaddrendition(){return this.#e}set onaddrendition(e){this.#e&&(this.removeEventListener("addrendition",this.#e),this.#e=void 0),typeof e=="function"&&(this.#e=e,this.addEventListener("addrendition",e))}get onremoverendition(){return this.#t}set onremoverendition(e){this.#t&&(this.removeEventListener("removerendition",this.#t),this.#t=void 0),typeof e=="function"&&(this.#t=e,this.addEventListener("removerendition",e))}get onchange(){return this.#i}set onchange(e){this.#i&&(this.removeEventListener("change",this.#i),this.#i=void 0),typeof e=="function"&&(this.#i=e,this.addEventListener("change",e))}}class vm{src;id;bitrate;codec;#e=!1;get selected(){return this.#e}set selected(e){this.#e!==e&&(this.#e=e,Em(this))}}function vo(s,e){const t=s.audioTracks;Q(e).media=s,Q(e).renditionSet||(Q(e).renditionSet=new Set);const i=Q(t).trackSet;i.add(e);const r=i.size-1;
43r in To.prototype||Object.defineProperty(To.prototype,r,{get(){return[...Q(this).trackSet][r]}}),queueMicrotask(()=>{t.dispatchEvent(new ha("addtrack",{track:e}))})}function yo(s){const e=Q(s).media?.audioTracks;if(!e)return;Q(e).trackSet.delete(s),queueMicrotask(()=>{e.dispatchEvent(new ha("removetrack",{track:s}))})}function ym(s){const e=Q(s).media.audioTracks;!e||Q(e).changeRequested||(Q(e).changeRequested=!0,queueMicrotask(()=>{delete Q(e).changeRequested,e.dispatchEvent(new Event("change"))}))}class To extends EventTarget{#e;#t;#i;constructor(){super(),Q(this).trackSet=new Set}get#s(){return Q(this).trackSet}[Symbol.iterator](){return this.#s.values()}get length(){return this.#s.size}getTrackById(e){return[...this.#s].find(t=>t.id===e)??null}get onaddtrack(){return this.#e}set onaddtrack(e){this.#e&&(this.removeEventListener("addtrack",this.#e),this.#e=void 0),typeof e=="function"&&(this.#e=e,this.addEventListener("addtrack",e))}get onremovetrack(){return this.#t}set onremovetrack(e){this.#t&&(this.removeEventListener("removetrack",this.#t),this.#t=void 0),typeof e=="function"&&(this.#t=e,this.addEventListener("removetrack",e))}get onchange(){return this.#i}set onchange(e){this.#i&&(this.removeEventListener("change",this.#i),this.#i=void 0),typeof e=="function"&&(this.#i=e,this.addEventListener("change",e))}}class Vu{id;kind;label="";language="";sourceBuffer;#e=!1;addRendition(e,t,i){const r=new vm;return r.src=e,r.codec=t,r.bitrate=i,mm(this,r),r}removeRendition(e){pm(e)}get enabled(){return this.#e}set enabled(e){this.#e!==e&&(this.#e=e,ym(this))}}const _d=Un(globalThis.HTMLMediaElement,"video"),Ld=Un(globalThis.HTMLMediaElement,"audio");function Tm(s){if(!s?.prototype)return s;const e=Un(s,"video");(!e||`${e}`.includes("[native code]"))&&Object.defineProperty(s.prototype,"videoTracks",{get(){return Sm(this)}});const t=Un(s,"audio");(!t||`${t}`.includes("[native code]"))&&Object.defineProperty(s.prototype,"audioTracks",{get(){return Am(this)}}),"addVideoTrack"in s.prototype||(s.prototype.addVideoTrack=function(n,a="",o=""){const l=new Gu;return l.kind=n,l.label=a,l.language=o,fo(this,l),l}),"removeVideoTrack"in s.prototype||(s.prototype.removeVideoTrack=go),"addAudioTrack"in s.prototype||(s.prototype.addAudioTrack=function(n,a="",o=""){const l=new Vu;return l.kind=n,l.label=a,l.language=o,vo(this,l),l}),"removeAudioTrack"in s.prototype||(s.prototype.removeAudioTrack=yo),"videoRenditions"in s.prototype||Object.defineProperty(s.prototype,"videoRenditions",{get(){return i(this)}});const i=n=>{let a=Q(n).videoRenditions;return a||(a=new po,Q(a).media=n,Q(n).videoRenditions=a),a};"audioRenditions"in s.prototype||Object.defineProperty(s.prototype,"audioRenditions",{get(){return r(this)}});const r=n=>{let a=Q(n).audioRenditions;return a||(a=new Eo,Q(a).media=n,Q(n).audioRenditions=a),a};return s}function Un(s,e){if(s?.prototype)return Object.getOwnPropertyDescriptor(s.prototype,`${e}Tracks`)?.get}function Sm(s){let e=Q(s).videoTracks;if(!e&&(e=new mo,Q(s).videoTracks=e,_d)){const t=_d.call(s.nativeEl??s);for(const i of t)fo(s,i);t.addEventListener("change",()=>{e.dispatchEvent(new Event("change"))}),t.addEventListener("addtrack",i=>{if([...e].some(r=>r instanceof Gu)){for(const r of t)go(r);return}fo(s,i.track)}),t.addEventListener("removetrack",i=>{go(i.track)})}return e}function Am(s){let e=Q(s).audioTracks;
43if(!e&&(e=new To,Q(s).audioTracks=e,Ld)){const t=Ld.call(s.nativeEl??s);for(const i of t)vo(s,i);t.addEventListener("change",()=>{e.dispatchEvent(new Event("change"))}),t.addEventListener("addtrack",i=>{if([...e].some(r=>r instanceof Vu)){for(const r of t)yo(r);return}vo(s,i.track)}),t.addEventListener("removetrack",i=>{yo(i.track)})}return e}const B=Number.isFinite||function(s){return typeof s=="number"&&isFinite(s)},bm=Number.isSafeInteger||function(s){return typeof s=="number"&&Math.abs(s)<=Im},Im=Number.MAX_SAFE_INTEGER||9007199254740991;let X=function(s){return s.NETWORK_ERROR="networkError",s.MEDIA_ERROR="mediaError",s.KEY_SYSTEM_ERROR="keySystemError",s.MUX_ERROR="muxError",s.OTHER_ERROR="otherError",s}({}),x=function(s){return s.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",s.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",s.KEY_SYSTEM_NO_SESSION="keySystemNoSession",s.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",s.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",s.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",s.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",s.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",s.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",s.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",s.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",s.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",s.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",s.MANIFEST_LOAD_ERROR="manifestLoadError",s.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",s.MANIFEST_PARSING_ERROR="manifestParsingError",s.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",s.LEVEL_EMPTY_ERROR="levelEmptyError",s.PLAYLIST_UNCHANGED_ERROR="playlistUnchangedError",s.LEVEL_LOAD_ERROR="levelLoadError",s.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",s.LEVEL_PARSING_ERROR="levelParsingError",s.LEVEL_SWITCH_ERROR="levelSwitchError",s.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",s.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",s.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",s.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",s.FRAG_LOAD_ERROR="fragLoadError",s.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",s.FRAG_DECRYPT_ERROR="fragDecryptError",s.FRAG_PARSING_ERROR="fragParsingError",s.FRAG_GAP="fragGap",s.REMUX_ALLOC_ERROR="remuxAllocError",s.KEY_LOAD_ERROR="keyLoadError",s.KEY_LOAD_TIMEOUT="keyLoadTimeOut",s.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",s.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",s.BUFFER_APPEND_ERROR="bufferAppendError",s.BUFFER_APPENDING_ERROR="bufferAppendingError",s.BUFFER_APPEND_NO_PROGRESS="bufferAppendNoProgress",s.BUFFER_STALLED_ERROR="bufferStalledError",s.BUFFER_FULL_ERROR="bufferFullError",s.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",s.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",s.ASSET_LIST_LOAD_ERROR="assetListLoadError",s.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",s.ASSET_LIST_PARSING_ERROR="assetListParsingError",s.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",s.INTERNAL_EXCEPTION="internalException",s.INTERNAL_ABORTED="aborted",s.ATTACH_MEDIA_ERROR="attachMediaError",s.MEDIA_SOURCE_REQUIRES_RESET="mediaSourceRequiresReset",s.UNKNOWN="unknown",s}({}),E=function(s){return s.MEDIA_ATTACHING="hlsMediaAttaching",s.MEDIA_ATTACHED="hlsMediaAttached",s.MEDIA_DETACHING="hlsMediaDetaching",s.MEDIA_DETACHED="hlsMediaDetached",s.MEDIA_ENDED="hlsMediaEnded",s.STALL_RESOLVED="hlsStallResolved",s.BUFFER_RESET="hlsBufferReset",s.BUFFER_CODECS="hlsBufferCodecs",s.BUFFER_CREATED="hlsBufferCreated",s.BUFFER_APPENDING="hlsBufferAppending",s.BUFFER_APPENDED="hlsBufferAppended",s.BUFFER_EOS="hlsBufferEos",s.BUFFERED_TO_END="hlsBufferedToEnd",s.BUFFER_FLUSHING="hlsBufferFlushing",s.BUFFER_FLUSHED="hlsBufferFlushed",s.MANIFEST_LOADING="hlsManifestLoading",s.MANIFEST_LOADED="hlsManifestLoaded",s.MANIFEST_PARSED="hlsManifestParsed",s.LEVEL_SWITCHING="hlsLevelSwitching",s.LEVEL_SWITCHED="hlsLevelSwitched",s.LEVEL_LOADING="hlsLevelLoading",s.LEVEL_LOADED="hlsLevelLoaded",s.LEVEL_UPDATED="hlsLevelUpdated",s.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",s.LEVELS_UPDATED="hlsLevelsUpdated",s.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",s.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",s.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",s.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",s.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",s.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",s.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUp
43dated",s.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",s.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",s.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",s.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",s.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",s.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",s.CUES_PARSED="hlsCuesParsed",s.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",s.INIT_PTS_FOUND="hlsInitPtsFound",s.FRAG_LOADING="hlsFragLoading",s.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",s.FRAG_LOADED="hlsFragLoaded",s.FRAG_DECRYPTED="hlsFragDecrypted",s.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",s.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",s.FRAG_PARSING_METADATA="hlsFragParsingMetadata",s.FRAG_PARSED="hlsFragParsed",s.FRAG_BUFFERED="hlsFragBuffered",s.FRAG_CHANGED="hlsFragChanged",s.FPS_DROP="hlsFpsDrop",s.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",s.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",s.ERROR="hlsError",s.DESTROYING="hlsDestroying",s.KEY_LOADING="hlsKeyLoading",s.KEY_LOADED="hlsKeyLoaded",s.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",s.BACK_BUFFER_REACHED="hlsBackBufferReached",s.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",s.ASSET_LIST_LOADING="hlsAssetListLoading",s.ASSET_LIST_LOADED="hlsAssetListLoaded",s.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",s.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",s.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",s.INTERSTITIAL_STARTED="hlsInterstitialStarted",s.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",s.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",s.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",s.INTERSTITIAL_ENDED="hlsInterstitialEnded",s.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",s.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",s.EVENT_CUE_ENTER="hlsEventCueEnter",s}({});function _m(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var La={exports:{}},xd;function Lm(){return xd||(xd=1,function(s,e){(function(t){var i=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,r=/^(?=([^\/?#]*))\1([^]*)$/,n=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(l,d,c){if(c=c||{},l=l.trim(),d=d.trim(),!d){if(!c.alwaysNormalize)return l;var u=o.parseURL(l);if(!u)throw new Error("Error trying to parse base URL.");return u.path=o.normalizePath(u.path),o.buildURLFromParts(u)}var h=o.parseURL(d);if(!h)throw new Error("Error trying to parse relative URL.");if(h.scheme)return c.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 g=r.exec(f.path);f.netLoc=g[1],f.path=g[2]}f.netLoc&&!f.path&&(f.path="/");var m={scheme:f.scheme,netLoc:h.netLoc,path:null,params:h.params,query:h.query,fragment:h.fragment};if(!h.netLoc&&(m.netLoc=f.netLoc,h.path[0]!=="/"))if(!h.path)m.path=f.path,h.params||(m.params=f.params,h.query||(m.query=f.query));else{var p=f.path,v=p.substring(0,p.lastIndexOf("/")+1)+h.path;m.path=o.normalizePath(v)}return m.path===null&&(m.path=c.alwaysNormalize?o.normalizePath(h.path):h.path),o.buildURLFromParts(m)},parseURL:function(l){var d=i.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}};s.exports=o})()}(La)),La.exports}var pl=Lm();class El{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}}}var ue={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack",MEDIA_FRAGMENT:"media-fragment",KEY:"key",STEERING_MANIFEST:"steering-manifest",SERVER_CERTIFICATE:"server-certificate",INTERSTITIAL_ASSET_LIST:"interstitial-asset-list"},j={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"},xe={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class Hu{constructor(e){this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,typeof e=="string"&&(e={url:e}),this.base=e,Rm(this,"stats")}
vendor: 5,580 bytes, line 43
43setByteRange(e,t){const i=e.split("@",2);let r;i.length===1?r=t?.byteRangeEndOffset||0:r=parseInt(i[1]),this._byteRange=[r,parseInt(i[0])+r]}get baseurl(){return this.base.url}get byteRange(){return this._byteRange===null?[]:this._byteRange}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get elementaryStreams(){return this._streams===null&&(this._streams={[xe.AUDIO]:null,[xe.VIDEO]:null,[xe.AUDIOVIDEO]:null}),this._streams}set elementaryStreams(e){this._streams=e}get hasStats(){return this._stats!==null}get hasStreams(){return this._streams!==null}get stats(){return this._stats===null&&(this._stats=new El),this._stats}set stats(e){this._stats=e}get url(){return!this._url&&this.relurl&&(this._url=pl.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[xe.AUDIO]=null,e[xe.VIDEO]=null,e[xe.AUDIOVIDEO]=null,this.url=null}}function Ue(s){return s.sn!=="initSegment"}function Gs(s,e){return s.sn===e?.sn&&s.level===e.level}function So(s,e){return s.sn===e?.sn&&s.level===e.level&&s.cc===e.cc}class Pr extends Hu{constructor(e,t){super(t),this._decryptdata=null,this._programDateTime=null,this._ref=null,this._bitrate=void 0,this.rawProgramDateTime=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.playlistOffset=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,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 byteLength(){if(this.hasStats){const e=this.stats.total;if(e)return e}if(this.byteRange.length){const e=this.byteRange[0],t=this.byteRange[1];if(B(e)&&B(t))return t-e}return null}get bitrate(){return this.byteLength?this.byteLength*8/this.duration:this._bitrate?this._bitrate:null}set bitrate(e){this._bitrate=e}get decryptdata(){var e;const{levelkeys:t}=this;if(!t||t.NONE)return null;if(t.identity)this._decryptdata||(this._decryptdata=t.identity.getDecryptData(this.sn));else if(!((e=this._decryptdata)!=null&&e.keyId)){const i=Object.keys(t);if(i.length===1){const r=this._decryptdata=t[i[0]]||null;r&&(this._decryptdata=r.getDecryptData(this.sn,t))}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null)return null;const e=B(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){var t;const i=Object.keys(this.levelkeys),r=i.length;if(r>1||r===1&&(t=this.levelkeys[i[0]])!=null&&t.encrypted)return!0}return!1}get programDateTime(){return this._programDateTime===null&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime}set programDateTime(e){if(!B(e)){this._programDateTime=this.rawProgramDateTime=null;return}this._programDateTime=e}get ref(){return Ue(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}addStart(e){this.setStart(this.start+e)}setStart(e){this.start=e,this._ref&&(this._ref.start=e)}setDuration(e){this.duration=e,this._ref&&(this._ref.duration=e)}setKeyFormat(e){const t=this.levelkeys;if(t){var i;const r=t[e];r&&!((i=this._decryptdata)!=null&&i.keyId)&&(this._decryptdata=r.getDecryptData(this.sn,t))}}abortRequests(){var e,t;(e=this.loader)==null||e.abort(),(t=this.keyLoader)==null||t.abort()}setElementaryStreamInfo(e,t,i,r,n,a=!1){const{elementaryStreams:o}=this,l=o[e];if(!l){o[e]={startPTS:t,endPTS:i,startDTS:r,endDTS:n,partial:a};return}l.startPTS=Math.min(l.startPTS,t),l.endPTS=Math.max(l.endPTS,i),l.startDTS=Math.min(l.startDTS,r),l.endDTS=Math.max(l.endDTS,n)}}class xm extends Hu{constructor(e,t,i,r,n){super(i),this.fragOffset=0,this.duration=0,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.gap=!1,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=r;const 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(){const{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo||this.fragment.type===j.SUBTITLE&&this.stats.loaded)}}function Ku(s,e){const t=Object.getPrototypeOf(s);if(t){const i=Object.getOwnPropertyDescriptor(t,e);return i||Ku(t,e)}}function Rm(s,e){const t=Ku(s,e);t&&(t.enumerable=!0,Object.defineProperty(s,e,t))}function Dm(s,e,t){return(e=Pm(e))in s?Object.defineProperty(s,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[e]=t,s}function Ie(){return Ie=Object.assign?Object.assign.bind():function(s){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)({}).hasOwnProperty.call(t,i)&&(s[i]=t[i])}return s},Ie.apply(null,arguments)}function Rd(s,e){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(s);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(s,r).enumerable})),t.push.apply(t,i)}return t}function Z(s){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};
vendor: 16,045 bytes, line 43
43e%2?Rd(Object(t),!0).forEach(function(i){Dm(s,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):Rd(Object(t)).forEach(function(i){Object.defineProperty(s,i,Object.getOwnPropertyDescriptor(t,i))})}return s}function ga(s,e){if(s==null)return{};var t,i,r=km(s,e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(s);for(i=0;i<n.length;i++)t=n[i],e.indexOf(t)===-1&&{}.propertyIsEnumerable.call(s,t)&&(r[t]=s[t])}return r}function km(s,e){if(s==null)return{};var t={};for(var i in s)if({}.hasOwnProperty.call(s,i)){if(e.indexOf(i)!==-1)continue;t[i]=s[i]}return t}function Cm(s,e){if(typeof s!="object"||!s)return s;var t=s[Symbol.toPrimitive];if(t!==void 0){var i=t.call(s,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(s)}function Pm(s){var e=Cm(s,"string");return typeof e=="symbol"?e:e+""}function $n(s){switch(s.details){case x.FRAG_LOAD_TIMEOUT:case x.KEY_LOAD_TIMEOUT:case x.LEVEL_LOAD_TIMEOUT:case x.MANIFEST_LOAD_TIMEOUT:case x.AUDIO_TRACK_LOAD_TIMEOUT:case x.SUBTITLE_TRACK_LOAD_TIMEOUT:case x.ASSET_LIST_LOAD_TIMEOUT:return!0}return!1}function Wu(s){return s.details.startsWith("key")}function Yu(s){return Wu(s)&&!!s.frag&&!s.frag.decryptdata}function Dd(s,e){const t=$n(e);return s.default[`${t?"timeout":"error"}Retry`]}function vl(s,e){const t=s.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*s.retryDelayMs,s.maxRetryDelayMs)}function kd(s){return Z(Z({},s),{errorRetry:null,timeoutRetry:null})}function lr(s,e,t,i){if(!s)return!1;const r=i?.code,n=e<s.maxNumRetry&&(wm(r)||!!t);return s.shouldRetry?s.shouldRetry(s,e,t,i,n):n}function wm(s){return dr(s)||!!s&&(s<400||s>499)}function dr(s){return s===0&&navigator.onLine===!1}function qu(s,e){return e>0&&s.loadError>0&&s.loadErrorTime!==0&&self.performance.now()-s.loadErrorTime>e}class ji{constructor(e,t=0,i=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_=i}sample(e,t){const i=Math.pow(this.alpha_,e);this.estimate_=t*(1-i)+i*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}class Mm{constructor(e,t,i,r=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_=i,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new ji(e),this.fast_=new ji(t),this.defaultTTFB_=r,this.ttfb_=new ji(e)}update(e,t){const{slow_:i,fast_:r,ttfb_:n}=this;i.halfLife!==e&&(this.slow_=new ji(e,i.getEstimate(),i.getTotalWeight())),r.halfLife!==t&&(this.fast_=new ji(t,r.getEstimate(),r.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new ji(e,n.getEstimate(),n.getTotalWeight()))}sample(e,t){if(t<=0)return;const i=Math.min(this.minDelayMs_,t/1e5),r=8*t,n=Math.max(e,i)/1e3,a=r/n;this.fast_.sample(n,a),this.slow_.sample(n,a)}sampleTTFB(e){const t=e/1e3,i=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(i,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_}get defaultEstimate(){return this.defaultEstimate_}destroy(){}}class Dt{constructor(e,t){this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;const i=`[${e}]:`;this.trace=_i,this.debug=t.debug.bind(null,i),this.log=t.log.bind(null,i),this.warn=t.warn.bind(null,i),this.info=t.info.bind(null,i),this.error=t.error.bind(null,i)}}const _i=function(){},Om={trace:_i,debug:_i,log:_i,warn:_i,info:_i,error:_i};function Ao(){return Ie({},Om)}function Fm(s,e){const t=self.console[s];return t?t.bind(self.console,`${e?"["+e+"] ":""}[${s}] >`):_i}function Cd(s,e,t){return e[s]?e[s].bind(e):Fm(s,t)}const bo=Ao();function Nm(s,e,t){const i=Ao();if(typeof console=="object"&&s===!0||typeof s=="object"){const r=["debug","log","info","warn","error"];r.forEach(n=>{i[n]=Cd(n,s,t)});try{i.log(`Debug logs enabled for "${e}" in hls.js version 1.7.0-rc.3`)}catch{return Ao()}r.forEach(n=>{bo[n]=Cd(n,s)})}else Ie(bo,i);return i}const Te=bo;function ki(s=!0){return typeof self>"u"?void 0:(s||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function Um(s){return typeof self<"u"&&s===self.ManagedMediaSource}function ju(s,e){const t=Object.keys(s),i=Object.keys(e),r=t.length,n=i.length;return!r||!n||r===n&&!t.some(a=>i.indexOf(a)===-1)}function $m(s){return btoa(String.fromCharCode(...s))}function ma(s){return s instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&s instanceof SharedArrayBuffer}const Bm="utf-16",xa="utf-16be",Pd="utf-16le",on="utf-8";function Gm(s,e={}){let t;ma(s)?t=new DataView(s):t=new DataView(s.buffer,s.byteOffset,s.byteLength);let i=0,{encoding:r}=e;if(!r){const d=t.getUint8(0),c=t.getUint8(1);d==239&&c==187&&t.getUint8(2)==191?(r=on,i=3):d==254&&c==255?(r=xa,i=2):d==255&&c==254?(r=Pd,i=2):r=on}if(typeof TextDecoder<"u")return new TextDecoder(r).decode(t);const{byteLength:n}=t,a=r!==xa;let o="",l;for(;i<n;){switch(r){case on:if(l=t.getUint8(i),l<128)i++;else if(l>=194&&l<=223)if(i+1<n){const d=t.getUint8(i+1);d>=128&&d<=191?(l=(l&31)<<6|d&63,i+=2):i++}else i++;else if(l>=224&&l<=239)if(i+2<=n-1){const d=t.getUint8(i+1),c=t.getUint8(i+2);d>=128&&d<=191&&c>=128&&c<=191?(l=(l&15)<<12|(d&63)<<6|c&63,i+=3):i++}else i++;else if(l>=240&&l<=244)if(i+3<=n-1){const d=t.getUint8(i+1),c=t.getUint8(i+2),u=t.getUint8(i+3);d>=128&&d<=191&&c>=128&&c<=191&&u>=128&&u<=191?(l=(l&7)<<18|(d&63)<<12|(c&63)<<6|u&63,i+=4):i++}else i++;else i++;break;case xa:case Bm:case Pd:l=t.getUint16(i,a),i+=2;break}o+=String.fromCodePoint(l)}return o}function Vm(s){const e=typeof s=="string"?new URL(s):s;return e.origin+e.pathname.substring(0,e.pathname.lastIndexOf("/")+1)}function zu(s,e){if(s<0)return-zu(-s,e);const t=Math.pow(10,e);if(Math.abs(s*t%1-.5)<Number.EPSILON){const i=Math.floor(s*t);return(i%2===0?i:i+1)/t}else return Math.round(s*t)/t}function Hm(s,e){let t;try{t=new URL(s)}catch{return s}const i=new URL(e);if(t.origin!==i.origin)return s;const r=t.pathname.split("/").slice(1),n=i.pathname.split("/").slice(1,-1),a=Math.min(r.length,n.length);for(let o=0;o<a&&r[o]===n[o];o++)r.shift(),n.shift();for(;n.length;)n.shift(),r.unshift("..");return r.join("/")+t.search+t.hash}function Qu(){try{return crypto.randomUUID()}catch{try{const 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,i=>{const r=(t+Math.random()*16)%16|0;return t=Math.floor(t/16),(i=="x"?r:r&3|8).toString(16)})}}}function yl(s,e){return e+10<=s.length&&s[e]===73&&s[e+1]===68&&s[e+2]===51&&s[e+3]<255&&s[e+4]<255&&s[e+6]<128&&s[e+7]<128&&s[e+8]<128&&s[e+9]<128}function pa(s,e){let t=0;return t=(s[e]&127)<<21,t|=(s[e+1]&127)<<14,t|=(s[e+2]&127)<<7,t|=s[e+3]&127,t}function Km(s,e){return yl(s,e)&&pa(s,e+6)+10<=s.length-e}function Xu(s,e){return e+10<=s.length&&s[e]===51&&s[e+1]===68&&s[e+2]===73&&s[e+3]<255&&s[e+4]<255&&s[e+6]<128&&s[e+7]<128&&s[e+8]<128&&s[e+9]<128}function cr(s,e){const t=e;let i=0;for(;yl(s,e);){i+=10;const r=pa(s,e+6);i+=r,Xu(s,e+10)&&(i+=10),e+=i}if(i>0)return s.subarray(t,t+i)}function Wm(s){return ma(s)?s:s.byteOffset==0&&s.byteLength==s.buffer.byteLength?s.buffer:new Uint8Array(s).buffer}function Ra(s,e=0,t=1/0){return Ym(s,e,t,Uint8Array)}function Ym(s,e,t,i){const r=qm(s);let n=1;"BYTES_PER_ELEMENT"in i&&(n=i.BYTES_PER_ELEMENT);const a=jm(s)?s.byteOffset:0,o=(a+s.byteLength)/n,l=(a+e)/n,d=Math.floor(Math.max(0,Math.min(l,o)));return new i(r,d,Math.floor(Math.min(d+Math.max(t,0),o))-d)}function qm(s){return ma(s)?s:s.buffer}function jm(s){return s&&ma(s.buffer)&&s.byteLength!==void 0&&s.byteOffset!==void 0}function Rt(s,e=!1){const t=e?s.indexOf(0):s.length,i=Gm(new DataView(s.buffer,s.byteOffset,t),{encoding:on});return e?i:i.replace(/\0/g,"")}function zm(s){const e={key:s.type,description:"",data:"",mimeType:null,pictureType:null},t=3;if(s.size<2||s.data[0]!==t)return;const i=s.data.subarray(1).indexOf(0);if(i===-1)return;const r=Rt(Ra(s.data,1,i)),n=s.data[2+i],a=s.data.subarray(3+i).indexOf(0);if(a===-1)return;const o=Rt(Ra(s.data,3+i,a));let l;return r==="-->"?l=Rt(Ra(s.data,4+i+a)):l=Wm(s.data.subarray(4+i+a)),e.mimeType=r,e.pictureType=n,e.description=o,e.data=l,e}function Qm(s){if(s.size<2)return;const e=Rt(s.data,!0),t=new Uint8Array(s.data.subarray(e.length+1));return{key:s.type,info:e,data:t.buffer}}function Xm(s){if(s.size<2)return;if(s.type==="TXXX"){let t=1;const{data:i}=s,r=Rt(i.subarray(t),!0);t+=r.length+1;const n=Rt(i.subarray(t));return{key:s.type,info:r,data:n}}const e=Rt(s.data.subarray(1));return{key:s.type,info:"",data:e}}function Zm(s){if(s.type==="WXXX"){if(s.size<2)return;let t=1;const i=Rt(s.data.subarray(t),!0);t+=i.length+1;const r=Rt(s.data.subarray(t));return{key:s.type,info:i,data:r}}const e=Rt(s.data);return{key:s.type,info:"",data:e}}function Jm(s){return s.type==="PRIV"?Qm(s):s.type[0]==="W"?Zm(s):s.type==="APIC"?zm(s):Xm(s)}function ep(s){const e=String.fromCharCode(s[0],s[1],s[2],s[3]),t=pa(s,4),i=10;return{type:e,size:t,data:s.subarray(i,i+t)}}const wr=10,tp=10;function Zu(s){let e=0;const t=[];for(;yl(s,e);){const i=pa(s,e+6);s[e+5]>>6&1&&(e+=wr),e+=wr;const r=e+i;for(;e+tp<r;){const n=ep(s.subarray(e)),a=Jm(n);a&&t.push(a),e+=n.size+wr}Xu(s,e)&&(e+=wr)}return t}function Ju(s){return s&&s.key==="PRIV"&&s.info==="com.apple.streaming.transportStreamTimestamp"}function ip(s){if(s.data.byteLength===8){const e=new Uint8Array(s.data),t=e[3]&1;let i=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return i/=45,t&&(i+=4772185884e-2),Math.round(i)}}function Tl(s){const e=Zu(s);for(const t of e)if(Ju(t))return ip(t)}function Ye(s){let e="";for(let t=0;t<s.length;t++){let i=s[t].toString(16);i.length<2&&(i="0"+i),e+=i}return e}function eh(s){return Uint8Array.from(s.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}function Sl(s){return Uint8Array.from(atob(s),e=>e.charCodeAt(0))}function Ne(s){return String.fromCharCode.apply(null,s)}const ti=Math.pow(2,32)-1,re={avc1:1635148593,avcC:1635148611,hvc1:1752589105,hvcC:1752589123,btrt:1651798644,dinf:1684631142,dref:1685218662,esds:1702061171,free:1718773093,ftyp:1718909296,hdlr:1751411826,mdat:1835295092,mdhd:1835296868,mdia:1835297121,mfhd:1835427940,minf:1835626086,moof:1836019558,moov:1836019574,mp4a:1836069985,".mp3":778924083,dac3:1684103987,"ac-3":1633889587,mvex:1836475768,mvhd:1836476516,pasp:1885434736,sdtp:1935963248,stbl:1937007212,stco:1937007471,stsc:1937011555,stsd:1937011556,stsz:1937011578,stts:1937011827,tfdt:1952867444,tfhd:1952868452,traf:1953653094,trak:1953653099,trun:1953658222,trex:1953654136,tkhd:1953196132,vmhd:1986881636,smhd:1936549988},th={video:1,audio:2,id3:3,text:4};function ih(s,e){const t=s[e]<<8|s[e+1];return t<0?65536+t:t}function W(s,e){const t=s[e]<<24|s[e+1]<<16|s[e+2]<<8|s[e+3];return t<0?4294967296+t:t}function wd(s,e){let t=W(s,e);return t*=Math.pow(2,32),t+=W(s,e+4),t}function Io(s,e){return s[e]<<24|s[e+1]<<16|s[e+2]<<8|s[e+3]}function He(s,e,t){s[e]=t>>24,s[e+1]=t>>16&255,s[e+2]=t>>8&255,s[e+3]=t&255}function Md(s,e,t){const i=e.byteOffset-s.byteOffset-8,r=8+t,n=e.byteLength+8-r;n<8||(He(s,i,r),He(s,i+r,n),He(s,i+r+4,re.free))}function _o(s,e){return[s.byteOffset-e-8,s.byteOffset-e+s.byteLength]}function sh(s,e){e.sort((o,l)=>o[0]-l[0]);const t=e.reduce((o,[l,d])=>o+d-l,0),i=new Uint8Array(s.byteLength-t);let r=0,n=0;for(let o=0;o<e.length;o++){const[l,d]=e[o];i.set(s.subarray(r,l),n),n+=l-r,r=d}return i.set(s.subarray(r),n),{result:i,dropped:t,droppedBefore:o=>e.reduce((l,[d,c])=>c<=o?l+c-d:l,0)}}function sp(s){const e=oe(s,["moov"]);if(e.length!==1||oe(s,["moof"]).length)return null;const t=s.byteOffset,i=[],r=[];let n=!1;const a=oe(e[0],["trak"]);for(let f=0;f<a.length;f++){const g=a[f],m=oe(g,["mdia","hdlr"])[0];if((m?Ne(m.subarray(8,12)):"")==="vide"){n=!0;continue}const v=oe(g,["tkhd"])[0];if(!v)return null;const T=v[0];r.push(W(v,T===0?12:20)),i.push(_o(g,t))}if(!n||!i.length)return null;const o=oe(e[0],["mvex"])[0];let l=0;if(o){const f=oe(o,["trex"]);for(let g=0;g<f.length;g++){const m=f[g];r.indexOf(W(m,4))!==-1&&(i.push(_o(m,t)),l+=m.byteLength+8)}}const{result:d,dropped:c,droppedBefore:u}=sh(s,i),h=e[0].byteOffset-t-8;if(He(d,h,e[0].byteLength+8-c),o&&l){const f=o.byteOffset-t-8;He(d,f-u(f),o.byteLength+8-l)}return d}function rp(s,e,t,i,r){if(t<1)return null;const n=oe(s,["moof"]);if(n.length!==1)return null;const a=n[0],o=s.byteOffset,l=[],d=[],c=oe(a,["traf"]);let u=!0;for(let m=0;m<c.length;m++){const p=c[m],v=oe(p,["tfhd"])[0];if(!v)return null;W(v,4)===e?(l.push(p),W(v,0)&131072||(u=!1)):d.push(_o(p,o))}if(!l.length||d.length&&!u)return null;if(i!==void 0){let m=t;for(let v=0;v<l.length;v++){const T=l[v];let y=0;const S=oe(T,["trun"]);for(let _=0;_<S.length;_++){const R=S[_],D=Math.min(m,W(R,4));if(D){He(s,R.byteOffset-o+4,D);const L=W(R,0)&16777215,k=(L&256?4:0)+(L&512?4:0)+(L&1024?4:0)+(L&2048?4:0);Md(s,R,8+(L&1?4:0)+(L&4?4:0)+D*k)}else He(s,R.byteOffset-o-4,re.free);m-=D,y+=D}const A=oe(T,["senc"])[0];A&&He(s,A.byteOffset-o+4,y);const I=oe(T,["saiz"])[0];if(I){const _=I[1]<<16|I[2]<<8|I[3];let R=4;_&1&&(R+=8);const D=I[R];R+=1,He(s,I.byteOffset-o+R,y),Md(s,I,R+4+(D===0?y:0))}}const p=oe(s,["mdat"]);if(p.length===1){const v=p[0].byteOffset-o-8;He(s,v,i-v)}}let h=s,f=0,g=()=>0;if(d.length){({result:h,dropped:f,droppedBefore:g}=sh(s,d)),He(h,a.byteOffset-o-8,a.byteLength+8-f);for(let m=0;m<l.length;m++){const p=l[m],v=g(p.byteOffset-o),T=oe(p,["trun"]);for(let y=0;y<T.length;y++){const S=T[y];W(S,0)&1&&He(h,S.byteOffset-o-v+8,W(S,8)-f)}if(v){const y=oe(p,["saio"]);for(let S=0;S<y.length;S++){const A=y[S],I=A[0]===0?4:8;let _=W(A,0)&1?12:4,R=W(A,_);for(_+=4;R--;_+=I){const D=_+I-4;He(h,A.byteOffset-o-v+D,W(A,D)-v)}}}}}if(r){const{durationOffset:m,value:p}=r;He(h,m-g(m),p)}return i!==void 0?h.subarray(0,i-f):h}function np(s,e){const t=s.byteLength;for(let i=0;i<t;){const r=W(s,i);if(r>8&&W(s,i+4)===re[e])return!0;i=r>1?i+r:t}return!1}function oe(s,e){const t=[];return e.length&&rh(s,e,0,0,s.byteLength,t),t}function rh(s,e,t,i,r,n){const a=e[t];if(a?.length!==4)return;const o=a.charCodeAt(0),l=a.charCodeAt(1),d=a.charCodeAt(2),c=a.charCodeAt(3),u=e.length-1;for(let h=i;h<r;){const f=h+8<=r,g=h+4<=r?s[h]*16777216+(s[h+1]<<16|s[h+2]<<8|s[h+3]):W(s,h),m=g>1?h+g:r;if(f&&s[h+4]===o&&s[h+5]===l&&s[h+6]===d&&s[h+7]===c){const p=Math.min(m,r);t===u?n.push(s.subarray(h+8,p)):rh(s,e,t+1,h+8,p,n)}h=m}}function ap(s){const e=[],t=s[0];let i=8;const r=W(s,i);i+=4;let n=0,a=0;t===0?(n=W(s,i),a=W(s,i+4),i+=8):(n=wd(s,i),a=wd(s,i+8),i+=16),i+=2;let o=s.length+a;const l=ih(s,i);i+=2;for(let d=0;d<l;d++){let c=i;const u=W(s,c);c+=4;const h=u&2147483647;if((u&2147483648)>>>31===1)return Te.warn("SIDX has hierarchical references (not supported)"),null;const g=W(s,c);c+=4,e.push({referenceSize:h,subsegmentDuration:g,info:{duration:g/r,start:o,end:o+h-1}}),o+=h,c+=4,i=c}return{earliestPresentationTime:n,timescale:r,version:t,referencesCount:l,references:e}}function nh(s){const e=[],t=oe(s,["moov","trak"]);for(let r=0;r<t.length;r++){const n=t[r],a=oe(n,["tkhd"])[0];if(a){let o=a[0];const l=W(a,o===0?12:20),d=oe(n,["mdia","mdhd"])[0];if(d){o=d[0];const c=W(d,o===0?12:20),u=oe(n,["mdia","hdlr"])[0];if(u){const h=Ne(u.subarray(8,12)),f={soun:xe.AUDIO,vide:xe.VIDEO}[h],g=oe(n,["mdia","minf","stbl","stsd"])[0],m=op(g);f?(e[l]={timescale:c,type:f,stsd:m},e[f]=Z({timescale:c,id:l},m)):e[l]={timescale:c,type:h,stsd:m}}}}}
vendor: 5,707 bytes, line 43
43return oe(s,["moov","mvex","trex"]).forEach(r=>{const n=W(r,4),a=e[n];a&&(a.default={duration:W(r,12),sampleSize:W(r,16),flags:W(r,20)})}),e}function op(s){const e=s.subarray(8),t=e.subarray(86),i=Ne(e.subarray(4,8));let r=i,n;const a=i==="enca"||i==="encv";if(a){const d=oe(e,[i])[0].subarray(i==="enca"?28:78);oe(d,["sinf"]).forEach(u=>{const h=oe(u,["schm"])[0];if(h){const f=Ne(h.subarray(4,8));if(f==="cbcs"||f==="cenc"){const g=oe(u,["frma"])[0];g&&(r=Ne(g))}}})}const o=r;switch(r){case"avc1":case"avc2":case"avc3":case"avc4":{const l=oe(t,["avcC"])[0];l&&l.length>3&&(r+="."+Or(l[1])+Or(l[2])+Or(l[3]),n=Mr(o==="avc1"?"dva1":"dvav",t));break}case"mp4a":{const l=oe(e,[i])[0],d=oe(l.subarray(28),["esds"])[0];if(d&&d.length>7){let c=4;if(d[c++]!==3)break;c=Da(d,c),c+=2;const u=d[c++];if(u&128&&(c+=2),u&64&&(c+=d[c++]),d[c++]!==4)break;c=Da(d,c);const h=d[c++];if(h===64)r+="."+Or(h);else break;if(c+=12,d[c++]!==5)break;c=Da(d,c);const f=d[c++];let g=(f&248)>>3;g===31&&(g+=1+((f&7)<<3)+((d[c]&224)>>5)),r+="."+g}break}case"hvc1":case"hev1":{const l=oe(t,["hvcC"])[0];if(l&&l.length>12){const d=l[1],c=["","A","B","C"][d>>6],u=d&31,h=W(l,2),f=(d&32)>>5?"H":"L",g=l[12],m=l.subarray(6,12);r+="."+c+u,r+="."+lp(h).toString(16).toUpperCase(),r+="."+f+g;let p="";for(let v=m.length;v--;){const T=m[v];(T||p)&&(p="."+T.toString(16).toUpperCase()+p)}r+=p}n=Mr(o=="hev1"?"dvhe":"dvh1",t);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":{r=Mr(r,t)||r;break}case"vp09":{const l=oe(t,["vpcC"])[0];if(l&&l.length>6){const d=l[4],c=l[5],u=l[6]>>4&15;r+="."+ii(d)+"."+ii(c)+"."+ii(u)}break}case"av01":{const l=oe(t,["av1C"])[0];if(l&&l.length>2){const d=l[1]>>>5,c=l[1]&31,u=l[2]>>>7?"H":"M",h=(l[2]&64)>>6,f=(l[2]&32)>>5,g=d===2&&h?f?12:10:h?10:8,m=(l[2]&16)>>4,p=(l[2]&8)>>3,v=(l[2]&4)>>2,T=l[2]&3;r+="."+d+"."+ii(c)+u+"."+ii(g)+"."+m+"."+p+v+T+"."+ii(1)+"."+ii(1)+"."+ii(1)+"."+0,n=Mr("dav1",t)}break}}return{codec:r,encrypted:a,supplemental:n}}function Mr(s,e){const t=oe(e,["dvvC"]),i=t.length?t[0]:oe(e,["dvcC"])[0];if(i){const r=i[2]>>1&127,n=i[2]<<5&32|i[3]>>3&31;return s+"."+ii(r)+"."+ii(n)}}function lp(s){let e=0;for(let t=0;t<32;t++)e|=(s>>t&1)<<31-t;return e>>>0}function Da(s,e){const t=e+5;for(;s[e++]&128&&e<t;);return e}function Or(s){return("0"+s.toString(16).toUpperCase()).slice(-2)}function ii(s){return(s<10?"0":"")+s}function dp(s,e){if(!s||!e)return;const t=e.keyId;t?.byteLength===16&&e.isCommonEncryption&&ah(s,(i,r)=>{const n=i.subarray(8,24);n.some(a=>a!==0)||(Te.log(`[eme] Patching keyId in 'enc${r?"a":"v"}>sinf>>tenc' box: ${Ye(n)} -> ${Ye(t)}`),i.set(t,8))})}function cp(s){const e=[];return ah(s,t=>e.push(t.subarray(8,24))),e}function ah(s,e){oe(s,["moov","trak"]).forEach(i=>{const r=oe(i,["mdia","minf","stbl","stsd"])[0];if(!r)return;const n=r.subarray(8);let a=oe(n,["enca"]);const o=a.length>0;o||(a=oe(n,["encv"])),a.forEach(l=>{const d=o?l.subarray(28):l.subarray(78);oe(d,["sinf"]).forEach(u=>{const h=oh(u);h&&e(h,o)})})})}function oh(s){const e=oe(s,["schm"])[0];if(e){const t=Ne(e.subarray(4,8));if(t==="cbcs"||t==="cenc"){const i=oe(s,["schi","tenc"])[0];if(i)return i}}}let Od;function up(s){return typeof TextDecoder>"u"?Rt(s):(Od||(Od=new TextDecoder("utf-8"))).decode(s).replace(/\0/g,"")}function hp(s){const e=s.byteLength,t=[];for(let i=0;i<e;){const r=i+8<=e,n=i+4<=e?s[i]*16777216+(s[i+1]<<16|s[i+2]<<8|s[i+3]):W(s,i),a=n>1?i+n:e;if(r&&s[i+4]===109&&s[i+5]===111&&s[i+6]===111&&s[i+7]===102){const o=Math.min(a,e);for(let l=i+8;l<o;){const d=l+8<=o,c=l+4<=o?s[l]*16777216+(s[l+1]<<16|s[l+2]<<8|s[l+3]):W(s,l),u=c>1?l+c:o;if(d&&s[l+4]===116&&s[l+5]===114&&s[l+6]===97&&s[l+7]===102){const h=Math.min(u,o);let f,g;const m=[];for(let p=l+8;p<h;){const v=p+8<=h,T=p+4<=h?s[p]*16777216+(s[p+1]<<16|s[p+2]<<8|s[p+3]):W(s,p),y=T>1?p+T:h;if(v&&s[p+4]===116){const S=Math.min(y,h);s[p+5]===102&&s[p+6]===104&&s[p+7]===100?g||(g=s.subarray(p+8,S)):s[p+5]===102&&s[p+6]===100&&s[p+7]===116?f||(f=s.subarray(p+8,S)):s[p+5]===114&&s[p+6]===117&&s[p+7]===110&&m.push(s.subarray(p+8,S))}p=y}t.push({moofOffset:s.byteOffset+i,tfdt:f,tfhd:g,truns:m})}l=u}}i=a}return t}function fp(s,e,t,i,r=!0){return lh(s,e,i,r)}function gp(s,e,t,i,r=!1){const n=[],a=e.samples,o=lh(a,t,i,r,{isHEVCFlavor:Dr(e.codec),samples:n,timeOffset:s,timescale:e.timescale,trackId:e.id});return{samples:n,sampleData:{includeSampleDetails:r,tracks:o}}}function lh(s,e,t,i,r){const n={};let a=!1;const o=hp(s),l=s.byteLength;for(let u=0;u<o.length;u++){const{moofOffset:h,tfdt:f,tfhd:g,truns:m}=o[u],p=W(g,4),v=e[p];if(!v)continue;const T=n[p]||(n[p]={start:NaN,duration:0,sampleCount:0,trun:[],timescale:v.timescale,type:v.type});let y;if(f){const F=f[0];y=W(f,4),F===1&&(y===ti?t.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"):(y*=ti+1,y+=W(f,8))),B(y)&&(!B(T.start)||y<T.start)&&(T.start=y),r&&B(y)&&(r.timeOffset=y/r.timescale)}const S=r?.trackId===p&&v.type===xe.VIDEO,A=v.default,I=W(g,0)&16777215;let _=A?.duration||0,R,D=A?.sampleSize||0,L=8;I&1&&(L+=8),I&2&&(L+=4),I&8&&(_=W(g,L),R=g.byteOffset-s.byteOffset+L,L+=4),I&16&&(D=W(g,L));let k=0;const w=(I&1)!==0,U=!w&&(I&131072)!==0;w?(k=W(g,8),k*=Math.pow(2,32),k+=W(g,12)):U&&(k=h);let K=y||0,G=0,O=_;for(let F=0;F<m.length;F++){const M=m[F],$=W(M,4),Y=T.sampleCount;T.sampleCount+=$;const N=M[3]&1;let V=0;const se=M[3]&4,J=M[2]&1,de=M[2]&2,te=M[2]&4,fe=M[2]&8;let le=8;N&&(V=Io(M,le),le+=4),se&&(!(M[le+1]&1)&&T.keyFrameIndex===void 0&&(T.keyFrameIndex=Y),le+=4);let pe=k+V;if(!i&&M[1]===0&&M[2]===6&&M[3]===1){var d,c;const _e=K,ht=pe,St=le;let z=-1,he=0,ge=0,we=(d=r?.timeOffset)!=null?d:0;const Me=_/((c=r?.timescale)!=null?c:1),ce=r?.isHEVCFlavor===!0,st=ce?2:1;for(let je=0;je<$;
vendor: 22,826 bytes, line 43
43je++){const rt=M[le]===0?M[le+1]<<16|M[le+2]<<8|M[le+3]:W(M,le),pt=z===-1&&T.keyFrameIndex===void 0&&(M[le+5]&1)===0;le+=8;const ft=pe+rt;if(S){if(rt>0){let Qe=pe;do{const Vt=s[Qe]===0?s[Qe+1]<<16|s[Qe+2]<<8|s[Qe+3]:W(s,Qe);Qe+=4;const Oe=s[Qe],Se=ce?Oe>>1&63:Oe&31;(ce?Se===39||Se===40:Se===6)&&ur(s.subarray(Qe,Qe+Vt),st,we,r.samples),Qe+=Vt}while(Qe<ft)}we+=Me}pe=ft,pt&&(z=je,he=pe)}if(pe<=l)ge=$;else{let je=ht,rt=St;for(let pt=0;pt<$;pt++){const ft=M[rt]===0?M[rt+1]<<16|M[rt+2]<<8|M[rt+3]:W(M,rt);if(je+=ft,je>l)break;ge=pt+1,rt+=8}}if(S&&(r.timeOffset=we),z!==-1&&he<=l&&T.keyFrameIndex===void 0&&(T.keyFrameIndex=z,T.keyFrameStart=_e+z*_),ge){(!B(T.ptsMin)||_e<T.ptsMin)&&(T.ptsMin=_e);const je=_e+ge*_;(!B(T.ptsMax)||je>T.ptsMax)&&(T.ptsMax=je)}const di=_*$;K=_e+di,G+=di;continue}let Pe,it;i&&(Pe=[],it={sampleOffset:pe,samples:Pe,defaultSampleDurationOffset:R},pe<=l&&T.trun.push(it));let dt;for(let _e=0;_e<$;_e++){let ht;J?(i&&(ht=M.byteOffset-s.byteOffset+le),O=W(M,le),le+=4):O=_,de?(dt=W(M,le),le+=4):dt=D;let St,z;te&&(z=M[le+1]&1?1:0,i&&(St={isNonSync:z,dependsOn:(M[le]&3)===1?1:2}),le+=4);let he=0;if(fe&&(he=M[0]===0?W(M,le):Io(M,le),le+=4),S){let ge=pe,we=0;for(;we<dt;){const Me=W(s,ge);ge+=4,dh(r.isHEVCFlavor,s[ge])&&ur(s.subarray(ge,ge+Me),r.isHEVCFlavor?2:1,r.timeOffset+he/r.timescale,r.samples),ge+=Me,we+=Me+4}r.timeOffset+=O/r.timescale}if(pe+=dt,pe<=l){it&&ht!==void 0&&(it.lastSampleDurationOffset=ht),z===0&&T.keyFrameIndex===void 0&&(T.keyFrameIndex=_e,T.keyFrameStart=K);const ge=K+he;(!B(T.ptsMin)||ge<T.ptsMin)&&(T.ptsMin=ge),(!B(T.ptsMax)||ge+O>T.ptsMax)&&(T.ptsMax=ge+O),Pe&&(Pe[_e]={cts:he,duration:O,flags:St,size:dt})}K+=O,G+=O}!G&&_&&(G+=_*$)}T.duration+=G,T.duration&&(a=!0)}if(!a){let u=1/0,h=0;const f=oe(s,["sidx"]);for(let g=0;g<f.length;g++){const m=ap(f[g]);if(m!=null&&m.references){u=Math.min(u,m.earliestPresentationTime/m.timescale);const p=m.references.reduce((v,T)=>v+T.info.duration||0,0);h=Math.max(h,p+m.earliestPresentationTime/m.timescale)}}h&&B(h)&&Object.keys(n).forEach(g=>{n[g].duration||(n[g].duration=h*n[g].timescale-n[g].start)})}return n}function mp(s){const e={valid:null,remainder:null},t=oe(s,["moof"]);if(t.length<2)return e.remainder=s,e;const i=t[t.length-1];return e.valid=s.slice(0,i.byteOffset-8),e.remainder=s.slice(i.byteOffset-8),e}function Pt(s,e){const t=new Uint8Array(s.length+e.length);return t.set(s),t.set(e,s.length),t}function pp(s,e){const t=[],i=e.samples,r=e.timescale,n=e.id;let a=!1;return oe(i,["moof"]).map(l=>{const d=l.byteOffset-8;oe(l,["traf"]).map(u=>{const h=oe(u,["tfdt"]).map(f=>{const g=f[0];let m=W(f,4);return g===1&&(m*=Math.pow(2,32),m+=W(f,8)),m/r})[0];return h!==void 0&&(s=h),oe(u,["tfhd"]).map(f=>{const g=W(f,4),m=W(f,0)&16777215,p=(m&1)!==0;let v=0;const T=(m&2)!==0,y=(m&8)!==0;let S=0;const A=(m&16)!==0;let I=0;const _=(m&32)!==0,R=!p&&(m&131072)!==0;let D=8;g===n&&(p?(v=W(f,D),D+=4,v*=Math.pow(2,32),v+=W(f,D),D+=4):R&&(v=d),T&&(D+=4),y&&(S=W(f,D),D+=4),A&&(I=W(f,D),D+=4),_&&(D+=4),e.type==="video"&&(a=Dr(e.codec)),oe(u,["trun"]).map(L=>{const k=L[0],w=W(L,0)&16777215,U=(w&1)!==0;let K=0;const G=(w&4)!==0,O=(w&256)!==0;let F=0;const M=(w&512)!==0;let $=0;const Y=(w&1024)!==0,N=(w&2048)!==0;let V=0;const se=W(L,4);let J=8;U&&(K=W(L,J),J+=4),G&&(J+=4);let de=v+K;for(let te=0;te<se;te++){if(O?(F=W(L,J),J+=4):F=S,M?($=W(L,J),J+=4):$=I,Y&&(J+=4),N&&(k===0?V=W(L,J):V=Io(L,J),J+=4),e.type===xe.VIDEO){let fe=0;for(;fe<$;){const le=W(i,de);if(de+=4,dh(a,i[de])){const pe=i.subarray(de,de+le);ur(pe,a?2:1,s+V/r,t)}de+=le,fe+=le+4}}s+=F/r}}))})})}),t}function Dr(s){if(!s)return!1;const e=s.substring(0,4);return e==="hvc1"||e==="hev1"||e==="dvh1"||e==="dvhe"}function dh(s,e){if(s){const t=e>>1&63;return t===39||t===40}else return(e&31)===6}function ur(s,e,t,i){const r=ch(s);let n=0;n+=e;let a=0,o=0,l=0;for(;n<r.length;){a=0;do{if(n>=r.length)break;l=r[n++],a+=l}while(l===255);o=0;do{if(n>=r.length)break;l=r[n++],o+=l}while(l===255);const d=r.length-n;let c=n;if(o<d)n+=o;else if(o>d){Te.error(`Malformed SEI payload. ${o} is too small, only ${d} bytes left to parse.`);break}if(a===4){if(r[c++]===181){const h=ih(r,c);if(c+=2,h===49){const f=W(r,c);if(c+=4,f===1195456820){const g=r[c++];if(g===3){const m=r[c++],p=31&m,v=64&m,T=v?2+p*3:0,y=new Uint8Array(T);if(v){y[0]=m;for(let S=1;S<T;S++)y[S]=r[c++]}i.push({type:g,payloadType:a,pts:t,bytes:y})}}}}}else if(a===5&&o>16){const u=[];for(let g=0;g<16;g++){const m=r[c++].toString(16);u.push(m.length==1?"0"+m:m),(g===3||g===5||g===7||g===9)&&u.push("-")}const h=o-16,f=new Uint8Array(h);for(let g=0;g<h;g++)f[g]=r[c++];i.push({payloadType:a,pts:t,uuid:u.join(""),userData:up(f),userDataBytes:f})}}}function ch(s){const e=s.byteLength;let t,i=s.indexOf(3,3);for(;i!==-1;)s[i-1]===0&&s[i-2]===0&&(t||(t=[])).push(i),i=s.indexOf(3,i+1);if(!t)return s;const r=e-t.length,n=new Uint8Array(r);let a=0,o=0;for(let l=0;l<r;o++,l++)o===t[a]&&(o++,a++),n[l]=s[o];return n}function Ep(s){const e=s[0];let t="",i="",r=0,n=0,a=0,o=0,l=0,d=0;if(e===0){for(;Ne(s.subarray(d,d+1))!=="\0";)t+=Ne(s.subarray(d,d+1)),d+=1;for(t+=Ne(s.subarray(d,d+1)),d+=1;Ne(s.subarray(d,d+1))!=="\0";)i+=Ne(s.subarray(d,d+1)),d+=1;i+=Ne(s.subarray(d,d+1)),d+=1,r=W(s,12),n=W(s,16),o=W(s,20),l=W(s,24),d=28}else if(e===1){d+=4,r=W(s,d),d+=4;const u=W(s,d);d+=4;const h=W(s,d);for(d+=4,a=2**32*u+h,bm(a)||(a=Number.MAX_SAFE_INTEGER,Te.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=W(s,d),d+=4,l=W(s,d),d+=4;Ne(s.subarray(d,d+1))!=="\0";)t+=Ne(s.subarray(d,d+1)),d+=1;for(t+=Ne(s.subarray(d,d+1)),d+=1;Ne(s.subarray(d,d+1))!=="\0";)i+=Ne(s.subarray(d,d+1)),d+=1;i+=Ne(s.subarray(d,d+1)),d+=1}const c=s.subarray(d,s.byteLength);return{schemeIdUri:t,value:i,timeScale:r,presentationTime:a,presentationTimeDelta:n,eventDuration:o,id:l,payload:c}}function vp(s,...e){const t=e.length;let i=8,r=t;for(;r--;)i+=e[r].byteLength;const n=new Uint8Array(i);for(n[0]=i>>24&255,n[1]=i>>16&255,n[2]=i>>8&255,n[3]=i&255,n.set(s,4),r=0,i=8;r<t;r++)n.set(e[r],i),i+=e[r].byteLength;return n}function yp(s,e,t){if(s.byteLength!==16)throw new RangeError("Invalid system id");let i,r;i=0,r=new Uint8Array;let n;i>0?(n=new Uint8Array(4),e.length>0&&new DataView(n.buffer).setUint32(0,e.length,!1)):n=new Uint8Array;const a=new Uint8Array(4);return t.byteLength>0&&new DataView(a.buffer).setUint32(0,t.byteLength,!1),vp([112,115,115,104],new Uint8Array([i,0,0,0]),s,n,r,a,t)}function uh(s){const e=[];if(s instanceof ArrayBuffer){const t=s.byteLength;let i=0;for(;i+32<t;){const r=new DataView(s,i),n=Sp(r);e.push(n),i+=n.size}}return e}function Tp(s){const e=[];for(let t=0;t<s.length;){const i=s[t++],r=i&7;if(r===0){for(;s[t++]&128;);continue}if(r!==2){t+=r===1?8:4;continue}let n=0;for(let a=0,o=128;o&128;a+=7)n|=((o=s[t++])&127)<<a;if(i>>3===2)if(n===32){const a=new Uint8Array(16);for(let o=0;o<16;o++)a[o]=parseInt(String.fromCharCode(s[t+o*2],s[t+o*2+1]),16);e.push(a)}else n===16&&e.push(s.subarray(t,t+16));t+=n}return e}function Sp(s){const e=s.getUint32(0),t=s.byteOffset,i=s.byteLength;if(i<e)return{offset:t,size:i};if(s.getUint32(4)!==1886614376)return{offset:t,size:e};const n=s.getUint32(8)>>>24;if(n!==0&&n!==1)return{offset:t,size:e};const a=s.buffer,o=Ye(new Uint8Array(a,t+12,16));let l=null,d=null,c=0;if(n===0)c=28;else{const h=s.getUint32(28);if(!h||i<32+h*16)return{offset:t,size:e};l=[];for(let f=0;f<h;f++)l.push(new Uint8Array(a,t+32+f*16,16));c=32+h*16}if(!c)return{offset:t,size:e};const u=s.getUint32(c);return e-32<u?{offset:t,size:e}:(d=new Uint8Array(a,t+c+4,u),n===0&&(l=Tp(d)),{version:n,systemId:o,kids:l,data:d,offset:t,size:e})}const Ds=hh("userAgent"),Ap=hh("vendor");let ka,Ca,Pa;function hh(s){try{return navigator[s]||""}catch{}return""}function bp(){if(Pa===void 0){const s=Ds.match(/Safari\/(\d+)/i);Pa=s?parseInt(s[1]):0}return Pa}function Js(){if(ka===void 0){const s=Ds.match(/Chrome\/(\d+)/i);ka=s?parseInt(s[1]):0}return ka}function Ip(){if(Ca===void 0){const s=Ds.match(/Firefox\/(\d+)/i);Ca=s?parseInt(s[1]):0}return Ca}function fh(){return/\(Windows.+Firefox\//i.test(Ds)}function _p(){return Ap.indexOf("Apple")>-1||/iPhone|iPad|iPod/.test(Ds)}function Lp(){return/Android/.test(Ds)}const bs={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,dav1:.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},image:{mjpg:1}};function Al(s,e){const t=bs[e];return!!t&&!!t[s.slice(0,4)]}function hr(s,e,t=!0){return!s.split(",").some(i=>!bl(i,e,t))}function bl(s,e,t=!0){var i;const r=ki(t);return(i=r?.isTypeSupported(fr(s,e)))!=null?i:!1}function fr(s,e){return`${e}/mp4;codecs=${s}`}function Fd(s){if(s){const e=s.substring(0,4);return bs.video[e]}return 2}function Bn(s){const e=fh();return s.split(",").reduce((t,i)=>{const n=e&&Dr(i)?9:bs.video[i];return n?(n*2+t)/(t?3:2):(bs.audio[i]+t)/(t?2:1)},0)}const wa={};function xp(s,e=!0){if(wa[s])return wa[s];const t={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[s];for(let r=0;r<t.length;r++){var i;if(bl(t[r],"audio",e))return wa[s]=t[r],t[r];if(t[r]==="mp3"&&(i=ki(e))!=null&&i.isTypeSupported("audio/mpeg"))return""}return s}const Rp=/flac|opus|mp4a\.40\.34/i;function Gn(s,e=!0){return s.replace(Rp,t=>xp(t.toLowerCase(),e))}function Dp(s,e){const t=[];if(s){const i=s.split(",");for(let r=0;r<i.length;r++)Al(i[r],"video")||t.push(i[r])}return e&&t.push(e),t.join(",")}function ln(s,e){if(s&&(s.length>4||["ac-3","ec-3","alac","fLaC","Opus"].indexOf(s)!==-1)&&(Nd(s,"audio")||Nd(s,"video")))return s;if(e){const t=e.split(",");if(t.length>1){if(s){for(let i=t.length;i--;)if(t[i].substring(0,4)===s.substring(0,4))return t[i]}return t[0]}}return e||s}function Nd(s,e){return Al(s,e)&&bl(s,e)}function kp(s){const e=s.split(",");for(let t=0;t<e.length;t++){const i=e[t].split(".");i.length>2&&i[0]==="avc1"&&(e[t]=`avc1.${parseInt(i[1]).toString(16)}${("000"+parseInt(i[2]).toString(16)).slice(-4)}`)}return e.join(",")}function Cp(s){if(s.startsWith("av01.")){const e=s.split("."),t=["0","111","01","01","01","0"];for(let i=e.length;i>4&&i<10;i++)e[i]=t[i-4];return e.join(".")}return s}function Ud(s){const e=ki(s)||{isTypeSupported:()=>!1};return{mpeg:e.isTypeSupported("audio/mpeg"),mp3:e.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:e.isTypeSupported('audio/mp4; codecs="ac-3"')}}function Lo(s){return s.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}const Pp={supported:!0,powerEfficient:!0,smooth:!0},wp={supported:!1,smooth:!1,powerEfficient:!1},gh={supported:!0,configurations:[],decodingInfoResults:[Pp]};function mh(s,e){return{supported:!1,configurations:e,decodingInfoResults:[wp],error:s}}function Mp(s,e,t,i,r,n){const a=s.videoCodec,o=s.audioCodec?s.audioGroups:null,l=n?.audioCodec,d=n?.channels,c=d?parseInt(d):l?1/0:2;let u=null;if(o!=null&&o.length)try{o.length===1&&o[0]?u=e.groups[o[0]].channels:u=o.reduce((h,f)=>{if(f){const g=e.groups[f];if(!g)throw new Error(`Audio track group ${f} not found`);Object.keys(g.channels).forEach(m=>{h[m]=(h[m]||0)+g.channels[m]})}return h},{2:0})}catch{return!0}return a!==void 0&&(a.split(",").some(h=>Dr(h))||s.width>1920&&s.height>1088||s.height>1920&&s.width>1088||s.frameRate>Math.max(i,30)||s.videoRange!=="SDR"&&s.videoRange!==t||s.bitrate>Math.max(r,8e6))||!!u&&B(c)&&Object.keys(u).some(h=>parseInt(h)>c)}function ph(s,e,t,i={}){const r=s.videoCodec;if(!r&&!s.audioCodec||!t)return Promise.resolve(gh);const n=[],a=Op(s),o=a.length,l=Fp(s,e,o>0),d=l.length;for(let c=o||1*d||1;c--;){const u={type:"media-source"};if(o&&(u.video=a[c%o]),d){u.audio=l[c%d];const h=u.audio.bitrate;u.video&&h&&(u.video.bitrate-=h)}n.push(u)}if(r){const c=navigator.userAgent;if(r.split(",").some(u=>Dr(u))&&fh())return Promise.resolve(mh(new Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent string: (${c})`),n))}return Promise.all(n.map(c=>{const u=Np(c);return i[u]||(i[u]=t.decodingInfo(c))})).then(c=>({supported:!c.some(u=>!u.supported),configurations:n,decodingInfoResults:c})).catch(c=>({supported:!1,configurations:n,decodingInfoResults:[],error:c}))}function Op(s){var e;const t=(e=s.videoCodec)==null?void 0:e.split(","),i=vh(s),r=s.width||640,n=s.height||480,a=s.frameRate||30,o=s.videoRange.toLowerCase();return t?t.map(l=>{const d={contentType:fr(Cp(l),"video"),width:r,height:n,bitrate:i,framerate:a};return o!=="sdr"&&(d.transferFunction=o),d}):[]}function Fp(s,e,t){var i;const r=(i=s.audioCodec)==null?void 0:i.split(","),n=vh(s);return r&&s.audioGroups?s.audioGroups.reduce((a,o)=>{var l;const d=o?(l=e.groups[o])==null?void 0:l.tracks:null;return d?d.reduce((c,u)=>{if(u.groupId===o){const h=parseFloat(u.channels||"");r.forEach(f=>{const g={contentType:fr(f,"audio"),bitrate:t?Eh(f,n):n};h&&(g.channels=""+h),c.push(g)})}return c},a):a},[]):[]}function Eh(s,e){if(e<=1)return 1;let t=128e3;return s==="ec-3"?t=768e3:s==="ac-3"&&(t=64e4),Math.min(e/2,t)}function vh(s){return Math.ceil(Math.max(s.bitrate*.9,s.averageBitrate)/1e3)*1e3||1}function Np(s){let e="";const{audio:t,video:i}=s;if(i){const r=Lo(i.contentType);e+=`${r}_r${i.height}x${i.width}f${Math.ceil(i.framerate)}${i.transferFunction||"sd"}_${Math.ceil(i.bitrate/1e5)}`}if(t){const r=Lo(t.contentType);e+=`${i?"_":""}${r}_c${t.channels}`}return e}const xo=["NONE","TYPE-0","TYPE-1",null];function Up(s){return xo.indexOf(s)>-1}const Vn=["SDR","PQ","HLG"];function $p(s){return!!s&&Vn.indexOf(s)>-1}var dn={No:"",Yes:"YES",v2:"v2"};function $d(s){const{canSkipUntil:e,canSkipDateRanges:t,age:i}=s,r=i<e/2;return e&&r?t?dn.v2:dn.Yes:dn.No}class Bd{constructor(e,t,i){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=i}addDirectives(e){const 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}}class gr{constructor(e){if(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.supplemental=void 0,this.videoCodec=void 0,this.width=void 0,this.imageCodec=void 0,this.iframes=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loadErrorTime=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,"imageCodec"in e&&(this.imageCodec=e.imageCodec),this.codecSet=[e.videoCodec,e.audioCodec].filter(i=>!!i).map(i=>i.substring(0,4)).join(","),"supplemental"in e){var t;this.supplemental=e.supplemental;const i=(t=e.supplemental)==null?void 0:t.videoCodec;i&&i!==e.videoCodec&&(this.codecSet+=`,${i.substring(0,4)}`)}"iframes"in e&&e.iframes?this.iframes=!0:(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 Gd(this._audioGroups,e)}hasSubtitleGroup(e){return Gd(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,t){if(t){if(e==="audio"){let i=this._audioGroups;i||(i=this._audioGroups=[]),i.indexOf(t)===-1&&i.push(t)}else if(e==="text"){let i=this._subtitleGroups;i||(i=this._subtitleGroups=[]),i.indexOf(t)===-1&&i.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 Gd(s,e){return!e||!s?!1:s.indexOf(e)!==-1}function Bp(){if(typeof matchMedia=="function"){const s=matchMedia("(dynamic-range: high)"),e=matchMedia("bad query");if(s.media!==e.media)return s.matches===!0}return!1}function Gp(s,e){let t=!1,i=[];if(s&&(t=s!=="SDR",i=[s]),e){i=e.allowedVideoRanges||Vn.slice(0);const r=i.join("")!=="SDR"&&!e.videoCodec;t=e.preferHDR!==void 0?e.preferHDR:r&&Bp(),t||(i=["SDR"])}return{preferHDR:t,allowedVideoRanges:i}}const Vp=s=>{const e=new WeakSet;return(t,i)=>{if(s&&(i=s(t,i)),typeof i=="object"&&i!==null){if(e.has(i))return;e.add(i)}return i}},Re=(s,e)=>JSON.stringify(s,Vp(e));function Hp(s,e,t,i,r){const n=Object.keys(s),a=i?.channels,o=i?.audioCodec,l=r?.videoCodec,d=a&&parseInt(a)===2;let c=!1,u=!1,h=1/0,f=1/0,g=1/0,m=1/0,p=0,v=[];const{preferHDR:T,allowedVideoRanges:y}=Gp(e,r);for(let R=n.length;R--;){const D=s[n[R]];c||(c=D.channels[2]>0),h=Math.min(h,D.minHeight),f=Math.min(f,D.minFramerate),g=Math.min(g,D.minBitrate),y.filter(k=>D.videoRanges[k]>0).length>0&&(u=!0)}h=B(h)?h:0,f=B(f)?f:0;const S=Math.max(1080,h),A=Math.max(30,f);g=B(g)?g:t,t=Math.max(g,t),u||(e=void 0);const I=n.length>1;return{codecSet:n.reduce((R,D)=>{const L=s[D];if(D===R)return R;if(v=u?y.filter(k=>L.videoRanges[k]>0):[],I){if(L.minBitrate>t)return Ht(D,`min bitrate of ${L.minBitrate} > current estimate of ${t}`),R;if(!L.hasDefaultAudio)return Ht(D,"no renditions with default or auto-select sound found"),R;if(o&&D.indexOf(o.substring(0,4))%5!==0)return Ht(D,`audio codec preference "${o}" not found`),R;if(a&&!d){if(!L.channels[a])return Ht(D,`no renditions with ${a} channel sound found (channels options: ${Object.keys(L.channels)})`),R}else if((!o||d)&&c&&L.channels[2]===0)return Ht(D,"no renditions with stereo sound found"),R;if(L.minHeight>S)return Ht(D,`min resolution of ${L.minHeight} > maximum of ${S}`),R;if(L.minFramerate>A)return Ht(D,`min framerate of ${L.minFramerate} > maximum of ${A}`),R;if(!v.some(k=>L.videoRanges[k]>0))return Ht(D,`no variants with VIDEO-RANGE of ${Re(v)} found`),R;if(l&&D.indexOf(l.substring(0,4))%5!==0)return Ht(D,`video codec preference "${l}" not found`),R;if(L.maxScore<p)return Ht(D,`max score of ${L.maxScore} < selected max of ${p}`),R}return R&&(Bn(D)>=Bn(R)||L.fragmentError>s[R].fragmentError)?R:(m=L.minIndex,p=L.maxScore,D)},void 0),videoRanges:v,preferHDR:T,minFramerate:f,minBitrate:g,minIndex:m}}function Ht(s,e){Te.log(`[abr] start candidates with "${s}" ignored because ${e}`)}function yh(s){return s.reduce((e,t)=>{let i=e.groups[t.groupId];i||(i=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),i.tracks.push(t);const r=t.channels||"2";return i.channels[r]=(i.channels[r]||0)+1,i.hasDefault=i.hasDefault||t.default,i.hasAutoSelect=i.hasAutoSelect||t.autoselect,i.hasDefault&&(e.hasDefaultAudio=!0),i.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function Kp(s,e,t,i){return s.slice(t,i+1).reduce((r,n,a)=>{if(!n.codecSet)return r;const o=n.audioGroups;let l=r[n.codecSet];l||(r[n.codecSet]=l={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:a,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!o,fragmentError:0}),l.minBitrate=Math.min(l.minBitrate,n.bitrate);const d=Math.min(n.height,n.width);return l.minHeight=Math.min(l.minHeight,d),l.minFramerate=Math.min(l.minFramerate,n.frameRate),l.minIndex=Math.min(l.minIndex,a),l.maxScore=Math.max(l.maxScore,n.score),l.fragmentError+=n.fragmentError,l.videoRanges[n.videoRange]=(l.videoRanges[n.videoRange]||0)+1,o&&o.forEach(c=>{if(!c)return;const u=e.groups[c];u&&(l.hasDefaultAudio=l.hasDefaultAudio||e.hasDefaultAudio?u.hasDefault:u.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(u.channels).forEach(h=>{l.channels[h]=(l.channels[h]||0)+u.channels[h]}))}),r},{})}function Vd(s){if(!s)return s;const{lang:e,assocLang:t,characteristics:i,channels:r,audioCodec:n}=s;return{lang:e,assocLang:t,characteristics:i,channels:r,audioCodec:n}}function ni(s,e,t){if("attrs"in s){const i=e.indexOf(s);if(i!==-1)return i}for(let i=0;i<e.length;i++){const r=e[i];if(Ki(s,r,t))return i}return-1}function Ki(s,e,t){const{groupId:i,name:r,lang:n,assocLang:a,default:o}=s,l=s.forced;return(i===void 0||e.groupId===i)&&(r===void 0||e.name===r)&&(n===void 0||Wp(n,e.lang))&&(n===void 0||e.assocLang===a)&&(o===void 0||e.default===o)&&(l===void 0||e.forced===l)&&(!("characteristics"in s)||Yp(s.characteristics||"",e.characteristics))&&(t===void 0||t(s,e))}function Wp(s,e="--"){return s.length===e.length?s===e:s.startsWith(e)||e.startsWith(s)}function Yp(s,e=""){const t=s.split(","),i=e.split(",");return t.length===i.length&&!t.some(r=>i.indexOf(r)===-1)}function Ni(s,e){const{audioCodec:t,channels:i}=s;return(t===void 0||(e.audioCodec||"").substring(0,4)===t.substring(0,4))&&(i===void 0||i===(e.channels||"2"))}function qp(s,e,t,i,r){const n=e[i],o=e.reduce((h,f,g)=>{const m=f.uri;return(h[m]||(h[m]=[])).push(g),h},{})[n.uri];o.length>1&&(i=Math.max.apply(Math,o));const l=n.videoRange,d=n.frameRate,c=n.codecSet.substring(0,4),u=Hd(e,i,h=>{if(h.videoRange!==l||h.frameRate!==d||h.codecSet.substring(0,4)!==c)return!1;const f=h.audioGroups,g=t.filter(m=>mr(m.groupId,f));return ni(s,g,r)>-1});return u>-1?u:Hd(e,i,h=>{const f=h.audioGroups,g=t.filter(m=>mr(m.groupId,f));return ni(s,g,r)>-1})}function Hd(s,e,t){for(let i=e;i>-1;i--)if(t(s[i]))return i;for(let i=e+1;i<s.length;i++)if(t(s[i]))return i;return-1}function Hn(s,e){var t;return!!s&&s!==((t=e.loadLevelObj)==null?void 0:t.uri)}function mr(s,e){return e?e.indexOf(s)!==-1:!0}function Th(s,e){if(e||s){const t=Ie({},e);return s&&(s.videoCodec&&(t.videoCodec=s.videoCodec),s.videoRange&&(t.allowedVideoRanges=[s.videoRange])),t}}class jp extends Dt{constructor(e){super("abr",e.logger),this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.firstAutoFloor=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.co
vendor: 4,983 bytes, lines 43-53
43decTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.rebufferNotice=-1,this.supportedCache={},this.bwEstimator=void 0,this._abandonRulesCheck=t=>{var i;const{fragCurrent:r,partCurrent:n,hls:a}=this;if(!a)return;const{autoLevelEnabled:o,media:l}=a;if(!r||!l)return;const d=performance.now(),c=n?n.stats:r.stats,u=n?n.duration:r.duration,h=d-c.loading.start,f=a.minAutoLevel,g=r.level,m=this._nextAutoLevel;if(c.aborted||c.loaded&&c.loaded===c.total||g<=f){this.clearTimer(),this._nextAutoLevel=-1;return}if(!o)return;const p=m>-1&&m!==g,v=!!t||p;if(!v&&(l.paused||!l.playbackRate||!l.readyState))return;const T=a.mainForwardBufferInfo;if(!v&&T===null)return;const y=this.bwEstimator.getEstimateTTFB(),S=Math.abs(l.playbackRate);if(h<=Math.max(y,1e3*(u/(S*2))))return;const A=T?T.len/S:0,I=c.loading.first?c.loading.first-c.loading.start:-1,_=c.loaded&&I>-1,R=this.getBwEstimate(),D=a.levels,L=D[g],k=Math.max(c.loaded,Math.round(u*(r.bitrate||L.averageBitrate)/8));let w=_?h-I:h;w<1&&_&&(w=Math.min(h,c.loaded*8/R));const U=_?c.loaded*1e3/w:0,K=y/1e3,G=U?(k-c.loaded)/U:k*8/R+K;if(G<=A)return;const O=U?U*8:R,F=((i=t?.details||a.latestLevelDetails)==null?void 0:i.live)===!0,M=a.config.abrBandWidthUpFactor;let $=Number.POSITIVE_INFINITY,Y;for(Y=g-1;Y>f;Y--){const J=D[Y].maxBitrate,de=!D[Y].details||F;if($=this.getTimeToLoadFrag(K,O,u*J,de),$<Math.min(A,u+K))break}if($>=G||$>u*10)return;_?this.bwEstimator.sample(h-Math.min(y,I),c.loaded):this.bwEstimator.sampleTTFB(h);const N=D[Y].maxBitrate;this.getBwEstimate()*M>N&&(this.firstAutoFloor=Math.min(Y,a.firstLevel),this.resetEstimator(N));const V=this.findBestLevel(N,f,Y,0,A,1,1);V>-1&&(Y=V),this.warn(`Fragment ${r.sn}${n?" part "+n.index:""} of level ${g} is loading too slowly;
44      Fragment duration: ${r.duration.toFixed(3)}
45      Time to underbuffer: ${A.toFixed(3)} s
46      Estimated load time for current fragment: ${G.toFixed(3)} s
47      Estimated load time for down switch fragment: ${$.toFixed(3)} s
48      TTFB estimate: ${I|0} ms
49      Current BW estimate: ${B(R)?R|0:"Unknown"} bps
50      New BW estimate: ${this.getBwEstimate()|0} bps
51      Switching to level ${Y} @ ${N|0} bps`),a.nextLoadLevel=a.nextAutoLevel=Y,this.clearTimer();const se=()=>{this.clearTimer();const J=this.hls;if(this.fragCurrent===r&&J.loadLevel===Y&&Y>0){const de=this.getStarvationDelay();if(this.warn(`Aborting inflight request ${Y>0?"and switching down":""}
52      Fragment duration: ${r.duration.toFixed(3)} s
53      Time to underbuffer: ${de.toFixed(3)} s`),r.abortRequests(),this.fragCurrent=this.partCurrent=null,Y>f){let te=this.findBestLevel(J.levels[f].bitrate,f,Y,0,de,1,1);te===-1&&(te=f),J.nextLoadLevel=J.nextAutoLevel=te,this.firstAutoFloor=Math.min(te,J.firstLevel),this.resetEstimator(J.levels[te].bitrate)}}};p||G>$*2?se():this.timer=self.setInterval(se,$*1e3),a.trigger(E.FRAG_LOAD_EMERGENCY_ABORTED,{frag:r,part:n,stats:c})},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(e){this.hls&&(e&&(this.log(`setting initial bwe to ${e}`),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator())}initEstimator(){const e=this.hls.config;return new Mm(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){const e=this.hls;e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.FRAG_LOADING,this.onFragLoading,this),e.on(E.FRAG_LOADED,this.onFragLoaded,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this),e.on(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(E.LEVEL_LOADED,this.onLevelLoaded,this),e.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(E.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(E.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e&&(e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.FRAG_LOADING,this.onFragLoading,this),e.off(E.FRAG_LOADED,this.onFragLoaded,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this),e.off(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(E.LEVEL_LOADED,this.onLevelLoaded,this),e.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(E.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(E.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=this.supportedCache=null,this.audioTracksByGroup=this.codecTiers=this.fragCurrent=this.partCurrent=null}onManifestLoading(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.firstAutoFloor=-1,this.lastLevelLoadSec=0,this.supportedCache={},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){const i=t.frag;
vendor: 3,466 bytes, line 53
53if(!this.ignoreFragment(i)){if(!i.bitrateTest){var r;this.fragCurrent=i,this.partCurrent=(r=t.part)!=null?r: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 x.BUFFER_ADD_CODEC_ERROR:case x.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case x.FRAG_LOAD_TIMEOUT:{const i=t.frag,{fragCurrent:r,partCurrent:n}=this;if(i&&So(i,r)){const a=performance.now(),o=n?n.stats:i.stats,l=a-o.loading.start,d=o.loading.first?o.loading.first-o.loading.start:-1;if(o.loaded&&d>-1){const u=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(l-Math.min(u,d),o.loaded)}else this.bwEstimator.sampleTTFB(l)}break}}}getTimeToLoadFrag(e,t,i,r){const n=e+i/t,a=r?e+this.lastLevelLoadSec:0;return n+a}onLevelLoaded(e,t){const i=this.hls.config,{loading:r}=t.stats,n=r.end-r.first;B(n)&&(this.lastLevelLoadSec=n/1e3),t.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD),this.timer>-1&&this._abandonRulesCheck(t.levelInfo)}onFragLoaded(e,t){var i;const{frag:r,part:n}=t,a=n?n.stats:r.stats;if(r.type===j.MAIN&&this.bwEstimator.sampleTTFB(a.loading.first-a.loading.start),!this.ignoreFragment(r)){if(this.clearTimer(),r.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,(i=this.hls)!=null&&i.config.abrMaxWithRealBitrate){const o=n?n.duration:r.duration,l=this.hls.levels[r.level],d=(l.loaded?l.loaded.bytes:0)+a.loaded,c=(l.loaded?l.loaded.duration:0)+o;l.loaded={bytes:d,duration:c},l.realBitrate=Math.round(8*d/c)}if(r.bitrateTest){const o={stats:a,frag:r,part:n,id:r.type};this.onFragBuffered(E.FRAG_BUFFERED,o),r.bitrateTest=!1}else this.lastLoadedFragLevel=r.level}}onFragBuffered(e,t){const{frag:i,part:r}=t,n=r!=null&&r.stats.loaded?r.stats:i.stats;if(n.aborted||this.ignoreFragment(i))return;const o=((i.bitrate||0)>=1e5?n.parsing.end:n.loading.end)-n.loading.start-Math.min(n.loading.first-n.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(o,n.loaded),n.bwEstimate=this.getBwEstimate(),i.bitrateTest?this.bitrateTestDelay=o/1e3:(this.bitrateTestDelay=0,this.firstAutoFloor>-1&&this.bwEstimator.canEstimate()&&(this.firstAutoFloor=-1))}ignoreFragment(e){return e.type!==j.MAIN||e.sn==="initSegment"}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}get firstAutoLevel(){const{hls:e}=this;if(!e)return 0;const{maxAutoLevel:t,minAutoLevel:i}=e,r=this.getBwEstimate(),n=this.getStarvationDelay(),a=e.config.maxStarvationDelay,o=this.findBestLevel(r,i,t,n/2,a,1,1);if(o>-1)return o;const l=e.firstLevel,d=this.firstAutoFloor===-1?1/0:this.firstAutoFloor,c=Math.min(Math.max(l,i),t,d);return this.warn(`Could not find best starting auto level. Defaulting to first in playlist ${l} clamped to ${c}`),c}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){if(!this.hls)return-1;const e=this.forcedAutoLevel,i=this.bwEstimator.canEstimate(),r=this.lastLoadedFragLevel>-1;if(e!==-1&&(!i||!r||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;const n=i&&r?this.getNextABRAutoLevel():this.firstAutoLevel;if(e!==-1){const 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()}
53_${this.getStarvationDelay().toFixed(2)}`}getNextABRAutoLevel(){const{fragCurrent:e,partCurrent:t,hls:i}=this;if(!i)return-1;if(i.levels.length<=1)return i.loadLevel;const{maxAutoLevel:r,config:n,minAutoLevel:a}=i,o=t?t.duration:e?e.duration:0,l=this.getBwEstimate(),d=this.getStarvationDelay();let c=n.abrBandWidthFactor,u=n.abrBandWidthUpFactor;if(d){const p=this.findBestLevel(l,a,r,d,0,c,u);if(p>=0)return this.rebufferNotice=-1,p}let h=o?Math.min(o,n.maxStarvationDelay):n.maxStarvationDelay;if(!d){const p=this.bitrateTestDelay;p&&(h=(o?Math.min(o,n.maxLoadingDelay):n.maxLoadingDelay)-p,this.info(`bitrate test took ${Math.round(1e3*p)}ms, set first fragment max fetchDuration to ${Math.round(1e3*h)} ms`),c=u=1)}const f=this.findBestLevel(l,a,r,d,h,c,u);if(this.rebufferNotice!==f&&(this.rebufferNotice=f,this.info(`${d?"rebuffering expected":"buffer is empty"}, optimal quality level ${f}`)),f>-1)return f;const g=i.levels[a],m=i.loadLevelObj;return m&&g?.bitrate<m.bitrate?a:i.loadLevel}getStarvationDelay(){const e=this.hls,t=e?.media;if(!t)return 1/0;const i=t&&t.playbackRate!==0?Math.abs(t.playbackRate):1,r=e.mainForwardBufferInfo;return(r?r.len:0)/i}getBwEstimate(){return this.bwEstimator.getEstimate()}findBestLevel(e,t,i,r,n,a,o){const{hls:l,lastLoadedFragLevel:d,fragCurrent:c,partCurrent:u}=this;if(!l)return-1;const h=r+n,f=d===-1?l.firstLevel:d,{levels:g,allAudioTracks:m,loadLevel:p,latestLevelDetails:v,config:T}=l;if(g.length===1)return 0;const y=g[f],S=!!(v!=null&&v.live),A=p===-1||d===-1;let I,_="SDR",R=y?.frameRate||0;const{audioPreference:D,videoPreference:L}=T,k=this.audioTracksByGroup||(this.audioTracksByGroup=yh(m));let w=-1;if(A){if(this.firstSelection!==-1)return this.firstSelection;const F=this.codecTiers||(this.codecTiers=Kp(g,k,t,i)),M=Hp(F,_,e,D,L),{codecSet:$,videoRanges:Y,minFramerate:N,minBitrate:V,minIndex:se,preferHDR:J}=M;w=se,I=$,_=J?Y[Y.length-1]:Y[0],R=N,e=Math.max(e,V),this.log(`picked start tier ${Re(M)}`)}else I=y?.codecSet,_=y?.videoRange;const U=u?u.duration:c?c.duration:0,K=this.bwEstimator.getEstimateTTFB()/1e3,G=[];for(let F=i;F>=t;F--){var O;const M=g[F],$=F>f;if(!M)continue;if(T.useMediaCapabilities&&!M.supportedResult&&!M.supportedPromise){const te=navigator.mediaCapabilities;typeof te?.decodingInfo=="function"&&Mp(M,k,_,R,e,D)?(M.supportedPromise=ph(M,k,te,this.supportedCache),M.supportedPromise.then(fe=>{if(!this.hls)return;M.supportedResult=fe;const le=this.hls.levels,pe=le.indexOf(M);fe.error?this.warn(`MediaCapabilities decodingInfo error: "${fe.error}" for level ${pe} ${Re(fe)}`):fe.supported?fe.decodingInfoResults.some(Pe=>Pe.smooth===!1||Pe.powerEfficient===!1)&&this.log(`MediaCapabilities decodingInfo for level ${pe} not smooth or powerEfficient: ${Re(fe)}`):(this.warn(`Unsupported MediaCapabilities decodingInfo result for level ${pe} ${Re(fe)}`),pe>-1&&le.length>1&&(this.log(`Removing unsupported level ${pe}`),this.hls.removeLevel(pe),this.hls.loadLevel===-1&&(this.hls.nextLoadLevel=0)))}).catch(fe=>{this.warn(`Error handling MediaCapabilities decodingInfo: ${fe}`)})):M.supportedResult=gh}if((I&&M.codecSet!==I||_&&M.videoRange!==_||$&&R>M.frameRate||!$&&R>0&&R<M.frameRate||(O=M.supportedResult)!=null&&(O=O.decodingInfoResults)!=null&&O.some(te=>te.smooth===!1))&&(!A||F!==w)){G.push(F);continue}const Y=M.details,N=(u?Y?.partTarget:Y?.averagetargetduration)||U||1;let V;$?V=o*e:V=a*e;const se=U&&r>=U*2&&n===0?M.averageBitrate:M.maxBitrate,J=this.getTimeToLoadFrag(K,V,se*N,!Y||Y.live);if(V>=se&&(F===d||M.loadError===0&&M.fragmentError===0||qu(M,T.errorPenaltyExpireMs))&&(J<=K||!B(J)||S&&!this.bitrateTestDelay||J<h)){const te=this.forcedAutoLevel;return F!==p&&(te===-1||te!==p)&&(G.length&&this.trace(`Skipped level(s) ${G.join(",")} of ${i} max with CODECS and VIDEO-RANGE:"${g[G[0]].codecs}" ${g[G[0]].videoRange}; not compatible with "${I}" ${_}`),this.info(`switch candidate:${f}->${F} adjustedbw(${Math.round(V)})-bitrate=${Math.round(V-se)} ttfb:${K.toFixed(1)} avgDuration:${N.toFixed(1)} maxFetchDuration:${h.toFixed(1)} fetchDuration:${J.toFixed(1)} firstSelection:${A} codecSet:${M.codecSet} videoRange:${M.videoRange} hls.loadLevel:${p}`)),A&&(this.firstSelection=F),F}}return-1}set nextAutoLevel(e){const t=this.deriveNextAutoLevel(e);this._nextAutoLevel!==t&&(this.nextAutoLevelKey="",this._nextAutoLevel=t)}deriveNextAutoLevel(e){if(!this.hls)return-1;const{maxAutoLevel:t,minAutoLevel:i}=this.hls;return Math.min(Math.max(e,i),t)}}const Sh={search:function(s,e){let t=0,i=s.length-1,r=null,n=null;for(;t<=i;){r=(t+i)/2|0,n=s[r];const a=e(n);if(a>0)t=r+1;else if(a<0)i=r-1;else return n}return null}};
vendor: 20,199 bytes, line 53
53function zp(s,e,t){if(e===null||!Array.isArray(s)||!s.length||!B(e))return null;const i=s[0].programDateTime;if(e<(i||0))return null;const r=s[s.length-1].endProgramDateTime;if(e>=(r||0))return null;for(let n=0;n<s.length;++n){const a=s[n];if(Xp(e,t,a))return a}return null}function Is(s,e,t=0,i=0,r=.005){let n=null;if(s){n=e[1+s.sn-e[0].sn]||null;const o=s.endDTS-t;o>0&&o<15e-7&&(t+=15e-7),n&&s.level!==n.level&&n.end<=s.end&&(n=e[2+s.sn-e[0].sn]||null)}else t===0&&e[0].start===0&&(n=e[0]);if(n&&((!s||s.level===n.level)&&Kd(t,i,n)===0||Qp(n,s,Math.min(r,i))))return n;const a=Sh.search(e,Kd.bind(null,t,i));return a&&(a!==s||!n)?a:n}function Qp(s,e,t){if(e?.start===0&&e.level<s.level&&(e.endPTS||0)>0){const i=e.tagList.reduce((r,n)=>(n[0]==="INF"&&(r+=parseFloat(n[1])),r),t);return s.start<=i}return!1}function Kd(s=0,e=0,t){if(t.start<=s&&t.start+t.duration>s)return 0;const i=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0));return t.start+t.duration-i<=s?1:t.start-i>s&&t.start?-1:0}function Xp(s,e,t){const i=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return(t.endProgramDateTime||0)-i>s}function Ah(s,e,t){if(s&&s.startCC<=e&&s.endCC>=e){let i=s.fragments;const{fragmentHint:r}=s;r&&(i=i.concat(r));let n;return Sh.search(i,a=>a.cc<e?1:a.cc>e?-1:(n=a,a.end<=t?1:a.start>t?-1:0)),n||null}return null}function bh(s,e,t){return t&&e===s.endSN&&s.fragmentHint?s.fragmentHint:s.fragments[1+e-s.startSN]||null}var ot={DoNothing:0,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,RetryRequest:5},Je={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,MoveAllAlternatesMatchingKey:4,SwitchToSDR:8,ResetMediaSource:16};class Zp extends Dt{constructor(e){super("error-controller",e.logger),this.hls=void 0,this.playlistError=0,this.hls=e,this.registerListeners()}registerListeners(){const e=this.hls;e.on(E.ERROR,this.onError,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off(E.ERROR,this.onError,this),e.off(E.ERROR,this.onErrorOut,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null}startLoad(e){}stopLoad(){this.playlistError=0}getVariantLevelIndex(e){return e?.type===j.MAIN?e.level:this.getVariantIndex()}getVariantIndex(){var e;const t=this.hls,i=t.currentLevel;return(e=t.loadLevelObj)!=null&&e.details||i===-1?t.loadLevel:i}variantHasKey(e,t){if(e){var i;if((i=e.details)!=null&&i.hasKey(t))return!0;const r=e.audioGroups;if(r)return this.hls.allAudioTracks.filter(a=>r.indexOf(a.groupId)>=0).some(a=>{var o;return(o=a.details)==null?void 0:o.hasKey(t)})}return!1}onManifestLoading(){this.playlistError=0}onLevelUpdated(){this.playlistError=0}onError(e,t){var i;if(t.fatal)return;const r=this.hls,n=t.context;switch(t.details){case x.FRAG_LOAD_ERROR:case x.FRAG_LOAD_TIMEOUT:case x.KEY_LOAD_ERROR:case x.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case x.FRAG_PARSING_ERROR:if((i=t.frag)!=null&&i.gap){t.errorAction=er();return}case x.FRAG_GAP:case x.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=ot.SendAlternateToPenaltyBox;return}case x.PLAYLIST_UNCHANGED_ERROR:case x.LEVEL_EMPTY_ERROR:case x.LEVEL_PARSING_ERROR:{var a;const o=t.parent===j.MAIN?t.level:r.loadLevel;t.details===x.LEVEL_EMPTY_ERROR&&((a=t.context)!=null&&(a=a.levelDetails)!=null&&a.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,o):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,o))}return;case x.LEVEL_LOAD_ERROR:case x.LEVEL_LOAD_TIMEOUT:typeof n?.level=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.level));return;case x.AUDIO_TRACK_LOAD_ERROR:case x.AUDIO_TRACK_LOAD_TIMEOUT:case x.SUBTITLE_LOAD_ERROR:case x.SUBTITLE_TRACK_LOAD_TIMEOUT:if(n){const o=r.loadLevelObj;if(o&&(n.type===ue.AUDIO_TRACK&&o.hasAudioGroup(n.groupId)||n.type===ue.SUBTITLE_TRACK&&o.hasSubtitleGroup(n.groupId))){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,r.loadLevel),t.errorAction.action=ot.SendAlternateToPenaltyBox,t.errorAction.flags=Je.MoveAllAlternatesMatchingHost;return}}return;case x.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:t.errorAction={action:ot.SendAlternateToPenaltyBox,flags:Je.MoveAllAlternatesMatchingHDCP};return;case x.KEY_SYSTEM_SESSION_UPDATE_FAILED:case x.KEY_SYSTEM_STATUS_INTERNAL_ERROR:case x.KEY_SYSTEM_NO_SESSION:t.errorAction={action:ot.SendAlternateToPenaltyBox,flags:Je.MoveAllAlternatesMatchingKey};return;case x.BUFFER_ADD_CODEC_ERROR:case x.REMUX_ALLOC_ERROR:case x.BUFFER_APPEND_ERROR:t.errorAction||(t.errorAction=this.getLevelSwitchAction(t,t.level));return;case x.MEDIA_SOURCE_REQUIRES_RESET:t.errorAction||(t.errorAction=this.getLevelSwitchAction(t,t.level)),t.errorAction.flags|=Je.ResetMediaSource|Je.SwitchToSDR;return;case x.INTERNAL_EXCEPTION:case x.BUFFER_APPENDING_ERROR:case x.BUFFER_APPEND_NO_PROGRESS:case x.BUFFER_FULL_ERROR:case x.LEVEL_SWITCH_ERROR:case x.BUFFER_STALLED_ERROR:case x.BUFFER_SEEK_OVER_HOLE:case x.BUFFER_NUDGE_ON_STALL:t.errorAction=er();return}t.type===X.KEY_SYSTEM_ERROR&&(t.levelRetry=!1,t.errorAction=er())}getPlaylistRetryOrSwitchAction(e,t){const i=this.hls,r=Dd(i.config.playlistLoadPolicy,e),n=this.playlistError++;if(lr(r,n,$n(e),e.response))return{action:ot.RetryRequest,flags:Je.None,retryConfig:r,retryCount:n};const o=this.getLevelSwitchAction(e,t);return r&&(o.retryConfig=r,o.retryCount=n),o}getFragRetryOrSwitchAction(e){const t=this.hls,i=this.getVariantLevelIndex(e.frag),r=t.levels[i],{fragLoadPolicy:n,keyLoadPolicy:a}=t.config,o=Dd(Wu(e)?a:n,e),l=t.levels.reduce((c,u)=>c+u.fragmentError,0);if(r&&(e.details!==x.FRAG_GAP&&r.fragmentError++,!Yu(e)&&lr(o,l,$n(e),e.response)))return{action:ot.RetryRequest,flags:Je.None,retryConfig:o,retryCount:l};const d=this.getLevelSwitchAction(e,i);return o&&(d.retryConfig=o,d.retryCount=l),d}getLevelSwitchAction(e,t){const i=this.hls;t==null&&(t=i.loadLevel);const r=this.hls.levels[t];if(r){var n,a;const d=e.details;r.loadError++,r.loadErrorTime=self.performance.now(),d===x.BUFFER_APPEND_ERROR&&r.fragmentError++;let c=-1;const{levels:u,loadLevel:h,minAutoLevel:f,maxAutoLevel:g}=i;!i.autoLevelEnabled&&!i.config.preserveManualLevelOnError&&(i.loadLevel=-1);const m=(n=e.frag)==null?void 0:n.type,v=(m===j.AUDIO&&d===x.FRAG_PARSING_ERROR||e.sourceBufferName==="audio"&&Wd(e))&&u.some(({audioCodec:I})=>r.audioCodec!==I),y=e.sourceBufferName==="video"&&Wd(e)&&u.some(({codecSet:I,audioCodec:_})=>r.codecSet!==I&&r.audioCodec===_),{type:S,groupId:A}=(a=e.context)!=null?a:{};for(let I=u.length;I--;){const _=(I+h)%u.length;if(_!==h&&_>=f&&_<=g&&(u[_].loadError===0||qu(u[_],i.config.errorPenaltyExpireMs))){var o,l;const R=u[_];if(d===x.FRAG_GAP&&m===j.MAIN&&e.frag){const D=u[_].details;if(D){const L=Is(e.frag,D.fragments,e.frag.start);if(L!=null&&L.gap)continue}}else{if(S===ue.AUDIO_TRACK&&R.hasAudioGroup(A)||S===ue.SUBTITLE_TRACK&&R.hasSubtitleGroup(A))continue;if(m===j.AUDIO&&(o=r.audioGroups)!=null&&o.some(D=>R.hasAudioGroup(D))||m===j.SUBTITLE&&(l=r.subtitleGroups)!=null&&l.some(D=>R.hasSubtitleGroup(D))||v&&r.audioCodec===R.audioCodec||y&&r.codecSet===R.codecSet||!v&&r.audioCodec!==R.audioCodec)continue}c=_;break}}if(c>-1&&i.loadLevel!==c)return e.levelRetry=!0,this.playlistError=0,{action:ot.SendAlternateToPenaltyBox,flags:Je.None,nextAutoLevel:c}}return{action:ot.SendAlternateToPenaltyBox,flags:Je.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var i,r;switch((i=t.errorAction)==null?void 0:i.action){case ot.DoNothing:break;case ot.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==x.FRAG_GAP&&t.details!==x.PLAYLIST_UNCHANGED_ERROR&&!Ih(t)&&(t.fatal=!0);break}if((((r=t.errorAction)==null?void 0:r.flags)||0)&Je.ResetMediaSource&&this.hls.recoverMediaError(),t.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(e){const t=this.hls,i=e.errorAction;if(!i)return;let r=i.nextAutoLevel;if(i.flags===Je.None)this.switchLevel(e,r);else if(i.flags&Je.SwitchToSDR){const o=this.hls.levels,l=o.length;for(let d=l;d--;)o[d].videoRange!=="SDR"?(o[d].fragmentError++,o[d].loadError++):r===void 0&&(r=d)}else if(i.flags&Je.MoveAllAlternatesMatchingHDCP){const o=this.getVariantLevelIndex(e.frag),l=t.levels[o],d=l?.attrs["HDCP-LEVEL"];i.hdcpLevel=d;const c=d==="NONE";d&&!c?(t.maxHdcpLevel=xo[xo.indexOf(d)-1],i.resolved=!0,this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`)):(c&&this.warn("HDCP policy resticted output with HDCP-LEVEL=NONE"),i.flags|=Je.MoveAllAlternatesMatchingKey)}if(i.flags&Je.MoveAllAlternatesMatchingKey){const o=e.decryptdata;if(o){const l=this.hls.levels,d=l.length;for(let u=d;u--;)if(this.variantHasKey(l[u],o)){var n,a;this.log(`Banned key found in level ${u} (${l[u].bitrate}bps) or audio group "${(n=l[u].audioGroups)==null?void 0:n.join(",")}" (${(a=e.frag)==null?void 0:a.type} fragment) ${Ye(o.keyId||[])}`),l[u].fragmentError++,l[u].loadError++,this.log(`Removing level ${u} with key error (${e.error})`),this.hls.removeLevel(u)}const c=e.frag;if(this.hls.levels.length<d)i.resolved=!0;else if(c&&c.type!==j.MAIN){const u=c.decryptdata;u&&!o.matches(u)&&(i.resolved=!0)}}}i.resolved||this.switchLevel(e,r)}switchLevel(e,t){if(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,e.details===x.BUFFER_ADD_CODEC_ERROR&&e.mimeType&&e.sourceBufferName!=="audiovideo")){const i=Lo(e.mimeType),r=this.hls.levels;for(let n=r.length;n--;)r[n][`${e.sourceBufferName}Codec`]===i&&(this.log(`Removing level ${n} for ${e.details} ("${i}" not supported)`),this.hls.removeLevel(n))}}}function Wd(s){const e=s.details;return e===x.BUFFER_ADD_CODEC_ERROR||e===x.MEDIA_SOURCE_REQUIRES_RESET||e===x.BUFFER_APPEND_ERROR&&!Ih(s)}function Ih(s){return s.details===x.BUFFER_APPEND_ERROR&&(s.error.name==="QuotaExceededError"||s.error.name==="InvalidStateError")}function er(s){const e={action:ot.DoNothing,flags:Je.None};return s&&(e.resolved=!0),e}var Ce={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class Jp{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(){const{hls:e}=this;e&&(e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.BUFFER_APPENDED,this.onBufferAppended,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this),e.on(E.FRAG_LOADED,this.onFragLoaded,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.BUFFER_APPENDED,this.onBufferAppended,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this),e.off(E.FRAG_LOADED,this.onFragLoaded,this))}destroy(){this._unregisterListeners(),this.hls=this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){const i=this.activePartLists[t];if(i)for(let r=i.length;r--;){const n=i[r];if(!n)break;if(n.start<=e&&e<=n.end&&n.loaded)return n}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){return this.getFragAtPos(e,t,!0)}getFragAtPos(e,t,i){const{fragments:r}=this,n=Object.keys(r);for(let a=n.length;a--;){const o=r[n[a]];if(o?.body.type===t&&(!i||o.buffered)){const l=o.body;if(l.start<=e&&e<=l.end)return l}}return null}detectEvictedFragments(e,t,i,r,n,a){this.timeRanges&&(this.timeRanges[e]=t);const o=n?.fragment.sn||-1;Object.keys(this.fragments).forEach(l=>{const d=this.fragments[l];if(!d||!this.hls)return;const c=d.body;if(o>=c.sn)return;if(!d.buffered&&(!d.loaded||a)){c.type===i&&this.removeFragment(c);return}const u=d.range[e];if(u){if(u.time.length===0){this.removeFragment(c);return}if(u.time.some(h=>{const f=!this.isTimeBuffered(h.startPTS,h.endPTS,t);return f&&this.removeFragment(c),f}),r&&r!==c&&Js()){const h=r.endPTS,f=c.startPTS;if(h&&f&&d.range.video){const g=f-h;g<0&&g>-.1&&(this.removeFragment(c),this.hls.trigger(E.BUFFER_FLUSHING,{startOffset:h+.004,endOffset:1/0,type:"video"}))}}}})}detectPartialFragments(e){const t=this.timeRanges,{frag:i,part:r,id:n}=e;if(!t||!Ue(i))return;const a=zi(i),o=this.fragments[a];if(!o||o.buffered&&i.gap)return;const l=!i.relurl;Object.keys(t).forEach(c=>{const u=i.elementaryStreams[c];if(!u)return;const h=t[c],f=l||u.partial===!0;o.range[c]=this.getBufferedTimes(i,r,f,h),this.detectEvictedFragments(c,h,n,i,r)}),o.loaded=null;const d=Object.keys(o.range);if(d.length){if(this.bufferedEnd(o,i),Fr(o)||this.removeParts(i.sn-1,i.type),!r){const c=Math.min(.004,i.duration);d.some(u=>{var h;const f=(h=o.range[u])==null?void 0:h.time,g=f.length===0||f.length===1&&f[0].endPTS-f[0].startPTS<c;return g&&this.addAsGap(i),g})}}else this.removeFragment(i)}addAsGap(e){e.gap=!0,this.removeFragment(e),this.fragBuffered(e,!0)}bufferedEnd(e,t){e.buffered=!0,(e.body.endList=t.endList||e.body.endList)&&(this.endListFragments[e.body.type]=e)}removeParts(e,t){const i=this.activePartLists[t];i&&(this.activePartLists[t]=Yd(i,r=>r.fragment.sn>=e))}fragBuffered(e,t){const i=zi(e);let r=this.fragments[i];return!r&&t&&(r=this.fragments[i]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),r&&(r.loaded=null,this.bufferedEnd(r,e)),r}getBufferedTimes(e,t,i,r){const n={time:[],partial:i},a=e.start,o=e.end,l=e.minEndPTS||o,d=e.maxStartPTS||a;for(let c=0;c<r.length;c++){const u=r.start(c)-this.bufferPadding,h=r.end(c)+this.bufferPadding;if(d>=u&&l<=h){n.time.push({startPTS:Math.max(a,r.start(c)),endPTS:Math.min(o,r.end(c))});break}else if(a<h&&o>u){const f=Math.max(a,r.start(c)),g=Math.min(o,r.end(c));g>f&&(n.partial=!0,n.time.push({startPTS:f,endPTS:g}))}else if(o<=u)break}return n}getPartialFragment(e){let t=null,i,r,n,a=0;const{bufferPadding:o,fragments:l}=this;return Object.keys(l).forEach(d=>{const c=l[d];c&&Fr(c)&&(r=c.body.start-o,n=c.body.end+o,e>=r&&e<=n&&(i=Math.min(e-r,n-e),a<=i&&(t=c.body,a=i)))}),t}isEndListAppended(e){const t=this.endListFragments[e];return t!==void 0&&(t.buffered||Fr(t))}getState(e){const t=zi(e),i=this.fragments[t];return i?i.buffered?Fr(i)?Ce.PARTIAL:Ce.OK:Ce.APPENDING:Ce.NOT_LOADED}isTimeBuffered(e,t,i){let r,n;for(let a=0;a<i.length;a++){if(r=i.start(a)-this.bufferPadding,n=i.end(a)+this.bufferPadding,e>=r&&t<=n)return!0;if(t<=r)return!1}return!1}onManifestLoading(){this.removeAllFragments()}onFragLoaded(e,t){if(!Ue(t.frag)||t.frag.bitrateTest)return;const i=t.frag,r=t.part?null:t,n=zi(i);this.fragments[n]={body:i,appendedPTS:null,loaded:r,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){const{frag:i,part:r,timeRanges:n}=t;if(!Ue(i))return;const a=i.type;if(r){let o=this.activePartLists[a];o||(this.activePartLists[a]=o=[]),o.push(r)}this.timeRanges=n}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){const t=zi(e);return!!this.fragments[t]}hasFragments(e){const{fragments:t}=this,i=Object.keys(t);if(!e)return i.length>0;for(let r=i.length;r--;){const n=t[i[r]];if(n?.body.type===e)return!0}return!1}hasParts(e){var t;return!!((t=this.activePartLists[e])!=null&&t.length)}getBackBufferEvictionEnd(e,t,i){const{fragments:r}=this;let n=0,a=0;const o=Object.keys(r);for(let l=0;l<o.length;l++){const d=r[o[l]];if(!d||!d.buffered||d.body.type!==t)continue;const c=d.body;if(c.gap)return 0;const u=c.hasStats&&c.stats.loaded||c.byteLength||c.bitrate&&c.bitrate*8*c.duration;if(c.end<=e&&u&&(n+=u,a=Math.max(a,c.end),n>=i))return a}return a>0?a:0}removeFragmentsInRange(e,t,i,r,n){r&&!this.hasGaps||Object.keys(this.fragments).forEach(a=>{const o=this.fragments[a];if(!o)return;const l=o.body;l.type!==i||r&&!l.gap||l.start<t&&l.end>e&&(o.buffered||n)&&this.removeFragment(l)})}removeFragment(e){const t=zi(e);e.clearElementaryStreamInfo();const i=this.activePartLists[e.type];if(i){const r=e.sn;this.activePartLists[e.type]=Yd(i,n=>n.fragment.sn!==r)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){var e;this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1;const t=(e=this.hls)==null||(e=e.latestLevelDetails)==null?void 0:e.partList;t&&t.forEach(i=>i.clearElementaryStreamInfo())}}function Fr(s){var e,t,i,r;return s.buffered&&!!(s.body.gap||(e=s.range.video)!=null&&e.partial||(t=s.range.audio)!=null&&t.partial||(i=s.range.audiovideo)!=null&&i.partial||(r=s.range.subs)!=null&&r.partial)}function zi(s){return`${s.type}_${s.level}_${s.sn}`}function Yd(s,e){return s.filter(t=>{const i=e(t);return i||t.clearElementaryStreamInfo(),i})}var Ci={cbc:0,ctr:1};class e0{constructor(e,t,i){this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=e,this.aesIV=t,this.aesMode=i}decrypt(e,t){switch(this.aesMode){case Ci.cbc:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case Ci.ctr:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},t,e);default:throw new Error(`[AESCrypto] invalid aes mode ${this.aesMode}`)}}}function t0(s){const e=s.byteLength,t=e&&new DataView(s.buffer).getUint8(e-1);return t?s.slice(0,e-t):s}class i0{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){const t=new DataView(e),i=new Uint32Array(4);for(let r=0;r<4;r++)i[r]=t.getUint32(r*4);return i}initTable(){const e=this.sBox,t=this.invSBox,i=this.subMix,r=i[0],n=i[1],a=i[2],o=i[3],l=this.invSubMix,d=l[0],c=l[1],u=l[2],h=l[3],f=new Uint32Array(256);let g=0,m=0,p=0;for(p=0;p<256;p++)p<128?f[p]=p<<1:f[p]=p<<1^283;for(p=0;p<256;p++){let v=m^m<<1^m<<2^m<<3^m<<4;v=v>>>8^v&255^99,e[g]=v,t[v]=g;const T=f[g],y=f[T],S=f[y];let A=f[v]*257^v*16843008;r[g]=A<<24|A>>>8,n[g]=A<<16|A>>>16,a[g]=A<<8|A>>>24,o[g]=A,A=S*16843009^y*65537^T*257^g*16843008,d[v]=A<<24|A>>>8,c[v]=A<<16|A>>>16,u[v]=A<<8|A>>>24,h[v]=A,g?(g=T^f[f[f[S^T]]],m^=f[f[m]]):g=m=1}}expandKey(e){const t=this.uint8ArrayToUint32Array_(e);let i=!0,r=0;for(;r<t.length&&i;)i=t[r]===this.key[r],r++;if(i)return;this.key=t;const n=this.keySize=t.length;if(n!==4&&n!==6&&n!==8)throw new Error("Invalid aes key size="+n);const a=this.ksRows=(n+6+1)*4;let o,l;const d=this.keySchedule=new Uint32Array(a),c=this.invKeySchedule=new Uint32Array(a),u=this.sBox,h=this.rcon,f=this.invSubMix,g=f[0],m=f[1],p=f[2],v=f[3];let 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=u[y>>>24]<<24|u[y>>>16&255]<<16|u[y>>>8&255]<<8|u[y&255],y^=h[o/n|0]<<24):n>6&&o%n===4&&(y=u[y>>>24]<<24|u[y>>>16&255]<<16|u[y>>>8&255]<<8|u[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?c[l]=y:c[l]=g[u[y>>>24]]^m[u[y>>>16&255]]^p[u[y>>>8&255]]^v[u[y&255]],c[l]=c[l]>>>0}networkToHostOrderSwap(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24}decrypt(e,t,i){const r=this.keySize+6,n=this.invKeySchedule,a=this.invSBox,o=this.invSubMix,l=o[0],d=o[1],c=o[2],u=o[3],h=this.uint8ArrayToUint32Array_(i);let f=h[0],g=h[1],m=h[2],p=h[3];const v=new Int32Array(e),T=new Int32Array(v.length);let y,S,A,I,_,R,D,L,k,w,U,K,G,O;const F=this.networkToHostOrderSwap;for(;t<v.length;){for(k=F(v[t]),w=F(v[t+1]),U=F(v[t+2]),K=F(v[t+3]),_=k^n[0],R=K^n[1],D=U^n[2],L=w^n[3],G=4,O=1;O<r;O++)y=l[_>>>24]^d[R>>16&255]^c[D>>8&255]^u[L&255]^n[G],S=l[R>>>24]^d[D>>16&255]^c[L>>8&255]^u[_&255]^n[G+1],A=l[D>>>24]^d[L>>16&255]^c[_>>8&255]^u[R&255]^n[G+2],I=l[L>>>24]^d[_>>16&255]^c[R>>8&255]^u[D&255]^n[G+3],_=y,R=S,D=A,L=I,G=G+4;y=a[_>>>24]<<24^a[R>>16&255]<<16^a[D>>8&255]<<8^a[L&255]^n[G],S=a[R>>>24]<<24^a[D>>16&255]<<16^a[L>>8&255]<<8^a[_&255]^n[G+1],A=a[D>>>24]<<24^a[L>>16&255]<<16^a[_>>8&255]<<8^a[R&255]^n[G+2],I=a[L>>>24]<<24^a[_>>16&255]<<16^a[R>>
vendor: 14,600 bytes, line 53
538&255]<<8^a[D&255]^n[G+3],T[t]=F(y^f),T[t+1]=F(I^g),T[t+2]=F(A^m),T[t+3]=F(S^p),f=k,g=w,m=U,p=K,t=t+4}return T.buffer}}class s0{constructor(e,t,i){this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=e,this.key=t,this.aesMode=i}expandKey(){const e=r0(this.aesMode);return this.subtle.importKey("raw",this.key,{name:e},!1,["encrypt","decrypt"])}}function r0(s){switch(s){case Ci.cbc:return"AES-CBC";case Ci.ctr:return"AES-CTR";default:throw new Error(`[FastAESKey] invalid aes mode ${s}`)}}const n0=16;class Il{constructor(e,t){if(this.logEnabled=!0,this.decryptRange=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.enableSoftwareAES=void 0,this.enableSoftwareAES=e.enableSoftwareAES,t!==!0)try{const i=self.crypto;i&&(this.subtle=i.subtle||i.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(){const{currentResult:e,remainderData:t}=this;if(!e||t)return this.reset(),null;const i=new Uint8Array(e);this.reset();const r=this.decryptRange;return r?r.start===0&&r.end>=i.length?i:i.slice(r.start,r.end):t0(i)}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,i,r,n){return this.decryptRange=n,this.useSoftware||n?new Promise((a,o)=>{const l=ArrayBuffer.isView(e)?e:new Uint8Array(e);this.softwareDecrypt(l,t,i,r);const d=this.flush();d?a(d.buffer):o(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,i,r)}softwareDecrypt(e,t,i,r){const{currentIV:n,currentResult:a,remainderData:o}=this;if(r!==Ci.cbc||t.byteLength!==16)return Te.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),o&&(e=Pt(o,e),this.remainderData=null);const l=this.getValidChunk(e);if(!l.length)return null;n&&(i=n);let d=this.softwareDecrypter;d||(d=this.softwareDecrypter=new i0),d.expandKey(t);const c=a;return this.currentResult=d.decrypt(l.buffer,0,i),this.currentIV=l.slice(-16).buffer,c||null}webCryptoDecrypt(e,t,i,r){if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,i,r));this.key=t,this.fastAesKey=new s0(this.subtle,t,r)}return this.fastAesKey.expandKey().then(n=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new e0(this.subtle,new Uint8Array(i),r).decrypt(e.buffer,n)):Promise.reject(new Error("web crypto not initialized"))).catch(n=>(Te.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${n.name}: ${n.message}`),this.onWebCryptoError(e,t,i,r)))}onWebCryptoError(e,t,i,r){const n=this.enableSoftwareAES;if(n){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,i,r);const a=this.flush();if(a)return a.buffer}throw new Error("WebCrypto"+(n?" and softwareDecrypt":"")+": failed to decrypt data")}getValidChunk(e){let t=e;const i=e.length-e.length%n0;return i!==e.length&&(t=e.slice(0,i),this.remainderData=e.slice(i)),t}logOnce(e){this.logEnabled&&(Te.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}const qd=Math.pow(2,17);class jd{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,i,r){const n=e.url;if(!n)return Promise.reject(new si({type:X.NETWORK_ERROR,details:x.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error(`Fragment does not have a ${n?"part list":"url"}`),networkDetails:null}));this.abort();const a=this.config,o=a.fLoader,l=a.loader;return new Promise((d,c)=>{if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(p=>p[0]==="GAP")){c(Qd(e));return}else e.gap=!1;const u=this.loader=o?new o(a):new l(a),h=zd(e,null,t);e.loader=u;const f=kd(a.fragLoadPolicy.default),g={loadPolicy:f,timeout:f.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:qd};u.stats.retry=e.stats.retry,e.stats=u.stats;const m={onSuccess:(p,v,T,y)=>{this.resetLoader(e,u);let S=p.data;T.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(S.slice(0,16)),S=S.slice(16)),d({frag:e,part:null,payload:S,networkDetails:y})},onError:(p,v,T,y)=>{this.resetLoader(e,u),c(new si({type:X.NETWORK_ERROR,details:x.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:Z({url:n,data:void 0},p),error:new Error(`HTTP Error ${p.code} ${p.text}`),networkDetails:T,stats:y}))},onAbort:(p,v,T)=>{this.resetLoader(e,u),c(new si({type:X.NETWORK_ERROR,details:x.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:T,stats:p}))},onTimeout:(p,v,T)=>{this.resetLoader(e,u),c(new si({type:X.NETWORK_ERROR,details:x.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${g.timeout}ms`),networkDetails:T,stats:p}))}};if(i){const p=this.gateProgress(i,r);m.onProgress=(v,T,y,S)=>p({frag:e,part:null,payload:y,networkDetails:S})}u.load(h,g,m)})}gateProgress(e,t){let i=e;if(t){const r=[];let n=!1;t.then(()=>{n=!0,r.forEach(a=>e(a)),r.length=0}).catch(()=>{}),i=a=>{n?e(a):r.push(a)}}return i}loadPart(e,t,i){this.abort();const r=this.config,n=r.fLoader,a=r.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap){l(Qd(e,t));return}const d=this.loader=n?new n(r):new a(r),c=zd(e,t);e.loader=d;const u=kd(r.fragLoadPolicy.default),h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:qd};t.stats=d.stats,d.load(c,h,{onSuccess:(f,g,m,p)=>{this.resetLoader(e,d),this.updateStatsFromPart(e,t);const v={frag:e,part:t,payload:f.data,networkDetails:p};i(v),o(v)},onError:(f,g,m,p)=>{this.resetLoader(e,d),l(new si({type:X.NETWORK_ERROR,details:x.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:Z({url:c.url,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:m,stats:p}))},onAbort:(f,g,m)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,d),l(new si({type:X.NETWORK_ERROR,details:x.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:m,stats:f}))},onTimeout:(f,g,m)=>{this.resetLoader(e,d),l(new si({type:X.NETWORK_ERROR,details:x.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:m,stats:f}))}})})}updateStatsFromPart(e,t){const i=e.stats,r=t.stats,n=r.total;if(i.loaded+=r.loaded,n){const l=Math.round(e.duration/t.duration),d=Math.min(Math.round(i.loaded/n),l),u=(l-d)*Math.round(i.loaded/d);i.total=i.loaded+u}else i.total=Math.max(i.loaded,i.total);const a=i.loading,o=r.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,e.url=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function zd(s,e=null,t){const i=e||s,r={type:ue.MEDIA_FRAGMENT,frag:s,part:e,responseType:"arraybuffer",url:i.url,headers:{},rangeStart:0,rangeEnd:0},n=Kn(s,e,t);return n.resetIV&&(r.resetIV=!0),n.byteRange&&(r.rangeStart=n.byteRange.start,r.rangeEnd=n.byteRange.end),r}function Kn(s,e=null,t){const i={},r=e||s,n=r.byteRangeStartOffset,a=r.byteRangeEndOffset;if(B(n)&&B(a)){var o;if((s.sn==="initSegment"||t)&&a0((o=s.decryptdata)==null?void 0:o.method)){let l=Math.floor(n/16)*16;const d=Math.ceil(a/16)*16;i.decryptRange={start:n-l,end:a-l},l>=16&&(i.resetIV=!0,l=l-16),i.byteRange={start:l,end:d}}else i.byteRange={start:n,end:a}}return i}function Qd(s,e){const t=new Error(`GAP ${s.gap?"tag":"attribute"} found`),i={type:X.MEDIA_ERROR,details:x.FRAG_GAP,fatal:!1,frag:s,error:t,networkDetails:null};return e&&(i.part=e),(e||s).stats.aborted=!0,new si(i)}function a0(s){return s==="AES-128"||s==="AES-256"}class si extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class _h extends Dt{constructor(e,t){super(e,t),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):(this.log(`possible exception thrown in task-loop (${this.constructor.name}.doTick)`),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}class _l{constructor(e,t,i,r=0,n=-1,a=!1,o,l,d){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.iframe=void 0,this.duration=void 0,this.decryptRange=void 0,this.transmuxing=Nr(),this.buffering={audio:Nr(),video:Nr(),audiovideo:Nr()},this.level=e,this.sn=t,this.id=i,this.size=r,this.part=n,this.partial=a,this.duration=o||0,this.decryptRange=d,this.iframe=l||!1}}function Nr(){return{start:0,executeStart:0,executeEnd:0,end:0}}const Xd={length:0,start:()=>0,end:()=>0};class ie{static isBuffered(e,t){if(e){const i=ie.getBuffered(e);for(let r=i.length;r--;)if(t>=i.start(r)&&t<=i.end(r))return!0}return!1}static bufferedRanges(e){if(e){const t=ie.getBuffered(e);return ie.timeRangesToArray(t)}return[]}static timeRangesToArray(e){const t=[];for(let i=0;i<e.length;i++)t.push({start:e.start(i),end:e.end(i)});return t}static bufferInfo(e,t,i){if(e){const r=ie.bufferedRanges(e);if(r.length)return ie.bufferedInfo(r,t,i)}return{len:0,start:t,end:t,bufferedIndex:-1}}static bufferedInfo(e,t,i){t=Math.max(0,t),e.length>1&&e.sort((c,u)=>c.start-u.start||u.end-c.end);let r=-1,n=[];if(i)for(let c=0;c<e.length;c++){t>=e[c].start&&t<=e[c].end&&(r=c);const u=n.length;if(u){const h=n[u-1].end;e[c].start-h<i?e[c].end>h&&(n[u-1].end=e[c].end):n.push(e[c])}else n.push(e[c])}else n=e;let a=0,o,l=t,d=t;for(let c=0;c<n.length;c++){const u=n[c].start,h=n[c].end;if(r===-1&&t>=u&&t<=h&&(r=c),t+i>=u&&t<h)l=u,d=h,a=d-t;else if(t+i<u){o=u;break}}return{len:a,start:l||0,end:d||0,nextStart:o,buffered:e,bufferedIndex:r}}static getBuffered(e){try{return e.buffered||Xd}catch(t){return Te.log("failed to get media.buffered",t),Xd}}}const Lh=/\{\$([a-zA-Z0-9-_]+)\}/g;function Zd(s){return Lh.test(s)}function Ll(s,e){if(s.variableList!==null||s.hasVariableRefs){const t=s.variableList;return e.replace(Lh,i=>{const r=i.substring(2,i.length-1),n=t?.[r];return n===void 0?(s.playlistParsingError||(s.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${r}"`)),i):n})}return e}function Jd(s,e,t){let i=s.variableList;i||(s.variableList=i={});let r,n;if("QUERYPARAM"in e){r=e.QUERYPARAM;try{const a=new self.URL(t).searchParams;if(a.has(r))n=a.get(r);else throw new Error(`"${r}" does not match any query parameter in URI: "${t}"`)}catch(a){s.playlistParsingError||(s.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${a.message}`))}}else r=e.NAME,n=e.VALUE;r in i?s.playlistParsingError||(s.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${r}"`)):i[r]=n||""}function o0(s,e,t){const i=e.IMPORT;if(t&&i in t){let r=s.variableList;r||(s.variableList=r={}),r[i]=t[i]}else s.playlistParsingError||(s.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`))}const l0=/^(\d+)x(\d+)$/,ec=/(.+?)=(".*?"|.*?)(?:,|$)/g;class ke{constructor(e,t){typeof e=="string"&&(e=ke.parseAttrList(e,t)),Ie(this,e)}get clientAttrs(){return Object.keys(this).filter(e=>e.substring(0,2)==="X-")}decimalInteger(e){const 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;const i=new Uint8Array(t.length/2);for(let r=0;r<t.length/2;r++)i[r]=parseInt(t.slice(r*2,r*2+2),16);return i}return null}hexadecimalIntegerAsNumber(e){const t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){const i=this[e];return i?parseFloat(i):t}enumeratedString(e){return this[e]}enumeratedStringList(e,t){const i=this[e];return(i?i.split(/[ ,]+/):[]).reduce((r,n)=>(r[n.toLowerCase()]=!0,r),t)}bool(e){return this[e]==="YES"}decimalResolution(e){const t=l0.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e,t){let i;const r={};for(ec.lastIndex=0;(i=ec.exec(e))!==null;){const a=i[1].trim();let o=i[2];const l=o.indexOf('"')===0&&o.lastIndexOf('"')===o.length-1;let d=!1;if(l)o=o.slice(1,-1);else switch(a){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":d=!0}if(t&&(l||d))o=Ll(t,o);else if(!d&&!l)switch(a){case"CLOSED-CAPTIONS":if(o==="NONE")break;case"ALLOWED-CPC":case"CLASS":case"ASSOC-LANGUAGE":case"AUDIO":case"BYTERANGE":case"CHANNELS":case"CHARACTERISTICS":case"CODECS":case"DATA-ID":case"END-DATE":case"GROUP-ID":case"ID":case"IMPORT":case"INSTREAM-ID":case"KEYFORMAT":case"KEYFORMATVERSIONS":case"LANGUAGE":case"NAME":case"PATHWAY-ID":case"QUERYPARAM":case"RECENTLY-REMOVED-DATERANGES":case"SERVER-URI":case"STABLE-RENDITION-ID":case"STABLE-VARIANT-ID":case"START-DATE":case"SUBTITLES":case"SUPPLEMENTAL-CODECS":case"URI":case"VALUE":case"VIDEO":case"X-ASSET-LIST":case"X-ASSET-URI":Te.warn(`${e}: attribute ${a} is missing quotes`)}r[a]=o}return r}}const d0="com.apple.hls.interstitial";function c0(s){return s!=="ID"&&s!=="CLASS"&&s!=="CUE"&&s!=="START-DATE"&&s!=="DURATION"&&s!=="END-DATE"&&s!=="END-ON-NEXT"}function u0(s){return s==="SCTE35-OUT"||s==="SCTE35-IN"||s==="SCTE35-CMD"}class xh{constructor(e,t,i=0){var r;if(this.attr=void 0,this.tagAnchor=void 0,this.tagOrder=void 0,this._startDate=void 0,this._endDate=void 0,this._dateAtEnd=void 0,this._cue=void 0,this._badValueForSameId=void 0,this.tagAnchor=t?.tagAnchor||null,this.tagOrder=(r=t?.tagOrder)!=null?r:i,t){const n=t.attr;for(const a in n)if(Object.prototype.hasOwnProperty.call(e,a)&&e[a]!==n[a]){Te.warn(`DATERANGE tag attribute: "${a}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=a;break}
vendor: 3,834 bytes, line 53
53e=Ie(new ke({}),n,e)}if(this.attr=e,t?(this._startDate=t._startDate,this._cue=t._cue,this._endDate=t._endDate,this._dateAtEnd=t._dateAtEnd):this._startDate=new Date(e["START-DATE"]),"END-DATE"in e){const n=t?.endDate||new Date(e["END-DATE"]);B(n.getTime())&&(this._endDate=n)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get cue(){const e=this._cue;return e===void 0?this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:!1,post:!1,once:!1}):e}get startTime(){const{tagAnchor:e}=this;return e===null||e.programDateTime===null?(Te.warn(`Expected tagAnchor Fragment with PDT set for DateRange "${this.id}": ${e}`),NaN):e.start+(this.startDate.getTime()-e.programDateTime)/1e3}get startDate(){return this._startDate}get endDate(){const e=this._endDate||this._dateAtEnd;if(e)return e;const t=this.duration;return t!==null?this._dateAtEnd=new Date(this._startDate.getTime()+t*1e3):null}get duration(){if("DURATION"in this.attr){const e=this.attr.decimalFloatingPoint("DURATION");if(B(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 isInterstitial(){return this.class===d0}get isValid(){return!!this.id&&!this._badValueForSameId&&B(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)&&(!this.attr.CUE||!this.cue.pre&&!this.cue.post||this.cue.pre!==this.cue.post)&&(!this.isInterstitial||"X-ASSET-URI"in this.attr||"X-ASSET-LIST"in this.attr)}get invalidReason(){return this.id?this._badValueForSameId?`Date range ${this._badValueForSameId} mismatch`:B(this.startDate.getTime())?this.isInterstitial&&!("X-ASSET-URI"in this.attr||"X-ASSET-LIST"in this.attr)?"Interstitial Date range missing X-ASSET-(LIST|URI)":this.isValid?null:"Unknown (check DURATION(|END|NEXT), CLASS, and CUE)":"Date range invalid start date":"Missing ID"}}const Rh=10;class h0{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.dateRangeTagCount=0,this.live=!0,this.iframesOnly=!1,this.requestScheduled=-1,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!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.appliedTimelineOffset=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}reloaded(e){if(!e){this.advanced=!0,this.updated=!0;return}const t=this.lastPartSn-e.lastPartSn,i=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!i||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||t===0&&i>0,this.updated||this.advanced?this.misses=0:this.misses=e.misses+1}hasKey(e){return this.encryptedFragments.some(t=>{let i=t.decryptdata;return i||(t.setKeyFormat(e.keyFormat),i=t.decryptdata),!!i&&e.matches(i)})}get hasProgramDateTime(){return this.fragments.length?B(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||Rh}
vendor: 19,866 bytes, line 53
53get drift(){const 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(){return this.fragments.length?this.fragments[this.fragments.length-1].end:0}get fragmentStart(){return this.fragments.length?this.fragments[0].start: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 maxPartIndex(){const e=this.partList;if(e){const t=this.lastPartIndex;if(t!==-1){for(let i=e.length;i--;)if(e[i].index>t)return e[i].index;return t}}return 0}get lastPartSn(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}get expired(){if(this.live&&this.age&&this.misses<3){const e=this.partEnd-this.fragmentStart;return this.age>Math.max(e,this.totalduration)+this.levelTargetDuration}return!1}}function Wn(s,e){return s.length===e.length?!s.some((t,i)=>t!==e[i]):!1}function tc(s,e){return!s&&!e?!0:!s||!e?!1:Wn(s,e)}function ys(s){return s==="AES-128"||s==="AES-256"||s==="AES-256-CTR"}function xl(s){switch(s){case"AES-128":case"AES-256":return Ci.cbc;case"AES-256-CTR":return Ci.ctr;default:throw new Error(`invalid full segment method ${s}`)}}function Ro(s){return Uint8Array.from(unescape(encodeURIComponent(s)),e=>e.charCodeAt(0))}function f0(s){const e=Ro(s).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function Dh(s){const e=function(i,r,n){const a=i[r];i[r]=i[n],i[n]=a};e(s,0,3),e(s,1,2),e(s,4,5),e(s,6,7)}function kh(s){const e=s.split(":");let t=null;if(e[0]==="data"&&e.length===2){const i=e[1].split(";"),r=i[i.length-1].split(",");if(r.length===2){const n=r[0]==="base64",a=r[1];n?(i.splice(-1,1),t=Sl(a)):t=f0(a)}}return t}const Yn=typeof self<"u"?self:void 0;var De={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},lt={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function Ur(s){switch(s){case lt.FAIRPLAY:return De.FAIRPLAY;case lt.PLAYREADY:return De.PLAYREADY;case lt.WIDEVINE:return De.WIDEVINE;case lt.CLEARKEY:return De.CLEARKEY}}var Ch={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function Ma(s){switch(s){case De.FAIRPLAY:return lt.FAIRPLAY;case De.PLAYREADY:return lt.PLAYREADY;case De.WIDEVINE:return lt.WIDEVINE;case De.CLEARKEY:return lt.CLEARKEY}}function ws(s){const{drmSystems:e,widevineLicenseUrl:t}=s,i=e?[De.FAIRPLAY,De.WIDEVINE,De.PLAYREADY,De.CLEARKEY].filter(r=>!!e[r]):[];return!i[De.WIDEVINE]&&t&&i.push(De.WIDEVINE),i}const Ph=function(s){return Yn!=null&&(s=Yn.navigator)!=null&&s.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function g0(s,e,t,i){let r;switch(s){case De.FAIRPLAY:r=["cenc","sinf"];break;case De.WIDEVINE:case De.PLAYREADY:r=["cenc"];break;case De.CLEARKEY:r=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${s}`)}return m0(r,e,t,i)}function m0(s,e,t,i){return[{initDataTypes:s,persistentState:i.persistentState||"optional",distinctiveIdentifier:i.distinctiveIdentifier||"optional",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:e.map(n=>({contentType:`audio/mp4; codecs=${n}`,robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null})),videoCapabilities:t.map(n=>({contentType:`video/mp4; codecs=${n}`,robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}))}]}function p0(s){var e;return!!s&&(s.sessionType==="persistent-license"||!!((e=s.sessionTypes)!=null&&e.some(t=>t==="persistent-license")))}function Rl(s){const e=new Uint16Array(s.buffer,s.byteOffset,s.byteLength/2),t=Ne(e),i=t.substring(t.indexOf("<"),t.length),a=new DOMParser().parseFromString(i,"text/xml").getElementsByTagName("KID")[0];if(a){const o=a.childNodes[0]?a.childNodes[0].nodeValue:a.getAttribute("VALUE");if(o){const l=Sl(o).subarray(0,16);return Dh(l),l}}return null}let Qi={};class Ei{static clearKeyUriToKeyIdMap(){Qi={}}static setKeyIdForUri(e,t){Qi[e]=t}static addKeyIdForUri(e){const t=Object.keys(Qi).length%Number.MAX_SAFE_INTEGER,i=new Uint8Array(16);return new DataView(i.buffer,12,4).setUint32(0,t),Qi[e]=i,i}constructor(e,t,i,r=[1],n=null,a){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.scheme=void 0,this.method=e,this.uri=t,this.keyFormat=i,this.keyFormatVersions=r,this.iv=n,this.encrypted=e?e!=="NONE":!1,this.isCommonEncryption=this.encrypted&&!ys(e),a!=null&&a.startsWith("0x")&&(this.keyId=new Uint8Array(eh(a)))}matches(e){return e.uri===this.uri&&e.method===this.method&&e.encrypted===this.encrypted&&e.keyFormat===this.keyFormat&&Wn(e.keyFormatVersions,this.keyFormatVersions)&&tc(e.iv,this.iv)&&tc(e.keyId,this.keyId)}isSupported(){if(this.method){if(ys(this.method)||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case lt.FAIRPLAY:case lt.WIDEVINE:case lt.PLAYREADY:case lt.CLEARKEY:return["SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1}getDecryptData(e,t){var i;if(!this.encrypted||!this.uri)return null;if(ys(this.method)){let a=this.iv;return a||(typeof e!="number"&&(Te.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0),a=v0(e)),new Ei(this.method,this.uri,"identity",this.keyFormatVersions,a)}if(this.keyId){const a=Qi[this.uri];if(a&&!Wn(this.keyId,a)&&Ei.setKeyIdForUri(this.uri,this.keyId),this.pssh)return this}const r=kh(this.uri);if(r)switch(this.keyFormat){case lt.WIDEVINE:if(this.pssh=r,!this.keyId){const a=uh(r.buffer).filter(o=>o.systemId===Ch.WIDEVINE);if(a.length){var n;const o=a[0];this.keyId=(n=o.kids)!=null&&n.length?o.kids[0]:null}}this.keyId||(this.keyId=ic(t));break;case lt.PLAYREADY:{const a=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=yp(a,null,r),this.keyId=Rl(r);break}default:{let a=r.subarray(0,16);if(a.length!==16){const o=new Uint8Array(16);o.set(a,16-a.length),a=o}this.keyId=a;break}}if(((i=this.keyId)==null?void 0:i.byteLength)!==16){let a;a=E0(t),a||(a=ic(t),a||(a=Qi[this.uri])),a&&(this.keyId=a,Ei.setKeyIdForUri(this.uri,a))}return this}}function E0(s){const e=s?.[lt.WIDEVINE];return e?e.keyId:null}function ic(s){const e=s?.[lt.PLAYREADY];if(e){const t=kh(e.uri);if(t)return Rl(t)}return null}function v0(s){const e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=s>>8*(15-t)&255;return e}const sc=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(I-FRAME-STREAM-INF|SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)(?:[\r\n]+|$)/g,rc=/#EXT-X-MEDIA:(.*)/g,y0=/^#EXT(?:INF|-X-TARGETDURATION):/m,Oa=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),T0=new RegExp([/#EXT-X-(PROGRAM-DATE-TIME|BYTERANGE|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|I-FRAMES-ONLY)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class ai{static findGroup(e,t){for(let i=0;i<e.length;i++){const r=e[i];if(r.id===t)return r}}static resolve(e,t){return pl.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return y0.test(e)}static parseMasterPlaylist(e,t){const i=Zd(e),r={contentSteering:null,levels:[],iframeVariants:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:i},n=[];if(sc.lastIndex=0,!e.startsWith("#EXTM3U"))return r.playlistParsingError=new Error("no EXTM3U delimiter"),r;let a;for(;(a=sc.exec(e))!=null;)if(a[1]){const l=new ke(a[1],r),d=nc(l,a[2],t,r,n);d&&r.levels.push(d)}else if(a[3]){const l=a[3],d=a[4];switch(l){case"I-FRAME-STREAM-INF":{const c=new ke(d,r),u=nc(c,c.URI,t,r,n,!0);u&&r.iframeVariants.push(u)}break;case"SESSION-DATA":{const c=new ke(d,r),u=c["DATA-ID"];u&&(r.sessionData===null&&(r.sessionData={}),r.sessionData[u]=c);break}case"SESSION-KEY":{const c=ac(d,t,r);c.encrypted&&c.isSupported()?(r.sessionKeys===null&&(r.sessionKeys=[]),r.sessionKeys.push(c)):Te.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${d}"`);break}case"DEFINE":{{const c=new ke(d,r);Jd(r,c,t)}break}case"CONTENT-STEERING":{const c=new ke(d,r);r.contentSteering={uri:ai.resolve(c["SERVER-URI"],t),pathwayId:c["PATHWAY-ID"]||"."};break}case"START":{r.startTimeOffset=oc(d);break}}}const o=n.length>0&&n.length<r.levels.length;return r.levels=o?n:r.levels,r.levels.length===0&&(r.playlistParsingError=new Error("no levels found in manifest")),r}static parseMasterPlaylistMedia(e,t,i){let r;const n={},a=i.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":[]};let l=0;for(rc.lastIndex=0;(r=rc.exec(e))!==null;){const d=new ke(r[1],i),c=d.TYPE;if(c){const u=o[c],h=n[c]||[];n[c]=h;const f=d.LANGUAGE,g=d["ASSOC-LANGUAGE"],m=d.CHANNELS,p=d.CHARACTERISTICS,v=d["INSTREAM-ID"],T={attrs:d,bitrate:0,id:l++,groupId:d["GROUP-ID"]||"",name:d.NAME||f||"",type:c,default:d.bool("DEFAULT"),autoselect:d.bool("AUTOSELECT"),forced:d.bool("FORCED"),lang:f,url:d.URI?ai.resolve(d.URI,t):""};if(g&&(T.assocLang=g),m&&(T.channels=m),p&&(T.characteristics=p),v&&(T.instreamId=v),u!=null&&u.length){const y=ai.findGroup(u,T.groupId)||u[0];dc(T,y,"audioCodec"),dc(T,y,"textCodec")}h.push(T)}}return n}static parseLevelPlaylist(e,t,i,r,n,a){var o;const l={url:t},d=new h0(t),c=d.fragments,u=[];let h=null,f=0,g=0,m=0,p=0,v=0,T=null,y=new Pr(r,l),S,A,I,_=-1,R=!1,D=null,L;if(Oa.lastIndex=0,d.m3u8=e,d.hasVariableRefs=Zd(e),((o=Oa.exec(e))==null?void 0:o[0])!=="#EXTM3U")return d.playlistParsingError=new Error("Missing format identifier #EXTM3U"),d;for(;(S=Oa.exec(e))!==null;){R&&(R=!1,y=new Pr(r,l),y.playlistOffset=m,y.setStart(m),y.sn=f,y.cc=p,v&&(y.bitrate=v),y.level=i,h&&(y.initSegment=h,h.rawProgramDateTime&&(y.rawProgramDateTime=h.rawProgramDateTime,h.rawProgramDateTime=null),D&&(y.setByteRange(D),D=null)));const G=S[1];if(G){y.duration=parseFloat(G);const O=(" "+S[2]).slice(1);y.title=O||null,y.tagList.push(O?["INF",G,O]:["INF",G])}else if(S[3]){if(B(y.duration)){var k;y.playlistOffset=m,y.setStart(m),I&&uc(y,I,d),y.sn=f,y.level=i,y.cc=p;const O=(" "+S[3]).slice(1);y.relurl=Ll(d,O),Do(y,T,u),T=y,m+=y.duration,f++,g=0;const F=y.byteRange;if(F.length===2&&(y.bitrate=(F[1]-F[0])*8/y.duration|0),d.iframesOnly&&F[0]&&((k=h)==null?void 0:k.cc)!==p){const M=new Pr(r,l);M.relurl=y.relurl,M.setByteRange(`${Math.min(F[0],1316)}@0`),M.level=i,M.sn="initSegment",I&&(M.levelkeys=I,I.identity&&(M._decryptdata=I.identity.getDecryptData(0))),h=M,y.initSegment=h}c.push(y),R=!0}}else{if(S=S[0].match(T0),!S){Te.warn("No matches on slow regex match for level playlist!");continue}for(A=1;A<S.length&&S[A]===void 0;A++);const O=(" "+S[A]).slice(1),F=(" "+S[A+1]).slice(1),M=S[A+2]?(" "+S[A+2]).slice(1):null;switch(O){case"BYTERANGE":T?y.setByteRange(F,T):y.setByteRange(F);break;case"PROGRAM-DATE-TIME":y.rawProgramDateTime=F,y.tagList.push(["PROGRAM-DATE-TIME",F]),_===-1&&(_=c.length);break;case"PLAYLIST-TYPE":d.type&&ci(d,O,S),d.type=F.toUpperCase();break;case"MEDIA-SEQUENCE":d.startSN!==0?ci(d,O,S):T!==null&&b0(d,O,S),d.startSN=parseInt(F),f=d.startSN+d.skippedSegments;break;case"SKIP":{d.skippedSegments&&ci(d,O,S);const $=new ke(F,d),Y=$.decimalInteger("SKIPPED-SEGMENTS");if(B(Y)){d.skippedSegments+=Y;for(let V=Y;V--;)c.push(null);f+=Y}const N=$.enumeratedString("RECENTLY-REMOVED-DATERANGES");N&&(d.recentlyRemovedDateranges=(d.recentlyRemovedDateranges||[]).concat(N.split("	")));break}case"TARGETDURATION":d.targetduration!==0&&ci(d,O,S),d.targetduration=Math.max(parseInt(F),1);break;case"VERSION":d.version!==null&&ci(d,O,S),d.version=parseInt(F);break;case"INDEPENDENT-SEGMENTS":break;case"I-FRAMES-ONLY":d.iframesOnly=!0;break;case"ENDLIST":d.live||ci(d,O,S),d.live=!1;break;case"#":(F||M)&&y.tagList.push(M?[F,M]:[F]);break;case"DISCONTINUITY":p++,y.tagList.push(["DIS"]);break;case"GAP":y.gap=!0,y.tagList.push([O]);break;case"BITRATE":y.tagList.push([O,F]),v=parseInt(F)*1e3,B(v)?y.bitrate=v:v=0;break;case"DATERANGE":{const $=new ke(F,d),Y=new xh($,d.dateRanges[$.ID],d.dateRangeTagCount);d.dateRangeTagCount++,Y.isValid||d.skippedSegments?d.dateRanges[Y.id]=Y:Te.log(`Ignoring invalid DATERANGE tag: ${Y.invalidReason}: ${F}`),y.tagList.push(["EXT-X-DATERANGE",F]);break}case"DEFINE":{{const $=new ke(F,d);"IMPORT"in $?o0(d,$,a):Jd(d,$,t)}break}case"DISCONTINUITY-SEQUENCE":d.startCC!==0&&ci(d,O,S),d.startCC=p=parseInt(F),c.forEach($=>$&&($.cc=p));break;case"KEY":{const $=ac(F,t,d);if($.isSupported()){if($.method==="NONE"){I=void 0;break}I||(I={});const Y=I[$.keyFormat];Y!=null&&Y.matches($)||(Y&&(I=Ie({},I)),I[$.keyFormat]=$)}else Te.warn(`[Keys] Ignoring unsupported EXT-X-KEY tag: "${F}"`);break}case"START":d.startTimeOffset=oc(F);break;case"MAP":{const $=new ke(F,d);if(y.duration){const Y=new Pr(r,l);cc(Y,$,i,I),h=Y,y.initSegment=h,h.rawProgramDateTime&&!y.rawProgramDateTime&&(y.rawProgramDateTime=h.rawProgramDateTime)}else{const Y=y.byteRangeEndOffset;if(Y){const N=y.byteRangeStartOffset;D=`${Y-N}@${N}`}else D=null;cc(y,$,i,I),h=y,R=!0}h.cc=p;break}case"SERVER-CONTROL":{L&&ci(d,O,S),L=new ke(F),d.canBlockReload=L.bool("CAN-BLOCK-RELOAD"),d.canSkipUntil=L.optionalFloat("CAN-SKIP-UNTIL",0),d.canSkipDateRanges=d.canSkipUntil>0&&L.bool("CAN-SKIP-DATERANGES"),d.partHoldBack=L.optionalFloat("PART-HOLD-BACK",0),d.holdBack=L.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{d.partTarget&&ci(d,O,S);const $=new ke(F);d.partTarget=$.decimalFloatingPoint("PART-TARGET");break}case"PART":{let $=d.partList;$||($=d.partList=[]);const Y=g>0?$[$.length-1]:void 0,N=g++,V=new ke(F,d),se=new xm(V,y,l,N,Y);$.push(se),y.duration+=se.duration;break}case"PRELOAD-HINT":{const $=new ke(F,d);d.preloadHint=$;break}case"RENDITION-REPORT":{const $=new ke(F,d);d.renditionReports=d.renditionReports||[],d.renditionReports.push($);break}default:Te.warn(`line parsed but not handled: ${S}`);break}}}T&&!T.relurl?(c.pop(),m-=T.duration,d.partList&&(d.fragmentHint=T)):d.partList&&(Do(y,T,u),y.cc=p,d.fragmentHint=y,I&&uc(y,I,d)),d.targetduration||(d.playlistParsingError=new Error("Missing Target Duration"));const w=c.length,U=c[0],K=c[w-1];if(m+=d.skippedSegments*d.targetduration,m>0&&w&&K){d.averagetargetduration=m/w;const G=K.sn;d.endSN=G!=="initSegment"?G:0,d.live||(K.endList=!0),_>0&&(A0(c,_,_>w-1?y:null),U&&u.unshift(U))}return d.fragmentHint&&(m+=d.fragmentHint.duration),d.totalduration=m,u.length&&d.dateRangeTagCount&&U&&wh(u,d),d.endCC=p,d}}function nc(s,e,t,i,r,n){var a;if(e===void 0)return null;const o=Ll(i,e),l={attrs:s,bitrate:s.decimalInteger("BANDWIDTH")||s.decimalInteger("AVERAGE-BANDWIDTH"),name:s.NAME,url:ai.resolve(o,t)},d=s.decimalResolution("RESOLUTION");d&&(l.width=d.width,l.height=d.height),lc(s.CODECS,l);const c=s["SUPPLEMENTAL-CODECS"];return c&&(l.supplemental={},lc(c,l.supplemental)),(a=l.unknownCodecs)!=null&&a.length||r.push(l),n&&(l.iframes=!0),l}function wh(s,e){let t=s.length;if(!t)if(e.hasProgramDateTime){const o=e.fragments[e.fragments.length-1];s.push(o),t++}else return;const i=s[t-1],r=e.live?1/0:e.totalduration,n=Object.keys(e.dateRanges);for(let o=n.length;o--;){const l=e.dateRanges[n[o]],d=l.startDate.getTime();l.tagAnchor=i.ref;for(let c=t;c--;){var a;if(((a=s[c])==null?void 0:a.sn)<e.startSN)break;const u=S0(e,d,s,c,r);if(u!==-1){l.tagAnchor=e.fragments[u].ref;break}}}}function S0(s,e,t,i,r){const n=t[i];if(n){const o=n.programDateTime;if(e>=o||i===0){var a;const l=(((a=t[i+1])==null?void 0:a.start)||r)-n.start;if(e<=o+l*1e3){const d=t[i].sn-s.startSN;if(d<0)return-1;const c=s.fragments;if(c.length>t.length){const h=(t[i+1]||c[c.length-1]).sn-s.startSN;for(let f=h;f>d;f--){const g=c[f].programDateTime;if(e>=g&&e<g+c[f].duration*1e3)return f}}return d}}}return-1}function ac(s,e,t){var i,r;const n=new ke(s,t),a=(i=n.METHOD)!=null?i:"",o=n.URI,l=n.hexadecimalInteger("IV"),d=n.KEYFORMATVERSIONS,c=(r=n.KEYFORMAT)!=null?r:"identity";o&&n.IV&&!l&&Te.error(`Invalid IV: ${n.IV}`);const u=o?ai.resolve(o,e):"",h=(d||"1").split("/").map(Number).filter(Number.isFinite);return new Ei(a,u,c,h,l,n.KEYID)}function oc(s){const t=new ke(s).decimalFloatingPoint("TIME-OFFSET");return B(t)?t:null}function lc(s,e){let t=(s||"").split(/[ ,]+/).filter(i=>i);["video","audio","text","image"].forEach(i=>{const r=t.filter(n=>Al(n,i));r.length&&(e[`${i}Codec`]=r.map(n=>n.split("/")[0]).join(","),t=t.filter(n=>r.indexOf(n)===-1))}),e.unknownCodecs=t}function dc(s,e,t){const i=e[t];i&&(s[t]=i)}function A0(s,e,t){if(t||(t=s[e]),!!t)for(let i=e;i--;){const r=s[i];if(!r)return;r.programDateTime=t.programDateTime-r.duration*1e3,t=r}}function Do(s,e,t){s.rawProgramDateTime?t.push(s):e!=null&&e.programDateTime&&(s.programDateTime=e.endProgramDateTime)}function cc(s,e,t,i){s.relurl=e.URI,e.BYTERANGE&&s.setByteRange(e.BYTERANGE),s.level=t,s.sn="initSegment",i&&(s.levelkeys=i),s.initSegment=null}function uc(s,e,t){s.levelkeys=e;const{encryptedFragments:i}=t;(!i.length||i[i.length-1].levelkeys!==e)&&Object.keys(e).some(r=>e[r].isCommonEncryption)&&i.push(s)}function ci(s,e,t){s.playlistParsingError=new Error(`#EXT-X-${e} must not appear more than once (${t[0]})`)}function b0(s,e,t){s.playlistParsingError=new Error(`#EXT-X-${e} must appear before the first Media Segment (${t[0]})`)}function Fa(s,e){const t=e.startPTS;if(B(t)){let i=0,r;e.sn>s.sn?(i=t-s.start,r=s):(i=s.start-t,r=e),r.duration!==i&&r.setDuration(i)}else e.sn>s.sn?s.cc===e.cc&&s.minEndPTS?e.setStart(s.start+(s.minEndPTS-s.start)):e.setStart(s.start+s.duration):e.setStart(Math.max(s.start-e.duration,0))}function Mh(s,e,t,i,r,n,a,o){i-t<=0&&(o.warn("Fragment should have a positive duration",e),i=t+e.duration,n=r+e.duration);let d=t,c=i;const u=e.startPTS,h=e.endPTS;if(B(u)){const T=Math.abs(u-t);s&&T>s.totalduration?o.warn(`media timestamps and playlist times differ by ${T}s for level ${e.level} ${s.url}`):B(e.deltaPTS)?e.deltaPTS=Math.max(T,e.deltaPTS):e.deltaPTS=T,d=Math.max(t,u),t=Math.min(t,u),r=e.startDTS!==void 0?Math.min(r,e.startDTS):r,c=Math.min(i,h),i=Math.max(i,h),n=e.endDTS!==void 0?Math.max(n,e.endDTS):n}const f=t-e.start;e.start!==0&&e.setStart(t),e.setDuration(i-e.start),e.startPTS=t,e.maxStartPTS=d,e.startDTS=r,e.endPTS=i,e.minEndPTS=c,e.endDTS=n;const g=e.sn;if(!s||g<s.startSN||g>s.endSN)return 0;let m;const p=g-s.startSN,v=s.fragments;for(v[p]=e,m=p;m>0;m--)Fa(v[m],v[m-1]);for(m=p;m<v.length-1;m++)Fa(v[m],v[m+1]);return s.fragmentHint&&Fa(v[v.length-1],s.fragmentHint),s.PTSKnown=s.alignedSliding=!0,f}function I0(s,e,t){if(s===e)return;let i=null;const r=s.fragments;for(let c=r.length-1;c>=0;c--){const u=r[c].initSegment;if(u){i=u;break}}s.fragmentHint&&delete s.fragmentHint.endPTS;let n;x0(s,e,(c,u,h,f)=>{if((!e.startCC||e.skippedSegments)&&u.cc!==c.cc){const g=c.cc-u.cc;for(let m=h;m<f.length;m++)f[m].cc+=g;e.endCC=f[f.length-1].cc}B(c.startPTS)&&B(c.endPTS)&&(u.setStart(u.startPTS=c.startPTS),u.startDTS=c.startDTS,u.maxStartPTS=c.maxStartPTS,u.endPTS=c.endPTS,u.endDTS=c.endDTS,u.minEndPTS=c.minEndPTS,u.setDuration(c.endPTS-c.startPTS),u.duration&&(n=u),e.PTSKnown=e.alignedSliding=!0),c.hasStream
vendor: 7,276 bytes, lines 53-58
53s&&(u.elementaryStreams=c.elementaryStreams),u.loader=c.loader,c.hasStats&&(u.stats=c.stats),c.initSegment&&(u.initSegment=c.initSegment,i=c.initSegment)});const a=e.fragments,o=e.fragmentHint?a.concat(e.fragmentHint):a;if(i&&o.forEach(c=>{var u;c&&(!c.initSegment||c.initSegment.relurl===((u=i)==null?void 0:u.relurl))&&(c.initSegment=i)}),e.skippedSegments){if(e.deltaUpdateFailed=a.some(c=>!c),e.deltaUpdateFailed){t.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let c=e.skippedSegments;c--;)a.shift();e.startSN=a[0].sn}else{e.canSkipDateRanges&&(e.dateRanges=_0(s.dateRanges,e,t));const c=s.fragments.filter(u=>u.rawProgramDateTime);if(s.hasProgramDateTime&&!e.hasProgramDateTime)for(let u=1;u<o.length;u++)o[u].programDateTime===null&&Do(o[u],o[u-1],c);wh(c,e)}e.endCC=a[a.length-1].cc}if(!e.startCC){var l;const c=Nh(s,e.startSN-1);e.startCC=(l=c?.cc)!=null?l:a[0].cc}if(L0(s.partList,e.partList,(c,u)=>{u.elementaryStreams=c.elementaryStreams,u.stats=c.stats,u.gap=c.gap||u.gap}),n){const c=e.iframesOnly&&n.type===j.MAIN;Mh(e,n,n.startPTS,n.endPTS,n.startDTS,n.endDTS,c,t)}else Oh(s,e);a.length&&(e.totalduration=e.edge-a[0].start),e.driftStartTime=s.driftStartTime,e.driftStart=s.driftStart;const d=e.advancedDateTime;if(e.advanced&&d){const c=e.edge;e.driftStart||(e.driftStartTime=d,e.driftStart=c),e.driftEndTime=d,e.driftEnd=c}else e.driftEndTime=s.driftEndTime,e.driftEnd=s.driftEnd,e.advancedDateTime=s.advancedDateTime;e.requestScheduled===-1&&(e.requestScheduled=s.requestScheduled)}function _0(s,e,t){const{dateRanges:i,recentlyRemovedDateranges:r}=e,n=Ie({},s);r&&r.forEach(l=>{delete n[l]});const o=Object.keys(n).length;return o?(Object.keys(i).forEach(l=>{const d=n[l],c=new xh(i[l].attr,d);c.isValid?(n[l]=c,d||(c.tagOrder+=o)):t.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${Re(i[l].attr)}"`)}),n):i}function L0(s,e,t){if(s&&e){let i=0;for(let r=0,n=s.length;r<n;r++){const a=s[r],o=e[r+i];a&&o&&a.index===o.index&&a.fragment.sn===o.fragment.sn?t(a,o):i--}}}function x0(s,e,t){var i;const r=e.skippedSegments,n=Math.max(s.startSN,e.startSN)-e.startSN,a=(s.fragmentHint?1:0)+(r?e.endSN:Math.min(s.endSN,e.endSN))-e.startSN,o=e.startSN-s.startSN,l=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,d=(i=s.fragmentHint)!=null&&i.duration?s.fragments.concat(s.fragmentHint):s.fragments;for(let c=n;c<=a;c++){const u=d[o+c];let h=l[c];if(r&&!h&&u&&(h=e.fragments[c]=u),u&&h){t(u,h,c,l);const f=u.relurl,g=h.relurl;if(f&&D0(f,g)){e.playlistParsingError=hc(`media sequence mismatch ${h.sn}:`,s,e,u,h);return}else if(u.cc!==h.cc){e.playlistParsingError=hc(`discontinuity sequence mismatch (${u.cc}!=${h.cc})`,s,e,u,h);return}}}}function hc(s,e,t,i,r){return new Error(`${s} ${r.url}
54Playlist starting @${e.startSN}
55${e.m3u8}
56
57Playlist starting @${t.startSN}
58${t.m3u8}`)}function Oh(s,e,t=!0,i){const r=e.startSN+e.skippedSegments-s.startSN,n=s.fragments,a=r>=0;let o=0;if(a&&r<n.length)o=n[r].start,i?.log(`Aligning playlists based on SN ${e.startSN} (diff: ${o})`);else if(a&&e.startSN===s.endSN+1)o=s.fragmentEnd,i?.log(`Aligning playlists based on first/last SN ${e.startSN} (diff: ${o})`);else if(a&&t)o=s.fragmentStart+r*e.levelTargetDuration;else if(!e.skippedSegments&&e.fragmentStart===0)o=s.fragmentStart,i?.log(`Aligning playlists based on first SN ${e.startSN} (diff: ${o})`);else return o;return R0(e,o),o}function R0(s,e){if(e){const t=s.fragments;for(let i=s.skippedSegments;i<t.length;i++)t[i].addStart(e);s.fragmentHint&&s.fragmentHint.addStart(e)}}function Fh(s,e=1/0){let t=1e3*s.targetduration;if(s.updated){const i=s.fragments;if(i.length&&t*4>e){const n=i[i.length-1].duration*1e3;n<t&&(t=n)}}else t/=2;return Math.round(t)}function Nh(s,e,t){var i;if(!s)return null;let r=s.fragments[e-s.startSN];return r||(r=s.fragmentHint,((i=r)==null?void 0:i.sn)===e)?r:t&&e<s.startSN&&t.sn===e?t:null}function fc(s,e,t){return s?Uh(s.partList,e,t):null}function Uh(s,e,t){if(s)for(let i=s.length;i--;){const r=s[i];if(r.index===t&&r.fragment.sn===e)return r}return null}function $h(s){s.forEach((e,t)=>{var i;(i=e.details)==null||i.fragments.forEach(r=>{r.level=t,r.initSegment&&(r.initSegment.level=t)})})}function D0(s,e){return s!==e&&e?gc(s)!==gc(e):!1}function gc(s){return s.replace(/\?[^?]*$/,"")}function tr(s,e){for(let i=0,r=s.length;i<r;i++){var t;if(((t=s[i])==null?void 0:t.cc)===e)return s[i]}return null}function k0(s,e){return!!(s&&e.startCC<s.endCC&&e.endCC>s.startCC)}function mc(s,e){const t=s.start+e;s.setStart(t)}function Bh(s,e){const t=e.fragments;for(let i=0,r=t.length;i<r;i++)mc(t[i],s);e.fragmentHint&&mc(e.fragmentHint,s),e.alignedSliding=!0}function qn(s,e,t){s&&(C0(e,s,t),e.alignedSliding||P0(e,s,t),!e.alignedSliding&&!e.skippedSegments&&Oh(s,e,!1,t))}function C0(s,e,t){if(!k0(e,s))return;const i=Math.min(e.endCC,s.endCC),r=tr(e.fragments,i),n=tr(s.fragments,i);if(!r||!n)return;const a=r.start-n.start;t.log(`Aligning playlists using dicontinuity sequence ${i} (diff: ${a})`),Bh(a,s)}function P0(s,e,t){if(!s.hasProgramDateTime||!e.hasProgramDateTime)return;const i=s.fragments,r=e.fragments;if(!i.length||!r.length)return;let n,a;const o=Math.min(e.endCC,s.endCC);e.startCC<o&&s.startCC<o&&(n=tr(r,o),a=tr(i,o)),(!n||!a)&&(n=r[Math.floor(r.length/2)]||r.filter(h=>!!h)[0],a=tr(i,n.cc)||i[Math.floor(i.length/2)]);const l=n.programDateTime,d=a.programDateTime;if(!l||!d)return;const c=(d-l)/1e3;if(Math.abs(c)>Math.max(60,s.totalduration)){t.log(`Cannot align playlists using PDT without overlap (${Math.abs(c)} > ${s.totalduration})`);return}const u=c-(a.start-n.start);t.log(`Aligning playlists using PDT (diff: ${u})`),Bh(u,s)}function Ae(s,e,t){ye(s,e,t),s.addEventListener(e,t)}function ye(s,e,t){s.removeEventListener(e,t)}function jn(s){let e="";const t=s.length;for(let i=0;i<t;i++)e+=`[${s.start(i).toFixed(3)}-${s.end(i).toFixed(3)}]`;return e}const C={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"};class Dl extends _h{constructor(e,t,i,r,n){super(r,e.logger),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragPlaying=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=C.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=-1,this.startTimeOffset=null,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.initFragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.buffering=!0,this.loadingParts=!1,this.loopSn=void 0,this.onMediaSeeking=()=>{const{config:a,fragCurrent:o,media:l,mediaBuffer:d,state:c}=this,u=l?l.currentTime:0,h=ie.bufferInfo(d||l,u,a.maxBufferHole),f=h.len;if(this.log(`Media seeking to ${u}, state: ${c}, ${f?"in":"out of"} buffer`),this.state===C.ENDED)this.resetLoadingState();else if(o){const m=a.maxFragLookUpTolerance,p=o.start-m,v=o.start+o.duration+m;if(!f||v<h.start||p>h.end){const T=u<p,y=u>v;
vendor: 4,537 bytes, line 58
58(T||y)&&(o.loader&&(y||!this.isFragmentNearlyDownloaded(o))?(this.log(`Cancelling fragment load for seek (sn: ${o.sn}) - ${T?"backward":"forward"} seek`),o.abortRequests(),this.resetLoadingState()):this.fragPrevious=null)}}if(l){this.fragmentTracker.removeFragmentsInRange(u,1/0,this.playlistType,!0);const m=this.lastCurrentTime;if(u>m&&(this.lastCurrentTime=u),!this.loadingParts){const p=Math.max(h.end,u),v=this.shouldLoadParts(this.getLevelDetails(),p);v&&(this.log(`LL-Part loading ON after seeking to ${u} with buffer @${p}`),this.loadingParts=v)}}const g=!ie.isBuffered(l,u);(!this.hls.hasEnoughToStart||g)&&(this.log(`Setting ${g?"startPosition":"nextLoadPosition"} to ${u} for seek without enough to start`),this.nextLoadPosition=u,g&&(this.startPosition=u)),f<1&&this.state===C.IDLE&&this.tickImmediate()},this.onMediaEnded=()=>{this.log("setting startPosition to 0 because media ended"),this.startPosition=this.lastCurrentTime=0},this.playlistType=n,this.hls=e,this.fragmentLoader=new jd(e.config),this.initFragmentLoader=new jd(e.config),this.keyLoader=i,this.fragmentTracker=t,this.config=e.config,this.decrypter=new Il(e.config)}registerListeners(){const{hls:e}=this;e.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(E.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(E.ERROR,this.onError,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){if(this.state===C.STOPPED)return;this.fragmentLoader.abort(),this.initFragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const 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=C.STOPPED}get startPositionValue(){const{nextLoadPosition:e,startPosition:t}=this;if(t===-1&&e){const i=this.getLevelDetails();return i!=null&&i.live?(this.hls.liveSyncPosition||i.fragmentStart)+this.timelineOffset:e}return t}get bufferingEnabled(){return this.buffering}get backtrackFragment(){}set backtrackFragment(e){}get couldBacktrack(){return!1}set couldBacktrack(e){}pauseBuffering(){this.buffering=!1}resumeBuffering(){this.buffering=!0}get inFlightFrag(){return{frag:this.fragCurrent,state:this.state}}_streamEnded(e,t){if(t.live||!this.media)return!1;const i=e.end||0,r=this.config.timelineOffset||0;if(i<=r)return!1;const n=e.buffered;this.config.maxBufferHole&&n&&n.length>1&&(e=ie.bufferedInfo(n,e.start,0));const a=e.nextStart;if(a&&a>r&&a<t.edge||this.media.currentTime<e.start)return!1;const l=t.partList;if(l!=null&&l.length){const c=l[l.length-1];return ie.isBuffered(this.media,c.start+c.duration/2)}const d=t.fragments[t.fragments.length-1];return this.fragmentTracker.isEndListAppended(d.type)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null)return this.levelLastLoaded.details}get timelineOffset(){const e=this.config.timelineOffset;if(e){var t;return((t=this.getLevelDetails())==null?void 0:t.appliedTimelineOffset)||e}return 0}onMediaAttached(e,t){const i=this.media=this.mediaBuffer=t.media;Ae(i,"seeking",this.onMediaSeeking),Ae(i,"ended",this.onMediaEnded);const r=this.config;this.levels&&r.autoStartLoad&&this.state===C.STOPPED&&this.startLoad(r.startPosition)}onMediaDetaching(e,t){this.fragPlaying=null;const i=!!t.transferMedia,r=this.media;if(r!==null){if(r.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),ye(r,"seeking",this.onMediaSeeking),ye(r,"ended",this.onMediaEnded),this.media=this.mediaBuffer=null,this.loopSn=void 0,i){this.resetLoadingState(),this.resetTransmuxer();return}this.loadingParts=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}}onManifestLoading(){this.initPTS=[],this.fragPlaying=this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=0,this.startPosition=-1,this.startFragRequested=!1}onError(e,t){}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset}onHandlerDestroying(){this.stopLoad(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),super.onHandlerDestroying(),this.hls=this.onMediaSeeking=this.onMediaEnded=null}
vendor: 9,872 bytes, line 58
58onHandlerDestroyed(){this.state=C.STOPPED,this.fragmentLoader&&this.fragmentLoader.destroy(),this.initFragmentLoader&&this.initFragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.decrypter=this.keyLoader=null,this.fragmentLoader=this.initFragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(e,t,i){this.startFragRequested=!0,this._loadFragForPlayback(e,t,i)}_loadFragForPlayback(e,t,i){const r=n=>{const a=n.frag;if(this.fragContextChanged(a)){this.warn(`${a.type} sn: ${a.sn}${n.part?" part: "+n.part.index:""} of ${this.fragInfo(a,!1,n.part)} was dropped during download.`),this.fragmentTracker.removeFragment(a);return}const o=++a.stats.chunkCount;this.log(`load progress ${a.type} sn: ${a.sn}${n.part?" part: "+n.part.index:""} of ${this.fragInfo(a,!1,n.part)} chunk: ${o}`),this._handleFragmentLoadProgress(n)};this._doFragLoad(e,t,i,r).then(n=>{if(!n)return;const a=this.state,o=n.frag;if(this.fragContextChanged(o)){(a===C.FRAG_LOADING||!this.fragCurrent&&a===C.PARSING)&&(this.fragmentTracker.removeFragment(o),this.state=C.IDLE);return}"payload"in n&&(this.log(`Loaded ${o.type} sn: ${o.sn} of ${this.playlistLabel()} ${o.level} (bytes ${o.stats.loaded})`),this.hls.trigger(E.FRAG_LOADED,n)),this._handleFragmentLoadComplete(n)}).catch(n=>{this.state===C.STOPPED||this.state===C.ERROR||(this.log(`Frag error ${e.type} sn:${e.sn} cc:${e.cc}: ${n?.message||n}`),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;const{fragmentTracker:i}=this;if(i.getState(e)===Ce.APPENDING){const 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,e.duration))&&i.removeFragment(e)}else((t=this.mediaBuffer)==null?void 0:t.buffered.length)===0?i.removeAllFragments():i.hasParts(e.type)&&(i.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),i.getState(e)===Ce.PARTIAL&&i.removeFragment(e))}checkLiveUpdate(e){if(e.updated&&!e.live){const t=this.fragmentTracker,i=e.fragments[e.fragments.length-1];if(i.endList&&!t.isEndListAppended(this.playlistType)){const r=t.getPartialFragment(i.end);r&&(t.removeFragment(r),t.fragBuffered(i,!0))}t.detectPartialFragments({frag:i,part:null,stats:i.stats,id:i.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}waitForLive(e){const t=e.details;return t?.live&&t.type!=="EVENT"&&(this.levelLastLoaded!==e||t.expired)}flushMainBuffer(e,t,i=null){if(!(e-t))return;const r={startOffset:e,endOffset:t,type:i};this.hls.trigger(E.BUFFER_FLUSHING,r)}_loadInitSegment(e){const{hls:t}=this;return this.initFragmentLoader.abort(),t.trigger(E.FRAG_LOADING,{frag:e,targetBufferTime:0}),this.initFragmentLoader.load(e).then(i=>{var r;const n=i.frag;if(!this.levels||!So(n,(r=this.fragCurrent)==null?void 0:r.initSegment))throw new si({type:X.NETWORK_ERROR,details:x.INTERNAL_ABORTED,error:new Error("init load aborted"),fatal:!1,frag:n,networkDetails:null});return i}).then(i=>{const{frag:r,payload:n}=i,a=r.decryptdata;if(n&&n.byteLength>0&&a!=null&&a.key&&a.iv&&ys(a.method)){const o=self.performance.now(),{decryptRange:l}=Kn(r,null,this.iframesOnly);return this.decrypter.decrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer,xl(a.method),l).catch(d=>{throw t.trigger(E.ERROR,{type:X.MEDIA_ERROR,details:x.FRAG_DECRYPT_ERROR,fatal:!1,error:d,reason:d.message,frag:r}),this.fragmentLoader.abort(),d}).then(d=>{const c=self.performance.now();return t.trigger(E.FRAG_DECRYPTED,{frag:r,part:null,payload:d,stats:{tstart:o,tdecrypt:c}}),i.payload=d,this.completeInitSegmentLoad(i)})}return this.completeInitSegmentLoad(i)})}completeInitSegmentLoad(e){const t=e.frag.stats;e.frag.data=new Uint8Array(e.payload),t.parsing.start=t.buffering.start=self.performance.now(),t.parsing.end=t.buffering.end=self.performance.now()}loadInitSegmentIfNeeded(e){const{initSegment:t}=e;if(!this.bitrateTest&&Ue(e)&&t&&!t.data){var i;return(t.encrypted&&!((i=t.decryptdata)!=null&&i.key)?this.keyLoader.load(t).then(()=>this._loadInitSegment(t)):this._loadInitSegment(t)).catch(n=>{throw this.state===C.STOPPED||this.state===C.ERROR||("data"in n&&(n.data.frag=e,this.fragmentLoader.abort(),this.handleFragLoadError(n)),this.resetFragmentLoading(e)),n})}}unhandledEncryptionError(e,t){var i,r;const n=e.tracks;if(n&&!t.encrypted&&((i=n.audio)!=null&&i.encrypted||(r=n.video)!=null&&r.encrypted)&&(!this.config.emeEnabled||!this.keyLoader.emeController)){const a=this.media,o=new Error(`Encrypted track with no key in ${this.fragInfo(t)} (media ${a?"attached mediaKeys: "+a.mediaKeys:"detached"})`);return this.warn(o.message),!a||a.mediaKeys?!1:(this.hls.trigger(E.ERROR,{type:X.KEY_SYSTEM_ERROR,details:x.KEY_SYSTEM_NO_KEYS,fatal:!1,error:o,frag:t}),this.resetTransmuxer(),!0)}return!1}fragContextChanged(e){const{fragCurrent:t}=this;return!e||!So(e,t)}fragBufferedComplete(e,t){const i=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)} > buffer:${i?jn(ie.getBuffered(i)):"(detached)"})`),Ue(e)){var r;if(e.type!==j.SUBTITLE){const a=e.elementaryStreams;if(!Object.keys(a).some(o=>!!a[o])){this.state=C.IDLE;return}}const n=(r=this.levels)==null?void 0:r[e.level];n!=null&&n.fragmentError&&(t||this.fragmentTracker.getState(e)!==Ce.PARTIAL)&&(this.log(`Resetting level fragment error count of ${n.fragmentError} on frag buffered`),n.fragmentError=0,e.stats.retry=0)}this.state=C.IDLE}_handleFragmentLoadComplete(e){const{transmuxer:t}=this;if(!t)return;const i=e.frag,{part:r,partsLoaded:n}=e,a=!n||n.length===0||n.some(d=>!d),{decryptRange:o}=Kn(i,r),l=new _l(i.level,i.sn,i.stats.chunkCount+1,0,r?r.index:-1,!a,i.duration,this.iframesOnly,o);this.log(`load complete ${i.type} sn: ${i.sn}${r?" part: "+r.index:""} of ${this.fragInfo(i,!1,r)}`),t.flush(l)}_handleFragmentLoadProgress(e){}loadKeyFor(e,t,i){var r;let n=null;return e.encrypted&&!((r=e.decryptdata)!=null&&r.key)?(this.log(`Loading key for ${e.sn} of [${t.startSN}-${t.endSN}], ${this.playlistLabel()} ${e.level}`),this.state=C.KEY_LOADING,n=this.keyLoader.load(e,i).then(a=>{if(!this.fragContextChanged(a.frag))return this.hls.trigger(E.KEY_LOADED,a),this.state===C.KEY_LOADING&&(this.state=C.IDLE),a}),this.hls.trigger(E.KEY_LOADING,{frag:e})):e.encrypted||(n=this.keyLoader.loadClear(e,t.encryptedFragments,this.startFragRequested),n&&this.log(`[eme] blocking frag sn: ${e.sn} load until media-keys acquired`)),n}_doFragLoad(e,t,i=null,r){this.fragCurrent=e;const n=t.details;if(!this.levels||!n)throw new Error(`frag load aborted, missing level${n?"":" detail"}s`);const a=this.fragPrevious;if(!Gs(e,a)){const f=this.shouldLoadParts(t.details,e.end);f!==this.loadingParts&&(this.log(`LL-Part loading ${f?"ON":"OFF"} loading sn ${a?.sn}->${e.sn}`),this.loadingParts=f)}if(i=Math.max(e.start,i||0),this.loadingParts){const f=n.partList;if(f&&r){i>n.fragmentEnd&&n.fragmentHint&&(e=n.fragmentHint);const g=this.getNextPart(f,e,i);if(g>-1){const m=f[g];if(e=this.fragCurrent=m.fragment,!Gs(e,a)&&!this.shouldLoadParts(t.details,e.end))return this.log(`LL-Part loading OFF @${this.playhead} next part: ${this.fragInfo(e,!1,m)}`),this.loadingParts=!1,Promise.resolve(null);if(!this.filterReplacedPrimary(m,t.details))return Promise.resolve(null);const p=this.loadKeyFor(e,n);if(this.fragContextChanged(e))return Promise.resolve(null);this.log(`Loading ${e.type} sn: ${e.sn} part: ${m.index} (${g}/${f.length-1}) of ${this.fragInfo(e,!1,m)} cc: ${e.cc} [${n.startSN}-${n.endSN}], target: ${i}${m.byteRange.length?` range:${m.byteRange.join("-")}`:""}`),this.nextLoadPosition=m.start+m.duration,this.state=C.FRAG_LOADING;let v;const T=this.loadInitSegmentIfNeeded(e);if(p||T){const y=!!p;v=Promise.all([p,T]).then(([S])=>y&&(!S||this.fragContextChanged(S.frag))?null:this.doFragPartsLoad(e,m,t,r)).catch(S=>this.handleFragLoadError(S))}else v=this.doFragPartsLoad(e,m,t,r).catch(y=>this.handleFragLoadError(y));return this.hls.trigger(E.FRAG_LOADING,{frag:e,part:m,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):v}else if(!e.url||this.loadedEndOfParts(f,i))return Promise.resolve(null)}}if(this.loadingParts){var o;this.log(`LL-Part loading OFF after next part miss @${i} Check buffer at sn: ${e.sn} loaded parts: ${(o=n.partList)==null?void 0:o.filter(f=>f.loaded).map(f=>`[${f.start}-${f.end}]`)}`),this.loadingParts=!1}else if(!e.url)return Promise.resolve(null);if(!this.filterReplacedPrimary(e,t.details))return Promise.resolve(null);const l=this.loadInitSegmentIfNeeded(e),d=this.loadKeyFor(e,n,l);if(this.fragContextChanged(e)){var c;return this.log(`Context changed in KEY_LOADING sn: ${e.sn} ${e.relurl} > ${(c=this.fragCurrent)==null?void 0:c.relurl}`),l?.catch(()=>null),d?.catch(()=>null),Promise.resolve(null)}this.log(`Loading ${e.type} sn: ${e.sn} of ${this.fragInfo(e,!1)} cc: ${e.cc} ${"["+n.startSN+"-"+n.endSN+"]"}, target: ${i}${e.byteRange.length?` range:${e.byteRange.join("-")}`:""}`),B(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=C.FRAG_LOADING;const u=this.config.progressive&&e.type!==j.SUBTITLE;let h;return u&&d?h=d.then(f=>!f||this.fragContextChanged(f.frag)?null:this.fragmentLoader.load(e,this.iframesOnly,r,l)).catch(f=>this.handleFragLoadError(f)):h=Promise.all([this.fragmentLoader.load(e,this.iframesOnly,u?r:void 0,u?l:void 0),d,l]).then(([f])=>(!u&&r&&r(f),f)).catch(f=>this.handleFragLoadError(f)),this.hls.trigger(E.FRAG_LOADING,{frag:e,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):Promise.all([h,l]).then(([f])=>f)}doFragPartsLoad(e,t,i,r){return new Promise((n,a)=>{var o;const l=[],d=(o=i.details)==null?void 0:o.partList,c=u=>
vendor: 10,878 bytes, line 58
58{this.fragmentLoader.loadPart(e,u,r).then(h=>{l[u.index]=h;const f=h.part;this.hls.trigger(E.FRAG_LOADED,h);const g=fc(i.details,e.sn,u.index+1)||Uh(d,e.sn,u.index+1);if(g)c(g);else return n({frag:e,part:f,partsLoaded:l})}).catch(a)};c(t)})}handleFragLoadError(e){if("data"in e){const t=e.data;t.frag&&t.details===x.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):t.frag&&t.type===X.KEY_SYSTEM_ERROR&&!t.fatal&&(t.frag.abortRequests(),this.resetStartWhenNotLoaded(),this.resetFragmentLoading(t.frag)),this.hls.trigger(E.ERROR,t)}else this.hls.trigger(E.ERROR,{type:X.OTHER_ERROR,details:x.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){const t=this.getCurrentContext(e);if(!t||this.state!==C.PARSING){!this.fragCurrent&&this.state!==C.STOPPED&&this.state!==C.ERROR&&(this.state=C.IDLE);return}const{frag:i,part:r,level:n}=t,a=self.performance.now();i.stats.parsing.end=a,r&&(r.stats.parsing.end=a);const o=this.getLevelDetails(),d=o&&i.sn>o.endSN||this.shouldLoadParts(o,i.end);d!==this.loadingParts&&(this.log(`LL-Part loading ${d?"ON":"OFF"} after parsing segment ending @${i.end}`),this.loadingParts=d),this.updateLevelTiming(i,r,n,e)}shouldLoadParts(e,t){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(e.partList&&!this.iframesOnly){var i;const r=e.partList[0],n=r.end+(((i=e.fragmentHint)==null?void 0:i.duration)||0);if(t>=n&&this.playhead>r.start-r.fragment.duration)return!0}}return!1}getCurrentContext(e){const{levels:t,fragCurrent:i}=this,{level:r,sn:n,part:a}=e;if(!(t!=null&&t[r]))return this.warn(`Levels object was unset while buffering fragment ${n} of ${this.playlistLabel()} ${r}. The current chunk will not be buffered.`),null;const o=t[r],l=o.details,d=a>-1?fc(l,n,a):null,c=d?d.fragment:Nh(l,n,i);return c?(i&&i!==c&&(c.stats=i.stats),{frag:c,part:d,level:o}):null}bufferFragmentData(e,t,i,r,n){if(this.state!==C.PARSING)return;Ue(t)&&!this.fragContextChanged(t)&&(this.fragPrevious=t);const{data1:a,data2:o}=e;let l=a;if(o&&(l=Pt(a,o)),!l.length)return;const d=this.initPTS[t.cc],c=d?-d.baseTime/d.timescale:void 0,u={type:e.type,frag:t,part:i,chunkMeta:r,offset:c,parent:t.type,data:l};if(this.hls.trigger(E.BUFFER_APPENDING,u),e.dropped&&e.independent&&!i){if(n)return;this.flushBufferGap(t)}}flushBufferGap(e){const t=this.media;if(!t)return;if(!ie.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}const i=t.currentTime,r=ie.bufferInfo(t,i,0),n=e.duration,a=Math.min(this.config.maxFragLookUpTolerance*2,n*.25),o=Math.max(Math.min(e.start-a,r.end-a),i+a);e.start-o>a&&this.flushMainBuffer(o,e.start)}getFwdBufferInfo(e,t){var i;const r=this.playhead,a=this.lastCurrentTime>r||(i=this.media)!=null&&i.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,r,t,a)}getFwdBufferInfoAtPos(e,t,i,r){const n=ie.bufferInfo(e,t,r);if(n.len===0&&n.nextStart!==void 0){const a=this.fragmentTracker.getBufferedFrag(t,i);if(a&&(n.nextStart<=a.end||a.gap)){const o=Math.max(Math.min(n.nextStart,a.end)-t,r);return ie.bufferInfo(e,t,o)}}return n}getMaxBufferLength(e){const{config:t}=this;let i;return e?i=Math.max(8*t.maxBufferSize/e,t.maxBufferLength):i=t.maxBufferLength,Math.min(i,t.maxMaxBufferLength)}exceedsMaxBuffer(e,t,i){const r=e.nextStart;if(r&&i.start>r){const n=e.buffered;if(n){let a=e.len;const o=e.bufferedIndex;for(let l=n.length-1;l>o;l--)n[l].start<i.start&&(a+=n[l].end-n[l].start);return a>=t}}return!1}reduceMaxBufferLength(e,t){const i=this.config,r=Math.max(Math.min(e-t,i.maxBufferLength),t/2),n=Math.max(e-t*3,i.maxMaxBufferLength/2,r);return n>=r?(i.maxMaxBufferLength=n,this.warn(`Reduce max buffer length to ${n}s`),!0):!1}getAppendedFrag(e){const t=this.fragmentTracker?this.fragmentTracker.getAppendedFrag(e,this.playlistType):null;return t&&"fragment"in t?t.fragment:t}getNextFragment(e,t){const i=t.fragments,r=i.length;if(!r)return null;const{config:n}=this,a=t.fragmentStart,o=n.lowLatencyMode&&!!t.partList;let l=null;if(t.live){const u=n.initialLiveManifestSize;if(r<u)return this.warn(`Not enough fragments to start playback (have: ${r}, need: ${u})`),null;if(!this.startFragRequested&&o&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),!t.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||e<a){var d;l=this.getInitialLiveFragment(t);const h=this.config.startPosition,f=this.hls.startPosition,g=this.hls.liveSyncPosition,m=((d=l)==null?void 0:d.start)||0;let p,v;if(f!==-1&&f>=a?(p=f,v=f===h?"config":"next load start"):g?(p=g,v="live edge"):(p=e,v="buffer pos"),p<m&&(p=m,v="live frag start"),p<a&&(p=a,v="playlist start"),this.startPosition!=p||this.nextLoadPosition!=p){const y=t.live&&!this.filterReplacedPrimary(l,t)?-1:p;this.log(`Setting startPosition to ${y} next load ${p} ${f===-1?"":`(from ${h}) `}based on ${v}. live edge: ${g} live frag start: ${m} playlist start: ${a} buffer pos: ${e}`),this.startPosition=y,this.nextLoadPosition=p}}}else e<=a&&(l=i[0]);if(!l){const u=this.loadingParts?t.partEnd:t.fragmentEnd;l=this.getFragmentAtPosition(e,u,t)}let c=this.filterReplacedPrimary(l,t);return!c&&l&&(c=bh(t,l.sn,this.loadingParts),c&&(this.nextLoadPosition=c.start)),c}isLoopLoading(e,t){if(this.nextLoadPosition<=t)return!1;const i=this.fragmentTracker.getState(e);return!!(i===Ce.OK||i===Ce.PARTIAL&&(e.gap||e.stats.retry>1))}getNextFragmentLoopLoading(e,t,i,r,n){let a=null;if(e.gap&&(a=this.getNextFragment(this.nextLoadPosition,t),a&&!a.gap&&i.nextStart)){const o=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,r,0);if(o!==null&&i.len+o.len>=n){const l=a.sn;return this.loopSn!==l&&(this.log(`buffer full after gaps in "${r}" playlist starting at sn: ${l}`),this.loopSn=l),null}}return this.loopSn=void 0,a}get primaryPrefetch(){if(ko(this.config)){var e;if((e=this.hls.interstitialsManager)==null||(e=e.playingItem)==null?void 0:e.event)return!0}return!1}filterReplacedPrimary(e,t){if(!e)return e;if(ko(this.config)&&("type"in e?e:e.fragment).type!==j.SUBTITLE){const i=this.hls.interstitialsManager,r=i?.bufferingItem;if(r){const n=r.event;if(n){if(!n.appendInPlace&&(Math.abs(e.start-r.start)>1||r.start===0))return null}else if(e.end<=r.start&&t?.live===!1||e.start>=r.end&&r.nextEvent&&(r.nextEvent.appendInPlace&&!r.nextEvent.hasPlayed||e.start-r.end>1))return null}if(Gh(e,i?.playerQueue,this.playhead))return null}return e}getNextPart(e,t,i){let r=-1,n=!1,a=!0;for(let l=0,d=e.length;l<d;l++){const c=e[l];if(a=a&&!c.independent,r>-1&&i<c.start)break;const u=c.loaded||c.gap;u?r=-1:(n||(c.independent||a)&&c.fragment===t)&&(r=l),n=u&&!c.gap}const o=e[r];return o&&o.fragment!==t&&this.log(`Need buffer at ${i} but next unloaded part starts at ${o.start} (sn: ${t.sn} -> ${o.fragment.sn})`),r}loadedEndOfParts(e,t){let i;for(let r=e.length;r--;){if(i=e[r],!i.loaded)return!1;if(t>i.start)return!0}return!1}getInitialLiveFragment(e){const t=e.fragments,i=this.fragPrevious;let r=null;if(i){if(e.hasProgramDateTime&&(r=zp(t,i.endProgramDateTime,this.config.maxFragLookUpTolerance),r&&this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`)),!r){const n=i.sn+1;if(n>=e.startSN&&n<=e.endSN){const a=t[n-e.startSN];i.cc===a.cc&&(r=a,this.log(`Live playlist, switching playlist, load frag with next SN: ${r.sn}`))}r||(r=Ah(e,i.cc,i.end),r&&this.log(`Live playlist, switching playlist, load frag with same CC: ${r.sn}`))}}else{const n=this.hls.liveSyncPosition;n!==null&&(r=this.getFragmentAtPosition(n,this.bitrateTest?e.fragmentEnd:e.edge,e))}return r}getFragmentAtPosition(e,t,i){const{config:r}=this;let{fragPrevious:n}=this,{fragments:a,endSN:o}=i;const{fragmentHint:l}=i,{maxFragLookUpTolerance:d}=r,c=i.partList,u=!!(this.loadingParts&&c!=null&&c.length&&l);u&&!this.bitrateTest&&c[c.length-1].fragment.sn===l.sn&&(a=a.concat(l),o=l.sn),n&&this.fragmentTracker.getState(n)===Ce.NOT_LOADED&&(n=null);let h;if(e<t){var f;const m=e<this.lastCurrentTime||e>t-d||(f=this.media)!=null&&f.paused||!this.startFragRequested?0:d;h=Is(n,a,e,m)}else h=a[a.length-1];if(h){const g=h.sn-i.startSN,m=this.fragmentTracker.getState(h);if((m===Ce.OK||m===Ce.PARTIAL&&h.gap)&&(n=h),Gs(h,n)&&(!u||c[0].fragment.sn>h.sn||!i.live)){const p=a[g+1];h.sn<o&&this.fragmentTracker.getState(p)!==Ce.OK?h=p:h=null}}return h}alignPlaylists(e,t,i){const r=e.fragments.length;if(!r)return this.warn("No fragments in live playlist"),0;const n=e.fragmentStart,a=!t,o=e.alignedSliding&&B(n);if(a||!o&&!n){qn(i,e,this);const l=e.fragmentStart;return this.log(`Live playlist sliding: ${l} start-sn: ${t?t.startSN:"na"}->${e.startSN} fragments: ${r}`),l}return n}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*3)}setStartPosition(e,t){let i=this.startPosition;i<t&&(i=-1);const r=this.timelineOffset;if(i===-1){const n=this.startTimeOffset!==null,a=n?this.startTimeOffset:e.startTimeOffset;if(a!==null&&B(a))i=t+a,a<0&&(i+=e.edge),i=Math.min(Math.max(t,i),t+e.totalduration),this.log(`Setting startPosition to ${i} for start time offset ${a} found in ${n?"multivariant":"media"} playlist`),this.startPosition=i;else if(e.live){const o=this.hls.liveSyncPosition;i=o||t,this.log(`Setting startPosition to -1 to start at ${o?"live edge":"playlist start"} ${i}`),this.startPosition=-1}else this.log("setting startPosition to 0 by default"),this.startPosition=i=0;this.lastCurrentTime=i+r}this.nextLoadPosition=i+r}getLoadPosition(){var e;const{media:t}=this;let i=0;return(e=this.hls)!=null&&e.hasEnoughToStart&&t&&!this.iframesOnly?i=t.currentTime:this.nextLoadPosition>=0&&(i=this.nextLoadPosition),i}get playhead(){var e;if((e=this.hls)!=null&&e.hasEnoughToStart){var t;const i=(t=this.media)==null?void 0:t.currentTime;return B(i)?i:this.lastCurrentTime}return this.getLoadPosition()}get iframesOnly(){var e;if(this.playlistType!==j.MAIN)return!1;const t=this.getLevelDetails();return t?t.iframesOnly:(e=this.levelLastLoaded)==null?void 0:e.iframes}handleFragLoadAborted(e,t){this.transmuxer&&e.type===this.playlistType&&Ue(e)&&e.stats.aborted&&(this.log(`Fragment ${e.sn}${t?" part "+t.index:""} of ${this.playlistLabel()} ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){(!this.fragCurrent||!this.fragContextChanged(e)&&this.state!==C.FRAG_LOADING_WAITING_RETRY)&&(this.state=C.IDLE)}onFragmentOrKeyLoadError(e,t){if(t.chunkMeta&&!t.frag){const T=this.getCurrentContext(t.chunkMeta);T&&(t.frag=T.frag)}const{frag:i,part:r}=t;if(!i||!this.levels||i.type!==e)return;if(this.fragContextChanged(i)){var n;this.warn(`Frag load error must match current frag to retry ${i.relurl} > ${(n=this.fragCurrent)==null?void 0:n.relurl}`);return}const a=t.details===x.FRAG_GAP;a&&this.fragmentTracker.addAsGap(i);const o=t.errorAction;if(!o){this.state=C.ERROR;return}const{action:l,flags:d,retryCount:c=0,retryConfig:u}
vendor: 4,872 bytes, line 58
58=o,h=!!u,f=h&&l===ot.RetryRequest,g=h&&!o.resolved&&d&Je.MoveAllAlternatesMatchingHost,m=this.hls.latestLevelDetails,p=m?.live;if(!f&&g&&Ue(i)&&p&&i.sn<m.endSN&&!Yu(t))this.resetFragmentErrors(e),r?r.gap=!0:this.treatAsGap(i),o.resolved=!0;else if((f||g)&&c<u.maxNumRetry){var v;const T=dr((v=t.response)==null?void 0:v.code),y=vl(u,c);if(this.resetStartWhenNotLoaded(),this.retryDate=self.performance.now()+y,this.state=C.FRAG_LOADING_WAITING_RETRY,o.resolved=!0,T){this.log("Waiting for connection (offline)"),this.retryDate=1/0,t.reason="offline";return}this.warn(`Fragment ${i.sn} of ${e} ${i.level} errored with ${t.details}, retrying loading ${c+1}/${u.maxNumRetry} in ${y}ms`)}else if(u)if(this.resetFragmentErrors(e),c<u.maxNumRetry)!a&&l!==ot.RemoveAlternatePermanently&&(o.resolved=!0);else{this.warn(`${t.details} reached or exceeded max retry (${c})`);return}else l===ot.SendAlternateToPenaltyBox?this.state=C.WAITING_LEVEL:this.state=C.ERROR;this.tickImmediate()}checkRetryDate(){const e=self.performance.now(),t=this.retryDate,i=t===1/0;(!t||e>=t||i&&!dr(0))&&(i&&this.log("Connection restored (online)"),this.resetStartWhenNotLoaded(),this.state=C.IDLE)}reduceLengthAndFlushBuffer(e){if(this.state===C.PARSING||this.state===C.PARSED){const t=e.frag,i=e.parent,r=this.getFwdBufferInfo(this.mediaBuffer,i),n=r&&r.len>.5;n&&this.reduceMaxBufferLength(r.len,t?.duration||10);const a=!n;return a?this.warn(`Buffer full error while media.currentTime (${this.playhead}) is not buffered, flush ${i} buffer`):r.nextStart&&t&&r.nextStart>t.start&&this.flushMainBuffer(r.nextStart,Number.POSITIVE_INFINITY,i===j.AUDIO?i:void 0),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),a}return!1}resetFragmentErrors(e){e===j.AUDIO&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==C.STOPPED&&(this.state=C.IDLE)}afterBufferFlushed(e,t){if(!e)return;const i=ie.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,i,this.playlistType),this.state===C.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==C.STOPPED&&(this.state=C.IDLE)}resetStartWhenNotLoaded(){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;const e=this.getLevelDetails();e!=null&&e.live?(this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(e,e.fragmentStart),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){this.log(`Loading context changed while buffering sn ${e.sn} of ${this.playlistLabel()} ${e.level===-1?"<removed>":e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,i,r){const n=i.details;if(!n){this.warn("level.details undefined");return}if(this.log(`update level timing ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)}`),!Object.keys(e.elementaryStreams).reduce((u,h)=>{const f=e.elementaryStreams[h];if(f){const g=f.endPTS-f.startPTS;if(g<=0)return this.warn(`Could not parse fragment ${e.sn} ${h} duration reliably (${g})`),u||!1;const m=r.partial?0:Mh(n,e,f.startPTS,f.endPTS,f.startDTS,f.endDTS,this.iframesOnly,this);return this.hls.trigger(E.LEVEL_PTS_UPDATED,{details:n,level:i,drift:m,type:h,frag:e,start:f.startPTS,end:f.endPTS}),!0}return u},!1)){var o,l,d,c;const u=((o=this.transmuxer)==null?void 0:o.error)===null,h=((l=this.transmuxer)==null?void 0:l.error)!=null,f=((d=(c=this.levels)==null?void 0:c.length)!=null?d:0)>1;if((i.fragmentError===0||u&&(i.fragmentError<2||e.endList)||h&&f)&&this.treatAsGap(e,i),u){const g=new Error(`Found no media in ${this.playlistLabel()} ${e.level} ${t?`part: ${t.index} of `:""}sn: ${e.sn} at playlist time: ${e.start}. Resetting transmuxer to fallback to playlist timing`);if(this.warn(g.message),this.hls.trigger(E.ERROR,{type:X.MEDIA_ERROR,details:x.FRAG_PARSING_ERROR,fatal:!1,error:g,frag:e,reason:`Found no media in msn ${e.sn} of ${this.playlistLabel()} "${i.url}"`}),!this.hls)return;this.resetTransmuxer()}}this.state=C.PARSED,this.log(`Parsed ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)}`),this.hls.trigger(E.FRAG_PARSED,{frag:e,part:t,chunkMeta:r})}playlistLabel(){return`${this.playlistType} playlist`}fragInfo(e,t=!0,i){var r,n;return`${this.playlistLabel()} ${e.level} (${i?"part":"frag"}:[${(r=t&&!i?e.startPTS:(i||e).start)!=null?r:NaN}-${(n=t&&!i?e.endPTS:(i||e).end)!=null?n:NaN}]${i&&e.type==="main"?"INDEPENDENT="+(i.independent?"YES":"NO"):""})`}treatAsGap(e,t){t&&t.fragmentError++,this.fragmentTracker.addAsGap(e)}resetTransmuxer(){var e;(e=this.transmuxer)==null||e.reset()}
vendor: 73,852 bytes, line 58
58isFragmentNearlyDownloaded(e){var t;const i=(t=e.loader)==null?void 0:t.stats;if(!i)return!1;const r=i.loading.first>0,a=(i.total-i.loaded)/(this.hls.bandwidthEstimate||this.hls.config.abrEwmaDefaultEstimate);return r&&a<=.15}recoverWorkerError(e){e.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),this.resetStartWhenNotLoaded(),this.resetLoadingState())}set state(e){const t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}calculateOptimalSwitchPoint(e,t){let i=0;const{hls:r,media:n,config:a,levels:o,playlistType:l}=this,d=this.getLevelDetails();if(n&&!n.paused&&o){var c;const f=l===j.AUDIO?Eh(e.audioCodec,128e3):e.maxBitrate,g=1+r.ttfbEstimate/1e3,m=r.bandwidthEstimate*a.abrBandWidthUpFactor,p=d&&(this.loadingParts?d.partTarget:d.averagetargetduration)||((c=this.fragCurrent)==null?void 0:c.duration)||6;i=g+f*p/m,e.details||(i+=g)}const u=this.playhead,h=!(d!=null&&d.live)||t.end-u>i*1.5;return{fetchdelay:i,okToFlushForwardBuffer:h}}scheduleTrackSwitch(e,t,i){const{media:r,playlistType:n}=this;if(!r||!e)return;const a=i?this.getBufferedFrag(this.playhead+t):null;if(a){const l=this.followingBufferedFrag(a);if(l){var o;this.abortCurrentFrag();const d=l.maxStartPTS?l.maxStartPTS:l.start,c=l.duration,u=Math.max(a.end,d+Math.min(Math.max(c-this.config.maxFragLookUpTolerance,c*(this.couldBacktrack?.5:.125)),c*(this.couldBacktrack?.75:.25)));if((((o=this.getLevelDetails())==null?void 0:o.fragmentStart)||0)>u)return;const f=n===j.MAIN?null:"audio";this.flushMainBuffer(u,Number.POSITIVE_INFINITY,f),this.cleanupBackBuffer()}}}cleanupBackBuffer(){const{media:e,playlistType:t}=this;if(!e)return;const i=this.getAppendedFrag(this.playhead);if(i&&i.start>1){const r=t===j.AUDIO;this.flushMainBuffer(0,i.start-(r?0:1),r?"audio":null)}}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,this.playlistType)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}abortCurrentFrag(){const e=this.fragCurrent;switch(this.fragCurrent=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case C.KEY_LOADING:case C.FRAG_LOADING:case C.FRAG_LOADING_WAITING_RETRY:case C.PARSING:case C.PARSED:this.state=C.IDLE;break}this.nextLoadPosition=this.playhead}checkFragPlaying(){const e=this.media;let t=null;if(e&&e.readyState>1&&e.seeking===!1){const i=e.currentTime;if(ie.isBuffered(e,i)?t=this.getAppendedFrag(i):ie.isBuffered(e,i+.1)&&(t=this.getAppendedFrag(i+.1)),t&&(this.backtrackFragment=void 0,!Gs(t,this.fragPlaying)))return this.fragPlaying=t,!0}return!1}getBufferOutput(){return null}nextLevelSwitch(){const{levels:e,media:t,hls:i,config:r,playlistType:n}=this;if(t!=null&&t.readyState&&e&&i&&r){const a=this.getBufferOutput(),o=this.getFwdBufferInfo(a,n);if(!o)return;const l=n===j.AUDIO?i.nextAudioTrack:i.nextLoadLevel,d=e[l],{fetchdelay:c,okToFlushForwardBuffer:u}=this.calculateOptimalSwitchPoint(d,o);this.scheduleTrackSwitch(o,c,u)}this.tickImmediate()}}function Gh(s,e,t){if(e)for(let i=e.length;i--;){const r=e[i].interstitial,n=r.startTime,a=Math.min(n+r.duration,r.resumeTime);if(r.appendInPlace&&(s.start>=n&&s.end<=a||t>s.start&&s.end>n&&s.start<a))return!0}return!1}function ko(s){return!!s.interstitialsController&&s.enableInterstitialPlayback!==!1}class Vh{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){const{chunks:e,dataLength:t}=this;let i;if(e.length)e.length===1?i=e[0]:i=w0(e,t);else return new Uint8Array(0);return this.reset(),i}reset(){this.chunks.length=0,this.dataLength=0}}function w0(s,e){const t=new Uint8Array(e);let i=0;for(let r=0;r<s.length;r++){const n=s[r];t.set(n,i),i+=n.length}return t}var Na={exports:{}},pc;function M0(){return pc||(pc=1,function(s){var e=Object.prototype.hasOwnProperty,t="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(t=!1));function r(l,d,c){this.fn=l,this.context=d,this.once=c||!1}function n(l,d,c,u,h){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new r(c,u||l,h),g=t?t+d:d;return l._events[g]?l._events[g].fn?l._events[g]=[l._events[g],f]:l._events[g].push(f):(l._events[g]=f,l._eventsCount++),l}function a(l,d){--l._eventsCount===0?l._events=new i:delete l._events[d]}function o(){this._events=new i,this._eventsCount=0}o.prototype.eventNames=function(){var d=[],c,u;if(this._eventsCount===0)return d;for(u in c=this._events)e.call(c,u)&&d.push(t?u.slice(1):u);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(c)):d},o.prototype.listeners=function(d){var c=t?t+d:d,u=this._events[c];if(!u)return[];if(u.fn)return[u.fn];for(var h=0,f=u.length,g=new Array(f);h<f;h++)g[h]=u[h].fn;return g},o.prototype.listenerCount=function(d){var c=t?t+d:d,u=this._events[c];return u?u.fn?1:u.length:0},o.prototype.emit=function(d,c,u,h,f,g){var m=t?t+d:d;if(!this._events[m])return!1;var p=this._events[m],v=arguments.length,T,y;if(p.fn){switch(p.once&&this.removeListener(d,p.fn,void 0,!0),v){case 1:return p.fn.call(p.context),!0;case 2:return p.fn.call(p.context,c),!0;case 3:return p.fn.call(p.context,c,u),!0;case 4:return p.fn.call(p.context,c,u,h),!0;case 5:return p.fn.call(p.context,c,u,h,f),!0;case 6:return p.fn.call(p.context,c,u,h,f,g),!0}for(y=1,T=new Array(v-1);y<v;y++)T[y-1]=arguments[y];p.fn.apply(p.context,T)}else{var S=p.length,A;for(y=0;y<S;y++)switch(p[y].once&&this.removeListener(d,p[y].fn,void 0,!0),v){case 1:p[y].fn.call(p[y].context);break;case 2:p[y].fn.call(p[y].context,c);break;case 3:p[y].fn.call(p[y].context,c,u);break;case 4:p[y].fn.call(p[y].context,c,u,h);break;default:if(!T)for(A=1,T=new Array(v-1);A<v;A++)T[A-1]=arguments[A];p[y].fn.apply(p[y].context,T)}}return!0},o.prototype.on=function(d,c,u){return n(this,d,c,u,!1)},o.prototype.once=function(d,c,u){return n(this,d,c,u,!0)},o.prototype.removeListener=function(d,c,u,h){var f=t?t+d:d;if(!this._events[f])return this;if(!c)return a(this,f),this;var g=this._events[f];if(g.fn)g.fn===c&&(!h||g.once)&&(!u||g.context===u)&&a(this,f);else{for(var m=0,p=[],v=g.length;m<v;m++)(g[m].fn!==c||h&&!g[m].once||u&&g[m].context!==u)&&p.push(g[m]);p.length?this._events[f]=p.length===1?p[0]:p:a(this,f)}return this},o.prototype.removeAllListeners=function(d){var c;return d?(c=t?t+d:d,this._events[c]&&a(this,c)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=t,o.EventEmitter=o,s.exports=o}(Na)),Na.exports}var O0=M0(),kl=_m(O0);const pr="1.7.0-rc.3",_s={};function F0(){return typeof __HLS_WORKER_BUNDLE__=="function"}function N0(){const s=_s[pr];if(s)return s.clientCount++,s;const e=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),t=self.URL.createObjectURL(e),r={worker:new self.Worker(t),objectURL:t,clientCount:1};return _s[pr]=r,r}function U0(s){const e=_s[s];if(e)return e.clientCount++,e;const t=new self.URL(s,self.location.href).href,r={worker:new self.Worker(t),scriptURL:t,clientCount:1};return _s[s]=r,r}function $0(s){const e=_s[s||pr];if(e&&e.clientCount--===1){const{worker:i,objectURL:r}=e;delete _s[s||pr],r&&self.URL.revokeObjectURL(r),i.terminate()}}function B0(s,e,t,i){const r=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],n=e[t+2],a=n>>2&15;if(a>12){const p=new Error(`invalid ADTS sampling index:${a}`);s.emit(E.ERROR,E.ERROR,{type:X.MEDIA_ERROR,details:x.FRAG_PARSING_ERROR,fatal:!0,error:p,reason:p.message});return}const o=(n>>6&3)+1,l=e[t+3]>>6&3|(n&1)<<2,d=r[a];let c=a;(o===5||o===29)&&(c-=3);let u;const h=(c&14)>>1,f=(c&1)<<7|l<<3;let g=0;if(o===1&&a>=6){g=5;const p=a-3;u=[g<<3|h,f|(p&14)>>1,(p&1)<<7|8,0]}else u=[o<<3|h,f];const m="mp4a.40."+(g||o);return Te.log(`manifest codec:${i}, parsed codec:${m}, channels:${l}, rate:${d} (ADTS object type:${o} sampling index:${a} esds config:[${u.join(",")}])`),{config:u,samplerate:d,channelCount:l,codec:m,parsedCodec:m,manifestCodec:i}}function Hh(s,e){return s[e]===255&&(s[e+1]&246)===240}function Kh(s,e){return s[e+1]&1?7:9}function Cl(s,e){return(s[e+3]&3)<<11|s[e+4]<<3|(s[e+5]&224)>>>5}function G0(s,e){return e+5<s.length}function zn(s,e){return e+1<s.length&&Hh(s,e)}function V0(s,e){return G0(s,e)&&Hh(s,e)&&Cl(s,e)<=s.length-e}function H0(s,e){if(zn(s,e)){const t=Kh(s,e);if(e+t>=s.length)return!1;const i=Cl(s,e);if(i<=t)return!1;const r=e+i;return r===s.length||zn(s,r)}return!1}function Wh(s,e,t,i,r){if(!s.samplerate){const n=B0(e,t,i,r);if(!n)return;Ie(s,n)}}function Yh(s){return 1024*9e4/s}function K0(s,e){const t=Kh(s,e);if(e+t<=s.length){const i=Cl(s,e)-t;if(i>0)return{headerLength:t,frameLength:i}}}function qh(s,e,t,i,r){const n=Yh(s.samplerate),a=i+r*n,o=K0(e,t);let l;if(o){const{frameLength:u,headerLength:h}=o,f=h+u,g=Math.max(0,t+f-e.length);g?(l=new Uint8Array(f-h),l.set(e.subarray(t+h,e.length),0)):l=e.subarray(t+h,t+f);const m={unit:l,pts:a};return g||s.samples.push(m),{sample:m,length:f,missing:g}}const 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}}let mt=function(s){return s.audioId3="org.id3",s.dateRange="com.apple.quicktime.HLS",s.emsg="https://aomedia.org/emsg/ID3",s.misbklv="urn:misb:KLV:bin:1910.1",s}({});function ri(s="",e=9e4){return{type:s,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}class Pl{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,i,r){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,i){}demux(e,t){this.cachedData&&(e=Pt(this.cachedData,e),this.cachedData=null);let i=cr(e,0),r=i?i.length:0,n;const a=this._audioTrack,o=this._id3Track,l=i?Tl(i):void 0,d=e.length;for((this.basePTS===null||this.frameIndex===0&&B(l))&&(this.basePTS=W0(l,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),i&&i.length>0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:mt.audioId3,duration:Number.POSITIVE_INFINITY});r<d;){if(this.canParse(e,r)){const c=this.appendFrame(a,e,r);c?(this.frameIndex++,this.lastPTS=c.sample.pts,r+=c.length,n=r):r=d}else Km(e,r)?(i=cr(e,r),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:mt.audioId3,duration:Number.POSITIVE_INFINITY}),r+=i.length,n=r):r++;if(r===d&&n!==d){const c=e.slice(n);this.cachedData?this.cachedData=Pt(this.cachedData,c):this.cachedData=c}}return{audioTrack:a,videoTrack:ri(),id3Track:o,textTrack:ri()}}demuxSampleAes(e,t,i){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){const t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:ri(),id3Track:this._id3Track,textTrack:ri()}}destroy(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}}const W0=(s,e,t)=>{if(B(s))return s*90;const i=t?t.baseTime*9e4/t.timescale:0;return e*9e4+i},Y0=[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],q0=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],j0=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],z0=[0,1,1,4];function jh(s,e,t,i,r){if(t+24>e.length)return;const n=zh(e,t);if(n&&t+n.frameLength<=e.length){const a=n.samplesPerFrame*9e4/n.sampleRate,o=i+r*a,l={unit:e.subarray(t,t+n.frameLength),pts:o,dts:o};return s.config=[],s.channelCount=n.channelCount,s.samplerate=n.sampleRate,s.samples.push(l),{sample:l,length:n.frameLength,missing:0}}}function zh(s,e){const t=s[e+1]>>3&3,i=s[e+1]>>1&3,r=s[e+2]>>4&15,n=s[e+2]>>2&3;if(t!==1&&r!==0&&r!==15&&n!==3){const a=s[e+2]>>1&1,o=s[e+3]>>6,l=t===3?3-i:i===3?3:4,d=Y0[l*14+r-1]*1e3,u=q0[(t===3?0:t===2?1:2)*3+n],h=o===3?1:2,f=j0[t][i],g=z0[i],m=f*8*g,p=Math.floor(f*d/u+a)*g,v=Js();return!!v&&v<=87&&i===2&&d>=224e3&&o===0&&(s[e+3]=s[e+3]|128),{sampleRate:u,channelCount:h,frameLength:p,samplesPerFrame:m}}}function wl(s,e){return s[e]===255&&(s[e+1]&224)===224&&(s[e+1]&6)!==0}function Qh(s,e){return e+1<s.length&&wl(s,e)}function Q0(s,e){return wl(s,e)&&4<=s.length-e}function Xh(s,e){if(e+1<s.length&&wl(s,e)){const i=zh(s,e);let r=4;i!=null&&i.frameLength&&(r=i.frameLength);const n=e+r;return n===s.length||Qh(s,n)}return!1}class Zh{constructor(e,t,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new Il(t,!0)}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,Ci.cbc,{start:0,end:e.byteLength})}decryptAacSample(e,t,i){const r=e[t].unit;if(r.length<=16)return;const n=r.subarray(16,r.length-r.length%16),a=n.buffer.slice(n.byteOffset,n.byteOffset+n.length);this.decryptBuffer(a).then(o=>{const l=new Uint8Array(o);r.set(l,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,i)}).catch(i)}decryptAacSamples(e,t,i){for(;;t++){if(t>=e.length){i();return}if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,i),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){const t=Math.floor((e.length-48)/160)*16+16,i=new Int8Array(t);let r=0;for(let n=32;n<e.length-16;n+=160,r+=16)i.set(e.subarray(n,n+16),r);return i}getAvcDecryptedUnit(e,t){const i=new Uint8Array(t);let r=0;for(let n=32;n<e.length-16;n+=160,r+=16)e.set(i.subarray(r,r+16),n);return e}decryptAvcSample(e,t,i,r,n){const a=ch(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,i+1,r)}).catch(r)}decryptAvcSamples(e,t,i,r){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,i=0){if(t>=e.length){r();return}const n=e[t].units;for(;!(i>=n.length);i++){const a=n[i];if(!(a.data.length<=48||a.type!==1&&a.type!==5)&&(this.decryptAvcSample(e,t,i,r,a),!this.decrypter.isSync()))return}}}}class X0 extends Pl{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.sampleAes=null,this.observer=e,this.config=t}resetInitSegment(e,t,i,r){super.resetInitSegment(e,t,i,r),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:r,inputTimeScale:9e4,dropped:0}}static probe(e,t){if(!e)return!1;const i=cr(e,0);let r=i?.length||0;if(Xh(e,r))return!1;for(let n=e.length;r<n;r++)if(H0(e,r))return t.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return V0(e,t)}appendFrame(e,t,i){Wh(e,this.observer,t,i,e.manifestCodec);const r=qh(e,t,i,this.basePTS,this.frameIndex);if(r?.missing===0)return r}demuxSampleAes(e,t,i){const r=this.demux(e,i),n=this.sampleAes=new Zh(this.observer,this.config,t);return new Promise(a=>{n.decryptAacSamples(r.audioTrack.samples,0,()=>{a(r)})})}}const Jh=(s,e)=>{let t=0,i=5;e+=i;const r=new Uint32Array(1),n=new Uint32Array(1),a=new Uint8Array(1);for(;i>0;){a[0]=s[e];const o=Math.min(i,8),l=8-o;n[0]=4278190080>>>24+l<<l,r[0]=(a[0]&n[0])>>l,t=t?t<<o|r[0]:r[0],e+=1,i-=o}return t};class Z0 extends Pl{constructor(e){super(),this.observer=void 0,this.observer=e}resetInitSegment(e,t,i,r){super.resetInitSegment(e,t,i,r),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:r,inputTimeScale:9e4,dropped:0}}canParse(e,t){return t+64<e.length}appendFrame(e,t,i){const r=ef(e,t,i,this.basePTS,this.frameIndex);if(r!==-1)return{sample:e.samples[e.samples.length-1],length:r,missing:0}}static probe(e){if(!e)return!1;const t=cr(e,0);if(!t)return!1;const i=t.length;if(e[i]===11&&e[i+1]===119&&Tl(t)!==void 0){if(Jh(e,i)<16)return!0;throw new Error("Containerless ec-3 is not supported")}return!1}}function ef(s,e,t,i,r){if(t+8>e.length||e[t]!==11||e[t+1]!==119)return-1;const n=e[t+4]>>6;if(n>=3)return-1;const o=[48e3,44100,32e3][n],l=e[t+4]&63,c=[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+c>e.length)return-1;const u=e[t+6]>>5;let h=0;u===2?h+=2:(u&1&&u!==1&&(h+=2),u&4&&(h+=2));const f=(e[t+6]<<8|e[t+7])>>12-h&1,m=[2,1,2,3,3,4,4,5][u]+f,p=e[t+5]>>3,v=e[t+5]&7,T=new Uint8Array([n<<6|p<<1|v>>2,(v&3)<<6|u<<3|f<<2|l>>4,l<<4&224]),y=1536/o*9e4,S=i+r*y,A=e.subarray(t,t+c);return s.config=T,s.channelCount=m,s.samplerate=o,s.samples.push({unit:A,pts:S}),c}class J0 extends Pl{resetInitSegment(e,t,i,r){super.resetInitSegment(e,t,i,r),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:r,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;const t=cr(e,0);let i=t?.length||0;if(t&&e[i]===11&&e[i+1]===119&&Tl(t)!==void 0&&Jh(e,i)<=16)return!1;for(let r=e.length;i<r;i++)if(Xh(e,i))return Te.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return Q0(e,t)}appendFrame(e,t,i){if(this.basePTS!==null)return jh(e,t,i,this.basePTS,this.frameIndex)}}const eE=/\/emsg[-/]ID3/i;class tE{constructor(e,t,i,r=Te){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.initData=void 0,this.logger=void 0,this.config=t,this.logger=r}resetTimeStamp(){}resetInitSegment(e,t,i,r){const n=this.videoTrack=ri("video",1),a=this.audioTrack=ri("audio",1),o=this.txtTrack=ri("text",1);if(this.id3Track=ri("id3",1),this.initData=void 0,this.timeOffset=0,!(e!=null&&e.byteLength))return;const l=this.initData=nh(e);if(l.video){const{id:d,timescale:c,codec:u,supplemental:h}=l.video;n.id=d,n.timescale=o.timescale=c,n.codec=u,n.supplemental=h}if(l.audio){const{id:d,timescale:c,codec:u}=l.audio;a.id=d,a.timescale=c,a.codec=u}o.id=th.text,n.sampleDuration=0,n.duration=a.duration=r}resetContiguity(){this.remainderData=null}static probe(e){return np(e,"moof")}demux(e,t,i){this.timeOffset=t;let r=e;const n=this.videoTrack,a=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=Pt(this.remainderData,e));const d=mp(r);this.remainderData=d.remainder,n.samples=d.valid||new Uint8Array}else n.samples=r;const o=this.extractID3Track(n,t),l=this.parseFragment(n,a,t,i);return{videoTrack:n,audioTrack:this.audioTrack,id3Track:o,textTrack:this.txtTrack,initData:this.initData,sampleData:l}}flush(e,t){const i=this.timeOffset,r=this.videoTrack,n=this.txtTrack;r.samples=this.remainderData||new Uint8Array,this.remainderData=null;const a=this.extractID3Track(r,this.timeOffset),o=this.parseFragment(r,n,i,t);return{videoTrack:r,audioTrack:ri(),id3Track:a,textTrack:ri(),initData:this.initData,sampleData:o}}parseFragment(e,t,i,r){const n=this.initData;if(n&&r){const{samples:a,sampleData:o}=gp(i,e,n,this.logger,r.iframe);return t.samples=a,o}t.samples=pp(i,e)}extractID3Track(e,t){const i=this.id3Track;if(e.samples.length){const r=oe(e.samples,["emsg"]);r&&r.forEach(n=>{const a=Ep(n);if(eE.test(a.schemeIdUri)){const o=Ec(a,t);let l=a.eventDuration===4294967295?Number.POSITIVE_INFINITY:a.eventDuration/a.timeScale;l<=.001&&(l=Number.POSITIVE_INFINITY);const d=a.payload;i.samples.push({data:d,len:d.byteLength,dts:o,pts:o,type:mt.emsg,duration:l})}else if(this.config.enableEmsgKLVMetadata){const o=this.config.emsgKLVSchemaUri||mt.misbklv;if(a.schemeIdUri.startsWith(o)){const l=Ec(a,t);i.samples.push({data:a.payload,len:a.payload.byteLength,dts:l,pts:l,type:mt.misbklv,duration:Number.POSITIVE_INFINITY})}}})}return i}demuxSampleAes(e,t,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0,this.initData=void 0}}function Ec(s,e){return B(s.presentationTime)?s.presentationTime/s.timeScale:e+s.presentationTimeDelta/s.timeScale}const iE=1,sE=2,Ms=-1;class tf{constructor(){this.VideoSample=null}createVideoSample(e,t,i){return{key:e,frame:!1,pts:t,dts:i,units:[],length:0}}getLastNalUnit(e){var t;let i=this.VideoSample,r;if((!i||i.units.length===0)&&(i=e[e.length-1]),(t=i)!=null&&t.units){const n=i.units;r=n[n.length-1]}return r}pushAccessUnit(e,t){if(e.units.length&&e.frame){if(e.pts===void 0){const i=t.samples,r=i.length;if(r){const n=i[r-1];e.pts=n.pts,e.dts=n.dts}else{t.dropped++;return}}t.samples.push(e)}}parseNALu(e,t,i){const r=t.byteLength;if(r===0)return[];const n=e.naluState||0,a=n===Ms?0:n,o=[];let l=0,d=0,c=-1,u=0;for(n===Ms&&(c=0,u=this.getNALuType(t,0),d=1);d<r;){const h=t.indexOf(iE,d);if(h===-1)break;d=h+1;let f=h;for(;f>0&&t[f-1]===0;)f--;if(!(h-f+(f===0?a:0)<sE)){if(c>=0)o.push({data:t.subarray(c,f),type:u});else{const m=this.getLastNalUnit(e.samples);m&&(f>0?m.data=Pt(m.data,t.subarray(0,f)):a>0&&(m.data=m.data.subarray(0,m.data.byteLength-a)),m.state=0)}if(d<r)c=d,u=this.getNALuType(t,d);else{l=Ms,c=-1;break}}}if(l!==Ms){let h=r;for(;h>0&&t[h-1]===0;)h--;l=r-h+(h===0?a:0)}if(c>=0)o.push({data:t.subarray(c),type:u,state:l});else if(o.length===0&&l!==Ms){const h=this.getLastNalUnit(e.samples);h&&(h.data=Pt(h.data,t),h.state=l)}return e.naluState=l,o}}class ir{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(){const e=this.data,t=this.bytesAvailable,i=e.byteLength-t,r=new Uint8Array(4),n=Math.min(4,t);if(n===0)throw new Error("no bytes available");r.set(e.subarray(i,i+n)),this.word=new DataView(r.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);const i=this.word>>>32-t;if(e>32&&Te.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?i<<t|this.readBits(t):i}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if((this.word&2147483648>>>e)!==0)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(){const e=this.skipLZ();return this.readBits(e+1)-1}readEG(){const e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return this.readBits(1)===1}readUByte(){return this.readBits(8)}}class rE extends tf{parsePES(e,t,i,r,n){const a=n.iframe,o=this.parseNALu(e,i.data,r);let l=this.VideoSample,d,c=!1;i.data=null,l&&o.length&&!e.audFound&&(this.pushAccessUnit(l,e),l=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),o.forEach(u=>{var h,f;switch(u.type){case 1:{if(a)break;let v=!1;d=!0;const T=u.data;if(c&&T.length>4){const y=this.readSliceType(T);(y===2||y===4||y===7||y===9)&&(v=!0)}if(v){var g;(g=l)!=null&&g.frame&&!l.key&&(this.pushAccessUnit(l,e),l=this.VideoSample=null)}l||(l=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),l.frame=!0,l.key=v;break}case 5:d=!0,(h=l)!=null&&h.frame&&!l.key&&(this.pushAccessUnit(l,e),l=this.VideoSample=null),l||(l=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),l.key=!0,l.frame=!0;break;case 6:{if(a)break;d=!0,ur(u.data,1,i.pts,t.samples);break}case 7:{var m,p;d=!0,c=!0;const v=u.data,T=this.readSPS(v);if(!e.sps||e.width!==T.width||e.height!==T.height||((m=e.pixelRatio)==null?void 0:m[0])!==T.pixelRatio[0]||((p=e.pixelRatio)==null?void 0:p[1])!==T.pixelRatio[1]){e.width=T.width,e.height=T.height,e.pixelRatio=T.pixelRatio,e.sps=[v];const y=v.subarray(1,4);let S="avc1.";for(let A=0;A<3;A++){let I=y[A].toString(16);I.length<2&&(I="0"+I),S+=I}e.codec=S}break}case 8:d=!0,e.pps=[u.data];break;case 9:d=!0,e.audFound=!0,(f=l)!=null&&f.frame&&(this.pushAccessUnit(l,e),l=null),l||(l=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts));break;case 12:d=!0;break;default:d=!1;break}l&&d&&l.units.push(u)}),r&&l&&(this.pushAccessUnit(l,e),this.VideoSample=null)}getNALuType(e,t){return e[t]&31}readSliceType(e){const t=new ir(e);return t.readUByte(),t.readUEG(),t.readUEG()}skipScalingList(e,t){let i=8,r=8,n;for(let a=0;a<e;a++)r!==0&&(n=t.readEG(),r=(i+n+256)%256),i=r===0?i:r}readSPS(e){const t=new ir(e);let i=0,r=0,n=0,a=0,o,l,d;const c=t.readUByte.bind(t),u=t.readBits.bind(t),h=t.readUEG.bind(t),f=t.readBoolean.bind(t),g=t.skipBits.bind(t),m=t.skipEG.bind(t),p=t.skipUEG.bind(t),v=this.skipScalingList.bind(this);c();const T=c();if(u(5),g(3),c(),p(),T===100||T===110||T===122||T===244||T===44||T===83||T===86||T===118||T===128){const R=h();if(R===3&&g(1),p(),p(),g(1),f())for(l=R!==3?8:12,d=0;d<l;d++)f()&&(d<6?v(16,t):v(64,t))}p();const y=h();if(y===0)h();else if(y===1)for(g(1),m(),m(),o=h(),d=0;d<o;d++)m();p(),g(1);const S=h(),A=h(),I=u(1);I===0&&g(1),g(1),f()&&(i=h(),r=h(),n=h(),a=h());let _=[1,1];if(f()&&f())switch(c()){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:{_=[c()<<8|c(),c()<<8|c()];break}}return{width:Math.ceil((S+1)*16-i*2-r*2),height:(2-I)*(A+1)*16-(I?2:4)*(n+a),pixelRatio:_}}}class nE extends tf{constructor(...e){super(...e),this.initVPS=null}parsePES(e,t,i,r){const n=this.parseNALu(e,i.data,r);let a=this.VideoSample,o,l=!1;i.data=null;const d=c=>(a=this.VideoSample=this.createVideoSample(c,i.pts,i.dts),a);n.forEach((c,u)=>{var h,f;if(this.startsNewAccessUnit(a,e,c,u)){this.pushAccessUnit(a,e);const m=c.type>=16&&c.type<=23;a=d(m),l=!1}switch(c.type){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:a||(a=d(!1)),a.frame=!0,o=!0;break;case 16:case 17:case 18:case 21:case 22:case 23:if(o=!0,l){var g;(g=a)!=null&&g.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null)}a||(a=d(!0)),a.key=!0,a.frame=!0;break;case 19:case 20:o=!0,(h=a)!=null&&h.frame&&!a.key&&(this.pushAccessUnit(a,e),a=this.VideoSample=null),a||(a=d(!0)),a.key=!0,a.frame=!0;break;case 39:o=!0,ur(c.data,2,i.pts,t.samples);break;case 32:o=!0,e.vps||(typeof e.params!="object"&&(e.params={}),e.params=Ie(e.params,this.readVPS(c.data)),this.initVPS=c.data),e.vps=[c.data];break;case 33:if(o=!0,l=!0,e.vps!==void 0&&e.vps[0]!==this.initVPS&&e.sps!==void 0&&!this.matchSPS(e.sps[0],c.data)&&(this.initVPS=e.vps[0],e.sps=e.pps=void 0),!e.sps){const m=this.readSPS(c.data);e.width=m.width,e.height=m.height,e.pixelRatio=m.pixelRatio,e.codec=m.codecString,e.sps=[],typeof e.params!="object"&&(e.params={});for(const p in m.params)e.params[p]=m.params[p]}this.pushParameterSet(e.sps,c.data,e.vps),a||(a=d(!1));break;case 34:if(o=!0,typeof e.params=="object"){if(!e.pps){e.pps=[];const m=this.readPPS(c.data);for(const p in m)e.params[p]=m[p]}this.pushParameterSet(e.pps,c.data,e.vps)}break;case 35:o=!0,e.audFound=!0,(f=a)!=null&&f.frame&&(this.pushAccessUnit(a,e),a=null),a||(a=d(!1));break;default:o=!1;break}a&&o&&a.units.push(c)}),r&&a&&(this.pushAccessUnit(a,e),this.VideoSample=null)}pushParameterSet(e,t,i){(i&&i[0]===this.initVPS||!i&&!e.length)&&e.push(t)}startsNewAccessUnit(e,t,i,r){if(!e)return!1;if(!t.audFound&&r===0)return!0;if(!e.frame)return!1;const{type:n,data:a}=i;return n>=32&&n<=35||n===39||n>=41&&n<=44||n>=48&&n<=55?!0:n<=31&&a.length>2&&(a[2]&128)!==0}getNALuType(e,t){return(e[t]&126)>>>1}ebsp2rbsp(e){const t=new Uint8Array(e.byteLength);let i=0;for(let r=0;r<e.byteLength;r++)r>=2&&e[r]===3&&e[r-1]===0&&e[r-2]===0||(t[i]=e[r],i++);return new Uint8Array(t.buffer,0,i)}pushAccessUnit(e,t){super.pushAccessUnit(e,t),this.initVPS&&(this.initVPS=null)}readVPS(e){const t=new ir(e);t.readUByte(),t.readUByte(),t.readBits(4),t.skipBits(2),t.readBits(6);const i=t.readBits(3),r=t.readBoolean();return{numTemporalLayers:i+1,temporalIdNested:r}}readSPS(e){const t=new ir(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.readBits(4);const i=t.readBits(3);t.readBoolean();const r=t.readBits(2),n=t.readBoolean(),a=t.readBits(5),o=t.readUByte(),l=t.readUByte(),d=t.readUByte(),c=t.readUByte(),u=t.readUByte(),h=t.readUByte(),f=t.readUByte(),g=t.readUByte(),m=t.readUByte(),p=t.readUByte(),v=t.readUByte(),T=[],y=[];for(let z=0;z<i;z++)T.push(t.readBoolean()),y.push(t.readBoolean());if(i>0)for(let z=i;z<8;z++)t.readBits(2);for(let z=0;z<i;z++)T[z]&&(t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte()),y[z]&&t.readUByte();t.readUEG();const S=t.readUEG();S==3&&t.skipBits(1);const A=t.readUEG(),I=t.readUEG(),_=t.readBoolean();let R=0,D=0,L=0,k=0;_&&(R+=t.readUEG(),D+=t.readUEG(),L+=t.readUEG(),k+=t.readUEG());const w=t.readUEG(),U=t.readUEG(),K=t.readUEG(),G=t.readBoolean();for(let z=G?0:i;z<=i;z++)t.skipUEG(),t.skipUEG(),t.skipUEG();if(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.readBoolean()&&t.readBoolean())for(let he=0;he<4;he++)for(let ge=0;ge<(he===3?2:6);ge++)if(!t.readBoolean())t.readUEG();else{const Me=Math.min(64,1<<4+(he<<1));he>1&&t.readEG();for(let ce=0;ce<Me;ce++)t.readEG()}t.readBoolean(),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.skipUEG(),t.skipUEG(),t.readBoolean());const M=t.readUEG();let $=0;for(let z=0;z<M;z++){let he=!1;if(z!==0&&(he=t.readBoolean()),he){z===M&&t.readUEG(),t.readBoolean(),t.readUEG();let ge=0;for(let we=0;we<=$;we++){const Me=t.readBoolean();let ce=!1;Me||(ce=t.readBoolean()),(Me||ce)&&ge++}$=ge}else{const ge=t.readUEG(),we=t.readUEG();$=ge+we;for(let Me=0;Me<ge;Me++)t.readUEG(),t.readBoolean();for(let Me=0;Me<we;Me++)t.readUEG(),t.readBoolean()}}if(t.readBoolean()){const z=t.readUEG();for(let he=0;he<z;he++){for(let ge=0;ge<K+4;ge++)t.readBits(1);t.readBits(1)}}let N=0,V=1,se=1,J=!0,de=1,te=0;t.readBoolean(),t.readBoolean();let fe=!1;if(t.readBoolean()){if(t.readBoolean()){const st=t.readUByte(),di=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2],je=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1];st>0&&st<16?(V=di[st-1],se=je[st-1]):st===255&&(V=t.readBits(16),se=t.readBits(16))}if(t.readBoolean()&&t.readBoolean(),t.readBoolean()&&(t.readBits(3),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.readUByte(),t.readUByte())),t.readBoolean()&&(t.readUEG(),t.readUEG()),t.readBoolean(),t.readBoolean(),t.readBoolean(),fe=t.readBoolean(),fe&&(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG()),t.readBoolean()&&(de=t.readBits(32),te=t.readBits(32),t.readBoolean()&&t.readUEG(),t.readBoolean())){const je=t.readBoolean(),rt=t.readBoolean();let pt=!1;(je||rt)&&(pt=t.readBoolean(),pt&&(t.readUByte(),t.readBits(5),t.readBoolean(),t.readBits(5)),t.readBits(4),t.readBits(4),pt&&t.readBits(4),t.readBits(5),t.readBits(5),t.readBits(5));for(let ft=0;ft<=i;ft++){J=t.readBoolean();const Qe=J||t.readBoolean();let Vt=!1;Qe?t.readEG():Vt=t.readBoolean();const Oe=Vt?1:t.readUEG()+1;if(je)for(let Se=0;Se<Oe;Se++)t.readUEG(),t.readUEG(),pt&&(t.readUEG(),t.readUEG()),t.skipBits(1);if(rt)for(let Se=0;Se<Oe;Se++)t.readUEG(),t.readUEG(),pt&&(t.readUEG(),t.readUEG()),t.skipBits(1)}}t.readBoolean()&&(t.readBoolean(),t.readBoolean(),t.readBoolean(),N=t.readUEG())}let pe=A,Pe=I;if(_){let z=1,he=1;S===1?z=he=2:S==2&&(z=2),pe=A-z*D-z*R,Pe=I-he*k-he*L}const it=r?["A","B","C"][r]:"",dt=o<<24|l<<16|d<<8|c;let _e=0;for(let z=0;z<32;z++)_e=(_e|(dt>>z&1)<<31-z)>>>0;let ht=_e.toString(16);return a===1&&ht==="2"&&(ht="6"),{codecString:`hvc1.${it}${a}.${ht}.${n?"H":"L"}${v}.B0`,params:{general_tier_flag:n,general_profile_idc:a,general_profile_space:r,general_profile_compatibility_flags:[o,l,d,c],general_constraint_indicator_flags:[u,h,f,g,m,p],general_level_idc:v,bit_depth:w+8,bit_depth_luma_minus8:w,bit_depth_chroma_minus8:U,min_spatial_segmentation_idc:N,chroma_format_idc:S,frame_rate:{fixed:J,fps:te/de}},width:pe,height:Pe,pixelRatio:[V,se]}}readPPS(e){const t=new ir(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.skipUEG(),t.skipUEG(),t.skipBits(2),t.skipBits(3),t.skipBits(2),t.skipUEG(),t.skipUEG(),t.skipEG(),t.skipBits(2),t.readBoolean()&&t.skipUEG(),t.skipEG(),t.skipEG(),t.skipBits(4);const r=t.readBoolean(),n=t.readBoolean();let a=1;return n&&r?a=0:n?a=3:r&&(a=2),{parallelismType:a}}matchSPS(e,t){return Ne(e).substring(3)===Ne(t).substring(3)}}const Ke=188;class pi{constructor(e,t,i,r){this.logger=void 0,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._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this._klvPid=-1,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.videoIntegrityChecker=null,this.observer=e,this.config=t,this.typeSupported=i,this.logger=r,this.videoParser=null}static probe(e,t){const i=pi.syncOffset(e);return i>0&&t.warn(`MPEG2-TS detected but first sync word found @ offset ${i}`),i!==-1}static syncOffset(e){const t=e.length;let i=Math.min(Ke*5,t-Ke)+1,r=0;for(;r<i;){let n=!1,a=-1,o=0;for(let l=r;l<t;l+=Ke)if(e[l]===71&&(t-l===Ke||e[l+Ke]===71)){if(o++,a===-1&&(a=l,a!==0&&(i=Math.min(a+Ke*99,e.length-Ke)+1)),n||(n=Qn(e,l)===0),n&&o>1&&(a===0&&o>2||l+Ke>i))return a}else{if(o)return-1;break}r++}return-1}static createTrack(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:th[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}}resetInitSegment(e,t,i,r,n,a){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=pi.createTrack("video"),this._videoTrack.duration=r,this.videoIntegrityChecker=this.config.handleMpegTsVideoIntegrityErrors==="skip"?new lE(this.logger):null,this._audioTrack=pi.createTrack("audio",r),this._id3Track=pi.createTrack("id3"),this._txtTrack=pi.createTrack("text"),this._audioTrack.segmentCodec="aac",this.videoParser=null,this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=i,e&&this.demux(e,0,a,n?.method==="SAMPLE-AES")}resetTimeStamp(){}resetContiguity(){const{_audioTrack:e,_videoTrack:t,_id3Track:i}=this;e&&(e.pesData=null),t&&(t.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.remainderData=null}demux(e,t,i,r=!1,n=!1){r||(this.sampleAes=null);let a;const o=this._videoTrack,l=this.videoIntegrityChecker,d=this._audioTrack,c=this._id3Track,u=this._txtTrack,h=i.iframe;let f=o.pid,g=o.pesData,m=d.pid,p=c.pid,v=this._klvPid,T=d.pesData,y=c.pesData,S=null,A=null,I=this.pmtParsed,_=this._pmtId,R=e.length;if(this.remainderData&&(e=Pt(this.remainderData,e),R=e.length,this.remainderData=null),R<Ke&&!n)return this.remainderData=e,{audioTrack:d,videoTrack:o,id3Track:c,textTrack:u};const D=Math.max(0,pi.syncOffset(e));R-=(R-D)%Ke,R<e.byteLength&&!n&&(this.remainderData=new Uint8Array(e.buffer,R,e.buffer.byteLength-R));let L=0;for(let w=D;w<R;w+=Ke)if(e[w]===71){const U=!!(e[w+1]&64),K=Qn(e,w),G=(e[w+3]&48)>>4;let O;if(G>1){if(O=w+5+e[w+4],O===w+Ke)continue}else O=w+4;switch(K){case f:U&&(g&&!(l!=null&&l.isCorrupted)&&(a=wi(g,this.logger))&&(this.readyVideoParser(o.segmentCodec),this.videoParser!==null&&this.videoParser.parsePES(o,u,a,!1,i)),g={data:[],size:0},l?.reset(f)),l?.handlePacket(e.subarray(w)),g&&(g.data.push(e.subarray(O,w+Ke)),g.size+=w+Ke-O);break;case m:if(h)break;if(U){if(T&&(a=wi(T,this.logger)))switch(d.segmentCodec){case"aac":this.parseAACPES(d,a,i);break;case"mp3":this.parseMPEGPES(d,a);break;case"ac3":this.parseAC3PES(d,a);break}T={data:[],size:0}}T&&(T.data.push(e.subarray(O,w+Ke)),T.size+=w+Ke-O);break;case p:if(h)break;U&&(y&&(a=wi(y,this.logger))&&this.parseID3PES(c,a),y={data:[],size:0}),y&&(y.data.push(e.subarray(O,w+Ke)),y.size+=w+Ke-O);break;case v:if(h)break;U&&(S&&(a=wi(S,this.logger))&&this.parseKlvPES(c,a),S={data:[],size:0}),S&&(S.data.push(e.subarray(O,w+Ke)),S.size+=w+Ke-O);break;case 0:U&&(O+=e[O]+1),_=this._pmtId=aE(e,O);break;case _:{U&&(O+=e[O]+1);const F=oE(e,O,this.typeSupported,r,this.observer,this.logger,this.config,i);f=F.videoPid,f>0&&(o.pid=f,o.segmentCodec=F.segmentVideoCodec),m=F.audioPid,m>0&&(d.pid=m,d.segmentCodec=F.segmentAudioCodec),p=F.id3Pid,p>0&&(c.pid=p),v=F.klvPid,v>0&&(this._klvPid=v),A!==null&&!I&&(this.logger.warn(`MPEG-TS PMT found at ${w} after unknown PID '${A}'. Backtracking to sync byte @${D} to parse all TS packets.`),A=null,w=D-188),I=this.pmtParsed=!0;break}case 17:case 8191:break;default:A=K;break}}else L++;L>0&&Co(this.observer,new Error(`Found ${L} TS packet/s that do not start with 0x47`),i,void 0,this.logger),o.pesData=g,d.pesData=T,c.pesData=y;const k={audioTrack:d,videoTrack:o,id3Track:c,textTrack:u};return n&&this.extractRemainingSamples(k,i),k}flush(e,t){const{remainderData:i}=this;this.remainderData=null;let r;return i?r=this.demux(i,0,t,!1,!0):r={videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(r,t),this.sampleAes?this.decrypt(r,this.sampleAes):r}extractRemainingSamples(e,t){const{audioTrack:i,videoTrack:r,id3Track:n,textTrack:a}=e,o=r.pesData,l=i.pesData,d=n.pesData,c=this.videoIntegrityChecker;let u;if(o&&!(c!=null&&c.isCorrupted)&&(u=wi(o,this.logger))?(this.readyVideoParser(r.segmentCodec),this.videoParser!==null&&(this.videoParser.parsePES(r,a,u,!0,t),r.pesData=null)):r.pesData=o,l&&(u=wi(l,this.logger))){switch(i.segmentCodec){case"aac":this.parseAACPES(i,u,t);break;case"mp3":this.parseMPEGPES(i,u);break;case"ac3":this.parseAC3PES(i,u);break}i.pesData=null}else l!=null&&l.size&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),i.pesData=l;d&&(u=wi(d,this.logger))?(this.parseID3PES(n,u),n.pesData=null):n.pesData=d}demuxSampleAes(e,t,i,r){const n=this.demux(e,i,r,!0,!this.config.progressive),a=this.sampleAes=new Zh(this.observer,this.config,t);return this.decrypt(n,a)}readyVideoParser(e){this.videoParser===null&&(e==="avc"?this.videoParser=new rE:e==="hevc"&&(this.videoParser=new nE))}decrypt(e,t){return new Promise(i=>{const{audioTrack:r,videoTrack:n}=e;r.samples&&r.segmentCodec==="aac"?t.decryptAacSamples(r.samples,0,()=>{n.samples?t.decryptAvcSamples(n.samples,0,0,()=>{i(e)}):i(e)}):n.samples&&t.decryptAvcSamples(n.samples,0,0,()=>{i(e)})})}destroy(){this.observer&&this.observer.removeAllListeners(),this.config=this.logger=this.observer=null,this.aacOverFlow=this.videoParser=this.remainderData=this.sampleAes=null,this._videoTrack=this._audioTrack=this._id3Track=this._txtTrack=void 0,this.videoIntegrityChecker=null}parseAACPES(e,t,i){let r=0;const n=this.aacOverFlow;let a=t.data;if(n){this.aacOverFlow=null;const h=n.missing,f=n.sample.unit.byteLength;if(h===-1)a=Pt(n.sample.unit,a);else{const g=f-h;n.sample.unit.set(a.subarray(0,h),g),e.samples.push(n.sample),r=n.missing}}let o,l;for(o=r,l=a.length;o<l-1&&!zn(a,o);o++);if(o!==r){let h;const f=o<l-1;if(f?h=`AAC PES did not start with ADTS header,offset:${o}`:h="No ADTS header found in AAC PES",Co(this.observer,new Error(h),i,f,this.logger),!f)return}Wh(e,this.observer,a,o,this.audioCodec);let d;if(t.pts!==void 0)d=t.pts;else if(n){const h=Yh(e.samplerate);d=n.sample.pts+h}else{this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}let c=0,u;for(;o<l;)if(u=qh(e,a,o,d,c),o+=u.length,u.missing){this.aacOverFlow=u;break}else for(c++;o<l-1&&!zn(a,o);o++);}parseMPEGPES(e,t){const i=t.data,r=i.length;let n=0,a=0;const o=t.pts;if(o===void 0){this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<r;)if(Qh(i,a)){const l=jh(e,i,a,o,n);if(l)a+=l.length,n++;else break}else a++}parseAC3PES(e,t){{const i=t.data,r=t.pts;if(r===void 0){this.logger.warn("[tsdemuxer]: AC3 PES unknown PTS");return}const n=i.length;let a=0,o=0,l;for(;o<n&&(l=ef(e,i,o,r,a++))>0;)o+=l}}parseID3PES(e,t){if(t.pts===void 0){this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}const i=Ie({},t,{type:this._videoTrack?mt.emsg:mt.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(i)}parseKlvPES(e,t){var i;const r=(i=t.pts)!=null?i:t.dts;if(r===void 0){this.logger.warn("[tsdemuxer]: KLV PES unknown PTS and DTS");return}const n=t.data;if(n.length<16){this.logger.warn("[tsdemuxer]: KLV PES payload too short");return}let a=0;for(;a<n.length;){var o;if(a+16>n.length)break;const l=a;if(a+=16,a>=n.length)break;const d=n[a];a+=1;let c=0;if(d&128){const g=d&127;if(g===0||g>4||a+g>n.length){this.logger.warn("[tsdemuxer]: Invalid KLV length encoding");break}for(let m=0;m<g;m++)c=c<<8|n[a+m];a+=g}else c=d;if(a+c>n.length){this.logger.warn("[tsdemuxer]: KLV value extends beyond PES payload");break}const u=a+c,h=n.subarray(l,u),f={data:h,len:h.byteLength,pts:r,dts:(o=t.dts)!=null?o:r,type:mt.misbklv,duration:Number.POSITIVE_INFINITY};e.samples.push(f),a=u}}}function Qn(s,e){return((s[e+1]&31)<<8)+s[e+2]}function aE(s,e){return(s[e+10]&31)<<8|s[e+11]}function oE(s,e,t,i,r,n,a,o){const l={audioPid:-1,videoPid:-1,id3Pid:-1,klvPid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},d=(s[e+1]&15)<<8|s[e+2],c=e+3+d-4,u=(s[e+10]&15)<<8|s[e+11];for(e+=12+u;e<c;){const h=Qn(s,e),f=(s[e+3]&15)<<8|s[e+4];switch(s[e]){case 207:if(!i){Ua("ADTS AAC",n);break}case 15:l.audioPid===-1&&(l.audioPid=h);break;case 21:l.id3Pid===-1&&(l.id3Pid=h);break;case 219:if(!i){Ua("H.264",n);break}case 27:l.videoPid===-1&&(l.videoPid=h);break;case 3:case 4:!t.mpeg&&!t.mp3?n.log("MPEG audio found, not supported in this browser"):l.audioPid===-1&&(l.audioPid=h,l.segmentAudioCodec="mp3");break;case 193:if(!i){Ua("AC-3",n);break}case 129:t.ac3?l.audioPid===-1&&(l.audioPid=h,l.segmentAudioCodec="ac3"):n.log("AC-3 audio found, not supported in this browser");break;case 6:if(f>0){let g=e+5,m=f;for(;m>2;){switch(s[g]){case 106:l.audioPid===-1&&(t.ac3!==!0?n.log("AC-3 audio found, not supported in this browser for now"):(l.audioPid=h,l.segmentAudioCodec="ac3"));break;case 5:l.klvPid===-1&&a.enableEmsgKLVMetadata&&(l.klvPid=h,n.log(`KLV metadata PID found: ${h}`));break}const v=s[g+1]+2;g+=v,m-=v}}break;case 194:case 135:return Co(r,new Error("Unsupported EC-3 in M2TS found"),o,void 0,n),l;case 36:l.videoPid===-1&&(l.videoPid=h,l.segmentVideoCodec="hevc",n.log("HEVC in M2TS found"));break}e+=f+5}return l}function Co(s,e,t,i,r){r.warn(`parsing error: ${e.message}`),s.emit(E.ERROR,E.ERROR,{type:X.MEDIA_ERROR,details:x.FRAG_PARSING_ERROR,fatal:!1,levelRetry:i,chunkMeta:t,error:e,reason:e.message})}function Ua(s,e){e.log(`${s} with AES-128-CBC encryption found in unencrypted stream`)}function wi(s,e){let t=0,i,r,n,a,o;const l=s.data;if(!s||s.size===0)return null;for(;l[0].length<19&&l.length>1;)l[0]=Pt(l[0],l[1]),l.splice(1,1);if(i=l[0],(i[0]<<16)+(i[1]<<8)+i[2]===1){if(r=(i[4]<<8)+i[5],r&&r>s.size-6)return null;const c=i[7];c&192&&(a=(i[9]&14)*536870912+(i[10]&255)*4194304+(i[11]&254)*16384+(i[12]&255)*128+(i[13]&254)/2,c&64?(o=(i[14]&14)*536870912+(i[15]&255)*4194304+(i[16]&254)*16384+(i[17]&255)*128+(i[18]&254)/2,a-o>60*9e4&&(e.warn(`${Math.round((a-o)/9e4)}s delta between PTS and DTS, align them`),a=o)):o=a),n=i[8];let u=n+9;if(s.size<=u)return null;s.size-=u;const h=new Uint8Array(s.size);for(let f=0,g=l.length;f<g;f++){i=l[f];let m=i.byteLength;if(u)if(u>m){u-=m;continue}else i=i.subarray(u),m-=u,u=0;h.set(i,t),t+=m}return r&&(r-=n+3),{data:h,pts:a,dts:o,len:r}}return null}class lE{constructor(e){this.logger=void 0,this.pid=0,this.lastContinuityCounter=-1,this.integrityState="ok",this.logger=e}get isCorrupted(){return this.integrityState!=="ok"}reset(e){this.pid=e,this.lastContinuityCounter=-1,this.integrityState="ok"}handlePacket(e){if(e.byteLength<4)return;const t=Qn(e,0);if(t!==this.pid){this.logger.debug(`Packet PID mismatch, expected ${this.pid} got ${t}`);return}const i=(e[3]&48)>>4;if(i===0)return;const r=e[3]&15,n=this.lastContinuityCounter;this.lastContinuityCounter=r;const a=(i&1)!=0;if((i&2)!=0&&e[4]!=0&&(e[5]&128)!=0||n<0)return;const d=a?n+1&15:n;if(r!==d){this.logger.warn(`MPEG-TS Continuity Counter check failed for PID='${t}', CC=${r}, Expected-CC=${d} Last-CC=${n}`),this.integrityState="cc-failed";return}if((e[1]&128)!==0){this.logger.warn(`MPEG-TS Packet had TEI flag set for PID='${t}'`),this.integrityState="tei-bit";return}}}class dE{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}}}var Xn;const cE={video: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]),audio: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])},$a=new Uint8Array([0,0,0,0,0,0,0,0]),uE=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),hE=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),fE=new Uint8Array([0,0,0,0,0,0,0,0]),Os=new Uint8Array([0,0,0,0,0,0,0,1]),vc=new Uint8Array([105,115,111,109]),gE=new Uint8Array([97,118,99,49]),mE=new Uint8Array([0,0,0,1]);class H{static box(e,...t){let i=8,r=t.length;const n=r;for(;r--;)i+=t[r].byteLength;const a=new Uint8Array(i);for(He(a,0,i),He(a,4,e),r=0,i=8;r<n;r++)a.set(t[r],i),i+=t[r].byteLength;return a}static hdlr(e){return H.box(re.hdlr,cE[e])}static mdat(e){return H.box(re.mdat,e)}static mdhd(e,t){t*=e;const i=Math.floor(t/(ti+1)),r=Math.floor(t%(ti+1));return H.box(re.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,i>>24,i>>16&255,i>>8&255,i&255,r>>24,r>>16&255,r>>8&255,r&255,85,196,0,0]))}static mdia(e){return H.box(re.mdia,H.mdhd(e.timescale||0,e.duration||0),H.hdlr(e.type),H.minf(e))}static mfhd(e){return H.box(re.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255]))}static minf(e){return e.type==="audio"?H.box(re.minf,H.box(re.smhd,fE),H.DINF,H.stbl(e)):H.box(re.minf,H.box(re.vmhd,hE),H.DINF,H.stbl(e))}static moof(e,t,i){return H.box(re.moof,H.mfhd(e),H.traf(i,t))}static moov(e){let t=e.length;const i=[];for(;t--;)i[t]=H.trak(e[t]);return H.box.apply(null,[re.moov,H.mvhd(e[0].timescale||0,e[0].duration||0)].concat(i).concat(H.mvex(e)))}static mvex(e){let t=e.length;const i=[];for(;t--;)i[t]=H.trex(e[t]);return H.box.apply(null,[re.mvex,...i])}static mvhd(e,t){t*=e;const i=Math.floor(t/(ti+1)),r=Math.floor(t%(ti+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,i>>24,i>>16&255,i>>8&255,i&255,r>>24,r>>16&255,r>>8&255,r&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 H.box(re.mvhd,n)}static sdtp(e){const t=e.samples||[],i=new Uint8Array(4+t.length);let r,n;for(r=0;r<t.length;r++)n=t[r].flags,i[r+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return H.box(re.sdtp,i)}static stbl(e){return H.box(re.stbl,H.stsd(e),H.box(re.stts,$a),H.box(re.stsc,$a),H.box(re.stsz,uE),H.box(re.stco,$a))}static avc1(e){let t=[],i=[],r,n,a;for(r=0;r<e.sps.length;r++)n=e.sps[r],a=n.byteLength,t.push(a>>>8&255),t.push(a&255),t=t.concat(Array.prototype.slice.call(n));for(r=0;r<e.pps.length;r++)n=e.pps[r],a=n.byteLength,i.push(a>>>8&255),i.push(a&255),i=i.concat(Array.prototype.slice.call(n));const o=H.box(re.avcC,new Uint8Array([1,t[3],t[4],t[5],255,224|e.sps.length].concat(t).concat([e.pps.length]).concat(i))),l=e.width,d=e.height,c=e.pixelRatio[0],u=e.pixelRatio[1];return H.box(re.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,H.box(re.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),H.box(re.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,c&255,u>>24,u>>16&255,u>>8&255,u&255])))}static esds(e){const t=e.config,i=t.length;return new Uint8Array([0,0,0,0,3,23+i,0,1,0,4,15+i,64,21,0,0,0,0,0,0,0,0,0,0,0,5,i,...t,6,1,2])}static audioStsd(e){const t=e.samplerate||0;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount||0,0,16,0,0,0,0,t>>8&255,t&255,0,0])}static mp4a(e){return H.box(re.mp4a,H.audioStsd(e),H.box(re.esds,H.esds(e)))}static mp3(e){return H.box(re[".mp3"],H.audioStsd(e))}static ac3(e){return H.box(re["ac-3"],H.audioStsd(e),H.box(re.dac3,e.config))}static stsd(e){const{segmentCodec:t}=e;if(e.type==="audio"){if(t==="aac")return H.box(re.stsd,Os,H.mp4a(e));if(t==="ac3"&&e.config)return H.box(re.stsd,Os,H.ac3(e));if(t==="mp3"&&e.codec==="mp3")return H.box(re.stsd,Os,H.mp3(e))}else if(e.pps&&e.sps){if(t==="avc")return H.box(re.stsd,Os,H.avc1(e));if(t==="hevc"&&e.vps)return H.box(re.stsd,Os,H.hvc1(e))}else throw new Error("video track missing pps or sps");throw new Error(`unsupported ${e.type} segment codec (${t}/${e.codec})`)}static tkhd(e){const t=e.id,i=(e.duration||0)*(e.timescale||0),r=e.width||0,n=e.height||0,a=Math.floor(i/(ti+1)),o=Math.floor(i%(ti+1));return H.box(re.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,r>>8&255,r&255,0,0,n>>8&255,n&255,0,0]))}static traf(e,t){const i=H.sdtp(e),r=e.id,n=Math.floor(t/(ti+1)),a=Math.floor(t%(ti+1));return H.box(re.traf,H.box(re.tfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,r&255])),H.box(re.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])),H.trun(e,i.length+16+20+8+16+8+8),i)}static trak(e){return e.duration=e.duration||4294967295,H.box(re.trak,H.tkhd(e),H.mdia(e))}static trex(e){const t=e.id;return H.box(re.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){const i=e.samples||[],r=i.length,n=12+16*r,a=new Uint8Array(n);let o,l,d,c,u,h;for(t+=8+n,a.set([e.type==="video"?1:0,0,15,1,r>>>24&255,r>>>16&255,r>>>8&255,r&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0),o=0;o<r;o++)l=i[o],d=l.duration,c=l.size,u=l.flags,h=l.cts,a.set([d>>>24&255,d>>>16&255,d>>>8&255,d&255,c>>>24&255,c>>>16&255,c>>>8&255,c&255,u.isLeading<<2|u.dependsOn,u.isDependedOn<<6|u.hasRedundancy<<4|u.paddingValue<<1|u.isNonSync,u.degradPrio&61440,u.degradPrio&15,h>>>24&255,h>>>16&255,h>>>8&255,h&255],12+16*o);return H.box(re.trun,a)}static initSegment(e){const t=H.moov(e);return Pt(H.FTYP,t)}static hvc1(e){const t=e.params,i=[e.vps,e.sps,e.pps],r=4,n=new Uint8Array([1,t.general_profile_space<<6|(t.general_tier_flag?32:0)|t.general_profile_idc,t.general_profile_compatibility_flags[0],t.general_profile_compatibility_flags[1],t.general_profile_compatibility_flags[2],t.general_profile_compatibility_flags[3],t.general_constraint_indicator_flags[0],t.general_constraint_indicator_flags[1],t.general_constraint_indicator_flags[2],t.general_constraint_indicator_flags[3],t.general_constraint_indicator_flags[4],t.general_constraint_indicator_flags[5],t.general_level_idc,240|t.min_spatial_segmentation_idc>>8,255&t.min_spatial_segmentation_idc,252|t.parallelismType,252|t.chroma_format_idc,248|t.bit_depth_luma_minus8,248|t.bit_depth_chroma_minus8,0,parseInt(t.frame_rate.fps),r-1|t.temporal_id_nested<<2|t.num_temporal_layers<<3|(t.frame_rate.fixed?64:0),i.length]);let a=n.length;for(let g=0;g<i.length;g+=1){a+=3;for(let m=0;m<i[g].length;m+=1)a+=2+i[g][m].length}const o=new Uint8Array(a);o.set(n,0),a=n.length;const l=i.length-1;for(let g=0;g<i.length;g+=1){o.set(new Uint8Array([32+g|(g===l?128:0),0,i[g].length]),a),a+=3;for(let m=0;m<i[g].length;m+=1)o.set(new Uint8Array([i[g][m].length>>8,i[g][m].length&255]),a),a+=2,o.set(i[g][m],a),a+=i[g][m].length}const d=H.box(re.hvcC,o),c=e.width,u=e.height,h=e.pixelRatio[0],f=e.pixelRatio[1];return H.box(re.hvc1,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,c>>8&255,c&255,u>>8&255,u&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]),d,H.box(re.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),H.box(re.pasp,new Uint8Array([h>>24,h>>16&255,h>>8&255,h&255,f>>24,f>>16&255,f>>8&255,f&255])))}}Xn=H;H.FTYP=Xn.box(re.ftyp,vc,mE,vc,gE);H.DINF=Xn.box(re.dinf,Xn.box(re.dref,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])));const sf=9e4;function Ml(s,e,t=1,i=!1){const r=s*e*t;return i?Math.round(r):r}function pE(s,e,t=1,i=!1){return Ml(s,e,1/t,i)}function Fs(s,e=!1){return Ml(s,1e3,1/sf,e)}function EE(s,e=1){return Ml(s,sf,1/e)}function yc(s){const{baseTime:e,timescale:t,trackId:i}=s;return`${e/t} (${e}/${t}) trackId: ${i}`}const vE=10*1e3,yE=1024,TE=1152,SE=1536,Po=8589934592;function Tc(s,e,t,i){return{duration:e,size:t,cts:i,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:s?2:1,isNonSync:s?0:1,paddingValue:0}}}class cn extends Dt{constructor(e,t,i,r){super("mp4-remuxer",r),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextVideoTs=null,this.nextAudioTs=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=i,this.ISGenerated=!1}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(e){const t=this._initPTS;(!t||!e||e.trackId!==t.trackId||e.baseTime!==t.baseTime||e.timescale!==t.timescale)&&this.log(`Reset initPTS: ${t&&yc(t)} > ${e&&yc(e)}`),this._initPTS=this._initDTS=e}resetNextTimestamp(){this.log("reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){this.log("ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}getVideoStartPts(e){let t=!1;const i=e[0].pts,r=e.reduce((n,a)=>{let o=a.pts,l=o-n;return l<-4294967296&&(t=!0,o=Lt(o,i),l=o-n),l>0?n:o},i);return t&&this.debug("PTS rollover detected"),r}remux(e,t,i,r,n,a,o,l,d){let c,u,h,f,g,m,p=n,v=n;const y=!d.iframe&&e.pid>-1,S=t.pid>-1,A=t.samples.length,I=e.samples.length>0,_=o&&A>0||A>1;if((!y||I)&&(!S||_)||this.ISGenerated||o){if(this.ISGenerated){var D,L,k,w;const O=this.videoTrackConfig;(O&&(t.width!==O.width||t.height!==O.height||((D=t.pixelRatio)==null?void 0:D[0])!==((L=O.pixelRatio)==null?void 0:L[0])||((k=t.pixelRatio)==null?void 0:k[1])!==((w=O.pixelRatio)==null?void 0:w[1]))||!O&&_||this.nextAudioTs===null&&I)&&this.resetInitSegment()}this.ISGenerated||(h=this.generateIS(e,t,n,a));const U=this.isVideoContiguous;let K=-1,G;if(_&&(K=AE(t.samples),!U&&this.config.forceKeyFrameOnDiscontinuity))if(m=!0,K>0){this.warn(`Dropped ${K} out of ${A} video samples due to a missing keyframe`);const O=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(K),t.dropped+=K,v+=(t.samples[0].pts-O)/t.inputTimeScale,G=v}else K===-1&&(this.warn(`No keyframe found out of ${A} video samples`),m=!1);if(this.ISGenerated){if(I&&_&&n){const O=this.getVideoStartPts(t.samples),M=(Lt(e.samples[0].pts,O)-O)/t.inputTimeScale;p+=Math.max(0,M),v+=Math.max(0,-M)}if(I){if(e.samplerate||(this.warn("regenerate InitSegment as audio detected"),h=this.generateIS(e,t,n,a)),u=this.remuxAudio(e,p,this.isAudioContiguous,a,S||_||l===j.AUDIO?v:void 0,d),_){const O=u?u.endPTS-u.startPTS:0;t.inputTimeScale||(this.warn("regenerate InitSegment as video detected"),h=this.generateIS(e,t,n,a)),c=this.remuxVideo(t,v,U,O,d)}}else _&&(c=this.remuxVideo(t,v,U,0,d));c&&(c.firstKeyFrame=K,c.independent=K!==-1,c.firstKeyFramePTS=G)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(g=rf(i,n,this._initPTS,this._initDTS)),r.samples.length&&(f=nf(r,n,this._initPTS))),{audio:u,video:c,initSegment:h,independent:m,text:f,id3:g}}computeInitPts(e,t,i,r){const n=Math.round(i*t);let a=Lt(e,n);if(a<n)for(this.log(`Adjusting PTS for rollover in timeline near ${(n-a)/t} ${r}`);a<n;)a+=Po;return a-n}generateIS(e,t,i,r){const n=e.samples,a=t.samples,o=this.typeSupported,l={},d=this._initPTS,c=!d||r;let u="audio/mp4",h,f,g,m=-1;if(c&&(h=f=1/0),e.config&&n.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":o.mpeg?(u="audio/mpeg",e.codec=""):o.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3";break}if(l.audio={id:"audio",container:u,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&o.mpeg?new Uint8Array(0):H.initSegment([e]),metadata:{channelCount:e.channelCount}},c){m=e.id,g=e.inputTimeScale;const p=this.computeInitPts(n[0].pts,g,i,"audio");(!d||g!==d.timescale||i===0&&p<d.baseTime)&&(h=f=p)}}if(t.sps&&t.pps&&a.length){if(t.timescale=t.inputTimeScale,l.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:H.initSegment([t]),metadata:{width:t.width,height:t.height}},c){m=t.id,g=t.inputTimeScale;const p=this.getVideoStartPts(a),v=Lt(a[0].dts,p),T=this.computeInitPts(v,g,i,"video"),y=this.computeInitPts(p,g,i,"video");(!d||g!==d.timescale||B(h)||i===0&&y<d.baseTime)&&(f=Math.min(f,T),h=Math.min(h,T))}this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(l).length)return this.ISGenerated=!0,c&&B(h)?(d&&this.warn(`Timestamps at playlist time: ${r?"":"~"}${i} ${h/g} != initPTS: ${d.baseTime/d.timescale} (${d.baseTime}/${d.timescale}) trackId: ${d.trackId}`),this.log(`Found initPTS at playlist time: ${i} offset: ${h/g} (${h}/${g}) trackId: ${m}`),this._initPTS={baseTime:h,timescale:g,trackId:m},this._initDTS={baseTime:f,timescale:g,trackId:m}):h=g=void 0,{tracks:l,initPTS:h,timescale:g,trackId:m}}remuxVideo(e,t,i,r,n){const a=e.inputTimeScale,o=e.samples,l=[],d=o.length,c=this._initPTS,u=c.baseTime*a/c.timescale;let h=this.nextVideoTs,f=8,g=this.videoSampleDuration,m,p,v=Number.POSITIVE_INFINITY,T=Number.NEGATIVE_INFINITY,y=!1;if(!i||h===null){const N=u+t*a,V=o[0].pts-Lt(o[0].dts,o[0].pts);Js()&&h!==null&&Math.abs(N-V-(h+u))<15e3?i=!0:h=N-V-u}const S=h+u;for(let N=0;N<d;N++){const V=o[N];V.pts=Lt(V.pts,S),V.dts=Lt(V.dts,S),V.dts<o[N>0?N-1:N].dts&&(y=!0)}y&&o.sort(function(N,V){const se=N.dts-V.dts,J=N.pts-V.pts;return se||J}),m=o[0].dts,p=o[o.length-1].dts;const A=p-m,I=A?Math.round(A/(d-1)):g||e.inputTimeScale/30;if(i){const N=m-S,V=N>I,se=N<-1;if((V||se)&&(V?this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${Fs(N,!0)} ms (${N}dts) hole between fragments detected at ${t.toFixed(3)}`):this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${Fs(-N,!0)} ms (${N}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!se||S>=o[0].pts||Js())){m=S;const J=o[0].pts-N;if(V)o[0].dts=m,o[0].pts=J;else{let de=!0;for(let te=0;te<o.length&&!(o[te].dts>J&&de);te++){const fe=o[te].pts;if(o[te].dts-=N,o[te].pts-=N,te<o.length-1){const le=o[te+1].pts,pe=o[te].pts,Pe=le<=pe,it=le<=fe;de=Pe==it}}}this.log(`Video: Initial PTS/DTS adjusted: ${Fs(J,!0)}/${Fs(m,!0)}, delta: ${Fs(N,!0)} ms`)}}m=Math.max(0,m);let _=0,R=0,D=m;for(let N=0;N<d;N++){const V=o[N],se=V.units,J=se.length;let de=0;for(let te=0;te<J;te++)de+=se[te].data.length;R+=de,_+=J,V.length=de,V.dts<D?(V.dts=D,D+=I/4|0||1):D=V.dts,v=Math.min(V.pts,v),T=Math.max(V.pts,T)}p=o[d-1].dts;const L=R+4*_+8;let k;try{k=new Uint8Array(L)}catch(N){this.observer.emit(E.ERROR,E.ERROR,{type:X.MUX_ERROR,details:x.REMUX_ALLOC_ERROR,fatal:!1,chunkMeta:n,error:N,bytes:L,reason:`fail allocating video mdat ${L}`});return}He(k,0,L),He(k,4,re.mdat);let w=!1,U=Number.POSITIVE_INFINITY,K=Number.POSITIVE_INFINITY,G=Number.NEGATIVE_INFINITY,O=Number.NEGATIVE_INFINITY;for(let N=0;N<d;N++){const V=o[N],se=V.units;let J=0;for(let fe=0,le=se.length;fe<le;fe++){const pe=se[fe],Pe=pe.data,it=pe.data.byteLength;He(k,f,it),f+=4,k.set(Pe,f),f+=it,J+=4+it}let de;if(N<d-1)g=o[N+1].dts-V.dts,de=o[N+1].pts-V.pts;else{const fe=this.config,le=N>0?V.dts-o[N-1].dts:I;if(de=N>0?V.pts-o[N-1].pts:I,fe.stretchShortVideoTrack&&this.nextAudioTs!==null){const pe=Math.floor(fe.maxBufferHole*a),Pe=(r?v+r*a:this.nextAudioTs+u)-V.pts;Pe>pe?(g=Pe-le,g<0?g=le:w=!0,this.log(`It is approximately ${Pe/90} ms to the next segment; using duration ${g/90} ms for the last video frame.`)):g=le}else g=le}let te=Math.round(V.pts-V.dts);if(U=Math.min(U,g),G=Math.max(G,g),K=Math.min(K,de),O=Math.max(O,de),!i&&N===0&&te>g){const fe=Math.round(te/I)*I;fe-te===1&&(this.log(`pad first CTS ${te} -> ${fe} of sn: ${n.sn}`),te=fe)}l.push(Tc(V.key,g,J,te))}if(l.length){const N=Js();if(N){if(N<70){const V=l[0].flags;V.dependsOn=2,V.isNonSync=0}}else if(bp()&&O-K<G-U&&I/G<.025&&l[0].cts===0){this.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let V=m;for(let se=0,J=l.length;se<J;se++){const de=V+l[se].duration,te=V+l[se].cts;if(se<J-1){const fe=de+l[se+1].cts;l[se].duration=fe-te}else l[se].duration=se?l[se-1].duration:I;l[se].cts=0,V=de}}}g=w||!g?I:g;const F=p+g;this.nextVideoTs=h=F-u,this.videoSampleDuration=g,this.isVideoContiguous=!0,n.iframe&&(l.length===1?(l[0].duration=g=n.duration*a,this.nextVideoTs=h=m+g-u):this.warn(`Not adjusting IFrame duration (sample count ${l.length})`));const Y={data1:H.moof(n.sn,m,Ie(e,{samples:l})),data2:k,startPTS:(v-u)/a,endPTS:(T+g-u)/a,startDTS:(m-u)/a,endDTS:h/a,type:"video",hasAudio:!1,hasVideo:!0,nb:l.length,dropped:e.dropped};return e.samples=[],e.dropped=0,Y}getSamplesPerFrame(e){switch(e.segmentCodec){case"mp3":return TE;case"ac3":return SE;default:return yE}}remuxAudio(e,t,i,r,n,a){const o=e.inputTimeScale,l=e.samplerate?e.samplerate:o,d=o/l,c=this.getSamplesPerFrame(e),u=c*d,h=this._initPTS,f=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,g=[],m=n!==void 0;let p=e.samples,v=f?0:8,T=this.nextAudioTs||-1;const y=h.baseTime*o/h.timescale,S=y+t*o;if(this.isAudioContiguous=i=i||p.length&&T>0&&(r&&Math.abs(S-(T+y))<9e3||Math.abs(Lt(p[0].pts,S)-(T+y))<20*u),p.forEach(function(F){F.pts=Lt(F.pts,S)}),!i||T<0){const F=p.length;if(p=p.filter(M=>M.pts>=0),F!==p.length&&this.warn(`Removed ${p.length-F} of ${F} samples (initPTS ${y} / ${o})`),!p.length)return;n===0?T=0:r&&!m?T=Math.max(0,S-y):T=p[0].pts-y}if(e.segmentCodec==="aac"){const F=this.config.maxAudioFramesDrift;for(let M=0,$=T+y;M<p.length;M++){const Y=p[M],N=Y.pts,V=N-$,se=Math.abs(1e3*V/o);if(V<=-F*u&&m)M===0&&(this.warn(`Audio frame @ ${(N/o).toFixed(3)}s overlaps marker by ${Math.round(1e3*V/o)} ms.`),this.nextAudioTs=T=N-y,$=N);else if(V>=F*u&&se<vE&&m){let J=Math.round(V/u);for($=N-J*u;$<0&&J&&u;)J--,$+=u;M===0&&(this.nextAudioTs=T=$-y),this.warn(`Injecting ${J} audio frames @ ${(($-y)/o).toFixed(3)}s due to ${Math.round(1e3*V/o)} ms gap.`);for(let de=0;de<J;de++){let te=dE.getSilentFrame(e.parsedCodec||e.manifestCodec||e.codec,e.channelCount);te||(this.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),te=Y.unit.subarray()),p.splice(M,0,{unit:te,pts:$}),$+=u,M++}}Y.pts=$,$+=u}}let A=null,I=null,_,R=0,D=p.length;for(;D--;)R+=p[D].unit.byteLength;for(let F=0,M=p.length;F<M;F++){const $=p[F],Y=$.unit;let N=$.pts;if(I!==null){const se=g[F-1];se.duration=Math.round((N-I)/d)}else if(i&&e.segmentCodec==="aac"&&(N=T+y),A=N,R>0){R+=v;try{_=new Uint8Array(R)}catch(se){this.observer.emit(E.ERROR,E.ERROR,{type:X.MUX_ERROR,details:x.REMUX_ALLOC_ERROR,fatal:!1,chunkMeta:a,error:se,bytes:R,reason:`fail allocating audio mdat ${R}`});return}f||(He(_,0,R),He(_,4,re.mdat))}else return;_&&_.set(Y,v);const V=Y.byteLength;v+=V,g.push(Tc(!0,c,V,0)),I=N}const L=g.length;if(!L)return;const k=g[g.length-1];T=I-y,this.nextAudioTs=T+d*k.duration;const w=f?new Uint8Array(0):H.moof(e.sequenceNumber++,A/d,Ie({},e,{samples:g}));e.samples=[];const U=(A-y)/o,K=this.nextAudioTs/o,O={data1:w,data2:_,startPTS:U,endPTS:K,startDTS:U,endDTS:K,type:"audio",hasAudio:!0,hasVideo:!1,nb:L};return this.isAudioContiguous=!0,O}}function Lt(s,e){let t;if(e===null)return s;for(e<s?t=-Po:t=Po;Math.abs(s-e)>4294967296;)s+=t;return s}function AE(s){for(let e=0;e<s.length;e++)if(s[e].key)return e;return-1}function rf(s,e,t,i){const r=s.samples.length;if(!r)return;const n=s.inputTimeScale;for(let o=0;o<r;o++){const l=s.samples[o];l.pts=Lt(l.pts-t.baseTime*n/t.timescale,e*n)/n,l.dts=Lt(l.dts-i.baseTime*n/i.timescale,e*n)/n}const a=s.samples;return s.samples=[],{samples:a}}function nf(s,e,t){const i=s.samples.length;if(!i)return;const r=s.inputTimeScale;for(let a=0;a<i;a++){const o=s.samples[a];o.pts=Lt(o.pts-t.baseTime*r/t.timescale,e*r)/r}s.samples.sort((a,o)=>a.pts-o.pts);const n=s.samples;return s.samples=[],{samples:n}}class bE extends Dt{constructor(e,t,i,r){super("passthrough-remuxer",r),this.observer=void 0,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,this.isVideoContiguous=!1,this.videoOnlyRemux=!1,this.decryptdata=null,this.pendingInitSegment=void 0,this.observer=e}destroy(){this.observer&&this.observer.removeAllListeners(),this.observer=null}resetTimeStamp(e){this.lastEndTime=null;const t=this.initPTS;t&&e&&t.baseTime===e.baseTime&&t.timescale===e.timescale||(this.initPTS=e)}resetNextTimestamp(){this.isVideoContiguous=!1,this.lastEndTime=null}resetInitSegment(e,t,i,r){this.audioCodec=t,this.videoCodec=i,this.decryptdata=r,this.pendingInitSegment=e,this.videoOnlyRemux=!1,this.initTracks=void 0,this.initData=void 0,this.emitInitSegment=!0}generateInitSegment(e,t,i){this.videoOnlyRemux=!1;let{audioCodec:r,videoCodec:n}=this;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}const{audio:a,video:o}=this.initData=i||nh(e);if(t)dp(e,t);else{const d=a||o;d!=null&&d.encrypted&&this.warn(`Init segment with encrypted track with has no key ("${d.codec}")!`)}a&&(r=Sc(a,xe.AUDIO,this)),o&&(n=Sc(o,xe.VIDEO,this));const l={};a&&o?l.audiovideo={container:"video/mp4",codec:r+","+n,supplemental:o.supplemental,encrypted:o.encrypted,initSegment:e,id:"main"}:a?l.audio={container:"audio/mp4",codec:r,encrypted:a.encrypted,initSegment:e,id:"audio"}:o?l.video={container:"video/mp4",codec:n,supplemental:o.supplemental,encrypted:o.encrypted,initSegment:e,id:"main"}:this.warn("initSegment does not contain moov or trak boxes."),this.initTracks=l}remux(e,t,i,r,n,a,o,l,d,c,u){var h,f;let{initPTS:g,lastEndTime:m}=this;const p={audio:void 0,video:void 0,text:void 0,id3:i,initSegment:void 0};B(m)||(m=this.lastEndTime=n||0);const v=t.samples;if(!v.length)return p;const T=this.pendingInitSegment;T&&(this.pendingInitSegment=void 0,this.generateInitSegment(T,this.decryptdata,c));const y={initPTS:void 0,timescale:void 0,trackId:void 0};let S=this.initData;if((h=S)!=null&&h.length||(this.generateInitSegment(v),S=this.initData),!((f=S)!=null&&f.length))return this.warn("Failed to generate initSegment."),p;if(d.iframe&&S.audio&&S.video){var A;const z=(A=this.initTracks)==null||(A=A.audiovideo)==null?void 0:A.initSegment,he=z?sp(z):null;if(he){var I;this.log("Converted muxed init segment to video-only for I-Frame playback"),this.generateInitSegment(he,this.decryptdata),(I=this.initData)!=null&&I.length&&(S=this.initData,this.emitInitSegment=!0,this.videoOnlyRemux=!0)}}this.emitInitSegment&&(y.tracks=this.initTracks,p.initSegment=y,this.emitInitSegment=!1);const _=d.iframe,R=u&&(!_||u.includeSampleDetails)?u.tracks:fp(v,S,d,this,_),D=S.audio?R[S.audio.id]:null,L=S.video?R[S.video.id]:null,k=!!S.audio,w=!!S.video;let U="";k&&(U+="audio"),w&&(U+="video");const K=$r(L,1/0),G=$r(D,1/0),O=$r(L,0,!0),F=$r(D,0,!0);let M=n,$=0;L&&D&&S.audio&&(G>O||K>F)&&this.warn(`audio and video track sample timestamps do not overlap. v: ${K}-${O} a: ${G}-${F}}`,L,D);const Y=!!D&&(!L||!g&&G<K||!!g&&g.trackId===S.audio.id),N=Y?D:L;if(!N)return this.log(`No media samples found in ${l} ${d.level} ${d.part===-1?"":`part: ${d.part} of`} sn: ${d.sn} at playlist time: ${n}`),p;let V=v,se,J;if(L&&L.sampleCount>=1&&S.video&&d.iframe){const{trun:z,start:he}=L,ge=z.length===1,we=z.length?ge?z[0].samples:z[0].samples.concat(...z.slice(1).map(Me=>Me.samples)):[];if(we.length){const Me=z[0];let ce=Me;for(let ft=z.length;ft--;)if(z[ft].samples.length){ce=z[ft];break}const st=ce.lastSampleDurationOffset,{defaultSampleDurationOffset:di}=Me,je=Math.abs(d.duration-(O-K))>.05,rt=we.length<L.sampleCount;if(!(je||rt||this.videoOnlyRemux||!ge))$=O-K;else{const ft=rt?ce.sampleOffset+ce.samples.reduce((Se,Ps)=>Se+Ps.size,0):void 0,Qe=je?d.duration:O-K,Vt=_E(we,Qe*S.video.timescale,st,di),Oe=rp(v,S.video.id,we.length,ft,Vt);Oe?(V=Oe,J=IE(he,we)):this.warn(`IFrame remux skipped (sn ${d.sn}); using native sample duration`),$=Oe&&Vt?Qe:O-K}}else this.warn(`Could not remux IFrame track fragment (no samples in range, trun count ${z.length})`),$=O-K}else $=Y?F-G:O-K;if(this.videoOnlyRemux&&V===v)return this.warn(`Dropping muxed I-Frame fragment that could not be remuxed to video-only (sn: ${d.sn})`),p;const de=N.timescale,te=N.start-n*de,fe=Y?S.audio.id:S.video.id;if(M=N.start/de,(a||!g)&&(LE(g,M,n,$)||de!==g.timescale)){let z=!1;const he=Y?"audio":"video";if(g){const ge=n!==0?M/n:1+M/1;z=M>=0&&Math.abs(1-ge)<.001,this.log(`${he} timestamps in track ${fe} at playlist time: ${a?"":"~"}${n} maps to ${M} with initPTS: ${g.baseTime/g.timescale} (${te/de-g.baseTime/g.timescale}s diff) (${U}) drift estimate: ${ge} ${z?"(ignoring drift)":"remapping timestamps (initPTS)"}`)}z||(this.log(`Found initPTS in ${he} track ${fe} at playlist time: ${n} offset: ${M-n} (${te}/${de})`),g=null,y.initPTS=te,y.timescale=de,y.trackId=fe)}g?(y.initPTS=g.baseTime,y.timescale=g.timescale,y.trackId=g.trackId):((!y.timescale||y.trackId===void 0||y.initPTS===void 0)&&(this.warn("Could not set initPTS"),y.initPTS=M,y.timescale=1,y.trackId=-1),this.initPTS=g={baseTime:y.initPTS,timescale:y.timescale,trackId:y.trackId});const le=M-g.baseTime/g.timescale,pe=le+$,Pe=w&&N?.ptsMin!==void 0?N.ptsMin/N.timescale-g.baseTime/g.timescale:le,it=J!==void 0&&L?J/L.timescale-g.baseTime/g.timescale:w&&N!=null&&N.ptsMax?N.ptsMax/N.timescale-g.baseTime/g.timescale:pe;$>0?this.lastEndTime=pe:(this.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const dt=(S.audio?S.audio.encrypted:!1)||(S.video?S.video.encrypted:!1),_e={data1:V,data2:se,startPTS:Pe,startDTS:le,endPTS:it,endDTS:pe,type:U,hasAudio:k,hasVideo:w,nb:1,dropped:0,encrypted:dt};p.audio=k&&!w?_e:void 0,p.video=w?_e:void 0;const ht=this.isVideoContiguous,St=L?.sampleCount;if(St){const z=L.keyFrameIndex,he=z!==-1;_e.nb=St,_e.dropped=z===0||ht?0:he?z:St,_e.independent=he,_e.firstKeyFrame=z,he&&L.keyFrameStart&&(_e.firstKeyFramePTS=(L.keyFrameStart-g.baseTime)/g.timescale),ht||(p.independent=he),this.isVideoContiguous||(this.isVideoContiguous=he),_e.dropped&&this.warn(`fmp4 does not start with IDR: firstIDR ${z}/${St} dropped: ${_e.dropped} start: ${_e.firstKeyFramePTS||"NA"}`)}return p.initSegment=y,p.id3=rf(i,n,g,g),r.samples.length&&(p.text=nf(r,n,g)),p}}function $r(s,e,t=!1){return s?.start!==void 0?(s.start+(t?s.duration:0))/s.timescale:e}function IE(s,e){let t=s,i=s;for(let r=0;r<e.length;r++){const{cts:n,duration:a}=e[r];i=Math.max(i,t+(n||0)+a),t+=a}return i}function _E(s,e,t,i){if(t!==void 0){const n=s[s.length-1];let a=e;for(let o=0;o<s.length-1;o++)a-=s[o].duration;return a<=0&&(a=n.duration),n.duration=a,{durationOffset:t,value:a}}if(i===void 0)return;const r=Math.round(e/s.length);for(let n=0;n<s.length;n++)s[n].duration=r;return{durationOffset:i,value:r}}function LE(s,e,t,i){if(s===null)return!0;const r=Math.max(i,1),n=e-s.baseTime/s.timescale;return Math.abs(n-t)>=r}function Sc(s,e,t){const i=s.codec;return i&&i.length>4?i:e===xe.AUDIO?i==="ec-3"||i==="ac-3"||i==="alac"?i:i==="fLaC"||i==="Opus"?Gn(i,!1):(t.warn(`Unhandled audio codec "${i}" in mp4 MAP`),i||"mp4a"):i==="mjpg"?i:(t.warn(`Unhandled video codec "${i}" in mp4 MAP`),i||"avc1")}let Li;try{Li=self.performance.now.bind(self.performance)}catch{Li=Date.now}const un=[{demux:tE,remux:bE},{demux:pi,remux:cn},{demux:X0,remux:cn},{demux:J0,remux:cn}];un.splice(2,0,{demux:Z0,remux:cn});class Ac{constructor(e,t,i,r,n,a){this.asyncResult=!1,this.logger=void 0,this.observer=void 0,this.typeSupp
vendor: 7,954 bytes, line 58
58orted=void 0,this.config=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=i,this.id=n,this.logger=a}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,i,r){if(!this.observer)return Br(i);const n=i.transmuxing;n.executeStart=Li();const a=new Uint8Array(e),{currentTransmuxState:o,transmuxConfig:l}=this;r&&(this.currentTransmuxState=r);const{contiguous:d,discontinuity:c,trackSwitch:u,accurateTimeOffset:h,timeOffset:f,initSegmentChange:g}=r||o,{audioCodec:m,videoCodec:p,defaultInitPts:v,duration:T,initSegmentData:y}=l,S=xE(a,t);if(S&&ys(S.method)){const R=this.getDecrypter(),D=xl(S.method);return this.asyncResult=!0,this.decryptionPromise=R.decrypt(a,S.key.buffer,S.iv.buffer,D,i.decryptRange).then(L=>{const k=this.push(L,null,i);return this.decryptionPromise=null,k}),this.decryptionPromise}const A=this.needsProbing(c,u);if(A){const R=i.iframe&&y&&pi.probe(y,this.logger)?y:a,D=this.configureTransmuxer(R);if(D)return this.logger.warn(`[transmuxer] ${D.message}`),this.observer.emit(E.ERROR,E.ERROR,{type:X.MEDIA_ERROR,details:x.FRAG_PARSING_ERROR,fatal:!1,error:D,reason:D.message}),n.executeEnd=Li(),Br(i)}(c||u||g||A)&&this.resetInitSegment(y,m,p,T,t,i),(c||g||A)&&this.resetInitialTimestamp(v),d||this.resetContiguity();const I=this.transmux(a,S,f,h,i);this.asyncResult=Er(I);const _=this.currentTransmuxState;return _.contiguous=!0,_.discontinuity=!1,_.trackSwitch=!1,n.executeEnd=Li(),I}flush(e){const t=e.transmuxing;t.executeStart=Li();const{decrypter:i,currentTransmuxState:r,decryptionPromise:n}=this;if(n)return this.asyncResult=!0,n.then(()=>this.flush(e));const a=[],{timeOffset:o}=r;if(i){const u=i.flush();u&&a.push(this.push(u.buffer,null,e))}const{demuxer:l,remuxer:d}=this;if(!l||!d){t.executeEnd=Li();const u=[Br(e)];return this.asyncResult?Promise.resolve(u):u}const c=l.flush(o,e);return Er(c)?(this.asyncResult=!0,c.then(u=>(this.flushRemux(a,u,e),a))):(this.flushRemux(a,c,e),this.asyncResult?Promise.resolve(a):a)}flushRemux(e,t,i){if(!this.remuxer)return;const{audioTrack:r,videoTrack:n,id3Track:a,textTrack:o}=t,{accurateTimeOffset:l,timeOffset:d}=this.currentTransmuxState;this.logger.log(`[transmuxer.ts]: Flushed ${this.id} sn: ${i.sn}${i.part>-1?" part: "+i.part:""} of ${this.id} playlist ${i.level}`);const c=this.remuxer.remux(r,n,a,o,d,l,!0,this.id,i,t.initData,t.sampleData);e.push({remuxResult:c,chunkMeta:i}),i.transmuxing.executeEnd=Li()}resetInitialTimestamp(e){const{demuxer:t,remuxer:i}=this;!t||!i||(t.resetTimeStamp(e),i.resetTimeStamp(e))}resetContiguity(){const{demuxer:e,remuxer:t}=this;!e||!t||(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,i,r,n,a){const{demuxer:o,remuxer:l}=this;!o||!l||(o.resetInitSegment(e,t,i,r,n,a),l.resetInitSegment(e,t,i,n))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0),this.observer&&this.observer.removeAllListeners(),this.decryptionPromise=null,this.decrypter=this.observer=void 0,this.logger=this.config=this.probe=void 0}transmux(e,t,i,r,n){let a;return t?.method==="SAMPLE-AES"?a=this.transmuxSampleAes(e,t,i,r,n):a=this.transmuxUnencrypted(e,i,r,n),a}transmuxUnencrypted(e,t,i,r){const{demuxer:n,remuxer:a}=this;if(!n||!a)return Br(r);const o=n.demux(e,t,r,!1,!this.config.progressive),{audioTrack:l,videoTrack:d,id3Track:c,textTrack:u}=o;return{remuxResult:a.remux(l,d,c,u,t,i,!1,this.id,r,o.initData,o.sampleData),chunkMeta:r}}transmuxSampleAes(e,t,i,r,n){return this.demuxer?this.demuxer.demuxSampleAes(e,t,i,n).then(a=>({remuxResult:this.remuxer.remux(a.audioTrack,a.videoTrack,a.id3Track,a.textTrack,i,r,!1,this.id,n,a.initData,a.sampleData),chunkMeta:n})):Promise.reject(new Error("no demuxer"))}configureTransmuxer(e){const{config:t,observer:i,typeSupported:r}=this;if(!i)return;let n;try{for(let u=0,h=un.length;u<h;u++){var a;if((a=un[u].demux)!=null&&a.probe(e,this.logger)){n=un[u];break}}}catch(u){return u}if(!n)return new Error("Failed to find demuxer by probing fragment data");const o=this.demuxer,l=this.remuxer,d=n.demux,c=n.remux;(!o||!(o instanceof d))&&(this.logger.log(`Using ${d.name}`),this.demuxer=new d(i,t,r,this.logger),this.probe=d.probe),(!l||!(l instanceof c))&&(this.logger.log(`Using ${c.name}`),this.remuxer=new c(i,t,r,this.logger))}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new Il(this.config)),e}}function xE(s,e){let t=null;return s.byteLength>0&&e?.key!=null&&e.iv!==null&&e.method!=null&&(t=e),t}const Br=s=>({remuxResult:{},chunkMeta:s});function Er(s){return"then"in s&&s.then instanceof Function}class RE{constructor(e,t,i,r,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=i,this.duration=r,this.defaultInitPts=n||null}}class DE{constructor(e,t,i,r,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=i,this.trackSwitch=r,this.timeOffset=n,this.initSegmentChange=a}}let bc=0;class af{constructor(e,t,i,r){this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=bc++,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.onWorkerMessage=l=>{const d=l.data,c=this.hls;if(!(!c||!(d!=null&&d.event)||d.instanceNo!==this.instanceNo))switch(d.event){case"init":{var u;const h=(u=this.workerContext)==null?void 0:u.objectURL;h&&self.URL.revokeObjectURL(h);break}case"transmuxComplete":{this.handleTransmuxComplete(d.data);break}case"flush":{this.onFlush(d.data);break}case"workerLog":{c.logger[d.data.logType]&&c.logger[d.data.logType](d.data.message);break}default:{d.data=d.data||{},d.data.frag=this.frag,d.data.part=this.part,d.data.id=this.id,c.trigger(d.event,d.data);break}}},this.onWorkerError=l=>{if(!this.hls)return;const d=new Error(`${l.message}  (${l.filename}:${l.lineno})`);this.hls.config.enableWorker=!1,this.hls.logger.warn(`Error in "${this.id}" Web Worker, fallback to inline`),this.hls.trigger(E.ERROR,{type:X.OTHER_ERROR,details:x.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:d})};const n=e.config;this.hls=e,this.id=t,this.useWorker=!!n.enableWorker,this.onTransmuxComplete=i,this.onFlush=r;const a=(l,d)=>{d=d||{},d.frag=this.frag||void 0,l===E.ERROR&&(d=d,d.parent=this.id,d.part=this.part,this.error=d.error),this.hls.trigger(l,d)};this.observer=new kl,this.observer.on(E.FRAG_DECRYPTED,a),this.observer.on(E.ERROR,a);const o=Ud(n.preferManagedMediaSource);if(this.useWorker&&typeof Worker<"u"){const l=this.hls.logger;if(n.workerPath||F0()){try{n.workerPath?(l.log(`loading Web Worker ${n.workerPath} for "${t}"`),this.workerContext=U0(n.workerPath)):(l.log(`injecting Web Worker for "${t}"`),this.workerContext=N0());const{worker:c}=this.workerContext;c.addEventListener("message",this.onWorkerMessage),c.addEventListener("error",this.onWorkerError),c.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:o,id:t,config:Re(n)})}catch(c){l.warn(`Error setting up "${t}" Web Worker, fallback to inline`,c),this.terminateWorker(),this.error=null,this.transmuxer=new Ac(this.observer,o,n,"",t,e.logger)}return}}this.transmuxer=new Ac(this.observer,o,n,"",t,e.logger)}reset(){if(this.frag=null,this.part=null,this.workerContext){const e=this.instanceNo;this.instanceNo=bc++;const t=this.hls.config,i=Ud(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:i,id:this.id,c
vendor: 36,236 bytes, lines 58-67
58onfig:Re(t)})}}terminateWorker(){if(this.workerContext){const{worker:e}=this.workerContext;this.workerContext=null,e.removeEventListener("message",this.onWorkerMessage),e.removeEventListener("error",this.onWorkerError),$0(this.hls.config.workerPath)}}destroy(){if(this.workerContext)this.terminateWorker(),this.onWorkerMessage=this.onWorkerError=null;else{const t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}const e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.part=null,this.observer=null,this.hls=null}push(e,t,i,r,n,a,o,l,d,c){var u,h;d.transmuxing.start=self.performance.now();const{instanceNo:f,transmuxer:g}=this,m=a?a.start:n.start,p=n.decryptdata,v=this.frag,T=v?n.cc!==v.cc:!0,y=v?d.level!==v.level:!0,S=v?d.sn-v.sn:-1,A=this.part?d.part-this.part.index:-1,I=S===0&&d.id>1&&d.id===v?.stats.chunkCount,_=!y&&(S===1||S===0&&(A===1||I&&A<=0)),R=self.performance.now();(y||S||n.stats.parsing.start===0)&&(n.stats.parsing.start=R),a&&(A||!_)&&(a.stats.parsing.start=R);const D=!(v&&((u=n.initSegment)==null?void 0:u.url)===((h=v.initSegment)==null?void 0:h.url)),L=new DE(T,_,l,y,m,D);if(!_||T||D){this.hls.logger.log(`[transmuxer-interface]: Starting new transmux session for ${n.type} sn: ${d.sn}${d.part>-1?" part: "+d.part:""} ${this.id} playlist: ${d.level} id: ${d.id}
59        discontinuity: ${T}
60        trackSwitch: ${y}
61        contiguous: ${_}
62        accurateTimeOffset: ${l}
63        timeOffset: ${m}
64        initSegmentChange: ${D}`);const k=new RE(i,r,t,o,c);this.configureTransmuxer(k)}if(this.frag=n,this.part=a,this.workerContext)this.workerContext.worker.postMessage({instanceNo:f,cmd:"demux",data:e,decryptdata:p,chunkMeta:d,state:L},e instanceof ArrayBuffer?[e]:[]);else if(g){const k=g.push(e,p,d,L);Er(k)?k.then(w=>{this.handleTransmuxComplete(w)}).catch(w=>{this.transmuxerError(w,d,"transmuxer-interface push error")}):this.handleTransmuxComplete(k)}}flush(e){e.transmuxing.start=self.performance.now();const{instanceNo:t,transmuxer:i}=this;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:t,cmd:"flush",chunkMeta:e});else if(i){const r=i.flush(e);Er(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,i){this.hls&&(this.error=e,this.hls.trigger(E.ERROR,{type:X.MEDIA_ERROR,details:x.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:e,err:e,reason:i}))}handleFlushResult(e,t){e.forEach(i=>{this.handleTransmuxComplete(i)}),this.onFlush(t)}configureTransmuxer(e){const{instanceNo:t,transmuxer:i}=this;this.workerContext?this.workerContext.worker.postMessage({instanceNo:t,cmd:"configure",config:e}):i&&i.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}const Ic=100;class kE extends Dl{constructor(e,t,i){super(e,t,i,"audio-stream-controller",j.AUDIO),this.mainAnchor=null,this.mainFragLoading=null,this.audioOnly=!1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.nextTrackId=-1,this.waitingData=null,this.mainDetails=null,this.flushing=!1,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this.registerListeners()}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.resetItem()}resetItem(){this.mainDetails=this.mainAnchor=this.mainFragLoading=this.bufferedTrack=this.switchingTrack=this.waitingData=this.cachedTrackLoadedData=null}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(E.LEVEL_LOADED,this.onLevelLoaded,this),e.on(E.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(E.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(E.BUFFER_RESET,this.onBufferReset,this),e.on(E.BUFFER_CREATED,this.onBufferCreated,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(E.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(E.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(E.FRAG_LOADING,this.onFragLoading,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){const{hls:e}=this;e&&(super.unregisterListeners(),e.off(E.LEVEL_LOADED,this.onLevelLoaded,this),e.off(E.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(E.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(E.BUFFER_RESET,this.onBufferReset,this),e.off(E.BUFFER_CREATED,this.onBufferCreated,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(E.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(E.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(E.FRAG_LOADING,this.onFragLoading,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this))}onInitPtsFound(e,t){const{frag:i,id:r,initPTS:n,timescale:a,trackId:o,timestampOffsets:l}=t;if(r===j.MAIN){const d=i.cc,c=this.fragCurrent;if(this.initPTS=l,this.log(`InitPTS for cc: ${d} found from main: ${n/a} (${n}/${a}) trackId: ${o}`),this.mainAnchor=i,this.state===C.WAITING_INIT_PTS){const u=this.waitingData;(!u&&!this.loadingParts||u&&u.frag.cc!==d)&&this.syncWithAnchor(i,u?.frag)}else!this.hls.hasEnoughToStart&&c&&c.cc!==d?(c.abortRequests(),this.syncWithAnchor(i,c)):this.state===C.IDLE&&this.tick()}}getLoadPosition(){var e;return!this.startFragRequested&&this.nextLoadPosition>=0&&((e=this.switchingTrack)==null?void 0:e.flushImmediate)!==!1?this.nextLoadPosition:super.getLoadPosition()}syncWithAnchor(e,t){var i;const r=((i=this.mainFragLoading)==null?void 0:i.frag)||null;if(t&&r?.cc===t.cc)return;const n=(r||e).cc,a=this.getLevelDetails(),o=this.getLoadPosition(),l=Ah(a,n,o);l&&(this.log(`Syncing with main frag at ${l.start} cc ${l.cc}`),this.startFragRequested=!1,this.nextLoadPosition=l.start,this.resetLoadingState(),this.state===C.IDLE&&this.doTickIdle())}startLoad(e,t){if(!this.levels){this.startPosition=e,this.state=C.STOPPED;return}const i=this.lastCurrentTime;this.stopLoad(),this.setInterval(Ic),i>0&&e===-1&&!t&&this.initPTS.length&&(this.log(`Override startPosition with lastCurrentTime @${i.toFixed(3)}`),e=i),this.state=C.IDLE,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,!t&&!this.fragmentTracker.hasFragments(this.playlistType)&&(this.startFragRequested=!1),this.tick()}doTick(){switch(this.state){case C.IDLE:this.doTickIdle();break;case C.WAITING_TRACK:{const{levels:e,trackId:t}=this,i=e?.[t],r=i?.details;if(r&&!this.waitForLive(i)){if(this.waitForCdnTuneIn(r))break;this.state=C.WAITING_INIT_PTS}break}case C.FRAG_LOADING_WAITING_RETRY:{this.checkRetryDate();break}case C.WAITING_INIT_PTS:{const e=this.waitingData;if(e){const{frag:t,part:i,cache:r,complete:n}=e,a=this.mainAnchor;if(this.initPTS[t.cc]!==void 0){this.waitingData=null,this.state=C.FRAG_LOADING;const o=r.flush().buffer,l={frag:t,part:i,payload:o,networkDetails:null};this._handleFragmentLoadProgress(l),n&&super._handleFragmentLoadComplete(l)}else a&&a.cc!==e.frag.cc&&this.syncWithAnchor(a,e.frag)}else this.state=C.IDLE}}this.onTickEnd()}resetLoadingState(){const e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null),super.resetLoadingState()}onTickEnd(){const{media:e}=this;e!=null&&e.readyState&&(this.lastCurrentTime=e.currentTime,this.checkFragmentChanged())}doTickIdle(){var e;const{hls:t,levels:i,media:r,trackId:n}=this,a=t.config;if(!this.buffering||!r&&!this.primaryPrefetch&&(this.startFragRequested||!a.startFragPrefetch)||!(i!=null&&i[n]))return;const o=i[n],l=o.details;if(!l||this.waitForLive(o)||this.waitForCdnTuneIn(l)){this.state=C.WAITING_TRACK,this.startFragRequested=!1;return}const d=this.getBufferOutput();this.bufferFlushed&&d&&(this.bufferFlushed=!1,this.afterBufferFlushed(d,xe.AUDIO));const c=this.getFwdBufferInfo();if(c===null)return;if(!this.switchingTrack&&this._streamEnded(c,l)){t.trigger(E.BUFFER_EOS,{type:"audio"}),this.state=C.ENDED;return}const u=c.len,h=t.maxBufferLength,f=l.fragments,g=f[0].start,m=this.getLoadPosition(),p=this.flushing||this.switchingTrack&&!this.switchingTrack.flushImmediate?m:c.end;if(this.switchingTrack&&r){const y=m;l.PTSKnown&&y<g&&y>=this.timelineOffset&&(c.end>g||c.nextStart)&&(this.log(`Alt audio track ahead of main track, seek to start of alt audio track ${y} -> ${g} + 0.05`),r.currentTime=g+.05)}if(u>=h&&!this.switchingTrack&&p<f[f.length-1].start)return;let v=this.getNextFragment(p,l);if(v&&this.isLoopLoading(v,p)&&(v=this.getNextFragmentLoopLoading(v,l,c,j.MAIN,h)),!v){this.bufferFlushed=!0;return}if(this.exceedsMaxBuffer(c,h,v))return;let T=((e=this.mainFragLoading)==null?void 0:e.frag)||null;if(!this.audioOnly&&this.startFragRequested&&T&&Ue(v)&&!v.endList&&(!l.live||!this.loadingParts&&p<this.hls.liveSyncPosition)&&(this.fragmentTracker.getState(T)===Ce.OK&&(this.mainFragLoading=T=null),T&&Ue(T))){if(v.start>T.end){const S=this.fragmentTracker.getFragAtPos(p,j.MAIN);S&&S.end>T.end&&(T=S,this.mainFragLoading={frag:S,targetBufferTime:null})}if(v.start>T.end)return}this.loadFragment(v,o,p)}onMediaDetaching(e,t){this.bufferFlushed=this.flushing=!1,super.onMediaDetaching(e,t)}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(i=>new gr(i))}onAudioTrackSwitching(e,t){const i=!!t.url;this.trackId=t.id;const{fragCurrent:r}=this;r&&(r.abortRequests(),this.removeUnbufferedFrags(r.start)),this.resetLoadingState(),i?(this.switchingTrack=t,t.flushImmediate||(this.nextTrackId=t.id,this.nextLevelSwitch()),this.flushAudioIfNeeded(t),this.state!==C.STOPPED&&(this.setInterval(Ic),this.state=C.IDLE,this.tick())):(this.resetTransmuxer(),this.switchingTrack=null,this.bufferedTrack=t,this.clearInterval())}onManifestLoading(){super.onManifestLoading(),this.bufferFlushed=this.flushing=this.audioOnly=!1,this.resetItem(),this.trackId=-1}onLevelLoaded(e,t){this.mainDetails=t.details;const i=this.cachedTrackLoadedData;i&&(this.cachedTrackLoadedData=null,this.onAudioTrackLoaded(E.AUDIO_TRACK_LOADED,i))}onAudioTrackLoaded(e,t){var i;const{levels:r}=this,{details:n,id:a,groupId:o,track:l}=t;if(!r){this.warn(`Audio tracks reset while loading track ${a} "${l.name}" of "${o}"`);return}const d=this.mainDetails;if(!d||n.endCC>d.endCC||d.expired){this.cachedTrackLoadedData=t,this.state!==C.STOPPED&&(this.state=C.WAITING_TRACK);return}this.cachedTrackLoadedData=null,this.log(`Audio track ${a} "${l.name}" of "${o}" loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`);const c=r[a];let u=0;if(n.live||(i=c.details)!=null&&i.live){if(this.checkLiveUpdate(n),n.deltaUpdateFailed)return;if(c.details){var h;u=this.alignPlaylists(n,c.details,(h=this.levelLastLoaded)==null?void 0:h.details)}n.alignedSliding||(qn(d,n,this),u=n.fragmentStart)}c.details=n,this.levelLastLoaded=c,this.startFragRequested||this.setStartPosition(d,u),this.hls.trigger(E.AUDIO_TRACK_UPDATED,{details:n,id:a,groupId:t.groupId}),this.state===C.WAITING_TRACK&&!this.waitForCdnTuneIn(n)&&(this.state=C.IDLE),this.tick()}_handleFragmentLoadProgress(e){var t;const i=e.frag,{part:r,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 ${i.sn} of level ${i.level} will not be buffered`);return}const d=l[o];if(!d){this.warn("Audio track is undefined on fragment load progress");return}const c=d.details;if(!c){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(i.start);return}const u=a.defaultAudioCodec||d.audioCodec||"mp4a.40.2";let h=this.transmuxer;h||(h=this.transmuxer=new af(this.hls,j.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const f=this.initPTS[i.cc],g=(t=i.initSegment)==null?void 0:t.data;if(f!==void 0){const p=r?r.index:-1,v=p!==-1,T=new _l(i.level,i.sn,i.stats.chunkCount,n.byteLength,p,v,i.duration);h.push(n,g,u,"",i,r,c.totalduration,!1,T,f)}else{this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${c.startSN} ,${c.endSN}],track ${o}`);const{cache:m}=this.waitingData=this.waitingData||{frag:i,part:r,cache:new Vh,complete:!1};m.push(new Uint8Array(n)),this.state!==C.STOPPED&&(this.state=C.WAITING_INIT_PTS)}}_handleFragmentLoadComplete(e){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=null}onBufferCreated(e,t){this.bufferFlushed=this.flushing=!1;const i=t.tracks.audio;i&&(this.mediaBuffer=i.buffer||null)}onFragLoading(e,t){!this.audioOnly&&t.frag.type===j.MAIN&&Ue(t.frag)&&(this.mainFragLoading=t,this.state===C.IDLE&&this.tick())}onFragBuffered(e,t){const{frag:i,part:r}=t;if(i.type!==j.AUDIO){!this.audioOnly&&i.type===j.MAIN&&!i.elementaryStreams.video&&!i.elementaryStreams.audiovideo&&(this.audioOnly=!0,this.mainFragLoading=null);return}if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${r?" p: "+r.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if(Ue(i)){const n=this.switchingTrack;n&&(this.bufferedTrack=n)}this.fragBufferedComplete(i,r),this.media&&this.tick()}getFwdBufferInfo(){const e=this.getBufferOutput();return super.getFwdBufferInfo(e,j.AUDIO)}getBufferOutput(){return this.mediaBuffer?this.mediaBuffer:this.media}checkFragmentChanged(){const e=this.fragPlaying;if(!this.checkFragPlaying())return!1;const i=this.fragPlaying,r=e?.level;return(!i||i.level!==r)&&(e&&this.cleanupBackBuffer(),this.switchingTrack&&this.completeAudioSwitch(this.switchingTrack)),!0}onError(e,t){var i;if(t.fatal){this.state=C.ERROR;return}switch(t.details){case x.FRAG_GAP:case x.FRAG_PARSING_ERROR:case x.FRAG_DECRYPT_ERROR:case x.FRAG_LOAD_ERROR:case x.FRAG_LOAD_TIMEOUT:case x.KEY_LOAD_ERROR:case x.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(j.AUDIO,t);break;case x.AUDIO_TRACK_LOAD_ERROR:case x.AUDIO_TRACK_LOAD_TIMEOUT:case x.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===C.WAITING_TRACK&&((i=t.context)==null?void 0:i.type)===ue.AUDIO_TRACK&&(this.state=C.IDLE);break;case x.BUFFER_APPEND_NO_PROGRESS:if(t.parent!=="audio")return;t.frag&&(t.appendsWithoutProgress||0)>=this.config.appendErrorMaxRetry&&(this.warn(`Marking fragment ${t.frag.sn} of track ${t.frag.level} as a gap after ${t.appendsWithoutProgress} appends without buffered range growth, to prevent loop loading`),this.fragmentTracker.addAsGap(t.frag));break;case x.BUFFER_ADD_CODEC_ERROR:case x.BUFFER_APPEND_ERROR:if(t.parent!=="audio")return;this.reduceLengthAndFlushBuffer(t)||this.resetLoadingState();break;case x.BUFFER_FULL_ERROR:if(t.parent!=="audio")return;this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case x.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onBufferFlushing(e,{type:t}){t!==xe.VIDEO&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==xe.VIDEO){this.flushing=!1,this.bufferFlushed=!0,this.state===C.ENDED&&(this.state=C.IDLE);const i=this.getBufferOutput();i&&(this.afterBufferFlushed(i,t),this.tick())}}_handleTransmuxComplete(e){var t;const i="audio",{hls:r}=this,{remuxResult:n,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}const{frag:l,part:d,level:c}=o,{details:u}=c,{audio:h,text:f,id3:g,initSegment:m}=n;if(this.fragContextChanged(l)||!u){this.fragmentTracker.removeFragment(l),m!=null&&m.tracks&&this.resetTransmuxer();return}if(this.state=C.PARSING,h&&this.switchingTrack&&!this.switchingTrack.flushImmediate){const{config:p}=this,v=p.nextAudioTrackBufferFlushForwardOffset,T=Math.max(this.getLoadPosition()+v,l.start);super.flushMainBuffer(T,Number.POSITIVE_INFINITY,j.AUDIO)}if(m!=null&&m.tracks){const p=l.initSegment||l;if(this.unhandledEncryptionError(m,l))return;this._bufferInitSegment(c,m.tracks,p,a),r.trigger(E.FRAG_PARSING_INIT_SEGMENT,{frag:p,id:i,tracks:m.tracks})}if(h){const{startPTS:p,endPTS:v,startDTS:T,endDTS:y}=h;d&&(d.elementaryStreams[xe.AUDIO]={startPTS:p,endPTS:v,startDTS:T,endDTS:y}),l.setElementaryStreamInfo(xe.AUDIO,p,v,T,y),this.bufferFragmentData(h,l,d,a)}if(g!=null&&(t=g.samples)!=null&&t.length){const p=Ie({id:i,frag:l,details:u},g);r.trigger(E.FRAG_PARSING_METADATA,p)}if(f){const p=Ie({id:i,frag:l,details:u},f);r.trigger(E.FRAG_PARSING_USERDATA,p)}}_bufferInitSegment(e,t,i,r){if(this.state!==C.PARSING||(t.video&&delete t.video,t.audiovideo&&delete t.audiovideo,!t.audio))return;const n=t.audio;n.id=j.AUDIO;const a=e.audioCodec;this.log(`Init audio buffer, container:${n.container}, codecs[level/parsed]=[${a}/${n.codec}]`),a?.split(",").length===1&&(n.levelCodec=a),this.hls.trigger(E.BUFFER_CODECS,t);const o=n.initSegment;if(o!=null&&o.byteLength){const l={type:"audio",frag:i,part:null,chunkMeta:r,parent:i.type,data:o};this.hls.trigger(E.BUFFER_APPENDING,l)}this.tickImmediate()}loadFragment(e,t,i){const r=this.fragmentTracker.getState(e);if(this.switchingTrack||r===Ce.NOT_LOADED||r===Ce.PARTIAL){var n;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=C.WAITING_INIT_PTS;const a=this.mainDetails;a&&a.fragmentStart!==t.details.fragmentStart&&qn(a,t.details,this)}else super.loadFragment(e,t,i)}else this.clearTrackerIfNeeded(e)}flushAudioIfNeeded(e){if(this.media&&this.bufferedTrack&&e.flushImmediate){const{name:t,lang:i,assocLang:r,characteristics:n,audioCodec:a,channels:o}=this.bufferedTrack;Ki({name:t,lang:i,assocLang:r,characteristics:n,audioCodec:a,channels:o},e,Ni)||(Hn(e.url,this.hls)?(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null):this.bufferedTrack=e)}}completeAudioSwitch(e){const{hls:t}=this;this.bufferedTrack=e,this.switchingTrack=null,t.trigger(E.AUDIO_TRACK_SWITCHED,Z({},e))}get nextAudioTrack(){return this.nextTrackId}}class Ol extends Dt{constructor(e,t){super(t,e.logger),this.hls=void 0,this.canLoad=!1,this.timer=-1,this.hls=e}destroy(){this.clearTimer(),this.hls=null}clearTimer(){this.timer!==-1&&(self.clearTimeout(this.timer),this.timer=-1)}startLoad(){this.canLoad=!0,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t,i){const r=t?.renditionReports;if(r){let n=-1;for(let a=0;a<r.length;a++){const o=r[a];let l;try{l=new self.URL(o.URI,t.url).href}catch(d){this.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){const a=r[n],o=parseInt(a["LAST-MSN"])||t.lastPartSn;let l=parseInt(a["LAST-PART"])||t.lastPartIndex;if(this.hls.config.lowLatencyMode){const c=Math.min(t.age-t.partTarget,t.targetduration);l>=0&&c>t.partTarget&&(l+=1)}const d=i&&$d(i);return new Bd(o,l>=0?l:void 0,d)}}}loadPlaylist(e){this.clearTimer()}loadingPlaylist(e,t){this.clearTimer()}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}getUrlWithDirectives(e,t){if(t)try{return t.addDirectives(e)}catch(i){this.warn(`Could not construct new URL with HLS Delivery Directives: ${i}`)}return e}playlistLoaded(e,t,i){const{details:r,stats:n}=t,a=r.fragments,o=self.performance.now(),l=n.loading.first?Math.max(0,Math.floor(o-n.loading.first)):0;r.advancedDateTime=Date.now()-l;const d=this.hls.config.timelineOffset;if(d!==r.appliedTimelineOffset){const u=Math.max(d||0,0);r.appliedTimelineOffset=u,a.forEach(h=>{h?.setStart(h.playlistOffset+u)})}if(r.live||i!=null&&i.live){var c;const u="levelInfo"in t?t.levelInfo:t.track;r.reloaded(i);const h=(c=a[a.length-1])==null?void 0:c.type;if(r.misses>=this.hls.config.liveMaxUnchangedPlaylistRefresh){const A=new Error(`${h} playlist ${u.id} hit max allowed unchanged reloads.`);this.warn(A);const{networkDetails:I,context:_}=t;this.hls.trigger(E.ERROR,{type:X.NETWORK_ERROR,details:x.PLAYLIST_UNCHANGED_ERROR,fatal:!1,url:r.url,error:A,reason:A.message,level:t.level,parent:h,context:_,networkDetails:I,stats:n});return}if(i){I0(i,r,this);const A=r.playlistParsingError;if(A){this.warn(A);const I=this.hls;if(!I.config.ignorePlaylistParsingErrors){const{networkDetails:_}=t;I.trigger(E.ERROR,{type:X.NETWORK_ERROR,details:x.LEVEL_PARSING_ERROR,fatal:!1,url:r.url,error:A,reason:A.message,level:t.level,parent:h,networkDetails:_,stats:n});return}r.playlistParsingError=null}}r.requestScheduled===-1&&(r.requestScheduled=n.loading.start);const f=this.hls.mainForwardBufferInfo,g=f?f.end-f.len:0,m=(r.edge-g)*1e3,p=Fh(r,m);r.requestScheduled+p<o?r.requestScheduled=o:r.requestScheduled<=o&&(r.requestScheduled+=p);const v=t.deliveryDirectives;if(this.log(`live playlist ${e} ${r.advanced?`REFRESHED ${r.lastPartSn} - ${r.lastPartIndex}`:r.updated?"UPDATED":`MISSED (received ${r.lastPartSn} - ${r.lastPartIndex}${v?` | requested ${v.msn} - ${v.part}`:""})`}`),!this.canLoad||!r.live)return;let T,y,S;if(r.canBlockReload&&r.endSN&&r.advanced){const A=this.hls.config.lowLatencyMode,I=r.lastPartSn,_=r.endSN,R=r.lastPartIndex,D=R!==-1,L=I===_;D?L?(y=_+1,S=A?0:R):(y=I,S=A?R+1:r.maxPartIndex):y=_+1;const k=r.age,w=k+r.ageHeader;let U=Math.min(w-r.partTarget,r.targetduration*1.5);if(U>0){if(w>r.targetduration*3)this.log(`Playlist last advanced ${k.toFixed(2)}s ago. Omitting segment and part directives.`),y=void 0,S=void 0;else if(i!=null&&i.tuneInGoal&&w-r.partTarget>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${U} with playlist age: ${r.age}`),U=0;else{const K=Math.floor(U/r.targetduration);if(y+=K,S!==void 0){const G=Math.round(U%r.targetduration/r.partTarget);S+=G}this.log(`CDN Tune-in age: ${r.ageHeader}s last advanced ${k.toFixed(2)}s goal: ${U} skip sn ${K} to part ${S}`)}r.tuneInGoal=U}if(T=this.getDeliveryDirectives(r,t.deliveryDirectives,y,S),A||!L){r.requestScheduled=o,this.loadingPlaylist(u,T);return}}else(r.canBlockReload||r.canSkipUntil)&&(T=this.getDeliveryDirectives(r,t.deliveryDirectives,y,S));T&&y!==void 0&&r.canBlockReload&&(r.requestScheduled=n.loading.first+Math.max(p-l*2,p/2)),this.scheduleLoading(u,T,r)}else this.clearTimer()}scheduleLoading(e,t,i){const r=i||e.details;if(!r){this.loadingPlaylist(e,t);return}const n=self.performance.now(),a=r.requestScheduled;if(n>=a){this.loadingPlaylist(e,t);return}const o=a-n;this.log(`reload live playlist ${e.name||e.bitrate+"bps"} in ${Math.round(o)} ms`),this.clearTimer(),this.timer=self.setTimeout(()=>this.loadingPlaylist(e,t),o)}getDeliveryDirectives(e,t,i,r){let n=$d(e);return t!=null&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,r=t.part,n=dn.No),new Bd(i,r,n)}checkRetry(e){const t=e.details,i=$n(e),r=e.errorAction,{action:n,retryCount:a=0,retryConfig:o}=r||{},l=!!r&&!!o&&(n===ot.RetryRequest||!r.resolved&&n===ot.SendAlternateToPenaltyBox);if(l){var d;if(a>=o.maxNumRetry)return!1;if(i&&(d=e.context)!=null&&d.deliveryDirectives)this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{var c;const u=dr((c=e.response)==null?void 0:c.code);if(this.clearTimer(),u)this.log("Waiting for connection (offline)"),e.reason="offline",this.timer=self.setTimeout(()=>this.checkOfflineStatus(),1e3);else{const h=vl(o,a);this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" in ${h}ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(),h)}}e.levelRetry=!0,r.resolved=!0}return l}checkOfflineStatus(){this.clearTimer(),dr(0)?this.timer=self.setTimeout(()=>this.checkOfflineStatus(),1e3):(this.log("Connection restored (online)"),this.loadPlaylist())}}function of(s,e){if(s.length!==e.length)return!1;for(let t=0;t<s.length;t++)if(!vr(s[t].attrs,e[t].attrs))return!1;return!0}function vr(s,e,t){const i=s["STABLE-RENDITION-ID"];return i&&!t?i===e["STABLE-RENDITION-ID"]:!(t||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(r=>s[r]!==e[r])}class CE extends Ol{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(){const{hls:e}=this;e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.LEVEL_LOADING,this.onLevelLoading,this),e.on(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(E.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(E.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.LEVEL_LOADING,this.onLevelLoading,this),e.off(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(E.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(E.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){const{id:i,groupId:r,details:n}=t,a=this.tracksInGroup[i];if(!a||a.groupId!==r){this.warn(`Audio track with id:${i} and group:${r} not found in active group ${a?.groupId}`);return}const o=a.details;a.details=t.details,this.log(`Audio track ${i} "${a.name}" lang:${a.lang} group:${r} loaded [${n.startSN}-${n.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!t)return;const i=t.audioGroups||null,r=this.groupIds;let n=this.currentTrack;if(!i||r?.length!==i?.length||i!=null&&i.some(o=>r?.indexOf(o)===-1)){this.groupIds=i,this.trackId=-1,this.currentTrack=null;const o=this.tracks.filter(h=>mr(h.groupId,i));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;const l=this.hls.config.audioPreference;if(!n&&l){const h=ni(l,o,Ni);if(h>-1)n=o[h];else{const f=ni(l,this.tracks);n=this.tracks[f]}}let d=this.findTrackId(n);d===-1&&n&&(d=this.findTrackId(null));const c={audioTracks:o};this.log(`Updating audio tracks, ${o.length} track(s) found in group(s): ${i?.join(",")}`),this.hls.trigger(E.AUDIO_TRACKS_UPDATED,c);const u=this.trackId;if(d!==-1&&u===-1)this.setAudioTrack(d);else if(o.length&&u===-1){var a;const 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(E.ERROR,{type:X.MEDIA_ERROR,details:x.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:h})}}}onError(e,t){t.fatal||!t.context||t.context.type===ue.AUDIO_TRACK&&t.context.id===this.trackId&&mr(t.context.groupId,this.groupIds)&&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)}get nextAudioTrack(){return this.trackId}set nextAudioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e,!1)}setAudioOption(e){const t=this.hls;if(t.config.audioPreference=e,e){const i=this.allAudioTracks;if(this.selectDefaultTrack=!1,i.length){const r=this.currentTrack;if(r&&Ki(e,r,Ni))return r;const n=ni(e,this.tracksInGroup,Ni);if(n>-1){const a=this.tracksInGroup[n];return this.setAudioTrack(n,"flushImmediate"in e&&e.flushImmediate),a}else if(r){let a=t.loadLevel;a===-1&&(a=t.firstAutoLevel);const o=qp(e,t.levels,i,a,Ni);if(o===-1)return null;t.nextLoadLevel=o}if(e.channels||e.audioCodec){const a=ni(e,i);if(a>-1)return i[a]}}}return null}setAudioTrack(e,t=!0){const i=this.tracksInGroup;if(e<0||e>=i.length){this.warn(`Invalid audio track id: ${e}`);return}this.selectDefaultTrack=!1;const r=this.currentTrack,n=i[e],a=n.details&&!n.details.live;if(e===this.trackId&&n===r&&a||(this.log(`Switching to audio-track ${e} "${n.name}" lang:${n.lang} group:${n.groupId} channels:${n.channels}`),this.trackId=e,this.currentTrack=n,this.hls.trigger(E.AUDIO_TRACK_SWITCHING,Z(Z({},n),{},{flushImmediate:t})),a))return;const o=this.switchParams(n.url,r?.details,n.details);this.loadPlaylist(o)}findTrackId(e){const t=this.tracksInGroup;for(let i=0;i<t.length;i++){const r=t[i];if(!(this.selectDefaultTrack&&!r.default)&&(!e||Ki(e,r,Ni)))return i}if(e){const{name:i,lang:r,assocLang:n,characteristics:a,audioCodec:o,channels:l}=e;for(let d=0;d<t.length;d++){const c=t[d];if(Ki({name:i,lang:r,assocLang:n,characteristics:a,audioCodec:o,channels:l},c,Ni))return d}for(let d=0;d<t.length;d++){const c=t[d];if(vr(e.attrs,c.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return d}for(let d=0;d<t.length;d++){const c=t[d];if(vr(e.attrs,c.attrs,["LANGUAGE"]))return d}}return-1}loadPlaylist(e){super.loadPlaylist();const t=this.currentTrack;this.shouldLoadPlaylist(t)&&Hn(t.url,this.hls)&&this.scheduleLoading(t,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const i=e.id,r=e.groupId,n=this.getUrlWithDirectives(e.url,t),a=e.details,o=a?.age;this.log(`Loading audio-track ${i} "${e.name}" lang:${e.lang} group:${r}${t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:""}${o&&a.live?" age "+o.toFixed(1)+(a.type&&" "+a.type||""):""} ${n}`),this.hls.trigger(E.AUDIO_TRACK_LOADING,{url:n,id:i,groupId:r,deliveryDirectives:t||null,track:e})}}class PE{constructor(e){this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=e}destroy(){this.tracks=this.queues=null}append(e,t,i){if(this.queues===null||this.tracks===null)return;const r=this.queues[t];r.push(e),r.length===1&&!i&&this.executeNext(t)}appendBlocker(e){return new Promise(t=>{const i={label:"async-blocker",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.append(i,e)})}prependBlocker(e){return new Promise(t=>{if(this.queues){const i={label:"async-blocker-prepend",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.queues[e].unshift(i)}})}removeBlockers(){this.queues!==null&&[this.queues.video,this.queues.audio,this.queues.audiovideo].forEach(e=>{var t;const i=(t=e[0])==null?void 0:t.label;i==="async-blocker"||i==="async-blocker-prepend"?(e[0].execute(),e.splice(0,1)):i==="block-audio"&&e.splice(0,1)})}insertNext(e,t){this.queues!==null&&this.queues[t].splice(1,0,...e)}unblockAudio(){var e;this.queues!==null&&((e=this.current("audio"))==null?void 0:e.label)==="block-audio"&&this.shiftAndExecuteNext("audio")}audioBlocking(){return this.queues===null?!1:this.queues.audio.some(e=>e.label==="block-audio")}executeNext(e){if(this.queues===null||this.tracks===null)return;const t=this.queues[e];if(t.length){const r=t[0];try{r.execute()}catch(n){var i;if(r.onError(n),this.queues===null||this.tracks===null)return;const a=(i=this.tracks[e])==null?void 0:i.buffer;a!=null&&a.updating||this.shiftAndExecuteNext(e)}}}shiftAndExecuteNext(e){this.queues!==null&&(this.queues[e].shift(),this.executeNext(e))}current(e){var t;return((t=this.queues)==null?void 0:t[e][0])||null}toString(){const{queues:e,tracks:t}=this;return e===null||t===null?"<destroyed>":`
65${this.list("video")}
66${this.list("audio")}
67${this.list("audiovideo")}}`}list(e){var t,i;return(t=this.queues)!=null&&t[e]||(i=this.tracks)!=null&&i[e]?`${e}: (${this.listSbInfo(e)}) ${this.listOps(e)}`:""}listSbInfo(e){var t;const i=(t=this.tracks)==null?void 0:t[e],r=i?.buffer;return r?`SourceBuffer${r.updating?" updating":""}${i.ended?" ended":""}${i.ending?" ending":""}`:"none"}listOps(e){var t;return((t=this.queues)==null?void 0:t[e].map(i=>i.label).join(", "))||""}}const _c=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,lf="HlsJsTrackRemovedError",wE=.25,df=.001;class ME extends Error{constructor(e){super(e),this.name=lf}}class OE extends Dt{constructor(e,t){super("buffer-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.fragmentAppendProgress=Object.create(null),this.appendsWithoutProgress=Object.create(null),this.details=null,this._objectUrl=null,this.operationQueue=null,this.bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.lastVideoAppendEnd=0,this.appendSource=void 0,this.transferData=void 0,this.overrides=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.appendError=void 0,this._quotaEvictionPending={},this.tracks={},this.sourceBuffers=[[null,null],[null,null]],this._onEndStreaming=i=>{var r;this.hls&&((r=this.mediaSource)==null?void 0:r.readyState)==="open"&&this.hls.pauseBuffering()},this._onStartStreaming=i=>{this.hls&&this.hls.resumeBuffering()},this._onMediaSourceOpen=i=>{const{media:r,mediaSource:n}=this;i&&this.log("Media source opened"),!(!r||!n)&&(ye(n,"sourceopen",this._onMediaSourceOpen),ye(r,"emptied",this._onMediaEmptied),this.updateDuration(),this.hls.trigger(E.MEDIA_ATTACHED,{media:r,mediaSource:n}),this.mediaSource!==null&&this.checkPendingTracks())},this._onMediaSourceClose=()=>{if(this.log("Media source closed"),this.media){const i=this.media.error,{appendError:r,appendErrors:n}=this;let a=!1;!r&&i&&(a=Math.max(++n.audio,++n.video,++n.audiovideo)>=this.hls.config.appendErrorMaxRetry);const o=new Error(`MediaSource closed while media attached${xc(a,i)}`);this.warn(o),this.hls.trigger(E.ERROR,Ie({fatal:a},r,{type:X.MEDIA_ERROR,details:x.MEDIA_SOURCE_REQUIRES_RESET,error:o}))}},this._onMediaSourceEnded=()=>{this.log("Media source ended")},this._onMediaEmptied=()=>{const{mediaSrc:i,_objectUrl:r}=this;i!==r&&this.error(`Media element src was set while attaching MediaSource (${r} > ${i})`)},this._onMediaError=()=>{const{media:i}=this;if(i){var r,n;this.log(`Media error (code: ${(r=i.error)==null?void 0:r.code}): ${(n=i.error)==null?void 0:n.message}`)}},this.hls=e,this.fragmentTracker=t,this.appendSource=Um(ki(e.config.preferManagedMediaSource)),this.initTracks(),this.registerListeners()}hasSourceTypes(){return Object.keys(this.tracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null,this.transferData=this.overrides=void 0,this.operationQueue&&(this.operationQueue.destroy(),this.operationQueue=null),this.hls=this.fragmentTracker=null,this._onMediaSourceOpen=this._onMediaSourceClose=null,this._onMediaSourceEnded=null,this._onStartStreaming=this._onEndStreaming=null}registerListeners(){const{hls:e}=this;e.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.BUFFER_RESET,this.onBufferReset,this),e.on(E.BUFFER_APPENDING,this.onBufferAppending,this),e.on(E.BUFFER_CODECS,this.onBufferCodecs,this),e.on(E.BUFFER_EOS,this.onBufferEos,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(E.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(E.FRAG_PARSED,this.onFragParsed,this),e.on(E.FRAG_CHANGED,this.onFragChanged,this),e.on(E.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.BUFFER_RESET,this.onBufferReset,this),e.off(E.BUFFER_APPENDING,this.onBufferAppending,this),e.off(E.BUFFER_CODECS,this.onBufferCodecs,this),e.off(E.BUFFER_EOS,this.onBufferEos,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(E.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(E.FRAG_PARSED,this.onFragParsed,this),e.off(E.FRAG_CHANGED,this.onFragChanged,this),e.off(E.ERROR,this.onError,this)}transferMedia(){const{media:e,mediaSource:t}=this;if(!e)return null;const i={};if(this.operationQueue){const n=this.isUpdating();n||this.operationQueue.removeBlockers();const a=this.isQueued();(n||a)&&this.warn(`Transfering MediaSource with${a?" operations in queue":""}${n?" updating SourceBuffer(s)":""} ${this.operationQueue}`),this.operationQueue.destroy()}const r=this.transferData;return r&&!this.sourceBufferCount&&r.mediaSource===t?Ie(i,r.tracks):this.sourceBuffers.forEac
vendor: 9,375 bytes, lines 67-69
67h(n=>{const[a]=n;a&&(i[a]=Ie({},this.tracks[a]),this.removeBuffer(a)),n[0]=n[1]=null}),{media:e,mediaSource:t,tracks:i}}initTracks(){const e={};this.resetAppendProgress(),this.sourceBuffers=[[null,null],[null,null]],this.tracks=e,this.resetQueue(),this.lastMpegAudioChunk=null,this.lastVideoAppendEnd=0}onManifestLoading(){this.bufferCodecEventsTotal=0,this.details=null,this.resetAppendErrors(),this.resetAppendProgress()}onManifestParsed(e,t){var i;let r=2;(t.audio&&!t.video||!t.altAudio)&&(r=1),this.bufferCodecEventsTotal=r,this.log(`${r} bufferCodec event(s) expected.`),(i=this.transferData)!=null&&i.mediaSource&&this.sourceBufferCount&&r&&this.bufferCreated()}onMediaAttaching(e,t){const i=this.media=t.media;this.transferData=this.overrides=void 0;const r=ki(this.appendSource);if(r){const n=!!t.mediaSource;(n||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);const a=this.mediaSource=t.mediaSource||new r;if(this.assignMediaSource(a),n)this._objectUrl=i.src,this.attachTransferred();else{const o=this._objectUrl=self.URL.createObjectURL(a);if(this.appendSource)try{i.removeAttribute("src");const l=self.ManagedMediaSource;i.disableRemotePlayback=i.disableRemotePlayback||l&&a instanceof l,Lc(i),FE(i,o),i.load()}catch{i.src=o}else i.src=o}Ae(i,"emptied",this._onMediaEmptied),Ae(i,"error",this._onMediaError)}}assignMediaSource(e){var t,i;this.log(`${((t=this.transferData)==null?void 0:t.mediaSource)===e?"transferred":"created"} media source: ${(i=e.constructor)==null?void 0:i.name}`),Ae(e,"sourceopen",this._onMediaSourceOpen),Ae(e,"sourceended",this._onMediaSourceEnded),Ae(e,"sourceclose",this._onMediaSourceClose),this.appendSource&&(Ae(e,"startstreaming",this._onStartStreaming),Ae(e,"endstreaming",this._onEndStreaming))}attachTransferred(){const e=this.media,t=this.transferData;if(!t||!e)return;const i=this.tracks,r=t.tracks,n=r?Object.keys(r):null,a=n?n.length:0,o=()=>{Promise.resolve().then(()=>{this.media&&this.mediaSourceOpenOrEnded&&this._onMediaSourceOpen()})};if(r&&n&&a){if(!this.tracksReady){this.hls.config.startFragPrefetch=!0,this.log("attachTransferred: waiting for SourceBuffer track info");return}if(this.log(`attachTransferred: (bufferCodecEventsTotal ${this.bufferCodecEventsTotal})
68required tracks: ${Re(i,(l,d)=>l==="initSegment"?void 0:d)};
69transfer tracks: ${Re(r,(l,d)=>l==="initSegment"?void 0:d)}}`),!ju(r,i)){t.mediaSource=null,t.tracks=void 0;const l=e.currentTime,d=this.details,c=Math.max(l,d?.fragments[0].start||0);if(c-l>1){this.log(`attachTransferred: waiting for playback to reach new tracks start time ${l} -> ${c}`);return}this.warn(`attachTransferred: resetting MediaSource for incompatible tracks ("${Object.keys(r)}"->"${Object.keys(i)}") start time: ${c} currentTime: ${l}`),this.onMediaDetaching(E.MEDIA_DETACHING,{}),this.onMediaAttaching(E.MEDIA_ATTACHING,t),e.currentTime=c;return}this.transferData=void 0,n.forEach(l=>{const d=l,c=r[d];if(c){const u=c.buffer;if(u){const h=this.fragmentTracker,f=c.id;if(h.hasFragments(f)||h.hasParts(f)){const p=ie.getBuffered(u);h.detectEvictedFragments(d,p,f,null,null,!0)}const g=Ba(d),m=[d,u];this.sourceBuffers[g]=m,u.updating&&this.operationQueue&&this.operationQueue.prependBlocker(d),this.trackSourceBuffer(d,c)}}}),o(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),o()}get mediaSourceOpenOrEnded(){var e;const t=(e=this.mediaSource)==null?void 0:e.readyState;return t==="open"||t==="ended"}onMediaDetaching(e,t){const i=!!t.transferMedia;this.transferData=this.overrides=void 0;const{media:r,mediaSource:n,_objectUrl:a}=this;if(n){if(this.log(`media source ${i?"transferring":"detaching"}`),i)this.sourceBuffers.forEach(([o])=>{o&&this.removeBuffer(o)}),this.resetQueue();else{if(this.mediaSourceOpenOrEnded){const o=n.readyState==="open";try{const l=n.sourceBuffers;for(let d=l.length;d--;)o&&l[d].abort(),n.removeSourceBuffer(l[d]);o&&n.endOfStream()}catch(l){this.warn(`onMediaDetaching: ${l.message} while calling endOfStream`)}}this.sourceBufferCount&&this.onBufferReset()}ye(n,"sourceopen",this._onMediaSourceOpen),ye(n,"sourceended",this._onMediaSourceEnded),ye(n,"sourceclose",this._onMediaSourceClose),this.appendSource&&(ye(n,"startstreaming",this._onStartStreaming),ye(n,"endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}r&&(ye(r,"emptied",this._onMediaEmptied),ye(r,"error",this._onMediaError),i||(a&&self.URL.revokeObjectURL(a),this.mediaSrc===a?(r.removeAttribute("src"),this.appendSource&&Lc(r),r.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null)}onBufferReset(){this.sourceBuffers.forEach(([e])=>{e&&this.resetBuffer(e)}),this.initTracks()}resetBuffer(e){var t;const i=(t=this.tracks[e])==null?void 0:t.buffer;if(this.removeBuffer(e),i)try{var r;(r=this.mediaSource)!=null&&r.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(i)}catch(n){this.warn(`onBufferReset ${e}`,n)}delete this.tracks[e]}removeBuffer(e){this.removeBufferListeners(e),this.sourceBuffers[Ba(e)]=[null,null];const t=this.tracks[e];t&&(this.clearBufferAppendTimeoutId(t),t.buffer=void 0)}resetQueue(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new PE(this.tracks)}onBufferCodecs(e,t){var i;const r=this.tracks,n=Object.keys(t);this.log(`BUFFER_CODECS: "${n}" (current SB count ${this.sourceBufferCount})`);const a="audiovideo"in t&&(r.audio||r.video)||r.audiovideo&&("audio"in t||"video"in t),o=!a&&this.sourceBufferCount&&this.media&&n.some(l=>!r[l]);if(a||o){this.warn(`Unsupported transition between "${Object.keys(r)}" and "${n}" SourceBuffers`);return}n.forEach(l=>{var d,c;const u=t[l],{id:h,codec:f,levelCodec:g,container:m,metadata:p,supplemental:v}=u;let T=r[l];const y=(d=this.transferData)==null||(d=d.tracks)==null?void 0:d[l],S=y!=null&&y.buffer?y:T,A=S?.pendingCodec||S?.codec,I=S?.levelCodec;T||(T=r[l]={buffer:void 0,listeners:[],codec:f,supplemental:v,container:m,levelCodec:g,metadata:p,id:h});const _=ln(A,I),R=_?.replace(_c,"$1");let D=ln(f,g);const L=(c=D)==null?void 0:c.replace(_c,"$1");D&&_&&R!==L&&(l.slice(0,5)==="audio"&&(D=Gn(D,this.appendSource)),this.log(`switching codec ${A} to ${D}`),D!==(T.pendingCodec||T.codec)&&(T.pendingCodec=D),T.container=m,this.appendChangeType(l,m,D))}),(this.tracksReady||this.sourceBufferCount)&&(t.tracks=this.sourceBufferTracks),!this.sourceBufferCount&&(this.bufferCodecEventsTotal>1&&!this.tracks.video&&!t.video&&((i=t.audio)==null?void 0:i.id)==="main"&&(this.log("Main audio-only"),this.bufferCodecEventsTotal=1),this.mediaSourceOpenOrEnded&&this.checkPendingTracks())}get sourceBufferTracks(){return Object.keys(this.tracks).reduce((e,t)=>{const i=this.tracks[t];return e[t]={id:i.id,container:i.container,codec:i.codec,levelCodec:i.levelCodec},e},{})}appendChangeType(e,t,i){const r=`${t};codecs=${i}`,n={label:`change-type=${r}`,execute:()=>{const a=this.tracks[e];if(a){const o=a.buffer;o!=null&&o.changeType&&(this.log(`changing ${e} sourceBuffer type to ${r}`),o.changeType(r),a.codec=i,a.container=t)}this.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:a=>{this.warn(`Failed to change ${e} SourceBuffer type`,a)}};this.append(n,e,this.isPending(this.tracks[e]))}blockAudio(e){var t;const i=e.start,r=i+e.duration*.05;if(((t=this.fragmentTracker.getAppendedFrag(i,j.MAIN))==null?void 0:t.gap)===!0)return;const a={label:"block-audio",execute:()=>{var o,l;(this.lastVideoAppendEnd>r||ie.isBuffered((o=this.tracks.video)==null?void 0:o.buffer,r)||((l=this.fragmentTracker.getAppendedFrag(r,j.MAIN))==null?void 0:l.gap)===!0)&&this.unblockAudio()},onStart:()=>{},onComplete:()=>{},onError:o=>{this.warn("Error executing block-audio operation",o)}};this.append(a,"audio",!0)}unblockAudio(){this.operationQueue&&this.operationQueue.unblockAudio()}onBufferAppending(e,t){const{tracks:i}=this,{data:r,type:n,parent:a,frag:o,part:l,chunkMeta:d,offset:c}=t,u=d.buffering[n],h=Ue(o)&&!l&&!o.gap&&!d.partial&&!d.iframe;let f=null,g=!1;const{sn:m,cc:p}=o,v=self.performance.now();u.start=v;const T=o.stats.buffering,y=l?l.stats.buffering:null;T.start===0&&(T.start=v),y?.start===0&&(y.start=v);const S=i.audio;let A=!1;n==="audio"&&S?.container==="audio/mpeg"&&(A=!this.lastMpegAudioChunk||d.id===1||this.lastMpegAudioChunk.sn!==d.sn,this.lastMpegAudioChunk=d);const I=i.video,_=I?.buffer;if(_&&m!=="initSegment"&&c!==void 0){const L=S?.buffer,k=l||o;if(n==="audio"&&a!=="main"&&!(I.ending||I.ended)&&L&&ie.getBuffered(L).length){const U=k.start+k.duration*.05,K=ie.getBuffered(_),G=this.currentOp("video");!K.length&&!G?this.blockAudio(k):!ie.isBuffered(_,U)&&this.lastVideoAppendEnd<U&&this.blockAudio(k)}else if(n==="video"){const w=k.end,U=this.lastVideoAppendEnd-w;this.lastVideoAppendEnd=w,U<0||U>k.duration?this.unblockAudio():this.isAudioBlocked()&&this.executeNext("audio")}}const R=(l||o).start,D={label:`append-${n}`,execute:()=>{var L;u.executeStart=self.performance.now();const k=(L=this.tracks[n])==null?void 0:L.buffer;k&&(h&&(f=ie.timeRangesToArray(ie.getBuffered(k)),g=Dc(Ga(f,o),o)),A?this.updateTimestampOffset(k,R,.1,n,m,p):c!==void 0&&B(c)&&this.updateTimestampOffset(k,c,1e-6,n,m,p)),this.appendExecutor(r,n)},onStart:()=>{},onComplete:()=>{this.clearBufferAppendTimeoutId(this.tracks[n]);const L=self.performance.now();u.executeEnd=u.end=L,T.first===0&&(T.first=L),y?.first===0&&(y.first=L);const k={};
vendor: 4,536 bytes, line 69
69if(this.sourceBuffers.forEach(([w,U])=>{w&&(k[w]=ie.getBuffered(U))}),h){const w=this.getFragmentAppendProgress(o),U=k[n];if(U&&f){const K=ie.timeRangesToArray(U),G=Ga(K,o);w.progressed||(w.progressed=G-Ga(f,o)>df);const O=g&&Dc(G,o);w.fullyBuffered[n]=(w.fullyBuffered[n]===void 0||w.fullyBuffered[n])&&O}}this.hls.trigger(E.BUFFER_APPENDED,{type:n,frag:o,part:l,chunkMeta:d,parent:a,timeRanges:k})},onError:L=>{var k;this.clearBufferAppendTimeoutId(this.tracks[n]);const w=L.code===DOMException.QUOTA_EXCEEDED_ERR||L.name=="QuotaExceededError"||"quota"in L;if(w&&!this._quotaEvictionPending[n]){const O=this.getBackBufferEvictionTarget(n,r.byteLength,o.type);if(O>0){this._quotaEvictionPending[n]=!0,this.log(`QuotaExceededError on "${n}" append sn: ${m} - evicting back buffer to ${O.toFixed(3)}s and retrying`);const F=this.getFlushOp(n,0,O),M=this.getClearEvictionPendingOp(n);this.insertNext([F,D,M],n);return}this.warn(`QuotaExceededError on "${n}" sn: ${m} - no back buffer available to evict`)}h&&(this.getFragmentAppendProgress(o).errored=!0);const U={type:X.MEDIA_ERROR,parent:a,details:x.BUFFER_APPEND_ERROR,sourceBufferName:n,frag:o,part:l,chunkMeta:d,error:L,err:L,fatal:!1},K=(k=this.media)==null?void 0:k.error;if(L.name===lf&&this.sourceBufferCount===0&&(!this.media||this.pendingTrackCount===0))U.errorAction=er(!0);else{var G;w&&(U.details=x.BUFFER_FULL_ERROR);const O=++this.appendErrors[n],F=this.hls.config.appendErrorMaxRetry;this.warn(`Failed ${O}/${F+1} times to append segment in "${n}" sourceBuffer with error: ${L.message}`),O>=F&&(U.fatal=!w);const M=(G=this.mediaSource)==null?void 0:G.readyState;(M==="ended"||M==="closed"||K)&&(this.warn(`MediaSource readyState "${M}" during SourceBuffer${xc(U.fatal,K)}`),U.details=x.MEDIA_SOURCE_REQUIRES_RESET)}this.appendError=U,this.hls.trigger(E.ERROR,U),w&&this.hls&&this.trimBuffers(o.start,1)}};this.log(`queuing "${n}" append sn: ${m}${l?" p: "+l.index:""} of ${a} playlist ${o.level} cc: ${p} offset: ${c} bytes: ${r.byteLength}`),this.append(D,n,this.isPending(this.tracks[n]))}getClearEvictionPendingOp(e){return{label:"clear",execute:()=>{this._quotaEvictionPending[e]=!1,this.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:()=>{}}}getFlushOp(e,t,i){return this.log(`queuing "${e}" remove ${t}-${i}`),{label:"remove",execute:()=>{this.removeExecutor(e,t,i)},onStart:()=>{},onComplete:()=>{var r;const n=(r=this.tracks[e])==null?void 0:r.buffer;this.log(`Remove request ${t}-${i} from ${e} Source Buffer complete > buffer: ${n?jn(ie.getBuffered(n)):"(detached)"}`),this.hls.trigger(E.BUFFER_FLUSHED,{type:e,start:t,end:i})},onError:r=>{this.warn(`Failed to remove ${t}-${i} from "${e}" SourceBuffer`,r),this.hls.trigger(E.BUFFER_FLUSHED,{type:e,start:0,end:0,error:r})}}}onBufferFlushing(e,t){const{type:i,startOffset:r,endOffset:n}=t;(!i||i==="audio")&&this.unblockAudio(),i?this.append(this.getFlushOp(i,r,n),i):this.sourceBuffers.forEach(([a])=>{a&&this.append(this.getFlushOp(a,r,n),a)})}onFragParsed(e,t){const{frag:i,part:r,chunkMeta:n}=t,a=[],o=r?r.elementaryStreams:i.elementaryStreams;o[xe.AUDIOVIDEO]?a.push("audiovideo"):(o[xe.AUDIO]&&a.push("audio"),o[xe.VIDEO]&&a.push("video"));const l=()=>{const d=self.performance.now();i.stats.buffering.end=d,r&&(r.stats.buffering.end=d);const c=r?r.stats:i.stats;this.checkAppendProgress(i,r,n,a),this.hls&&(this.hls.trigger(E.FRAG_BUFFERED,{frag:i,part:r,stats:c,id:i.type,chunkMeta:n}),!r&&i.gap&&c.retry&&this.log(`Nothing buffered for ${i.type} level: ${i.level} sn: ${i.sn} retries ${c.retry}`))};a.length===0&&this.log(`Fragments must have at least one ElementaryStreamType set. ${i.type} ${i.level} ${r?`part: ${r.index} of `:""}sn: ${i.sn}`),this.blockBuffers(l,a).catch(d=>{this.warn(`Fragment buffered callback ${d.message}`),this.stepOperationQueue(this.sourceBufferTypes)})}onFragChanged(e,t){var i,r;const n=(i=this.hls)==null?void 0:i.config;if(!n)return;const{backBufferLength:a,frontBufferFlushThreshold:o}=n;this.trimBuffers(o,a,t.frag,t.previousFrag);const l=t.frag.elementaryStreams,{appendErrors:d}=this,c=(r=this.appendError)==null?void 0:r.sourceBufferName;Object.keys(l).forEach(u=>{l[u]&&(d[u]=0,u===c&&(this.appendError=void 0),u==="audio"||u==="video"?(d.audiovideo=0,c==="audiovideo"&&(this.appendError=void 0)):(d.audio=0,d.video=0,c!=="audiovideo"&&(this.appendError=void 0)))})}get bufferedToEnd(){return this.sourceBufferCount>0&&!this.sourceBuffers.some(([e])=>{if(e){const t=this.tracks[e];if(t)return!t.ended||t.ending}return!1})}onBufferEos(e,t){var i;
vendor: 11,332 bytes, line 69
69this.sourceBuffers.forEach(([a])=>{if(a){const o=this.tracks[a];(!t.type||t.type===a)&&(o.ending=!0,o.ended||(o.ended=!0,this.log(`${a} buffer reached EOS`)))}});const r=((i=this.overrides)==null?void 0:i.endOfStream)!==!1;this.sourceBufferCount>0&&!this.sourceBuffers.some(([a])=>{var o;return a&&!((o=this.tracks[a])!=null&&o.ended)})?(this.unblockAudio(),r?(this.log("Queueing EOS"),this.blockUntilOpen(()=>{this.tracksEnded();const{mediaSource:a}=this;if(a?.readyState!=="open"){a&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${a.readyState}`);return}this.log("Calling mediaSource.endOfStream()"),a.endOfStream(),this.hls.trigger(E.BUFFERED_TO_END,void 0)})):(this.tracksEnded(),this.hls.trigger(E.BUFFERED_TO_END,void 0))):t.type==="video"&&this.unblockAudio()}tracksEnded(){this.sourceBuffers.forEach(([e])=>{if(e!==null){const t=this.tracks[e];t&&(t.ending=!1)}})}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.updateDuration())}updateDuration(){this.blockUntilOpen(()=>{const e=this.getDurationAndRange();e&&this.updateMediaSource(e)})}onError(e,t){if(t.details===x.BUFFER_APPEND_ERROR&&t.frag){var i;const r=(i=t.errorAction)==null?void 0:i.nextAutoLevel;B(r)&&r!==t.frag.level&&this.resetAppendErrors()}}getBackBufferEvictionTarget(e,t,i){const{media:r}=this;return r?this.fragmentTracker.getBackBufferEvictionEnd(r.currentTime,i,t):0}getFragmentAppendProgress(e){var t;const i=Rc(e);let r=this.fragmentAppendProgress[i];return((t=r)==null?void 0:t.stats)!==e.stats&&(r={stats:e.stats,progressed:!1,errored:!1,fullyBuffered:Object.create(null)},this.fragmentAppendProgress[i]=r),r}checkAppendProgress(e,t,i,r){if(t||!Ue(e)||e.gap||i.iframe||i.partial)return;const n=Rc(e),a=this.fragmentAppendProgress[n];delete this.fragmentAppendProgress[n];const o=a?.stats===e.stats?a:void 0;if(o!=null&&o.errored)return;const l=r.length>0&&r.every(h=>o?.fullyBuffered[h]===!0);if(o!=null&&o.progressed||l){delete this.appendsWithoutProgress[n];return}if(!o&&r.length===0)return;const d=(this.appendsWithoutProgress[n]||0)+1,c=this.hls;d>=c.config.appendErrorMaxRetry?delete this.appendsWithoutProgress[n]:this.appendsWithoutProgress[n]=d,this.warn(`Fragment ${e.sn} of ${e.type} playlist ${e.level} appended ${d} time${d>1?"s":""} without buffered range growth`),c.trigger(E.ERROR,{type:X.MEDIA_ERROR,details:x.BUFFER_APPEND_NO_PROGRESS,fatal:!1,frag:e,chunkMeta:i,parent:e.type,appendsWithoutProgress:d,error:new Error(`Fragment append did not increase buffered coverage (${d})`)})}resetAppendProgress(){this.fragmentAppendProgress=Object.create(null),this.appendsWithoutProgress=Object.create(null)}resetAppendErrors(){this.appendErrors={audio:0,video:0,audiovideo:0},this.appendError=void 0}trimBuffers(e,t,i,r){const{hls:n,details:a,media:o}=this;if(!o||a===null||!this.sourceBufferCount)return;const l=n.config,d=o.currentTime,c=a.levelTargetDuration;t=a.live&&l.liveBackBufferLength!==null?l.liveBackBufferLength:t;let u=-1/0;if(B(t)&&t>=0){const h=Math.max(t,c);u=Math.floor(d/c)*c-h}if(i){const h=this.getLoopBackBufferFlushEnd(i,r??null);h>0&&(u=Math.max(u,h))}if(u>0&&this.flushBackBuffer(d,c,u),B(e)&&e>0){const h=Math.max(l.maxBufferLength,e),f=Math.max(h,c),g=Math.floor(d/c)*c+f;this.flushFrontBuffer(d,c,g)}}getLoopBackBufferFlushEnd(e,t){var i;const{media:r}=this;if(((i=this.hls)==null?void 0:i.config.loopBackBufferFlush)===!1||!(r!=null&&r.loop)||!t||e.level<=t.level)return 0;const{video:n,audiovideo:a}=e.elementaryStreams;if(n!=null&&n.partial||a!=null&&a.partial)return 0;const o=this.getEarliestElementaryStreamStart(e)-wE;return o<=0?0:(this.log(`Flushing lower quality back buffer for loop: level ${e.level}, range [0-${o.toFixed(3)}]`),o)}getEarliestElementaryStreamStart(e){const{audio:t,video:i,audiovideo:r}=e.elementaryStreams;let n=e.start;return r?n=Math.min(n,r.startDTS):(t&&(n=Math.min(n,t.startDTS)),i&&(n=Math.min(n,i.startDTS))),n}flushBackBuffer(e,t,i){this.sourceBuffers.forEach(([r,n])=>{if(n){const d=ie.getBuffered(n);if(d.length>0&&i>d.start(0)){var a,o,l;this.hls.trigger(E.BACK_BUFFER_REACHED,{bufferEnd:i});const c=this.tracks[r];if((a=this.details)!=null&&a.live)this.hls.trigger(E.LIVE_BACK_BUFFER_REACHED,{bufferEnd:i});else if(c!=null&&c.ended&&!((o=this.media)!=null&&o.loop&&((l=this.hls)==null?void 0:l.config.loopBackBufferFlush)!==!1)){this.log(`Cannot flush ${r} back buffer while SourceBuffer is in ended state`);return}this.hls.trigger(E.BUFFER_FLUSHING,{startOffset:0,endOffset:i,type:r})}}})}flushFrontBuffer(e,t,i){this.sourceBuffers.forEach(([r,n])=>{if(n){const a=ie.getBuffered(n),o=a.length;if(o<2)return;const l=a.start(o-1),d=a.end(o-1);if(i>l||e>=l&&e<=d)return;this.hls.trigger(E.BUFFER_FLUSHING,{startOffset:l,endOffset:1/0,type:r})}})}getDurationAndRange(){var e;const{details:t,mediaSource:i}=this;if(!t||!this.media||i?.readyState!=="open")return null;const r=t.edge;if(t.live&&this.hls.config.liveDurationInfinity){if(t.fragments.length&&i.setLiveSeekableRange){const d=Math.max(0,t.fragmentStart),c=Math.max(d,r);return{duration:1/0,start:d,end:c}}return{duration:1/0}}const n=(e=this.overrides)==null?void 0:e.duration;if(n)return B(n)?{duration:n}:null;const a=this.media.duration,o=B(i.duration)?i.duration:0;return r>o&&r>a||!B(a)?{duration:r}:null}updateMediaSource({duration:e,start:t,end:i}){const r=this.mediaSource;!r||!this.media||r.readyState!=="open"||(r.duration!==e&&(B(e)&&this.log(`Updating MediaSource duration to ${e.toFixed(3)}`),r.duration=e),t!==void 0&&i!==void 0&&(this.log(`MediaSource duration is set to ${r.duration}. Setting seekable range to ${t}-${i}.`),r.setLiveSeekableRange(t,i)))}get tracksReady(){const e=this.pendingTrackCount;return e>0&&(e>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}checkPendingTracks(){const{bufferCodecEventsTotal:e,pendingTrackCount:t,tracks:i}=this;if(this.log(`checkPendingTracks (pending: ${t} codec events expected: ${e}) ${Re(i)}`),this.tracksReady){var r;const n=(r=this.transferData)==null?void 0:r.tracks;n&&Object.keys(n).length?this.attachTransferred():this.createSourceBuffers()}}bufferCreated(){if(this.sourceBufferCount){const e={};this.sourceBuffers.forEach(([t,i])=>{if(t){const r=this.tracks[t];e[t]={buffer:i,container:r.container,codec:r.codec,supplemental:r.supplemental,levelCodec:r.levelCodec,id:r.id,metadata:r.metadata}}}),this.hls.trigger(E.BUFFER_CREATED,{tracks:e}),this.log(`SourceBuffers created. Running queue: ${this.operationQueue}`),this.sourceBuffers.forEach(([t])=>{this.executeNext(t)})}else{const e=new Error("could not create source buffer for media codec(s)");this.hls.trigger(E.ERROR,{type:X.MEDIA_ERROR,details:x.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:e,reason:e.message})}}createSourceBuffers(){const{tracks:e,sourceBuffers:t,mediaSource:i}=this;if(!i)throw new Error("createSourceBuffers called when mediaSource was null");for(const n in e){const a=n,o=e[a];if(this.isPending(o)){const l=this.getTrackCodec(o,a),d=`${o.container};codecs=${l}`;o.codec=l,this.log(`creating sourceBuffer(${d})${this.currentOp(a)?" Queued":""} ${Re(o)}`);try{const c=i.addSourceBuffer(d),u=Ba(a),h=[a,c];t[u]=h,o.buffer=c}catch(c){var r;this.error(`error while trying to add sourceBuffer: ${c.message}`),this.shiftAndExecuteNext(a),(r=this.operationQueue)==null||r.removeBlockers(),delete this.tracks[a],this.hls.trigger(E.ERROR,{type:X.MEDIA_ERROR,details:x.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:c,sourceBufferName:a,mimeType:d,parent:o.id});return}this.trackSourceBuffer(a,o)}}this.bufferCreated()}clearBufferAppendTimeoutId(e){e&&(self.clearTimeout(e.bufferAppendTimeoutId),e.bufferAppendTimeoutId=void 0)}getTrackCodec(e,t){const i=e.supplemental;let r=e.codec;i&&(t==="video"||t==="audiovideo")&&hr(i,"video")&&(r=Dp(r,i));const n=ln(r,e.levelCodec);return n?t.slice(0,5)==="audio"?Gn(n,this.appendSource):n:""}trackSourceBuffer(e,t){const i=t.buffer;if(!i)return;const r=this.getTrackCodec(t,e);this.tracks[e]={buffer:i,codec:r,container:t.container,levelCodec:t.levelCodec,supplemental:t.supplemental,metadata:t.metadata,id:t.id,listeners:[]},this.removeBufferListeners(e),this.addBufferListener(e,"updatestart",this.onSBUpdateStart),this.addBufferListener(e,"updateend",this.onSBUpdateEnd),this.addBufferListener(e,"error",this.onSBUpdateError),this.appendSource&&this.addBufferListener(e,"bufferedchange",(n,a)=>{const o=a.removedRanges;o!=null&&o.length&&(this.log(`${n} buffer removed ${jn(o)}`),this.hls.trigger(E.BUFFER_FLUSHED,{type:n,start:o.start(0),end:o.end(o.length-1)}))})}get mediaSrc(){var e,t;const i=((e=this.media)==null||(t=e.querySelector)==null?void 0:t.call(e,"source"))||this.media;return i?.src}onSBUpdateStart(e){const t=this.currentOp(e);t&&t.onStart()}onSBUpdateEnd(e){var t,i;if(((t=this.mediaSource)==null?void 0:t.readyState)==="closed"){this.resetBuffer(e);return}const r=this.currentOp(e);if(!r)return;if(r.onComplete(),(i=this.tracks[e])==null||(i=i.buffer)==null?void 0:i.updating){this.log(`${e} SourceBuffer updating on "updateend"`),this.blockUntilOpen(()=>{this.shiftAndExecuteNext(e)});return}this.shiftAndExecuteNext(e)}onSBUpdateError(e,t){var i;const r=(i=this.mediaSource)==null?void 0:i.readyState,n=new Error(`${e} SourceBuffer error. MediaSource readyState: ${r}`);this.error(`${n.message}`,t),this.hls.trigger(E.ERROR,{type:X.MEDIA_ERROR,details:x.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:n,fatal:!1});const a=this.currentOp(e);a&&a.onError(n)}updateTimestampOffset(e,t,i,r,n,a){const o=t-e.timestampOffset;Math.abs(o)>=i&&(this.log(`Updating ${r} SourceBuffer timestampOffset to ${t} (sn: ${n} cc: ${a})`),e.timestampOffset=t)}removeExecutor(e,t,i){const{media:r,mediaSource:n}=this,a=this.tracks[e],o=a?.buffer;if(!r||!n||!o)throw new Error(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`);const l=B(r.duration)?r.duration:1/0,d=B(n.duration)?n.duration:1/0,c=Math.max(0,t);if(c>=d){var u;(u=this.currentOp(e))==null||u.onComplete(),this.shiftAndExecuteNext(e);return}const h=Math.min(i,l,d);if(h>c&&(!a.ending||a.ended))a.ended=!1,this.log(`Removing [${c},${h}] from the ${e} SourceBuffer`),o.remove(c,h);else throw new Error(`Cannot remove ${h<=c?`invalid range (${c} >= ${h}) `:""}from the ${e} SourceBuffer${a.ending?" while track ending":""}`)}appendExecutor(e,t){const i=this.tracks[t],r=i?.buffer;if(!r)throw new ME(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);if(i.ending=!1,i.ended=!1,this.hls.config.appendTimeout!==1/0){const n=this.calculateAppendTimeoutTime(r);i.bufferAppendTimeoutId=self.setTimeout(()=>this.appendTimeoutHandler(t,r,n),n)}r.appendBuffer(e)}appendTimeoutHandler(e,t,i){this.log(`Received timeout after ${i}ms for append on ${e} source buffer. Aborting and triggering error.`);try{t.abort()}catch{this.log(`Failed to abort append on ${e} source buffer after timeout.`)}const r=this.currentOp(e);r&&r.onError(new Error(`${e}-append-timeout`))}calculateAppendTimeoutTime(e){let t=Rh;this.details&&(t=this.details.levelTargetDuration);let i=2*t*1e3;if(this.media===null)return i;const r=ie.bufferInfo(e,this.media.currentTime,0);return r.len?(i=Math.max(r.len*1e3,i),Math.max(this.hls.config.appendTimeout,i)):i}blockUntilOpen(e){if(this.isUpdating()||this.isQueued())this.blockBuffers(e).catch(t=>{this.warn(`SourceBuffer blocked callback ${t}
69`),this.stepOperationQueue(this.sourceBufferTypes)});else try{e()}catch(t){this.warn(`Callback run without blocking ${this.operationQueue} ${t}`)}}isUpdating(){return this.sourceBuffers.some(([e,t])=>e&&t.updating)}isQueued(){return this.sourceBuffers.some(([e])=>e&&!!this.currentOp(e))}isPending(e){return!!e&&!e.buffer}isAudioBlocked(){var e;return((e=this.currentOp("audio"))==null?void 0:e.label)==="block-audio"}isAudioBlocking(){return this.operationQueue?this.operationQueue.audioBlocking():!1}blockBuffers(e,t=this.sourceBufferTypes){if(!t.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);const{operationQueue:i}=this,n=t.length===2&&this.isAudioBlocking()?[this.appendBlocker("video")]:t.map(a=>this.appendBlocker(a));return Promise.all(n).then(a=>{i===this.operationQueue&&(e(),this.stepOperationQueue(this.sourceBufferTypes))})}stepOperationQueue(e){e.forEach(t=>{var i;const r=(i=this.tracks[t])==null?void 0:i.buffer;!r||r.updating||t==="audio"&&this.isAudioBlocked()||this.shiftAndExecuteNext(t)})}append(e,t,i){this.operationQueue&&this.operationQueue.append(e,t,i)}insertNext(e,t){this.operationQueue&&this.operationQueue.insertNext(e,t)}appendBlocker(e){if(this.operationQueue)return this.operationQueue.appendBlocker(e)}currentOp(e){return this.operationQueue?this.operationQueue.current(e):null}executeNext(e){e&&this.operationQueue&&this.operationQueue.executeNext(e)}shiftAndExecuteNext(e){this.operationQueue&&this.operationQueue.shiftAndExecuteNext(e)}get pendingTrackCount(){return Object.keys(this.tracks).reduce((e,t)=>e+(this.isPending(this.tracks[t])?1:0),0)}get sourceBufferCount(){return this.sourceBuffers.reduce((e,[t])=>e+(t?1:0),0)}get sourceBufferTypes(){return this.sourceBuffers.map(([e])=>e).filter(e=>!!e)}addBufferListener(e,t,i){const r=this.tracks[e];if(!r)return;const n=r.buffer;if(!n)return;const a=i.bind(this,e);r.listeners.push({event:t,listener:a}),Ae(n,t,a)}removeBufferListeners(e){const t=this.tracks[e];if(!t)return;const i=t.buffer;i&&(t.listeners.forEach(r=>{ye(i,r.event,r.listener)}),t.listeners.length=0)}}function Lc(s){const e=s.querySelectorAll("source");[].slice.call(e).forEach(t=>{s.removeChild(t)})}function FE(s,e){const t=self.document.createElement("source");t.type="video/mp4",t.src=e,s.appendChild(t)}function Ba(s){return s==="audio"?1:0}function xc(s,e){return`${s?"":" - triggering recovery"}${e?" with HTMLMediaElement Error: "+e.message:""}`}function Rc(s){return`${s.type}_${s.sn}_${s.level}`}function Ga(s,e){const{start:t,end:i}=e;let r=0;for(let n=0;n<s.length;n++){const a=s[n];if(a.start>=i)break;const o=Math.max(t,a.start),l=Math.min(i,a.end);l>o&&(r+=l-o)}return r}function Dc(s,e){return e.duration-s<=df}class Fl{constructor(e){this.hls=null,this.autoLevelCapping=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.observer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.media=null,this.restrictedLevels=[],this.clientRect=null,this.registerListeners()}setStreamController(e){this.streamController=e}destroy(){this.hls&&this.unregisterListener(),(this.timer||this.observer)&&this.stopCapping(),this.media=this.clientRect=this.hls=null,this.streamController=void 0}registerListeners(){const{hls:e}=this;e&&(e.on(E.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(E.BUFFER_CODECS,this.onBufferCodecs,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this))}unregisterListener(){const{hls:e}=this;e&&(e.off(E.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(E.BUFFER_CODECS,this.onBufferCodecs,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this))}onFpsDropLevelCapping(e,t){if(!this.hls)return;const i=this.hls.levels[t.droppedLevel];this.isLevelAllowed(i)&&this.restrictedLevels.push({bitrate:i.bitrate,height:i.height,width:i.width})}onMediaAttaching(e,t){const i=t.media;this.clientRect=null,this.hls&&(i instanceof HTMLVideoElement?(this.media=i,this.hls.config.capLevelToPlayerSize&&this.observe()):this.media=null,(this.timer||this.observer)&&this.hls.levels.length>1&&this.detectPlayerSize())}onManifestParsed(e,t){this.restrictedLevels=[],t.video&&this.startCapping()}onLevelsUpdated(e,{levels:t}){(this.timer||this.observer)&&B(this.autoLevelCapping)?this.detectPlayerSize():this.observer===void 0&&this.timer===void 0&&t.length>1&&t.some(i=>!!i.videoCodec)&&this.startCapping()}onBufferCodecs(e,t){t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping(),this.media=null}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0||!this.hls){this.clientRect=null;return}const e=this.hls.levels;if(e.length>1){const t=this.hls,i=this.getMaxLevel(e.length-1);i!==this.autoLevelCapping&&t.logger.log(`Setting autoLevelCapping to ${i}: ${e[i].height}p@${e[i].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=i,t.autoLevelEnabled&&t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}else e.length===1&&this.stopCapping()}}getMaxLevel(e){if(!this.hls)return-1;const t=this.hls.levels;if(!t.length)return-1;const i=t.filter((r,n)=>this.isLevelAllowed(r)&&n<=e);return this.observer||(this.clientRect=null),Fl.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)}observe(){const e=self.ResizeObserver;e&&(this.observer=new e(t=>{var i;const r=(i=t[0])==null?void 0:i.contentRect;r&&(this.clientRect=r,this.detectPlayerSize())})),this.observer&&this.media&&this.observer.observe(this.media)}startCapping(){var e;this.timer||this.observer||!((e=this.hls)!=null&&e.config.capLevelToPlayerSize)||(self.clearInterval(this.timer),this.timer=void 0,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.observe(),this.observer||(this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3)),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0),this.observer&&(this.observer.disconnect(),this.observer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;const e=this.media,t={width:0,height:0};if(e){const i=e.getBoundingClientRect();t.width=i.width,t.height=i.height,!t.width&&!t.height&&(t.width=i.right-i.left||e.
vendor: 4,221 bytes, line 69
69width||0,t.height=i.bottom-i.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)return e;const{ignoreDevicePixelRatio:t,maxDevicePixelRatio:i}=this.hls.config;if(!t)try{e=self.devicePixelRatio}catch{}return Math.min(e,i)}isLevelAllowed(e){return!this.restrictedLevels.some(i=>e.bitrate===i.bitrate&&e.width===i.width&&e.height===i.height)}static getMaxLevelByMediaSize(e,t,i){if(!(e!=null&&e.length))return-1;const r=(o,l)=>l?o.width!==l.width||o.height!==l.height:!0;let n=e.length-1;const a=Math.max(t,i);for(let o=0;o<e.length;o+=1){const l=e[o];if((l.width>=a||l.height>=a)&&r(l,e[o+1])){n=o;break}}return n}}var Tt=class wo{constructor(e,t){Array.isArray(e)&&(e=e.map(i=>i instanceof wo?i:new wo(i))),this.value=e,this.params=t}};const NE="Dict";function UE(s){return Array.isArray(s)?JSON.stringify(s):s instanceof Map?"Map{}":s instanceof Set?"Set{}":typeof s=="object"?JSON.stringify(s):String(s)}function $E(s,e,t,i){return new Error(`failed to ${s} "${UE(e)}" as ${t}`,{cause:i})}const kc="Bare Item",BE="Boolean",GE="Byte Sequence",VE="Decimal",HE="Integer";function KE(s){return s<-999999999999999||999999999999999<s}const WE="String",YE=/[\x00-\x1f\x7f]+/;var cf=class{constructor(s){this.description=s}};const qE="Token",jE="Key";function li(s,e,t){return $E("serialize",s,e,t)}function zE(s){if(typeof s!="boolean")throw li(s,BE);return s?"?1":"?0"}function QE(s){if(ArrayBuffer.isView(s)===!1)throw li(s,GE);return`:${$m(s)}:`}function uf(s){if(KE(s))throw li(s,HE);return s.toString()}function XE(s){return`@${uf(s.getTime()/1e3)}`}function ZE(s){const e=zu(s,3);if(Math.floor(Math.abs(e)).toString().length>12)throw li(s,VE);const t=e.toString();return t.includes(".")?t:`${t}.0`}function JE(s){if(YE.test(s))throw li(s,WE);return`"${s.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function ev(s){return s.description||s.toString().slice(7,-1)}function Cc(s){const e=ev(s);if(/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(e)===!1)throw li(e,qE);return e}function Mo(s){switch(typeof s){case"number":if(!B(s))throw li(s,kc);return Number.isInteger(s)?uf(s):ZE(s);case"string":return JE(s);case"symbol":return Cc(s);case"boolean":return zE(s);case"object":if(s instanceof Date)return XE(s);if(s instanceof Uint8Array)return QE(s);if(s instanceof cf)return Cc(s);default:throw li(s,kc)}}function Oo(s){if(/^[a-z*][a-z0-9\-_.*]*$/.test(s)===!1)throw li(s,jE);return s}function Nl(s){return s==null?"":Object.entries(s).map(([e,t])=>t===!0?`;${Oo(e)}`:`;${Oo(e)}=${Mo(t)}`).join("")}function hf(s){return s instanceof Tt?`${Mo(s.value)}${Nl(s.params)}`:Mo(s)}function tv(s){return`(${s.value.map(hf).join(" ")})${Nl(s.params)}`}function iv(s,e={whitespace:!0}){if(typeof s!="object"||s==null)throw li(s,NE);const t=s instanceof Map?s.entries():Object.entries(s),i=e!=null&&e.whitespace?" ":"";return Array.from(t).map(([r,n])=>{n instanceof Tt||(n=new Tt(n));let a=Oo(r);return n.value===!0?a+=Nl(n.params):(a+="=",Array.isArray(n.value)?a+=tv(n):a+=hf(n)),a}).join(`,${i}`)}function ff(s,e){return iv(s,e)}const sv=["url"],rv=["version","eventTargets","sid","transmissionMode"],nv=["customData","headers"],Pc=s=>s instanceof Tt?new Tt(Math.round(s.value),s.params):Math.round(s),Va=s=>Array.isArray(s)?s.map(Pc):Pc(s),Fo=(s,e)=>Array.isArray(s)?s.map(t=>Fo(t,e)):s instanceof Tt&&typeof s.value=="string"?new Tt(Fo(s.value,e),s.params):(e.baseUrl&&(s=Hm(s,Vm(e.baseUrl))),e.version===1?encodeURIComponent(s):s),wc=s=>s instanceof Tt?new Tt(Math.round(s.value/100)*100,s.params):Math.round(s/100)*100,Gr=s=>Array.isArray(s)?s.map(wc):wc(s),av=(s,e)=>{let t=s;return e.version>=2&&(s instanceof Tt&&typeof s.value=="string"?t=new Tt([s]):typeof s=="string"&&(t=[s])),Fo(t,e)},ov={br:Va,d:Va,bl:Gr,dl:Gr,mtp:Gr,nor:av,rtp:Gr,tb:Va},yr=2,gf="bc",lv="ps",mf="pr",dv="e",Mc="t",cv="c",pf="b",Ul="rr",Ef="ce",Vr={BITRATE_CHANGE:gf,ERROR:dv,RESPONSE_RECEIVED:Ul,CUSTOM_EVENT:Ef},vf=new Map([[lv,"sta"],[mf,"pr"],[cv,"cid"],[pf,"bg"],[gf,"br"]]),$l="event",Bl="request",yf=["cen","e","h","ts"],Tf=["ab","bg","bl","br","bs","b
69sa","bsd","bsda","cdn","cid","cs","d","dfa","dl","ec","lab","lb","ltc","msd","mtp","nor","nr","ot","pb","pr","pt","rtp","sf","sid","sn","st","sta","su","tab","tb","tbl","tpb","v"],uv=/^[a-zA-Z0-9-.]+-[a-zA-Z0-9-.]+$/;function Gl(s){return uv.test(s)}const hv=new Set(Tf);function Sf(s){return hv.has(s)||Gl(s)}const Af=["cmsdd","cmsds","rc","smrt","ttfb","ttfbb","ttlb","url"],fv=new Set(Af);function bf(s){return fv.has(s)}const gv=new Set(yf);function mv(s){return Sf(s)||bf(s)||gv.has(s)}const pv=new Set(["ab","bl","br","bsa","bsd","bsda","lab","lb","mtp","pb","tab","tb","tbl","tpb"]),Ea=["bl","br","bs","cid","d","dl","mtp","nor","nrr","ot","pr","rtp","sf","sid","st","su","tb","v"],Ev=new Set(Ea);function vv(s){return Ev.has(s)||Gl(s)}const yv=new Set(["ot","sf","st","e","sta"]);function Tv(s){return yv.has(s)}function Sv(s){return typeof s=="number"?B(s):s!=null&&s!==""&&s!==!1}const Av={[$l]:mv,[Bl]:Sf};function If(s,e){if(Array.isArray(s)){let t;return e&&(t=s.find(i=>{var r;return((r=i.params)==null?void 0:r.ot)===e})),t||(t=s[0]),If(t)}return s instanceof Tt?s.value:s}function bv(s){const e={};for(const[i,r]of Object.entries(s)){if(r==null){e[i]=r;continue}if(i==="nor"){const n=(Array.isArray(r)?r:[r])[0];if(n instanceof Tt){var t;e.nor=n.value,(t=n.params)!=null&&t.r&&(e.nrr=n.params.r)}else e.nor=n}else pv.has(i)?e[i]=If(r,s.ot):e[i]=r}return e}function _f(s,e={}){const t={};if(s==null||typeof s!="object")return t;const i=e.version||s.v||yr,r=e.reportingMode||Bl,n=i===1?bv(s):s,a=i===1?vv:Av[r];let o=Object.keys(n).filter(a);n.e&&n.e!==Ul&&(o=o.filter(f=>!bf(f)));const l=e.filter;typeof l=="function"&&(o=o.filter(l));const d=r===$l;if(d){const f=n.e;!o.includes("e")&&f!=null&&o.push("e"),o.includes("ts")||o.push("ts"),!o.includes("cen")&&n.cen!=null&&f===Ef&&o.push("cen");const g=f?vf.get(f):void 0;g&&n[g]!=null&&!o.includes(g)&&o.push(g)}if(o.length===0)return t;i>1&&!o.includes("v")&&o.push("v");const c={version:i,reportingMode:r,baseUrl:e.baseUrl};o.sort();for(const f of o){var u,h;let g=n[f];const m=(u=(h=e.formatters)==null?void 0:h[f])!=null?u:ov[f];if(typeof m=="function"&&(g=m(g,c)),f==="v"){if(i===1)continue;g=i}if(f==="pr"&&g===1&&!(d&&n.e===mf))continue;d&&f==="ts"&&!B(g)&&(g=Date.now());const p=d&&g===!1&&f==="bg"&&n.e===pf;!Sv(g)&&!p||(Tv(f)&&typeof g=="string"&&(g=new cf(g)),t[f]=g)}return t}const ui="CMCD-Object",Et="CMCD-Request",Xi="CMCD-Session",Mt="CMCD-Status",Iv={REQUEST:Et},_v={ab:ui,br:ui,d:ui,lab:ui,lb:ui,ot:ui,tab:ui,tb:ui,tpb:ui,bl:Et,cs:Et,dfa:Et,dl:Et,ltc:Et,mtp:Et,nor:Et,nrr:Et,pb:Et,sn:Et,sta:Et,su:Et,tbl:Et,cid:Xi,msd:Xi,sf:Xi,sid:Xi,st:Xi,v:Xi,bg:Mt,bs:Mt,bsa:Mt,bsd:Mt,bsda:Mt,cdn:Mt,ec:Mt,nr:Mt,pr:Mt,pt:Mt,rtp:Mt};function Lv(s){return Object.keys(s).reduce((e,t)=>{var i;return(i=s[t])==null||i.forEach(r=>e[r]=t),e},{})}function xv(s,e){const t={};if(!s)return t;const i=Object.keys(s),r=e?Lv(e):{};for(const a of i){var n;const o=_v[a]||r[a]||Iv.REQUEST,l=(n=t[o])!=null?n:t[o]={};l[a]=s[a]}return t}function Rv(s,e){const t={},i=xv(s,e);for(const[r,n]of Object.entries(i)){const a=ff(n,{whitespace:!1});a&&(t[r]=a)}return t}const Oc="CMCD";function Lf(s){return ff(s,{whitespace:!1})}function Dv(s,e={}){return s?Lf(_f(s,e)):""}const kv=30,No=[...Ea,...Tf,...Af,...yf].filter((s,e,t)=>t.indexOf(s)===e),Cv="application/cmcd",Pv=1,nt={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",
69KEY:"k",OTHER:"o"},Ot={STARTING:"s",PLAYING:"p",SEEKING:"k",REBUFFERING:"r",PAUSED:"a",ENDED:"e",FATAL_ERROR:"f",PRELOADING:"d"},Vl="query",xf="headers";function Fc(s,e,t){var i;const r=new Set((i=e.enabledKeys)!=null?i:[]);return{version:e.version||yr,reportingMode:s,filter:n=>r.has(n),baseUrl:t}}function wv(s,e){if(s===e)return!0;if(s.length!==e.length)return!1;for(let t=0;t<s.length;t++){const i=s[t],r=e[t];if(i===r)continue;if(typeof i=="number"||typeof r=="number"||i.value!==r.value)return!1;const n=i.params,a=r.params,o=n&&Object.keys(n)[0],l=a&&Object.keys(a)[0];if(o!==l||o!==void 0&&l!==void 0&&n&&a&&n[o]!==a[l])return!1}return!0}const Mv=Object.is,Ov=s=>s,Rf=Array.from(vf,([s,e])=>e==="br"?{event:s,field:e,equal:(t,i)=>t===void 0||i===void 0?t===i:wv(t,i),snapshot:t=>t.slice()}:{event:s,field:e,equal:Mv,snapshot:Ov}),Fv=new Map(Rf.map(s=>[s.event,s]));function Nv(s){const{url:e}=s,t=ga(s,sv);return fetch(e,t)}function Uv(s){const{version:e=yr,eventTargets:t=[],sid:i=Qu(),transmissionMode:r=Vl}=s,n=ga(s,rv);return Z(Z({},n),{},{version:e,transmissionMode:r,sid:i,eventTargets:t.reduce((a,o)=>{var l,d,c;return o!=null&&o.url&&(l=o.events)!=null&&l.length&&a.push({version:o.version||yr,enabledKeys:((d=o.enabledKeys)==null?void 0:d.slice())||[],url:o.url,events:o.events.slice(),interval:(c=o.interval)!=null?c:kv,batchSize:o.batchSize||1}),a},[])})}var $v=class{constructor(s,e=Nv){var t;this.timeOrigin=performance.timeOrigin||((t=performance.timing)==null?void 0:t.fetchStart)||Date.now()-performance.now(),this.data={},this.msd=NaN,this.eventTargets=new Map,this.lastEmitted={},this.requestTarget={sn:0,msdSent:!1},this.config=Uv(s),this.data={cid:this.config.cid,sid:this.config.sid,v:this.config.version},this.requester=e;for(const i of this.config.eventTargets)this.eventTargets.set(i,{intervalId:void 0,sn:0,msdSent:!1,queue:[]})}start(){this.eventTargets.forEach((s,e)=>{if(this.disarmInterval(s),e.interval===0||!e.events.includes(Mc))return;const t=()=>{this.recordTargetEvent(s,e,Mc),this.processEventTargets()};s.intervalId=setInterval(t,e.interval*1e3),t()})}stop(s=!1){s&&this.flush(),this.eventTargets.forEach(e=>{this.disarmInterval(e)})}flush(){this.processEventTargets(!0)}update(s){s.sid&&s.sid!==this.data.sid&&this.resetSession(),s.msd&&!isNaN(s.msd)&&(this.msd=s.msd),this.data=Z(Z(Z({},this.data),s),{},{msd:void 0});for(const e of Rf)e.field in s&&!e.equal(this.data[e.field],this.lastEmitted[e.field])&&this.recordEvent(e.event)}recordEvent(s,e={}){const t=Fv.get(s);if(t){const i=t.field,r=e[i];r!==void 0&&Ie(this.data,{[i]:r});const n=this.data[i];if(n===void 0||t.equal(n,this.lastEmitted[i]))return;Ie(this.lastEmitted,{[i]:t.snapshot(n)})}this.eventTargets.forEach((i,r)=>{this.recordTargetEvent(i,r,s,e)}),this.processEventTargets()}recordTargetEvent(s,e,t,i={}){var r;if(!e.events.includes(t))return;const n=Z(Z(Z({},this.data),i),{},{e:t,ts:(r=i.ts)!=null?r:Date.now(),sn:s.sn++});!isNaN(this.msd)&&!s.msdSent&&(n.msd=this.msd,s.msdSent=!0),s.queue.push(n)}recordResponseReceived(s,e={}){var t,i,r;const{request:n}=s,a=(t=e.url)!=null?t:n?.url;if(!a)return;const o=new URL(a);o.searchParams.delete(Oc);const l={url:o.toString(),rc:s.status},d=s.resourceTiming;d&&(d.startTime!=null&&(l.ts=Math.round(this.timeOrigin+d.startTime),d.responseStart!=null&&(l.ttfb=Math.round(d.responseStart-d.startTime))),d.duration!=null&&(l.ttlb=Math.round(d.duration)));const c=(i=(r=n.customData)==null?void 0:r.cmcd)!=null?i:{};this.recordEvent(Ul,Z(Z(Z({},c),l),e))}applyRequestReport(s){var e;return(e=this.createRequestReport(s))!=null?e:s}isRequestReportingEnabled(){var s;return!!((s=this.config.enabledKeys)!=null&&s.length)}createRequestReport(s,e){var t;const{customData:i={},headers:r={}}=s,n=ga(s,nv),a=Z(Z({},n),{},{headers:Z({},r),customData:Z(Z({},i),{},{cmcd:{}})});if(!((t=this.config.enabledKeys)!=null&&t.length)||!a.url)return a;const o=new URL(a.url),l=Z(Z(Z({},this.data),e),{},{sn:this.requestTarget.sn++}),d=Fc(Bl,this.config,a.url);!isNaN(this.msd)&&!this.requestTarget.msdSent&&(l.msd=this.msd,this.requestTarget.msdSent=!0);const c=a.customData.cmcd=_f(l,d);switch(this.config.transmissionMode){case Vl:const u=Lf(c);u&&(o.searchParams.set(Oc,u),a.url=o.toString());break;
69case xf:Ie(a.headers,Rv(c,d.customHeaderMap));break}return a}processEventTargets(s=!1){let e=!1;this.eventTargets.forEach((t,i)=>{const{queue:r}=t;if(!r.length||r.length<i.batchSize&&!s)return;const n=s?r.length:i.batchSize,a=r.splice(0,n);this.sendEventReport(i,a).catch(()=>{t.queue.unshift(...a)}),e||(e=r.length>0)}),e&&this.processEventTargets()}async sendEventReport(s,e){const t=Fc($l,s),{status:i}=await this.requester({url:s.url,method:"POST",headers:{"Content-Type":Cv},body:e.map(r=>Dv(r,t)).join(`
70`)+`
71`});if(i===410)this.disposeEventTarget(s);else if(i===429||i>499&&i<600)throw new Error(`Event report failed with status ${i}`)}disarmInterval(s){clearInterval(s.intervalId),s.intervalId=void 0}disposeEventTarget(s){const e=this.eventTargets.get(s);e&&(this.disarmInterval(e),this.eventTargets.delete(s))}resetSession(){this.eventTargets.forEach(s=>s.sn=0),this.requestTarget.sn=0,this.lastEmitted={}}};const Bv={HLS:"h"},Ha={VOD:"v",LIVE:"l",LOW_LATENCY:"ll"};function Gv(s,e){return new Tt(s,e)}new Set(Ea);new Set(No);const Vv=["includeKeys"];function Nc(s){return Object.keys(s).every(Gl)}class Hv{constructor(e){this.hls=void 0,this.config=void 0,this.media=void 0,this.initialized=!1,this.starved=!1,this.buffering=!0,this.playerState=void 0,this.reporter=void 0,this.playheadLevel=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0,this.setPlayerState(Ot.REBUFFERING)),this.buffering=!0},this.onPlay=()=>{this.initialized||this.setPlayerState(Ot.STARTING)},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1,this.setPlayerState(Ot.PLAYING)},this.onPause=()=>{this.media&&!this.media.ended&&this.setPlayerState(Ot.PAUSED)},this.onSeeking=()=>{this.initialized&&this.setPlayerState(Ot.SEEKING)},this.onSeeked=()=>{var r;this.initialized&&(r=this.media)!=null&&r.paused&&this.setPlayerState(Ot.PAUSED)},this.onRateChange=()=>{this.reporter&&this.media&&this.reporter.update({pr:this.media.playbackRate})},this.applyPlaylistData=r=>{try{this.apply(r,{ot:nt.MANIFEST,su:!this.initialized})}catch(n){this.hls.logger.warn("Could not generate manifest CMCD data.",n)}},this.applyFragmentData=r=>{try{const{frag:o,part:l}=r,d=this.hls.levels[o.level],c=this.getObjectType(o,d),u={d:(l||o).duration*1e3,ot:c};if(c===nt.VIDEO||c===nt.AUDIO||c===nt.MUXED||c==null&&(o.type==="main"||o.type==="audio")){var n;const f=d.bitrate/1e3;u.br=[f];const{cmcd:g}=this.config,m=(n=g?.rtpSafetyFactor)!=null?n:5;if(u.rtp=Math.round(f*m/100)*100,c===nt.MUXED||c==null&&o.type==="main"){const T=this.getTopBandwidth()/1e3;B(T)&&(u.tb=[T]);const y=this.getLowestBandwidth()/1e3;B(y)&&(u.lb=[y])}const p=this.getBufferLength(o);if(B(p)){var a;u.bl=[p];const T=((a=this.media)==null?void 0:a.playbackRate)||1;u.dl=Math.round(p/T/100)*100}this.playheadLevel&&(u.pb=[this.playheadLevel.bitrate/1e3]);const v=this.hls.maxAutoLevel;if(v>=0){const T=this.hls.levels[v];T&&(u.tpb=[T.bitrate/1e3])}}const h=l?this.getNextPart(l):this.getNextFrag(o);h!=null&&h.url&&h.url!==o.url&&(h.byteRange.length>0?u.nor=[Gv(h.url,{r:`${h.byteRange[0]}-${h.byteRange[1]}`})]:u.nor=[h.url]),this.apply(r,u)}catch(o){this.hls.logger.warn("Could not generate segment CMCD data.",o)}},this.recordFragmentResponse=(r,n,a)=>{var o;const{cmcd:l}=this.config,d=l==null||(o=l.eventTargets)==null?void 0:o.some(c=>{var u;return(u=c.events)==null?void 0:u.includes(Vr.RESPONSE_RECEIVED)});if(!(!this.reporter||!(a.loading.first>0)||!d))try{this.reporter.recordResponseReceived({request:{url:r},status:n.code,resourceTiming:{startTime:a.loading.start,responseStart:a.loading.first,duration:a.loading.end-a.loading.start,encodedBodySize:a.total}})}catch(c){this.hls.logger.warn("Could not record fragment response CMCD data.",c)}},this.hls=e;const t=this.config=e.config,{cmcd:i}=t;i!=null&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.registerListeners())}createReporter(){var e,t;const{cmcd:i}=this.config;if(i==null)return;const r=i.version||Pv;if(this.reporter=new $v({sid:i.sessionId||this.hls.sessionId,cid:i.contentId,version:r,transmissionMode:i.useHeaders===!0?xf:Vl,enabledKeys:(e=i.includeKeys)!=null?e:[...r>=yr?No:Ea],eventTargets:((t=i.eventTargets)!=null?t:[]).map(n=>{let{includeKeys:a}=n,o=ga(n,Vv);return Z(Z({},o),{},{enabledKeys:a??No})})},i.loader),this.reporter.update({sf:Bv.HLS,sta:this.playerState}),i.reporterCallback){const n=this.reporter,a={updateCustomData:o=>{Nc(o)&&n.update(o)}
71,recordCustomEvent:(o,l={})=>{Nc(l)&&n.recordEvent(Vr.CUSTOM_EVENT,Z({cen:o},l))}};i.reporterCallback(a)}this.reporter.start()}registerListeners(){const e=this.hls;e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(E.MEDIA_DETACHED,this.onMediaDetached,this),e.on(E.MEDIA_ENDED,this.onMediaEnded,this),e.on(E.ERROR,this.onError,this),e.on(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(E.LEVEL_SWITCHED,this.onLevelSwitched,this),e.on(E.BUFFER_APPENDED,this.onBufferInfoChange,this),e.on(E.BUFFER_FLUSHED,this.onBufferInfoChange,this)}unregisterListeners(){const e=this.hls;e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(E.MEDIA_DETACHED,this.onMediaDetached,this),e.off(E.MEDIA_ENDED,this.onMediaEnded,this),e.off(E.ERROR,this.onError,this),e.off(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(E.LEVEL_SWITCHED,this.onLevelSwitched,this),e.off(E.BUFFER_APPENDED,this.onBufferInfoChange,this),e.off(E.BUFFER_FLUSHED,this.onBufferInfoChange,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.reporter&&(this.reporter.stop(!0),this.reporter=void 0),this.hls=this.config=null,this.onWaiting=this.onPlay=this.onPlaying=this.onPause=null,this.onSeeking=this.onSeeked=this.onRateChange=this.media=null}onMediaAttaching(e,t){const i=this.media=t.media;this.setPlayerState(this.media.autoplay?Ot.STARTING:Ot.PRELOADING),Ae(i,"waiting",this.onWaiting),Ae(i,"play",this.onPlay),Ae(i,"playing",this.onPlaying),Ae(i,"pause",this.onPause),Ae(i,"seeking",this.onSeeking),Ae(i,"seeked",this.onSeeked),Ae(i,"ratechange",this.onRateChange)}onMediaDetached(){const e=this.media;e&&(ye(e,"waiting",this.onWaiting),ye(e,"play",this.onPlay),ye(e,"playing",this.onPlaying),ye(e,"pause",this.onPause),ye(e,"seeking",this.onSeeking),ye(e,"seeked",this.onSeeked),ye(e,"ratechange",this.onRateChange),this.media=null)}onMediaEnded(e,t){this.setPlayerState(Ot.ENDED)}onManifestLoading(e,t){this.initialized=!1,this.starved=!1,this.buffering=!0,this.reporter&&(this.reporter.stop(!0),this.reporter=void 0),this.createReporter(),this.media||this.setPlayerState(Ot.PRELOADING)}onError(e,t){t.fatal&&(this.setPlayerState(Ot.FATAL_ERROR),this.reporter&&this.reporter.recordEvent(Vr.ERROR,{ec:[t.details]}))}onLevelSwitching(e,t){var i;if(!this.reporter)return;const r={br:[t.bitrate/1e3]},n=(i=t.details)==null?void 0:i.fragments[0];n&&(r.ot=this.getObjectType(n,t)),this.reporter.recordEvent(Vr.BITRATE_CHANGE,r)}onLevelSwitched(e,t){const i=this.hls.levels[t.level];i&&(this.playheadLevel=i)}setPlayerState(e){this.playerState=e,this.reporter&&this.reporter.update({sta:e})}getStreamType(){const e=this.hls.latestLevelDetails;if(e)return e.live?e.partList&&e.canBlockReload?Ha.LOW_LATENCY:Ha.LIVE:Ha.VOD}apply(e,t={}){var i;if(!this.reporter)return;this.reporter.update({mtp:[this.hls.bandwidthEstimate/1e3],pr:(i=this.media)==null?void 0:i.playbackRate,st:this.getStreamType()});const r=t.ot===nt.INIT||t.ot===nt.VIDEO||t.ot===nt.MUXED;this.starved&&r&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering);const n=this.reporter.createRequestReport({url:e.url,headers:e.headers},t);e.url=n.url,e.headers=n.headers}getNextFrag(e){var t;const i=(t=this.hls.levels[e.level])==null?void 0:t.details;if(i){const r=e.sn-i.startSN;return i.fragments[r+1]}}getNextPart(e){var t;const{index:i,fragment:r}=e,n=(t=this.hls.levels[r.level])==null||(t=t.details)==null?void 0:t.partList;if(n){const{sn:a}=r;for(let o=n.length-1;o>=0;o--){const l=n[o];if(l.index===i&&l.fragment.sn===a)return n[o+1]}}}getObjectType(e,t){const{type:i}=e;if(i==="subtitle")return nt.TIMED_TEXT;if(e.sn==="initSegment")return nt.INIT;if(i==="audio")return nt.AUDIO;if(i==="main"){if(e.hasStreams){const r=e.elementaryStreams;if(r.audiovideo)return nt.MUXED;if(r.video)return nt.VIDEO;if(r.audio)return nt.AUDIO}if(t){const{audioCodec:r,videoCodec:n}=t;if(!this.hls.audioTracks.length){if(r&&n)return nt.MUXED;if(r)return nt.AUDIO}if(n)return nt.VIDEO}}}getTopBandwidth(){let e=0;const t=this.hls,i=t.maxAutoLevel,r=i>-1?i+1:t.levels.length;return t.levels.slice(0,r).forEach(a=>{a.bitrate>e&&(e=a.bitrate)}),e>0?e:NaN}getLowestBandwidth(){let e=1/0;const t=this.hls,i=t.maxAutoLevel,r=i>-1?i+1:t.levels.length;return t.levels.slice(0,r).forEach(a=>{a.bitrate<e&&(e=a.bitrate)}),B(e)?e:NaN}getBufferLength(e){if(!this.media)return NaN;const t=e.type==="audio"?this.hls.audioForwardBufferInfo:this.hls.mainForwardBufferInfo;return t?t.len*1e3:NaN}getEventBufferLength(){if(!this.media)return NaN;const e=this.hls.mainForwardBufferInfo,t=this.hls.audioForwardBufferInfo;if(e&&t)return Math.min(e.len,t.len)*1e3;const i=e||t;return i?i.len*1e3:NaN}onBufferInfoChange(e,t){if(!this.reporter)return;const i=this.getEventBufferLength();B(i)&&this.reporter.update({bl:[i]})}createPlaylistLoader(){const{pLoader:e}=this.config,t=this.applyPlaylistData,i=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new i(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(){const{fLoader:e}=this.config,t=this.applyFragmentData,i=this.recordFragmentResponse,r=e||this.config.loader;return class{constructor(a){this.loader=void 0,this.loader=new r(a)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(a,o,l){t(a);const{onSuccess:d}=l;this.loader.load(a,o,Z(Z({},l),{},{onSuccess:(c,u,h,f)=>{d(c,u,h,f),i(a.url,c,u)}}))}}}}const Kv=3e5;class Wv extends Dt{constructor(e){super("content-steering",e.logger),this.hls=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.registerListeners()}registerListeners(){const e=this.hls;e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.ERROR,this.onError,this))}pathways(){return(this.levels||[]).reduce((e,t)=>
vendor: 6,870 bytes, line 71
71(e.indexOf(t.pathwayId)===-1&&e.push(t.pathwayId),e),[])}get pathwayPriority(){return this._pathwayPriority}set pathwayPriority(e){this.updatePathwayPriority(e)}startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){const 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){const t=this.levels;t&&(this.levels=t.filter(i=>i!==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){const{contentSteering:i}=t;i!==null&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){const{errorAction:i}=t;if(i?.action===ot.SendAlternateToPenaltyBox&&i.flags&Je.MoveAllAlternatesMatchingHost){const r=this.levels;let n=this._pathwayPriority,a=this.pathwayId;if(t.context){const{groupId:o,pathwayId:l,type:d}=t.context;o&&r?a=this.getPathwayForGroupId(o,d,a):l&&(a=l)}a in this.penalizedPathways||(this.penalizedPathways[a]=performance.now()),!n&&r&&(n=this.pathways()),n&&n.length>1&&(this.updatePathwayPriority(n),i.resolved=this.pathwayId!==a,!i.resolved&&(t.details!==x.BUFFER_APPEND_ERROR||t.fatal)&&this.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${a} levels: ${r&&r.length} priorities: ${Re(n)} penalized: ${Re(this.penalizedPathways)}`))}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){const i=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${i}"`),t=this.getLevelsForPathway(i),this.pathwayId=i}return t.length!==e.length&&this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t}getLevelsForPathway(e){return this.levels===null?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){this._pathwayPriority=e;let t;const i=this.penalizedPathways,r=performance.now();Object.keys(i).forEach(n=>{r-i[n]>Kv&&delete i[n]});for(let n=0;n<e.length;n++){const a=e[n];if(a in i)continue;if(a===this.pathwayId)return;const 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,$h(t),this.hls.trigger(E.LEVELS_UPDATED,{levels:t});const 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,i){const r=this.getLevelsForPathway(i).concat(this.levels||[]);for(let n=0;n<r.length;n++)if(t===ue.AUDIO_TRACK&&r[n].hasAudioGroup(e)||t===ue.SUBTITLE_TRACK&&r[n].hasSubtitleGroup(e))return r[n].pathwayId;return i}clonePathways(e){const t=this.levels;if(!t)return;const i={},r={};e.forEach(n=>{const{ID:a,"BASE-ID":o,"URI-REPLACEMENT":l}=n;if(t.some(c=>c.pathwayId===a))return;const d=this.getLevelsForPathway(o).map(c=>{const u=new ke(c.attrs);u["PATHWAY-ID"]=a;const h=u.AUDIO&&`${u.AUDIO}_clone_${a}`,f=u.SUBTITLES&&`${u.SUBTITLES}_clone_${a}`;h&&(i[u.AUDIO]=h,u.AUDIO=h),f&&(r[u.SUBTITLES]=f,u.SUBTITLES=f);const g=Df(c.uri,u["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l),m=new gr({attrs:u,audioCodec:c.audioCodec,bitrate:c.bitrate,height:c.height,name:c.name,url:g,videoCodec:c.videoCodec,width:c.width});if(c.audioGroups)for(let p=1;p<c.audioGroups.length;p++)m.addGroupId("audio",`${c.audioGroups[p]}_clone_${a}`);if(c.subtitleGroups)for(let p=1;p<c.subtitleGroups.length;p++)m.addGroupId("text",`${c.subtitleGroups[p]}_clone_${a}`);return m});t.push(...d),Uc(this.audioTracks,i,l,a),Uc(this.subtitleTracks,r,l,a)})}loadSteeringManifest(e){const t=this.hls.config,i=t.loader;this.loader&&this.loader.destroy(),this.loader=new i(t);let r;try{r=new self.URL(e)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if(r.protocol!=="data:"){const c=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;r.searchParams.set("_HLS_pathway",this.pathwayId),r.searchParams.set("_HLS_throughput",""+c)}const n={type:ue.STEERING_MANIFEST,responseType:"json",url:r.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:(c,u,h,f)=>{this.log(`Loaded steering manifest: "${r}"`);const g=c.data;if(g?.VERSION!==1){this.log(`Steering VERSION ${g.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=g.TTL;const{"RELOAD-URI":m,"PATHWAY-CLONES":p,"PATHWAY-PRIORITY":v}=g;if(m)try{this.uri=new self.URL(m,r).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${m}`);return}this.scheduleRefresh(this.uri||h.url),p&&this.clonePathways(p);const T={steeringManifest:g,url:r.toString()};this.hls.trigger(E.STEERING_MANIFEST_LOADED,T),v&&this.updatePathwayPriority(v)},onError:(c,u,h,f)=>{if(this.log(`Error loading steering manifest: ${c.code} ${c.text} (${u.url})`),this.stopLoad(),c.code===410){this.enabled=!1,this.log(`Steering manifest ${u.url} no longer available`);return}let g=this.timeToLoad*1e3;if(c.code===429){const m=this.loader;if(typeof m?.getResponseHeader=="function"){const p=m.getResponseHeader("Retry-After");p&&(g=parseFloat(p)*1e3)}this.log(`Steering manifest ${u.url} rate limited`);return}this.scheduleRefresh(this.uri||u.url,g)},onTimeout:(c,u,h)=>{this.log(`Timeout loading steering manifest (${u.url})`),this.scheduleRefresh(this.uri||u.url)}};this.log(`Requesting steering manifest: ${r}`),this.loader.load(n,l,d)}scheduleRefresh(e,t=this.timeToLoad*1e3){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var i;const r=(i=this.hls)==null?void 0:i.media;if(r&&!r.ended){this.loadSteeringManifest(e);return}this.scheduleRefresh(e,this.timeToLoad*1e3)},t)}}function Uc(s,e,t,i){s&&Object.keys(e).forEach(r=>{const n=s.filter(a=>a.groupId===r).map(a=>{const o=Ie({},a);return o.details=void 0,o.attrs=new ke(o.attrs),o.url=o.attrs.URI=Df(a.url,a.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),o.groupId=o.attrs["GROUP-ID"]=e[r],o.attrs["PATHWAY-ID"]=i,o});s.push(...n)})}function Df(s,e,t,i){if(e){const{[t]:o}=i;if(o){const l=o[e];if(l)return l}}const{HOST:r,PARAMS:n}=i,a=new self.URL(s);
71return r&&(a.hostname=r),n&&Object.keys(n).sort().forEach(o=>{o&&a.searchParams.set(o,n[o])}),a.href}class Ft 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}}class Ts extends Dt{constructor(e){super("eme",e.logger),this.hls=void 0,this.config=void 0,this.media=null,this.mediaResolved=void 0,this.keyFormatPromise=null,this.keySystemAccessPromises={},this.sessionSetupByUri={},this.mediaKeySessions=[],this.activeKeys={},this.mediaKeys=null,this.setMediaKeysQueue=Ts.CDMCleanupPromise?[Ts.CDMCleanupPromise]:[],this.onMediaEncrypted=t=>{const{initDataType:i,initData:r}=t,n=`"${t.type}" event: init data type: "${i}"`;if(this.log(n),r!==null){if(!this.keyFormatPromise){let a=Object.keys(this.keySystemAccessPromises);a.length||(a=ws(this.config));const o=a.map(Ma).filter(l=>!!l);this.keyFormatPromise=this.getKeyFormatPromise(o)}this.keyFormatPromise.then(a=>{let o;const l=Ur(a),d=this.activeLevelKeys();if(l===De.FAIRPLAY&&i==="sinf")try{const g=Ne(new Uint8Array(r)),m=Sl(JSON.parse(g).sinf),p=oh(m);if(!p)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");o=new Uint8Array(p.subarray(8,24))}catch(g){this.warn(`${n} Failed to parse sinf: ${g}`);return}else if(l===De.PLAYREADY)o=Rl(new Uint8Array(r));else if(l===De.WIDEVINE){const g=uh(r).filter(m=>m.systemId===Ch.WIDEVINE);if(g.length){var c;const m=g[0];o=(c=m.kids)!=null&&c.length?m.kids[0]:null}}let u;if(o){const g=Ye(o);for(let m=0;m<d.length;m++){const p=d[m];if(p.keyId&&(Wn(o,p.keyId)||p.uri.replace(/-/g,"").indexOf(g)!==-1)){p.pssh||(p.scheme=i,p.pssh=new Uint8Array(r),p.keyId=o,Ei.setKeyIdForUri(p.uri,o)),u=this.getSessionForKey(p,"encrypted-event-key-match");break}}}if(!u){if(d.length){var h,f;return(h=d[0]).scheme||(h.scheme=i),(f=d[0]).pssh||(f.pssh=new Uint8Array(r)),this.get
71SessionForKey(d[0],"encrypted-event-no-match")}if(o)throw new Error(`Key ID ${Ye(o)} not encountered in playlist`);this.log(`Ignoring "${t.type}" event - could not determine keyId`)}return u}).catch(a=>this.handleError(a))}},this.onWaitingForKey=t=>{this.log(`"${t.type}" event`)},this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.onDestroying(),this.onMediaDetached();const e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.config=null,this.onMediaEncrypted=this.onWaitingForKey=null}registerListeners(){const{hls:e}=this;e&&(e.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHED,this.onMediaDetached,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(E.DESTROYING,this.onDestroying,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHED,this.onMediaDetached,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(E.DESTROYING,this.onDestroying,this))}attemptKeySystemAccess(e){if(!this.hls)return Promise.reject(new Error("destroyed"));const t=this.hls.levels,i=(a,o,l)=>!!a&&l.indexOf(a)===o,r=t.map(a=>a.audioCodec).filter(i),n=t.map(a=>a.videoCodec).filter(i);return r.length+n.length===0&&n.push("avc1.42e01e"),new Promise((a,o)=>{const l=d=>{const c=d.shift();this.getMediaKeysPromise(c,r,n).then(u=>a({keySystem:c,mediaKeys:u})).catch(u=>{d.length?l(d):u instanceof Ft?o(u):o(new Ft({type:X.KEY_SYSTEM_ERROR,details:x.KEY_SYSTEM_NO_ACCESS,error:u,fatal:!0},u.message))})};l(e)})}requestMediaKeySystemAccess(e,t){const{requestMediaKeySystemAccessFunc:i}=this.config;if(typeof i!="function"){let r=`Configured requestMediaKeySystemAccess is not a function ${i}`;return Ph===null&&self.location.protocol==="http:"&&(r=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(r))}return i(e,t)}getMediaKeysPromise(e,t,i){var r;const n=g0(e,t,i,this.config.drmSystemOptions||{});let a=this.keySystemAccessPromises[e],o=(r=a)==null?void 0:r.keySystemAccess;if(!o){this.log(`Requesting encrypted media "${e}" key-system access with config: ${Re(n)}`),o=this.requestMediaKeySystemAccess(e,n);const l=a=this.keySystemAccessPromises[e]={keySystemAccess:o};return o.catch(d=>{this.log(`Failed to obtain access to key-system "${e}": ${d}`)}),o.then(d=>{this.throwIfDestroyed(),this.log(`Access for key-system "${d.keySystem}" obtained`);const c=this.fetchServerCertificate(e);this.log(`Create media-keys for "${e}"`);const u=l.mediaKeys=d.createMediaKeys().then(h=>(this.log(`Media-keys created for "${e}"`),l.hasMediaKeys=!0,c.then(f=>f?this.setMediaKeysServerCertificate(h,e,f):h)));return u.catch(h=>{this.error(`Failed to create media-keys for "${e}"}: ${h}`)}),u})}return o.then(()=>a.mediaKeys)}getMediaKeySessionContext(e,t,i,r){const{mediaKeySessions:n}=this,a=` key-session "${e}" keyId: ${Ye(i.keyId||[])} keyUri: ${i.uri} for "${r}"`;for(let d=0;d<n.length;d++){const c=n[d];if(!c.initialized&&c.createdFor.levelKey.uri===i.uri)return this.log(`Reusing${a}`),c}this.log(`Creating${a}`);const o=t.createSession(),l={keySystem:e,mediaKeys:t,mediaKeysSession:o,keyRequests:{},keyStatuses:{},createdFor:{levelKey:i,reason:r},initialized:!1};return n.push(l),l}resetMediaKeys(){var e;const t=(e=this.mediaKeySessions[0])==null?void 0:e.keySystem,i=this.keySystemAccessPromises[t];i&&(this.log("reset mediaKeys"),this.mediaKeys=null,i.hasMediaKeys=!1,delete i.mediaKeys,delete this.keySystemAccessPromises[t])}updateKeySession(e,t,i){const r=e.mediaKeysSession;return this.log(`Updating key-session "${r.sessionId}" for keyId ${Ye(t.keyId||[])}
72      } (data length: ${i.byteLength})`),r.update(i)}getSelectedKeySystemFormats(){return Object.keys(this.keySystemAccessPromises).map(e=>({keySystem:e,hasMediaKeys:this.keySystemAccessPromises[e].hasMediaKeys})).filter(({hasMediaKeys:e})=>!!e).map(({keySystem:e})=>Ma(e)).filter(e=>!!e)}getKeySystemAccess(e){return this.getKeySystemSelectionPromise(e).then(({keySystem:t,mediaKeys:i})=>this.attemptSetMediaKeys(t,i))}selectKeySystem(e){return this.getKeySystemSelectionPromise(e).then(({keySystem:t})=>{const i=Ma(t);if(!i)throw new Error(`Unable to find format for key-system "${t}"`);return i})}selectKeySystemFormat(e){const 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){const t=ws(this.config),i=e.map(Ur).filter(r=>!!r&&t.indexOf(r)!==-1);return this.selectKeySystem(i)}loadClear(e,t,i){if(this.config.emeEnabled&&!this.getSelectedKeySystemFormats().length){if(t.length)for(let r=0,n=t.length;r<n;r++){const a=t[r];if(e.cc<=a.cc&&(!Ue(e)||!Ue(a)||e.sn<a.sn)||!i&&r==n-1)return this.selectKeySystemFormat(a).then(o=>{if(!this.hls)return;a.setKeyFormat(o);const l=Ur(o);if(l)return this.getKeySystemAccess([l])})}if(this.config.requireKeySystemAccessOnStart){const r=ws(this.config);if(r.length)return this.getKeySystemAccess(r)}}return null}getKeyStatus(e){const{mediaKeySessions:t}=this;for(let i=0;i<t.length;i++){const r=Ka(e,t[i]);if(r)return r}}loadKey(e){const t=e.decryptdata,i=this.getKeyStatus(t);if(i==="internal-error"){const o=$c(i,t);return o.data.frag=e,this.error(`${o.message} (${Ye(t.keyId||[])})`),Promise.reject(o)}const r=e.type,n=this.activeKeys,a=n[r];a&&!t.matches(a.decryptdata)&&(n.previous||(n.previous=[]),n.previous.push(a),delete n[r]),n[r]||(n[r]=e);for(let o=this.mediaKeySessions.length;o--;){const l=this.mediaKeySessions[o];if(t.keyId&&l.keyStatuses[Ye(t.keyId)]==="expired")return this.renewKeySession(t,l)}return this.updateUsablePromise(t,"playlist-key",e)}renewKeySession(e,t){return this.resetMediaKeys(),this.removeSession(t).then(()=>(this.throwIfDestroyed(),this.updateUsablePromise(e,"expired")))}updateUsablePromise(e,t,i){const r=this.getSessionForKey(e,t);return r.catch(n=>this.handleError(n,i)),r.then(n=>e)}getSessionForKey(e,t){const i=this.findContextForKey(e);if(i!==void 0)return Promise.resolve(i);const r=e.uri,n=this.sessionSetupByUri[r];let a;n===void 0?a=this.resolveSessionForKey(e,t):a=n.catch(()=>{}).then(()=>(this.throwIfDestroyed(),this.resolveSessionForKey(e,t))),this.sessionSetupByUri[r]=a;const o=()=>{this.sessionSetupByUri[r]===a&&delete this.sessionSetupByUri[r]};return a.then(o,o),a}findContextForKey(e){const{mediaKeySessions:t}=this;for(let i=t.length;i--;){const r=t[i];if(Ka(e,r))return r}}resolveSessionForKey(e,t){return this.getKeySystemForKeyPromise(e).then(({keySystem:i,mediaKeys:r})=>{this.throwIfDestroyed();for(let n=this.mediaKeySessions.length;n--;){const a=this.mediaKeySessions[n];if(Ka(e,a))return a;const o=this.getUsableKeyPromise(a,e,t);if(o)return o}return this.attemptSetMediaKeys(i,r).then(()=>(this.throwIfDestroyed(),this.getMediaKeySessionContext(i,r,e,t))).then(n=>{this.throwIfDestroyed();const a=e.scheme||"cenc",o=e.pssh?e.pssh.buffer:null;return this.generateRequestWithPreferredKeySession(n,e,a,o,t)})})}getUsableKeyPromise(e,t,i){const r=e.keyRequests[t.uri];if(r)return this.log(`Waiting for usable key (${i} keyId: ${jv(t)} format: "${t.keyFormat}" URI: ${t.uri})`),Bc(r).then(()=>e)}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e,t){if(this.hls)if(e instanceof Ft){t&&(e.data.frag=t);const i=e.data.decryptdata;this.error(`${e.message}${i?` (${Ye(i.keyId||[])})`:""}`),this.hls.trigger(E.ERROR,e.data)}else this.error(e.message),this.hls.trigger(E.ERROR,{type:X.KEY_SYSTEM_ERROR,details:x.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0})}
vendor: 4,657 bytes, line 72
72getKeySystemForKeyPromise(e){const t=Ur(e.keyFormat),i=t?[t]:ws(this.config);return this.attemptKeySystemAccess(i)}getKeySystemSelectionPromise(e){if(e.length||(e=ws(this.config)),e.length===0)throw new Ft({type:X.KEY_SYSTEM_ERROR,details:x.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${Re({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}activeLevelKeys(){const e=this.activeKeys,t=(e.previous||[]).map(i=>i.decryptdata);return e.audio&&t.unshift(e.audio.decryptdata),e.main&&t.unshift(e.main.decryptdata),t}attemptSetMediaKeys(e,t){if(this.mediaResolved=void 0,this.mediaKeys===t)return Promise.resolve();const i=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);const r=Promise.all(i).then(()=>this.media?this.media.setMediaKeys(t):new Promise((n,a)=>{this.mediaResolved=()=>{if(this.mediaResolved=void 0,!this.media)return a(new Error("Attempted to set mediaKeys without media element attached"));this.mediaKeys=t,this.media.setMediaKeys(t).then(n).catch(a)}}));return this.mediaKeys=t,this.setMediaKeysQueue.push(r),r.then(()=>{this.log(`Media-keys set for "${e}"`),i.push(r),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(n=>i.indexOf(n)===-1)})}filterInitData(e,t,i,r,n){var a;const o=(a=this.config.drmSystems)==null||(a=a[e.keySystem])==null?void 0:a.generateRequest;if(o)try{const d=o.call(this.hls,i,r,Ie({},e,{decryptdata:t,reason:n}),n);if(!d)throw new Error("Invalid response from configured generateRequest filter");t.scheme=d.initDataType?d.initDataType:"cenc";const c=d.initData?d.initData:null;return t.pssh=c?new Uint8Array(c):null,d}catch(d){var l;if(this.warn(d.message),(l=this.hls)!=null&&l.config.debug)throw d}return{initDataType:i,initData:r}}generateRequestWithPreferredKeySession(e,t,i,r,n){const a=this.getUsableKeyPromise(e,t,n);if(a)return a;const o=this.filterInitData(e,t,i,r,n);if(o&&(r=o.initData?o.initData:null,i=o.initDataType),r===null)return n.startsWith("encrypted-event")?Promise.reject(new Error(`missing initialization data for "${n}"`)):(this.log(`Skipping key-session request for "${n}" (no initData)`),Promise.resolve(e));const l=t.uri,d=new kl;d.status="initialized",d.requestErrors=[],e.keyRequests[l]=d;const c=h=>{const f=e.mediaKeysSession;if(!f){const p=new Error("invalid state");d.errored=p,d.emit("error",p);return}const{messageType:g,message:m}=h;d.status=g,this.log(`"${g}" message event for session "${f.sessionId}" message size: ${m.byteLength}`),g==="license-request"||g==="license-renewal"?this.renewLicense(e,t,m).catch(p=>{d.errored=p,d.eventNames().length?d.emit("error",p):this.handleError(p),this.removeSession(e)}):g==="license-release"?e.keySystem===De.FAIRPLAY&&this.updateKeySession(e,t,Ro("acknowledged")).then(()=>this.removeSession(e)).catch(p=>this.handleError(p)):this.warn(`unhandled media key message type "${g}"`)};return d.onmessage=c,Ae(e.mediaKeysSession,"message",c),this.generateRequest(e,t,i,r,n,!1)}generateRequest(e,t,i,r,n,a){if(a){const f=this.filterInitData(e,t,i,r,n);f&&(r=f.initData?f.initData:r,i=f.initDataType)}const o=t.uri,l=e.keyRequests[o],d=Ye(t.keyId||[]),c=f=>{let g;f.startsWith("usable")?(l.resolved=!0,l.emit("resolved")):f==="internal-error"||f==="output-restricted"||f==="output-downscaled"?g=$c(f,t):f==="expired"?g=new Error(`key expired (keyId: ${d})`):f==="released"?g=new Error("key released"):f==="status-pending"||this.warn(`unhandled key status change "${f}" (keyId: ${d})`),g&&(l.errored=g,l.eventNames().length?l.emit("error",g):this.handleError(g))},u=f=>{if(!e.mediaKeysSession){const A=new Error("invalid state");l.errored=A,l.emit("error",A);return}const m=e.keyStatuses=this.getKeyStatuses(e);if(!Object.keys(m).some(A=>m[A]!=="status-pending"))return;const v=this.activeLevelKeys();for(let A=0;A<v.length;A++){const I=Ye(v[A].keyId||[]);if(m[I]==="expired"){var T;this.log(`Expired key ${Re(m)} in key-session "${(T=e.mediaKeysSession)==null?void 0:T.sessionId}"`),this.renewKeySession(t,e).catch(_=>this.handleError(_));break}}let y=m[d];if(y)c(y);else{var S;e.keyStatusTimeouts||(e.keyStatusTimeouts={}),(S=e.keyStatusTimeouts)[d]||(S[d]=self.setTimeout(()=>{var I;if(!e.mediaKeysSession)return;const _=this.getKeyStatus(t);if(_&&_!=="status-pending"){var R;return this.log(`No status for keyId ${d} in key-session "${(R=e.mediaKeysSession)==null?void 0:R.sessionId}". Using session key-status ${_} from other session.`),c(_)}this.log(`key status for ${d} in key-session "${(I=e.mediaKeysSession)==null?void 0:I.sessionId}" timed out after 1000ms`),y="internal-error",c(y)},1e3)),this.log(`No status for keyId ${d} (${Re(m)}
72).`)}};l.onkeystatuseschange=u,Ae(e.mediaKeysSession,"keystatuseschange",u);const h=Bc(l);return this.log(`Generating key-session request for "${n}" keyId: ${d} URI: ${o} (init data type: ${i} length: ${r.byteLength})`),l.status="started",e.initialized=!0,e.mediaKeysSession.generateRequest(i,r).then(()=>{var f;l.status="generated",this.log(`Request generated for key-session "${(f=e.mediaKeysSession)==null?void 0:f.sessionId}" keyId: ${d} URI: ${o}`)}).catch(f=>{throw this.log(`mediaKeysSession.generateRequest failed: ${f}`),new Ft({type:X.KEY_SYSTEM_ERROR,details:x.KEY_SYSTEM_NO_SESSION,error:f,decryptdata:t,fatal:!1},`Error generating key-session request: ${f}`)}).then(()=>h).catch(f=>{var g;this.log(`mediaKeysSession.generateRequest failed: ${f}`);const m=(g=f.data)==null?void 0:g.details;return(m===x.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED||m===x.KEY_SYSTEM_STATUS_INTERNAL_ERROR)&&Object.keys(e.keyStatuses).some(p=>e.keyStatuses[p]==="usable")?(this.handleError(f),e):(l.removeAllListeners(),this.removeSession(e).then(()=>{throw f}))}).then(()=>e)}getKeyStatuses(e){const t={},i=e.mediaKeysSession.sessionId;return e.mediaKeysSession.keyStatuses.forEach((r,n)=>{if(typeof n=="string"&&typeof r=="object"){const l=n;n=r,r=l}const a="buffer"in n?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):new Uint8Array(n);if(e.keySystem===De.PLAYREADY&&a.length===16){const l=Ye(a);t[l]=r,Dh(a)}const o=Ye(a);this.log(`key status change "${r}" for keyStatuses keyId: ${o} key-session "${i}"`),t[o]=r}),t}fetchServerCertificate(e){const t=this.config,i=t.loader,r=new i(t),n=qv(e,t);return n?(this.log(`Fetching server certificate for "${e}"`),new Promise((a,o)=>{const l={type:ue.SERVER_CERTIFICATE,responseType:"arraybuffer",url:n},d=t.certLoadPolicy.default,c={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:(h,f,g,m)=>{a(h.data)},onError:(h,f,g,m)=>{o(new Ft({type:X.KEY_SYSTEM_ERROR,details:x.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:g,response:Z({url:l.url,data:void 0},h)},`"${e}" certificate request failed (${n}). Status: ${h.code} (${h.text})`))},onTimeout:(h,f,g)=>{o(new Ft({type:X.KEY_SYSTEM_ERROR,details:x.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:g,response:{url:l.url,data:void 0}},`"${e}" certificate request timed out (${n})`))},onAbort:(h,f,g)=>{o(new Error("aborted"))}};r.load(l,c,u)})):(this.log(`No Server Certificate in config.drmSystems["${e}"]`),Promise.resolve())}setMediaKeysServerCertificate(e,t,i){return new Promise((r,n)=>{e.setServerCertificate(i).then(a=>{this.log(`setServerCertificate ${a?"success":"not supported by CDM"} (${i.byteLength}) on "${t}"`),r(e)}).catch(a=>{n(new Ft({type:X.KEY_SYSTEM_ERROR,details:x.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:a,fatal:!0},a.message))})})}renewLicense(e,t,i){return this.requestLicense(e,t,new Uint8Array(i)).then(r=>this.updateKeySession(e,t,new Uint8Array(r)).catch(n=>{throw new Ft({type:X.KEY_SYSTEM_ERROR,details:x.KEY_SYSTEM_SESSION_UPDATE_FAILED,decryptdata:t,error:n,fatal:!1},n.message)}))}unpackPlayReadyKeyMessage(e,t){const i=Ne(new Uint16Array(t.buffer));if(!i.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;const r=new DOMParser().parseFromString(i,"application/xml"),n=r.querySelectorAll("HttpHeader");if(n.length>0){let c;for(let u=0,h=n.length;u<h;u++){var a,o;c=n[u];const f=(a=c.querySelector("name"))==null?void 0:a.textContent,g=(o=c.querySelector("value"))==null?void 0:o.textContent;f&&g&&e.setRequestHeader(f,g)}}const l=r.querySelector("Challenge"),d=l?.textContent;if(!d)throw new Error("Cannot find <Challenge> in key message");return Ro(atob(d))}setupLicenseXHR(e,t,i,r,n){const a=this.config.licenseXhrSetup;return a?Promise.resolve().then(()=>(this.throwIfDestroyed(),a.call(this.hls,e,t,Z(Z({},i),{},{decryptdata:r}),n))).catch(o=>{if(!i.mediaKeysSession)throw o;return e.open("POST",t,!0),a.call(this.hls,e,t,Z(Z({},i),{},{decryptdata:r}),n)}).then(o=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:o||n})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:n}))}requestLicense(e,t,i){return new Promise((r,n)=>{const a=Yv(e.keySystem,this.config);if(!a)return n(new Error(`no license server URL configured for key-system "${e.keySystem}"`));const o=e.keyRequests[t.uri];if(!o)return n(new Error("License emitter removed"));this.log(`Sending license request to URL: ${a}`);const l=this.config.keyLoadPolicy.default,d=new XMLHttpRequest;d.responseType="arraybuffer",d.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return n(new Error("invalid state"));if(d.readyState===4)if(d.status===200){o.requestErrors=[];let c=d.response;this.log(`License received ${c instanceof ArrayBuffer?c.byteLength:c}`);const u=this.config.licenseResponseCallback;if(u)try{c=u.call(this.hls,d,a,Z(Z({},e),{},{decryptdata:t}))}catch(h){this.error(h)}r(c)}else{const c=l.errorRetry,u=c?c.maxNumRetry:0;if(o.requestErrors.push({status:d.status,message:d.statusText}),o.requestErrors.length>u||d.status>=400&&d.status<500)n(new Ft({type:X.KEY_SYSTEM_ERROR,details:x.KEY_SYSTEM_LICENSE_REQUEST_FAILED,decryptdata:t,fatal:!0,networkDetails:d,response:{url:a,data:void 0,code:d.status,text:d.statusText}},`License Request XHR failed (${a}). Status: ${d.status} (${d.statusText})`));else{const h=u-o.requestErrors.length;this.warn(`Retrying license request, ${h} attempts left`),this.requestLicense(e,t,i).then(r,n)}}},o.licenseXhr&&o.licenseXhr.readyState!==XMLHttpRequest.DONE&&o.licenseXhr.abort(),o.licenseXhr=d,this.setupLicenseXHR(d,a,e,t,i).then(({xhr:c,licenseChallenge:u})=>{e.keySystem==De.PLAYREADY&&(u=this.unpackPlayReadyKeyMessage(c,u)),c.send(u)}).catch(n)})}onDestroying(){this.unregisterListeners(),this._clear()}onMediaAttached(e,t){if(!this.config.emeEnabled)return;const i=t.media;this.media=i,Ae(i,"encrypted",this.onMediaEncrypted),Ae(i,"waitingforkey",this.onWaitingForKey);const r=this.mediaResolved;r?r():this.mediaKeys=i.mediaKeys}onMediaDetached(){const e=this.media;e&&(ye(e,"encrypted",this.onMediaEncrypted),ye(e,"waitingforkey",this.onWaitingForKey),this.media=null,this.mediaKeys=null)}_clear(){var e;this.keyFormatPromise=null,this.keySystemAccessPromises={},this.activeKeys={},this.sessionSetupByUri={};const t=this.mediaResolved;if(t&&t(),!this.mediaKeys&&!this.mediaKeySessions.length)return;const i=this.media,r=this.mediaKeySessions.slice();this.mediaKeySessions=[],this.mediaKeys=null,Ei.clearKeyUriToKeyIdMap();const n=r.length;Ts.CDMCleanupPromise=Promise.all(r.map(a=>this.removeSession(a)).concat((i==null||(e=i.setMediaKeys(null))==null?void 0:e.catch(a=>
vendor: 40,753 bytes, lines 72-82
72{this.log(`Could not clear media keys: ${a}`),this.hls&&this.hls.trigger(E.ERROR,{type:X.OTHER_ERROR,details:x.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:!1,error:new Error(`Could not clear media keys: ${a}`)})}))||Promise.resolve())).catch(a=>{this.log(`Could not close sessions and clear media keys: ${a}`),this.hls&&this.hls.trigger(E.ERROR,{type:X.OTHER_ERROR,details:x.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close sessions and clear media keys: ${a}`)})}).then(()=>{n&&this.log("finished closing key sessions and clearing media keys")})}onManifestLoading(){this._clear(),this.keyFormatPromise=null}onManifestLoaded(e,{sessionKeys:t}){if(!(!t||!this.config.emeEnabled)&&!this.keyFormatPromise){const i=t.reduce((r,n)=>(r.indexOf(n.keyFormat)===-1&&r.push(n.keyFormat),r),[]);this.log(`Selecting key-system from session-keys ${i.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(i),this.keyFormatPromise.catch(()=>{})}}removeSession(e){const{mediaKeysSession:t}=e;if(t){this.log(`Remove licenses and keys and close session "${t.sessionId}"`),Object.keys(e.keyRequests).forEach(o=>{const l=e.keyRequests[o];l.onmessage&&(t.removeEventListener("message",l.onmessage),l.onmessage=void 0),l.onkeystatuseschange&&(t.removeEventListener("keystatuseschange",l.onkeystatuseschange),l.onkeystatuseschange=void 0);const d=l.licenseXhr;d&&(d.readyState!==XMLHttpRequest.DONE&&d.abort(),l.licenseXhr=void 0),e.keyRequests[o]=void 0}),e.mediaKeysSession=void 0;const i=this.mediaKeySessions.indexOf(e);i>-1&&this.mediaKeySessions.splice(i,1);const{keyStatusTimeouts:r}=e;r&&Object.keys(r).forEach(o=>self.clearTimeout(r[o]));const{drmSystemOptions:n}=this.config;return(p0(n)?new Promise((o,l)=>{self.setTimeout(()=>l(new Error("MediaKeySession.remove() timeout")),8e3),t.remove().then(o).catch(l)}):Promise.resolve()).catch(o=>{this.log(`Could not remove session: ${o}`),this.hls&&this.hls.trigger(E.ERROR,{type:X.OTHER_ERROR,details:x.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR,fatal:!1,error:new Error(`Could not remove session: ${o}`)})}).then(()=>t.close()).then(()=>t.closed).catch(o=>{this.log(`Could not close session: ${o}`),this.hls&&this.hls.trigger(E.ERROR,{type:X.OTHER_ERROR,details:x.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close session: ${o}`)})})}return Promise.resolve()}}Ts.CDMCleanupPromise=void 0;function Yv(s,e){const{drmSystems:t,widevineLicenseUrl:i}=e,r=t?.[s];if(r)return r.licenseUrl;if(s===De.WIDEVINE&&i)return i}function qv(s,e){const{drmSystems:t}=e,i=t?.[s];if(i)return i.serverCertificateUrl}function jv(s){if(s.keyFormat===lt.FAIRPLAY)return s.uri;if(s.keyId===null)throw new Error("keyId is null");return Ye(s.keyId)}function Ka(s,e){const t=s.keyId,i=e.mediaKeysSession;if(t&&i){const r=e.mediaKeysSession.keyStatuses;if(r.size)return r.has(t)?r.get(t):e.keyStatuses[Ye(t)]}}function $c(s,e){const t=s==="output-restricted",i=t?x.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:x.KEY_SYSTEM_STATUS_INTERNAL_ERROR;return new Ft({type:X.KEY_SYSTEM_ERROR,details:i,fatal:!1,decryptdata:e},t?"HDCP level output restricted":`key status changed to "${s}"`)}function Bc(s){return new Promise((e,t)=>{if(s.resolved)return e();if(s.errored)return t(s.errored);s.on("error",t),s.on("resolved",e)})}class zv{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(E.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(E.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListeners(){this.hls.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(E.MEDIA_DETACHING,this.onMediaDetaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){const i=this.hls.config;if(i.capLevelOnFPSDrop){const r=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=r,r&&typeof r.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod)}}onMediaDetaching(){this.media=null}checkFPS(e,t,i){const r=performance.now();if(t){if(this.lastTime){const n=r-this.lastTime,a=i-this.lastDroppedFrames,o=t-this.lastDecodedFrames,l=1e3*a/n,d=this.hls;if(d.trigger(E.FPS_DROP,{currentDropped:a,currentDecoded:o,totalDroppedFrames:i}),l>0&&a>d.config.fpsDroppedMonitoringThreshold*o){let c=d.currentLevel;d.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+c),c>0&&(d.autoLevelCapping===-1||d.autoLevelCapping>=c)&&(c=c-1,d.trigger(E.FPS_DROP_LEVEL_CAPPING,{level:c,droppedLevel:d.currentLevel}),d.autoLevelCapping=c,this.streamController.nextLevelSwitch())}}this.lastTime=r,this.lastDroppedFrames=i,this.lastDecodedFrames=t}}checkFPSInterval(){const e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){const t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}}var Hl=function(){if(Yn!=null&&Yn.VTTCue)return self.VTTCue;const s=["","lr","rl"],e=["start","middle","end","left","right"];function t(o,l){if(typeof l!="string"||!Array.isArray(o))return!1;const d=l.toLowerCase();return~o.indexOf(d)?d:!1}function i(o){return t(s,o)}function r(o){return t(e,o)}function n(o,...l){let d=1;for(;d<arguments.length;d++){const c=arguments[d];for(const u in c)o[u]=c[u]}return o}function a(o,l,d){const c=this,u={enumerable:!0};c.hasBeenReset=!1;let h="",f=!1,g=o,m=l,p=d,v=null,T="",y=!0,S="auto",A="start",I=50,_="middle",R=50,D="middle";Object.defineProperty(c,"id",n({},u,{get:function(){return h},set:function(L){h=""+L}})),Object.defineProperty(c,"pauseOnExit",n({},u,{get:function(){return f},set:function(L){f=!!L}})),Object.defineProperty(c,"startTime",n({},u,{get:function(){return g},set:function(L){if(typeof L!="number")throw new TypeError("Start time must be set to a number.");g=L,this.hasBeenReset=!0}})),Object.defineProperty(c,"endTime",n({},u,{get:function(){return m},set:function(L){if(typeof L!="number")throw new TypeError("End time must be set to a number.");m=L,this.hasBeenReset=!0}})),Object.defineProperty(c,"text",n({},u,{get:function(){return p},set:function(L){p=""+L,this.hasBeenReset=!0}})),Object.defineProperty(c,"region",n({},u,{get:function(){return v},set:function(L){v=L,this.hasBeenReset=!0}})),Object.defineProperty(c,"vertical",n({},u,{get:function(){return T},set:function(L){const k=i(L);if(k===!1)throw new SyntaxError("An invalid or illegal string was specified.");T=k,this.hasBeenReset=!0}})),Object.defineProperty(c,"snapToLines",n({},u,{get:function(){return y},set:function(L){y=!!L,this.hasBeenReset=!0}})),Object.defineProperty(c,"line",n({},u,{get:function(){return S},set:function(L){if(typeof L!="number"&&L!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");S=L,this.hasBeenReset=!0}})),Object.defineProperty(c,"lineAlign",n({},u,{get:function(){return A},set:function(L){const k=r(L);if(!k)throw new SyntaxError("An invalid or illegal string was specified.");A=k,this.hasBeenReset=!0}})),Object.defineProperty(c,"position",n({},u,{get:function(){return I},set:function(L){if(L<0||L>100)throw new Error("Position must be between 0 and 100.");I=L,this.hasBeenReset=!0}})),Object.defineProperty(c,"positionAlign",n({},u,{get:function(){return _},set:function(L){const k=r(L);if(!k)throw new SyntaxError("An invalid or illegal string was specified.");_=k,this.hasBeenReset=!0}})),Object.defineProperty(c,"size",n({},u,{get:function(){return R},set:function(L){if(L<0||L>100)throw new Error("Size must be between 0 and 100.");R=L,this.hasBeenReset=!0}})),Object.defineProperty(c,"align",n({},u,{get:function(){return D},set:function(L){const k=r(L);if(!k)throw new SyntaxError("An invalid or illegal string was specified.");D=k,this.hasBeenReset=!0}})),c.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}();class Qv{decode(e,t){if(!e)return"";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function kf(s){function e(i,r,n,a){return(i|0)*3600+(r|0)*60+(n|0)+parseFloat(a||0)}const t=s.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}class Xv{constructor(){this.values=Object.create(null)}set(e,t){!this.get(e)&&t!==""&&(this.values[e]=t)}get(e,t,i){return i?this.has(e)?this.values[e]:t[i]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,i){for(let r=0;r<i.length;++r)if(t===i[r]){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)){const i=parseFloat(t);if(i>=0&&i<=100)return this.set(e,i),!0}return!1}}function Cf(s,e,t,i){const r=i?s.split(i):[s];for(const n in r){if(typeof r[n]!="string")continue;const a=r[n].split(t);if(a.length!==2)continue;const o=a[0],l=a[1];e(o,l)}}const Uo=new Hl(0,0,""),Hr=Uo.align==="middle"?"middle":"center";function Zv(s,e,t){const i=s;function r(){const o=kf(s);if(o===null)throw new Error("Malformed timestamp: "+i);return s=s.replace(/^[^\sa-zA-Z-]+/,""),o}function n(o,l){const d=new Xv;Cf(o,function(h,f){let g;switch(h){case"region":for(let m=t.length-1;m>=0;m--)if(t[m].id===f){d.set(h,t[m].region);break}break;case"vertical":d.alt(h,f,["rl","lr"]);break;case"line":g=f.split(","),d.integer(h,g[0]),d.percent(h,g[0])&&d.set("snapToLines",!1),d.alt(h,g[0],["auto"]),g.length===2&&d.alt("lineAlign",g[1],["start",Hr,"end"]);break;case"position":g=f.split(","),d.percent(h,g[0]),g.length===2&&d.alt("positionAlign",g[1],["start",Hr,"end","line-left","line-right","auto"]);break;case"size":d.percent(h,f);break;case"align":d.alt(h,f,["start",Hr,"end","left","right"]);break}},/:/,/\s/),l.region=d.get("region",null),l.vertical=d.get("vertical","");let c=d.get("line","auto");c==="auto"&&Uo.line===-1&&(c=-1),l.line=c,l.lineAlign=d.get("lineAlign","start"),l.snapToLines=d.get("snapToLines",!0),l.size=d.get("size",100),l.align=d.get("align",Hr);let u=d.get("position","auto");u==="auto"&&Uo.position===50&&(u=l.align==="start"||l.align==="left"?0:l.align==="end"||l.align==="right"?100:50),l.position=u}function a(){s=s.replace(/^\s+/,"")}if(a(),e.startTime=r(),a(),s.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+i);s=s.slice(3),a(),e.endTime=r(),a(),n(s,e)}function Pf(s){return s.replace(/<br(?: \/)?>/gi,`
73`)}class Jv{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new Qv,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){const t=this;e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));function i(){let n=t.buffer,a=0;for(n=Pf(n);a<n.length&&n[a]!=="\r"&&n[a]!==`
74`;)++a;const o=n.slice(0,a);return n[a]==="\r"&&++a,n[a]===`
75`&&++a,t.buffer=n.slice(a),o}function r(n){Cf(n,function(a,o){},/:/)}try{let n="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;n=i();const 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=i(),t.state){case"HEADER":/:/.test(n)?r(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 Hl(0,0,""),t.state="CUE",n.indexOf("-->")===-1){t.cue.id=n;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{Zv(n,t.cue,t.regionList)}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{const 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+=`
76`),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(){const e=this;try{if((e.cue||e.state==="HEADER")&&(e.buffer+=`
77
78`,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}}function sr(s){let e=5381,t=s.length;for(;t;)e=e*33^s.charCodeAt(--t);return(e>>>0).toString()}const ey=/\r\n|\n\r|\n|\r/g,Gc="Missing initPTS for VTT ",ty=function(e){let t=parseInt(e.slice(-3));const i=parseInt(e.slice(-6,-4)),r=parseInt(e.slice(-9,-7)),n=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!B(t)||!B(i)||!B(r)||!B(n))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*i,t+=60*1e3*r,t+=3600*1e3*n,t};function Kl(s,e,t){return sr(s.toString())+sr(e.toString())+sr(t)}function iy(s,e,t,i,r,n,a){const o=new Jv,l=Rt(new Uint8Array(s)).trim().replace(ey,`
79`).split(`
80`),d=[],c=e?EE(e.baseTime,e.timescale):0;let u="00:00.000",h=0,f=0,g=!1,m,p=!0;o.oncue=function(v){const T=t[i];let y=t.ccOffset;const S=(h-c)/9e4;if(g){if(T!=null&&T.new&&(y=t.ccOffset=T.start),S){if(!e){m=new Error(Gc+"MPEGTS");return}y=S-t.presentationOffset}}else if(e)y=-e.baseTime/e.timescale;else{m=new Error(Gc+"without X-TIMESTAMP-MAP");return}const A=v.endTime-v.startTime,I=Lt((v.startTime+y-f)*9e4,r*9e4)/9e4;v.startTime=Math.max(I,0),v.endTime=Math.max(I+A,0);const _=v.text.trim();v.text=decodeURIComponent(encodeURIComponent(_)),v.id?i&&(v.id=`hlsjscc${i}_${v.id}`):v.id=Kl(v.startTime,v.endTime,_),v.endTime>0&&d.push(v)},o.onparsingerror=function(v){m=v},o.onflush=function(){if(m){a(m);return}n(d)},l.forEach(v=>{if(p)if(v.startsWith("X-TIMESTAMP-MAP=")){p=!1,g=!0,v.slice(16).split(",").forEach(T=>{T.startsWith("LOCAL:")?u=T.slice(6):T.startsWith("MPEGTS:")&&(h=parseInt(T.slice(7)))});try{f=ty(u)/1e3}catch(T){m=T}return}else v===""&&(p=!1);o.parse(v+`
81`)}),o.flush()}const $o="stpp.ttml.im1t",wf=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Mf=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,sy={left:"start",center:"center",right:"end",start:"start",end:"end"};function Vc(s,e,t,i){const r=oe(new Uint8Array(s),["mdat"]);if(r.length===0){i(new Error("Could not parse IMSC1 mdat"));return}const n=r.map(o=>Rt(o)),a=pE(e.baseTime,1,e.timescale);try{n.forEach(o=>t(ry(o,a)))}catch(o){i(o)}}function ry(s,e){const r=new DOMParser().parseFromString(s,"text/xml").getElementsByTagName("tt")[0];if(!r)throw new Error("Invalid ttml");const n={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},a=Object.keys(n).reduce((u,h)=>(u[h]=r.getAttribute(`ttp:${h}`)||n[h],u),{}),o=r.getAttribute("xml:space")!=="preserve",l=Hc(Wa(r,"styling","style")),d=Hc(Wa(r,"layout","region")),c=Wa(r,"body","[begin]");return[].map.call(c,u=>{const h=Of(u,o);if(!h||!u.hasAttribute("begin"))return null;const f=qa(u.getAttribute("begin"),a),g=qa(u.getAttribute("dur"),a);let m=qa(u.getAttribute("end"),a);if(f===null)throw Kc(u);if(m===null){if(g===null)throw Kc(u);m=f+g}const p=new Hl(f-e,m-e,h);p.id=Kl(p.startTime,p.endTime,p.text);const v=d[u.getAttribute("region")],T=l[u.getAttribute("style")],y=ny(v,T,l),{textAlign:S}=y;if(S){const A=sy[S];A&&(p.lineAlign=A),p.align=S}return Ie(p,y),p}).filter(u=>u!==null)}function Wa(s,e,t){const i=s.getElementsByTagName(e)[0];return i?[].slice.call(i.querySelectorAll(t)):[]}function Hc(s){return s.reduce((e,t)=>{const i=t.getAttribute("xml:id");return i&&(e[i]=t),e},{})}function Of(s,e){return[].slice.call(s.childNodes).reduce((t,i,r)=>{var n;return i.nodeName==="br"&&r?t+`
82`:(n=i.childNodes)!=null&&n.length?Of(i,e):e?t+i.textContent.trim().replace(/\s+/g," "):t+i.textContent},"")}function ny(s,e,t){const i="http://www.w3.org/ns/ttml#styling";let r=null;const n=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=s!=null&&s.hasAttribute("style")?s.getAttribute("style"):null;return a&&t.hasOwnProperty(a)&&(r=t[a]),n.reduce((o,l)=>{const d=Ya(e,i,l)||Ya(s,i,l)||Ya(r,i,l);return d&&(o[l]=d),o},{})}function Ya(s,e,t){return s&&s.hasAttributeNS(e,t)?s.getAttributeNS(e,t):null}function Kc(s){return new Error(`Could not parse ttml timestamp ${s}`)}function qa(s,e){if(!s)return null;let t=kf(s);return t===null&&(wf.test(s)?t=ay(s,e):Mf.test(s)&&(t=oy(s,e))),t}function ay(s,e){const t=wf.exec(s),i=(t[4]|0)+(t[5]|0)/e.subFrameRate;return(t[1]|0)*3600+(t[2]|0)*60+(t[3]|0)+i/e.frameRate}function oy(s,e){const t=Mf.exec(s),i=Number(t[1]);switch(t[2]){case"h":return i*3600;case"m":return i*60;case"ms":return i*1e3;case"f":return i/e.frameRate;case"t":return i/e.tickRate}return i}function Wl(s,e,t,i="",r="disabled"){const n=s.ownerDocument.createElement("track");return n.kind=e,n.label=t,i&&(n.srclang=i),n.src="data:,WEBVTT",n.track.mode=r,s.appendChild(n),n}function ly(s){return s.forced&&_p()?"forced":s.characteristics&&/transcribes-spoken-dialog/gi.test(s.characteristics)&&/describes-music-and-sound/gi.test(s.characteristics)?"captions":"subtitles"}function Bo(s,e){const t=s.mode;if(t==="disabled"&&(s.mode="hidden"),s.cues&&!s.cues.getCueById(e.id))try{if(s.addCue(e),!s.cues.getCueById(e.id))throw new Error(`addCue is failed for: ${e}`)}catch(i){Te.debug(`[texttrack-utils]: ${i}`);try{const r=new self.TextTrackCue(e.startTime,e.endTime,e.text);r.id=e.id,s.addCue(r)}catch(r){Te.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${r}`)}}t==="disabled"&&(s.mode=t)}function Go(s,e,t,i){const r=s.mode;if(r==="disabled"&&(s.mode="hidden"),s.cues&&s.cues.length>0){const n=cy(s.cues,e,t);for(let a=0;a<n.length;a++)(!i||i(n[a]))&&s.removeCue(n[a])}r==="disabled"&&(s.mode=r)}function dy(s,e){if(e<=s[0].startTime)return 0;const t=s.length-1;if(e>s[t].endTime)return-1;let i=0,r=t,n;for(;i<=r;)if(n=Math.floor((r+i)/2),e<s[n].startTime)r=n-1;else if(e>s[n].startTime&&i<t)i=n+1;else return n;return s[i].startTime-e<e-s[r].startTime?i:r}function cy(s,e,t){const i=[],r=dy(s,e);if(r>-1)for(let n=r,a=s.length;n<a;n++){const o=s[n];if(o.startTime>=e&&o.endTime<=t)i.push(o);else if(o.startTime>t)return i}return i}class uy extends Ol{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.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.onTextTracksChanged=()=>{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let t=-1,i=!1;if(this.currentTrack){var r;const o=(r=this.currentTrack.trackNode)==null?void 0:r.track.mode;o==="showing"?(t=this.trackId,i=!0):o==="hidden"&&(t=this.trackId)}if(!i)for(let o=0;o<this.tracksInGroup.length;o++){var n;const l=(n=this.tracksInGroup[o].trackNode)==null?void 0:n.track.mode;if(l==="showing"){t=o;break}else t<0&&l==="hidden"&&(t=o)}if(t>-1){var a;this._subtitleDisplay=((a=this.tracksInGroup[t].trackNode)==null?void 0:a.track.mode)==="showing"}this.setSubtitleTrack(t,!0)},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(){const{hls:e}=this;e.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.LEVEL_LOADING,this.onLevelLoading,this),e.on(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(E.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(E.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.LEVEL_LOADING,this.onLevelLoading,this),e.off(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(E.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(E.ERROR,this.onError,this)}createTracksInGroup(){var e;if(!this.media||!this.hls.config.renderTextTracksNatively)return;this.tracksInGroup.forEach(i=>{i.trackNode||(i.trackNode=Wl(this.media,ly(i),i.name,i.lang))});const t=(e=this.currentTrack)==null||(e=e.trackNode)==null?void 0:e.track;t?.mode==="disabled"&&(t.mode=this._subtitleDisplay?"showing":"hidden")}onMediaAttached(e,t){const i=t.media;this.media=i;let r=this.trackId;this.queuedDefaultTrack>-1&&(r=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.setSubtitleTrack(r),this.createTracksInGroup(),this.useTextTrackPolling=!(i.textTracks&&"onchange"in i.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):i.textTracks.addEventListener("change",this.asyncPollTrackChange)}pollTrackChange(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,e)}onMediaDetaching(e,t){const i=this.media;if(!i)return;const r=!!t.transferMedia;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||i.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId,this.setSubtitleTrack(-1)),this.media=null,!r&&this.hls.config.renderTextTracksNatively&&this.tracksInGroup.forEach(n=>{const a=n.trackNode;a&&(a.track.mode="hidden",a.remove(),n.trackNode=void 0)})}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){const{id:i,groupId:r,details:n}=t,a=this.tracksInGroup[i];if(!a||a.groupId!==r){this.warn(`Subtitle track with id:${i} and group:${r} not found in active group ${a?.groupId}`);return}const o=a.details;a.details=t.details,this.log(`Subtitle track ${i} "${a.name}" lang:${a.lang} group:${r} loaded [${n.startSN}-${n.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!t)return;const i=t.subtitleGroups||null,r=this.groupIds;let n=this.currentTrack;if(!i||r?.length!==i?.length||i!=null&&i.some(a=>r?.indexOf(a)===-1)){this.groupIds=i;const a=[];if(this.tracks.forEach(c=>{(c.textCodec===$o?this.hls.config.enableIMSC1:this.hls.config.enableWebVTT)&&(!i||i.indexOf(c.groupId)>-1?(c.id=a.length,a.push(c)):c.trackNode&&(c.trackNode.remove(),c.trackNode=void 0))}),a.length===this.tracksInGroup.length){let c=!1;for(let u=0;u<a.length;u++)if(a[u]!==this.tracksInGroup[u]){c=!0;break}if(!c)return}a.length&&this.selectDefaultTrack&&!a.some(c=>c.default)&&(this.selectDefaultTrack=!1),this.tracksInGroup=a,this.trackId=-1,this.currentTrack=null;const o=this.hls.config.subtitlePreference;if(!n&&o){this.selectDefaultTrack=!1;const c=ni(o,a);if(c>-1)n=a[c];else{const u=ni(o,this.tracks);n=this.tracks[u]}}let l=this.findTrackId(n);l===-1&&n&&(l=this.findTrackId(null));const d={subtitleTracks:a};this.log(`Updating subtitle tracks, ${a.length} track(s) found in "${i?.join(",")}" group-id`),this.hls.trigger(E.SUBTITLE_TRACKS_UPDATED,d),this.setSubtitleTrack(l),this.createTracksInGroup()}}findTrackId(e){const t=this.tracksInGroup,i=this.selectDefaultTrack;for(let r=0;r<t.length;r++){const n=t[r];if(!(i&&!n.default||!i&&!e)&&(!e||Ki(n,e)))return r}if(e){for(let r=0;r<t.length;r++){const n=t[r];if(vr(e.attrs,n.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return r}for(let r=0;r<t.length;r++){const n=t[r];if(vr(e.attrs,n.attrs,["LANGUAGE"]))return r}}return-1}onError(e,t){t.fatal||!t.context||t.context.type===ue.SUBTITLE_TRACK&&t.context.id===this.trackId&&mr(t.context.groupId,this.groupIds)&&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,!0)}setSubtitleOption(e){if(this.hls.config.subtitlePreference=e,e){if(e.id===-1)return this.setSubtitleTrack(-1,!0),null;const t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){const i=this.currentTrack;if(i&&Ki(e,i))return i;const r=ni(e,this.tracksInGroup);if(r>-1){const n=this.tracksInGroup[r];return this.setSubtitleTrack(r,!0),n}else{if(i)return null;{const n=ni(e,t);if(n>-1)return t[n]}}}}return null}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentTrack)&&this.scheduleLoading(this.currentTrack,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const i=e.id,r=e.groupId,n=this.getUrlWithDirectives(e.url,t),a=e.details,o=a?.age;this.log(`Loading subtitle ${i} "${e.name}" lang:${e.lang} group:${r}${t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:""}${o&&a.live?" age "+o.toFixed(1)+(a.type&&" "+a.type||""):""} ${n}`),this.hls.trigger(E.SUBTITLE_TRACK_LOADING,{url:n,id:i,groupId:r,deliveryDirectives:t||null,track:e})}toggleTrackModes(){if(!this.media||!this.hls.config.renderTextTracksNatively)return;const e=this.currentTrack;this.tracksInGroup.forEach(t=>{if(t.trackNode){const i=t===e?this._subtitleDisplay?"showing":"hidden":"disabled",r=t.trackNode.track;r.mode!==i&&(r.mode=i)}})}setSubtitleTrack(e,t=!1){const i=this.tracksInGroup;if(this.media||(this.queuedDefaultTrack=e),e<-1||e>=i.length||!B(e)){this.warn(`Invalid subtitle track id: ${e}`);return}const r=this.currentTrack,n=i[e]||null;if(this.trackId=e,this.currentTrack=n,t&&this.toggleTrackModes(),!n){r&&this.hls.trigger(E.SUBTITLE_TRACK_SWITCH,{id:e});return}const a=!!n.details&&!n.details.live;if(n===r&&a)return;this.log(`Switching to subtitle-track ${e}`+(n?` "${n.name}" lang:${n.lang} group:${n.groupId}`:""));const{id:o,groupId:l="",name:d,type:c,url:u}=n;this.hls.trigger(E.SUBTITLE_TRACK_SWITCH,{id:o,groupId:l,name:d,type:c,url:u});const h=this.switchParams(n.url,r?.details,n.details);this.loadPlaylist(h)}}const hn=2,hy=100;class fy extends _h{constructor(e,t){super("gap-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.media=null,this.mediaSource=void 0,this.nudgeRetry=0,this.skipRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.buffered={},this.lastCurrentTime=void 0,this.ended=0,this.waiting=0,this.onMediaPlaying=()=>{this.ended=0,this.waiting=0},this.onMediaWaiting=()=>{var i;(i=this.media)!=null&&i.seeking||(this.waiting=self.performance.now(),this.tick())},this.onMediaEnded=()=>{if(this.hls){var i;this.ended=((i=this.media)==null?void 0:i.currentTime)||1,this.hls.trigger(E.MEDIA_ENDED,{stalled:!1})}},this.hls=e,this.fragmentTracker=t,this.lastCurrentTime=this.getCurrentTime(),this.registerListeners()}registerListeners(){const{hls:e}=this;e&&(e.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.BUFFER_APPENDED,this.onBufferAppended,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.BUFFER_APPENDED,this.onBufferAppended,this))}destroy(){super.destroy(),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0}onMediaAttached(e,t){this.setInterval(hy),this.mediaSource=t.mediaSource;const i=this.media=t.media;Ae(i,"playing",this.onMediaPlaying),Ae(i,"waiting",this.onMediaWaiting),Ae(i,"ended",this.onMediaEnded)}onMediaDetaching(e,t){this.clearInterval();const{media:i}=this;i&&(ye(i,"playing",this.onMediaPlaying),ye(i,"waiting",this.onMediaWaiting),ye(i,"ended",this.onMediaEnded),this.media=null),this.mediaSource=void 0}onBufferAppended(e,t){this.buffered=t.timeRanges}get hasBuffered(){return Object.keys(this.buffered).length>0}getCurrentTime(){var e;const t=((e=this.hls)==null?void 0:e.config.timelineOffset)||0;return this.media?Math.max(this.media.currentTime,t):t}tick(){var e;if(!((e=this.media)!=null&&e.readyState)||!this.hasBuffered)return;const t=this.getCurrentTime();this.media.currentTime<t||(this.poll(t,this.lastCurrentTime),this.lastCurrentTime=t)}poll(e,t){var i,r;const n=(i=this.hls)==null?void 0:i.config;if(!n)return;const a=this.media;if(!a)return;const{seeking:o}=a,l=this.seeking&&!o,d=!this.seeking&&o,c=a.paused&&!o||a.ended||a.playbackRate===0;if(this.seeking=o,e!==t){t&&(this.ended=0),this.moved=!0,o||(this.skipRetry=this.nudgeRetry=0,n.nudgeOnVideoHole&&!c&&e>t&&this.nudgeOnVideoHole(e,t)),this.waiting===0&&this.stallResolved(e);return}if(d||l){l&&this.stallResolved(e);return}if(c){this.skipRetry=this.nudgeRetry=0,this.stallResolved(e),!this.ended&&a.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(E.MEDIA_ENDED,{stalled:!1}));return}if(!ie.getBuffered(a).length){this.skipRetry=this.nudgeRetry=0;return}const u=ie.bufferInfo(a,e,0),h=this.fragmentTracker;h&&this.hls&&qc(u,e,h,this.hls);const f=u.nextStart||0;if(o&&h&&this.hls){const I=Wc(this.hls.inFlightFragments,e),_=u.len>hn,R=!f||I||f-e>hn&&!h.getPartialFragment(e);if(_||R)return;this.moved=!1}const g=(r=this.hls)==null?void 0:r.latestLevelDetails;if(!this.moved&&this.stalled!==null&&h){if(!(u.len>0)&&!f)return;const _=Math.max(f,u.start||0)-e,D=!!(g!=null&&g.live)?g.targetduration*2:hn,L=Vs(e,h);if(_>0&&(_<=D||L)){a.paused||this._trySkipBufferHole(L);return}}const m=n.detectStallWithCurrentTimeMs,p=self.performance.now(),v=this.waiting;let T=this.stalled;if(T===null)if(v>0&&p-v<m)T=this.stalled=v;else{this.stalled=p;return}const y=p-T;if(!o&&(y>=m||v&&this.moved)&&this.hls){var S;if(((S=this.mediaSource)==null?void 0:S.readyState)==="ended"&&!(g!=null&&g.live)&&Math.abs(e-(g?.edge||0))<1){if(this.ended)return;this.ended=e||1,this.hls.trigger(E.MEDIA_ENDED,{stalled:!0});return}if(this._reportStall(u),!this.media||!this.hls)return;if(a.currentTime!==e){const I=e;e=a.currentTime,this.moved=!0,this.log(`currentTime changed ${I} > ${e}`);return}}const A=ie.bufferInfo(a,e,n.maxBufferHole);this._tryFixBufferStall(A,y,e)}stallResolved(e){const t=this.stalled;if(t&&this.hls&&(this.stalled=null,this.stallReported)){const i=self.performance.now()-t;this.log(`playback not stuck anymore @${e}, after ${Math.round(i)}ms`),this.stallReported=!1,this.waiting=0,this.hls.trigger(E.STALL_RESOLVED,{})}}nudgeOnVideoHole(e,t){var i;const r=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&(i=this.buffered.audio)!=null&&i.length&&r&&r.length>1&&e>r.end(0)){const n=ie.bufferedInfo(ie.timeRangesToArray(this.buffered.audio),e,0);if(n.len>1&&t>=n.start){const a=ie.timeRangesToArray(r),o=ie.bufferedInfo(a,t,0).bufferedIndex;if(o>-1&&o<a.length-1){const l=ie.bufferedInfo(a,e,0).bufferedIndex,d=a[o].end,c=a[o+1].start;if((l===-1||l>o)&&c-d<1&&e-d<2){const u=new Error(`nudging playhead to flush pipeline after video hole. currentTime: ${e} hole: ${d} -> ${c} buffered index: ${l}`);this.warn(u.message),this.media.currentTime+=1e-6;let h=Vs(e,this.fragmentTracker);h&&"fragment"in h?h=h.fragment:h||(h=void 0);const f=ie.bufferInfo(this.media,e,0);this.hls.trigger(E.ERROR,{type:X.MEDIA_ERROR,details:x.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:u,reason:u.message,frag:h,buffer:f.len,bufferInfo:f})}}}}}_tryFixBufferStall(e,t,i){var r,n;const{fragmentTracker:a,media:o}=this,l=(r=this.hls)==null?void 0:r.config;if(!o||!a||!l)return;const d=(n=this.hls)==null?void 0:n.latestLevelDetails,c=Vs(i,a);if((c||d!=null&&d.live&&i<d.fragmentStart)&&(this._trySkipBufferHole(c)||!this.media))return;const u=e.buffered,h=this.adjacentTraversal(e,i);(u&&u.length>1&&e.len>l.maxBufferHole||e.nextStart&&(e.nextStart-i<l.maxBufferHole||h))&&(t>l.highBufferWatchdogPeriod*1e3||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(e))}adjacentTraversal(e,t){const i=this.fragmentTracker,r=e.nextStart;if(i&&r){const n=i.getFragAtPos(t,j.MAIN),a=i.getFragAtPos(r,j.MAIN);if(n&&a)return a.sn-n.sn<2}return!1}_reportStall(e){const{hls:t,media:i,stallReported:r,stalled:n}=this;if(!r&&n!==null&&i&&t){this.stallReported=!0;const a=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${Re(e)})`);this.warn(a.message),t.trigger(E.ERROR,{type:X.MEDIA_ERROR,details:x.BUFFER_STALLED_ERROR,fatal:!1,error:a,buffer:e.len,bufferInfo:e,stalled:{start:n}})}}_trySkipBufferHole(e){const{fragmentTracker:t,media:i,hls:r}=this,n=r?.config;if(!i||!t||!n)return 0;const a=i.currentTime,o=ie.bufferInfo(i,a,0);qc(o,a,t,r);const l=a<o.start?o.start:o.nextStart;if(l){const c=o.len<=n.maxBufferHole,u=o.len>0&&o.len<1&&i.readyState<3,h=l-a;if(h>0&&(c||u)){if(h>n.maxBufferHole){let v=!1;if(a===0){const T=t.getAppendedFrag(0,j.MAIN);T&&l<T.end&&(v=!0)}if(!v&&e){var d;if(!((d=r.loadLevelObj)!=null&&d.details)||Wc(r.inFlightFragments,l))return 0;let y=!1,S=e.end;for(;S<l;){const A=Vs(S,t),I=A?A.duration:0;if(I>0)S+=I;else{y=!0;break}}if(y)return 0}}const{nudgeMaxRetry:f,skipBufferHolePadding:g}=n,m=++this.skipRetry>f,p=Math.max(l,a)+g;if(m||(this.warn(`skipping hole, adjusting currentTime from ${a} to ${p}`),this.moved=!0,i.currentTime=p),!(e!=null&&e.gap)||m){const v=new Error(m?`Playhead still not moving after seeking over buffer hole from ${a} to ${p} after ${n.nudgeMaxRetry} attempts.`:`fragment loaded with buffer holes, seeking from ${a} to ${p}`),T={type:X.MEDIA_ERROR,details:x.BUFFER_SEEK_OVER_HOLE,fatal:m,error:v,reason:v.message,buffer:o.len,bufferInfo:o};e&&("fragment"in e?T.part=e:T.frag=e),r.trigger(E.ERROR,T)}return p}}return 0}_tryNudgeBuffer(e){const{hls:t,media:i,nudgeRetry:r}=this,n=t?.config;if(!i||!n)return 0;const a=i.currentTime;if(this.nudgeRetry++,r<n.nudgeMaxRetry){const o=a+(r+1)*n.nudgeOffset,l=new Error(`Nudging 'currentTime' from ${a} to ${o}`);this.warn(l.message),i.currentTime=o,t.trigger(E.ERROR,{type:X.MEDIA_ERROR,details:x.BUFFER_NUDGE_ON_STALL,error:l,fatal:!1,buffer:e.len,bufferInfo:e})}else{const o=new Error(`Playhead still not moving while enough data buffered @${a} after ${n.nudgeMaxRetry} nudges`);this.error(o.message),t.trigger(E.ERROR,{type:X.MEDIA_ERROR,details:x.BUFFER_STALLED_ERROR,error:o,fatal:!0,buffer:e.len,bufferInfo:e})}}}function Wc(s,e){const t=Yc(s.main);if(t&&t.start<=e)return t;const i=Yc(s.audio);return i&&i.start<=e?i:null}function Yc(s){if(!s)return null;switch(s.state){case C.IDLE:case C.STOPPED:case C.ENDED:case C.ERROR:return null}return s.frag}function Vs(s,e){return e.getAppendedFrag(s,j.MAIN)||e.getPartialFragment(s)}function qc(s,e,t,i){const r=i.latestLevelDetails,n=Vs(e,t);if(ko(i.config)&&!s.nextStart&&r&&n&&i.interstitialsManager){const a="type"in n?n:n.fragment,o=bh(r,a.sn,!0);o?.level===a.level&&Gh(o,i.interstitialsManager.playerQueue,e)&&(s.nextStart=o.start)}}const gy=.25;function Vo(){if(!(typeof self>"u"))return self.VTTCue||self.TextTrackCue}function ja(s,e,t,i,r){let n=new s(e,t,"");try{n.value=i,r&&(n.type=r)}catch{n=new s(e,t,Re(r?Z({type:r},i):i))}return n}const Kr=(()=>{const s=Vo();try{s&&new s(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();class my{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.assetCue=void 0,this.onEventCueEnter=()=>{this.hls&&this.hls.trigger(E.EVENT_CUE_ENTER,{})},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null}_registerListeners(){const{hls:e}=this;e&&(e.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(E.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(E.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(E.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(E.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}onMediaAttaching(e,t){this.media=t.media}onMediaAttached(){var e;const t=(e=this.hls)==null?void 0:e.latestLevelDetails;t&&this.updateDateRangeCues(t)}onMediaDetaching(e,t){this.media=null,!t.transferMedia&&(this.id3Track&&(this.id3Track.remove(),this.id3Track=null),this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){return Wl(e,"metadata","id3","","hidden")}onFragParsingMetadata(e,t){if(!this.media||!this.hls)return;const{enableEmsgMetadataCues:i,enableID3MetadataCues:r}=this.hls.config;if(!i&&!r)return;const{samples:n}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));const a=Vo();if(a)for(let o=0;o<n.length;o++){const l=n[o].type;if(l===mt.emsg&&!i||!r)continue;const d=Zu(n[o].data),c=n[o].pts;let u=c+n[o].duration;u>Kr&&(u=Kr),u-c<=0&&(u=c+gy);for(let f=0;f<d.length;f++){const g=d[f];if(!Ju(g)){this.updateId3CueEnds(c,l);const m=ja(a,c,u,g,l);m&&this.id3Track.track.addCue(m)}}}}updateId3CueEnds(e,t){var i;const r=(i=this.id3Track)==null?void 0:i.track.cues;if(r)for(let n=r.length;n--;){const a=r[n];a.type===t&&a.startTime<e&&a.endTime===Kr&&(a.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:i,type:r}){const{id3Track:n,hls:a}=this;if(!a)return;const{config:{enableEmsgMetadataCues:o,enableID3MetadataCues:l}}=a;if(n&&(o||l)){let d;r==="audio"?d=c=>c.type===mt.audioId3&&l:r==="video"?d=c=>c.type===mt.emsg&&o:d=c=>c.type===mt.audioId3&&l||c.type===mt.emsg&&o,Go(n.track,t,i,d)}}onLevelUpdated(e,{details:t}){this.updateDateRangeCues(t,!0)}onLevelPtsUpdated(e,t){Math.abs(t.drift)>.01&&this.updateDateRangeCues(t.details)}updateDateRangeCues(e,t){if(!this.hls||!this.media)return;const{assetPlayerId:i,timelineOffset:r,enableDateRangeMetadataCues:n,interstitialsController:a}=this.hls.config;if(!n)return;const o=Vo();if(i&&r&&!a){const{fragmentStart:m,fragmentEnd:p}=e;let v=this.assetCue;v?(v.startTime=m,v.endTime=p):o&&(v=this.assetCue=ja(o,m,p,{assetPlayerId:this.hls.config.assetPlayerId},"hlsjs.interstitial.asset"),v&&(v.id=i,this.id3Track||(this.id3Track=this.createTrack(this.media)),this.id3Track.track.addCue(v),v.addEventListener("enter",this.onEventCueEnter)))}if(!e.hasProgramDateTime)return;const{id3Track:l}=this,{dateRanges:d}=e,c=Object.keys(d);let u=this.dateRangeCuesAppended;if(l&&t){var h;if((h=l.track.cues)!=null&&h.length){const m=Object.keys(u).filter(p=>c.indexOf(p)===-1);for(let p=m.length;p--;){var f;const v=m[p],T=(f=u[v])==null?void 0:f.cues;delete u[v],T&&Object.keys(T).forEach(y=>{const S=T[y];if(S){S.removeEventListener("enter",this.onEventCueEnter);try{l.track.removeCue(S)}catch{}}})}}else u=this.dateRangeCuesAppended={}}const g=e.fragments[e.fragments.length-1];if(!(c.length===0||!B(g?.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(let m=0;m<c.length;m++){const p=c[m],v=d[p],T=v.startTime,y=u[p],S=y?.cues||{};let A=y?.durationKnown||!1,I=Kr;const{duration:_,endDate:R}=v;if(R&&_!==null)I=T+_,A=!0;else if(v.endOnNext&&!A){const L=c.reduce((k,w)=>{if(w!==v.id){const U=d[w];if(U.class===v.class&&U.startDate>v.startDate&&(!k||v.startDate<k.startDate))return U}return k},null);L&&(I=L.startTime,A=!0)}const D=Object.keys(v.attr);for(let L=0;L<D.length;L++){const k=D[L];if(!c0(k))continue;const w=S[k];if(w)A&&!(y!=null&&y.durationKnown)?w.endTime=I:Math.abs(w.startTime-T)>.01&&(w.startTime=T,w.endTime=I);else if(o){let U=v.attr[k];u0(k)&&(U=eh(U));const G=ja(o,T,I,{key:k,data:U},mt.dateRange);G&&(G.id=p,this.id3Track.track.addCue(G),S[k]=G,a&&(k==="X-ASSET-LIST"||k==="X-ASSET-URL")&&G.addEventListener("enter",this.onEventCueEnter))}}u[p]={cues:S,dateRange:v,durationKnown:A}}}}}function Ff(){return self.SourceBuffer||self.WebKitSourceBuffer}function Nf(){if(!ki())return!1;const e=Ff();return!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function"}function py(){if(!Nf())return!1;const s=ki();
vendor: 17,557 bytes, line 82
82return typeof s?.isTypeSupported=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(e=>s.isTypeSupported(fr(e,"video")))||["mp4a.40.2","fLaC"].some(e=>s.isTypeSupported(fr(e,"audio"))))}function Ey(){var s;const e=Ff();return typeof(e==null||(s=e.prototype)==null?void 0:s.changeType)=="function"}var Kt={DISABLED:0,SWITCHING:1,SWITCHED:2};const vy=100;class Uf extends Dl{constructor(e,t,i){super(e,t,i,"stream-controller",j.MAIN),this.audioCodecSwap=!1,this.level=-1,this._forceStartLoad=!1,this._hasEnoughToStart=!1,this.altAudio=Kt.DISABLED,this.audioOnly=!1,this._couldBacktrack=!1,this._backtrackFragment=void 0,this.audioCodecSwitch=!1,this.videoBuffer=null,this.onMediaPlaying=()=>{this.tick()},this.onMediaSeeked=()=>{const r=this.media,n=r?r.currentTime:null;if(n===null||!B(n)||(this.log(`Media seeked to ${n}`),!this.getBufferedFrag(n)))return;const a=this.getFwdBufferInfoAtPos(r,n,j.MAIN,0);if(!a||a.len===0){this.log(`Main buffer empty at ${n} on "seeked" event: ${a&&a.len}`);return}this.tick()},this.registerListeners()}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.LEVEL_LOADING,this.onLevelLoading,this),e.on(E.LEVEL_LOADED,this.onLevelLoaded,this),e.on(E.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(E.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(E.BUFFER_CREATED,this.onBufferCreated,this),e.on(E.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.LEVEL_LOADED,this.onLevelLoaded,this),e.off(E.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(E.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(E.BUFFER_CREATED,this.onBufferCreated,this),e.off(E.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),super.onHandlerDestroying()}startLoad(e,t){if(this.levels){const{lastCurrentTime:i,hls:r}=this;if(this.stopLoad(),this.setInterval(vy),this.level=-1,!this.startFragRequested){let n=r.startLevel;n===-1&&(r.config.testBandwidth&&this.levels.length>1?(n=0,this.bitrateTest=!0):n=r.firstAutoLevel),r.nextLoadLevel=n,this.level=r.loadLevel,this._hasEnoughToStart=!!t}i>0&&e===-1&&!t&&this.initPTS.length&&(this.log(`Override startPosition with lastCurrentTime @${i}`),e=i),this.state=C.IDLE,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,!t&&!this.fragmentTracker.hasFragments(this.playlistType)&&(this._hasEnoughToStart=this.startFragRequested=!1),this.tick()}else this._forceStartLoad=!0,this.state=C.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case C.WAITING_LEVEL:{const{levels:e,level:t}=this,i=e?.[t],r=i?.details;if(r&&(!r.live||this.levelLastLoaded===i&&!this.waitForLive(i))){if(this.waitForCdnTuneIn(r))break;this.state=C.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=C.IDLE;break}break}case C.FRAG_LOADING_WAITING_RETRY:this.checkRetryDate();break}this.state===C.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){var e;super.onTickEnd(),(e=this.media)!=null&&e.readyState&&this.media.seeking===!1&&(this.lastCurrentTime=this.media.currentTime),this.checkFragmentChanged()}doTickIdle(){const{hls:e,levelLastLoaded:t,levels:i,media:r}=this;if(t===null||!r&&!this.primaryPrefetch&&(this.startFragRequested||!e.config.startFragPrefetch)||this.altAudio&&this.audioOnly)return;const n=this.buffering?e.nextLoadLevel:e.loadLevel;if(!(i!=null&&i[n]))return;const a=i[n],o=this.getMainFwdBufferInfo();if(o===null)return;const l=this.getLevelDetails();if(l&&this._streamEnded(o,l)){const m={type:this.targetBufferType()};this.hls.trigger(E.BUFFER_EOS,m),this.state=C.ENDED;return}if(!this.buffering)return;e.loadLevel!==n&&e.manualLevel===-1&&this.log(`Adapting to level ${n} from level ${this.level}`),this.level=e.nextLoadLevel=n;const d=a.details;if(!d||this.state===C.WAITING_LEVEL||this.waitForLive(a)){this.level=n,this.state=C.WAITING_LEVEL,this.startFragRequested=!1;return}const c=o.len,u=this.getMaxBufferLength(a.maxBitrate);if(c>=u)return;this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=void 0);const h=this.backtrackFragment?this.backtrackFragment.start:o.end;let f=this.getNextFragment(h,d);if(this.couldBacktrack&&!this.fragPrevious&&f&&Ue(f)&&this.fragmentTracker.getState(f)!==Ce.OK){var g;const p=((g=this.backtrackFragment)!=null?g:f).sn-d.startSN,v=d.fragments[p-1];v&&f.cc===v.cc&&(f=v,this.fragmentTracker.removeFragment(v))}else this.backtrackFragment&&o.len&&(this.backtrackFragment=void 0);if(f&&this.isLoopLoading(f,h)){if(!f.gap){const p=this.audioOnly&&!this.altAudio?xe.AUDIO:xe.VIDEO,v=(p===xe.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;v&&this.afterBufferFlushed(v,p)}f=this.getNextFragmentLoopLoading(f,d,o,j.MAIN,u)}f&&(this.exceedsMaxBuffer(o,u,f)||this.loadFragment(f,a,h))}loadFragment(e,t,i){const r=this.fragmentTracker.getState(e);r===Ce.NOT_LOADED||r===Ce.PARTIAL?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)):super.loadFragment(e,t,i):this.clearTrackerIfNeeded(e)}immediateLevelSwitch(){if(this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY),this.altAudio!==Kt.DISABLED){var e;(((e=this.getLevelDetails())==null?void 0:e.fragmentStart)||0)>this.lastCurrentTime&&super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio")}}getBufferOutput(){return this.mediaBuffer&&this.altAudio===Kt.SWITCHED?this.mediaBuffer:this.media}checkFragmentChanged(){const e=this.fragPlaying;if(!this.checkFragPlaying())return!1;const i=this.fragPlaying;if(i){const r=i.level;this.hls.trigger(E.FRAG_CHANGED,{frag:i,previousFrag:e}),e?.level!==r&&this.hls.trigger(E.LEVEL_SWITCHED,{level:r})}return!0}get backtrackFragment(){return this._backtrackFragment}set backtrackFragment(e){this._backtrackFragment=e}get couldBacktrack(){return this._couldBacktrack}set couldBacktrack(e){this._couldBacktrack=e}abortCurrentFrag(){this.backtrackFragment=void 0,super.abortCurrentFrag()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.targetBufferType())}targetBufferType(){return this.altAudio===Kt.SWITCHED&&!this.audioOnly?"video":null}onMediaAttached(e,t){super.onMediaAttached(e,t);const i=t.media;Ae(i,"playing",this.onMediaPlaying),Ae(i,"seeked",this.onMediaSeeked)}onMediaDetaching(e,t){const{media:i}=this;i&&(ye(i,"playing",this.onMediaPlaying),ye(i,"seeked",this.onMediaSeeked)),this.videoBuffer=null,super.onMediaDetaching(e,t),!t.transferMedia&&(this._hasEnoughToStart=!1)}onManifestLoading(){super.onManifestLoading(),this.log("Trigger BUFFER_RESET"),this.hls.trigger(E.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.backtrackFragment=void 0,this.altAudio=Kt.DISABLED,this.audioOnly=!1}onManifestParsed(e,t){let i=!1,r=!1;for(let n=0;n<t.levels.length;n++){const a=t.levels[n].audioCodec;a&&(i=i||a.indexOf("mp4a.40.2")!==-1,r=r||a.indexOf("mp4a.40.5")!==-1)}this.audioCodecSwitch=i&&r&&!Ey(),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){const{levels:i}=this;if(!i||this.state!==C.IDLE)return;const r=t.levelInfo;(!r.details||r.details.live&&(this.levelLastLoaded!==r||r.details.expired)||this.waitForCdnTuneIn(r.details))&&(this.state=C.WAITING_LEVEL)}onLevelLoaded(e,t){var i;const{levels:r,startFragRequested:n}=this,a=t.level,o=t.details,l=o.totalduration;if(!r){this.warn(`Levels were reset while loading level ${a}`);return}this.log(`Level ${a} loaded [${o.startSN},${o.endSN}]${o.lastPartSn?`[part-${o.lastPartSn}-${o.lastPartIndex}]`:""}, cc [${o.startCC}, ${o.endCC}] duration:${l}`);const d=t.levelInfo,c=this.fragCurrent;c&&(this.state===C.FRAG_LOADING||this.state===C.FRAG_LOADING_WAITING_RETRY)&&c.level!==t.level&&c.loader&&this.abortCurrentFrag();let u=0;if(o.live||(i=d.details)!=null&&i.live){var h;if(this.checkLiveUpdate(o),o.deltaUpdateFailed)return;u=this.alignPlaylists(o,d.details,(h=this.levelLastLoaded)==null?void 0:h.details)}if(d.details=o,this.levelLastLoaded=d,n||this.setStartPosition(o,u),this.hls.trigger(E.LEVEL_UPDATED,{details:o,level:a}),this.state===C.WAITING_LEVEL){if(this.waitForCdnTuneIn(o))return;this.state=C.IDLE}n&&o.live&&this.synchronizeToLiveEdge(o),this.initPTS.some((f,g)=>{if(g>=o.startCC)return!0;delete this.initPTS[g]}),this.tick()}synchronizeToLiveEdge(e){const{config:t,media:i}=this;if(!i)return;const r=this.hls.liveSyncPosition,n=this.playhead,a=e.fragmentStart,o=e.edge,l=n>=a-t.maxFragLookUpTolerance&&n<=o;if(r!==null&&i.duration>r&&(n<r||!l)){const c=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;if((!l&&i.readyState<4||n<o-c)&&(this._hasEnoughToStart||(this.nextLoadPosition=r),i.readyState))if(this.warn(`Playback: ${n} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${r}`),this.config.liveSyncMode==="buffered"){var d;const u=ie.bufferInfo(i,r,0);if(!((d=u.buffered)!=null&&d.length)){i.currentTime=r;return}if(u.start<=n){i.currentTime=r;return}const{nextStart:f}=ie.bufferedInfo(u.buffered,n,0);f&&(i.currentTime=f)}else i.currentTime=r}}_handleFragmentLoadProgress(e){var t;const i=e.frag,{part:r,payload:n}=e,{levels:a}=this;if(!a){this.warn(`Levels were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);return}const o=a[i.level];if(!o){this.warn(`Level ${i.level} not found on progress`);return}const l=o.details;if(!l){this.warn(`Dropping fragment ${i.sn} of level ${i.level} after level details were reset`),this.fragmentTracker.removeFragment(i);return}const d=o.videoCodec,c=l.PTSKnown||!l.live,u=(t=i.initSegment)==null?void 0:t.data,h=this._getAudioCodec(o),f=this.transmuxer=this.transmuxer||new af(this.hls,j.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),g=r?r.index:-1,m=g!==-1,{decryptRange:p,byteRange:v}=Kn(i,r,this.iframesOnly),T=new _l(i.level,i.sn,i.stats.chunkCount,v?v.end-v.start:n.byteLength,g,m,i.duration,this.iframesOnly,p),y=this.initPTS[i.cc];f.push(n,u,h,d,i,r,l.totalduration,c,T,y)}onAudioTrackSwitching(e,t){const i=this.hls,r=this.altAudio!==Kt.DISABLED;if(Hn(t.url,i))this.altAudio=Kt.SWITCHING;else{if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const 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();if(r){this.altAudio=Kt.DISABLED,this.fragmentTracker.removeAllFragments(),i.once(E.BUFFER_FLUSHED,()=>{this.hls&&this.hls.trigger(E.AUDIO_TRACK_SWITCHED,t)}),i.trigger(E.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});return}i.trigger(E.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const i=Hn(t.url,this.hls);if(i){const r=this.videoBuffer;r&&this.mediaBuffer!==r&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=r)}this.altAudio=i?Kt.SWITCHED:Kt.DISABLED,this.tick()}onBufferCreated(e,t){const i=t.tracks;let r,n,a=!1;for(const o in i){const l=i[o];if(l.id==="main"){if(n=o,r=l,o==="video"){const d=i[o];d&&(this.videoBuffer=d.buffer)}}else a=!0}a&&r?(this.log(`Alternate track found, use ${n}.buffered to schedule main fragment loading`),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){const{frag:i,part:r}=t,n=i.type===j.MAIN;if(n){if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${r?" p: "+r.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),this.state===C.PARSED&&(this.state=C.IDLE);return}let l=!1;if(Ue(i)&&(l=!!i.gap&&!i.tagList.some(d=>d[0]==="GAP")),this.fragBufferedComplete(i,r),l){var a;i.stats.retry++;const d=(a=this.levels)==null?void 0:a[i.level];d&&d.fragmentError++}}const o=this.media;o&&(!this._hasEnoughToStart&&ie.getBuffered(o).length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),n&&this.tick())}get hasEnoughToStart(){return this._hasEnoughToStart}onError(e,t){var i;if(t.fatal){this.state=C.ERROR;return}switch(t.details){case x.FRAG_GAP:case x.FRAG_PARSING_ERROR:case x.FRAG_DECRYPT_ERROR:case x.FRAG_LOAD_ERROR:case x.FRAG_LOAD_TIMEOUT:case x.KEY_LOAD_ERROR:case x.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(j.MAIN,t);break;case x.LEVEL_LOAD_ERROR:case x.LEVEL_LOAD_TIMEOUT:case x.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===C.WAITING_LEVEL&&((i=t.context)==null?void 0:i.type)===ue.LEVEL&&(this.state=C.IDLE);break;case x.BUFFER_APPEND_NO_PROGRESS:if(t.parent!=="main")return;t.frag&&(t.appendsWithoutProgress||0)>=this.config.appendErrorMaxRetry&&(this.warn(`Marking fragment ${t.frag.sn} of level ${t.frag.level} as a gap after ${t.appendsWithoutProgress} appends without buffered range growth, to prevent loop loading`),this.fragmentTracker.addAsGap(t.frag));break;case x.BUFFER_ADD_CODEC_ERROR:case x.BUFFER_APPEND_ERROR:if(t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&this.resetLoadingState();break;case x.BUFFER_FULL_ERROR:if(t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&(!this.config.interstitialsController&&this.config.assetPlayerId?this._hasEnoughToStart=!0:this.flushMainBuffer(0,Number.POSITIVE_INFINITY));break;case x.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onFragLoadEmergencyAborted(){this.state=C.IDLE,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==xe.AUDIO||!this.altAudio){const i=(t===xe.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;i&&(this.afterBufferFlushed(i,t),this.tick())}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,this.level===-1&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:e}=this;if(!e)return;const t=e.currentTime;let i=this.startPosition;if(i>=0&&t<i){if(e.seeking){this.log(`could not seek to ${i}, already seeking at ${t}`);return}const r=this.timelineOffset;r&&i&&(i+=r);const n=this.getLevelDetails(),a=ie.getBuffered(e),o=a.length?a.start(0):0,l=o-i,d=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);(this.config.startOnSegmentBoundary||l>0&&(l<d||this.loadingParts&&l<2*(n?.partTarget||0)))&&(this.log(`adjusting start position by ${l} to match buffer start`),i+=l,this.startPosition=i),t<i&&(this.log(`seek to target start position ${i} from current time ${t} buffer start ${o}`),e.currentTime=i)}}_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(i=>{const{hls:r}=this,n=i?.frag;if(!n||this.fragContextChanged(n))return;t.fragmentError=0,this.state=C.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;const a=n.stats;a.parsing.start=a.parsing.end=a.buffering.start=a.buffering.end=self.performance.now(),r.trigger(E.FRAG_LOADED,i),n.bitrateTest=!1}).catch(i=>{this.state===C.STOPPED||this.state===C.ERROR||(this.warn(i),this.resetFragmentLoading(e))})}_handleTransmuxComplete(e){const t=this.playlistType,{hls:i}=this,{remuxResult:r,chunkMeta:n}=e,a=this.getCurrentContext(n);if(!a){this.resetWhenMissingContext(n);return}const{frag:o,part:l,level:d}=a,{video:c,text:u,id3:h,initSegment:f}=r,{details:g}=d,m=this.altAudio?void 0:r.audio;if(this.fragContextChanged(o)){this.fragmentTracker.removeFragment(o);return}if(this.state=C.PARSING,f){const p=f.tracks;if(p){const S=o.initSegment||o;if(this.unhandledEncryptionError(f,o))return;this._bufferInitSegment(d,p,S,n),i.trigger(E.FRAG_PARSING_INIT_SEGMENT,{frag:S,id:t,tracks:p})}const v=f.initPTS,T=f.timescale,y=this.initPTS[o.cc];if(B(v)&&(!y||y.baseTime!==v||y.timescale!==T)){const S=f.trackId;this.initPTS[o.cc]={baseTime:v,timescale:T,trackId:S};const A=this.initPTS.slice(0);i.trigger(E.INIT_PTS_FOUND,{timestampOffsets:A,frag:o,id:t,initPTS:v,timescale:T,trackId:S})}}if(c&&g){m&&c.type==="audiovideo"&&this.logMuxedErr(o);const p=g.fragments[o.sn-1-g.startSN],v=o.sn===g.startSN,T=!p||o.cc>p.cc;if(r.independent!==!1){const{startPTS:y,endPTS:S,startDTS:A,endDTS:I}=c;if(l)l.elementaryStreams[c.type]={startPTS:y,endPTS:S,startDTS:A,endDTS:I};else if(c.firstKeyFrame&&c.independent&&n.id===1&&!T&&(this.couldBacktrack=!0),c.dropped&&c.independent){const _=this.getMainFwdBufferInfo(),R=(_?_.end:this.getLoadPosition())+this.config.maxBufferHole,D=c.firstKeyFramePTS?c.firstKeyFramePTS:y;if(!v&&R<D-this.config.maxBufferHole&&!T){this.backtrack(o);return}else T&&(o.gap=!0);o.setElementaryStreamInfo(c.type,o.start,S,o.start,I,!0)}
vendor: 38,213 bytes, lines 82-83
82else v&&y-(g.appliedTimelineOffset||0)>hn&&(o.gap=!0);o.setElementaryStreamInfo(c.type,y,S,A,I),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(c,o,l,n,v||T)}else if(v||T)o.gap=!0;else{this.backtrack(o);return}}if(m){const{startPTS:p,endPTS:v,startDTS:T,endDTS:y}=m;l&&(l.elementaryStreams[xe.AUDIO]={startPTS:p,endPTS:v,startDTS:T,endDTS:y}),o.setElementaryStreamInfo(xe.AUDIO,p,v,T,y),this.bufferFragmentData(m,o,l,n)}if(g&&h!=null&&h.samples.length){const p={id:t,frag:o,details:g,samples:h.samples};i.trigger(E.FRAG_PARSING_METADATA,p)}if(g&&u){const p={id:t,frag:o,details:g,samples:u.samples};i.trigger(E.FRAG_PARSING_USERDATA,p)}}logMuxedErr(e){this.warn(`${Ue(e)?"Media":"Init"} segment with muxed audiovideo where only video expected: ${e.url}`)}_bufferInitSegment(e,t,i,r){if(this.state!==C.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&(delete t.audio,t.audiovideo&&this.logMuxedErr(i));const{audio:n,video:a,audiovideo:o}=t;if(n){const d=e.audioCodec;let c=ln(n.codec,d);if(c==="mp4a"&&(c="mp4a.40.5"),this.audioCodecSwitch){c&&(c.indexOf("mp4a.40.5")!==-1?c="mp4a.40.2":c="mp4a.40.5");const u=n.metadata;u&&"channelCount"in u&&(u.channelCount||1)!==1&&!Ip()&&(c="mp4a.40.5")}c&&c.indexOf("mp4a.40.5")!==-1&&Lp()&&n.container!=="audio/mpeg"&&(c="mp4a.40.2",this.log(`Android: force audio codec to ${c}`)),d&&d!==c&&this.log(`Swapping manifest audio codec "${d}" for "${c}"`),n.levelCodec=c,n.id=j.MAIN,this.log(`Init audio buffer, container:${n.container}, codecs[selected/level/parsed]=[${c||""}/${d||""}/${n.codec}]`),delete t.audiovideo}if(a){a.levelCodec=e.videoCodec,a.id=j.MAIN;const d=a.codec;if(d?.length===4)switch(d){case"hvc1":case"hev1":a.codec="hvc1.1.6.L120.90";break;case"av01":a.codec="av01.0.04M.08";break;case"avc1":a.codec="avc1.42e01e";break}this.log(`Init video buffer, container:${a.container}, codecs[level/parsed]=[${e.videoCodec||""}/${d}]${a.codec!==d?" parsed-corrected="+a.codec:""}${a.supplemental?" supplemental="+a.supplemental:""}`),delete t.audiovideo}o&&(this.iframesOnly&&this.logMuxedErr(i),this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.codecs}/${o.codec}]`),delete t.video,delete t.audio);const l=Object.keys(t);if(l.length){if(this.hls.trigger(E.BUFFER_CODECS,t),!this.hls)return;l.forEach(d=>{const u=t[d].initSegment;u!=null&&u.byteLength&&this.hls.trigger(E.BUFFER_APPENDING,{type:d,data:u,frag:i,part:null,chunkMeta:r,parent:i.type})})}this.tickImmediate()}getMainFwdBufferInfo(){const e=this.getBufferOutput();return this.getFwdBufferInfo(e,j.MAIN)}get maxBufferLength(){const{levels:e,level:t}=this,i=e?.[t];return i?this.getMaxBufferLength(i.maxBitrate):this.config.maxBufferLength}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=C.IDLE}get nextLevel(){const e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){var e;if(this.fragPlaying)return this.fragPlaying;const t=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;return B(t)?this.getAppendedFrag(t):null}get currentProgramDateTime(){var e;const t=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;if(B(t)){const i=this.getLevelDetails(),r=this.currentFrag||(i?Is(null,i.fragments,t):null);if(r){const n=r.programDateTime;if(n!==null){const a=n+(t-r.start)*1e3;return new Date(a)}}}return null}get currentLevel(){const e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){const e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}}class $f extends Uf{constructor(...e){super(...e),this.currentOp=void 0,this.nextOp=void 0,this.cached=[],this.cachedSize=0,this.cacheFragmentData=!0,this.initDetails=void 0,this.onBufferedToEnd=()=>{const t=this.media;t!=null&&t.seeking&&(t.currentTime=t.currentTime)},this.onMediaSeeking=()=>{}}setInitPts(e){this.initPTS=e.slice()}loadMediaAt(e,t){if(!this.hls)return;const{seekOnAppend:i}=t,r=e+this.timelineOffset;switch(this.nextLoadPosition=this.lastCurrentTime=r,this.startPosition=e,this.state){case C.STOPPED:case C.ENDED:case C.ERROR:this.state=C.IDLE}this.state===C.IDLE?(this.hls.resumeBuffering(),this.tick(),this.currentOp=[r,t]):this.nextOp=[r,t],this.hls.off(E.BUFFERED_TO_END,this.onBufferedToEnd);const n=this.media;i&&n&&this.seekTo(r)&&(this.currentOp=[r,t],this.nextOp=void 0,this.flushPipeline(r,!0))}seekTo(e){const t=this.media;if(t){var i;const r=(i=this.getLevelDetails())==null?void 0:i.edge,n=r!==void 0?r:t.duration;if(e>=n&&(e=n-.01),ie.bufferInfo(t,e,0).len>0&&this.getBufferedAt(e))return t.currentTime=e,!0}return!1}getBufferedAt(e){return this.fragmentTracker.getBufferedFrag(e,j.MAIN)}cacheSet(e,t){if(!this.hls)return;e.data=t;const i=this.cached;i.push(e),this.cachedSize+=t.buffer.byteLength;const r=this.hls.config.iframeCacheLimit;for(;this.cachedSize>r&&i.length>1;){const n=i.shift();if(n.data)this.cachedSize-=n.data.byteLength,n.data=void 0;else{this.cached=i.filter(a=>!!a.data),this.cachedSize=i.reduce((a,{data:o})=>o?o.buffer.byteLength:0,0);break}}}onHandlerDestroying(){this.cached.length=0,this.cachedSize=0,super.onHandlerDestroying()}_handleFragmentLoadProgress(e){const t=e.frag,{part:i,payload:r}=e;this.cacheFragmentData&&!i&&r!=null&&r.byteLength&&!t.data&&Ue(t)&&this.cacheSet(t,new Uint8Array(r.slice(0))),super._handleFragmentLoadProgress(e)}loadFragment(e,t,i){const r=this.fragmentTracker.getState(e);if((r===Ce.NOT_LOADED||r===Ce.PARTIAL)&&this.canReplayCached(e)){this.replayCachedFragment(e);return}super.loadFragment(e,t,i)}canReplayCached(e){var t;if(!this.cacheFragmentData||!((t=e.data)!=null&&t.byteLength))return!1;const i=e.decryptdata;return i?.keyFormat!=="identity"||!!i.key}replayCachedFragment(e){const t=e.data.slice().buffer;this.log(`Buffering cached ${e.type} sn: ${e.sn} of level ${e.level} (${t.byteLength} bytes)`),this.fragCurrent=e,this.startFragRequested=!0;const i=e.stats=new El;i.loading.start=i.loading.first=i.loading.end=self.performance.now(),i.loaded=i.total=t.byteLength,i.chunkCount=1,this.state=C.FRAG_LOADING;const r={frag:e,part:null,payload:t,networkDetails:null};this._handleFragmentLoadProgress(r),this.hls.trigger(E.FRAG_LOADED,r),this._handleFragmentLoadComplete(r)}fragBufferedComplete(e,t){super.fragBufferedComplete(e,t);const{currentOp:i,nextOp:r}=this;this.currentOp=this.nextOp=void 0,this.state=C.STOPPED,i!=null&&i[1].seekOnAppend&&(this.flushPipeline(i[0],!r),this.seekTo(i[0])||this.log(`Could not seek to ${i[0]} after fragment buffered (superseded or flushed) buffer: ${this.media?jn(ie.getBuffered(this.media)):"none"}`)),r&&this.loadMediaAt.apply(this,r)}flushPipeline(e,t){if(t){const i=this.media;if(i){const r=ie.bufferInfo(i,e,0),n=r.len?r.nextStart:0;n&&(this.fragmentTracker.removeFragmentsInRange(n,1/0,j.MAIN),this.flushMainBuffer(n,1/0))}this.hls.once(E.BUFFERED_TO_END,this.onBufferedToEnd)}this.hls.trigger(E.BUFFER_EOS,{type:"video"})}get playhead(){return this.nextLoadPosition}startLoad(){if(!this.startFragRequested){const e=this.hls;e.nextLoadLevel=e.startLevel===-1?0:e.firstAutoLevel}}seekToStartPos(){}setStartPosition(){}alignPlaylists(e,t,i){const r=this.initDetails;return this.initDetails=null,super.alignPlaylists(e,t,i||r||void 0)}getMainFwdBufferInfo(){const e=this.playhead,t=this.getBufferedAt(e);if(t){const i=t.duration;return{len:i,start:e,end:e+i,bufferedIndex:-1}}return{len:0,start:e,end:e,bufferedIndex:-1}}_streamEnded(){const e=this.playhead,t=this.fragmentTracker.getBufferedFrag(e,j.MAIN);return!!(t!=null&&t.endList)}}class yy extends $f{constructor(...e){super(...e),this._img=void 0,this.queued=void 0,this.cacheFragmentData=!1}get image(){return this._img}set image(e){var t;const i=(t=this._img)==null?void 0:t.src;i&&self.URL.revokeObjectURL(i),this._img=e}loadMediaAt(e){if(!this.hls)return;const t=e+this.timelineOffset;switch(this.nextLoadPosition=this.lastCurrentTime=t,this.startPosition=e,this.state){case C.STOPPED:case C.ENDED:case C.ERROR:this.state=C.IDLE}if(this.state===C.IDLE){if(this.hls.resumeBuffering(),this.media||(this.media={}),this.tick(),this.state===C.IDLE){const i=this.getBufferedAt(e);i&&(this.fragCurrent=i,this.updateImage(i,null))}}else{const i=this.fragCurrent;(!i||e>=i.start&&e<i.end)&&(this.queued=[t])}}updateImage(e,t,i){const r=e.data;r||this.fragmentTracker.removeFragment(e);const n=this._img;if(n&&r){const a=self.performance.now(),o=t?t.stats:e.stats;o.buffering.start=e.stats.buffering.start=a,n.onload=()=>{if(!this.hls)return;const c=this.hls.levels[e.level];c!=null&&c.fragmentError&&(c.fragmentError=0,e.stats.retry=0);const u=self.performance.now(),h=t?t.stats:e.stats;h.buffering.end=e.stats.buffering.end=u,this.hls.trigger(E.FRAG_BUFFERED,{frag:e,part:t,stats:h,id:e.type,chunkMeta:i})},n.onerror=()=>{this.handleError("Image decode error",e,t,i)};const l=n.src;l&&self.URL.revokeObjectURL(l);const d=new Blob([r],{type:"image/jpeg"});n.src=self.URL.createObjectURL(d)}else this.state=C.STOPPED,this.processQueued()}processQueued(){const e=this.queued;this.queued=void 0,e&&this.loadMediaAt.apply(this,e)}handleError(e,t,i,r){if(!this.hls)return;const n=new Error(e);this.hls.trigger(E.ERROR,{type:X.MEDIA_ERROR,details:x.FRAG_PARSING_ERROR,chunkMeta:r,frag:t,part:i,fatal:!1,error:n,err:n})}_bufferInitSegment(){}bufferFragmentData(e,t,i,r){super.bufferFragmentData(e,t,i,r,!0);const n=oe(new Uint8Array(e.data1),["mdat"]);if(n.length===0){this.handleError("Could not find I-Frame mdat",t,i,r);return}const a=t;this.cacheSet(a,n[0]),this.updateImage(a,i,r)}fragBufferedComplete(e,t){this.fragmentTracker.fragBuffered(e,!0),super.fragBufferedComplete(e,t),this.processQueued()}checkFragPlaying(){var e;const t=(e=this.fragPrevious)==null?void 0:e.start;if(t!==void 0){const i=this.getAppendedFrag(t);if(i&&!Gs(i,this.fragPlaying))return this.fragPlaying=i,!0}return!1}getMainFwdBufferInfo(){return{len:0,start:this.playhead,end:this.playhead,bufferedIndex:-1}}}const Ty=10,Sy="Image I-Frame player does not accept HTMLMediaElements",jc={seekOnAppend:!0};let Wr,za;class Ay extends Dt{constructor(e,t){super("iframes",e.logger),this.hls=void 0,this.stats=void 0,this.variableList=null,this.initPTS=[],this.iframeInstances=void 0,this.instanceCounter=0,Wr||(Wr=by(t)),za||(za=Iy(Wr)),this.hls=e,this.iframeInstances=[],this.registerListeners()}registerListeners(){const e=this.hls;e&&(e.on(E.MANIFEST_LOADING,this.clearAsset,this),e.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(E.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this),e.on(E.DESTROYING,this.onDestroying,this))}unregisterListeners(){const e=this.hls;e&&(e.off(E.MANIFEST_LOADING,this.clearAsset,this),e.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(E.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this),e.off(E.DESTROYING,this.onDestroying,this))}clearAsset(){this.stats=void 0,this.variableList=null,this.initPTS=[],this.iframeInstances.forEach(e=>e.destroy()),this.iframeInstances.length=0}onDestroying(){this.unregisterListeners(),this.clearAsset(),this.hls=void 0}onManifestLoaded(e,t){this.stats=t.stats,this.variableList=t.variableList}onLevelsUpdated(e,{levels:t}){var i;const r=(i=this.hls)==null?void 0:i.pathwayPriority;t.length&&r&&this.iframeInstances.forEach(n=>{n.pathwayPriority=r})}onInitPtsFound(e,{id:t,timestampOffsets:i}){t===j.MAIN&&(this.initPTS=i)}onFragBuffered(e,t){var i;const r=this.hls;r&&r.hasEnoughToStart&&(((i=r.mainForwardBufferInfo)==null?void 0:i.len)||0)>Ty&&this.iframeInstances.forEach(n=>{if(!n.loadingEnabled){var a;n.startLoad(((a=this.hls)==null||(a=a.media)==null?void 0:a.currentTime)||0)}})}createIFramePlayer(e){var t;return this.createInstance(Wr,(t=this.hls)==null?void 0:t.iframeVariants,e)}createImageIFramePlayer(e){var t;const i=(t=this.hls)==null?void 0:t.iframeVariants.filter(r=>r.imageCodec);return this.createInstance(za,i,e,"image-")}createInstance(e,t,i,r){const{hls:n}=this;if(!n)return null;const{url:a,userConfig:o,latestLevelDetails:l,loadLevelObj:d,loadLevel:c,bandwidthEstimate:u,sessionId:h}=n,{stats:f,variableList:g}=this;if(!(t!=null&&t.length)||!f||!a)return null;const m=`${r||""}iframe-player-${this.instanceCounter++}`,p=n.levels,v=d||p[c],T=Th(v,o.videoPreference),y=v?.pathwayId||".",S=Z(Z({},o),{},{loggerId:m,primarySessionId:h,videoPreference:T,abrEwmaDefaultEstimate:u,streamController:void 0,audioStreamController:void 0,audioTrackController:void 0,subtitleStreamController:void 0,subtitleTrackController:void 0,timelineController:void 0,id3TrackController:void 0,fpsController:void 0,gapController:void 0,iframeController:void 0,cmcd:void 0,interstitialsController:void 0,backBufferLength:1/0,maxMaxBufferLength:1,capLevelToPlayerSize:!0,enableWorker:!1,autoStartLoad:!1,startFragPrefetch:!1,testBandwidth:!1,progressive:!1},i),A=new e(S,a,this.initPTS,l);return this.iframeInstances=this.iframeInstances.filter(I=>!I.url),this.iframeInstances.push(A),A.trigger(E.MANIFEST_LOADED,{levels:t,contentSteering:{uri:"",pathwayId:y},sessionKeys:null,audioTracks:[],iframeVariants:[],sessionData:null,startTimeOffset:null,stats:f,networkDetails:null,url:a,variableList:g}),A}}function by(s){return class extends s{constructor(t,i,r,n){t.streamController||(t.streamController=$f),super(t),this._url=i,this.streamController.setInitPts(r),this.streamController.initDetails=n}loadSource(){}loadMediaAt(t,i=jc){if(t<0)return;const r=Z(Z({},jc),i);this.loadingEnabled||this.startLoad(t),this.streamController.loadMediaAt(t,r)}}}function Iy(s){return class extends s{constructor(t,i,r,n){t.cmcdController=void 0,t.emeController=void 0,t.streamController||(t.streamController=yy),t.capLevelController=void 0,t.bufferController=void 0,super(t,i,r,n)}attachImage(t){this.streamController.image=t}detachImage(){this.streamController.image=void 0}loadSource(){}attachMedia(){throw new Error(Sy)}detachMedia(){}recoverMediaError(){}transferMedia(){return null}loadMediaAt(t){if(t<0)return null;this.loadingEnabled||this.startLoad(t),this.streamController.loadMediaAt(t)}}}const Ss=.025;let Zn=function(s){return s[s.Point=0]="Point",s[s.Range=1]="Range",s}({});function _y(s,e,t){return`${s.identifier}-${t+1}-${sr(e)}`}class Ly{constructor(e,t){this.base=void 0,this._duration=null,this._timelineStart=null,this.appendInPlaceDisabled=void 0,this.appendInPlaceStarted=void 0,this.dateRange=void 0,this.hasPlayed=!1,this.cumulativeDuration=0,this.resumeOffset=NaN,this.playoutLimit=NaN,this.restrictions={skip:!1,jump:!1},this.snapOptions={out:!1,in:!1},this.assetList=[],this.assetListLoader=void 0,this.assetListResponse=null,this.resumeAnchor=void 0,this.error=void 0,this.resetOnResume=void 0,this.base=t,this.dateRange=e,this.setDateRange(e)}setDateRange(e){this.dateRange=e,this.resumeOffset=e.attr.optionalFloat("X-RESUME-OFFSET",this.resumeOffset),this.playoutLimit=e.attr.optionalFloat("X-PLAYOUT-LIMIT",this.playoutLimit),this.restrictions=e.attr.enumeratedStringList("X-RESTRICT",this.restrictions),this.snapOptions=e.attr.enumeratedStringList("X-SNAP",this.snapOptions)}reset(){var e;this.appendInPlaceStarted=!1,(e=this.assetListLoader)==null||e.destroy(),this.assetListLoader=void 0,this.supplementsPrimary||(this.assetListResponse=null,this.assetList=[],this._duration=null)}isAssetPastPlayoutLimit(e){var t;if(e>0&&e>=this.assetList.length)return!0;const i=this.playoutLimit;return e<=0||isNaN(i)?!1:i===0?!0:(((t=this.assetList[e])==null?void 0:t.startOffset)||0)>i}findAssetIndex(e){return this.assetList.indexOf(e)}get identifier(){return this.dateRange.id}get startDate(){return this.dateRange.startDate}get startTime(){const e=this.dateRange.startTime;if(this.snapOptions.out){const t=this.dateRange.tagAnchor;if(t)return fn(e,t)}return e}get startOffset(){return this.cue.pre?0:this.startTime}get startIsAligned(){if(this.startTime===0||this.snapOptions.out)return!0;const e=this.dateRange.tagAnchor;if(e){const t=this.dateRange.startTime,i=fn(t,e);return t-i<.1}return!1}get resumptionOffset(){const e=this.resumeOffset,t=B(e)?e:this.duration;return this.cumulativeDuration+t}get resumeTime(){const e=this.startOffset+this.resumptionOffset;if(this.snapOptions.in){const t=this.resumeAnchor;if(t)return fn(e,t)}return e}get appendInPlace(){return this.appendInPlaceStarted?!0:this.appendInPlaceDisabled?!1:!!(!this.cue.once&&!this.cue.pre&&this.startIsAligned&&(isNaN(this.playoutLimit)&&isNaN(this.resumeOffset)||this.resumeOffset&&this.duration&&Math.abs(this.resumeOffset-this.duration)<Ss))}set appendInPlace(e){if(this.appendInPlaceStarted){this.resetOnResume=!e;return}this.appendInPlaceDisabled=!e}get timelineStart(){return this._timelineStart!==null?this._timelineStart:this.startTime}set timelineStart(e){this._timelineStart=e}get duration(){const e=this.playoutLimit;let t;return this._duration!==null?t=this._duration:this.dateRange.duration?t=this.dateRange.duration:t=this.dateRange.plannedDuration||0,!isNaN(e)&&e<t&&(t=e),t}set duration(e){this._duration=e}get cue(){return this.dateRange.cue}get timelineOccupancy(){return this.dateRange.attr["X-TIMELINE-OCCUPIES"]==="RANGE"?Zn.Range:Zn.Point}get supplementsPrimary(){return this.dateRange.attr["X-TIMELINE-STYLE"]==="PRIMARY"}get contentMayVary(){return this.dateRange.attr["X-CONTENT-MAY-VARY"]!=="NO"}get assetUrl(){return this.dateRange.attr["X-ASSET-URI"]}get assetListUrl(){return this.dateRange.attr["X-ASSET-LIST"]}get baseUrl(){return this.base.url}get assetListLoaded(){return this.assetList.length>0||this.assetListResponse!==null}toString(){return xy(this)}}function fn(s,e){return s-e.start<e.duration/2&&!(Math.abs(s-(e.start+e.duration))<Ss)?e.start:e.start+e.duration}function Bf(s,e,t){const i=new self.URL(s,t);return i.protocol!=="data:"&&i.searchParams.set("_HLS_primary_id",e),i}function Qa(s,e){for(;(t=s.assetList[++e])!=null&&t.error;)var t;return e}function xy(s){return`["${s.identifier}" ${s.cue.pre?"<pre>":s.cue.post?"<post>":""}${s.timelineStart.toFixed(2)}-${s.resumeTime.toFixed(2)}]`}function ns(s){const e=s.timelineStart,t=s.duration||0;return`["${s.identifier}" ${e.toFixed(2)}-${(e+t).toFixed(2)}]`}class Ry{constructor(e,t,i,r){this.hls=void 0,this.interstitial=void 0,this.assetItem=void 0,this.tracks=null,this.hasDetails=!1,this.mediaAttached=null,this._currentTime=void 0,this._bufferedEosTime=void 0,this.checkPlayout=()=>{this.reachedPlayout(this.currentTime)&&this.hls&&this.hls.trigger(E.PLAYOUT_LIMIT_REACHED,{})};const n=this.hls=new e(t);this.interstitial=i,this.assetItem=r;const a=()=>{this.hasDetails=!0};n.once(E.LEVEL_LOADED,a),n.once(E.AUDIO_TRACK_LOADED,a),n.once(E.SUBTITLE_TRACK_LOADED,a),n.on(E.MEDIA_ATTACHING,(o,{media:l})=>{this.removeMediaListeners(),this.mediaAttached=l,this.interstitial.playoutLimit&&(l.addEventListener("timeupdate",this.checkPlayout),this.appendInPlace&&n.on(E.BUFFER_APPENDED,()=>{const c=this.bufferedEnd;this.reachedPlayout(c)&&(this._bufferedEosTime=c,n.trigger(E.BUFFERED_TO_END,void 0))}))})}get appendInPlace(){return this.interstitial.appendInPlace}loadSource(){const e=this.hls;if(e)if(e.url)e.levels.length&&!e.started&&e.startLoad(-1,!0);else{let t=this.assetItem.uri;try{t=Bf(t,e.config.primarySessionId||"").href}catch{}e.loadSource(t)}}bufferedInPlaceToEnd(e,t){var i;if(!this.appendInPlace)return!1;if((i=this.hls)!=null&&i.bufferedToEnd)return!0;if(!e)return!1;const r=Math.min(this._bufferedEosTime||1/0,this.duration),n=this.timelineOffset+(t||0),a=ie.bufferInfo(e,n,.02);return this.getAssetTime(a.end)>=r-.02}reachedPlayout(e){const i=this.interstitial.playoutLimit;return this.startOffset+e>=i}get destroyed(){var e;return!((e=this.hls)!=null&&e.userConfig)}get assetId(){return this.assetItem.identifier}get interstitialId(){return this.assetItem.parentIdentifier}get media(){var e;return((e=this.hls)==null?void 0:e.media)||null}get bufferedEnd(){const e=this.media||this.mediaAttached;if(!e)return this._bufferedEosTime?this._bufferedEosTime:this.currentTime;const t=ie.bufferInfo(e,e.currentTime,.001);return this.getAssetTime(t.end)}get currentTime(){const e=this.media||this.mediaAttached;return e?this.getAssetTime(e.currentTime):this._currentTime||0}get duration(){const e=this.assetItem.duration;if(!e)return 0;const t=this.interstitial.playoutLimit;if(t){const i=t-this.startOffset;if(i>0&&i<e)return i}return e}get remaining(){const e=this.duration;return e?Math.max(0,e-this.currentTime):0}get startOffset(){return this.assetItem.startOffset}get timelineOffset(){var e;return((e=this.hls)==null?void 0:e.config.timelineOffset)||0}set timelineOffset(e){const t=this.timelineOffset;if(e!==t){const i=e-t;if(Math.abs(i)>1/9e4&&this.hls){if(this.hasDetails)throw new Error("Cannot set timelineOffset after playlists are loaded");this.hls.config.timelineOffset=e}}}getAssetTime(e){const t=this.timelineOffset,i=this.duration;return Math.min(Math.max(0,e-t),i)}removeMediaListeners(){const e=this.mediaAttached;e&&(this._currentTime=e.currentTime,this.bufferSnapShot(),e.removeEventListener("timeupdate",this.checkPlayout))}bufferSnapShot(){if(this.mediaAttached){var e;(e=this.hls)!=null&&e.bufferedToEnd&&(this._bufferedEosTime=this.bufferedEnd)}}destroy(){this.removeMediaListeners(),this.hls&&this.hls.destroy(),this.hls=null,this.tracks=this.mediaAttached=this.checkPlayout=null}attachMedia(e){var t;this.loadSource(),(t=this.hls)==null||t.attachMedia(e)}detachMedia(){var e;this.removeMediaListeners(),this.mediaAttached=null,(e=this.hls)==null||e.detachMedia()}resumeBuffering(){var e;(e=this.hls)==null||e.resumeBuffering()}pauseBuffering(){var e;(e=this.hls)==null||e.pauseBuffering()}transferMedia(){var e;return this.bufferSnapShot(),((e=this.hls)==null?void 0:e.transferMedia())||null}resetDetails(){const e=this.hls;if(e&&this.hasDetails){e.stopLoad();const t=i=>delete i.details;e.levels.forEach(t),e.allAudioTracks.forEach(t),e.allSubtitleTracks.forEach(t),this.hasDetails=!1}}on(e,t,i){var r;(r=this.hls)==null||r.on(e,t)}once(e,t,i){var r;(r=this.hls)==null||r.once(e,t)}off(e,t,i){var r;(r=this.hls)==null||r.off(e,t)}toString(){var e;return`HlsAssetPlayer: ${ns(this.assetItem)} ${(e=this.hls)==null?void 0:e.sessionId} ${this.appendInPlace?"append-in-place":""}`}}const Xa=.033;class Dy extends Dt{constructor(e,t){super("interstitials-sched",t),this.onScheduleUpdate=void 0,this.eventMap={},this.events=null,this.items=null,this.durations={primary:0,playout:0,integrated:0},this.onScheduleUpdate=e}destroy(){this.reset(),this.onScheduleUpdate=null}reset(){this.eventMap={},this.setDurations(0,0,0),this.events&&this.events.forEach(e=>e.reset()),this.events=this.items=null}resetErrorsInRange(e,t){return this.events?this.events.reduce((i,r)=>e<=r.startOffset&&t>r.startOffset?(delete r.error,i+1):i,0):0}get duration(){const e=this.items;return e?e[e.length-1].end:0}get length(){return this.items?this.items.length:0}getEvent(e){return e&&this.eventMap[e]||null}hasEvent(e){return e in this.eventMap}findItemIndex(e,t){if(e.event)return this.findEventIndex(e.event.identifier);let i=-1;e.nextEvent?i=this.findEventIndex(e.nextEvent.identifier)-1:e.previousEvent&&(i=this.findEventIndex(e.previousEvent.identifier)+1);const r=this.items;if(r)for(r[i]||(t===void 0&&(t=e.start),i=this.findItemIndexAtTime(t));i>=0&&(n=r[i])!=null&&n.event;){var n;i--}return i}findItemIndexAtTime(e,t){const i=this.items;if(i)for(let r=0;r<i.length;r++){let n=i[r];t&&t!=="primary"&&(n=n[t]);const a=n.start,o=i[r].event,l=o!=null&&o.cue.pre?o.duration:n.end;if(e===a||e>a&&e<l)return r}return-1}findJumpRestrictedIndex(e,t){const i=this.items;if(i)for(let r=e;r<=t&&i[r];r++){const n=i[r].event;if(n!=null&&n.restrictions.jump&&!n.appendInPlace)return r}return-1}findEventIndex(e){const t=this.items;if(t)for(let r=t.length;r--;){var i;if(((i=t[r].event)==null?void 0:i.identifier)===e)return r}return-1}findAssetIndex(e,t){const i=e.assetList,r=i.length;if(r>1)for(let n=0;n<r;n++){const a=i[n];if(!a.error){const o=a.timelineStart;if(t===o||t>o&&(t<o+(a.duration||0)||n===r-1))return n}}return 0}get assetIdAtEnd(){var e;const t=(e=this.items)==null||(e=e[this.length-1])==null?void 0:e.event;if(t){const i=t.assetList,r=i[i.length-1];if(r)return r.identifier}return null}parseInterstitialDateRanges(e,t,i=0){const r=e.main.details,{dateRanges:n}=r,a=this.events,o=this.parseDateRanges(n,{url:r.url},t),l=Object.keys(n),d=a?a.filter(c=>l.indexOf(c.identifier)===-1):[];o.length&&o.sort((c,u)=>{const h=c.cue.pre,f=c.cue.post,g=u.cue.pre,m=u.cue.post;if(h&&!g)return-1;if(g&&!h||f&&!m)return 1;if(m&&!f)return-1;if(!h&&!g&&!f&&!m){const p=c.startTime,v=u.startTime;if(p!==v)return p-v}return c.dateRange.tagOrder-u.dateRange.tagOrder}),this.events=o,d.forEach(c=>{this.removeEvent(c)}),this.updateSchedule(e,d,i)}updateSchedule(e,t=[],i=0,r=!1){const n=this.events||[];if(n.length||t.length||this.length<2){const a=this.items,o=this.parseSchedule(n,e,i);(r||t.length||a?.length!==o.length||o.some((d,c)=>Math.abs(d.playout.start-a[c].playout.start)>.005||Math.abs(d.playout.end-a[c].playout.end)>.005))&&(this.items=o,this.onScheduleUpdate(t,a))}}parseDateRanges(e,t,i){const r=[],n=Object.keys(e);for(let a=0;a<n.length;a++){const o=n[a],l=e[o];if(l.isInterstitial){let d=this.eventMap[o];d?d.setDateRange(l):(d=new Ly(l,t),this.eventMap[o]=d,i===!1&&(d.appendInPlace=i)),r.push(d)}}return r}parseSchedule(e,t,i=0){const r=[],n=t.main.details,a=n.live?1/0:n.edge;let o=0;if(e=e.filter(d=>!d.error&&!(d.cue.once&&d.hasPlayed)),e.length){this.resolveOffsets(e,t);let d=0,c=0;if(e.forEach((u,h)=>{const f=u.cue.pre,g=u.cue.post,m=e[h-1]||null,p=u.appendInPlace,v=g?a:u.startOffset,T=u.duration,y=u.timelineOccupancy===Zn.Range?T:0,S=f&&n.live?i+(u.resumeOffset||0):0,A=S||u.resumptionOffset,I=m?.startTime===v,_=v+u.cumulativeDuration;let R=p?_+T:v+A;if(f||!g&&v<=0){const L=c;c+=y,u.timelineStart=_;const k=o;o+=T,r.push({event:u,start:_,end:R,playout:{start:k,end:o},integrated:{start:L,end:c}})}else if(v<=a){if(!I){const w=v-d;if(w>Xa){const U=d,K=c;c+=w;const G=o;o+=w;const O={previousEvent:e[h-1]||null,nextEvent:u,start:U,end:U+w,playout:{start:G,end:o},integrated:{start:K,end:c}};r.push(O)}else w>0&&m&&(m.cumulativeDuration+=w,r[r.length-1].end=v)}g&&(R=_),u.timelineStart=_;const L=c;c+=y;const k=o;o+=T,r.push({event:u,start:_,end:R,playout:{start:k,end:o},integrated:{start:L,end:c}})}else return;const D=S||u.resumeTime;g||D>a?d=a:!f&&R&&u.appendInPlaceStarted&&D-R>Xa?d=R:d=D}),d<a){var l;const u=d,h=c,f=a-d;c+=f;const g=o;o+=f,r.push({previousEvent:((l=r[r.length-1])==null?void 0:l.event)||null,nextEvent:null,start:d,end:u+f,playout:{start:g,end:o},integrated:{start:h,end:c}})}this.setDurations(a,o,c)}else r.push({previousEvent:null,nextEvent:null,start:0,end:a,playout:{start:0,end:a},integrated:{start:0,end:a}}),this.setDurations(a,a,a);return r}setDurations(e,t,i){this.durations={primary:e,playout:t,integrated:i}}resolveOffsets(e,t){const i=t.main.details,r=i.live?1/0:i.edge;let n=0,a=-1;e.forEach((o,l)=>{const d=o.cue.pre,c=o.cue.post,u=d?0:c?r:o.startTime;this.updateAssetDurations(o),a===u?o.cumulativeDuration=n:(n=0,a=u),!c&&o.snapOptions.in&&(o.resumeAnchor=Is(null,i.fragments,o.startOffset+o.resumptionOffset,0,0)||void 0),o.appendInPlace&&!o.appendInPlaceStarted&&(this.primaryCanResumeInPlaceAt(o,t)||(o.appendInPlace=!1)),!o.appendInPlace&&l+1<e.length&&e[l+1].startTime-e[l].resumeTime<Xa&&(e[l+1].appendInPlace=!1,e[l+1].appendInPlace&&this.warn(`Could not change append strategy for abutting event ${o}`));const f=B(o.resumeOffset)?o.resumeOffset:o.duration;n+=f})}primaryCanResumeInPlaceAt(e,t){const i=e.resumeTime,r=e.startTime+e.resumptionOffset;return Math.abs(i-r)>Ss?(this.log(`"${e.identifier}" resumption ${i} not aligned with estimated timeline end ${r}`),!1):!Object.keys(t).some(a=>{const o=t[a].details,l=o.edge;if(i>=l)return this.log(`"${e.identifier}" resumption ${i} past ${a} playlist end ${l}`),!1;const d=Is(null,o.fragments,i);if(!d)return this.log(`"${e.identifier}" resumption ${i} does not align with any fragments in ${a} playlist (${o.fragStart}-${o.fragmentEnd})`),!0;const c=a==="audio"?.175:0;return Math.abs(d.start-i)<Ss+c||Math.abs(d.end-i)<Ss+c?!1:(this.log(`"${e.identifier}" resumption ${i} not aligned with ${a} fragment bounds (${d.start}-${d.end} sn: ${d.sn} cc: ${d.cc})`),!0)})}updateAssetDurations(e){if(!e.assetListLoaded)return;const t=e.timelineStart;let i=0,r=!1,n=!1;for(let a=0;a<e.assetList.length;a++){const o=e.assetList[a],l=t+i;o.startOffset=i,o.timelineStart=l,r||(r=o.duration===null),n||(n=!!o.error);const d=o.error?0:o.duration||0;i+=d}r&&!n?e.duration=Math.max(i,e.duration):e.duration=i}removeEvent(e){e.reset(),delete this.eventMap[e.identifier]}}function bt(s){return`[${s.event?'"'+s.event.identifier+'"':"primary"}: ${s.start.toFixed(2)}-${s.end.toFixed(2)}]`}class ky{constructor(e){this.hls=void 0,this.hls=e}destroy(){this.hls=null}loadAssetList(e,t){const i=e.assetListUrl;let r;try{r=Bf(i,this.hls.sessionId,e.baseUrl)}catch(h){const f=this.assignAssetListError(e,x.ASSET_LIST_LOAD_ERROR,h,i);this.hls.trigger(E.ERROR,f);return}t&&r.protocol!=="data:"&&r.searchParams.set("_HLS_start_offset",""+t);const n=this.hls.config,a=n.loader,o=new a(n),l={type:ue.INTERSTITIAL_ASSET_LIST,responseType:"json",url:r.href},d=n.interstitialAssetListLoadPolicy.default,c={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:(h,f,g,m)=>{const p=h.data,v=p?.ASSETS;if(!Array.isArray(v)){const T=this.assignAssetListError(e,x.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),g.url,f,m);this.hls.trigger(E.ERROR,T);return}e.assetListResponse=p,this.hls.trigger(E.ASSET_LIST_LOADED,{event:e,assetListResponse:p,networkDetails:m})},onError:(h,f,g,m)=>{const p=this.assignAssetListError(e,x.ASSET_LIST_LOAD_ERROR,new Error(`Error loading X-ASSET-LIST: HTTP status ${h.code} ${h.text} (${f.url})`),f.url,m,g);this.hls.trigger(E.ERROR,p)},onTimeout:(h,f,g)=>{const m=this.assignAssetListError(e,x.ASSET_LIST_LOAD_TIMEOUT,new Error(`Timeout loading X-ASSET-LIST (${f.url})`),f.url,h,g);this.hls.trigger(E.ERROR,m)}};return o.load(l,c,u),this.hls.trigger(E.ASSET_LIST_LOADING,{event:e}),o}assignAssetListError(e,t,i,r,n,a){return e.error=i,{type:X.NETWORK_ERROR,details:t,fatal:!1,interstitial:e,url:r,error:i,networkDetails:a,stats:n}}}function zc(s){var e;s==null||(e=s.play())==null||e.catch(()=>{})}function Mi(s,e){return`[${s}] Advancing timeline position to ${e}`}class Cy extends Dt{constructor(e,t){super("interstitials",e.logger),this.HlsPlayerClass=void 0,this.hls=void 0,this.assetListLoader=void 0,this.mediaSelection=null,this.altSelection=null,this.media=null,this.detachedData=null,this.requiredTracks=null,this.manager=null,this.playerQueue=[],this.bufferedPos=-1,this.timelinePos=-1,this.schedule=void 0,this.playingItem=null,this.bufferingItem=null,this.waitingItem=null,this.endedItem=null,this.playingAsset=null,this.endedAsset=null,this.bufferingAsset=null,this.bufferPastEdge=!1,this.shouldPlay=!1,this.onPlay=()=>{this.shouldPlay=!0},this.onPause=()=>{this.shouldPlay=!1},this.onSeeking=()=>{const i=this.currentTime;if(i===void 0||this.playbackDisabled||!this.schedule)return;const r=i-this.timelinePos;if(Math.abs(r)<1/7056e5)return;const a=r<=-.01;this.timelinePos===-1&&!this.effectivePlayingItem&&this.checkStart(),this.timelinePos=i,this.bufferedPos=i;const o=this.playingItem;if(!o){this.checkBuffer();return}if(a&&this.schedule.resetErrorsInRange(i,i-r)&&this.updateSchedule(!0),this.checkBuffer(),a&&i<o.start||i>=o.end){var l;const f=this.findItemIndex(o);let g=this.schedule.findItemIndexAtTime(i);if(g===-1&&(g=f+(a?-1:1),this.log(`seeked ${a?"back ":""}to position not covered by schedule ${i} (resolving from ${f} to ${g})`)),!this.isInterstitial(o)&&(l=this.media)!=null&&l.paused&&(this.shouldPlay=!1),!a&&g>f){const m=this.schedule.findJumpRestrictedIndex(f+1,g);if(m>f){this.setSchedulePosition(m);return}}this.setSchedulePosition(g);return}const d=this.playingAsset;if(!d){if(this.playingLastItem&&this.isInterstitial(o)){const f=o.event.assetList[0];f&&(this.endedItem=this.playingItem,this.playingItem=null,this.setScheduleToAssetAtTime(i,f))}return}const c=d.timelineStart,u=d.duration||0;if(a&&i<c||i>=c+u){var h;(h=o.event)!=null&&h.appendInPlace&&(this.clearAssetPlayers(o.event,o),this.flushFrontBuffer(i)),this.setScheduleToAssetAtTime(i,d)}},this.onTimeupdate=()=>{const i=this.currentTime;if(i===void 0||this.playbackDisabled)return;if(this.timelinePos===-1&&!this.effectivePlayingItem&&this.checkStart(),i>this.timelinePos)this.timelinePos=i,i>this.bufferedPos&&this.checkBuffer();else return;const r=this.playingItem;if(!r||this.playingLastItem)return;if(i>=r.end){this.timelinePos=r.end;const o=this.findItemIndex(r);this.setSchedulePosition(o+1)}const n=this.playingAsset;if(!n)return;const a=n.timelineStart+(n.duration||0);i>=a&&this.setScheduleToAssetAtTime(i,n)},this.onScheduleUpdate=(i,r)=>{const n=this.schedule;if(!n)return;const a=this.playingItem,o=n.events||[],l=n.items||[],d=n.durations,c=i.map(m=>m.identifier),u=!!(o.length||c.length);(u||r)&&this.log(`INTERSTITIALS_UPDATED (${o.length}): ${o}
83Schedule: ${l.map(m=>bt(m))} pos: ${this.timelinePos}`),c.length&&this.log(`Removed events ${c}`);let h=null,f=null;a&&(h=this.updateItem(a,this.timelinePos),this.itemsMatch(a,h)?this.playingItem=h:this.waitingItem=null),this.waitingItem=this.updateItem(this.waitingItem);const g=this.bufferingItem;if(g&&(f=this.updateItem(g,this.bufferedPos),this.itemsMatch(g,f)?this.bufferingItem=f:g.event&&(this.bufferingItem=this.playingItem,this.clearInterstitial(g.event,null))),i.forEach(m=>{m.assetList.forEach(p=>{this.clearAssetPlayer(p.identifier,null)})}),this.playerQueue.forEach(m=>{if(m.interstitial.appendInPlace){const p=m.assetItem.timelineStart,v=m.timelineOffset-p;if(v)try{m.timelineOffset=p}catch(T){Math.abs(v)>Ss&&this.warn(`${T} ("${m.assetId}" ${m.timelineOffset}->${p})`)}}}),u||r){if(this.hls.trigger(E.INTERSTITIALS_UPDATED,{events:o.slice(0),schedule:l.slice(0),durations:d,removedIds:c}),this.isInterstitial(a)&&c.indexOf(a.event.identifier)>-1){this.warn(`Interstitial "${a.event.identifier}" removed while playing`),this.primaryFallback(a.event);return}a&&this.trimInPlace(h,a),g&&f!==h&&this.trimInPlace(f,g),this.checkBuffer()}},this.hls=e,this.HlsPlayerClass=t,this.assetListLoader=new ky(e),this.schedule=new Dy(this.onScheduleUpdate,e.logger),this.registerListeners()}registerListeners(){const e=this.hls;e&&(e.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(E.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on(E.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(E.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on(E.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on(E.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on(E.BUFFER_APPENDED,this.onBufferAppended,this),e.on(E.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(E.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on(E.MEDIA_ENDED,this.onMediaEnded,this),e.on(E.ERROR,this.onError,this),e.on(E.DESTROYING,this.onDestroying,this))}unregisterListeners(){const e=this.hls;e&&(e.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(E.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off(E.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(E.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off(E.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off(E.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off(E.BUFFER_CODECS,this.onBufferCodecs,this),e.off(E.BUFFER_APPENDED,this.onBufferAppended,this),e.off(E.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(E.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off(E.MEDIA_ENDED,this.onMediaEnded,this),e.off(E.ERROR,this.onError,this),e.off(E.DESTROYING,this.onDestroying,this))}startLoad(){this.resumeBuffering()}stopLoad(){this.pauseBuffering()}resumeBuffering(){var e;(e=this.getBufferingPlayer())==null||e.resumeBuffering()}pauseBuffering(){var e;(e=this.getBufferingPlayer())==null||e.pauseBuffering()}destroy(){this.unregisterListeners(),this.stopLoad(),this.assetListLoader&&this.assetListLoader.destroy(),this.emptyPlayerQueue(),this.clearScheduleState(),this.schedule&&this.schedule.destroy(),this.media=this.detachedData=this.mediaSelection=this.requiredTracks=this.altSelection=this.schedule=this.manager=null,this.hls=this.HlsPlayerClass=null,this.assetListLoader=null,this.onPlay=this.onPause=this.onSeeking=this.onTimeupdate=null,this.onScheduleUpdate=null}onDestroying(){const e=this.primaryMedia||this.media;e&&this.removeMediaListeners(e)}removeMediaListeners(e){ye(e,"play",this.onPlay),ye(e,"pause",this.onPause),ye(e,"seeking",this.onSeeking),ye(e,"timeupdate",this.onTimeupdate)}onMediaAttaching(e,t){const i=this.media=t.media;Ae(i,"seeking",this.onSeeking),Ae(i,"timeupdate",this.onTimeupdate),Ae(i,"play",this.onPlay),Ae(i,"pause",this.onPause)}onMediaAttached(e,t){const i=this.effectivePlayingItem,r=this.detachedData;if(this.detachedData=null,i===null)this.checkStart();else if(!r){this.clearScheduleState();const n=this.findItemIndex(i);this.setSchedulePosition(n)}}clearScheduleState(){this.log("clear schedule state"),this.playingItem=this.bufferingItem=this.waitingItem=this.endedItem=this.playingAsset=this.endedAsset=this.bufferingAsset=null}onMediaDetaching(e,t){const i=!!t.transferMedia,r=this.media;if(this.media=null,!i&&(r&&this.removeMediaListeners(r),this.detachedData)){const n=this.getBuffer
83ingPlayer();n&&(this.log(`Removing schedule state for detachedData and ${n}`),this.playingAsset=this.endedAsset=this.bufferingAsset=this.bufferingItem=this.waitingItem=this.detachedData=null,n.detachMedia()),this.shouldPlay=!1}}get interstitialsManager(){if(!this.hls)return null;if(this.manager)return this.manager;const e=this,t=()=>e.bufferingItem||e.waitingItem,i=u=>u&&e.getAssetPlayer(u.identifier),r=(u,h,f,g,m)=>{if(u){let p=u[h].start;const v=u.event;if(v){if(h==="playout"||v.timelineOccupancy!==Zn.Point){const T=i(f);T?.interstitial===v&&(p+=T.assetItem.startOffset+T[m])}}else{const T=g==="bufferedPos"?a():e[g];p+=T-u.start}return p}return 0},n=(u,h)=>{var f;if(u!==0&&h!=="primary"&&(f=e.schedule)!=null&&f.length){var g;const m=e.schedule.findItemIndexAtTime(u),p=(g=e.schedule.items)==null?void 0:g[m];if(p){const v=p[h].start-p.start;return u+v}}return u},a=()=>{const u=e.bufferedPos;return u===Number.MAX_VALUE?o("primary"):Math.max(u,0)},o=u=>{var h,f;return(h=e.primaryDetails)!=null&&h.live?e.primaryDetails.edge:((f=e.schedule)==null?void 0:f.durations[u])||0},l=(u,h)=>{var f,g;const m=e.effectivePlayingItem;if(m!=null&&(f=m.event)!=null&&f.restrictions.skip||!e.schedule)return;e.log(`seek to ${u} "${h}"`);const p=e.effectivePlayingItem,v=e.schedule.findItemIndexAtTime(u,h),T=(g=e.schedule.items)==null?void 0:g[v],y=e.getBufferingPlayer(),S=y?.interstitial,A=S?.appendInPlace,I=p&&e.itemsMatch(p,T);if(p&&(A||I)){const _=i(e.playingAsset),R=_?.media||e.primaryMedia;if(R){const D=h==="primary"?R.currentTime:r(p,h,e.playingAsset,"timelinePos","currentTime"),L=u-D,k=(A?D:R.currentTime)+L;if(k>=0&&(!_||A||k<=_.duration)){R.currentTime=k;return}}}if(T){let _=u;if(h!=="primary"){const D=T[h].start,L=u-D;_=T.start+L}const R=!e.isInterstitial(T);if((!e.isInterstitial(p)||p.event.appendInPlace)&&(R||T.event.appendInPlace)){const D=e.media||(A?y?.media:null);D&&(D.currentTime=_)}else if(p){const D=e.findItemIndex(p);if(v>D){const k=e.schedule.findJumpRestrictedIndex(D+1,v);if(k>D){e.setSchedulePosition(k);return}}let L=0;if(R)e.timelinePos=_,e.checkBuffer();
vendor: 14,285 bytes, line 83
83else{const k=T.event.assetList,w=u-(T[h]||T).start;for(let U=k.length;U--;){const K=k[U];if(K.duration&&w>=K.startOffset&&w<K.startOffset+K.duration){L=U;break}}}e.setSchedulePosition(v,L)}}},d=()=>{const u=e.effectivePlayingItem;if(e.isInterstitial(u))return u;const h=t();return e.isInterstitial(h)?h:null},c={get bufferedEnd(){const u=t(),h=e.bufferingItem;if(h&&h===u){var f;return r(h,"playout",e.bufferingAsset,"bufferedPos","bufferedEnd")-h.playout.start||((f=e.bufferingAsset)==null?void 0:f.startOffset)||0}return 0},get currentTime(){const u=d(),h=e.effectivePlayingItem;return h&&h===u?r(h,"playout",e.effectivePlayingAsset,"timelinePos","currentTime")-h.playout.start:0},set currentTime(u){const h=d(),f=e.effectivePlayingItem;f&&f===h&&l(u+f.playout.start,"playout")},get duration(){const u=d();return u?u.playout.end-u.playout.start:0},get assetPlayers(){var u;const h=(u=d())==null?void 0:u.event.assetList;return h?h.map(f=>e.getAssetPlayer(f.identifier)):[]},get playingIndex(){var u;const h=(u=d())==null?void 0:u.event;return h&&e.effectivePlayingAsset?h.findAssetIndex(e.effectivePlayingAsset):-1},get scheduleItem(){return d()}};return this.manager={get events(){var u;return((u=e.schedule)==null||(u=u.events)==null?void 0:u.slice(0))||[]},get schedule(){var u;return((u=e.schedule)==null||(u=u.items)==null?void 0:u.slice(0))||[]},get interstitialPlayer(){return d()?c:null},get playerQueue(){return e.playerQueue.slice(0)},get bufferingAsset(){return e.bufferingAsset},get bufferingItem(){return t()},get bufferingIndex(){const u=t();return e.findItemIndex(u)},get playingAsset(){return e.effectivePlayingAsset},get playingItem(){return e.effectivePlayingItem},get playingIndex(){const u=e.effectivePlayingItem;return e.findItemIndex(u)},primary:{get bufferedEnd(){return a()},get currentTime(){const u=e.timelinePos;return u>0?u:0},set currentTime(u){l(u,"primary")},get duration(){return o("primary")},get seekableStart(){return e.seekableStart}},integrated:{get bufferedEnd(){return r(t(),"integrated",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return r(e.effectivePlayingItem,"integrated",e.effectivePlayingAsset,"timelinePos","currentTime")},set currentTime(u){l(u,"integrated")},get duration(){return o("integrated")},get seekableStart(){return n(e.seekableStart,"integrated")}},skip:()=>{const u=e.effectivePlayingItem,h=u?.event;if(h&&!h.restrictions.skip){const f=e.findItemIndex(u);if(h.appendInPlace){const g=u.playout.start+u.event.duration;l(g+.001,"playout")}else e.advanceAfterAssetEnded(h,f,1/0)}}}}get effectivePlayingItem(){return this.waitingItem||this.playingItem||this.endedItem}get effectivePlayingAsset(){return this.playingAsset||this.endedAsset}get playingLastItem(){var e;const t=this.playingItem,i=(e=this.schedule)==null?void 0:e.items;return!this.playbackStarted||!t||!i?!1:this.findItemIndex(t)===i.length-1}get playbackStarted(){return this.effectivePlayingItem!==null}get currentTime(){var e,t;if(this.mediaSelection===null)return;const i=this.waitingItem||this.playingItem;if(this.isInterstitial(i)&&!i.event.appendInPlace)return;let r=this.media;!r&&(e=this.bufferingItem)!=null&&(e=e.event)!=null&&e.appendInPlace&&(r=this.primaryMedia);const n=(t=r)==null?void 0:t.currentTime;if(!(n===void 0||!B(n)))return n}get primaryMedia(){var e;return this.media||((e=this.detachedData)==null?void 0:e.media)||null}isInterstitial(e){return!!(e!=null&&e.event)}retreiveMediaSource(e,t){const i=this.getAssetPlayer(e);i&&this.transferMediaFromPlayer(i,t)}transferMediaFromPlayer(e,t){const i=e.interstitial.appendInPlace,r=e.media;if(i&&r===this.primaryMedia){if(this.bufferingAsset=null,(!t||this.isInterstitial(t)&&!t.event.appendInPlace)&&t&&r){this.detachedData={media:r};return}const n=e.transferMedia();this.log(`transfer MediaSource from ${e} ${Re(n)}`),this.detachedData=n}else t&&r&&(this.shouldPlay||(this.shouldPlay=!r.paused))}transferMediaTo(e,t){var i,r;if(e.media===t)return;let n=null;const a=this.hls,o=e!==a,l=o&&e.interstitial.appendInPlace,d=(i=this.detachedData)==null?void 0:i.mediaSource;let c;if(a.media)l&&(n=a.transferMedia(),this.detachedData=n),c="Primary";else{const g=this.getBufferingPlayer();g?(n=g.transferMedia(),this.detachedData=n,c=`${g}`):d?c="detached MediaSource":c="detached media"}if(!n){if(d)n=this.detachedData,this.log(`using detachedData: MediaSource ${Re(n)}`);else if(!this.detachedData||a.media===t){const g=this.playerQueue;g.length>1&&g.forEach(m=>{if(o&&m.interstitial.appendInPlace!==l){const p=m.interstitial;this.clearInterstitial(m.interstitial,null),p.appendInPlace=!1,p.appendInPlace&&this.warn(`Could not change append strategy for queued assets ${p}`)}}),this.hls.detachMedia(),this.detachedData={media:t}}}const u=n&&"mediaSource"in n&&((r=n.mediaSource)==null?void 0:r.readyState)!=="closed";if(this.log(`${u?"transfering MediaSource":"attaching media"} to ${o?e:"Primary"} from ${c} (media.currentTime: ${t.currentTime})`),!u&&!o){e.attachMedia(t);return}const h=u&&n?n:{media:t},f=this.schedule;if(f){const g=o&&e.assetId===f.assetIdAtEnd;h.overrides={duration:f.duration,endOfStream:!o||g||e.appendInPlace===!1}}if(!u&&l){const g=e,m=g.assetItem.timelineStart;if(m){const p=g.hls,v=Math.max(this.timelinePos-m,Number.EPSILON);p.startPosition!==v&&(this.log(`Set ${g} startPosition: ${v}`),p.config.startPosition=v,p.loadingEnabled&&p.startLoad(v))}}e.attachMedia(h)}onInterstitialCueEnter(){this.onTimeupdate()}checkStart(){const e=this.schedule,t=e?.events,i=this.hls;if(!t||this.playbackDisabled||!this.media||!i)return;this.bufferedPos===-1&&(this.bufferedPos=0);const r=this.timelinePos,n=this.effectivePlayingItem;if(r===-1){if(!i.loadingEnabled){this.log("waiting for startLoad( <startPosition> )");return}const a=i.startPosition;if(this.timelinePos=a,t.length===0)this.setSchedulePosition(0);else if(t[0].cue.pre){this.log(Mi("checkStart (preroll)",a));const o=e.findEventIndex(t[0].identifier);this.setSchedulePosition(o)}else if(a>=0||!this.primaryLive){this.log(Mi("checkStart",a));const o=this.timelinePos=a>0?a:0,l=e.findItemIndexAtTime(o);this.setSchedulePosition(l)}else i.liveSyncPosition===0?this.setSchedulePosition(0):this.log("[checkStart] waiting for live start")}else if(n&&!this.playingItem){this.log(Mi("checkStart (playing item)",n.start));const a=e.findItemIndex(n);this.setSchedulePosition(a)}}advanceAssetBuffering(e,t){const i=e.event,r=i.findAssetIndex(t),n=Qa(i,r);if(!i.isAssetPastPlayoutLimit(n))this.bufferedToEvent(e,n);else if(this.schedule){var a;const o=this.getNextItemIndex(e,!0),l=(a=this.schedule.items)==null?void 0:a[o];l&&this.bufferedToItem(l)}}livePrerollResumption(e,t){if(e.cue.pre&&this.primaryLive&&!B(e.resumeOffset)&&this.hls){const i=this.getLiveStartPos();if(t){const r=this.getBufferingPlayer(),n=r!=null&&r.interstitial.cue.pre?r.remaining:0;return i+n}return i}}getNextItemIndex(e,t){if(this.schedule){const i=this.livePrerollResumption(e.event,t);if(i!==void 0)return this.log(`find next item index @${i}`),this.schedule.findItemIndexAtTime(i)}return this.findItemIndex(e)+1}advanceAfterAssetEnded(e,t,i){const r=Qa(e,i);if(e.isAssetPastPlayoutLimit(r)){if(this.schedule){const n=this.schedule.items;if(n){const a=n[t],o=a.event?this.getNextItemIndex(a):t+1,l=n.length;if(o>=l){this.setSchedulePosition(-1);return}const d=e.resumeTime;this.timelinePos<d&&(this.log(Mi("advanceAfterAssetEnded",d)),this.timelinePos=d,e.appendInPlace&&!n[o].event&&this.hls.startLoad(d+.01),this.checkBuffer(this.bufferedPos<d)),this.setSchedulePosition(o)}}}else{if(e.appendInPlace){const n=e.assetList[r];n&&this.advanceInPlace(n.timelineStart)}this.setSchedulePosition(t,r)}}setScheduleToAssetAtTime(e,t){const i=this.schedule;if(!i)return;const r=t.parentIdentifier,n=i.getEvent(r);if(n){const a=i.findEventIndex(r),o=i.findAssetIndex(n,e);this.advanceAfterAssetEnded(n,a,o-1)}}setSchedulePosition(e,t){var i;const r=(i=this.schedule)==null?void 0:i.items;if(!r||this.playbackDisabled)return;const n=e>=0?r[e]:null;this.log(`setSchedulePosition ${e}, ${t} (${n&&bt(n)}) pos: ${this.timelinePos}`);const a=this.waitingItem||this.playingItem,o=this.playingLastItem;if(this.isInterstitial(a)){const u=a.event,h=this.playingAsset,f=h?.identifier,g=f?this.getAssetPlayer(f):null;if(g&&f&&(!this.eventItemsMatch(a,n)||t!==void 0&&f!==u.assetList[t].identifier)){var l;const m=u.findAssetIndex(h);if(this.log(`INTERSTITIAL_ASSET_ENDED ${m+1}/${u.assetList.length} ${ns(h)}`),this.endedAsset=h,this.playingAsset=null,this.hls.trigger(E.INTERSTITIAL_ASSET_ENDED,{asset:h,assetListIndex:m,event:u,schedule:r.slice(0),scheduleIndex:e,player:g}),a!==this.playingItem){this.itemsMatch(a,this.playingItem)&&!this.playingAsset&&this.advanceAfterAssetEnded(u,this.findItemIndex(this.playingItem),m);return}this.retreiveMediaSource(f,n),g.media&&!((l=this.detachedData)!=null&&l.mediaSource)&&g.detachMedia()}if(!this.eventItemsMatch(a,n)&&(this.endedItem=a,this.playingItem=this.waitingItem=null,this.log(`INTERSTITIAL_ENDED ${u} ${bt(a)}`),u.hasPlayed=!0,this.hls.trigger(E.INTERSTITIAL_ENDED,{event:u,schedule:r.slice(0),scheduleIndex:e}),u.cue.once&&this.hls)){var d;this.updateSchedule();const m=(d=this.schedule)==null?void 0:d.items;if(n&&m){const p=this.findItemIndex(n),v=this.livePrerollResumption(u);if(v!==void 0){let T=v;const y=this.getNextItemIndex(a);if(!this.isInterstitial(r[y])){var c;const S=(c=this.primaryDetails)==null?void 0:c.fragments;if(u.snapOptions.in&&S){const A=Is(null,S,v);A&&(T=Math.min(Math.max(r[y].start,fn(T,A)),r[y].end))}}if(this.log(Mi("live join (preroll)",T)),this.timelinePos=T,y!==p&&(y||y===0)){this.advanceSchedule(y,m,void 0,a,o);return}}this.advanceSchedule(p,m,t,a,o)}return}}this.advanceSchedule(e,r,t,a,o)}advanceSchedule(e,t,i,r,n){const a=this.schedule;if(!a)return;const o=t[e]||null,l=this.primaryMedia,d=this.playerQueue;if(d.length&&d.forEach(c=>{const u=c.interstitial,h=a.findEventIndex(u.identifier);(h<e||h>e+1)&&this.clearInterstitial(u,o)}),this.isInterstitial(o)){this.timelinePos=Math.min(Math.max(this.timelinePos,o.start),o.end);const c=o.event;if(i===void 0){i=c.cue.pre?0:a.findAssetIndex(c,this.timelinePos);const g=Qa(c,i-1);if(c.isAssetPastPlayoutLimit(g)||c.appendInPlace&&this.timelinePos===o.end){this.advanceAfterAssetEnded(c,e,i);return}i=g}const u=this.waitingItem;this.assetsBuffered(o,l)||this.setBufferingItem(o);let h=this.preloadAssets(c,i);if(this.eventItemsMatch(o,u||r)||(this.waitingItem=o,this.log(`INTERSTITIAL_STARTED ${bt(o)} ${c.appendInPlace?"append in place":""}`),c.hasPlayed=!1,this.hls.trigger(E.INTERSTITIAL_STARTED,{event:c,schedule:t.slice(0),scheduleIndex:e})),!c.assetListLoaded){this.log(`Waiting for ASSET-LIST to complete loading ${c}`);return}if(c.assetListLoader&&(c.assetListLoader.destroy(),c.assetListLoader=void 0),!l){this.log(`Waiting for attachMedia to start Interstitial ${c}`);return}this.waitingItem=this.endedItem=null,this.playingItem=o;const f=c.assetList[i];if(!f){this.advanceAfterAssetEnded(c,e,i||0);return}if(h||(h=this.getAssetPlayer(f.identifier)),h===null||h.destroyed){const g=c.assetList.length;this.warn(`asset ${i+1}/${g} player destroyed ${c}`),h=this.createAssetPlayer(c,f,i),h.loadSource()}if(!this.eventItemsMatch(o,this.bufferingItem)&&c.appendInPlace&&this.isAssetBuffered(f))return;this.startAssetPlayer(h,i,t,e,l),this.shouldPlay&&zc(h.media)}else o?(this.resumePrimary(o,e,r),this.shouldPlay&&zc(this.hls.media)):n&&this.isInterstitial(r)&&(this.endedItem=null,this.playingItem=r,r.event.appendInPlace||this.attachPrimary(a.durations.primary,null))}get playbackDisabled(){return this.hls.config.enableInterstitialPlayback===!1}get primaryDetails(){var e;return(e=this.mediaSelection)==null?void 0:e.main.details}get primaryLive(){var e;return!!((e=this.primaryDetails)!=null&&e.live)}resumePrimary(e,t,i){var r,n;this.playingItem=e,this.playingAsset=this.endedAsset=null,this.waitingItem=null,this.bufferedToItem(e),this.endedItem=null,this.log(`resuming ${bt(e)}`);let a=this.timelinePos;if((r=this.detachedData)!=null&&r.mediaSource?this.primaryLive&&this.startLoadingPrimaryAt(a):((a<e.start||a>=e.end||a<this.seekableStart)&&(a=this.getPrimaryResumption(e,t),this.log(Mi("resumePrimary",a)),this.timelinePos=a),this.attachPrimary(a,e)),!i)return;const o=(n=this.schedule)==null?void 0:n.items;o&&(this.log(`INTERSTITIALS_PRIMARY_RESUMED ${bt(e)}`),this.hls.trigger(E.INTERSTITIALS_PRIMARY_RESUMED,{schedule:o.slice(0),scheduleIndex:t}),this.checkBuffer())}get seekableStart(){var e;return this.primaryLive&&((e=this.primaryDetails)==null?void 0:e.fragmentStart)||0}getPrimaryResumption(e,t,i){const r=e.start;if(this.primaryLive){if(t===0)return this.hls.startPosition;const n=this.endedItem||this.playingItem,a=n!=null&&n.event?this.livePrerollResumption(n.event,i):void 0;if(a!==void 0)return a;const o=this.primaryDetails;if(o){const{fragmentStart:l,edge:d}=o;if(r<l||r>d&&!i){const c=this.hls.liveSyncPosition;return this.log(`primary resumption out of bounds (${r} [${l}-${d}]) snapping to liveSync ${c}`),c||l}}}return this.log(`primary resumption itemStart: ${r}`),r}getLiveStartPos(){var e;const t=this.hls.startPosition,i=this.hls.liveSyncPosition||0,r=(((e=this.primaryDetails)==null?void 0:e.targetduration)||10)*3;return t===-1||i&&i-t<r?i||0:t}isAssetBuffered(e){const t=this.getAssetPlayer(e.identifier);return t!=null&&t.hls?t.hls.bufferedToEnd:ie.bufferInfo(this.primaryMedia,this.timelinePos,0).end+1>=e.timelineStart+(e.duration||0)}attachPrimary(e,t,i){t?this.setBufferingItem(t):this.bufferingItem=this.playingItem,this.bufferingAsset=null;const r=this.primaryMedia;if(!r)return;const n=this.hls;n.media?this.checkBuffer():(this.transferMediaTo(n,r),i&&this.startLoadingPrimaryAt(e,i)),i||(this.log(Mi("attachPrimary",e)),this.timelinePos=e,this.startLoadingPrimaryAt(e,i))}startLoadingPrimaryAt(e,t){const i=this.hls,{loadingEnabled:r,bufferingEnabled:n,startPosition:a}=i,o=!t&&i.hasEnoughToStart;if(this.log(`Start loading primary @${e} bufferedPos: ${this.bufferedPos} instructToSeek: ${o} startPosition: ${a} loadingEnabled: ${r} bufferingEnabled: ${n}`),o||!r||Math.abs(a-e)>.1){const l=this.primaryDetails;if(l!=null&&l.live&&e>=l.edge){const d=this.bufferingItem;this.log(`Resume primary loading when live reaches ${e} buffering item: ${d?bt(d):null}
83`),i.pauseBuffering(),this.bufferPastEdge=!0;return}i.startLoad(e,t)}else n||i.resumeBuffering()}onManifestLoading(){var e;this.stopLoad(),(e=this.schedule)==null||e.reset(),this.emptyPlayerQueue(),this.clearScheduleState(),this.shouldPlay=!1,this.bufferedPos=this.timelinePos=-1,this.mediaSelection=this.altSelection=this.manager=this.requiredTracks=null,this.hls.off(E.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(E.BUFFER_CODECS,this.onBufferCodecs,this)}onLevelUpdated(e,t){if(t.level===-1||!this.schedule)return;const i=this.hls.levels[t.level];if(!i.details)return;const r=Z(Z({},this.mediaSelection||this.altSelection),{},{main:i});this.mediaSelection=r;const n=this.hls.startPosition;if(this.schedule.parseInterstitialDateRanges(r,this.hls.config.interstitialAppendInPlace,n===-1?0:n),!!this.schedule.items){if(!this.effectivePlayingItem)this.checkStart();else if(this.bufferPastEdge){const o=this.primaryDetails,l=this.bufferedPos;if(o!=null&&o.live&&l<o.edge){this.bufferPastEdge=!1;const d=this.bufferingItem;if(this.log(`Live edge ${o.edge} reached buffer: ${l} buffering item: ${d?bt(d):null}`),d?.end===1/0)this.startLoadingPrimaryAt(Math.max(l,d.start));else{const u=this.getBufferingPlayer();u&&u.bufferedInPlaceToEnd(this.primaryMedia,u.currentTime)&&u.hls&&u.hls.trigger(E.BUFFERED_TO_END,void 0)}}}}}onAudioTrackUpdated(e,t){const i=this.hls.audioTracks[t.id],r=this.mediaSelection;if(!r){this.altSelection=Z(Z({},this.altSelection),{},{audio:i});return}const n=Z(Z({},r),{},{audio:i});this.mediaSelection=n}onSubtitleTrackUpdated(e,t){const i=this.hls.subtitleTracks[t.id],r=this.mediaSelection;if(!r){this.altSelection=Z(Z({},this.altSelection),{},{subtitles:i});return}const n=Z(Z({},r),{},{subtitles:i});this.mediaSelection=n}onAudioTrackSwitching(e,t){const i=Vd(t);this.playerQueue.forEach(({hls:r})=>r&&(r.setAudioOption(t)||r.setAudioOption(i)))}onSubtitleTrackSwitch(e,t){const i=Vd(t);this.playerQueue.forEach(({hls:r})=>r&&(r.setSubtitleOption(t)||t.id!==-1&&r.setSubtitleOption(i)))}onBufferCodecs(e,t){const i=t.tracks;i&&(this.requiredTracks=i)}onBufferAppended(e,t){this.checkBuffer()}onBufferFlushed(e,t){const i=this.playingItem;if(i&&!this.itemsMatch(i,this.bufferingItem)&&!this.isInterstitial(i)){const r=this.timelinePos;this.bufferedPos=r,this.checkBuffer()}}onBufferedToEnd(e){if(!this.schedule)return;const t=this.schedule.events;if(this.bufferedPos<Number.MAX_VALUE&&t){for(let i=0;i<t.length;i++){const r=t[i];if(r.cue.post){const n=this.getEventItem(r.identifier);n&&this.eventItemsMatch(n,this.bufferingItem)&&this.bufferedToItem(n,0);break}}this.bufferedPos=Number.MAX_VALUE}}onMediaEnded(e){const t=this.playingItem;if(!this.playingLastItem&&t){const i=this.findItemIndex(t);this.setSchedulePosition(i+1)}else this.shouldPlay=!1}updateItem(e,t){var i;const r=(i=this.schedule)==null?void 0:i.items;if(e&&r){const n=this.findItemIndex(e,t);return r[n]||null}return null}trimInPlace(e,t){if(this.isInterstitial(e)&&e.event.appendInPlace&&t.end-e.end>.25){e.event.assetList.forEach((n,a)=>{e.event.isAssetPastPlayoutLimit(a)&&this.clearAssetPlayer(n.identifier,null)});const i=e.end+.25,r=ie.bufferInfo(this.primaryMedia,i,0);(r.end>i||(r.nextStart||0)>i)&&(this.log(`trim buffered interstitial ${bt(e)} (was ${bt(t)})`),this.attachPrimary(i,null,!0),this.flushFrontBuffer(i))}}itemsMatch(e,t){return!!t&&(e===t||e.event&&t.event&&this.eventItemsMatch(e,t)||!e.event&&!t.event&&this.findItemIndex(e)===this.findItemIndex(t))}eventItemsMatch(e,t){var i;return!!t&&(e===t||e.event.identifier===((i=t.event)==null?void 0:i.identifier))}findEventIndex(e){return this.schedule?this.schedule.findEventIndex(e):-1}getEventItem(e){if(this.schedule){var t;const i=(t=this.schedule.items)==null?void 0:t[this.findEventIndex(e)];if(this.isInterstitial(i)&&i.event.identifier===e)return i}}findItemIndex(e,t){return e&&this.schedule?this.schedule.findItemIndex(e,t):-1}updateSchedule(e=!1){var t,i;const r=this.mediaSelection;if(!r)return;const n=((t=this.hls)==null?void 0:t.liveSyncPosition)||0;(i=this.schedule)==null||i.updateSchedule(r,[],n,e)}checkBuffer(e){var t;const i=(t=this.schedule)==null?void 0:t.items;if(!i)return;const r=ie.bufferInfo(this.primaryMedia,this.timelinePos,0);e&&(this.bufferedPos=this.timelinePos),e||(e=r.len<1),this.updateBufferedPos(r.end,i,e)}updateBufferedPos(e,t,i){const r=this.schedule,n=this.bufferingItem;if(this.bufferedPos>e||!r)return;if(t.length===1&&this.itemsMatch(t[0],n)){this.bufferedPos=e;return}const a=this.playingItem,o=this.findItemIndex(a);let l=r.findItemIndexAtTime(e);
vendor: 59,971 bytes, lines 83-84
83if(this.bufferedPos<e){var d;const c=this.findItemIndex(n),u=Math.min(c+1,t.length-1),h=t[u];if((l===-1&&n&&e>=n.end||(d=h.event)!=null&&d.appendInPlace&&e+.01>=h.start)&&(l=u),this.isInterstitial(n)){const f=n.event;if(u-o>1&&f.appendInPlace===!1||f.assetList.length===0&&f.assetListLoader)return}if(this.bufferedPos=e,l>c&&l>o)this.bufferedToItem(h);else{const f=this.primaryDetails;this.primaryLive&&f&&e>f.edge-f.targetduration&&h.start<f.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(h)&&this.preloadAssets(h.event,0)}}else i&&a&&!this.itemsMatch(a,n)&&(l===o?this.bufferedToItem(a):l===o+1&&this.bufferedToItem(t[l]))}assetsBuffered(e,t){return e.event.assetList.length===0?!1:!e.event.assetList.some(r=>{const n=this.getAssetPlayer(r.identifier);return!(n!=null&&n.bufferedInPlaceToEnd(t))})}setBufferingItem(e){const t=this.bufferingItem,i=this.schedule;if(!this.itemsMatch(e,t)&&i){const{items:r,events:n}=i;if(!r||!n)return t;const a=this.isInterstitial(e),o=this.getBufferingPlayer();this.bufferingItem=e,this.bufferedPos=Math.max(e.start,Math.min(e.end,this.timelinePos));const l=o?o.remaining:t?t.end-this.timelinePos:0;if(this.log(`INTERSTITIALS_BUFFERED_TO_BOUNDARY ${bt(e)}`+(t?` (${l.toFixed(2)} remaining)`:"")),!this.playbackDisabled)if(a){const d=i.findAssetIndex(e.event,this.bufferedPos);e.event.assetList.forEach((c,u)=>{const h=this.getAssetPlayer(c.identifier);h&&(u===d&&h.loadSource(),h.resumeBuffering())})}else this.hls.resumeBuffering(),this.playerQueue.forEach(d=>d.pauseBuffering());this.hls.trigger(E.INTERSTITIALS_BUFFERED_TO_BOUNDARY,{events:n.slice(0),schedule:r.slice(0),bufferingIndex:this.findItemIndex(e),playingIndex:this.findItemIndex(this.playingItem)})}else this.bufferingItem!==e&&(this.bufferingItem=e);return t}bufferedToItem(e,t=0){const i=this.setBufferingItem(e);if(!this.playbackDisabled){if(this.isInterstitial(e))this.bufferedToEvent(e,t);else if(i!==null){this.bufferingAsset=null;const r=this.getPrimaryResumption(e,this.findItemIndex(e),!0),n=this.bufferedPos=Math.max(r,Math.min(this.bufferedPos,e.end),this.timelinePos,e.start),a=this.detachedData;a?a.mediaSource?this.attachPrimary(n,e,!0):this.startLoadingPrimaryAt(n):this.startLoadingPrimaryAt(n)}}}bufferedToEvent(e,t){const i=e.event,r=i.assetList.length===0&&!i.assetListLoader,n=i.cue.once;if(r||!n){const a=this.preloadAssets(i,t);if(a!=null&&a.interstitial.appendInPlace){const o=this.primaryMedia;o&&this.bufferAssetPlayer(a,o)}}}preloadAssets(e,t){const i=e.assetUrl,r=e.assetList.length,n=r===0&&!e.assetListLoader,a=e.cue.once;if(n){const l=e.timelineStart,d=this.playingItem,c=this.getBufferingPlayer();if(e.appendInPlace){var o;!this.isInterstitial(d)&&(d==null||(o=d.nextEvent)==null?void 0:o.identifier)===e.identifier&&this.flushFrontBuffer(l+.25)}let u,h=0;if((!c||c.interstitial.cue.pre)&&this.primaryLive&&(h=this.getLiveStartPos(),c&&(h+=c.remaining)),h&&!(e.cue.pre||e.cue.post)){const g=h-l;g>0&&(u=Math.round(g*1e3)/1e3)}if(this.log(`Load interstitial asset ${t+1}/${i?1:r} ${e}${h?` live-start: ${h} start-offset: ${u} (timeline-start: ${l})`:""}`),i)return this.createAsset(e,0,0,l,e.duration,i);const f=this.assetListLoader.loadAssetList(e,u);f&&(e.assetListLoader=f)}else if(!a&&r){for(let d=t;d<r;d++){const c=e.assetList[d],u=this.getAssetPlayerQueueIndex(c.identifier);(u===-1||this.playerQueue[u].destroyed)&&!c.error&&this.createAssetPlayer(e,c,d)}const l=e.assetList[t];if(l){const d=this.getAssetPlayer(l.identifier);return d&&d.loadSource(),d}}return null}flushFrontBuffer(e){const t=this.requiredTracks;if(!t)return;const i=this.primaryDetails;if(i&&e>=i.edge)return;this.log(`Removing front buffer starting at ${e}`),Object.keys(t).forEach(n=>{this.hls.trigger(E.BUFFER_FLUSHING,{startOffset:e,endOffset:1/0,type:n})})}getAssetPlayerQueueIndex(e){const t=this.playerQueue;for(let i=0;i<t.length;i++)if(e===t[i].assetId)return i;return-1}getAssetPlayer(e){const t=this.getAssetPlayerQueueIndex(e);return this.playerQueue[t]||null}getBufferingPlayer(){const{playerQueue:e,primaryMedia:t}=this;if(t){for(let i=0;i<e.length;i++)if(e[i].media===t)return e[i]}return null}createAsset(e,t,i,r,n,a){const o={parentIdentifier:e.identifier,identifier:_y(e,a,t),duration:n,startOffset:i,timelineStart:r,uri:a};return this.createAssetPlayer(e,o,t)}createAssetPlayer(e,t,i){const r=this.hls,n=r.userConfig,a=r.loadLevelObj||r.levels[r.currentLevel],o=Th(a,n.videoPreference),l=r.audioTracks[r.audioTrack],d=r.subtitleTracks[r.subtitleTrack];let c=0;if(this.primaryLive||e.appendInPlace){const S=this.timelinePos-t.timelineStart;if(S>=0){const A=t.duration;A&&S<A&&(c=S)}}const u=t.identifier,h=Z(Z({},n),{},{maxMaxBufferLength:Math.min(15,r.config.maxMaxBufferLength),autoStartLoad:!0,startFragPrefetch:!0,primarySessionId:r.sessionId,assetPlayerId:u,abrEwmaDefaultEstimate:r.bandwidthEstimate,interstitialsController:void 0,startPosition:c,liveDurationInfinity:!1,testBandwidth:!1,videoPreference:o,audioPreference:l||n.audioPreference,subtitlePreference:d||n.subtitlePreference});e.appendInPlace&&(e.appendInPlaceStarted=!0,t.timelineStart&&(h.timelineOffset=t.timelineStart));const f=h.cmcd;f!=null&&f.sessionId&&f.contentId&&(h.cmcd=Ie({},f,{contentId:sr(t.uri)})),this.getAssetPlayer(u)&&this.warn(`Duplicate date range identifier ${e} and asset ${u}`);const g=new Ry(this.HlsPlayerClass,h,e,t);this.playerQueue.push(g),e.assetList[i]=t;let m=!0;const p=S=>{if(S.live){const _=new Error(`Interstitials MUST be VOD assets ${e}`),R={fatal:!0,type:X.OTHER_ERROR,details:x.INTERSTITIAL_ASSET_ITEM_ERROR,error:_},D=this.findEventIndex(e.identifier);this.handleAssetItemError(R,e,D,i,_.message);return}const A=S.edge-S.fragmentStart,I=t.duration;(m||I===null||A>I)&&(m=!1,this.log(`Interstitial asset "${u}" duration change ${I} > ${A}`),t.duration=A,this.updateSchedule())};g.on(E.LEVEL_UPDATED,(S,{details:A})=>p(A)),g.on(E.LEVEL_PTS_UPDATED,(S,{details:A})=>p(A)),g.on(E.EVENT_CUE_ENTER,()=>this.onInterstitialCueEnter());const v=(S,A)=>{const I=this.getAssetPlayer(u);if(I&&A.tracks){I.off(E.BUFFER_CODECS,v),I.tracks=A.tracks;const _=this.primaryMedia;this.bufferingAsset===I.assetItem&&_&&!I.media&&this.bufferAssetPlayer(I,_)}};g.on(E.BUFFER_CODECS,v);const T=()=>{const S=this.getAssetPlayer(u);if(this.log(`buffered to end of asset ${S}`),!S||!this.schedule)return;const A=this.getEventItem(e.identifier);A&&this.advanceAssetBuffering(A,S.assetItem)};g.on(E.BUFFERED_TO_END,T);const y=S=>()=>{if(!this.getAssetPlayer(u)||!this.schedule)return;this.shouldPlay=!0;const I=this.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,I,S)};return g.once(E.MEDIA_ENDED,y(i)),g.once(E.PLAYOUT_LIMIT_REACHED,y(1/0)),g.on(E.ERROR,(S,A)=>{if(!this.schedule)return;const I=this.getAssetPlayer(u);if(A.details===x.BUFFER_STALLED_ERROR){if(I!=null&&I.appendInPlace){this.handleInPlaceStall(e);return}this.onTimeupdate(),this.checkBuffer(!0);return}else if(A.details===x.BUFFER_SEEK_OVER_HOLE)return;this.handleAssetItemError(A,e,this.findEventIndex(e.identifier),i,`Asset player error ${A.error} ${e}`)}),g.on(E.DESTROYING,()=>{if(!this.getAssetPlayer(u)||!this.schedule)return;const A=new Error(`Asset player destroyed unexpectedly ${u}`),I={fatal:!0,type:X.OTHER_ERROR,details:x.INTERSTITIAL_ASSET_ITEM_ERROR,error:A};this.handleAssetItemError(I,e,this.findEventIndex(e.identifier),i,A.message)}),this.log(`INTERSTITIAL_ASSET_PLAYER_CREATED ${ns(t)}`),this.hls.trigger(E.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:t,assetListIndex:i,event:e,player:g}),g}clearInterstitial(e,t){this.clearAssetPlayers(e,t),e.reset()}clearAssetPlayers(e,t){e.assetList.forEach(i=>{this.clearAssetPlayer(i.identifier,t)})}resetAssetPlayer(e){const t=this.getAssetPlayerQueueIndex(e);if(t!==-1){this.log(`reset asset player "${e}" after error`);const i=this.playerQueue[t];this.transferMediaFromPlayer(i,null),i.resetDetails()}}clearAssetPlayer(e,t){const i=this.getAssetPlayerQueueIndex(e);if(i!==-1){const r=this.playerQueue[i];this.log(`clear ${r} toSegment: ${t&&bt(t)}`),this.transferMediaFromPlayer(r,t),this.playerQueue.splice(i,1),r.destroy()}}emptyPlayerQueue(){let e;for(;e=this.playerQueue.pop();)e.destroy();this.playerQueue=[]}startAssetPlayer(e,t,i,r,n){const{interstitial:a,assetItem:o,assetId:l}=e,d=a.assetList.length,c=this.playingAsset;this.endedAsset=null,this.playingAsset=o,c?.identifier!==l&&(c&&(this.clearAssetPlayer(c.identifier,i[r]),delete c.error),this.log(`INTERSTITIAL_ASSET_STARTED ${t+1}/${d} ${ns(o)}`),this.hls.trigger(E.INTERSTITIAL_ASSET_STARTED,{asset:o,assetListIndex:t,event:a,schedule:i.slice(0),scheduleIndex:r,player:e})),this.bufferAssetPlayer(e,n)}bufferAssetPlayer(e,t){var i;if(!this.schedule)return;const{interstitial:r,assetItem:n}=e,a=this.getEventItem(r.identifier);if(!a)return;if(e.loadSource(),this.setBufferingItem(a),this.bufferingAsset=n,e.bufferedInPlaceToEnd(this.primaryMedia,e.currentTime)){this.advanceAssetBuffering(a,n);return}const o=this.getBufferingPlayer();if(o===e)return;const l=r.appendInPlace;if(l&&o?.interstitial.appendInPlace===!1)return;const d=o?.tracks||((i=this.detachedData)==null?void 0:i.tracks)||this.requiredTracks;if(l&&n!==this.playingAsset){if(!e.tracks){this.log(`Waiting for track info before buffering ${e}`);return}if(d&&!ju(d,e.tracks)){const c=new Error(`Asset ${ns(n)} SourceBuffer tracks ('${Object.keys(e.tracks)}') are not compatible with primary content tracks ('${Object.keys(d)}')`),u={fatal:!0,type:X.OTHER_ERROR,details:x.INTERSTITIAL_ASSET_ITEM_ERROR,error:c},h=r.findAssetIndex(n);this.handleAssetItemError(u,r,this.findEventIndex(r.identifier),h,c.message);return}}this.transferMediaTo(e,t)}handleInPlaceStall(e){const t=this.schedule,i=this.primaryMedia;if(!t||!i)return;const r=i.currentTime,n=t.findAssetIndex(e,r),a=e.assetList[n];if(a){const o=this.getAssetPlayer(a.identifier);if(o){const l=o.currentTime||r-a.timelineStart,d=o.duration-l;if(this.warn(`Stalled at ${l} of ${l+d} in ${o} ${e} (media.currentTime: ${r})`),l&&(d/i.playbackRate<.5||o.bufferedInPlaceToEnd(i,o.currentTime))&&o.hls){const c=t.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,c,n)}}}}advanceInPlace(e){const t=this.primaryMedia;if(t&&t.currentTime<e){const i=`advance currentTime to ${e}, duration: ${t.duration}`;t.duration>e?(this.log(i),t.currentTime=e):this.log(`Cannot ${i}`)}}handleAssetItemError(e,t,i,r,n){if(e.details===x.BUFFER_STALLED_ERROR)return;const a=t.assetList[r]||null;if(this.warn(`INTERSTITIAL_ASSET_ERROR ${a&&ns(a)} ${e.error}`),!this.schedule)return;const o=a?.identifier||"",l=this.getAssetPlayerQueueIndex(o),d=this.playerQueue[l]||null,c=this.schedule.items,u=Ie({},e,{fatal:!1,errorAction:er(!0),asset:a,assetListIndex:r,event:t,schedule:c,scheduleIndex:i,player:d});if(this.hls.trigger(E.INTERSTITIAL_ASSET_ERROR,u),!e.fatal)return;const h=this.playingAsset,f=this.bufferingAsset,g=new Error(n);if(a&&(this.clearAssetPlayer(o,null),a.error=g),!t.assetList.some(m=>!m.error))t.error=g;else for(let m=r;m<t.assetList.length;m++)this.resetAssetPlayer(t.assetList[m].identifier);this.updateSchedule(!0),t.error?this.primaryFallback(t):h?.identifier===o?this.advanceAfterAssetEnded(t,i,r):f?.identifier===o&&this.isInterstitial(this.bufferingItem)&&this.advanceAssetBuffering(this.bufferingItem,f)}primaryFallback(e){const t=e.timelineStart,i=this.effectivePlayingItem,r=this.playingItem,n=this.seekableStart,a=this.hls.startPosition;let o=this.timelinePos;if(this.isInterstitial(i)){this.log(`Fallback to primary from event "${e.identifier}" start: ${t} pos: ${o} playing: ${bt(i)} startPosition: ${a} seekableStart: ${n} error: ${e.error}`),o===-1&&(o=a),o=Math.max(o,n);const d=this.updateItem(i,o);this.itemsMatch(i,d)&&this.clearInterstitial(e,null),e.appendInPlace&&(this.attachPrimary(t,null),this.flushFrontBuffer(t))}else if(o===-1){this.checkStart();return}if(!this.schedule||!this.isInterstitial(r))return;const l=this.schedule.findItemIndexAtTime(o);this.setSchedulePosition(l)}onAssetListLoaded(e,t){var i,r;const n=t.event,a=n.identifier,o=t.assetListResponse.ASSETS;if(!((i=this.schedule)!=null&&i.hasEvent(a)))return;const l=n.timelineStart,d=n.duration;let c=0;o.forEach((g,m)=>{const p=parseFloat(g.DURATION);this.createAsset(n,m,c,l+c,p,g.URI),c+=p}),n.duration=c,this.log(`Loaded asset-list with duration: ${c} (was: ${d}) ${n}`);const u=this.waitingItem,h=u?.event.identifier===a;this.updateSchedule();const f=(r=this.bufferingItem)==null?void 0:r.event;if(h){const g=this.findEventIndex(a),m=this.getEventItem(a);if(m){if(!this.playingItem&&this.timelinePos>m.end&&this.schedule.findItemIndexAtTime(this.timelinePos)!==g){n.error=new Error(`Interstitial ${o.length?"no longer within playback range":"asset-list is empty"} ${this.timelinePos} ${n}`),this.log(n.error.message),this.updateSchedule(!0),this.primaryFallback(n);return}this.setBufferingItem(m)}this.setSchedulePosition(g)}else if(f?.identifier===a){const g=n.assetList[0];if(g){const m=this.getAssetPlayer(g.identifier);if(f.appendInPlace){const p=this.primaryMedia;m&&p&&this.bufferAssetPlayer(m,p)}else m&&m.loadSource()}}}onError(e,t){if(this.schedule)switch(t.details){case x.ASSET_LIST_PARSING_ERROR:case x.ASSET_LIST_LOAD_ERROR:case x.ASSET_LIST_LOAD_TIMEOUT:{const i=t.interstitial;i&&(this.updateSchedule(!0),this.primaryFallback(i));break}case x.BUFFER_STALLED_ERROR:{const i=this.endedItem||this.waitingItem||this.playingItem;if(this.isInterstitial(i)&&i.event.appendInPlace){this.handleInPlaceStall(i.event);return}const r=this.primaryMedia;this.log(`Primary player stall @${this.timelinePos} currentTime: ${r?.currentTime} bufferedPos: ${this.bufferedPos}`),this.onTimeupdate(),this.checkBuffer(!0);break}}}}class Py{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.currentTime=0,this.stallCount=0,this._latency=null,this._targetLatencyUpdated=!1,this.onTimeupdate=()=>{const{media:t}=this,i=this.levelDetails;if(!t||!i)return;this.currentTime=t.currentTime;const r=this.computeLatency();if(r===null)return;this._latency=r;const{lowLatencyMode:n,maxLiveSyncPlaybackRate:a}=this.config;if(!n||a===1||!i.live)return;const o=this.targetLatency;if(o===null)return;const l=r-o,d=Math.min(this.maxLatency,o+i.targetduration);if(l<d&&l>.05&&this.forwardBufferLength>1){const u=Math.min(2,Math.max(1,a)),h=Math.round(2/(1+Math.exp(-.75*l-this.edgeStalled))*20)/20,f=Math.min(u,Math.max(1,h));this.changeMediaPlaybackRate(t,f)}else t.playbackRate!==1&&t.playbackRate!==0&&this.changeMediaPlaybackRate(t,1)},this.hls=e,this.config=e.config,this.registerListeners()}get levelDetails(){var e;return((e=this.hls)==null?void 0:e.latestLevelDetails)||null}get latency(){return this._latency||0}get maxLatency(){const{config:e}=this;if(e.liveMaxLatencyDuration!==void 0)return e.liveMaxLatencyDuration;const t=this.levelDetails;return t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){const e=this.levelDetails;if(e===null||this.hls===null)return null;const{holdBack:t,partHoldBack:i,targetduration:r}=e,{liveSyncDuration:n,liveSyncDurationCount:a,lowLatencyMode:o}=this.config,l=this.hls.userConfig;let d=o&&i||t;(this._targetLatencyUpdated||l.liveSyncDuration||l.liveSyncDurationCount||d===0)&&(d=n!==void 0?n:a*r);const c=r;return d+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,c)}set targetLatency(e){this.stallCount=0,this.config.liveSyncDuration=e,this._targetLatencyUpdated=!0}get liveSyncPosition(){const e=this.estimateLiveEdge(),t=this.targetLatency;if(e===null||t===null)return null;const i=this.levelDetails;if(i===null)return null;const r=i.edge,n=e-t-this.edgeStalled,a=r-i.totalduration,o=r-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(a,n),o)}get drift(){const e=this.levelDetails;return e===null?1:e.drift}get edgeStalled(){const e=this.levelDetails;if(e===null)return 0;const t=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-t,0)}get forwardBufferLength(){const{media:e}=this,t=this.levelDetails;if(!e||!t)return 0;const i=e.buffered.length;return(i?e.buffered.end(i-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null}registerListeners(){const{hls:e}=this;e&&(e.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(E.ERROR,this.onError,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(E.ERROR,this.onError,this))}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.onTimeupdate)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null)}onManifestLoading(){this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){t.advanced&&this.onTimeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate)}onError(e,t){var i;t.details===x.BUFFER_STALLED_ERROR&&(this.stallCount++,this.hls&&(i=this.levelDetails)!=null&&i.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"))}changeMediaPlaybackRate(e,t){var i,r;e.playbackRate!==t&&((i=this.hls)==null||i.logger.debug(`[latency-controller]: latency=${this.latency.toFixed(3)}, targetLatency=${(r=this.targetLatency)==null?void 0:r.toFixed(3)}, forwardBufferLength=${this.forwardBufferLength.toFixed(3)}: adjusting playback rate from ${e.playbackRate} to ${t}`),e.playbackRate=t)}estimateLiveEdge(){const e=this.levelDetails;return e===null?null:e.edge+e.age}computeLatency(){const e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}}const Qc=500;class wy extends Dl{constructor(e,t,i){super(e,t,i,"subtitle-stream-controller",j.SUBTITLE),this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this.registerListeners()}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(E.LEVEL_LOADED,this.onLevelLoaded,this),e.on(E.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(E.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(E.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(E.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off(E.LEVEL_LOADED,this.onLevelLoaded,this),e.off(E.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(E.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(E.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(E.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this)}startLoad(e,t){this.stopLoad(),this.state=C.IDLE,this.setInterval(Qc),this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}onManifestLoading(){super.onManifestLoading(),this.mainDetails=null}onMediaDetaching(e,t){this.tracksBuffered=[],super.onMediaDetaching(e,t)}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){const{frag:i,part:r,success:n}=t;if(!n)return;const a=this.tracksBuffered[this.currentTrackId];if(!a)return;let o;const l=(r||i).start;for(let c=0;c<a.length;c++)if(l>=a[c].start&&l<=a[c].end){o=a[c];break}const d=l+(r||i).duration;if(o?o.end=d:(o={start:l,end:d},a.push(o)),!r||d>=i.end){const c=this.fragmentTracker.fragBuffered(i);r&&c&&(c.range.subs={time:[{startPTS:i.start,endPTS:d}],partial:!0}),Ue(i)&&!this.fragContextChanged(i)&&(this.fragPrevious=i),this.fragBufferedComplete(i,r),this.media&&this.tickImmediate()}}onBufferFlushing(e,t){const{startOffset:i,endOffset:r}=t;if(i===0&&r!==Number.POSITIVE_INFINITY){const n=r-1;if(n<=0)return;t.endOffsetSubtitles=Math.max(0,n),this.tracksBuffered.forEach(a=>{if(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(i,n,j.SUBTITLE)}}onError(e,t){const i=t.frag;i?.type===j.SUBTITLE&&(t.details===x.FRAG_GAP&&this.fragmentTracker.addAsGap(i),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==C.STOPPED&&(this.state=C.IDLE))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(this.levels&&of(this.levels,t)){this.levels=t.map(i=>new gr(i));return}this.tracksBuffered=[],this.levels=t.map(i=>{const r=new gr(i);return this.tracksBuffered[r.id]=[],r}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,j.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null}onSubtitleTrackSwitch(e,t){var i;if(this.currentTrackId=t.id,!((i=this.levels)!=null&&i.length)||this.currentTrackId===-1){this.clearInterval();return}const r=this.levels[this.currentTrackId];if(!(r!=null&&r.details)){this.mediaBuffer=null;return}this.mediaBuffer=this.mediaBufferTimeRanges,this.state!==C.STOPPED&&this.setInterval(Qc)}onSubtitleTrackLoaded(e,t){var i;const{currentTrackId:r,levels:n}=this,{details:a,id:o}=t;if(!n){this.warn(`Subtitle tracks were reset while loading level ${o}`);return}const 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;const d=this.mainDetails;let c=0;if(a.live||(i=l.details)!=null&&i.live){if(a.deltaUpdateFailed)return;if(!d){this.startFragRequested=!1;return}if(l.details){var u;c=this.alignPlaylists(a,l.details,(u=this.levelLastLoaded)==null?void 0:u.details)}a.alignedSliding||(qn(d,a,this),c=a.fragmentStart)}l.details=a,this.levelLastLoaded=l,d&&!this.startFragRequested&&this.setStartPosition(d,c),o===r&&(this.hls.trigger(E.SUBTITLE_TRACK_UPDATED,{details:a,id:o,groupId:t.groupId}),this.tickImmediate())}_handleFragmentLoadProgress(e){const{frag:t,part:i,payload:r}=e;!i||!(r!=null&&r.byteLength)||!this.shouldDecrypt(t)||this.decryptPayload(r,t,i)}_handleFragmentLoadComplete(e){const{frag:t,payload:i}=e;this.fragContextChanged(t)||!(i!=null&&i.byteLength)||!this.shouldDecrypt(t)||this.decryptPayload(i,t,null)}shouldDecrypt(e){const t=e.decryptdata;return!!(t!=null&&t.key&&t.iv&&ys(t.method))}decryptPayload(e,t,i){const r=t.decryptdata,n=performance.now();this.decrypter.decrypt(new Uint8Array(e),r.key.buffer,r.iv.buffer,xl(r.method)).then(a=>{this.fragContextChanged(t)||this.hls.trigger(E.FRAG_DECRYPTED,{frag:t,part:i,payload:a,stats:{tstart:n,tdecrypt:performance.now()}})}).catch(a=>{this.hls.trigger(E.ERROR,{type:X.MEDIA_ERROR,details:x.FRAG_DECRYPT_ERROR,fatal:!1,error:a,reason:a.message,frag:t,part:i}),i||(this.warn(`${a.name}: ${a.message}`),this.state=C.IDLE)})}doTick(){if(this.state===C.IDLE&&this.levels){var e;if(!this.media&&!this.primaryPrefetch&&(this.startFragRequested||!this.config.startFragPrefetch))return;const{currentTrackId:i,levels:r}=this,n=r[i],a=n?.details;if(!a||this.waitForLive(n)||this.waitForCdnTuneIn(a)){this.startFragRequested=!1;return}const{config:o}=this,l=this.playhead,d=ie.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],l,o.maxBufferHole),{end:c,len:u}=d,h=Math.max(this.hls.maxBufferLength+a.levelTargetDuration,((e=this.hls.mainForwardBufferInfo)==null?void 0:e.len)||0);if(u>h||u&&!this.buffering)return;let f=this.getNextFragment(c,a);if(!f)return;if(Ue(f)){var t;const g=f.sn-a.startSN,m=a.fragments[g-1];f.cc===m?.cc&&!((t=a.partList)!=null&&t.length)&&this.fragmentTracker.getState(m)===Ce.NOT_LOADED&&(f=m)}this.loadFragment(f,n,c)}}loadFragment(e,t,i){const r=this.fragmentTracker.getState(e);(r===Ce.NOT_LOADED||r===Ce.PARTIAL)&&super.loadFragment(e,t,i)}get mediaBufferTimeRanges(){return new My(this.tracksBuffered[this.currentTrackId]||[])}}class My{constructor(e){this.buffered=void 0;const t=(i,r,n)=>{if(r=r>>>0,r>n-1)throw new DOMException(`Failed to execute '${i}' on 'TimeRanges': The index provided (${r}) is greater than the maximum bound (${n})`);return e[r][i]};this.buffered={get length(){return e.length},end(i){return t("end",i,e.length)},start(i){return t("start",i,e.length)}}}}const Oy={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},Gf=s=>String.fromCharCode(Oy[s]||s),Ut=15,Nt=42,Fy={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Ny={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Uy={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},$y={25:2,26:4,29:6,30:8,31:10,27:13,28:15},By=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class Gy{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){const i=typeof t=="function"?t():t;Te.log(`${this.time} [${e}] ${i}`)}}}const Oi=function(e){const t=[];for(let i=0;i<e.length;i++)t.push(e[i].toString(16));return t},Ho=Object.freeze({foreground:"white",underline:!1,italics:!1,background:"black",flash:!1});class Vf{constructor(){this.styles=Ho}get foreground(){return this.styles.foreground}set foreground(e){const t=this.styles;this.styles={foreground:e,underline:t.underline,italics:t.italics,background:t.background,flash:t.flash}}get underline(){return this.styles.underline}set underline(e){const t=this.styles;this.styles={foreground:t.foreground,underline:e,italics:t.italics,background:t.background,flash:t.flash}}get italics(){return this.styles.italics}set italics(e){const t=this.styles;this.styles={foreground:t.foreground,underline:t.underline,italics:e,background:t.background,flash:t.flash}}get background(){return this.styles.background}set background(e){const t=this.styles;this.styles={foreground:t.foreground,underline:t.underline,italics:t.italics,background:e,flash:t.flash}}get flash(){return this.styles.flash}set flash(e){const t=this.styles;this.styles={foreground:t.foreground,underline:t.underline,italics:t.italics,background:t.background,flash:e}}reset(){this.styles=Ho}setStyles(e){const t=this.styles,i=Object.prototype.hasOwnProperty;this.styles={foreground:i.call(e,"foreground")?e.foreground:t.foreground,underline:i.call(e,"underline")?e.underline:t.underline,italics:i.call(e,"italics")?e.italics:t.italics,background:i.call(e,"background")?e.background:t.background,flash:i.call(e,"flash")?e.flash:t.flash}}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}class Vy{constructor(){this.uchar=" ",this.penState=new Vf}reset(){this.uchar=" ",this.penState.reset()}setChar(e,t){this.uchar=e,this.penState.styles=t.styles}setPenState(e){this.penState.styles=e.styles}copy(e){this.uchar=e.uchar,this.penState.styles=e.penState.styles}}class Hy{constructor(e){this.chars=[],this.pos=0,this.currPenState=new Vf,this.cueStartTime=null,this.logger=void 0;for(let t=0;t<Nt;t++)this.chars.push(new Vy);this.logger=e}equals(e){const t=this.chars,i=e.chars;for(let r=0;r<Nt;r++){const n=t[r],a=i[r];if(n.uchar!==a.uchar)return!1;const o=n.penState.styles,l=a.penState.styles;if(o!==l&&(o.foreground!==l.foreground||o.underline!==l.underline||o.italics!==l.italics||o.background!==l.background||o.flash!==l.flash))return!1}return!0}copy(e){for(let t=0;t<Nt;t++)this.chars[t].copy(e.chars[t])}isEmpty(){const e=this.chars;for(let t=0;t<Nt;t++){const i=e[t];if(i.uchar!==" ")return!1;const r=i.penState.styles;if(r!==Ho&&(r.foreground!=="white"||r.underline||r.italics||r.background!=="black"||r.flash))return!1}return!0}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>=Nt&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Nt-1)}moveCursor(e){const t=Math.min(this.pos+e,Nt);if(e>1)for(let i=this.pos+1;i<t;i++)this.chars[i].setPenState(this.currPenState);this.setCursor(t)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(e){e>=144&&this.backSpace();const t=Gf(e);if(this.pos>=Nt){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<Nt;t++)this.chars[t].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){const e=[];let t=!0;for(let i=0;i<Nt;i++){const r=this.chars[i].uchar;r!==" "&&(t=!1),e.push(r)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}}class Za{constructor(e){this.rows=[],this.currRow=Ut-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<Ut;t++)this.rows.push(new Hy(e));this.logger=e}reset(){for(let e=0;e<Ut;e++)this.rows[e].clear();this.currRow=Ut-1}equals(e){let t=!0;for(let i=0;i<Ut;i++)if(!this.rows[i].equals(e.rows[i])){t=!1;break}return t}copy(e){for(let t=0;t<Ut;t++){const i=this.rows[t].chars,r=e.rows[t].chars;for(let n=0;n<Nt;n++){const a=i[n],o=r[n];a.uchar=o.uchar,a.penState.styles=o.penState.styles}}}isEmpty(){let e=!0;for(let t=0;t<Ut;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 = "+Re(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<Ut;o++)this.rows[o].clear();const n=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){const 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;const i=this.rows[this.currRow];if(e.indent!==null){const n=e.indent,a=Math.max(n-1,0);i.setCursor(e.indent),e.color=i.chars[a].penState.foreground}const r={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(r)}setBkgData(e){this.logger.log(2,()=>"bkgData = "+Re(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());const 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;const t=[];let i="",r=-1;for(let n=0;n<Ut;n++){const a=this.rows[n].getTextString();a&&(r=n+1,e?t.push("Row "+r+": '"+a+"'"):t.push(a.trim()))}return t.length>0&&(e?i="["+t.join(" | ")+"]":i=t.join(`
84`)),i}getTextAndFormat(){return this.rows}}class Ky{constructor(e,t,i){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 Za(i),this.nonDisplayedMemory=new Za(i),this.lastOutputScreen=new Za(i),this.currRollUpRow=this.displayedMemory.rows[Ut-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=i}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[Ut-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 i=0;i<e.length;i++)this.writeScreen.insertChar(e[i]);const 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"){const 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){const t={flash:!1};if(t.underline=e%2===1,t.italics=e>=46,t.italics)t.foreground="white";else{const i=Math.floor(e/2)-16,r=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=r[i]}this.logger.log(2,"MIDROW: "+Re(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){const 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))}}class Xc{constructor(e,t,i){this.channels=[null,null,null],this.currentChannel=0,this.cmdHistory=Yy(),this.logger=void 0,this.field=void 0,this.outputFilters=void 0,this.logger=new Gy,this.field=e,this.outputFilters=[null,t,i]}getHandler(e){return this.outputFilters[e]}setHandler(e,t){var i;this.outputFilters[e]=t,(i=this.channels[e])==null||i.setHandler(t)}getChannel(e){let t=this.channels[e];return t||(t=this.channels[e]=new Ky(this.field+e-1,this.outputFilters[e],this.logger)),t}addData(e,t){this.logger.time=e;for(let i=0;i<t.length;i+=2){const r=t[i]&127,n=t[i+1]&127;let a=!1,o=null;if(r===0&&n===0)continue;this.logger.log(3,()=>"["+Oi([t[i],t[i+1]])+"] -> ("+Oi([r,n])+")");const l=this.cmdHistory;if(r>=16&&r<=31){if(Wy(r,n,l)){Yr(null,null,l),this.logger.log(3,()=>"Repeated command ("+Oi([r,n])+") is dropped");continue}Yr(r,n,this.cmdHistory),a=this.parseCmd(r,n),a||(a=this.parseMidrow(r,n)),a||(a=this.parsePAC(r,n)),a||(a=this.parseBackgroundAttributes(r,n))}else Yr(null,null,l);if(!a&&(o=this.parseChars(r,n),o)){const c=this.currentChannel;c&&c>0?this.getChannel(c).insertChars(o):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!a&&!o&&this.logger.log(2,()=>"Couldn't parse cleaned data "+Oi([r,n])+" orig: "+Oi([t[i],t[i+1]]))}}parseCmd(e,t){const i=(e===20||e===28||e===21||e===29)&&t>=32&&t<=47,r=(e===23||e===31)&&t>=33&&t<=35;if(!(i||r))return!1;const n=e===20||e===21||e===23?1:2,a=this.getChannel(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 i=0;if((e===17||e===25)&&t>=32&&t<=47){if(e===17?i=1:i=2,i!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const r=this.channels[i];return r?(r.ccMIDROW(t),this.logger.log(3,()=>"MIDROW ("+Oi([e,t])+")"),!0):!1}return!1}parsePAC(e,t){let i;const r=(e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127,n=(e===16||e===24)&&t>=64&&t<=95;if(!(r||n))return!1;const a=e<=23?1:2;return t>=64&&t<=95?i=a===1?Fy[e]:Uy[e]:i=a===1?Ny[e]:$y[e],this.getChannel(a).setPAC(this.interpretPAC(i,t)),this.currentChannel=a,!0}interpretPAC(e,t){let i;const r={color:null,italics:!1,indent:null,underline:!1,row:e};return t>95?i=t-96:i=t-64,r.underline=(i&1)===1,i<=13?r.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(r.italics=!0,r.color="white"):r.indent=Math.floor((i-16)/2)*4,r}parseChars(e,t){let i,r=null,n=null;if(e>=25?(i=2,n=e-8):(i=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 '"+Gf(a)+"' in channel "+i),r=[a]}else e>=32&&e<=127&&(r=t===0?[e]:[e,t]);return r&&this.logger.log(3,()=>"Char codes =  "+Oi(r).join(",")),r}parseBackgroundAttributes(e,t){const i=(e===16||e===24)&&t>=32&&t<=47,r=(e===23||e===31)&&t>=45&&t<=47;if(!(i||r))return!1;let n;const a={};e===16||e===24?(n=Math.floor((t-32)/2),a.background=By[n],t%2===1&&(a.background=a.background+"_semi")):t===45?a.background="transparent":(a.foreground="black",t===47&&(a.underline=!0));const o=e<=23?1:2;return this.getChannel(o).setBkgData(a),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){const t=this.channels[e];t&&t.reset()}Yr(null,null,this.cmdHistory)}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){const i=this.channels[t];i&&i.cueSplitAtTime(e)}}}function Yr(s,e,t){t.a=s,t.b=e}function Wy(s,e,t){return t.a===s&&t.b===e}function Yy(){return{a:null,b:null}}class qr{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,i){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}class qy{constructor(e){this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.cueCache={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Zc(),this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.cueCache={},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(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(E.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(E.FRAG_LOADING,this.onFragLoading,this),e.on(E.FRAG_LOADED,this.onFragLoaded,this),e.on(E.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(E.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(E.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(E.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(E.BUFFER_APPENDED,this.onBufferAppended,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(E.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(E.FRAG_LOADING,this.onFragLoading,this),e.off(E.FRAG_LOADED,this.onFragLoaded,this),e.off(E.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(E.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(E.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(E.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(E.BUFFER_APPENDED,this.onBufferAppended,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){const e=new qr(this,"textTrack1"),t=new qr(this,"textTrack2"),i=new qr(this,"textTrack3"),r=new qr(this,"textTrack4");this.cea608Parser1=new Xc(1,e,t),this.cea608Parser2=new Xc(3,i,r)}addCues(e,t,i,r,n){let a=!1;for(let l=n.length;l--;){const d=n[l],c=jy(d[0],d[1],t,i);if(c>=0&&(d[0]=Math.min(d[0],t),d[1]=Math.max(d[1],i),a=!0,c/(i-t)>.5))return}if(a||n.push([t,i]),this.config.renderTextTracksNatively){const l=this.cueCache[e];if(l){const d=this.Cues.newCue(null,t,i,r);d.length&&l.push.apply(l,d)}else{const d=this.captionsTracks[e].track;this.Cues.newCue(d,t,i,r)}}else{var o;const l=this.Cues.newCue(null,t,i,r),d=(o=this.captionsProperties[e])==null?void 0:o.media;this.hls.trigger(E.CUES_PARSED,{type:"captions",cues:l,track:e,closedCaptions:d})}}onInitPtsFound(e,{id:t,timestampOffsets:i}){const{unparsedVttFrags:r}=this;t===j.MAIN&&(this.initPTS=i),r.length&&(this.unparsedVttFrags=[],r.forEach(n=>{this.initPTS[n.frag.cc]?this.onFragLoaded(E.FRAG_LOADED,n):this.hls.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:n.frag,part:null,error:new Error("Subtitle discontinuity domain does not match main")})}))}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;const{captionsProperties:t,captionsTracks:i,cueCache:r,media:n}=this,{label:a,languageCode:o}=t[e];n&&(r[e]=[],i[e]=Wl(n,"captions",a,o,"hidden"))}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;const t=this.captionsProperties[e];if(!t)return;const i=t.label,r={_id:e,label:i,kind:"captions",default:t.media?!!t.media.default:!1,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=r,this.hls.trigger(E.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[r]})}onMediaAttaching(e,t){this.media=t.media}onMediaDetaching(e,t){const i=!!t.transferMedia;if(this.media=null,!i){if(this.config.renderTextTracksNatively){const{captionsTracks:r,cueCache:n}=this;for(const a in r)r[a].remove(),delete n[a]}this.cueCache={},this.captionsTracks={},this.nonNativeCaptionsTracks={}}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Zc(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}onSubtitleTracksUpdated(e,t){const i=t.subtitleTracks||[];if(i.length&&!this.config.renderTextTracksNatively&&!of(this.tracks,i)){const r=i.map(n=>({label:n.name,kind:n.type.toLowerCase(),default:n.default,subtitleTrack:n}));this.hls.trigger(E.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:r})}this.tracks=i}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(i=>{const r=/(?:CC|SERVICE)([1-4])/.exec(i.instreamId);if(!r)return;const n=`textTrack${r[1]}`,a=this.captionsProperties[n];a&&(a.label=i.name,i.lang&&(a.languageCode=i.lang),a.media=i)})}closedCaptionsForLevel(e){const t=this.hls.levels[e.level];return t?.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){if(this.enabled&&t.frag.type===j.MAIN){var i,r;const{cea608Parser1:n,cea608Parser2:a,lastSn:o}=this,{cc:l,sn:d}=t.frag,c=(i=(r=t.part)==null?void 0:r.index)!=null?i:-1;n&&a&&(d!==o+1||d===o&&c!==this.lastPartIndex+1||l!==this.lastCc)&&(n.reset(),a.reset()),this.lastCc=l,this.lastSn=d,this.lastPartIndex=c}}onFragLoaded(e,t){const{frag:i,payload:r}=t;if(i.level<this.tracks.length&&i.type===j.SUBTITLE)if(r.byteLength){const n=i.decryptdata,a="stats"in t;if(n==null||!n.encrypted||a){const o=this.tracks[i.level],l=this.vttCCs;l[i.cc]||(l[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),o?.textCodec===$o?this._parseIMSC1(t):this._parseVTTs(t)}}else{const n="part"in t?t.part:null;this.hls.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,part:n,error:new Error("Empty subtitle payload")})}}_parseIMSC1(e){const{frag:t,payload:i}=e,r="part"in e?e.part:null,n=this.hls;Vc(i,this.initPTS[t.cc],a=>{this._appendCues(a,t.level),n.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t,part:r})},a=>{n.logger.log(`Cannot parse IMSC1 (sn: ${t.sn} @${t.start}): ${a}`),n.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,part:r,error:a})})}_parseVTTs(e){var t;const{frag:i,payload:r}=e,n="part"in e?e.part:null,{initPTS:a,unparsedVttFrags:o}=this,l=a.length-1;if(!a[i.cc]&&l===-1){o.push(e);return}const d=this.hls,c=(t=i.initSegment)==null?void 0:t.data,u=c?Pt(c,new Uint8Array(r)).buffer:r;iy(u,this.initPTS[i.cc],this.vttCCs,i.cc,(n&&!c?n:i).start,h=>{this._appendCues(h,i.level),d.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i,part:n})},h=>{const f=h.message.startsWith("Missing initPTS");if(d.logger.log(`${f?"Deferred parsing of":"Cannot parse"} VTT cue (sn: ${i.sn} @${i.start}): ${h}`),f){o.push(e);return}else this.config.enableIMSC1&&this._fallbackToIMSC1(e);d.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,part:n,error:h})})}_fallbackToIMSC1(e){const{frag:t,payload:i}=e,r=this.tracks[t.level];r.textCodec||Vc(i,this.initPTS[t.cc],()=>{r.textCodec=$o,this._parseIMSC1(e)},()=>{r.textCodec="wvtt"})}_appendCues(e,t){const i=this.hls;if(this.config.renderTextTracksNatively){var r;const n=(r=this.tracks[t].trackNode)==null?void 0:r.track;if(!n||n.mode==="disabled")return;e.forEach(a=>Bo(n,a))}else{const n=this.tracks[t];if(!n)return;const a=n.default?"default":"subtitles"+t;i.trigger(E.CUES_PARSED,{type:"subtitles",cues:e,track:a,subtitleTrack:n})}}onFragDecrypted(e,t){const{frag:i}=t;i.type===j.SUBTITLE&&this.onFragLoaded(E.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){if(!this.enabled||!this.config.enableCEA708Captions)return;const{frag:i,samples:r}=t;if(!(i.type===j.MAIN&&this.closedCaptionsForLevel(i)==="NONE"))for(let n=0;n<r.length;n++){const a=r[n].bytes;if(a){this.cea608Parser1||this.initCea608Parsers();const o=this.extractCea608Data(a);this.cea608Parser1.addData(r[n].pts,o[0]),this.cea608Parser2.addData(r[n].pts,o[1])}}}onBufferAppended(e,t){if(this.config.renderTextTracksNatively){var i;const{type:r,timeRanges:n}=t;if(r==="video"&&(i=n[r])!=null&&i.length){const{captionsTracks:a,cueCache:o}=this;Object.keys(o).forEach(l=>{var d;const c=(d=a[l])==null?void 0:d.track;if(c){const u=o[l];for(let h=0;h<u.length;h++)Bo(c,u[h])}delete o[l]})}}}onBufferFlushing(e,t){const{startOffset:i,endOffset:r,endOffsetSubtitles:n,type:a}=t,{media:o}=this;if(!(!o||o.currentTime<r)){if(!a||a==="video"){const{captionsTracks:l,cueCache:d}=this;Object.keys(l).forEach(c=>Go(l[c].track,i,r)),Object.keys(d).forEach(c=>{const u=d[c];for(let h=u.length;h--;){const f=u[h];f.startTime>=i&&f.endTime<=r&&u.splice(h,1)}})}this.config.renderTextTracksNatively&&i===0&&n!==void 0&&this.tracks.forEach(l=>{var d;const c=(d=l.trackNode)==null?void 0:d.track;c&&Go(c,i,n)})}}extractCea608Data(e){const t=[[],[]],i=e[0]&31;let r=2;for(let n=0;n<i;n++){const a=e[r++],o=127&e[r++],l=127&e[r++];if(o===0&&l===0)continue;if((4&a)!==0){const c=3&a;(c===0||c===1)&&(t[c].push(o),t[c].push(l))}}return t}}function jy(s,e,t,i){return Math.min(e,i)-Math.max(s,t)}function Zc(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}const zy=/\s/,Qy={newCue(s,e,t,i){const r=[];let n,a,o,l,d;const c=self.VTTCue||self.TextTrackCue;for(let h=0;h<i.rows.length;h++)if(n=i.rows[h],o=!0,l=0,d="",!n.isEmpty()){var u;for(let m=0;m<n.chars.length;m++)zy.test(n.chars[m].uchar)&&o?l++:(d+=n.chars[m].uchar,o=!1);n.cueStartTime=e,e===t&&(t+=1e-4),l>=16?l--:l++;const f=Pf(d.trim()),g=Kl(e,t,f);s!=null&&(u=s.cues)!=null&&u.getCueById(g)||(a=new c(e,t,f),a.id=g,a.line=h+1,a.align="left",a.position=10+Math.min(80,Math.floor(l*8/32)*10),r.push(a))}return s&&r.length&&(r.sort((h,f)=>h.line==="auto"||f.line==="auto"?0:h.line>8&&f.line>8?f.line-h.line:h.line-f.line),r.forEach(h=>Bo(s,h))),r}};class Hf{constructor(){this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=0,this.config=null,this.callbacks=null,this.context=null,this.stats=new El}destroy(){this.callbacks=this.context=this.config=null,this.abortInternal(),this.stats=null}load(e,t,i){const r=this.stats;if(r.loading.start)throw new Error("Loader can only be used once.");r.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=i,this.loadInternal()}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.getNetworkDetails())}loadtimeout(){if(!this.config)return;const e=this.config.loadPolicy.timeoutRetry,t=this.stats.retry;if(lr(e,t,!0))this.retry(e);else{var i;Te.warn(`timeout while loading ${(i=this.context)==null?void 0:i.url}`);const r=this.callbacks;r&&(this.abortInternal(),r.onTimeout(this.stats,this.context,this.getNetworkDetails()))}}retry(e){const{context:t,stats:i}=this;this.retryDelay=vl(e,i.retry),i.retry++,Te.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${t?.url}, retrying ${i.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.resetInternalLoader(),self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(()=>this.loadInternal(),this.retryDelay)}}function Xy(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const Zy=/(\d+)-(\d+)\/(\d+)/;class Jc extends Hf{constructor(e){super(),this.fetchSetup=void 0,this.request=null,this.response=null,this.controller=null,this.fetchSetup=e.fetchSetup||iT}destroy(){this.request=null,super.destroy(),this.response=null,this.controller=null,this.fetchSetup=null}abortInternal(){self.clearTimeout(this.retryTimeout),this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}getNetworkDetails(){return this.response}resetInternalLoader(){this.response=null}loadInternal(){const{config:e,context:t,stats:i}=this;if(!e||!t)return;i.loading.first=0,i.loaded=0,i.aborted=!1,this.controller=new self.AbortController;const r=Jy(t,this.controller.signal),n=t.responseType==="arraybuffer",a=n?"byteLength":"length",{maxTimeToFirstByteMs:o,maxLoadTimeMs:l}=e.loadPolicy;this.request=this.fetchSetup(t,r),self.clearTimeout(this.requestTimeout),e.timeout=o&&B(o)?o:l,this.requestTimeout=self.setTimeout(()=>{this.loadtimeout()},e.timeout),(Er(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then(c=>{var u;this.response=c;const h=Math.max(self.performance.now(),i.loading.start);if(self.clearTimeout(this.requestTimeout),e.timeout=l,this.requestTimeout=self.setTimeout(()=>{this.loadtimeout()},l-(h-i.loading.start)),!c.ok){const{status:g,statusText:m}=c;throw new sT(m||"fetch, bad network response",g,c)}i.loading.first=h,i.total=tT(c.headers)||i.total;const f=(u=this.callbacks)==null?void 0:u.onProgress;return f&&B(e.highWaterMark)?this.loadProgressively(c,i,t,e.highWaterMark,f):n?c.arrayBuffer():t.responseType==="json"?c.json():c.text()}).then(c=>{var u,h;const f=this.response;if(!f)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),i.loading.end=Math.max(self.performance.now(),i.loading.first);const g=c[a];g&&(i.loaded=i.total=g);const m={url:f.url,data:c,code:f.status},p=(u=this.callbacks)==null?void 0:u.onProgress;p&&!B(e.highWaterMark)&&p(i,t,c,f),(h=this.callbacks)==null||h.onSuccess(m,i,t,f)}).catch(c=>{if(self.clearTimeout(this.requestTimeout),i.aborted)return;const u=c&&c.code||0,h=c?c.message:null,f=e.loadPolicy.errorRetry,g=i.retry,m={url:t.url,data:void 0,code:u};if(lr(f,g,!1,m))this.retry(f);else{var p;Te.error(`${u} while loading ${t.url}`),(p=this.callbacks)==null||p.onError({code:u,text:h},t,c?c.details:null,i)}})}getCacheAge(){let e=null;if(this.response){const 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,i,r=0,n){const a=new Vh,o=e.body.getReader(),l=()=>o.read().then(d=>{if(d.done)return a.dataLength&&n(t,i,a.flush().buffer,e),Promise.resolve(new ArrayBuffer(0));const c=d.value,u=c.length;return t.loaded+=u,u<r||a.dataLength?(a.push(c),a.dataLength>=r&&n(t,i,a.flush().buffer,e)):n(t,i,c.buffer,e),l()}).catch(()=>Promise.reject());return l()}}function Jy(s,e){const t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(Ie({},s.headers))};return s.rangeEnd&&t.headers.set("Range","bytes="+s.rangeStart+"-"+String(s.rangeEnd-1)),t}function eT(s){const e=Zy.exec(s);if(e)return parseInt(e[2])-parseInt(e[1])+1}function tT(s){const e=s.get("Content-Range");if(e){const i=eT(e);if(B(i))return i}const t=s.get("Content-Length");if(t)return parseInt(t)}function iT(s,e){return new self.Request(s.url,e)}class sT extends Error{constructor(e,t,i){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=i}}const rT=(s,e,t)=>Math.max(e,Math.min(s,t)),nT=/^age:\s*[\d.]+\s*$/im;class Kf extends Hf{constructor(e){super(),this.xhrSetup=void 0,this.loader=null,this.xhrSetup=e.xhrSetup||null}destroy(){super.destroy(),this.loader=null,this.xhrSetup=null}abortInternal(){const 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()))}getNetworkDetails(){return this.loader}resetInternalLoader(){this.loader=null}loadInternal(){const{config:e,context:t}=this;if(!e||!t)return;const i=this.loader=new self.XMLHttpRequest,r=this.stats;r.loading.first=0,r.loaded=0,r.aborted=!1;const n=this.xhrSetup;n?Promise.resolve().then(()=>{if(!(this.loader!==i||this.stats.aborted))return n.call(this,i,t.url,t)}).catch(a=>{if(!(this.loader!==i||this.stats.aborted))return i.open("GET",t.url,!0),n.call(this,i,t.url,t)}).then(()=>{this.loader!==i||this.stats.aborted||this.openAndSendXhr(i,t,e)}).catch(a=>{var o;(o=this.callbacks)==null||o.onError({code:i.status,text:a.message},t,i,r)}):this.openAndSendXhr(i,t,e)}openAndSendXhr(e,t,i){e.readyState||e.open("GET",t.url,!0);const r=t.headers,{maxTimeToFirstByteMs:n,maxLoadTimeMs:a}=i.loadPolicy;if(r)for(const o in r)e.setRequestHeader(o,r[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),i.timeout=n&&B(n)?n:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),e.send()}readystatechange(){const{context:e,loader:t,stats:i}=this;if(!e||!t)return;const r=t.readyState,n=this.config;if(!i.aborted&&r>=2&&(i.loading.first===0&&(i.loading.first=Math.max(self.performance.now(),i.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-(i.loading.first-i.loading.start)))),r===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;const d=t.status,c=t.responseType==="text"?t.responseText:null;if(d>=200&&d<300){const g=c??t.response;if(g!=null){var a,o;i.loading.end=Math.max(self.performance.now(),i.loading.first);const m=t.responseType==="arraybuffer"?g.byteLength:g.length;i.loaded=i.total=m,i.bwEstimate=i.total*8e3/(i.loading.end-i.loading.first);const p=(a=this.callbacks)==null?void 0:a.onProgress;p&&p(i,e,g,t);const v={url:t.responseURL,data:g,code:d};e.rangeEnd&&m!==e.rangeEnd-e.rangeStart&&Te.warn(`Payload length ${m} does not match requested Range: bytes=${e.rangeStart}-${e.rangeEnd-1}`),(o=this.callbacks)==null||o.onSuccess(v,i,e,t);return}}const u=n.loadPolicy.errorRetry,h=i.retry,f={url:e.url,data:void 0,code:d};if(lr(u,h,!1,f))this.retry(u);else{var l;Te.error(`${d} while loading ${e.url}`),(l=this.callbacks)==null||l.onError({code:d,text:t.statusText},e,t,i)}}}loadprogress(e){const t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&nT.test(this.loader.getAllResponseHeaders())){const 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}}const aT={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},oT=Z(Z({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,maxDevicePixelRatio:Number.POSITIVE_INFINITY,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,loopBackBufferFlush:void 0,startOnSegmentBoundary:!1,nextAudioTrackBufferFlushForwardOffset:.25,maxBufferSize:60*1e3*1e3,maxFragLookUpTolerance:.25,maxBufferHole:.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,nudgeOnVideoHole:!0,skipBufferHolePadding:.1,liveSyncMode:"edge",liveSyncDurationCount:3,liveSyncOnStallIncrease:1,liveMaxLatencyDurationCount:1/0,liveMaxUnchangedPlaylistRefresh:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftw
vendor: 4,403 bytes, line 84
84areAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,appendTimeout:1/0,ignorePlaylistParsingErrors:!1,loader:Kf,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,handleMpegTsVideoIntegrityErrors:"process",abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,abrSwitchInterval:0,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:Ph,requireKeySystemAccessOnStart:!1,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableEmsgKLVMetadata:!1,enableID3MetadataCues:!0,emsgKLVSchemaUri:void 0,enableInterstitialPlayback:!0,interstitialAppendInPlace:!0,interstitialLiveLookAhead:10,iframeCacheLimit:2*1024*1024,useMediaCapabilities:!0,preserveManualLevelOnError:!1,errorPenaltyExpireMs:0,certLoadPolicy:{default:aT},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}}},interstitialAssetListLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:3e4,timeoutRetry:{maxNumRetry:0,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:0,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,streamController:Uf,abrController:jp,bufferController:OE,capLevelController:Fl,errorController:Zp,fpsController:zv,id3TrackController:my,gapController:fy,latencyController:Py},lT()),{},{subtitleStreamController:wy,subtitleTrackController:uy,timelineController:qy,audioStreamController:kE,audioTrackController:CE,emeController:Ts,cmcdController:Hv,contentSteeringController:Wv,iframeController:Ay,interstitialsController:Cy});function lT(){return{cueHandler:Qy,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 dT(s,e,t){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"');
vendor: 8,747 bytes, line 84
84if(e.liveMaxUnchangedPlaylistRefresh!==void 0){const a=e.liveMaxUnchangedPlaylistRefresh,o=rT(a,2,1/0);o!==a&&t.warn(`hls.js config: "liveMaxUnchangedPlaylistRefresh" clamped from ${a} to ${o}.`),e.liveMaxUnchangedPlaylistRefresh=o}const i=Ko(s),r=["manifest","level","frag"],n=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return r.forEach(a=>{const o=`${a==="level"?"playlist":a}LoadPolicy`,l=e[o]===void 0,d=[];n.forEach(c=>{const u=`${a}Loading${c}`,h=e[u];if(h!==void 0&&l){d.push(u);const f=i[o].default;switch(e[o]={default:f},c){case"TimeOut":f.maxLoadTimeMs=h,f.maxTimeToFirstByteMs=h;break;case"MaxRetry":f.errorRetry.maxNumRetry=h,f.timeoutRetry.maxNumRetry=h;break;case"RetryDelay":f.errorRetry.retryDelayMs=h,f.timeoutRetry.retryDelayMs=h;break;case"MaxRetryTimeout":f.errorRetry.maxRetryDelayMs=h,f.timeoutRetry.maxRetryDelayMs=h;break}}}),d.length&&t.warn(`hls.js config: "${d.join('", "')}" setting(s) are deprecated, use "${o}": ${Re(e[o])}`)}),Z(Z({},i),e)}function Ko(s){return s&&typeof s=="object"?Array.isArray(s)?s.map(Ko):Object.keys(s).reduce((e,t)=>(e[t]=Ko(s[t]),e),{}):s}function cT(s,e){const t=s.loader;t!==Jc&&t!==Kf?(e.log("[config]: Custom loader detected, cannot enable progressive streaming"),s.progressive=!1):Xy()&&(s.loader=Jc,s.progressive=!0,s.enableSoftwareAES=!0,e.log("[config]: Progressive streaming enabled, using FetchLoader"))}class uT extends Ol{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.lastABRSwitchTime=-1,this._iframeVariants=[],this.onParsedComplete=void 0,this.steering=t,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(E.LEVEL_LOADED,this.onLevelLoaded,this),e.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this),e.on(E.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(E.LEVEL_LOADED,this.onLevelLoaded,this),e.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this),e.off(E.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,this._iframeVariants=[]}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){const i=this.hls.config.preferManagedMediaSource,r=[],n={},a={};let o=!1,l=!1,d=!1,c=!1;t.levels.forEach(u=>{const h=u.attrs,f=eu(u,i),{audioCodec:g,videoCodec:m,imageCodec:p,width:v,height:T}=u;if(!f){this.log(`Some or all CODECS not supported "${h.CODECS}"`);return}o||(o=!!(v&&T)),l||(l=!!m),d||(d=!!g),c||(c=!!p);const{CODECS:y,"FRAME-RATE":S,"HDCP-LEVEL":A,"PATHWAY-ID":I,RESOLUTION:_,"VIDEO-RANGE":R}=h,L=`${`${I||"."}-`}${u.bitrate}-${_}-${S}-${y}-${R}-${A}`;if(n[L])if(n[L].uri!==u.url&&!u.attrs["PATHWAY-ID"]){const k=a[L]+=1;u.attrs["PATHWAY-ID"]=new Array(k+1).join(".");const w=this.createLevel(u);n[L]=w,r.push(w)}else u.iframes||(n[L].addGroupId("audio",h.AUDIO),n[L].addGroupId("text",h.SUBTITLES));else{const k=this.createLevel(u);n[L]=k,a[L]=1,r.push(k)}}),this.filterAndSortMediaOptions(r,t,o,l,d,c)}createLevel(e){const t=new gr(e),i=e.supplemental;if(i!=null&&i.videoCodec&&!Yf(i.videoCodec,this.hls.config.preferManagedMediaSource)){const r=new Error(`SUPPLEMENTAL-CODECS not supported "${i.videoCodec}"`);this.log(r.message),t.supportedResult=mh(r,[])}return t}filterAndSortMediaOptions(e,t,i,r,n,a){var o;let l=[],d=[],c=e;const u=((o=t.stats)==null?void 0:o.parsing)||{},h=this.hls.config.preferManagedMediaSource;if((i||r)&&n&&(c=c.filter(({videoCodec:A,videoRange:I,width:_,height:R})=>(!!A||!!(_&&R))&&$p(I))),r&&a&&(c=c.filter(A=>!A.imageCodec)),c.length===0){Promise.resolve().then(()=>{if(this.hls){let A="no level with compatible codecs found in manifest",I=A;t.levels.length&&(I=`one or more CODECS in variant not supported: ${Re(t.levels.map(R=>R.attrs.CODECS).filter((R,D,L)=>L.indexOf(R)===D))}`,this.warn(I),A+=` (${I})`);const _=new Error(A);this.hls.trigger(E.ERROR,{type:X.MEDIA_ERROR,details:x.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:_,reason:I})}}),u.end=performance.now();return}t.audioTracks&&(l=t.audioTracks.filter(A=>!A.audioCodec||Wf(A.audioCodec,h)),tu(l)),t.subtitles&&(d=t.subtitles,tu(d));const f=c.slice(0);c.sort((A,I)=>{if(A.attrs["HDCP-LEVEL"]!==I.attrs["HDCP-LEVEL"])return(A.attrs["HDCP-LEVEL"]||"")>(I.attrs["HDCP-LEVEL"]||"")?1:-1;if(i&&A.height!==I.height)return A.height-I.height;if(A.frameRate!==I.frameRate)return A.frameRate-I.frameRate;if(A.videoRange!==I.videoRange)return Vn.indexOf(A.videoRange)-Vn.indexOf(I.videoRange);if(A.videoCodec!==I.videoCodec){const _=Fd(A.videoCodec),R=Fd(I.videoCodec);if(_!==R)return R-_}if(A.uri===I.uri&&A.codecSet!==I.codecSet){const _=Bn(A.codecSet),R=Bn(I.codecSet);if(_!==R)return R-_}return A.averageBitrate!==I.averageBitrate?A.averageBitrate-I.averageBitrate:0});let g=f[0];if(this.steering&&(c=this.steering.filterParsedLevels(c),c.length!==f.length)){for(let A=0;A<f.length;A++)if(f[A].pathwayId===c[0].pathwayId){g=f[A];break}}this._levels=c;for(let A=0;A<c.length;A++)if(c[A]===g){var m;this._firstLevel=A;const I=g.bitrate,_=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${c.length} level(s) found, first bitrate: ${I}`),((m=this.hls.userConfig)==null?void 0:m.abrEwmaDefaultEstimate)===void 0){const R=Math.min(I,this.hls.config.abrEwmaDefaultEstimateMax);R>_&&_===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=R)}break}const p=t.iframeVariants.filter(A=>eu(A,h));this._iframeVariants=p;const v=n&&!r,T=this.hls.config,y=!!(T.audioStreamController&&T.audioTrackController),S={levels:c,audioTracks:l,subtitleTracks:d,iframeVariants:p,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:n,video:r,altAudio:y&&!v&&l.some(A=>!!A.url)};u.end=performance.now(),this.hls.trigger(E.MANIFEST_PARSED,S)}get iframeVariants(){return this._iframeVariants.length===0?null:this._iframeVariants}get levels(){return this._levels.length===0?null:this._levels}get loadLevelObj(){return this.currentLevel}get level(){return this.currentLevelIndex}set level(e){const t=this._levels;if(t.length===0)return;if(e<0||e>=t.length){const c=new Error("invalid level idx"),u=e<0;if(this.hls.trigger(E.ERROR,{type:X.OTHER_ERROR,details:x.LEVEL_SWITCH_ERROR,level:e,fatal:u,error:c,reason:c.message}),u)return;e=Math.min(e,t.length-1)}const i=this.currentLevelIndex,r=this.currentLevel,n=r?r.attrs["PATHWAY-ID"]:void 0,a=t[e],o=a.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=a,i===e&&r&&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 ${i}${n?" with Pathway "+n:""}`);const 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(E.LEVEL_SWITCHING,l);const d=a.details;if(!d||d.live){const c=this.switchParams(a.uri,r?.details,d);this.loadPlaylist(c)}}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){const e=this.hls.config.startLevel;return e!==void 0?e:this.hls.firstAutoLevel}return this._startLevel}set startLevel(e){this._startLevel=e}get pathways(){return this.steering?this.steering.pathways():[]}get pathwayPriority(){return this.steering?this.steering.pathwayPriority:null}set pathwayPriority(e){if(this.steering){const t=this.steering.pathways(),i=e.filter(r=>t.indexOf(r)!==-1);if(e.length<1){this.warn(`pathwayPriority ${e} should contain at least one pathway from list: ${t}`);return}this.steering.pathwayPriority=i}}
vendor: 10,468 bytes, line 84
84onError(e,t){t.fatal||!t.context||t.context.type===ue.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(t.type===j.MAIN){const i=t.elementaryStreams;if(!Object.keys(i).some(n=>!!i[n]))return;const r=this._levels[t.level];r!=null&&r.loadError&&(this.log(`Resetting level error count of ${r.loadError} on frag buffered`),r.loadError=0)}}onLevelLoaded(e,t){var i;const{level:r,details:n}=t,a=t.levelInfo;if(!a){var o;this.warn(`Invalid level index ${r}`),(o=t.deliveryDirectives)!=null&&o.skip&&(n.deltaUpdateFailed=!0);return}if(a===this.currentLevel||t.withoutMultiVariant){a.fragmentError===0&&(a.loadError=0);let l=a.details;l===t.details&&l.advanced&&(l=void 0),this.playlistLoaded(r,t,l)}else(i=t.deliveryDirectives)!=null&&i.skip&&(n.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const i=this.getUrlWithDirectives(e.uri,t),r=this.currentLevelIndex,n=e.attrs["PATHWAY-ID"],a=e.details,o=a?.age;this.log(`Loading level index ${r}${t?.msn!==void 0?" at sn "+t.msn+" part "+t.part:""}${n?" Pathway "+n:""}${o&&a.live?" age "+o.toFixed(1)+(a.type&&" "+a.type||""):""} ${i}`),this.hls.trigger(E.LEVEL_LOADING,{url:i,level:r,levelInfo:e,pathwayId:e.attrs["PATHWAY-ID"],id:0,deliveryDirectives:t||null})}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){const t=this.currentLevelIndex;if(this.manualLevelIndex===-1&&e!==t&&e!==-1){const r=this.hls.config.abrSwitchInterval;if(r>0){const n=performance.now(),a=n-this.lastABRSwitchTime,o=r*1e3;if(this.lastABRSwitchTime>-1&&a<o){this.warn(`Preventing ABR level switch: ${t} -> ${e} (${Math.round(a)}ms < ${o}ms / ${r}s)`);return}this.lastABRSwitchTime=n,this.log(`Allowing ABR level switch: ${t} -> ${e} (${Math.round(a)}ms >= ${o}ms / ${r}s)`)}}this.level=e,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=e)}removeLevel(e){var t;if(this._levels.length===1)return;const i=this._levels.filter((n,a)=>a!==e?!0:(this.steering&&this.steering.removeLevel(n),n===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,n.details&&n.details.fragments.forEach(o=>o.level=-1)),!1));$h(i),this._levels=i,this.currentLevelIndex>-1&&(t=this.currentLevel)!=null&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);const r=i.length-1;this._firstLevel=Math.min(this._firstLevel,r),this._startLevel&&(this._startLevel=Math.min(this._startLevel,r)),this.hls.trigger(E.LEVELS_UPDATED,{levels:i})}onLevelsUpdated(e,{levels:t}){this._levels=t}checkMaxAutoUpdated(){const{autoLevelCapping:e,maxAutoLevel:t,maxHdcpLevel:i}=this.hls;this._maxAutoLevel!==t&&(this._maxAutoLevel=t,this.hls.trigger(E.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:i}))}}function Wf(s,e){return hr(s,"audio",e)}function Yf(s,e){return hr(s,"video",e)}function eu(s,e){let{audioCodec:t,videoCodec:i}=s;t&&(s.audioCodec=t=Gn(t,e)||void 0),i&&(i=s.videoCodec=kp(i));const{unknownCodecs:r}=s;return!(r?.length||0||t&&!Wf(t,e)||i&&!Yf(i,e))}function tu(s){const e={};s.forEach(t=>{const i=t.groupId||"";t.id=e[i]=e[i]||0,e[i]++})}class hT extends Dt{constructor(e,t){super("key-loader",t),this.config=void 0,this.keyLoaderInfo={},this.emeController=null,this.config=e}abort(e){for(const i in this.keyLoaderInfo){const r=this.keyLoaderInfo[i].loader;if(r){var t;if(e&&e!==((t=r.context)==null?void 0:t.frag.type))return;r.abort()}}}destroy(){for(const e in this.keyLoaderInfo){const t=this.keyLoaderInfo[e].loader;t&&t.destroy()}this.emeController=null,this.keyLoaderInfo={}}loadClear(e,t,i){return this.emeController?this.emeController.loadClear(e,t,i):null}load(e,t){return!e.decryptdata&&e.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(e).then(i=>this.loadInternal(e,t,i)):this.loadInternal(e,t)}loadInternal(e,t,i){i&&e.setKeyFormat(i);const r=e.decryptdata;if(!r){const a=new Error(i?`Expected frag.decryptdata to be defined after setting format ${i}`:`Missing decryption data on fragment in onKeyLoading (emeEnabled with controller: ${this.emeController&&this.config.emeEnabled})`);return Promise.reject(vi(e,x.KEY_LOAD_ERROR,a))}const n=e;switch(r.method){case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return r.keyFormat==="identity"?this.loadKeyHTTP(n):t?t.then(()=>this.loadKeyEME(n)):this.loadKeyEME(n);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(n);default:return Promise.reject(vi(e,x.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${r.method}"`)))}}loadKeyEME(e){if(this.emeController&&this.config.emeEnabled){var t;if(!e.decryptdata.keyId&&(t=e.initSegment)!=null&&t.data){const i=cp(e.initSegment.data);if(i.length){let r=i[0];const n=e.decryptdata.uri;if(r.some(a=>a!==0))this.log(`Using keyId found in init segment ${Ye(r)} keyUri: ${n}`),Ei.setKeyIdForUri(n,r);else{const a=Ei.addKeyIdForUri(n);this.log(`Patching empty keyId with ${Ye(a)} keyUri: ${n}`),r=a}e.decryptdata.keyId=r}}return this.emeController.loadKey(e).then(()=>({frag:e,keyInfo:{decryptdata:e.decryptdata}}))}return Promise.reject(vi(e,x.KEY_LOAD_ERROR,new Error(`emeEnabled with controller: ${this.emeController&&this.config.emeEnabled})`)))}loadKeyHTTP(e){const t=e.decryptdata,i=t.uri;if(!i)return Promise.reject(vi(e,x.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${i}"`)));const r=this.keyLoaderInfo[i];if(r){if(r.decryptdata.key)return t.key=r.decryptdata.key,r.keyLoadPromise=null,Promise.resolve({frag:e,keyInfo:r});if(r.keyLoadPromise)return r.keyLoadPromise.then(d=>(t.key=r.decryptdata.key,Z(Z({},d),{},{frag:e})))}this.log(`Loading${t.keyId?" keyId: "+Ye(t.keyId):""} URI: ${t.uri} from ${e.type} ${e.level}`);const n=this.config,a=n.loader,o=new a(n);e.keyLoader=o;const l=this.keyLoaderInfo[i]={decryptdata:t,keyLoadPromise:null,loader:o};return l.keyLoadPromise=new Promise((d,c)=>{const u={type:ue.KEY,keyInfo:l,frag:e,responseType:"arraybuffer",url:i},h=n.keyLoadPolicy.default,f={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},g={onSuccess:(m,p,v,T)=>{const{frag:y,keyInfo:S,url:A}=v;if(!y.decryptdata||S!==this.keyLoaderInfo[A])return c(vi(y,x.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),T));S.decryptdata.key=y.decryptdata.key=new Uint8Array(m.data),y.keyLoader=S.loader=S.keyLoadPromise=null,d({frag:y,keyInfo:S})},onError:(m,p,v,T)=>{this.resetLoader(p),c(vi(e,x.KEY_LOAD_ERROR,new Error(`HTTP Error ${m.code} loading key ${m.text}`),v,Z({url:i,data:void 0},m)))},onTimeout:(m,p,v)=>{this.resetLoader(p),c(vi(e,x.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),v))},onAbort:(m,p,v)=>{this.resetLoader(p),c(vi(e,x.INTERNAL_ABORTED,new Error("key loading aborted"),v))}};o.load(u,f,g)})}resetLoader(e){const{frag:t,keyInfo:i,url:r}=e,n=i.loader;t.keyLoader===n&&(t.keyLoader=i.loader=i.keyLoadPromise=null),delete this.keyLoaderInfo[r],n&&n.destroy()}}function vi(s,e=x.KEY_LOAD_ERROR,t,i,r){return new si({type:X.NETWORK_ERROR,details:e,fatal:!1,frag:s,response:r,error:t,networkDetails:i||null})}function iu(s){const{type:e}=s;switch(e){case ue.AUDIO_TRACK:return j.AUDIO;case ue.SUBTITLE_TRACK:return j.SUBTITLE;default:return j.MAIN}}function Ja(s,e){let t=s.url;return(t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}class fT{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:e}=this;e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.LEVEL_LOADING,this.onLevelLoading,this),e.on(E.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(E.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this)}unregisterListeners(){const{hls:e}=this;e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.LEVEL_LOADING,this.onLevelLoading,this),e.off(E.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(E.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this)}createInternalLoader(e){const t=this.hls.config,i=t.pLoader,r=t.loader,n=i||r,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(const e in this.loaders){const t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){const{url:i}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:ue.MANIFEST,url:i,deliveryDirectives:null,levelOrTrack:null})}onLevelLoading(e,t){const{id:i,level:r,pathwayId:n,url:a,deliveryDirectives:o,levelInfo:l}=t;this.load({id:i,level:r,pathwayId:n,responseType:"text",type:ue.LEVEL,url:a,deliveryDirectives:o,levelOrTrack:l})}onAudioTrackLoading(e,t){const{id:i,groupId:r,url:n,deliveryDirectives:a,track:o}=t;this.load({id:i,groupId:r,level:null,responseType:"text",type:ue.AUDIO_TRACK,url:n,deliveryDirectives:a,levelOrTrack:o})}onSubtitleTrackLoading(e,t){const{id:i,groupId:r,url:n,deliveryDirectives:a,track:o}=t;this.load({id:i,groupId:r,level:null,responseType:"text",type:ue.SUBTITLE_TRACK,url:n,deliveryDirectives:a,levelOrTrack:o})}onLevelsUpdated(e,t){const i=this.loaders[ue.LEVEL];if(i){const r=i.context;r&&!t.levels.some(n=>n===r.levelOrTrack)&&(i.abort(),delete this.loaders[ue.LEVEL])}}load(e){var t;const i=this.hls.config;let r=this.getInternalLoader(e);if(r){const d=this.hls.logger,c=r.context;if(c?.levelOrTrack===e.levelOrTrack&&(c.url===e.url||c.deliveryDirectives&&!e.deliveryDirectives)){c.url===e.url?d.log(`[playlist-loader]: ignore ${e.url} ongoing request`):d.log(`[playlist-loader]: ignore ${e.url} in favor of ${c.url}`);return}d.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),r.abort()}let n;if(e.type===ue.MANIFEST?n=i.manifestLoadPolicy.default:n=Ie({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),r=this.createInternalLoader(e),B((t=e.deliveryDirectives)==null?void 0:t.part)){let d;
vendor: 10,237 bytes, line 84
84if(e.type===ue.LEVEL&&e.level!==null?d=this.hls.levels[e.level].details:e.type===ue.AUDIO_TRACK&&e.id!==null?d=this.hls.audioTracks[e.id].details:e.type===ue.SUBTITLE_TRACK&&e.id!==null&&(d=this.hls.subtitleTracks[e.id].details),d){const c=d.partTarget,u=d.targetduration;if(c&&u){const h=Math.max(c*3,u*.8)*1e3;n=Ie({},n,{maxTimeToFirstByteMs:Math.min(h,n.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(h,n.maxTimeToFirstByteMs)})}}}const 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,c,u,h)=>{const f=this.getInternalLoader(u);this.resetInternalLoader(u.type);const g=d.data;c.parsing.start=performance.now(),ai.isMediaPlaylist(g)||u.type!==ue.MANIFEST?this.handleTrackOrLevelPlaylist(d,c,u,h||null,f):this.handleMasterPlaylist(d,c,u,h)},onError:(d,c,u,h)=>{this.handleNetworkError(c,u,!1,d,h)},onTimeout:(d,c,u)=>{this.handleNetworkError(c,u,!0,void 0,d)}};r.load(e,o,l)}checkAutostartLoad(){if(!this.hls)return;const{config:{autoStartLoad:e,startPosition:t},forceStartLoad:i}=this.hls;(e||i)&&(this.hls.logger.log(`${e?"auto":"force"} startLoad with configured startPosition ${t}`),this.hls.startLoad(t))}handleMasterPlaylist(e,t,i,r){const n=this.hls,a=e.data,o=Ja(e,i),l=ai.parseMasterPlaylist(a,o);if(l.playlistParsingError){t.parsing.end=performance.now(),this.handleManifestParsingError(e,i,l.playlistParsingError,r,t);return}const{contentSteering:d,levels:c,iframeVariants:u,sessionData:h,sessionKeys:f,startTimeOffset:g,variableList:m}=l;this.variableList=m,c.forEach(y=>{const{unknownCodecs:S}=y;if(S){const{preferManagedMediaSource:A}=this.hls.config;let{audioCodec:I,videoCodec:_}=y;for(let R=S.length;R--;){const D=S[R];hr(D,"audio",A)?(y.audioCodec=I=I?`${I},${D}`:D,bs.audio[I.substring(0,4)]=2,S.splice(R,1)):hr(D,"video",A)&&(y.videoCodec=_=_?`${_},${D}`:D,bs.video[_.substring(0,4)]=2,S.splice(R,1))}}});const{AUDIO:p=[],SUBTITLES:v,"CLOSED-CAPTIONS":T}=ai.parseMasterPlaylistMedia(a,o,l);p.length&&!p.some(S=>!S.url)&&c[0].audioCodec&&!c[0].attrs.AUDIO&&(this.hls.logger.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(E.MANIFEST_LOADED,{levels:c,audioTracks:p,subtitles:v,iframeVariants:u,captions:T,contentSteering:d,url:o,stats:t,networkDetails:r,sessionData:h,sessionKeys:f,startTimeOffset:g,variableList:m})}handleTrackOrLevelPlaylist(e,t,i,r,n){const a=this.hls,{id:o,level:l,type:d}=i,c=Ja(e,i),u=B(l)?l:B(o)?o:0,h=iu(i),f=ai.parseLevelPlaylist(e.data,c,u,h,0,this.variableList);if(d===ue.MANIFEST){const g={attrs:new ke({}),bitrate:0,details:f,name:"",url:c};f.requestScheduled=t.loading.start+Fh(f,0),a.trigger(E.MANIFEST_LOADED,{levels:[g],audioTracks:[],iframeVariants:[],url:c,stats:t,networkDetails:r,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),i.levelDetails=f,this.handlePlaylistLoaded(f,e,t,i,r,n)}handleManifestParsingError(e,t,i,r,n){this.hls.trigger(E.ERROR,{type:X.NETWORK_ERROR,details:x.MANIFEST_PARSING_ERROR,fatal:t.type===ue.MANIFEST,url:e.url,err:i,error:i,reason:i.message,response:e,context:t,networkDetails:r,stats:n})}handleNetworkError(e,t,i=!1,r,n){let a=`A network ${i?"timeout":"error"+(r?" (status "+r.code+")":"")} occurred while loading ${e.type}`;e.type===ue.LEVEL?a+=`: ${e.level} id: ${e.id}`:(e.type===ue.AUDIO_TRACK||e.type===ue.SUBTITLE_TRACK)&&(a+=` id: ${e.id} group-id: "${e.groupId}"`);const o=new Error(a);this.hls.logger.warn(`[playlist-loader]: ${a}`);let l=x.UNKNOWN,d=!1;const c=this.getInternalLoader(e);switch(e.type){case ue.MANIFEST:l=i?x.MANIFEST_LOAD_TIMEOUT:x.MANIFEST_LOAD_ERROR,d=!0;break;case ue.LEVEL:l=i?x.LEVEL_LOAD_TIMEOUT:x.LEVEL_LOAD_ERROR,d=!1;break;case ue.AUDIO_TRACK:l=i?x.AUDIO_TRACK_LOAD_TIMEOUT:x.AUDIO_TRACK_LOAD_ERROR,d=!1;break;case ue.SUBTITLE_TRACK:l=i?x.SUBTITLE_TRACK_LOAD_TIMEOUT:x.SUBTITLE_LOAD_ERROR,d=!1;break}c&&this.resetInternalLoader(e.type);const u={type:X.NETWORK_ERROR,details:l,fatal:d,url:e.url,loader:c,context:e,error:o,networkDetails:t,stats:n};if(r){let h=e.url;t&&"url"in t&&(h=t.url),u.response=Z({url:h,data:void 0},r)}this.hls.trigger(E.ERROR,u)}handlePlaylistLoaded(e,t,i,r,n,a){const o=this.hls,{type:l,level:d,levelOrTrack:c,id:u,groupId:h,deliveryDirectives:f}=r,g=Ja(t,r),m=iu(r);let p=typeof r.level=="number"&&m===j.MAIN?d:void 0;c&&"iframes"in c&&c.iframes&&!e.iframesOnly&&(e.playlistParsingError=new Error("EXT-X-I-FRAME-STREAM-INF media playlist MUST contain an EXT-X-I-FRAMES-ONLY tag"),e.iframesOnly=!0);const v=e.playlistParsingError;if(v){if(this.hls.logger.warn(`${v} ${e.url}`),!o.config.ignorePlaylistParsingErrors){o.trigger(E.ERROR,{type:X.NETWORK_ERROR,details:x.LEVEL_PARSING_ERROR,fatal:!1,url:g,error:v,reason:v.message,response:t,context:r,level:p,parent:m,networkDetails:n,stats:i});return}e.playlistParsingError=null}if(!e.fragments.length){const T=e.playlistParsingError=new Error("No Segments found in Playlist");o.trigger(E.ERROR,{type:X.NETWORK_ERROR,details:x.LEVEL_EMPTY_ERROR,fatal:!1,url:g,error:T,reason:T.message,response:t,context:r,level:p,parent:m,networkDetails:n,stats:i});return}switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),(!a.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),l){case ue.MANIFEST:case ue.LEVEL:if(p){if(!c)p=0;else if(c!==o.levels[p]){const T=o.levels.indexOf(c);T>-1&&(p=T)}}o.trigger(E.LEVEL_LOADED,{details:e,levelInfo:c||o.levels[0],level:p||0,id:u||0,stats:i,networkDetails:n,deliveryDirectives:f,withoutMultiVariant:l===ue.MANIFEST,context:r});break;case ue.AUDIO_TRACK:o.trigger(E.AUDIO_TRACK_LOADED,{details:e,track:c,id:u||0,groupId:h||"",stats:i,networkDetails:n,deliveryDirectives:f,context:r});break;case ue.SUBTITLE_TRACK:o.trigger(E.SUBTITLE_TRACK_LOADED,{details:e,track:c,id:u||0,groupId:h||"",stats:i,networkDetails:n,deliveryDirectives:f,context:r});break}}}class gt{static get version(){return pr}static isMSESupported(){return Nf()}static isSupported(){return py()}static getMediaSource(){return ki()}static get Events(){return E}static get MetadataSchema(){return mt}static get ErrorTypes(){return X}static get ErrorDetails(){return x}static get DefaultConfig(){return gt.defaultConfig?gt.defaultConfig:oT}static set DefaultConfig(e){gt.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.logger=void 0,this._url=null,this.streamController=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new kl,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.audioStreamController=void 0,this.subtititleStreamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.iframeController=void 0,this.gapController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this._sessionId=void 0,this.triggeringException=void 0,this.started=!1;const t=this.logger=Nm(e.debug||!1,"Hls instance",e.loggerId||e.assetPlayerId),i=this.config=dT(gt.DefaultConfig,e,t);this.userConfig=e,i.progressive&&cT(i,t);const{streamController:r,abrController:n,bufferController:a,capLevelController:o,errorController:l,fpsController:d,id3TrackController:c,iframeController:u,gapController:h}=i,f=new l(this),g=this.abrController=new n(this),m=new Jp(this),p=i.interstitialsController,v=p?this.interstitialsController=new p(this,gt):null,T=a?this.bufferController=new a(this,m):null,y=o?this.capLevelController=new o(this):null,S=d?new d(this):null,A=i.cmcdController,I=A?this.cmcdController=new A(this):null,_=new fT(this),R=i.contentSteeringController,D=R?new R(this):null,L=this.levelController=new uT(this,D),k=c?new c(this):void 0,w=new hT(this.config,this.logger),U=this.streamController=new r(this,m,w),K=this.gapController=h?new h(this,m):void 0;y&&y.setStreamController(U);const G=[_,L,U];v&&G.splice(1,0,v),D&&G.splice(1,0,D),this.networkControllers=G;const O=[g];T&&O.push(T),K&&O.push(K),y&&O.push(y),S&&(S.setStreamController(U),O.push(S)),k&&O.push(k),O.push(m),this.audioTrackController=this.createController(i.audioTrackController,G);const F=i.audioStreamController;F&&G.push(this.audioStreamController=new F(this,m,w)),this.subtitleTrackController=this.createController(i.subtitleTrackController,G);const M=i.subtitleStreamController;M&&G.push(this.subtititleStreamController=new M(this,m,w)),this.createController(i.timelineController,O),w.emeController=this.emeController=this.createController(i.emeController,O),I&&O.push(I),this.latencyController=this.createController(i.latencyController,O),this.coreComponents=O,this.iframeController=u?new u(this,gt):void 0,G.push(f);const $=f.onErrorOut;typeof $=="function"&&this.on(E.ERROR,$,f),this.on(E.MANIFEST_LOADED,_.onManifestLoaded,_)}createController(e,t){if(e){const i=new e(this);return t&&t.push(i),i}return null}on(e,t,i=this){this._emitter.on(e,t,i)}once(e,t,i=this){this._emitter.once(e,t,i)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,i=this,r){this._emitter.off(e,t,i,r)}listeners(e){return this._emitter.listeners(e)}emit(e,t,i){return this._emitter.emit(e,t,i)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(i){if(this.logger.error("An internal error happened while handling event "+e+'. Error message: "'+i.message+'". Here is a stacktrace:',i),!this.triggeringException){this.triggeringException=!0;const r=e===E.ERROR;this.trigger(E.ERROR,{type:X.OTHER_ERROR,details:x.INTERNAL_EXCEPTION,fatal:r,event:e,error:i}),this.triggeringException=!1}}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){this.logger.log("destroy"),this.trigger(E.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=>
vendor: 6,518 bytes, line 84
84t.destroy()),this.coreComponents.length=0,this.iframeController=void 0;const e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){if(!e||"media"in e&&!e.media){const n=new Error(`attachMedia failed: invalid argument (${e})`);this.trigger(E.ERROR,{type:X.OTHER_ERROR,details:x.ATTACH_MEDIA_ERROR,fatal:!0,error:n});return}this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());const t="media"in e,i=t?e.media:e,r=t?e:{media:i};this._media=i,this.trigger(E.MEDIA_ATTACHING,r)}detachMedia(){this.logger.log("detachMedia");const e={};this.trigger(E.MEDIA_DETACHING,e),this._media=null,this.trigger(E.MEDIA_DETACHED,e)}transferMedia(){var e;this._media=null;const t=((e=this.bufferController)==null?void 0:e.transferMedia())||null,i={transferMedia:t};return this.trigger(E.MEDIA_DETACHING,i),this.trigger(E.MEDIA_DETACHED,i),t}loadSource(e){var t;this.stopLoad();const i=this.media,r=this._url,n=this._url=pl.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log(`loadSource:${n}`),i&&r&&(r!==n||(t=this.bufferController)!=null&&t.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(i)),this.trigger(E.MANIFEST_LOADING,{url:e})}get url(){return this._url}get hasEnoughToStart(){return this.streamController.hasEnoughToStart}get startPosition(){return this.streamController.startPositionValue}startLoad(e=-1,t){this.logger.log(`startLoad(${e+(t?", <skip seek to start>":"")})`),this.started=!0,this.resumeBuffering();for(let i=0;i<this.networkControllers.length&&(this.networkControllers[i].startLoad(e,t),!(!this.started||!this.networkControllers));i++);}stopLoad(){this.logger.log("stopLoad"),this.started=!1;for(let e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!(this.started||!this.networkControllers));e++);}get loadingEnabled(){return this.started&&this.streamController.state!==C.STOPPED}get bufferingEnabled(){return this.streamController.bufferingEnabled}resumeBuffering(){this.bufferingEnabled||(this.logger.log("resume buffering"),this.networkControllers.forEach(e=>{e.resumeBuffering&&e.resumeBuffering()}))}pauseBuffering(){this.bufferingEnabled&&(this.logger.log("pause buffering"),this.networkControllers.forEach(e=>{e.pauseBuffering&&e.pauseBuffering()}))}get inFlightFragments(){const e={[j.MAIN]:this.streamController.inFlightFrag};return this.audioStreamController&&(e[j.AUDIO]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[j.SUBTITLE]=this.subtititleStreamController.inFlightFrag),e}swapAudioCodec(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){this.logger.log("recoverMediaError");const e=this._media,t=this.started,i=e?.currentTime;this.detachMedia(),e&&(this.attachMedia(e),t&&(i?this.startLoad(i):this.config.autoStartLoad||this.startLoad()))}removeLevel(e){this.levelController.removeLevel(e)}get sessionId(){let e=this._sessionId;return e||(e=this._sessionId=Qu()),e}get levels(){const e=this.levelController.levels;return e||[]}get latestLevelDetails(){return this.streamController.getLevelDetails()||null}get loadLevelObj(){return this.levelController.loadLevelObj}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){this.logger.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){this.logger.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){this.logger.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){this.logger.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){const e=this.levelController.startLevel;return e===-1&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e}set startLevel(e){this.logger.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){const t=this.capLevelController,i=!!e;t&&i!==this.config.capLevelToPlayerSize&&(i?t.startCapping():(t.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=i)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}set bandwidthEstimate(e){this.abrController.resetEstimator(e)}get abrEwmaDefaultEstimate(){const{bwEstimator:e}=this.abrController;return e?e.defaultEstimate:NaN}get ttfbEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(this.logger.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){Up(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(){const{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;const i=e.length;for(let r=0;r<i;r++)if(e[r].maxBitrate>=t)return r;return 0}get maxAutoLevel(){const{levels:e,autoLevelCapping:t,maxHdcpLevel:i}=this;let r;if(t===-1&&e!=null&&e.length?r=e.length-1:r=t,i)for(let n=r;n--;){const a=e[n].attrs["HDCP-LEVEL"];if(a&&a<=i)return n}return r}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()}get audioForwardBufferInfo(){var e;return((e=this.audioStreamController)==null?void 0:e.getFwdBufferInfo())||null}get maxBufferLength(){return this.streamController.maxBufferLength}setAudioOption(e){var t;return((t=this.audioTrackController)==null?void 0:t.setAudioOption(e))||null}
vendor: 2,338 bytes, line 84
84setSubtitleOption(e){var t;return((t=this.subtitleTrackController)==null?void 0:t.setSubtitleOption(e))||null}get allAudioTracks(){const e=this.audioTrackController;return e?e.allAudioTracks:[]}get audioTracks(){const e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){const e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){const t=this.audioTrackController;t&&(t.audioTrack=e)}get nextAudioTrack(){var e,t;return(e=(t=this.audioStreamController)==null?void 0:t.nextAudioTrack)!=null?e:-1}set nextAudioTrack(e){const{audioTrackController:t}=this;t&&(t.nextAudioTrack=e)}get allSubtitleTracks(){const e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}get subtitleTracks(){const e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){const e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){const t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){const e=this.subtitleTrackController;return e?e.subtitleDisplay:!1}set subtitleDisplay(e){const t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){var e,t;return(e=(t=this.latencyController)==null?void 0:t.liveSyncPosition)!=null?e:null}get latency(){var e;return((e=this.latencyController)==null?void 0:e.latency)||0}get maxLatency(){var e;return((e=this.latencyController)==null?void 0:e.maxLatency)||0}get targetLatency(){var e;return((e=this.latencyController)==null?void 0:e.targetLatency)||null}set targetLatency(e){this.latencyController&&(this.latencyController.targetLatency=e)}get drift(){var e;return((e=this.latencyController)==null?void 0:e.drift)||null}get forceStartLoad(){return this.streamController.forceStartLoad}get pathways(){return this.levelController.pathways}get pathwayPriority(){return this.levelController.pathwayPriority}set pathwayPriority(e){this.levelController.pathwayPriority=e}get bufferedToEnd(){var e;return!!((e=this.bufferController)!=null&&e.bufferedToEnd)}get interstitialsManager(){return this.interstitialsController?this.interstitialsController.interstitialsManager:null}get iframeVariants(){const e=this.levelController.iframeVariants;return e||[]}
84createIFramePlayer(e){return this._url&&this.iframeController?this.iframeController.createIFramePlayer(e):null}createImageIFramePlayer(e){return this._url&&this.iframeController?this.iframeController.createImageIFramePlayer(e):null}getMediaDecodingInfo(e,t=this.allAudioTracks){const i=yh(t);return ph(e,i,navigator.mediaCapabilities)}}gt.defaultConfig=void 0;const gT=s=>class extends s{static shadowRootOptions={...s.shadowRootOptions};static getTemplateHTML=(t,i={})=>{const{src:r,...n}=t;return`
85        <script type="application/json" id="config">
86          ${JSON.stringify(i.config||{})}
87        <\/script>
88        ${s.getTemplateHTML(n)}
89      `};#e=null;#t=null;constructor(){super(),this.#r("config")}get config(){return this.#t}set config(t){this.#t=t}attributeChangedCallback(t,i,r){t!=="src"&&super.attributeChangedCallback(t,i,r),t==="src"&&i!=r&&this.load()}#i(){var t,i;(t=this.#e)==null||t.remove(),(i=this.nativeEl)==null||i.removeEventListener("webkitcurrentplaybacktargetiswirelesschanged",this.#s),this.api&&(this.api.detachMedia(),this.api.destroy(),this.api=null)}async load(){var t,i;const r=!this.api;if(this.#i(),!!this.src){if(r&&!this.#t&&(this.#t=JSON.parse(((t=this.shadowRoot.getElementById("config"))==null?void 0:t.textContent)||"{}")),gt.isSupported()){switch(this.api=new gt({liveDurationInfinity:!0,autoStartLoad:!1,...this.config}),await Promise.resolve(),this.api.loadSource(this.src),this.api.attachMedia(this.nativeEl),this.nativeEl.preload){case"none":{const l=()=>this.api.startLoad();this.nativeEl.addEventListener("play",l,{once:!0}),this.api.on(gt.Events.DESTROYING,()=>{this.nativeEl.removeEventListener("play",l)});break}case"metadata":{const l=this.api.config.maxBufferLength,d=this.api.config.maxBufferSize;this.api.config.maxBufferLength=1,this.api.config.maxBufferSize=1;const c=()=>{this.api.config.maxBufferLength=l,this.api.config.maxBufferSize=d};this.nativeEl.addEventListener("play",c,{once:!0}),this.api.on(gt.Events.DESTROYING,()=>{this.nativeEl.removeEventListener("play",c)}),this.api.startLoad();break}default:this.api.startLoad()}this.nativeEl.webkitCurrentPlaybackTargetIsWireless&&this.api.stopLoad(),this.nativeEl.addEventListener("webkitcurrentplaybacktargetiswirelesschanged",this.#s),this.#e=document.createElement("source"),this.#e.setAttribute("type","application/x-mpegURL"),this.#e.setAttribute("src",this.src),this.nativeEl.disableRemotePlayback=!1,this.nativeEl.append(this.#e);const n=new WeakMap;this.api.on(gt.Events.MANIFEST_PARSED,(l,d)=>{this.nativeEl.autoplay&&this.nativeEl.paused&&this.nativeEl.play().catch(u=>{console.warn("Autoplay failed:",u)}),o();let c=this.videoTracks.getTrackById("main");c||(c=this.addVideoTrack("main"),c.id="main",c.selected=!0);for(const[u,h]of d.levels.entries()){const f=c.addRendition(h.url[0],h.width,h.height,h.videoCodec,h.bitrate);n.set(h,`${u}`),f.id=`${u}`}for(let[u,h]of d.audioTracks.entries()){const f=h.default?"main":"alternative",g=this.addAudioTrack(f,h.name,h.lang);g.id=`${u}`,h.default&&(g.enabled=!0)}}),this.audioTracks.addEventListener("change",()=>{var l;const d=+((l=[...this.audioTracks].find(u=>u.enabled))==null?void 0:l.id),c=this.api.audioTracks.map(u=>u.id);d!=this.api.audioTrack&&c.includes(d)&&(this.api.audioTrack=d)}),this.api.on(gt.Events.LEVELS_UPDATED,(l,d)=>{const c=this.videoTracks[this.videoTracks.selectedIndex??0];if(!c)return;const u=d.levels.map(h=>n.get(h));for(const h of this.videoRenditions)h.id&&!u.includes(h.id)&&c.removeRendition(h)});const a=l=>{const d=l.target.selectedIndex;d!=this.api.nextLevel&&(this.api.nextLevel=d)};(i=this.videoRenditions)==null||i.addEventListener("change",a);const o=()=>{for(const l of this.videoTracks)this.removeVideoTrack(l);for(const l of this.audioTracks)this.removeAudioTrack(l)};this.api.once(gt.Events.DESTROYING,o);return}await Promise.resolve(),this.nativeEl.canPlayType("application/vnd.apple.mpegurl")&&(this.nativeEl.src=this.src)}}#s=()=>{var t,i,r;(t=this.nativeEl)!=null&&t.webkitCurrentPlaybackTargetIsWireless?(i=this.api)==null||i.stopLoad():(r=this.api)==null||r.startLoad()};#r(t){if(Object.prototype.hasOwnProperty.call(this,t)){const i=this[t];delete this[t],this[t]=i}}},mT=gT(Tm(lm));globalThis.customElements&&!globalThis.customElements.get("hls-video")&&globalThis.customElements.define("hls-video",mT);const ee={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:"mediash
89owtexttracksrequest",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"},be={MEDIA_CHROME_ATTRIBUTES:"mediachromeattributes",MEDIA_CONTROLLER:"mediacontroller"},qf={MEDIA_AIRPLAY_UNAVAILABLE:"mediaAirplayUnavailable",MEDIA_AUDIO_TRACK_ENABLED:"mediaAudioTrackEnabled",MEDIA_AUDIO_TRACK_LIST:"mediaAudioTrackList",MEDIA_AUDIO_TRACK_UNAVAILABLE:"mediaAudioTrackUnavailable",MEDIA_BUFFERED:"mediaBuffered",MEDIA_CAST_UNAVAILABLE:"mediaCastUnavailable",MEDIA_CHAPTERS_CUES:"mediaChaptersCues",MEDIA_CURRENT_TIME:"mediaCurrentTime",MEDIA_DURATION:"mediaDuration",MEDIA_ENDED:"mediaEnded",MEDIA_ERROR:"mediaError",MEDIA_ERROR_CODE:"mediaErrorCode",MEDIA_ERROR_MESSAGE:"mediaErrorMessage",MEDIA_FULLSCREEN_UNAVAILABLE:"mediaFullscreenUnavailable",MEDIA_HAS_P
89LAYED:"mediaHasPlayed",MEDIA_HEIGHT:"mediaHeight",MEDIA_IS_AIRPLAYING:"mediaIsAirplaying",MEDIA_IS_CASTING:"mediaIsCasting",MEDIA_IS_FULLSCREEN:"mediaIsFullscreen",MEDIA_IS_PIP:"mediaIsPip",MEDIA_LOADING:"mediaLoading",MEDIA_MUTED:"mediaMuted",MEDIA_PAUSED:"mediaPaused",MEDIA_PIP_UNAVAILABLE:"mediaPipUnavailable",MEDIA_PLAYBACK_RATE:"mediaPlaybackRate",MEDIA_PREVIEW_CHAPTER:"mediaPreviewChapter",MEDIA_PREVIEW_COORDS:"mediaPreviewCoords",MEDIA_PREVIEW_IMAGE:"mediaPreviewImage",MEDIA_PREVIEW_TIME:"mediaPreviewTime",MEDIA_RENDITION_LIST:"mediaRenditionList",MEDIA_RENDITION_SELECTED:"mediaRenditionSelected",MEDIA_RENDITION_UNAVAILABLE:"mediaRenditionUnavailable",MEDIA_SEEKABLE:"mediaSeekable",MEDIA_STREAM_TYPE:"mediaStreamType",MEDIA_SUBTITLES_LIST:"mediaSubtitlesList",MEDIA_SUBTITLES_SHOWING:"mediaSubtitlesShowing",MEDIA_TARGET_LIVE_WINDOW:"mediaTargetLiveWindow",MEDIA_TIME_IS_LIVE:"mediaTimeIsLive",MEDIA_VOLUME:"mediaVolume",MEDIA_VOLUME_LEVEL:"mediaVolumeLevel",MEDIA_VOLUME_UNAVAILABLE:"mediaVolumeUnavailable",MEDIA_LANG:"mediaLang",MEDIA_WIDTH:"mediaWidth"},jf=Object.entries(qf),b=jf.reduce((s,[e,t])=>(s[e]=t.toLowerCase(),s),{}),pT={USER_INACTIVE_CHANGE:"userinactivechange",BREAKPOINTS_CHANGE:"breakpointchange",BREAKPOINTS_COMPUTED:"breakpointscomputed"},Ls=jf.reduce((s,[e,t])=>(s[e]=t.toLowerCase(),s),{...pT});Object.entries(Ls).reduce((s,[e,t])=>{const i=b[e];return i&&(s[t]=i),s},{userinactivechange:"userinactive"});const ET=Object.entries(b).reduce((s,[e,t])=>{const i=Ls[e];return i&&(s[t]=i),s},{userinactive:"userinactivechange"}),oi={SUBTITLES:"subtitles",CAPTIONS:"captions",CHAPTERS:"chapters",METADATA:"metadata"},As={DISABLED:"disabled",SHOWING:"showing"},su={MOUSE:"mouse",TOUCH:"touch"},kt={UNAVAILABLE:"unavailable",UNSUPPORTED:"unsupported"},mi={LIVE:"live",ON_DEMAND:"on-demand",UNKNOWN:"unknown"},vT={FULLSCREEN:"fullscreen"};function yT(s){return s?.map(TT).join(" ")}function TT(s){if(s){const{id:e,width:t,height:i}=s;return[e,t,i].filter(r=>r!=null).join(":")}}function ST(s){return s?.map(AT).join(" ")}function AT(s){if(s){const{id:e,kind:t,language:i,label:r}=s;return[e,t,i,r].filter(n=>n!=null).join(":")}}function Yl(s){return typeof s=="number"&&!Number.isNaN(s)&&Number.isFinite(s)}const zf=s=>new Promise(e=>setTimeout(e,s)),ru=[{singular:"hour",plural:"hours"},{singular:"minute",plural:"minutes"},{singular:"second",plural:"seconds"}],bT=(s,e)=>{const t=s===1?ru[e].singular:ru[e].plural;return`${s} ${t}`},rr=s=>{if(!Yl(s))return"";const e=Math.abs(s),t=e!==s,i=new Date(0,0,0,0,0,e,0);return`${[i.getHours(),i.getMinutes(),i.getSeconds()].map((o,l)=>o&&bT(o,l)).filter(o=>o).join(", ")}${t?" remaining":""}`};function Di(s,e){let t=!1;s<0&&(t=!0,s=0-s),s=s<0?0:s;let i=Math.floor(s%60),r=Math.floor(s/60%60),n=Math.floor(s/3600);const a=Math.floor(e/60%60),o=Math.floor(e/3600);return(isNaN(s)||s===1/0)&&(n=r=i="0"),n=n>0||o>0?n+":":"",r=((n||a>=10)&&r<10?"0"+r:r)+":",i=i<10?"0"+i:i,(t?"-":"")+n+r+i}const IT={"Start airplay":"Start airplay","Stop airplay":"Stop airplay",Audio:"Audio",Captions:"Captions","Enable captions":"Enable captions","Disable captions":"Disable captions","Start casting":"Start casting","Stop casting":"Stop casting","Enter fullscreen mode":"Enter fullscreen mode","Exit fullscreen mode":"Exit fullscreen mode",Mute:"Mute",Unmute:"Unmute","Enter picture in picture mode":"Enter picture in picture mode","Exit picture in picture mode":"Exit picture in picture mode",Play:"Play",Pause:"Pause","Playback rate":"Playback rate","Playback rate {playbackRate}":"Playback rate {playbackRate}",Quality:"Quality","Seek backward":"Seek backward","Seek forward":"Seek forward",Settings:"Settings",Auto:"Auto","audio player":"audio player","video player":"video player",volume:"volume",seek:"seek","closed captions":"closed captions","current playback rate":"current playback rate","playback time":"playback time","media loading":"media loading",settings:"settings","audio tracks":"audio tracks",quality:"quality",play:"play",pause:"pause",mute:"mute",unmute:"unmute","chapter: {chapterName}":"chapter: {chapterName}",live:"live",Off:"Off","start airplay":"start airplay","stop airplay":"stop airplay","start casting":"start casting","stop casting":"stop casting","enter fullscreen mode":"enter fullscreen mode","exit fullscreen mode":"exit fullscreen mode","enter picture in picture mode":"enter picture in picture mode","exit picture in picture mode":"exit picture in picture mode","seek to live":"seek to live","playing live":"playing live","seek back {seekOffset} seconds":"seek back {seekOffset} seconds","seek forward {seekOffset} seconds":"seek forward {seekOffset} seconds","Network Error":"Network Error","Decode Error":"Decode Error","S
89ource Not Supported":"Source Not Supported","Encryption Error":"Encryption Error","A network error caused the media download to fail.":"A network error caused the media download to fail.","A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.":"A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.","An unsupported error occurred. The server or network failed, or your browser does not support this format.":"An unsupported error occurred. The server or network failed, or your browser does not support this format.","The media is encrypted and there are no keys to decrypt it.":"The media is encrypted and there are no keys to decrypt it."};var nu;const eo={en:IT};let Wo=((nu=globalThis.navigator)==null?void 0:nu.language)||"en";const _T=s=>{Wo=s},LT=s=>{var e,t,i;const[r]=Wo.split("-");return((e=eo[Wo])==null?void 0:e[s])||((t=eo[r])==null?void 0:t[s])||((i=eo.en)==null?void 0:i[s])||s},ne=(s,e={})=>LT(s).replace(/\{(\w+)\}/g,(t,i)=>i in e?String(e[i]):`{${i}}`);let Qf=class{addEventListener(){}removeEventListener(){}dispatchEvent(){return!0}};class Xf extends Qf{}class au extends Xf{constructor(){super(...arguments),this.role=null}}class xT{observe(){}unobserve(){}disconnect(){}}const Zf={createElement:function(){return new Tr.HTMLElement},createElementNS:function(){return new Tr.HTMLElement},addEventListener(){},removeEventListener(){},dispatchEvent(s){return!1}},Tr={ResizeObserver:xT,document:Zf,Node:Xf,Element:au,HTMLElement:class extends au{constructor(){super(...arguments),this.innerHTML=""}get content(){return new Tr.DocumentFragment}},DocumentFragment:class extends Qf{},customElements:{get:function(){},define:function(){},whenDefined:function(){}},localStorage:{getItem(s){return null},setItem(s,e){},removeItem(s){}},CustomEvent:function(){},getComputedStyle:function(){},navigator:{languages:[],get userAgent(){return""}},matchMedia(s){return{matches:!1,media:s}},DOMParser:class{parseFromString(e,t){return{body:{textContent:e}}}}},Jf=typeof window>"u"||typeof window.customElements>"u",eg=Object.keys(Tr).every(s=>s in globalThis),P=Jf&&!eg?Tr:globalThis,yt=Jf&&!eg?Zf:globalThis.document,ou=new WeakMap,ql=s=>{let e=ou.get(s);return e||ou.set(s,e=new Set),e},tg=new P.ResizeObserver(s=>{for(const e of s)for(const t of ql(e.target))t(e)});function ig(s,e){ql(s).add(e),tg.observe(s)}function sg(s,e){const t=ql(s);t.delete(e),t.size||tg.unobserve(s)}function Gt(s){const e={};for(const t of s)e[t.name]=t.value;return e}function RT(s){var e;return(e=DT(s))!=null?e:kr(s,"media-controller")}function DT(s){var e;const{MEDIA_CONTROLLER:t}=be,i=s.getAttribute(t);if(i)return(e=CT(s))==null?void 0:e.getElementById(i)}const rg=(s,e,t=".value")=>{const i=s.querySelector(t);i&&(i.textContent=e)},kT=(s,e)=>{const t=`slot[name="${e}"]`,i=s.shadowRoot.querySelector(t);return i?i.children:[]},ng=(s,e)=>kT(s,e)[0],ks=(s,e)=>!s||!e?!1:s?.contains(e)?!0:ks(s,e.getRootNode().host),kr=(s,e)=>{if(!s)return null;const t=s.closest(e);return t||kr(s.getRootNode().host,e)};function ag(s=document){var e;const t=s?.activeElement;return t?(e=ag(t.shadowRoot))!=null?e:t:null}function CT(s){var e;const t=(e=s?.getRootNode)==null?void 0:e.call(s);return t instanceof ShadowRoot||t instanceof Document?t:null}function og(s,{depth:e=3,checkOpacity:t=!0,checkVisibilityCSS:i=!0}={}){if(s.checkVisibility)return s.checkVisibility({checkOpacity:t,checkVisibilityCSS:i});let r=s;for(;r&&e>0;){const n=getComputedStyle(r);if(t&&n.opacity==="0"||i&&n.visibility==="hidden"||n.display==="none")return!1;r=r.parentElement,e--}return!0}function PT(s,e,t,i){const r=i.x-t.x,n=i.y-t.y,a=r*r+n*n;if(a===0)return 0;const o=((s-t.x)*r+(e-t.y)*n)/a;return Math.max(0,Math.min(1,o))}function qe(s,e){const t=wT(s,i=>i===e);return t||MT(s,e)}function wT(s,e){var t,i;let r;for(r of(t=s.querySelectorAll("style:not([media])"))!=null?t:[]){let n;try{n=(i=r.sheet)==null?void 0:i.cssRules}catch{continue}for(const a of n??[])if(e(a.selectorText))return a}}function MT(s,e){var t,i;const r=(t=s.querySelectorAll("style:not([media])"))!=null?t:[],n=r?.[r.length-1];return n?.sheet?(n?.sheet.insertRule(`${e}{}`,n.sheet.cssRules.length),(i=n.sheet.cssRules)==null?void 0:i[n.sheet.cssRules.length-1]):(console.warn("Media Chrome: No style sheet found on style tag of",s),{style:{setProperty:()=>{},removeProperty:()=>"",getPropertyValue:()=>""}})}function $e(s,e,t=Number.NaN){const i=s.getAttribute(e);return i!=null?+i:t}function tt(s,e,t){const i=+t;if(t==null||Number.isNaN(i)){s.hasAttribute(e)&&s.removeAttribute(e);return}$e(s,e,void 0)!==i&&s.setAttribute(e,`${i}`)}function Ee(s,e){return s.hasAttribute(e)}function ve(s,e,t){if(t==null){s.hasAttribute(e)&&s.removeAttribute(e);return}Ee(s,e)!=t&&s.toggleAttribute(e,t)}function Be(s,e,t=null){var i;return(i=s.getAttribute(e))!=null?i:t}function Ge(s,e,t){if(t==null){s.hasAttribute(e)&&s.removeAttribute(e);return}const i=`${t}`;Be(s,e,void 0)!==i&&s.setAttribute(e,i)}var lg=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},yi=(s,e,t)=>(lg(s,e,"read from private field"),t?t.call(s):e.get(s)),OT=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},jr=(s,e,t,i)=>(lg(s,e,"write to private field"),e.set(s,t),t),vt;function FT(s){return`
90    <style>
91      :host {
92        display: var(--media-control-display, var(--media-gesture-receiver-display, inline-block));
93        box-sizing: border-box;
94      }
95    </style>
96  `}class va extends P.HTMLElement{constructor(){if(super(),OT(this,vt,void 0),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);const e=Gt(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}}static get observedAttributes(){return[be.MEDIA_CONTROLLER,b.MEDIA_PAUSED]}attributeChangedCallback(e,t,i){var r,n,a,o,l;e===be.MEDIA_CONTROLLER&&(t&&((n=(r=yi(this,vt))==null?void 0:r.unassociateElement)==null||n.call(r,this),jr(this,vt,null)),i&&this.isConnected&&(jr(this,vt,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(l=(o=yi(this,vt))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,i,r;this.tabIndex=-1,this.setAttribute("aria-hidden","true"),jr(this,vt,NT(this)),this.getAttribute(be.MEDIA_CONTROLLER)&&((t=(e=yi(this,vt))==null?void 0:e.associateElement)==null||t.call(e,this)),(i=yi(this,vt))==null||i.addEventListener("pointerdown",this),(r=yi(this,vt))==null||r.addEventListener("click",this)}disconnectedCallback(){var e,t,i,r;this.getAttribute(be.MEDIA_CONTROLLER)&&((t=(e=yi(this,vt))==null?void 0:e.unassociateElement)==null||t.call(e,this)),(i=yi(this,vt))==null||i.removeEventListener("pointerdown",this),(r=yi(this,vt))==null||r.removeEventListener("click",this),jr(this,vt,null)}handleEvent(e){var t;const i=(t=e.composedPath())==null?void 0:t[0];if(["video","media-controller"].includes(i?.localName)){if(e.type==="pointerdown")this._pointerType=e.pointerType;else if(e.type==="click"){const{clientX:n,clientY:a}=e,{left:o,top:l,width:d,height:c}=this.getBoundingClientRect(),u=n-o,h=a-l;if(u<0||h<0||u>d||h>
96c||d===0&&c===0)return;const{pointerType:f=this._pointerType}=e;if(this._pointerType=void 0,f===su.TOUCH){this.handleTap(e);return}else if(f===su.MOUSE){this.handleMouseClick(e);return}}}}get mediaPaused(){return Ee(this,b.MEDIA_PAUSED)}set mediaPaused(e){ve(this,b.MEDIA_PAUSED,e)}handleTap(e){}handleMouseClick(e){const t=this.mediaPaused?ee.MEDIA_PLAY_REQUEST:ee.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new P.CustomEvent(t,{composed:!0,bubbles:!0}))}}vt=new WeakMap;va.shadowRootOptions={mode:"open"};va.getTemplateHTML=FT;function NT(s){var e;const t=s.getAttribute(be.MEDIA_CONTROLLER);return t?(e=s.getRootNode())==null?void 0:e.getElementById(t):kr(s,"media-controller")}P.customElements.get("media-gesture-receiver")||P.customElements.define("media-gesture-receiver",va);var lu=va,jl=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},xt=(s,e,t)=>(jl(s,e,"read from private field"),t?t.call(s):e.get(s)),It=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},Ui=(s,e,t,i)=>(jl(s,e,"write to private field"),e.set(s,t),t),Ct=(s,e,t)=>(jl(s,e,"access private method"),t),Jn,as,Sr,Es,gn,Yo,dg,Hs,mn,qo,cg,jo,ug,Ar,ya,Ta,zl,xs,br;const ae={AUDIO:"audio",AUTOHIDE:"autohide",BREAKPOINTS:"breakpoints",GESTURES_DISABLED:"gesturesdisabled",KEYBOARD_CONTROL:"keyboardcontrol",NO_AUTOHIDE:"noautohide",USER_INACTIVE:"userinactive",AUTOHIDE_OVER_CONTROLS:"autohideovercontrols"};function UT(s){return`
97    <style>
98      
99      :host([${b.MEDIA_IS_FULLSCREEN}]) ::slotted([slot=media]) {
100        outline: none;
101      }
102
103      :host {
104        box-sizing: border-box;
105        position: relative;
106        display: inline-block;
107        line-height: 0;
108        background-color: var(--media-background-color, #000);
109      }
110
111      :host(:not([${ae.AUDIO}])) [part~=layer]:not([part~=media-layer]) {
112        position: absolute;
113        top: 0;
114        left: 0;
115        bottom: 0;
116        right: 0;
117        display: flex;
118        flex-flow: column nowrap;
119        align-items: start;
120        pointer-events: none;
121        background: none;
122      }
123
124      slot[name=media] {
125        display: var(--media-slot-display, contents);
126      }
127
128      
129      :host([${ae.AUDIO}]) slot[name=media] {
130        display: var(--media-slot-display, none);
131      }
132
133      
134      :host([${ae.AUDIO}]) [part~=layer][part~=gesture-layer] {
135        height: 0;
136        display: block;
137      }
138
139      
140      :host(:not([${ae.AUDIO}])[${ae.GESTURES_DISABLED}]) ::slotted([slot=gestures-chrome]),
141          :host(:not([${ae.AUDIO}])[${ae.GESTURES_DISABLED}]) media-gesture-receiver[slot=gestures-chrome] {
142        display: none;
143      }
144
145      
146      ::slotted(:not([slot=media]):not([slot=poster]):not(media-loading-indicator):not([role=dialog]):not([hidden])) {
147        pointer-events: auto;
148      }
149
150      :host(:not([${ae.AUDIO}])) *[part~=layer][part~=centered-layer] {
151        align-items: center;
152        justify-content: center;
153      }
154
155      :host(:not([${ae.AUDIO}])) ::slotted(media-gesture-receiver[slot=gestures-chrome]),
156      :host(:not([${ae.AUDIO}])) media-gesture-receiver[slot=gestures-chrome] {
157        align-self: stretch;
158        flex-grow: 1;
159      }
160
161      slot[name=middle-chrome] {
162        display: inline;
163        flex-grow: 1;
164        pointer-events: none;
165        background: none;
166      }
167
168      
169      ::slotted([slot=media]),
170      ::slotted([slot=poster]) {
171        width: 100%;
172        height: 100%;
173      }
174
175      
176      :host(:not([${ae.AUDIO}])) .spacer {
177        flex-grow: 1;
178      }
179
180      
181      :host(:-webkit-full-screen) {
182        
183        width: 100% !important;
184        height: 100% !important;
185      }
186
187      
188      ::slotted(:not([slot=media]):not([slot=poster]):not([${ae.NO_AUTOHIDE}]):not([hidden]):not([role=dialog])) {
189        opacity: 1;
190        transition: var(--media-control-transition-in, opacity 0.25s);
191      }
192
193      
194      :host([${ae.USER_INACTIVE}]:not([${b.MEDIA_PAUSED}]):not([${b.MEDIA_IS_AIRPLAYING}]):not([${b.MEDIA_IS_CASTING}]):not([${ae.AUDIO}])) ::slotted(:not([slot=media]):not([slot=poster]):not([${ae.NO_AUTOHIDE}]):not([role=dialog])) {
195        opacity: 0;
196        transition: var(--media-control-transition-out, opacity 1s);
197      }
198
199      :host([${ae.USER_INACTIVE}]:not([${ae.NO_AUTOHIDE}]):not([${b.MEDIA_PAUSED}]):not([${b.MEDIA_IS_CASTING}
199]):not([${ae.AUDIO}])) ::slotted([slot=media]) {
200        cursor: none;
201      }
202
203      :host([${ae.USER_INACTIVE}][${ae.AUTOHIDE_OVER_CONTROLS}]:not([${ae.NO_AUTOHIDE}]):not([${b.MEDIA_PAUSED}]):not([${b.MEDIA_IS_CASTING}]):not([${ae.AUDIO}])) * {
204        --media-cursor: none;
205        cursor: none;
206      }
207
208
209      ::slotted(media-control-bar)  {
210        align-self: stretch;
211      }
212
213      
214      :host(:not([${ae.AUDIO}])[${b.MEDIA_HAS_PLAYED}]) slot[name=poster] {
215        display: none;
216      }
217
218      ::slotted([role=dialog]) {
219        width: 100%;
220        height: 100%;
221        align-self: center;
222      }
223
224      ::slotted([role=menu]) {
225        align-self: end;
226      }
227    </style>
228
229    <slot name="media" part="layer media-layer"></slot>
230    <slot name="poster" part="layer poster-layer"></slot>
231    <slot name="gestures-chrome" part="layer gesture-layer">
232      <media-gesture-receiver slot="gestures-chrome">
233        <template shadowrootmode="${lu.shadowRootOptions.mode}">
234          ${lu.getTemplateHTML({})}
235        </template>
236      </media-gesture-receiver>
237    </slot>
238    <span part="layer vertical-layer">
239      <slot name="top-chrome" part="top chrome"></slot>
240      <slot name="middle-chrome" part="middle chrome"></slot>
241      <slot name="centered-chrome" part="layer centered-layer center centered chrome"></slot>
242      
243      <slot part="bottom chrome"></slot>
244    </span>
245    <slot name="dialog" part="layer dialog-layer"></slot>
246  `}const $T=Object.values(b),BT="sm:384 md:576 lg:768 xl:960";function GT(s){hg(s.target,s.contentRect.width)}function hg(s,e){var t;if(!s.isConnected)return;const i=(t=s.getAttribute(ae.BREAKPOINTS))!=null?t:BT,r=VT(i),n=HT(r,e);let a=!1;if(Object.keys(r).forEach(o=>{if(n.includes(o)){s.hasAttribute(`breakpoint${o}`)||(s.setAttribute(`breakpoint${o}`,""),a=!0);return}s.hasAttribute(`breakpoint${o}`)&&(s.removeAttribute(`breakpoint${o}`),a=!0)}),a){const o=new CustomEvent(Ls.BREAKPOINTS_CHANGE,{detail:n});s.dispatchEvent(o)}s.breakpointsComputed||(s.breakpointsComputed=!0,s.dispatchEvent(new CustomEvent(Ls.BREAKPOINTS_COMPUTED,{bubbles:!0,composed:!0})))}function VT(s){const e=s.split(/\s+/);return Object.fromEntries(e.map(t=>t.split(":")))}function HT(s,e){return Object.keys(s).filter(t=>e>=parseInt(s[t]))}class Sa extends P.HTMLElement{constructor(){if(super(),It(this,Yo),It(this,qo),It(this,jo),It(this,Ar),It(this,Ta),It(this,xs),It(this,Jn,0),It(this,as,null),It(this,Sr,null),It(this,Es,void 0),this.breakpointsComputed=!1,It(this,gn,new MutationObserver(Ct(this,Yo,dg).bind(this))),It(this,Hs,!1),It(this,mn,t=>{xt(this,Hs)||(setTimeout(()=>{GT(t),Ui(this,Hs,!1)},0),Ui(this,Hs,!0))}),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);const t=Gt(this.attributes),i=this.constructor.getTemplateHTML(t);this.shadowRoot.setHTMLUnsafe?this.shadowRoot.setHTMLUnsafe(i):this.shadowRoot.innerHTML=i}const e=this.querySelector(":scope > slot[slot=media]");e&&e.addEventListener("slotchange",()=>{if(!e.assignedElements({flatten:!0}).length){xt(this,as)&&this.mediaUnsetCallback(xt(this,as));return}this.handleMediaUpdated(this.media)})}static get observedAttributes(){return[ae.AUTOHIDE,ae.GESTURES_DISABLED].concat($T).filter(e=>![b.MEDIA_RENDITION_LIST,b.MEDIA_AUDIO_TRACK_LIST,b.MEDIA_CHAPTERS_CUES,b.MEDIA_WIDTH,b.MEDIA_HEIGHT,b.MEDIA_ERROR,b.MEDIA_ERROR_MESSAGE].includes(e))}attributeChangedCallback(e,t,i){e.toLowerCase()==ae.AUTOHIDE&&(this.autohide=i)}get media(){let e=this.querySelector(":scope > [slot=media]");return e?.nodeName=="SLOT"&&(e=e.assignedElements({flatten:!0})[0]),e}async handleMediaUpdated(e){e&&(Ui(this,as,e),e.localName.includes("-")&&await P.customElements.whenDefined(e.localName),this.mediaSetCallback(e))}connectedCallback(){var e;xt(this,gn).observe(this,{childList:!0,subtree:!0}),ig(this,xt(this,mn));const t=this.getAttribute(ae.AUDIO)!=null,i=ne(t?"audio player":"video player");this.setAttribute("role","region"),this.setAttribute("aria-label",i),this.handleMediaUpdated(this.media),this.setAttribute(ae.USER_INACTIVE,""),hg(this,this.getBoundingClientRect().width),this.addEventListener("pointerdown",this),this.addEventListener("pointermove",this),this.addEventListener("pointerup",this),this.addEventListener("mouseleave",this),this.addEventListener("keyup",this),(e=P.window)==null||e.addEventListener("mouseup",this)}disconnectedCallback(){var e;xt(this,gn).disconnect(),sg(this,xt(this,mn)),this.media&&this.mediaUnsetCallback(this.media),(e=P.window)==null||e.removeEventListener("mouseup",this)}mediaSetCallback(e){}mediaUnsetCallback(e){Ui(this,as,null)}handleEvent(e){switch(e.type){case"pointerdown":Ui(this,Jn,e.timeStamp);break;case"pointermove":Ct(this,qo,cg).call(this,e);break;case"pointerup":Ct(this,jo,ug).call(this,e);break;case"mouseleave":Ct(this,Ar,ya).call(this);break;case"mouseup":this.removeAttribute(ae.KEYBOARD_CONTROL);break;case"keyup":Ct(this,xs,br).call(this),this.setAttribute(ae.KEYBOARD_CONTROL,"");break}}set autohide(e){const t=Number(e);Ui(this,Es,isNaN(t)?0:t)}get autohide(){return(xt(this,Es)===void 0?2:xt(this,Es)).toString()}get breakpoints(){return Be(this,ae.BREAKPOINTS)}set breakpoints(e){Ge(this,ae.BREAKPOINTS,e)}get audio(){return Ee(this,ae.AUDIO)}set audio(e){ve(this,ae.AUDIO,e)}get gesturesDisabled(){return Ee(this,ae.GESTURES_DISABLED)}set gesturesDisabled(e){ve(this,ae.GESTURES_DISABLED,e)}get keyboardControl(){return Ee(this,ae.KEYBOARD_CONTROL)}set keyboardControl(e){ve(this,ae.KEYBOARD_CONTROL,e)}get noAutohide(){return Ee(this,ae.NO_AUTOHIDE)}set noAutohide(e){ve(this,ae.NO_AUTOHIDE,e)}get autohideOverControls(){return Ee(this,ae.AUTOHIDE_OVER_CONTROLS)}set autohideOverControls(e){ve(this,ae.AUTOHIDE_OVER_CONTROLS,e)}get userInteractive(){return Ee(this,ae.USER_INACTIVE)}set userInteractive(e){ve(this,ae.USER_INACTIVE,e)}}Jn=new WeakMap;as=new WeakMap;Sr=new WeakMap;Es=new WeakMap;gn=new WeakMap;Yo=new WeakSet;dg=function(s){const e=this.media;for(const t of s){if(t.type!=="childList")continue;const i=t.removedNodes;for(const r of i){if(r.slot!="media"||t.target!=this)continue;let n=t.previousSibling&&t.previousSibling.previousElementSibling;if(!n||!e)this.mediaUnsetCallback(r);else{let a=n.slot!=="media";for(;(n=n.previousSibling)!==null;)n.slot=="media"&&(a=!1);a&&this.mediaUnsetCallback(r)}}if(e)for(const r of t.addedNodes)r===e&&this.handleMediaUpdated(e)}};Hs=new WeakMap;mn=new WeakMap;qo=new WeakSet;cg=function(s){if(s.pointerType!=="mouse"&&s.timeStamp-xt(this,Jn)<250)return;Ct(this,Ta,zl).call(this),clearTimeout(xt(this,Sr));const e=this.hasAttribute(ae.AUTOHIDE_OVER_CONTROLS);([this,this.media].includes(s.target)||e)&&Ct(this,xs,br).call(this)};jo=new WeakSet;ug=function(s){if(s.pointerType==="touch"){const e=!this.hasAttribute(ae.USER_INACTIVE);[this,this.media].includes(s.target)&&e?Ct(this,Ar,ya).call(this):Ct(this,xs,br).call(this)}else s.composedPath().some(e=>["media-play-button","media-fullscreen-button"].includes(e?.localName))&&Ct(this,xs,br).call(this)};Ar=new WeakSet;ya=function(){if(xt(this,Es)<0||this.hasAttribute(ae.USER_INACTIVE))return;this.setAttribute(ae.USER_INACTIVE,"");const s=new P.CustomEvent(Ls.USER_INACTIVE_CHANGE,{composed:!0,bubbles:!0,detail:!0});this.dispatchEvent(s)};Ta=new WeakSet;zl=function(){if(!this.hasAttribute(ae.USER_INACTIVE))return;this.removeAttribute(ae.USER_INACTIVE);const s=new P.CustomEvent(Ls.USER_INACTIVE_CHANGE,{composed:!0,bubbles:!0,detail:!1});this.dispatchEvent(s)};xs=new WeakSet;br=function(){Ct(this,Ta,zl).call(this),clearTimeout(xt(this,Sr));const s=parseInt(this.autohide);s<0||Ui(this,Sr,setTimeout(()=>{Ct(this,Ar,ya).call(this)},s*1e3))};Sa.shadowRootOptions={mode:"open"};Sa.getTemplateHTML=UT;P.customElements.get("media-container")||P.customElements.define("media-container",Sa);var fg=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},et=(s,e,t)=>(fg(s,e,"read from private field"),t?t.call(s):e.get(s)),Ns=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},zr=(s,e,t,i)=>(fg(s,e,"write to private field"),e.set(s,t),t),os,ls,ea,Vi,gi,Ai;class gg{constructor(e,t,{defaultValue:i}={defaultValue:void 0}){Ns(this,gi),Ns(this,os,void 0),Ns(this,ls,void 0),Ns(this,ea,void 0),Ns(this,Vi,new Set),zr(this,os,e),zr(this,ls,t),zr(this,ea,new Set(i))}[Symbol.iterator](){return et(this,gi,Ai).values()}get length(){return et(this,gi,Ai).size}get value(){var e;return(e=[...et(this,gi,Ai)].join(" "))!=null?e:""}set value(e){var t;e!==this.value&&(zr(this,Vi,new Set),this.add(...(t=e?.split(" "))!=null?t:[]))}toString(){return this.value}item(e){return[...et(this,gi,Ai)][e]}values(){return et(this,gi,Ai).values()}
246forEach(e,t){et(this,gi,Ai).forEach(e,t)}add(...e){var t,i;e.forEach(r=>et(this,Vi).add(r)),!(this.value===""&&!((t=et(this,os))!=null&&t.hasAttribute(`${et(this,ls)}`)))&&((i=et(this,os))==null||i.setAttribute(`${et(this,ls)}`,`${this.value}`))}remove(...e){var t;e.forEach(i=>et(this,Vi).delete(i)),(t=et(this,os))==null||t.setAttribute(`${et(this,ls)}`,`${this.value}`)}contains(e){return et(this,gi,Ai).has(e)}toggle(e,t){return typeof t<"u"?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}}os=new WeakMap;ls=new WeakMap;ea=new WeakMap;Vi=new WeakMap;gi=new WeakSet;Ai=function(){return et(this,Vi).size?et(this,Vi):et(this,ea)};const KT=(s="")=>s.split(/\s+/),mg=(s="")=>{const[e,t,i]=s.split(":"),r=i?decodeURIComponent(i):void 0;return{kind:e==="cc"?oi.CAPTIONS:oi.SUBTITLES,language:t,label:r}},pg=(s="",e={})=>KT(s).map(t=>{const i=mg(t);return{...e,...i}}),Eg=s=>s?Array.isArray(s)?s.map(e=>typeof e=="string"?mg(e):e):typeof s=="string"?pg(s):[s]:[],WT=({kind:s,label:e,language:t}={kind:"subtitles"})=>e?`${s==="captions"?"cc":"sb"}:${t}:${encodeURIComponent(e)}`:t,zo=(s=[])=>Array.prototype.map.call(s,WT).join(" "),YT=(s,e)=>t=>t[s]===e,vg=s=>{const e=Object.entries(s).map(([t,i])=>YT(t,i));return t=>e.every(i=>i(t))},nr=(s,e=[],t=[])=>{const i=Eg(t).map(vg),r=n=>i.some(a=>a(n));Array.from(e).filter(r).forEach(n=>{n.mode=s})},Aa=(s,e=()=>!0)=>{if(!s?.textTracks)return[];const t=typeof e=="function"?e:vg(e);return Array.from(s.textTracks).filter(t)},qT=s=>{var e;return!!((e=s.mediaSubtitlesShowing)!=null&&e.length)||s.hasAttribute(b.MEDIA_SUBTITLES_SHOWING)},jT=s=>{var e;const{media:t,fullscreenElement:i}=s;try{const r=i&&"requestFullscreen"in i?"requestFullscreen":i&&"webkitRequestFullScreen"in i?"webkitRequestFullScreen":void 0;if(r){const n=(e=i[r])==null?void 0:e.call(i);if(n instanceof Promise)return n.catch(()=>{})}else t?.webkitEnterFullscreen?t.webkitEnterFullscreen():t?.requestFullscreen&&t.requestFullscreen()}catch(r){console.error(r)}},du="exitFullscreen"in yt?"exitFullscreen":"webkitExitFullscreen"in yt?"webkitExitFullscreen":"webkitCancelFullScreen"in yt?"webkitCancelFullScreen":void 0,zT=s=>{var e;const{documentElement:t}=s;if(du){const i=(e=t?.[du])==null?void 0:e.call(t);if(i instanceof Promise)return i.catch(()=>{})}},Ks="fullscreenElement"in yt?"fullscreenElement":"webkitFullscreenElement"in yt?"webkitFullscreenElement":void 0,QT=s=>{const{documentElement:e,media:t}=s,i=e?.[Ks];return!i&&"webkitDisplayingFullscreen"in t&&"webkitPresentationMode"in t&&t.webkitDisplayingFullscreen&&t.webkitPresentationMode===vT.FULLSCREEN?t:i},XT=s=>{var e;const{media:t,documentElement:i,fullscreenElement:r=t}=s;if(!t||!i)return!1;const n=QT(s);if(!n)return!1;if(n===r||n===t)return!0;if(n.localName.includes("-")){let a=n.shadowRoot;if(!(Ks in a))return ks(n,r);for(;a?.[Ks];){if(a[Ks]===r)return!0;a=(e=a[Ks])==null?void 0:e.shadowRoot}}return!1},ZT="fullscreenEnabled"in yt?"fullscreenEnabled":"webkitFullscreenEnabled"in yt?"webkitFullscreenEnabled":void 0,JT=s=>{const{documentElement:e,media:t}=s;return!!e?.[ZT]||t&&"webkitSupportsFullscreen"in t};let Qr;const Ql=()=>{var s,e;return Qr||(Qr=(e=(s=yt)==null?void 0:s.createElement)==null?void 0:e.call(s,"video"),Qr)},eS=async(s=Ql())=>{if(!s)return!1;const e=s.volume;s.volume=e/2+.1;const t=new AbortController,i=await Promise.race([tS(s,t.signal),iS(s,e)]);return t.abort(),i},tS=(s,e)=>new Promise(t=>{s.addEventListener("volumechange",()=>t(!0),{signal:e})}),iS=async(s,e)=>{for(let t=0;t<10;t++){if(s.volume===e)return!1;await zf(10)}return s.volume!==e},sS=/.*Version\/.*Safari\/.*/.test(P.navigator.userAgent),yg=(s=Ql())=>P.matchMedia("(display-mode: standalone)").matches&&sS?!1:typeof s?.requestPictureInPicture=="function",Tg=(s=Ql())=>JT({documentElement:yt,media:s}),rS=Tg(),nS=yg(),aS=!!P.WebKitPlaybackTargetAvailabilityEvent,oS=!!P.chrome,ta=s=>Aa(s.media,e=>[oi.SUBTITLES,oi.CAPTIONS].includes(e.kind)).sort((e,t)=>e.kind>=t.kind?1:-1),Sg=s=>Aa(s.media,e=>e.mode===As.SHOWING&&[oi.SUBTITLES,oi.CAPTIONS].includes(e.kind)),Ag=(s,e)=>{const t=ta(s),i=Sg(s),r=!!i.length;if(t.length){if(e===!1||r&&e!==!0)nr(As.DISABLED,t,i);else if(e===!0||!r&&e!==!1){let n=t[0];const{options:a}=s;if(!a?.noSubtitlesLangPref){const c=globalThis.localStorage.getItem("media-chrome-pref-subtitles-lang"),u=c?[c,...globalThis.navigator.languages]:globalThis.navigator.languages,h=t.filter(f=>u.some(g=>f.language.toLowerCase().startsWith(g.split("-")[0]))).sort((f,g)=>{const m=u.findIndex(v=>f.language.toLowerCase().startsWith(v.split("-")[0])),p=u.findIndex(v=>g.language.toLowerCase().startsWith(v.split("-")[0]));return m-p});h[0]&&(n=h[0])}const{language:o,label:l,kind:d}=n;nr(As.DISABLED,t,i),nr(As.SHOWING,t,[{language:o,label:l,kind:d}])}}},Xl=(s,e)=>s===e?!0:s==null||e==null||typeof s!=typeof e?!1:typeof s=="number"&&Number.isNaN(s)&&Number.isNaN(e)?!0:typeof s!="object"?!1:Array.isArray(s)?lS(s,e):Object.entries(s).every(([t,i])=>t in e&&Xl(i,e[t])),lS=(s,e)=>{const t=Array.isArray(s),i=Array.isArray(e);return t!==i?!1:t||i?s.length!==e.length?!1:s.every((r,n)=>Xl(r,e[n])):!0},dS=Object.values(mi);let ia;const cS=eS().then(s=>(ia=s,ia)),uS=async(...s)=>{await Promise.all(s.filter(e=>e).map(async e=>{if(!("localName"in e&&e instanceof P.HTMLElement))return;const t=e.localName;if(!t.includes("-"))return;const i=P.customElements.get(t);i&&e instanceof i||(await P.customElements.whenDefined(t),P.customElements.upgrade(e))}))},hS=new P.DOMParser,fS=s=>s&&(hS.parseFromString(s,"text/html").body.textContent||s),Ws={mediaError:{get(s,e){const{media:t}=s;if(e?.type!=="playing")return t?.error},mediaEvents:["emptied","error","playing"]},mediaErrorCode:{get(s,e){var t;const{media:i}=s;if(e?.type!=="playing")return(t=i?.error)==null?void 0:t.code},mediaEvents:["emptied","error","playing"]},mediaErrorMessage:{get(s,e){var t,i;const{media:r}=s;if(e?.type!=="playing")return(i=(t=r?.error)==null?void 0:t.message)!=null?i:""},mediaEvents:["emptied","error","playing"]},mediaWidth:{get(s){var e;const{media:t}=s;return(e=t?.videoWidth)!=null?e:0},mediaEvents:["resize"]},mediaHeight:{get(s){var e;const{media:t}=s;return(e=t?.videoHeight)!=null?e:0},mediaEvents:["resize"]},mediaPaused:{get(s){var e;const{media:t}=s;return(e=t?.paused)!=null?e:!0},set(s,e){var t;const{media:i}=e;i&&(s?i.pause():(t=i.play())==null||t.catch(()=>{}))},mediaEvents:["play","playing","pause","emptied"]},mediaHasPlayed:{get(s,e){const{media:t}=s;return t?e?e.type==="playing":!t.paused:!1},mediaEvents:["playing","emptied"]},mediaEnded:{get(s){var e;const{media:t}=s;return(e=t?.ended)!=null?e:!1},mediaEvents:["seeked","ended","emptied"]},mediaPlaybackRate:{get(s){var e;const{media:t}=s;return(e=t?.playbackRate)!=null?e:1},set(s,e){const{media:t}=e;t&&Number.isFinite(+s)&&(t.playbackRate=+s)},mediaEvents:["ratechange","loadstart"]},mediaMuted:{get(s){var e;const{media:t}=s;return(e=t?.muted)!=null?e:!1},set(s,e){const{media:t}=e;if(t){try{P.localStorage.setItem("media-chrome-pref-muted",s?"true":"false")}catch(i){}t.muted=s}},mediaEvents:["volumechange"],stateOwnersUpdateHandlers:[(s,e)=>{const{options:{noMutedPref:t}}=e,{media:i}=e;if(!(!i||i.muted||t))try{const r=P.localStorage.getItem("media-chrome-pref-muted")==="true";Ws.mediaMuted.set(r,e),s(r)}catch(r){}}]},mediaVolume:{get(s){var e;const{media:t}=s;return(e=t?.volume)!=null?e:1},set(s,e){const{media:t}=e;if(t){try{s==null?P.localStorage.removeItem("media-chrome-pref-volume"):P.localStorage.setItem("media-chrome-pref-volume",s.toString())}catch(i){}Number.isFinite(+s)&&(t.volume=+s)}},mediaEvents:["volumechange"],stateOwnersUpdateHandlers:[(s,e)=>{const{options:{noVolumePref:t}}=e;if(!t)try{const{media:i}=e;if(!i)return;const r=P.localStorage.getItem("media-chrome-pref-volume");if(r==null)return;Ws.mediaVolume.set(+r,e),s(+r)}catch(i){}}]},mediaVolumeLevel:{get(s){const{media:e}=s;return typeof e?.volume>"u"?"high":e.muted||e.volume===0?"off":e.volume<.5?"low":e.volume<.75?"medium":"high"},mediaEvents:["volumechange"]},mediaCurrentTime:{get(s){var e;const{media:t}=s;return(e=t?.currentTime)!=null?e:0},set(s,e){const{media:t}=e;!t||!Yl(s)||(t.currentTime=s)},mediaEvents:["timeupdate","loadedmetadata"]},mediaDuration:{get(s){const{media:e,options:{defaultDuration:t}={}}=s;return t&&(!e||!e.duration||Number.isNaN(e.duration)||!Number.isFinite(e.duration))?t:Number.isFinite(e?.duration)?e.duration:Number.NaN},mediaEvents:["durationchange","loadedmetadata","emptied"]},mediaLoading:{get(s){const{media:e}=s;return e?.readyState<3},mediaEvents:["waiting","playing","emptied"]},mediaSeekable:{get(s){var e;const{media:t}=s;if(!((e=t?.seekable)!=null&&e.length))return;const i=t.seekable.start(0),r=t.seekable.end(t.seekable.length-1);if(!(!i&&!r))return[Number(i.toFixed(3)),Number(r.toFixed(3))]},mediaEvents:["loadedmetadata","emptied","progress","seekablechange"]},mediaBuffered:{get(s){var e;const{media:t}=s,i=(e=t?.buffered)!=null?e:[];return Array.from(i).map((r,n)=>[Number(i.start(n).toFixed(3)),Number(i.end(n).toFixed(3))])},mediaEvents:["progress","emptied"]},mediaStreamType:{get(s){const{media:e,options:{defaultStreamType:t}={}}=s,i=[mi.LIVE,mi.ON_DEMAND].includes(t)?t:void 0;if(!e)return i;const{streamType:r}=e;if(dS.includes(r))return r===mi.UNKNOWN?i:r;const n=e.duration;return n===1/0?mi.LIVE:Number.isFinite(n)?mi.ON_DEMAND:i}
246,mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange"]},mediaTargetLiveWindow:{get(s){const{media:e}=s;if(!e)return Number.NaN;const{targetLiveWindow:t}=e,i=Ws.mediaStreamType.get(s);return(t==null||Number.isNaN(t))&&i===mi.LIVE?0:t},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange","targetlivewindowchange"]},mediaTimeIsLive:{get(s){const{media:e,options:{liveEdgeOffset:t=10}={}}=s;if(!e)return!1;if(typeof e.liveEdgeStart=="number")return Number.isNaN(e.liveEdgeStart)?!1:e.currentTime>=e.liveEdgeStart;if(!(Ws.mediaStreamType.get(s)===mi.LIVE))return!1;const r=e.seekable;if(!r)return!0;if(!r.length)return!1;const n=r.end(r.length-1)-t;return e.currentTime>=n},mediaEvents:["playing","timeupdate","progress","waiting","emptied"]},mediaSubtitlesList:{get(s){return ta(s).map(({kind:e,label:t,language:i})=>({kind:e,label:t,language:i}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack"]},mediaSubtitlesShowing:{get(s){return Sg(s).map(({kind:e,label:t,language:i})=>({kind:e,label:t,language:i}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack","change"],stateOwnersUpdateHandlers:[(s,e)=>{var t,i;const{media:r,options:n}=e;if(!r)return;const a=o=>{var l;!n.defaultSubtitles||o&&![oi.CAPTIONS,oi.SUBTITLES].includes((l=o?.track)==null?void 0:l.kind)||Ag(e,!0)};return r.addEventListener("loadstart",a),(t=r.textTracks)==null||t.addEventListener("addtrack",a),(i=r.textTracks)==null||i.addEventListener("removetrack",a),()=>{var o,l;r.removeEventListener("loadstart",a),(o=r.textTracks)==null||o.removeEventListener("addtrack",a),(l=r.textTracks)==null||l.removeEventListener("removetrack",a)}}]},mediaChaptersCues:{get(s){var e;const{media:t}=s;if(!t)return[];const[i]=Aa(t,{kind:oi.CHAPTERS});return Array.from((e=i?.cues)!=null?e:[]).map(({text:r,startTime:n,endTime:a})=>({text:fS(r),startTime:n,endTime:a}))},mediaEvents:["loadstart","loadedmetadata"],textTracksEvents:["addtrack","removetrack","change"],stateOwnersUpdateHandlers:[(s,e)=>{var t;const{media:i}=e;if(!i)return;const r=i.querySelector('track[kind="chapters"][default][src]'),n=(t=i.shadowRoot)==null?void 0:t.querySelector(':is(video,audio) > track[kind="chapters"][default][src]');return r?.addEventListener("load",s),n?.addEventListener("load",s),()=>{r?.removeEventListener("load",s),n?.removeEventListener("load",s)}}]},mediaIsPip:{get(s){var e,t;const{media:i,documentElement:r}=s;if(!i||!r||!r.pictureInPictureElement)return!1;if(r.pictureInPictureElement===i)return!0;if(r.pictureInPictureElement instanceof HTMLMediaElement)return(e=i.localName)!=null&&e.includes("-")?ks(i,r.pictureInPictureElement):!1;if(r.pictureInPictureElement.localName.includes("-")){let n=r.pictureInPictureElement.shadowRoot;for(;n?.pictureInPictureElement;){if(n.pictureInPictureElement===i)return!0;n=(t=n.pictureInPictureElement)==null?void 0:t.shadowRoot}}return!1},set(s,e){const{media:t}=e;if(t)if(s){if(!yt.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}const i=()=>{console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a readyState > 0.")};t.requestPictureInPicture().catch(r=>{if(r.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"){const n=()=>{t.removeEventListener("loadedmetadata",a),t.preload="none"},a=()=>{t.requestPictureInPicture().catch(i),n()};t.addEventListener("loadedmetadata",a),t.preload="metadata",setTimeout(()=>{t.readyState===0&&i(),n()},1e3)}else throw r}else throw r})}else yt.pictureInPictureElement&&yt.exitPictureInPicture()},mediaEvents:["enterpictureinpicture","leavepictureinpicture"]},mediaRenditionList:{get(s){var e;const{media:t}=s;return[...(e=t?.videoRenditions)!=null?e:[]].map(i=>({...i}))},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},mediaRenditionSelected:{get(s){var e,t,i;const{media:r}=s;return(i=(t=r?.videoRenditions)==null?void 0:t[(e=r.videoRenditions)==null?void 0:e.selectedIndex])==null?void 0:i.id},set(s,e){const{media:t}=e;if(!t?.videoRenditions){console.warn("MediaController: Rendition selection not supported by this media.");return}const i=s,r=Array.prototype.findIndex.call(t.videoRenditions,n=>n.id==i);t.videoRenditions.selectedIndex!=r&&(t.videoRenditions.selectedIndex=r)},mediaEvents:["emptied"],videoRenditionsEvents:["addrendition","removerendition","change"]},mediaAudioTrackList:{get(s){var e;const{media:t}=s;return[...(e=t?.audioTracks)!=null?e:[]]},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]},mediaAudioTrackEnabled:{get(s){var e,t;const{media:i}=s;return(t=[...(e=i?.audioTracks)!=null?e:[]].find(r=>r.enabled))==null?void 0:t.id},set(s,e){const{media:t}=e;if(!t?.audioTracks){console.warn("MediaChrome: Audio track selection not supported by this media.");return}const i=s;for(const r of t.audioTracks)r.enabled=i==r.id},mediaEvents:["emptied"],audioTracksEvents:["addtrack","removetrack","change"]},mediaIsFullscreen:{get(s){return XT(s)},set(s,e){s?jT(e):zT(e)},rootEvents:["fullscreenchange","webkitfullscreenchange"],mediaEvents:["webkitbeginfullscreen","webkitendfullscreen","webkitpresentationmodechanged"]},mediaIsCasting:{get(s){var e;const{media:t}=s;return!t?.remote||((e=t.remote)==null?void 0:e.state)==="disconnected"?!1:!!t.remote.state},set(s,e){var t,i;const{media:r}=e;if(r&&!(s&&((t=r.remote)==null?void 0:t.state)!=="disconnected")&&!(!s&&((i=r.remote)==null?void 0:i.state)!=="connected")){if(typeof r.remote.prompt!="function"){console.warn("MediaChrome: Casting is not supported in this environment");return}r.remote.prompt().catch(()=>{})}},remoteEvents:["connect","connecting","disconnect"]},mediaIsAirplaying:{get(){return!1},set(s,e){const{media:t}=e;if(t){if(!(t.webkitShowPlaybackTargetPicker&&P.WebKitPlaybackTargetAvailabilityEvent)){console.error("MediaChrome: received a request to select AirPlay but AirPlay is not supported in this environment");return}t.webkitShowPlaybackTargetPicker()}},mediaEvents:["webkitcurrentplaybacktargetiswirelesschanged"]},mediaFullscreenUnavailable:{get(s){const{media:e}=s;if(!rS||!Tg(e))return kt.UNSUPPORTED}},mediaPipUnavailable:{get(s){const{media:e}=s;if(!nS||!yg(e))return kt.UNSUPPORTED}},mediaVolumeUnavailable:{get(s){const{media:e}=s;if(ia===!1||e?.volume==null)return kt.UNSUPPORTED},stateOwnersUpdateHandlers:[s=>{ia==null&&cS.then(e=>s(e?void 0:kt.UNSUPPORTED))}]},mediaCastUnavailable:{get(s,{availability:e="not-available"}={}){var t;const{media:i}=s;if(!oS||!((t=i?.remote)!=null&&t.state))return kt.UNSUPPORTED;if(!(e==null||e==="available"))return kt.UNAVAILABLE},stateOwnersUpdateHandlers:[(s,e)=>{var t;const{media:i}=e;return i?(i.disableRemotePlayback||i.hasAttribute("disableremoteplayback")||(t=i?.remote)==null||t.watchAvailability(n=>{s({availability:n?"available":"not-available"})}).catch(n=>{n.name==="NotSupportedError"?s({availability:null}):s({availability:"not-available"})}),()=>{var n;(n=i?.remote)==null||n.cancelWatchAvailability().catch(()=>{})}):void 0}]},mediaAirplayUnavailable:{get(s,e){if(!aS)return kt.UNSUPPORTED;if(e?.availability==="not-available")return kt.UNAVAILABLE},mediaEvents:["webkitplaybacktargetavailabilitychanged"],stateOwnersUpdateHandlers:[(s,e)=>{var t;const{media:i}=e;return i?(i.disableRemotePlayback||i.hasAttribute("disableremoteplayback")||(t=i?.remote)==null||t.watchAvailability(n=>{s({availability:n?"available":"not-available"})}).catch(n=>{n.name==="NotSupportedError"?s({availability:null}):s({availability:"not-available"})}),()=>{var n;(n=i?.remote)==null||n.cancelWatchAvailability().catch(()=>{})}):void 0}]},mediaRenditionUnavailable:{get(s){var e;const{media:t}=s;if(!t?.videoRenditions)return kt.UNSUPPORTED;if(!((e=t.videoRenditions)!=null&&e.length))return kt.UNAVAILABLE},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},mediaAudioTrackUnavailable:{get(s){var e,t;const{media:i}=s;if(!i?.audioTracks)return kt.UNSUPPORTED;if(((t=(e=i.audioTracks)==null?void 0:e.length)!=null?t:0)<=1)return kt.UNAVAILABLE},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]},mediaLang:{get(s){const{options:{mediaLang:e}={}}=s;return e??"en"}}},gS={[ee.MEDIA_PREVIEW_REQUEST](s,e,{detail:t}){var i,r,n;const{media:a}=e,o=t??void 0;let l,d;if(a&&o!=null){const[f]=Aa(a,{kind:oi.METADATA,label:"thumbnails"}),g=Array.prototype.find.call((i=f?.cues)!=null?i:[],(m,p,v)=>p===0?m.endTime>o:p===v.length-1?m.startTime<=o:m.startTime<=o&&m.endTime>o);if(g){const m=/'^(?:[a-z]+:)?\/\//i.test(g.text)||(r=a?.querySelector('track[label="thumbnails"]'))==null?void 0:r.src,p=new URL(g.text,m);d=new URLSearchParams(p.hash).get("#xywh").split(",").map(T=>+T),l=p.href}}const c=s.mediaDuration.get(e);
246let h=(n=s.mediaChaptersCues.get(e).find((f,g,m)=>g===m.length-1&&c===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}},[ee.MEDIA_PAUSE_REQUEST](s,e){s["mediaPaused"].set(!0,e)},[ee.MEDIA_PLAY_REQUEST](s,e){var t,i,r,n;const a="mediaPaused",l=s.mediaStreamType.get(e)===mi.LIVE,d=!((t=e.options)!=null&&t.noAutoSeekToLive),c=s.mediaTargetLiveWindow.get(e)>0;if(l&&d&&!c){const u=(i=s.mediaSeekable.get(e))==null?void 0:i[1];if(u){const h=(n=(r=e.options)==null?void 0:r.seekToLiveOffset)!=null?n:0,f=u-h;s.mediaCurrentTime.set(f,e)}}s[a].set(!1,e)},[ee.MEDIA_PLAYBACK_RATE_REQUEST](s,e,{detail:t}){const i="mediaPlaybackRate",r=t;s[i].set(r,e)},[ee.MEDIA_MUTE_REQUEST](s,e){s["mediaMuted"].set(!0,e)},[ee.MEDIA_UNMUTE_REQUEST](s,e){const t="mediaMuted";s.mediaVolume.get(e)||s.mediaVolume.set(.25,e),s[t].set(!1,e)},[ee.MEDIA_VOLUME_REQUEST](s,e,{detail:t}){const i="mediaVolume",r=t;r&&s.mediaMuted.get(e)&&s.mediaMuted.set(!1,e),s[i].set(r,e)},[ee.MEDIA_SEEK_REQUEST](s,e,{detail:t}){const i="mediaCurrentTime",r=t;s[i].set(r,e)},[ee.MEDIA_SEEK_TO_LIVE_REQUEST](s,e){var t,i,r;const n="mediaCurrentTime",a=(t=s.mediaSeekable.get(e))==null?void 0:t[1];if(Number.isNaN(Number(a)))return;const o=(r=(i=e.options)==null?void 0:i.seekToLiveOffset)!=null?r:0,l=a-o;s[n].set(l,e)},[ee.MEDIA_SHOW_SUBTITLES_REQUEST](s,e,{detail:t}){var i;const{options:r}=e,n=ta(e),a=Eg(t),o=(i=a[0])==null?void 0:i.language;o&&!r.noSubtitlesLangPref&&P.localStorage.setItem("media-chrome-pref-subtitles-lang",o),nr(As.SHOWING,n,a)},[ee.MEDIA_DISABLE_SUBTITLES_REQUEST](s,e,{detail:t}){const i=ta(e),r=t??[];nr(As.DISABLED,i,r)},[ee.MEDIA_TOGGLE_SUBTITLES_REQUEST](s,e,{detail:t}){Ag(e,t)},[ee.MEDIA_RENDITION_REQUEST](s,e,{detail:t}){const i="mediaRenditionSelected",r=t;s[i].set(r,e)},[ee.MEDIA_AUDIO_TRACK_REQUEST](s,e,{detail:t}){const i="mediaAudioTrackEnabled",r=t;s[i].set(r,e)},[ee.MEDIA_ENTER_PIP_REQUEST](s,e){const t="mediaIsPip";s.mediaIsFullscreen.get(e)&&s.mediaIsFullscreen.set(!1,e),s[t].set(!0,e)},[ee.MEDIA_EXIT_PIP_REQUEST](s,e){s["mediaIsPip"].set(!1,e)},[ee.MEDIA_ENTER_FULLSCREEN_REQUEST](s,e){const t="mediaIsFullscreen";s.mediaIsPip.get(e)&&s.mediaIsPip.set(!1,e),s[t].set(!0,e)},[ee.MEDIA_EXIT_FULLSCREEN_REQUEST](s,e){s["mediaIsFullscreen"].set(!1,e)},[ee.MEDIA_ENTER_CAST_REQUEST](s,e){const t="mediaIsCasting";s.mediaIsFullscreen.get(e)&&s.mediaIsFullscreen.set(!1,e),s[t].set(!0,e)},[ee.MEDIA_EXIT_CAST_REQUEST](s,e){s["mediaIsCasting"].set(!1,e)},[ee.MEDIA_AIRPLAY_REQUEST](s,e){s["mediaIsAirplaying"].set(!0,e)}},mS=({media:s,fullscreenElement:e,documentElement:t,stateMediator:i=Ws,requestMap:r=gS,options:n={},monitorStateOwnersOnlyWithSubscriptions:a=!0})=>{const o=[],l={options:{...n}};let d=Object.freeze({mediaPreviewTime:void 0,mediaPreviewImage:void 0,mediaPreviewCoords:void 0,mediaPreviewChapter:void 0});const c=m=>{m!=null&&(Xl(m,d)||(d=Object.freeze({...d,...m}),o.forEach(p=>p(d))))},u=()=>{const m=Object.entries(i).reduce((p,[v,{get:T}])=>(p[v]=T(l),p),{});c(m)},h={};let f;const g=async(m,p)=>{var v,T,y,S,A,I,_,R,D,L,k,w,U,K,G,O;const F=!!f;if(f={...l,...f??{},...m},F)return;await uS(...Object.values(m));const M=o.length>0&&p===0&&a,$=l.media!==f.media,Y=((v=l.media)==null?void 0:v.textTracks)!==((T=f.media)==null?void 0:T.textTracks),N=((y=l.media)==null?void 0:y.videoRenditions)!==((S=f.media)==null?void 0:S.videoRenditions),V=((A=l.media)==null?void 0:A.audioTracks)!==((I=f.media)==null?void 0:I.audioTracks),se=((_=l.media)==null?void 0:_.remote)!==((R=f.media)==null?void 0:R.remote),J=l.documentElement!==f.documentElement,de=!!l.media&&($||M),te=!!((D=l.media)!=null&&D.textTracks)&&(Y||M),fe=!!((L=l.media)!=null&&L.videoRenditions)&&(N||M),le=!!((k=l.media)!=null&&k.audioTracks)&&(V||M),pe=!!((w=l.media)!=null&&w.remote)&&(se||M),Pe=!!l.documentElement&&(J||M),it=de||te||fe||le||pe||Pe,dt=o.length===0&&p===1&&a,_e=!!f.media&&($||dt),ht=!!((U=f.media)!=null&&U.textTracks)&&(Y||dt),St=!!((K=f.media)!=null&&K.videoRenditions)&&(N||dt),z=!!((G=f.media)!=null&&G.audioTracks)&&(V||dt),he=!!((O=f.media)!=null&&O.remote)&&(se||dt),ge=!!f.documentElement&&(J||dt),we=_e||ht||St||z||he||ge;if(!(it||we)){Object.entries(f).forEach(([ce,st])=>{l[ce]=st}),u(),f=void 0;return}
246Object.entries(i).forEach(([ce,{get:st,mediaEvents:di=[],textTracksEvents:je=[],videoRenditionsEvents:rt=[],audioTracksEvents:pt=[],remoteEvents:ft=[],rootEvents:Qe=[],stateOwnersUpdateHandlers:Vt=[]}])=>{h[ce]||(h[ce]={});const Oe=Ve=>{const At=st(l,Ve);c({[ce]:At})};let Se;Se=h[ce].mediaEvents,di.forEach(Ve=>{Se&&de&&(l.media.removeEventListener(Ve,Se),h[ce].mediaEvents=void 0),_e&&(f.media.addEventListener(Ve,Oe),h[ce].mediaEvents=Oe)}),Se=h[ce].textTracksEvents,je.forEach(Ve=>{var At,wt;Se&&te&&((At=l.media.textTracks)==null||At.removeEventListener(Ve,Se),h[ce].textTracksEvents=void 0),ht&&((wt=f.media.textTracks)==null||wt.addEventListener(Ve,Oe),h[ce].textTracksEvents=Oe)}),Se=h[ce].videoRenditionsEvents,rt.forEach(Ve=>{var At,wt;Se&&fe&&((At=l.media.videoRenditions)==null||At.removeEventListener(Ve,Se),h[ce].videoRenditionsEvents=void 0),St&&((wt=f.media.videoRenditions)==null||wt.addEventListener(Ve,Oe),h[ce].videoRenditionsEvents=Oe)}),Se=h[ce].audioTracksEvents,pt.forEach(Ve=>{var At,wt;Se&&le&&((At=l.media.audioTracks)==null||At.removeEventListener(Ve,Se),h[ce].audioTracksEvents=void 0),z&&((wt=f.media.audioTracks)==null||wt.addEventListener(Ve,Oe),h[ce].audioTracksEvents=Oe)}),Se=h[ce].remoteEvents,ft.forEach(Ve=>{var At,wt;Se&&pe&&((At=l.media.remote)==null||At.removeEventListener(Ve,Se),h[ce].remoteEvents=void 0),he&&((wt=f.media.remote)==null||wt.addEventListener(Ve,Oe),h[ce].remoteEvents=Oe)}),Se=h[ce].rootEvents,Qe.forEach(Ve=>{Se&&Pe&&(l.documentElement.removeEventListener(Ve,Se),h[ce].rootEvents=void 0),ge&&(f.documentElement.addEventListener(Ve,Oe),h[ce].rootEvents=Oe)});const Ps=h[ce].stateOwnersUpdateHandlers;Vt.forEach(Ve=>{Ps&&it&&Ps(),we&&(h[ce].stateOwnersUpdateHandlers=Ve(Oe,f))})}),Object.entries(f).forEach(([ce,st])=>{l[ce]=st}),u(),f=void 0};return g({media:s,fullscreenElement:e,documentElement:t,options:n}),{dispatch(m){const{type:p,detail:v}=m;if(r[p]&&d.mediaErrorCode==null){c(r[p](i,l,m));return}p==="mediaelementchangerequest"?g({media:v}):p==="fullscreenelementchangerequest"?g({fullscreenElement:v}):p==="documentelementchangerequest"?g({documentElement:v}):p==="optionschangerequest"&&(Object.entries(v??{}).forEach(([T,y])=>{l.options[T]=y}),u())},getState(){return d},subscribe(m){return g({},o.length+1),o.push(m),m(d),()=>{const p=o.indexOf(m);p>=0&&(g({},o.length-1),o.splice(p,1))}}}};var Zl=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},me=(s,e,t)=>(Zl(s,e,"read from private field"),t?t.call(s):e.get(s)),hi=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},Ti=(s,e,t,i)=>(Zl(s,e,"write to private field"),e.set(s,t),t),xi=(s,e,t)=>(Zl(s,e,"access private method"),t),Hi,Ys,Le,qs,qt,pn,En,Qo,Rs,Ir,vn,Xo;const bg=["ArrowLeft","ArrowRight","Enter"," ","f","m","k","c"],cu=10,q={DEFAULT_SUBTITLES:"defaultsubtitles",DEFAULT_STREAM_TYPE:"defaultstreamtype",DEFAULT_DURATION:"defaultduration",FULLSCREEN_ELEMENT:"fullscreenelement",HOTKEYS:"hotkeys",KEYS_USED:"keysused",LIVE_EDGE_OFFSET:"liveedgeoffset",SEEK_TO_LIVE_OFFSET:"seektoliveoffset",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",LANG:"lang"};class pS extends Sa{constructor(){super(),hi(this,En),hi(this,Rs),hi(this,vn),this.mediaStateReceivers=[],this.associatedElementSubscriptions=new Map,hi(this,Hi,new gg(this,q.HOTKEYS)),hi(this,Ys,void 0),hi(this,Le,void 0),hi(this,qs,void 0),hi(this,qt,void 0),hi(this,pn,t=>{var i;(i=me(this,Le))==null||i.dispatch(t)}),this.associateElement(this);let e={};Ti(this,qs,t=>{Object.entries(t).forEach(([i,r])=>{if(i in e&&e[i]===r)return;this.propagateMediaState(i,r);const n=i.toLowerCase(),a=new P.CustomEvent(ET[n],{composed:!0,detail:r});this.dispatchEvent(a)}),e=t}),this.enableHotkeys()}static get observedAttributes(){return super.observedAttributes.concat(q.NO_HOTKEYS,q.HOTKEYS,q.DEFAULT_STREAM_TYPE,q.DEFAULT_SUBTITLES,q.DEFAULT_DURATION,q.LANG)}get mediaStore(){return me(this,Le)}set mediaStore(e){var t,i;if(me(this,Le)&&((t=me(this,qt))==null||t.call(this),Ti(this,qt,void 0)),Ti(this,Le,e),!me(this,Le)&&!this.hasAttribute(q.NO_DEFAULT_STORE)){xi(this,En,Qo).call(this);return}Ti(this,qt,(i=me(this,Le))==null?void 0:i.subscribe(me(this,qs)))}get fullscreenElement(){var e;return(e=me(this,Ys))!=null?e:this}set fullscreenElement(e){var t;this.hasAttribute(q.FULLSCREEN_ELEMENT)&&this.removeAttribute(q.FULLSCREEN_ELEMENT),Ti(this,Ys,e),(t=me(this,Le))==null||t.dis
246patch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement})}get defaultSubtitles(){return Ee(this,q.DEFAULT_SUBTITLES)}set defaultSubtitles(e){ve(this,q.DEFAULT_SUBTITLES,e)}get defaultStreamType(){return Be(this,q.DEFAULT_STREAM_TYPE)}set defaultStreamType(e){Ge(this,q.DEFAULT_STREAM_TYPE,e)}get defaultDuration(){return $e(this,q.DEFAULT_DURATION)}set defaultDuration(e){tt(this,q.DEFAULT_DURATION,e)}get noHotkeys(){return Ee(this,q.NO_HOTKEYS)}set noHotkeys(e){ve(this,q.NO_HOTKEYS,e)}get keysUsed(){return Be(this,q.KEYS_USED)}set keysUsed(e){Ge(this,q.KEYS_USED,e)}get liveEdgeOffset(){return $e(this,q.LIVE_EDGE_OFFSET)}set liveEdgeOffset(e){tt(this,q.LIVE_EDGE_OFFSET,e)}get noAutoSeekToLive(){return Ee(this,q.NO_AUTO_SEEK_TO_LIVE)}set noAutoSeekToLive(e){ve(this,q.NO_AUTO_SEEK_TO_LIVE,e)}get noVolumePref(){return Ee(this,q.NO_VOLUME_PREF)}set noVolumePref(e){ve(this,q.NO_VOLUME_PREF,e)}get noSubtitlesLangPref(){return Ee(this,q.NO_SUBTITLES_LANG_PREF)}set noSubtitlesLangPref(e){ve(this,q.NO_SUBTITLES_LANG_PREF,e)}get noDefaultStore(){return Ee(this,q.NO_DEFAULT_STORE)}set noDefaultStore(e){ve(this,q.NO_DEFAULT_STORE,e)}attributeChangedCallback(e,t,i){var r,n,a,o,l,d,c,u,h;if(super.attributeChangedCallback(e,t,i),e===q.NO_HOTKEYS)i!==t&&i===""?(this.hasAttribute(q.HOTKEYS)&&console.warn("Media Chrome: Both `hotkeys` and `nohotkeys` have been set. All hotkeys will be disabled."),this.disableHotkeys()):i!==t&&i===null&&this.enableHotkeys();else if(e===q.HOTKEYS)me(this,Hi).value=i;else if(e===q.DEFAULT_SUBTITLES&&i!==t)(r=me(this,Le))==null||r.dispatch({type:"optionschangerequest",detail:{defaultSubtitles:this.hasAttribute(q.DEFAULT_SUBTITLES)}});else if(e===q.DEFAULT_STREAM_TYPE)(a=me(this,Le))==null||a.dispatch({type:"optionschangerequest",detail:{defaultStreamType:(n=this.getAttribute(q.DEFAULT_STREAM_TYPE))!=null?n:void 0}});else if(e===q.LIVE_EDGE_OFFSET)(o=me(this,Le))==null||o.dispatch({type:"optionschangerequest",detail:{liveEdgeOffset:this.hasAttribute(q.LIVE_EDGE_OFFSET)?+this.getAttribute(q.LIVE_EDGE_OFFSET):void 0,seekToLiveOffset:this.hasAttribute(q.SEEK_TO_LIVE_OFFSET)?void 0:+this.getAttribute(q.LIVE_EDGE_OFFSET)}});else if(e===q.SEEK_TO_LIVE_OFFSET)(l=me(this,Le))==null||l.dispatch({type:"optionschangerequest",detail:{seekToLiveOffset:this.hasAttribute(q.SEEK_TO_LIVE_OFFSET)?+this.getAttribute(q.SEEK_TO_LIVE_OFFSET):void 0}});else if(e===q.NO_AUTO_SEEK_TO_LIVE)(d=me(this,Le))==null||d.dispatch({type:"optionschangerequest",detail:{noAutoSeekToLive:this.hasAttribute(q.NO_AUTO_SEEK_TO_LIVE)}});else if(e===q.FULLSCREEN_ELEMENT){const f=i?(c=this.getRootNode())==null?void 0:c.getElementById(i):void 0;Ti(this,Ys,f),(u=me(this,Le))==null||u.dispatch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement})}else e===q.LANG&&i!==t&&(_T(i),(h=me(this,Le))==null||h.dispatch({type:"optionschangerequest",detail:{mediaLang:i}}))}connectedCallback(){var e,t;!me(this,Le)&&!this.hasAttribute(q.NO_DEFAULT_STORE)&&xi(this,En,Qo).call(this),(e=me(this,Le))==null||e.dispatch({type:"documentelementchangerequest",detail:yt}),super.connectedCallback(),me(this,Le)&&!me(this,qt)&&Ti(this,qt,(t=me(this,Le))==null?void 0:t.subscribe(me(this,qs))),this.enableHotkeys()}disconnectedCallback(){var e,t,i,r;(e=super.disconnectedCallback)==null||e.call(this),me(this,Le)&&((t=me(this,Le))==null||t.dispatch({type:"documentelementchangerequest",detail:void 0}),(i=me(this,Le))==null||i.dispatch({type:ee.MEDIA_TOGGLE_SUBTITLES_REQUEST,detail:!1})),me(this,qt)&&((r=me(this,qt))==null||r.call(this),Ti(this,qt,void 0))}mediaSetCallback(e){var t;super.mediaSetCallback(e),(t=me(this,Le))==null||t.dispatch({type:"mediaelementchangerequest",detail:e}),e.hasAttribute("tabindex")||(e.tabIndex=-1)}mediaUnsetCallback(e){var t;super.mediaUnsetCallback(e),(t=me(this,Le))==null||t.dispatch({type:"mediaelementchangerequest",detail:void 0})}propagateMediaState(e,t){fu(this.mediaStateReceivers,e,t)}associateElement(e){if(!e)return;const{associatedElementSubscriptions:t}=this;if(t.has(e))return;const i=this.registerMediaStateReceiver.bind(this),r=this.unregisterMediaStateReceiver.bind(this),n=AS(e,i,r);Object.values(ee).forEach(a=>{e.addEventListener(a,me(this,pn))}),t.set(e,n)}unassociateElement(e){if(!e)return;const{associatedElementSubscriptions:t}=this;if(!t.has(e))return;t.get(e)(),t.delete(e),Object.values(ee).forEach(r=>{e.removeEventListener(r,me(this,pn))})}registerMediaStateReceiver(e){if(!e)return;const t=this.mediaStateReceivers;t.indexOf(e)>-1||(t.push(e),me(this,Le)&&Object.entries(me(this,Le).getState()).forEac
246h(([r,n])=>{fu([e],r,n)}))}unregisterMediaStateReceiver(e){const t=this.mediaStateReceivers,i=t.indexOf(e);i<0||t.splice(i,1)}enableHotkeys(){this.addEventListener("keydown",xi(this,vn,Xo))}disableHotkeys(){this.removeEventListener("keydown",xi(this,vn,Xo)),this.removeEventListener("keyup",xi(this,Rs,Ir))}get hotkeys(){return Be(this,q.HOTKEYS)}set hotkeys(e){Ge(this,q.HOTKEYS,e)}keyboardShortcutHandler(e){var t,i,r,n,a;const o=e.target;if(((r=(i=(t=o.getAttribute(q.KEYS_USED))==null?void 0:t.split(" "))!=null?i:o?.keysUsed)!=null?r:[]).map(h=>h==="Space"?" ":h).filter(Boolean).includes(e.key))return;let d,c,u;if(!me(this,Hi).contains(`no${e.key.toLowerCase()}`)&&!(e.key===" "&&me(this,Hi).contains("nospace")))switch(e.key){case" ":case"k":d=me(this,Le).getState().mediaPaused?ee.MEDIA_PLAY_REQUEST:ee.MEDIA_PAUSE_REQUEST,this.dispatchEvent(new P.CustomEvent(d,{composed:!0,bubbles:!0}));break;case"m":d=this.mediaStore.getState().mediaVolumeLevel==="off"?ee.MEDIA_UNMUTE_REQUEST:ee.MEDIA_MUTE_REQUEST,this.dispatchEvent(new P.CustomEvent(d,{composed:!0,bubbles:!0}));break;case"f":d=this.mediaStore.getState().mediaIsFullscreen?ee.MEDIA_EXIT_FULLSCREEN_REQUEST:ee.MEDIA_ENTER_FULLSCREEN_REQUEST,this.dispatchEvent(new P.CustomEvent(d,{composed:!0,bubbles:!0}));break;case"c":this.dispatchEvent(new P.CustomEvent(ee.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0}));break;case"ArrowLeft":{const h=this.hasAttribute(q.KEYBOARD_BACKWARD_SEEK_OFFSET)?+this.getAttribute(q.KEYBOARD_BACKWARD_SEEK_OFFSET):cu;c=Math.max(((n=this.mediaStore.getState().mediaCurrentTime)!=null?n:0)-h,0),u=new P.CustomEvent(ee.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:c}),this.dispatchEvent(u);break}case"ArrowRight":{const h=this.hasAttribute(q.KEYBOARD_FORWARD_SEEK_OFFSET)?+this.getAttribute(q.KEYBOARD_FORWARD_SEEK_OFFSET):cu;c=Math.max(((a=this.mediaStore.getState().mediaCurrentTime)!=null?a:0)+h,0),u=new P.CustomEvent(ee.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:c}),this.dispatchEvent(u);break}}}}Hi=new WeakMap;Ys=new WeakMap;Le=new WeakMap;qs=new WeakMap;qt=new WeakMap;pn=new WeakMap;En=new WeakSet;Qo=function(){var s;this.mediaStore=mS({media:this.media,fullscreenElement:this.fullscreenElement,options:{defaultSubtitles:this.hasAttribute(q.DEFAULT_SUBTITLES),defaultDuration:this.hasAttribute(q.DEFAULT_DURATION)?+this.getAttribute(q.DEFAULT_DURATION):void 0,defaultStreamType:(s=this.getAttribute(q.DEFAULT_STREAM_TYPE))!=null?s:void 0,liveEdgeOffset:this.hasAttribute(q.LIVE_EDGE_OFFSET)?+this.getAttribute(q.LIVE_EDGE_OFFSET):void 0,seekToLiveOffset:this.hasAttribute(q.SEEK_TO_LIVE_OFFSET)?+this.getAttribute(q.SEEK_TO_LIVE_OFFSET):this.hasAttribute(q.LIVE_EDGE_OFFSET)?+this.getAttribute(q.LIVE_EDGE_OFFSET):void 0,noAutoSeekToLive:this.hasAttribute(q.NO_AUTO_SEEK_TO_LIVE),noVolumePref:this.hasAttribute(q.NO_VOLUME_PREF),noSubtitlesLangPref:this.hasAttribute(q.NO_SUBTITLES_LANG_PREF)}})};Rs=new WeakSet;Ir=function(s){const{key:e}=s;if(!bg.includes(e)){this.removeEventListener("keyup",xi(this,Rs,Ir));return}this.keyboardShortcutHandler(s)};vn=new WeakSet;Xo=function(s){const{metaKey:e,altKey:t,key:i}=s;if(e||t||!bg.includes(i)){this.removeEventListener("keyup",xi(this,Rs,Ir));return}[" ","ArrowLeft","ArrowRight"].includes(i)&&!(me(this,Hi).contains(`no${i.toLowerCase()}`)||i===" "&&me(this,Hi).contains("nospace"))&&s.preventDefault(),this.addEventListener("keyup",xi(this,Rs,Ir),{once:!0})};const ES=Object.values(b),vS=Object.values(qf),Ig=s=>{var e,t,i,r;let{observedAttributes:n}=s.constructor;!n&&((e=s.nodeName)!=null&&e.includes("-"))&&(P.customElements.upgrade(s),{observedAttributes:n}=s.constructor);const a=(r=(i=(t=s?.getAttribute)==null?void 0:t.call(s,be.MEDIA_CHROME_ATTRIBUTES))==null?void 0:i.split)==null?void 0:r.call(i,/\s+/);return Array.isArray(n||a)?(n||a).filter(o=>ES.includes(o)):[]},yS=s=>{var e,t;return(e=s.nodeName)!=null&&e.includes("-")&&P.customElements.get((t=s.nodeName)==null?void 0:t.toLowerCase())&&!(s instanceof P.customElements.get(s.nodeName.toLowerCase()))&&P.customElements.upgrade(s),vS.some(i=>i in s)},Zo=s=>yS(s)||!!Ig(s).length,uu=s=>{var e;return(e=s?.join)==null?void 0:e.call(s,":")},hu={[b.MEDIA_SUBTITLES_LIST]:zo,[b.MEDIA_SUBTITLES_SHOWING]:zo,[b.MEDIA_SEEKABLE]:uu,[b.MEDIA_BUFFERED]:s=>s?.map(uu).join(" "),[b.MEDIA_PREVIEW_COORDS]:s=>s?.join(" "),[b.MEDIA_RENDITION_LIST]:yT,[b.MEDIA_AUDIO_TRACK_LIST]:ST},TS=async(s,e,t)=>{var i,r;if(s.isConnected||await zf(0),typeof t=="boolean"||t==null)return ve(s,e,t);if(typeof t=="number")return tt(s,e,t);if(typeof t=="string")return Ge(s,e,t);if(Array.isArray(t)&&!t.length)return s.removeAttribute(e);const n=(r=(i=hu[e])==null?void 0:i.call(hu,t))!=null?r:t;return s.setAttribute(e,n)},SS=s=>{var e;return!!((e=s.closest)!=null&&e.call(s,'*[slot="media"]'))},$i=(s,e)=>{if(SS(s))return;const t=(r,n)=>{var a,o;Zo(r)&&n(r);const{children:l=[]}=r??{},d=(o=(a=r?.shadowRoot)==null?void 0:a.children)!=null?o:[];
246[...l,...d].forEach(u=>$i(u,n))},i=s?.nodeName.toLowerCase();if(i.includes("-")&&!Zo(s)){P.customElements.whenDefined(i).then(()=>{t(s,e)});return}t(s,e)},fu=(s,e,t)=>{s.forEach(i=>{if(e in i){i[e]=t;return}const r=Ig(i),n=e.toLowerCase();r.includes(n)&&TS(i,n,t)})},AS=(s,e,t)=>{$i(s,e);const i=c=>{var u;const h=(u=c?.composedPath()[0])!=null?u:c.target;e(h)},r=c=>{var u;const h=(u=c?.composedPath()[0])!=null?u:c.target;t(h)};s.addEventListener(ee.REGISTER_MEDIA_STATE_RECEIVER,i),s.addEventListener(ee.UNREGISTER_MEDIA_STATE_RECEIVER,r);const n=c=>{c.forEach(u=>{const{addedNodes:h=[],removedNodes:f=[],type:g,target:m,attributeName:p}=u;g==="childList"?(Array.prototype.forEach.call(h,v=>$i(v,e)),Array.prototype.forEach.call(f,v=>$i(v,t))):g==="attributes"&&p===be.MEDIA_CHROME_ATTRIBUTES&&(Zo(m)?e(m):t(m))})};let a=[];const o=c=>{const u=c.target;u.name!=="media"&&(a.forEach(h=>$i(h,t)),a=[...u.assignedElements({flatten:!0})],a.forEach(h=>$i(h,e)))};s.addEventListener("slotchange",o);const l=new MutationObserver(n);return l.observe(s,{childList:!0,attributes:!0,subtree:!0}),()=>{$i(s,t),s.removeEventListener("slotchange",o),l.disconnect(),s.removeEventListener(ee.REGISTER_MEDIA_STATE_RECEIVER,i),s.removeEventListener(ee.UNREGISTER_MEDIA_STATE_RECEIVER,r)}};P.customElements.get("media-controller")||P.customElements.define("media-controller",pS);const Zi={PLACEMENT:"placement",BOUNDS:"bounds"};function bS(s){return`
247    <style>
248      :host {
249        --_tooltip-background-color: var(--media-tooltip-background-color, var(--media-secondary-color, rgba(20, 20, 30, .7)));
250        --_tooltip-background: var(--media-tooltip-background, var(--_tooltip-background-color));
251        --_tooltip-arrow-half-width: calc(var(--media-tooltip-arrow-width, 12px) / 2);
252        --_tooltip-arrow-height: var(--media-tooltip-arrow-height, 5px);
253        --_tooltip-arrow-background: var(--media-tooltip-arrow-color, var(--_tooltip-background-color));
254        position: relative;
255        pointer-events: none;
256        display: var(--media-tooltip-display, inline-flex);
257        justify-content: center;
258        align-items: center;
259        box-sizing: border-box;
260        z-index: var(--media-tooltip-z-index, 1);
261        background: var(--_tooltip-background);
262        color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238)));
263        font: var(--media-font,
264          var(--media-font-weight, 400)
265          var(--media-font-size, 13px) /
266          var(--media-text-content-height, var(--media-control-height, 18px))
267          var(--media-font-family, helvetica neue, segoe ui, roboto, arial, sans-serif));
268        padding: var(--media-tooltip-padding, .35em .7em);
269        border: var(--media-tooltip-border, none);
270        border-radius: var(--media-tooltip-border-radius, 5px);
271        filter: var(--media-tooltip-filter, drop-shadow(0 0 4px rgba(0, 0, 0, .2)));
272        white-space: var(--media-tooltip-white-space, nowrap);
273      }
274
275      :host([hidden]) {
276        display: none;
277      }
278
279      img, svg {
280        display: inline-block;
281      }
282
283      #arrow {
284        position: absolute;
285        width: 0px;
286        height: 0px;
287        border-style: solid;
288        display: var(--media-tooltip-arrow-display, block);
289      }
290
291      :host(:not([placement])),
292      :host([placement="top"]) {
293        position: absolute;
294        bottom: calc(100% + var(--media-tooltip-distance, 12px));
295        left: 50%;
296        transform: translate(calc(-50% - var(--media-tooltip-offset-x, 0px)), 0);
297      }
298      :host(:not([placement])) #arrow,
299      :host([placement="top"]) #arrow {
300        top: 100%;
301        left: 50%;
302        border-width: var(--_tooltip-arrow-height) var(--_tooltip-arrow-half-width) 0 var(--_tooltip-arrow-half-width);
303        border-color: var(--_tooltip-arrow-background) transparent transparent transparent;
304        transform: translate(calc(-50% + var(--media-tooltip-offset-x, 0px)), 0);
305      }
306
307      :host([placement="right"]) {
308        position: absolute;
309        left: calc(100% + var(--media-tooltip-distance, 12px));
310        top: 50%;
311        transform: translate(0, -50%);
312      }
313      :host([placement="right"]) #arrow {
314        top: 50%;
315        right: 100%;
316        border-width: var(--_tooltip-arrow-half-width) var(--_tooltip-arrow-height) var(--_tooltip-arrow-half-width) 0;
317        border-color: transparent var(--_tooltip-arrow-background) transparent transparent;
318        transform: translate(0, -50%);
319      }
320
321      :host([placement="bottom"]) {
322        position: absolute;
323        top: calc(100% + var(--media-tooltip-distance, 12px));
324        left: 50%;
325        transform: translate(calc(-50% - var(--media-tooltip-offset-x, 0px)), 0
325);
326      }
327      :host([placement="bottom"]) #arrow {
328        bottom: 100%;
329        left: 50%;
330        border-width: 0 var(--_tooltip-arrow-half-width) var(--_tooltip-arrow-height) var(--_tooltip-arrow-half-width);
331        border-color: transparent transparent var(--_tooltip-arrow-background) transparent;
332        transform: translate(calc(-50% + var(--media-tooltip-offset-x, 0px)), 0);
333      }
334
335      :host([placement="left"]) {
336        position: absolute;
337        right: calc(100% + var(--media-tooltip-distance, 12px));
338        top: 50%;
339        transform: translate(0, -50%);
340      }
341      :host([placement="left"]) #arrow {
342        top: 50%;
343        left: 100%;
344        border-width: var(--_tooltip-arrow-half-width) 0 var(--_tooltip-arrow-half-width) var(--_tooltip-arrow-height);
345        border-color: transparent transparent transparent var(--_tooltip-arrow-background);
346        transform: translate(0, -50%);
347      }
348      
349      :host([placement="none"]) #arrow {
350        display: none;
351      }
352    </style>
353    <slot></slot>
354    <div id="arrow"></div>
355  `}class ba extends P.HTMLElement{constructor(){if(super(),this.updateXOffset=()=>{var e;if(!og(this,{checkOpacity:!1,checkVisibilityCSS:!1}))return;const t=this.placement;if(t==="left"||t==="right"){this.style.removeProperty("--media-tooltip-offset-x");return}const i=getComputedStyle(this),r=(e=kr(this,"#"+this.bounds))!=null?e:RT(this);if(!r)return;const{x:n,width:a}=r.getBoundingClientRect(),{x:o,width:l}=this.getBoundingClientRect(),d=o+l,c=n+a,u=i.getPropertyValue("--media-tooltip-offset-x"),h=u?parseFloat(u.replace("px","")):0,f=i.getPropertyValue("--media-tooltip-container-margin"),g=f?parseFloat(f.replace("px","")):0,m=o-n+h-g,p=d-c+h+g;if(m<0){this.style.setProperty("--media-tooltip-offset-x",`${m}px`);return}if(p>0){this.style.setProperty("--media-tooltip-offset-x",`${p}px`);return}this.style.removeProperty("--media-tooltip-offset-x")},!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);const e=Gt(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}if(this.arrowEl=this.shadowRoot.querySelector("#arrow"),Object.prototype.hasOwnProperty.call(this,"placement")){const e=this.placement;delete this.placement,this.placement=e}}static get observedAttributes(){return[Zi.PLACEMENT,Zi.BOUNDS]}get placement(){return Be(this,Zi.PLACEMENT)}set placement(e){Ge(this,Zi.PLACEMENT,e)}get bounds(){return Be(this,Zi.BOUNDS)}set bounds(e){Ge(this,Zi.BOUNDS,e)}}ba.shadowRootOptions={mode:"open"};ba.getTemplateHTML=bS;P.customElements.get("media-tooltip")||P.customElements.define("media-tooltip",ba);var gu=ba,Jl=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},We=(s,e,t)=>(Jl(s,e,"read from private field"),t?t.call(s):e.get(s)),Ji=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},Xr=(s,e,t,i)=>(Jl(s,e,"write to private field"),e.set(s,t),t),IS=(s,e,t)=>(Jl(s,e,"access private method"),t),jt,vs,Ri,ds,yn,Jo,_g;const Si={TOOLTIP_PLACEMENT:"tooltipplacement",DISABLED:"disabled",NO_TOOLTIP:"notooltip"};function _S(s,e={}){return`
356    <style>
357      :host {
358        position: relative;
359        font: var(--media-font,
360          var(--media-font-weight, bold)
361          var(--media-font-size, 14px) /
362          var(--media-text-content-height, var(--media-control-height, 24px))
363          var(--media-font-family, helvetica neue, segoe ui, roboto, arial, sans-serif));
364        color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238)));
365        background: var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .7)));
366        padding: var(--media-button-padding, var(--media-control-padding, 10px));
367        justify-content: var(--media-button-justify-content, center);
368        display: inline-flex;
369        align-items: center;
370        vertical-align: middle;
371        box-sizing: border-box;
372        transition: background .15s linear;
373        pointer-events: auto;
374        cursor: var(--media-cursor, pointer);
375        -webkit-tap-highlight-color: transparent;
376      }
377
378      
379      :host(:focus-visible) {
380        box-shadow: inset 0 0 0 2px rgb(27 127 204 / .9);
381        outline: 0;
382      }
383      
384      :host(:where(:focus)) {
385        box-shadow: none;
386        outline: 0;
387      }
388
389      :host(:hover) {
390        background: var(--media-control-hover-background, rgba(50 50 70 / .7));
391      }
392
393      svg, img, ::slotted(svg), ::slotted(img) {
394        width: var(--media-button-icon-width);
395        height: var(--media-button-icon-height, var(--media-control-height, 24px));
396        transform: var(--media-button-icon-transform);
397        transition: var(--media-button-icon-transition);
398        fill: var(--media-icon-color, var(--media-primary-color, rgb(238 238 238)));
399        vertical-align: middle;
400        max-width: 100%;
401        max-height: 100%;
402        min-width: 100%;
403      }
404
405      media-tooltip {
406        
407        max-width: 0;
408        overflow-x: clip;
409        opacity: 0;
410        transition: opacity .3s, max-width 0s 9s;
411      }
412
413      :host(:hover) media-tooltip,
414      :host(:focus-visible) media-tooltip {
415        max-width: 100vw;
416        opacity: 1;
417        transition: opacity .3s;
418      }
419
420      :host([notooltip]) slot[name="tooltip"] {
421        display: none;
422      }
423    </style>
424
425    ${this.getSlotTemplateHTML(s,e)}
426
427    <slot name="tooltip">
428      <media-tooltip part="tooltip" aria-hidden="true">
429        <template shadowrootmode="${gu.shadowRootOptions.mode}">
430          ${gu.getTemplateHTML({})}
431        </template>
432        <slot name="tooltip-content">
433          ${this.getTooltipContentHTML(s)}
434        </slot>
435      </media-tooltip>
436    </slot>
437  `}function LS(s,e){return`
438    <slot></slot>
439  `}function xS(){return""}class ut extends P.HTMLElement{constructor(){if(super(),Ji(this,Jo),Ji(this,jt,void 0),this.preventClick=!1,this.tooltipEl=null,Ji(this,vs,e=>{this.preventClick||this.handleClick(e),setTimeout(We(this,Ri),0)}),Ji(this,Ri,()=>{var e,t;(t=(e=this.tooltipEl)==null?void 0:e.updateXOffset)==null||t.call(e)}),Ji(this,ds,e=>{const{key:t}=e;if(!this.keysUsed.includes(t)){this.removeEventListener("keyup",We(this,ds));return}this.preventClick||this.handleClick(e)}),Ji(this,yn,e=>{const{metaKey:t,altKey:i,key:r}=e;if(t||i||!this.keysUsed.includes(r)){this.removeEventListener("keyup",We(this,ds));return}this.addEventListener("keyup",We(this,ds),{once:!0})}),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);const e=Gt(this.attributes),t=this.constructor.getTemplateHTML(e);this.shadowRoot.setHTMLUnsafe?this.shadowRoot.setHTMLUnsafe(t):this.shadowRoot.innerHTML=t}this.tooltipEl=this.shadowRoot.querySelector("media-tooltip")}static get observedAttributes(){return["disabled",Si.TOOLTIP_PLACEMENT,be.MEDIA_CONTROLLER,b.MEDIA_LANG]}enable(){this.addEventListener("click",We(this,vs)),this.addEventListener("keydown",We(this,yn)),this.tabIndex=0}disable(){this.removeEventListener("click",We(this,vs)),this.removeEventListener("keydown",We(this,yn)),this.removeEventListener("keyup",We(this,ds)),this.tabIndex=-1}attributeChangedCallback(e,t,i){var r,n,a,o,l;e===be.MEDIA_CONTROLLER?(t&&((n=(r=We(this,jt))==null?void 0:r.unassociateElement)==null||n.call(r,this),Xr(this,jt,null)),i&&this.isConnected&&(Xr(this,jt,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(l=(o=We(this,jt))==null?void 0:o.associateElement)==null||l.call(o,this))):e==="disabled"&&i!==t?i==null?this.enable():this.disable():e===Si.TOOLTIP_PLACEMENT&&this.tooltipEl&&i!==t?this.tooltipEl.placement=i:e===b.MEDIA_LANG&&(this.shadowRoot.querySelector('slot[name="tooltip-content"]').innerHTML=this.constructor.getTooltipContentHTML()),We(this,Ri).call(this)}connectedCallback(){var e,t,i;const{style:r}=qe(this.shadowRoot,":host");r.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`),this.hasAttribute("disabled")?this.disable():this.enable(),this.setAttribute("role","button");const n=this.getAttribute(be.MEDIA_CONTROLLER);n&&(Xr(this,jt,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(i=(t=We(this,jt))==null?void 0:t.associateElement)==null||i.call(t,this)),P.customElements.whenDefined("media-tooltip").then(()=>
439IS(this,Jo,_g).call(this))}disconnectedCallback(){var e,t;this.disable(),(t=(e=We(this,jt))==null?void 0:e.unassociateElement)==null||t.call(e,this),Xr(this,jt,null),this.removeEventListener("mouseenter",We(this,Ri)),this.removeEventListener("focus",We(this,Ri)),this.removeEventListener("click",We(this,vs))}get keysUsed(){return["Enter"," "]}get tooltipPlacement(){return Be(this,Si.TOOLTIP_PLACEMENT)}set tooltipPlacement(e){Ge(this,Si.TOOLTIP_PLACEMENT,e)}get mediaController(){return Be(this,be.MEDIA_CONTROLLER)}set mediaController(e){Ge(this,be.MEDIA_CONTROLLER,e)}get disabled(){return Ee(this,Si.DISABLED)}set disabled(e){ve(this,Si.DISABLED,e)}get noTooltip(){return Ee(this,Si.NO_TOOLTIP)}set noTooltip(e){ve(this,Si.NO_TOOLTIP,e)}handleClick(e){}}jt=new WeakMap;vs=new WeakMap;Ri=new WeakMap;ds=new WeakMap;yn=new WeakMap;Jo=new WeakSet;_g=function(){this.addEventListener("mouseenter",We(this,Ri)),this.addEventListener("focus",We(this,Ri)),this.addEventListener("click",We(this,vs));const s=this.tooltipPlacement;s&&this.tooltipEl&&(this.tooltipEl.placement=s)};ut.shadowRootOptions={mode:"open"};ut.getTemplateHTML=_S;ut.getSlotTemplateHTML=LS;ut.getTooltipContentHTML=xS;P.customElements.get("media-chrome-button")||P.customElements.define("media-chrome-button",ut);const mu=`<svg aria-hidden="true" viewBox="0 0 26 24">
440  <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"/>
441</svg>
442`;function RS(s){return`
443    <style>
444      :host([${b.MEDIA_IS_AIRPLAYING}]) slot[name=icon] slot:not([name=exit]) {
445        display: none !important;
446      }
447
448      
449      :host(:not([${b.MEDIA_IS_AIRPLAYING}])) slot[name=icon] slot:not([name=enter]) {
450        display: none !important;
451      }
452
453      :host([${b.MEDIA_IS_AIRPLAYING}]) slot[name=tooltip-enter],
454      :host(:not([${b.MEDIA_IS_AIRPLAYING}])) slot[name=tooltip-exit] {
455        display: none;
456      }
457    </style>
458
459    <slot name="icon">
460      <slot name="enter">${mu}</slot>
461      <slot name="exit">${mu}</slot>
462    </slot>
463  `}function DS(){return`
464    <slot name="tooltip-enter">${ne("start airplay")}</slot>
465    <slot name="tooltip-exit">${ne("stop airplay")}</slot>
466  `}const pu=s=>{const e=s.mediaIsAirplaying?ne("stop airplay"):ne("start airplay");s.setAttribute("aria-label",e)};class ed extends ut{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_IS_AIRPLAYING,b.MEDIA_AIRPLAY_UNAVAILABLE]}connectedCallback(){super.connectedCallback(),pu(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===b.MEDIA_IS_AIRPLAYING&&pu(this)}get mediaIsAirplaying(){return Ee(this,b.MEDIA_IS_AIRPLAYING)}set mediaIsAirplaying(e){ve(this,b.MEDIA_IS_AIRPLAYING,e)}get mediaAirplayUnavailable(){return Be(this,b.MEDIA_AIRPLAY_UNAVAILABLE)}set mediaAirplayUnavailable(e){Ge(this,b.MEDIA_AIRPLAY_UNAVAILABLE,e)}handleClick(){const e=new P.CustomEvent(ee.MEDIA_AIRPLAY_REQUEST,{composed:!0,bubbles:!0});this.dispatchEvent(e)}}ed.getSlotTemplateHTML=RS;ed.getTooltipContentHTML=DS;P.customElements.get("media-airplay-button")||P.customElements.define("media-airplay-button",ed);const kS=`<svg aria-hidden="true" viewBox="0 0 26 24">
467  <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 
4670 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"/>
468</svg>`,CS=`<svg aria-hidden="true" viewBox="0 0 26 24">
469  <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"/>
470</svg>`;function PS(s){return`
471    <style>
472      :host([aria-checked="true"]) slot[name=off] {
473        display: none !important;
474      }
475
476      
477      :host(:not([aria-checked="true"])) slot[name=on] {
478        display: none !important;
479      }
480
481      :host([aria-checked="true"]) slot[name=tooltip-enable],
482      :host(:not([aria-checked="true"])) slot[name=tooltip-disable] {
483        display: none;
484      }
485    </style>
486
487    <slot name="icon">
488      <slot name="on">${kS}</slot>
489      <slot name="off">${CS}</slot>
490    </slot>
491  `}function wS(){return`
492    <slot name="tooltip-enable">${ne("Enable captions")}</slot>
493    <slot name="tooltip-disable">${ne("Disable captions")}</slot>
494  `}const Eu=s=>{s.setAttribute("aria-checked",qT(s).toString())};class td extends ut{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_SUBTITLES_LIST,b.MEDIA_SUBTITLES_SHOWING]}connectedCallback(){super.connectedCallback(),this.setAttribute("role","switch"),this.setAttribute("aria-label",ne("closed captions")),Eu(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===b.MEDIA_SUBTITLES_SHOWING&&Eu(this)}get mediaSubtitlesList(){return vu(this,b.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){yu(this,b.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return vu(this,b.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){yu(this,b.MEDIA_SUBTITLES_SHOWING,e)}handleClick(){this.dispatchEvent(new P.CustomEvent(ee.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0}))}}td.getSlotTemplateHTML=PS;td.getTooltipContentHTML=wS;const vu=(s,e)=>{const t=s.getAttribute(e);return t?pg(t):[]},yu=(s,e,t)=>{if(!t?.length){s.removeAttribute(e);return}const i=zo(t);s.getAttribute(e)!==i&&s.setAttribute(e,i)};P.customElements.get("media-captions-button")||P.customElements.define("media-captions-button",td);const 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>',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"/><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>';function FS(s){return`
495    <style>
496      :host([${b.MEDIA_IS_CASTING}]) slot[name=icon] slot:not([name=exit]) {
497        display: none !important;
498      }
499
500      
501      :host(:not([${b.MEDIA_IS_CASTING}])) slot[name=icon] slot:not([name=enter]) {
502        display: none !important;
503      }
504
505      :host([${b.MEDIA_IS_CASTING}]) slot[name=tooltip-enter],
506      :host(:not([${b.MEDIA_IS_CASTING}])) slot[name=tooltip-exit] {
507        display: none;
508      }
509    </style>
510
511    <slot name="icon">
512      <slot name="enter">${MS}</slot>
513      <slot name="exit">${OS}</slot>
514    </slot>
515  `}function NS(){return`
516    <slot name="tooltip-enter">${ne("Start casting")}</slot>
517    <slot name="tooltip-exit">${ne("Stop casting")}</slot>
518  `}const Tu=s=>{const e=s.mediaIsCasting?ne("stop casting"):ne("start casting");s.setAttribute("aria-label",e)};class id extends ut{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_IS_CASTING,b.MEDIA_CAST_UNAVAILABLE]}connectedCallback(){super.connectedCallback(),Tu(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===b.MEDIA_IS_CASTING&&Tu(this)}get mediaIsCasting(){return Ee(this,b.MEDIA_IS_CASTING)}set mediaIsCasting(e){ve(this,b.MEDIA_IS_CASTING,e)}get mediaCastUnavailable(){return Be(this,b.MEDIA_CAST_UNAVAILABLE)}
518set mediaCastUnavailable(e){Ge(this,b.MEDIA_CAST_UNAVAILABLE,e)}handleClick(){const e=this.mediaIsCasting?ee.MEDIA_EXIT_CAST_REQUEST:ee.MEDIA_ENTER_CAST_REQUEST;this.dispatchEvent(new P.CustomEvent(e,{composed:!0,bubbles:!0}))}}id.getSlotTemplateHTML=FS;id.getTooltipContentHTML=NS;P.customElements.get("media-cast-button")||P.customElements.define("media-cast-button",id);var sd=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Wi=(s,e,t)=>(sd(s,e,"read from private field"),e.get(s)),fi=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},rd=(s,e,t,i)=>(sd(s,e,"write to private field"),e.set(s,t),t),Fi=(s,e,t)=>(sd(s,e,"access private method"),t),sa,_r,qi,Tn,el,tl,Lg,il,xg,sl,Rg,rl,Dg,nl,kg;function US(s){return`
519    <style>
520      :host {
521        font: var(--media-font,
522          var(--media-font-weight, normal)
523          var(--media-font-size, 14px) /
524          var(--media-text-content-height, var(--media-control-height, 24px))
525          var(--media-font-family, helvetica neue, segoe ui, roboto, arial, sans-serif));
526        color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238)));
527        display: var(--media-dialog-display, inline-flex);
528        justify-content: center;
529        align-items: center;
530        
531        transition-behavior: allow-discrete;
532        visibility: hidden;
533        opacity: 0;
534        transform: translateY(2px) scale(.99);
535        pointer-events: none;
536      }
537
538      :host([open]) {
539        transition: display .2s, visibility 0s, opacity .2s ease-out, transform .15s ease-out;
540        visibility: visible;
541        opacity: 1;
542        transform: translateY(0) scale(1);
543        pointer-events: auto;
544      }
545
546      #content {
547        display: flex;
548        position: relative;
549        box-sizing: border-box;
550        width: min(320px, 100%);
551        word-wrap: break-word;
552        max-height: 100%;
553        overflow: auto;
554        text-align: center;
555        line-height: 1.4;
556      }
557    </style>
558    ${this.getSlotTemplateHTML(s)}
559  `}function $S(s){return`
560    <slot id="content"></slot>
561  `}const Us={OPEN:"open",ANCHOR:"anchor"};class Cr extends P.HTMLElement{constructor(){super(),fi(this,Tn),fi(this,tl),fi(this,il),fi(this,sl),fi(this,rl),fi(this,nl),fi(this,sa,!1),fi(this,_r,null),fi(this,qi,null),this.addEventListener("invoke",this),this.addEventListener("focusout",this),this.addEventListener("keydown",this)}static get observedAttributes(){return[Us.OPEN,Us.ANCHOR]}get open(){return Ee(this,Us.OPEN)}set open(e){ve(this,Us.OPEN,e)}handleEvent(e){switch(e.type){case"invoke":Fi(this,sl,Rg).call(this,e);break;case"focusout":Fi(this,rl,Dg).call(this,e);break;case"keydown":Fi(this,nl,kg).call(this,e);break}}connectedCallback(){Fi(this,Tn,el).call(this),this.role||(this.role="dialog")}attributeChangedCallback(e,t,i){Fi(this,Tn,el).call(this),e===Us.OPEN&&i!==t&&(this.open?Fi(this,tl,Lg).call(this):Fi(this,il,xg).call(this))}focus(){rd(this,_r,ag());const e=!this.dispatchEvent(new Event("focus",{composed:!0,cancelable:!0})),t=!this.dispatchEvent(new Event("focusin",{composed:!0,bubbles:!0,cancelable:!0}));if(e||t)return;const i=this.querySelector('[autofocus], [tabindex]:not([tabindex="-1"]), [role="menu"]');i?.focus()}get keysUsed(){return["Escape","Tab"]}}sa=new WeakMap;_r=new WeakMap;qi=new WeakMap;Tn=new WeakSet;el=function(){if(!Wi(this,sa)&&(rd(this,sa,!0),!this.shadowRoot)){this.attachShadow(this.constructor.shadowRootOptions);const s=Gt(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(s),queueMicrotask(()=>{const{style:e}=qe(this.shadowRoot,":host");e.setProperty("transition","display .15s, visibility .15s, opacity .15s ease-in, transform .15s ease-in")})}};tl=new WeakSet;Lg=function(){var s;(s=Wi(this,qi))==null||s.setAttribute("aria-expanded","true"),this.dispatchEvent(new Event("open",{composed:!0,bubbles:!0})),this.addEventListener("transitionend",()=>this.focus(),{once:!0})};il=new WeakSet;xg=function(){var s;(s=Wi(this,qi))==null||s.setAttribute("aria-expanded","false"),this.dispatchEvent(new Event("close",{c
vendor: 4,874 bytes, lines 561-681
561omposed:!0,bubbles:!0}))};sl=new WeakSet;Rg=function(s){rd(this,qi,s.relatedTarget),ks(this,s.relatedTarget)||(this.open=!this.open)};rl=new WeakSet;Dg=function(s){var e;ks(this,s.relatedTarget)||((e=Wi(this,_r))==null||e.focus(),Wi(this,qi)&&Wi(this,qi)!==s.relatedTarget&&this.open&&(this.open=!1))};nl=new WeakSet;kg=function(s){var e,t,i,r,n;const{key:a,ctrlKey:o,altKey:l,metaKey:d}=s;o||l||d||this.keysUsed.includes(a)&&(s.preventDefault(),s.stopPropagation(),a==="Tab"?(s.shiftKey?(t=(e=this.previousElementSibling)==null?void 0:e.focus)==null||t.call(e):(r=(i=this.nextElementSibling)==null?void 0:i.focus)==null||r.call(i),this.blur()):a==="Escape"&&((n=Wi(this,_r))==null||n.focus(),this.open=!1))};Cr.shadowRootOptions={mode:"open"};Cr.getTemplateHTML=US;Cr.getSlotTemplateHTML=$S;P.customElements.get("media-chrome-dialog")||P.customElements.define("media-chrome-dialog",Cr);var nd=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Fe=(s,e,t)=>(nd(s,e,"read from private field"),t?t.call(s):e.get(s)),at=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},bi=(s,e,t,i)=>(nd(s,e,"write to private field"),e.set(s,t),t),$t=(s,e,t)=>(nd(s,e,"access private method"),t),zt,Ia,Sn,An,Bt,ra,bn,In,_n,ad,Cg,Ln,al,xn,ol,na,od,ll,Pg,dl,wg,cl,Mg,ul,Og;function BS(s){return`
562    <style>
563      :host {
564        --_focus-box-shadow: var(--media-focus-box-shadow, inset 0 0 0 2px rgb(27 127 204 / .9));
565        --_media-range-padding: var(--media-range-padding, var(--media-control-padding, 10px));
566
567        box-shadow: var(--_focus-visible-box-shadow, none);
568        background: var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .7)));
569        height: calc(var(--media-control-height, 24px) + 2 * var(--_media-range-padding));
570        display: inline-flex;
571        align-items: center;
572        
573        vertical-align: middle;
574        box-sizing: border-box;
575        position: relative;
576        width: 100px;
577        transition: background .15s linear;
578        cursor: var(--media-cursor, pointer);
579        pointer-events: auto;
580        touch-action: none; 
581      }
582
583      
584      input[type=range]:focus {
585        outline: 0;
586      }
587      input[type=range]:focus::-webkit-slider-runnable-track {
588        outline: 0;
589      }
590
591      :host(:hover) {
592        background: var(--media-control-hover-background, rgb(50 50 70 / .7));
593      }
594
595      #leftgap {
596        padding-left: var(--media-range-padding-left, var(--_media-range-padding));
597      }
598
599      #rightgap {
600        padding-right: var(--media-range-padding-right, var(--_media-range-padding));
601      }
602
603      #startpoint,
604      #endpoint {
605        position: absolute;
606      }
607
608      #endpoint {
609        right: 0;
610      }
611
612      #container {
613        
614        width: var(--media-range-track-width, 100%);
615        transform: translate(var(--media-range-track-translate-x, 0px), var(--media-range-track-translate-y, 0px));
616        position: relative;
617        height: 100%;
618        display: flex;
619        align-items: center;
620        min-width: 40px;
621      }
622
623      #range {
624        
625        display: var(--media-time-range-hover-display, block);
626        bottom: var(--media-time-range-hover-bottom, -7px);
627        height: var(--media-time-range-hover-height, max(100% + 7px, 25px));
628        width: 100%;
629        position: absolute;
630        cursor: var(--media-cursor, pointer);
631
632        -webkit-appearance: none; 
633        -webkit-tap-highlight-color: transparent;
634        background: transparent; 
635        margin: 0;
636        z-index: 1;
637      }
638
639      @media (hover: hover) {
640        #range {
641          bottom: var(--media-time-range-hover-bottom, -5px);
642          height: var(--media-time-range-hover-height, max(100% + 5px, 20px));
643        }
644      }
645
646      
647      
648      #range::-webkit-slider-thumb {
649        -webkit-appearance: none;
650        background: transparent;
651        width: .1px;
652        height: .1px;
653      }
654
655      
656      #range::-moz-range-thumb {
657        background: transparent;
658        border: transparent;
659        width: .1px;
660        height: .1px;
661      }
662
663      #appearance {
664        height: var(--media-range-track-height, 4px);
665        display: flex;
666        flex-direction: column;
667        justify-content: center;
668        width: 100%;
669        position: absolute;
670        
671        will-change: transform;
672      }
673
674      #track {
675        background: var(--media-range-track-background, rgb(255 255 255 / .2));
676        border-radius: var(--media-range-track-border-radius, 1px);
677        border: var(--media-range-track-border, none);
678        outline: var(--media-range-track-outline);
679        outline-offset: var(--media-range-track-outline-offset);
680        backdrop-filter: var(--media-range-track-backdrop-filter);
681        -webkit-backdrop-filter: var(--media-range-track-backdrop-filter);
682        box-shadow: var(--media-range-track-box-shadow, none);
683        position: absolute;
684        width: 100%;
685        height: 100%;
686        overflow: hidden;
687      }
688
689      #progress,
690      #pointer {
691        position: absolute;
692        height: 100%;
693        will-change: width;
694      }
695
696      #progress {
697        background: var(--media-range-bar-color, var(--media-primary-color, rgb(238 238 238)));
698        transition: var(--media-range-track-transition);
699      }
700
701      #pointer {
702        background: var(--media-range-track-pointer-background);
703        border-right: var(--media-range-track-pointer-border-right);
704        transition: visibility .25s, opacity .25s;
705        visibility: hidden;
706        opacity: 0;
707      }
708
709      @media (hover: hover) {
710        :host(:hover) #pointer {
711          transition: visibility .5s, opacity .5s;
712          visibility: visible;
713          opacity: 1;
714        }
715      }
716
717      #thumb,
718      ::slotted([slot=thumb]) {
719        width: var(--media-range-thumb-width, 10px);
720        height: var(--media-range-thumb-height, 10px);
721        transition: var(--media-range-thumb-transition);
722        transform: var(--media-range-thumb-transform, none);
723        opacity: var(--media-range-thumb-opacity, 1);
724        translate: -50%;
725        position: absolute;
726        left: 0;
727        cursor: var(--media-cursor, pointer);
728      }
729
730      #thumb {
731        border-radius: var(--media-range-thumb-border-radius, 10px);
732        background: var(--media-range-thumb-background, var(--media-primary-color, rgb(238 238 238)));
733        box-shadow: var(--media-range-thumb-box-shadow, 1px 1px 1px transparent);
734        border: var(--media-range-thumb-border, none);
735      }
736
737      :host([disabled]) #thumb {
738        background-color: #777;
739      }
740
741      .segments #appearance {
742        height: var(--media-range-segment-hover-height, 7px);
743      }
744
745      #track {
746        clip-path: url(#segments-clipping);
747      }
748
749      #segments {
750        --segments-gap: var(--media-range-segments-gap, 2px);
751        position: absolute;
752        width: 100%;
753        height: 100%;
754      }
755
756      #segments-clipping {
757        transform: translateX(calc(var(--segments-gap) / 2));
758      }
759
760      #segments-clipping:empty {
761        display: none;
762      }
763
764      #segments-clipping rect {
765        height: var(--media-range-track-height, 4px);
766        y: calc((var(--media-range-segment-hover-height, 7px) - var(--media-range-track-height, 4px)) / 2);
767        transition: var(--media-range-segment-transition, transform .1s ease-in-out);
768        transform: var(--media-range-segment-transform, scaleY(1));
769        transform-origin: center;
770      }
771    </style>
772    <div id="leftgap"></div>
773    <div id="container">
774      <div id="startpoint"></div>
775      <div id="endpoint"></div>
776      <div id="appearance">
777        <div id="track" part="track">
778          <div id="pointer"></div>
779          <div id="progress" part="progress"></div>
780        </div>
781        <slot name="thumb">
782          <div id="thumb" part="thumb"></div>
783        </slot>
784        <svg id="segments"><clipPath id="segments-clipping"></clipPath></svg>
785      </div>
786      <input id="range" type="range" min="0" max="1" step="any" value="0">
787    </div>
788    <div id="rightgap"></div>
789  `}class Cs extends P.HTMLElement{constructor(){if(super(),at(this,ad),at(this,Ln),at(this,xn),at(this,na),at(this,ll),at(this,dl),at(this,cl),at(this,ul),at(this,zt,void 0),at(this,Ia,void 0),at(this,Sn,void 0),at(this,An,void 0),at(this,Bt,{}),at(this,ra,[]),at(this,bn,()=>{if(this.range.matches(":focus-visible")){const{style:e}=qe(this.shadowRoot,":host");e.setProperty("--_focus-visible-box-shadow","var(--_focus-box-shadow)")}}),at(this,In,()=>{const{style:e}=qe(this.shadowRoot,":host");e.removeProperty("--_focus-visible-box-shadow")}),at(this,_n,()=>{const e=this.shadowRoot.querySelector("#segments-clipping");e&&e.parentNode.append(e)}),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);const e=Gt(this.attributes),t=this.constructor.getTemplateHTML(e);this.shadowRoot.setHTMLUnsafe?this.shadowRoot.setHTMLUnsafe(t):this.shadowRoot.innerHTML=t}this.container=this.shadowRoot.querySelector("#container"),bi(this,Sn,this.shadowRoot.querySelector("#startpoint")),bi(this,An,this.shadowRoot.querySelector("#endpoint")),this.range=this.shadowRoot.querySelector("#range"),this.appearance=this.shadowRoot.querySelector("#appearance")}static get observedAttributes(){return["disabled","aria-disabled",be.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,i){var r,n,a,o,l;e===be.MEDIA_CONTROLLER?(t&&((n=(r=Fe(this,zt))==null?void 0:r.unassociateElement)==null||n.call(r,this),bi(this,zt,null)),i&&this.isConnected&&(bi(this,zt,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(l=(o=Fe(this,zt))==null?void 0:o.associateElement)==null||l.call(o,this))):(e==="disabled"||e==="aria-disabled"&&t!==i)&&(i==null?(this.range.removeAttribute(e),$t(this,Ln,al).call(this)):(this.range.setAttribute(e,i),$t(this,xn,ol).call(this)))}connectedCallback(){var e,t,i;const{style:r}=qe(this.shadowRoot,":host");r.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`),Fe(this,Bt).pointer=qe(this.shadowRoot,"#pointer"),Fe(this,Bt).progress=qe(this.shadowRoot,"#progress"),Fe(this,Bt).thumb=qe(this.shadowRoot,'#thumb, ::slotted([slot="thumb"])'),Fe(this,Bt).activeSegment=qe(this.shadowRoot,"#segments-clipping rect:nth-child(0)");const n=this.getAttribute(be.MEDIA_CONTROLLER);n&&(bi(this,zt,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(i=(t=Fe(this,zt))==null?void 0:t.associateElement)==null||i.call(t,this)),this.updateBar(),this.shadowRoot.addEventListener("focusin",Fe(this,bn)),this.shadowRoot.addEventListener("focusout",Fe(this,In)),$t(this,Ln,al).call(this),ig(this.container,Fe(this,_n))}disconnectedCallback(){var e,t;$t(this,xn,ol).call(this),(t=(e=Fe(this,zt))==null?void 0:e.unassociateElement)==null||t.call(e,this),bi(this,zt,null),this.shadowRoot.removeEventListener("focusin",Fe(this,bn)),this.shadowRoot.removeEventListener("focusout",Fe(this,In)),sg(this.container,Fe(this,_n))}updatePointerBar(e){var t;(t=Fe(this,Bt).pointer)==null||t.style.setProperty("width",`${this.getPointerRatio(e)*100}%`)}updateBar(){var e,t;const i=this.range.valueAsNumber*100;(e=Fe(this,Bt).progress)==null||e.style.setProperty("width",`${i}%`),(t=Fe(this,Bt).thumb)==null||t.style.setProperty("left",`${i}%`)}updateSegments(e){const t=this.shadowRoot.querySelector("#segments-clipping");if(t.textContent="",this.container.classList.toggle("segments",!!e?.length),!e?.length)return;const i=[...new Set([+this.range.min,...e.flatMap(n=>[n.start,n.end]),+this.range.max])];bi(this,ra,[...i]);const r=i.pop();for(const[n,a]of i.entries()){const[o,l]=[n===0,n===i.length-1],d=o?"calc(var(--segments-gap) / -1)":`${a*100}%`,u=`calc(${((l?r:i[n+1])-a)*100}%${o||l?"":" - var(--segments-gap)"})`,h=yt.createElementNS("http://www.w3.org/2000/svg","rect"),f=qe(this.shadowRoot,`#segments-clipping rect:nth-child(${n+1})`);f.style.setProperty("x",d),f.style.setProperty("width",u),t.append(h)}}getPointerRatio(e){return PT(e.clientX,e.clientY,Fe(this,Sn).getBoundingClientRect(),Fe(this,An).getBoundingClientRect())}get dragging(){return this.hasAttribute("dragging")}handleEvent(e){switch(e.type){case"pointermove":$t(this,ul,Og).call(this,e);break;case"input":this.updateBar();break;case"pointerenter":$t(this,ll,Pg).call(this,e);break;case"pointerdown":$t(this,na,od).call(this,e);break;case"pointerup":$t(this,dl,wg).call(this);break;case"pointerleave":$t(this,cl,Mg).call(this);break}}get keysUsed(){return["ArrowUp","ArrowRight","ArrowDown","ArrowLeft"]}}zt=new WeakMap;Ia=new WeakMap;Sn=new WeakMap;An=new WeakMap;Bt=new WeakMap;ra=new WeakMap;bn=new WeakMap;In=new WeakMap;_n=new WeakMap;ad=new WeakSet;Cg=function(s){const e=Fe(this,Bt).activeSegment;if(!e)return;const t=this.getPointerRatio(s),r=`#segments-clipping rect:nth-child(${Fe(this,ra).findIndex((n,a,o)=>{const l=o[a+1];return l!=null&&t>=n&&t<=l})+1})`;(e.selectorText!=r||!e.style.transform)&&(e.selectorText=r,e.style.setProperty("transform","var(--media-range-segment-hover-transform, scaleY(2))"))};Ln=new WeakSet;al=function(){this.hasAttribute("disabled")||(this.addEventListener("input",this),this.addEventListener("pointerdown",this),this.addEventListener("pointerenter",this))};xn=new WeakSet;ol=function(){var s,e;this.removeEventListener("input",this),this.removeEventListener("pointerdown",this),this.removeEventListener("pointerenter",this),(s=P.window)==null||s.removeEventListener("pointerup",this),(e=P.window)==null||e.removeEventListener("pointermove",this)};na=new WeakSet;od=function(s){var e;bi(this,Ia,s.composedPath().includes(this.range)),(e=P.window)==null||e.addEventListener("pointerup",this)};ll=new WeakSet;Pg=function(s){var e;s.pointerType!=="mouse"&&$t(this,na,od).call(this,s),this.addEventListener("pointerleave",this),(e=P.window)==null||e.addEventListener("pointermove",this)};dl=new WeakSet;wg=function(){var s;(s=P.window)==null||s.removeEventListener("pointerup",this),this.toggleAttribute("dragging",!1),this.range.disabled=this.hasAttribute("disabled")};cl=new WeakSet;Mg=function(){var s,e;this.removeEventListener("pointerleave",this),(s=P.window)==null||s.removeEventListener("pointermove",this),this.toggleAttribute("dragging",!1),this.range.disabled=this.hasAttribute("disabled"),(e=Fe(this,Bt).activeSegment)==null||e.style.removeProperty("transform")};ul=new WeakSet;Og=function(s){this.toggleAttribute("dragging",s.buttons===1||s.pointerType!=="mouse"),this.updatePointerBar(s),$t(this,ad,Cg).call(this,s),this.dragging&&(s.pointerType!=="mouse"||!Fe(this,Ia))&&(this.range.disabled=!0,this.range.valueAsNumber=this.getPointerRatio(s),this.range.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})))};Cs.shadowRootOptions={mode:"open"};Cs.getTemplateHTML=BS;P.customElements.get("media-chrome-range")||P.customElements.define("media-chrome-range",Cs);var Fg=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Zr=(s,e,t)=>(Fg(s,e,"read from private field"),t?t.call(s):e.get(s)),GS=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)}
789,Jr=(s,e,t,i)=>(Fg(s,e,"write to private field"),e.set(s,t),t),Qt;function VS(s){return`
790    <style>
791      :host {
792        
793        box-sizing: border-box;
794        display: var(--media-control-display, var(--media-control-bar-display, inline-flex));
795        color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238)));
796        --media-loading-indicator-icon-height: 44px;
797      }
798
799      ::slotted(media-time-range),
800      ::slotted(media-volume-range) {
801        min-height: 100%;
802      }
803
804      ::slotted(media-time-range),
805      ::slotted(media-clip-selector) {
806        flex-grow: 1;
807      }
808
809      ::slotted([role="menu"]) {
810        position: absolute;
811      }
812    </style>
813
814    <slot></slot>
815  `}class ld extends P.HTMLElement{constructor(){if(super(),GS(this,Qt,void 0),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);const e=Gt(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}}static get observedAttributes(){return[be.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,i){var r,n,a,o,l;e===be.MEDIA_CONTROLLER&&(t&&((n=(r=Zr(this,Qt))==null?void 0:r.unassociateElement)==null||n.call(r,this),Jr(this,Qt,null)),i&&this.isConnected&&(Jr(this,Qt,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(l=(o=Zr(this,Qt))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,i;const r=this.getAttribute(be.MEDIA_CONTROLLER);r&&(Jr(this,Qt,(e=this.getRootNode())==null?void 0:e.getElementById(r)),(i=(t=Zr(this,Qt))==null?void 0:t.associateElement)==null||i.call(t,this))}disconnectedCallback(){var e,t;(t=(e=Zr(this,Qt))==null?void 0:e.unassociateElement)==null||t.call(e,this),Jr(this,Qt,null)}}Qt=new WeakMap;ld.shadowRootOptions={mode:"open"};ld.getTemplateHTML=VS;P.customElements.get("media-control-bar")||P.customElements.define("media-control-bar",ld);var Ng=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},en=(s,e,t)=>(Ng(s,e,"read from private field"),t?t.call(s):e.get(s)),HS=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},tn=(s,e,t,i)=>(Ng(s,e,"write to private field"),e.set(s,t),t),Xt;function KS(s,e={}){return`
816    <style>
817      :host {
818        font: var(--media-font,
819          var(--media-font-weight, normal)
820          var(--media-font-size, 14px) /
821          var(--media-text-content-height, var(--media-control-height, 24px))
822          var(--media-font-family, helvetica neue, segoe ui, roboto, arial, sans-serif));
823        color: var(--media-text-color, var(--media-primary-color, rgb(238 238 238)));
824        background: var(--media-text-background, var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .7))));
825        padding: var(--media-control-padding, 10px);
826        display: inline-flex;
827        justify-content: center;
828        align-items: center;
829        vertical-align: middle;
830        box-sizing: border-box;
831        text-align: center;
832        pointer-events: auto;
833      }
834
835      
836      :host(:focus-visible) {
837        box-shadow: inset 0 0 0 2px rgb(27 127 204 / .9);
838        outline: 0;
839      }
840
841      
842      :host(:where(:focus)) {
843        box-shadow: none;
844        outline: 0;
845      }
846    </style>
847
848    ${this.getSlotTemplateHTML(s,e)}
849  `}function WS(s,e){return`
850    <slot></slot>
851  `}class Pi extends P.HTMLElement{constructor(){if(super(),HS(this,Xt,void 0),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);const e=Gt(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}}static get observedAttributes(){return[be.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,i){var r,n,a,o,l;e===be.MEDIA_CONTROLLER&&(t&&((n=(r=en(this,Xt))==null?void 0:r.unassociateElement)==null||n.call(r,this),tn(this,Xt,null)),i&&this.isConnected&&(tn(this,Xt,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(l=(o=en(this,Xt))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,i;const{style:r}=qe(this.shadowRoot,":host");r.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`);const n=this.getAttribute(be.MEDIA_CONTROLLER);n&&(tn(this,Xt,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(i=(t=en(this,Xt))==null?void 0:t.associateElement)==null||i.call(t,this))}disconnectedCallback(){var e,t;(t=(e=en(this,Xt))==null?void 0:e.unassociateElement)==null||t.call(e,this),tn(this,Xt,null)}}Xt=new WeakMap;Pi.shadowRootOptions={mode:"open"};Pi.getTemplateHTML=KS;Pi.getSlotTemplateHTML=WS;P.customElements.get("media-text-display")||P.customElements.define("media-text-display",Pi);var Ug=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Su=(s,e,t)=>(Ug(s,e,"read from private field"),t?t.call(s):e.get(s)),YS=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},qS=(s,e,t,i)=>(Ug(s,e,"write to private field"),e.set(s,t),t),js;function jS(s,e){return`
852    <slot>${Di(e.mediaDuration)}</slot>
853  `}class $g extends Pi{constructor(){var e;super(),YS(this,js,void 0),qS(this,js,this.shadowRoot.querySelector("slot")),Su(this,js).textContent=Di((e=this.mediaDuration)!=null?e:0)}static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_DURATION]}attributeChangedCallback(e,t,i){e===b.MEDIA_DURATION&&(Su(this,js).textContent=Di(+i)),super.attributeChangedCallback(e,t,i)}get mediaDuration(){return $e(this,b.MEDIA_DURATION)}set mediaDuration(e){tt(this,b.MEDIA_DURATION,e)}}js=new WeakMap;$g.getSlotTemplateHTML=jS;P.customElements.get("media-duration-display")||P.customElements.define("media-duration-display",$g);const zS={2:ne("Network Error"),3:ne("Decode Error"),4:ne("Source Not Supported"),5:ne("Encryption 
853Error")},QS={2:ne("A network error caused the media download to fail."),3:ne("A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format."),4:ne("An unsupported error occurred. The server or network failed, or your browser does not support this format."),5:ne("The media is encrypted and there are no keys to decrypt it.")},Bg=s=>{var e,t;return s.code===1?null:{title:(e=zS[s.code])!=null?e:`Error ${s.code}`,message:(t=QS[s.code])!=null?t:s.message}};var Gg=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},XS=(s,e,t)=>(Gg(s,e,"read from private field"),t?t.call(s):e.get(s)),ZS=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},JS=(s,e,t,i)=>(Gg(s,e,"write to private field"),e.set(s,t),t),Rn;function eA(s){return`
854    <style>
855      :host {
856        background: rgb(20 20 30 / .8);
857      }
858
859      #content {
860        display: block;
861        padding: 1.2em 1.5em;
862      }
863
864      h3,
865      p {
866        margin-block: 0 .3em;
867      }
868    </style>
869    <slot name="error-${s.mediaerrorcode}" id="content">
870      ${Vg({code:+s.mediaerrorcode,message:s.mediaerrormessage})}
871    </slot>
872  `}function tA(s){return s.code&&Bg(s)!==null}function Vg(s){var e;const{title:t,message:i}=(e=Bg(s))!=null?e:{};let r="";return t&&(r+=`<slot name="error-${s.code}-title"><h3>${t}</h3></slot>`),i&&(r+=`<slot name="error-${s.code}-message"><p>${i}</p></slot>`),r}const Au=[b.MEDIA_ERROR_CODE,b.MEDIA_ERROR_MESSAGE];class dd extends Cr{constructor(){super(...arguments),ZS(this,Rn,null)}static get observedAttributes(){return[...super.observedAttributes,...Au]}formatErrorMessage(e){return this.constructor.formatErrorMessage(e)}attributeChangedCallback(e,t,i){var r;if(super.attributeChangedCallback(e,t,i),!Au.includes(e))return;const n=(r=this.mediaError)!=null?r:{code:this.mediaErrorCode,message:this.mediaErrorMessage};this.open=tA(n),this.open&&(this.shadowRoot.querySelector("slot").name=`error-${this.mediaErrorCode}`,this.shadowRoot.querySelector("#content").innerHTML=this.formatErrorMessage(n))}get mediaError(){return XS(this,Rn)}set mediaError(e){JS(this,Rn,e)}get mediaErrorCode(){return $e(this,"mediaerrorcode")}set mediaErrorCode(e){tt(this,"mediaerrorcode",e)}get mediaErrorMessage(){return Be(this,"mediaerrormessage")}set mediaErrorMessage(e){Ge(this,"mediaerrormessage",e)}}Rn=new WeakMap;dd.getSlotTemplateHTML=eA;dd.formatErrorMessage=Vg;P.customElements.get("media-error-dialog")||P.customElements.define("media-error-dialog",dd);const iA=`<svg aria-hidden="true" viewBox="0 0 26 24">
873  <path d="M16 3v2.5h3.5V9H22V3h-6ZM4 9h2.5V5.5H10V3H4v6Zm15.5 9.5H16V21h6v-6h-2.5v3.5ZM6.5 15H4v6h6v-2.5H6.5V15Z"/>
874</svg>`,sA=`<svg aria-hidden="true" viewBox="0 0 26 24">
875  <path d="M18.5 6.5V3H16v6h6V6.5h-3.5ZM16 21h2.5v-3.5H22V15h-6v6ZM4 17.5h3.5V21H10v-6H4v2.5Zm3.5-11H4V9h6V3H7.5v3.5Z"/>
876</svg>`;function rA(s){return`
877    <style>
878      :host([${b.MEDIA_IS_FULLSCREEN}]) slot[name=icon] slot:not([name=exit]) {
879        display: none !important;
880      }
881
882      
883      :host(:not([${b.MEDIA_IS_FULLSCREEN}])) slot[name=icon] slot:not([name=enter]) {
884        display: none !important;
885      }
886
887      :host([${b.MEDIA_IS_FULLSCREEN}]) slot[name=tooltip-enter],
888      :host(:not([${b.MEDIA_IS_FULLSCREEN}])) slot[name=tooltip-exit] {
889        display: none;
890      }
891    </style>
892
893    <slot name="icon">
894      <slot name="enter">${iA}</slot>
895      <slot name="exit">${sA}</slot>
896    </slot>
897  `}function nA(){return`
898    <slot name="tooltip-enter">${ne("Enter fullscreen mode")}</slot>
899    <slot name="tooltip-exit">${ne("Exit fullscreen mode")}</slot>
900  `}const bu=s=>{const e=s.mediaIsFullscreen?ne("exit fullscreen mode"):ne("enter fullscreen mode");s.setAttribute("aria-label",e)};class cd extends ut{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_IS_FULLSCREEN,b.MEDIA_FULLSCREEN_UNAVAILABLE]}connectedCallback(){super.connectedCallback(),bu(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===b.MEDIA_IS_FULLSCREEN&&bu(this)}get mediaFullscreenUnavailable(){return Be(this,b.MEDIA_FULLSCREEN_UNAVAILABLE)}
900set mediaFullscreenUnavailable(e){Ge(this,b.MEDIA_FULLSCREEN_UNAVAILABLE,e)}get mediaIsFullscreen(){return Ee(this,b.MEDIA_IS_FULLSCREEN)}set mediaIsFullscreen(e){ve(this,b.MEDIA_IS_FULLSCREEN,e)}handleClick(){const e=this.mediaIsFullscreen?ee.MEDIA_EXIT_FULLSCREEN_REQUEST:ee.MEDIA_ENTER_FULLSCREEN_REQUEST;this.dispatchEvent(new P.CustomEvent(e,{composed:!0,bubbles:!0}))}}cd.getSlotTemplateHTML=rA;cd.getTooltipContentHTML=nA;P.customElements.get("media-fullscreen-button")||P.customElements.define("media-fullscreen-button",cd);const{MEDIA_TIME_IS_LIVE:Dn,MEDIA_PAUSED:ar}=b,{MEDIA_SEEK_TO_LIVE_REQUEST:aA,MEDIA_PLAY_REQUEST:oA}=ee,lA='<svg viewBox="0 0 6 12"><circle cx="3" cy="6" r="2"></circle></svg>';function dA(s){return`
901    <style>
902      :host { --media-tooltip-display: none; }
903      
904      slot[name=indicator] > *,
905      :host ::slotted([slot=indicator]) {
906        
907        min-width: auto;
908        fill: var(--media-live-button-icon-color, rgb(140, 140, 140));
909        color: var(--media-live-button-icon-color, rgb(140, 140, 140));
910      }
911
912      :host([${Dn}]:not([${ar}])) slot[name=indicator] > *,
913      :host([${Dn}]:not([${ar}])) ::slotted([slot=indicator]) {
914        fill: var(--media-live-button-indicator-color, rgb(255, 0, 0));
915        color: var(--media-live-button-indicator-color, rgb(255, 0, 0));
916      }
917
918      :host([${Dn}]:not([${ar}])) {
919        cursor: var(--media-cursor, not-allowed);
920      }
921
922      slot[name=text]{
923        text-transform: uppercase;
924      }
925
926    </style>
927
928    <slot name="indicator">${lA}</slot>
929    
930    <slot name="spacer">&nbsp;</slot><slot name="text">${ne("live")}</slot>
931  `}const Iu=s=>{var e;const t=s.mediaPaused||!s.mediaTimeIsLive,i=ne(t?"seek to live":"playing live");s.setAttribute("aria-label",i);const r=(e=s.shadowRoot)==null?void 0:e.querySelector('slot[name="text"]');r&&(r.textContent=ne("live")),t?s.removeAttribute("aria-disabled"):s.setAttribute("aria-disabled","true")};class Hg extends ut{static get observedAttributes(){return[...super.observedAttributes,Dn,ar]}connectedCallback(){super.connectedCallback(),Iu(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),Iu(this)}get mediaPaused(){return Ee(this,b.MEDIA_PAUSED)}set mediaPaused(e){ve(this,b.MEDIA_PAUSED,e)}get mediaTimeIsLive(){return Ee(this,b.MEDIA_TIME_IS_LIVE)}set mediaTimeIsLive(e){ve(this,b.MEDIA_TIME_IS_LIVE,e)}handleClick(){!this.mediaPaused&&this.mediaTimeIsLive||(this.dispatchEvent(new P.CustomEvent(aA,{composed:!0,bubbles:!0})),this.hasAttribute(ar)&&this.dispatchEvent(new P.CustomEvent(oA,{composed:!0,bubbles:!0})))}}Hg.getSlotTemplateHTML=dA;P.customElements.get("media-live-button")||P.customElements.define("media-live-button",Hg);var Kg=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},$s=(s,e,t)=>(Kg(s,e,"read from private field"),t?t.call(s):e.get(s)),_u=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},Bs=(s,e,t,i)=>(Kg(s,e,"write to private field"),e.set(s,t),t),Zt,kn;const sn={LOADING_DELAY:"loadingdelay",NO_AUTOHIDE:"noautohide"},Wg=500,cA=`
932<svg aria-hidden="true" viewBox="0 0 100 100">
933  <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">
934    <animateTransform
935       attributeName="transform"
936       attributeType="XML"
937       type="rotate"
938       dur="1s"
939       from="0 50 50"
940       to="360 50 50"
941       repeatCount="indefinite" />
942  </path>
943</svg>
944`;function uA(s){return`
945    <style>
946      :host {
947        display: var(--media-control-display, var(--media-loading-indicator-display, inline-block));
948        vertical-align: middle;
949        box-sizing: border-box;
950        --_loading-indicator-delay: var(--media-loading-indicator-transition-delay, ${Wg}ms);
951      }
952
953      #status {
954        color: rgba(0,0,0,0);
955        width: 0px;
956        height: 0px;
957      }
958
959      :host slot[name=icon] > *,
960      :host ::slotted([slot=icon]) {
961        opacity: var(--media-loading-indicator-opacity, 0);
962        transition: opacity 0.15s;
963      }
964
965      :host([${b.MEDIA_LOADING}]:not([${b.MEDIA_PAUSED}])) slot[name=icon] > *,
966      :host([${b.MEDIA_LOADING}]:not([${b.MEDIA_PAUSED}])) ::slotted([slot=icon]) {
967        opacity: var(--media-loading-indicator-opacity, 1);
968        transition: opacity 0.15s var(--_loading-indicator-delay);
969      }
970
971      :host #status {
972        visibility: var(--media-loading-indicator-opacity, hidden);
973        transition: visibility 0.15s;
974      }
975
976      :host([${b.MEDIA_LOADING}]:not([${b.MEDIA_PAUSED}])) #status {
977        visibility: var(--media-loading-indicator-opacity, visible);
978        transition: visibility 0.15s var(--_loading-indicator-delay);
979      }
980
981      svg, img, ::slotted(svg), ::slotted(img) {
982        width: var(--media-loading-indicator-icon-width);
983        height: var(--media-loading-indicator-icon-height, 100px);
984        fill: var(--media-icon-color, var(--media-primary-color, rgb(238 238 238)));
985        vertical-align: middle;
986      }
987    </style>
988
989    <slot name="icon">${cA}</slot>
990    <div id="status" role="status" aria-live="polite">${ne("media loading")}</div>
991  `}class ud extends P.HTMLElement{constructor(){if(super(),_u(this,Zt,void 0),_u(this,kn,Wg),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);const e=Gt(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}}static get observedAttributes(){return[be.MEDIA_CONTROLLER,b.MEDIA_PAUSED,b.MEDIA_LOADING,sn.LOADING_DELAY]}attributeChangedCallback(e,t,i){var r,n,a,o,l;e===sn.LOADING_DELAY&&t!==i?this.loadingDelay=Number(i):e===be.MEDIA_CONTROLLER&&(t&&((n=(r=$s(this,Zt))==null?void 0:r.unassociateElement)==null||n.call(r,this),Bs(this,Zt,null)),i&&this.isConnected&&(Bs(this,Zt,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(l=(o=$s(this,Zt))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,i;const r=this.getAttribute(be.MEDIA_CONTROLLER);r&&(Bs(this,Zt,(e=this.getRootNode())==null?void 0:e.getElementById(r)),(i=(t=$s(this,Zt))==null?void 0:t.associateElement)==null||i.call(t,this))}disconnectedCallback(){var e,t;(t=(e=$s(this,Zt))==null?void 0:e.unassociateElement)==null||t.call(e,this),Bs(this,Zt,null)}get loadingDelay(){return $s(this,kn)}set loadingDelay(e){Bs(this,kn,e);const{style:t}=qe(this.shadowRoot,":host");t.setProperty("--_loading-indicator-delay",`var(--media-loading-indicator-transition-delay, ${e}ms)`)}get mediaPaused(){return Ee(this,b.MEDIA_PAUSED)}set mediaPaused(e){ve(this,b.MEDIA_PAUSED,e)}get mediaLoading(){return Ee(this,b.MEDIA_LOADING)}set mediaLoading(e){ve(this,b.MEDIA_LOADING,e)}get mediaController(){return Be(this,be.MEDIA_CONTROLLER)}set mediaController(e){Ge(this,be.MEDIA_CONTROLLER,e)}get noAutohide(){return Ee(this,sn.NO_AUTOHIDE)}set noAutohide(e){ve(this,sn.NO_AUTOHIDE,e)}}Zt=new WeakMap;kn=new WeakMap;ud.shadowRootOptions={mode:"open"};ud.getTemplateHTML=uA;P.customElements.get("media-loading-indicator")||P.customElements.define("media-loading-indicator",ud);const hA=`<svg aria-hidden="true" viewBox="0 0 24 24">
992  <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"/>
993</svg>`,Lu=`<svg aria-hidden="true" viewBox="0 0 24 24">
994  <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"/>
995</svg>`,fA=`<svg aria-hidden="true" viewBox="0 0 24 24">
996  <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"/>
997</svg>`;function gA(s){return`
998    <style>
999      :host(:not([${b.MEDIA_VOLUME_LEVEL}])) slot[name=icon] slot:not([name=high]),
1000      :host([${b.MEDIA_VOLUME_LEVEL}=high]) slot[name=icon] slot:not([name=high]) {
1001        display: none !important;
1002      }
1003
1004      :host([${b.MEDIA_VOLUME_LEVEL}=off]) slot[name=icon] slot:not([name=off]) {
1005        display: none !important;
1006      }
1007
1008      :host([${b.MEDIA_VOLUME_LEVEL}=low]) slot[name=icon] slot:not([name=low]) {
1009        display: none !important;
1010      }
1011
1012      :host([${b.MEDIA_VOLUME_LEVEL}=medium]) slot[name=icon] slot:not([name=medium]) {
1013        display: none !important;
1014      }
1015
1016      :host(:not([${b.MEDIA_VOLUME_LEVEL}=off])) slot[name=tooltip-unmute],
1017      :host([${b.MEDIA_VOLUME_LEVEL}=off]) slot[name=tooltip-mute] {
1018        display: none;
1019      }
1020    </style>
1021
1022    <slot name="icon">
1023      <slot name="off">${hA}</slot>
1024      <slot name="low">${Lu}</slot>
1025      <slot name="medium">${Lu}</slot>
1026      <slot name="high">${fA}</slot>
1027    </slot>
1028  `}function mA(){return`
1029    <slot name="tooltip-mute">${ne("Mute")}</slot>
1030    <slot name="tooltip-unmute">${ne("Unmute")}</slot>
1031  `}const xu=s=>{const e=s.mediaVolumeLevel==="off",t=ne(e?"unmute":"mute");s.setAttribute("aria-label",t)};class hd extends ut{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_VOLUME_LEVEL]}connectedCallback(){super.connectedCallback(),xu(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===b.MEDIA_VOLUME_LEVEL&&xu(this)}get mediaVolumeLevel(){return Be(this,b.MEDIA_VOLUME_LEVEL)}
1031set mediaVolumeLevel(e){Ge(this,b.MEDIA_VOLUME_LEVEL,e)}handleClick(){const e=this.mediaVolumeLevel==="off"?ee.MEDIA_UNMUTE_REQUEST:ee.MEDIA_MUTE_REQUEST;this.dispatchEvent(new P.CustomEvent(e,{composed:!0,bubbles:!0}))}}hd.getSlotTemplateHTML=gA;hd.getTooltipContentHTML=mA;P.customElements.get("media-mute-button")||P.customElements.define("media-mute-button",hd);const Ru=`<svg aria-hidden="true" viewBox="0 0 28 24">
1032  <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"/>
1033</svg>`;function pA(s){return`
1034    <style>
1035      :host([${b.MEDIA_IS_PIP}]) slot[name=icon] slot:not([name=exit]) {
1036        display: none !important;
1037      }
1038
1039      :host(:not([${b.MEDIA_IS_PIP}])) slot[name=icon] slot:not([name=enter]) {
1040        display: none !important;
1041      }
1042
1043      :host([${b.MEDIA_IS_PIP}]) slot[name=tooltip-enter],
1044      :host(:not([${b.MEDIA_IS_PIP}])) slot[name=tooltip-exit] {
1045        display: none;
1046      }
1047    </style>
1048
1049    <slot name="icon">
1050      <slot name="enter">${Ru}</slot>
1051      <slot name="exit">${Ru}</slot>
1052    </slot>
1053  `}function EA(){return`
1054    <slot name="tooltip-enter">${ne("Enter picture in picture mode")}</slot>
1055    <slot name="tooltip-exit">${ne("Exit picture in picture mode")}</slot>
1056  `}const Du=s=>{const e=s.mediaIsPip?ne("exit picture in picture mode"):ne("enter picture in picture mode");s.setAttribute("aria-label",e)};class fd extends ut{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_IS_PIP,b.MEDIA_PIP_UNAVAILABLE]}connectedCallback(){super.connectedCallback(),Du(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===b.MEDIA_IS_PIP&&Du(this)}get mediaPipUnavailable(){return Be(this,b.MEDIA_PIP_UNAVAILABLE)}set mediaPipUnavailable(e){Ge(this,b.MEDIA_PIP_UNAVAILABLE,e)}get mediaIsPip(){return Ee(this,b.MEDIA_IS_PIP)}set mediaIsPip(e){ve(this,b.MEDIA_IS_PIP,e)}handleClick(){const e=this.mediaIsPip?ee.MEDIA_EXIT_PIP_REQUEST:ee.MEDIA_ENTER_PIP_REQUEST;this.dispatchEvent(new P.CustomEvent(e,{composed:!0,bubbles:!0}))}}fd.getSlotTemplateHTML=pA;fd.getTooltipContentHTML=EA;P.customElements.get("media-pip-button")||P.customElements.define("media-pip-button",fd);var vA=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},es=(s,e,t)=>(vA(s,e,"read from private field"),t?t.call(s):e.get(s)),yA=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},Ii;const to={RATES:"rates"},TA=[1,1.2,1.5,1.7,2],zs=1;function SA(s){return`
1057    <style>
1058      :host {
1059        min-width: 5ch;
1060        padding: var(--media-button-padding, var(--media-control-padding, 10px 5px));
1061      }
1062    </style>
1063    <slot name="icon">${s.mediaplaybackrate||zs}x</slot>
1064  `}function AA(){return ne("Playback rate")}class gd extends ut{constructor(){var e;super(),yA(this,Ii,new gg(this,to.RATES,{defaultValue:TA})),this.container=this.shadowRoot.querySelector('slot[name="icon"]'),this.container.innerHTML=`${(e=this.mediaPlaybackRate)!=null?e:zs}x`}static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_PLAYBACK_RATE,to.RATES]}attributeChangedCallback(e,t,i){if(super.attributeChangedCallback(e,t,i),e===to.RATES&&(es(this,Ii).value=i),e===b.MEDIA_PLAYBACK_RATE){const r=i?+i:Number.NaN,n=Number.isNaN(r)?zs:r;this.container.innerHTML=`${n}x`,this.setAttribute("aria-label",ne("Playback rate {playbackRate}",{playbackRate:n}))}}get rates(){return es(this,Ii)}set rates(e){e?Array.isArray(e)?es(this,Ii).value=e.join(" "):typeof e=="string"&&(es(this,Ii).value=e):es(this,Ii).value=""}get mediaPlaybackRate(){return $e(this,b.MEDIA_PLAYBACK_RATE,zs)}set mediaPlaybackRate(e){tt(this,b.MEDIA_PLAYBACK_RATE,e)}handleClick(){var e,t;const i=Array.from(es(this,Ii).values(),a=>+a).sort((a,o)=>a-o),r=(t=(e=i.find(a=>a>this.mediaPlaybackRate))!=null?e:i[0])!=null?t:zs,n=new P.CustomEvent(ee.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:r});this.dispatchEvent(n)}}Ii=new WeakMap;gd.getSlotTemplateHTML=SA;gd.getTooltipContentHTML=AA;P.customElements.get("media-playback-rate-button")||P.customElements.define("media-playback-rate-button",gd);const bA=`<svg aria-hidden="true" viewBox="0 0 24 24">
1065  <path d="m6 21 15-9L6 3v18Z"/>
1066</svg>`,IA=`<svg aria-hidden="true" viewBox="0 0 24 24">
1067  <path d="M6 20h4V4H6v16Zm8-16v16h4V4h-4Z"/>
1068</svg>`;function _A(s){return`
1069    <style>
1070      :host([${b.MEDIA_PAUSED}]) slot[name=pause],
1071      :host(:not([${b.MEDIA_PAUSED}])) slot[name=play] {
1072        display: none !important;
1073      }
1074
1075      :host([${b.MEDIA_PAUSED}]) slot[name=tooltip-pause],
1076      :host(:not([${b.MEDIA_PAUSED}
1076])) slot[name=tooltip-play] {
1077        display: none;
1078      }
1079    </style>
1080
1081    <slot name="icon">
1082      <slot name="play">${bA}</slot>
1083      <slot name="pause">${IA}</slot>
1084    </slot>
1085  `}function LA(){return`
1086    <slot name="tooltip-play">${ne("Play")}</slot>
1087    <slot name="tooltip-pause">${ne("Pause")}</slot>
1088  `}const ku=s=>{const e=s.mediaPaused?ne("play"):ne("pause");s.setAttribute("aria-label",e)};class md extends ut{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_PAUSED,b.MEDIA_ENDED]}connectedCallback(){super.connectedCallback(),ku(this)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),(e===b.MEDIA_PAUSED||e===b.MEDIA_LANG)&&ku(this)}get mediaPaused(){return Ee(this,b.MEDIA_PAUSED)}set mediaPaused(e){ve(this,b.MEDIA_PAUSED,e)}handleClick(){const e=this.mediaPaused?ee.MEDIA_PLAY_REQUEST:ee.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new P.CustomEvent(e,{composed:!0,bubbles:!0}))}}md.getSlotTemplateHTML=_A;md.getTooltipContentHTML=LA;P.customElements.get("media-play-button")||P.customElements.define("media-play-button",md);const Wt={PLACEHOLDER_SRC:"placeholdersrc",SRC:"src"};function xA(s){return`
1089    <style>
1090      :host {
1091        pointer-events: none;
1092        display: var(--media-poster-image-display, inline-block);
1093        box-sizing: border-box;
1094      }
1095
1096      img {
1097        max-width: 100%;
1098        max-height: 100%;
1099        min-width: 100%;
1100        min-height: 100%;
1101        background-repeat: no-repeat;
1102        background-position: var(--media-poster-image-background-position, var(--media-object-position, center));
1103        background-size: var(--media-poster-image-background-size, var(--media-object-fit, contain));
1104        object-fit: var(--media-object-fit, contain);
1105        object-position: var(--media-object-position, center);
1106      }
1107    </style>
1108
1109    <img part="poster img" aria-hidden="true" id="image"/>
1110  `}const RA=s=>{s.style.removeProperty("background-image")},DA=(s,e)=>{s.style["background-image"]=`url('${e}')`};class pd extends P.HTMLElement{static get observedAttributes(){return[Wt.PLACEHOLDER_SRC,Wt.SRC]}constructor(){if(super(),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);const e=Gt(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}this.image=this.shadowRoot.querySelector("#image")}attributeChangedCallback(e,t,i){e===Wt.SRC&&(i==null?this.image.removeAttribute(Wt.SRC):this.image.setAttribute(Wt.SRC,i)),e===Wt.PLACEHOLDER_SRC&&(i==null?RA(this.image):DA(this.image,i))}get placeholderSrc(){return Be(this,Wt.PLACEHOLDER_SRC)}set placeholderSrc(e){Ge(this,Wt.SRC,e)}get src(){return Be(this,Wt.SRC)}set src(e){Ge(this,Wt.SRC,e)}}pd.shadowRootOptions={mode:"open"};pd.getTemplateHTML=xA;P.customElements.get("media-poster-image")||P.customElements.define("media-poster-image",pd);var Yg=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},kA=(s,e,t)=>(Yg(s,e,"read from private field"),t?t.call(s):e.get(s)),CA=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},PA=(s,e,t,i)=>(Yg(s,e,"write to private field"),e.set(s,t),t),Cn;class wA extends Pi{constructor(){super(),CA(this,Cn,void 0),PA(this,Cn,this.shadowRoot.querySelector("slot"))}static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_PREVIEW_CHAPTER,b.MEDIA_LANG]}attributeChangedCallback(e,t,i){if(super.attributeChangedCallback(e,t,i),(e===b.MEDIA_PREVIEW_CHAPTER||e===b.MEDIA_LANG)&&i!==t&&i!=null)if(kA(this,Cn).textContent=i,i!==""){const r=ne("chapter: {chapterName}",{chapterName:i});this.setAttribute("aria-valuetext",r)}else this.removeAttribute("aria-valuetext")}get mediaPreviewChapter(){return Be(this,b.MEDIA_PREVIEW_CHAPTER)}set mediaPreviewChapter(e){Ge(this,b.MEDIA_PREVIEW_CHAPTER,e)}}Cn=new WeakMap;P.customElements.get("media-preview-chapter-display")||P.customElements.define("media-preview-chapter-display",wA);var qg=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},rn=(s,e,t)=>(qg(s,e,"read from private field"),t?t.call(s):e.get(s)),MA=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},nn=(s,e,t,i)=>(qg(s,e,"write to private field"),e.set(s,t),t),Jt;function OA(s){return`
1111    <style>
1112      :host {
1113        box-sizing: border-box;
1114        display: var(--media-control-display, var(--media-preview-thumbn
1114ail-display, inline-block));
1115        overflow: hidden;
1116      }
1117
1118      img {
1119        display: none;
1120        position: relative;
1121      }
1122    </style>
1123    <img crossorigin loading="eager" decoding="async">
1124  `}class _a extends P.HTMLElement{constructor(){if(super(),MA(this,Jt,void 0),!this.shadowRoot){this.attachShadow(this.constructor.shadowRootOptions);const e=Gt(this.attributes);this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(e)}}static get observedAttributes(){return[be.MEDIA_CONTROLLER,b.MEDIA_PREVIEW_IMAGE,b.MEDIA_PREVIEW_COORDS]}connectedCallback(){var e,t,i;const r=this.getAttribute(be.MEDIA_CONTROLLER);r&&(nn(this,Jt,(e=this.getRootNode())==null?void 0:e.getElementById(r)),(i=(t=rn(this,Jt))==null?void 0:t.associateElement)==null||i.call(t,this))}disconnectedCallback(){var e,t;(t=(e=rn(this,Jt))==null?void 0:e.unassociateElement)==null||t.call(e,this),nn(this,Jt,null)}attributeChangedCallback(e,t,i){var r,n,a,o,l;[b.MEDIA_PREVIEW_IMAGE,b.MEDIA_PREVIEW_COORDS].includes(e)&&this.update(),e===be.MEDIA_CONTROLLER&&(t&&((n=(r=rn(this,Jt))==null?void 0:r.unassociateElement)==null||n.call(r,this),nn(this,Jt,null)),i&&this.isConnected&&(nn(this,Jt,(a=this.getRootNode())==null?void 0:a.getElementById(i)),(l=(o=rn(this,Jt))==null?void 0:o.associateElement)==null||l.call(o,this)))}get mediaPreviewImage(){return Be(this,b.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){Ge(this,b.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewCoords(){const 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(){const e=this.mediaPreviewCoords,t=this.mediaPreviewImage;if(!(e&&t))return;const[i,r,n,a]=e,o=t.split("#")[0],l=getComputedStyle(this),{maxWidth:d,maxHeight:c,minWidth:u,minHeight:h}=l,f=Math.min(parseInt(d)/n,parseInt(c)/a),g=Math.max(parseInt(u)/n,parseInt(h)/a),m=f<1,p=m?f:g>1?g:1,{style:v}=qe(this.shadowRoot,":host"),T=qe(this.shadowRoot,"img").style,y=this.shadowRoot.querySelector("img"),S=m?"min":"max";v.setProperty(`${S}-width`,"initial","important"),v.setProperty(`${S}-height`,"initial","important"),v.width=`${n*p}px`,v.height=`${a*p}px`;const A=()=>{T.width=`${this.imgWidth*p}px`,T.height=`${this.imgHeight*p}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(-${i*p}px, -${r*p}px)`}}Jt=new WeakMap;_a.shadowRootOptions={mode:"open"};_a.getTemplateHTML=OA;P.customElements.get("media-preview-thumbnail")||P.customElements.define("media-preview-thumbnail",_a);var Cu=_a,jg=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Pu=(s,e,t)=>(jg(s,e,"read from private field"),t?t.call(s):e.get(s)),FA=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},NA=(s,e,t,i)=>(jg(s,e,"write to private field"),e.set(s,t),t),Qs;class UA extends Pi{constructor(){super(),FA(this,Qs,void 0),NA(this,Qs,this.shadowRoot.querySelector("slot")),Pu(this,Qs).textContent=Di(0)}static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_PREVIEW_TIME]}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===b.MEDIA_PREVIEW_TIME&&i!=null&&(Pu(this,Qs).textContent=Di(parseFloat(i)))}get mediaPreviewTime(){return $e(this,b.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){tt(this,b.MEDIA_PREVIEW_TIME,e)}}Qs=new WeakMap;P.customElements.get("media-preview-time-display")||P.customElements.define("media-preview-time-display",UA);const ts={SEEK_OFFSET:"seekoffset"},io=30,$A=s=>`
1125  <svg aria-hidden="true" viewBox="0 0 20 24">
1126    <defs>
1127      <style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style>
1128    </defs>
1129    <text class="text value" transform="translate(2.18 19.87)">${s}</text>
1130    <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"/>
1131  </svg>`;function BA(s,e){return`
1132    <slot name="icon">${$A(e.seekOffset)}</slot>
1133  `}function GA(){return ne("Seek backward")}const VA=0;class Ed extends ut{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_CURRENT_TIME,ts.SEEK_OFFSET]}connectedCallback(){super.connectedCallback(),this.seekOffset=$e(this,ts.SEEK_OFFSET,io)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===ts.SEEK_OFFSET&&(this.seekOffset=$e(this,ts.SEEK_OFFSET,io))}get seekOffset(){return $e(this,ts.SEEK_OFFSET,io)}set seekOffset(e){tt(this,ts.SEEK_OFFSET,e),this.setAttribute("aria-label",ne("seek back {seekOffset} seconds",{seekOffset:this.seekOffset})),rg(ng(this,"icon"),this.seekOffset)}get mediaCurrentTime(){return $e(this,b.MEDIA_CURRENT_TIME,VA)}set mediaCurrentTime(e){tt(this,b.MEDIA_CURRENT_TIME,e)}handleClick(){const e=Math.max(this.mediaCurrentTime-this.seekOffset,0),t=new P.CustomEvent(ee.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}}Ed.getSlotTemplateHTML=BA;Ed.getTooltipContentHTML=GA;P.customElements.get("media-seek-backward-button")||P.customElements.define("media-seek-backward-button",Ed);const is={SEEK_OFFSET:"seekoffset"},so=30,HA=s=>`
1134  <svg aria-hidden="true" viewBox="0 0 20 24">
1135    <defs>
1136      <style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style>
1137    </defs>
1138    <text class="text value" transform="translate(8.9 19.87)">${s}</text>
1139    <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"/>
1140  </svg>`;function KA(s,e){return`
1141    <slot name="icon">${HA(e.seekOffset)}</slot>
1142  `}function WA(){return ne("Seek forward")}const YA=0;class vd extends ut{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_CURRENT_TIME,is.SEEK_OFFSET]}connectedCallback(){super.connectedCallback(),this.seekOffset=$e(this,is.SEEK_OFFSET,so)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),e===is.SEEK_OFFSET&&(this.seekOffset=$e(this,is.SEEK_OFFSET,so))}get seekOffset(){return $e(this,is.SEEK_OFFSET,so)}set seekOffset(e){tt(this,is.SEEK_OFFSET,e),this.setAttribute("aria-label",ne("seek forward {seekOffset} seconds",{seekOffset:this.seekOffset})),rg(ng(this,"icon"),this.seekOffset)}get mediaCurrentTime(){return $e(this,b.MEDIA_CURRENT_TIME,YA)}set mediaCurrentTime(e){tt(this,b.MEDIA_CURRENT_TIME,e)}handleClick(){const e=this.mediaCurrentTime+this.seekOffset,t=new P.CustomEvent(ee.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}}vd.getSlotTemplateHTML=KA;vd.getTooltipContentHTML=WA;P.customElements.get("media-seek-forward-button")||P.customElements.define("media-seek-forward-button",vd);var zg=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},ro=(s,e,t)=>(zg(s,e,"read from private field"),t?t.call(s):e.get(s)),qA=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},jA=(s,e,t,i)=>(zg(s,e,"write to private field"),e.set(s,t),t),cs;const Bi={REMAINING:"remaining",SHOW_DURATION:"showduration",NO_TOGGLE:"notoggle"},wu=[...Object.values(Bi),b.MEDIA_CURRENT_TIME,b.MEDIA_DURATION,b.MEDIA_SEEKABLE],Mu=["Enter"," "],zA="&nbsp;/&nbsp;",hl=(s,{timesSep:e=zA}={})=>{var t,i;const r=(t=s.mediaCurrentTime)!=null?t:0,[,n]=(i=s.mediaSeekable)!=null?i:[];let a=0;Number.isFinite(s.mediaDuration)?a=s.mediaDuration:Number.isFinite(n)&&(a=n);const o=s.remaining?Di(0-(a-r)):Di(r);return s.showDuration?`${o}${e}${Di(a)}`:o},QA="video not loaded, unknown time.",XA=s=>{var e;const t=s.mediaCurrentTime,[,i]=(e=s.mediaSeekable)!=null?e:[];let r=null;if(Number.isFinite(s.mediaDuration)?r=s.mediaDuration:Number.isFinite(i)&&(r=i),t==null||r===null){s.setAttribute("aria-valuetext",QA);return}const n=s.remaining?rr(0-(r-t)):rr(t);if(!s.showDuration){s.setAttribute("aria-valuetext",n);return}const a=rr(r),o=`${n} of ${a}`;s.setAttribute("aria-valuetext",o)};function ZA(s,e){return`
1143    <slot>${hl(e)}</slot>
1144  `}class Qg extends Pi{constructor(){super(),qA(this,cs,void 0),jA(this,cs,this.shadowRoot.querySelector("slot")),ro(this,cs).innerHTML=`${hl(this)}`}static get observedAttributes(){return[...super.observedAttributes,...wu,"disabled"]}connectedCallback(){const{style:e}=qe(this.shadowRoot,":host(:hover:not([notoggle]))");e.setProperty("cursor","var(--media-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",ne("playback time"));const t=i=>{const{key:r}=i;if(!Mu.includes(r)){this.removeEventListener("keyup",t);return}this.toggleTimeDisplay()};this.addEventListener("keydown",i=>{const{metaKey:r,altKey:n,key:a}=i;if(r||n||!Mu.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,i){wu.includes(e)?this.update():e==="disabled"&&i!==t&&(i==null?this.enable():this.disable()),super.attributeChangedCallback(e,t,i)}enable(){this.tabIndex=0}disable(){this.tabIndex=-1}get remaining(){return Ee(this,Bi.REMAINING)}set remaining(e){ve(this,Bi.REMAINING,e)}get showDuration(){return Ee(this,Bi.SHOW_DURATION)}set showDuration(e){ve(this,Bi.SHOW_DURATION,e)}get noToggle(){return Ee(this,Bi.NO_TOGGLE)}set noToggle(e){ve(this,Bi.NO_TOGGLE,e)}get mediaDuration(){return $e(this,b.MEDIA_DURATION)}set mediaDuration(e){tt(this,b.MEDIA_DURATION,e)}get mediaCurrentTime(){return $e(this,b.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){tt(this,b.MEDIA_CURRENT_TIME,e)}get mediaSeekable(){const 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(){const e=hl(this);XA(this),e!==ro(this,cs).innerHTML&&(ro(this,cs).innerHTML=e)}}cs=new WeakMap;Qg.getSlotTemplateHTML=ZA;P.customElements.get("media-time-display")||P.customElements.define("media-time-display",Qg);var Xg=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},Ze=(s,e,t)=>(Xg(s,e,"read from private field"),e.get(s)),Yt=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},_t=(s,e,t,i)=>(Xg(s,e,"write to private field"),e.set(s,t),t),JA=(s,e,t,i)=>({set _(r){_t(s,e,r)},get _(){return Ze(s,e)}}),us,Pn,hs,Xs,wn,Mn,On,fs,Gi,Fn;class eb{constructor(e,t,i){Yt(this,us,void 0),Yt(this,Pn,void 0),Yt(this,hs,void 0),Yt(this,Xs,void 0),Yt(this,wn,void 0),Yt(this,Mn,void 0),Yt(this,On,void 0),Yt(this,fs,void 0),Yt(this,Gi,0),Yt(this,Fn,(r=performance.now())=>{_t(this,Gi,requestAnimationFrame(Ze(this,Fn))),_t(this,Xs,performance.now()-Ze(this,hs));const n=1e3/this.fps;if(Ze(this,Xs)>n){_t(this,hs,r-Ze(this,Xs)%n);const a=1e3/((r-Ze(this,Pn))/++JA(this,wn)._),o=(r-Ze(this,Mn))/1e3/this.duration;let l=Ze(this,On)+o*this.playbackRate;l-Ze(this,us).valueAsNumber>0?_t(this,fs,this.playbackRate/this.duration/a):(_t(this,fs,.995*Ze(this,fs)),l=Ze(this,us).valueAsNumber+Ze(this,fs)),this.callback(l)}}),_t(this,us,e),this.callback=t,this.fps=i}start(){Ze(this,Gi)===0&&(_t(this,hs,performance.now()),_t(this,Pn,Ze(this,hs)),_t(this,wn,0),Ze(this,Fn).call(this))}stop(){Ze(this,Gi)!==0&&(cancelAnimationFrame(Ze(this,Gi)),_t(this,Gi,0))}update({start:e,duration:t,playbackRate:i}){const r=e-Ze(this,us).valueAsNumber,n=Math.abs(t-this.duration);(r>0||r<-.03||n>=.5)&&this.callback(e),_t(this,On,e),_t(this,Mn,performance.now()),this.duration=t,this.playbackRate=i}}us=new WeakMap;Pn=new WeakMap;hs=new WeakMap;Xs=new WeakMap;wn=new WeakMap;Mn=new WeakMap;On=new WeakMap;fs=new WeakMap;Gi=new WeakMap;Fn=new WeakMap;var yd=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)},ze=(s,e,t)=>(yd(s,e,"read from private field"),t?t.call(s):e.get(s)),Xe=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)},ei=(s,e,t,i)=>(yd(s,e,"write to private field"),e.set(s,t),t),ct=(s,e,t)=>(yd(s,e,"access private method"),t),gs,Yi,aa,or,oa,Nn,Lr,xr,ms,ps,Zs,Td,Zg,fl,la,Sd,da,Ad,ca,bd,gl,Jg,Rr,ua,ml,em;const tb="video not loaded, unknown time.",ib=s=>
1144{const e=s.range,t=rr(+tm(s)),i=rr(+s.mediaSeekableEnd),r=t&&i?`${t} of ${i}`:tb;e.setAttribute("aria-valuetext",r)};function sb(s){return`
1145    ${Cs.getTemplateHTML(s)}
1146    <style>
1147      :host {
1148        --media-box-border-radius: 4px;
1149        --media-box-padding-left: 10px;
1150        --media-box-padding-right: 10px;
1151        --media-preview-border-radius: var(--media-box-border-radius);
1152        --media-box-arrow-offset: var(--media-box-border-radius);
1153        --_control-background: var(--media-control-background, var(--media-secondary-color, rgb(20 20 30 / .7)));
1154        --_preview-background: var(--media-preview-background, var(--_control-background));
1155
1156        
1157        contain: layout;
1158      }
1159
1160      #buffered {
1161        background: var(--media-time-range-buffered-color, rgb(255 255 255 / .4));
1162        position: absolute;
1163        height: 100%;
1164        will-change: width;
1165      }
1166
1167      #preview-rail,
1168      #current-rail {
1169        width: 100%;
1170        position: absolute;
1171        left: 0;
1172        bottom: 100%;
1173        pointer-events: none;
1174        will-change: transform;
1175      }
1176
1177      [part~="box"] {
1178        width: min-content;
1179        
1180        position: absolute;
1181        bottom: 100%;
1182        flex-direction: column;
1183        align-items: center;
1184        transform: translateX(-50%);
1185      }
1186
1187      [part~="current-box"] {
1188        display: var(--media-current-box-display, var(--media-box-display, flex));
1189        margin: var(--media-current-box-margin, var(--media-box-margin, 0 0 5px));
1190        visibility: hidden;
1191      }
1192
1193      [part~="preview-box"] {
1194        display: var(--media-preview-box-display, var(--media-box-display, flex));
1195        margin: var(--media-preview-box-margin, var(--media-box-margin, 0 0 5px));
1196        transition-property: var(--media-preview-transition-property, visibility, opacity);
1197        transition-duration: var(--media-preview-transition-duration-out, .25s);
1198        transition-delay: var(--media-preview-transition-delay-out, 0s);
1199        visibility: hidden;
1200        opacity: 0;
1201      }
1202
1203      :host(:is([${b.MEDIA_PREVIEW_IMAGE}], [${b.MEDIA_PREVIEW_TIME}])[dragging]) [part~="preview-box"] {
1204        transition-duration: var(--media-preview-transition-duration-in, .5s);
1205        transition-delay: var(--media-preview-transition-delay-in, .25s);
1206        visibility: visible;
1207        opacity: 1;
1208      }
1209
1210      @media (hover: hover) {
1211        :host(:is([${b.MEDIA_PREVIEW_IMAGE}], [${b.MEDIA_PREVIEW_TIME}]):hover) [part~="preview-box"] {
1212          transition-duration: var(--media-preview-transition-duration-in, .5s);
1213          transition-delay: var(--media-preview-transition-delay-in, .25s);
1214          visibility: visible;
1215          opacity: 1;
1216        }
1217      }
1218
1219      media-preview-thumbnail,
1220      ::slotted(media-preview-thumbnail) {
1221        visibility: hidden;
1222        
1223        transition: visibility 0s .25s;
1224        transition-delay: calc(var(--media-preview-transition-delay-out, 0s) + var(--media-preview-transition-duration-out, .25s));
1225        background: var(--media-preview-thumbnail-background, var(--_preview-background));
1226        box-shadow: var(--media-preview-thumbnail-box-shadow, 0 0 4px rgb(0 0 0 / .2));
1227        max-width: var(--media-preview-thumbnail-max-width, 180px);
1228        max-height: var(--media-preview-thumbnail-max-height, 160px);
1229        min-width: var(--media-preview-thumbnail-min-width, 120px);
1230        min-height: var(--media-preview-thumbnail-min-height, 80px);
1231        border: var(--media-preview-thumbnail-border);
1232        border-radius: var(--media-preview-thumbnail-border-radius,
1233          var(--media-preview-border-radius) var(--media-preview-border-radius) 0 0);
1234      }
1235
1236      :host([${b.MEDIA_PREVIEW_IMAGE}][dragging]) media-preview-thumbnail,
1237      :host([${b.MEDIA_PREVIEW_IMAGE}][dragging]) ::slotted(media-preview-thumbnail) {
1238        transition-delay: var(--media-preview-transition-delay-in, .25s);
1239        visibility: visible;
1240      }
1241
1242      @media (hover: hover) {
1243        :host([${b.MEDIA_PREVIEW_IMAGE}]:hover) media-preview-thumbnail,
1244        :host([${b.MEDIA_PREVIEW_IMAGE}
1244]:hover) ::slotted(media-preview-thumbnail) {
1245          transition-delay: var(--media-preview-transition-delay-in, .25s);
1246          visibility: visible;
1247        }
1248
1249        :host([${b.MEDIA_PREVIEW_TIME}]:hover) {
1250          --media-time-range-hover-display: block;
1251        }
1252      }
1253
1254      media-preview-chapter-display,
1255      ::slotted(media-preview-chapter-display) {
1256        font-size: var(--media-font-size, 13px);
1257        line-height: 17px;
1258        min-width: 0;
1259        visibility: hidden;
1260        
1261        transition: min-width 0s, border-radius 0s, margin 0s, padding 0s, visibility 0s;
1262        transition-delay: calc(var(--media-preview-transition-delay-out, 0s) + var(--media-preview-transition-duration-out, .25s));
1263        background: var(--media-preview-chapter-background, var(--_preview-background));
1264        border-radius: var(--media-preview-chapter-border-radius,
1265          var(--media-preview-border-radius) var(--media-preview-border-radius)
1266          var(--media-preview-border-radius) var(--media-preview-border-radius));
1267        padding: var(--media-preview-chapter-padding, 3.5px 9px);
1268        margin: var(--media-preview-chapter-margin, 0 0 5px);
1269        text-shadow: var(--media-preview-chapter-text-shadow, 0 0 4px rgb(0 0 0 / .75));
1270      }
1271
1272      :host([${b.MEDIA_PREVIEW_IMAGE}]) media-preview-chapter-display,
1273      :host([${b.MEDIA_PREVIEW_IMAGE}]) ::slotted(media-preview-chapter-display) {
1274        transition-delay: var(--media-preview-transition-delay-in, .25s);
1275        border-radius: var(--media-preview-chapter-border-radius, 0);
1276        padding: var(--media-preview-chapter-padding, 3.5px 9px 0);
1277        margin: var(--media-preview-chapter-margin, 0);
1278        min-width: 100%;
1279      }
1280
1281      media-preview-chapter-display[${b.MEDIA_PREVIEW_CHAPTER}],
1282      ::slotted(media-preview-chapter-display[${b.MEDIA_PREVIEW_CHAPTER}]) {
1283        visibility: visible;
1284      }
1285
1286      media-preview-chapter-display:not([aria-valuetext]),
1287      ::slotted(media-preview-chapter-display:not([aria-valuetext])) {
1288        display: none;
1289      }
1290
1291      media-preview-time-display,
1292      ::slotted(media-preview-time-display),
1293      media-time-display,
1294      ::slotted(media-time-display) {
1295        font-size: var(--media-font-size, 13px);
1296        line-height: 17px;
1297        min-width: 0;
1298        
1299        transition: min-width 0s, border-radius 0s;
1300        transition-delay: calc(var(--media-preview-transition-delay-out, 0s) + var(--media-preview-transition-duration-out, .25s));
1301        background: var(--media-preview-time-background, var(--_preview-background));
1302        border-radius: var(--media-preview-time-border-radius,
1303          var(--media-preview-border-radius) var(--media-preview-border-radius)
1304          var(--media-preview-border-radius) var(--media-preview-border-radius));
1305        padding: var(--media-preview-time-padding, 3.5px 9px);
1306        margin: var(--media-preview-time-margin, 0);
1307        text-shadow: var(--media-preview-time-text-shadow, 0 0 4px rgb(0 0 0 / .75));
1308        transform: translateX(min(
1309          max(calc(50% - var(--_box-width) / 2),
1310          calc(var(--_box-shift, 0))),
1311          calc(var(--_box-width) / 2 - 50%)
1312        ));
1313      }
1314
1315      :host([${b.MEDIA_PREVIEW_IMAGE}]) media-preview-time-display,
1316      :host([${b.MEDIA_PREVIEW_IMAGE}]) ::slotted(media-preview-time-display) {
1317        transition-delay: var(--media-preview-transition-delay-in, .25s);
1318        border-radius: var(--media-preview-time-border-radius,
1319          0 0 var(--media-preview-border-radius) var(--media-preview-border-radius));
1320        min-width: 100%;
1321      }
1322
1323      :host([${b.MEDIA_PREVIEW_TIME}]:hover) {
1324        --media-time-range-hover-display: block;
1325      }
1326
1327      [part~="arrow"],
1328      ::slotted([part~="arrow"]) {
1329        display: var(--media-box-arrow-display, inline-block);
1330        transform: translateX(min(
1331          max(calc(50% - var(--_box-width) / 2 + var(--media-box-arrow-offset)),
1332          calc(var(--_box-shift, 0))),
1333          calc(var(--_box-width) / 2 - 50% - var(--media-box-arrow-offset))
1334        ));
1335        
1336        border-color: transparent;
1337        border-top-color: var(--media-box-arrow-background, var(--_control-background));
1338        border-width: var(--media-box-arrow-border-width,
1339          var(--media-box-arrow-height, 5px) var(--media-box-arrow-width, 6px) 0);
1340        border-style: solid;
1341        justify-content: center;
1342        height: 0;
1343      }
1344    </style>
1345    <div id="preview-rail">
1346      <slot name="preview" part="box preview-box">
1347        <media-preview-thumbnail>
1348          <template shadowrootmode="${Cu.shadowRootOptions.mode}">
1349            ${Cu.getTemplateHTML({})}
1350          </template>
1351        </media-preview-thumbnail>
1352        <media-preview-chapter-display></media-preview-chapter-display>
1353        <media-preview-time-display></media-preview-time-display>
1354        <slot name="preview-arrow"><div part="arrow"></div></slot>
1355      </slot>
1356    </div>
1357    <div id="current-rail">
1358      <slot name="current" part="box current-box">
1359        
1360      </slot>
1361    </div>
1362  `}const an=(s,e=s.mediaCurrentTime)=>{const t=Number.isFinite(s.mediaSeekableStart)?s.mediaSeekableStart:0,i=Number.isFinite(s.mediaDuration)?s.mediaDuration:s.mediaSeekableEnd;if(Number.isNaN(i))return 0;const r=(e-t)/(i-t);return Math.max(0,Math.min(r,1))},tm=(s,e=s.range.valueAsNumber)=>{const t=Number.isFinite(s.mediaSeekableStart)?s.mediaSeekableStart:0,i=Number.isFinite(s.mediaDuration)?s.mediaDuration:s.mediaSeekableEnd;return Number.isNaN(i)?0:e*(i-t)+t};class Id extends Cs{constructor(){super(),Xe(this,ps),Xe(this,Td),Xe(this,la),Xe(this,da),Xe(this,ca),Xe(this,gl),Xe(this,Rr),Xe(this,ml),Xe(this,gs,void 0),Xe(this,Yi,void 0),Xe(this,aa,void 0),Xe(this,or,void 0),Xe(this,oa,void 0),Xe(this,Nn,void 0),Xe(this,Lr,void 0),Xe(this,xr,void 0),Xe(this,ms,void 0),Xe(this,fl,i=>{this.dragging||(Yl(i)&&(this.range.valueAsNumber=i),this.updateBar())}),this.shadowRoot.querySelector("#track").insertAdjacentHTML("afterbegin",'<div id="buffered" part="buffered"></div>'),ei(this,aa,this.shadowRoot.querySelectorAll('[part~="box"]')),ei(this,oa,this.shadowRoot.querySelector('[part~="preview-box"]')),ei(this,Nn,this.shadowRoot.querySelector('[part~="current-box"]'));const t=getComputedStyle(this);ei(this,Lr,parseInt(t.getPropertyValue("--media-box-padding-left"))),ei(this,xr,parseInt(t.getPropertyValue("--media-box-padding-right"))),ei(this,Yi,new eb(this.range,ze(this,fl),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",ne("seek")),ct(this,ps,Zs).call(this),ei(this,gs,this.getRootNode()),(e=ze(this,gs))==null||e.addEventListener("transitionstart",this)}disconnectedCallback(){var e;super.disconnectedCallback(),ct(this,ps,Zs).call(this),(e=ze(this,gs))==null||e.removeEventListener("transitionstart",this),ei(this,gs,null)}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),t!=i&&(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?(ze(this,Yi).update({start:an(this),duration:this.mediaSeekableEnd-this.mediaSeekableStart,playbackRate:this.mediaPlaybackRate}),ct(this,ps,Zs).call(this),ib(this)):e===b.MEDIA_BUFFERED&&this.updateBufferedBar(),(e===b.MEDIA_DURATION||e===b.MEDIA_SEEKABLE)&&(this.mediaChaptersCues=ze(this,ms),this.updateBar()))}get mediaChaptersCues(){return ze(this,ms)}set mediaChaptersCues(e){var t;ei(this,ms,e),this.updateSegments((t=ze(this,ms))==null?void 0:t.map(i=>({start:an(this,i.startTime),end:an(this,i.endTime)})))}get mediaPaused(){return Ee(this,b.MEDIA_PAUSED)}set mediaPaused(e){ve(this,b.MEDIA_PAUSED,e)}get mediaLoading(){return Ee(this,b.MEDIA_LOADING)}set mediaLoading(e){ve(this,b.MEDIA_LOADING,e)}get mediaDuration(){return $e(this,b.MEDIA_DURATION)}set mediaDuration(e){tt(this,b.MEDIA_DURATION,e)}get mediaCurrentTime(){return $e(this,b.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){tt(this,b.MEDIA_CURRENT_TIME,e)}get mediaPlaybackRate(){return $e(this,b.MEDIA_PLAYBACK_RATE,1)}set mediaPlaybackRate(e){tt(this,b.MEDIA_PLAYBACK_RATE,e)}get mediaBuffered(){const e=this.getAttribute(b.MEDIA_BUFFERED);return e?e.split(" ").map(t=>t.split(":").map(i=>+i)):[]}set mediaBuffered(e){if(!e){this.removeAttribute(b.MEDIA_BUFFERED);return}const t=e.map(i=>i.join(":")).join(" ");this.setAttribute(b.MEDIA_BUFFERED,t)}get mediaSeekable(){const 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;const[,t=this.mediaDuration]=(e=this.mediaSeekable)!=null?e:[];return t}get mediaSeekableStart(){var e;const[t=0]=(e=this.mediaSeekable)!=null?e:[];return t}get mediaPreviewImage(){return Be(this,b.MEDIA_PREVIEW_IMAGE)}
1362set mediaPreviewImage(e){Ge(this,b.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewTime(){return $e(this,b.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){tt(this,b.MEDIA_PREVIEW_TIME,e)}get mediaEnded(){return Ee(this,b.MEDIA_ENDED)}set mediaEnded(e){ve(this,b.MEDIA_ENDED,e)}updateBar(){super.updateBar(),this.updateBufferedBar(),this.updateCurrentBox()}updateBufferedBar(){var e;const t=this.mediaBuffered;if(!t.length)return;let i;if(this.mediaEnded)i=1;else{const n=this.mediaCurrentTime,[,a=this.mediaSeekableStart]=(e=t.find(([o,l])=>o<=n&&n<=l))!=null?e:[];i=an(this,a)}const{style:r}=qe(this.shadowRoot,"#buffered");r.setProperty("width",`${i*100}%`)}updateCurrentBox(){if(!this.shadowRoot.querySelector('slot[name="current"]').assignedElements().length)return;const t=qe(this.shadowRoot,"#current-rail"),i=qe(this.shadowRoot,'[part~="current-box"]'),r=ct(this,la,Sd).call(this,ze(this,Nn)),n=ct(this,da,Ad).call(this,r,this.range.valueAsNumber),a=ct(this,ca,bd).call(this,r,this.range.valueAsNumber);t.style.transform=`translateX(${n})`,t.style.setProperty("--_range-width",`${r.range.width}`),i.style.setProperty("--_box-shift",`${a}`),i.style.setProperty("--_box-width",`${r.box.width}px`),i.style.setProperty("visibility","initial")}handleEvent(e){switch(super.handleEvent(e),e.type){case"input":ct(this,ml,em).call(this);break;case"pointermove":ct(this,gl,Jg).call(this,e);break;case"pointerup":case"pointerleave":ct(this,Rr,ua).call(this,null);break;case"transitionstart":ks(e.target,this)&&setTimeout(()=>ct(this,ps,Zs).call(this),0);break}}}gs=new WeakMap;Yi=new WeakMap;aa=new WeakMap;or=new WeakMap;oa=new WeakMap;Nn=new WeakMap;Lr=new WeakMap;xr=new WeakMap;ms=new WeakMap;ps=new WeakSet;Zs=function(){ct(this,Td,Zg).call(this)?ze(this,Yi).start():ze(this,Yi).stop()};Td=new WeakSet;Zg=function(){return this.isConnected&&!this.mediaPaused&&!this.mediaLoading&&!this.mediaEnded&&this.mediaSeekableEnd>0&&og(this)};fl=new WeakMap;la=new WeakSet;Sd=function(s){var e;const i=((e=this.getAttribute("bounds")?kr(this,`#${this.getAttribute("bounds")}`):this.parentElement)!=null?e:this).getBoundingClientRect(),r=this.range.getBoundingClientRect(),n=s.offsetWidth,a=-(r.left-i.left-n/2),o=i.right-r.left-n/2;return{box:{width:n,min:a,max:o},bounds:i,range:r}};da=new WeakSet;Ad=function(s,e){let t=`${e*100}%`;const{width:i,min:r,max:n}=s.box;if(!i)return t;if(Number.isNaN(r)||(t=`max(${`calc(1 / var(--_range-width) * 100 * ${r}% + var(--media-box-padding-left))`}, ${t})`),!Number.isNaN(n)){const o=`calc(1 / var(--_range-width) * 100 * ${n}% - var(--media-box-padding-right))`;t=`min(${t}, ${o})`}return t};ca=new WeakSet;bd=function(s,e){const{width:t,min:i,max:r}=s.box,n=e*s.range.width;if(n<i+ze(this,Lr)){const a=s.range.left-s.bounds.left-ze(this,Lr);return`${n-t/2+a}px`}if(n>r-ze(this,xr)){const a=s.bounds.right-s.range.right-ze(this,xr);return`${n+t/2-a-s.range.width}px`}return 0};gl=new WeakSet;Jg=function(s){const e=[...ze(this,aa)].some(c=>s.composedPath().includes(c));if(!this.dragging&&(e||!s.composedPath().includes(this))){ct(this,Rr,ua).call(this,null);return}const t=this.mediaSeekableEnd;if(!t)return;const i=qe(this.shadowRoot,"#preview-rail"),r=qe(this.shadowRoot,'[part~="preview-box"]'),n=ct(this,la,Sd).call(this,ze(this,oa));let a=(s.clientX-n.range.left)/n.range.width;a=Math.max(0,Math.min(1,a));const o=ct(this,da,Ad).call(this,n,a),l=ct(this,ca,bd).call(this,n,a);i.style.transform=`translateX(${o})`,i.style.setProperty("--_range-width",`${n.range.width}`),r.style.setProperty("--_box-shift",`${l}`),r.style.setProperty("--_box-width",`${n.box.width}px`);const d=Math.round(ze(this,or))-Math.round(a*t);Math.abs(d)<1&&a>.01&&a<.99||(ei(this,or,a*t),ct(this,Rr,ua).call(this,ze(this,or)))};Rr=new WeakSet;ua=function(s){this.dispatchEvent(new P.CustomEvent(ee.MEDIA_PREVIEW_REQUEST,{composed:!0,bubbles:!0,detail:s}))};ml=new WeakSet;em=function(){ze(this,Yi).stop();const s=tm(this);this.dispatchEvent(new P.CustomEvent(ee.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:s}))};Id.shadowRootOptions={mode:"open"};Id.getTemplateHTML=sb;P.customElements.get("media-time-range")||P.customElements.define("media-time-range",Id);const rb=1,nb=s=>s.mediaMuted?0:s.mediaVolume,ab=s=>`${Math.round(s*100)}%`;class ob extends Cs{static get observedAttributes(){return[...super.observedAttributes,b.MEDIA_VOLUME,b.MEDIA_MUTED,b.MEDIA_VOLUME_UNAVAILABLE]}constructor(){super(),this.range.addEventListener("input",()=>{const e=this.range.value,t=new P.CustomEvent(ee.MEDIA_VOLUME_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)})}connectedCallback(){super.connectedCallback(),this.range.setAttribute("aria-label",ne("volume"))}attributeChangedCallback(e,t,i){super.attributeChangedCallback(e,t,i),(e===b.MEDIA_VOLUME||e===b.MEDIA_MUTED)&&(this.range.valueAsNumber=nb(this),this.range.setAttribute("aria-valuetext",ab(this.range.valueAsNumber)),this.updateBar())}get mediaVolume(){return $e(this,b.MEDIA_VOLUME,rb)}set mediaVolume(e){tt(this,b.MEDIA_VOLUME,e)}get mediaMuted(){return Ee(this,b.MEDIA_MUTED)}set mediaMuted(e){ve(this,b.MEDIA_MUTED,e)}get mediaVolumeUnavailable(){return Be(this,b.MEDIA_VOLUME_UNAVAILABLE)}
1362set mediaVolumeUnavailable(e){Ge(this,b.MEDIA_VOLUME_UNAVAILABLE,e)}}P.customElements.get("media-volume-range")||P.customElements.define("media-volume-range",ob);const lb="https://www.youtube.com/embed",db="https://www.youtube-nocookie.com/embed",cb="https://www.youtube.com/iframe_api",ub="YT",hb="onYouTubeIframeAPIReady",Ou=/(?:youtu\.be\/|youtube(?:-nocookie)?\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=|shorts\/|live\/))((\w|-){11})/,fb=/(?:youtu\.be\/|youtube(?:-nocookie)?\.com\/.*?[?&]list=)([\w_-]+)/;function Fu(s,e={}){const t={src:im(s,e),frameborder:0,width:"100%",height:"100%",allow:"accelerometer; fullscreen; autoplay; encrypted-media; gyroscope; picture-in-picture"};return e.config&&(t["data-config"]=JSON.stringify(e.config)),`
1363    <style>
1364      :host {
1365        display: inline-block;
1366        line-height: 0;
1367        position: relative;
1368        min-width: 300px;
1369        min-height: 150px;
1370      }
1371      iframe {
1372        position: absolute;
1373        top: 0;
1374        left: 0;
1375      }
1376    </style>
1377    <iframe${mb(t)}></iframe>
1378  `}function im(s,e){if(!s.src)return;const t=s.src.includes("-nocookie")?db:lb,i={controls:s.controls===""?null:0,autoplay:s.autoplay,loop:s.loop,mute:s.muted,playsinline:s.playsinline,preload:s.preload??"metadata",enablejsapi:1,showinfo:0,rel:0,iv_load_policy:3,modestbranding:1,...e.config};if(Ou.test(s.src)){const o=s.src.match(Ou),l=o&&o[1];return`${t}/${l}?${Nu(i)}`}const r=s.src.match(fb),a={listType:"playlist",list:r&&r[1],...i};return`${t}?${Nu(a)}`}class gb extends(globalThis.HTMLElement??class{}){static getTemplateHTML=Fu;static shadowRootOptions={mode:"open"};static observedAttributes=["autoplay","controls","crossorigin","loop","muted","playsinline","poster","preload","src"];loadComplete=new oo;#e;#t;#i=0;#s=!1;#r;isLoaded=!1;#a=null;#n=null;constructor(){super(),this.#o("config")}get config(){return this.#n}set config(e){this.#n=e}async load(){if(this.#e)return;this.shadowRoot||this.attachShadow({mode:"open"});const e=!this.#t;this.#t&&(this.loadComplete=new oo,this.isLoaded=!1),this.#t=!0,await(this.#e=Promise.resolve()),this.#e=null,this.#i=0,this.dispatchEvent(new Event("emptied"));let t=this.api;if(this.api=null,!this.src){t?.destroy();return}this.dispatchEvent(new Event("loadstart"));let i=this.shadowRoot.querySelector("iframe"),r=Eb(this.attributes);e&&i&&(this.#n=JSON.parse(i.getAttribute("data-config")||"{}")),(!i?.src||i.src!==im(r,this))&&(this.shadowRoot.innerHTML=Fu(r,this),i=this.shadowRoot.querySelector("iframe"));const n=await vb(cb,ub,hb);this.api=new n.Player(i,{events:{onReady:()=>{this.#i=1,this.dispatchEvent(new Event("loadedmetadata")),this.dispatchEvent(new Event("durationchange")),this.dispatchEvent(new Event("volumechange")),this.dispatchEvent(new Event("loadcomplete")),this.isLoaded=!0,this.loadComplete.resolve()},onError:c=>{console.error(c),this.#a={code:c.data,message:`YouTube iframe player error #${c.data}; visit https://developers.google.com/youtube/iframe_api_reference#onError for the full error message.`},this.dispatchEvent(new Event("error"))}}});let a=!1;this.api.addEventListener("onStateChange",c=>{var u;const h=c.data;if((h===n.PlayerState.PLAYING||h===n.PlayerState.BUFFERING)&&(a||(a=!0,this.dispatchEvent(new Event("play")))),h===n.PlayerState.PLAYING)this.seeking&&(this.#s=!1,(u=this.#r)==null||u.resolve(),this.dispatchEvent(new Event("seeked"))),this.#i=3,this.dispatchEvent(new Event("playing"));else if(h===n.PlayerState.PAUSED){const f=Math.abs(this.currentTime-o);!this.seeking&&f>.1&&(this.#s=!0,this.dispatchEvent(new Event("seeking"))),a=!1,this.dispatchEvent(new Event("pause"))}h===n.PlayerState.ENDED&&(a=!1,this.dispatchEvent(new Event("pause")),this.dispatchEvent(new Event("ended")),this.loop&&this.play())}),this.api.addEventListener("onPlaybackRateChange",()=>{this.dispatchEvent(new Event("ratechange"))}),this.api.addEventListener("onVolumeChange",()=>{this.dispatchEvent(new Event("volumechange"))}),this.api.addEventListener("onVideoProgress",()=>{this.dispatchEvent(new Event("timeupdate"))}),await this.loadComplete;let o=0;setInterval(()=>{var c;const u=Math.abs(this.currentTime-o),h=this.buffered.end(this.buffered.length-1);this.seeking&&h>.1?(this.#s=!1,(c=this.#r)==null||c.resolve(),this.dispatchEvent(new Event("seeked"))):!this.seeking&&u>.1&&(this.#s=!0,this.dispatchEvent(new Event("seeking"))),o=this.currentTime},50);let l;const d=setInterval(()=>{const c=this.buffered.end(this.buffered.length-1);c>=this.duration&&(clearInterval(d),this.#i=4),l!=c&&(l=c,this.dispatchEvent(new Event("progress")))},100)}async attributeChangedCallback(e,t,i){if(t!==i)switch(e){case"src":case"auto
1378play":case"controls":case"loop":case"playsinline":this.load()}}async play(){var e;return this.#r=null,await this.loadComplete,(e=this.api)==null||e.playVideo(),Sb(this)}async pause(){var e;return await this.loadComplete,(e=this.api)==null?void 0:e.pauseVideo()}get seeking(){return this.#s}get readyState(){return this.#i}get src(){return this.getAttribute("src")}set src(e){this.src!=e&&this.setAttribute("src",e)}get error(){return this.#a}get paused(){var e,t;return this.isLoaded?[-1,0,2,5].includes((t=(e=this.api)==null?void 0:e.getPlayerState)==null?void 0:t.call(e)):!this.autoplay}get duration(){var e,t;return((t=(e=this.api)==null?void 0:e.getDuration)==null?void 0:t.call(e))??NaN}get autoplay(){return this.hasAttribute("autoplay")}set autoplay(e){this.autoplay!=e&&this.toggleAttribute("autoplay",!!e)}get buffered(){var e,t;if(!this.isLoaded)return lo();const i=((e=this.api)==null?void 0:e.getVideoLoadedFraction())*((t=this.api)==null?void 0:t.getDuration());return i>0?lo(0,i):lo()}get controls(){return this.hasAttribute("controls")}set controls(e){this.controls!=e&&this.toggleAttribute("controls",!!e)}get currentTime(){var e,t;return((t=(e=this.api)==null?void 0:e.getCurrentTime)==null?void 0:t.call(e))??0}set currentTime(e){this.currentTime!=e&&(this.#r=new oo,this.loadComplete.then(()=>{var t,i;(t=this.api)==null||t.seekTo(e,!0),this.paused&&((i=this.#r)==null||i.then(()=>{var r;this.#r&&((r=this.api)==null||r.pauseVideo())}))}))}set defaultMuted(e){this.defaultMuted!=e&&this.toggleAttribute("muted",!!e)}get defaultMuted(){return this.hasAttribute("muted")}get loop(){return this.hasAttribute("loop")}set loop(e){this.loop!=e&&this.toggleAttribute("loop",!!e)}set muted(e){this.muted!=e&&this.loadComplete.then(()=>{var t,i;e?(t=this.api)==null||t.mute():(i=this.api)==null||i.unMute()})}get muted(){var e,t;return this.isLoaded?(t=(e=this.api)==null?void 0:e.isMuted)==null?void 0:t.call(e):this.defaultMuted}get playbackRate(){var e,t;return((t=(e=this.api)==null?void 0:e.getPlaybackRate)==null?void 0:t.call(e))??1}set playbackRate(e){this.playbackRate!=e&&this.loadComplete.then(()=>{var t;(t=this.api)==null||t.setPlaybackRate(e)})}get playsInline(){return this.hasAttribute("playsinline")}set playsInline(e){this.playsInline!=e&&this.toggleAttribute("playsinline",!!e)}get poster(){return this.getAttribute("poster")}set poster(e){this.poster!=e&&this.setAttribute("poster",`${e}`)}set volume(e){this.volume!=e&&this.loadComplete.then(()=>{var t;(t=this.api)==null||t.setVolume(e*100)})}get volume(){var e;return this.isLoaded?((e=this.api)==null?void 0:e.getVolume())/100:1}#o(e){if(Object.prototype.hasOwnProperty.call(this,e)){const t=this[e];delete this[e],this[e]=t}}}function mb(s){let e="";for(const t in s){const i=s[t];i===""?e+=` ${no(t)}`:e+=` ${no(t)}="${no(`${i}`)}"`}return e}function no(s){return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/`/g,"&#x60;")}function Nu(s){return String(new URLSearchParams(pb(s)))}function pb(s){let e={};for(let t in s){let i=s[t];i===!0||i===""?e[t]=1:i===!1?e[t]=0:i!=null&&(e[t]=i)}return e}function Eb(s){let e={};for(let t of s)e[t.name]=t.value;return e}const ao={};async function vb(s,e,t){return ao[s]?ao[s]:self[e]?(await yb(0),self[e]):ao[s]=new Promise(function(i,r){const n=document.createElement("script");n.src=s;const a=()=>i(self[e]);self[t]=a,n.onload=()=>!t,n.onerror=r,document.head.append(n)})}const yb=s=>new Promise(e=>setTimeout(e,s));function Tb(s){return(...e)=>new Promise(t=>{s(...e,(...i)=>{i.length>1?t(i):t(i[0])})})}function Sb(s){return Tb((e,t)=>{let i;s.addEventListener(e,i=()=>{s.removeEventListener(e,i),t()})})("playing")}class oo extends Promise{constructor(e=()=>{}){let t,i;super((r,n)=>{e(r,n),t=r,i=n}),this.resolve=t,this.reject=i}}function lo(s,e){return Array.isArray(s)?co(s):s==null||e==null||s===0&&e===0?co([[0,0]]):co([[s,e]])}function co(s){return Object.defineProperties(s,{start:{value:e=>s[e][0]},end:{value:e=>s[e][1]}}),s}globalThis.customElements&&!globalThis.customElements.get("youtube-video")&&globalThis.customElements.define("youtube-video",gb);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.